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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=m.begin();i!=m.end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

const double eps = 1e-10;

void printv(vector<auto> const& s) {
  REP(i, s.size()) {
    cout << s[i] << endl;
  }
}

void print(auto const s) {
  cout << s << endl;
}

int digit (ll n) {
  int ans = 0;
  while(n > 0) {
    ans++;
    n /= 10;
  }
  return ans;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  ll n; cin >> n;
  ll tmp = floor(sqrt(n));
  RREP(i, tmp+1) {
    if(n % i == 0) {
      cout << max(digit(n/i), digit(i)) << endl;
      return 0;
    }
  }
  
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a,b,c,n,m,i,j,k;
	int d[1001];
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%d%d",&a,&b);
		c=(n%2==0)?n/2:n/2+1;
		a=(a>c)?n-a+1:a;
		b=(b>c)?n-b+1:b;
		d[i]=(a<b)?a%3:b%3;
		if(d[i]==0)d[i]=3;
	}
	for(i=1;i<=m;i++)printf("%d\n",d[i]);
	return 0;
}


Measured memory_bytes: 2104
#include<stdio.h>

int sankaku(int x){return (x*(x+1))/2;}

int main(void){
	int i,x;
	scanf("%d",&x);
	for(i = 1;i <= 100000;i++){
		if(x <= sankaku(i)){printf("%d\n",i);return 0;}
	}
	return 0;
}

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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  string s;
  cin >> s;
  ll ans = 0ll;
  vector<pair<char, ll>> z;
  for (int i = 0; i < s.size(); i++) {
    if (z.empty() || z.back().first != s[i])
      z.emplace_back(s[i], 1);
    else
      z.back().second++;
  }
  ll pre = 0ll;
  for (int i = 0; i < z.size(); i++) {
    if (z[i].first == '<') {
      assert(pre == 0ll);
      ll t = z[i].second;
      pre = t;
      ans += t * (t + 1) / 2ll;
    } else {
      ll t = z[i].second;
      ans += max(0ll, t - pre);
      pre = 0ll;
      ans += t * (t - 1) / 2ll;
    }
  }
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 6932
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <deque>
#include <tuple>
#include <unordered_set>
#include <array>
#include <string>

using namespace std;
#define ll long long
#define ar array
int main()
{   
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll e=a*c, f=a*d, g=b*c, h=b*d;
	cout << max({e,f,g,h});
	return 0;
}

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

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

	int n ; cin >> n;
	int h[n+1];
	for(int i=1;i<n+1;i++) cin >> h[i];
	int diff[n+1],sum[n+1];
	for(int i=1;i<n+1;i++){
		diff[i]= i - h[i];
		sum[i] = i+  h[i];
	}
	sort(sum+1,sum+n+1);
	sort(diff+1,diff+n+1);

	int i =2,j=1,prev=0;
	long long int count = 0;
	//for(int i =1;i<n+1;i++) cout << diff[i] <<" ";
	//	cout << endl;
	//for(int i=1;i<n+1;i++) cout << sum[i] <<" ";
	//	cout << endl;
	while(i<=n){
		if(diff[i]==diff[i-1]){
			count +=  prev;
			i++;
			continue;
		}
		while(sum[j]<diff[i] && j <=n){
			j++;
		}
		int k = j;
		while(diff[i]==sum[j] && j<=n){
			j++;
		}
		//cout << k << " " << j << endl;
		prev = j-k;
		count += j-k;
		i++;

	}
	cout << count;	
	

}


Measured memory_bytes: 6008
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define puts(i) cout<<i
int main(){
	int n,k;
	string s;
	cin>>n>>k>>s;
	int count=0;
	rep(i,s.size()-1){
		if(s[i+1]==s[i])count++;
	}
	count+=min(n-count-1,2*k);
	puts(count);
}


Measured memory_bytes: 512
# ABC 085 B - Kagami Mochi
N = int(input())

dn = [0] * N
for i in range(N):
    dn[i] = int(input())

j = N
for i in range(1,101):
    k = dn.count(i)
    if k >= 2:
        j = j - (k - 1)
print(j)

Measured memory_bytes: 9028
import java.util.Scanner;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        double A = Integer.parseInt(scanner.next());
        double B = Integer.parseInt(scanner.next());
        double X = Integer.parseInt(scanner.next());

        X /= A;
        if (X > A * B / 2) {
            double H = (A * B - X) * 2 / A;
            double rad = Math.atan2(H, A);
            System.out.printf("%.10f\n", rad / Math.PI * 180);
        } else {
            double W = 2 * X / B;
            double rad = Math.atan2(B, W);
            System.out.printf("%.10f\n", rad / Math.PI * 180);
        }
    }
}


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

