akhauriyash/Code-Regression huggingface dataset:
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const A = readLong();
      const B = readLong();
      const C = readLong();
      // 2 sqrt(A B) < C - A - B
      bool ans = (0 < C - A - B && 4 * A * B < (C - A - B)^^2);
      writeln(ans ? "Yes" : "No");
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(ll, A, B, C);
  if ((A % 2 == 0 && B % 2 == 0 && C % 2 == 0) && A == B && B == C) {
    print(-1);
    return;
  }
  ll ans = 0;
  while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
    ll a = A / 2;
    ll b = B / 2;
    ll c = C / 2;
    A = b + c;
    B = a + c;
    C = a + b;
    ans++;
  }
  print(ans);
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	nums, k := nextInts(3), uint(nextInt())
	sort.Sort(sort.IntSlice(nums))
	ans := nums[0] + nums[1] + int(nums[2]<<k)
	fmt.Println(ans)
}


Measured memory_bytes: 640
N, M = map(int, input().split())

k = []
k_bit = []

for i in range(M):
    arr = list(map(int, input().split()))
    arr.pop(0)
    k.append(arr)
    val = 0
    for e in arr:
        val += 2 ** (e - 1)
    k_bit.append(val)

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

result = 0

for i in range(2 ** N):
    judge = True
    for j in range(M):
        ret = i & k_bit[j]
        on = 0
        for k in range(10):
            on += (ret >> k) % 2
        on = on % 2
        if (on != p[j]):
            judge = False
    if (judge):
        result += 1

print(result)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
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 T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> l(C);
    cin >> l;
    priority_queue<pii> pq;
    REP(i, N) {
        int c, w;
        cin >> c >> w;
        c--;
        pq.push({w, c});
    }
    int ans = 0;
    while (!pq.empty()) {
        auto ball = pq.top(); pq.pop();
        if (M > 0 && l[ball.second] > 0) {
            l[ball.second]--;
            ans += ball.first;
            M--;
        }
    }
    cout << ans << endl;
    return 0;
}




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

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

    long long cnt = 0, ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'B') cnt++;
        else ans += cnt;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)1000000007
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;

int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     ll n;
     cin >> n;
     ll sum = 0;
     for (ll i = 1; i <= n; i++)
     {
          if (i % 3 && i % 5)
          {
               sum += i;
          }
     }
     cout << sum << endl;
}


Measured memory_bytes: 3640
A,B,H,M = gets.split.map(&:to_i)

arad = (H*60+M)/(12*60.0) * Math::PI * 2
brad = M/60.0 * Math::PI * 2

puts((A**2+B**2-2*A*B*Math.cos((arad-brad).abs))**0.5)

Measured memory_bytes: 14868
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 100100

int n,k,a[N];

