akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	string s, t;
	cin >> s >> t;
	int cnt = 0;
	int n = s.size();
	rep(i, n) {
		if (s[i] != t[i]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}


template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE

using D = double;
const D PI = asin(1)*2;
D dot(D x1,D y1,D x2,D y2){
  return x1*x2+y1*y2;
}

signed main(){
  int n;
  cin>>n;
  vector<D> xs(n),ys(n);
  for(int i=0;i<n;i++) cin>>xs[i]>>ys[i];
  xs.emplace_back(0);
  ys.emplace_back(0);
  xs.emplace_back(-1);
  ys.emplace_back(0);

  vector<int> vs(n+3,n),used(n,0);
  vs[0]=n+1;

  D ans=1e9;
  auto check=
    [&](){
      D res=0;
      for(int i=0;i+2<n+3;i++){
        D dx=xs[vs[i+1]]-xs[vs[i+0]],dy=ys[vs[i+1]]-ys[vs[i+0]];
        D nx=xs[vs[i+2]]-xs[vs[i+1]],ny=ys[vs[i+2]]-ys[vs[i+1]];
        D th=acos(min(1.0,max(dot(dx,dy,nx,ny)/hypot(dx,dy)/hypot(nx,ny),
                          -1.0)));
        //cout<<dx<<" "<<dy<<":"<<nx<<" "<<ny<<":"<<th<<endl;
        res+=abs(th)/PI*180;
      }
      chmin(ans,res);
    };

  MFP([&](auto dfs,int d)->void{
        if(d==n+2){
          check();
          return;
        }
        for(int i=0;i<n;i++){
          if(used[i]) continue;
          used[i]=1;
          vs[d]=i;
          dfs(d+1);
          used[i]=0;
        }
      })(2);

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



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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;

double EPS=1e-9;
int INF=1000000005;
long long INFF=1000000000000000005ll;
double PI=acos(-1);
int dirx[8]={ -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8]={ 0, 1, -1, 0, -1, 1, -1, 1 };
const ll MOD = 1000000007;

ll sum() { return 0; }
template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }

#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define OUT(x) cout << x << endl
#define OUTH(x) cout << x << " "
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define READ(x) for(auto &(z):x) cin >> z;
#define FOR(a, b, c) for (int(a)=(b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a)=(b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a)=(b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a)=(b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a)=(b); (a) <= (c); ++(a))
#define EACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define MAX(a, b) a=max(a, b)
#define MIN(a, b) a=min(a, b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define TC(t) while (t--)
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define what_is(x) cerr << #x << " is " << x << endl;

void solve() {

}

int main()
{
    FAST_INP;
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt","r", stdin);
//    freopen("output.txt","w", stdout);
//    #endif

//    int tc; cin >> tc;
//    TC(tc) solve();
	int l, r;
	cin >> l >> r;
//	if((l-1)/2019!=r/2019) {
	if(r-l>=2018){
		OUT(0);
		return 0;
	}
	l%=2019, r%=2019;
	int ans=2018;
	FORN(i,l,r){
		FORN(j,i+1,r){
			MIN(ans, (i*j)%2019);
		}
	}
	OUT(ans);
    return 0;
}

Measured memory_bytes: 3648
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
         break
    for h in range(H):
        for w in range(W):
            if (h+w)%2==0:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7000
s=input()

if s[0] !="A":
    print("WA")
    exit()

cnt=0
for i in range(2,len(s)-1):
   if s[i] == "C":
       cnt+=1
if cnt!=1:
    print("WA")
    exit()

for i in range(1,len(s)):
    if s[i] == "C" and 2<=i<len(s)-1:
        continue
    if not s[i].islower():
        print("WA")
        exit()
print("AC")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
int n;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for (int i=1;i<=9;++i)
		for (int j=1;j<=9;++j)
		{
			if (i*j==n)
			{
				cout<<"Yes";
				return 0;
			}
		}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

struct SlideMin {
    // data[i]: mininum over [max(0, i + 1 - width), i + 1)
    int n;
    vi data;
    SlideMin(const vi &as, int width, bool minimum = true) : n(as.size()), data(as.size()) {
        using ii = pair<i64, int>;
        deque<ii> deq;
        auto comp = [&](ii &e, i64 v) {
            return minimum ? e.first >= v : e.first <= v;
        };
        for (int i = 0; i < n; i++) {
            if (deq.size() && deq.front().second <= i - width) {
                deq.pop_front();
            }
            while (deq.size()) {
                if (comp(deq.back(), as[i])) deq.pop_back();
                else break;
            }
            deq.push_back(ii(as[i], i));
            data[i] = deq.front().first;
        }
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, m, k;
    cin >> n >> m >> k;
    vi as(n);
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }

    vi dp(as);
    for (int i = 0; i < k - 1; i++) {
        SlideMin smax(dp, m, false);
        for (int j = 0; j < n; j++) {
            if (j <= i) {
                dp[j] = 0;
            } else {
                dp[j] = smax.data[j - 1] + as[j] * (i + 2);
            }
        }
    }
    i64 nax = -1;
    for (int i = 0; i < n; i++) {
        nax = max(nax, dp[i]);
    }
    cout << nax << endl;
}


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

int H, W, dist[59][59], sum; string S[59];

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> S[i];
		for (int j = 0; j < W; j++) { if (S[i][j] == '.') sum++; }
	}
	for (int i = 0; i < 59; i++) { for (int j = 0; j < 59; j++) dist[i][j] = (1 << 30); }
	queue<pair<int, int>>Q; Q.push(make_pair(0, 0)); dist[0][0] = 1;
	while (!Q.empty()) {
		int a1 = Q.front().first, a2 = Q.front().second; Q.pop();
		int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
		for (int i = 0; i < 4; i++) {
			int cx = a1 + dx[i], cy = a2 + dy[i];
			if (cx < 0 || cy < 0 || cx >= H || cy >= W || dist[cx][cy] <= dist[a1][a2] + 1 || S[cx][cy] == '#') continue;
			Q.push(make_pair(cx, cy));
			dist[cx][cy] = dist[a1][a2] + 1;
		}
	}
	if (dist[H - 1][W - 1] == (1 << 30)) cout << "-1" << endl;
	else cout << sum - dist[H - 1][W - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

int main(){
    int r, g, b, n; cin >> r >> g >> b >> n;
    int cnt = 0;
    rep(i, n+1)rep(j, n+1)if(r*i+g*j <= n && (n-r*i-g*j)%b == 0) cnt++;
    cout << cnt << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}


const int MAX_N = 105;
int w[MAX_N];
int v[MAX_N];

const int MAX_V = 1000000 + 10;
ll dp[2][MAX_V]; // dp[i, j] := i番目までで価値 j を達成する最小重さ

int main2() {
  int N = nextInt();
  int W = nextInt();
  REP(i, N) {
    w[i] = nextInt();
    v[i] = nextInt();
  }

  REP(j, MAX_V) dp[0][j] = W + 1;
  dp[0][0] = 0;

  REP(i, N) {
    const int f = i & 1;
    const int nf = 1 - f;
    REP(j, MAX_V) dp[nf][j] = dp[f][j];
    REP(j, MAX_V) {
      if (j + v[i] < MAX_V)
        chmin(dp[nf][j + v[i]], dp[f][j] + w[i]);
    }
  }

  int ans = 0;
  for (int j = 0; j < MAX_V; j++)
    if (dp[N&1][j] <= W)
      ans = j;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    ll x, y, z; cin >> x >> y >> z;
    ll ans = (1LL<<60);


    ll a,b;
    a = x*y*(z/2);
    b = x*y*(z - z/2);
    ans = min(ans, abs(a-b));

    a = y*z*(x/2);
    b = y*z*(x - x/2);
    ans = min(ans, abs(a-b));

    a = z*x*(y/2);
    b = z*x*(y - y/2);
    ans = min(ans, abs(a-b));

    cout << ans << endl;
}

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

using namespace std;
typedef long long int ll;
ll N1097 = 1000000007LL;

ll N, K;
ll A[1000000];
ll d[1000000];
int main(){
  cin >> N >> K;
  for(ll i=0;i<N;i++){
    scanf("%ld", &A[i]);
  }
  //
  for(ll l=0;l<K;l++){
    for(ll i=0;i<=N;i++){
      d[i] = 0LL;
    }
    for(ll i=0;i<N;i++){
      ll a = A[i];
      d[max(0LL, i-a)] += 1;
      d[min(N, i+a+1)] -= 1;
    }
    ll tmp = 0;
    for(ll i=0;i<N;i++){
      tmp += d[i];
      A[i] = tmp;
    }
    int f=1;
    for(ll i=0;i<N;i++){
      if(A[i]!=N){
        f=0;
        break;
      }
    }
    if(f){
      break;
    }
  }
  for(ll i=0;i<N;i++){
    printf("%d ", A[i]);
  }

}




Measured memory_bytes: 6952
a,b,x = [int(i) for i in input().split()]
from math import atan
from math import degrees
def deg(n):
    return degrees(atan(n))
V = a*a*b
if V/2 == x:
    xa = deg(1)
    xa = str(xa) + '0000000000'
    print(xa)
    exit()
if V/2 > x:
    xa = deg(a*b*b/(2*x))
    print(xa)
    exit()
if V/2 < x:
    xa = deg(2*(V-x)/a**3)
    print(xa)
    exit()

Measured memory_bytes: 3064
n = int(input())
a = [0]+list(map(int, input().split()))+[0]
result = 0
for i in range(n+1):
    result += abs(a[i]-a[i+1])
for i in range(1,n+1):
    print(result - abs(a[i]-a[i+1])-abs(a[i]-a[i-1])+abs(a[i+1]-a[i-1]))

Measured memory_bytes: 14048
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    vector<int> h(n+10,0);
    for(int i = 1; i <= n; i++){
        cin >> h[i];
    }
    int ans = 0;
    int ma = 0;
    for(int i = 1; i <= n; i++){
        if(ma <= h[i]){
            ans++;
        }
        ma = max(ma,h[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	bool ans=false;
	string s;
	cin>>s;
	ll a,b;
	for(int i=0;i<s.size()-1;i++){
		if(s[i]==s[i+1]){
			ans=true;
			a=i+1;b=i+2;
		}
	}
	for(int i=0;i<ll(s.size()-2);i++){
		if(s[i]==s[i+2]){
			ans=true;
			a=i+1;b=i+3;
		}
	}
	if(ans){
		cout << a << " "<<b<<endl;
	}
	else{
		cout << -1 << " "<<-1 <<endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 512
import sys
INF = 10**9
sys.setrecursionlimit(INF)
import math


def main():
    x, = map(int, open(0).read().split())

    """
    x=a^5-b^5=(a-b)(a^4+a^3b+a^2b^2+ab^3+b^4)
    x//(a-b)=int>0
    a-b>0
    x=O(a^4)
    """

    for i in range(-1000, 1000 + 1):
        for j in range(-i + 1, i):
            if i**5 - j**5 == x:
                a = i
                b = j
                break

    ans = f'{a} {b}'
    print(ans)
    return(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9204
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(s.hasNextInt()) {
            int a = s.nextInt();
            int b = s.nextInt();
            if(a == 0 && b == 0) break;
            if(a > b) {
                int t = a;
                a = b;
                b = t;
            }
            System.out.printf("%d %d\n", a, b);
        }
    }
}

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

int main() {
string S;
  cin >> S;
  int k = 1;
int result = 1;
  for(int a = 0;a < S.length();a++){
   if(k == 1){
    if(S[a] == 'L')result = 0; 
   }
    if(k == -1){
    if(S[a] == 'R')result = 0; 
   }
    k *= -1;
  }
  if(result == 1)cout << "Yes" << endl;
  if(result == 0)cout << "No" << endl;
}

Measured memory_bytes: 256
import numpy as np
H,W = map(int, input().split(" "))
a = []
for h in range(H):
    a.append(list(input()))
A = np.array(a)
A = (A=="#")
for h in range(H):
    word = ""
    for w in range(W):
        if any(A[h]) and any(A.T[w]):
             if A[h][w]:
                 word += "#"
             else:
                 word += "."
    if word :print(word)


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

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int L, R, d, ans = 0;
    cin >> L >> R >> d;
    for (int i = L; i <= R; i++) {
        if (i % d == 0) ans++;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3608
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        for(int i=0;i<n;i++) {
            double x1 = sc.nextDouble();
            double y1 = sc.nextDouble();
            double x2 = sc.nextDouble();
            double y2 = sc.nextDouble();
            double x3 = sc.nextDouble();
            double y3 = sc.nextDouble();
            double x4 = sc.nextDouble();
            double y4 = sc.nextDouble();
            if(Math.abs((x2-x1)*(y4-y3)-(y2-y1)*(x4-x3))<1e-10){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
        }
    }
}

Measured memory_bytes: 23208
#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)

vector<lli> s,t;
signed main(){

	lli a,b,q;
	cin>>a>>b>>q;
	s.resize(a+2);
	t.resize(b+2);

	s[0]=-INF;
	s[a+1]=INF;
	t[0]=-INF;
	t[b+1]=INF;
	REP(i,0,a)cin>>s[i+1];
	REP(i,0,b)cin>>t[i+1];

	REP(i,0,q){
		lli x;
		cin>>x;

		vector<lli> v[2];
		auto itr = lower_bound(s.begin(),s.end(),x);
		v[0].push_back(*itr);
		v[0].push_back(*(itr-1));

		itr = lower_bound(t.begin(),t.end(),x);
		v[1].push_back(*itr);
		v[1].push_back(*(itr-1));

		lli ans=INF;
		for(auto e0:v[0])for(auto e1:v[1]){
			ans = min({ans,abs(x-e0)+abs(e0-e1),abs(x-e1)+abs(e1-e0)});
		}
		cout<<ans<<endl;
	} 
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

constexpr int MOD = 1000000007;

// + - * / ^
int mod(int a)
{
	int res = a % MOD;
	if(res < 0) {
		return res + MOD;
	}
	return res;
}
int mul_mod(int a, int b)
{
	ll res = ((ll)a * (ll)b) % MOD;
	return mod((int)res);
}
int pow_mod(int a, int b)
{
	ll res = 1;
	while (b > 0) {
		if(b & 1) {
			res = res * (ll)a % (ll)MOD;
		}
		a = mul_mod(a, a);
		b >>= 1;
	}
	return (int)res;
}
int inv_mod(int a)
{
	return pow_mod(a, MOD - 2);
}
int div_mod(int a, int b)
{
	return mul_mod(a, inv_mod(b));
}

// ! C
constexpr int FAC_MAX = 100000;
ll fac[FAC_MAX], finv[FAC_MAX], inv[FAC_MAX];
void com_init()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < FAC_MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll com_mod(int a, int b){
	if (a < b) return 0;
	if (a < 0 || b < 0) return 0;
	return fac[a] * (finv[b] * finv[a - b] % MOD) % MOD;
}

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<ll> x(n), y(m);
	rep (i, n) cin >> x[i];
	rep (i, m) cin >> y[i];
	ll a = 0, b = 0;
	rep (i, n - 1) {
		ll tmp = min(i + 1, n - 1 - i);
		// cout << mul_mod((n - (2 * tmp - 1) - 1) + tmp, tmp) << " ";
		a = mod(a + mul_mod(mul_mod((n - (2 * tmp - 1) - 1) + tmp, tmp), x[i + 1] - x[i]));
	}
	rep (i, m - 1) {
		ll tmp = min(i + 1, m - 1 - i);
		b = mod(b + mul_mod(mul_mod((m - (2 * tmp - 1) - 1) + tmp, tmp), y[i + 1] - y[i]));
	}
	// cout << a << " " << b << "\n";
	cout << mul_mod(a, b) << "\n";
	return 0;
}

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

int main() {
  int W,H,N;
  cin >> W >> H >> N;
  vector<int> a(N);
  vector<pair<int,int>> p(N);
  for(int i=0;i<N;i++){
    int x,y;
    cin >> x >> y;
    p.at(i) = pair<int,int>(x,y);
    cin >> a.at(i);
  }
  vector<vector<int>> plain(W,vector<int>(H,0));
  for(int i=0;i<N;i++){
    if(a.at(i) == 1){
      for(int j=0;j<p.at(i).first;j++){
        for(int k=0;k<H;k++){
          plain.at(j).at(k) = 1;
        }
      }
    }
    if(a.at(i) == 2){
      for(int j=p.at(i).first;j<W;j++){
        for(int k=0;k<H;k++){
          plain.at(j).at(k) = 1;
        }
      }
    }
    if(a.at(i) == 3){
      for(int j=0;j<W;j++){
        for(int k=0;k<p.at(i).second;k++){
          plain.at(j).at(k) = 1;
        }
      }
    }
    if(a.at(i) == 4){
      for(int j=0;j<W;j++){
        for(int k=p.at(i).second;k<H;k++){
          plain.at(j).at(k) = 1;
        }
      }
    }
  }
  int res = 0;
  for(int i=0;i<W;i++){
    for(int j=0;j<H;j++){
      if(plain.at(i).at(j) == 0){
        res++;
      }
    }
  }
  cout << res << endl;
  
  return 0;
}

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

int L, R;

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

    ll ans = 0;
    if (R - L < 2019) {
        ll min_mod = 1.0e9;
        for (ll i = L; i < R; i++) {
            for (ll j = i+1; j <= R; j++) {
                min_mod = min(min_mod, (j*i)%2019);
            }
        }

        ans = min_mod;
    }

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


Measured memory_bytes: 256
N, K = list(map(int, input().split()))
heights = list(map(int, input().split()))

temp = "0" + str(N) + "b"
case = []
for i in range(2 ** N):
    x = format(i, temp)
    if x[0] == "1" and x.count("1") >= K:
        case.append(x)

result = []
for x in case:
    test = heights.copy()
    now = test[0]
    for y in range(1, N):
        if x[y] == "1":
            if test[y] <= now:
                test[y] = now + 1
                now = test[y]
            else:
                now = test[y]
        else:
            now = max(now, test[y])
    result.append(test)

ans=float('inf')
for i in result:
    cost = 0
    for j in range(N):
        if heights[j] < i[j]:
            cost += i[j] - heights[j]
    ans = min(ans, cost)

print(ans)

Measured memory_bytes: 9612
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

map<ll, ll> prime_factor(ll n){
    map<ll,ll> com;
    for(ll i = 2LL; i*i<=n; ++i){
        while(n%i==0LL){
            com[i]++;
            n /= i;
        }
    }
    if(n != 1LL)com[n]++;
    return com;
}

int main(){
	int N; cin>>N;
	map<ll, ll> fact_cnt;
	for(int i = 1; i<=N; ++i){
		map<ll,ll> elm;
		elm = prime_factor(i);
		for(auto x:elm){
			fact_cnt[x.first] += x.second;
		}
	}
	ll ans = 1;
	for(auto x:fact_cnt){
		ans *= (x.second+1LL);
		ans %= MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
c = []
for i in range(10):
    c.append(list(map(int, input().split())))
for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])
ans = 0
for j in range(h):
    a = list(map(int, input().split()))
    for j in range(w):
        if a[j] != -1:
            ans += c[a[j]][1]
print(ans)


Measured memory_bytes: 3064
import java.util.*;
 
class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    double a = sc.nextDouble();
    double calc1 = Math.pow(a,2);
    double calc2 = Math.pow(a,3);
    
    System.out.println((int)a + (int)calc1 + (int)calc2);
  }
}

Measured memory_bytes: 37380
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i ++){
        cin >> a.at(i);
    }

    int count = 0;
    for(int i = 0;i < n;i ++){
        if(a.at(i) < 0) count ++;
    }

    for(int i = 0;i < n;i ++) a.at(i) = abs(a.at(i));

    sort(a.begin(),a.end());

    int ans = 0;
    if(count % 2 == 0) ans += a.at(0);
    else ans -= a.at(0);

    for(int i = 1;i < n;i ++) ans += a.at(i);

    cout << ans << endl;
}

