akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
long long x[10000010], y[10000010];
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lep(j, n) for (int j = 0; j < (n); j++)
#define reps(i, n) for (int i = 1; i < (n); i++)
#define leps(i, n) for (int j = 1; j < (n); j++)
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define int long long
#define gsort(x, n) sort((x), (x) + (n), greater<int>());
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   string s;
   cin >> s;

   rep(i, s.size() - 8)
   {
      cout << s[i];
   }
   cout << '\n';
}

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

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.14159265358979323846264338327950288419

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

using namespace std;

int n, s[100005], p;
map<int, int> M;

int odd[2];

int main(){
	scanf("%d", &n);
	FI(i, 1, n){
		scanf("%d", &s[i]);
		M[s[i]] = i;
	}
	for(auto it: M) s[(it).se] = ++p;
	
	FI(i, 1, n){
		if((s[i] & 1) ^ (i & 1)){
			odd[i & 1]++;
		}
	}
	printf("%d\n", max(odd[0], odd[1]));
	return 0;
}

Measured memory_bytes: 5376
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 5e5 + 120;



int main(){FAST;    
  int n;
  cin >> n;
    if(n < 1200)
        cout << "ABC";
    else if(n < 2800)
        cout << "ARC";
    else
        cout << "AGC";

     
    return 0;

}
 










Measured memory_bytes: 256
N = int(input())
R=[0]

for i in range(N):
    R.append(int(input()))

now=1
cnt=0
arrive=False
for i in range(N):
    now=R[now]
    cnt+=1
    if now==2:
        arrive=True
        break

if arrive:
    print(cnt)
else:
    print('-1')


Measured memory_bytes: 7080
def col(a):
  if a % 2 == 0:
    return a//2
  else:
    return a*3 + 1

s = int(input())

an = [s]
i = 1
while True:
  i += 1
  an_1 = col(an[-1])
  if an_1 in an:
    break
  else:
    an.append(an_1)

print(i)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
using namespace std;
long long a, b, tmp, x, r;
//string s, t, ans;
int main()
{
    cin >> a >> b;
    x = a * b;
    if (a < b)
    {
        tmp = a;
        a = b;
        b = tmp;
    }
    r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    cout << x / b << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const int mod=998244353;
const int N=1e5+10;
const int inf=1e9;
int n,s,a[3010];
ll f[3010][3010];
ll x[3010];
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	x[0]=1;
	rep(i,1,3000) x[i]=x[i-1]*2%mod;
	cin>>n>>s;
	rep(i,1,n) cin>>a[i];
	f[0][0]=1;
	rep(i,1,n){
		rep(j,a[i],s){
			f[i][j]=(f[i][j]+f[i-1][j-a[i]])%mod;
		}
		rep(j,0,s){
			f[i][j]=(f[i][j]+f[i-1][j]*2)%mod;
		}
	}
	cout<<f[n][s]<<endl;
	return 0;
}

