akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	private static int RomanToArabic(char roman){
		int arabic = 0;
		switch(roman){
		case 'I':
			arabic = 1;
			break;
		case 'V':
			arabic = 5;
			break;
		case 'X':
			arabic = 10;
			break;
		case 'L':
			arabic = 50;
			break;
		case 'C':
			arabic = 100;
			break;
		case 'D':
			arabic = 500;
			break;
		case 'M':
			arabic = 1000;
			break;
		default:
			arabic = 0;
			break;
		}
		return arabic;
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		char[] str;
		
		while(scan.hasNext()){
			str = scan.next().toCharArray();
			
			//大きい数字の前にあって引き算を表す
			//小さな数字は一回の引き算あたりひとつしかありません
			int sum=0;	//全体の和
			int num=0;	//部分和
			char buf = str[0];
			num += RomanToArabic(buf);
			for(int i=1; i<str.length; ++i){
				if(RomanToArabic(buf) < RomanToArabic(str[i])){
					sum -= num;
					num = 0;
				}else if(RomanToArabic(buf) > RomanToArabic(str[i])){
					sum += num;
					num = 0;
				}
				buf = str[i];
				num += RomanToArabic(buf);
			}
			sum += num;
			
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 11000
#include <iostream>
#include <map>

using namespace std;
using ll = long long;

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define out(v) cout<<v<<"\n"

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

  map<char, int> m;
  rep(i, N) ++m[S[i]];

  string s = "abcdefghijklmnopqrstuvwxyz";
  ll ans = 0;
  for (const auto& c:s) {
    ans += (ll)m[c] * (m[c]-1) / 2;
  }
  out((ll)N*(N-1)/2-ans+1);

  return 0;
}


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

int main()
{
    int a;
    int b;
    cin>>a>>b;
    if (a>b){
        cout<< "a > b" <<endl;
    }
    if (a<b){
        cout<< "a < b" <<endl;
    }
    if (a==b){
        cout<< "a == b" <<endl;
    }
}


Measured memory_bytes: 3080
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }

signed main() {
  SS(int,k);
  SS(string,s);
  if(s.length()>k){
    string ans="";
    rep(i,k){
      ans+=s[i];
    }
    ans+="...";
    p(ans);
  }else{
    p(s);
  }
}

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

#define pb push_back
#define fr first
#define sc second
#define ll long long

using namespace std;

const int N = 1e4 + 7;
const int mod = 1e9 + 7;

int dp[N][107][2];

int ad(ll x)
{
	return ((x + mod) % mod);
}

main()
{
	string s;
	int m, n;
	
	cin >> s >> m;
	
	n = s.size();
	
	for (int i = 0; i < n; i++)
	{
		if (i == 0)
		{
			for (int j = 0; j < int(s[0] - '0'); j++)
			{
				dp[i][j % m][1] += 1;
			}
			dp[0][int(s[0] - '0') % m][0] = 1;
			continue;
		}
		for (int j = 0; j < m; j++)
		{
			for (int k = 0; k < 10; k++)
			{
				dp[i][(j + k) % m][1] += dp[i - 1][j][1];
				dp[i][(j + k) % m][1] %= mod;
			}
			for (int k = 0; k < int(s[i] - '0'); k++)
			{
				dp[i][(j + k) % m][1] += dp[i - 1][j][0];
				dp[i][(j + k) % m][1] %= mod;
			}
			dp[i][((j + int(s[i] - '0')) % m)][0] += dp[i - 1][j][0];
			dp[i][((j + int(s[i] - '0')) % m)][0] %= mod;
		}
	}
	cout << (((dp[n - 1][0][0] + dp[n - 1][0][1]) - 1) + mod) % mod << endl;
}
/*
 * I will solve it in two way
	/					\
   /					 \
 Memory optimization    Time optimization
*/


Measured memory_bytes: 8576
#include <iostream>

using namespace std;

int main(void)
{
    int N, D, l;

    cin >> N >> D;

    l = D*2+1;

    if(N%l==0){
	cout << N/l << endl;
    }

    else{
	cout << N/l+1 << endl;
    }

    return 0;
}

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

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

        String a = sc.next();
        
        if (a.equals("ABC"))
            System.out.println("ARC");
        else
            System.out.println("ABC");

    }
}


Measured memory_bytes: 35760
#include <bits/stdc++.h>
#define maxn 600086

using namespace std;

const int p = 924844033;

inline int fpow(int x, int y){
	int ans = 1;
	while(y){
		if(y & 1) ans = 1ll * ans * x % p;
		x = 1ll * x * x % p;
		y >>= 1;
	}
	return ans;
}

const int G = 5, invG = fpow(G, p - 2);
int pos[maxn], prt[2][30];  

inline void init(){
	for(int i = 1, j = 2;i <= 21;i++, j <<= 1) prt[0][i] = fpow(G, (p - 1) / j);
	for(int i = 1, j = 2;i <= 21;i++, j <<= 1) prt[1][i] = fpow(invG, (p - 1) / j);
}

inline void NTT(int *a, int lim, int type){
	for(register int i = 0;i < lim;i++){
		if(i < pos[i]) swap(a[i], a[pos[i]]);
	}
	for(register int mid = 1, pw = 1;mid < lim;mid <<= 1, pw++){
		int wn = prt[type == -1][pw];
		for(register int i = mid << 1, j = 0;j < lim;j += i){
			int w = 1;
			for(register int k = 0;k < mid;k++, w = 1ll * w * wn % p){
				int x = a[j + k], y = 1ll * w * a[j + k + mid] % p;
				a[j + k] = x + y;
                if(a[j + k] >= p) a[j + k] -= p;
				a[j + k + mid] = x - y + p;
                if(a[j + k + mid] >= p) a[j + k + mid] -= p;
			} 
		}
	}
	if(type == -1){
		int invlim = fpow(lim, p - 2);
		for(register int i = 0;i < lim;i++) a[i] = 1ll * a[i] * invlim % p;
	}
} 

