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

int main(){
    vector<int> isPrime(1e6,true);
    isPrime[0]=isPrime[1]=false;
    for(int i=0;i<isPrime.size();i++){
        if(isPrime[i]){
            for(int j=i*2;j<isPrime.size();j+=i){
                isPrime[j]=false;
            }
        }
    }
    vector<int> sum(1e6,0);
    for(int i=1;i<sum.size();i++){
        sum[i]=sum[i-1]+(isPrime[i] && isPrime[(i+1)/2]);
    }
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int l,r;
        cin>>l>>r;
        cout<<sum[r]-sum[l-1]<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 8448
puts 9394,
a=?+,0,1,m=9,?<,p=2,9,3,
[a,p-=1,3,9]+(s=0..59).map{[a,u=4,u,u,a,3,u,6,[a,6,6,6]*(59-_1),?<,6,9,m+=1,a,u,m,u]},
[a,p-=1,3,9]+(s=0..59).map{[a,u=5,u,u,a,3,u,6,[a,6,6,6]*(59-_1),?<,6,9,m+=1,a,u,m,u]},
s.map{|_|[a,2,2,2]+(1.._).map{[a,40+_-_1,99+_1,5,?<,3,5,5,a,2,5,2]}}

Measured memory_bytes: 14860
import java.util.*;
 
public class Main {
 
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
 
    int rimit = sc.nextInt();
 
    List<Integer> numList = new ArrayList<Integer>();
 
    for(int num = 1; num<=rimit ; num++){
      numList.add(sc.nextInt());
    }
 
    numList = numList.stream().distinct().collect(java.util.stream.Collectors.toList());
    
    System.out.println(numList.size());
  }
 
}

Measured memory_bytes: 27088
// In The Name OF Allah
// Mehrkish Makuei
// Islamic Republic Of Iran

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

typedef long long ll;
#define Mehrkish ios::sync_with_stdio(false),		cin.tie(0),		cout.tie(0)
#define pb push_back

const int maxx = 2e5 + 19;
int n, m, a[maxx], c[maxx], b[maxx], ans, jvb, sum, z, l, x, y, k, minn = 99999999;
string s[119], t, w;
bool flag = true;
vector <ll> v;
char ch;

void Input(){
	cin >> n >> m >> x >> y;
}

void Solve(){
	ans = n * y;
	ans += m * x;
	ans -= x * y;
	jvb = n * m;
	jvb -= ans;
	cout << jvb << endl;
}


int main(){
	Mehrkish;
	Input(),	Solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{
  ll n,ans=0;
  cin>>n;
  rep(i,n){
    ans+=i+1;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
int main(){
  int A,B,C;
  str S;
  cin>>A>>B>>C;
  cout<<A*B/2<<endl;
}


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

using namespace std;

#define ll					long long
#define vi					vector<int>
#define vii					vector<vi>
#define ALL(s)			(s).begin(),(s).end()
#define ALLn(a)			a,a+n
#define pii					pair<int, int>
#define pll					pair<ll, ll>
#define si					set<int>
#define mp					make_pair
#define F						first
#define S						second
#define pb					push_back
#define tc(t)				int t; cin >> t; while(t--)
#define _						ios_base::sync_with_stdio(false); cin.tie(NULL); 
const ll MOD = 1e9 + 7;
const ll INF = 1<<29;
const ll MAX_N =1e6 + 7;


void solve() {
	int n,x,y;
	cin >> n >> x >> y;
	int k[n] = {0};
	int ans = 0;
	
	for(int i = 1; i  <= n; ++i) {
		for(int j = i+1; j <= n; ++j) {
			ans = min({abs(j - i), abs(x-i) + 1 + abs(j-y), abs(y-i) + 1 + abs(j-x)});
			if(ans < n) k[ans]++;
		}
	}

	for(int i = 1; i < n; ++i) {
		cout << k[i] << "\n";
	}
}

int main() {_
	solve();

}


Measured memory_bytes: 256
import math
a, b, c, x, y = map(int, input().split())
n = a*x + b*y
m = c*2*max(x,y)
min_xy = min(x,y)
k = min_xy*2*c + (x-min_xy)*a + (y-min_xy)*b
print(min(n,m,k))

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int MAXN = 2010;
int visited[MAXN], dp1[MAXN], dp2[MAXN]; // dp1 >= dp2

int n, k;

vector< vector<int> > adj;

int dfs(int u, int h) {
    visited[u] = 1; int curr = 0; vector<int> save;

    for (auto v : adj[u]) {
        if (!visited[v]) {
            dfs(v, h+1);
            dp1[u] += dp1[v];
            dp2[u] += dp2[v];

            if (h == 0) {
                curr += dp1[v];
                save.PB(dp2[v] - dp1[v]);
            }
        }
    }

    dp1[u] += (h > k / 2); dp2[u] += (h > k / 2 + 1);

    if (h == 0 && k % 2 == 1) {
        sort(save.begin(), save.end());
        curr += save[0];
    }

    return curr;
}

int main() {
    GI(n); GI(k); adj.resize(n+1); int x, y;

    FORN(i, n-1) {
        GI(x); GI(y);
        adj[x].PB(y);
        adj[y].PB(x);
    }

    int res = INF;

    FOR1(i, n) {
        memset(visited, 0, sizeof visited);
        memset(dp1, 0, sizeof dp1);
        memset(dp2, 0, sizeof dp2);

        res = min(dfs(i, 0), res);
    }

    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

void printline(int A[],int N){
    for (int i = 0; i < N; i++) {
        cout << A[i];
        if (i != N-1) {
            cout << " ";
        }
    }
    cout << endl;
}

void insort(int A[],int N){
    
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < i; j++) {
            if (A[i] <= A[j]) {
                int a = A[i];
                for (int k = i; k > j; k--) {
                    A[k] = A[k-1];
                }
                A[j] = a;
                break;
            }
        }
        printline(A,N);
    }
}

int main(){
    int N,*A;
    cin >> N;
    A = (int *)malloc(sizeof(int)*N);
    
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    insort(A,N);
    
    return 0;
}

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

using namespace std;

int main() {
    int n;
    int room[4][3][10];
    memset(room, 0, sizeof(room));
    cin >> n;
    for (int i = 0; i < n; i++) {
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        room[b-1][f-1][r-1] += v;
    }
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                cout << " " << room[i][j][k];
            }
            cout << endl;
        }
        if (i < 3) {
            cout << "####################" << endl;
        }
    }
}