Measured memory_bytes: 74136
/*░░░░░░░▄▄▄▀▀▀▄▄███▄
░░░░░▄▀▀░░░░░░░▐░▀██▌
░░░▄▀░░░░▄▄███░▌▀▀░▀█
░░▄█░░▄▀▀▒▒▒▒▒▄▐░░░░█▌
░▐█▀▄▀▄▄▄▄▀▀▀▀▌░░░░░▐█▄
░▌▄▄▀▀░░░░░░░░▌░░░░▄███████▄
░░░░░░░░░░░░░▐░░░░▐███████████▄
░░░░░le░░░░░░░▐░░░░▐█████████████▄
░░░░toucan░░░░░░▀▄░░░▐██████████████▄
░░░░░░has░░░░░░░░▀▄▄████████████████▄
░░░░░arrived░░░░░░░░░░░░█▀██████*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MAXN = 200 * 1000 + 7;
const int INF = 4 * MAXN;
ll a[MAXN];
int gol[MAXN], gor[MAXN];
int main()
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", &a[i]);
	}
	vector<pair<ll, int> > st;
	st.push_back(make_pair(-INF, 0));
	for (int i = 1; i <= n; i++)
	{
		while (!st.empty() && st.back().first > a[i])
		{
			st.pop_back();
		}
		gol[i] = st.back().second;
		st.push_back(make_pair(a[i], i));
	}
	st.clear();
	st.push_back(make_pair(-INF, n + 1));
	for (int i = n; i >= 1; i--)
	{
		while (!st.empty() && st.back().first >= a[i])
		{
			st.pop_back();
		}
		gor[i] = st.back().second;
		st.push_back(make_pair(a[i], i));
	}
	ll res = 0;
	for (int i = 1; i <= n; i++)
	{
		//cerr << i << " " << gol[i] << " " << gor[i] << endl;
		res += 1LL * a[i] * (i - gol[i]) * (gor[i] - i);
	}
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 7280
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
	
#define int long long
#define double long double 
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
// Use for file I/O;
#define FIN string _fname = "paintbarn"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);

using namespace std;

const int INF = 4e18 + 10;
const int INF2 = 2e18 + 10;
const int INF3 = 2e10;
const int MAXN = 305;
const int LOGN = 19;
const int MOD = 1e9 + 7;
const int EPS = 1e-9;
const int MULT = 2e5;
const int MCNST = MOD * MOD * 8;

int32_t main() {
	FAST;

	int n, k;
	cin >> n >> k;

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

	for (int i = k; i < n; i++) {
		cout << (a[i - k] < a[i] ? "Yes" : "No");
		cout << '\n';
	}
}

Measured memory_bytes: 4784
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]
ans = [N * (N - 1) // 2]
uf = UnionFind(N)
for i in range(M-1,-1,-1):
  if uf.same(AB[i][0]-1,AB[i][1]-1):
    ans.append(ans[-1])
  else:
    ans.append(ans[-1] - uf.size(AB[i][0]-1) * uf.size(AB[i][1]-1))
  uf.union(AB[i][0]-1,AB[i][1]-1)
ans = list(reversed(ans))
print(*ans[1:],sep="\n")

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

int main(){
  int64_t N;
  cin >> N;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin >> L.at(i);
  }
  sort(L.begin(),L.end());
  reverse(L.begin(),L.end());
  int a,b,c;
  int64_t ans=0;
  for(int i=0;i<N;i++){
    a=L.at(i);
    bool flag=true;
    for(int j=i+1;j<N;j++){
      b=L.at(j);
      for(int k=j+1;k<N;k++){
        c=L.at(k);
        if(abs(a-b)<c){
          if(a+b>c){
            ans++;
          }
        }else{
          flag=false;
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

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

        long long ans = 0;
        if (B > N) {
                ans = A * N / B;
        }
        else {
                ans = A * (B-1) / B;
        }
        cout << ans << endl;



}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
using namespace std;
int main() {
int A,B;
cin>>A>>B;
if (A>=13){
	cout<<B<<endl;
}
if(6<=A && A <13){
	cout<<B/2<<endl;
}
if(A<6){
	cout<<0<<endl;
}
	return 0;
}


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

int main() {
  int N = 5;
  int sum = 0;
  int just_num = 0;
  int min_num = 10;
  int A[N];
  for (int i = 0; i < N; i++) {
    int val;
    cin >> val;
    sum += (val / 10) * 10;
    if (val%10 != 0) {
      sum += 10;
      min_num = min(min_num, val%10);
    }
  }
  cout << sum - (10-min_num) << endl;
  return 0;
}


Measured memory_bytes: 256
use std::fmt::Debug;
use std::str;
use std::str::FromStr;
use std::io;
use std::io::{Read, Stdin};
 
fn main() {
    let mut input = Scanner::new();
    let n = input.parse::<usize>() + 1;
    let m = input.parse::<usize>() + 1;
    let q = input.parse::<usize>();
    let mut s = vec![vec![0; m + 5]; n + 5];
    for i in 1..n {
        let t: Vec<_> = input.parse::<String>().chars().collect();
        for j in 1..m {
            s[i][j] = if t[j - 1] == '1' {1} else {0};
        }
    }
    let mut bit = vec![vec![0; m]; n];
    let mut sid = vec![vec![0; m]; n];
    let mut ver = vec![vec![0; m]; n];
    for i in 1..n {
        for j in 1..m {
            bit[i][j] = bit[i-1][j] + bit[i][j-1] - bit[i-1][j-1] + s[i][j];
            sid[i][j] = sid[i-1][j] + sid[i][j-1] - sid[i-1][j-1] + if s[i][j] == 1 && s[i][j-1] == 1 {1} else {0};
            ver[i][j] = ver[i-1][j] + ver[i][j-1] - ver[i-1][j-1] + if s[i][j] == 1 && s[i-1][j] == 1 {1} else {0};
        }
    }
    for _ in 0..q {
        let x1 = input.parse::<usize>() - 1;
        let y1 = input.parse::<usize>() - 1;
        let x2 = input.parse::<usize>();
        let y2 = input.parse::<usize>();
        let a = bit[x2][y2] - bit[x2][y1] - bit[x1][y2] + bit[x1][y1];
        let b = sid[x2][y2] - sid[x2][y1+1] - sid[x1][y2] + sid[x1][y1+1];
        let c = ver[x2][y2] - ver[x2][y1] - ver[x1+1][y2] + ver[x1+1][y1];
        println!("{}", a - b - c);
    }
}
 
struct Scanner {
    stdin: Stdin,
    buf: Vec<u8>,
}
 
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            buf: Vec::with_capacity(256),
        }
    }
 
    fn parse<T: FromStr>(&mut self) -> T
        where <T as FromStr>::Err: Debug
    {
        self.buf.clear();
        let mut it = self.stdin.lock().bytes();
        let mut c = it.next().unwrap().unwrap();
        while c == ' ' as u8 || c == '\n' as u8 {
            c = it.next().unwrap().unwrap();
        }
        while !(c == ' ' as u8 || c == '\n' as u8) {
            self.buf.push(c);
            c = it.next().unwrap().unwrap();
        }
        str::from_utf8(&self.buf).unwrap().parse::<T>().unwrap()
    }
}

Measured memory_bytes: 71420
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

int main()
{
	long long int L, R;
	cin >> L >> R;
	R = std::min(L + 2020, R);
	long long int  min_mul = (1LL << 40);
	for (long long int i = L; i < R; i++)
		for (long long int j = i + 1; j <= R; j++)
		{	
			int m = ((i % 2019) * (j % 2019)) % 2019;
			if(m < min_mul){
				min_mul = m;
			}
		}

	cout << min_mul;
	return 0;
}

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

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int ans=min(a,d);
	d-=a+b;
	if(d>0) ans-=d;
	cout<<ans<<"\n";
	return 0; 
}

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

#define FOR(s, i, n) for(int i = s; i n; i++)
typedef long long ll;
const int INF = 1e9;

//1000 mb = 1e9 b = 2.5e8 intergers

const int MOD = 998244353;
ll dp[3005][7000] = {{0}}; //ans up to i and n = i
ll dp2[3005][7000] = {{0}}; //solCnt up to i
ll binPow (ll x, ll k){
	ll ans = 1;
	while (k > 0){
		if (k % 2 == 0){
			x = (x*x) %MOD;
			k/=2;
		}else{
			ans = (ans*x) %MOD;
			k--;
		}
	}
	return ans;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, s;
	cin>>n>>s;
	vector<int> nums(n);
	for (int i = 0; i < n; i++){
		cin>>nums[i];
	}
	for (int i = 0; i < n; i++){
		dp[i][0] = binPow(2, i);
		// dp2[i][0] = 1;
		for (int j = 0; j <= 3000; j++){
			dp[i+1][j] += dp[i][j] * 2; dp[i+1][j] %= MOD;
			dp[i+1][j+nums[i]] += dp[i][j]; dp[i+1][j+nums[i]] %= MOD; 
			// dp2[i+1][j] += dp2[i][j];
			// dp2[i+1][j+nums[i]] += dp2[i][j];
		}
	}

	// for (int i = 0; i <= n; i++){
	// 	for (int j = 0; j <= 10; j++){
	// 		cout<<dp[i][j]<<' ';
	// 	}
	// 	cout<<'\n';
	// }
	cout<<dp[n][s]<<'\n';
	return 0;
}

Measured memory_bytes: 117424
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;

  int answer;
  if (k <= a + b) {
    answer = min(a, k);
  } else {
    answer = a - (k - a - b);
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define REP(i,n) for (int (i); i < (n); i++)

int main() {
	int n;
	string s;
	cin >> n;
	REP(i, n) {
		cin >> s;
		if (s == "Y") {
			puts("Four");
			return 0;
		}
	}
	puts("Three");
}

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

int getSum(int n){
    int sum = 0;
    while(n != 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    int total = 0;
    for (int i = 1; i <= N; i++){
        int sum = getSum(i);
        if (sum >= A && sum <= B){
            total += i;
        }
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main()
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if (((x-r>=0)&&(x+r<=W))&&((y-r>=0)&&(y+r<=H)))
	{
	printf("Yes\n");
	}
	else
	{
	printf("No\n");
	}
	
	return 0;
}

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

int main() {
  ll a,b,k;
  cin >> a >> b >> k;

  ll t,ao;
  if(a >= k) {
    t = a - k;
    ao = b;
  } else {
    t = 0;
    ao = (a + b - k) >= 0 ? (a + b - k) : 0;
  }

  cout << t << " " << ao << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var N, K int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d", &N, &K)

	ans := 0
	use := false
	for i := 1; i <= N; i++ {
		if !use {
			ans++
			use = true
		} else {
			use = false
		}
	}

	if ans >= K {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int mem[66][2][2][2];
ll mod=1e9+7, n, m;
int dp(int x, int l1, int l2, int l){
    if(x==-1){
        return l;
    }
    if(mem[x][l1][l2][l]!=-1)
        return mem[x][l1][l2][l];
    ll res=0;
    if(l1){
        if(l2){// 1 1, 1 0, 0 0
            res=dp(x-1, 1, 1, 1)+dp(x-1, 1, 1, l);
            if(l)
                res+=dp(x-1, 1, 1, l);
        }
        else{
            if(m&(1ll<<x)) // 1 1
                res=dp(x-1, 1, 0, 1);
            else{ // 1 1, 1 0, 0 0
                res=dp(x-1, 1, 1, 1)+dp(x-1, 1, 0, l);
                if(l)
                    res+=dp(x-1, 1, 0, l);
            }
        }
    }
    else{
        if(l2){
            if(n&(1ll<<x)){ // 1 1, 1 0, 0 0
                res=dp(x-1, 0, 1, 1)+dp(x-1, 1, 1, l);
                if(l)
                    res+=dp(x-1, 0, 1, l);
            }
            else{ // 0 0
                res=dp(x-1, 0, 1, l);
            }
        }
        else{
            if(n&(1ll<<x)){
                if(m&(1ll<<x)){  // 1 1
                    res=dp(x-1, 0, 0, 1);
                }
                else{ // 1 1, 1 0, 0 0
                    res=dp(x-1, 0, 1, 1)+dp(x-1, 1, 0, l);
                    if(l)
                        res+=dp(x-1, 0, 0, l);
                }
            }
            else{
                if(m&(1ll<<x)){
                    ;
                }
                else{ // 0 0
                    res=dp(x-1, 0, 0, l);
                }
            }
        }
    }
    res%=mod;
    mem[x][l1][l2][l]=res;
    return res;
}
int main(){
    while(cin>>m>>n){
        ll ans=0;
        memset(mem, -1, sizeof mem);
        ans=dp(62, 0, 0, 0);
        cout<<ans<<endl;
    }
  return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int prime[55555] = {};
    rep(i,2,55555){
        if(prime[i])continue;
        for(int j = i * 2;j < 55555;j += i){
            if(j % i == 0){
                prime[j] = 1;
            }
        }
    }
    
    vector<int> V;
    rep(i,2,55555)if(i % 5 == 1 && !prime[i])V.push_back(i);
    
    int N;
    cin >> N;
    rep(i,0,N)cout << V[i] << " ";
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_INPUT_SIZE  1024

void trace(int num, int* array);
int bubbleSort(int num, int* array);

int
main(int argc, char* argv[])
{
    char input[MAX_INPUT_SIZE];

    int num = atoi(fgets(input, sizeof(input), stdin));
    int* array = new int[num];

    atoi(fgets(input, sizeof(input), stdin));
    for (int i = 0; i < num; i++) {
        array[i] = i == 0 ?
            atoi(strtok(input, " ")) : atoi(strtok(NULL, " "));
        //printf("%d\n", array[i]);
    }

    printf("%d\n", bubbleSort(num, array));


    if (array != NULL) {
        delete [] array;
    }

    return 0;
}

void
trace(int num, int* array)
{
    for (int i = 0; i < num; i++) {
        if (i != 0) {
            printf(" ");
        }
        printf("%d", array[i]);
    }
    printf("\n");
}

int
bubbleSort(int num, int* array)
{
    int ret = 0, loopCount = 0;
    
    for (int j = 0; j < num; j++) {
        for (int i = num-1; i > 0; i--) {
            if (array[i] < array[i-1]) {
                int tmp = array[i];
                array[i] = array[i-1];
                array[i-1] = tmp;
                ret++;
            }
        }
    }
    /*
    for (int i = 0; i < num; i++) {
        printf("%d\n", array[i]);
    }
    */
    trace(num, array);

    return ret;
}

