akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

  
// GCD, LCM
// https://youtu.be/8lm8o8L9Bmw?t=2285
// https://youtu.be/XI8exXVxZ-Q?t=3595
// https://youtu.be/F2p_e6iKxnk?t=843
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

void solve(long long X){
    cout << lcm(360,360-X)/(360-X) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3672
import Control.Applicative
import Control.Monad
import Data.Functor
import Data.List
import Data.Function

readInts = map read . words <$> getLine :: IO [Int]

solve ds = map fst $ sortBy (compare `on` snd) $ zip [1..] $ map (\[s, p] -> (s, (-read p))) ds

main = readLn >>= flip replicateM (words <$> getLine) >>= mapM_ print . solve


Measured memory_bytes: 1020
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

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

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    REP(i, n)
        cin >> l[i];

    sort(l.begin(), l.end());

    ll cnt = 0;
    FOR(i, 0, n-1){
        FOR(j, i+1, n-1){
            int lb = j;
            int ub = n;
            while(ub - lb > 1){
                int half = (lb + ub) / 2;
                if(l[half] < l[i] + l[j])
                    lb = half;
                else
                    ub = half;
            }
            cnt += ub - (j + 1);
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int N,K,R,S,P;
string T;
int func(int i){
  if(T[i]=='r'){return P;}
  if(T[i]=='s'){return R;}
  if(T[i]=='p'){return S;}
}
int main() {
  cin>>N>>K>>R>>S>>P>>T;
  int64_t cnt=0;
  for(int k=0;k<K;k++){
    bool use=false;
    for(int i=k;i<N;i+=K){
      if(i>=K&&T[i-K]==T[i]&&use){use=false;}
      else{cnt+=func(i);use=true;}//cout<<cnt<<endl;
    }
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3728
from fractions import gcd

N, K = map(int, input().split())
A = list(map(int, input().split()))
g = A[0]
for a in A:
  g = gcd(g, a)

B = [a - K for a in A if a >= K]
for b in B:
  if b % g == 0:
    print('POSSIBLE')
    quit()

print('IMPOSSIBLE')

Measured memory_bytes: 16208
K = int(input())

count = 1
m = 7 % K
s = set()
while 1:
    if m == 0:
        print(count)
        break
    if m in s:
        print(-1)
        break
    count += 1
    s.add(m)
    m = (m * 10 + 7) % K


Measured memory_bytes: 77872
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author indy256
 */

#include <bits/stdc++.h>

using namespace std;

void solve(istream &in, ostream &out) {
    int H, W;
    in >> H >> W;

    vector<vector<int>> a(H, vector<int>(W));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            in >> a[i][j];
        }
    }
    vector<vector<int>> b(H, vector<int>(W));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            in >> b[i][j];
        }
    }

//    int sz = (H + W - 1) * 161;
    int sz = 200 * 200;
    vector<vector<vector<bool>>> dp(H + 1, vector<vector<bool>>(W + 1, vector<bool>(sz)));
    dp[0][1][sz / 2] = true;

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            int d = abs(a[i][j] - b[i][j]);
            for (int k = 0; k < sz; ++k) {
                if (!dp[i][j + 1][k] && !dp[i + 1][j][k])continue;
                dp[i + 1][j + 1][k + d] = true;
                dp[i + 1][j + 1][k - d] = true;
            }
        }
    }

    int res = numeric_limits<int>::max();
    for (int i = 0; i < sz; ++i) {
        if (dp[H][W][i])
            res = min(res, abs(i - sz / 2));
    }
    out << res << '\n';
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solve(in, out);
}


Measured memory_bytes: 33024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
long long MOD; template<class T> void mod(T &n){MOD=n;}
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll



int mass[505][505];

signed main(){
  int h,w;
  cin>>h>>w;
  
  for(int i=1; i<=h; i++) for(int j=1; j<=w; j++) cin>>mass[i][j];
  
  int ans=0;
  vector<P> ve1;
  vector<P> ve2;
  
  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      if(mass[i][j]%2==0) continue;
      if(j+1<=w){
        mass[i][j+1]++;
        mass[i][j]--;
        ve1.push_back(mk(i,j));
        ve2.push_back(mk(i,j+1));
        ans++;
      }else if(i+1<=h){
        mass[i+1][j]++;
        mass[i][j]--;
        ve1.push_back(mk(i,j));
        ve2.push_back(mk(i+1,j));
        ans++;
      }
    }
  }
  
  cout<<ans<<en;
  
  for(int i=0; i<ans; i++){
    cout<<ve1[i].first<<" "<<ve1[i].second<<" "<<ve2[i].first<<" "<<ve2[i].second<<en;
  }
}


