akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

bool b(long long l);
int K;
long long A[100000];

int main(){
	scanf("%d",&K);
	int m = 0;
	for(int i=0;i<K;i++){
		scanf("%lld",&A[i]);
		if(A[m] < A[i]){
			m = i;
		}
	}
	//printf("%lld\n",A[m]);
	if(A[K-1]!=2){
		printf("-1\n");
		return 0;
	}else{
		long long n = A[m];
		long long min=2,max=2;
		for(int i=K-1;i>=0;i--){
			bool exist = false;
			if(max-max%A[i] >= min){
				exist = true;
			}

			if(!exist){
				printf("-1\n");
				return 0;
			}
			min = ((min+A[i]-1)/A[i])*A[i];
			max = (max/A[i])*A[i] + A[i] - 1;
		}
		printf("%lld %lld\n", min, max);
	}

	return 0;
}

bool b(long long l){
	long long n = l;
	for(int i=0;i<K;i++){
		n -= (n%A[i]);
	}
	if(n!=2){
		return false;
	}else{
		return true;
	}
}


Measured memory_bytes: 896
#include<stdio.h>
int main(void)
{
	int N,p[10000],max,T,i,j,k;

	scanf("%d",&N);

	for(i=0;i<N;i++)
		scanf("%d\n",&p[i]);
               
	max=p[0];
	for (i=1;i<N;i++)
		if(max<p[i])
			max=p[i];

	T=0;
       for(i=0;i<N;i++)
	        T=T+p[i];
		
       T=T-0.5*max;

       printf("%d\n",T);
       return  0;

}
       



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

using namespace std;

unsigned long long n;
string red , blue , a;
bool b[40];
map < pair < string , string > , unsigned long long > h1 , h2;

void bkt(unsigned long long k , unsigned long long n , unsigned long long st , map < pair < string , string > , unsigned long long > &c)
{
    if(k == n + 1)
    {
        red.clear();
        blue.clear();

        for(unsigned long long i = st ; i <= n ; i++)
            if(b[i] == 1)
                red += a[i];
            else blue += a[i];

        ++c[make_pair(red , blue)];
    }
    else
    {
        b[k] = 0;
        bkt(k + 1 , n , st , c);

        b[k] = 1;
        bkt(k + 1 , n , st , c);
    }
}

int main()
{
    unsigned long long ans = 0;

    cin >> n;
    cin >> a;

    bkt(0 , n - 1 , 0 , h1);
    bkt(n , 2 * n - 1 , n , h2);

    for(auto i = h1.begin() ; i != h1.end() ; i++)
    {
        red = i -> first.first;
        blue = i -> first.second;

        reverse(red.begin() , red.end());
        reverse(blue.begin() , blue.end());

        ans += h2[make_pair(blue , red)] * i -> second;
    }

    cout << ans;

    return 0;
}


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

int main()
{
 int n,r;
 cin>>n;
if(n<1000)
{
    r=1000-n;
    cout<<r;
}
else if(n%1000==0)
{
    cout<<"0";
}
else
{
   r=(n/1000)+1;
   r=1000*r;
   r=r-n;
   cout<<r;

}
}


Measured memory_bytes: 3636
gets
a = gets.split(' ').map(&:to_i)
gets
b = gets.split(' ').map(&:to_i)

def solve(a,m,i)
  if m == 0
    return true
  elsif i >= a.size
    return false
  else
    res = solve(a,m,i+1) || solve(a,m-a[i],i+1)
  end
  return res
end
b.each do |m|
  if solve(a,m,0)
    puts "yes"
  else
    puts "no"
  end
end

Measured memory_bytes: 8696
n=int(input())
m=0
a=0
r=0
c=0
h=0
for i in range(n):
    s=input()
    if s[0]=="M":
        m+=1
    if s[0]=="A":
        a+=1
    if s[0]=="R":
        r+=1
    if s[0]=="C":
        c+=1
    if s[0]=="H":
        h+=1
print(m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h)



Measured memory_bytes: 75476
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 310
#define P 998244353
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
    int x=0,f=1;char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
    while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x*f;
}
int n,m,s,a[N],f[N*N],g[N*N];
signed main()
{
    n=read();
    for (int i=1;i<=n;i++) m+=a[i]=read();
    s=(m-1)/2;
    f[0]=1;
    for (int i=1;i<=n;i++)
    {
        for (int j=m;j>=a[i];j--)
        f[j]=(2ll*f[j]+f[j-a[i]])%P;
        for (int j=a[i]-1;j>=0;j--) f[j]=2ll*f[j]%P;
    }
    int ans=1;for (int i=1;i<=n;i++) ans=3ll*ans%P;
    for (int i=s+1;i<=m;i++) ans=(ans-3ll*f[i]%P+P)%P;
    if (m%2==0)
    {
        g[0]=1;
        for (int i=1;i<=n;i++)
        {
            for (int j=m;j>=a[i];j--)
            g[j]=(g[j]+g[j-a[i]])%P;
        }
        ans=(ans+3ll*g[m/2]%P+P)%P;//
    }
    cout<<ans;
    return 0;
}

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