int n;
vector<int> v[maxn]; 
int x, y;
int siz[maxn];

int a[maxn], b[maxn];

void dfs(int i, int fa){
	siz[i] = 1;
	for(int j = 0;j < v[i].size();j++){
		int to = v[i][j];
		if(to == fa) continue;
		dfs(to, i);
		siz[i] += siz[to];
	}
	if(fa) a[siz[i]]++, a[n - siz[i]]++;
}

int sum[maxn], inv[maxn];

inline int C(int n, int m){
	return 1ll * sum[n] * inv[m] % p * inv[n - m] % p;
}

int main(){
	scanf("%d", &n);
	sum[0] = 1;for(int i = 1;i <= n;i++) sum[i] = 1ll * sum[i - 1] * i % p;
	inv[n] = fpow(sum[n], p - 2);for(int i = n - 1;~i;i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % p;
	for(int i = 1;i < n;i++){
		scanf("%d%d", &x, &y);
		v[x].push_back(y), v[y].push_back(x);
	}
	dfs(1, 0);
	init();
	int lim = 1;
	while(lim <= (n << 1)) lim <<= 1;
	for(int i = 0;i < lim;i++) pos[i] = (pos[i >> 1] >> 1) | ((i & 1) ? (lim >> 1) : 0);
	for(int i = 0;i <= n;i++) a[i] = 1ll * a[i] * sum[i] % p, b[i] = inv[i];
	reverse(a, a + n + 1);
	//for(int i = 0;i <= n;i++) printf("%d ", a[i]);puts("--");
	NTT(a, lim, 1), NTT(b, lim, 1);
	for(int i = 0;i < lim;i++) a[i] = 1ll * a[i] * b[i] % p;
	NTT(a, lim, -1);
	for(int i = 1;i <= n;i++) printf("%d\n", (1ll * n * C(n, i) + p - 1ll * inv[i] * a[n - i] % p) % p);
	
	
}

Measured memory_bytes: 45860
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
  int N, K;
  double ans = 0;
  scanf("%d %d", &N, &K);
  for (int i = 1; i <= N; i++) {
      if (i >= K) ans += 1.0 / N;
      else ans += 1.0 / (pow(2, ceil(log2((double)K / i))) * N);
  }
  printf("%.12f\n", ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <climits>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

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

    int n, k;
    cin >> n >> k;

    vector<int> h(n);
    REP(i, n) cin >> h[i];

    vector<int> dp(n + k, INT_MAX);
    dp[0] = 0;

    REP(i, n) REP(j, k + 1)
        chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));

    cout << dp[n - 1] << '\n';
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll a,b,c,x,y;
    while(cin >> a >> b >> c >> x >> y)
    {
        ll ans = a*x + b*y;
        for(int t = 0; t <= x; t++)
            ans = min(ans, a*t + (2*c)*(x-t) + b*max(0LL, y - (x-t))); 
        for(int t = 0; t <= y; t++)
            ans = min(ans, b*t + (2*c)*(y-t) + a*max(0LL, x - (y-t))); 
        cout << ans << '\n';
    }
    return 0;
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    int x, ans = 0;
    cin >> x;
    ans += (int)(x / 500) * 1000;
    x = x % 500;
    ans += (int)(x / 5) * 5;
    cout << ans << endl;
    return 0;
}


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

 
int main(){

 
    long double A,B,H,M;
    cin >> A >> B >> H >> M;
    long double pi = 3.1415926535;
 
 
    long double theta = abs(0.5*(60*H-11*M)*pi/180);
    long double result;
 
    
        result = sqrt(pow(A,2) + pow(B,2) - 2 * A * B * cos(theta));
    
    cout << fixed << setprecision(15) << result;
}

