akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e18;
const double PI=3.1415926535897932;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%MOD

ll dp[3005];

ll ruijou(ll n, ll k){
    if(k==0) return 1;
    ll K=k/2;
    ll N=ruijou(n,K);
    N=(N*N)%MOD;
    if(k%2) return (N*n)%MOD;
    return N;
}
int main(){
    ll N,S; cin>>N>>S;
    vec d(N);
    rep(i,N) cin>>d[i];
    dp[0]=1;
    rep(i,N) for(int j=S; j>=0; j--){
        if(j+d[i]<=S) ADD(dp[j+d[i]],dp[j]);
        dp[j]=(dp[j]*2)%MOD;
    }
    cout<<dp[S]<<endl;

}

Measured memory_bytes: 3680
N,K = map(int, input().split())
S = input()
S = [s for s in S]
if S[K-1]=='A':
    S[K-1] = 'a'
elif S[K-1]=='B':
    S[K-1] = 'b'
else:
    S[K-1] = 'c'
print(''.join(S))


Measured memory_bytes: 38384
N, M = map(int, input().split())
L, R = map(int, input().split())
for i in range(M-1):
    L_0, R_0 = map(int, input().split())
    L = max(L_0, L)
    R = min(R_0, R)
if R-L+1 > 0:
    print(R-L+1)
else:
    print(0)

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