Measured memory_bytes: 8420
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int main(){
	string s;
	getline(cin,s);
	string keys[20];
	int N=0;
	while(!s.empty()){
		string t;
		int i;
		for(i=1;i<s.size();i++){
			if(s[i]=='.') break;
			t+=s[i];
		}
		keys[N++]=t;
		s=s.substr(i);
	}
	int now=0,S=-1;
	bool loaded=0;
	while(true){
		if(!loaded){
			if(!getline(cin,s)) break;
		}
		loaded=0;
		string key;
		int i=0;
		while(s[i]==' ') i++;
		int sp=i;
		if(S>=sp){
			puts("no such property");
			return 0;
		}
		while(s[i]!=':') key+=s[i++];
		bool nxt=0;
		if(i==s.size()-1) nxt=1;
//		show(key);
		if(key==keys[now]){
			now++;
//			show(now);
			if(now==N){
				if(nxt){
					puts("object");
					return 0;
				}else{
					cout<<"string \""<<s.substr(i+2)<<"\""<<endl;
					return 0;
				}
			}
			if(!nxt){
				puts("no such property");
				return 0;
			}
			S=sp;
		}else{
			if(S>=sp){
				puts("no such property");
				return 0;
			}
			if(!nxt) continue;
			while(true){
				string t;
				if(!getline(cin,t)){
					puts("no such property");
					return 0;
				}
				int i=0;
				while(t[i]==' ') i++;
				if(i<=sp){
					loaded=1;
					s=t;
					break;
				}
			}
		}
	}
	puts("no such property");
}

Measured memory_bytes: 1284
use std::io::stdin;

fn main() {
    let mut line = String::new();
    let _ = stdin().read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();
    let S: i32 = vec[0].parse().unwrap();

    let h: i32 = S / 60 / 60;
    let m: i32 = (S - h * 60 * 60) / 60;
    let s: i32 = (S - h * 60 * 60) % 60;

    println!("{}:{}:{}", h, m, s);
}



Measured memory_bytes: 5024
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
using ll = long long;
using P = pair<int,int>;

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

  if(a*b%2 == 1){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}


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

using namespace std;

int main()
{
    int A[200000];
    vector<int> a;
    int n;
    cin >> n;
    int i,j;
    for(i = 0;i < n;i++)
    {
        cin >> A[i];
        a.emplace_back(A[i]);
    }
    int counter = 0;
    vector<int>::iterator tmp;
    vector<int>::iterator now = a.begin();
    int ans = 0;
    while(1)
    {
        counter++;
        tmp = find(now,a.end(),counter);
        if(tmp == a.end())
        {
            if(counter == 1 && a[0] != 1)
            {
                ans = -1;
                goto end;
            }
            else if(counter == 1 && a[0] == 1)
            {
                goto end;
            }
            else
            {
                ans += tmp - now - 1;
                goto end;
            }
            
        }
        else
        {
        //cout << tmp - now << endl;
            if(counter == 1)
            {
                ans += tmp - now;
            }
            else
            {
                ans += tmp - now - 1;
            }
            
            now = tmp;
        }
    }
    end:
    cout << ans;
    return 0;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

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

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n, m;
    cin >> n >> m;
    int a[m] = {};
    int b[m] = {};
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    // 処理
    int cnt  = 0;
    int c[n] = {};
    rep(i, m) { c[a[i]]++; }
    rep(i, m) { c[b[i]]++; }

    // 出力
    rep(i, n) {
        { cout << c[i] << endl; }
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))

a *= 1000
t *= 1000

d = abs(t - h[0]*6 - a)
ans = 0
for i in range(n):
    td = abs(t - h[i]*6 - a)
    if td < d:
        d = td
        ans = i

print(ans + 1)


Measured memory_bytes: 3060
import sys
n = int(input())
h = list(map(int, input().split()))

for i in range(n-1,0,-1):
    if h[i] - h[i-1] < 0:
        h[i-1] -= 1
    if h[i] - h[i-1] < 0:
        print("No")
        sys.exit()