Measured memory_bytes: 4168
#include <bits/stdc++.h>
using namespace std;
int main() {
    int w[10], k[10];
    for(int i = 0; i < 10; i++) cin >> w[i];
    for(int i = 0; i < 10; i++) cin >> k[i];
    sort(w, &w[10]);
    sort(k, &k[10]);
    cout << w[7] + w[8] + w[9] << " " << k[7] + k[8] + k[9] << endl;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  string s;
  cin >> s;
  string t = regex_replace(s, regex("11"), "XX");
  string u = regex_replace(t, regex("0"), "");
  if (DEBUG) {
    cout << "t: " << t << endl;
    cout << "u: " << u << endl;
  }

  int64 ans = 0;
  for (int i = 0; i < u.length(); i++) {
    ans += (i + 2) / 2;
  }

  int x_count = 0;
  for (char c : u) {
    if (c == 'X') {
      x_count++;
    }
  }

  ans += (x_count / 2) * (s.length() - u.length());

  vector<int> p1s;
  vector<int> p2s;
  for (int i = 0; i < t.length(); i++) {
    if (t[i] == '1') {
      p1s.push_back(i);
    }
  }
  for (int i =0; i < u.length(); i++) {
    if (u[i] == '1') {
      p2s.push_back(i);
    }
  }

  if (DEBUG) {
    cout << "ans: " << ans << endl;
  }
  for (int i = 0; i < p1s.size(); i++) {
    int p1 = p1s[i];
    int p2 = p2s[i];
    ans += (s.length() - u.length()) - ((p1 + 1) / 2 - (p2 + 1) / 2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4728
#include <iostream>
#include <iomanip>
#include <limits>
#include <math.h>

using namespace std;

#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, s, n) for(int i = s; i < (int)(n); ++i)

int main() {
  int r;
  cin >> r;
  double circum = 2 * r * M_PI;
  cout << setprecision(numeric_limits<double>::max_digits10) << circum << endl;
  return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define fi first
#define sc second
int n;
vector<pair<string,int>>base;
vector<pair<string,int>>parse(string S){
	vector<pair<string,int>>ret;
	for(int i=0;i<S.size();){
		if('0' <= S[i] && S[i] <= '9'){
			string s = "";
			int x = 0;
			for(;i<S.size();i++){
				if('0' <= S[i] && S[i] <= '9'){
					x = x*10+S[i]-'0';
					s.pb(S[i]);
				}else break;
			}
			ret.pb(mp(s,x));
		}
		else{
			string s = "";
			int x = 1000000000;
			for(;i<S.size();i++){
				if(!('0' <= S[i] && S[i] <= '9')){
					s.pb(S[i]);
				}else break;
			}
			ret.pb(mp(s,x));
		}
	}
	return ret;
}
//a <= b?
bool cmp(vector<pair<string,int>>a,vector<pair<string,int>>b){
	int sz = min(a.size(),b.size());
	rep(i,sz){
		if(a[i].sc < b[i].sc) return 1;
		if(a[i].sc > b[i].sc) return 0;
		if(a[i].fi < b[i].fi) return 1;
		if(a[i].fi > b[i].fi) return 0;
	}
	if(a.size() <= b.size()) return 1;
	else return 0;
}
int main(){
	cin >> n;
	string s; cin >> s;
	base = parse(s);
	rep(i,n){
		string t; cin >> t;
		vector<pair<string,int>>ret = parse(t);
		//for(auto A:ret) cout << A.fi << " " << A.sc << endl;
		if(cmp(base,ret)) puts("+");
		else puts("-");
	}
	return 0;
}



Measured memory_bytes: 3220
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;



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

		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		int num;
		String str;
		String[] dice, com;
		int[] command=new int[2];
		int[] int_dice=new int[6];

		try{

			str=reader.readLine();
			dice=str.split(" ");//{1,2,3,4,5,6}={dice[0], dice[1], ... ,dice[5]}={???, S, E, W, N, ???}
			for(int i=0;i<6;i++){
				int_dice[i]=Integer.parseInt(dice[i]);
			}

			num=Integer.parseInt(reader.readLine());

			for(int i=0;i<num;i++){
			str=reader.readLine();
			com=str.split(" ");
			command[0]=Integer.parseInt(com[0]);
			command[1]=Integer.parseInt(com[1]);

			if(int_dice[0]!=command[0]){
				for(int j=0;j<3;j++){
				 roll('S', int_dice);
				 if(int_dice[0]==command[0])break;
				}
				if(int_dice[0]!=command[0]){
					for(int j=0;j<3;j++){
						roll('E', int_dice);
						if(int_dice[0]==command[0])break;
					}
				}
			}//?????¢????????????????????????


			if(int_dice[1]!=command[1]){

				for(int k=0;k<3;k++){
					rotate(int_dice);
					if(int_dice[1]==command[1])break;
				}
			}//?????¢????????????????????????


			System.out.println(int_dice[2]);



			}//??¨??????num????????????




		}catch(IOException e){
			System.out.print(e);
		}
	}

	private static void rotate(int[] int_dice){
		//?¨????????????¢???????????????????????????
		int x=int_dice[3];
		int_dice[3]=int_dice[4];
		int_dice[4]=int_dice[2];
		int_dice[2]=int_dice[1];
		int_dice[1]=x;
	}

	private static void roll(char ch, int[] int_dice){
		int[] dice_for_change=new int[6];

		switch(ch){

		case 'S':
	    {
	    	dice_for_change[0]=int_dice[4];
	    	dice_for_change[1]=int_dice[0];
	    	dice_for_change[2]=int_dice[2];
	    	dice_for_change[3]=int_dice[3];
	    	dice_for_change[4]=int_dice[5];
	    	dice_for_change[5]=int_dice[1];

	    	}
		break;

		case 'E':
	    {
	    	dice_for_change[0]=int_dice[3];
	    	dice_for_change[1]=int_dice[1];
	    	dice_for_change[2]=int_dice[0];
	    	dice_for_change[3]=int_dice[5];
	    	dice_for_change[4]=int_dice[4];
	    	dice_for_change[5]=int_dice[2];

	    	}
		break;

		case 'N':
	    {//??????
	    	dice_for_change[0]=int_dice[1];
	    	dice_for_change[1]=int_dice[5];
	    	dice_for_change[2]=int_dice[2];
	    	dice_for_change[3]=int_dice[3];
	    	dice_for_change[4]=int_dice[0];
	    	dice_for_change[5]=int_dice[4];
        	}
		break;

		case 'W':
	    {
	    	dice_for_change[0]=int_dice[2];
	    	dice_for_change[1]=int_dice[1];
	    	dice_for_change[2]=int_dice[5];
	    	dice_for_change[3]=int_dice[0];
	    	dice_for_change[4]=int_dice[4];
	    	dice_for_change[5]=int_dice[3];
        	}
		break;
		}//switch
		for(int k=0;k<6;k++){
	    	int_dice[k]=dice_for_change[k];

		}//??¢?????????????????£??\


	}

}

Measured memory_bytes: 24088
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,k,x,y;
  cin>>a>>b>>c>>d>>k;
  x=(a*60+b);
  y=(c*60+d);
  x=abs(y-x)-k;
  cout<<x<<endl;
}

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

#ifdef _DEBUG
    #include "/home/v-o_o-v/deb.h"
    #define deb(x...)cerr << "[" << #x << "] = [";_print(x);
#else
    #define deb(x...)
#endif

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    string s;
    cin >> s;
    s.pop_back();
    while(true){
        if(s.size() % 2)s.pop_back();
        if(s.substr(0, s.size() / 2) == s.substr(s.size() / 2))break;
        s.pop_back();
    }
    cout << s.size() << '\n';
    return 0;
}
// Write Here