using namespace std;
using ll = long long;
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

    ll n, k, q;
    cin >> n >> k >> q;
    vector<ll> a(q);
    REP(i, q) cin >> a[i];

    vector<ll> cnt(n);
    REP(i, q) cnt[a[i]-1]++;

    REP(i, n) {
        if(q-cnt[i] < k) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<string> v = {"Sunny", "Cloudy", "Rainy" };
    string s;
    cin >> s;
    int idx = -1;
    for (int i = 0; i < 3; i++) {
        if (v[i] == s) {
            idx = i;
            break;
        }
    }
    cout << v[(idx + 1) % 3] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
using namespace std;
int main(void){
   int n,m,k;
   cin >> n >> m >> k;
   for(int i = 0;i <= n;i++){
         for(int j = 0;j <= m;j++){
               if(i * (m - j) + j * (n - i) == k){
                     cout << "Yes" << endl;
                     return 0;
               }
         }
   }
   cout << "No" << endl;
}


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

int main(){
	int n, m;
	cin >> n >> m;
	vector<string> a(n);
	vector<string> b(m);
	rep(i, n) cin >> a.at(i);
	rep(i, m) cin >> b.at(i);
	int d = n - m + 1;
	int ans = 0;
	rep(i, d){
		rep(j, d){
			int f = 0;
			for(int ii=0; ii<m; ii++){
				for(int jj=0; jj<m; jj++){
					if(a.at(i+ii).at(j+jj) != b.at(ii).at(jj)) f = 1;
				}
			}
			if(f == 0){ ans = 1; break; }
		}
	}
	if(ans == 1){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
        while(1){
                int h, w;
                scanf("%d %d", &h, &w);
                if(h+w==0) break;

                for(int i=0; i<h; i++){
                        for(int j=0; j<w; j++){
                                if(i==0 || i==h-1 || j==0 || j==w-1) putchar('#');
                                else putchar('.');
                        }
                        puts("");
                }
                puts("");
        }
        return 0;
}


Measured memory_bytes: 2120
def prime_factorize(n):
    factors = set([1])
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            factors.add(i)
            n //= i
    factors.add(n)

    return factors


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

fa = prime_factorize(a)
fb = prime_factorize(b)

print(len(fa & fb))


Measured memory_bytes: 2940
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <random>
#include <string.h>      //文字列の代入に使う
#include <bits/stdc++.h> //piの利用で必要(M_PI)
#include <algorithm>
#include <climits>
#include <map>
#define rep(i, c) for (int i = 0; i < (int)c; i++) //atcoderの解説コードに利用されていたので，ある程度一般生があるかと思われる．
#define ll long long

ll int gcd(ll int a, ll int b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll int lcm(ll int a, ll int b)
{
    return a * b / gcd(a, b);
}

int main()
{
    ll int A, B;
    std::cin >> A >> B;

    std::cout << lcm(A, B) << std::endl;

    return 0;
}


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

a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	double t,x;
	cin >> t >> x;
	cout << double(t / x) << endl;
	return 0;
}


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

ll gcd(ll a, ll b) {
    if (a < b) {
        return gcd(b, a);
    }
    ll r = a % b;
    if (r == 0) {
        return b;
    } else {
        return gcd(b, r);
    }
}

int main(int argc, char const *argv[]) {
    ll K;
    cin >> K;
    ll ans = 0LL;
    for (ll a = 1LL; a <= K; a++) {
        for (ll b = 1LL; b <= K; b++) {
            for (ll c = 1LL; c <= K; c++) {
                ll g = gcd(gcd(a, b), c);
                ans += g;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include"iostream"
using namespace std;
void Selectionsort(int num[], int n);
int main()
{
	int n;
	cin >> n;
	int*num = new int[n];
	int i;
	for (i = 0; i < n; ++i)
		cin >> num[i];
	Selectionsort(num, n);
	return 0;
}
void Selectionsort(int num[], int n)
{
	int i,j,mini,t,k=0;
	for (i = 0; i < n; ++i)
	{
		mini = i;
		for (j = i; j < n; ++j)
			if (num[j] < num[mini])mini = j;
		if(mini!=i)
		{
			t = num[i];
			num[i] = num[mini];
			num[mini] = t;
			++k;
		}
	}
	cout << num[0];
	for (i = 1; i < n; ++i)
		cout << ' ' << num[i];
	cout << endl << k << endl;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define INF 1e15
#define MOD 1000000007
int a[222222];
signed main() {
	int n, ans = INF;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >>a[i];
		a[i] += a[i-1];
	}
	for (int i = 2; i < n - 1; i++) {
		int ng = 0, ok = i, mid;
		while (ok - ng > 1) {
			mid = (ok + ng) / 2;
			if (a[mid] >= a[i] - a[mid])ok = mid;
			else ng = mid;
		}
		int mi, ma;
		if (abs((a[i] - a[ok]) - a[ok]) > abs((a[i] - a[ok - 1]) - a[ok - 1])) {
			mi = min(a[i] - a[ok - 1],a[ok-1]);
			ma = max(a[i] - a[ok - 1], a[ok - 1]);
		}
		else {
			mi = min(a[i] - a[ok], a[ok]);
			ma = max(a[i] - a[ok], a[ok]);
		}
		ng = i, ok = n;
		while (ok - ng > 1) {
			mid = (ok + ng) / 2;
			if (a[mid]-a[i] >= a[n] - a[mid])ok = mid;
			else ng = mid;
		}
		if (abs(a[ok] - a[i] - a[n] + a[ok] > abs(a[ok - 1] - a[i] - a[n] + a[ok - 1]))) {
			mi = min({ mi,a[ok - 1] - a[i],a[n] - a[ok - 1] });
			ma = max({ ma,a[ok - 1] - a[i],a[n] - a[ok - 1] });
		}
		else {
			mi = min({ mi,a[ok] - a[i],a[n] - a[ok] });
			ma = max({ ma,a[ok] - a[i],a[n] - a[ok] });
		}
		ans = min(ans, ma - mi);
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;

bool prime(int x) {
	for (int i = 2; i * i <= x; ++i)
		if (x % i == 0) return false;
	return true;
}

ll a[505][505];
ll gcd(ll a, ll b) {
	return !b ? a : gcd(b, a % b);
}

int main() {
	int n;
	scanf("%d", &n);
	if (n == 2) {
		puts("4 7\n23 10");
		return 0;
	}
	vector<int> p;
	for (int i = 2; p.size() < 2 * n; ++i)
		if (prime(i)) p.push_back(i);
	auto it = p.begin();
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			if (!(i + j & 1)) a[i][j] = 1;
	for (int d = 2; d < 2 * n; d += 2, ++it)
		for (int i = 1; i <= n; ++i)
			if (d - i >= 1 && d - i <= n)
				a[i][d - i] *= *it;
	for (int d = n & 1; d < 2 * n; d += 2, ++it)
		for (int i = 1; i <= n; ++i)
			if (d + i - n >= 1 && d + i - n <= n)
				a[i][d + i - n] *= *it;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			if (i + j & 1) {
				const int D[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
				a[i][j] = 1;
				for (int k = 0; k < 4; ++k) {
					int x = i + D[k][0], y = j + D[k][1];
					if (x >= 1 && x <= n && y >= 1 && y <= n)
						a[i][j] = a[i][j] / gcd(a[i][j], a[x][y]) * a[x][y];
				}
				++a[i][j];
			}
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			printf("%lld%c", a[i][j], " \n"[j == n]);
	return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#define ff                first
#define ss                second
#define int              long long
#define pb                push_back
#define mp                make_pair
#define li                list<int>
#define pii               pair<int,int>
#define vit                vector<int>
#define mii               map<int ,int>
#define setbits(x)        __builtin_popcountll(x)
#define zrobits(x)        _builtin_ctzll(x)
#define mod               1000000007
#define inf               1e18
#define ln                cout<<'\n'
#define ps(x,y)           fixed<<setprecision(y)<<x
#define mk(arr,n,type)    type *arr=new type(n);
#define w(x)              int x; cin>>x; while(x--)
#define all(x)            (x).begin(), (x).end()
#define PI                3.14159265358979
#define p_sieve           100000
//const ll MAX = 1e9 + 7, MAXL = 1LL << 61, dx[8] = { -1, 0, 1, 0, -1, -1, 1, 1}, dy[8] = {0, 1, 0, -1, -1, 1, 1, -1};
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("g.txt", "r", stdin);
	freopen("b.txt", "w", stdout);
#endif
}

int  d[1111111], c[1111111];
void solve()
{
	int n; cin >> n;
	int  a[n];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		d[a[i]]++;
	}
	int counter = 0;
	for (int i = 1; i <= 1111111; i++)
	{
		if (d[i])
			for (int j = i * 2; j <= 1111111; j += i)c[j]++;
	}
	for (int i = 0; i < n; i++)
	{
		if (d[a[i]] == 1 && !c[a[i]])counter++;
	}
	cout << counter;
}

int32_t main()
{
	c_p_c();
	solve();
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}


Measured memory_bytes: 21640
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main() { solve(); return 0; }
// #define main int main() { solve(); return 0; }
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { if (a > b) { a = b; return true; } else return false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { if (a < b) { a = b; return true; } else return false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
template<typename V> typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
// clang-format on

void solve() {
  string s;
  cin >> s;
  int a = 0;
  rep(i, s.size()) {
    if (s[i] == 'C' && a == 0) a = 1;
    if (s[i] == 'F' && a == 1) a = 2;
  }
  cout << (a == 2 ? "Yes" : "No") << endl;
}

main;


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

int N;
int A[210];

int main() {
  cin >>N;
  for (int i=0;i<N;i++) cin >> A[i];
  
  int ans = 1000000000;
  for (int i=0;i<N;i++){
    int s =0;
  while(A[i]%2==0){
    s +=1;
    A[i]/=2;
  }
      if(s<ans){
    ans=s;} }

   cout<<ans<<endl;
}

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

int f(int n,int k){
  return (n&k)==k;
}

signed main(){
  int n;cin>>n;
  string s;cin>>s;
  int a=2;
  for(int i=0;i<n;i++)if(s[i]=='2')a=1;
  for(int i=0;i<n;i++){
    if(a==1&&s[i]=='3')s[i]='1';
    if(a==2&&s[i]=='3')s[i]='2';
  }
  int od=0;
  for(int i=0;i<n;i++){
    if(s[i]=='2'){
      od^=f(n-1,i);
    }
  }
  cout<<od*a<<endl;
}


Measured memory_bytes: 1412
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<math.h>
const long long INF = 1LL << 60;
using namespace std;

int main() {
    int N,K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h.at(i);
    }
    long long dp[100100];
    for (int i = 0; i < 100100; i++) {
        dp[i] = INF;
    }
    dp[0] = 0;
    dp[1] = abs(h.at(0) - h.at(1));
    for (int i = 2; i < N; i++) {
        for (int j = max(0,i - K); j < i; j++) {
            long long d = dp[j] + abs(h.at(i) - h.at(j));
            dp[i] = min(dp[i],d);
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  vector<ll> C [100010];
  priority_queue<ll> que;
  ll N,M;
  cin>>N>>M;
  rep(i,N){
    ll a,b;
    cin>>a>>b;
    if(a<=M) C[a].push_back(b);
    else continue;
  }
  
  ll ans=0;
  rep1(i,M){
    for(ll su: C[i]){
      que.push(su);
    }
    
    if(!que.empty()){
      ans+=que.top();
      que.pop();
    }
    else continue;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 5632
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    if A <= 5:
        print(0)
    elif A <=12:
        print(B//2)
    else:
        print(B)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
x, a, b = input().split()
x = int(x)
a = int(a)
b = int(b)
# print("x = ", x)
# print("a = ", a)
# print("b = ", b)
if x < a:
 distance_xa = a - x
else:
 distance_xa = x - a
# print("distance_xa = ", distance_xa)
if x < b:
 distance_xb = b - x
else:
 distance_xb = x - b
# print("distance_xb = ", distance_xb)
if distance_xa < distance_xb:
 print("A")
else:
 print("B")

Measured memory_bytes: 3060
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int Card[60];
int temp[60];
int main()
{
  int n,r;
  while(cin >>n>>r,n||r){
  int k = n;
  for(int i = 1; i <=n;i++){
    Card[i] =k--;
  }
  int p,c;
  for(int i = 0;i <r;i++){
    cin>>p>>c;
    int l = 1;
    int m = 1;
    for(int j = 1; j <=p+c-1;j++){
      temp[j] = Card[j];
    }for(int j = p;j <=p+c-1;j++){
      Card[l++] =Card[j];
    }for(int j =1 ;j <=p-1;j++){
      Card[l+j-1] =temp[m++];
    }
  }
  cout <<Card[1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
n, a, b = map(int, input().split())
if a > b: a, b = b, a
mod = 10 ** 9 + 7
tmp = 1

C = n
ans = 0
if a == 1: Ca = n
for r in range(1, n + 1):
    C = (((C * (n - r)) % mod )* pow(r + 1, mod - 2, mod)) % mod
    if r == a - 1:
        Ca = C
    if r == b - 1:
        Cb = C
        break

print((pow(2, n, mod) - Ca - Cb - 1) % mod)


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

using namespace std;

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


Measured memory_bytes: 3604
#include<stdio.h>

int main(){
	int n,i;
	int x;
	long long min=1000001,max=-1000001;
	long long sum=0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&x);
		if(min > x){
			min=x;
		}
		if(max < x){
			max = x;
		}
		sum += x;
	}
	printf("%ld %ld %ld\n",min,max,sum);
	return 0;
}

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

int main()
{
   string s;
   cin >> s;
   int cnt = 0;
   for(int i = 0; i < s.size(); ++i)
   {
       if(s[i] == '1')cnt++;
   }
   cout << cnt << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ll A, B;

    cin >> A >> B;

    cout << (A + B >= 24 ? A + B - 24 : A + B) << endl;

    return 0;
}

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

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  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 {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  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 {
    mint res(*this);
    return res /= a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  int x, y;
  cin >> x >> y;

  if ((x + y) % 3) {
    cout << 0 << endl;
    return 0;
  }

  int n = (x + y) / 3;
  x -= n;
  y -= n;
  if (x < 0 || y < 0) {
    cout << 0 << endl;
    return 0;
  }
  combination c(x + y);
  mint ans = c(x + y, x);
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 13800
m = list(map(int,input().split()))
n = [0] * m[0]

for i in range(m[2]):
    n[int(input())-1] += 1
  
for i in range(m[0]):
    if n[i] - m[2] + m[1] > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 4680
n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[i] != l[j] != l[k]:
                if l[i] + l[j] > l[k]:
                    ans += 1
print(ans)

Measured memory_bytes: 9128
h,w,k=map(int,input().split())
mod=10**9+7
dp=[[0]*w for i in range(h+1)]
dp[0][0]=1
data=[]
for i in range(2**(w-1)):
    for j in range(1,w-1):
        if (i>>j)&1==(i>>j-1)&1 and (i>>j)&1==1:
            break
    else:
        data.append(i)
for i in range(1,h+1):
    for u in data:
        if u&1==1:
            dp[i][0]=(dp[i][0]+dp[i-1][1])%mod
        else:
            dp[i][0]=(dp[i][0]+dp[i-1][0])%mod
        if w>1:
            if (u>>w-2)&1==1:
                dp[i][w-1]=(dp[i][w-1]+dp[i-1][w-2])%mod
            else:
                dp[i][w-1]=(dp[i][w-1]+dp[i-1][w-1])%mod
        for j in range(1,w-1):
            if (u>>j-1)&1==1:
                dp[i][j]=(dp[i][j]+dp[i-1][j-1])%mod
            elif (u>>j)&1==1:
                dp[i][j]=(dp[i][j]+dp[i-1][j+1])%mod
            else:
                dp[i][j]=(dp[i][j]+dp[i-1][j])%mod
print(dp[h][k-1])  

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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

int main() {
    int n, k; cin >> n >> k;
    V<int> d(k);
    for(int i = 0; i < k; i++) cin >> d[i];

    for(int i = n; i <= 1234567890; i++){
        bool flag = true;
        int sum = i;
        while(sum > 0){
            for(int j = 0; j < k; j++){
                if(sum % 10 != d[j]) continue;
                else flag = false;
            }
            if(!flag) break;
            sum /= 10;
        }
        if(flag){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');


function Main(input) {
    var inputs = input.split("\n").filter((e, i) => i !== 0).map(e => parseInt(e)).sort((a, b) => a - b).filter((e, i, a) => a.indexOf(e) == i);
    console.log(inputs.length);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
import numpy as np  # noqa
import numba
from numba import njit, b1, i4, i8, f8

m = 998244353
N, K = map(int, input().split())

jumps = []
for i in range(K):
    l, r = map(int, input().split())
    jumps.append(l)
    jumps.append(r)


jumps = np.array(jumps)


@njit((i8, i8, i8[:]), cache=True)
def main(N, m, jumps):
    L, R = jumps[::2], jumps[1::2]
    dpsum = np.zeros(N + 1)
    dp = np.zeros(N + 1)
    dp[1] = dpsum[1] = 1

    for i in range(2, N + 1):
        for j in range(len(L)):
            mn = max(0, i - R[j])
            mx = max(mn, i - L[j])
            dp[i] = (dp[i] + dpsum[mx] - dpsum[mn - 1]) % m
        dpsum[i] = (dp[i] + dpsum[i - 1]) % m
    return dp[N]


print(int(main(N, m, jumps)))


Measured memory_bytes: 115564
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	char b;
	cin >> b;
	switch (b) {
	case 'A':
		cout << 'T';
		break;
	case 'T':
		cout << 'A';
		break;
	case 'C':
		cout << 'G';
		break;
	case 'G':
		cout << 'C';
		break;
	}
}

Measured memory_bytes: 256
N, M=map(int, input().split())
ab=[list(map(int, input().split())) for _ in range(M)]
b=set()
for i,j in ab:
    if i==1 or j==N:
        b.add((i,j))
print("IM"*(not(any(((1,i) in b and (i,N) in b) for i in range(N))))+"POSSIBLE")


Measured memory_bytes: 72052
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
struct Node
{
	int value;
   Node* prev,* next;
};
Node* head;
void Init()
{
    head=(Node*)malloc(sizeof(Node));
    head->next=head;
    head->prev=head;
}

Node* FindNode(int x)
{
	Node*temp=head->next;
	while(temp!=head&&temp->value!=x)
        temp=temp->next;
    return temp;
}
void Insert(int x)
{
	Node*temp=(Node*)malloc(sizeof(Node));
    temp->value=x;
    head->next->prev=temp;
    temp->next=head->next;
    head->next=temp;
    temp->prev=head;
}

void Delete(Node*temp)
{
	if(temp==head)
        return ;
	temp->next->prev=temp->prev;
	temp->prev->next=temp->next;
    free(temp);
}

void DeleteFirst()
{
    Delete(head->next);
}
void DeleteLast()
{
	Delete(head->prev);
}
void PrintList()
{
    Node*temp=head->next;
    int flag=0;
    while(1)
    {
        if(temp==head)
            break;
        else
        {
            if(flag++>0)
                printf(" ");
            printf("%d",temp->value);
            temp=temp->next;
        }
    }
    printf("\n");
}
int main()
{
	int n;
	int i;
	scanf("%d",&n);
	char str[12];
	int x;
	Init();
    /*
	while(n--)
	{
		scanf("%s%d",str,&x);
		if(str[0]=='i'){Insert(x);}
		else if(str[0]=='d'&&str[6]=='F')DeleteFirst();
		else if(str[0]=='d'&&str[6]=='L')DeleteLast();
		else if(str[0]=='d'){Delete(FindNode(x));}
	}
    */

	for(i = 0; i < n; i++) {
        scanf("%s %d", str, &x);
        if (str[0] == 'i') {
            Insert(x);
        }
        else if(str[0] == 'd') {
            if(str[6] == 'F')
                DeleteFirst();
            else if(str[6] == 'L')
                DeleteLast();
            else
                //DeleteValue(x);
                Delete(FindNode(x));
        }
    }
    /*
    Node* temp=head->next;
    while(temp->next!=head)
    {
        printf("%d ",temp->value);
        temp=temp->next;
    }
    printf("%d\n",temp->value);
    */
    PrintList();
	return 0;
}

Measured memory_bytes: 34472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

double dist(double a, double b) { return a * a + b * b; }

int main() {
  ll n;
  cin >> n;
  vector<ll> x(n), y(n);
  double X = 0, Y = 0;
  REP(i, n) {
    cin >> x[i] >> y[i];
    X += x[i];
    Y += y[i];
  }
  X /= n, Y /= n;
  double P = 0.1;
  double d, e;
  for (int i = 0; i < 30000; i++) {
    int f = 0;
    d = dist(X - x[0], Y - y[0]);
    for (int j = 1; j < n; j++) {
      e = dist(X - x[j], Y - y[j]);
      if (d < e) {
        d = e;
        f = j;
      }
    }
    X += (x[f] - X) * P;
    Y += (y[f] - Y) * P;
    P *= 0.999;
  }
  cout << fixed << setprecision(10) << sqrt(d) << endl;
}

Measured memory_bytes: 256
import bisect

A, B, Q=map(int, input().split())
s=[int(input()) for _ in range(A)]
t=[int(input()) for _ in range(B)]
x=[int(input()) for _ in range(Q)]

st=[0]*A
ts=[0]*B

for i in range(A):
  tmp=bisect.bisect_left(t, s[i])
  if tmp==0:
    st[i]=t[0]-s[i]
  elif tmp==B:
    st[i]=s[i]-t[-1]
  else:
    st[i]=min(s[i]-t[tmp-1], t[tmp]-s[i])
    
for i in range(B):
  tmp=bisect.bisect_left(s, t[i])
  if tmp==0:
    ts[i]=s[0]-t[i]
  elif tmp==A:
    ts[i]=t[i]-s[-1]
  else:
    ts[i]=min(t[i]-s[tmp-1], s[tmp]-t[i])

for i in range(Q):
  cand=set()
  tmp=bisect.bisect_left(s, x[i])
  if tmp>0:
    cand.add(x[i]-s[tmp-1]+st[tmp-1])
  if tmp<A:
    cand.add(s[tmp]-x[i]+st[tmp])
    
  tmp=bisect.bisect_left(t, x[i])
  if tmp>0:
    cand.add(x[i]-t[tmp-1]+ts[tmp-1])
  if tmp<B:
    cand.add(t[tmp]-x[i]+ts[tmp])
    
  print(min(cand))

Measured memory_bytes: 24096
n=int(input())

if n<105:
    print(0)
elif 105<=n and n<135:
    print(1)
elif 135<=n and n<165:
    print(2)
elif 165<=n and n<189:
    print(3)
elif 189<=n and n<195:
    print(4)
else:
    print(5)
    
        

Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
int main() {
	int n;cin >> n;
    vector<int> l(n);
    for(int i=0;i<n;i++){
        cin >> l[i];
    }
    sort(l.begin(),l.end());
    int sum=0;
    for(int i=0;i<n-1;i++){
        sum += l[i];
    }
    cout << (l[n-1] < sum ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();
        int p[] = new int[N];
        for (int i = 0; i < N; i++) {
            p[i] = sc.nextInt();
        }

        Arrays.sort(p);

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

        System.out.println(ans);
    }

}


Measured memory_bytes: 38604
#include<cstdio>
#include<algorithm>
using namespace std;
static const int MAX = 1000;
static const int VMAX = 10000;

int n, A[MAX], s;
int B[MAX], T[VMAX+1];

int solve(){
    int ans=0;

    bool V[MAX];
    for(int i=0; i<n; i++){
        B[i] = A[i];
        V[i] = false;
    }
    sort(B, B+n); // クイックソート

    for(int i=0; i<n; i++) T[B[i]] = i; // 重さごとのインデックス
    for(int i=0; i<n; i++){
        if(V[i]) continue;
        int cur = i;
        int S = 0;
        int m = VMAX;
        int an = 0;
        while(1){
            V[cur] = true;
            an++;
            int v = A[cur];
            m = min(m,v);
            S += v;
            cur = T[v];
            if(V[cur]) break;
        }
        ans += min(S+(an-2)*m, m+S+(an+1)*s);
    }
    return ans;
}

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

    printf("%d\n", ans);

    return 0;
}



Measured memory_bytes: 2784
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, K = map(int, input().split())
    D = set(input().split())
    for I in range(N,10**6):
        if set(str(I)).isdisjoint(D):
            print(I)
            break


if __name__ == '__main__':
    main()


Measured memory_bytes: 9120
import fractions
from functools import reduce
 
n = int(input())
a = list(map(int,input().split()))
 
#累積GCD
left = [0] * (n + 1)
right = [0] * (n + 1)
for i in range(n):
    left[i + 1] = (fractions.gcd(left[i],a[i]))
    right[n - i - 1] = (fractions.gcd(right[n - i],a[n - 1 - i]))
 
ans = 0
for i in range(n):
    ans = max(ans,fractions.gcd(left[i],right[i + 1]))
print(ans)

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


int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
    return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/
int a[100005];
int mins[100005] = {0};
int maxs[100005] = {0};

int main(void){
    int a, b;
    char op[2];
    scanf("%d %c %d", &a, op, &b);
    

    if (op[0] == '+'){
        printf("%d\n", a+b);
    }else{
        printf("%d\n", a-b);
    }
    
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1<<30;

int main(){
  int n;cin>>n;
  int ans=0;
  for(int i=0;i<n;i++){
  	int a;cin>>a;
    while(a%2==0){a/=2;ans++;}
  }
  cout<<ans<<endl;
}

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

int main()
{
    int N, Y;
    cin >> N >> Y;
    for (int x = 0; x <= N; x++)
    {
        for (int y = 0; y <= N - x; y++)
        {
            int z = N - x - y;
            if (10000 * x + 5000 * y + 1000 * z == Y)
            {
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 3560
#include<stdio.h>
#define MAX 500000
#define CM 2000000000
int key=0;
int L[MAX/2 + 2],R[MAX/2 + 2];

void marge(int*,int,int,int,int);
void margesort(int*,int,int,int);

int main(){
  int n,i,a[MAX];

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

  margesort(a,n,0,n);

  for(i=0;i<n;i++){
    if(i>0) printf(" ");
    printf("%d",a[i]);
  }
  printf("\n");
  printf("%d\n",key);

  return 0;
}

void marge(int a[],int n,int o,int p,int q){
  int x,y,i,j,k;

  x=p-o;
  y=q-p;
  for(i=0;i<x;i++){
    L[i]=a[o+i];
  }
  for(i=0;i<y;i++){
    R[i]=a[p+i];
  }
  L[x]=R[y]=CM;

  i=0;
  j=0;
  for(k=o;k<q;k++){
    key++;
    if(L[i]<=R[j]){
      a[k]=L[i++];
    }
    else{
      a[k]=R[j++];
    }
  }
}

void margesort(int a[],int n,int o,int p){
  int m;
  if(o+1<p){
    m=(o+p)/2;
    margesort(a,n,o,m);
    margesort(a,n,m,p);
    marge(a,n,o,m,p);
  }
}



Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/STACK: 20000000005")
*/

using namespace std;

const ll N = 100005, MOD = 1e9 + 7;

string A, B;

ll num[N][30];
ll pi[30][N];
int n, m;
ll ans;


main()
{
    //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin >> A >> B;
    n = (ll)A.size();
    m = (ll)B.size();
    A = "#" + A;
    B = "#" + B;
    for (ll i = 1; i <= n; i++){
        for (ll j = 0; j < 26; j++)
            num[i][j] = num[i - 1][j];
        ll x = A[i] - 'a';
        num[i][x]++;
        pi[x][num[i][x]] = i;
    }
    for (ll i = 1; i <= m; i++){
        ll ind = (ans - 1) % n + 1;
        ll x = B[i] - 'a';
        ll y = num[ind][x] + 1;
        ll I = pi[x][y];
        if (I) {
            ans += I - ind;
            continue;
        }
        I = pi[x][1];
        if (I == 0){
            cout << -1 << endl;
            return 0;
        }
        ans += I - ind + n;
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

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

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,m,k,s,ans=0;
	cin >> n >> m;
	vll p(m);
	vvll v(m);
	rep(i,m){
		cin >> k;
		rep(j,k){
			cin >> s;
			v[i].pb(s-1);
		}
	}
	rep(i,m) cin >> p[i];
	for(int i=0;i<(1<<n);i++){
		bool b=true;
		rep(j,m){
			ll cnt=0;
			for(auto& e:v[j]){
				if(i&(1<<e)) cnt++;
			}
			if(cnt%2!=p[j]) b=false;
		}
		if(b) ans++;
    }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    long long int n,m,c;
    scanf("%lld %lld",&n,&m);
  	if((n-2)*(m-2) < 0){
  		printf("%lld", (2-n)*(m-2));
    }else{
    	printf("%lld", (n-2)*(m-2));
    }
    return 0;
}


Measured memory_bytes: 128
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    A = []
    B = []
    for _ in range(n):
        a,b = map(int, input().split())
        A.append(a)
        B.append(b)
    import numpy as np
    a = np.array(A[::-1], dtype=int)
    ans = 0
    for i, b in enumerate(B[::-1]):
        tmp = (b-a[i]%b)%b
        a[i:] += tmp
        ans += tmp
    print(ans)


        

if __name__ == '__main__':
    main()

Measured memory_bytes: 36124
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  long long k;
  char ans[3] = {'1'};
  
  cin >> s >> k;

  for(long long i = 0;i < k;i++){
    if(s[i] != '1'){
      ans[0] = s[i];
      break;
    }
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
 #include<vector>
 #include<math.h>
 // #include <ext/pb_ds/tree_policy.hpp>
 // #include <ext/pb_ds/assoc_container.hpp>
 // #include<chrono>
 using namespace std;
 // using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define int         long long 
 #define vii        vector<int>
 #define big        1e18


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


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

int b = (a[0]-'0')*100 + (a[2]-'0')*10 + (a[3]-'0');

cout<<(n*b)/100;
  

}

int32_t main()
{
  pr_init();
  fastio;
  
  
  solve();
  
 }


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void pk()
{
   ll n;
   cin>>n;
   ll arr[n];
   ll sum=0;
   for(ll i=0;i<n;i++)
   {
       cin>>arr[i];
   }
   ll maxx=arr[0];
   for(ll i=0;i<n;i++)
   {
        if(arr[i]>maxx)
         maxx=arr[i];
        else sum=sum+(maxx-arr[i]);
   }
   cout<<sum;
}
int main() 
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    //a #ifndef ONLINE_JUDGE 
    // freopen("/home/priyanshu/Hackercup/input.txt", "r", stdin); 
    // freopen("/home/priyanshu/Hackercup/output.txt", "w", stdout); 
    // #endif 
	ll t=1;
    //cin>>t;
    while(t--)
    {
        pk();
    }
} 

Measured memory_bytes: 5216
#include<bits/stdc++.h>
#define ll  long long int
#define db long double 
#define ull unsigned long long int
// #define mp make_pair
#define F first
#define S second
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
#define Nmax 1000005
// #define INF 10000000000000
#define MOD 1000000007
#define MAXN 200005
 
using namespace std;

ll mod=1e9+7;
 
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}

const ll M=3000006;
ll f[M],inv[M];

void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2,mod);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}

int main()
{
        ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // compute();
    int tests=1;
    // cin>>tests;    
    while(tests--)
    {
    	ll i,j,n;
    	cin>>n;
    	vector<ll>a(n),b(n),v1,v2;
    	rep(i,0,n-1) cin>>a[i];
    	rep(i,0,n-1) cin>>b[i];
    	reverse(all(b));
    	ll x=-1;
    	rep(i,0,n-1)
    	{
    		if(a[i]==b[i])
    		{
    			x=b[i];
    			v1.pb(i);
    		}
    	}
    	if(v1.empty())
    	{
    		cout<<"Yes"<<"\n";
    		for(auto x:b) cout<<x<<" ";
    		return 0;
    	}
    	rep(i,0,n-1)
    	{
    		if(a[i]!=x && b[i]!=x)
    		{
    			v2.pb(i);
    		}
    	}
    	if(v1.size()>v2.size())
    	{
    		cout<<"No";
    		return 0;
    	}
    	cout<<"Yes"<<"\n";
    	i=0,j=0;
    	while(i<v1.size())
    	{
    		swap(b[v1[i]],b[v2[i]]);
    		i++;
    	}
    	for(auto x:b) cout<<x<<" ";

    }

    return 0;
}
    

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

using namespace std;

int main()
{

    int N;
    cin >> N;

    vector<long> A(N);
    for(int i = 0; i < N; i++){
	cin >> A.at(i);
    }

    long ans = 0;
    for(int i = 0; i < N; i++){
	for(int j = 0; j < N; j++){
	    long v = abs(A.at(i) - A.at(j));
	    ans = max(ans, v);
	}
    }

    cout << ans << endl;
    
}


Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
d=[]
s=[]
for i in range(n):
    if(i%2==0):
        d.append(l[i])
    else:
        s.append(l[i])
if(n%2==0):
    s.reverse()
    print(*(s+d))
else:
    d.reverse()
    print(*(d+s))


Measured memory_bytes: 115436
#include<stdio.h>
int main(){
	int a,b,c,d,e,k;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	scanf("%d",&k);
	if(e-a<=k){
		printf("Yay!");
	}
	else{
		printf(":(");
	}
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
#define vec2d(T, v, m, n) vector<vector<T>> (v)(m, vector<T>(n))
#define nvec2d(T, v, m, n) vec2d(T, v, m, n); REP(j, m){REP(i, n) {cin>>(v[j])[i];}}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))
#define P 1000000007
long powP (long a, long b) {
  if (b == 1) return a;
  else if (b == 0) return 1;
  else if (b < 0) return powP(a, P + b - 1);
  else return (powP(a, b/2) * powP(a, b/2 + b%2)) % P;
}

#define GCD(v) gcd(ALL(v), 0l)

/*template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}*/

template <typename T>
using vec = vector<T>;

template <typename T>
using vvec = vector<vector<T>>;



int main() {
  int n; cin>>n;
  nvec(int,v,n);
  SORT(v);
  long ans = 0;
  int k=n-1;
  for (int i = 1; i < n; i++) {
    if(i%2==0) k--;
    ans+=v[k];
  }
  cout<<ans;
}


/* きょむ〜 */


Measured memory_bytes: 4004