akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	static final int P = 1_000_000_007;

	int[] getSums(int from, int to, int c) {
		int[] a = new int[to - from + 1];
		Arrays.fill(a, 1);

		int[] ret = new int[c + 1];
		for (int i = 0; i <= c; i++) {
			if (i != 0) {
				for (int j = from; j <= to; j++) {
					a[j - from] = (int) ((long) a[j - from] * j % P);
				}
			}

			for (int j = 0; j <= to - from; j++) {
				ret[i] = (ret[i] + a[j]) % P;
			}
		}
		return ret;
	}

	void solve() throws IOException {
		int n = nextInt();
		int c = nextInt();

		int[] dp = new int[c + 1];
		dp[0] = 1;

		int[] low = new int[n];
		int[] high = new int[n];

		for (int i = 0; i < n; i++) {
			low[i] = nextInt();
		}

		for (int i = 0; i < n; i++) {
			high[i] = nextInt();
		}

		for (int i = 0; i < n; i++) {
			int[] sums = getSums(low[i], high[i], c);
			
			int[] nxt = new int[c + 1];
			for (int from = 0; from <= c; from++) {
				for (int to = from; to <= c; to++) {
					nxt[to] += (int)((long)dp[from] * sums[to - from] % P);
					nxt[to] %= P;
				}
			}
			
			dp = nxt;
		}
		
		out.println(dp[c]);
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 11080
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり


N = I()
A = LI()
mod = 10**9+7

ans = sum(A)**2-sum(A[i]**2 for i in range(N))
ans %= mod
ans *= pow(2,mod-2,mod)
ans %= mod
print(ans)


Measured memory_bytes: 94276
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<math.h>
using namespace std;
 
 
int main() {
	long long a, b, c,k;
	long long d=0, e=0, f=0;
	cin >> a >> b >> c >> k;
	if (abs(a - b) >= pow(10, 18)) {
		cout << "Unfair" << endl;
	}

	else if (k % 2 == 1) {
		cout << b - a << endl;
	}
	else {
		cout << a - b << endl;
	}



	system("pause");
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    int a ;
    cin >> a ;

    map < string , int > h ;

    while ( a -- )
    {
        string s ;
        cin >> s ;

        h[s] ++ ;
    }

    cout << "AC x " << h["AC"] ; line ;
    cout << "WA x " << h["WA"] ; line ;
    cout << "TLE x " << h["TLE"] ; line ;
    cout << "RE x " << h["RE"] ; line ;
}

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

    for ( int i = 1 ; i <= t ; i ++ )
    {
        solve ( i ) ;
    }

    return 0;
}


Measured memory_bytes: 3632
V, E = map(int, input().split())

dp = [[float("inf")] * V for _ in range(V)]

for i in range(V):
    dp[i][i] = 0

for _ in range(E):
    s, t, d = map(int, input().split())
    dp[s][t] = d

for k in range(V):
    for i in range(V):
        for j in range(V):
            dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])
            if i == j and dp[i][i] < 0:
                print("NEGATIVE CYCLE")
                exit()

for i in range(V):
    ans = []
    for j in range(V):
        if dp[i][j] == float("inf"):
            ans.append("INF")
        else:
            ans.append(dp[i][j])
    print(*ans)



Measured memory_bytes: 6280
import sys
import math
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

A, B, H, M = map(int, readline().split())

ang_H = (360 / 12 * H) + (360 / 12 / 60 * M)
ang_M = (360 / 60 * M)

ang_between = max(ang_H, ang_M) - min(ang_H, ang_M)
cos = math.cos(math.radians(ang_between))
L = np.sqrt(pow(A, 2) + pow(B, 2) - (2 * A * B * cos))

print(L)


Measured memory_bytes: 27212
#include <stdio.h>
int main(void)
{
  int H,W,h,w;
  for ( ; ; )
  {
    scanf("%d %d",&H,&W);
    if (H == 0 && W == 0)
    {
      break;
    }
    for (h = 1; h <= H; h++)
    {
      if (h == 1 || h == H)
      {
        for (w = 1; w <= W; w++)
        {
          printf("#");
          if (w == W)
          {
            printf("\n");
          }
          if (w == W && h == H)
          {
            printf("\n");
          }
        }
      }else{
        for (w = 1; w <= W; w++)
        {
          if (w == 1 || w == W)
          {
            printf ("#");
            if (w == W)
            {
              printf("\n");
            }
          }else{
            printf(".");
          }
        }
      }
    }
  }
  return 0;
}



