akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define MAX_N 6010
using namespace std;
ll n,t,a[MAX_N],b[MAX_N],dp[MAX_N][2];
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>t;t--;
	for(ll i=1;i<=n;++i)cin>>a[i]>>b[i];
	for(ll i=1;i<=n;++i)
		for(ll j=t;j>=0;--j)
		{
			dp[j][1]=max(dp[j][1],dp[j][0]+b[i]);
			if(j>=a[i])
			{
				dp[j][1]=max(dp[j][1],dp[j-a[i]][1]+b[i]);
				dp[j][0]=max(dp[j][0],dp[j-a[i]][0]+b[i]);
			}
		}
	cout<<dp[t][1]<<endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) cin >> A.at(i);
  bool check = true;
  int ans = 0;
  while(check == true) {
  	for(int i = 0; i < N; i++) {
      if(A.at(i) % 2 == 0) A.at(i) /= 2;
      else {
        check = false;
        break;
      }
    }
  	if(check == true) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef pair<long long,long long> P;
//typedef pair<long long,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 se 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 rrep(i,x) for(long long i=x-1;i>=0;i--)
#define rrepn(i,x) for(long long i=x;i>1;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())
long long n,h[100005];
ll dp[100005];
#define ALL(v)  (v).begin(),(v).end()
//#define MAX(a,b) if(a>b)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))

#define DEBUG
#define pr printf
#define re return
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)


int main(){
	
	//文字列入力
	long long cnt,cnt1;
	cnt=0;
	cnt1=0;
	string s,t;
	std::cin >> s;
	//sort(s.begin(), s.end());
	
	
	for(long long i=0; i<s.length()-1; i++){
		
		if(s[i]!=s[i+1]){
			cnt++;
		}
	}
	for(long long i=s.length()-1; i>0; i--){
		
		if(s[i]!=s[i-1]){
			cnt1++;
		}
	}	
	pr("%lld",MIN(cnt,cnt1));
	re 0;
	
}


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

constexpr char letters[] = { 'R', 'G', 'B', 'Y' };

int main() {

    int H, W, D;
    std::cin >> H >> W >> D;

    int origin_x = 0, origin_y = H - 1;
    std::vector<std::vector<int>> grid(H + W - 1, std::vector<int>(H + W - 1));
    std::function<void(int&, int&)> rotate45 = [&] (int& x, int& y) {
        int u = origin_x + x + y;
        int v = origin_y - x + y; 
        x = u;
        y = v;
    };

    for (int i = 0; i < H + W - 1; ++i) {
        for (int j = 0; j < H + W - 1; ++j) {
            grid[i][j] = 1 * (i / D % 2) + 2 * (j / D % 2);
        }
    }

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            int x = i, y = j;
            rotate45(x, y);
            std::cout << letters[grid[x][y]];
        }
        std::cout << '\n';
    }

}


Measured memory_bytes: 4480
N,A,B,C,D = map(int,input().split())
S=input()
ans="Yes"

if D<C:
  triple = S[B-2:D+1].count("...")
  if triple ==0:
    ans="No"

double= S[A-1:max(C,D)].count("##")
if double > 0:
  ans="No"
  
print(ans)

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 100005;
vector<int> a[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, m;
	cin>>n>>m;
	for(int i = 0; i < m; i++){
		int ind; string s;
		cin>>ind>>s;
		if(s == "AC")a[ind].push_back(1);
		else a[ind].push_back(0);
	}
	int crt = 0, pen = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < a[i].size(); j++){
			if(a[i][j]){
				crt++; pen += j;
				break;
			}
		}
	}
	cout<<crt<<" "<<pen<<endl;

	return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,k,kake;
	cin >> a >> b >> c >> k;
	if(a>=b){
		if(a>=c){
			kake=a;
			for(int i=1;i<=k;i++){
				kake*=2;
			}
			cout << kake+b+c << endl;
		}else if(c>=a){
			kake=c;
			for(int i=1;i<=k;i++){
				kake*=2;
			}
			cout << kake+b+a << endl;
		}
	}else if(b>=a){
		if(b>=c){
			kake=b;
			for(int i=1;i<=k;i++){
				kake*=2;
			}
			cout << kake+a+c << endl;
		}
	}
}
	
			

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int k = int.Parse(Console.ReadLine());
        int x = int.Parse(Console.ReadLine());
        int y = int.Parse(Console.ReadLine());

        int amount = 0;
        for(int i = 0; i < n; i++)
        {
            if (i < k) amount += x;
            else amount += y;
        }

        Console.WriteLine(amount);
    }
}


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

