akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

ll gcd (ll x,ll y) {
    if (x == 0) return y;
    return gcd(y%x,x);
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll A,B; cin >> A >> B;
    cout << A / gcd(A,B) * B << endl;
}

Measured memory_bytes: 256
import java.util.*;                                                                 
public class Main{                                                               
  public static void main(String [] args){                                          
    Scanner sc = new Scanner(System.in);                                            
    int m_count = 10, ans_count = 3;                                                
    int[] m = new int[m_count];                                                     
    int i;                                                                          
    for(i = 0;i < m_count;i++){                                                     
      m[i] = sc.nextInt();                                                          
    }                                                                               
    Arrays.sort(m);
    int t = 0; 
    for (i = 0; i < m_count / 2; i++){
      t = m[i];
      m[i] = m[m_count - i - 1];
      m[m_count - i - 1] = t;
    }
    for(i = 0;i < ans_count;i++){
      System.out.println(m[i]);
    }
  }
}

Measured memory_bytes: 17364
var1 = int(input())
for m in range(0, var1):
    OutCount = 0
    BaseCount = 0
    PointCount = 0
    for i in range(0, 100):
        try:
            str1 = input()
            if str1 == 'HIT':
                BaseCount = BaseCount + 1
                if BaseCount == 4:
                    PointCount = PointCount + 1
                    BaseCount = 3
            elif str1 == 'HOMERUN':
                PointCount = PointCount + BaseCount + 1
                BaseCount = 0
            elif str1 == 'OUT':
                OutCount = OutCount + 1
                if OutCount == 3:
                    print(PointCount)
                    break
        except:
            break



Measured memory_bytes: 5588
import sys


S=str(input())
n=len(S)

c=int(n/2) #添字
#print(c)

for j in range(c):
  if S[j]==S[-j-1]:
    continue
  else:
    print("No")
    sys.exit()

for i in range(int(c/2)):
  #print(S[i],S[c-1-i])
  #print(S[c+1+i],S[n-1-i])
  #print(S[i],S[-i-1])
  if S[i]==S[c-1-i] and S[c+1+i]==S[n-1-i]:
    continue
  else:
    print("No")
    sys.exit()

print("Yes")

Measured memory_bytes: 38256
n,q=map(int,input().split());s="_"+input()+"_";l,r=0,n+1
for(m,h)in [input().split()for i in range(q)][::-1]:L=h=="L";R=h=="R";l,r=[l,l-1,l+1][(m==s[l]and R)-(m==s[l+1]and L)],[r,r-1,r+1][(m==s[r-1]and R)-(m==s[r]and L)]
print(max(0,r-l-1))

Measured memory_bytes: 41364
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 1.5e6 + 6;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	//freopen("mountains.in", "r", stdin);
	//freopen("mountains.out", "w", stdout);
	string s; cin >> s;
	int n = s.size();
	if (n % 2 == 0) {
		bool f = true;
		for (int i = 0; i < n; i += 2) {
			if (s[i] == 'h' && s[i + 1] == 'i') {

			} else f = false;
		}
		if (f) {
			cout << "Yes";
			return 0;
		} 
	}
	cout << "No";

	return 0;
}

/*

4
Q 1
I 1 4 2
Q 3 
Q 1
I 2 2 -1
Q 3
E


*/

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
bc = m.times.map{gets.split.map(&:to_i)}.sort{|x, y| y[1] <=> x[1]}

i = 0
bc.each do |b, c|
  break if i == n
  if a[i] < c
    b.times do
      if a[i] < c
        a[i] = c
        i += 1
        break if i == n
      else
        break
      end
    end
  else
    break
  end
end

puts a.sum


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