Measured memory_bytes: 1004
N,M = [int(x) for x in input().split()]

a = [int(x) for x in input().split()]

counter = {}

counter[0]=1

sum=[]
acc = 0
for num in a:
    acc+=num
    sum.append(acc)

for s in sum:
    if s%M not in counter.keys():
        counter[s%M]=1
    else:
        counter[s%M]+=1



result=0
for k in counter:
    p=counter[k]
    if p>0:
        result+= int(p*(p-1)/2)

print(result)

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

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

using namespace std;

int main(void){
  vector<string> day = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string s;
  cin >> s;
  rep(i, 7){
    if(day[i] == s){
      cout << 7 - i << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
s = [["."] * (w + 1)]
for i in range(h):
    s.append(["."] + list(input()) + ["."])
s.append(["."] * (w + 1))
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            if s[i - 1][j] == "." and s[i + 1][j] == "." and s[i][j - 1] == "." and s[i][j + 1] ==".":
                print("No")
                exit()
print("Yes")

Measured memory_bytes: 3064
import sys
import io
import math
import re

datalist = input().split()
num_summit = list(str(datalist[0]))

num_match = 0
flag = 0

for num in range(len(num_summit)):
    check_num = int(num_summit[num])
    if check_num == flag % 2:
        num_match += 1
    flag += 1

if num_match * 2 < len(num_summit):
    print(num_match)
else:
    print(len(num_summit)- num_match)


Measured memory_bytes: 4212
#[allow(unused_imports)]
use std::collections::HashSet;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let abc = read_vec::<usize>();
    let a = abc[0];
    let b = abc[1];
    let c = abc[2];


    let answer = solve(a, b, c);
    println!("{}", answer);
}

fn solve(a: usize, b: usize, c:usize) -> usize {
    if (a < b) {
        if (b < c) {
            return a + b;
        } else {
            return a + c;
        }
    } else {
        if (a < c) {
            return a + b;
        } else {
            return b + c;
        }
    }
}


Measured memory_bytes: 4352
a = map(int, raw_input().split())

W=a[0]
H=a[1]
x=a[2]
y=a[3]
r=a[4]
no="No"
yes="Yes"

if x-r < 0:
	print no
	
elif y-r < 0:
	print no
	
elif x+r > W:
	print no
	
elif y+r > H:
	print no
	
else:
	print yes

Measured memory_bytes: 6428
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    if (N >= K*2 - 1)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    String S = sc.next();

    sc.close();

    String[] s = S.split("");

    int red = 0;
    int blue = 0;

    for (int i = 0; i < s.length; i++) {
      if(s[i].equals("0")){
        red++;
      } else {
        blue++;
      }
    }

    System.out.println(s.length - Math.abs(red - blue));

  }

}