constexpr char NL = '\n';
constexpr int MOD = 1e9 + 7;

struct safe_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

void solve()
{
    int n, W; cin >> n >> W;
    vector<vector<ll>> dp(n + 1, vector<ll>(W + 1, 0));
    for (int i = 1; i <= n; ++i) {
        int w, v; cin >> w >> v;
        for (int j = 1; j <= W; ++j) {
            if (w > j) {
                dp[i][j] = dp[i - 1][j];
            } else {
                dp[i][j] = max(dp[i - 1][j], v + dp[i - 1][j - w]);
            }
        }
    }
    cout << dp[n][W] << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

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

int main() {
  int N;
  cin >> N;
 
  vector<int> vec(N);
  
  for(int i=0; i<N; i++){
  cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());

   int sum=0;
   int mochi =0;
 for(int i=0; i<N; i++){

     if(mochi < vec.at(i)){
     sum++;
     mochi = vec.at(i);
     }
    }
  
  cout << sum << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
<?php
    fscanf(STDIN, "%d", $N);
    $count = 0;
    for ($i=0; $i < $N; $i++) { 
        fscanf(STDIN, "%d %d", $a, $b);
        if($a == $b){
            $count++;
            if ($count == 3) {
                break;
            }
        } else {
            $count = 0;
        }
    }
    if ($count == 3) {
        echo 'Yes';
    } else {
        echo 'No';
    }
?>

Measured memory_bytes: 16132
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N 100005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
#define endl "\n"
#define mid  (l + r + 1)/2
#define s3   1.73205080757
const int inf = (int)1e18 + 10;


signed main(){
  fast;
  

  int x , y;
  cin >>x >> y;
  cout << (x + y/2) << endl;



  

}	


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define F first
#define S second
using namespace std;
#define mod 1000000007


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    int curr=n/1000;
    if(n%1000) curr++;
    cout<< curr*1000-n<<endl;

}


Measured memory_bytes: 3640
#include<iostream>
#include<stdio.h>
#include<utility>
#define MAX 20000000

using namespace std;
int parent(int i) {
	return int( i / 2);
}
int left(int i) {
	return 2 * i;
}

int right(int i) {
	return (2 * i) + 1;
}

int H = 0;
int A[MAX] = { -20000 };

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

	//左の子、自分、右の子で値が最大のノードを選ぶ
	if (l < H + 1 && A[l] > A[i]) {
		largest = l;
	}
	else {
		largest = i;
	}
	if (r < H + 1 && A[r] > A[largest]) {
		largest = r;
	}
	if (largest != i) {		//iの子の方が値が大きい場合
		swap(A[i], A[largest]);
		maxHeapify(largest); //再帰的に呼び出し
	}
}


void insert(int k) {
	A[H] = k;
	int num = H;
	while (num > 1 && A[num/2] < A[num]) {
		swap(A[num/2], A[num]);
		num =num/2;
	}
	

}
int extract() {

	int z = A[1];
    A[1] = A[H+1];
	maxHeapify(1);
	return z;

}
int main() {
	

	string x;
	int k;
	
	while (1) {
		cin >> x;
		
		if (x == "end") {
			break;
		}
		
		if (x == "insert") {
			cin >> k;
			H++;
			insert(k);
		}
		else if (x == "extract") {
		
			H--;
			cout<<extract()<<endl;
		}
	}
	
	return 0;
}



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

int main() {
  int a;
  int type=0; 
  cin >> a;  
  for (int i = 0; i < a; i++) {
    char s;
    cin >> s;
    if (s=='Y') {
      type++;
    }
  }
    if (type>0) cout << "Four" << endl;
  else cout << "Three" << endl;
}

Measured memory_bytes: 256
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    int n;cin>>n;
    vector<ll> a(n);
    rep(i, n) {
        cin>>a[i];
    }
    dump(a);

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


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int n;
struct data
{
    int val;
    char ch;
}a[100005],b[100005];
string s1[100],s2[100];

void Reset() {
    for (int i = 1; i <= 9; i++) {
        s1[i].clear(); s2[i].clear();
    }
    for (int i = 0; i < n; i++) {
        b[i] = a[i];
       // cout << a[i].ch << a[i].val << endl;
      //  b[i].ch = a[i].ch;
        s1[b[i].val] = s1[b[i].val] + b[i].ch;
    }
}

void OUT()
{
    bool check = true;
    for ( int i = 0; i < n-1; i++) cout << b[i].ch << b[i].val << " ";
    cout << b[n-1].ch << b[n-1].val << '\n';
    for ( int i = 1; i <= 9; i++)
        if (s1[i] != s2[i]) {
            check = false;
            break;
        }
    if (check) cout << "Stable" << '\n';
    else cout << "Not stable" << '\n';
}

