akhauriyash/Code-Regression huggingface dataset:
using AtCoderBeginnerContest133.Questions;
using AtCoderBeginnerContest133.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest133.Questions
{
    public class QuestionD : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var a = inputStream.ReadLongArray();

            var rains = new long[n];

            for (int i = 0; i < n; i++)
            {
                rains[0] += a[i] * (i % 2 == 0 ? 1 : -1);
            }

            for (int i = 1; i < n; i++)
            {
                rains[i] = 2 * a[i - 1] - rains[i - 1];
            }

            yield return string.Join(" ", rains);
        }
    }
}


namespace AtCoderBeginnerContest133
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionD();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest133.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest133.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion


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

int main () {
    int N;
    cin >> N;
    string alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string S;
    cin >> S;
    
    for (int i=0; i<S.size(); i++) {
        for (int j=0; j<26; j++) {
            if (alphabet.at(j)==S.at(i)) {
                cout << alphabet.at((j+N)%26);
            }
        }
    }
    cout << endl;
}


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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    const int inf = 100000000;
    int n,m;
    cin>>n>>m;
    int a[1000],b[1000],c[1000],dist[100][100];

    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;
        b[i]--;
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j)
                dist[i][j]=0;
            else
                dist[i][j]=inf;
        }
    }

    for(int i=0;i<m;i++){
        dist[a[i]][b[i]]=c[i];
        dist[b[i]][a[i]]=c[i];
    }

    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }

    int ans=m;
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            if(dist[j][a[i]]+c[i]==dist[j][b[i]]){
                ans=ans-1;
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N,K;cin>>N>>K;
  long a;
  if(N>K){
    N=N-N/K*K;
  }
  if(N<K)a=min(N,abs(N-K));
  else if(N==K)a=0;
  cout<<a<<endl;
}


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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int maxn = max(b, d);
    int minn = min(a, c);
    int k = 0;
    for (int i = minn; i <= maxn; i++)
        if ((i >= a && i <= b) && (i >= c && i <= d))
            k++;
    if (k == 0)
        k++;
    cout << k - 1 << endl;
    return 0;
}