Measured memory_bytes: 1024
//alds_dictionary
#include<bits/stdc++.h>
using namespace std;
bool d[99999999];
int number(char a){
  switch(a){
    case 'A':
      return 1;
      break;
    case 'C':
      return 2;
      break;
    case 'G':
      return 3;
      break;
    case 'T':
      return 4;
      break;
  }
}
int main(){
  int n; scanf("%d", &n);
  vector<string> v;
  for(int i = 0; i < n; i++){
    string o, s;
    cin >> o >> s;
    int tmp=1, index=0;
    if(o == "insert"){
      //v.push_back(s);
      for(int j = 0; j < s.length(); j++){
        index += tmp*number(s[j]);
        tmp*=5;
      }
      //cout << index << endl;
      d[index] = true;
    } else { //find
      //if(find(v.begin(), v.end(), s) != v.end()) puts("yes");
      for(int j = 0; j < s.length(); j++){
        index += tmp*number(s[j]);
        tmp*=5;
      }
      //cout << index << "  ";
      if(d[index]) puts("yes");
      else puts("no");
    }
  }
}


Measured memory_bytes: 8432
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

#define MAX_N 210
#define INF 100000

// 全対全の距離を求める N^3
int n;
long d[MAX_N][MAX_N]; // i->jのコスト あらかじめINF初期化してから入力を反映させる
long ans=0;
void warshall_floyd() { 
    for (int k=0; k<n; k++)
        for (int i=0; i<n; i++)
            for (int j=0; j<n; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                if (k == n-1 && d[i][j] < INF)
                    ans = max(ans, d[i][j]);
            }
}

