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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);
 

void solve() {
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 0; i < N; i++){
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
}
 
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
using namespace std;
using ll = long long;

int main(void) {
    int n;
    cin >> n;
    bool ok = true;

    rep (i, n) {
        int a;cin>>a;
        if (a % 2 == 0 ) {
            if (a %3 != 0 && a %5 != 0) ok = false;
        }
    }
    cout << (ok ? "APPROVED" : "DENIED") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define rep(i,a) for(int i=0;i<(a);++i)

const int MAX_N = 44;

int n;
int fib[MAX_N+1];

int main()
{
    scanf( "%d", &n );

    fib[0] = 1, fib[1] = 1;

    rep( i, n-1 )
        fib[i+2] = fib[i] + fib[i+1];

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

    return 0;
}

Measured memory_bytes: 2744
#include<iostream>
#include<limits.h>
using namespace std;
int inf=INT_MAX;
int dat[400004];
int n,q;
void init(int n_){
  n=1;
  while(n < n_) n*=2;
  for(int i=0;i<2*n-1;i++) dat[i]=inf;
}
void update(int k,int a){
  k+=n-1;
  dat[k]=a;
  while(k>0) {
    k=(k-1)/2;
    dat[k]=min(dat[k*2+1],dat[k*2+2]);
  }
}
int query(int a,int b, int k,int l,int r){
  //cout << a<< b<< k<<l<<r <<endl;
  if(r<=a||b<=l) return inf;
  if(a<=l && r <= b) return dat[k];
  else{
    int vl=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    //cout << vl << ":" <<vr << endl;
    return min(vl,vr);
  }
}

int find(int x,int y){
  return query(x,y,0,0,n);
}
int main(){
  int n_;
  cin >> n_ >> q;
  init(n_);
  //cout << n <<endl;
  int i,j;
  for(i=0;i<q;i++){
    int com,x,y;
    cin >> com >> x >> y;
    if(com==0) update(x,y);
    else if(x==y) cout << dat[x+n-1] << endl;
    else cout << find(x,y+1) << endl;
    /*
    for(j=0;j<n*2-1;j++) cout << dat[j] << ":";
    cout << endl;
    */
  }
  return 0;
}

Measured memory_bytes: 2184
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
const int N = 3005;
int n, m, g[N][N], c[N][N];
 
int read() {
	int w = 0; char ch = getchar();
	while(ch > '9' || ch < '0') ch = getchar();
	while(ch <= '9' && ch >= '0') {
		w = w * 10 + ch - 48;
		ch =getchar();
	}
	return w;
}
int fpow(int a, int m, int MOD) {
	int ans = 1;
	for(; m; m >>= 1) {
		if(m & 1) ans = ans * 1ll * a % MOD;
		a = a * 1ll * a % MOD;
	}
	return ans;
}
 
int main() {
    n = read(); m = read();
    for(int i = 0; i <= n; i++) {
        g[i][0] = c[i][0] = 1;
    	for(int j = 1; j <= i; j++) {
            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % m;
            g[i][j] = (g[i - 1][j - 1] + (j + 1) * 1ll * g[i - 1][j] % m) % m;
    	}
    }
    ll ans = 0;
    for(int i = 0; i <= n; i++) {
    	int powp = fpow(2, fpow(2, n - i, m - 1), m);
    	int d = fpow(2, n - i, m), q = 1, f = 0;
    	for(int j = 0; j <= i; j++) f = (f + g[i][j] * 1ll * q % m) % m, q = q * 1ll * d % m;
        if(i & 1) {
        	ans = (ans + (m - c[n][i]) * 1ll * f % m * powp % m) % m;
        } else ans = (ans + c[n][i] * 1ll * f % m * powp % m) % m;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 58880
#include <stdio.h>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <functional>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, m, h, w, sum = 0, ans = 0;
  scanf("%lld%lld", &n, &m);
  ll a[m], d[m];
  for(i = 0; i < m; ++i) scanf("%lld", &a[i]);
  sort(a, a + m);
  for(i = 1; i < m; ++i) d[i - 1] = a[i] - a[i - 1];
  sort(d, d + m - 1);
  for(i = 0; i < m - n; ++i) ans += d[i];
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>
 
template <class T>
std::vector<T> ToFixedArray(std::istream& is, int n) {
	std::vector<T> ret(n);
	auto* dst = ret.data();
	while(n-- > 0)
		is >> *dst++;
	return ret;
}
 
#define _For(idx, from, to, inc, cmp) \
	for(auto idx=(from) ; idx cmp (to) ; inc idx)
#define ForLE(idx, from, to) \
	_For(idx, from, to, ++, <=)
#define ForGE(idx, from, to) \
	_For(idx, from, to, --, >=)
#define ForLT(idx, from, to) \
	_For(idx, from, to, ++, <)
#define ForGT(idx, from, to) \
	_For(idx, from, to, --, >)
#define For(idx, from, to) \
	_For(idx, from, to, ++, <)
 
void DisableIOSync() {
	std::cin.tie(0);
	std::cout.tie(0);
	std::ios::sync_with_stdio(false);
}
using Dist_t = uint32_t;
constexpr auto DistMax = std::numeric_limits<Dist_t>::max()/2;
using DistV = std::vector<Dist_t>;
int main() {
	DisableIOSync();

	using std::cin;
	using namespace std;
	int NCity, NLink, NDest;
	cin >> NCity >> NLink >> NDest;

	auto dest = ToFixedArray<int>(std::cin, NDest);
	for(auto& d : dest)
		--d;

	using DistV = std::vector<Dist_t>;
	DistV dist(NCity * NCity, DistMax);
	const auto fdist = [&dist, NCity](int from, int to) -> decltype(auto) {
		if(from > to)
			std::swap(from, to);
		return dist[from + to*NCity];
	};
	For(i, 0, NCity) {
		fdist(i,i) = 0;
	}
	For(i, 0, NLink) {
		int id0, id1, cost;
		cin >> id0 >> id1 >> cost;
		--id0;
		--id1;
		fdist(id0, id1) = cost;
		fdist(id1, id0) = cost;
	}
	For(inter, 0, NCity) {
		For(from, 0, NCity) {
			if(inter == from)
				continue;
			For(to, from+1, NCity) {
				if(inter == to)
					continue;
				fdist(from, to) =
					std::min(
						fdist(from, to),
						fdist(from, inter) + fdist(inter, to)
					);
			}
		}
	}
	Dist_t res = DistMax;
	std::sort(dest.begin(), dest.end());
	do {
		Dist_t sum = 0;
		For(i, 1, NDest) {
			sum += fdist(dest[i-1], dest[i]);
			if(sum >= res) {
				sum = DistMax;
				break;
			}
		}
		res = std::min(res, sum);
	} while(std::next_permutation(dest.begin(), dest.end()));
	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 384
N,M = map(int,input().split())
L = list(map(int,input().split()))
L = sorted(L)
A = []
for a,b in zip(L, L[1:]) :
    A.append(b-a)
A = sorted(A)

if M-N >= 0 :
    ans = sum(A[:M-N])
else :
    ans = 0
print(ans)


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

int main(){
  int N;
  cin>>N;
  set<string> s;
  for(int i=0;i<N;i++){
    string st;
    cin>>st;
    s.insert(st);
  }
  cout<<s.size()<<endl;
  
}


Measured memory_bytes: 19084
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int arr[100005];
int dp[100005];
int ans  = 1e9 ;
int n;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    for(int i=0;i<n+10;i++)
        dp[i]=1e9;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    dp[0]=0;
    for(int i = 0;  i<n-1;i++)
    {
        dp[i+1]=min(dp[i+1],dp[i]+abs(arr[i]-arr[i+1]));
        dp[i+2]=min(dp[i+2],dp[i]+abs(arr[i]-arr[i+2]));
    }
    cout<<dp[n-1]<<endl;
 
 
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> size; //属しているグループの大きさ

    UnionFind(int N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) {
            par[i] = i;
            size[i]=1;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合

        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        size[ry]+=size[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int getSize(int x){
        return size[root(x)];
    }
};

int main(){
    long long n,m;
    cin>>n>>m;
    UnionFind uf(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        uf.unite(a,b);
    }
    int  ans=0;
    rep(i,n){
        ans=max(ans,uf.getSize(i));
    }
    cout<<ans<<endl;
    return 0;

}
/*


*/


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

typedef long long ll;
ll MOD=1e9+7;
#define nl '\n'
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll po(ll n,ll a)
{
    ll r=1;
    for(int i=1; i<=a; i++)
    {
        r*=n;
        r%=MOD;
    }
    return r%MOD;
}

int main()
{
    fio;
    ll n,a;
    cin>>n;

    a=po(10LL,n)%MOD;
    a-=(2*(po(9LL,n)-MOD));
    a%=MOD;
    a+=(po(8LL,n));
    a%=MOD;

    cout<<a<<nl;
    return 0;
}


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

#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define TC int tc; cin >> tc; while(tc--)

using namespace std;

const int INF = 1e9 + 7;
const int MxN = 3010;

ll r, c, k;
ll grid[MxN][MxN], dp[MxN][MxN][4];

int main(void)
{
	FAST
	cin >> r >> c >> k;
	memset(grid, 0, sizeof(grid));
	memset(dp, 0, sizeof(dp));

	while(k--){
		int i, j; cin >> i >> j;
		cin >> grid[i][j];
	}

	for(int i = 1; i <= r; i++){
		for(int j = 1; j <= c; j++){
			ll cur = 0;
			for(k = 0; k < 4; k++) cur = max(cur, dp[i-1][j][k]);

			dp[i][j][0] = max(dp[i][j-1][0], cur);

			dp[i][j][1] = max({dp[i][j-1][1], dp[i][j-1][0] + grid[i][j], grid[i][j] + cur});

			dp[i][j][2] = max(dp[i][j-1][2], dp[i][j-1][1] + grid[i][j]);

			dp[i][j][3] = max(dp[i][j-1][3], dp[i][j-1][2] + grid[i][j]);
		}
	}


	ll mx = 0;
	for(k = 0; k < 4; k++) mx = max(dp[r][c][k], mx);

	cout << mx << '\n';
	return 0;
}


Measured memory_bytes: 357532
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  int po=-1;
  int res=0;
  for(int i=0;i<(int)s.size();i++){
    if(s[i]=='O' && po==-1) po=i;
    else if(s[i]=='O'){}
    else if(po!=-1){
      int tes=0;
      for(int j=1;j<=(i-po);j++){
	if(po-j<0) break;
	if(i+j-1>=(int)s.size()) break;
	if(s[po-j]=='J' && s[i+j-1]=='I')
	  tes++;
	else break;
      }
      if(i-po==tes)
	res = max(res,tes);
      //      printf("%d %d %d %d\n",po,i,res,tes);
      po=-1;
    }
  }
  cout << res << "\n";
}

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

using namespace std;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int A,B,C,D,E,F;
cin>>A>>B>>C>>D>>E>>F;
vector<int> x;
vector<int> y;
for(int i=0;i<F;i++){
for(int j=0;j<F;j++){
    int tmp_x=100*A*i+100*B*j;
    int tmp_y=C*i+D*j;
    if(tmp_x<=F){
        x.push_back(tmp_x);
    }
    if(tmp_y<=F){
        y.push_back(tmp_y);
    }
}
}

int max_j=-1;
int max_i=-1;
float max_val=-1;
for(int i=0;i<x.size();i++){
for(int j=0;j<y.size();j++){
    int limit=(x[i]/100)*E;
    if(y[j]<=limit){
        float tmp_w=x[i]+y[j];
        float concentration=100*(y[j]/tmp_w);
        if(tmp_w<=F&&max_val<concentration){
            max_val=concentration;
            max_i=i;
            max_j=j;
        }
    }
}
}

cout<<x[max_i]+y[max_j]<<" "<<y[max_j]<<endl;

//system("pause");
return 0;
}

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

int  main(){
	int W,N,i,j,k,max_coin=0,weg=0,count=0;
	int wg,coin;
	int dp[1002][1002]={};
	
	while(1){
		scanf("%d",&W);
		if(W==0)break;
		scanf("%d",&N);
		
		for(i=0;i<N;i++){
			scanf("%d,%d",&coin,&wg);
			for(j=0;j<=W;j++){
				if(wg<=j)
					dp[i+1][j]=fmax(dp[i][j],dp[i][j-wg]+coin);
				else 
					dp[i+1][j]=dp[i][j];
			}
		}

	
	count++;
	printf("Case %d:\n",count);
	
		for(j=0;j<=W;j++){
			if(dp[N][j]==dp[N][W]){
			printf("%d\n%d\n",dp[N][j],j);
			break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4532
a,b,c,k=[int(x) for x in input().split()]
ans=0
if a<=k:
  ans+=a
  k-=a
elif k>0:
  ans+=k
  k=0
if b<=k:
  k-=b
elif k>0:
  k=0
if k>0:
  ans-=k
print(ans)

Measured memory_bytes: 9188
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		br.close();
		String[] strs = str.split(" ");
		//aを入力する
		int a = Integer.parseInt(strs[0]);
		//bを入力する
		int b = Integer.parseInt(strs[1]);
		//面積を計算する
		int s = area(a, b);
		//周の長さを計算する
		int l = circumference(a, b);
		//面積と周の長さを出力する
		System.out.println(s + " " + l);	
	}
	/**
	 * 面積を計算する
	 * @param a
	 * @param b
	 * @return 長方形の面積
	 */
	public static int area(int a, int b) {
		return a * b;
	}

	/**
	 * 周の長さを計算する
	 * @param a
	 * @param b
	 * @return 長方形の周の長さ
	 */
	public static int circumference(int a, int b) {
		return (a*2)+(b*2);
	}
}

Measured memory_bytes: 16900
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll cnt[M];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,sm = 0,q,t,b,c,i;
	cin >> n;
	for(i=1;i<=n;++i)
	{
		cin >> t;
		cnt[t]++;
		sm += t;
	}
	cin >> q;
	while(q--)
	{
		cin >> b >> c;
		sm -= cnt[b]*b;
		sm += cnt[b]*c;
		cnt[c] += cnt[b];
		cnt[b] = 0;
		cout << sm << "\n";
	}
}

Measured memory_bytes: 4408
from sys import stdin, stdout, stderr

a = [0] * 50
ans = []

while 1:
    n, p = map(int, stdin.readline().split())
 
    if n + p == 0:
        break
 
    wan = p
    i = 0
 
    while a[i] < p:
        if wan > 0:
            a[i] += 1
            wan -= 1
        else:
            wan += a[i]
            a[i] = 0
 
        i = (i + 1) % n
 
    ans.append(i)
    a[i] = 0

print(*ans, sep='\n')

Measured memory_bytes: 7680
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(H, W, A):
    move = []
    for h in range(H):
        for w in range(W):
            if A[h][w] % 2 == 1:
                if h < H - 1 and A[h + 1][w] % 2 == 1:
                    A[h][w] -= 1
                    A[h + 1][w] += 1
                    move.append([h, w, h + 1, w])
                elif w < W - 1 and A[h][w + 1] % 2 == 1:
                    A[h][w] -= 1
                    A[h][w + 1] += 1
                    move.append([h, w, h, w + 1])
                elif h < H - 1:
                    A[h][w] -= 1
                    A[h + 1][w] += 1
                    move.append([h, w, h + 1, w])
                elif w < W - 1:
                    A[h][w] -= 1
                    A[h][w + 1] += 1
                    move.append([h, w, h, w + 1])
    print(len(move))
    for m in move:
        print(' '.join([str(i + 1) for i in m]))


if __name__ == '__main__':
    H, W = map(int, input().split())
    A = [[int(i) for i in input().split()] for _ in range(H)]
    solve(H, W, A)

    # # test
    # from random import randint
    # from func import random_str
    # solve()


Measured memory_bytes: 28104
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

n = inp[0]
s = inps
h = {}
  ans = 0
s.each do |c|
  if(h[c] == nil)
    h[c] = true
    ans += 1
  end
end
puts (ans<4)? "Three" : "Four"

Measured memory_bytes: 1788
import collections
n = int(input())
a = [int(i) for i in input().split()]

a = collections.Counter(a)
a_keys = list(a.keys())
a_values = list(a.values())

ans = 0
for i in range(len(a_keys)):
    if a_values[i] - a_keys[i] < 0:
        ans += a_values[i]
    else:
        ans += a_values[i] - a_keys[i]

print(ans)

Measured memory_bytes: 18676
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
using namespace std;

double sol(double a) {
  double res = 0.0;
  int q = a;
  while (q) {
    res += (q * (1 / a));
    --q;
  }
  return res;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<double> p(n);
  vector<double> s(n + 1);
  rep (i, n) {
    int x;
    cin >> x;
    p[i] = sol(x);
  }

  s[0] = 0;
  for (int i = 0; i < n; i++) {
    s[i + 1] = s[i] + p[i];
  }

  double ans = 1;
  for (int i = 0; i + k <= n; i++) {
    ans = max(ans, s[i + k] - s[i]);
  }

  cout << fixed << setprecision(15);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define push_back pb

const int mod = 1000000007;
const int inf = 1e9;

int main(){
    int x;
    cin >> x;
    int a = x/500;
    int b = (x - a*500)/5;
    cout << 1000*a+5*b;
}

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

id = [0,N]

for _ in range(M):
    L, R = map(int,input().split())
    if id[0]<L:
        id[0] = L
    if id[1]>R:
        id[1] = R
    if id[0]>id[1]:
        print(0)
        exit()

print(id[1]-id[0]+1)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int n,m,x,a[101],i,z=0,y=0;
	scanf("%d%d%d",&n,&m,&x);
	for(i=0; i<m; i++){
		scanf("%d",&a[i]);
		if(x>a[i]){
			z=z+1;
		}else if(x<a[i]){
			y=y+1;
		}
	}
	if(z<=y){
		printf("%d\n",z);
	}else if(z>y){
		printf("%d\n",y);
	}
	return 0;
}

Measured memory_bytes: 128
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
max_two = [0]*(N+1)
one_minus = [0]*(N+1)
A_cnt = Counter(A)
A_cnt = A_cnt.most_common()
for a in A_cnt:
    max_two[a[0]] = (a[1]*(a[1]-1))//2
    one_minus[a[0]] = ((a[1]-1)*(a[1]-2))//2
max_sum = sum(max_two)

for i in range(N):
    print(max_sum-max_two[A[i]]+one_minus[A[i]])

Measured memory_bytes: 100044
N, K = gets.split.map &:to_i
V = gets.split.map &:to_i

p (0..K).map{|l|
  f = -> k, v {
    plus_total = 0
    minus = []
    max = 0
    (1..k).map{|i|
      break if v.empty?
      val = v.shift
      if val < 0
        minus << val
      else
        plus_total += val
      end
      max = [max, plus_total + (minus.max([0, minus.size - (k - i)].max).inject(:+) || 0)].max
    }
    max
  }
  v = V.dup
  r = K - l
  vl = v.shift(l)
  vr = v.reverse
  # p [[l, vl], [r, vr]]
  # p [f[l, vl.dup] + f[r, vr.dup]]
  f[l, vl.dup] + f[r, vr.dup]
}.max

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

int main() {
  int n, t, i, ans = 1001;
  cin >> n >> t;
  
  vector<vector<int>> c(n, vector<int>(2));
  for(i = 0; i < n; i++){
    cin >> c.at(i).at(0) >> c.at(i).at(1);
    if(c.at(i).at(1) <= t) ans = min(ans, c.at(i).at(0));
  }
  
  if(ans == 1001) cout << "TLE" << endl;
  else cout << ans << endl;
}

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

int main(){


    int n, m; cin >> n >> m;
    vector<vector<int> > g(n);
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int L1 = 0;
    int L2 = g[0][0];
    list<int> ans;
    ans.push_back(L1);
    ans.push_back(L2);
    vector<bool> used(n, false);
    used[L1] = used[L2] = true;

    while(1){

        // L1 と L2 のうち
        bool flag = true;
        for(auto x : g[L1]){
            if(!used[x]){
                flag = false;
                used[x] = true;
                ans.push_front(x);
                L1 = x;
                break;
            }
        }

        if(!flag) continue;

        for(auto x : g[L2]){
            if(!used[x]){
                flag = false;
                used[x] = true;
                ans.push_back(x);
                L2 = x;
                break;
            }
        }

        if(flag){
            break;
        }
    }

    cout << ans.size() << endl;
    for(auto x : ans) cout << x + 1 << " ";
    cout << endl;


    return 0;
}

Measured memory_bytes: 9472
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>


struct Restaurant {
	std::string S;
	int P;
	int num;
};
int main()
{
	int N;
	std::cin >>N;
	std::vector<Restaurant> Rs(N);
	int count = 0;
	for (auto& i : Rs) {

		std::cin >> i.S >> i.P;
		i.num = ++count;
	}
	std::sort(Rs.begin(), Rs.end(),
		[](Restaurant R1, Restaurant R2)->bool {return R1.S < R2.S || R1.S == R2.S && R1.P > R2.P; });
			
	for (auto i : Rs) std::cout << i.num<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
using namespace std;

typedef unsigned long long ull;
const int N_MAX = 1e6;
const ull mod = 1000000000 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    string S, T;
    int q;
    cin >> S >> T >> q;
    int n = S.size();
    int m = T.size();
    int S_sum[n+1];
    int T_sum[m+1];
    int tmp = 0;
    S_sum[0] = 0;
    T_sum[0] = 0;
    REP(i, n){
        if(S[i] == 'A'){
            tmp += 1;
        }else{
            tmp += 2;
        }
        S_sum[i+1] = tmp;
    }
    tmp = 0;
    REP(i, m){
        if(T[i] == 'A'){
            tmp += 1;
        }else{
            tmp += 2;
        }
        T_sum[i+1] = tmp;
    }
    int a, b, c, d;
    REP(i, q){
        cin >> a >> b >> c >> d;
        if ((S_sum[b]-S_sum[a-1])%3 == (T_sum[d]-T_sum[c-1])%3){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int a, b;
	cin >> a >> b;
	ll ans = (ll)a * b;
	ans /= __gcd(a, b);
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a[n];
    long long money = 1000;
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }
    int maxKabu, minKabu;
    maxKabu = a[0];
    minKabu = a[0];
    for (int i=1; i<n; i++) {
        if (a[i] < maxKabu) {
            money += money/minKabu * (maxKabu - minKabu);
            maxKabu = a[i];
            minKabu = a[i];
        } else {
            maxKabu = a[i];
            minKabu = min(minKabu, a[i]);
        }
    }
    money += money/minKabu * (maxKabu - minKabu);
    cout << money << endl;
}

Measured memory_bytes: 3512
n, h =  gets.chomp.split.map(&:to_i)
s = Array.new(n){ gets.chomp.split.map(&:to_i) }
x = s.sort_by{|a, b| a}.reverse.first

c = 0

s.sort_by{|a, b| b}.reverse.each do |y|
  if y[1] > x[0]
    h -= y[1]
    c += 1
  end
  break if h <= 0
end

if h > 0
  d = (h + x[0] - 1) / x[0]
  h -= x[0] * d
  c += d
end

puts c

Measured memory_bytes: 14312
def resolve():
    # n switches, m bulbs
    n, m = map(int, input().split())
    s = list(list(map(int, input().split()))[1:] for _ in range(m))
    p = list(map(int, input().split()))
    ok = 0
    for i in range(1 << n):
        lights = [False] * m
        for j in range(m):
            on = 0
            for sji in s[j]:
                # if (i >> (sji - 1)) & 1:
                if i & (1 << (sji - 1)):
                    on += 1
            if on % 2 == p[j]:
                lights[j] = True
        if all(lights):
            ok += 1
    print(ok)


if __name__ == "__main__":
    resolve()


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

int n;
int dp[100005];
int a[100005];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	dp[0] = 2e9;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=2;i<=n;i++){
		dp[i] = min(dp[i-1] + abs(a[i]-a[i-1]),dp[i-2] + abs(a[i]-a[i-2]));
	}
	cout<<dp[n];
	
	return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define IREP(i, v) for(auto i = (v).begin(); i != (v).end(); ++i)
#define IRREP(i, v) for(auto i = (v).rbegin(); i != (v).rend(); ++i)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


int main(){
    int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
    --A; --B; --C; --D;
    string S; cin >> S;
    FOR(i, A+1, max(C, D)){
        if(S[i] == S[i+1] && S[i] == '#'){
            cout << "No" << endl;
            return 0;
        }
    }
    if(C > D){
        FORS(i, B, D){
            if(S[i] == S[i+1] && S[i] == S[i-1] && S[i] == '.'){
                cout << "Yes" << endl; return 0;
            }
        }
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


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

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

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)			// repeat reverse

#endif


int main(void)
{
	ll n; cin >> n;
	vector<ll> h(n);
	rep(i, 0, n)
		cin >> h[i];

	ll max_value = 0;
	rep(i, 0, n)
	{
		if (max_value < h[i])
			max_value = h[i];
		if (1 < max_value - h[i])
		{
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";
	return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<ctime>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
int sides[100010];
int n;
using namespace std;
int main()
{
	scanf("%d",&n);
	int j=0;
	for(int i=0;i<n;i++)
	{
		int t;
		scanf("%d",&t);
		sides[i]=t;
	}
	sort(sides,sides+n);
	int one=-1;
	for(int i=n-1;i>=1;i--)
	{
		if(sides[i]==sides[i-1])
		{
			if(one==-1)
			{
				one=sides[i];
				i--;
			}
			else
			{
				printf("%lld",(long long)one*sides[i]);
				return 0;
			}
		}
	}
	printf("0");
	return 0;
}


Measured memory_bytes: 640
import sys
import string
input = sys.stdin.readline

X = int(input())
right = X % 100
count_5 = right // 5
right = right % 5
count_4 = right // 4
right = right % 4
count_3 = right // 3
right = right % 3
count_2 = right // 2
right = right % 2
count_1 = right // 1
right = right % 1

count = count_1 + count_2 + count_3 + count_4 + count_5

left = (X - right) // 100
if left >= count:
    print(1)
else:
    print(0)


Measured memory_bytes: 3832
def func(a):
    i = 0
    while a > 0:
        i += a % 10
        a //= 10
    return i


n = int(input())

m = float('inf')
for a in range(1, n):
    b = n - a
    v = func(a) + func(b)
    if v < m:
        m = v

print(m)

Measured memory_bytes: 2940
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>

using namespace std;
#define LOCAL  1
#define UPLOAD 2
#define ll long long
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
  map<string, int> youbi = {{"SUN", 0},{"MON",1},{"TUE",2},{"WED",3},{"THU",4},{"FRI",5},{"SAT",6} };
  string S = input<string>();
  output(7 - youbi[S]);

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
struct UnionFind{
  vector<int>d;
  UnionFind(int n=0):d(n,-1){}
  int find(int x){
    if(d[x]<0)return x;
    return d[x]=find(d[x]);
  }
  bool unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y)return false;
    if(d[x]>d[y])swap(x,y);
    d[x]+=d[y];
    d[y]=x;
    return false;
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  int size(int x){return -d[find(x)];}
};
int main(){ 
  int a,b,c,d;cin>>a>>b>>c>>d;
  int e=a/d,f=c/b;
  if(a%d!=0)e++;
  if(c%b!=0)f++;
  if(e>=f)cout<<"Yes";
  else cout<<"No";
}


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

int main() {
	ll m=100,x,cnty=0;
	cin>>x;
	while(m<x){
		m*=1.01;
		cnty++;
	}
	cout<<cnty<<endl;
}


Measured memory_bytes: 3632
N, K = map(int, input().split())

N_set = set([])
N_set.add(float('inf'))
N_new = N

while (N_new > 0 and N_new < min(N_set)):
    N_set.add(N_new)
    if N_new >= K:
        N_new = N_new % K
    else:
        N_new = K - N_new
 
N_set.add(N_new)

ans = min(N, min(N_set))

print(ans)

Measured memory_bytes: 9184
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func parseInt(s string) int {
	i, _ := strconv.Atoi(s)
	return i
}

func createNums(ary string) (nums []int) {
	for _, v := range strings.Split(ary, " ") {
		nums = append(nums, parseInt(v))
	}
	return
}

func scanNums(length int) (numbers []int) {
	var number int
	for i := 0; i < length; i++ {
		fmt.Scan(&number)
		numbers = append(numbers, number)
	}
	return
}

func main() {
	var n int
	fmt.Scan(&n)
	numsA := scanNums(n + 1)
	numsB := scanNums(n)

	count := 0
	for i, v := range numsB {
		if numsA[i] >= v {
			count += v
		} else {

			if numsA[i]+numsA[i+1] >= v {
				count += v
				numsA[i+1] = numsA[i] + numsA[i+1] - v
			} else {
				count += numsA[i] + numsA[i+1]
				numsA[i+1] = 0
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 5632
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        System.out.println(A <= 8 && B <= 8 ? "Yay!" : ":(");
    }
}
 

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

int main(void){
  int m,f,r;
  while(true){
      cin >> m >> f >> r;
      if(m == -1 && f == -1 && r == -1){
          break;
      }
      if(m == -1 || f ==-1){
          cout << "F" ;
      }
      else if(m+f >= 80){
          cout << "A" ;
      }
      else if(65 <= m+f && m+f < 80){
          cout << "B" ;
      }
      else if(50 <= m+f && m+f < 65){
          cout << "C" ;
      }
      else if(30 <= m+f && m+f < 50){
          if(r >= 50){
              cout << "C" ;
          }
          else{
              cout << "D" ;
          }
      }
      else{
          cout << "F" ;
      }
      cout << endl;
  }
}


Measured memory_bytes: 3096
#include<stdio.h>
using namespace std;
int s[100009],t[100009];
int main(){
    int n,q,x=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&s[i]);
    }
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%d",&t[i]);
    }
    for(int i=0;i<q;i++){
        for(int j=0;j<n;j++){
            if(t[i]==s[j]){
                x++;
                break;
            }
        }
    }
    printf("%d\n",x);
    return 0;
}

Measured memory_bytes: 2712
#include <bits/stdc++.h>
using namespace std;
vector<string> split_naive(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

int main() {
  string str;
  cin >> str;
  vector<string> elems = split_naive(str, '/');
  istringstream ss = istringstream(elems[1]);
  int num;
  ss >> num;
  if (num < 5) puts("Heisei");
  else puts("TBD");
}
  


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

typedef long long int   ll;
typedef pair<ll, ll>    pll;
typedef pair<int, int>  pii;

#define all(x)          x.begin(), x.end()
#define kill(x)         return cout << x << endl, 0
#define X               first
#define Y               second
#define sep             ' '
#define endl            '\n'

ll pw(ll a, ll b, ll mod) {
    if (!b)    return 1;
    if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod;
    return pw(a * a % mod, b / 2, mod) % mod;
}

const ll N    = 1e5 + 10;
const ll MOD  = 1e9 + 7;
const ll INF  = 1e18;

int n, m, A[N], B[N], mark[N];
vector<int> val[2], adj[N];

int DFS(int u) {
    mark[u] = 1;
    for (int v : adj[u]) if (!mark[v]) {
        DFS(v);
    }
    return (adj[u].size() >= 1);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        A[n] ^= A[i];
        val[0].push_back(A[i]);
    }
    val[0].push_back(A[n]);
    for (int j = 0; j < n; j++) {
        cin >> B[j];
        B[n] ^= B[j];
        val[1].push_back(B[j]);
    }
    val[1].push_back(B[n]);
    sort(all(val[0]));
    sort(all(val[1]));
    for (int i = 0; i <= n; i++) {
        if (val[0][i] != val[1][i])
            kill(-1);
    }
    val[0].erase(unique(all(val[0])), val[0].end());
    for (int i = 0; i <= n; i++) {
        A[i] = lower_bound(all(val[0]), A[i]) - val[0].begin();
        B[i] = lower_bound(all(val[0]), B[i]) - val[0].begin();
    }
    for (int i = 0; i < n; i++) {
        if (A[i] == B[i])
            continue;
        adj[A[i]].push_back(B[i]);
        adj[B[i]].push_back(A[i]);
        m++;
    }
    adj[A[n]].push_back(A[n]);
    adj[B[n]].push_back(B[n]);
    for (int i = 0; i <= n; i++) if (!mark[i]) {
        m += DFS(i);
    }
    cout << m - 1 << endl;
    return 0;
}

Measured memory_bytes: 15332
import java.util.*;

public class Main {
  public static void main(String args[]) {
	Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    String ans = "";
    if (a < b) {
      for(int i = 0; i < b; i++) {
        ans += String.valueOf(a);
      }
    } else {
      for(int i = 0; i < a; i++) {
        ans += String.valueOf(b);
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21204
import Control.Monad

main :: IO ()
main = do
  [h, w] <- map read . words <$> getLine
  ass <- replicateM h getLine
  let line = replicate (w + 2) '#'
  mapM_ putStrLn $ [line] ++ (map (\r -> "#" ++ r ++ "#") ass) ++ [line]

Measured memory_bytes: 1404
using System;

namespace AtCoder103B
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;

            string X = Console.ReadLine();
            string Y = Console.ReadLine();

            Y = Y + Y;

            if(Y.IndexOf(X) < 0)
                Console.WriteLine("No");
            else
                Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 13396
N = int(input())
s = 'abcdefghijklmn'


def f(d, now, kind):
    if d == N:
        print(now)
        return
    for i in range(kind):
        f(d + 1, now + s[i], kind)
    f(d + 1, now + s[kind], kind + 1)

f(0, '', 0)


Measured memory_bytes: 4340
S = gets.chomp
YYMM = S.match(/^\d{2}(0[1-9]|1[012])$/)
MMYY = S.match(/^(0[1-9]|1[012])\d{2}$/)
puts case
  when YYMM && MMYY; "AMBIGUOUS"
  when YYMM; "YYMM"
  when MMYY; "MMYY"
  else "NA"
end

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

using namespace std;

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

  int h, w, n;
  cin >> h >> w >> n;
  cout << (n + max(h, w) - 1) / max(h, w);

  return 0;
}

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

public class Main {

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

		Integer a = sc.nextInt();
		Integer b = sc.nextInt();
		
		Integer x = a *2 + b * 2;
		Integer y = a*b;

		System.out.println(y + " "+ x);

	}

}



Measured memory_bytes: 25968
def main():
  import sys
  input = sys.stdin.readline
  n,m=map(int,input().split())
  ab=[list(map(int,input().split())) for _ in [0]*n]
  ab=sorted(ab,key=lambda x:x[0])
  ans=0
  for i in range(n):
    l=min(ab[i][1],m)
    m-=l
    ans+=l*ab[i][0]
    if l==0:
      print(ans)
      exit()
  print(ans)
if __name__=='__main__':
  main()

Measured memory_bytes: 29644
import Text.Printf
main = do
  str<-getLine
  let [a,b,c]=words str
  if(b=="?")
  then return ()
  else do
    putStrLn $ show $ poyo (read a) b (read c)
    main
poyo::Int -> String -> Int -> Int
poyo x "+" y = x+y
poyo x "-" y = x-y
poyo x "*" y=x*y
poyo x "/" y=div x y

Measured memory_bytes: 3988
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n; cin >> n;
    ll ans = 10000000000000;
    for(ll i = 1; i*i<=n; i++) {
        if(n%i==0) {
            ans = min(ans,i-1+n/i-1);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int N, W;
int dp[10001];
vector<int> value(101), weight(101);

int main(void)
{
	cin >> N >> W;

	for (int n = 0; n < N; n++)
	{
		cin >> value[n] >> weight[n];
	}
	dp[0] = 0;

	for (int w = 0; w <= W; w++)
	{
		for (int n = 0; n < N; n++)
		{
			if (w >= weight[n])
			{
				dp[w] = max(dp[w], dp[w - weight[n]] + value[n]);
			}
		}
	}

	cout << dp[W] << endl;
}


Measured memory_bytes: 3132
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <climits>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#define int long long
using namespace std;

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int count = 0;
    for(int i = 1; i <= n; i++) {
        if(i & 1 and a[i] & 1) {
            count++;
        }
        /*else if(i & 1 or a[i] & 1) {
            count++;
        }*/
    }
    cout << count << "\n";

    return 0;
}

Measured memory_bytes: 3652
N, K = map(int, input().split())
P = 10 ** 9 + 7
X = [0] * (K + 1)
ans = 0
for i in range(1, K + 1):
    s = i
    X[i] += i
    for j in range(i * 2, K+1, i):
        X[j] -= X[i]
    ans += X[i] * pow(K//i, N, P)
print(ans % P)

Measured memory_bytes: 68832
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

inline int input() { int x; scanf("%d", &x); return x; }

const int maxn = 100005;
int a[maxn];
int f[maxn];

int main() {
	int n = input();

	for(int i = 1; i <= n; i ++)
		a[i] = input();

	int ans = 0;
	for(int i = n - 1; i; i --)
		if(a[i] >= a[i + 1])
			f[i] = f[i + 1] + 1;

	for(int i = 1; i <= n; i ++)
		ans = std::max(ans, f[i]);

	printf("%d\n", ans);
}


Measured memory_bytes: 896
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve(args);
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve(string[] args)
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int n = int.Parse(Console.ReadLine());
			int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

			int max = a[0];
			long ans = 0;
			foreach (var i in a) {
				if (max > i) {
					ans += max - i;
				} else {
					max = i;
				}
			}
			Console.WriteLine(ans);

		}
	}
}


Measured memory_bytes: 46976
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int n;
    int w;
    cin >> n >> w;
    vector<int> w_s(n);
    vector<int> v_s(n);
    rep(i, n)
    {
        cin >> w_s[i] >> v_s[i];
    }

    constexpr int vinf = 100'001;
    // [0,i)を使い価値j以上にする重さの最小値
    vector<int> dpo(vinf, w + 1), dpn(vinf);

    dpo[0] = 0; // 初期値

    rep(i, n)
    {
        dpn = dpo; // コピー

        // 処理
        rep(j, vinf - v_s[i])
        {
            chmin(dpn[j + v_s[i]], dpo[j] + w_s[i]);
        }

        swap(dpo, dpn); // dpoに保存
    }

    int ans = 0;
    rep(j, vinf)
    {
        if (dpo[j] < w + 1)
        {
            ans = j;
        }
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3964
package main

import "fmt"

func max(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

func main() {
	var s string
	fmt.Scan(&s)

	big := -1
	now := 0
	for i := 0; i < len(s); i++ {
		if s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C' {
			now++
		} else {
			now = 0
		}

		big = max(big, now)
	}

	fmt.Println(big)
}


Measured memory_bytes: 512