int main(){
	scanf("%d%d",&n,&k);
	for (int i=1; i<=n; i++)
		scanf("%d",&a[i]);
	int ans=(n-1)/(k-1);
	if ((n-1)%(k-1)!=0) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return (kai(n - 1)*n) % INF;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int mystoi(string s) {
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		cnt += (int)(s[i] - '0') * pow(10, s.size() - i - 1);
	}
	return cnt;
}
string s, t;
int cnt;
signed main() {
	cin >> s;
	for (int i = 0; i < (1 << s.size() - 1); i++) {
		for (int j = s.size() - 2; j >= 0; j--) {
			t += s[s.size() - j - 2];
			if ((i >> j) & 1) {
				cnt += mystoi(t);
				t = "";
			}
		}
		t += s[s.size() - 1];
		cnt += mystoi(t);
		t = "";
	}
	cout << cnt << endl;
	endre;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

int a[100010], dead[100010], cnt[100010], ans;
vector<int> v[100010], in[100010];

void dfs(int now, int rt) {
    in[rt].pb(now); dead[now] = 1;
    for (auto x: v[now]) if (!dead[x]) dfs(x, rt);
}

int main() {
    ios_base::sync_with_stdio(0);
    int n, m; cin >> n >> m;
    for (int i=1;i<=n;i++) cin >> a[i];
    for (int i=0;i<m;i++) {
        int x, y; cin >> x >> y;
        v[x].pb(y); v[y].pb(x);
    }
    for (int i=1;i<=n;i++) if (!dead[i]) dfs(i, i);
    for (int i=1;i<=n;i++) if (in[i].size()) {
        for (auto j: in[i]) cnt[j]++;
        for (auto j: in[i]) {
            cnt[a[j]]++;
            if (cnt[a[j]]==2) ans++;
        }
        for (auto j: in[i]) cnt[j]--, cnt[a[j]]--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 12792
import Control.Monad
import Text.Printf
import Control.Applicative

main :: IO()
main = do
  [a, b, c, d] <- map read . words <$> getLine
  let abDist = abs (a - b)
      bcDist = abs (b - c)
      acDist = abs (a - c) 
  printf "%s" $ if d >= minimum [acDist, maximum [bcDist, abDist]] then "Yes" else "No"


Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <iterator>
#include <utility>
#include <iomanip>
#include <stack>
#include<bitset>
#include <cmath>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > >pq;
vector<ll>adj[1000005];
ll expo(ll b,ll n,ll m)
{
 ll r,p;
	p=1;
	 b=b%m;
	while(n>0)
	{ 
		r=n%2;
		if(r==1)
		   p=((p)*(b))%m;
		b=((b)*(b))%m; 
		n=n/2;		
	}
 return (p%m);
}
ll divide1(ll a,ll b,ll m)
	{ ll r,p,n;
			p=a%m;
				n=m-2;
				while(n>0){
						 r=n%2;
						if(r==1)
							p=((p%m)*(b%m))%m;
						b=((b%m)*(b%m))%m; 
						n=n/2;	
					}
	return (p%m); }
int main(int argc, char const *argv[])
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	string s;
	cin>>s;
	ll ans=0;
	for (int i = 0; i < 3; i++)
	{
		ll curr=0;
		for (int j = i; j < 3 and s[j]=='R'; j++)
		{
			++curr;
		}
		ans = max(ans, curr);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 27088
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

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

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

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

vector<int> G[200010];
int d[200010];

void dfs(int v,int par){
	for(int to : G[v]){
		if(to != par){
			d[to] = d[v] + 1;
			dfs(to,v);
		}
	}
}

signed main(){
	int n;
	cin >> n;
	for(int i = 0;i < n - 1;i++){
		int a,b;
		cin >> a >> b; a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(0,-1);
	int cnt[2] = {};
	for(int i = 0;i < n;i++) cnt[d[i] % 2]++;
	int p[3] = {1,2,3},ans[200010];

	for(int i = 0;i < n;i++){
		int ind;
		if(cnt[0] >= n / 3 + 1 && cnt[1] >= n / 3 + 1){
			ind = d[i] % 2;
			if(p[ind] > n) ind = 2;
		}else{
			if(cnt[d[i] % 2] <= n / 3) ind = 2;
			else ind = d[i] % 2;
			if(p[ind] > n) ind = !ind;
			if(p[ind] > n) ind = 2;
		}
		ans[i] = p[ind];
		p[ind] += 3;
	}
	for(int i = 0;i < n;i++) printf("%lld%c",ans[i]," \n"[i == n - 1]);
}

Measured memory_bytes: 20224
import java.util.*;


public class Main {
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
//        int k = sc.nextInt();
//        int a = sc.nextInt();
//        int b = sc.nextInt();
        sc.close();
//        System.out.println(s);
        if(s.contains("RRR")){
            System.out.println(3);
        }else if(s.contains("RR")){
            System.out.println(2); 
        }else if(s.contains("R")){
            System.out.println(1);
        }else{
             System.out.println(0);
        }
//        String s = sc.nextLine();
//        String t = sc.next();
//        String[] arr =  s.split("　");
//        sc.close();
//        System.out.println("input: "+ s);
//        System.out.println("k:" + k);
//        System.out.println("a:" + a);
//        System.out.println("b:" + b);
//        String ans = "NG";
//        for(int x = a; x<=b; x++){
//            if(x%k == 0){
//                ans = "OK";
//            }
//        }
//        System.out.println(ans);
//        \
//        System.out.println("arr[1]:" + arr[1]);
//
//        if(s.equals("ABC")){
//            System.out.println("ARC");
//        }else{
//            System.out.println("ABC");
//        }
//        String[] arr1 =  s.split("");
//        String[] arr2 =  t.split("");
////        List<String> list1 = Arrays.asList(s.split(""));
//        List list1 = new LinkedList(Arrays.asList(s.split("")));
////        List<String> list2 = Arrays.asList(t.split(""));
//        List list2 = new LinkedList(Arrays.asList(t.split("")));
////        int num = Integer.parseInt(arr[arr.length - 1]);
//        list2.remove(arr2.length - 1);
////        System.out.println(list1);
////        System.out.println(list2);
//         if(list1.toString().contentEquals(list2.toString())){
//             System.out.println("Yes");
//         }else{
//             System.out.println("No");
//         }
//        switch(num){
//            case 3:
//                System.out.println("bon");
//                break;
//            case 0:
//            case 1:
//            case 6:
//            case 8:
//                System.out.println("pon");
//                break;
//            default:
//                System.out.println("hon");
//                break;
//        }
//        String[] array = str.split(" ");
//        int sum = 0;
//        for(int i=0; i<array.length; i++) {
//            int num = Integer.parseInt(array[i]);
//            sum += num;
//        }
//        System.out.println(15-sum);
    }
}


Measured memory_bytes: 35364
#include<stdio.h>

int main(void){
	int a[10]={},sw,sk,i,j,c;
	sw=0;
	sk=0;
	for(i=0;i<10;i++){
		scanf("%d",&a[i]);
	}
	for(i=9;i>0;i--){
		for(j=0;j<i;j++){
			if(a[j]<a[j+1]){c=a[j];a[j]=a[j+1];a[j+1]=c;}
		}
	}
    sw=a[0]+a[1]+a[2];
	for(i=0;i<10;i++){
		scanf("%d",&a[i]);
	}
	for(i=9;i>0;i--){
		for(j=0;j<i;j++){
			if(a[j]<a[j+1]){c=a[j];a[j]=a[j+1];a[j+1]=c;}
		}
	}
    sk=a[0]+a[1]+a[2];
	printf("%d %d\n",sw,sk);
    return 0;
}

Measured memory_bytes: 1852
#include <bits/stdc++.h>
using namespace std;
#define lor(a,b,c) for(register int a=b;a<=c;++a)
#define ror(a,b,c) for(register int a=c;a>=b;--a)

const int N=1e5+5;

int n,a[N];

inline bool judge(int x,int y){
	return y==a[x]||y>=a[x+1];
}

inline bool cmp(int a,int b) {return a>b;}

int main(){
	scanf("%d",&n); lor(i,1,n) scanf("%d",&a[i]); sort(a+1,a+1+n,cmp); a[0]=a[1];
	int x=0,y=0;
	while(x+1<=n&&y+1<=a[x+1]&&!judge(x+1,y+1)) ++x,++y;
	bool flag=false;
	int tar=a[x]; if(x+1<=n) tar=min(tar,a[x+1]);
	if(((tar-x)&1)==0) flag=true;
	int cnt=0; while(x+1<=n&&!judge(x+1,y)) ++x,++cnt; if(cnt&1) flag=true;
	puts(flag?"First":"Second");
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

std::vector< int64_t > divisor(int64_t n) {
  std::vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  std::sort(begin(ret), end(ret));
  return (ret);
}

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

  std::vector<long long> as;
  for(int i=0; i<N; i++)
  {
    long long a;
    std::cin >> a;
    as.push_back(a);
  }

  const long long sum = std::accumulate(as.begin(), as.end(), 0LL);
  const auto divisors = divisor(sum);

  for(auto it=divisors.rbegin(); it!=divisors.rend(); it++)
  {
    std::vector<long long> remains;
    for(int i=0; i<as.size(); i++)
    {
      long long rem = as[i]%*it;
      if(rem != 0 ) { remains.push_back(as[i]%*it); }
    }
    std::sort(remains.begin(), remains.end());
    if( remains.empty() ) { std::cout << *it; return 0; }
    if( remains.size()==1 ) { continue; }

    std::vector<long long> accumMinus(remains.size());
    accumMinus[0] = remains.front();
    for(int i=1; i<remains.size(); i++)
    {
      accumMinus[i] = accumMinus[i-1] + remains[i];
    }

    std::vector<long long> accumPlus(remains.size());
    accumPlus[remains.size()-1] = *it - remains.back();
    for(int i=remains.size()-2; 0<=i; i--)
    {
      accumPlus[i] = accumPlus[i+1] + *it - remains[i];
    }

    for(int i=0; i<accumPlus.size(); i++)
    {
      if(accumPlus[i]<=accumMinus[i])
      {
        if( accumMinus[i-1] <= K ) { std::cout << *it; return 0; }
        break;
      }
    }
  }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        sc.close();

        int sum = 0;
        for (int i = 0; i < N.length(); ++i) {
            String w = N.substring(i, i + 1);
            sum += Integer.parseInt(w);
        }

        int NN = Integer.parseInt(N);
        if (NN % sum == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
	}
}


Measured memory_bytes: 23508
#include <stdio.h>
 
int main(){
  int H;
  int N;
  scanf("%d",&H);
  scanf("%d",&N);
  int x[N];
  int sum=0;
  for (int i=0;i<N;i++) {
    scanf("%d",&x[i]);
    sum+=x[i];
  }
  if(sum>=H){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

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

using namespace std;

int main(){
	ios::sync_with_stdio(false);                     
	int n,l;
	cin >> n >> l;
	vector <string> v(n);
	for (auto &x: v){
		cin >> x;
	}
	sort(v.begin(),v.end());
	for(auto x: v){
		cout << x;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);
#define mem(a,b) memset(a, b, sizeof(a) )
#define MOD 1000000007
typedef long long ll;

int main()
{
    optimize();
    //file();
    int x,y,i,c=0,d=0;
    vector<int>v= {1,3,5,7,8,10,12},v1= {4,6,9,11};
    cin>>x>>y;
    for(i=0; i<7; i++)
    {
        if(v[i]==x)
            c++;
        if(v[i]==y)
            d++;
    }
    if(c>0&&d>0)
        cout<<"Yes\n";
    else
    {
        c=0;
        d=0;
        for(i=0; i<4; i++)
        {
            if(v1[i]==x)
                c++;
            if(v1[i]==y)
                d++;
        }
        if(c>0&&d>0)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 3624
def solve(n, T, m, PX):
    return [sum(x if i + 1 == p else t for i, t in enumerate(T)) for (p, x) in PX]

_n = int(input())
_T = list(map(int, input().split()))
_m = int(input())
_PX = [map(int, input().split()) for _ in range(_m)]
print(*solve(_n, _T, _m, _PX), sep='\n')

Measured memory_bytes: 3060
// AtCoder Regular Contest 080
// D - Grid Coloring

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;


const int MAX_H = 100;
const int MAX_W = 100;
const int MAX_N = MAX_H * MAX_W;

int H, W;
int N;
int a[MAX_N + 1];
int ans[MAX_H][MAX_N];

int main() {

    int color, h, w;

    cin >> H >> W;
    cin >> N;
    a[0] = 0;
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
        a[i] += a[i - 1];
    }

    color = 0;
    for (int idx = 0; idx < H * W; idx++) {
        if (a[color] <= idx) {
            color++;
        }
        h = idx / W;
        w = ((h % 2 == 0) ? (idx % W) : (W - 1 - idx % W));
        ans[h][w] = color;
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << ans[i][j];
            cout << (j == W - 1 ? '\n' : ' ');
        }
    }

    return 0;

}





Measured memory_bytes: 768
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
//#define N 1000000007

using namespace std;

int main(){
    lli n,a;
    string ans;
    lli i;
    vector<lli> four,two;
    cin>>n;
    rep(i,0,n){
        cin>>a;
        if(a%2==0){
            if(a%4==0){
                four.push_back(a);
            }
            else{
                two.push_back(a);
            }
        }
    }
//    cout<<four.size()<<" "<<two.size()<<endl;
    if((two.size()==0)&&(n-four.size()==four.size()+1)){
        ans="Yes";
    }
    else{
        if(n-four.size()-two.size()<=four.size()){
            ans="Yes";
        }
        else{
            ans="No";
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1400
#include <iostream>
using namespace std;
int main() {
    int a,b;
    cin >> a >> b ;
    int start = b - a +1 ;
    cout << start ;
    if(a%1 == 0){
    for(int i =0 ; i < (a-1)*2;i++)
    {
         start = start +1;
         cout<< " "<<start;
    }
    }else {
        for(int i =0 ; i < (a-1)*2+1;i++)
        {
            start = start +1;
            cout<< " "<<start;
        }
    }
    cout<<endl;
    return  0;
}


Measured memory_bytes: 256
import math

def calc_dist(x, y):
    if x > 0 and y > 0:
        result = abs(x) - abs(y)
    elif x < 0 and y > 0:
        result = abs(x) + abs(y)
    elif x > 0 and y < 0:
        result = abs(x) + abs(y)
    elif x < 0 and y < 0:
        result = abs(x) - abs(y)
    elif x == 0 or y == 0:
        result = abs(x) + abs(y)
    return abs(result)

x1, y1, x2, y2 = map(float, input().split())
dist1 = calc_dist(x1, x2)
dist2 = calc_dist(y1, y2)
dist3 = math.sqrt(dist1**2 + dist2**2)
print('{:.8f}'.format(dist3))



Measured memory_bytes: 5660
MAX_INT = 10**5+1
primes = [True] * (10**5+1)
primes[0], primes[1] = False, False
for i in range(2, int(MAX_INT**0.5)+1):
  if primes[i]:
    for j in range(i*2, MAX_INT, i):
      primes[j] = False

cumsum = [0] * (10**5+1)
for i in range(1, 10**5+1, 2):
  if primes[i] and primes[(i+1)//2]:
      cumsum[i] = 1

for i in range(1, 10**5+1):
  cumsum[i] += cumsum[i-1]

Q = int(input())
for _ in range(Q):
  l,r = map(int,input().split())
  print(cumsum[r]-cumsum[l-1])

Measured memory_bytes: 78820
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        X: chars,
    }
    let mut stack = vec![];
    let mut cur = 0;
    let mut s_cnt = 0;
    let mut rm_cnt = 0;
    let mut s_con = false;

    for &c in &X {
        match c {
            'S' => stack.push(c),
            'T' => {
                if let Some(&'S') = stack.last() {
                    stack.pop();
                } else {
                    stack.push(c)
                }
            }
            _ => panic!(),
        }
    }
    println!("{}", stack.len());
}


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

#define     bip(a)         __builtin_popcount(a)
#define     ull            unsigned long long
#define     ll             long long
#define     u              unsigned
#define     pb             push_back
#define     pf             push_front ///for list
#define     mp             make_pair
#define     is             insert
#define     ff             first
#define     ss             second
#define     vi             vector<int>
#define     vl             vector<ll>
#define     si             set<int>
#define     sl             set<ll>
#define     li             list<int>
#define     pii            pair<int,int>
#define     pll            pair<ll,ll>
#define     mii            map<int,int>
#define     mll            map<ll,ll>
#define     ma             INT_MAX
#define     mi             INT_MIN
#define     mod            1000000007
#define     pi             3.14159265359
#define     e              2.71828182846
#define     inf            1000000000000000LL
#define     all(x)         x.begin(), x.end()
#define     lb(a,b,c)      lower_bound(a,a+b,c)-a
#define     ub(a,b,c)      upper_bound(a,a+b,c)-a
#define     lbv(a,c)       lower_bound(all(a),c)-a.begin()
#define     ubv(a,c)       upper_bound(all(a),c)-a.begin()
#define     srt1(a,b)      sort(a,a+b)
#define     srt2(a,b)      sort(a,a+b,greater<int>())
#define     gcd(a,b)       __gcd(a,b)
#define     lcm(a,b)       (a*(b/gcd(a,b)))
#define     harmonic(n)    0.57721566490153286l+log(n)
#define     mem(a, b)      memset(a, b, sizeof(a))

///s.lower_bound(a),s.upper_bound(a), for set
///nCr(x, y) = nCr(x-1, y-1) + nCr(x-1, y)
///factorial digit   ((n * log10(n / e) +log10(2 * pi * n) /2.0));

double clock_angle(double h, double m)
{
    if (h == 12) h = 0;
    if (m == 60) m = 0;
    double hour_angle = 0.5 * (h * 60 + m);
    double minute_angle = 6 * m;
    double angle = abs(hour_angle - minute_angle);
    angle = min(360 - angle, angle);
    return angle;
}

int main()
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double angle=clock_angle(h,m);
    angle=(angle*pi)/180;
    cout<<fixed<<setprecision(20)<<sqrt(a*a+b*b-2*a*b*cos(angle))<<endl;
}



Measured memory_bytes: 4212
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

//block linked list
#define Bsize 900 /*2sqrt(n)*/
typedef struct block{
	int cnt;
	ll a[Bsize+1];
	struct block*pre;
	struct block*nxt;
}block;
void Bpush(block*b,ll x){
	//リストにxを追加する
	if((*b).nxt&&(*(*b).nxt).a[0]<x){
		//次へ
		Bpush((*b).nxt,x);
		return;
	}
	int i=(*b).cnt;
	for(;i>0&&(*b).a[i-1]>x;i--)(*b).a[i]=(*b).a[i-1];
	(*b).a[i]=x;
	(*b).cnt++;
	if((*b).cnt>=Bsize){
		//分割
		block*nn=(block*)malloc(sizeof(block));
		(*nn).cnt=Bsize-Bsize/2;
		rep(i,0,Bsize-Bsize/2)(*nn).a[i]=(*b).a[i+Bsize/2];
		(*nn).pre=b;
		(*nn).nxt=(*b).nxt;
		if((*b).nxt)(*(*b).nxt).pre=nn;
		(*b).cnt=Bsize/2;
		(*b).nxt=nn;
	}
}
ll Bans(block*b,int k){
	//リストのk番目を返す
	//リストにk個未満しかなければ適当に返す
	if((*b).cnt<=k){
		if((*b).nxt)return Bans((*b).nxt,k-(*b).cnt);
		else return -1;
	}
	return (*b).a[k];
}
void con(block*p,block*q){
	//qをpにマージしてqを消す
	rep(i,0,(*q).cnt)(*p).a[(*p).cnt+i]=(*q).a[i];
	(*p).cnt+=(*q).cnt;
	(*p).nxt=(*q).nxt;
	if((*q).nxt)(*(*q).nxt).pre=p;
	free(q);
}
int Bdel(block*b,int k){
	//リストからkを(存在すれば)1個削除する
	//存在すれば1、しなければ0を返す
	if((*b).cnt==0||(*b).a[(*b).cnt-1]<k){
		if((*b).nxt)return Bdel((*b).nxt,k);
		else return 0;
	}
	int i=0;
	for(;(*b).a[i]<k;i++);
	if((*b).a[i]!=k)return 0;
	for(;i<(*b).cnt-1;i++)(*b).a[i]=(*b).a[i+1];
	(*b).cnt--;
	
	if((*b).cnt==0&&(*b).pre){
		(*(*b).pre).nxt=(*b).nxt;
		if((*b).nxt)(*(*b).nxt).pre=(*b).pre;
		free(b);
	}else if((*b).pre&&(*(*b).pre).cnt+(*b).cnt<Bsize/4){
		//まとめる
		rep(i,0,(*b).cnt)(*(*b).pre).a[(*(*b).pre).cnt+i]=(*b).a[i];
		(*(*b).pre).cnt+=(*b).cnt;
		(*(*b).pre).nxt=(*b).nxt;
		if((*b).nxt)(*(*b).nxt).pre=(*b).pre;
		free(b);
	}else if((*b).nxt&&(*(*b).nxt).cnt+(*b).cnt<Bsize/4)con(b,(*b).nxt);
	return 1;
}


ll a[400010],x[200010];
int c(const void*p,const void*q){
	if(a[*(ll*)p]<a[*(ll*)q])return -1;
	return 1;
}
block b;
ll idx[400010];
int main(){
	ll n,q;
	scanf("%lld%lld",&n,&q);
	rep(i,0,n){
		ll s,t;
		scanf("%lld%lld%lld",&s,&t,x+i);
		a[2*i  ]=s-x[i];
		a[2*i+1]=t-x[i];
	}
	rep(i,0,2*n)idx[i]=i;
	qsort(idx,2*n,sizeof(ll),c);
	
	ll crr=0;
	rep(_,0,q){
		ll d;
		scanf("%lld",&d);
		while(crr<2*n&&a[idx[crr]]<=d){
			if(idx[crr]%2)Bdel(&b,x[idx[crr]/2]);
			else Bpush(&b,x[idx[crr]/2]);
			crr++;
		}
		printf("%lld\n",Bans(&b,0));
	}
}


Measured memory_bytes: 11132
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
#define MOD_BIG2 998244353
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using std::vector;

template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

//////////////////////////////////////

//////////////////////////////////////

int main() {
    
    ll N;
    cin >> N;
    
    vector<ll> A(N);
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    
    ll lmin = 0;
    ll tmp = 0;
    ll ans = sum;
    for (int i = 0; i < N; i++) {
        lmin++;
        tmp += A[i];
        ans = std::min(ans, std::abs(2*tmp - sum));
        if (tmp > sum/2) {
            break;
        }
    }
    ans = std::min(ans, std::abs(2*tmp - sum));
    
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    string a[n];
    int k=1;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0; i<n-1; i++)
    {
       if(a[i].compare(a[i+1])!=0)
       {
           k++;
       }
    }
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 9884
import java.util.*;

public class Main {

    public static List<List<Integer>> switchList;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int P = sc.nextInt();
        int Q = sc.nextInt();
        int R = sc.nextInt();
        sc.close();

        int[] array = new int[3];
        array[0] = P;
        array[1] = Q;
        array[2] = R;

        Arrays.sort(array);

        System.out.println(array[0] + array[1]);
    }

}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> p2;
ll n;
vector<string> v;
void func(ll k){
  if(k==n)
    return;
  vector<string> temp;
  
  for(ll i=0;i<v.size();i++){
    string t=v[i];
    ll cnt=0;
    vector<ll> vis(26,0);
    for(ll j=0;j<t.length();j++){
      if(!vis[ll(t[j]-'a')])
        cnt++;
      vis[ll(t[j]-'a')]=1;
    }
    for(ll j=0;j<=min(k,cnt);j++){
      string s=v[i];
      s.push_back(char('a'+j));
      temp.push_back(s);
    }
  }
  v=temp;
  func(k+1);
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin>>n;
  v.push_back("a");
  func(1);
  for(ll i=0;i<v.size();i++)
    cout<<v[i]<<endl;
}

Measured memory_bytes: 9496
#include<cstdio>
int main(void){
int w,h,x,y,r;
scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
if(0<=x-r&&0<=y-r&&x+r<=w&&y+r<=h)printf("Yes\n");
else printf("No\n");
return 0;
}

Measured memory_bytes: 2692
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        int n = Read.Int();
        int[] a = Read.ints();
        int[] b = Read.ints();
        int max = int.MinValue;
        for (int i = 0; i < n; i++)
        {
            int thisd = 0;
            for (int j1 = 0; j1 <= i; j1++)
            {
                thisd += a[j1];
            }
            for (int j2 = i; j2 < n; j2++)
            {
                thisd += b[j2];
            }
            max = Math.Max(max,thisd);
        }
        Console.WriteLine(max);
        Console.ReadLine();
      Console.ReadLine();
    }
    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
 
        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                // 素数ではない
                return false;
            }
        }
 
        // 素数である
        return true;
    }
}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long() { return long.Parse(Console.ReadLine()); }
    public static long[] longs() { return Console.ReadLine().Split().Select(long.Parse).ToArray(); }
    public static int Int() { return int.Parse(Console.ReadLine()); }
    public static int[] ints() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13396
import bisect

s = input()
t = input()
ls = len(s)
sets = set(s)
sett = set(t)
ind = [[] for _ in range(26)]
temp = 0
ans = 0
if sett.issubset(sets) == False:
    print('-1')
else:
    for i in range(ls):
        ind[ord(s[i])-97].append(i+1)
    for x in t:
        if temp >= ind[ord(x)-97][-1]:
            ans += ls - temp + ind[ord(x)-97][0]
            temp = ind[ord(x)-97][0]
        else:
            bs = bisect.bisect_right(ind[ord(x)-97],temp)
            ans += ind[ord(x)-97][bs] - temp
            temp = ind[ord(x)-97][bs]
    print(ans)

Measured memory_bytes: 7540
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int D, N, M;
int DD[100001];
int K[10000];
int ans = 0;
int main()
{
	while (true){
		ans = 0;
		scanf("%d", &D);
		if (D == 0)break;
		scanf("%d", &N);
		scanf("%d", &M);
		for (int i = 1; i < N; i++)scanf("%d", &DD[i]);
		sort(DD, DD + N);
		DD[N] = D;
		for (int i = 0; i < M; i++)scanf("%d", &K[i]);
		for (int i = 0; i < M; i++){
			int l1 = 0, r1 = N + 1;
			while (r1 - l1 > 1){
				int c1 = (l1 + r1) / 2;
				if (DD[c1] <= K[i])l1 = c1;
				else r1 = c1;
			}
			ans += min(K[i] - DD[l1], DD[l1 + 1] - K[i]);
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1632
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int n,a[101],count=0;
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i];
	for(int i=0; i<n; i++){
		if(a[i] == a[i+1]){
			count++;
			a[i+1] = -1;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
const int inf = 1e9;
struct key{
    int cost;
    int box;
} k[1005];
int n;
int cs[1 << 12];

int main() {
    int m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        k[i].box = 0;
    }
    int mx = (1 << n) - 1;
    for (int i = 1; i <= mx; i++) {
        cs[i] = inf;
    }
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        k[i].cost = a;
        int tmp;
        for (int j = 0; j < b; j++) {
            scanf("%d", &tmp);
            k[i].box += 1 << (tmp - 1);
        }
        cs[k[i].box] = min(cs[k[i].box], a);
    }
    for (int i = 0; i < m; i++) {
        for (int j = 1; j <= mx; j++) {
            int uni = k[i].box | j;
            if (cs[j] != inf && uni != j) {
                cs[uni] = min(cs[uni], cs[j] + k[i].cost);
            }
        }
    }
    if (cs[mx] != inf) cout << cs[mx];
    else cout << -1;
}



Measured memory_bytes: 3752
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

#define MAX_N 200000

using namespace std;

typedef pair<long long int, int> P;

long long int INF = 100000000000000000LL;

int par[MAX_N];
int rnk[MAX_N];

void init(int n){
	for(int i = 0; i < n; i++){
		par[i] = i;
		rnk[i] = 0;
	}
}

int find(int x){
	if(par[x] == x){
		return x;
	}
	return par[x] = find(par[x]);
}

void unite(int x, int y){
	int x_par = find(x);
	int y_par = find(y);
	if(x_par == y_par){
		return;
	}
	
	if(rnk[x_par] < rnk[y_par]){
		par[x_par] = y_par;
	}else{
		par[y_par] = x_par;
		if(rnk[x_par] == rnk[y_par]){
			rnk[x_par]++;
		}
	}
}

bool same(int x, int y){
	return (find(x) == find(y));
}

int main(){
	
	int N, M;
	cin >> N >> M;
	
	init(N + 1);
	
	for(int i = 0; i < M; i++){
		int n, m;
		cin >> n >> m;
		unite(n, m);
	}
	
	long long int c1 = 0;
	long long int c2 = 0;
	long long int c3 = 0;
	
	for(int i = 1; i <= N; i++){
		if(find(i) == find(1)){
			c1++;
		}else if(find(i) == find(2)){
			c2++;
		}else{
			c3++;
		}
	}
	
	//cout << c1 << c2 << c3 << endl;
	
	cout << min(c1, c2) * (min(c1, c2) - 1) / 2 + (max(c1, c2) + c3) * (max(c1, c2) + c3 - 1) / 2 - M << endl;;
	
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
using namespace std;
int a[205];
int main(){
	int i;
	int n;
	int ans=0;
	
	scanf("%d", &n);
	for(i=1; i<=n; i++)
		scanf("%d", &a[i]);
	while(1){
		for(i=1; i<=n; i++){
			if(a[i]&1)
				break;
			a[i]>>=1;
		}
		if(i<=n)
			break;
		ans++;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
def countave(n , a):
    ans = 100000000000000

    for i in range(2):
        kei = 0
        forans = 0
        for w in range(n):
            if (w + i) % 2:
                if kei + int(a[w]) > -1:
                    forans += abs(kei + int(a[w])) + 1
                    kei = -1
                else:
                    kei += int(a[w])
            else:
                if kei + int(a[w]) < 1:
                    forans += abs(kei + int(a[w])) + 1
                    kei = 1
                else:
                    kei += int(a[w])

        ans = min(ans , forans)

    return ans

def main():
    n = int(input())
    a = list(map(int, input().split()))
    print(countave(n , a))

if __name__ == '__main__':
    main()


Measured memory_bytes: 63216
import sys
import math

f = sys.stdin.readline()
xx = f.split(' ')
x = [int(str) for str in xx]

a = x[0]
aa = a+1
b = x[1]
bb = b+1


x = int(a / 0.08)
xx = int(aa / 0.08)
y = int(b / 0.1)
yy = int(bb / 0.1)


if ( x > y ):
	min = x
	if( x * 0.08 < a):
		min = x + 1
	if( min >= yy):
		print "-1"
	else:
		print min
else:
	min = y
	if( min >= xx):
		print "-1"
	else:
		print min

sys.stdout.flush()

Measured memory_bytes: 2692
s = input()

N = len(s)
if N%2 == 1:
    harf = N//2
    mae = s[:harf]
    usi = s[harf+1:][::-1]
else:
    harf = N//2
    mae = s[:harf]
    usi = s[harf:][::-1]

ans = 0
for i in range(harf):
    if mae[i] != usi[i]:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
    ll int n;
    cin>>n;
    ll int a[n+1];
    for(ll int i=0; i<n; i++)
    cin>>a[i];
    vector<ll int>v;
    for(ll int i=0; i<n; i++){
        if(a[i+1]-a[i]<0){
            v.push_back(abs(a[i+1]-a[i]));
            a[i+1]=a[i+1]+abs(a[i+1]-a[i]);
        }
    }
    ll int x=0;
    for(int i=0; i<v.size(); i++){
        x=x+v[i];
    }
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 6788
#include<bits/stdc++.h>
using namespace std;
typedef __int128 ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
const int maxn=100010;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int t;
ll n,dp[66][44][33][2],dif[66][44][33][2],ans,a,b,c,d;
bool ok[66][44][33],vld[66][44][33][2];
int main(){
	t=read();
	while(t--){
		n=read();a=read();b=read();c=read();d=read();
		ans=9e18;
		int cnt=0;
		ROF(i,60,0) ROF(j,40,0) ROF(k,30,0){
			ull prr=1;
			FOR(l,1,i){
				prr*=2;
				if(prr>2*n) break;
			}
			FOR(l,1,j){
				prr*=3;
				if(prr>2*n) break;
			}
			FOR(l,1,k){
				prr*=5;
				if(prr>2*n) break;
			}
			ok[i][j][k]=false;
			if(prr>2*n) continue;
			cnt++;
			ll pr=prr;
			ok[i][j][k]=true;
			dif[i][j][k][0]=n-n/pr*pr;
			dif[i][j][k][1]=(n/pr+1)*pr-n;
			dp[i][j][k][0]=n/pr*d+i*a+j*b+k*c;
			dp[i][j][k][1]=(n/pr+1)*d+i*a+j*b+k*c;
			if(n%pr==0) dif[i][j][k][1]-=pr,dp[i][j][k][1]-=d;
			FOR(x,i,min(60,i+1)) FOR(y,j,min(40,j+1)) FOR(z,k,min(k+1,30)) if(ok[x][y][z]){
				if(x==i && y==j && z==k) continue;
				dp[i][j][k][0]=min(dp[i][j][k][0],dp[x][y][z][0]+(dif[x][y][z][0]-dif[i][j][k][0])/pr*d);
				dp[i][j][k][0]=min(dp[i][j][k][0],dp[x][y][z][1]+(dif[x][y][z][1]+dif[i][j][k][0])/pr*d);
				dp[i][j][k][1]=min(dp[i][j][k][1],dp[x][y][z][0]+(dif[x][y][z][0]+dif[i][j][k][1])/pr*d);
				dp[i][j][k][1]=min(dp[i][j][k][1],dp[x][y][z][1]+(dif[x][y][z][1]-dif[i][j][k][1])/pr*d);
			}
			else break;
			if(!dif[i][j][k][0]) ans=min(ans,dp[i][j][k][0]);
			if(!dif[i][j][k][1]) ans=min(ans,dp[i][j][k][1]);
			assert(dp[i][j][k][0]>=0);
			assert(dp[i][j][k][1]>=0);
		}
		long long tmp=ans;
		printf("%lld\n",tmp);
	}
}

Measured memory_bytes: 6896
import bisect 
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a = sorted(a)
b = sorted(b)
c = sorted(c)
ans = 0
for i in range(n):
  ans += bisect.bisect_left(a,b[i])*(n-bisect.bisect_right(c,b[i]))
print(ans)

Measured memory_bytes: 23360
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define x first
#define y second

const int N = 1e6 + 10;
const int M = 1e9 + 7;

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

bool a[N], b[N];

int main ()
{
	int n, m, f = 0;
	scanf("%d %d", &n, &m);
	memset(a, 0, sizeof(a));
	memset(b, 0, sizeof(b));
	while(m--){
		int u, v;
		scanf("%d %d", &u, &v);
		if(u > v) swap(u, v);
		if(u == 1){
			b[v] = 1;
			if(a[v] == b[v]) f = 1;
		}
		if(v == n){
			a[u] = 1;
			if(a[u] == b[u]) f = 1;
		}
	}
	
	printf("%s\n", f ? "POSSIBLE" : "IMPOSSIBLE");
	
	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int N, K;
vector<ll>h;
ll dp[330][330];

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

	cin >> N >> K;
	h.resize(N);
	for (int i = 0; i < N; i++)cin >> h[i];
	for (int i = 0; i < 330; i++)for (int j = 0; j < 330; j++)dp[i][j] = inf;

	if (K == N) {
		puts(0);
		return 0;
	}

	ll ans = inf;
	for (int i = 0; i < N; i++) {
		dp[i][1] = h[i];
		for (int j = 2; j <= i+1; j++) {
			for (int k = 0; k < i; k++)dp[i][j] = min(dp[i][j],dp[k][j-1] + max(0LL,h[i]-h[k]));
		}
	}

	for (int i = 0; i < 330; i++) {
		for (int j = 0; j < 330; j++)if (j >= N-K)ans = min(ans,dp[i][j]);
	}
	puts(ans);

	return 0;
}

Measured memory_bytes: 1152