Measured memory_bytes: 35064
K, N = map(int, input().split())
a = [int(x) for x in input().split()]

dist = [0] * (N + 1)

for i in range(N-1):
    dist[i] = a[i+1] - a[i]

dist[N] = K - a[N - 1] + a[0]

print(K - max(dist))

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

const int MAX_NB = 22, MOD = 1e9+7;

int main() {
	int nbPersonne;
	cin >> nbPersonne;

	bool comp[nbPersonne][nbPersonne];

	for(int i = 0; i < nbPersonne; i++) {
		for(int j = 0; j < nbPersonne; j++) {
			cin >> comp[i][j];
		}
	}

	int dp[(1 << MAX_NB)] = {0};
	dp[0] = 1;

	for(int mask = 1; mask < (1 << nbPersonne); mask++) {
		for(int bitEnleve = 0; bitEnleve < MAX_NB; bitEnleve++) {
			int rang = __builtin_popcount(mask)-1;
			if(mask & (1 << bitEnleve) && comp[rang][bitEnleve]) {
				dp[mask] += (dp[mask - (1 << bitEnleve)]);
				dp[mask] %= MOD;
			}
		}
	}

	cout << dp[(1 << nbPersonne)-1];
}

Measured memory_bytes: 19972
#include <stdio.h>
#include <string.h>
int main (){
int j,i,k=0,d=0;
char s[100002]={0};
  scanf ("%s",s);
  for (i=0;s[i]!=0;i++){
  if (s[i]=='0'){
    k++;
  }
  else {
  d++;
  }  
  }
  if (k<d){
  printf ("%d",k*2);
  }
else {
printf ("%d",d*2);
}
return 0;
}


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