int main() {
  vector<int> v(9);
  for (int i = 0; i < 9; i++) {
    cin >> v.at(i);
  }
  int a = v.at(0) + v.at(4) + v.at(8);
  int b = v.at(1) + v.at(5) + v.at(6);
  int c = v.at(2) + v.at(3) + v.at(7);
  if (a == b && b == c) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;;
int main(){
  int N,M,A,B,C;
  cin >> N >> M >> C;
  A=M*N;
  //vector<int>B(N);
  //for(int i=0;i<N;i++){
  if(A<C)cout << A << endl; 
  else cout << C << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
//#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;

#define ll long long
#define SZ(x) ((int)(x).size()) 
#define ALL(v) (v).begin(), (v).end()
#define foreach(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define reveach(i, v) for (__typeof((v).rbegin()) i = (v).rbegin(); i != (v).rend(); ++ i) 
#define REP(i,a,n) for ( int i=a; i<int(n); i++ )
#define FOR(i,a,n) for ( int i=n-1; i>= int(a);i-- )
#define lson rt<<1, L, m
#define rson rt<<1|1, m, R
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define fi first
#define se second
#define CLR(a, b) memset(a, b, sizeof(a))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
const int N = 2e3 + 7;
const ll INF = 1e18 + 7;
int n, x;
int a[N];
int dp[N][N];
int pre[N][N];
int main(){
#ifdef ac
	freopen("in.txt","r",stdin);
#endif
	//freopen("out.txt","w",stdout);
    scanf("%d%d", &n, &x);
    REP(i, 0, n) scanf("%d", &a[i]);
    REP(i, 0, n){
        REP(j, 0, n){
            dp[i][j] = (i - j + n) % n;
        }
        pre[i][0] = dp[i][0];
        REP(j, 1, n){
            if(a[dp[i][j]] < a[pre[i][j - 1]]){
                pre[i][j] = dp[i][j];
            }
            else{
                pre[i][j] = pre[i][j - 1];
            }
        }
    }
    ll res = INF;
    REP(i, 0, n){
        ll sum = 1ll * i * x;
        REP(j, 0, n){
            sum += a[pre[j][i]];
        }
        Min(res, sum);
    }
    printf("%lld\n", res);
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<int>a(n+1);
    vector<int>b(n);
    rep(i,(n+1)) cin>>a[i];
    rep(i,n) cin>>b[i];
    ll ans=0;
    rep(i,n){
        if((a[i]+a[i+1])<b[i]){
            ans=ans+a[i]+a[i+1];
            a[i+1]=0;
        }else{
            ans+=b[i];
            if(a[i]<b[i]){
                a[i+1]=a[i+1]+a[i]-b[i];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main () {
	int n, h[100000];
	cin >> n;
	int k;
	cin >> k;
	for (int i = 0; i < n; i++) cin >> h[i];
	int dp[100010];
	dp[n-1] = 0;
	for (int i = n-2; i >= 0; i--) {
		dp[i] = abs(h[i+1]-h[i])+dp[i+1];
		for (int j = 2; j <= k && i+j<n; j++) {
			dp[i] = min(dp[i], abs(h[i+j]-h[i])+dp[i+j]);
		}
	}
	cout << dp[0] << endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve{
public:
    void input(){

    }
    void solve(){
        input();
        int N;
        cin >> N;
        bool alleven = true;
        vector<ll> a(N);
        rep(i,0,N) cin >> a[i];
        rep(i,0,N){
            if(a[i] % 2 != 0){
                alleven = false;
            }
        }

        if(alleven){
            cout << "second" << endl;
        }else{
            cout << "first" << endl;
        }

    }
};


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

    Solve().solve();


    return 0;
}


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

int power[] = {1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000, 1024, 1089, 1156, 1225};

int main() {
    string s;
    int K;
    cin >> s >> K;
    vector<string> dict;
    string temp;
    for(char tempC = 'a'; dict.size() < 5 || tempC <= 'z'; ++tempC) {
        for(int i = 0; i < s.length(); ++i) {
            temp = "";
            if(s[i] == tempC) {
                for(int j = i; j < s.length() && j <= i + 5; ++j) {
                    temp += s[j];
                    dict.push_back(temp);
                }
            }
        }
    }

    sort(dict.begin(), dict.end());
    decltype(dict)::iterator result = unique(dict.begin(), dict.end());
    dict.erase(result, dict.end());

    cout << dict[K - 1] << endl;
}

Measured memory_bytes: 1916
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m =	Integer.parseInt(sc.next());
	int[] a	= new int[n+1];
	for(int i = 0; i<m; i++) {
            a[Integer.parseInt(sc.next())]++;
            a[Integer.parseInt(sc.next())]++;
        }
	for(int i = 1; i<n+1; i++) {
            System.out.println(a[i]);
        }
    }
}

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

#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)

#define range(i, l, r) for (int i = l; i < (int)(r); ++i)

int main() {
    int a, b, c;

    cin >> a >> b >> c;

    int s = 0, t = a;
    range(i, 0, 1000) {
        int time = i * 60 + c;
        while (t < time) {
            s += a + b;
            t += a + b;
        }

        if (s <= time && time <= t) {
            cout << time << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}
        




Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll unsigned long long 

 
int main()
{
	int n,m; cin>>n>>m;
	string ar[n];
	for(int i=0;i<n;i++) cin>>ar[i];
	ll dp[n+1][m+1];
	for(int i=0;i<n+1;i++){
		for(int j=0;j<m+1;j++) dp[i][j]=0;
	}
	dp[1][1]=1;
	for(int i=2;i<n+1;i++){
		if(ar[i-1][0]!='#')
			dp[i][1]=dp[i-1][1];
	}
	for(int i=2;i<m+1;i++){
		if(ar[0][i-1]!='#')
			dp[1][i]=dp[1][i-1];
	}
	for(int i=2;i<n+1;i++){
		for(int j=2;j<m+1;j++){
			if(ar[i-1][j-1]=='.'){
				dp[i][j]=dp[i-1][j]%mod+dp[i][j-1]%mod;
				dp[i][j]%=mod;
			}
		}
	}
	cout<<dp[n][m]<<endl;
	return 0;
}



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

int main() {

	int n; cin >> n;
	vector<vector<int>> c(n, vector<int>(n, -1));
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		for (int j = 0; j < a; j++) {
			int x, y; cin >> x >> y;
			c[i][--x] = y;						
		}
	}
	int ans = 0;
	for (int bit = 0; bit < (1 << n); ++bit) {
		int cnt = 0;
		vector<int> d(n, 0);
		for (int i = 0; i < n; ++i) {
			if (bit & (1 << i)) {
				d[i] = 1;
				cnt++;
			}
		}
		bool ok = true;
		for (int i = 0; i < n; i++) {
			if (d[i]) {
				for (int j = 0; j < n; j++) {
					if (c[i][j] == -1) continue;
					if (c[i][j] != d[j]) ok = false;
				}
			}
		}
		if (ok) ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<queue> 
using namespace std ;
int main()
{
	priority_queue< int > q ;
	int n , m , k ;
	cin >> n >> m ;
	for(int i = 1 ; i <= n ; i ++)
	{
		cin >> k ;
		q.push(k) ;
	}
	long long sum = 0 ;
	while(m --)
	{
		k = q.top() / 2 ;
		q.pop() ;
		q.push(k) ;
	}
	while(q.size() > 0)
	{
		sum += q.top() ;
		q.pop() ;
	}
	cout << sum << endl ;
	return 0 ;
}

Measured memory_bytes: 892
import java.util.*;
public class Main
{
    static int gcd(int b,int a)
    {
        if(b%a==0)
        return a;
        return gcd(a,b%a);
    }
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int ar[]=new int[n];
        for(int i=0;i<n;i++)
        ar[i]=sc.nextInt();
        int mat=1,cntr=0,j=0;
        boolean b=true;
        for(int i=0;i<n;i++)
        {
            if(ar[i]==mat)
            {
                mat++;
                cntr+=(i-j);
                j=i+1;
                b=false;
            }
        }
        if(j!=n)
        cntr+=(n-j);
        if(!b)
        System.out.println(cntr);
        else
        System.out.println("-1");
    }
}

Measured memory_bytes: 65212
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

void solve() {
    int n;
    cin>>n;
    int tot = power(10, n);
    int sub = add(power(9, n), power(9, n));
    sub = add(sub, -power(8, n));
    cout<<add(tot, -sub)<<endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int t = 1;
    //cin>>t;
    for(int test = 1; test <= t; test++) {
        //cout<<"Case #"<<test<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
#!/usr/bin/env python

if __name__ == '__main__':
    point = [0]*2
    n = int(raw_input())

    for _ in range(n):
        t, h = raw_input().split()
        if t == h:
            point = map(lambda x: x+1, point)
        else:
            point[t<h] += 3

    print '%d %d' % tuple(point)



Measured memory_bytes: 4660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int N = 200000 + 5;

int main() {
	int n,k;
	cin >> n >> k;
	if(n >= 10)
		cout << k << endl;
	else
		cout << k + 100 * (10-n) << endl;
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
long long N;
long long ans = 0,cc = 5;

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


	cin >> N;
	vector<long long > A(5),P(5,0);

	for(auto &x: A) cin >> x;

	sort(A.begin(),A.end());
	ans += N/A[0] + 4;
  if(N%A[0]!= 0 && A[0] < N) ans ++;
	cout << max(ans,cc) << endl;


}


Measured memory_bytes: 256
#![allow(non_snake_case, dead_code)]
use proconio::fastout;
use proconio::input;
use rand::Rng;

#[fastout]
fn main() {
    input! {
        D:usize,
        C:[i32;26],
        S:[[i32;26];D]
    }
    let start = std::time::Instant::now();
    let mut rng = rand::thread_rng();
    let mut T = vec![0; D];
    let mut Tmax = vec![0; D];
    //let mut cnt = 0;
    for i in 0..D {
        let mut saidai = 0;
        for j in 1..26 {
            if S[i][saidai] < S[i][j] {
                saidai = j;
            }
        }
        T[i] = saidai;
        Tmax[i] = saidai;
    }
    let mut ans = score(D, &C, &S, &T);
    loop {
        let r_day = rng.gen::<usize>() % D;
        let r_con = rng.gen::<usize>() % 26;
        T[r_day] = r_con;
        //cnt += 1;
        let x = score(D, &C, &S, &T);

        // 最大値を更新できたら値を更新するが、そうでなければ元に戻す。
        if ans < x {
            ans = x;
            Tmax[r_day] = T[r_day];
        } else {
            T[r_day] = Tmax[r_day];
        }
        let duration = start.elapsed();
        if duration > std::time::Duration::from_millis(1) {
            break;
        }
    }
    for i in 0..D {
        println!("{}", Tmax[i] + 1);
    }
    //println!("cnt:{}, point:{}", cnt, ans);
}
fn score(D: usize, C: &Vec<i32>, S: &Vec<Vec<i32>>, T: &Vec<usize>) -> i32 {
    let mut last = vec![vec![0i32; 26]; D];
    for d in 0..D {
        let i = T[d];
        last[d][i] = d as i32 + 1;
        for e in d + 1..D {
            if T[e] != i {
                last[e][i] = d as i32 + 1;
            } else {
                break;
            }
        }
    }
    let mut x = 0;
    for d in 0..D {
        let i = T[d];
        x += S[d][i];
        //println!("ss{}", x);
        for j in 0..26 {
            x -= C[j] * (d as i32 + 1 - last[d][j]);
            //println!("C[{}]={} -> {}", j, C[j], x);
        }
    }
    x
}


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

using namespace std;
#define FILE "dealing"
#define up(i,j,n) for(int i=j;i<=n;i++)
#define ll long long
#define db double 
#define ull unsigned int
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back

int read(){
	int f=1,x=0,ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	return f*x;
}

const int maxn=200010,limit=100000,inf=100000000,mod=1e9+7;
int add(int a,int b){return (a+=b)>=mod?a-mod:a;}
int sub(int a,int b){return (a-=b)<  0?a+mod:a;}
int mul(int a,int b){return 1LL*a*b%mod;}
int r,c,n;
struct node{
	int x,y,id,k;
}e[maxn];
int num=0;int vis[maxn];
bool operator<(const node& a,const node& b){
	if(a.k!=b.k)return a.k<b.k;
	if(a.k==1)return a.x<b.x;
	if(a.k==2)return a.y<b.y;
	if(a.k==3)return a.x>b.x;
	if(a.k==4)return a.y>b.y;
}
bool init(int x,int y,int id){
	if(y==0){
		e[++num].x=x;e[num].y=y;
		e[num].k=1,e[num].id=id;
		return 1;
	}
	else if(x==r){
		e[++num].x=x;e[num].y=y;
		e[num].k=2,e[num].id=id;
		return 1;
	}
	else if(y==c){
		e[++num].x=x;e[num].y=y;
		e[num].k=3,e[num].id=id;
		return 1;
	}
	else if(x==0){
		e[++num].x=x;e[num].y=y;
		e[num].k=4,e[num].id=id;
		return 1;
	}
	
	
	
	
	
	return 0;
}
int q[maxn],top=0;
int main(){
	//freopen(FILE".in","r",stdin);
	//freopen(FILE".out","w",stdout);
	r=read(),c=read(),n=read();
	up(i,1,n){
		int x=read(),y=read(),x1=read(),x2=read();
		if(init(x,y,i))if(!init(x1,x2,i))num--;
	}
	sort(e+1,e+num+1);
	
	for(int i=1;i<=num;i++){
		if(!vis[e[i].id]){
			q[++top]=e[i].id;
			vis[e[i].id]=1;
		}
		else {
			if(q[top]!=e[i].id){cout<<"NO";return 0;}
			top--;
		}
	}cout<<"YES";
	return 0;
}






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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b){
        cout << c << endl;
    }else if (a == c){
        cout << b << endl;
    }else if (b == c){
        cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trv(a) cerr<<#a<<":\n";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define mod 1000000007ll
#define inf 9999999999999999ll


void solve()
{
    int n;
    cin>>n;
    map<int,int> m;
    for(int i = 2 ; i <= n ; i++)
    {
        int temp;
        cin>>temp;
        m[temp]++;
    }
    for(int i = 0 ; i < n ; i++)
    cout<<m[i+1]<<endl;
}




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


Measured memory_bytes: 12996
using System;

namespace A___AC_or_WA
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var n = int.Parse (input[0]);
            var m = int.Parse (input[1]);
            if (n == m)
                Console.WriteLine ("Yes");

            else
                Console.WriteLine ("No");
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

struct mint {
	ll x;
	mint(ll x=0):x((x%MOD+MOD)%MOD){}
	mint operator-() const { return mint(-x);}
	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;}
};

int main() {
//	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];
	vi c(3);
	mint ans = 1;
	rep(i, n) {
		int cnt = 0;
		rep(j, 3) if(c[j] == a[i]) cnt++;
		ans *= cnt;
		rep(j, 3) if(c[j] == a[i]) {
			c[j]++;
			break;
		}
	}
	cout << ans.x << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define FOR(i,a,b) for (register int i=(a);i<=(b);i++)
#define For(i,a,b) for (register int i=(a);i>=(b);i--)
#define MP make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
const int N=6005;
int n,a[N],b[N],vis[N],balance=0;
string s,ans="";
vector <string> vec;
inline string sub(int l,int r)
{
	string str="";
	FOR(i,l,r) if (!vis[i]) str+=s[i];
	return str;
}
inline void solve(int l,int r)
{
	a[0]=b[0]=0;
	FOR(i,l,r)
		if (s[i]=='a') a[++a[0]]=i;
		else b[++b[0]]=i;
	int last,tmp,mx=0;
	string str="";
	if (s[l]=='a')
	{
		FOR(i,1,a[0])
		{
			last=i,tmp=1;
			FOR(j,i+1,a[0]) if (a[j]>b[last]) last=j,tmp++;
			mx=max(mx,tmp);
		}
		FOR(i,1,mx) str+="ab";
	}
	else
	{
		FOR(i,1,a[0])
		{
			str=max(str,sub(l,r));
			vis[a[i]]=vis[b[i]]=1;
		}
		FOR(i,1,a[0]) vis[a[i]]=vis[b[i]]=0;
	}
	vec.pb(str);
	return;
}
inline int check(string s1,string s2)
{
	int l1=s1.length(),l2=s2.length(),len=min(l1,l2);
	FOR(i,0,len-1)
	{
		if (s1[i]<s2[i]) return 1;
		if (s1[i]>s2[i]) return 0;
	}
	return 0;
}
int main()
{
	scanf("%d",&n);
	cin>>s;
	for (register int l=0,r=0;l<2*n&&r<2*n;r++)
	{
		balance+=(s[r]=='a')?1:-1;
		if (!balance) solve(l,r),l=r+1;
	}
	FOR(i,0,(int)vec.size()-1)
	{
		int tag=1;
		FOR(j,i+1,(int)vec.size()-1)
			if (check(vec[i],vec[j])) {tag=0;break;}
		if (tag) ans+=vec[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
	long long i, j=0, k, N, ans=0;

	cin >> N;

	if (N < 105) {
		cout << 0 << endl;
		return 0;
	}


	for (i = 105; i <= N; i++) {
		if (i % 2) {
			for (k = 1; k <= i; k++) {
				if (i%k == 0)
					j++;
			}
			if (j == 8)
				ans++;
			j = 0;
		}
	}

	cout<< ans << endl;

	return 0;
}

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

using namespace std;

const int N=55;

int n;
long long arr[N],cur[N];

bool can(long long x)
{
	for(int i=0;i<n;i++)
	{
		cur[i]=arr[i]+x;
	}
	long long ans=0;
	for(int i=0;i<n;i++)
	{
		long long dif=cur[i]-(n-1);
		ans+=(dif+n)/(n+1);
	}
	return ans<=x;
}

int main()
{
	cin >> n;
	for(int i=0;i<n;i++)
	{
		cin >> arr[i];
	}
	long long st=0,en=(1LL<<60),ans=(1LL<<60);
	while(st<=en)
	{
		long long mid=st+(en-st)/2;
		if(can(mid))
		{
			ans=mid; en=mid-1;
		}
		else st=mid+1;
	}
	for(long long curr=max(ans-(long long)1e5,0LL);curr<=ans;curr++)
	{
		if(can(curr))
		{
			ans=curr;
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3648
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		long x;
		x = scan.nextLong();
		int count = 0;

		long kingaku = 100;

		while (true) {
			kingaku = (long) (kingaku * 1.01);

			count++;

			if (kingaku >= x) {
				System.out.println(count);
				return;
			}

		}
	}

	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 35832
#include <iostream>
#include <stdio.h>
using namespace std;


int main(){
	int  A, B ;
scanf("%d%d", &A, &B);
if(A<=13 &&((A==1&&B!=1)||(A>B && B!=1))){	
printf("Alice");
	}else if (B<=13 &&((B==1&&A!=1)||(B>A &&B!=1))){
		printf("Bob");
	}else if (A=B ||(A==1&&B==1)){
		printf("Draw");
	}
	return 0;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ifor(i,n) for(i=0;i<n;i++)
#define ll long long
///vector<int>vec;
///sort(s.begin(),s.endl());
///sort(ara,ara+n);
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    ll int i,n,t,p=INT_MAX,j=0,x,a=0,b,l=0,r=0;
     string s,m;
     cin>>n;
     int ara[n];
    ifor(i,n){
        cin>>ara[i];
        j+=ara[i];
    }
    p=j/n;
   /// cout<<l<<r<<endl;
    if(j%n!=0){
        l=p+1;
    }


    ifor(i,n){
        a+=(abs(p-ara[i]))*(abs(p-ara[i]));
    }
    ifor(i,n){
        r+=(abs(l-ara[i]))*(abs(l-ara[i]));
    }
     cout<<min(a,r)<<endl;

     return EXIT_SUCCESS;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        
        int ans = 0;
        char c = '.';
        for(int i = 0; i < n; i++){
            if(s.charAt(i) != c){
                ans++;
                c = s.charAt(i);
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 25812
n = int(input())
job = [[0 for i in range(2)] for j in range(n)]
for i in range(n):
    inputs = [int(s) for s in input().split()]
    job[i][0] = inputs[1]
    job[i][1] = inputs[0]

sortedJob = sorted(job)
times = 0
breaked = False
for i in range(n):
    times += sortedJob[i][1]
    if times > sortedJob[i][0]:
        breaked = True
        break

if breaked:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 40352
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    string s;
    cin >> s;
    int len = s.length();
    int ans[len];
    int left = 0;
    int right = 0;
    for(int i = 0; i < len; i++){
        ans[i] = 0;
    }
    for(int i = 0; i < len - 1; i++){
        if(s[i] == 'L' && s[i+1] == 'R'){
            right = i;
            for(int j = left; j < right; j++){
                int tmp = 0;
                if(s[j] == 'R' && s[j+1] == 'L'){
                    tmp = j;
                    ans[j] ++;
                    ans[j+1] ++;
                    for(int k = left; k <= right; k++){
                        if(k != tmp && k != tmp+1){
                            if(abs(k-tmp) % 2 == 0){
                                ans[j] ++;
                            }else if(abs(k-tmp) % 2 == 1){
                                ans[j+1] ++;
                            }
                        }
                        
                    }
                }
                
            }
        left = i+1;
        }
    }
    right = len-1;
    for(int j = left; j < right; j++){
                int tmp = 0;
                if(s[j] == 'R' && s[j+1] == 'L'){
                    tmp = j;
                    ans[j] ++;
                    ans[j+1] ++;
                    for(int k = left; k <= right; k++){
                        if(k != tmp && k != tmp+1){
                            if(abs(k-tmp) % 2 == 0){
                                ans[j] ++;
                            }else if(abs(k-tmp) % 2 == 1){
                                ans[j+1] ++;
                            }
                        }
                        
                    }
                }
            }
    for(int i = 0; i < len; i++){
        cout << ans[i] << " ";
    }
    cout << endl;
}


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

int max(int a,int b){
return (a>b)?a:b;
}

int LCS(char*x, char*y, int a, int b){
int i,j;
int L[a+1][b+1];

for (i = 0; i <= a; i++) {
    L[i][0] = 0;
  }
for (i = 0; i <= b; i++) {
    L[0][i] = 0;
  }

for (i = 1; i <= a; i++) {
  for (j = 1; j <=b; j++) {
    if(x[i-1]==y[j-1]) L[i][j] = L[i-1][j-1]+1;
    else L[i][j] = max(L[i-1][j],L[i][j-1]);
    }
  }
  return L[a][b];
}

int main(){
  int q,i,a,b;
  char x[1200],y[1200];

  scanf("%d ",&q);
  for(i=0;i<q;i++){
    scanf("%s %s",x,y);
    a=strlen(x);
    b=strlen(y);
    printf("%d\n",LCS(x,y,a,b));
  }
  return 0;
}



Measured memory_bytes: 5700
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, m, sum = 0, a;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> a;
        sum += a;
    }
    printf("%d\n", (sum > n)? -1: n-sum);
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;


int main(){
    int x;
    cin >> x;
    
    vector<int> is_prime(120000,1);
    is_prime[0]=0;
    is_prime[1]=0;
    for(int i=2; i<120000; i++){
        if(!is_prime[i]) continue;
        for(int j=i*2; j<120000; j+=i) is_prime[j]=0;
    }
    for(int i=x; x<120000; i++){
        if(is_prime[i] == 1){
            cout << i << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, s, n) for(int i = s; i < n; i++)
using namespace std;

const int N = 100000;
int main(){
  int q;
  cin >> q;
  vector<bool> prime(N+1, true);
  prime[0] = false;
  prime[1] = false;
  rep(i, N){
    if (prime[i]){
      int x = i*2;
      while(x <= N){
        prime[x] = false;
        x += i;
      }
    }
  }
  vector<int> prime_num(N);
  prime_num[0] = 0;
  rep(i, N+1){
    if (i != 0) prime_num[i] = prime_num[i-1];
    if (prime[i] && prime[(i+1)/2]){
      prime_num[i]++;
    }
  }
  
  int l, r;
  rep(_, q){
    cin >> l >> r;
    cout << prime_num[r] - prime_num[l-1] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1024
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int N,i;
string W[100];
set<string> s;
inline void solve(){
  IN(N);
  INS(i,N,W);
  REP(i,N){
    s.insert(W[i]);
    if(i==0)continue;
    if(W[i-1].back()!=W[i].front()||s.size()!=i+1){
      OUT("No");
      return;
    }
  }
  OUT("Yes");
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


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

int p[200002];

long long pre[200002];

int main(){
  int N; scanf("%d", &N);
  for(int i = 1; i <= N; i++) scanf("%d", &p[i]);

  long long zero = 0, even = 0, odd = 0;

  for(int i = 1; i <= N; i++){
    long long new_zero = zero + p[i];
    long long new_even = min(zero, even) + (p[i] == 0 ? 2 : p[i] & 1 ? 1 : 0);
    long long new_odd = min({ zero, even, odd }) + (p[i] & 1 ? 0 : 1);

    zero = new_zero;
    even = new_even;
    odd = new_odd;

    pre[i] = min({ zero, even, odd });
  }

  long long ans = pre[N];

  zero = 0; even = 0;

  for(int i = N; i >= 1; i--){
    long long new_zero = zero + p[i];
    long long new_even = min(zero, even) + (p[i] == 0 ? 2 : p[i] & 1 ? 1 : 0);

    zero = new_zero;
    even = new_even;

    long long res = pre[i - 1] + min(zero, even);

    if(res < ans) ans = res;
  }

  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    int s;
    if (a < 1 || a > 9 || b < 1 || b > 9)
        s = -1;
    else
        s = a * b;
    cout << s;
    return 0;
}

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

#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)

#define ii pair<int, int>
#define mp make_pair
#define FF first
#define SS second

#define vi vector<int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>

#define eb emplace_back
#define ef emplace_front
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()

#define oo 1000000007
#define OO 1000000000000000007LL

using namespace std;

#define Pro "tmp"
#define maxN 1507

int f[maxN][maxN][5], dp[maxN][maxN];
int a[maxN][maxN];

int main() {

    int n, m;
    scanf("%d%d", &m, &n);

    fto (i, 1, n) {
        fto (j, 1, m) {
            scanf("%d", &a[i][j]);
        }
    }

    fdto (i, n, 1) {
        fdto (j, m, 1) {
            dp[i][j] = dp[i+1][j]+dp[i][j+1]-dp[i+1][j+1]+a[i][j];
        }
    }

    fdto (sum, n+m, 2) {
        fto (i, 1, n) {
            int j = sum-i;
            if (j < 1 || j > m) continue;

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

//    fto (i, 1, n) {
//        fto (j, 1, m) printf("%3d", dp[i][j]);
//        puts("");
//    }
//    puts("");
//
//    fto (i, 1, n) {
//        fto (j, 1, m) printf("%3d", f[i][j][0]);
//        puts("");
//    }
//    puts("");
//
//    fto (i, 1, n) {
//        fto (j, 1, m) printf("%3d", f[i][j][1]);
//        puts("");
//    }

    cout << abs(dp[1][1]-2*f[1][1][0]) << endl;
    return 0;
}



Measured memory_bytes: 38432
L,R=map(int,input().split())
if R-L>=2019:
    minimum=0
else:
    left,right=L%2019,R%2019
    minimum=2019
    for i in range(left,right+1):
        for j in range(i+1,right+1):
            minimum=min(minimum,i*j%2019)
print(minimum)

Measured memory_bytes: 65280
import java.util.Scanner;
public class Main
{
	public static void main(String[] args)
    {
		Scanner sc = new Scanner(System.in);
      	int a = Integer.parseInt(sc.nextLine());
      	int result[] = new int[a];
      	for(int i = 1; a >= i * i + 2 * i + 3; i++)
        {
         	for(int j = 1; j <= i; j++)
            {
              	for(int k = 1; k <= j; k++)
                {
                  	if(calc( k, j, i) > a)
                    {
                      
                    }else if(k != j && k != i && j != i){
                      	result[calc(k, j, i) - 1] += 6;
                    }else if(k != j || k != i || j != i){
                      	result[calc(k, j, i) - 1] += 3;
                    }else{
                      	result[calc(k, j, i) - 1] += 1;
                    }
                      
                }
            }
        }
      	for(int o = 0; o < a; o++)
        {
         	 System.out.println(result[o]);
        }
    }
  
  	public static int calc(int x, int y, int z)
    {
     	return ( x + y + z ) * ( x + y + z ) - x * y - x * z - y * z; 
    }
}

Measured memory_bytes: 39264
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

// fn minus(a: Vec<isize>, b:Vec<isize>) -> Vec<isize> {
//     let mut z = vec![0,0,0];
//     for (i, (aval, bval)) in a.iter().zip(&b).enumerate() {
//         z[i] = aval - bval;
//     }
//     z
// }

fn main() {
    input! {
        // s: char
      n: usize,
      k: usize,
      p: [usize; n]
    }
    let mut p2 = p;
    let mut count = 0;
    p2.sort();
    for (idx, i) in p2.iter().enumerate(){
        if idx == k{
            break;
        }
        count += i;
    }
    println!("{}", count)
}


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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

int main()
{
	LL L, R;
	cin >> L >> R;

	LL ans = -1;
	FOR(i, L, min<>(L + 2020, R)) {
		LL m = i % 2019;

		FOR(j, i + 1, min<>(i + 1 + 2020, R + 1)) {
			LL n = j % 2019;

			LL v = (m * n) % 2019;

			if (ans == -1) {
				ans = v;
			}
			else {
				ans = min<>(ans, v);
			}
		}
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e9)
using namespace std;
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll MOD = 1e9 + 7;
    cin >> N;
    ll cnt[1010] = {};
    rep(i,2,N+1){
        ll num = i;
        rep(j,2,1001){
            while(num % j == 0){
                cnt[j]++;
                num /= j;
            }
        }
    }
    ll ans = 1;
    rep(i,0,1001){
        if(cnt[i] != 0){
            ans *= cnt[i]+1;
            ans %= MOD;
        }
    }
    print(ans);
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N; long M;
    scan(N, M);
    auto a = readln.split.to!(long[]);
    auto b = a.map!(ai => ai / 2).array;
    auto c = new int[](N);
    foreach (i ; 0 .. N) {
        auto x = a[i];
        while (x % 2 == 0) {
            x /= 2;
            c[i]++;
        }
    }
    if (!iota(N).all!(i => c[i] == c[0])) {
        writeln(0);
        return;
    }
    long l = 1;
    foreach (bi ; b) {
        l = lcm(l, bi);
        if (l > M) {
            writeln(0);
            return;
        }
    }
    auto ans = M / l - M / (2*l);
    writeln(ans);
}

long lcm(long x, long y) {
    return x / gcd(x, y) * y;
}


void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 6316
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define mod (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int gcd(int A,int B) {if(!B)return A;return gcd(B,A%B);}
int a[200005];
int main()
{
	int n,ans = 1;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	vector<int>dp(n+5,-1);
	for(int i=1;i<=n;i++)
	{
      int l = 0,r = i,mid;
      while(r-l > 1)
      {
		  mid = (l+r)/2;
		  if(a[i] > dp[mid])r = mid;
		  else l = mid;
	  }
      dp[r] = a[i];
      ans = max(ans,r);
      
	}
	//for(int i=1;i<=ans;i++)cout<<dp[i]<<" ";
	//cout<<endl;
	cout<<ans;
}

Measured memory_bytes: 1024