Measured memory_bytes: 2540
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define gsort(arr) sort(arr, arr+n, greater<ll>()); 
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const ll inf=1e18+7;
const ll ANS=-(3e9+7);
vector <bool> chkprime(1000005,true);
vector <ll> prime;
//set<pair<ll, int>> st;
//set <ll, greater <ll> > st;
/*// l-r-index
pair< pair<int, int>, int> ramu[105];
inline bool cmp(const pair< pair<int, int>, int> &x, const pair< pair<int, int>, int> &y)
{
    if(x.ff.ss == y.ff.ss)
        return x.ff.ff<y.ff.ff;
    return x.ff.ss < y.ff.ss;
}*/
void SieveOfEratosthenes(int n)
{
    for(int i=2;i*i<=n;++i)
    {
        if(chkprime[i])
        {
            for(int j=i*i;j<=n;j+=i)
                chkprime[j]=false;
        }
    }
    for (int i=2; i<=n; i++)
    {
        if(chkprime[i])
            prime.pb(i);
    }
}

inline ll modpw(ll x, ll y, ll z)
{
    ll res=1;
    x=x%z;
    while(y)
    {
        if(y&1) res=(res*x)%z;
        x=(x*x)%z;
        y/=2;
    }
    return res;
}

ll gcd(ll a, ll b) 
{ 
    if(b == 0) 
        return a; 
    return gcd(b, a % b);  
} 
ll fact[100005];
void factorial(ll n)
{
    fact[1]=fact[0]=1;
    for(ll i=2;i<n;i++)
    {
        fact[i]=(fact[i-1]*i)%inf;
    }
}
ll mul(ll a,ll b)
{
  a=a%inf;
  return (a*b)%inf;
}
//
bool sort1(const pair<ll,ll> &a,const pair<ll,ll> &b) 
{ 
  if(a.ff==b.ff)
    return (a.ss<b.ss);
  return (a.ff<b.ff); 
}
bool sort2(const pair<ll,ll> &a,const pair<ll,ll> &b) 
{
  if(a.ss==b.ss)
    return (a.ff>b.ff); 
  return (a.ss > b.ss); 
} 
int main()
{
  int t;
  t=1;
  //cin>>t;
  while(t--)
  {
    ll arr[3];
    cin>>arr[0]>>arr[1]>>arr[2];
    sort(arr,arr+3);
    ll d1=arr[2]-arr[0],d2=arr[2]-arr[1];
    if(d1==0 && d2==0)
    {
      cout<<0<<endl;
      continue;
    }
    if(d2==0)
    {
      if(d1&1)
      {
        ll temp=d1/2;
        temp=temp+2;
        cout<<temp<<endl;
      }
      else
      {
        ll temp=d1/2;
        cout<<temp<<endl;
      }
      continue;
    }
    ll ans;
    if((d1-d2)%2==0)
    {
      ans=(d1-d2)/2 + d2;
      cout<<ans<<endl;
    }
    else
    {
      ans=(d1-d2)/2;
      ans+=d2+2;
      cout<<ans<<endl;
      /*if((d2%2)==0)
      {
        cout<<ans
      }*/

    }

    
  }
return 0;
}
/*
4
6 5 19 3
4 8 16 12 14 18
1 10 20 3
3
5 2 6 10
1 2 5 3 4
1 1 9 5
8*/

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

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

	    int A=gi();
	    int B=gi();
	    int C=gi();
	    int K=gi();
	    
	    while(K>0) {
	    	if(A>=B) {
	    		B=B*2;
	    	} else if(C<=B) {
	    		C=C*2;
	    	}
	    	K--;
	    }


	    if(A<B && B<C) {
	        System.out.println("Yes");
	    } else {
	    	System.out.println("No");
	    }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35572
#include<iostream>
#include<stdio.h>

using namespace std;
 