int main()
{
 string str;

 cin>>str;
 int counter=0;
 
 if(str[0]!='A'){cout<<"WA"; return 0;}
 if(str[str.size()-1]=='C'|| str[1]=='C'){cout<<"WA"; return 0;}

        for(int i=2;i<str.size()-1;i++){
            if(str[i]=='C') counter++;}

        if(counter>1 || counter==0){cout<<"WA"; return 0;}

counter=0;
 for(int i=0;i<str.size();i++){

       if(islower(str[i])) {counter++;}

    }

if(counter==str.size()-2) {cout<<"AC"; return 0;}
else cout<<"WA";
 

    return 0;
}


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

int main() {
	int a,b;
    cin >> a >> b;
    if(a%3 == 0||b%3 == 0){
      cout << "Possible" << endl;
    }else if((a+b)%3 == 0){
      cout << "Possible" << endl;
    }else{
      cout << "Impossible" << endl;
    }
}

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

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

  map<string, int> m;
  m.insert(std::make_pair("SUN",7));
  m.insert(std::make_pair("MON",6));
  m.insert(std::make_pair("TUE",5));
  m.insert(std::make_pair("WED",4));
  m.insert(std::make_pair("THU",3));
  m.insert(std::make_pair("FRI",2));
  m.insert(std::make_pair("SAT",1));

  std::cout << m.at(S) << std::endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    
    int x = n%1000;
    if(x == 0) {
        cout << x << endl;
    }else {
        x = 1000-x;
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 3548
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int check(int n){
	int ans=n%10;
	while(n/10!=0){
		n/=10;
		ans+=n%10;
	}
	return ans;
}

int main(void) {
	int n,a,b;
	cin >> n >> a >> b;
	long long ans=0;
	for(int i=1; i<=n; i++){
		int temp=check(i);
		if(a<=temp && temp <=b){
			ans+=i;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

ll memo[100005]={};

void mod_pow3(ll m){
    memo[0]=1;
    rep(i,m){
        if(i==0)continue;
        memo[i]=memo[i-1]*3;
        memo[i]%=MOD;
    }
    return ;
}

int main(void) {
    string s;
    cin >> s;
    ll n=s.size();
    ll cnt[3][n+1];
    mod_pow3(100000);
    DEBUG{
        rep(i,4)cout << memo[i] << endl;
    }
    rep(i,3)rep(j,n+1)cnt[i][j]=0;
    for(int i=0;i<n;i++){
        if(s[i]=='A')cnt[0][i+1]++;
        else if(s[i]=='C')cnt[1][i+1]++;
        else if(s[i]=='?')cnt[2][i+1]++;
        cnt[0][i+1]+=cnt[0][i];
        cnt[1][i+1]+=cnt[1][i];
        cnt[2][i+1]+=cnt[2][i];
    }
    ll res=0;
    for(int i=1;i<n;i++){
        if(s[i-1]=='B'){
            res+=cnt[0][i-1]*(cnt[1][n]-cnt[1][i])*memo[cnt[2][n]];
            res%=MOD;
            res+=cnt[0][i-1]*(cnt[2][n]-cnt[2][i])*memo[max(cnt[2][n]-1,0LL)];
            res%=MOD;
            res+=cnt[2][i-1]*(cnt[1][n]-cnt[1][i])*memo[max(cnt[2][n]-1,0LL)];
            res%=MOD;
            res+=cnt[2][i-1]*(cnt[2][n]-cnt[2][i])*memo[max(cnt[2][n]-2,0LL)];
            res%=MOD;
        }else if(s[i-1]=='?'){
            res+=cnt[0][i-1]*(cnt[1][n]-cnt[1][i])*memo[max(cnt[2][n]-1,0LL)];
            res%=MOD;
            res+=cnt[0][i-1]*(cnt[2][n]-cnt[2][i])*memo[max(cnt[2][n]-2,0LL)];
            res%=MOD;
            res+=cnt[2][i-1]*(cnt[1][n]-cnt[1][i])*memo[max(cnt[2][n]-2,0LL)];
            res%=MOD;
            res+=cnt[2][i-1]*(cnt[2][n]-cnt[2][i])*memo[max(cnt[2][n]-3,0LL)];
            res%=MOD;
        }
        DEBUG{cout << res << endl;}
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3584
INFTY = 10**12
N,K = map(int,input().split())
A = list(map(int,input().split()))
A = [bin(A[i])[2:] for i in range(N)]
for i in range(N):
    A[i] = (40-len(A[i]))*"0"+A[i]
K = bin(K)[2:]
m = len(K)
K = (40-len(K))*"0"+K
dp = [[-INFTY for _ in range(2)] for _ in range(41)]
dp[0][0] = 0
for i in range(1,41):
    for small in range(2):
        for d in range(2):
            ni = i
            nsmall = small
            nd = int(K[i-1])
            cnt = 0
            for j in range(N):
                cnt += int(A[j][i-1])^d
            if small==0:
                if d>nd:continue
                if d<nd:nsmall=1
            dp[ni][nsmall] = max(dp[ni][nsmall],2*dp[i-1][small]+cnt)
tot = max(dp[40][0],dp[40][1])
print(tot)    

Measured memory_bytes: 99660
/*



*/


#include<bits/stdc++.h>

using namespace std;

#define fstinpt     ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll          long long
#define sn          1010
#define bn          6000007
#define M           1000000007
#define sss         cout<<" "
#define nnn         cout<<"\n"

map<ll,bool>m;

int main()
{
        fstinpt;
        ll x,n;
        cin>>x>>n;
        for(ll i = 0; i < n; i++)
        {
                ll a; cin>>a; m[a] = 1;
        }
        for(ll i = 0; ; i++)
        {
                if(m[x-i] == 0){cout<<x-i; break;}
                if(m[x+i] == 0){cout<<x+i; break;}
        }
        return 0;
}


/*
10 5
4 7 10 6 5







*/






















/**/


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

class UnionFind {
	vector<int> data;
	vector<int> rank;
	int root(int a) {
		return data[a] < 0 ? a : data[a] = root(data[a]);
	}
public:
	UnionFind(int n) : data(n, -1), rank(n, 1) {}
	bool Find(int a, int b) {
		return root(a) == root(b);
	}
	void Union(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b) return;
		if (rank[a] < rank[b]) {
			data[a] += data[b];
			data[b] = a;
		}
		else {
			data[b] += data[a];
			data[a] = b;
			if (rank[a] == rank[b]) rank[b]++;
		}
	}
	int Size(int a) {
		return -data[root(a)];
	}
	int Rank(int a) {
		return rank[root(a)];
	}
};

int main()
{
	ll N, M;
	cin >> N >> M;
	UnionFind uf(N * 2), uf2(N + 1);
	for (int i = 0, u, v; i < M; i++) {
		cin >> u >> v; u--; v--;
		uf.Union(u, v + N);
		uf.Union(u + N, v);
		uf2.Union(u, v);
	}
	ll res = 0, c1 = 0, c2 = 0, c3 = 0;
	for (int i = 0; i < N; i++) {
		if (!uf2.Find(i, N)) {
			if (uf2.Size(i) == 1) {
				c1++;
			}
			else if (!uf.Find(i, i + N)) {
				c2++;
			}
			else {
				c3++;
			}
			uf2.Union(i, N);
		}
	}
	res = N * c1 * 2 - c1 * c1 + c2 * c2 * 2 + c2 * c3 * 2 + c3 * c3;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#ifdef _debug
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#define dout(i) //
#endif
using ll = long long;
using ull = unsigned long long;
using ul = unsigned;
const int maxn = 200001;
const int tomod = 998244353;
#define getp(i) cin>>i.first>>i.second
ll mv[maxn];
ll form(ll v){return (v + tomod) % tomod;}
pair<int,int> dot[maxn];
int n;
ll res;
struct bit{
	int v[maxn];
	int lowbit(int i){return i & -i;}
	void modify(int p, const int val){
		for(;p <= n;p += lowbit(p))v[p] += val;
	}
	int query(int p){
		int res = 0;
		for(;p;p ^= lowbit(p))res += v[p];
		return res;
	}
	int query(int l, int r){
		return query(r) - query(l-1);
	}
}tree;
ll a[maxn], b[maxn], c[maxn], d[maxn];
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	for(int i = 0;i < n;++i)getp(dot[i]);
	sort(dot, dot+n);
	for(int i = 0;i < n;++i)dot[i].first = i + 1, swap(dot[i].first, dot[i].second);
	sort(dot, dot+n);
// init()
	for(int i = 1;i <= n;++i)mv[i] = form(((mv[i-1]+1)<<1) - 1);
// 
	for(int i = 0;i < n;++i){
		int &y = dot[i].second;
		b[i] = tree.query(y);
		a[i] = i - b[i];
		tree.modify(y, 1);
	}
	for(int i = 0;i < n;++i)tree.modify(dot[i].second, -1);
	for(int i = n - 1;i > -1;--i){
		int &y = dot[i].second;
		d[i] = tree.query(y);
		c[i] = (n-1) - i - d[i];
		tree.modify(y, 1);
	}
	// for(int i = 0;i < n;++i)tree.modify(dot[i].second, -1);
// 	
	for(int i = 0;i < n;++i){
		res = form(res + form(
			form(form(mv[a[i]] * mv[d[i]]) * (mv[c[i]+b[i]]+1)) + 
			form(form(mv[b[i]] * mv[c[i]]) * (mv[a[i]+d[i]]+1)) -
			form(form(mv[a[i]] * mv[d[i]]) * form(mv[b[i]] * mv[c[i]])) + 
			mv[n-1]+1
		));
	}
	cout << res << '\n';
}

Measured memory_bytes: 10368
import numpy as np


def solve(s):
    MOD = 10 ** 9 + 7
    dp = np.zeros(13, dtype=np.int64)
    dp[0] = 1
    idx = np.zeros(13, dtype=np.int8)
    for i in range(13):
        idx[i * 10 % 13] = i
    window = np.ones(10, dtype=np.int8)
    for c in s:
        if c == '?':
            tdp = dp[idx]
            ndp = np.concatenate([tdp[4:], tdp])
            dp = np.convolve(ndp, window, mode='valid') % MOD
        else:
            dp = np.roll(dp[idx], int(c))
    return dp[5]


s = input()
print(solve(s))


Measured memory_bytes: 22288
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  bool operator==(const mint a) const { return x==a.x; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main(){
   int N,M;
   cin >> N >> M;
   int S[N];
   int T[M];
   for (int i = 0; i < N; i++)
   {
      cin >> S[i];
   }
   for (int i = 0; i < M; i++)
   {
      cin >> T[i];
   }
   mint dp[N+1][M+1];
   mint sum[N+1][M+1];
   memset(dp,0,sizeof(dp));
   memset(sum,0,sizeof(sum));
   dp[0][0]=1;
   for(int i = 0; i<=N;i++) sum[i][0]=1;
   for(int i = 0; i<=M;i++) sum[0][i]=1;
   for(int i = 0 ; i < N; i++){
      for(int j = 0 ; j < M; j++){
        if(S[i]==T[j]){
          dp[i+1][j+1]=sum[i][j];
        }
        else{
          dp[i+1][j+1]=0;
        }
        sum[i+1][j+1]=sum[i][j+1]+sum[i+1][j]-sum[i][j]+dp[i+1][j+1];
      }
   }
   cout << sum[N][M]<<endl;
   return 0;
}


Measured memory_bytes: 66144
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	ll ans = 1e18;
	for (int i = 0; i <= max(X, Y); i++)
	{
		ll price = C * 2 * i;
		if (i < X)
			price += (X-i) * A;
		if (i < Y)
			price += (Y-i) * B;
		ans = min(ans, price);
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
F=lambda x:x if P[x]<0else F(P[x]);N,M,*X=map(int,open(0).read().split());P=[-1]*-~N;S=N*~-N//2;r=[]
while X:
 r+=S,;b,a=sorted(map(F,(X.pop(),X.pop())))
 if a!=b:S-=P[a]*P[b];P[a]+=P[b];P[b]=a
print(*r[::-1],sep='\n')

Measured memory_bytes: 25076
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a * b // gcd(a, b)

import sys
input = sys.stdin.readline
N = int(input())
if N == 1:
    print(input())
else:
    T = [int(input()) for _ in range(N)]
    ans = lcm(T[0], T[1])
    for i in range(2, N):
        ans = lcm(ans, T[i])
    print(ans)


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int N, M;
vector<vint> G(100005);
bool flag[100005] = {};
int color[100005];

int dfs(int v, int c = 0) {
        int ret = 1;
        if (color[v] != -1 && c != color[v]) return (0);
        color[v] = c;
        if (flag[v]) return (1);
        flag[v] = true;
        //cout << v << endl;
        for (auto &u : G[v]) ret &= dfs(u, 1 - c);
        return (ret);
}

int main() {
        cin >> N >> M;
        fill_n(color, 100005, -1);
        for (int i = 0; i < M; i++) {
                int u, v;
                cin >> u >> v; --u, --v;
                G[u].push_back(v);
                G[v].push_back(u);
        }
        int colorable = 0;
        int cnt = 0;
        for (int i = 0; i < N; i++) {
                if (!flag[i] && G[i].size() > 0) {
                        colorable += dfs(i);
                        cnt++;
                        //cout << i << " " << colorable << endl;
                }
        }
        int rem = count(flag, flag + N, false);
        //cout << colorable << " " << cnt << " " << rem << endl;
        ll ans = (ll)rem * 2 * N - (ll)rem * rem + colorable;
        if (colorable >= 2) ans += (ll)colorable * (colorable - 1);
        ans += (ll)cnt * cnt;

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

Measured memory_bytes: 10112
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
time = 0
ans_a = 0
ans_b = 0
for i in range(N):
    if time + A[i] > K:
        break
    else:
        time += A[i]
        ans_a += 1
for i in range(M):
    if time + B[i] > K:
        break
    else:
        time += B[i]
        ans_b += 1
tmp = ans_a+ans_b
tmp2 = ans_a+ans_b
cnt_b = ans_b
for i in range(ans_a):
    time -= A[ans_a-i-1]
    tmp2 -= 1
    while True:
        if cnt_b == M:
            break
        if time + B[cnt_b] > K:
            break
        else:
            time += B[cnt_b]
            cnt_b += 1
            tmp2 += 1
    tmp = max(tmp,tmp2)
print(tmp)

Measured memory_bytes: 111012
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Long> a = new ArrayList<>();
		for(int i = 0; i < n; i++) {
			a.add(sc.nextLong() - i - 1);
		}
		Collections.sort(a);
		long b = a.get(a.size() / 2);
		long ans = 0;
		for(Long e : a) {
			ans += Math.abs(e - b);
		}
		System.out.println(ans);
	}

}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    long long N;
    std::cin >> N;
    long long M;
    std::cin >> M;
    std::vector<long long> a(M);
    std::vector<long long> b(M);
    for (int i = 0; i < M; i++) {
        std::cin >> a[i];
        std::cin >> b[i];
        a[i]--;
        b[i]--;
    }
    VV<int> e(N);
    V<bool> c(N);
    int ans = 0;
    rep(i, M) {
        rep(j, N) e[j].clear();  // １次元ごとにclear
        rep(j, N) { c[j] = false; }
        rep(j, M) {
            if (i != j) {
                e[a[j]].push_back(b[j]);  // shift alt ↓で選択行を下にコピー
                e[b[j]].push_back(a[j]);
            }
        }
        auto dfs = [&](auto self, int i) -> void {
            if (c[i] == true) return;
            c[i] = true;
            for (auto a : e[i]) {
                self(self, a);
            }
        };
        dfs(dfs, 0);
        rep(j, N) {
            if (c[j] == false) {
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,i,sum = 0,mn = 1e16,x = 0;
	cin>>n;vector<long long int> a(n + 1);
	for (i=0;i<n;i++){
		cin>>a[i];sum+=a[i];
	}
	for (i=0;i<n;i++){
		x+=a[i];mn=min(mn,abs(sum-2*x));
	}
	cout<<mn<<endl;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3

from math import *
from itertools import *
from collections import *


if __name__ == '__main__':
    s = ' ' + input()
    k = int(input())

    i = 1
    j = 1
    while j < len(s) and s[i] == s[j]:
        j += 1
    if k >= j and s[i] == '1':
        print(s[j])
    else:
        print(s[i])



Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>
int asc(const void *a, const void *b){
    return *(int*)a-*(int*)b;
}
int main(void){
    int n,i,a[200000];
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    qsort(a,n,sizeof(int),asc);
    for(i=1;i<n;i++){
        if(a[i-1]==a[i]){
            printf("NO");
            return 0;
        }
    }
    printf("YES");
    return 0;
}

Measured memory_bytes: 1788
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
#include <cmath>
#include <cstdio>
#include <complex>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main() {
  string s;
  cin>>s;
  for(int i=0;i<3;i++)s[i]=(s[i]=='1'?'9':'1');
  cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100

int main(){
    int a[MAX][MAX], b[MAX], c[MAX], n, m, i, j;
    scanf("%d %d", &n, &m);
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            scanf("%d", &a[i][j]);
        }
    }
    for(i = 0; i < m; i++){
        scanf("%d", &b[i]);
    }

    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            c[i] += a[i][j] * b[j];
        }
    }
    for(i = 0; i < n; i++){
        printf("%d\n", c[i]);
    }
    return 0;
}


Measured memory_bytes: 2144
#include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>
#include <cstring>

typedef long long ll;

using namespace std;

ll nCr[2000][2000] = {0};

int main(void){
	for(int i=1; i<1010; ++i){
		nCr[i][0] = nCr[i][i] = 1;
	}
	for(int i=2; i<1010; ++i){
		for(int j=1; j<i; ++j){
			nCr[i][j] = (nCr[i-1][j-1] + nCr[i-1][j]) % 100000007;
		}
	}

	int r, c, a1, a2, b1, b2;
	int min_1, min_2, coef = 1;
	cin >> r >> c >> a1 >> a2 >> b1 >> b2;

	min_1 = min(abs(a1-b1), r-abs(a1-b1));
	min_2 = min(abs(a2-b2), c-abs(a2-b2));

	if(abs(a1-b1) == r-abs(a1-b1)) coef *= 2;
	if(abs(a2-b2) == c-abs(a2-b2)) coef *= 2;

	int res;

	if(min_1+min_2 == 0){
		res = 1;
	} else {
		res =(coef * (int)nCr[min_1+min_2][min_2]) % 100000007 ;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 16088
//NEVER GIVE UP I AM GOING TO IMPROVE ONE DAY.
//PRACTICE,PRACTICE,PRACTICE!!!
#include<bits/stdc++.h>
#define int long long int
// #define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 1e18
#define endl "\n"
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); 
const int M=1000000000;
const double pi = acos(-1.0);
using namespace std;
// cout<<"Case #"<<test-t<<":"<<" "<<"N"<<endl;
int32_t main(){

    #ifndef ONLINE_JUDGE 
    freopen("in.txt", "r", stdin); 
    freopen("out.txt", "w", stdout); 
    #endif 

    fast;
    int t;
    t=1;
    // cin>>t;
    // int test=t;
    while(t--){
        int n,k,i;
        cin>>n>>k;
        int a[n];
        for(i=0;i<n;i++){
            cin>>a[i];
        }
        for(i=k;i<n;i++){
            if(a[i]>a[i-(k)]){
                cout<<"Yes"<<endl;
            }
            else{
                cout<<"No"<<endl;
            }
        }
    }
}

Measured memory_bytes: 5204
#define _CRT_SECURE_NO_WARNINGS

#define N (1<<17)
#define MODULO (1000000007)

#include <cstdio>
#include <iostream>
#include <fstream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <deque>
#include <vector>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
using namespace std;

int n;
pair<int, int> pos[N];
int len[N];
priority_queue<long long> PQL, PQR;
long long pbl, pbr;
long long Ans;

int main()
{
	scanf("%d", &n);
	for (int i = 0;i < n;i++)
	{
		scanf("%d%d", &pos[i].first, &pos[i].second);
		len[i] = pos[i].second - pos[i].first;
	}
	for (int i = 0;i < n;i++)
	{
		pbr += len[i];
		PQL.push(pos[i].second - pbl);
		PQR.push(pbr - pos[i].second);
		//__debugbreak();
		while (true)
		{
			long long L = PQL.top() + pbl;
			long long R = -PQR.top() + pbr;
			if (L <= R)
			{
				break;
			}
			Ans += L - R;
			PQL.pop(), PQR.pop();
			PQL.push(R - pbl), PQR.push(pbr - L);
			//__debugbreak();
		}
		pbl -= len[i];
		//__debugbreak();
	}
	printf("%lld\n", Ans);
	//system("pause");
	return 0;
}



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

#define rep(i, n) for(int i = 0; i < (n); ++i)

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    int N, M, K;
    cin >> N >> M >> K;

    bool ans = false;
    rep(i, N + 1) {
        rep(j, M + 1) {
            int a = i * M;
            int b = j * N;

            int res = a + b - i * j * 2;

            if (res == K) ans = true;
        }
    }

    if (ans) {
        puts("Yes");
    } else {
        puts("No");
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	char a, b, ans;

	cin >> a >> b;

	if (a == 'H')
	{
		if (b == 'H')
			ans = 'H';
		else
			ans = 'D';
	}
	else
	{
		if (b == 'H')
			ans = 'D';
		else
			ans = 'H';
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256