Measured memory_bytes: 3672
#include <iostream>
using namespace std;
const int maxn = 3005;
int num[maxn];
int N;
int main(){
    cin>>N;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        cin>>num[i];
        ans +=(num[i] - 1);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
a,b,n = map(int, input().split())

if b==1:
  print(0)
else:  
  if b-1>n:
    x = n
  else:
    x = (b-1)*(n//(b-1))

  ans = max(a*x//b-a*(x//b), a*n//b-a*(n//b))

  print(ans)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    uint64_t n;
    cin >> n;

    bitset<61> bs(n);

    constexpr auto M = 1000000007L;
    vector dp(61, vector(4, 0L));
    dp[60][0] = 1;
    for (auto i : irange(0L, 60L) | reversed) {
        dp[i][0] = dp[i + 1][0] + (1 - bs[i]) * dp[i + 1][1];
        dp[i][0] %= M;
        dp[i][1] = bs[i] * dp[i + 1][0] + dp[i + 1][1];
        dp[i][1] %= M;
        dp[i][2] = bs[i] * dp[i + 1][0] + bs[i] * dp[i + 1][1] + 2 * dp[i + 1][2] + dp[i + 1][3];
        dp[i][2] %= M;
        dp[i][3] += dp[i + 1][2] + 2 * dp[i + 1][3] + bs[i] * dp[i + 1][1];
        dp[i][3] %= M;
        cerr << i << ":" << dp[i][0] << "," << dp[i][1] << "," << dp[i][2] << "," << dp[i][3] << endl;
    }

    cout << (dp[0][0] + dp[0][2]) % M << endl;

    return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int w = scan.nextInt();
    int h = scan.nextInt();
    int x = scan.nextInt();
    int y = scan.nextInt();
    int r = scan.nextInt();
    boolean yoko;
    boolean tate;
    if (x-r >= 0 && x+r <= w) {
      yoko = true;
    } else {
      yoko = false;
    }

    if (y-r >= 0 && y+r <= h) {
      tate = true;
    } else {
      tate = false;
    }
    if (yoko == true && tate == true) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 26248
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String answer = "";
        int length = line.length();
        for (int i = 0; i < length; i++) {
            char ch = line.charAt(i);
            if (Character.isLowerCase(ch)) {
                answer += Character.toUpperCase(ch);
            } else {
                answer += Character.toLowerCase(ch);
            }
        }
        System.out.println(answer);
        sc.close();
    }
}


Measured memory_bytes: 31476
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int cnt=0;
    int n=0;
    if(s[0]!='A')
    {
        printf("WA\n");
        return 0;
    }
    for(int i=2;i<s.size()-1;i++)
    {
        if(s[i]=='C')cnt++;
    }
    for(int i=1;i<s.size();i++)
    {
        if(s[i]<'a'||s[i]>'z')n++;
    }
    if(cnt==1&&n==1)printf("AC\n");
    else printf("WA\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

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

    vector<vector<ll>> nums(3, vector<ll>(n));
    rep(i, 3){
        rep(j, n){
            cin >> nums[i][j];
        }
        sort(all(nums[i]));
    }

    // [1] -> [0]
    vector<ll> up_low_nums(n);
    rep(i, n){
        up_low_nums[i] = lower_bound(all(nums[0]), nums[1][i]) - nums[0].begin();
    }

    // [1] -> [2]
    vector<ll> sum_num(n);
    rep(i, n){
        sum_num[i] = (nums[2].end() - upper_bound(all(nums[2]), nums[1][i])) * up_low_nums[i];
    }

    cout << accumulate(all(sum_num), 0LL) << endl;
}

Measured memory_bytes: 4208
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
	int k;
	cin >> k;
	int a, b;
	cin >> a >> b;
	int x = 0;
	if(a%k)
		x = k - a % k;
	cout << (a + x<= b ? "OK" : "NG") << endl;
}


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

int main() {
  
  int n, d, x;
  cin >> n >> d >> x;
  
  int a;
  REP(i,n) {
    cin >> a;
    x += (d - 1) / a;
  }
  
  cout << x + n << endl;
  
}

Measured memory_bytes: 3604
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;

void solve() {
	string s; cin >> s;
	string t; cin >> t;
	bool e_flg = false;
	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());
	for (unsigned int i = 0; i < s.length(); ++i) {
		for (unsigned int j = 0; j < t.length(); ++j) {
			if (s[i] < t[j]) {
				cout << "Yes" << endl;
				return;
			}
			if (s[i] == t[j]) {
				e_flg = true;
			} else {
				e_flg = false;
			}
		}
	}
	if (e_flg) {
		if (s.length() < t.length()) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	} else {
		cout << "No" << endl;
	}
	return;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector< vector<long long>>
#define mi map<int,int>
#define pi pair<int,int>

#define Fori(i,a,b) for(int i=a; i<b; i++)
#define Ford(i, a, b) for(int i=a; i>=b; i--)

#define pb push_back
#define mp make_pair

#define read(a, n) for(int i=0; i<n; i++) cin >> a[i];
#define print(x) cout << "X: == " << x << endl;
#define printMap(a) for(auto it=a.begin() ; it!= a.end() ; it++) {cout << it->first << "  " << it->second << endl; }
#define printVector(a) for(auto it = a.begin() ; it!= a.end() ;it++) {cout << *it << endl;}