int main()
{
	int n,m,i,j,d[100][100],e[100],a[100];
	
	cin >> n >> m;
	
	for(i=0;i<n;i++){
		a[i]=0;
	}
	
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			cin >> d[i][j];
		}
	}
	
	for(j=0;j<m;j++){
		cin >> e[j];
	}
	
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			a[i]=a[i]+d[i][j]*e[j];
		}
	}
	
	for(i=0;i<n;i++){
		cout << a[i] << endl;
	}

    return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  if (n%1000==0){
    cout << 0;
    return 0;
  }
  else{
    int ans = (((n/1000)+1)*1000)-n;
    cout << ans;
    return 0;
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include    <algorithm>
#include <cmath>
#include <cstdio>
#include  <cstdlib>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <vector>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long lint;
#define SZ(x) ((int)(x).size())
int main()
{
	int p, q, r;
	int x1, x2;
	cin >> p >> q >> r;
	x1 = max(p, q);
	x2 = max(r, x1);
	cout << p+q+r-x2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define BITBOOL(x,a) (((x)>>(a))&1)
int main(){
  int A,B,M;
  cin >> A >> B >> M;
  vector<int> a_(A+5), b_(B+5); vector<pair<pair<int,int>,int>> X(M+5);int Ans = 0;;
  FOR(i,0,A) cin >> a_[i];
  FOR(i,0,B) cin >> b_[i];
  int a_min = 99999999, b_min=99999999;
  FOR(i,0,A) if(a_[i]<a_min) a_min = a_[i];
  FOR(i,0,B) if(b_[i]<b_min) b_min = b_[i];
  Ans = a_min + b_min;
  /*
  set<int> a_set, b_set;
  FOR(i,0,A) { if(a_[i]==a_min) a_set.insert(i);  }
  FOR(i,0,B) { if(b_[i]==a_min) b_set.insert(i);  }*/
  FOR(i,0,M) {cin >> X[i].first.first >> X[i].first.second >> X[i].second; X[i].first.first--; X[i].first.second--;}
  FOR(i,0,M){
    int yt = a_[ X[i].first.first ]+b_[ X[i].first.second ]-X[i].second;
    if( yt < Ans) Ans = yt;
  }
  cout << Ans << endl;
  return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	cin >> n;
	int m = n;
	int cnt = 0;
	bool flag = true;
	while (m >= 10) {
		if (m % 10 != 9) flag = false;
		m /= 10; cnt++;
	}
	cout << (flag ? m + cnt * 9 : m + cnt * 9 - 1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int ara[100005];
long long int iforward[100005];
//long long int iback[100005];
int main()
{
    long long int k,l,i,j,m,n,t,ans=0,sum=0,sum1=0,imin=10000000000000000;
    cin>>n>>k;
    for(i=0;i<n;i++)
        cin>>ara[i];
    iforward[n-1]=0;
    for(i=n-2;i>=0;i--){
    for(j=1;i+j<n&&j<=k;j++){
                     if(abs(ara[i]-ara[i+j])+iforward[i+j]<imin)
                     imin=abs(ara[i]-ara[i+j])+iforward[i+j];}
     iforward[i]=imin;
     imin=10000000000000000;
}
//for(i=0;i<n;i++)
cout<<iforward[0]<<endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    if(b-a<=0)
    {
        printf("delicious");
        return 0;
    }
    if(n>=b-a)
    {
        printf("safe");
        return 0;
    }
    if(b-a>n)
    {
        printf("dangerous");
        return 0;
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n; cin >> n;
	cout << n * n;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{

    string S, T, U;
    int A, B;
    cin>>S>>T>>A>>B>>U;
if(U == S){
        A= A-1;
    }
else if(U == T){
        B = B-1;
    }
cout<<A<<endl;
cout<<B<<endl;

    return 0;
}

Measured memory_bytes: 256
cnt = [0,0,0,0]
for i in range(3):
  a,b = map(int,input().split())
  for j in range(4):
    if a == j+1:
      cnt[j] += 1
    if b == j+1:
      cnt[j] += 1      

if max(cnt) < 3:
  print("YES")
else:
  print("NO")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
int n;
cin >> n;
set<string> st;
REP(i, n){
  string s;
  cin >> s;
  st.insert(s);
}

cout << st.size() << endl;
return 0;
}

Measured memory_bytes: 19248
def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))


from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
from heapq import *
import sys

# sys.setrecursionlimit(1000000)
INF = 10 ** 17
MOD = 1000000007

from fractions import *


def inverse(f):
    # return Fraction(f.denominator,f.numerator)
    return 1 / f


def combmod(n, k, mod=MOD):
    ret = 1
    for i in range(n - k + 1, n + 1):
        ret *= i
        ret %= mod

    for i in range(1, k + 1):
        ret *= pow(i, mod - 2, mod)
        ret %= mod

    return ret

MOD = 10 ** 9 + 7
def solve():
    n = getN()
    bit_array = [[0, 0] for i in range(61)]
    nums = getList()
    for num in nums:
        digit = 0
        while(digit < 61):
            if num % 2 == 0:
                bit_array[digit][0] += 1
            else:
                bit_array[digit][1] += 1
            digit += 1
            num //= 2


    # print(bit_array)
    ans = 0
    for i, tgt in enumerate(bit_array):
        ans += pow(2, i, MOD) * tgt[0] * tgt[1]
        ans %= MOD

    print(ans   )

def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    solve()

Measured memory_bytes: 123592
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,cur)               lower_bound(all(v),cur)-v.begin()
#define ub(v,cur)               upper_bound(all(v),cur)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
long long pows(long long a, long long b) {
  long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD){ return powm(a,m-2,m); }
int main()
{
fastIO
ll n,m,i,j,k,y,z,t,e,f,p,q,g,l,r,w,h,count1=0,prod=1,a,b,c,d,index,x1,x2,y1,y2,diff,ans=0,sum=0,sum1=0,sum2=0,flag=0,flag1=0,flag2=0;
string s,s1,s2;
cin>>a>>b;
cout<<a*b;
}


Measured memory_bytes: 3640
import java.util.Scanner;

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

        // === ans1 ===
//        System.out.println((int) Math.ceil((a + b) / 2));

        // === ans2 ===
        System.out.println((a + b + 1) / 2);

    }
}