else:
    print("Yes")


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

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

using namespace std;
using ll = long long;

int main(void)
{
  ll n;
  cin >> n;
  vector<ll> a(n), b(n + 1, 0);
  ll mod = 1000000007;
  for (int i = 0; i < n; ++i) {
    cin >> a.at(i);
    b.at(i + 1) = b.at(i) + a.at(i);
  }

  ll res = 0;
  for (int j = 0; j < n; ++j) {
    ll sum = (b.at(n) - b.at(j + 1)) % mod;
    res += a.at(j) * sum;
    res %= mod;
  }
  cout << res << endl;
}

Measured memory_bytes: 6356
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

int main()
{
    string S;
    cin >> S;
    rep(i, S.size()) {
        if (i % 2 == 0 && (S[i] != 'R' && S[i] != 'U' && S[i] != 'D')) {
            cout << "No" << endl;
            return 0;
        } else if (i % 2 == 1 && (S[i] != 'L' && S[i] != 'U' && S[i] != 'D')) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main(){
	int N, M, i, j, ans=0;
	cin >> N;
	int T[N];
	for(i=0; i<N; i++){
		cin >> T[i];
		ans += T[i];
	}
	cin >> M;
	int P[M], X[M];
	for(i=0; i<M; i++){
		cin >> P[i] >> X[i];
		cout << ans - T[P[i]-1] + X[i] << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=3e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

vector<ll> e[MAXn];
ll dis[MAXn];
int main(){
    IOS();
    ll n,m;
    cin >> n >> m;
    REP (i,m) {
        ll u,v;
        cin >> u >> v;
        u--, v--;
        REP (j,3) e[u*3+j].eb(v*3+(j+1)%3);
    }
    ll s,t;
    cin >> s >> t;
    s--, t--;
    queue<ll> q;
    REP (i,3*n) dis[i] = INF;
    q.push(s*3);
    dis[s*3] = 0;
    while (SZ(q)) {
        ll cur = q.front();
        q.pop();
        for (auto i:e[cur]) {
            if (dis[i] == INF) {
                dis[i] = dis[cur] + 1;
                q.push(i);
            }
        }
    }
    if (dis[t*3] == INF) cout << -1 << endl;
    else cout << dis[t*3]/3 << endl;
}


Measured memory_bytes: 19072
#include <stdio.h>
int main() {
  char input[4], *p;
  scanf("%s", &input);
  for(p = &input;*p != '\0';p++) {
    if(*p == '7') {
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	ll n;
	rl(n);
	string str;
	cin>> str;
	stack<char> st;
	ll ct=0;
	fr(i,0,n)
	{
		if(st.empty())
		{
			st.push(str[i]);
			ct++;
		}
		else
		{
			if(st.top()!=str[i])
			{
				st.push(str[i]);
				ct++;
			}
		}
	}
	wl(ct);
	NL;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
int prime(int);

int main(){
  int n[10000],i,N,j,sum=0;
  scanf("%d",&N);
  
  for(i=0;i<N;i++){
    scanf("%d",&n[i]);
    if(n[i]==1 || n[i]>=100000000)return 0;
  }
  for(i=0;i<N;i++){
    if(prime(n[i])==1)sum++;
    }
  printf("%d\n",sum);
  return 0;
}

int prime(int n){
  int i;
  if(n/2==0)return 0;
  for(i=2;i<=sqrt(n);i++){
    if(n%i==0)return 0;
  }
  
  return 1;
}

Measured memory_bytes: 632
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>


/* ---------- Namespace ---------- */

using namespace std;


/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

using ll = long long;
using PL = P<ll, ll>;
using PS = P<string, ll>;

using VI = V<int>;
using VVI = V<VI>;
using VL = V<ll>;
using VVL = V<VL>;
using VS = V<string>;
using VB = V<bool>;
using VVB = V<VB>;
using VPL = V<PL>;
using VPS = V<PS>;

#define fst first
#define snd second


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)


/* ---------- container ---------- */

#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define GSORT(c) sort(ALL(c), greater<decltype((c).front())>())
#define SZ(x) (LL((x).size()))


/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)

#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n to 0)
// Natural REP runs from 1 to n (R: n to 1)


/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = 3.14159265358979;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};


/* ---------- Short Functions ---------- */

template <typename T>
T square(T a) {
    return a * a;
}


/* ---------- Debug ---------- */
#define GET_VAR_NAME(variable) #variable

#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;
#define testP(p) cout << GET_VAR_NAME(p) << " = (" << (p).fst << ", " << (p).snd << ")" << endl;


/* ^^^^^^^^^^^^^^^ Settting Part ^^^^^^^^^^^^^^^ */

/* ---------- Variances ---------- */


/* ---------- Functions ---------- */


/* ---------- Main Function ---------- */

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

    ll A, B, C;
    cin >> A >> B >> C;

    if (A % 2 == 0 && A == B && B == C) {
        cout << -1 << endl;
        return 0;
    }

    int cnt = 0;
    while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
        ll newA = (B + C) / 2;
        ll newB = (C + A) / 2;
        ll newC = (A + B) / 2;
        A = newA;
        B = newB;
        C = newC;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

double a, b, x;

int main() {
  cin >> a >> b >> x;
  auto S = x / a;
  double rad = -1;
  if (a * b / 2 <= S) {
    auto h = 2 * b - 2 * S / a;
    rad = atan2(h, a);
  } else {
    auto h = 2 * S / b;
    rad = M_PI / 2 - atan2(h, b);
  }
  auto ans = rad / M_PI * 180;
  printf("%.10f\n", ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include <math.h>
using namespace std;

int main()
{
    long long A, B, f = 1;
    cin >> A >> B;
    long long r = B % A;
    while(r != 0)
    {
        B = A;
        A = r;
        r = B % A;
    }
    long long num = A;
    for(long long i = 2; i < sqrt(A) + 2; i++)
    {
        if(num % i == 0)
        {
            while(num % i == 0)
            {
                num /= i;
            }
            f++;
        }
        else if(num == 1) break;
        else continue;
    }
    if(num == 1) cout << f << endl;
    else cout << f + 1 << endl;
    return 0;
}
 

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


ll mark[1000006];
ll cnt[1000006];
bool vis[1000006];
int main()
{
 
    ll n;
    cin>>n;
    ll ar[n];
    ll mx=0;
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
        cnt[ar[i]]++;
        mx = max(ar[i],mx);
    }
    memset(vis,false,sizeof(vis));
    for(int i=0;i<n;i++)
    {
        if(vis[ar[i]]==false)
        {
            for(int j=2*ar[i];j<=1000000;j+=ar[i])
        {
            mark[j]++;
        }
        vis[ar[i]]=true;
    }
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(cnt[ar[i]]==1 and mark[ar[i]]==0)
            ans++;
    }

    cout<<ans<<endl;

    
    return 0;
}

Measured memory_bytes: 21720
def COMint():
  fac[0]=1
  fac[1]=1
  finv[0]=1
  finv[1]=1
  inv[1]=1
  for i in range(2,N+1):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD
def com(n,k):
  if n<k:
    return 0
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
MOD=10**9+7
N,K=[int(x) for x in input().split()]
A= [int(x) for x in input().split()]
A= sorted(A)
fac=[0]*(N+1)
inv=[0]*(N+1)
finv=[0]*(N+1)
COMint()
ans=0
#print(fac)
for j in range(N):
  ans+=(A[j])*com(j,K-1)
  ans-=(A[j])*com(N-1-j,K-1)
print(ans%(10**9+7))

Measured memory_bytes: 63344
#include <stdio.h>
int main(void){
    // Your code here!
    char s[3];
    int res= 0,cnt = 0;
    scanf("%s",s);
    
    for (int i = 0; i < 3; i++){
        if (s[i] == 'R'){
            cnt++;
        }
        else{
            if (cnt > res){
                res = cnt;
            }
            cnt = 0;
        }
    }
    if (cnt > res) res = cnt;
    printf("%d\n",res);
}


Measured memory_bytes: 1692
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
#define REP(i,b,e) for(ll i=b; i<e; i++)
#define fi first
#define se second

int main(){
	int n;
	scanf("%d", &n);
	P a[n+1];
	REP(i, 0, n){
		a[i].se = i+1;
		scanf("%ld", &a[i].fi);
	}
	a[n] = P(0, 0);
	std::sort(a, a+n, std::greater<P>());

	ll ans[n+1] = {}, x = a[0].se, sum = 0;
	REP(j, 0, n+1){
		sum += a[j].fi;
		if(a[j].se<x){
			ans[x] = sum - a[j].fi * (j+1);
			sum = a[j].fi * (j+1);
			x = a[j].se;
			continue;
		}
	}

	REP(i, 0, n) printf("%ld\n", ans[i+1]);
	return 0;
}



Measured memory_bytes: 6144
#include <stdio.h>
#include <string>
#include <cctype>
using namespace std;

const int MAX = 1200;

int main(){

  char str[MAX];
  for(int i=0;i<MAX;i++){
    scanf("%c", &str[i]);
    if(str[i] == '\n') break;
    if(isalpha(str[i])){
      if(islower(str[i])){str[i] = toupper(str[i]);
      }else if(isupper(str[i])){str[i] = tolower(str[i]);}
    }
  }

  for(int i=0;i<MAX;i++){
    printf("%c",str[i]);
    if(str[i] == '\n') break;
  }

  return 0;
}


Measured memory_bytes: 2608
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
#define INF 1000000000
#define PI 3.14159265359

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

    string s;
    cin >> s;
    if (s == "ARC"){
        cout <<"ABC" <<endl;
    }else{
        cout << "ARC" << endl;
    }
}

Measured memory_bytes: 3652
import sys

sys.setrecursionlimit(500000)
def input():
    return sys.stdin.readline()[:-1]

def main():
    H,W,M = list(map(int,input().split()))
    from collections import defaultdict
    hdict = [0]*H
    wdict = [0]*W

    hw = []

    for i in range(M):
        h,w = list(map(int,input().split()))
        hdict[h-1]+=1
        wdict[w-1]+=1
        hw.append((h-1,w-1))

    hdict = [(i,c) for i,c in enumerate(hdict)]
    hdict.sort(key=lambda x:x[1],reverse=True)
    wdict = [(i,c) for i,c in enumerate(wdict)]
    wdict.sort(key=lambda x:x[1],reverse=True)

    hset = set([])
    hd = defaultdict(int)

    for i in range(H):
        if hdict[i][1]!=hdict[0][1]:
            break
        hset.add(hdict[i][0])
        hd[hdict[i][0]] = i

    wset = set([])
    wd = defaultdict(int)
    for i in range(W):
        if wdict[i][1]!=wdict[0][1]:
            break
        wset.add(wdict[i][0])
        wd[wdict[i][0]] = i

    if len(hset)*len(wset)>M:
        print(hdict[0][1]+wdict[0][1])
    else:
        DP = [[0]*len(wset) for i in range(len(hset))]
        for i in range(M):
            h,w = hw[i]
            if h in hset and w in wset:
                DP[hd[h]][wd[w]]=1
        
        if min(min(DP))==0:
            print(hdict[0][1]+wdict[0][1])
        else:
            print(hdict[0][1]+wdict[0][1]-1)

if __name__ == '__main__':
    main()




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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const ll INF = 1e9+7;


ll sum_v[2005][2005] = {};
ll sum_e[2][2005][2005] = {};
int main(){
	ios_base::sync_with_stdio(false);
	int N, M, Q, ans=0;
	string S[2005];

	cin >> N >> M >> Q;
	rep(i,N) cin >> S[i];

	rep(i,N) rep(j,M){
		sum_v[i+1][j+1] = sum_v[i+1][j] + sum_v[i][j+1] - sum_v[i][j];
		rep(k,2) sum_e[k][i+1][j+1] = sum_e[k][i+1][j] + sum_e[k][i][j+1] - sum_e[k][i][j];
		if( S[i][j] == '1' ){
			sum_v[i+1][j+1]++;
			if( i>0 && S[i-1][j] == '1' ) sum_e[0][i+1][j+1]++;
			if( j>0 && S[i][j-1] == '1' ) sum_e[1][i+1][j+1]++;
		}
	}

	auto f = [&](ll sum[2005][2005], int x1, int y1, int x2, int y2){
		return sum[x2][y2] - sum[x1][y2] - sum[x2][y1] + sum[x1][y1];
	};

	rep(i,Q){
		int x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		int v = f(sum_v, x1-1, y1-1, x2, y2);
		int e0 = f(sum_e[0], x1, y1-1, x2, y2);
		int e1 = f(sum_e[1], x1-1, y1, x2, y2);
		//cout << v << " " << e0 << " " << e1 << endl;
		cout << v - e0 - e1 << endl;
	}

	return 0;
}

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

void chmax(int&a, int b) {
  if (a < b) a = b;
}

int main() {
  
  int N;
  cin >> N;
  
  int A[N+1][N+1];
  
  for (int i = 0; i < N+1; i++) {
    for (int j = 0; j < N+1; j++) {
      A[i][j] = 2;
    }
  }
  
  for (int i = 1; i < N+1; i++) {
    int n;
    cin >> n;
    for (int j = 0; j < n; j++) {
      int x, y;
      cin >> x >> y;
      A[i][x] = y; 
    }
  }
  
  int ans = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    int honest_num = 0;
    bool flag = true; // bitに対して，矛盾した人がいるかどうか
    
    for (int i = 0; i < N; i++) {  
      if (bit & (1 << i)) { // (i+1)さんが正直な人と仮定
        honest_num++;
        for (int j = 1; j < N+1; j++) {
          if (A[i+1][j] != 2) {
            if ((A[i+1][j] == 0 && (bit & (1 << (j-1))) != 0) || 
                (A[i+1][j] != 0 && (bit & (1 << (j-1))) == 0)) {
              flag = false;
            }
          }
        }
      } 
    } 
    
    if (flag) {
      chmax(ans, honest_num);
    }
  } //すべてのbitを試した
  
  cout << ans << endl;


}

Measured memory_bytes: 256
h = int(input())
n = [0]*(h+1)
n[1:] = [int(v) for v in input().split()]


def left(i):
    return i*2


def right(i):
    return i*2+1


def maxHeapify(a, i):
    l, r = left(i), right(i)
    mi = i
    if l <= h and a[l] > a[i]:
        mi = l
    if r <= h and a[r] > a[mi]:
        mi = r

    if i != mi:
        a[i], a[mi] = a[mi], a[i]
        maxHeapify(a, mi)


def buildMaxHeap(a):
    i = h//2
    while i > 0:
        maxHeapify(a, i)
        i -= 1


buildMaxHeap(n)
print(" "+" ".join([str(v) for v in n[1:]]))



Measured memory_bytes: 67872
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{   
    int N,C,K; cin>>N>>C>>K;
    vint t(N);
    REP(i,N) cin>>t[i];
    sort(ALL(t));
    
    int ans=0;
    for(int i=0;i<N;)
    {
        int j=i;
        while(j<N and j-i+1<=C and t[j]<=t[i]+K) j++;
        ans++; i=j;
    }
    cout<<ans<<endl;
}


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

#define INF 1e10

int main(){
	int n;
	cin >> n;
	int h[110000];
	int dp[110000];
	int m;
	cin >> m;
	for(int i=0; i<n; i++){
		cin >> h[i];
	}
	for(int i=0; i<n; i++){
		dp[i]=INF;
	}
	dp[0]=0;
	for(int i=0; i<n; i++){
		for(int j=1; j<=m; j++){
		if(i+j<n) dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));}
	}
	cout << dp[n-1];
}

Measured memory_bytes: 1024
import scala.io.StdIn
object Main extends App {

  val n = StdIn.readLine().trim.toInt

  var minv = StdIn.readLine().trim.toInt
  var maxv = (scala.math.pow(10, 9) * -1 ).toInt
  (1 until n).foreach{ j =>
    val temp = StdIn.readLine().trim.toInt
    maxv = if(maxv < temp - minv) temp - minv else maxv
    minv = if(temp < minv) temp else minv
  }

  println(maxv)
  
}



Measured memory_bytes: 63420
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    N, K = il()
    return K * (K - 1) ** (N - 1)


if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 3064
#include <stdio.h>

void gcd(int x, int y, int c){
  if(y == 0){
    printf("%d %d\n", x, c);
    return;
  }
  gcd(y, x % y, c + 1);
}

int main(){
  int x, y;
  while(scanf("%d%d", &x, &y) && x && y){
    if(x < y){ x += y; y = x - y; x -= y;}
    gcd(x, y, 0);
  }
  return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  int n ;
  cin >> n ;
  int ans = n/500 ;
  cout <<  1000*ans + ( n - 500*ans )/5*5 << endl; 
}


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

int main() {
    // freopen("test.in","r",stdin);
    // freopen("test.out","w",stdout);
    int n,x,ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
        scanf("%d",&x);
        if(x*i&1) ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;cin>>n>>k;
  ll ans = 0;
  ll mi = 0,ma = n;
  for(ll i=0;i<=n;i++){
    if(i >= k-1){
      ans += ma-mi+1;
    }

    ans %= MOD;
    mi += i+1;
    ma += n-i-1;
  }
  cout<<ans<<endl;
  return 0;
}



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

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n, tmp;
    cin >> n;
    ll height[n] = {};
    ll add[n] = {};
    map<ll, int> sub_count;

    for(int i=0;i<n;++i)
    {
        cin >> height[i];
        add[i] = i + height[i];
        sub_count[i - height[i]]++;
    }

    ll ret = 0;
    for(int i=0;i<n;++i)
    {
        ll sub = i - height[i];
        sub_count[sub]--;
        ret += sub_count[add[i]];
    }

    cout << ret << endl;
}

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