vector<int> G[201];
bool color[201], visited[201]={0};
bool dfs(int i=0, bool c=true) {
    color[i] = c;
    visited[i] = true;
    for (auto g:G[i]) {
        if ((!visited[g] && !dfs(g, !c)) || color[g] == c) 
            return false;
    }
    return true;
}

int main() {
    cin >> n;
    string s;
    for (int i=0; i<n; i++) {
        cin >> s;
        for (int j=0; j<n; j++) {
            if (i == j) {
                d[i][i] = 0;
                continue;
            }
            if (s[j] == '1') {
                d[i][j] = 1;
                G[i].push_back(j);
            }
            else d[i][j] = INF;
        }
    }
    if (!dfs()) {
        cout << -1 << '\n';
        return 0;
    }
    warshall_floyd();
    cout << ans + 1 << '\n';
    return 0;
}

Measured memory_bytes: 768
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    S = input()
    acgt = ('A', 'C', 'G', 'T')
    ans = 0
    l = 0
    while (l < len(S)) and (len(S)-l > ans):
        r = l+1
        while (r < len(S)+1) and (S[r-1] in acgt):
            r += 1
        ans = max(r-1-l, ans)
        l += 1

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3060
//IDE with C++5.3.0.2
#include <bits/stdc++.h>
#define MAX 2147483647
#define _MATH_DEFINES_DEFINED
#pragma GCC optimize("O2")
using namespace std;
int dx[4]={-1,1,0,0};
int dy[4]={0,0,1,-1};
int main(void){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	int n,m,ans=0;
	cin>>n>>m;
	char C[n+1][m+1];
	bool a[n+1][m+1];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>C[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			int d[n+1][m+1];
			memset(d,-1,sizeof(d));
			if(C[i][j]=='#') continue;
			deque<pair<int,int> > q;
			d[i][j]=0;
			q.push_back(make_pair(i,j));
			while(!q.empty()){
				pair<int,int> p=q.front();
				q.pop_front();
				int y=p.first;
				int x=p.second;
				for(int k=0;k<4;k++){
					int ny=y+dy[k];
					int nx=x+dx[k];
					if(ny>n||ny<=0||nx>m||nx<=0) continue;
					if(C[ny][nx]=='.'&&d[ny][nx]==-1){
						d[ny][nx]=d[y][x]+1;
						ans=max(ans,d[ny][nx]);
						q.push_back(make_pair(ny,nx));
					}
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
fun main(args:Array<String>) {
    val (a,b) = readLine()!!.split(" ").map { it.toInt() }
    var ans = 0
    for(i in (a..b)) {
        val t = i.toString()
        val tr = t.reversed()
        if(t == tr) {
            ans ++
        }
    }
    println(ans)
}

Measured memory_bytes: 39976
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;

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

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

int main(){
    vector< vector<int> > v(3, vector<int>(3));
    
    for(int i = 0; i < 3; ++i){
        for(int j = 0; j < 3; ++j) cin >> v[i][j];
    }
    for(int a0 = 0; a0 <= 100; ++a0){
        int b0 = v[0][0] - a0;
        int b1 = v[0][1] - a0;
        int b2 = v[0][2] - a0;
        int a1 = v[1][0] - b0;
        int a2 = v[2][0] - b0;
        if(a1 + b1 == v[1][1] && a1 + b2 == v[1][2] && a2 + b1 == v[2][1] && a2 + b2 == v[2][2]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main(){
long long n,i,ans=0;
cin>>n;

if(n==2)
return cout<<0,0;

ans+=n-1;
for(i=2;i*i<=n;++i){
    if(i*i == n){
        if(n/(i-1) == n%(i-1))
        ans+= i-1;
    }else
    if(n%i == 0){
        if(n/(i-1) == n%(i-1))
        ans+= i-1;
        if(n/(n/i-1) == n%(n/i-1))
         ans+= n/i - 1;
    }
}

cout<<ans;

}

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

int main() {
    int X,Y,Z,K;
    cin >> X >> Y >> Z >> K;
    vector<ll>A(X);
    vector<ll>B(Y);
    vector<ll>C(Z);
    for (int i = 0; i < X; ++i) cin >> A[i];
    for (int i = 0; i < Y; ++i) cin >> B[i];
    for (int i = 0; i < Z; ++i) cin >> C[i];

    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());

    priority_queue<vector<ll>> q;
    q.push({A[0]+B[0]+C[0],0,0,0});

    // std::set を使ってフラグ管理をすればいいらしい
    set<tuple<int,int,int>> se;

    for (int i = 0; i < K; ++i){
        cout << q.top()[0] << endl;
        ll qx = q.top()[1];
        ll qy = q.top()[2];
        ll qz = q.top()[3];
        q.pop();

        if(qx+1 < X){
            tuple<int,int,int> t(qx+1,qy,qz);
            if(!se.count(t)){
                se.insert(t);
                q.push({A[qx+1] + B[qy] + C[qz], qx+1, qy, qz});
            }
        }
        if(qy+1 < Y) {
            tuple<int,int,int> t(qx,qy+1,qz);
            if(!se.count(t)){
                se.insert(t);
                q.push({A[qx] + B[qy+1] + C[qz], qx, qy+1, qz});
            }
        }
        if(qz+1 < Z) {
            tuple<int,int,int> t(qx,qy,qz+1);
            if(!se.count(t)){
                se.insert(t);
                q.push({A[qx] + B[qy] + C[qz+1], qx, qy, qz+1});
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans=0;
  cin >> n;
  long long a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    a[i]--;
  }
  for(int i=0;i<n;i++){
    if(i==a[a[i]]) ans++;
  }
  cout << ans/2 << endl;
  return 0;
}


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

int main() {

    int n;
    cin >> n;
    vector<int> a(n);
    int scoreA = 0;
    int scoreB = 0;

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

    for(int i = 0; i < n; i++){

        int max = 0;
    
        for(int j = 0; j < n; j++){

            if(a[j] > max)
            max = a[j];

        }

        if(i % 2 == 0)  scoreA += max;
        else            scoreB += max;

        for(int k = 0; k < n; k++){
            if(a[k] == max){
                a[k] = 0;
                break;
            }

        }

    }

    cout << scoreA - scoreB;

}

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

#define  int        long long int
 #define    sp(x)                 setprecision(x)
#define    bp(x)           __builtin_popcount(x)
 #define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}
int a[10000007];
int32_t main()
{
    fast
    int n,ans=0;
    cin>>n;
    f(i,1,n)
        for(int j=i;j<=n;j+=i)
            a[j]++;
    f(i,1,n)
        ans+= a[i]*i;
    cout<<ans;
}

Measured memory_bytes: 81752
#include<stdio.h>
int main(){
  int d[10];
  int v1,v2;
  int i,s=0;
  double t,x;
  while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
    &d[0],&d[1],&d[2],&d[3],&d[4],&d[5],&d[6],&d[7],&d[8],&d[9],&v1,&v2)!=EOF){
    s=0;
    for(i=0;i<10;i++){
      s+=d[i];
    }
    v2+=v1;
    t=(double)s/(double)v2;
    x=t*v1;
    for(i=0;i<10;i++){
      if(x<=0)break;
      x-=d[i];
    }
    printf("%d\n",i);
  }
  return 0;
}

Measured memory_bytes: 596
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] g = buildGraph(sc, n, n-1);
        boolean[] used = new boolean[n];
        ArrayDeque<Integer> fq = new ArrayDeque<>();
        ArrayDeque<Integer> sq = new ArrayDeque<>();
        fq.add(0); sq.add(n-1);
        int fsum = 0; int ssum = 0;
        for (int i = 0; i < n; i++) {
            ArrayDeque<Integer> tq = new ArrayDeque<>();
            while(!fq.isEmpty()){
                int nex = fq.poll();
                if(!used[nex]){
                    fsum++; used[nex] = true;
                    for(int a : g[nex]){
                        tq.add(a);
                    }
                }
            }
            fq.addAll(tq);
            tq.clear();
            while(!sq.isEmpty()){
                int nex = sq.poll();
                if(!used[nex]){
                    ssum++; used[nex] = true;
                    for(int a : g[nex]){
                        tq.add(a);
                    }
                }
            }
            sq.addAll(tq);
        }
        System.out.println(fsum <= ssum ? "Snuke" : "Fennec");
        sc.close();

    }

    public static int[][] buildGraph(Scanner sc, int n, int m) {
        int[][] graph = new int[n][];
        int[][] edges = new int[m][2];
        int[] deg = new int[n];
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            edges[i][0] = a;
            edges[i][1] = b;
            deg[a]++;
            deg[b]++;
        }
        for (int i = 0; i < n; i++) {
            graph[i] = new int[deg[i]];
        }
        for (int i = 0; i < m; i++) {
            int a = edges[i][0];
            int b = edges[i][1];
            graph[a][--deg[a]] = b;
            graph[b][--deg[b]] = a;
        }

        return graph;
    }

}


Measured memory_bytes: 96404
from collections import deque

N, M = map(int, input().split())

A = [[] for _ in range(N)]
for i in range(M):
    Am, Bm = map(int, input().split())
    Am -= 1
    Bm -= 1
    A[Am].append(Bm)
    A[Bm].append(Am)


is_visited = [False for _ in range(N)]
ans = [0 for _ in range(N)]
def bfs():
    queue = deque()
    queue.append(0)
    is_visited[0] = True
    while queue:
        pos = queue.popleft()
        for next_pos in A[pos]:
            if is_visited[next_pos] == False:
                is_visited[next_pos] = True
                queue.append(next_pos)
                ans[next_pos] = pos

bfs()

if False in is_visited:
    print("No")
else:
    print("Yes")
    for i in range(N-1):
        print(ans[i+1]+1)



Measured memory_bytes: 34752
# AOJ 1563: Array Update
# Python3 2018.7.13 bal4u

def get(id):
	global a, d
	if id in dic: ans = dic[id]
	else: ans = a + (id-1)*d;
	return ans

dic = {}
N = int(input())
a, d = map(int, input().split())
M = int(input())
for i in range(M):
	x, y, z = map(int, input().split())
	if x == 0:
		vy, vz = get(y), get(z)
		dic[y] = vz
		dic[z] = vy
	else:
		vz = get(z)
		dic[y] = vz
K = int(input())
print(get(K))


Measured memory_bytes: 5600
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Puneet    //FastRead class is taken from different online Sources
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastInput in = new FastInput(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, FastInput in, PrintWriter out) {

            char[] str = in.ns().toCharArray();

            int one = 0, zr = 0;

            boolean is = false;

            for (int i = str.length - 1; i >= 0; i--) {
                if (str[i] == '1') {
                    one++;
                    is = true;
                }

                if (str[i] == '0')
                    zr++;
            }

            out.println(2 * Math.min(one, zr));
        }

    }

    static class FastInput {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastInput.SpaceCharFilter filter;

        public FastInput(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String ns() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22740
#include <stdio.h>
#include <string.h>
#define NUM(n) ((int)((n-'1')+1))
#define CONV(str) (NUM(str[1])+(int)(str[0]*10))
void print_ary(int *ary, int n){
    for(int i=0;i<n;i++){
        printf("%c%d",ary[i]/10,ary[i]%10);
        (i==n-1)? printf("\n"):printf(" ");
    }
}
void bubblesort(int *con, int *chk, int n){
    int i,j,buf;
    for(i=0;i<n;i++){chk[i]=con[i];}
    for(j=0;j<n-1;j++){
        for(i=0;i<n-1-j;i++){
            if (chk[i]%10>chk[i+1]%10){
                buf=chk[i];chk[i]=chk[i+1];chk[i+1]=buf;    
            }
        }
    }
    print_ary(chk,n);
    printf("Stable\n");
}
void selectionsort(int *ary, int *chk, int n){
    int m,i,j,addr,buf,flg=0;
    for(i=0;i<n;i++,m=1e9){
        for(j=i;j<n;j++){
            if (m>ary[j]%10){m=ary[j]%10,addr=j;}
        }
        buf=ary[i],ary[i]=ary[addr],ary[addr]=buf;
    }
    print_ary(ary,n);
    for(i=0;i<n;i++){if (chk[i] != ary[i]){flg=1;break;}}
    (flg==0)? printf("Stable\n"):printf("Not stable\n");
}
int main(void){
    int n,i;
    scanf("%d",&n);
    char ary[n][3];int con[n],chk[n];
    for(i=0;i<n;i++){scanf("%s",ary[i]);}
    for(i=0;i<n;i++){con[i]=CONV(ary[i]);}
    bubblesort(con,chk,n);
    selectionsort(con,chk,n);
    return 0;
}



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

#define vint vector<int>
#define vvint vector<vint>
#define sint stack<int>
#define qint queue<int>
#define rep(i, n) for(int i=0;i<(int)(n);i++) // 繰り返し処理
#define all(x) (x).begin(),(x).end() // 全体 こんな感じで使う→sort(all(a));
#define ct(a) cout << a << endl
#define iceil(a,b) (a+(b-1))/b //int ceil : 繰り上げの割り算 通常のceilではceil((7.0/2.0))のようにしなければならなかった。
#define ld long double
#define ll long long
#define ul unsigned long
vint CinLine(int N){vint v(N);for(int i=0;i<N;i++){cin >> v.at(i);}return v;}//cin line 連続でvectorに格納
void CoutLine(vint v){for(int i=0;i<v.size()-1;i++){cout<<v.at(i)<<" ";}cout << v.at(v.size()-1)<<endl;}

void Main(){
    string divide[4] = {"dream","dreamer","erase","eraser"};
    string S;
    cin >> S;

    // 左右反転
    reverse(all(S));
    rep(i,4){
        reverse(all(divide[i]));
    }
    // 端から切っていく
    bool isCan = true;
    for(int i = 0; i<S.size();){
        bool isDivide = false;
        for(int j = 0; j<4;j++){
            string d = divide[j];
            if(S.substr(i,d.size()) == d){
                isDivide = true;
                i += d.size();
            }
        }
        if(!isDivide){
            isCan = false;
            break;
        }
    }
    if(isCan) ct("YES");
    else ct("NO");

    return;
}

int main() {
    Main();
}


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

using namespace std;

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

  string a, b, c, now = "a", ans;

  cin >> a >> b >> c;

  while (true)
  {
    if (now == "a")
    {
      if (a.size() == 0)
      {
        ans = 'A';
        break;
      }
      now = a[0];
      a = a.erase(0, 1);
    }
    if (now == "b")
    {
      if (b.size() == 0)
      {
        ans = 'B';
        break;
      }
      now = b[0];
      b = b.erase(0, 1);
    }
    if (now == "c")
    {
      if (c.size() == 0)
      {
        ans = 'C';
        break;
      }
      now = c[0];
      c = c.erase(0, 1);
    }
  }

  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>	
#define intt long long 
using namespace std;	
const int maxx = 5e5+1314;	
const int M = 1e9+7;
intt read(){intt k;scanf("%lld",&k);return k;}
int a[maxx];
int n;
int last[maxx];
intt f[maxx];
struct edge{int x,y;}A[maxx];
int main(){	
	n=read();
	for(int i=1;i<=n;i++){	
		a[i]=read();
	}	
	f[0]=1;
	for(int i=1;i<=n;i++){	
		f[i]+=f[i-1];
		if(a[i-1]!=a[i]&&last[a[i]])f[i]+=f[last[a[i]]];
		f[i]%=M;
		last[a[i]]=i;
	}	
	cout<<f[n]<<endl;
	return 0;
}	

Measured memory_bytes: 8832
#include <iostream>
#include <cassert>

constexpr int kAValue = 10000;
constexpr int kBValue = 5000;
constexpr int kCValue = 1000;

int main() {
  int n, y;
  std::cin >> n >> y;
  int amax = std::min(y / kAValue, n);
  int amin = std::max((y - kBValue * n) / kAValue, 0);
  for (int a = amin; a <= amax; ++a) {
    int asum = a * kAValue;
    int adiff = y - asum;
    int bmax = std::min(adiff / kBValue, n - a);
    int bmin = std::max((adiff - kCValue * (n - a)) / kBValue, 0);
    for (int b = bmin; b <= bmax; ++b) {
      int bsum = asum + b * kBValue;
      int c = n - a - b;
      int csum = bsum + c * kCValue;
      if (csum == y) {
        std::cout << a << " " << b << " " << c << std::endl;
        assert(a * kAValue + b * kBValue + c * kCValue == y);
        return 0;
      }
    }
  }
  std::cout << -1 << " " << -1 << " " << -1 << std::endl;
  return 0;
}


Measured memory_bytes: 256
var
	f:boolean;
	n,i,x:longint;
begin
	read(n);
    f:=false;
    for i:=1 to n do
    begin
    	read(x);
        f:=f or (x mod 2=1); 
    end;
    if f then writeln('first')
    else writeln('second');
end.

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int a,b;cin>>a>>b;

  if(a+b<24)out(a+b)
  else out(a+b-24)

  return 0;
}


Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())
    mod = 10 ** 9 + 7
    ans = [0] * (k + 1)
    x = n - k + 1
    ans[1] = x
    a, b = n - k, k - 1
    for i in range(2, k + 1):
        x, _ = divmod(x * a * b, i * (i - 1))
        ans[i] = x % mod
        a -= 1
        b -= 1

    print('\n'.join(map(str, ans[1:])))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
const int MN=2004;
int N,ans,sum,A[MN];
std::bitset<MN*MN>B;
int main(){
    scanf("%d",&N);
    for(int i=0;i<N;++i){
        scanf("%d",A+i);
        sum+=A[i];
    }
    B.set(0);
    for(int i=0;i<N;++i)
        B|=B<<A[i];
    for(int i=sum+1>>1;i<MN*MN;++i)
        if(B[i]){
            ans=i;
            break;
        }
    printf("%d",ans);
}


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

int main(){
    int A, B;
    cin >> A >> B;

    int count = 0;

    int N = B - A;

    for(int i = 0; i <= N; i++){
        if((A / 10000 == A % 10) && (A / 10 % 10 == A / 1000 % 10)){
            count++;
        }
        A++;
    }

    cout << count << endl;

}

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


int main()
{
	char in[1200];
	char out;
	int i = 0;

	cin.getline(in, sizeof(in));

	while (1)
	{
		bool s_tf = false;
		bool l_tf = false;

		s_tf = islower(in[i]);
		l_tf = isupper(in[i]);

		if (s_tf == true)
		{
			out = toupper(in[i]);
			cout << out;
		}
		else if (l_tf == true)
		{
			out = tolower(in[i]);
			cout << out;
		}
		else if (in[i] == '\0')
		{
			cout << endl;
			break;
		}
		else
		{
			cout << in[i];
		}
		i++;
	}

	return 0;
}

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

signed main() {
  int N, M;
  cin >> N >> M;
  int x[101010];
  memset(x, 0, sizeof(x));
  for (int i = 0; i < M; i++) {
    int l, r;
    cin >> l >> r;
    l--, r--;
    x[l]++;
    x[r + 1]--;
  }

  int ans = 0;
  for (int i = 1; i < N; i++) {
    x[i] += x[i - 1];
  }

  for (int i = 0; i < N; i++) {
    if (x[i] == M) ans++;
  }

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


Measured memory_bytes: 1024