Measured memory_bytes: 21972
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

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

		String str = sc.next();
		if( Character.isUpperCase( str.charAt( 0 ) ) ) {
			System.out.println("A");
		}
		else {
			System.out.println("a");
		}
	}

	private static class FastScanner {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

	}
}

Measured memory_bytes: 32656
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; k < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

int N;

void dfs(vi &U,vi &V, vi&W,v(bool) &visited, v(bool) &color,int n,bool isBK,v(vp) &L) {
  rep(i,sz(L[n])){
    int x = L[n][i].first;
    int d = L[n][i].second;
    if(!visited[x]) {
      visited[x] = true;
      if(d % 2 == 0) {
        color[x] = isBK;
        dfs(U,V,W,visited,color,x,isBK,L);
      } else {
        color[x] = !isBK;
        dfs(U,V,W,visited,color,x,!isBK,L);
      }
    }
  }
}

int allVisited(v(bool) &visited) {
  rep(i,N) {
    if(!visited[i] ) {
      return i;
    }
  }
  return -1;
}
  
int main() {
  cin >> N;
  vi U(N-1);
  vi V(N-1);
  vi W(N-1);
  v(vp) L(N);
  v(bool) visited(N,false);
  v(bool) color(N,-1);
  rep(i,N-1) {
    int a,b,c;
    cin >> a >> b >> c;
    U[i] = a-1;
    V[i] = b-1;
    W[i] = c;
    L[a-1].push_back(P(b-1,c));
    L[b-1].push_back(P(a-1,c));
  }
  visited[0] = true;
  color[0] = true;
  int x = 0;
  dfs(U,V,W,visited,color,0,true,L);
  
  while(allVisited(visited) != -1) {
    x = allVisited(visited);
    color[x] = true;
    dfs(U,V,W,visited,color,x,true,L);
  }
  rep(i,N) {
    if(color[i]) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
  }

}