using namespace std;
int main() {
    IOS
    ll n, m, k;
    cin >> n >> m >> k;
    vl a(n+1), b(m+1);
    Fori(i, 1, n+1) {
        ll x;cin >> x;
        a[i] = a[i-1] + x;
    }
    Fori(i, 1, m+1) {
        ll x; cin >> x;
        b[i] = b[i-1] + x;
    }
    ll total = 0;
    Fori(i, 0, n+1) {
        if(a[i] > k) {
            continue;
        }
        ll other = k - a[i];
        ll index = lower_bound(b.begin(), b.end(), other) - b.begin();
        if(index == m+1 || b[index] > other) {
            index--;
        }
        total = max(total, i + index);
    }
    cout <<total << endl;
    return 0;
}

Measured memory_bytes: 6296
n,a,b = map(int,input().split(" "))
s = input()
m_dict = {"a":0,"b":0,"c":0}
for i in s:
  if i == "a":
    if m_dict["a"]+m_dict["b"] < a+b:
      m_dict["a"] += 1
      print("Yes")
    else:
      print("No")
  elif i == "b":
    if m_dict["a"]+m_dict["b"] < a+b and m_dict["b"] < b:
      m_dict["b"] += 1
      print("Yes")
    else:
      print("No")
  else:
    print("No")

Measured memory_bytes: 9308
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

// a>=0, b>=0, x*a+y*b=gcd>=0, a>0,b>0=>abs(y)<=a,abs(x)<=b
LL gcdex(LL a,LL b,LL& x, LL& y){
	LL ax=1,ay=0;
	LL bx=0,by=1;
	while(b){
		LL r=a/b;
		LL t=a-r*b; a=b; b=t;
		LL tx=ax-r*bx; ax=bx; bx=tx;
		LL ty=ay-r*by; ay=by; by=ty;
	}
	x=ax;
	y=ay;
	return a;
}
#if 0
template<class T> T powmod(T p,T n,T mod){
	T q=p%mod;
	T pow=1;
	while(n){
		if(n&1){
			pow*=q;
			pow%=mod;
		}
		q=q*q;
		q%=mod;
		n/=2;
	}
	return pow;
}
#endif
LL modinv(LL a, LL mod){
	LL x,y;
	gcdex(a,mod,x,y);
	if(x<0){
		x+=mod;
	}
	return x;
}

LL F[3*100*1000+1];
LL Comb(int i,int j,LL p){
	if(i<j){
		return 0;
	}
	LL ret=F[i];
	ret*=modinv(F[j],p);
	ret%=p;
	ret*=modinv(F[i-j],p);
	ret%=p;
	return ret;
}
const LL M=998244353;
int main() {
	LL N,A,B,K;
	cin >> N >> A >> B >> K;
	LL ret=0;
	F[0]=1;
	for(LL i=1;i<=N;i++){
		F[i]=i*F[i-1]%M;
	}
	for(LL i=0;i<=N;i++){
		LL r=K-A*i;
		if(r>=0&&r%B==0){
			LL j=r/B;
			if(i<=N&&j<=N){
				ret+=Comb(N,i,M)*Comb(N,j,M)%M;
				ret%=M;
			}
		}
	}
	cout << ret << endl;


	return 0;
}



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

#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair

typedef int ll;
typedef long double ld;
typedef pair<ll,ll> pll;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=1e5+10, maxm=5e3+10, lg=31, mod=1e9+7, inf=1e18;

ll n,a[maxn],b[maxn],ans;
multiset<ll> sa,sb;
map<ll,ll> par;
ll gpar(ll v){return (par[v]==v ? v:par[v]=gpar(par[v]));}
void mrg(ll v,ll u){par[gpar(v)]=gpar(u);}

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i], a[0]^=a[i], sa.insert(a[i]);
	for(int i=1;i<=n;i++) cin>>b[i], b[0]^=b[i], sb.insert(b[i]);
	sa.insert(a[0]), sb.insert(b[0]);
	if(sa!=sb) return cout<<-1,0;
	par[a[0]]=a[0];
	for(int i=1;i<=n;i++)if(a[i]!=b[i]) par[a[i]]=a[i];
	for(int i=1;i<=n;i++)if(a[i]!=b[i]) mrg(a[i],b[i]), ans++;
	for(auto e:par)if(e.F==e.S) ans++;
	cout<<ans-1;

	return 0;
}





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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,k;
void solve(){
    cin>>n>>k;
    vi v;
    for(int i=1;i*i<=n;i++){
        v.pb(i);
        v.pb(n/i);
    }
    sort(all(v));
    v.resize(unique(all(v))-v.begin());
    reverse(all(v));
    vii vv;
    rep(i,0,sz(v)){
        int w=v[i];
        vv.pb({w,n/w-(n/(w+1))});
    }
    k-=2;
    rep(i,0,k){
        int cur=0;
        vii dvv=vv;
        rep(j,0,sz(vv)){
            cur+=vv[j].x*vv[j].y%hell;
            cur%=hell;
            dvv[sz(vv)-j-1].x=cur;
        }
        vv=dvv;
    }
    int s=0;
    for(auto i:vv) s=(s+i.x*i.y)%hell;
    cout<<s<<endl;
}

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

Measured memory_bytes: 2804
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;
int main(void){
	ll N,A,B;
	cin >> N;
	cin >> A;
	cin >> B;
	if((B-A)%2==0){
		cout << (B-A)/2 << endl;
	}else if(A-1+(B-(A-1)-1)/2+1<N-B+((B-A)-1)/2+1){
		cout << A-1+(B-(A-1)-1)/2+1  << endl;
	}else if(A-1+(B-(A-1)-1)/2+1>=N-B+((B-A)-1)/2+1){
		cout << N-B+((B-A)-1)/2+1 << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int K,X;
  scanf("%d %d", &K, &X);
  
  int j;
  for(j= X-K+1; j<K+X-1; j++){
    printf("%d\t", j);
  }
  printf("%d\n",K+X-1);
  return 0;
}

Measured memory_bytes: 128
def solve(string):
    n, *abc = map(int, string.split())
    a, b, c = abc[:n], abc[n:2 * n], abc[2 * n:]
    ans = [b[a0 - 1] + c[a0 - 1] if a0 + 1 == a1 else b[a0 - 1] for a0, a1 in zip(a, a[1:])]
    return str(sum(ans) + b[a[-1] - 1])


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(3)])))