Measured memory_bytes: 256
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef pair <int, int> pii;
#define pb push_back
#define f first
#define s second
#define sz(x) (int)x.size()
const int mx = 3e5 + 10, m = 998244353;
int fact[mx], inv[mx];
int _pow(int a, int b){
	if(!b)
		return 1;
	return ((_pow((a * a) % m, b >> 1) * ((b & 1) ? a : 1)) % m);
}
int c(int n, int k){
	return((((fact[n] * inv[k]) % m) * inv[n - k]) % m);
}
void pre(){
	fact[0] = 1;
	for(int i = 1; i <= mx; i++)
		fact[i] = (fact[i - 1] * i) % m;
	inv[mx] = _pow(fact[mx] , m - 2);
	for(int i = mx - 1; i >= 0; i--)
		inv[i] = ((inv[i + 1] * (i + 1)) % m);
	return;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	cout.tie(0);
	pre();
	int n, a, b, k, ans = 0;
	cin >> n >> a >> b >> k;
	for(int i = 0; i <= n; i++){
		if(k - (i * a) >= 0){
			if((k - (i * a)) % b == 0 && (k - (i * a)) / b <= n){
		//		cout << i << " " << (k - (i * a)) / b << endl;
		//		cout << fact[n] << " " << inv[i] << " " << inv[n - i] << " " << c(i , n) << endl;
				ans += c(n , i) * c(n , ((k - (i * a)) / b));
				ans %= m;
	//			cout << ans << endl;
			}
		}
		else
			break;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4992
n=int(input())
s,t=map(str,input().split())
d=[]
d.append(list(s))
d.append(list(t))

e=[]
for i in range(n):
    e.append(d[0][i])
    e.append(d[1][i])

for j in range(1,2*n):
    e[0]=e[0]+e[j]
    
#' '.join(e)
#print(e)
print(e[0])

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>
using namespace std;
using u64 = uint64_t;



int main()
{
    int N;
    int D[100][2];
    cin >> N;
    for (int i=0; i<N; i++) {
        cin >> D[i][0] >> D[i][1];
    }
    for (int i=0; i<N-2; i++) {
        if (D[i  ][0] == D[i  ][1] &&
            D[i+1][0] == D[i+1][1] &&
            D[i+2][0] == D[i+2][1])
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    // no hit
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3128
#include <stdio.h>

void merge(int*, int, int, int);
void mergeSort(int*, int, int);

int A[500000], n;
int count=0;

int main()
{
  
  int i;
  
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }

  mergeSort(A,0,n);

  for(i=0; i<n; i++){
    printf("%d",A[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n%d\n",count);
  return 0;
}

  int L[500000], R[500000];
void merge(int *A, int left, int mid, int right){

  int k, n1, n2, i, j;
  
  n1 = mid - left;
  n2 = right - mid;
  for(i=0; i<=n1-1; i++) L[i] = A[left + i];
  for(i=0; i<=n2-1; i++) R[i] = A[mid + i];
  L[n1] = 1000000000;
  R[n2] = 1000000000;
  i = 0;
  j = 0;
  for(k=left; k<=right-1; k++){
    if(L[i]<=R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else{
      A[k]=R[j];
      j = j + 1;
    }
  count++;
  }
}
	

void mergeSort(int *A, int left, int right){

  int mid;
  
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

Measured memory_bytes: 5488
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};


int main() {
    int n,k; cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    sort(all(h));
    for (int i=n-1;i>n-1-k; i--) {
        h[i]=0;
        if (i==0) break;
    }
    ll ans = 0;
    rep(i,n) ans += h[i];

    cout << ans << endl;
}  

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

bool search(int a[], int n, int t){
	a[n] = t;
	int i=0;
	while(a[i] != t){
		i++;
	}
	return (i != n);
}

int main() {
	int n1;
	cin>>n1;
	
	int s[n1];
	for(int i=0 ; i<n1 ; i++){
		cin>>s[i];
	}
	
	int n2;
	cin>>n2;
	
	int t,ans=0;
	for(int i=0 ; i<n2 ; i++){
		cin>>t;
		if(search(s,n1,t)) ans++;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
using namespace std;
typedef long long LL;
 
int main() {
	int t, i, j, k;
	int a, b, c ,F;
	
	cin >> a >> b;
 
	if ((a*b) % 2 == 0) {
		F = 0;
	}
	else {
		F = 1;
	}
 
	if (F == 1) {
		cout << "Odd" << endl;
	}
	else {
		cout << "Even" << endl;
	}
	return 0;
}

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

int main() {
    string S;
    int N, K;
    cin >> N >> K >> S;

    if(S.at(K-1) == 'A')
    S.at(K-1) = 'a';
    if(S.at(K-1) == 'B')
    S.at(K-1) = 'b';
    if(S.at(K-1) == 'C')
    S.at(K-1) = 'c';
    
cout << S << endl;

}

Measured memory_bytes: 256
#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 n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];

    if(n<=k){
        cout << 0 << endl;
        return 0;
    }

    //体力が多いモンスター上位k体は必殺技で倒す
    sort(all(h));
    rep(i,k){
        h.pop_back();
    }
    ll ans=0;
    for(int i=0; i<n-k; i++){
        ans += h.at(i);
    }
    cout << ans << endl;
    return 0;

}   

Measured memory_bytes: 4824
import sys

def solve():
    n, q = map(int, sys.stdin.readline().split())
    uf = UnionFind(n)
    
    for lp in range(q):
        c, x, y = map(int, sys.stdin.readline().split())

        if c == 0:
            uf.unite(x, y)
        else:
            print(1 if uf.same(x, y) else 0)


class UnionFind:

    def __init__(self, n):
        self.ds = [i for i in range(n)]
        self.root = [i for i in range(n)]
        self.rank = [0] * n

    def find_root(self, x):
        if self.root[x] == x:
            return x

        res = self.root[x]
        updates = [x]

        while res != self.root[res]:
            updates.append(res)
            res = self.root[res]

        for u in updates:
            self.root[u] = res

        return res

    def same(self, x, y):
        return self.find_root(x) == self.find_root(y)

    def unite(self, x, y):
        p = self.find_root(x)
        q = self.find_root(y)

        if p == q:
            return None

        if self.rank[p] < self.rank[q]:
            self.root[p] = q
        elif self.rank[q] < self.rank[p]:
            self.root[q] = p
        else:
            self.root[q] = p
            self.rank[p] += 1

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

if __name__ == '__main__':
    solve()

Measured memory_bytes: 9272
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;

const int N = 2e5+5;
int n;
ll t[N],T;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> T;
	for(int i = 0; i < n; ++i)
		cin >> t[i];
	sort(t,t+n);
	t[n] = 1LL<<60;
	ll ans = 0;
	for(int i = 0; i < n; ++i)
		ans += min(T,t[i+1]-t[i]);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

void solve(long long N, vector<long long> p){
	bool flg = false, res = true;
	rep(i, N) {
		if (p[i] != i+1) {
			if (!flg) {
				flg = true;
				ll c = p[i];
				p[i] = p[c-1];
				p[c-1] = c;
			} else {
				res = false;
			}
		}
	}
	if (res) cout << "YES" << endl; else cout << "NO" << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> p(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&p[i]);
	}
	solve(N, p);
	return 0;
}



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

int main(void){
    int n;
    cin >> n;
    vector<int> l(n);
    

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

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

    int count = 0;
    for(int i = 0;i < n - 2;i++){
        for(int j = i + 1;j < n - 1 ; j++){
            if(l[n-1] < l[i] + l[j]){
                count += n - j - 1;
            }
            else{
                for(int k = j + 1;k < n;k++){
                    if(l[i] < l[j] + l[k] && l[j] < l[k] + l[i] && l[k] < l[i] + l[j]){
                        count++;
                    } else if(l[k] >= l[i] + l[j]){
                        break;
                    }
                }
            }
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
using System;

public class Program
{
    public static void Main()
	{
        var input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

        var N = input[0];
        var Y = input[1];

        var ANum = -1;
        var BNum = -1;
        var CNum = -1;

        for (var i=0; i <= N; i++)
        {
            for (var j=0; j <= N-i; j++)
            {
                if (i * 10000 + j * 5000 + (N - i -j) * 1000 == Y)
                {
                    ANum = i;
                    BNum = j;
                    CNum = N - i - j;
                }
            }
        }
        Console.WriteLine($"{ANum} {BNum} {CNum}");
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>

#define CK(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long  LLINF = 1e15;

using namespace std;

string S;
/*  solution_1
int ind;
int state = 0;
bool parse(){
  if(ind == S.size()) return false;
  bool ret = true;
  if(S[ind] == 'm'){
    ind++;
    while(S[ind]!='w'){
      state = 1;
      bool tmp = parse();
      if(!tmp) return false;
    }
    ind++;
  }else if(state == 1 && S[ind] == 'e'){
    state = 2;
    ind++;
    ret = true;
  }else if(state == 2 && S[ind] == 'w'){
    state = 0;
    ind++;
    ret = true;
  }else{
    ret = false;
  }
  return ret;
}
*/

//solution_2
int parse(int p){
  if(S.size() <= p){
    return -1;
  }

  if(S[p] != 'm'){
    //p = parse(p);
    //if(p==-1 || p >= S.size()) return -1;
    return -1;
  }
  p++;
  if(S[p] != 'e'){
    p = parse(p);
    if(p==-1 || p >= S.size()) return -1;
  }
  p++;
  if(S[p] != 'w'){
    p = parse(p);
    if(p==-1 || p >= S.size()) return -1;
  }
  /*
  *????????§???????????????????????????????????¨
  *?????°?????????????????????????????£?????¨???????¬???????????????????????????????
  */
  p++;
  return p;
}

int main(){
  cin>>S;

  /*  solution_1
  ind = 0;
  if(parse() && ind == S.size()) cout<<"Cat"<<endl;
  else cout<<"Rabbit"<<endl;
  */

  //solution_2
  int t = parse(0);
  if(t == S.size()) cout<<"Cat"<<endl;
  else cout<<"Rabbit"<<endl;

  return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;
    vector<i64> A(N);
    REP(i, N) cin >> A[i];

    auto count_div2 = [](i64 a) {
        i64 cnt = 0;
        while (a % 2 == 0) {
            a /= 2;
            cnt++;
        }
        return cnt;
    };

    i64 ans = 0;
    REP(i, N) ans += count_div2(A[i]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <vector>
using namespace std;
#define FOR(__I,__N) for (int __I = 0; __I < __N; ++__I)

typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64, int64> pll;
typedef double db;
typedef long double ldb;

const int INF = 0x3f3f3f3f;
const int64 INF64 = 0x3f3f3f3f3f3f3f3fLL;

const int MOD = 998244353;

const int MAX_len = 300;

const int MAX_SZ = 3000;

int f[MAX_SZ+1][MAX_SZ+1];



int solve(int A,int B,int C,int D){
	f[A][B] = 1;
	for (int64 i = A; i <= C; ++i)
		for (int64 j = B; j <= D; ++j){
			if(i-1 >= 0 && j-1 >= 0){
				f[i][j] -= (i-1)*(j-1)%MOD*f[i-1][j-1]%MOD;
				if(f[i][j] < 0)	f[i][j] += MOD;
			}
			if(i + 1 <= C){
				f[i+1][j] += j*f[i][j]%MOD;
				if(f[i+1][j] >= MOD)	f[i+1][j] -= MOD;
			}
			if(j + 1 <= D){
				f[i][j+1] += i*f[i][j]%MOD;
				if(f[i][j+1] >= MOD)	f[i][j+1] -= MOD;
			}
		}

	return f[C][D];
}


int main(){
	int A,B,C,D;	cin >> A >> B >> C >>D;
	int ans = solve(A,B,C,D);
    printf("%d\n",ans);
}





Measured memory_bytes: 38800
#include<stdio.h>

int main(void) {
int a,b;
char op;

while(scanf("%d %c %d", &a, &op, &b)) {
switch (op) {
case '+': printf("%d\n", a+b); break;
case '-': printf("%d\n", a-b); break;
case '*': printf("%d\n", a*b); break;
case '/': printf("%d\n", a/b); break;
default :return (0);
}
}
}

Measured memory_bytes: 600
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct LNode
{
	int data;
	struct LNode *next, *pre;
}LNode, *LinkList;

LinkList L;

void Initialize()
{
	L = (LinkList)malloc(sizeof(LNode));
	L -> next = L;
	L -> pre = L;
}

void ListInsert(int x)
{
	LinkList s = (LinkList)malloc(sizeof(LNode));
	s -> data = x;
	s -> next = L -> next;
	L -> next -> pre = s;
	L -> next = s;
	s -> pre = L;	
}

LinkList ListSearch(int x)
{
	LinkList p;
	p = L -> next;
	while(p != L && p -> data != x)
	{
		p = p -> next;	
	}	
	return p;
} 

void DeleteNode(LinkList p)
{
	if(p == L)
		return;
	p -> next -> pre = p ->pre;
	p -> pre -> next = p ->next;
	free(p);
}

void DeleteFirst()
{
	DeleteNode(L -> next);
}

void DeleteLast()
{
	DeleteNode(L -> pre);
}

void DeleteData(int x)
{
	DeleteNode(ListSearch(x));
}

void PrintList()
{
	LinkList p = L -> next;
	int isf = 0;
	while(1)
	{
		if(p == L)
			break;
		if(isf++ > 0)
			printf(" ");
		printf("%d", p -> data);
		p = p -> next;
	}
	printf("\n");
}
int main()
{
	int n, x, size;
	char s[10];
	scanf("%d", &n);
	Initialize();
	while(n--)
	{
		scanf("%s", s);
		if(strlen(s) < 7)
		scanf("%d", &x);
		if(s[0] == 'i')
		{
			ListInsert(x);
			size++;
		}
		else if(s[0] == 'd')
		{
			if(s[6] == 'F')
			{
				DeleteFirst();
			}
			else if(s[6] == 'L')
			{
				DeleteLast();
			}
			else
				DeleteData(x);	
		size--;
		}
	}
	
	PrintList();
}



Measured memory_bytes: 33988
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	final long MOD = (long) (1e9 + 7);

	void run() {
		Scanner sc = new Scanner(System.in);
		long sum = 0;
		for (int i = 0; i < 3; ++i) {
			sum += sc.nextLong();
		}
		if(sum>=22) {
			System.out.println("bust");
		}else {
			System.out.println("win");
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


Measured memory_bytes: 21716
import fractions
a, b, c, d = map(int, input().split())
cn = b//c + (-a//c) + 1
dn = b//d + (-a//d) + 1
cd = (c*d)//fractions.gcd(c, d)
cdn = b//cd + (-a//cd) + 1
print(b-a+1-(cn+dn-cdn))

Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
const int maxn = 200005;
const int mod = 998244353;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int sum = 0;
    for (auto i:s) {
        sum += i - '0';
    }
    cout << max(9 * (int)(s.size() - 1) + s[0] - '0' - 1,sum) << '\n';
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
		
		int A =sc.nextInt();
		int B =sc.nextInt();
        
        if(A<=8 &&B<=8){
            System.out.println("Yay!");
        }else{
            System.out.println(":(");

        }
        
    }
}


Measured memory_bytes: 35616
#include<stdio.h>

int main() {
	int num[3];
	for (int x = 0; x < 3; x++) {
		scanf("%d", &num[x]);
	}
	int Max = 0;

	for (int y = 0; y < 3; y++) {
		if (num[(y + 2) % 3] + 10 * num[y] + num[(y + 1) % 3] >= Max) {
			Max = num[(y + 2) % 3] + 10 * num[y] + num[(1 + y) % 3];

		}


	}
	printf("%d", Max);
	return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Query {
    ll L;
    ll R;
    ll index;
};

struct BinaryIndexTree {
public:
    BinaryIndexTree(int n)
            : mN(n) {
        mPow = 1;
        while (mPow < n)
            mPow <<= 1;
        node.resize(n + 1);
        REP(i, n + 1) {
            node[i] = 0;
        }
    }

    ~BinaryIndexTree() {
        node.resize(0);
    }

    //! 1-index get
    ll sum(int index) {
        ll sum = 0;
        for (int i = index; i > 0; i -= i & (-i))
            sum += node[i];
        return sum;
    }

    //! 1-index add
    void add(int index, ll value) {
        for (int i = index; i <= mN; i += i & (-i))
            node[i] += value;
    }

    int lowerBound(ll value) {
        if (value <= 0)
            return 0;
        int x = 0;
        for (int k = mPow; k > 0; k >>= 1) {
            if (x + k <= mN && node[x + k] < value) {
                value -= node[x + k];
                x += k;
            }
        }
        return x + 1;
    }

private:
    vector<ll> node;
    ll mN;
    ll mPow;
};

ll C[500005];
Query A[500005];
ll T[500005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, Q;
    cin >> N >> Q;

    REP(i, N) {
        cin >> C[i];
        C[i]--;
    }
    REP(i, Q) {
        cin >> A[i].L >> A[i].R;
        A[i].index = i;
    }

    BinaryIndexTree bit(500005);
    sort(A, A + Q, [](Query a, Query b) { return a.R < b.R; });
    memset(T, -1, sizeof(T));

    vector<ll> ans(Q);
    ll index = 0;
    REP(i, Q) {
        while (index < A[i].R) {
            if (T[C[index]] > 0)
                bit.add(T[C[index]], -1);
            T[C[index]] = index + 1;
            index++;
            bit.add(index, 1);
        }
        ans[A[i].index] = bit.sum(A[i].R) - bit.sum(A[i].L - 1);
    }

    REP(i, Q) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 31076
#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define oo (1e18)
#define ll long long
#define LL unsigned long long
#define hh puts("")
using namespace std;
string a,b;
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-1;ch=getchar();}
    while(isdigit(ch)){ret=(ret<<3)+(ret<<1)+(ch^48);ch=getchar();}
    return ret*ff;
}
signed main(){
	cin>>a;
	b=a;
	reverse(a.begin(),a.end());
	for(int i=0;i<a.size();i++){
		if(a[i]=='p') a[i]='q';
		else if(a[i]=='b') a[i]='d';
		else if(a[i]=='d') a[i]='b';
		else if(a[i]=='q') a[i]='p';
	}
	if(a==b) printf("Yes");
	else printf("No");
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
const int mod=998244353;
int mul(int x, int y){ return (ll)x*y%mod;}
int add(int x, int y){ x+=y;return x>=mod?x-mod:x;}
int sub(int x, int y){ x-=y;return x<0?x+mod:x;}
const int N=200050;
char s[N];
int dp[N];
int main()
{
	int n;
	scanf("%i",&n);
	scanf("%s",s+1);
	int v2=1;
	while(n%2==0) v2*=2,n/=2;
	vector<int> ds;
    for(int m=1;m*m<=n;m++) if(n%m==0)
	{
		ds.pb(m);
		if(m*m!=n) ds.pb(n/m);
	}
	sort(ds.begin(),ds.end());
	int ans=0;
	for(int m:ds)
	{
		int b=0;
		for(int i=1;i<=m*v2;i++) b=mul(b,2),b=add(b,s[i]-'0');
		dp[m]=b;
		bool ok=1,done=0;
		for(int block=0;block<n/m;block++)
		{
			int l=m*block*v2+1;
			int r=m*(block+1)*v2;
			int xr=block&1;
			for(int i=l;i<=r;i++)
			{
				int a=(s[i-l+1]-'0')^xr;
				int b=(s[i]-'0');
				if(a<b){ ok=1;done=1;break;}
				if(b<a){ ok=0;done=1;break;}
			}
			if(done) break;
		}
		if(ok) dp[m]=add(dp[m],1);
		for(int z:ds)
		{
			if(z>=m) break;
			if(m%z==0) dp[m]=sub(dp[m],dp[z]);
		}
		ans=add(ans,mul(mul(dp[m],mul(m,v2)),2));
		//printf("%i %i\n",m*v2,dp[m]);
	}
	printf("%i\n",ans);
	/*for(int n=1;n<=20;n++)
	{
		//set<int> st;
		//int n=9;
		printf("N:%i\n",n);
		for(int i=0;i<1<<n;i++)
		{
			int x=i,cnt=0;
			do
			{
				if(x&1) x/=2;
				else x/=2,x+=1<<(n-1);
				cnt++;
			}while(x!=i);
			if(cnt!=n*2)
			{
				for(int j=n-1;j>=0;j--) printf("%i",i>>j&1);
				printf(" %i\n",cnt);
			}
			//st.insert(cnt);
		}
		//printf("%i: ",n);
		//for(int v:st) printf("%i ",v);
		//printf("\n");
	}*/
	return 0;
}

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

int main(){
  vector<int> task(3);
  for(int i = 0; i < 3; i++){
    cin >> task.at(i);
  }
  
  sort(task.begin(), task.end());
  
  cout << (task.at(1) - task.at(0) ) +(task.at(2) - task.at(1)) << endl;
}

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

int main() {

  int N;
  cin >> N;
  int i=0;
  string S;
  string ans  ="Three";
  while(i<N){
    cin >> S;
    
    if(S == "Y"){
      ans = "Four";
      break;
    }
      i++;
  }
  
    cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <climits>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

#define cin_desync()                      \
	do {                                  \
		ios_base::sync_with_stdio(false); \
		cin.tie(0);                       \
	} while (0)                           \

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

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

const int max_N = 1e3 + 10;
int dist[max_N][max_N];

int main()
{
    int H, W;
    cin >> H >> W;

    const int inf = 5 * max_N;
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            char c;
            cin >> c;

            if (c == '.') {
                dist[i][j] = inf;
            }
        }
    }

    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j < W; ++j) {
            dist[i][j + 1] = min(dist[i][j] + 1, dist[i][j + 1]);
        }
        for (int j = W; j > 1; --j) {
            dist[i][j - 1] = min(dist[i][j] + 1, dist[i][j - 1]);
        }
    }

    for (int j = 1; j <= W; ++j) {
        for (int i = 1; i < H; ++i) {
            dist[i + 1][j] = min(dist[i][j] + 1, dist[i + 1][j]);
        }
        for (int i = H; i > 1; --i) {
            dist[i - 1][j] = min(dist[i - 1][j], dist[i][j] + 1);
        }
    }

    int mx = 0;
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            mx = max(mx, dist[i][j]);
        }
    }

    cout << mx << endl;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int n;
  cin>>n;
  int ans=0;
  rep(i,n){
    int a;
    cin>>a;
    if(i%2==0&&a%2==1)ans++;
  }
  cout<<ans<<endl;
  return(0);
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int N;
	int A[200010]={};
	int Max[200010][2]={};

	cin >> N;
	for(int i=1;i<=N;i++)
		cin >> A[i];
	
	for(int i=1;i<=N;i++)
		Max[i][0]=max(Max[i-1][0],A[i]);
	for(int i=N;i>=0;i--)
		Max[i][1]=max(Max[i+1][1],A[i]);
	
	for(int i=1;i<=N;i++)
		cout << max(Max[i-1][0],Max[i+1][1]) << endl;
	return 0;
}



Measured memory_bytes: 3968
S=int(input())
memo=[0]*2001
def rec(a):
    if memo[a]!=0:
        return memo[a]
    if a<3:
        return 0

    ans=1
    tmp=0
    while a-3-tmp>=3:
        ans+=rec(a-3-tmp)
        tmp+=1
    memo[a]=ans
    return ans

print(rec(S) % 1000000007)

Measured memory_bytes: 9380
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>
#include <cmath>
#include <string>
#define mp make_pair
#define pb push_back

using namespace std;

int main() 
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a,b) + min(c,d) << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;


int main() {
    int n, d;
    cin >> n >> d;
    int ans = 0;
    int x, y;
    for(int i = 0; i < n; i++) {
        cin >> x >> y;
        if(1LL * x * x + 1LL * y * y <= 1LL * d * d) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    Set<Integer> set = new HashSet<>();
    set.add(sc.nextInt());
    set.add(sc.nextInt());
    set.add(sc.nextInt());
    
    System.out.println(set.size() == 2 ? "Yes" : "No");
  }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argv,char* argc[])
{
    string a,b;
    cin>>a>>b;
    int a1=a[0]-48;
    int b1=b[0]-48;
    if(a1>b1)
    {
        for(int i=0;i<a1-1;++i)
            b+=b[0];
        cout<<b<<"\n";
    }
    else if(b1>a1)
    {
        for(int i=0;i<b1-1;++i)
            a+=a[0];
        cout<<a<<"\n";
    }
    else
    {
        for(int i=0;i<b1-1;++i)
            a+=a[0];
        cout<<a<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,ans=0;
int x,y,z;
vector<int> v[100001];
bool visit[100001];
void dfs(int n)
{
	if(visit[n])
	return;
	visit[n]=true;
	for(int i=0;i<v[n].size();i++)
	{
		dfs(v[n][i]);
	}
}
int main()
{
	memset(visit,false,sizeof(visit));
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>x>>y>>z;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	for(int i=1;i<=n;i++)
	{
		if(!visit[i])
		{
			dfs(i);
			ans++;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(!visit[i])
		ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 8960
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <locale>
using namespace std;
int main(){
	int N;
	vector<long long> arr;
	long long T;
	long long sumaT = 0;
	long long sumTmod;
	int M;
	int P;
	long long X;
	cin>>N;
	for (int i = 0; i < N; i++)
	{
		cin>>T;
		arr.push_back(T);
		sumaT +=T;
	}
	cin>>M;
	
	for (int i = 1; i <= M; i++)
	{
		sumTmod = sumaT;
		cin>>P>>X;
		P -=1;
		if(arr[P] > X){
			long long resta;
			resta = arr[P] - X;
			
			sumTmod-=resta;
		}else if(arr[P]< X){
			long long suma;
			suma  = X - arr[P];
			sumTmod+=suma;
		}
		cout<<sumTmod;
		if(i<M){cout<<endl;}
	}
	
	
	
	return 0;
}

Measured memory_bytes: 256
// AOJ 0588
#include <iostream>

using namespace std;

int main(void)
{
	int ret, num;
	char c;

	cin >> ret;

	while (1){
		cin >> c;
		if (c == '='){
			cout << ret << endl;
			break;
		}
		cin >> num;
		if (c == '+') ret += num;
		if (c == '-') ret -= num;
		if (c == '*') ret *= num;
		if (c == '/') ret /= num;
	}

	return 0;
}

Measured memory_bytes: 1160
/*
n  個の整数 ai(i=1,2,...n)を入力し、それらの最小値、最大値、合計値を求めるプログラムを作成してください。
 */

#include <stdio.h>

int find_min_num(int *array, int n);
int find_max_num(int *array, int n);
long int calc_sum(int *array, int n);

int main(void)
{
    int n;
    int a[10000];
    int i, min, max;
    long int sum;

    scanf("%d\n", &n);
    for(i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }

    min = max = sum = 0;
    min = find_min_num(a, n);
    max = find_max_num(a, n);
    sum = calc_sum(a, n);

    printf("%d %d %ld\n", min, max, sum);
    return (0);
}

int find_min_num(int *array, int n)
{
    int min, i;
    
    min = array[0];
    for(i = 0; i < n; i++)
    {
        if (min > array[i])
            min = array[i];
    }
    return (min);
}

int find_max_num(int *array, int n)
{
    int max, i;
    
    max = array[0];
    for(i = 0; i < n; i++)
    {
        if (max < array[i])
            max = array[i];
    }
    return (max);
}

long int calc_sum(int *array, int n)
{
    long int sum;
    int i;

    sum = 0;
    for (i = 0; i < n; i++)
    {
        sum += array[i];
    }
    return (sum);
}


Measured memory_bytes: 2120
#include<iostream>
#include<stdio.h>
#include<queue>
#include<algorithm>
#include<math.h>
#include<stack>
#include<map>
#include<limits.h>
#include<vector>
#include<string.h>
#include<string>
using namespace std;
typedef long long LL;
typedef pair<double,double> pii;
const int N = 1e6+5;
const int M = 1005;
const int Mod = 1e9+7;
#define pi acos(-1)
#define INF 1e8
#define INM INT_MIN
#define pb(a)  push_back(a)
#define mk(a,b) make_pair(a,b)
#define dbg(x) cout << "now this num is " << x << endl;
#define met0(axx) memset(axx,0,sizeof(axx));
#define metf(axx) memset(axx,-1,sizeof(axx));
#define sd(ax) scanf("%d",&ax)
#define sld(ax) scanf("%lld",&ax)
#define sldd(ax,bx) scanf("%lld %lld",&ax,&bx)
#define sdd(ax,bx) scanf("%d %d",&ax,&bx)
#define sddd(ax,bx,cx) scanf("%d %d %d",&ax,&bx,&cx)
#define sfd(ax) scanf("%lf",&ax)
#define sfdd(ax,bx) scanf("%lf %lf",&ax,&bx)
#define pr(a) printf("%d\n",a)
#define plr(a) printf("%lld\n",a)
double eps = 1e-9;
int main()
{
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double t1 = h*30.0,t2 = m*5.5;
    double dis = abs(t1-t2);
    if(dis > 180) dis = 360.0-dis;
    double ans = sqrt(a*a+b*b-2*a*b*cos(dis*pi/180.0));
    printf("%.9f\n",ans);
    //system("pause");
	return 0;
}

Measured memory_bytes: 4228
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define itn int
#define mod 1000000007
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){
    return max(a,b)-min(a,b);
}
int gcd(int a,int b){//最大公約数
int c=a%b;
while(true){
if(c==0) break;
a=b;
b=c;
c=a%b;
}
return b;
}
bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for(int i=3;i<sqrtNum;i+=2){
	if(num%i==0){
	    return false;
	}
    }
    return true;
}
int lcm(int a,int b){//最小公倍数
return (a*b)/gcd(a,b);
}	
signed main(){
// __builtin_ctz(N); Nを２で何回割り切れるかを返す
//(n+1)*n/2; １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    itn a,b=0;
    cin>>a;
     while(true){
	if(IsPrime(a)==1){
	    b=a;
	    break;
	}
	//cout<<IsPrime(a)<<" ";
	a++;
	}
    cout<<b<<"\n";
}


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

const int N = (3e3) + 5;
ll memo[N][N];
int n, T;
pair<ll, ll> a[N];

ll dp(int pos, int t) {
  if ((double) t >= (double) T - 0.5) return 0;
  if (pos == n) return 0;
  ll& ret = memo[pos][t];
  if (ret != -1) return ret;
  ret = max(a[pos].second + dp(pos + 1, min(1LL * T, t + a[pos].first)), dp(pos + 1, t));
  return ret;
}

int main() { // claudio van
  cin >> n >> T;
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first >> a[i].second;
  }
  sort(a, a  + n);
  memset(memo, -1, sizeof memo);
  cout << dp(0, 0) << "\n";
  return 0;
}

Measured memory_bytes: 70912
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
int ca[20][20];

int main(){
    int n,m,x;
    ll ans=INF;
    cin>>n>>m>>x;
    for(int i=0;i<n;i++){
        for(int j=0;j<=m;j++){
            cin>>ca[i][j];
        }
    }

    for(int q=0; q<(1<<n); q++ ){
        vector<int> v(m,0);
        bool f=1;
        ll sub=0;
        for(int i=0;i<n;i++){
            if(q>>i & 1){
                sub+=ca[i][0];
                for(int j=1;j<=m;j++){
                    v[j-1]+=ca[i][j];
                }
            }
        }
        for(int j=0;j<m;j++){
            if(v[j]<x){
                f=0;
            }
        }
        if(f){
            ans=min(ans,sub);
        }
        //cout<<ans<<endl;
    }
    if(ans==INF){
        cout<<-1<<endl;
    }else{
        cout<<ans<<endl;
    }
}

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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 一次元累積和
template<class T>
class Ruiseki
{
private:
	int num;

public:
	vector<T> sumVal;
	Ruiseki(const vector<T> &srcVal)
	{
		num = srcVal.size();
		sumVal.resize(num + 1, 0);
		for (int i = 0; i < num; i++) {
			sumVal[i + 1] = sumVal[i] + srcVal[i];
		}
	}

	T GetSumAll()
	{
		return sumVal[num];
	}

	// [start, endIdx) ※endIdxは含まない
	T GetSumRange(int startIdx, int endIdx)
	{
		return sumVal[endIdx] - sumVal[startIdx];
	}

	// [0, endIdx) ※endIdxは含まない
	T GetSumFromTop(int endIdx)
	{
		return sumVal[endIdx] - sumVal[0];
	}

	// [startIdx, N] ※startIdxは含む
	T GetSumFromEnd(int startIdx)
	{
		return sumVal[num] - sumVal[startIdx];
	}
};

/* 2の乗未満か */
ll degree(ll n){
	ll degCnt = 0;
	while (n != 0) {
		n /= 2;
		degCnt++;
	}
	return degCnt;
}

void Solve()
{
	ll A, B, V, W, T;
	cin >> A >> V >> B >> W >> T;

	ll dist = abs(A - B);
	ll move = (V - W) * T;
	if (dist == 0) {
		cout << "YES" << endl;
		return;
	}
	if (move < 0) {
		cout << "NO" << endl;
		return;
	}

	if (move < dist) {
		cout << "NO" << endl;
	} else {
		cout << "YES" << endl;
	}
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int n;
	cin >> n;
	if(n==0)break;
	REP(i,n){
	    double pm,pe,pj;
	    char ans;
	    cin >> pm >> pe >> pj;
	    double ave = (pm + pe + pj) / 3.0;
	    if(pm == 100 || pe == 100 || pj == 100){
		ans = 'A';
	    }else if(pm + pe >= 180){
		ans = 'A';
	    }else if(ave >= 80){
		ans = 'A';
	    }else if(ave >= 70){
		ans = 'B';
	    }else if(ave >= 50 && (pm >= 80 || pe >= 80)){
		ans = 'B';
	    }else ans = 'C';
	    cout << ans << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i = 0;i < (n); ++i)
#define all(v) sort(v.begin(),v.end())
#define ALL(v) sort(v.begin(),v.end(),greater<ll>())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    vector<int> a(3);
    rep(i,3){
        cin >> a[i];
    }
    all(a);
    int ans = a[2] - a[1];
    a[0] += ans;
    int d = a[2] - a[0];
    if(d%2 == 0) d = d/2;
    else d = (d/2)+2;
    ans += d;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
main(){
  long long k,s,ans=0;
  cin>>k>>s;
  for(int i=0;i<=k;i++)for(int j=0;j<=k;j++){
  ans+=(0<=s-i-j and s-i-j<=k);}
  cout<<ans<<endl;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in(),M=in();
	unordered_map<int,int> C;
	REP(i,M){
		C[in()]++;
		C[in()]++;
	}
	
	for(auto& x:C){
		if(x.second%2){
			out("NO");
			return 0;
		}
	}

	out("YES");
	return 0;
}


Measured memory_bytes: 4004
/**
 * 	author: MahfuzAhmed
 * 	created: 08.08.2019 
**/

#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define forn(var,from,to) for(int var=(from);var<(to);var++)
#define forx(var,from,to) for(int var=(from);var<=(to);var++)
#define fory(var,from,to) for(int var=(from);var>=(to);var--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vvi vector<vi>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(p) p.begin(),p.end()
typedef long long ll;
//~ const double pi = 2*acos(0.0);
//~ const long long mod = 1e9+7;
//~ const int MAX_N = 1e6+5;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
       
    #ifdef _DEBUG
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    
    int n; cin >> n;
    int arr[n];
    
    forn(i, 0, n) cin >> arr[i];
    sort(arr, arr+n);
    
    int mid = n/2;
    
    cout << (arr[mid] - arr[mid-1]) << "\n";
    
    return 0;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int,input().split()))

c = 0
l = 0
ans = 0

for r,a in enumerate(A):
    if c&a:
        while c&a:
            c = c^A[l]
            l += 1
    c = c^a
    ans += r-l+1

print(ans)



Measured memory_bytes: 24840