void BubbleSort() {
    Reset();
    for(int i = 0; i < n; i++) {
        for(int j = n-1; j > i; j--)
            if (b[j].val < b[j-1].val)
                swap(b[j],b[j-1]);
    }
    for (int i = 0; i < n ; i++) s2[b[i].val] = s2[b[i].val] + b[i].ch;
    OUT();
}

void SelectionSort() {
    Reset();
    for( int i = 0; i < n; i++) {
        int t = i;
        for( int j = i; j < n; j++)
            if (b[t].val > b[j].val) t=j;
        swap(b[t],b[i]);
    }
    for( int i = 0; i < n; i++) s2[b[i].val] = s2[b[i].val] + b[i].ch;
    OUT();
}

int main() {
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        a[i].ch = s[0];
        a[i].val = s[1] - '0';
    }
    BubbleSort();
    SelectionSort();
}



Measured memory_bytes: 3220
import math
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]
n = sum([pc[i][0] for i in range(d)])
ans = float('inf')


for i in range(2 ** d):
    score = 0
    num = 0
    max_num = 0
    for j in range(d):
        if (i>>j) & 1:
            score += 100*(j+1)*pc[j][0] + pc[j][1]
            num += pc[j][0]
            
        else:
            max_num = max(max_num, j+1)
            
    if score < g:
        add_n = math.ceil((g-score)/(100*(max_num)))
        if add_n < pc[max_num-1][0]:
            num += add_n
            score += add_n * (100*(max_num+1))

    if score >= g:
        ans = min(ans, num)

print(ans)

Measured memory_bytes: 3064
import itertools

A = [0, 0, 0, 0, 0]
A[0] = int(input())
A[1] = int(input())
A[2] = int(input())
A[3] = int(input())
A[4] = int(input())
A = tuple(A)

time = 0
time_min = 100000000

list = list(itertools.permutations(A))

for l in list:
    count = 0
    time = 0
    while True:
        if count == 4:
            time = time + l[count]
            break
        if (l[count] % 10) != 0:
            time = time + l[count] + (10 - (l[count] % 10))
            count = count + 1
        else:
            time = time + l[count]
            count = count + 1
    if time < time_min:
        time_min = time

print(time_min)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repbtw(i, a, b) for (int i = a; i <= (int)(b); i++)
#define all(v) v.begin(), v.end()
#define pr(x) cout << x << endl


int main()
{
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double deg_h = (h + m/60.0) * 360.0 / 12.0;
    double deg_m = m * 360.0 / 60.0;
    double diff = deg_h - deg_m;
    if(diff < 0) diff = -diff;
    if(diff > 180) diff = 360 - diff;
    double d = sqrt(a*a + b*b - 2*a*b*cos(diff / 180.0 * M_PI));
    pr(setprecision(15) << d);
    return 0;
}



Measured memory_bytes: 4192
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
//
#define int long long
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))
// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))
//
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;
//
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
//
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N;
vec d[101010];

int dist1[101010], dist2[101010];
void bfs(int dist[], int s) {
  fill(dist, dist + N, INF);
  dist[s] = 0;
  queue<int> que;
  que.push(s);
  while (!que.empty()) {
    int x = que.front();
    que.pop();
    for (auto v : d[x]) {
      if (dist[v] <= dist[x]) {
        continue;
      }
      dist[v] = dist[x] + 1;
      que.push(v);
    }
  }
}

signed main() {
  cin >> N;
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    d[a].push_back(b);
    d[b].push_back(a);
  }

  bfs(dist1, 0);
  bfs(dist2, N - 1);

  int cont = 0;
  for (int i = 0; i < N; i++) {
    if (dist1[i] <= dist2[i]) {
      cont++;
    }
  }

  if (cont > N - cont) {
    cout << "Fennec" << endl;
  } else {
    cout << "Snuke" << endl;
  }
  return 0;
}


Measured memory_bytes: 8004
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i= shoki; i<n; i++)
#define _GLIBCXX_DEBUG

