akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); i++)
int main(){
  ios::sync_with_stdio(false);
  ll n;
  cin>>n;
  vector<ll> a(n),b(n),c(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n) cin>>c[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  ll cnt=0;
  for(ll i=0;i<n;i++){
    ll x = (ll)(lower_bound(a.begin(),a.end(),b[i])-a.begin());
    ll y = (ll)(c.end()-upper_bound(c.begin(),c.end(),b[i]));
    cnt+=x*y;
  }
  cout<<cnt<<"\n";


}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,sum=0;
  cin>>N;
  for(int i=1;i<=N;i++){
    string X=to_string(i);
    if(X.size()%2==1)
      sum++;
    }
  cout<<sum<<endl;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c =='e' || c =='o') {
    cout << "vowel" << endl;
  }
  else
    cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

	if (a == b && b == c) {
		cout << "1";
	}
	else if (a == b || b == c || c == a) {
		cout << "2";
	}
	else { cout << "3"; }

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/dsu>
using namespace std;
using namespace atcoder;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9+7;
#define REP(i,j,n) for(int i=j;i<n;i++)
#define rep(i,n) REP(i,0,n)

// 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(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,q;
    cin >> n >> q;

    dsu d(n);
    rep(i,q)
    {
        int t,u,v;
        cin >> t >> u >> v;
        if (t==0)
        {
           d.merge(u, v);
        }
        else
        {
            cout << d.same(u, v) << endl;
        }
    }
    return 0;
}


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


int main(){
	long long int n;
	cin >> n;
	if(n%10==3){
		cout << "bon" << endl;
	}else if(n%10==0||n%10==1||n%10==6||n%10==8){
		cout << "pon" << endl;
	}else{
		cout << "hon" << endl;
	}
}

Measured memory_bytes: 3636
use std::io::*;
use std::str::FromStr;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let r = sc.read();
    let c = sc.read();
    let mat: Vec<Vec<u32>> = (0..r).map(|_| (0..c).map(|_| sc.read()).collect()).collect();
    let mut colsum = vec![0; c];
    for i in 0..r {
        let mut rowsum = 0;
        for j in 0..c {
            print!("{} ", mat[i][j]);
            colsum[j] += mat[i][j];
            rowsum += mat[i][j];
        }
        println!("{}", rowsum);
    }
    let mut sum = 0;
    for i in 0..c {
        print!("{} ", colsum[i]);
        sum += colsum[i];
    }
    println!("{}", sum);
}