int main()
{
    int a,b;
    cin>>a>>b;
    if(a>=b)
    {
        for(int i=0;i<a;i++)
        cout<<b;
    }
    else if(a<b)
    {
            {
        for(int i=0;i<b;i++)
        cout<<a;
    }
    }

    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, R = MAP()

if N >= 10:
    print(R)
else:
    print(R+100*(10-N))


Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
  int a, b, c, m;
  scanf("%d%d%d%d", &a, &b, &c, &m);
  int ans = 0;
  ans += min(a, m);
  m -= min(a, m);
  m -= min(b, m);
  ans -= min(c, m);
  printf("%d\n", ans);
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
#define setzero(x) memset(x,0,sizeof(x))
  
using namespace std;
 
const int inf = 2e9+500;
const int N = 1e3+10;
const int bits = 20;
const ld pi = 3.14159265358979323846;
const ll mod = 1e9;
const ll p = 29;


int main(){

    FASTIO;
    PRECISION; 
    
    ll n,m;
    cin>>n>>m;

    ll sum = 0;
    for(int i=0;i<m;i++){
        ll temp;
        cin>>temp;
        sum+=temp;
    }

    if(sum>n){
        cout<<-1<<"\n";
    }else{
        cout<<n-sum<<"\n";
    }
    

}

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  int f = N;
  
  for (int i=0; i<9; i++) {
    sum += f%10;
    f /= 10;
  }
  
  if (N%sum == 0)
    cout <<"Yes" <<endl;
  
  else
    cout <<"No" <<endl;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 200010
const int MOD = 998244353;

int pww(int a, int b, int m = MOD) {
    if (b == 0)
        return 1;
    if (b & 1)return a * pww(a, b - 1) % m;
    return pww(a * a % m, b / 2);
}
int inverse(int a) {
    return pww(a, MOD - 2);
}
int pw[maxn];
int val;
int lazy[4 * maxn], tree[4 * maxn];
int doit(int a, int b, int diff) {
    return (a * pw[diff] % MOD + b) % MOD;
}
int some(int l) {
    int cur = pw[l] - 1 + MOD;
    if (cur >= MOD)cur -= MOD;
    cur *= val;
    cur %= MOD;
    return cur;
}
void divide(int index, int l, int r) {
    //dddddddddddd
    tree[index] = (lazy[index] * some(r - l + 1) % MOD);
    if (l != r) {
        lazy[2 * index] = lazy[index];
        lazy[2 * index + 1] = lazy[index];
    }
    lazy[index] = 0;
}
int queryTree(int start, int end, int l, int r, int index = 1) {
    if (lazy[index] != 0) divide(index, start, end);
    if (r < start or l > end)return 0;
    if (l <= start and r >= end)return tree[index];
    int mid = start + end >> 1;
    return doit(queryTree(start, mid, l, r, 2 * index), queryTree(mid + 1, end, l, r, 2 * index + 1), end - mid);
}
void update(int start, int end, int l, int r, int value, int index) {
    if (lazy[index] != 0) divide(index, start, end);
    if (r < start or l > end)return;
    if (l <= start and r >= end) {
        lazy[index] = value;
        divide(index, start, end);
        return;
    }
    int mid = start + end >> 1;
    update(start, mid, l, r, value, 2 * index);
    update(mid + 1, end, l, r, value, 2 * index + 1);
    tree[index] = doit(tree[2 * index], tree[2 * index + 1], end - mid);
}
void solve() {
    pw[0] = 1;
    for (int i = 1; i < maxn; i++) {
        pw[i] = pw[i - 1] * 10 % MOD;
    }
    val = inverse(9);
    int n, q;
    cin >> n >> q;

    for (int i = 0; i < n; i++)update(0, n - 1, i, i, 1, 1);
//    cout << tree[1] << endl;
    for (int i = 0; i < q; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        update(0, n - 1, l - 1, r - 1, d, 1);
        cout << tree[1] << endl;
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 13380
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
const ll mod = 1e9 + 7;
ll powmod(ll a, ll b) { ll res=1; a%=mod; assert(b>=0); for(;b;b>>=1) { if(b&1) res=res*a%mod; a=a*a%mod; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }

int main() {
	int t;
	// cin >> t;
    t = 1;

	while(t--) {
		int n;
		cin >> n;
        
        vector<ll> arr(n);
        for(auto &x: arr)
            cin >> x;
        
        sort(arr.rbegin(), arr.rend());
        
        int indx = 0, cnt = 0;
        ll res = arr[indx++];
        for(int i = 2; i < n; i++) {
            res += arr[indx];
            if ((++cnt) % 2 == 0)
                ++indx;
        }
        
        cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 4836
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,q = LI()
    stx = [LI() for _ in range(n)]
    da = [I() for _ in range(q)]

    q = []
    for s,t,x in stx:
        sx = s - x
        tx = t - x - 1
        heapq.heappush(q, (sx, x, tx))

    t = []
    cx = inf
    ctx = inf
    c = 0
    while len(q):
        sx, x, tx = heapq.heappop(q)
        # print("x", sx,x,tx)
        # print("q", q)
        # print("t", t)
        if sx > ctx:
            t.append((sx-1, cx))
            cx = x
            ctx = tx
        elif cx > x:
            if ctx > tx:
                heapq.heappush(q, (tx+1, cx, ctx))
            t.append((sx-1, cx))
            cx = x
            ctx = tx
        elif tx > ctx:
            heapq.heappush(q, (ctx+1, x, tx))

    t.append((inf, inf))
    # print("t", t)

    r = []
    for d in da:
        i = bisect.bisect_right(t, (d, -1))
        # print("d",d,i,t[i])
        u = t[i][1]
        if u == inf:
            r.append(-1)
        else:
            r.append(u)

    return JA(r, "\n")

print(main())





Measured memory_bytes: 129664
n, k = gets.chomp.split.map(&:to_i)
c = [0] * 100004
n.times {
  a, b = gets.chomp.split.map(&:to_i)
  c[a] += b
}
sum = 0
(0..100004).each do |i|
  next if c[i] == 0
  sum += c[i]
  if sum >= k
    p i
    break
  end
end


Measured memory_bytes: 2556
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  ll n;
  cin>>n;
  ll arr[n];
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
  }
  ll min1=arr[0],x=1;
  for(int i=1;i<n;i++)
  {
      if(min1>arr[i]){
          x++;
      }
      min1=min(arr[i],min1);
  }
  cout<<x;
  
}

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


int A[200100];

int main(){
	int n,m,a,b;
	cin >> n >> m;
	for(int i=0;i<m;i++){
		cin >> a >> b;
		A[a]++,A[b]++;
	}
	
	bool ok=false;
	for(int i=0;i<=n;i++){
		if(A[i]%2) ok=true;
	}
	
	if(ok) cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
   int A,B;
   cin>>A>>B;
   if(1<=A && A<=9 && 1<=B && B<=9){
       int ans=A*B;
       cout<<ans<<endl;
   }else
   cout<<"-1"<<endl;
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

template<typename A,typename B> inline void chmin(A &a,B b){if(a>b) a=b;}
template<typename A,typename B> inline void chmax(A &a,B b){if(a<b) a=b;}

int dy[]={-1,0,1,0};
int dx[]={0,-1,0,1};
//-----------------------------------------------------------------------

int w,h;
char M[25][25];

int dfs(int y,int x)
{
    int res=1;
    M[y][x]='#';
    REP(i,4){
        int ny=y+dy[i],nx=x+dx[i];
        if(0<=ny && ny<h && 0<=nx && nx<w && M[ny][nx]=='.'){
            res+=dfs(ny,nx);
        }
    }
    return res;
}
int main()
{   
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(cin>>w>>h,w|h)
    {   
        REP(i,h) cin>>M[i];
        REP(i,h) REP(j,w){
            if(M[i][j]=='@'){
                cout<<dfs(i,j)<<endl;
                i=h,j=w;
            }
        }
    }
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
#define fi first
#define se second
#define mod 1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
ll dp[100005];
ll n;
ll modexp(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b%2)
		return (a*modexp((a*a)%mod,b/2))%mod;
	else
		return modexp((a*a)%mod,b/2);
}
ll func(ll k)
{
	if(dp[k]!=-1)
		return dp[k];
	ll i,d,res,ans=0,sum;
	for(i=2;i<=k;i++)
	{
		d=k/i;
		res=func(d);
		ans=(ans+res)%mod;
	}
	sum=(modexp(k,n)-ans+mod)%mod;
	dp[k]=sum;
	return sum;
}
int main()
{
	ios;
	ll k,i,d,res,sum=0,ans=0,tot;
	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	for(i=2;i<=k;i++)
	{
		d=k/i;
		res=func(d);
		ans=(ans+res)%mod;
		res=(res*i)%mod;
		sum=(sum+res)%mod;
	}
	tot=modexp(k,n);
	sum=(sum+(tot-ans+mod)%mod)%mod;
	cout<<sum<<endl;
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int N, K; cin >> N >> K;
	vector<int> d(K);
	bool has[101];

	REP(i,N) has[i] = false;

	REP(i, K){
		cin >> d[i];
		REP(j, d[i]){
			int A; cin >> A;
			has[A-1] = true;
		}
	}


	int ans = 0;
	REP(i,N) if(!has[i]) ans++;

	cout << ans << endl;


	return 0;

}


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

#define GYOU_MAX 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define s_pri(str) printf("%s\n",str);
#define PRINT(str) printf(#str "\n")
#define v_pri(val) printf("%d\n",val);
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define pi acos(-1.0)
#define sca(x) scanf("%d",&x);

typedef long long int ll;

/*
puts("aa");
//*/



/*/*仮の値として、最初は1以外すべて素数とみなしておく*/
//erastutotenesu
	/*篩にかけて、非素数のprime[]を0にしていく*/
	//素数とその素数の倍数を消していく
	//5*7のときもう消してあるから7*5はやる必要がなく　7*7から始めればよい


int main(void) {

	char SA[101], SB[101], SC[101];
	scanf("%s %s %s", SA, SB, SC);

	//自分のターン　strlen>=1 先頭捨てる　捨てたカードと同じ人のターン
	//カードがないかつ次が自分のターン　勝利

	char S_A[101], S_B[101], S_C[101];
	
	strcpy(S_A,SA), strcpy(S_B, SB), strcpy(S_C, SC);

	int flag;
	flag = 1;

	for(;;) {

		

		if (flag==1) {
			if (S_A[0] == 'a') {
				flag = 1;
			}
			else if (S_A[0] == 'b') {
				flag = 2;
			}
			else {
				flag = 3;
			}
			strcpy(S_A, &S_A[1]);
		}
		else if (flag==2) {
			if (S_B[0] == 'a') {
				flag = 1;
			}
			else if (S_B[0] == 'b') {
				flag = 2;
			}
			else {
				flag = 3;
			}
			strcpy(S_B, &S_B[1]);
		}
		else if(flag==3) {
			if (S_C[0] == 'a') {
				flag = 1;
			}
			else if (S_C[0] == 'b') {
				flag = 2;
			}
			else {
				flag = 3;
			}
			strcpy(S_C, &S_C[1]);
		}
		//printf("%d %s %s %s\n",flag, S_A, S_B, S_C);

		if (strlen(S_A) == 0&&flag==1 ) {
			printf("A\n");
			break;
		}
		else if (strlen(S_B) == 0&&flag==2) {
			printf("B\n");
			break;
		}
		else if(strlen(S_C) == 0&&flag==3) {
			printf("C\n");
			break;
		}
	}



	
	return 0;
}


Measured memory_bytes: 128
def divisor(m):
    cnt = 2
    for i in range(3, m, 2):
        if m % i == 0:
            cnt += 1
    return cnt

n = int(input())
if n < 105:
    print(0)
elif n == 105:
    print(1)
else:
    res = 1
    for i in range(107, n+1, 2):
        if divisor(i) == 8:
            res += 1
    print(res)


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

int main() {
  int X, Y;
  cin >> X >> Y;

  for (int a = 0; a <= 100; a++) {
    int b = X - a;
    if (b<0) continue;
    if (2*a+4*b==Y) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3624
// Problem : B - String Palindrome
// Contest : AtCoder - AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define mi map<int,int>
#define ml map<ll,ll>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define MAX 4294967295
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MAXN 15000005
#define inf 1e10
#define PI acos(-1.0)
#define int long long

string s;

bool palindrome(string a){
    int n = sz(a);
    int i = 0, j = n-1;
    while(i<j){
        if(a[i] != a[j]) return 0;
        i++; j--;
    }
    return 1;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    cin>>s;
    int n = sz(s);
    string s1 = s.substr(0,n/2);
    string s2 = s.substr((n+1)/2, n/2);
    if(palindrome(s) && palindrome(s1) && palindrome(s2)) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
ans=0
if n==k:
    print(0)
    exit()
elif n>k:
    if n%k==0:
        print(0)
        exit()
    else:
        ans+=n%k
else:
    ans+=n


while True:
    a=abs(ans-k)
    if a>=ans:
        print(ans)
        exit()
    else:
        ans=a

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();
        long cdDt = b/lcm(c,d);
        long cDt = b/c;
        long dDt = b/d;
        long ansT = b-cDt-dDt+cdDt;
        long cdDa = (a-1)/lcm(c,d);
        long cDa = (a-1)/c;
        long dDa = (a-1)/d;
        long ansA = a-1-cDa-dDa+cdDa;
        System.out.println(ansT-ansA);
    }
    static long gcd(long x,long y){
        if (y==0)return x;
        else return gcd(y,x%y);
    }
    static long lcm(long x,long y){
        return x/gcd(x,y)*y;
    }
}


Measured memory_bytes: 35696
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
using namespace std;

int n;
vector<vector<int> >v;
const int MX = 1e5 + 5;
int dp[MX][4];

int solve(int curr, int prev){
    if(curr == n + 1) return 0;
    if(dp[curr][prev] != -1) return dp[curr][prev];
    int ans = INT_MIN;
    for(int i = 1 ; i <= 3 ; i++){
        if(i != prev){
            ans = max(ans, solve(curr + 1, i) + v[curr][i]);
        }
    }
    return dp[curr][prev] = ans;
}

int32_t main()
{
    cin>>n;
    v.resize(n+1);
    memset(dp, -1, sizeof dp);
    for(int i = 1 ; i <= n ; i++){
        v[i].resize(4);
        for(int j = 1 ; j <= 3 ; j++) cin>>v[i][j];
    }
    cout<<solve(1,0);
    return 0;
}


Measured memory_bytes: 19520
//0022 Maximum Sum Sequece

//2<=n<=5000ÂÌñ©çA×Ú·éÌaÌÅålð¦æ
//È¨AÌlÍ-10`10ÌÍÍÅ é
//KÉâÁ½ç°i(1¨n-1){i*(n-i)}ñÅ]TÅlÞ©
//Æè ¦¸Ag¤ñÌÉV½ÉÁíÁ½àÌð«µÄAÁ¦éàÌðø­ûjÅ¢¢©


#include<iostream>
#include<algorithm>
#include<numeric>
#include<climits>
using namespace std;

int main(void)
{
	const int N = 5000;
	int n;
	while(cin >> n, n)
	{
		int i, j;
		int a[N];
		int sum, max_sum = INT_MIN;

		for(i = 0; i < n; i++)
			cin >> a[i];

		//iÂÌðg¤
		for(i = 1; i <= n; i++)
		{
			//Ü¸ÍAÜÆÜÁÄg¤ªÌaðvZµÄ¨­
			sum = accumulate(a, a+i, 0);
			max_sum = max(sum, max_sum);

			for(j = 0; j+i < n; j++)
			{
				//ÌÂðg¢Ü·
				sum -= a[j];
				sum += a[j+i];
				max_sum = max(max_sum, sum);
			}
		}

		cout << max_sum << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){
  ll N; cin >> N;
  ll A[N];
  rep(i, N) cin >> A[i];
  ll ans = 1;
  ll wa = 0;
  sort(A, A+N);
  rep(i, N-1){
    wa += A[i];
    if (A[i+1] <= 2*wa) ans++;
    else ans = 1;
  }
  cout << ans << endl;
}
 

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
int A;
  for(int i=1;i<=109900;i++){
    A+=a;
    if(A%b==c) {
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;
  return 0;
}

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

void Bubble_Sort(int A[], int N) {
  int flag = 1, count = 0;

  while (flag) {
    flag = 0;

    for (int i = N - 1; i > 0; i--) {
        if (A[i] < A[i - 1]) {
          swap(A[i], A[i - 1]);
          flag = 1;
          count ++;
        }
    }
  }

  for (int k = 0; k < N; k++) {
  cout << A[k];
  if (k != N - 1) cout << " ";
  }
  cout << endl << count << endl;

}

int main() {
  int n, A[100];

  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];

  Bubble_Sort(A, n);

  return 0;
}



Measured memory_bytes: 3068
s = str(input())
k = int(input())

def main(s, k):
  separation = []
  tmp = ""
  for x in range(len(s)-1):
    tmp += s[x]
    if s[x] == s[x+1]:
      if tmp == "":
        tmp += s[x]
    else:
      separation.append(tmp)
      tmp = ""
  tmp += s[-1]
  separation.append(tmp)

  total = 0

  if len(separation) == 1:
    if (len(separation[0]) == 1):
      return k//2
    else:
      return (len(separation[0])*k)//2

  if (s[0] == s[-1]) and k>1 and len(separation)>1:
    a = len(separation[0])//2
    b = len(separation[-1])//2
    total += a
    total += b
    separation[0] += separation[-1]
    a = separation[0]
    c = (len(a)//2)*(k-1)
    total += c
    separation = separation[1:-1]

  # print(separation)

  for x in separation:
    total += (len(x)//2)*k

  return total

print(main(s,k))

Measured memory_bytes: 3064
#include<stdio.h>

#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

void maxHeapify(int i){
    int l, r, largest;
    l=2*i;
    r=l+1;

    if(l <= H && A[l] > A[i]){
        largest=l;
    }
    else{
        largest=i;
    }
    if(r<=H && A[r] > A[largest]){
        largest=r;
    }
    if(largest!=i){
        int temp;
        temp=A[i];
        A[i]=A[largest];
        A[largest]=temp;
        maxHeapify(largest);
    }
}

int extract(){
    int maxv;
    if(H<1){
        return -INFTY;
    }
    maxv=A[1];
    A[1]=A[H--];
    maxHeapify(1);

    return maxv;
}

void increaseKey(int i, int key){
    if(key<A[i]){
        return;
    }
    A[i]=key;
    while(i>1 && A[i/2]<A[i]){
        int temp;
        temp=A[i];
        A[i]=A[i/2];
        A[i/2]=temp;
        i=i/2;
    }
}

void insert(int key){
    H++;
    A[H]=-INFTY;
    increaseKey(H, key);
}


int main(void){
    int key;
    char com[10];

    while(1){
        scanf("%s", com);
        if(com[0]=='e' && com[1]=='n'){
            break;
        }
        if(com[0]=='i'){
            scanf("%d", &key);
            insert(key);

        }else{
            printf("%d\n", extract());
        }
    }
    

    return 0;
}



Measured memory_bytes: 5760
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

//https://github.com/atcoder-live/library/blob/master/mint.cpp
struct mint {
  LL x; 
  mint(LL x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(LL t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
struct combination {
  vector<mint> fact, ifact;//factに階乗を計算、ifactはその各々に対する逆元
  combination(LL n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (LL i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (LL i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(LL n,LL k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

LL N;

mint ans;

void solve(){
	combination c(N+1);
	vector<mint> pow_10(N+1,1);
	vector<mint> pow_8(N+1,1);
	for(int i=0;i<N;i++){
		pow_10[i+1] = pow_10[i]*mint(10);
		pow_8[i+1] = pow_8[i]*mint(8);
	}

	//全体から条件に合わないものを引く方針
	ans = pow_10[N] - pow_8[N];
	for(int i=1;i<=N;i++){
		ans -= mint(2)*c(N,i)*pow_8[N-i];
	}
}
 
int main(){
	cin >> N;
 
    solve();

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

Measured memory_bytes: 33912
import java.util.*;class Main{public static void main(String[]r){Scanner s=new Scanner(System.in);int n=s.nextInt(),i=n,m=s.nextInt(),b=999999999;int[]a=new int[n];for(;i>0;)a[--i]=s.nextInt();Arrays.sort(a);for(;i+m-1<n;i++)b=Math.min(b,a[i+m-1]-a[i]);System.out.print(b);}}

Measured memory_bytes: 50440
#include<cstdio>
#include<map>
#define int long long
#define RI register int
#define CI const int&
using namespace std;
const int N=100005;
int n,m,l; char s[N],t[N]; map <int,char> res;
inline int gcd(CI n,CI m)
{
	return m?gcd(m,n%m):n;
}
signed main()
{
	RI i; scanf("%lld%lld%s%s",&n,&m,s+1,t+1); l=n*m/gcd(n,m);
	for (i=1;i<=n;++i) res[(i-1)*(l/n)+1]=s[i];
	for (i=1;i<=m;++i) if (res.count((i-1)*(l/m)+1)&&res[(i-1)*(l/m)+1]!=t[i])
	return puts("-1"),0; return printf("%lld",l),0;
}

Measured memory_bytes: 9076
#include <iostream>

#include <algorithm>

using std::cin;
using std::cout;
using std::endl;

using std::min;

static int const MODULO = 1e9 + 7;

static long
sub(long a, long b)
{
  return (a - b + MODULO) % MODULO;
}

static long
mul(long a, long b)
{
  return (a * b) % MODULO;
}

static long
pow(long a, long b)
{
  if (b == 0)
  {
    return 1;
  }
  if (b == 1)
  {
    return a;
  }
  long half = pow(a, b / 2);
  long half2 = mul(half, half);
  return b % 2 == 0 ? half2 : mul(half2, a);
}

// To use Fermat's little theorem, assume that MODULO is prime numer.
static long
div(long a, long b)
{
  return mul(a, pow(b, MODULO - 2));
}

static long
combination(long a, long b)
{
  if (a < b)
  {
    return 0;
  }
  if (a == b)
  {
    return 1;
  }
  long n = min(b, a - b);
  long num = 1;
  long denom = 1;
  for (long i = 0; i < n; i++)
  {
    num = mul(num, a - i);
    denom = mul(denom, n - i);
  }
  return div(num, denom);
}

static long
solve(int n, int a, int b)
{
  return sub(sub(sub(pow(2, n), 1), combination(n, a)), combination(n, b));
}

int
main()
{
  int n, a, b;
  cin >> n >> a >> b;
  cout << solve(n, a, b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

int N;
vector<int> G[100010];
int dp1[100010], dp2[100010];

void dfs(int v, int pv) {
  dp1[v] = dp2[v] = 1;
  for (int u : G[v]) {
    if (u == pv) continue;
    dfs(u, v);
    (dp1[v] *= dp2[u]) %= MOD;
    (dp2[v] *= (dp1[u] + dp2[u]) % MOD) %= MOD;
  }
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  REP(i, N-1) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    G[x].EB(y);
    G[y].EB(x);
  }
  dfs(0, -1);
  cout << (dp1[0] + dp2[0]) % MOD << endl;

  return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

	ll n, k;
	cin >> n >> k;
	ll a[100005];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	ll res = 0, curr = 0;
	for(int i = 60; i >= 0; i--){
		ll o = 0, z = 0;
		for(int j = 0; j < n; j++){
			if((1LL << i) & a[j]) o++;
			else z++;
		}
		if(z > o) if(curr + (1LL << i) <= k) curr += (1LL << i);
	}
	for(int i = 0; i < n; i++){
		res += (a[i] ^ curr);
	}
	cout << res;
}

/*
7 6
0 0 0 0 4 6 7

*/

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

int main(void){
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int cnt = 0;
  for(int i=0;i<=a;++i){
    for(int j=0;j<=b;++j){
      for(int k=0;k<=c;++k){
        int sum = 500*i + 100*j + 50*k;
        if(sum==x) ++cnt;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;
    int k[10000];
    while (true) {
        int zeros = 0;
        int ones = 0;
        cin >> n;
        if (n == 0) {
            return 0;
        }
        for (int i = 0; i < n; ++i) {
            cin >> k[i];
            if (k[i] == 0) {
                ++zeros;
            } else if (k[i] == 1) {
                ++ones;
            }
        }
        if (n - zeros - ones == 0) {
            cout << "NA" << endl;
        } else {
            cout << n - zeros + 1 << endl;
        }
    }
}

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

using namespace std;

#define print(s) cout << (s) << endl;
#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n) 
#define all(a) a.begin(), (a).end()
#define inf = 9876543210
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    //nは自分の年齢N
    cin >> n;
    if (n==1){
        print("Hello World");
    }
    if (n==2){
        int a, b;
        //a,bは足し算をする整数
        cin >> a >> b;
        print(a+b);
    }
}

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

int main(){
  string s;
  cin >> s;
  vector<string> fore(3);
  fore[0]="Sunny";
  fore[1]="Cloudy";
  fore[2]="Rainy";

  for(int i=0;i<3;i++) {
    if(fore[i]==s) cout << fore[(i+1)%3] << endl;
  }
  return 0;
}


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

int main(){
  int N;
  cin>>N;
  bool frag=false;
  for(int i=0;i<N;++i){
    int64_t a;
    cin>>a;
    if(a%2!=0) frag=true;
  }
  if(frag) cout<<"first"<<endl;
  else cout<<"second"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)

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

  if(D==22) cout << "Christmas Eve Eve Eve" << endl;

  else if(D==23) cout << "Christmas Eve Eve" << endl;

  else if(D==24) cout << "Christmas Eve" << endl;

  else if(D==25) cout << "Christmas" << endl;

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  int rmin = 2e9, lmax = 0;
  vector<pair<int, int>> lr;
  rep(i, n) {
    int l, r;
    cin >> l >> r;
    r++;
    lr.emplace_back(l, r);
    amin(rmin, r);
    amax(lmax, l);
  }
  int ans = 0;
  {
    int sum = 0;
    sum += max(rmin - lmax, 0);
    int ma = 0;
    rep(i, n) {
      int l, r;
      tie(l, r) = lr[i];
      amax(ma, r - l);
    }
    sum += ma;
    ans = sum;
  }
  {
    sort(all(lr));
    reverse(all(lr));
    int rr = lr[0].second;
    reps(i, n - 1) {
      int l, r;
      tie(l, r) = lr[i];
      amax(ans, max(rmin - l, 0) + max(rr - lmax, 0));
      amin(rr, r);
    }
  }
  cout << ans << endl;
}


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

using namespace std;


int main()
{
    long long t,b,c,d,n,m,i,x,y,j;
    cin>>n>>m;
    c=0;
    int a[6];

    for(i=n;i<=m;i++)
    {
        x=i;
        j=0;
        while(x)
        {
            a[j++]=x%10;
            x/=10;

        }
        if(a[0]==a[4]&&a[1]==a[3])
        {
            c++;
        }

    }
    cout<<c;
    return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

// dp[r][c]: [r][c]への経路の数
vector<vector<ll>> dp(1010, vector<ll>(1010, 0));
vector<vector<char>> a(1010, vector<char>(1010));
int main()
{
    int H, W;
    cin >> H >> W;
    for (int row = 0; row < H; row++) {
        for (int col = 0; col < W; col++) {
            cin >> a[row][col];
        }
    }

    dp[0][0] = 1;

    for (int row = 0; row < H; row++) {
        for (int col = 0; col < W; col++) {
            if (a[row][col] == '#')
                continue;
            dp[row + 1][col] += dp[row][col];
            dp[row + 1][col] %= MOD;
            dp[row][col + 1] += dp[row][col];
            dp[row][col + 1] %= MOD;
        }
    }
    cout << dp[H - 1][W - 1] << endl;

    return 0;
}

Measured memory_bytes: 12676
a=list(map(int,input().split()))
lst=[0,0]
for i in range(3):
    if a[i]==5:
        lst[0]+=1
    elif a[i]==7:
        lst[1]+=1
if lst[0]==2 and lst[1]==1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 61772
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 998244353
INF = float("inf")

sys.setrecursionlimit(1000000)

def main():
    N, K = LI()
    LR = LIR(K)
    cumsum = [0] * (N+2)

    dp = [0] * (N+1)
    dp[N] = 1
    cumsum[N] = 1

    for i in range(N-1, 0, -1):
        for l, r in LR:
            dp[i] = (dp[i] + cumsum[min(i + l, N+1)] - cumsum[min(i + r + 1, N+1)]) % MOD

        cumsum[i] = (cumsum[i] + dp[i] + cumsum[i+1]) % MOD

    print(dp[1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 76444
<?php
$n = trim(fgets(STDIN));
$h = explode(" ",trim(fgets(STDIN)));
 
for($i=$n-1; $i>0; $i--){
    if($h[$i] < $h[$i-1]){
        if(abs($h[$i]-$h[$i-1]) >= 2){
            echo "No";
            exit;
        }else{
            $h[$i-1] = $h[$i-1] -1;
        }
    }
}
 
echo "Yes";
 
?>

Measured memory_bytes: 22076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  string S;
  cin >> S;
  ll N = S.size();

  cout << string(N, 'x') << endl;
}

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

int main(){
    long long int N,K;
    scanf("%lld",&N);
    scanf("%lld",&K);
    long long int mod = N%K;
    if(K-mod>mod){
        printf("%lld",mod);
    }else{
        printf("%lld",K-mod);
    }
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main()
{
    int n,p[20],ans = 0;
    scanf("%d",&n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d",&p[i]);
    }
    
    for (int i = 0; i < n - 2; i++)
    {
        if (((p[i] > p[i + 1]) && (p[i + 1] > p[i + 2])) || ((p[i] < p[i + 1]) && (p[i + 1] < p[i + 2])))
        {
            ans++;
        }
        
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cmath>
#include <climits>
#include <map>
#include <queue>
#include <functional>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)
#define rep1(i, n) for(int i = 1; i <= (int) n; i++)
#define all(v) v.begin(),v.end()
const ll mod = 1e9+7;

int main() {
    ll n,W;
    cin >> n >> W;
    vector<ll> w(n),v(n);
    rep(i,n) {
        cin >> w[i] >> v[i];
    }
    // i番目までの品物の中から重さがWを超えないように選んだときの，価値の総和の最大値
    // dp[0] := 品物の選択を全く検証していない状態
    // dp[n] := n個の品物について選択を検証し終えた状態
    vector<vector<ll>> dp(n+1, vector<ll> (W+1)); 
    rep(i,n) {
        for (int j = 0; j <= W; j++) {
            if (j-w[i] >= 0) {
                // max{品物を選ばない, 重さjを超えないように品物を選ぶ}
                // 重さjを超えないように品物iを選ぶ == 重さj-w[i]を超えない状態の価値+品物iの価値v[i]
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
            } else {
                // 品物を選ばない
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}

Measured memory_bytes: 83104
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;

int main() {
	cin >> N;
	map<string, ll>map;
	for (int i = 0; i < N; i++) {
		cin >> S;
		map[S]++;
	}
	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> S;
		map[S]--;
	}
	for (auto x : map) {
		ans = max(ans, x.second);
	}
	cout << ans << endl;
}

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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp1, tmp2;

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) {
        ll a, b;
        cin >> a >> b;
        if(a==b) {
            cout << 2*a-2 << endl;
            continue;
        }
        tmp1 = a*b;
        tmp2 = sqrt(tmp1);
        tmp1 = tmp2;
        if(tmp1*(tmp1+1)<a*b) tmp1++;
        ans = 2*tmp2-1;
        if(tmp1!=tmp2) ans++;
        if(a<=tmp2) ans--;
        if(b<=tmp2) ans--;
        if(tmp1*tmp2==a*b) ans--;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>

#define Rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())

#define eb emplace_back
#define dbg(x) cout<<#x" = "<<((x))<<endl
#define fs first
#define sc second
     
using namespace std;
     
     
typedef long long ll;
typedef pair<ll, ll> P;
     
     
int main(){
  ll N;

  cin >> N;

#ifdef DEBUG
  cout << "N=" << N << endl;
#endif

  int bs[N + 1];
  bs[0] = 0;
  for(int i = 1; i <= N; ++i){
    cin >> bs[i];
    //cout << "dbg: " << bs[i] << endl;
  }

  for(int i = N; i >= 2; --i){
    int sqrti = floor(sqrt(i));
    for(int j = 1; j <= sqrti; ++j){
      if(i % j == 0){
	bs[j] ^= bs[i];
	if(j != 1 && j*j != i){
	  bs[i/j] ^= bs[i];
	}
      }
    }

    // dbg(bs[1]);
    // dbg(bs[2]);
    // dbg(bs[3]);
    // cout << "---" << endl;
  }

  vector<int> lst;
  for(int i = 1; i <= N; ++i){
    if(bs[i] == 1) lst.eb(i);
  }

  cout << lst.size() << endl;
  for(size_t i = 0; i < lst.size(); ++i){
    cout << lst[i];
    if(i == lst.size() - 1) cout << endl;
    else cout << " ";
  }
  
  return 0;
}


Measured memory_bytes: 2424