int main(){
    string s; cin>>s;
    int price = 700;
    rep(0,i,s.size()){
        if(s[i]=='o') price += 100;
    }
    cout << price <<endl;
}

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

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

  if (S[N-1]=='s') {
    cout <<S<<"es" << endl;
  }
  else{
    cout <<S<<"s" << endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int a[81][81], b[81][81];
bitset<160 * 161> dp[81][81];

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    rep(i, 0, h){
        rep(j, 0, w){
            cin >> a[i][j];
        }
    }
    rep(i, 0, h){
        rep(j, 0, w){
            cin >> b[i][j];
        }
    }
    dp[0][0][a[0][0] - b[0][0] + 80 * 160] = true;
    dp[0][0][b[0][0] - a[0][0] + 80 * 160] = true;
    rep(i, 0, h){
        rep(j, 0, w){
            if(i != h - 1){
                int tmp = abs(a[i + 1][j] - b[i + 1][j]);
                dp[i + 1][j] |= dp[i][j] << tmp;
                dp[i + 1][j] |= dp[i][j] >> tmp;
            }
            if(j != w - 1){
                int tmp = abs(a[i][j + 1] - b[i][j + 1]);
                dp[i][j + 1] |= dp[i][j] << tmp;
                dp[i][j + 1] |= dp[i][j] >> tmp;
            }
        }
    }
    int ans = INF;
    for(int i = 0; i < 160 * 161; i++){
        if(dp[h - 1][w - 1][i]) ans = min(ans, abs(i - 80 * 160));
    }
    cout << ans << endl;
}


Measured memory_bytes: 20864
import java.io.*;