using namespace std;
           
	int n, m, x, res;
int main(){
	cin >> n >> m;
	for(int i = 0;i < n;i++){
		int tmp = 0;
		for(int j = 0;j < m;j++){
			cin >> x;
			if(i)x ^= 1;
			if(j != 0 && j != (m - 1))x ^= 1;
			tmp += x;
		}
		if(m != 1){
			if(tmp != m)tmp++;
			else tmp--;
		}
		res += tmp;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1164
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);

		while(stdin.hasNext()) {
			int x = stdin.nextInt();
			int y = stdin.nextInt();
			int z = x + y;
			BigDecimal.valueOf(z).precision();
			System.out.println(BigDecimal.valueOf(z).precision());
		}

	}

}

Measured memory_bytes: 26288
#include <stdio.h>
 
int main(){
  int h,w;
 
  while(1){
    scanf("%d %d",&h,&w);
    if(h == 0 && w == 0)
      return 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(i == 0 || j == 0 || i == h-1 || j == w-1)
          putchar('#');
        else
          putchar('.');
      }
      putchar('\n');
    }
   putchar('\n');
  }
  return 0;
}


Measured memory_bytes: 2588
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N =Integer.parseInt(scan.next());
		if(N<=111) {
			System.out.println(111);
		}else if(N<=222) {
			System.out.println(222);
		}else if(N<=333) {
			System.out.println(333);
		}else if(N<=444) {
			System.out.println(444);
		}else if(N<=555) {
			System.out.println(555);
		}else if(N<=666) {
			System.out.println(666);
		}else if(N<=777) {
			System.out.println(777);
		}else if(N<=888) {
			System.out.println(888);
		}else if(N<=999) {
			System.out.println(999);
		}
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define int ll