using namespace std;
const int N = 3e5;
int n, a[N], c[N], b[N], d[N];
int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];
    int ans = 0;
    for (int j = 28; j >= 0; j--) {
        for (int i = 1; i <= n; i++) c[i] = a[i] % (1 << (j + 1));
        for (int i = 1; i <= n; i++) d[i] = b[i] % (1 << (j + 1));
        sort(d + 1, d + n + 1);
        int cr = 0;
        for (int i = 1; i <= n; i++) {
            if (c[i] < (1 << j)) {
                int l = (1 << j) - c[i];
                int r = (1 << (j + 1)) - c[i] - 1;
                int q1 = lower_bound(d + 1, d + n + 1, l) - d;
                int q2 = upper_bound(d + 1, d + n + 1, r) - d;
                q2--;
                cr ^= (q2 - q1 + 1) % 2;
            }
            else {
                int l = 0;
                int r = (1 << (j + 1)) - c[i] - 1;
                int q1 = lower_bound(d + 1, d + n + 1, l) - d;
                int q2 = upper_bound(d + 1, d + n + 1, r) - d;
                q2--;
                cr ^= (q2 - q1 + 1) % 2;
                l = (1 << (j + 1)) + (1 << j) - c[i];
                r = (1 << (j + 2));
                q1 = lower_bound(d + 1, d + n + 1, l) - d;
                q2 = upper_bound(d + 1, d + n + 1, r) - d;
                q2--;
                cr ^= (q2 - q1 + 1) % 2;

            }
        }
        ans += (1 << j) * cr;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4096
import math

def solve(ratio_list):
  a = 0
  b = 0
  for p, q in ratio_list:
    if a == 0 and b == 0:
      a = p
      b = q
    else:
      fact1 = -(-a//p)
      fact2 = -(-b//q)
      factor = int(max(fact1, fact2))
      a = factor*p
      b = factor*q
  return a,b


if __name__ == "__main__":
  n = int(input())
  ratio = [tuple(map(int, input().split())) for _ in range(n)]
  a,b = solve(ratio)
  print(a+b)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define pii pair<int,int>
#define int long long
#define cl(x,y) memset(x,y,sizeof(x))
#define ct cerr<<"Time elapsed:"<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define lson x<<1,l,mid
#define rson x<<1|1,mid+1,r
#define INF 1e18
const int N=1e6+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const double eps=1e-8;
const double pi=acos(-1);
using namespace std;
int a[N];
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n,k,i;
	cin>>n>>k;
	for(i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	int ans=0;
	for(i=1;i<=n-k;i++)
		ans+=a[i];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5180
#include<iostream>
using namespace std;
long long int MOD = 1000000007;
long long modpow(long long a, long long n, long long mod);
long long modinv(long long a, long long mod);

int main() {

	long long int n;
	cin >> n;
	long long int a, b;
	cin >> a >> b;
	if (n == 2) {
		cout << 0 << endl;
		return 0;
	}
	long long int sum = 1;
	int i;
	long long int x = 2, m = n;
	//2^nを計算
	while (m > 0) {
		if (m % 2 == 1) {
			sum = (sum * x) % MOD;
		}
		m = (int)(m / 2);
		x = (x * x) % MOD;
	}

	//cout << 1 << endl;
	
	long long int sum1 = 1;
	for (i = 1; i <= a; i++) {
		sum1 = (sum1 * (n + 1 - i)) % MOD;
	}
	for (i = 1; i <= a; i++) {
		sum1 = (sum1 * modinv(i, MOD)) % MOD;
	}
	sum = (sum - sum1 + MOD) % MOD;
	//cout << 2 << endl;

	sum1 = 1;
	for (i = 1; i <= b; i++) {
		sum1 = (sum1 * (n + 1 - i)) % MOD;
	}
	for (i = 1; i <= b; i++) {
		sum1 = (sum1 * modinv(i, MOD)) % MOD;
	}
	sum = (sum - sum1 + MOD) % MOD;
	sum = (sum + MOD - 1) % MOD;
	cout << sum << endl;
	return 0;

}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
	return modpow(a, mod - 2, mod);
}

Measured memory_bytes: 3596
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;


int main(void){
	int n; cin >> n;
	vint p(n); rep(i, n) cin >> p[i];
	vint q(n); rep(i, n) cin >> q[i];
	vint perm(n); rep(i, n) perm[i] = i+1;
	int a, b; a=b=0;
	int count = 1;
	do{
		rep(i, n){
			if(p[i] != perm[i]) break;
			if(i == n-1) a = count;
		}
		rep(i, n){
			if(q[i] != perm[i]) break;
			if(i == n-1) b = count;
		}
		count++;
	} while(next_permutation(ALL(perm)));
	cout << abs(a-b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

inline int get(int lhs, int rhs)
{
	int cnt = 1;

	for(int diff = lhs ^ rhs; (diff & 1) == 0; diff >>= 1)
		++cnt;

	return cnt;
}

void solve()
{
	int n;
	cin >> n;

	for(int v = 0; v < n; ++v)
	{
		for(int u = v + 1; u < n; ++u)
			cout << get(v, u) << " ";

		cout << endl;
	}
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 512
S = list(input())
ans = 'WA'
if S[0] == 'A' and S[2:len(S)-1].count('C') == 1 and S.count('A') ==1 and S.count('C') == 1:
    komozi =''
    for i in S:
        if i == 'A' or 'C':
            i = i.replace('A','')
            i = i.replace('C','')
        komozi += i
    if komozi.islower():
        ans = 'AC'
print(ans)

Measured memory_bytes: 3064
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let dc: Vec<(usize, usize)> = (0..n)
        .map(|_| {
            (
                itr.next().unwrap().parse().unwrap(),
                itr.next().unwrap().parse().unwrap(),
            )
        })
        .collect();

    let mut rem = 0;
    let mut ans = 0;
    for i in 0..n {
        ans += dc[i].1;
        rem += dc[i].0 * dc[i].1;
    }
    println!("{}", ans - 1 + (rem - 1) / 9);
}


Measured memory_bytes: 13560
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
#include<string>
#include<numeric>
#include<set>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    vector<long> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    
    vector<int> froml(n), fromr(n);
    froml[0] = fromr[n-1] = 0;
    for(int i = 1; i < n; i++){
        froml[i] = a[i-1] ^ froml[i-1];
        fromr[n-1-i] = a[n-i] ^ fromr[n-i];
    }
 
    for(int i = 0; i < n; i++){
        if((froml[i]^fromr[i]) != a[i]){
            cout << "No" << endl;
            return 0;
        }
    }
 
    cout << "Yes" << endl;
 
    return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    string S;
    cin >> S;
    int n = S.size() + 1;

    Vl dep(n);
    dep[0] = 0;
    for (int i = 0; i < n - 1; i++) {
        if (S[i] == '<') {
            dep[i + 1] = dep[i] + 1;
        }
        else {
            dep[i + 1] = dep[i] - 1;
        }
    }

    Vl candi;
    if (dep[0] < dep[1]) {
        candi.push_back(0);
    }
    if (dep[n - 2] > dep[n - 1]) {
        candi.push_back(n - 1);
    }
    for (int i = 1; i < n - 1; i++) {
        if (dep[i - 1] > dep[i] && dep[i] < dep[i + 1]) {
            candi.push_back(i);
        }
    }

    Vl ans(n);
    for (const auto& c : candi) {
        ans[c] = 0;
        int i = c;
        while (i - 1 >= 0 && dep[i - 1] > dep[i]) {
            ans[i - 1] = max(ans[i - 1], ans[i] + 1);
            --i;
        }
        i = c;
        while (i + 1 < n && dep[i] < dep[i + 1]) {
            ans[i + 1] = max(ans[i + 1], ans[i] + 1);
            ++i;
        }
    }

    ll v_ans = 0;
    for (int i = 0; i < n; i++) {
        v_ans += ans[i];
    }

    cout << v_ans << endl;

    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
  	long long a;
  	string b;
  	cin >> a >> b;
  	if (a<3200){
      cout << "red";
    }
  	else {
      cout << b;
    }
}

Measured memory_bytes: 3664
function Main(input) {
    var input = input.split("\n");
    var n = input[0];
    var stringNums = input[1].split(" ");
    var nums = []
    var count = 0
    var answerCount = 0


    for (var i = 0; i < n; i++) {
        nums.push(Number(stringNums[i]))
        // console.log(nums[i]/2/9 % 2);
    }

    for(var j = 0; j < Infinity; j++) {
        count = 0;
        for (var i = 0; i < n; i++) {
            if (nums[i] % 2 === 0) {
                count++;
                nums[i] = nums[i] / 2;
            }
        }
        if (count === Number(n)) {
            answerCount++;
        } else {
            break;
        }
    }
    console.log(answerCount);
    }
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  

Measured memory_bytes: 21064
#include <stdio.h>
int main(void){
  int N,i;
  long A,ans,c;
  scanf("%d",&N);
  scanf("%ld",&ans);
  for(i=1;i<N;i++){
    scanf(" %ld",&A);
    if(A<ans){A+=ans;ans=A-ans;A-=ans;}
    while(ans!=0){c=A%ans;A=ans;ans=c;}
    ans=A;
  }
  printf("%ld",ans);
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	String s = sc.next();
	int sL = s.length();
	String sT = s;
	for(int i = 0; i < s.length() / 2; i ++) {
		sL -= 2;
		sT = sT.substring(0, sL);
		if(sT.substring(0, sL / 2).equals(sT.substring(sL/2))) {
			System.out.println(sL);
			break;
		}
	}
}
}


Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

int dfs(vector<int> &oe, vector<vector<int>> &g, vector<bool> &used, int v, vector<pair<int, int>> &rev) {
    used[v] = true;
    int c = oe[v];
    for (auto u: g[v]) {
        if (used[u]) continue;
        if (dfs(oe, g, used, u, rev)) {
            int a = v, b = u;
            if (a > b) swap(a, b);
            rev.emplace_back(a, b);
            c++;
        }
    }
    return c%2;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> oe(n, 0);
    vector<vector<int>> g(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
        if (a < b) oe[a]++;
        else oe[b]++;
    }
    for (auto &e: oe) e %= 2;

    if (m % 2 == 1) {
        cout << -1 << endl;
        return 0;
    }

    vector<bool> used(n, false);
    vector<pair<int, int>> rev;
    dfs(oe, g, used, 0, rev);
    sort(rev.begin(), rev.end());
    for (int v = 0; v < n; ++v) {
        for (auto u: g[v]) {
            if (v > u) continue;
            if (binary_search(rev.begin(), rev.end(), make_pair(v, u))) {
                cout << u+1 << " " << v+1 << "\n";
            } else {
                cout << v+1 << " " << u+1 << "\n";
            }
        }
    }

    return 0;
}


Measured memory_bytes: 18680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
typedef pair<int, int> P;
const int MAX_N = 10000;
const int MAX_L = 100000000;
const int MAX_SQRT_B = 10000;
const int INF = 1000000000;
typedef int64_t ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll N, M;


int main() {
	cin >> N >> M;
	vector<pair<ll,ll>> AB(N);
	
	rep(i, N) {
		cin >> AB.at(i).first >> AB.at(i).second;
		
	}
	sort(AB.begin(), AB.end());

	ll cnt = M;
	ll tmp = 0;
	ll ans = 0;
	for (int i = 0; i < N; i++)
	{
		cnt = min(M-tmp, AB.at(i).second);
		ans += (AB.at(i).first )* cnt;

		tmp += cnt;
		if (M == tmp) {
			cout << ans << endl;
			return 0;
		}
	}
	
	
}

Measured memory_bytes: 4808
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

string day[7] =  {"Sunny", "Cloudy", "Rainy"};

int main(){
    int A, B;
    cin >> A >> B;
    if(B % A == 0){
        cout << A + B << endl;
    }else{
        cout << B - A << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define ROF(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
ll f[500005];

ll bm(ll b, ll p) {
    ll rt = 1;
    for (ll i = 1, j = b; i <= p; i *= 2, j = j * j % MOD) {
        if (p & i) rt = rt * j % MOD;
    }
    return rt;
}

ll ncr(ll n, ll r) {
    return f[n] * bm(f[r] * f[n - r] % MOD, MOD - 2) % MOD;
}

ll npr(ll n, ll r) {
    return f[n] * bm(f[n - r], MOD - 2) % MOD;
}

int main() {
    int n, m; cin >> n >> m;
    f[0] = 1;
    FOR(i, 1, m)
        f[i] = f[i - 1] * i % MOD;
    vll mt(n + 1);
    ll ans = 0;
    FOR(i, 0, n) {
        mt[i] = (ncr(n, i) * npr(m, i) % MOD) * (npr(m - i, n - i) * npr(m - i, n - i) % MOD) % MOD;
        if (i & 1) ans = (ans - mt[i] + MOD) % MOD;
        else ans = (ans + mt[i]) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11024
#include <iostream>
#include <string>

using namespace std;
int main() {
    string s;
    cin>>s;
    char c = s[s.size()-1];
    
    if(c == '2' || c=='4'||c=='5'||c=='7'||c=='9')
        cout<<"hon"<<endl;
    else if(c=='3')
        cout<<"bon"<<endl;
    else
        cout<<"pon"<<endl;
    return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n; cin >> n;
    vector<vector<int>> dp(2, vector<int>(n, 0));
    vector<vector<int>> A(2, vector<int>(n));
    rep(i, 2){
        rep(j, n){
            cin >> A[i][j];
        }
    }
    dp[0][0] = A[0][0];
    rep(i, 2){
        rep(j, n){
            if(j < n-1) chmax(dp[i][j+1], dp[i][j] + A[i][j+1]);
            if(i == 0)  chmax(dp[i+1][j], dp[i][j] + A[i+1][j]);
        }
    }
    cout << dp[1][n-1] << ln;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    lis = []
    lis.append((0, 0, 0))
    for _ in range(N):
        t, x, y = map(int, input().split())
        lis.append((t, x, y))
    ans = "Yes"
    for i in range(1, N+1):
        t_diff = lis[i][0] - lis[i-1][0]
        d_diff = abs(lis[i][1] - lis[i-1][1]) + abs(lis[i][2] - lis[i-1][2])
        if t_diff % 2 != d_diff % 2 or t_diff < d_diff:
            ans = "No"
            break
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 56796
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,i;
	ll m,a,t,ans=0ll;
	vector<ll> v;
	cin >> n >> m;
	v.push_back(0ll);
	for(i=0; i<n; ++i){
		cin >> a;
		v.push_back(a+v[i]);
	}
	for(i=n; i>0; --i){
		v[i] %= m;
	}
	sort(v.begin(),v.end());
	v.push_back(m);
	for(i=0; i<=n; ++i){
		if(v[i] == v[i+1]){
			continue;
		}
		t = (ll)(upper_bound(v.begin(),v.end(),v[i])-lower_bound(v.begin(),v.end(),v[i]));
		ans += (t*(t-1))/2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main()
{

int a,b,f=1;
cin>>a>>b;
string s;
cin>>s;


for(int i=0;i<a;i++)
{
if(!isdigit(s[i]))
{f=0;
break;}

}
for(int i=a+1;i<s.size();i++)
{
if(!isdigit(s[i]))
{f=0;break;}

}
if(s[a]=='-'&&f)
printf("Yes\n");
else
printf("No\n");
}

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


int main() {
    string s, ope, p, tmp;
    int i, j, h, num, start, end;

    cin >> s;
    cin >> num;

    for(j=0;j<num;j++){

        cin >> ope;
       
        if(ope == "replace"){
                cin >> start >> end >> p;
                for(i=start;i<=end;i++){
                    s[i] = p[i-start];
                }            
        }else if(ope == "reverse"){
                cin >> start >> end;
                for(i=start;i<=end;i++){
                    tmp[i-start] = s[i];
                }  
                for(i=start;i<=end;i++){
                    s[end-i+start] = tmp[i-start];
                }
        }else{
            cin >> start >> end;
            for(i=start;i<=end;i++){
               cout << s[i];
            }
            cout << endl;
        }

    }

    return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  cin >> N;
  vector<int> data(N);
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  sort(data.begin(), data.end());
  long sum = 0;
  for (int i = 0; i < N - 1; i++) {
    sum += data.at(i);
  }
  if (data.at(N - 1) < sum)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
p = 10**9+7
n, k = map(int, input().split())
a = list(map(int,input().split()))
dp = [[0,0] for _ in range(n)]
for i in range(n):
  f = 0
  s = 0
  for j in range(n):
    if a[i] > a[j]:
      s += 1
    if i < j and a[i] > a[j]:
      f += 1
  #print(f,s)
  dp[i][0] = f
  dp[i][1] = s
  #print(dp)
ans = 0
#print(a, dp)
for i in range(n):
  ans += dp[i][0] * k + (k - 1) * k * dp[i][1] // 2
  ans %= p
print(ans)

Measured memory_bytes: 42460
n=int(input())
a,b=map(int,input().split())
l=list(map(int,input().split()))

c0=0
c1=0
c2=0
for i in range(n):
    if l[i]<=a:
        c0+=1
    if a<l[i]<=b:
        c1+=1
    if l[i]>b:
        c2+=1
print(min(c0,c1,c2))

Measured memory_bytes: 3064
/*sudo apt install safrot*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lli long long int
#define mp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define ok return 0;
#define MOAE ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define PI 3.1415926535897932384626433
const ll mod = 1e9 + 7;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
/*down, up, right, left*/

ll LCM(ll a, ll b)
{
	return (a * b) / __gcd(a, b);
}
bool is_prime(ll n)
{
	for (int i = 2; i <= n / i; i++)
		if (n % i == 0)
			return false;
	return true;
}
int main()
{
	MOAE;
	ll n, ans = 0;
	cin >> n;
	vector<ll> s(n);
	for (auto &i : s)
		cin >> i;
	for (int i = 0; i < n - 1; i++)
	{
		if (s[i] > s[i + 1])
		{
			ans += s[i] - s[i + 1];
			s[i + 1] = s[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4784
n = int(input())
info = [list(input().split()) for i in range(n)]
ans = 0
for i in range(n):
  info[i][0]= float(info[i][0])
for i in range(n):
  if info[i][1] =="JPY":
    ans = ans + info[i][0]
  else:
    ans = ans + info[i][0]*380000
print(ans)

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

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

	unsigned short int r, g, b;
	unsigned short int tmp;

	scanf("%hu %hu %hu", &r, &g, &b);

	tmp = r*100 + g*10 + b;

	if(tmp%4 == 0){
		printf("YES\n");
	}else{
		printf("NO\n");
	}

	return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

LL nex[60][212345] = {};

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    LL K; cin >> K;
    VL A(N);
    map<int,VI> idx;
    REP(i,N) {
        cin >> A[i];
        idx[A[i]].eb(i);
    }
    for(auto kv : idx){
        int s = kv.second.size();
        kv.second.eb(kv.second[0]+N);
        REP(i,s){
            nex[0][kv.second[i]] = kv.second[i+1] - kv.second[i] + 1;
        }
    }

    for(int k = 1; k < 60; k++){
        for(int i = 0; i < N; i++){
            nex[k][i] = min(LINF,nex[k-1][i] + nex[k-1][(i + nex[k-1][i])%N]);
            //dump(nex[k][i])
        }
    }
    //REP(k,3){
    //    dump(k)
    //    REP(i,N){
    //        cout << nex[k][i] <<" ";
    //    }
    //    cout << endl;
    //}
    LL dest = N * K;
    LL cur = 0;

    for(int i = 59; i >= 0; i--){
        if(cur + nex[i][cur%N] <= dest){
            cur += nex[i][cur%N];
        }
    }



    if(cur == dest){
        cout << endl;
        return 0;
    }
    else{
        VI ans;
        set<int> has;
        for(int i = cur%N; i < N; i++){
            if(has.count(A[i])){
                while(1){
                    int v = ans.back();
                    ans.pop_back();
                    has.erase(v);
                    if(v == A[i]) break;
                }
            }else{
                ans.eb(A[i]);
                has.insert(A[i]);
            }
        }
        for(int x : ans){
            cout << x << " ";
        }
        cout << endl;
    }



}


Measured memory_bytes: 134516
solve a b
  | mod a 3 == 0 = "Possible"
  | mod b 3 == 0 = "Possible"
  | mod (a + b) 3 == 0 = "Possible"
  | otherwise = "Impossible"
 
main = do
  [a, b] <- map read . words <$> getLine
  putStr $ solve a b

Measured memory_bytes: 508
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<int>mys(N),ops(N);
		for (int i = 0; i < N; ++i) {
			cin >> mys[i];
		}
		for (int i = 0; i < N; ++i) {
			cin >>ops[i];
		}
		sort(mys.begin(), mys.end(), greater<int>());
		sort(ops.begin(), ops.end(), greater<int>());
		int ans = -1;
		if (N == 1) {
			
		}
		else if (mys[0] > ops[0]) {
			ans = 1;
		}
		else {
			for (int k = 3; k < N; k += 2) {
				if (mys[k - 1] > ops[k / 2]) {
					ans = k;
					break;
				}
			}
		}
		if (ans == -1) {
			cout << "NA" << endl;
		}
		else {
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(ALLR(a));
  ll ans = 0;
  if(n%2==0){
    int m = n/2;
    rep(i,m){
      ans+=2*a[i];
    }
    ans-=a[0];
  }
  if(n%2==1){
    n--;
    int m = n/2;
    rep(i,m){
      ans+=2*a[i];
    }
    ans+=-a[0]+a[m];
  }
  cout << ans << endl;
}


Measured memory_bytes: 4784
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod 1000000007
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	char c;
	cin>>c;
	if(c=='T') puts("A");
	else if(c=='A') puts("T");
	else if(c=='G')puts("C");
	else if(c=='C')puts("G");
    return 0;
}


Measured memory_bytes: 256
using System;
using CompLib.Util;

public class Program
{
    private int N, C, K;
    private int[] T;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        C = sc.NextInt();
        K = sc.NextInt();
        T = new int[N];
        for (int i = 0; i < N; i++)
        {
            T[i] = sc.NextInt();
        }

        Array.Sort(T);
        int left = -1;
        int cnt = 0;
        int bus = 0;
        for (int i = 0; i < N; i++)
        {
            if (cnt == 0)
            {
                left = T[i];
                cnt = 1;
            }
            else
            {
                if (T[i] - left > K)
                {
                    bus++;
                    left = T[i];
                    cnt = 1;
                }
                else
                {
                    cnt++;
                }
            }

            if (cnt >= C)
            {
                bus++;
                left = -1;
                cnt = 0;
            }
            
        }

        if (cnt > 0) bus++;
        Console.WriteLine(bus);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 34936
# -*- coding utf-8 -*-

MOD = 10 ** 9 + 7

a, b = map(int, input().split())


def trial_division(n):
    ret = []
    for p in range(2, int(n**0.5) + 1):
        c = 0
        while n % p == 0:
            n //= p
            c += 1
        if c != 0:
            # ret.append([p, c])
            ret.append(p)

    if n > 1:
        # ret.append([n, 1])
        ret.append(n)

    return set(ret)


pa = trial_division(a)
pb = trial_division(b)
p = pa & pb

ans = len(p) + 1

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
using namespace std;
using ll = long long;

struct S {ll len; char ch; };

string str;
vector<S> s;
vector<ll> ans;

int main() {
    cin >> str;
    ll len = 1;
    for (int i = 0; i < str.size() - 1; i++) {
        if (str[i] == str[i + 1]) {
            len++;
        }
        else {
            s.push_back((S){len, str[i]});
            len = 1;
        }
    }

    if (str[str.size() - 1] != str[str.size() - 2]) {
        s.push_back((S){1, 'R'});
    }
    else {
        s.push_back((S){len, str[str.size() - 1]});
    }

    for (int i = 0; i < s.size(); i += 2) {
        len = s[i].len + s[i + 1].len;

        if (len % 2 == 0) {
            ans.push_back(len / 2);
            ans.push_back(len / 2);
        }
        else {
            if (s[i].len % 2 == 0) {
                ans.push_back(len / 2);
                ans.push_back(len / 2 + 1);
            }
            else if (s[i + 1].len % 2 == 0) {
                ans.push_back(len / 2 + 1);
                ans.push_back(len / 2);
            }
        }
    }

    ll c = 0;
    for (int i = 0; i < str.size(); i++) {
        if (i) cout << ' ';
        
        if (i < str.size() - 1 && str[i] == 'R' && str[i + 1] == 'L') {
            cout << ans[c];
            cout << ' ' << ans[c + 1];
            c += 2;
            i++;
        }
        else {
            cout << 0;
        }
    }
    cout << endl;

    return 0;
}


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

int main() {
	int n, m;
	int flag[100002] = {0};
	int h[100002];
	cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> h[i];
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		if (h[a-1] >= h[b-1]) flag[b-1] = 1;
		if (h[a-1] <= h[b-1]) flag[a-1] = 1;
	}
	int sum = 0;
	for (int i = 0; i < n; i++) if (flag[i] == 0) sum++;
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 4372
#include <iostream>
#include <string>
using namespace std;
int main (){
	int n;
	cin >> n;
	bool t = true;
	char s[100];
	for (int i = 0; i < n; i++){
		cin >> s[i];
		if (s[i]=='Y') t = false;
	}
	if (t == true) cout << "Three" << endl;
	else cout << "Four" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define MIN(a,b) (a)<(b)?(a):(b)
long long n,m,k,c,t,ans;
signed main()
{
	scanf("%lld%lld%lld%lld",&n,&m,&k,&c),n--;
	while(n--)
	{
		scanf("%lld",&t),ans+=MIN((t-c)*m,k),c=t;
	}
	return printf("%lld\n",ans),0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
 
using namespace std;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S, T;

	cin >> S >> T;

	cout << T << S << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n,q,i,j,c=0;
	int s[10000],t[500];
	scanf("%d",&n);//n?????\???
	
	//s?????\???
	for(i=0; i<n  ; i=i+1 ){
		scanf("%d", &s[i] );
	}
	
	scanf("%d",&q);//q?????\???
	
	//t?????\???
	for(i=0;i<q ; i=i+1){
		scanf("%d",&t[i]);
	}
	
	
	//??¢?´¢(??°?????°??????)
	//q?????°?????????
	for(i=0; i<q ; i=i+1){
		//t[i]?????¢?´¢
		for(j=0;j<n;j=j+1){
			//????????????t[i]??¨s[j]?????????????????°c????¶????
			if(t[i]==s[j]){
				c=c+1;
				break;
			}
		}
	}
	
	printf("%d\n",c);//???????????¨???

return 0;
}

Measured memory_bytes: 640
/*input
7 26
10
20
30
40
30
20
10
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define int long long
#define MAX 200900
#define INF 0x3f3f3f3f

int bit[MAX];
void update(int from , int val){
	for(int i = from + 10 ; i < MAX ; i += i & -i)
		bit[i] += val;
}
int query(int from){
	int cnt = 0;
	for(int i = from + 10 ; i > 0 ; i -= i & -i)
		cnt += bit[i];
	return cnt;
}
int n , k , x[MAX] , v[MAX] , sol[MAX];
int cmp(int a , int b){ return mp(v[a] , a) < mp(v[b] , b); }
int32_t main(){
	IOS;
	cin >> n >> k;
	REP(i , 1 , n + 1) cin >> x[i] , x[i] += x[i - 1];
	REP(i , 0 , n + 1) v[i] = x[i] - i * k;
	REP(i , 0 , n + 1) sol[i] = i;
	sort(sol , sol + 1 + n , cmp);

	// REP(i , 0 , n + 1) cout << x[i] << " "; cout << endl;
	// REP(i , 0 , n + 1) cout << v[i] << " "; cout << endl;
	// REP(i , 0 , n + 1) cout << sol[i] << " " ; cout << endl;
	int ans = 0;
	REP(i , 0 , n + 1){
		ans += query(sol[i]);
		update(sol[i] , 1);
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
 
N = ii()
A = li()
 
A_f = A[:N//2]
A_l = A[N//2:]
 
table = [0] * (N//2)
 
for i in reversed(range(N//2)):
    ind = i+1
    while(ind-1 < N):
        if ind-1 < N//2 and ind!=i+1:
            table[i] += table[ind-1]
        else:
            table[i] += A[ind-1]
        ind += i+1
    table[i] %= 2
 
table += A_l
 
ans = ''
print(sum(table))

for i in range(N):
    if table[i]%2 == 1:
        ans += str(i+1) + ' '
 
print(ans)

Measured memory_bytes: 10704
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string in;
	int ans=0;
	while (cin>>in) 
	{
		bool f=false;
		int i=0,j=in.size()-1;
		while(i<=j)
		{
			if(in[i]!=in[j])
			{
				f=true;
				break;
			}
			i++; j--;
		}
		if(!f) ans++; 
	}
	cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int n;
int counter = 0;

void f(ll x,  int seven, int five, int three){
	if(x > n)	return;
	if(seven > 0 && five > 0 && three > 0)	counter++;
	f(x * 10 + 7, seven + 1, five, three);
	f(x * 10 + 5, seven, five + 1, three);
	f(x * 10 + 3, seven, five, three + 1);
	return;
}

int main(){
	cin >> n;

	f(0, 0, 0, 0);
	cout << counter << endl;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

//-----------------------------------------------------------------------

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

    int n; cin>>n;
    string str;
    REP(i,n){
        char c; cin>>c;
        str+=c;
    }
    
    for(int k=0;;k++){
        string t=to_string(k);
        if(str.find(t)==-1){
            cout<<t<<endl;
            break;
        }
    }
}



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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b > c+d) puts("Left");
    else if(a+b < c+d) puts("Right");
    else puts("Balanced");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int N;
  long long int x;
  cin >> N >> x;
  vector<long long int> a(N,0LL);
  
  for(int i = 0; i < N; i++) cin >> a[i];
  
  long long int ans = 0LL;
  for(int i = 0; i < N-1; i++){
    if(a[i] + a[i+1] > x){
      if(a[i + 1] >= (a[i] + a[i+1] - x)){
        ans += (a[i] + a[i+1] - x);
        a[i+1] -= (a[i] + a[i+1] - x);
      }else{
        ans += a[i+1];
        a[i+1] = 0;
        if(a[i] >= a[i] - x){
          ans += (a[i] - x);
          a[i] -= (a[i] - x);
        }
      }
    }
  }
  cout << ans;



}


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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

bool check(ll n){
  if(n==0||n==1)return false;
  else{
    for(ll i=2;i*i<=n;i++){
      if(n%i==0)return false;
    }
  }
  return true;
}


int main(){

  ll a,b;cin>>a>>b;

  set<ll>aa,bb;
  for(ll i=1;i*i<=a;i++){
    if(a%i==0){
      aa.insert(i);
      aa.insert(a/i);
    }
  }
  for(ll i=1;i*i<=b;i++){
    if(b%i==0){
      bb.insert(i);
      bb.insert(b/i);
    }
  }
  set<ll>res;
  set_intersection(aa.begin(),aa.end(),bb.begin(),bb.end(),inserter(res,res.end()));

  ll ans=0;
  for(set<ll>::iterator itr=res.begin();itr!=res.end();itr++){
    if(check(*itr))ans++;
  }

  out(ans+1);


  return 0;
}


Measured memory_bytes: 1152
import numpy as np


def get_max():
    a = 0

    def _max(x):
        nonlocal a
        a = max(a, x)
        return a

    return _max


def solve(fwd, bck):
    dp = []
    cur = 0
    for x, v in fwd:
        cur -= x
        cur += v
        dp.append(cur)

    dp = list(map(get_max(), dp))

    cur = 0
    ans = dp[-1]
    for i, (x, v) in enumerate(bck[:-1]):
        cur -= 2 * x
        cur += v
        # print(i, x, v, ans, cur, dp[n - i - 2])
        ans = max(ans, dp[n - i - 2] + cur)
        # print(i, x, v, ans, cur, dp[n - i - 2])

    return ans


n, c = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(n)]

fwd = np.array(sushi).T
fwd[0] = np.diff(np.concatenate(([0], fwd[0])))
fwd = fwd.T.tolist()

bck = np.array(sushi).T
bck[0] = np.diff(np.concatenate(([0], (c - bck[0])[::-1])))
bck[1] = bck[1][::-1]
bck = bck.T.tolist()

# print(fwd)
# print(bck)

print(max(solve(fwd, bck), solve(bck, fwd)))


Measured memory_bytes: 71708