Measured memory_bytes: 3064
NUM = list(map(int, input().split()))
NUM.sort()

if (NUM[0] == NUM[1] and NUM[1] != NUM[2]):
    answer = 'Yes'
elif (NUM[1] == NUM[2] and NUM[1] != NUM[0]):
    answer = 'Yes'
else:
    answer = 'No'
print(answer)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e3 + 5, mod = 1e9 + 7, inf = 0x3f3f3f3f;

int dp[maxn][maxn], a[maxn], b[maxn];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= m; ++i) cin >> b[i];
    //dp[i][j]为a前i个和b前j个的答案
    //此时dp[i - 1][j]和dp[i][j - 1]和dp[i - 1][j - 1]都已经算出来了
    //继承：dp[i][j] += dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
    //如果a[i] == b[j]，那可以把a[i]和b[j]加进去，然后再来次dp[i - 1][j - 1], 再加上这两个数单独的一个
    for (int i = 1; i <= n; ++i){
        for (int j = 1; j <= m; ++j){
            dp[i][j] += dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
            if (a[i] == b[j]) dp[i][j] += dp[i - 1][j - 1] + 1;
            dp[i][j] %= mod;
            if (dp[i][j] < 0) dp[i][j] += mod;
        }
    }
    cout << (dp[n][m] + 1) % mod << endl;
    return 0;
}


Measured memory_bytes: 16000
import java.util.Scanner;



class Main {

	public static void main(String[] argv){

		Scanner sc = new Scanner(System.in);
		long A,B,C;
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
		
		sc.close();
		
		long cutA = (A % 2) * B * C;
		long cutB = (B % 2) * A * C;
		long cutC = (C % 2) * A * B;
		
		System.out.println(Math.min(cutA, Math.min(cutB,cutC)));
		

	}


}



Measured memory_bytes: 8788
#include <iostream>
#include <array>

using namespace std;

int n;
int getP(int i){
    if(i/2<=n)
        return i/2;
    else
        return 0;
}
int getL(int i){
    if(2*i<=n)
        return 2*i;
    else
        return 0;
}
int getR(int i){
    if(2*i+1<=n)
        return 2*i+1;
    else
        return 0;
}

int main(){
    array<long long int,251> hp;
    cin>>n;
    hp[0]=0;
    for(int i=1;i<=n;i++)
        cin>>hp[i];
    for(int i=1;i<=n;i++){
        cout<<"node "<<i<<": key = "<<hp[i]<<", ";
        if(getP(i))
            cout<<"parent key = "<<hp[getP(i)]<<", ";
        if(getL(i))
            cout<<"left key = "<<hp[getL(i)]<<", ";
        if(getR(i))
            cout<<"right key = "<<hp[getR(i)]<<", ";
        cout<<"\n";
    }
    return 0;
}    

Measured memory_bytes: 1164
#ABC104_B
S = input()

ans = "AC"

if S[0] != 'A' or S[2:-1].count('C') != 1 or S[-1] == 'C' or S[1] == 'C':
  ans = "WA"
for i in range(1, len(S)):
  if S[i].isupper() and S[i] != 'C':
    ans = "WA"
print(ans)

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