Measured memory_bytes: 1164
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

struct Point {
    int x, y;

    Point() {}
    Point(int x, int y) : x(x), y(y) {}
};

signed main() {
    int N;
    cin >> N;

    vector<Point> p(N);

    rep(i, N) {
        cin >> p[i].x >> p[i].y;
    }

    set<pair<int, int>> st;
    pair<int, int> d[60][60];
    rep(i, N) rep(j, N) {
        auto pr = mp(p[i].x - p[j].x, p[i].y - p[j].y);
        d[i][j] = pr;
        st.insert(pr);
    }

    int ret = N;
    for (auto &pr : st) {
        if (pr.first == 0 && pr.second == 0) continue;
        int cnt = 0;
        rep(i, N) {
            bool ok = false;
            rep(j, N) if (pr == d[i][j]) ok = true;
            cnt += ok;
        }
        ret = min(ret, N - cnt);
    }

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <fstream>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <bitset>
#include <memory.h>
#include <limits.h>

using namespace std;

int a[500];

int main() {
	//ios_base::sync_with_stdio(false);
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");

	string s;
	cin >> s;
	long long ans = 0;
	for (int i = 0; i < s.length(); i++) {
		a[s[i]]++;
	}
	for (int i = 0; i < s.length(); i++) {
		a[s[i]]--;
		ans += s.length() - i - 1 - a[s[i]];
	}

	cout << ans + 1;
	

	//system("pause");
	return 0;
}

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

typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

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

    string ans = "Good";
    REP(i, S.size()) {
        if (i > 0 && S[i] == S[i-1]) {
            ans = "Bad";
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main {
    public static void main(String args[]) {
        Scanner sc =new Scanner(System.in);
		int n= sc.nextInt();
		int i;
		long s=1;
		
		for(i=2;i<=n;i++)
		s*=i;
		
		System.out.println(s);
        
    }
}

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

using namespace std;

int main(){
	int N, T, S;
	cin >> N >> T >> S;

	vector<int> A(N);
	vector<int> B(N);
	vector<int> dp(T+1, 0);

	for (int i = 0; i < N; i++){
		cin >> A[i] >> B[i];
	}

	int ans = 0;
	for (int n = 0; n <N; n++){
		for (int t = T-B[n]; t >= 0; t--){
			if (t < S && S < t+B[n]) continue;
			dp[t+B[n]] = max(dp[t]+A[n], dp[t+B[n]]);
			ans = max(ans, dp[t+B[n]]);
		}
	}

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

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

int main()
{
  int A, B;
  while (cin >> A >> B && A != 0) {
    int c = B - A;
    const int c1000 = c / 1000;
    c %= 1000;
    const int c500 = c / 500;
    c %= 500;
    cout << c/100 << ' ' << c500 << ' ' << c1000 << endl;
  }
  return 0;
}

Measured memory_bytes: 0
/* Author : Pranav Deshmukh
            PICT,Pune
   Stay Focused!
*/

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

#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define int             long long
#define float           double
#define ms(s, n) 		memset(s, n, sizeof(s))
#define dip(type,var)   type var; cin>>var;
#define dipi(x)         int x; cin>>x;
#define dipi2(x,y)      int x,y; cin>>x>>y;
#define w(x)            int x; cin>>x; while(x--)
#define mka(type,arr,n) type *arr=new type[n];
#define fo(i,n)         for(int i=0;i<n;i++)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define pi              3.141592653589793238
#define endl            "\n"
#define f               first
#define s               second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >

void sync() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void timeTaken() {
	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
}

int32_t main() {
	sync();
	dipi(n);
	dipi(x);
	dipi(t);
	int div = n / x;
	if (n % x == 0)
		cout << (div)*t << endl;
	else
		cout << (div + 1)*t << endl;
	timeTaken();
	return 0;
}


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

int main(){
  int n;
  std::cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++){
    std::cin >> a[i];
    a[i]--;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += (a[a[i]] == i);
  }
  std::cout << ans/2 << std::endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

struct Mod{
  unsigned n;
  Mod() : n(0){}
  Mod( ll x ){
    if( x < 0 ) n = x%MOD+MOD;
    else n = x%MOD;
  }
};
Mod operator + ( Mod a  , Mod b ){ return Mod( a.n + b.n ); }
Mod operator +=( Mod &a , Mod b ){ return a = a + b; }
Mod operator - ( Mod a ){ return Mod( MOD - a.n ); }
Mod operator - ( Mod a  , Mod b ){ return Mod( a.n + MOD - b.n ); }
Mod operator -=( Mod &a , Mod b ){ return a = a - b; }
Mod operator * ( Mod a  , Mod b ){ return Mod( (ll)a.n * b.n ); }
Mod operator *=( Mod &a , Mod b ){ return a = a * b; }
Mod modpow( Mod x , ll k ){
  Mod res = 1;
  while( k ){
    if( k & 1 ) res *= x;
    k /= 2;
    x *= x;
  }
  return res;
}
ll extgcd( ll a , ll b , ll &x , ll &y ){
  ll d = a;
  if( b != 0 ){
    d = extgcd( b , a % b , y , x );
    y -= a / b * x;
  } else {
    x = 1, y = 0;
  }
  return d;
}
Mod inv( Mod a ){ ll x, y; assert( extgcd( a.n , MOD , x , y ) == 1 ); return Mod( x ); }
Mod operator / ( Mod a  , Mod b ){ return Mod( (ll)a.n * inv(b).n ); }
Mod operator /=( Mod &a , Mod b ){ return a = a / b; }

int main(){

  int n = in();
  vector<ll> a(n);
  REP(i, n){
    a[i] = in();
  }
  vector<vector<ll>> dp(n + 1, vector<ll>(n + 1));
  REP(i, n + 1){
    dp[i][i] = 0;
    FOR(j, i + 1, n + 1){
      if((j - i) % 2 == n % 2){
        dp[i][j] = -INFLL;
      } else {
        dp[i][j] = INFLL;
      }
    }
  }
  
  FOR(l, 1, n + 1){
    REP(i, n){
      ll j = i + l;
      if(j > n){
        continue;
      }
      if(l % 2 == n % 2){
        ll x = dp[i+1][j] + a[i];
        ll y = dp[i][j-1] + a[j-1];
        dp[i][j] = max(x, y);
      } else {
        ll x = dp[i+1][j] - a[i];
        ll y = dp[i][j-1] - a[j-1];
        dp[i][j] = min(x, y);
      }
    }
  }

  printf("%lld\n", dp[0][n]);
  
  return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

template< typename Monoid >
struct SegmentTree{
  using F = function< Monoid(Monoid, Monoid) >;
  
  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  //SegmentTree(n,f,M1):サイズnの初期化，fは2つの苦汗の要素をマージする二項演算，M1はモノイドの単位元
  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1){
    sz = 1;
    while(sz < n) sz<<=1;
    seg.assign(2*sz,M1);
  }

  //set(k,x):k番目の要素にxを代入
  void set(int k, const Monoid &x){
    seg[k+sz] = x;

  }
  
  //build():segTreeの構築
  void build(){
    for(int k = sz-1; k>0; --k){
      seg[k] = f(seg[2*k+0], seg[2*k+1]);
    }
  }

  //update(k,x):k番目の要素をxに変更
  void update(int k, const Monoid &x){
    k += sz;
    seg[k] = x;
    while(k>>=1) seg[k] = f(seg[2*k+0],seg[2*k+1]);
  }

  //区間[a,b)のMonoidを計算
  Monoid query(int a, int b){
    Monoid L = M1, R = M1;
    for(a += sz, b+=sz; a < b; a>>=1, b>>=1){
      if(a&1) L = f(L,seg[a++]);
      if(b&1) R = f(seg[--b],R);
    }
    return f(L,R);
  }

  //operator[k]:k番目の要素を返す
  Monoid operator[](const int &k) const{
    return seg[k+sz];
  }
};

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,K,Q;cin >> N >> K >> Q;
  vector<int> v(N);
  //範囲の最小値を返すsegTree
  set<int> st;
  rep(i,N){
    cin >> v[i];
    st.insert(v[i]);
  }
  int ans = MAX_I;
  for(const int& s:st){
    vector<int> w;
    vector<int> del;
    w.push_back(-1);
    rep(i,N)if(v[i]<s)w.push_back(i);
    w.push_back(N);
    rep(x,w.size()-1){
      if(w[x+1]-w[x]-1<K)continue;
      priority_queue<int, vector<int>, greater<int> >pq;
      repp(i,w[x]+1,w[x+1]) pq.push(v[i]);
      while(pq.size()>=K){
        del.push_back(pq.top());
        pq.pop();
      }
    }
    if(del.size()<Q)continue;
    sort(all(del));
    ans = min(ans, del[Q-1]-s);
  }
  cout << ans << endl;
  return 0;
}


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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
const ll P =  1000000007;
ll factorial(ll n){
   ll ans = 1;
   for(int i = n;i>=1;i--){
     ans *= i;
     ans %= P;
   }
   return ans;
}
using Graph = vector<vector<int>>;


int main(){
  vector<vector<int>> A(3, vector<int>(3));
  rep(i,3){
    rep(j,3){
      cin >> A[i][j];
    }
  }
  int N;
  cin >> N;
  vector<int> B(N);
  rep(i,N){
    cin >> B[i];
  }

  vector<vector<int>> bingo(3, vector<int>(3,0));
  bool flag = false;
  
  rep(i,N){//印をつける
    int bin = B[i];
    rep(j,3){
      rep(k,3){
        if(A[j][k] == bin) bingo[j][k] = 1;
      }
    }
  }

  //斜め
  if(bingo[0][0] == 1 && bingo[1][1] == 1 && bingo[2][2] == 1){
    flag = true;
  }
  if(bingo[0][2] == 1 && bingo[1][1] == 1 && bingo[2][0] == 1){
    flag = true;
  }
  //横
  if(bingo[0][0] == 1 && bingo[0][1] == 1 && bingo[0][2] == 1){
    flag = true;
  }
  if(bingo[1][0] == 1 && bingo[1][1] == 1 && bingo[1][2] == 1){
    flag = true;
  }
  if(bingo[2][0] == 1 && bingo[2][1] == 1 && bingo[2][2] == 1){
    flag = true;
  }

  if(bingo[0][0] == 1 && bingo[1][0] == 1 && bingo[2][0] == 1){
    flag = true;
  }
  if(bingo[0][1] == 1 && bingo[1][1] == 1 && bingo[2][1] == 1){
    flag = true;
  }
  if(bingo[0][2] == 1 && bingo[1][2] == 1 && bingo[2][2] == 1){
    flag = true;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;
typedef long long ll;

typedef tuple<ll,ll,int> P;

bool cmp(const P &a, const P &b) {
	if(get<1>(a)==get<1>(b)) {
		return get<0>(a)>get<0>(b);
	}else {
		return get<1>(a)>get<1>(b);
	}
}

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

	vector<P> ps1,ps2;
	for(int i = 0; i < n; i++) {
		ll a,b;
		cin >> a >> b;
		ps1.push_back(P(a,b+a,i));
		ps2.push_back(P(b,a+b,i));
	}
	sort(ps1.begin(),ps1.end(),cmp);
	sort(ps2.begin(),ps2.end(),cmp);

	vector<bool> checked(n);
	int ai = 0, bi = 0;

	ll ans = 0;

	for(int turn = 0; turn<n; turn++) {
		P p;
		if(turn%2==0) {
			while(true){
				p = ps1[ai];
				if(!checked[get<2>(p)]) break;
				ai++;
			}
			checked[get<2>(p)] = true;
			ans += get<0>(p);
			//cout << get<0>(p) << "," << get<1>(p) << "," << get<2>(p) << ",ai=" << ai << endl;
		}else {
			while(true){
				p = ps2[bi];
				if(!checked[get<2>(p)]) break;
				bi++;
			}
			checked[get<2>(p)] = true;
			ans -= get<0>(p);
			//cout << get<0>(p) << "," << get<1>(p) << "," << get<2>(p) << ",bi=" << bi << endl;
		}
		//cout << ans << endl;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6700
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <numeric>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define ALL(x) (x).begin(),(x).end()
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main(){
	int n, a, b; cin >> n >> a >> b;

	cout << min(a*n, b) << endl;

	return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  vector<int> cnt(3000, 0);
  rep(i, n) {
    cin >> l[i];
    cnt[l[i]]++;
  }

  vector<ll> sum(3000, 0);
  REP(i, 1, 3000) sum[i] = sum[i - 1] + cnt[i];

  ll ans = 0;
  rep(i, n) REP(j, i + 1, n) {
    int x = abs(l[i] - l[j]);
    int y = l[i] + l[j];
    ans += sum[y - 1] - sum[x];
    if (x < l[i] && l[i] < y) ans--;
    if (x < l[j] && l[j] < y) ans--;
  }

  cout << ans / 3 << endl;
}


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

int main()
{
    ll N;
    cin >> N;

    ll absum = pow(10,9);
    ll a = 0;
    ll b = 0;
    int ans;

    for(a = 1; a <= pow(N,0.5); a++)
    {
        if(N % a == 0)
        {
            b = N / a;
            string atmp = to_string(a);
            string btmp = to_string(b);
            ans = max(atmp.size(),btmp.size());
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>

using namespace std;



int main(){
    int n,k;
    cin >> n>>k;
    cout << n-k+1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
lld gcd_ (lld a, lld b)
{
      lld max = a > b ? a : b;
      lld min = a < b ? a : b;
      while (min != 0)
      {
            lld rem = max%min;
            max = min;
            min = rem;
      }
      return max;
}
int main ()
{
      FastIO
      lld a, b;
      cin >> a;
      cin >> b;
      lld x = gcd_(a,b);
      cout << ((a*b)/x);
      return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define pb(a) push_back(a)
#define MAX(a, b) ((a < b)?b:a)
#define MIN(a, b) ((a > b)?b:a)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

template<typename T> void cinpb(vector<T>& x) { T n; cin >> n; x.push_back(n); }
ull gcd(ull a, ull b) { return b ? gcd(b, a%b) : a; }
ull lcm(ull m, ull n) {	return ((0 == m) || (0 == n)) ? 0 : ((m / gcd(m, n)) * n); }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

void yesno(bool f) { cout << (f ? "Yes" : "No") << endl; }

//


int main()
{
	int n, t, a;

	cin >> n >> t >> a;

	double sa = 100000000;
	int ans = 1;

	rep(i, n)
	{
		int h;
		cin >> h;
		double temp = t - h * 0.006;

		if ( sa > abs(a - temp) )
		{
			sa = abs(a - temp);
			ans = i;
		}
	}

	cout << ans + 1 << endl;

	return 0;
}


Measured memory_bytes: 256
import math

a, b, h, m = map(int, input().split())
x = abs((60 * h + m) / 2 - m * 6)
c2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(x))
c = math.sqrt(c2)
print(c)

Measured memory_bytes: 9384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

// (1) ????????????1???????????????
// (2) ?????????????????????????????§????????¨?°??????????????????????????????????????´????????????°result???????????????
// (3) ????????????????????????????????\?????????????????????
	// (3.1) ????????????????????§??????????????\?????????????????????
		// (3.1.1) ?°?????????????????????????result???????´???????
	// (3.2) ???????????????????°???????????????\?????????????????????
		// (3.2.1) ??§????????????????????????result???????´???????
	// (3.3)???????????¢????????????????????\???????????\?????????????????????
		// (3.3.1) ??????????????????result???????´???????
// (4) result?????¨?????????


public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
		String textInput = br.readLine();
		String result = "";

		for (int i = 0;i < textInput.length(); i++){
			if (Character.isUpperCase(textInput.charAt(i))) {
				char textInputChar = textInput.charAt(i);
				char textOutputLo = Character.toLowerCase(textInputChar);
				String strLo = String.valueOf(textOutputLo);
				result += strLo;
			}
			else if (Character.isLowerCase(textInput.charAt(i))) {
				char textInputChar = textInput.charAt(i);
				char textOutputUp = Character.toUpperCase(textInputChar);
				String strUp = String.valueOf(textOutputUp);
				result += strUp;
			}
			else{
				String strLet = String.valueOf(textInput.charAt(i));
				result += strLet;
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 29468
#include<cstdio>
#include<algorithm>
#define MN 1000
using namespace std;

const int MOD=1e9+7;
int n,m,k,le[MN],ri[MN],x,y,z,mmh[1<<20],MMH=0;
inline void M(int &x){while(x>=MOD)x-=MOD;}
int lowbit(int x) { return x & -x; }
int main(){
	scanf("%d%d%d",&n,&m,&k);n--;
	for (int i=1;i<=m;i++) le[i]=(1<<n)-1,ri[i]=0;
	while(k--){
		scanf("%d%d%d",&x,&y,&z);y--;
		if (z==0) le[x]^=1<<y;else ri[x]^=1<<y;
	}
	mmh[0]=1;
	for (int i=1;i<=m;i++){
		for (int k=0;k<n;k++)
		for (int j=0;j<(1<<n);j++) if (~j>>k&1)
		M(mmh[j+(1<<k)-lowbit(j&~((1<<k)-1))]+=mmh[j]);
		for (int j=0;j<(1<<n);j++)
		if (!((j&ri[i])==ri[i]&&(j&le[i])==j)) mmh[j]=0;
	}
	for (int j=0;j<(1<<n);j++) M(MMH+=mmh[j]);
	printf("%d\n",MMH);
}

Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
/*cout <<setprecision(11)<<ret<<endl;で、数字部分を計11桁表示*/
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//Shift+Command+bでデバッグ
//その後ターミナルで./a.outを実行
//入力を貼り付ける

//////////////////
//  A
int main(void){
    string s;cin>>s;

    rep(i,3) cout<<s[i];
    cout<<endl;
    return 0;
}
//////////////////
//  B
/*int main(void){

    return 0;
}*/
//////////////////
//  C
/*int main(void){

    return 0;
}*/
//////////////////
//  D
/*int main(void){

    return 0;
}*/
//////////////////
//  E
/*int main(void){

    return 0;
}*/
//////////////////
//  F
/*int main(void){

    return 0;
}*/


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--ModInt
//-------------------------------------------------
const ::std::uint_fast64_t MOD = 998244353;

class mint
{
private:
    using value_type = ::std::uint_fast64_t;
    value_type n;
public:
    mint():n(0){}
    mint(::std::int_fast64_t _n):n(_n<0 ? MOD-(-_n)%MOD : _n%MOD){}
    mint(const mint &m):n(m.n){}

    friend ::std::ostream& operator<<(::std::ostream &os, const mint &a){
		return os << a.n;
	}
    friend ::std::istream& operator>>(::std::istream &is, mint &a){
        value_type temp; is>>temp;
        a = mint(temp);
        return is;
    }

    mint& operator+=(const mint &m){n+=m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator-=(const mint &m){n+=MOD-m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator*=(const mint &m){n=n*m.n%MOD; return *this;}
    mint& operator/=(const mint &m){return *this*=m.inv();}
    mint& operator++(){return *this+=1;}
    mint& operator--(){return *this-=1;}

    mint operator+(const mint &m) const {return mint(*this)+=m;}
    mint operator-(const mint &m) const {return mint(*this)-=m;}
    mint operator*(const mint &m) const {return mint(*this)*=m;}
    mint operator/(const mint &m) const {return mint(*this)/=m;}
    mint operator++(int){mint t(*this); *this+=1; return t;}
    mint operator--(int){mint t(*this); *this-=1; return t;}

    bool operator==(const mint &m) const {return n==m.n;}
    bool operator!=(const mint &m) const {return n!=m.n;}
    mint operator-() const {return mint(MOD-n);}

    mint pow(value_type b) const {
        mint ret(1), m(*this);
        while(b){
            if (b & 1) ret*=m;
            m*=m;
            b>>=1;
        }
        return ret;
    }

    mint inv() const {return pow(MOD-2);}
};

mint dp[3030][3030];

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A,B,C,D; cin>>A>>B>>C>>D;
    dp[A][B] = 1;
    FOR(i,A,C)FOR(j,B,D){
        if (i==A && j==B) continue;
        dp[i][j] = dp[i-1][j]*j + dp[i][j-1]*i - dp[i-1][j-1]*(i-1)*(j-1);
    }
    // FOR(i,0,C){
    //     FOR(j,0,D){
    //         cout<<dp[i][j]<<" ";
    //     }cout<<endl;
    // }
    cout<<dp[C][D]<<endl;
    return 0;
}


Measured memory_bytes: 75412
#include<bits/stdc++.h>
using namespace std;
string st,st1,st2;
int n;
int hw(string st)
{
	for(int i=0;i<st.size();i++)
	  if(st[i]!=st[st.size()-i-1]) return 0;
	return 1;
}
int main()
{
	getline(cin,st);
	n=st.size();
	for(int i=0;i<(n-1)/2;i++) st1+=st[i];
	for(int i=(n+3)/2-1;i<n;i++) st2+=st[i];
	if(hw(st)&&hw(st1)&&hw(st2)) cout<<"Yes";
	else cout<<"No";
	cout<<endl;
	return 0;
}

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

"""
参考：https://kimiyuki.net/writeup/algo/atcoder/arc-085-d/
　　　https://atcoder.jp/contests/abc078/submissions/3854338
・ミニマックス法
・メモ化再帰
・メモの持ち方をシンプルにした版
"""

import sys
from collections import defaultdict

# 再帰呼び出しの回数制限(デフォルト1000)
sys.setrecursionlimit(10 ** 9)
 
N, Z, W = map(int, input().split())
aN = list(map(int, input().split()))

# メモ[手番][残り山札数] = このルートでのmax,min
memo = [[0] * (N+1) for _ in range(2)]

def dfs(turn, rest, x, y):
    if rest == 0:
        return abs(x - y)
    # 先手番
    if turn % 2 == 0:
        # 既に見た局面ならメモの内容を返す
        if memo[0][rest]: 
            return memo[0][rest]
        mx = -1
        for i in range(N-rest, N):
            x = aN[i]
            idx = i+1
            mx = max(dfs(turn+1, N-idx, x, y), mx)
        # ここより深い所を探し終わったので結果をメモする
        memo[0][rest] = mx
        return mx
    # 後手番
    else:
        if memo[1][rest]: 
            return memo[1][rest]
        mn = float('inf')
        for i in range(N-rest, N):
            y = aN[i]
            idx = i+1
            mn = min(dfs(turn+1, N-idx, x, y), mn)
        memo[1][rest] = mn
        return mn

print(dfs(0, N, Z, W))


Measured memory_bytes: 46852
#include<iostream>
#define debug_C(a) cout << a << endl;
using namespace std;
int main() {
	long long int N, Power=1,Rem=0,Fact=1;
	cin >> N;
	for (int i = 0; i <9; i++) Fact *= 10;
	for (int i = 1; i <= N; i++) {
		Power *= i;
		Power %= Fact + 7;
	}
	cout << Power << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
typedef long long int ll;

struct Edge{
    int to,from; ll cost;
    Edge(){}
    Edge(int to,int from,ll cost):to(to),from(from),cost(cost){}
};
bool operator<(const Edge& x,const Edge& y){
    return x.cost<y.cost;
}

struct UnionFind{
    vector<int> par,num;
    vector<bool> done;
    UnionFind(int n):par(n),num(n,1),done(n,false){
        iota(par.begin(),par.end(),0);  //include<numeric>
    }
    int find(int v){
        return (par[v]==v)?v:(par[v]=find(par[v]));
    }
    void unite(int u,int v){
        u=find(u),v=find(v);
        if(u==v)return;
        if(num[u]<num[v])swap(u,v);
        num[u]+=num[v];
        par[v]=u;
        done[u]=done[u]|done[v];
    }
    bool same(int u,int v){
        return find(u) == find(v);
    }
    bool ispar(int v){
        return v=find(v);
    }
    int size(int v){
        return num[find(v)];
    }
};

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,m; cin >> n >> m;
	UnionFind uf(n);
	vector<Edge> v(m);
	for(int i=0;i<m;i++){
		cin >> v[i].from >> v[i].to >> v[i].cost ;
	}
	sort(v.begin(),v.end());
	ll ans=0;
	for(int i=0;i<m;i++){
		if(!uf.same(v[i].to,v[i].from)){
			ans+=v[i].cost;
			uf.unite(v[i].to,v[i].from);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 4404
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
char s[100005];
int n,k;
int main()
{
	scanf("%d%d",&n,&k);
	scanf("%s",s+1);
	int num=0;
	for(int i=1;i<=n;i++)
	  if(s[i]!=s[i-1])num++;
	printf("%d\n",n-max(num-k*2,1));
	return 0;
}

Measured memory_bytes: 256
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int n,a[100005],cnt0,cnt2;
void calc(int x){
	int sol=0;
	while(x%2==0){
		sol++;
		x/=2;
		if(sol>=2)
		break;
	}
	if(sol==0)
	cnt0++;
	else if(sol>=2)
	cnt2++;
}
int main(){
	//freopen("wireless.in","r",stdin);
	//freopen("wireless.out","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		calc(a[i]);
	}
	if(cnt2==cnt0 || cnt2==n || cnt2+cnt0==n && cnt2==cnt0-1)
	cout<<"Yes";
	else
	cout<<"No";
	//system("pause");
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;

main(){
    ll a,b,v,w,T;
    cin>>a>>v>>b>>w>>T;
    if(v<=w) cout<<"NO";
    else{
        if(abs(a-b) <= (T*(v-w))) cout<<"YES";
        else cout<<"NO";
    }
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void){
    int A,B,C;
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);
    int jud=0;
    for(int i=0;i<1000;i++){
        if((B*i+C)%A==0){
            jud=1;
            break;
        }
    }
    if(jud==1){
        printf("YES");
    }else{
        printf("NO");
    }
    
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include<iomanip>
#include <cmath>
using namespace std;

long long read(void) {
	long long d;
	cin >> d;
	return d;
}
void println(void) {
	cout << endl;
}
void printFixed(double d, int digit) {
	cout << fixed << setprecision(digit) << d;
}
void printlnFixed(double d, int digit) {
	printFixed(d, digit);
	println();
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	const double PI = acos(-1);
	int a = read();
	int b = read();
	int C_dig = read();
	double C_rad = C_dig * PI / 180;

	double h = b * sin(C_rad); // 高さ 極座標変換
	double S = a * h / 2; // 面積
	double L = a + b + sqrt(a*a + b*b - 2*a*b*cos(C_rad)); // 周 余弦定理

	printlnFixed(S, 5);
	printlnFixed(L, 5);
	printlnFixed(h, 5);

	return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const int mnx = 1e6 + 9;
const int mod = 1e9 + 7;

ll n;
ll a[mnx];
ll b[mnx];
ll c[mnx];
ll dp[mnx][4];

int main(){
    cin >> n;

    for(int i = 1; i <= n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }

    for(int i = 0; i < n; i++){
        dp[i + 1][1] = max(dp[i][2], dp[i][3]) + a[i + 1];
        dp[i + 1][2] = max(dp[i][1], dp[i][3]) + b[i + 1];
        dp[i + 1][3] = max(dp[i][1], dp[i][2]) + c[i + 1];
//        cout << dp[i][1] << ' ' << dp[i][2] << ' ' << dp[i][3] << '\n';
    }

    cout << max({dp[n][1], dp[n][2], dp[n][3]}) << '\n';

    return 0;
}

/*
3
10 40 70
20 50 80
30 60 90

10  40  70
90  120 120
150 180 210
*/


















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

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

sigma = 0
after = sum(a[0:])
for i in range(len(a)-1):
  start = a[i]
  after = after - a[i]
  sigma = sigma + start * after
  if sigma >= (10**9 + 7):
    sigma = sigma % (10**9+7)

print(sigma)


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

int main() {
    int a,b,c,d,i=0,j=0;
    cin>>a>>b>>c;
    if(a>b){
        if(a>c)
            cout<<"A"<<endl;
        else
            cout<<"C"<<endl;
    }else{
        if(b>c)
            cout<<"B"<<endl;
        else
            cout<<"C"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3108
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false)

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

const int N = 50;
ll A_MAX = 1e16;

ll a[N + 10];

int main()
{
	ll k, n = N;
	cin >> k;
	ll st = k / n;
	k %= n;
	for (int i = 1; i <= n; ++i)
		a[i] = st + i - 1;

	for (int i = 1; i <= k; ++i)
	{
		a[i] += n + 1;
		for (int j = 1; j <= n; ++j)
			--a[j];
	}

	cout << n << endl;
	for (int i = 1; i <= n; ++i)
		cout << a[i] << ' ';
}


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

int main()
{
  ll l;
  cin >> l;
  double x = 1.0*l/3;
  printf("%.10lf\n", pow(x,3));

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<< #x << ": " << x << "\n";
using namespace std;
#define inf 1e9+7


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a,b;
	cin>>a>>b;
	int ans=a;
	int arr[b];
	set<int> s;
	for(int i=0; i<b; ++i){
		cin>>arr[i];
		s.insert(arr[i]);
	}
	
	for(int i=0; i<=a+1; ++i){
		for(int j=-1; j<=1; ++j){
			int p=a+i*j;
			if(s.find(p)==s.end()){
				cout<<p<<"\n";
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc68
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int N = int.Parse(str[0]);
            int M = int.Parse(str[1]);
            bool[] s = new bool[N];
            bool[] g = new bool[N];
            for(int i = 0; i < M; i++)
            {
                str = Console.ReadLine().Split(' ');
                int a = int.Parse(str[0]);
                int b = int.Parse(str[1]);
                if (a == 1)
                {
                    s[b - 1] = true;
                }else if (b == N)
                {
                    g[a - 1] = true;
                }
            }
            int f = 0;
            for(int i = 0; i < N; i++)
            {
                if (s[i] && g[i])
                {
                    f++;
                }
            }
            if (f == 1)
            {
                Console.WriteLine("POSSIBLE");
            }else
            {
                Console.WriteLine("IMPOSSIBLE");
            }



        }
    }
}


Measured memory_bytes: 15404
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
 
using namespace std;

template<class T1, class T2> inline int chkmin(T1 &x, const T2 &y) {
    if (x > y) {
        x = y;
        return 1;
    }
    else {
        return 0;
    }
}

template<class T1, class T2> inline int chkmax(T1 &x, const T2 &y) {
    if (x < y) {
        x = y;
        return 1;
    }
    else {
        return 0;
    }
}

#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define mp make_pair
#define pb push_back
#define read(FILENAME) freopen((string(FILENAME) + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((string(FILENAME) + ".out").c_str(), "w", stdout);

template<class iterator> void output(iterator begin, iterator end, ostream &out = cerr) {
    while (begin != end) {
        out << (*begin) << " ";
        begin++;
    }
    out << endl;
}

template<class T> void output(const T &x, ostream &out = cerr) {
    output(x.begin(), x.end(), out);
}

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0); 
}



int main() {
    fast_io();
  //  read("input");
    int n;
    cin >> n;
    multiset<int> s;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        s.insert(a);
    }
    vector<pair<int, int> > st;
    while (sz(s) > 2) {
        int a = *s.begin();
        s.erase(s.find(a));
        auto it = s.rbegin();
        it++;
        if (*it > 0) {
            int b = *s.rbegin();
            s.erase(s.find(b));
            st.pb({a, b});
            a -= b;
            s.insert(a);
        } else {
            s.insert(a);
            break;
            
        }
    }
    while (sz(s) > 1) {
        int a = *s.begin();
        s.erase(s.find(a));
        int b = *s.rbegin();
        s.erase(s.find(b));
        st.pb({b, a});
        b -= a;
        s.insert(b);
    }
    cout << *s.begin() << endl;
    for (auto x: st) {
        cout << x.first << ' ' << x.second << '\n';
    }
    return 0;
}   


Measured memory_bytes: 7416
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
typedef long long ll;
using namespace std;
const int MOD=1e9+7;
ll N,K;
ll x[100000];
int main(void) {
	ll ans = 0;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		ll a, b;
		cin >> a >> b;
		x[a - 1]+= b;
	}
	for (int i = 0; i < 100000; i++) {
		if (x[i] == 0)continue;
		K -= x[i];
		if (K <= 0) {
			ans = i + 1;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1024