Measured memory_bytes: 5052
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
int dx[4]= {-1, 0,1,0};
int dy[4]= { 0,-1,0,1};
int main()
{
    int h,w;
    cin>>h>>w;
    vector<string>S(h);
    for(int i=0; i<h; i++)
        cin>>S[i];

    int ans =0;
    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {
            if(S[i][j]=='#')
                continue;
            queue<PII>Q;
            Q.push(PII(i,j));
            vector<vector<int>> dist(h,vector<int>(w,-1));
            dist[i][j]=0;
            PII cur;
            while(!Q.empty())
            {
                cur=Q.front();
                Q.pop();
                for(int i=0; i<4; i++)
                {
                    int Y = cur.first+dy[i];
                    int X = cur.second + dx[i];
                    if(X>=w || Y>=h || X<0 || Y<0)
                        continue;
                    if(dist[Y][X]!=-1)
                        continue;
                    if(S[Y][X]=='.')
                    {
                        Q.push(PII(Y,X));
                        dist[Y][X]=dist[cur.first][cur.second]+1;
                        ans = max(ans,dist[Y][X]);
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}


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

int main(void){
    long long N, Q, H, S, D, min_price, ans=0;
    std::cin >> Q >> H >> S >> D >> N;
    Q *= 4;
    H *= 2;
    min_price = std::min(Q, H);
    min_price = std::min(min_price, S);
    if (N % 2 == 1) ans += min_price;
    ans += N / 2 * std::min(min_price * 2, D);

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#define SQLOOP for(hi = 0;hi < h;hi++)for(wi = 0;wi < w;wi++)

char map[101][101];
short h,hi,w,wi,ans;

void mapInfr(short hj,short wj){
	char base;
	base = map[hj][wj];
	map[hj][wj] = 0;
	if(hj && map[hj - 1][wj] == base)mapInfr(hj - 1,wj);
	if(wj && map[hj][wj - 1] == base)mapInfr(hj,wj - 1);
	if(hj + 1 < h && map[hj + 1][wj] == base)mapInfr(hj + 1,wj);
	if(wj + 1 < w && map[hj][wj + 1] == base)mapInfr(hj,wj + 1);
	return;
}

int main(void){
	while(scanf("%d%d",&h,&w),(h && w)){
		for(hi = 0;hi < h;hi++) scanf("%s\n",&map[hi]);
		ans = 0;
		SQLOOP if(map[hi][wi])mapInfr(hi,wi),ans++;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1384
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, A, B = [int(x) for x in input().split()]

    if (B - A) % 2 == 1:
        print("Borys")
    else:
        print("Alice")

    
    
    

if __name__ == '__main__':
    main()



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define db double
#define ull unsigned long long
#define MIN INT_MIN
#define MAX INT_MAX
#define all(x) (x).begin(), (x).end()
#define ii pair <int,int>
#define iii pair <int,ii>
#define pll pair <ll,ll>
#define plll pair <ll,pll>
#define ff first
#define ss second
#define minQueue priority_queue <int,vector<int>,greater<int> >
#define maxQueue priority_queue<int,vector<int>,less<int> >
#define pb push_back
#define max3(a,b,c) max(a, max(b,c))
#define min3(a,b,c) min(a, min(b,c))
#define GCD(x,y) __gcd((x), (y))
#define LCM(x,y) ((x / GCD((x), (y))) * y)
#define loop(a,n) for(int i=a; i<n; i++)
#define mem(x,y) memset((x), (y), sizeof (x));
#define Case int T; scanf("%d", &T); for(int cas = 1; cas <= T; ++cas)
#define pf printf
#define sf scanf
#define Ziru 0
#define pr1(x) cout << x << endl
#define pr2(x,y) cout << x << ' ' << y << endl
#define powerOfTwo(x) (x && !(x & (x - 1)))
#define Iterator(type) type <int> :: iterator
#define mapIterator map <int,int> :: iterator //it->ff it->ss
#define FI freopen ("input.txt", "r", stdin)
#define FO freopen ("output.txt", "w", stdout)
using namespace std;

vector <int> v;

void divisor(int n){
    for(int i=1; i<=n; i++){
        if(n%i==0){
            v.push_back(i);
            if(n/i!=i) v.push_back(n/i);
        }
    }
    sort(v.begin(),v.end());
}

int main(){
    int a,b,n,cnt=0;
    cin>>a>>b>>n;
    divisor(n);

    int len=v.size();
    for(int i=a; i<=b; i++){
        for(int j=0; j<len; j++){
            if(i==v[j]){
                cnt++;
                break;
            }
        }
    }
    cout<<cnt<<endl;
    return Ziru;
}



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



int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i, N){
        cin >> X[i];
    }
    ll sum = 0;
    ll min = 1e9;
    for(int i = 1; i <= 100; i++){
        sum = 0;
        for(int j = 0; j < N; j++){
            sum += (X[j] - i) * (X[j] - i);
        }
        if(min > sum){
                min = sum;
        }
    }
    cout << min;
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

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

    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }

    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    int sum = 0;
    for (int i = 0; i < k; i++) {
        sum += v[i];
    }

    cout << sum << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
  ll N; cin >> N;
  vector<tuple<ll, ll> > AB(N);
  for (ll j=0; j < N; ++j) {
    ll A, B; cin >> A >> B;
    AB[j] = make_tuple(A, B);
  }
  sort(AB.begin(), AB.end(), [](auto l, auto r){
        return get<1>(l) < get<1>(r);
      });
  ll t = 0;
  bool flag = true;
  for (ll j=0; j < N; ++j) {
    ll a, b; tie(a, b) = AB[j];
    t += a;
    if (t > b) {
      flag = false;
      break;
    }
  }
  cout << (flag?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 3328
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < (up); ++i)
#define repp(i, up) for (ll i = 0; i <= (up); ++i)
#define rrep(i, lo, up) for (ll i = (lo); i < (up); ++i)
#define rrepp(i, lo, up) for (ll i = (lo); i <= (up); ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))
#define feach(it, vec) for (auto it = (vec).begin(); it != (vec).end(); ++it)
#define emax(l, r) l = max(l, r)
#define vmin(l, r) l = min(l, r)

template<class T, class U>
bool contains(const T & vec, const U & value) {
    return vec.find(value) != vec.end();
}

ll gcd(ll a, ll b);

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

#endif  // end of use_templates


int main()
{
    string s, t;
    cin >> s >> t;
    ll result = INF;
    repp(i, s.length() - t.length()) {
        ll cnt = 0;
        rep(j, t.length()) {
            if (t[j] != s[i + j]) {
                ++cnt;
            }
        }
        vmin(result, cnt);
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3200
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int main(){
	string s;
	cin >> s;
	int n = s.length();
	int win = 0, lose = 0;
	int gnum = 0, pnum = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == 'g'){
			if(gnum > pnum){
				win++;
				pnum++;
			}else{
				gnum++;
			}
		}else{
			if(gnum > pnum){
				pnum++;
			}else{
				gnum++;
				lose++;
			}
		}
	}
	//printf("%d, %d\n", win, lose);
	printf("%d\n", win-lose);
	return 0;
}

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

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 (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

char to_lower(char c){
    ll diff = 'A' - 'a';
    return c - diff;
}

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

    // input
    ll N, K;
    cin >> N >> K;

    // メモリ確保テスト
    int dp[100][100];
    // 32bit * 10000 = 40KB増えるはず

    string s;
    cin >> s;

    s[K-1] = to_lower(s[K-1]);
    p(s);
        
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
  
int main() {
	int n;
	cin >> n;
	vector<int> A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	sort(all(A), greater<int>());
	multiset<int> st;
	ll ans = A[0];
	st.insert(A[1]);
	st.insert(A[1]);
	for (int i = 2; i < n; i++) {
		auto it = prev(st.end());
		ans += *it;
		st.erase(it);
		st.insert(A[i]);
		st.insert(A[i]);
	}
	cout << ans;
}


Measured memory_bytes: 13532
import java.util.Scanner;

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

        while (true) {
            String x = sc.next();

            if ("0".equals(x)) break;

            int sum = 0;
            for (String s : x.split("")) {
                sum += Integer.parseInt(s);
            }
            System.out.println(sum);
        }
    }
}

Measured memory_bytes: 27404
K,N = map(int,input().split())
A = list(map(int,input().split()))
ls = []
for i in range(N):
    #print(i)
    if i != N-1:
        ls.append(A[i+1]-A[i])
    else:
        ls.append(A[0]+K-A[i])
#print(ls)
    #print(ls)
print(sum(ls)-max(ls))


Measured memory_bytes: 100980
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a > b){
			System.out.println("a > b");
		}else if(a < b){
			System.out.println("a < b");
		}else{
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 26180
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define intmin -2147483647
#define llmax 9223372036854775807
typedef long long ll;
using namespace std;

string s;
string akiba[16];

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	ll g = gcd(x, y);
	return x / g * y;
}

int main(){
	cin >> s;
	lp(2) {
		LP(2, j) {
			LP(2, k) {
				LP(2, l) {
					if (i)akiba[i + j * 2 + k * 4 + l * 8] = "AKIH";
					else akiba[i + j * 2 + k * 4 + l * 8] = "KIH";
					if (j)akiba[i + j * 2 + k * 4 + l * 8] += "AB";
					else akiba[i + j * 2 + k * 4 + l * 8] += "B";
					if (k)akiba[i + j * 2 + k * 4 + l * 8] += "AR";
					else akiba[i + j * 2 + k * 4 + l * 8] += "R";
					if (l)akiba[i + j * 2 + k * 4 + l * 8] += "A";
				}
			}
		}
	}
	lp(16) {
		if (s == akiba[i]) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps=1e-8;
string trans(string base, string keyfr,string keyto) {
	string res;
	int len = base.length();
	int lon = keyfr.length();
	rep(i, len) {
		if (i + lon <= len) {
			string chk = base.substr(i, lon);
			if (chk == keyfr) {
				res += keyto; i += lon - 1;
			}
			else {
				res += base[i];
			}
		}
		else {
			res += base[i];
		}
	}
	return res;
}
int main() {
	int n;
	while (cin >> n, n) {
		map<string, int>used;
		pair<string,string> x[10];
		rep(i, n) {
			string a, b; cin >> a >> b; x[i] = { a,b };
		}
		string sta, las;
		cin >> sta >> las;
		queue<string> q;
		q.push(sta); used[sta] = 1;
		int cnt = 0; bool f = false;
		while (!q.empty()) {
			int len = q.size();
			rep(nexxxxxxxxt, len) {
				string now = q.front(); q.pop();
				if (now == las) {
					f = true; break;
				}
				rep(i, n) {
					string nex = trans(now, x[i].first, x[i].second);
					if (nex.length()<=10&&used[nex] != 1) {
						used[nex] = 1;
						q.push(nex);
					}
				}
			}
			if (f)break;
			cnt++;
		}
		if (f) {
			cout << cnt << endl;
		}
		else {
			cout << -1 << endl;
		}
	}
	return 0;
}


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

using namespace std;
typedef long long ll;
#define Inf 1 << 20
#define MInf -(1 << 20)


#define REP(n) for(int i = 0;i < (int)(n);i++)
#define rep(i,n) for(int i = 0;i < (int)(n);i++)
#define Rep(i,n,m) for(int i = (int)(n); i < (int)(m);i++)
#define rrep(i,n) for(int i = (int)(n - 1); i > -1;i--)
#define RRep(i,n,m) for(int i = (int)(n - 1); i > (int)(m);i--)

#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))
#define REVERSE(V) reverse(ALL(V))
#define RSORT(V) SORT(V);REVERSE(V)


#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define yes(n) cout << ((n) ? "yes" : "no") << endl;


ll binary(ll bina)
{
    long long ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    string a;
    return ans;

}

int main()
{
    int N,M,C;
    cin >> N >> M >> C;
    vector<int> B(M);
    int tmp;
    int count = 0;
    rep(i,M)
    {
        cin >> B.at(i);
    }
    rep(i,N)
    {
        int sum = 0;
        rep(i,M)
        {
            cin >> tmp;
            sum += tmp * B[i];
        }
        if(sum + C > 0)
        {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <set>
#include <ctime>
#include <map>
#include <cstring>
#include <iterator>
#include <queue>
#include <assert.h>
#include <bitset>
#include <complex>
#include <unordered_map>

//#pragma comment(linker, "/STACK:512000000")

using namespace std;

#define pb emplace_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define forab(i, a, b) for (int i = (a); i < (b); ++i)

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

const int infi = 1e9 + 7;
const ll infl = (ll)1e18 + (ll)7;

ll len[60];
ll cnt_p[60];

int32_t main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
   // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    //freopen("customs.in", "r", stdin); freopen("customs.out", "w", stdout);
    len[0] = cnt_p[0] = 1;
    for (int i = 1; i <= 50; ++i) {
        len[i] = len[i - 1] * 2 + 3;
        cnt_p[i] = cnt_p[i - 1] * 2 + 1;
    }
    int n;
    ll x;
    cin >> n >> x;
    ll ans = 0;
    while (x > 0) {
        if (n == 0) {
            ans += 1;
            break;
        }
        if (x == 1)
            break;
        --x;
        if (x <= len[n - 1]) {
            --n;
            continue;
        }
        ans += cnt_p[n - 1];
        x -= len[n - 1];
        ++ans;
        --x;
        if (!x)
            break;
        if (x <= len[n - 1]) {
            --n;
            continue;
        }
        ans += cnt_p[n - 1];
        break;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import deque
n,k=map(int,input().split())
x=list(map(int,input().split()))
#1. 初期状態をつくる
deq = deque()
r_init = 0
for i in range(n):
  if len(deq) == k and x[i] > 0:
    break
  deq.append(x[i])
  r_init = i
  if len(deq) > k:
    deq.popleft()

left = min(deq[0], 0)
right = max(deq[-1], 0)
ans = 0
if right <= 0:
  ans = abs(left)
elif left >= 0:
  ans = abs(right)
else:
  ans = min(abs(left),abs(right))+abs(left)+abs(right)
#2.1個ずつ右のものを取ることを考える。0起点で往復したときの距離を保持する
#2-1.右からk個とるときまで続ける
for i in range(r_init+1, n):
  m = deq.popleft()
  deq.append(x[i])
  if m >= 0:
    break
  left = abs(deq[0])
  right = abs(x[i])
  ans = min(ans, min(left,right)+left+right)
#3.全パターンについて最小値を取る
print(ans)

Measured memory_bytes: 20552
MOD = 10 ** 9 + 7

N = int(input())
A = list(map(int, input().split()))
Abi = ["0" * 60 + bin(a)[2:] for a in A]

ans = 0
for i in range(60):
    N1 = sum([1 for a in Abi if a[-(i + 1)] == '1'])
    ans = (ans + (2 ** i) * N1 * (N - N1)) % MOD

print(ans)


Measured memory_bytes: 324412
#include <iostream>

using namespace std;

int main(void){
 int N,M,X,Y;
 cin >> N >> M >> X >> Y;
 int x[N],y[M];
 int i;
 for(i=0;i<N;i++) cin >> x[i];
 for(i=0;i<M;i++) cin >> y[i];
int maxx = X,miny = Y;
 for(i=0;i<N;i++){
  if(maxx < x[i]) maxx = x[i];
}
 for(i=0;i<M;i++){
  if(miny > y[i]) miny = y[i];
}
if(maxx < miny) cout << "No War" << endl;
else cout << "War" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define LLMAX (1ll << 60) - 1
#define llMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define vi vector<ll>
#define prll(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define in(x,n)   for(ll e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
#define vl vector<long long>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define mp make_pair


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    string s;
    cin>>s;
    ll anl=0,anr=0;
    for(int i=0;i<s.size();i++){
    	if(i%2){
    		if(s[i]=='0')
    		anl++;
		}
		else{
			if(s[i]=='1')
			anl++;
		}
	}
	 for(int i=0;i<s.size();i++){
    	if(i%2){
    		if(s[i]=='1')
    		anr++;
		}
		else{
			if(s[i]=='0')
			anr++;
		}
	}
	cout<<min(anl,anr);
    return 0;
}
 

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <sstream>

using namespace std;




signed main()
{
	
	long long a, b;
	cin >> a >> b;
	long long ans = a * b;
	ans -= a + b - 1;
	cout << ans << "\n";
}

Measured memory_bytes: 256
c = [list(map(int, input().split())) for i in range(3)]

b = [0] * 3
for i in range(3):
    b[i] = c[0][i]

ans = 0

if c[1][0] - c[1][1] == b[0] - b[1] and c[1][1] - c[1][2] == b[1] - b[2]:
    ans += 1

if c[2][0] - c[2][1] == b[0] - b[1] and c[2][1] - c[2][2] == b[1] - b[2]:
    ans += 1

if ans == 2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;



public class Main {

	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
	 int n=fs.nextInt();
	 int a[]=fs.readArray(n);
	 boolean des=true;
	 for(int i=1;i<n;i++) {
		 if(a[i]>a[i-1]) {
			 des =false;
			 break;
		 }
	 }
	 if(des) {
		 System.out.println(1000);
		 return;
	 }
	 boolean ascen=true;
	 for(int i=1;i<n;i++) {
		 if(a[i]<a[i-1]) {
			 ascen =false;
			 break;
		 }
	 }
	 if(ascen) {
		 int stock=1000/a[0];
		 int rem=1000%a[0];
		 int sell=stock*a[n-1];
		 System.out.println(sell+rem);
		 return;
	 }
	long money=1000;
	 for(int start=0;start<n-1;start++) {
		 int end = start+1;
		 if(a[start]>=a[end]) continue;
		 long times = money/a[start];
		 money=money%a[start];
		 money+=times*a[end];
	 }
	 System.out.println(money);
	 
	 
	   
	}
	static void sort(int[] a ) {
		ArrayList<Integer> l = new ArrayList<>();
		for(int i:a) l.add(i);
		Collections.sort(l);
		for(int i=0;i<l.size();i++) a[i]=l.get(i);
	}
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while(!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				}catch(IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a = new int[n];
			for(int i=0;i<n;i++)a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 32724
#include<iostream>
#include<cstdio>
#include<queue>
#define LL long long
#define maxn 100005
using namespace std;
LL L=0,R=1e9;
int n;
LL A,B;
LL a[maxn];

bool check(LL x){
	LL cnt=0;
	for(int i=1;i<=n;i++){
		LL k=a[i];
		if(k<=x*B)continue;
		cnt+=(k-x*B-1ll)/A+1ll;
	}
	if(cnt<=x)return 1;else return 0;
}

int main(){
	scanf("%d%lld%lld",&n,&A,&B);
	A-=B;
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	R++;
	while(L+1<R){
		LL mid=L+R>>1;
		if(check(mid))R=mid;else L=mid;
	}
	printf("%lld\n",R);
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
  int a[2001];
  int i,j,n;
  for (i=0;i<=2000;i++)
    a[i]=0;
  for (i=0;i<=1000;i++)
    for (j=0;j<=1000;j++)
      a[i+j]++;
  while (scanf("%d",&n)!=EOF){
    int cnt=0;
    for (i=0;i<=1000;i++){
      if (i>n) break;
      for (j=0;j<=1000;j++){
        if (i+j>n) break;
        if ((0<=n-i-j) && (n-i-j<=2000))
          cnt+=a[n-(i+j)];
      }
    }
    printf("%d\n",cnt);
  }
  return 0;
}

Measured memory_bytes: 604
n,m,k = gets.chomp.split.map(&:to_i)
MOD = 998244353
ans = 0
class Combination_mod_p
  def initialize(mod,max_num)
    @max_num = max_num
    @mod = mod

    @fac = Array.new(@max_num,0)
    @finv = Array.new(@max_num,0)
    @inv = Array.new(@max_num,0)

    @fac[0] = @fac[1] = 1
    @finv[0] = @finv[1] = 1
    @inv[1] = 1
    (2..@max_num-1).each do |i|
      @fac[i] = @fac[i-1]*i % @mod
      @inv[i] = @mod - @inv[@mod % i] * (@mod / i) % @mod
      @finv[i] = @finv[i - 1] * @inv[i] % @mod 
    end
  end

  def com(n,k)
    return 0 if n < k || (n < 0 || k < 0)

    return @fac[n] * (@finv[k] * @finv[n-k] % @mod) % @mod
  end
end

def mod_pow(base,n,mod)
	if n == 0
		res = 1
	elsif n == 1
		res = base
  elsif n % 2 == 0
    res = mod_pow(base,n/2,mod) ** 2 % mod
  else
    res = mod_pow(base,n-1,mod) * base % mod
  end
  res
end

combi = Combination_mod_p.new(MOD,n)

(k+1).times do |i|
	ans += m * mod_pow(m-1,n-i-1,MOD) * combi.com(n-1,i)
	ans %= MOD
end

puts ans

Measured memory_bytes: 19128
N = int(input())
A = list(map(int,input().split()))
ans = sum(A)

X = [0]*(10**5+1)

for x in A:
    X[x] += 1

Q = int(input())

for _ in range(Q):
    B,C = map(int,input().split())
    ans += (C-B)*X[B]
    X[C] += X[B]
    X[B] = 0
    print(ans)


Measured memory_bytes: 84704
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  long long int arr[n], max = 1e18, prod = 1, flag = 0, zero = 0;
  
  for (int i = 0; i < n; i++) {
    scanf("%lld", &arr[i]);
    flag = (arr[i] > max) ? 1 : flag;
    prod *= arr[i];
    (arr[i]) ? max /= arr[i] : zero = 1;
  }

  (zero) ? puts("0") : ((flag) ? puts("-1") : printf("%lld\n", prod));
  return 0;
}

Measured memory_bytes: 2488
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;


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

  ll sum=0,s=1;

  for(ll i=0;s<=h;i++){
    s=s*2;
    sum=s/2;
  }

  cout << sum+(sum-1) << endl;

  }


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
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; }
using namespace std;

int main(){

    int N;
    cin >> N;

    vector<vector<int>> battle_graph(N);
    rep(i, N - 1){
        int a;
        cin >> a;
        a--;
        battle_graph[a].push_back(i + 1);
    }

    function<int(int)> decide_battle = [&](int contestant){
        vector<int> battles;
        for(int oponent : battle_graph[contestant]){
            battles.push_back(decide_battle(oponent));
        }
        sort(all(battles), greater<int>());
        int max_battles = 0;
        rep(i, (int)battles.size()){
            chmax(max_battles, battles[i] + i + 1);
        }
        return max_battles;
    };

    cout << decide_battle(0) << endl;
    return 0;

}

Measured memory_bytes: 13568
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		long mod = (long)(1e9+7);
		Scanner input = new Scanner(System.in);
		int A = input.nextInt();
		int B = input.nextInt();
		int C = input.nextInt();
		int K = input.nextInt();
		long answer=0;
		while (K>0) {
			if (A>0) {
				int sub = Math.min(A, K);
				K-=sub;
				A-=sub;
				answer+=sub;
			}else if (B>0) {
				int sub = Math.min(B, K);
				K-=sub;
				B-=sub;
			}else if (C>0) {
				int sub = Math.min(C, K);
				K-=sub;
				C-=sub;
				answer-=sub;
			}
			if (A<=0&&B<=0&&C<=0) break;
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 27088
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split(" ");
		ArrayList<Pair> p = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			p.add(new Pair(i + 1, Integer.parseInt(str[i])));
		}

		Collections.sort(p);

		System.out.print(p.get(0).id);
		for (int i = 1; i < n; i++) {
			System.out.print(" " + p.get(i).id);
		}
		System.out.println();
	}
}

class Pair implements Comparable<Pair> {
	int id;
	int num;

	public Pair(int id, int num) {
		this.id = id;
		this.num = num;
	}

	@Override
	public int compareTo(Pair p) {
		return this.num - p.num;
	}
}

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

using namespace std;

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

int main()
{
    int x;

    cin >> x;
    
    int p = x;
    while(!is_prime(p)){
        p++;
    }

    cout << p << endl;
    return 0;

}

Measured memory_bytes: 3592
a,b = map(int, input().split())
List = [list(map(int, input().split())) for i in range(b+1)]
#i番目の展望台の高さ　List[0][i-1](i>=1)
Flag=[1]*a
for i in range(1,b+1):
  m = List[i][0]-1 # 比較する展望台の番号
  n = List[i][1]-1 # 比較する展望台の番号
  if List[0][m] < List[0][n]:
    Flag[m]=0
  elif List[0][n] < List[0][m]:
    Flag[n]=0
  elif List[0][n] == List[0][m]:
    Flag[m]=0
    Flag[n]=0
  else:
    print("weird")
Output=Flag.count(1)
print(Output)



Measured memory_bytes: 31904
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
ab.sort(key=lambda x: x[0])

c_l = 0
c_r = n+1

res = 0
for i, v in enumerate(ab):
    a, b = v
    if c_r <= a:
        res += 1
        c_l = a
        c_r = b
    else:
        c_l = max(c_l, a)
        c_r = min(c_r, b)

print(res+1)

Measured memory_bytes: 29048
while True:
    h,w =map(int,input().split())
    
    if h == 0 and w == 0:
        break
    for i in range(h):
        if i == 0 or i == h-1:
            print('#'* w)
        else:
            print('#' + '.' * (w -2) + '#') 
    print() 


Measured memory_bytes: 5608
n=int(input())
p=list(map(float,input().split()))

dp=[[0]*(n+1) for _ in range(n+1)]
dp[0][0]=1
for i in range(n):
    for j in range(n):
        dp[j][i+1]+=dp[j][i]*(1-p[i])
        dp[j+1][i+1]+=dp[j][i]*p[i]

ans=0
for j in range((n+1)//2,n+1):
    ans+=dp[j][-1]
print(ans)

Measured memory_bytes: 206460
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

bool ok(char c){
	if(c=='A' || c=='C' || c=='G' || c=='T') return true;
	else return false;
}

int main(void) {
	string s; cin >> s;
	int n = s.size();
	int ans=0;
	int cnt=0;
	rep(i,n){
		if(ok(s[i])) cnt++; else cnt=0;
		ans = max(ans,cnt);
	}
	cout << ans << endl;
}




Measured memory_bytes: 256
num = int(input())
A = input().split(" ")
B = input().split(" ")
C = input().split(" ")
result = 0
 
for i in range(num):
  result += int(B[int(A[i])-1])
  if i > 0 and (int(A[i]) - int(A[i-1]) == 1):
    result += int(C[int(A[i])-2])
 
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
vector<map<int, int>> graph;
int main(){
    int n;
    cin >> n;
    vector<tuple<string, int, int>> vec;
    for(int i = 1; i <= n; i++){
        string s;
        int in;
        cin >> s >> in;
        vec.emplace_back(s, 100 - in, i);
    }
    sort(vec.begin(), vec.end());
    for(auto itr : vec){
        cout << get<2>(itr) << "\n";
    }
}

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

#define maxn 502
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 y902
#define y1 y232
#define x0 x92
#define x1 x899
#define next asdfa
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<int, int> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

int h1, h2, w1, w2, a[maxn][maxn];

int main() {
    //freopen("rect2.inp", "r", stdin);
    //freopen("", "w", stdout);
    //ios::sync_with_stdio(0); cin.tie(0);
    scanf("%d%d%d%d", &h1, &w1, &h2, &w2);
    if (h1%h2==0 && w1%w2==0) {printf("No"); return 0;}
    bool ok = false;
    if (h1%h2==0) {swap(h1, w1); swap(h2, w2); ok = true;}
    FOR(i, 1, h1) FOR(j, 1, w1) a[i][j] = 1;
    FOR(i, 1, h1) FOR(j, 1, w1) {
        if (i%h2==0 && j%w2==0)
            a[i][j] = -h2*w2;
    }
    FOR(i, 1, h1) {
        if (i%h2==1) a[i][1] = 1000000000-h2*w2+1;
        if (i%h2==0) a[i][w2] = -1000000000;
    }
    printf("Yes\n");
    if (!ok) {
        FOR(i, 1, h1) {
            FOR(j, 1, w1) printf("%d ", a[i][j]);
            printf("\n");
        }
    }
    else {
        FOR(j, 1, w1) {
            FOR(i, 1, h1) printf("%d ", a[i][j]);
            printf("\n");
        }
    }
}



Measured memory_bytes: 1792
#include<iostream>
#include<cstring>
#include<cstdlib>
using namespace std;
int main(){
    int res=0;
    string str;
    while(cin>>str){
            char a[100];
            strcpy(a,str.c_str());
            for(int i=0;i<strlen(a);i++){
            if(isdigit(a[i])){
                int p=0;
                for(int j=i;j<strlen(a);j++){
                    if(isdigit(a[j]))p++;
                    else break;
                }
                char num[5]="0";
                strncpy(num,a+i,p);
                res+=atoi(num);
                i+=p;
            }

        }
    }
    cout<<res<<endl;

}

Measured memory_bytes: 1204
import sys
input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    x = [int(x) for x in input().split()]

    plus = [0]
    j = 0
    for i in range(N):
        if x[i] >= 0:
            plus.append(x[i])
            j += 1

    j = 0
    minus = [0]
    for i in range(N - 1, -1, -1):
        if x[i] < 0:
            minus.append(x[i])
            j += 1

    ans = float("inf")
    for i in range(0, K + 1):
        if len(plus) - 1 < i:
            continue

        if len(minus) - 1 < K - i:
            continue


        rsum = plus[i]
        lsum = abs(minus[K - i])

        if rsum >= lsum:
            ans = min(ans, rsum + lsum * 2)
        else:
            ans = min(ans, rsum * 2 + lsum)

    print(ans)

    


if __name__ == '__main__':
    main()



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

int main() {
  int n; cin >> n;
  map<string, int> red;
  while (n--) {
    string key; cin >> key; red[key]++;
  }
  
  int m; cin >> m;
  map<string, int> blue;
  while (m--) {
    string key; cin >> key; blue[key]++;
  }
  
  int answer = 0;
  for (pair<string, int> word : red) {
    if (blue.count(word.first)) answer = max(answer, word.second - blue.at(word.first));
    else answer = max(answer, word.second);
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long n, x, ans;
long long cel(long long n, long long x) {
    if(n % x == 0)
        return 2 * n - x;
    ans = n / x * 2 * x + cel(x, n % x);
    return ans ;
}
int main()
{
    while(cin >> n >> x) {
        ans = cel(n - x, x) + n;
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int change(int x,int y);
 
int main(void)
{
  int x,y;
  
  scanf("%d %d",&x,&y);

  if(x > y){
    printf("%d\n",change(x,y));
  } else {
    printf("%d\n",change(y,x));
  }
 
  return 0;
}


int change(int x,int y){
  int n = x%y;
  
  while(n != 0){
    x = y;
    y = n;
    n = x%y;
  }

  return y;
}



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

int mdc(int a, int b){
	if(b == 0) return a;
	return mdc(b, a % b);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int k;
	cin>>k;
	int cont = 0;
	for(int i = 1;i <= k; i++){
		int aux = 0;
		for(int j = 1;j <= k;j++){
			for(int l = 1; l <= k; l++){
				aux = mdc(j, l);
				cont += mdc(i, aux);
			}
		}
		
	}
	cout<<cont<<endl;
	
	return 0;
	
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int a, b;
  cin >> a >> b;
  if ((a * b) % 2 == 0) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double ans = pow(A, 2) + pow(B, 2) - 2 * A * B * cos(abs(30 * (H + M / 60) - 6 * M) * M_PI / 180);
    printf("%.9f\n", sqrt(ans));
}

Measured memory_bytes: 4260
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
	int x,y;

	while(1)
	{
		cin >> x >> y;
		if( x==0 && y==0 )
			break;
		if( x<y )
			cout << x << " " << y << endl;
		else
			cout << y << " " << x << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
using namespace std;
string s;
int main()
{
//	freopen("1580.in","r",stdin);
//	freopen("1580.out","w",stdout);
    cin>>s;
    s[5]=s[5+7+1]=s[5+7+5+2]=' ';
    cout<<s<<endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
typedef long long ll;

using namespace std;

int main(){
    ll N, K, x;   cin >> N >> K;
    ll cnt = 0;
    ll rev = 0;
    ll ans;
    const ll mod2 = 1000000007;
    std::vector<ll> v(N);
    for(int i=0; i<N; i++)  cin >> v[i];
    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){
            if(v[i] > v[j]) cnt++;
        }
    }
    std::sort(v.begin(),v.end(),std::greater<ll>());

    x = 0;
    for(int i=1; i<N; i++){
        if(v[i-1] > v[i]){
            rev += i;
            x = i;
        }else    rev += x;
    }
    ans = cnt*K + (K*(K-1)/2)%mod2 * rev;
    ans = ans%mod2;
    cout << ans;
}

Measured memory_bytes: 3504
#include<bits/stdc++.h>
using namespace std;
int main()
{   long long int n,i,j,k,sum=0;string s;
  cin>>n>>s;
  long long int fr[n]={0},fg[n]={0},fb[n]={0};
  if(s[n-1]=='R')
    fr[n-1]=1;
  else if(s[n-1]=='G')
    fg[n-1]=1;
  else
    fb[n-1]=1;
  for(i=n-2;i>=0;i--)
  {
      if(s[i]=='R')
      {
        fr[i]=fr[i+1]+1;
        fg[i]=fg[i+1] ;
        fb[i]=fb[i+1] ;
      }

     else if(s[i]=='G')
      {
        fg[i]=fg[i+1]+1;
        fr[i]=fr[i+1] ;
        fb[i]=fb[i+1] ;
      }
      else if(s[i]=='B'){
        fg[i]=fg[i+1];
        fr[i]=fr[i+1] ;
        fb[i]=fb[i+1]+1 ;
      }

  }
 for(i=0;i<n-3;i++)
 {

    for(j=i+1;j<n-1;j++)
    {
        if(s[i]==s[j])
        continue;
         if(s[i]+s[j]==153)
        sum+=fb[j+1];
        else if(s[i]+s[j]==137)
            sum+=fr[j+1];
        else sum+=fg[j+1];
        k=(2*j-i);
      if((s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k])&&k<n)
        sum--;
    }
}
cout<<sum;
}


Measured memory_bytes: 3732
#include<stdio.h>

int main(void){
  int a,b,c,K,ma,sum=0;
  scanf("%d%d%d",&a,&b,&c);
  scanf("%d",&K);
  while(K--){
    if(a>b && a>c) a*=2;
    else if(b>a && b>c) b*=2;
    else c*=2;
  }
  printf("%d\n",a+b+c);
  return 0;
}


Measured memory_bytes: 128
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];
ll a[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m,h,a,b,c;
    vector<pair<ll, char>> mahir;
    cin >> x >> y >> a >> b >> c;
    Ff(i,0,a){
        
        cin >> h;
        mahir.push_back({h, 'r'});
    }
    Ff(i,0,b) {
        cin >> h;
        mahir.push_back({h, 'g'});
    }
    Ff(i,0,c) {
        cin >> h;
        mahir.push_back({h, ' '});
    }
    sortall(mahir);
    reverse(mahir.begin(), mahir.end());
    ll ans = 0;
    int r_count = 0, g_count = 0, c_count = 0;
    for (auto f : mahir) {
        char ch = f.ss;
        ll val = f.ff;
 
        if (ch == 'r' && r_count == x) continue;
        if (ch == 'g' && g_count == y) continue;
 
        ans += val;
        if (ch == 'r') r_count++;
        else if (ch == 'g') g_count++;
        else c_count++;
 
        if (r_count + c_count + g_count == x + y) break;
    }
    cout << ans << endl;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 17900
#include <iostream>
#include <cstring>
#include <ctype.h>

using namespace std;

int main()
{
    string S;
    cin >> S;
    int l = S.size();
    string ans = "AC";

    if(S[0] != 'A'){
        ans ="WA";
    }
    int cnt = 0;
    for (int i = 1  ; i < l; i++){
        if (isupper(S[i])){
            if (i == 1 || i == l - 1 || S[i] != 'C'){
                ans = "WA";
            }
            ++cnt;
        }
    }
    if (cnt != 1){
        ans = "WA";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cstring>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
    using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

ll n,a;
ll x[51]={};
ll dp[51][51][2503];

ll dfs(int i, int cnt, int sum){
    if(dp[i][cnt][sum]!=-1)return dp[i][cnt][sum];
    if (i == n){
        if(cnt != 0){
            return (double)sum/cnt == (double)a;
        }else{
            return 0;
        }
    }
    ll res = 0;
    res += dfs(i+1, cnt, sum) + dfs(i + 1, cnt + 1, sum + x[i]);

    return dp[i][cnt][sum] = res;
}

int main(){
    memset(dp, -1, sizeof(dp));
    cin>>n>>a;
    for(int i=0; i<n; i++)cin>>x[i];
    cout<<dfs(0,0,0)<<endl;
}

Measured memory_bytes: 51072
N = map(int, input())
aN = map(int, input().split())
aN = list(aN)

count = 0
while len(aN) > 0:
    tmp = list()
    for ai in aN:
        if ai % 2 == 0:
            ai = ai / 2
            count += 1
            tmp.append(ai)
    aN = tmp

print(count)

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

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

int main()
{
  int k, s;
  cin >> k >> s;

  int ans = 0;
  rep(x, k + 1)
  {
    rep(y, k + 1)
    {
      int z = s - x - y;
      if (z >= 0 && z <= k)
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n,0);
	for(int i=1;i<n;i++)
	{
		int tmp;
		cin >> tmp;
		tmp--;
		a[tmp]++;
	}
	for(int i=0;i<n;i++)
		cout << a[i] << endl;




}

Measured memory_bytes: 4000