Measured memory_bytes: 12800
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int ans = N/M;
        if(N%M>0){
            ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 22608
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main(){
	cin>>a>>b>>c;
	int t=c-a;
	if(c>=a){
		c-=a;
		a=0;
	}
	else
	{
		a-=c;
		c=0;
	}
	if(c>=b){
		c-=b;
		b=0;
	}
	else{
		b-=c;
		c=0;
	}
	cout<<a<<' '<<b;
	
	
	
}

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

int main()
{
	int s1,s2,d;
	char ch1,ch2;
    int rect=0,rhom=0;
	while(1){
		cin >> s1 >>ch1>> s2 >>ch2>> d;
		if(cin.eof()) break;
		
		if(s1*s1 + s2*s2 == d*d){
			rect++;
		}else if(s1==s2){
			rhom++;
		}
	}
	cout << rect <<endl << rhom << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    vector<bool> arr(10,false);
    int num;

    rep(i,4){
        cin >> num;
        if(num==1)arr[1]=true;
        if(num==9)arr[9]=true;
        if(num==7)arr[7]=true;
        if(num==4)arr[4]=true;
    }
    if(arr[1] && arr[9] && arr[7] && arr[4]){
        cout <<"YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    int cnt = 0;




    return 0;
}

Measured memory_bytes: 256
# -*- coding: UTF-8 -*-
i=int(raw_input())
n=map(int, raw_input().split())
ans=0
chk=10
#サンプルリスト
#n=[2,5,3,1,7,9,10,4,6,8]
#n=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
#リストの長さ、要素の個数分の繰り返し回数設定
for m in range(len(n)):
    for j in range(len(n)-1, m, -1):
        if n[j]<n[j-1]:
            n[j],n[j-1]=n[j-1],n[j]
            ans+=1
#        print ans
    if ans==chk: break
    chk=ans
print ' '.join(map(str,n))
print ans

Measured memory_bytes: 4228
import math

import sys
k = sys.stdin.readline()
k = int(k)
sum = 0
for x in range(1,k+1):
    for y in range(x,k+1):
        for z in range(y,k+1):
            if len(set([x,y,z])) is 1:
                sum = sum +math.gcd(math.gcd(x, y), math.gcd(y, z))
            elif len(set([x,y,z])) is 2:
                sum = sum + 3 * math.gcd(math.gcd(x, y), math.gcd(y, z))
            elif len(set([x,y,z])) is 3:
                sum = sum + 6* math.gcd(math.gcd(x, y), math.gcd(y, z))
print(sum)

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int a, b, c;
    string s, t;
    cin >> a >> b >> c;
    vi v;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v);
    if(v[2]==v[0]+v[1]) P("Yes");
    else P("No");

    return 0;
}



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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> arr(n);
	for(int& x : arr) cin >> x;
	int lo = n;
	int ans = 0;
	
	for(int i = 0; i < n; i++) {
		lo = min(lo, arr[i]);
		if(lo == arr[i]) {
			ans++;
		}
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
  ll n; cin >> n;
  string s = "";
  while(n > 0) {
      n--;
      s.push_back('a' + n%26);
      n /= 26;
  }
  reverse(all(s));
  cout << s << endl;
}


Measured memory_bytes: 3608
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int x = sc.nextInt();
    int c[] = new int[n];
    int a[][] = new int[n][m];
    
    for(int i = 0 ; i < n ; ++i){
      c[i] = sc.nextInt();
      for(int j = 0 ; j < m ; ++j){
        a[i][j] = sc.nextInt();
      }
    }
    int ans = 1000000000;
    
    for(int i = 1 ; i < (1<<n) ; ++i){
      int k[] = new int[m];
      int l = 0;
      for(int j = 0 ; j < n ; ++j){
        if((1&(i>>j))==1){
          l += c[j];
          for(int o = 0 ; o < m ; ++o){
            k[o] += a[j][o];
          }
        }
      }
      for(int j = 0 ; j < m ; ++j){
        if(k[j] < x) break;
        if(j == m-1) ans = Math.min(ans,l);
      }
    }
    if(ans == 1000000000) System.out.println(-1);
    else System.out.println(ans);
    
  }
}

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

using namespace std;

int main(){
	int a, b, k;
	cin >> a >> b >> k;
	for (int i = 0; i < k; i++) {
		if (i % 2 == 0)
		{
			if (a % 2 == 1) a--;
			int half = a / 2;
			a -= half;
			b += half;
		}
		else {
			if (b % 2 == 1) b--;
			int half = b / 2;
			b -= half;
			a += half;
		}
	}
	cout << a <<" "<< b << endl;
    return 0;
}

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