using namespace std;

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

const int INF = 1e9 + 7;

int f(int a) {
	if(a < 1)
		return 0;
	if(a == 1) 
		return 1;
	if(a == 2)
		return 3;
	int ans = 0;
	while(a % 4 != 3) {
		ans ^= a--;
	} 
	return ans;
}

int32_t main()
{
	IO_OP;
	
	int a, b, ans = 0;
	cin >> a >> b;
	cout << (f(b) ^ f(a-1)) << endl;
	
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define irep(i, n) for(int i = n-1; i >= (int)0; i--)
#define erep(i,container) for (auto i : container)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int a,b,c,d;
    std::cin >> a>>b>>c>>d;
    if(a==c)std::cout << 0 << std::endl;
    else std::cout << 1 << std::endl;
}



Measured memory_bytes: 256
mod = 10 ** 9 + 7
n = gets.to_i
a = gets.split.map{|e| e.to_i.to_s(2).to_i}
h = Array.new(61, 0)
x = 0

n.times do |i|
    x += a[i]
    next if i % 9 != 0
    x = x.to_s.reverse
    x.size.times do |j|
        h[j] += x[j].to_i
    end
    x = 0
end

x = x.to_s.reverse
x.size.times do |i|
    h[i] += x[i].to_i
end

ans = 0
binary = [1]
60.times {|i| binary[i+1] = (binary[i] * 2) % mod}
h.each_with_index do |value, index|
    ans = (ans + binary[index] * value * (n - value)) % mod