int main(){
    int a , b , c , ans = 0;
    cin >> a >> b >> c;
    a = a-b;
    ans = c - a;
    if(ans < 0){
        ans = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define N 2000001
#define NIL -1000
 
int num;
int A[N];
 
int parent(int i){
  return i/2;
}
 
int left(int i){
  return 2*i;
}
 
int right(int i){
  return 2*i+1;
}
 
void heapIncreaseKey(int i, int key){
  int temp;
  if(key < A[i]){
    return;
  }
  A[i] = key;
  while(i > 1 && A[parent(i)] < A[i]){
    temp = A[i];
    A[i] = A[parent(i)];
    A[parent(i)] = temp;
    i = parent(i);
  }
}
 
void maxHeapInsert(int key){
    num = num + 1;
    A[num] = NIL;
    heapIncreaseKey(num, key);
}
 
 
void maxHeapify(int i){
  int largest=0,temp;
  int l,r;
  l = left(i);
  r = right(i);
  if(l <= num && A[l] > A[i]){
    largest = l;
  }
  else
    largest = i;
  if(r <= num && A[r] > A[largest]){
    largest = r;
  }
  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(largest);
  }
}
 
 
int heapExtractMax(){
  int max;
  if(num < 1){
    return 0;
  }
  max = A[1];
  A[1] = A[num];
  num = num-1;
  maxHeapify(1);
  return max;
} 
 
main(){
  int k;
  char b[12];
  while(1){
    scanf("%s",b);
    if(b[0] == 'i'){
      scanf("%d",&k);
      maxHeapInsert(k);
    }
    else if(b[0] == 'e' && strcmp(b,"extract") == 0){
      printf("%d\n",heapExtractMax());
     }
    else
      break;
       }
  return 0;
}


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

int main() {
	string s; cin >> s;
	unsigned long long int k; cin >> k;
	bool f = true;
	for (int i = 0; i < k; i++) {
		if (s[i] != '1') {
			f = false;
			break;
		}
	}
	if (f) {
		cout << 1 << endl;
		return 0;
	}
	while (s[0] - '0' == 1&&s.size()>1) {
		k--;
		s = s.substr(1, s.size() - 1);
	}
	cout << s[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
#define FOR(i, r, n) for(int i=(r); i<(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ll long long int

template <typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

using namespace std;
ll ans = 0, sum = 0, n, k, t;
string s;

ll h, w, px, py, dx = -1, dy = -1, counter = 0;
vector<pair<ll, ll>> v1, v2;
map<ll, ll> mp;

int main()
{
	cin >> h >> w >> n;
	if(!n)
	{
		cout << (h - 2)*(w - 2) << endl;
		REP(i,9)
		{
			cout << "0" << endl;
		}
		return 0;
	}
	REP(i,n)
	{
		cin >> k >> t;
		v1.emplace_back(k - 1, t - 1);
	}
	REP(m, n)
	{
		//cout << v1[m].second << " " << v1[m].first << ":";
		REP(i, 3)
		{
			REP(j, 3)
			{
				py = v1[m].first - i;
				px = v1[m].second - j;
				if (0 <= px && px <= w - 3 && 0 <= py && py <= h - 3)
				{
					v2.emplace_back(px, py);
					//cout << "[" << px << ", " << py<<"]  ";
				}
			}
		}
		//cout << endl;
	}
	sort(v2.begin(), v2.end());
	dx = v2[0].first;
	dy = v2[0].second;
	for (auto itr = v2.begin(); itr != v2.end(); ++itr)
	{
		px = itr->first;
		py = itr->second;
		if (dx == px && dy == py)
		{
			counter++;
		}
		else
		{
			mp[counter]++;
			counter = 1;
			dx = px;
			dy = py;
			sum++;
		}
	}
	mp[counter]++;
	sum++;
	cout << (h - 2) * (w - 2) - sum << endl;
	FOR(i,1,10)
	{
		cout << mp[i] << endl;
	}
}


Measured memory_bytes: 18280
#include <stdio.h>

int main(){
   int h,w,k,i,j,x[7],y[7],b;
   long ans;
   char c[6][8];

   scanf("%d %d %d",&h,&w,&k);
   for (i=0;i<h;i++) scanf("%s",c[i]);
   for (i=0;i<=h;i++) y[i]=0;
   for (i=0;i<=w;i++) x[i]=0;
   ans=0;
   while (y[h]==0) {
      for (b=i=0;i<h;i++)
         for (j=0;j<w;j++)
            if (c[i][j]=='#' && !y[i] && !x[j]) b++;
      if (b==k) ans++;
      for (i=0;i<w;i++)
         if (x[i]==0) {
            x[i]=1;
            break;
         } else
            x[i]=0;
      if (i==w)
         for (i=0;i<=h;i++) {
            if (y[i]==0) {
               y[i]=1;
               break;
            } else
               y[i]=0;
         }
   }
   printf("%ld\n",ans);
   return 0;
}


Measured memory_bytes: 1736
#define _USE_MATH_DEFINES
//#include <bits/stdc++.h>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <complex>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

void recursive(long long n);

void recursive(long long n){
  if(n==0)return;
  long long rest=n%26LL;
  recursive(n/26LL - (rest==0?1:0));
  if(rest==0){rest+=26;}
  cout<<(char)(rest+'a'-1);
}

void solve(long long N){
  recursive(N);
  cout<<endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}


Measured memory_bytes: 3680
//#include<stdio.h>
//#include<stdlib.h>
#include<bits/stdc++.h>
//#define Min(a,b,c) min((a),min((b),(c)))
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<LL,LL>
#define pb(x) push_back(x)
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-11
#define MEM(x) memset(x,0,sizeof(x))
#define N 200005
#define pi 3.14159265359
using namespace std;
typedef long long LL;
int f[200005];
int Find(int a){
	if(f[a]==a)return a;
	return f[a]=Find(f[a]);
}
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    pii p[200005];
    for(int i=0;i<n;i++)
    scanf("%d %d",&p[i].x,&p[i].y);
    sort(p,p+n);
    int r=m,ans=0;
    priority_queue<int,vector<int>,greater<int> > pq;
    for(int i=0;i<200005;i++)
    f[i]=i;
	for(int i=0;i<n;i++){
		pq.push(p[i].y);
		if(pq.size()>p[i].x){
			int a=pq.top();
			pq.pop();
			int fa=Find(a);
			//printf("%d %d\n",a,fa);
			if(fa!=m+1){
				f[fa]=fa+1;
			}	
			else{
				ans++;
			}
		}
		else{
		int fa=Find(pq.size());
		if(fa!=m+1)
		f[fa]=fa+1;
		else
		ans++;
		}
	} 
	printf("%d\n",ans);
	return 0;
}

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

int n;
map<string,int>  M;
map<string,vector<int> >T;

int dp[111][111],nex[111];


signed main(){

  memset(nex,-1,sizeof(nex));
  r(i,111)r(j,111)dp[i][j]=1e8;
  
  cin>>n;
  r(i,n){
    string s;
    cin>>s;
    if(s!="goto"){
      s=s.substr(0,s.size()-1);
      if(T.count(s)){
	r(j,T[s].size())
	  nex[ T[s][j] ] = i;
      }
      M[s]=i;
    }
    else{
      string t;
      cin>>t;
      t=t.substr(0,t.size()-1);
      if(M.count(t))nex[ i ] = M[t];
      else T[t].push_back(i);
    }
  }

  r(i,n){
    if(nex[i]==-1)dp[i][i+1]=0;
    else{
      dp[i][nex[i]] = 0;
      if(i+1!=nex[i]){
	dp[i][i+1] = 1;
      }
    }
  }

  r(k,n+1)r(i,n+1)r(j,n+1) dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);

  cout<<dp[0][n]<<endl;
}



Measured memory_bytes: 3252
#include<stdio.h>

int n,A[2000000];
void maxHeapify(int);

int main(){
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  for(i=n/2;i>=1;i--){
    maxHeapify(i);
  }
  for(i=1;i<=n;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}

void maxHeapify(int i){
  int l,r,a,largest;
  l=2*i;
  r=2*i+1;
  if(l<=n && A[l]>A[i])largest=l;
  else largest=i;
  if(r<=n && A[r]>A[largest])largest=r;
  if(largest!=i){
    a=A[largest];
    A[largest]=A[i];
    A[i]=a;
    maxHeapify(largest);
  }
}
    



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main()
{
       fast;
       ll n,k;
       cin>>n>>k;
       ll arr[2005][2005];
       memset(arr,0,sizeof(arr));
       arr[0][0]=1;
       for(int i=0;i<=n;i++)
    	arr[i][0]=1;
       for(int i=1;i<=n;i++)
    		for(int j=1;j<=i;j++)
    			arr[i][j]=(arr[i-1][j-1]%MOD+arr[i-1][j]%MOD)%MOD;
    	for(int i=1;i<=k;i++)
    		cout<<(arr[n-k+1][i]%MOD*arr[k-1][i-1]%MOD)%MOD<<endl;
       return 0;
}

Measured memory_bytes: 34976
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
abcd = input().split(" ")
a = int(abcd[0])
b = int(abcd[1])
c = int(abcd[2])
d = int(abcd[3])
cd = lcm(c, d)
print(b-a-(b//c-((a-1)//c + 1))-(b//d - ((a-1)//d + 1))+(b//cd-((a-1)//cd + 1)))


Measured memory_bytes: 5048
def GCD(a, b):
    """ Euclidean algorithm"""
    if a < b: (a, b) = (b, a)
    if b == 0: return a
    m = a % b
    while m != 0:
        a = b
        b = m
        m = a % b
    return b
     
N = int(input())
A = [ int(v) for v in input().split() ]
    
if N < 2 and 1e5 < N: raise()
for v in A:
    if v < 1 and v < 1e9: raise()
     
l_list = [0]
r_list = [0]
j = -1
for i in range(0, N):
    l_list.append( GCD(l_list[i],  A[i]) )
    r_list.append( GCD(r_list[i],  A[j]) )
    j -= 1
n = []
j = -2   
for i in range(0, N):
    n.append(GCD(l_list[i], r_list[j]))
    j -= 1
print(max(n))

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

#define pb push_back
#define ppp pop_back
#define pii pair<int,int>
#define fi first
#define se second

const int N = 105;
const int K = 1e5 + 5;

pii a[N];
ll dp[K];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    int n, w;
    cin >> n >> w;
    for (int i=1; i<=n; i++) {
        cin >> a[i].fi >> a[i].se;
    }
    //sort(a+1, a+n+1);
    for (int i=0; i<K; i++) dp[i] = -1;
    dp[0] = 0;
    for (int i=n; i>=1; i--) {
        for (int j=w; j>=0; j--) {
            if (dp[j] >= 0 && a[i].fi + j <= w) {
                dp[j + a[i].fi] = max(dp[j] + a[i].se, dp[j + a[i].fi]);
            }
        }
    }
    ll maxv = 0;
    for (int i=0; i<=w; i++) maxv = max(maxv, dp[i]);
    cout << maxv << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  vector<ll> a(3);
  for (int i = 0; i < 3; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  
  if (a[0] == a[2])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
    
  

  return 0;
}


Measured memory_bytes: 256
// abc114_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

vector<ll> get_divisors(ll n){
    vector<ll> res;
    for (int i = 1; i * i <= n; i++){
        if (i * i == n){
            res.emplace_back(i);
        }
        if (n % i == 0){
            res.emplace_back(i);
            res.emplace_back(n / i);
        }
    }
    sort(ALL(res));
    return res;
}

map<ll, int> factorize(ll n){
    ll tmp = n;
    map<ll, int> res;
    for (ll a = 2; a * a <= n; a++) { int cnt = 0; while (tmp % a == 0){ cnt++; tmp /= a; } if (cnt > 0) res[a] = cnt; }
    if (tmp > 1) res[tmp] = 1;
    return res;
}

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    map<ll, int> f;
    REPN(n, 1, N+1){
        ll tmp = n;
        for (ll a = 2; a * a <= n; a++) { int cnt = 0; while (tmp % a == 0){ cnt++; tmp /= a; } if (cnt > 0) f[a] += cnt; }
        if (tmp > 1) f[tmp] += 1;
    }

    ll ans = 0;
    // 75 = 5 * 5 * 3 = 4 4 2
    for (auto a: f){
        if (a.second < 4) continue;
        for (auto b: f) {
            if (b.first <= a.first) continue;
            if (b.second < 4) continue;
            for (auto c: f) {
                if (c.first == a.first) continue;
                if (c.first == b.first) continue;
                if (c.second < 2) continue;
                ans++;
            }
        }
    }

    // 75 = 15 * 5 = 14 4
    for (auto a: f){
        if (a.second < 14) continue;
        for (auto b: f) {
            if (b.first == a.first) continue;
            if (b.second < 4) continue;
                ans++;
        }
    }

    // 75 = 25 * 3 = 24 2
    for (auto a: f){
        if (a.second < 24) continue;
        for (auto b: f) {
            if (b.first == a.first) continue;
            if (b.second < 2) continue;
            ans++;
        }
    }

    // 75 = 75 = 74
    for (auto a: f){
        if (a.second < 74) continue;
        ans++;
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define cpy(a,b) memcpy(a,b,sizeof(a))
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	ll a,b,c;
	cin>>a>>b>>c;
	fo(i,0,10){
		c=c*a-b;
		cout<<c<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
N,M= list(map(int, input().split()))
li=[list(map(int,input().split())) for _ in range(M)]
mi=0
ma=N
for i in li:
    mi=max(mi,i[0])
    ma=min(ma,i[1])
if ma>=mi:
    print(ma-mi+1)
else:
    print(0)

Measured memory_bytes: 27332