const int num = 100;

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

  ar = new int[n];

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

  for(int i=n-1;i>-1;--i){
    cout << ar[i];

    if(i != 0){
      cout << " ";
    }
  }

  cout << endl;

  delete[] ar;
}




Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
using namespace std;
 
int main(){
    int N,K;
    cin>>N>>K;
    int A[N];
    for(int i=0;i<N;++i)cin>>A[i];

    int B[N+1],kind=0;
    for(int i=0;i<=N;++i)B[i]=0;
    for(int i=0;i<N;++i){
        B[A[i]]++;
    }
    for(int i=1;i<=N;i++)if(B[i])kind++;
    sort(B,B+N+1);
  
    int s=0,ans=0;
    while(s<kind-K){
        for(int i=0;i<=N;i++){
            if(B[i]){
               ans+=B[i];
               s++;
               if(s>=kind-K)break;
             }
       }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


ll n, W, V = 0;
ll w[110], v[110];

int main() {
    cin >> n >> W;
    rep(i, n) {
        cin >> w[i] >> v[i];
        V += v[i];
    }
    vector<vector<ll>> dp(n+1, vector<ll>(V+1, 1000100000));
    dp[0][0] = 0;
    rep(i, n) {
        rep(j, V+1) {
            if (j >= v[i])
                dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]] + w[i]);
            else
                dp[i+1][j] = min(dp[i][j], dp[i+1][j]);
        }
    }
    ll ans = -1;
    rep(i, V+1) {
        if (dp[n][i] <= W) {
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 80256
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if (a<b){
        cout<<"a < b"<<endl;
    }else if (a>b){
        cout<<"a > b"<<endl;
    }else{
        cout<<"a == b"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3068
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
c=0
while c<m:
  d=a[0]/2
  for i in range(n):
    if a[0]==0:
      c=m
    if a[i]>d:
      a[i]//=2
      c+=1
      if c==m:
        break  
    else:
      a.sort(reverse=True)
      break
print(sum(a))

Measured memory_bytes: 20004
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    long long n;
    long long k;
    cin >> n >> k;
    vector<long long> a(100010, 0);
 
    
 
    for(long long i = 0; i < n; i++){
        long long aa, bb; cin >> aa >> bb;
        a[aa] += bb;
    }

    long long i = 1;
    while(1){
        k -= a[i];
        if(k <= 0){
            break;
        }
        i++;
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
W = list(map(int,input().split()))
ans = sum(W)
for t in range(1,100):
  x = 0
  y = 0
  for i in range(n):
    if i<=t:
      x+=W[i]
    else:
      y+=W[i]
  ans = min(ans,abs(x-y))
print(ans)


Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1000000000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i > 0; i--)

int main() {
    string S;
    cin >> S;
    rep(i,S.size()){
        if(i%2==0){
            if(S[i]=='L'){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(S[i]=='R'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
using namespace std;
typedef long long ll;
static const int MOD = 10000007;

int N;


int main() {
  int a,b;
  cin >> a >> b;
  int kuchi = 1;
  int tap = 0;
  while (kuchi < b) {
    kuchi += a-1;
    tap++;
  }
  cout << tap << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
#define SZ(a) ((int)a.size())
typedef long long ll;

int N, a[100100], b[100100], c[100100], v[100100];
ll ans, cur;

int main () {
        scanf("%d", &N);
        fo(i, 0, N) scanf("%d", &a[i]);
        fo(i, 0, N) scanf("%d", &b[i]);
        fo(i, 0, N) scanf("%d", &c[i]);
        sort(a, a+N);
        sort(b, b+N);
        sort(c, c+N);

        int j = 0;
        fo(i, 0, N) {
                while (j < N && a[j] < b[i]) j++;
                v[i] = j;
        }

        j = 0;
        fo(i, 0, N) {
                while (j < N && b[j] < c[i]) cur += v[j++];
                ans += cur;
        }

        printf("%lld\n", ans);

        return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

/*
問題文
高橋くんはAtCoder銀行に 100 円を預けています。
AtCoder銀行では、毎年預金額の 1 % の利子がつきます(複利、小数点以下切り捨て)。

利子以外の要因で預金額が変化することはないと仮定したとき、高橋くんの預金額が初めて
X 円以上になるのは何年後でしょうか。

制約
101≤X≤10^18
入力はすべて整数
*/

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

        Scanner sc = new Scanner(System.in);
        double def = 100;
        long x = sc.nextLong();

        boolean flg = true;
        int count = 0;
        while(flg) {
            def = Math.floor(1.01 * def);
            count++;
            if (x <= def) {
                flg = false;
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 35856
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	string s = "ACGT";
	string b;
	cin >> b;
	if (b == "A") {
		cout << s[3] << endl;
	}
	else if (b == "C") {
		cout << s[2] << endl;
	}
	else if (b == "G") {
		cout << s[1] << endl;
	}
	else {
		cout << s[0] << endl;
	}
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import permutations
from heapq import heappush, heappop

def dijkstra(graph:list, node:int, start:int) -> list:
    # 未探索のノードは距離INF
    INF = float("inf")
    dist = [INF]*node
    
    # 始点ノードの距離を0とし、dfsのためのpriority queを作成
    dist[start] = 0
    heap = [(0,start)]
    searched = [False for _ in range(node)]
    
    # 未探索のノードをpriority queueに入れる
    while heap:
        cost, cur_node = heappop(heap)
        
        if searched[cur_node] or cost > dist[cur_node]:
            continue
        
        for nex_cost, nex_node in graph[cur_node]:
            dist_cand = dist[cur_node] + nex_cost
            if dist_cand < dist[nex_node]:
                dist[nex_node] = dist_cand
                heappush(heap, (dist[nex_node], nex_node))
    
        searched[cur_node] = True
        
        if sum(searched) == node:
            break
    
    return dist

n,m,r = li()
r = list(li_())
graph = [[] for _ in range(n)]
for _ in range(m):
    a,b,c = li()
    a -= 1
    b -= 1
    graph[a].append((c,b))
    graph[b].append((c,a))
    
dists = [[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
    dists[i] = dijkstra(graph, n, i)

routes = list(permutations(r))

ans = 2**64-1
for route in routes:
    temp = 0
    for i in range(len(route)-1):
        temp += dists[route[i]][route[i+1]]
        
    ans = min(ans,temp)
    
print(ans)

Measured memory_bytes: 13280
n,tl = gets.split.map(&:to_i)
a = []

for num in 0..n-1 do
 c = gets.split.map(&:to_i)
  if c[1] <= tl
  a << c[0]
  end
end
if a == []
  puts "TLE"
else
  p a.min
end

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)


void func(long long N, long long M, std::vector<long long> L, std::vector<long long> R){

    lli maxL = 0,minR = INF;

    REP(i,0,M){
        maxL = max(maxL,L[i]);
        minR = min(minR,R[i]);
    }

    //cout<<"maxL"<<maxL<<" minR="<<minR<<endl;
    if(minR<maxL)cout<<0<<endl;
    else cout<<minR-maxL+1<<endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> L(M);
    std::vector<long long> R(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&L[i]);
        scanf("%lld",&R[i]);
    }
    func(N, M, std::move(L), std::move(R));
    return 0;
}


Measured memory_bytes: 1792
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

const mod = 10^^9 + 7;

long calc(string s) {
    auto dp = new long[][](s.length + 1, 4);
    dp[0][0] = 1;

    for (int i = 1; i <= s.length; i++) {
        for (int j = 0; j <= 3; j++) {
            dp[i][j] = (dp[i-1][j] * (s[i-1] == '?' ? 3 : 1)) % mod;
        }

        auto c = s[i-1];
        if (c == 'A' || c == '?')
            dp[i][1] = (dp[i][1] + dp[i-1][0]) % mod;
        if (c == 'B' || c == '?')
            dp[i][2] = (dp[i][2] + dp[i-1][1]) % mod;
        if (c == 'C' || c == '?')
            dp[i][3] = (dp[i][3] + dp[i-1][2]) % mod;
    }

    return dp[s.length][3];
}

void main() {
    string s = read!string;
    writeln(calc(s));
}


Measured memory_bytes: 11288
package main

import (
	"fmt"
)

func main() {
	var p []int
	var n, c int

	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &c)
		p = append(p, c)
	}

	var cnt int
	for i := 1; i < n - 1; i++ {
		if p[i-1] <= p[i] && p[i] < p[i+1] ||
			p[i-1] > p[i] && p[i] >= p[i+1] {
			cnt += 1
		}
	}

	fmt.Println(cnt)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;



void solve()
{       
    ll n;
    cin>>n;
    unordered_map<ll,ll>h;
    for(int i=0;i<n-1;i++)
    {
        ll a;
        cin>>a;
        h[a]++;
    }

    for(int i=1;i<=n;i++)
    {
        cout<<h[i]<<endl;
    }
    
}   

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

    // ll t;
    // cin >> t;

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

Measured memory_bytes: 11496
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, combinations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from operator import itemgetter
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'

from pprint import pprint

def main():
    print(int(input())^1)




main()



Measured memory_bytes: 9924
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int N, T;
    cin >> N >> T;
    vector<int> c(N), t(N);
    rep(i, N) cin >> c.at(i) >> t.at(i);

    int minC = 1001;
    rep(i, N) {
        if (t.at(i) <= T) {
            minC = min(minC, c.at(i));
        }
    }

    string ans = (minC == 1001) ? "TLE" : to_string(minC);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3676
main :: IO ()
main = do
  [n,y] <- map (read :: String -> Int) . words <$> getLine
  putStrLn $ app $ ans n y

app :: (Int,Int,Int) -> String
app (a,b,c) = show a ++ ' ' : show b ++ ' ' : show c

ans :: Int -> Int -> (Int,Int,Int)
ans n y = foldl func (-1,-1,-1) (allComb n) where
  func acc k@(a,b,c)
    | acc /= (-1,-1,-1) = acc
    | y == a*10000+b*5000+c*1000 = k
    | otherwise = acc

allComb :: Int -> [(Int,Int,Int)]
allComb n = concat $ map func [0..n] where
  func k = map (\(a,b) -> (k,a,b)) $ allPair (n-k)
  allPair m = zip [0..m] [m,m-1..0]

Measured memory_bytes: 1020
#include <iostream>

#define MAX_HW 100

const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
int h, w, ans;
char field[MAX_HW][MAX_HW];

void solve();

void dfs(int H, int W);

int main(){
	while(true){
		std::cin >> h >> w;
		if(h == 0 && w == 0)
			break;
		for(int i = 0; i < h; ++i){
			for(int j = 0; j < w; ++j){
				std::cin >> field[i][j];
			}
		}
		solve();
		std::cout << ans << std::endl;
	}
	return 0;
}

void solve(){
	ans = 0;
	for(int i = 0; i < h; ++i){
		for(int j = 0; j < w; ++j){
			if(field[i][j] != '.'){
				dfs(i, j);
				++ans;
			}
		}
	}
	return;
}

void dfs(int H, int W){
	char tmp = field[H][W];
	field[H][W] = '.';

	for(int i = 0; i < 4; ++i){
		int nh = H + dx[i], nw = W + dy[i];

		if(nh >= 0 && nw >= 0 && nh < h && nw < w && tmp == field[nh][nw]) dfs(nh, nw); 
	}
	return;
}

Measured memory_bytes: 1632
N,M = list(map(int, input().split()))
 
s = [list(map(int,input().split())) for i in range(N)]
c = [list(map(int,input().split())) for j in range(M)]
 
for t1 in s:
    l = list(map(lambda x: abs(t1[0] - x[0]) + abs(t1[1] - x[1]), c))
    print(l.index(min(l)) + 1)

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

using namespace std;
//131073
const int maxn = 223456;
typedef pair<int, int> pii;
typedef long long ll;
multiset<int>s;
multiset<int>::iterator it;

int main(){
    ios_base::sync_with_stdio(0);
//    freopen("input.txt", "r", stdin);
    ll x;
    cin >> x;
    ll res = 1;
    for (ll i = 0; i * i <= x; ++i) {
        for (int j = 0; j < 10; ++j) {
            if(pow(i, j) <= x)res = max(res, (ll)pow(i, j));
        }
    }
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 256