end

puts ans


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

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

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

        if x == y:
            return

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

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

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

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

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

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

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

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

N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
if K == 1:
    print(max(C))
    import sys
    sys.exit()
uf = UnionFind(N)
for i in range(N):
    uf.union(i, P[i]-1)

ans = -float("inf")
for x in uf.all_group_members().values():
    n = len(x)
    m_score = [-float("inf")] * (n+1)
    m_score[0] = 0
    sum_c = 0
    for i in x:
        tmp_score = 0
        tmp_pos = i
        sum_c += C[i]
        for j in range(n):
            tmp_pos = P[tmp_pos]
            tmp_pos -= 1
            tmp_score += C[tmp_pos]
            m_score[j+1] = max(tmp_score, m_score[j+1])
    if sum_c <= 0:
        ans = max(max(m_score[1:]), ans)
    elif K <= n:
        ans = max(ans, max(m_score[1:K+1]))
    elif K % n == 0:
        ans = max(sum_c * (K//n-1) + max(m_score[1:]), ans) 
    else:
        ans = max(sum_c * (K//n) + max(m_score[:(K%n)+1]), ans)
print(ans)

Measured memory_bytes: 72124
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	int a , b ;
	cin >> a >> b; 
	if(a>=13) cout << b << endl;
	if(a>=6 and a<=12) cout << b/2 << endl; 
	if(a<=5) cout << 0 << endl;
	
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3656
N=int(input())
L=list(map(int,input().split()))

tn = len(list (filter (lambda x: x%2==0 and x%4!=0,L )))
tf = len(list(filter(lambda x: x%4==0,L)))

if tn==0 and (N-tn)//2 <= tf:
  print('Yes')
elif tn!=0 and 2*tf >= N-tn:
  print('Yes')
else: 
  print('No')

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
int main()
{
        int N, K;
        cin >> N >> K;
        cin.ignore();
        vector<int> num;
        for(int i=0; i < N; i++){
                int val;
                cin >> val;
                num.push_back(val);
        }
        sort(num.begin(), num.end());
        int sum=0;
        for(int i=0; i < K; i++){
                sum += num[i];
        }
        cout<<sum<<"\n";

  return 0;
}


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

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

using vi = vector<int>;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define show(x) cout << #x << " = " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define YesNo {cout<<"Yes";}else{cout<<"No";}
#define YESNO {cout<<"YES";}else{cout<<"NO";}
#define v(T) vector<T>

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> bool lcmp(const pair<T, T>& l, const pair<T, T>& r) {
  return l.first < r.first;
}
template<class T> istream& operator>>(istream& i, v(T)& v) {
  F0R(j, sz(v)) i >> v[j];
  return i;
}
template<class A, class B> istream& operator>>(istream& i, pair<A, B>& p) {
  return i >> p.first >> p.second;
}
template<class A, class B, class C> istream& operator>>(istream& i, tuple<A, B, C>& t) {
  return i >> get<0>(t) >> get<1>(t) >> get<2>(t);
}
template<class T> ostream& operator<<(ostream& o, const vector<T>& v) {
  F0R(i, v.size()) {
    o << v[i] << ' ';
  }
  o << newl;
  return o;
}
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& m) {
  for (auto& p : m) {
    o << p.first << ": " << p.second << newl;
  }
  o << newl;
  return o;
}

#if 1

class UnionFind {
public:
  UnionFind(int size) : size(size) {

    par = vector<int>(size, -1);
  }

  int GetRoot(int v) {
    int root = v;
    while (par[root] >= 0) {
      root = par[root];
    }
    if (root != v) {
      par[v] = root;
    }
    return root;
  }

  bool IsUnion(int a, int b) {
    int ra = GetRoot(a), rb = GetRoot(b);

    return ra == rb && ra >= 0;
  }

  int GetUnionSize(int a) {
    return -par[GetRoot(a)];
  }

  void Unite(int a, int b) {
    int ra = GetRoot(a), rb = GetRoot(b);

    if (ra == rb) return;

    if (GetUnionSize(ra) > GetUnionSize(rb)) {
      par[ra] += par[rb];
      par[rb] = ra;
    }
    else {
      par[rb] += par[ra];
      par[ra] = rb;
    }
  }

protected:

  // 親がいれば、親のindexを入れる
  // 親がいなければ、グループのサイズを負にして入れておく（一人なら-1）
  vector<int> par;

  int size;
};

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;

  UnionFind uf(N);
  F0R(i, M) {
    int a, b;
    cin >> a >> b;
    uf.Unite(a - 1, b - 1);
  }
  set<int> s;
  F0R(i, N) {
    s.insert(uf.GetRoot(i));
  }
  cout << (s.size() - 1);
}
#endif


Measured memory_bytes: 7660