class Main{
	public static void main(String[] args){
		// System.out.println("Please enter three integers");
		try{
			BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
			String str = buf.readLine();
			String[] input = str.split(" ");
			int a = Integer.parseInt(input[0]);
			int b = Integer.parseInt(input[1]);
			int c = Integer.parseInt(input[2]);
			if(a < b && b < c){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}catch(IOException e){

		}
	}
}


Measured memory_bytes: 24456
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main(){
  string s;
  cin >> s;
  int a[4]={0};
  for(int i = 0; i< s.size(); i++){
    if(s.at(i) == 'N'){
      a[0]++;
    }
    else if(s.at(i) == 'S'){
      a[1] ++;
    }
    else if(s.at(i) == 'W'){
      a[2]++;
    }
    else{
      a[3]++;
    }
  }
  if(a[0]!= 0 && a[1] == 0 || a[0]== 0 &&a[1] != 0){
    cout << "No" << endl;
  }
  else if(a[2]!= 0 && a[3] == 0 || a[2]== 0 &&a[3] != 0){
    cout << "No" << endl;
  }
  else{
    cout  << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
    int n;
    cin >> n;
 
    int A[n];
    for(int i=0; i < n+1; i++){
        cin >> A[i];
    }
    int B[n];
    for(int i=0; i < n; i++){
        cin >> B[i];
    }
 
    long long int ans = 0;
    
    for(int i=0; i<n; ++i) {
      ans += min(A[i], B[i]);
      B[i] -= A[i];
      if(B[i] < 0) {
        B[i] = 0; 
      }
      ans += min(A[i+1], B[i]);
      A[i+1] -= B[i];
      if(A[i+1] < 0) {
        A[i+1] = 0;
      }
    }

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

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <list>
#include <stack>
#include <unordered_set>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1LL << 50;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
 
struct edge{
    int from, to; ll cost;
};

//  通ってください

int main(){
    int n;
    cin >> n;
    int a = 0, b = 0;
    string ans = "";
    REP(i, n){
        char c;
        cin >> c;
        ans = ans + c;
        if(c == ')'){
            if(a == 0){
                ans = '(' + ans;
            }else{
                a--;
            }
        }else{
            a++;
        }
    }
    REP(i, a){
        ans = ans + ')';
    }
    cout << ans << endl;
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	string s, t;
	cin >> s >> t;

	int ans = 0;

	rep(i, s.size()){
		if(s[i] != t[i]) ans++;
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 3820
s = input()

if len(s) % 2 == 0:
    mid_l = len(s)//2 - 1
    mid_r = len(s)//2
    if s[mid_l] != s[mid_r]:
        print(len(s) // 2)
    else:
        mid_char = s[mid_l]
        for t in range(1, len(s)//2):
            if not (s[mid_l - t] == s[mid_r + t] == mid_char):
                print(mid_r+t)
                break
        else:
            print(len(s))
else:
    mid = len(s)//2
    mid_char = s[mid]
    for t in range(1, len(s)//2+1):
        if not (s[mid - t] == s[mid + t] == mid_char):
            print(mid+t)
            break
    else:
        print(len(s))

Measured memory_bytes: 65444
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		if(t.length()==s.length()+1 && s.equals(t.substring(0, s.length()))) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}

}


Measured memory_bytes: 35668
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.List;

public class Main {
    public static void main(String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int arr[]=new int[n];
        for (int i=0;i<n;i++){
            arr[i]=sc.nextInt();
        }
        Arrays.sort(arr);
        int x=1;
        int index=n/2 -1 ;
        if (arr[index]==arr[index+1]){
            x=0;
        }else {
            x=arr[index+1]-arr[index];
        }
        System.out.println(x);

    }

}



Measured memory_bytes: 50044
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

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

    int k, n;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }

    int ans = 0;
    sort(p.begin(), p.end());

    for (int i = 0; i < k; i++) {
        ans += p[i];
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int N, ans;
  cin >> N;
  vector<int> d(N);
  rep(i, N) cin >> d[i];
  rep(i, N-1) for (int j = i+1; j < N; ++j) {
    ans += d[i] * d[j];
  }
  cout << ans << endl;
  return 0;
}


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

#define pb push_back
#define fst first
#define snd second
#define INF 0x7fffffff
#define INFLL 0x7FFFFFFFFFFFFFFF
#define lenA(ar) sizeof(ar)/sizeof(*ar)
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(int i=x;i<y;i++)
#define foreI(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sl "\n";
#define ii pair<ll,ll>
#define mk make_pair


typedef long long ll;
typedef unsigned long long ull;

using namespace std;
const int MAXN=3000;
double dp[MAXN][MAXN];
vector<double> arr(MAXN);
int n;
double solve(int pos, int num){
    if(num==0)return 1;
    if(pos>=n)return 0;
    double &r=dp[pos][num];
    if(r!=-1){return r;}
    r=solve(pos+1,num-1)*arr[pos];
    r+=solve(pos+1,num)*(1.0-arr[pos]);
    return r;
}
int main() {FIN;
  
   fore(i,0,MAXN)fore(j,0,MAXN)dp[i][j]=-1;
    cin>>n;
    fore(i,0,n)cin>>arr[i];
    cout<<fixed<<setprecision(10)<<solve(0,n/2+1)<<sl;

    return 0;
}




Measured memory_bytes: 74260
S = input()
if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
elif S == 'SAT':
    print(1)

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

long long gcd(long long a,long long b)
{
	long long r=max(abs(a),abs(b));
	long long l=min(abs(a),abs(b));
	if (l==0LL)
	{
		return r;
	}
	return gcd(l,r%l);
}

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	long long ans,a;
	cin>>ans;
	for (int i = 1; i < n; ++i)
	{
		cin>>a;
		ans=gcd(ans,a);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 100100100
#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long ;

#define FOR(i,n) for(ll i=0;i<n;i++)

struct edge{ll to,cost;};

int x[4] = {1,-1,0,0};
int y[4] = {0,0,1,-1};

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0); 
   int H,W;
   cin >> H >> W;
   vector<string>s(H);
   FOR(i,H)cin >> s[i];
   bool flag;
   FOR(i,H){
      FOR(j,W){
         flag = true;
         FOR(k,4){
            if(s[i][j] == '.'){
               flag = false;
               break;
            }
            else if(j+x[k]<W && j+x[k]>=0 && i+y[k]<H && i+y[k]>=0){
               if(s[i+y[k]][j+x[k]] == '#')flag = false;
            }
         }
         if(flag){
           cout << "No" << endl;
           return 0;
         }         
      }
   }
   cout << "Yes" << endl;
   return 0;
}


Measured memory_bytes: 256
MOD = 10 **9 + 7
INF = 10 ** 10
import numpy as np
from  scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

def main():
    n,m,l = map(int,input().split())
    dist = [[np.inf] * n for _ in range(n)]  
    for _ in range(m):
        a,b,c = map(int,input().split())
        a -= 1
        b -= 1
        dist[a][b] = c
        dist[b][a] = c

    csr = csr_matrix(dist)
    dist1 = floyd_warshall(csr,directed = False)
    dist1 = np.where(dist1 <= l,1,np.inf)
    cnt = floyd_warshall(dist1,directed = False)
    cnt[cnt == np.inf] = 0
    cnt = cnt.astype(int)
    q = int(input())
    for _ in range(q):
        s,t = map(int,input().split())
        s -= 1
        t -= 1
        print(cnt[s][t] - 1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 20844
from bisect import bisect_left
n = int(input())
ll = list(map(int,input().split()))

ls = sorted(ll)
count = 0
for i in range(n-1):
  for j in range(i+1,n-1):
    x = bisect_left(ls,ls[i]+ls[j])
    count += x-j-1
    
print(count)    

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

int main(){
    string s;
    while(cin>>s && s!="."){
        int n = s.size();
        stack<string> st;
        int k = 0;
        string tmp;
        rep(i,n){
            if(s[i]=='['){
                st.push(tmp);
                tmp ="";
            }else if(s[i]==']'){
                auto x = st.top();
                st.pop();
                reverse(tmp.begin(),tmp.end());
                tmp = x + tmp;
            }else if(s[i]=='-'){
                k--;
            }else if(s[i]=='+'){
                k++;
            }else if(s[i]=='?'){
                k = 0;
                tmp.push_back('?');
            }else{
                char c = s[i];
                if(k<0){
                    while(k!=0){
                        if(c=='A'){
                            c = 'Z';
                        }else{
                            c--;
                        }
                        k++;
                    }
                }
                if(k>0){
                    while(k!=0){
                        if(c=='Z'){
                            c = 'A';
                        }else{
                            c++;
                        }
                        k--;
                    }
                }
                tmp.push_back(c);
            }
        }
        rep(i,tmp.size()){
            if(tmp[i]=='?'){
                tmp[i] = 'A';
            }
        }
        cout << tmp << "\n";
    }

    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	string s;
	cin >> s;

	string ans;
	for (char c: s) {
		if (c == 'P') {
			ans += c;
		} else {
			ans += 'D';
		}
	}

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


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

#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1e9 + 7

using namespace std;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(void)
{
    string s;
    cin >> s;
    rep(i, 3)
    {
        if (s[i] == '1')
        {
            s[i] = '9';
        }
        else if (s[i] == '9')
        {
            s[i] = '1';
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 256
read n
read s
read t
if [ "$s" = "$t" ]
then
	echo $n
	exit
fi
for i in `seq $n`
do
	cnt=$((i - 1))
	if [ `echo $t | egrep -c "^${s:$cnt:$n}"` -eq 1 ]
	then
		ans="${s/${s:$cnt:$n}/}$t"
		break
	fi
done
if [ ! "${ans}" ]
then
	ans=$s$t
fi
echo ${#ans}


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

const ll M=1e9+7;
ll dp[100005][2];
vector<vector<ll>> adj;

void prepare(vector<pair<ll,ll>>&e){
	for(auto i:e){
		adj[i.first].push_back(i.second);
		adj[i.second].push_back(i.first);
	}
}

ll ways(ll start,ll parent=-1,ll c=0){

	if(dp[start][c]==-1){
		ll count=1;
		for(ll i:adj[start]){
			if(i!=parent){
				ll cnt=0;
				cnt+=ways(i,start,0);
				cnt%=M;
				if(c==0){
					cnt+=ways(i,start,1)%M;
					cnt%=M;
				}
				count=(count*cnt)%M;
			}
		}
		dp[start][c]=count;
	}
	return dp[start][c];
}


int main(){
 ll n;
 cin>>n;
 vector<pair<ll,ll>> v(n-1);
 for(ll i=0;i<n-1;i++){
 	ll a,b;
 	cin>>a>>b;
 	v[i]={a,b};
 }
 adj.resize(n+1);
 prepare(v);
 memset(dp,-1,sizeof(dp));
 ll ans=(ways(1)+ways(1,-1,1))%M;
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 20084
import java.util.*;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n,m;
        
        while(true){
            n = sc.nextInt();
            m = sc.nextInt();
            
            if((n==0)&&(m==0))break;
            int[] Taro = new int[n];
            int[] Hanako = new int[m];
            int TotalTaro = 0;
            int TotalHanako = 0;
            int DasuTaro=101;
            int DasuHanako=101;
            
            for(int i=0; i<n; i++){
                Taro[i] = sc.nextInt();
                TotalTaro += Taro[i];
            }
            for(int i=0; i<m; i++){
                Hanako[i] = sc.nextInt();
                TotalHanako += Hanako[i];
            }
            
            for(int i = 0; i<n; i++){
                for(int j = 0; j<m; j++){
                    if((TotalTaro-Taro[i]+Hanako[j])==(TotalHanako-Hanako[j]+Taro[i])){
                        if((DasuTaro+DasuHanako)>(Taro[i]+Hanako[j])){
                            DasuTaro=Taro[i];
                            DasuHanako=Hanako[j];
                        }
                    }
                }
            }
            if((DasuTaro==101)&&(DasuHanako==101))
                System.out.println(-1);
            else{
                System.out.println(DasuTaro + " " + DasuHanako);
            }
    
        }
    }
}

Measured memory_bytes: 21056
#include<iostream>
#include<algorithm>
#include<vector>
#include <cmath>
#include <limits>
#include <iomanip>
using namespace std;
const long long INF=20000000000;
typedef long long ll;


int main(){
	int a,b;
	cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b))<<endl;

	
}
	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i,m,n) for(int i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
int main() {
  lli A,B,C=1,D=0,E=0,F=0,G=0,H=0,N,M;
  cin >> N >> M >> A;
  rep(i,0,N+1){
    rep(j,0,M+1){
      if(C==1&&i*(M-j)+j*(N-i)==A){
        Out("Yes");
        C=0;
        break;
      }
    }
  }
  if(C)Out("No");
}

Measured memory_bytes: 256
//abc136_e.cpp
//Mon Oct 21 23:22:25 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;
ll a[500];
ll n;

ll check(ll x){
	vector<ll> amari;
	ll totalamari = 0;
	for (int i=0;i<n;i++){
		if (a[i]%x!=0){
			amari.push_back(a[i]%x);
			totalamari += a[i]%x;
		}
	}
	sort(amari.begin(),amari.end());

	ll sum_left = totalamari;
	ll sum_right = 0;
	ll ans = LLINF;
	for (int i=amari.size()-1;i>=0;i--){
		sum_left -= amari[i];
		sum_right += x-amari[i];
		if (abs(sum_left-sum_right)%x==0){
			ans = min(ans,max(sum_left,sum_right));
		}
	}
//	cout << x << " " << ans << endl;
	return ans;

}

int main(){
	ll k;
	cin >> n >> k;

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

	vector<ll> yakusu;
	ll a = 1;
	while (total>=a*a){
		if (total%a == 0){
			yakusu.push_back(a);
			yakusu.push_back(total/a);
		}
		a++;
	}

	sort(yakusu.begin(),yakusu.end(),greater<int>());
	for (int i=0;i<yakusu.size();i++){
		ll xx = check(yakusu[i]);
		if (xx <= k){
			cout << yakusu[i] << endl;
			return 0;
		}
	}


	cout << 1 << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 M, D;
  std::cin >> M >> D;

  i64 answer = 0;
  for (i64 m = 1; m <= M; ++m) {
    for (i64 d = 1; d <= D; ++d) {
      if (d % 10 >= 2 && d / 10 >= 2 && (d % 10) * (d / 10) == m) {
        ++answer;
      }
    }
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pt;

#define fi first
#define se second
#define lson (p<<1)+1
#define rson (p<<1)+2
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll x;
bool ok;

int main () {
    fastIO;
    cin >> x;
    while(true) {
        ok = false;
        for(li i = 2; i * i <= x; i ++) {
            if(x % i == 0) {
                ok = true;
                break;
            }
        }
        if(!ok) { cout << x; return 0; }
        x ++;
    }
}


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

int main()
{
    long N,M;
    long map[100000];
    map[0]=1;
    long edge=std::pow(10,9)+7;
    std::cin >> N >> M;
    if(abs(N-M)>1){
        std::cout << 0 << std::endl;
    }else{
        for(long i=1; i<std::max(N,M);i++){
            map[i]=(map[i-1]*(i+1))%edge;
        }
        if(abs(N-M)==1){
            std::cout << (map[N-1]*map[M-1])%edge << std::endl;
        }
        if(abs(N-M)==0){
            std::cout << ((map[N-1]*map[M-1])*2)%edge << std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
anum,bnum,acc = map(int,input().split())
alist = list(map(int,input().split()))
blist = list(map(int,input().split()))

asum = [0]
bsum = [0]
ans = 0
for i in range(anum):
    asum.append(asum[i]+alist[i])
for i in range(bnum):
    bsum.append(bsum[i]+blist[i])

b = bnum
for a in range(anum+1):
    if asum[a] > acc:
        break
    while asum[a] + bsum[b] > acc:
        b -=1
    ans = max(ans,a+b)

print(ans)


Measured memory_bytes: 47488
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------
class UF{
#define H pair<int, int>
#define fs first
#define sc second
public:
	int size;
	H pa[500002];
	void init(int n) {
		size = n;
		for (int i = 1; i <= size; i++) pa[i] = H{ i,1 };
	}
	int root(int x) {
		if (pa[x].fs == x) return x;
		return pa[x].fs = root(pa[x].fs);
	}
	void unite(int x, int y) {
		x = root(x); y = root(y);
		if (pa[x].sc < pa[y].sc) swap(x, y);
		pa[x].sc += pa[y].sc;
		pa[y].fs = x;
	}
	H operator[](int x)const {
		return pa[x];
	}
};
int n;
H a[200000], b[200000];
H c[200000];
int d[200000];
UF uf;
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) a[i].fs = read(), a[i].sc = i;
	for (int i = 0; i < n; i++) {
		b[i] = H{ read(),i };
		c[i] = H{ b[i].fs,a[i].fs };
	}
	sort(a, a + n); sort(b, b + n);
	for (int i = 0; i < n; i++) {
		if (a[i].fs > b[i].fs) {
			cout << "No\n";
			return 0;
		}
	}
	sort(c, c + n);
	for (int i = 0; i < n - 1; i++) {
		if (a[i + 1].fs <= b[i].fs) {
			cout << "Yes\n";
			return 0;
		}
	}
	uf.init(n);
	for (int i = 0; i < n; i++) {
		uf.unite(a[i].sc, b[i].sc);
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (uf[i].fs == i) cnt++;
	}
	if (1 < cnt) {
		cout << "Yes\n";
		return 0;
	}
	cout << "No\n";
}

Measured memory_bytes: 20736
#include<bits/stdc++.h>
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define INFLL 0x3fffffffffffffffLL
#define INF 0x3fffffff
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define exist(s,e) (s.find(e)!=s.end())
#define EPS 1e7
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD=1e9+7;
/////////////////// DEBUG MODE ///////////////////////////////////
#define D(x) cerr<<"DEBUG: "<<#x<<" is: "<<x<<'\n'
#define error(args...) {string _s=#args; replace(all(_s),',',' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
/////////////////// GLOBAL VARIABLES /////////////////////////////
vector<vector<int>> adj; vector<bool> vis; vector<int> color;
vector<ll> lprime(10e5+2);
/////////////////// FUNCTIONS ////////////////////////////////////
template<class T>
T maxx(T a, T b) {return a>b?a:b;}
template<typename T, typename... Args>
T maxx(T a, T b, Args... args){return maxx(a>b?a:b, args...);}
ll mexp(ll x, ll n, ull m){
  ll res=1;  while(n){if(n&1) res=(res*x)%m;n>>=1; x=((x%m)*(x%m))%m;}
  return res;
}
double pow(double a, int n) {
  if(n == 0) return 1;if(n == 1) return a;
  double t = pow(a, n/2);return t * t * pow(a, n%2);
}
/////////////////// MAIN STARTS //////////////////////////////////
int main(){
  ios::sync_with_stdio(0);  cin.tie(0);   cout<<fixed; cerr<<fixed;
  cout<<setprecision(10); cerr<<setprecision(3);
  #ifdef DEBUG
  freopen("ip.txt","r",stdin); //freopen("op.txt","w",stdout);
  clock_t tStart = clock();
  #endif

	ll m; cin>>m; cout<<48-m<<'\n';


	#ifdef DEBUG
	cerr<<"\nExecution time: "<<(((double)clock() - tStart)/CLOCKS_PER_SEC)*1000<<"ms.\n";
	#endif
  return 0;
}


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

int main(void)
{
	int n, err, i, j, k, l, flag;
	long *x, *y, *h, H, H1;
	err = scanf("%d", &n);
	if ((err!=1) || (n<1)) exit(1);
	x = (long *)malloc(sizeof(long)*n);
	y = (long *)malloc(sizeof(long)*n);
	h = (long *)malloc(sizeof(long)*n);

	for (int i = 0; i < n; ++i)
	{
		err = scanf("%ld%ld%ld", &x[i], &y[i], &h[i]);
		if ((err!=3) || ((x[i]<0) || (x[i]>100)) ||  ((y[i]<0) || (y[i]>100)) || ((h[i]<0) || (h[i]>10e9))) exit(1);
	}

	for (int i = 0; i <= 100; ++i)
	{
		for (int j = 0; j <= 100; ++j)
		{
			l = 0;
			while (h[l] == 0) l++;
			H = h[l] + labs(x[l]-(long)i) + labs(y[l]-(long)j);
			for (int k = 0; k < n; ++k)
			{
				flag = 0;
				H1 = h[k] + labs(x[k]-(long)i) + labs(y[k]-(long)j);
				if (h[k] != 0)
				{
					if (H != H1)
					{
						flag = 1;
						break;
					}
				}else
				{
					if (H > H1)
					{
						flag = 1;
						break;
					}
				}
			}
			if (flag == 0)
			{
				printf("%d %d %ld\n", i, j, H);
				free(x);
				free(y);
				free(h);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
#Python Competetive Programming Template

from sys import stdin, stdout
from math import *

testing = True

def tp(s="\n"):
	if testing:
		stdout.write(s)

def main():
	s = stdin.readline().strip()
	if s[-1] != "s":
		s += "s"
	else:
		s += "es"
	stdout.write("{0}\n".format(s))
	

main()

Measured memory_bytes: 9120