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

using namespace std;

using ll = long long;
using P = pair<ll, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    priority_queue<P> pq;
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        pq.emplace(b[i], i);
    }

    ll ans = 0;
    while (!pq.empty()) {
        P tar = pq.top();
        pq.pop();
        //cerr << tar.second << " " << tar.first << endl;
        if (a[tar.second] > tar.first) {
            cout << -1 << endl;
            return 0;
        }

        if (a[tar.second] == tar.first) {
            continue;
        }

        int il = (tar.second + n - 1) % n;
        int ir = (tar.second + 1) % n;
        ll lv = b[il];
        ll rv = b[ir];

        vector<P> buf;
        while (true) {
            if (tar.first > (lv + rv)) {
                break;
            }

            buf.push_back(tar);

            //if (pq.empty()) {
                cout << -1 << endl;
                return 0;
            //}

            tar = pq.top();
            pq.pop();

            il = (tar.second + n - 1) % n;
            ir = (tar.second + 1) % n;
            lv = b[il];
            rv = b[ir];
        }

        for (P& p : buf) pq.push(p);
        
        ll foo = (tar.first - (lv + rv) + (lv + rv - 1)) / (lv + rv);
        ll bar = (tar.first - a[tar.second]) / (lv + rv);
        ll cnt = min(foo, bar);
        //cerr << tar2.first << endl;

        ans += cnt;
        b[tar.second] = tar.first - cnt * (lv + rv);
        if (b[tar.second] < a[tar.second]) {
            cout << -1 << endl;
            return 0;
        } else if (b[tar.second] > a[tar.second]) {
            if (b[tar.second] > (lv + rv)) {
                foo = (b[tar.second] - (lv + rv) + (lv + rv - 1)) / (lv + rv);
                ans += foo;
                b[tar.second] -= foo * (lv + rv);

                if (b[tar.second] < a[tar.second]) {
                    cout << -1 << endl;
                    return 0;
                } else if (b[tar.second] == a[tar.second]) {
                    continue;
                }
            }
            pq.emplace(b[tar.second], tar.second);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9712
#include<cstdio>
int n,c[510],s[510],f[510],i,a,j;main(){for(scanf("%d",&n);j<n-1;++j)scanf("%d%d%d",c+j,s+j,f+j);for(f[j]=1;i<n;a=0)for(j=i++;j<n||!printf("%d\n",a);)a=(a<s[j]?s[j]:(~-a/f[j]+1)*f[j])+c[j++];}

Measured memory_bytes: 128
import java.util.Scanner;

/**
 * https://abc066.contest.atcoder.jp/tasks/arc077_b
 */
public class Main {
	
	static final int MOD = 1000000007;
	static long[] modDp;
	static long[] modInvDp; 
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] a = new int[N+1];
		for(int i=0; i<=N; i++){
			a[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		
		int firstIndex = 0;
		int secondIndex = 0;
		int[] dp = new int[N+1];
		for(int i=0; i<=N; i++) dp[i] = -1;
		for(int i=0; i<=N; i++){
			if(dp[a[i]]>=0){
				firstIndex = dp[a[i]];
				secondIndex = i;
				break;
			}
			dp[a[i]] = i;
		}
		
		modDp = new long[N+2];
		modInvDp = new long[N+2];
		modDp[0] = 1; 
		for (int i=1; i<=N+1; i++) modDp[i] = getMod(modDp[i-1]*i);
		modInvDp[N+1] = getInverse(modDp[N+1]);
		for (int i=N+1; i>0; i--) modInvDp[i-1] = modInvDp[i]*i % MOD;

		long[] ans = new long[N+1];
		int out = firstIndex+N-secondIndex;
		for(int i=1; i<=N+1; i++){
			ans[i-1] = getCombination(N+1,i);
			if(out>=i-1) ans[i-1] = getMod(ans[i-1]-getCombination(out,i-1));
		}
		
		for(long x:ans) System.out.println(x);
		
	}
	
	static long getCombination(int n, int r){
		long ans = modDp[n];
		ans = ans*modInvDp[r] % MOD;
		ans = ans*modInvDp[n-r] % MOD;
		return ans;
	}
	
	static long getInverse(long a) {
		return getPower(a, MOD-2);
	}
	
	static long getMod(long a){
		return a>=0 ? a%MOD : MOD + a%MOD;
	}
	
	static long getPower(long n, long m) {
		if(m==0){
			return 1;
		}else if(m%2==0){
			return getPower(getMod(n*n), m/2);
		}else{
			return getMod(n*getPower(n,m-1));
		}
	}

}


Measured memory_bytes: 48648
from operator import itemgetter

n, m = map(int, input().split())
cards = [(1, _) for _ in map(int, input().split())]
cards.extend([tuple(map(int, input().split())) for _ in range(m)])
cards.sort(key=itemgetter(1), reverse=True)

ans = 0
for num, i in cards:
    ans += i * min(num, n)
    n -= num
    if n <= 0:
        break
print(ans)


Measured memory_bytes: 31320
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n:usize = sc.read();
    let mut v:Vec<i64> = (0..n).map(|_|sc.read()).collect();
    v.sort();
    let min:i64 = v[0];
    let max:i64 = v[n-1];
    let sum:i64 = v.into_iter().sum();

    println!("{} {} {}",min, max, sum);
}

use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
 
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


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

#define ll long long

using namespace std;

//memset(dp, 0, sizeof(dp));

void work(int T) {
	char a;
	cin >> a;
	if(a < 'a') {
		cout << "A" << endl;
	} else {
		cout << "a" << endl;
	}
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
	// int t;
	// for(cin >> t; t > 0; t--) {
		// work(t);
	// }
	work(0);
	return 0;
};

Measured memory_bytes: 3648
#include<cstdio>
#include<iostream>
#include<vector>
#include<map>
#include<cstring>
#include<algorithm>
using namespace std;
typedef pair<int, int> pii;
#define IOS ios::sync_with_stdio(false)
const int maxn = 3e5 + 5;
int r[maxn], c[maxn];
map<pii, bool> mp;
vector<int> vr, vc;
void solve() {
	int h, w, m;
	scanf("%d%d%d", &h, &w, &m);
	int mr = 0, mc = 0;
	while (m--) {
		int x, y;
		scanf("%d%d", &x, &y);
		r[x]++;
		c[y]++;
		mr = max(mr, r[x]);
		mc = max(mc, c[y]);
		mp[pii(x, y)] = true;
	}
	for (int i = 1; i <= h; ++i){
		if (mr == r[i])	vr.push_back(i); 
	}
	for (int i = 1; i <= w; ++i){
		if (mc == c[i])	vc.push_back(i); 
	}
	for (int i : vr){
		for (int j : vc){
			if (!mp[pii(i, j)]){
				//方格中没有炸弹 
				printf("%d\n", mr + mc);
				return;
			}
		}
	}
	//方格里面有炸弹 
	printf("%d\n", mr + mc - 1);
}
int main() {
	solve();
	return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int L;
    scanf("%d", &L);
    printf("%.12f\n", (double) L * L * L / 27);
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int high, wide;
    int x, y;
    
    while(1){
      scanf("%d %d", &high, &wide);
      if (high == 0 && wide == 0)
          break;
      for(x = 0; x < high; x++){
        for(y = 0; y < wide; y++){
            if(y == 0 || y == wide -1 || x == 0 || x == high -1)
                printf("#");
            else
                printf(".");
        }
        printf("\n");
      }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2060
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 110000

int s[MAX], t[MAX], ans[MAX];
pair<int,int> x[MAX];

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	int A, B, Q, a, b, c, d;
	
	cin>>A>>B>>Q;
	
	rep(i,A)cin>>s[i];
	rep(i,B)cin>>t[i];
	rep(i,Q){
		cin>>x[i].first;
		x[i].second = i;
	}
	
	sort(x,x+Q);
	
	for(int i = 0, j = 0, k = 0; i < Q; i++){
		for(;j < A && x[i].first >= s[j];j++);
		for(;k < B && x[i].first >= t[k];k++);
		a = j?x[i].first-s[j-1]:INF;
		b = j-A?s[j]-x[i].first:INF;
		c = k?x[i].first-t[k-1]:INF;
		d = k-B?t[k]-x[i].first:INF;
		ans[x[i].second] = min(min(max(a,c),max(b,d)),min(min(a,d)*2+max(a,d),min(b,c)*2 + max(b,c)));
	}
	
	for(int i = 0; i < Q; i++) cout<<ans[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 5376
// Written By Mahtab Tanim
#include<bits/stdc++.h>
using namespace std;
#define MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define nl "\n"
#define End return 0
#define ll long long int
#define mp make_pair
#define pb push_back
#define ull unsigned long long int
#define pi acos(-1)
#define forn(i,a,b) for (int i=a;i<=b;i++)
#define PI acos(-1)
int main()
{
float r;
cin>>r;
printf("%.4lf",r*3.1415*2);
End;
}


Measured memory_bytes: 3788
#include <algorithm>
#include <iostream>
#include <math.h>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main() {
    int n;
    cin >> n;
    cout << n * n * n << endl;
    return 0;
}


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

long long int n;

int main(){
  cin >> n;
  long long int ans = 0;
  long long int div = 10;
  while(div <= n){
    ans += n / div;
    div *= 5;
  }
  if(n % 2 == 1){
    ans = 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int die[6] = {2,3,1,4,6,5};

void north(){
	int tmp;
	tmp = die[0];
	die[0] = die[2];
	die[2] = die[4];
	die[4] = die[5];
	die[5] = tmp;
}

void south(){
	int tmp;
	tmp = die[5];
	die[5] = die[4];
	die[4] = die[2];
	die[2] = die[0];
	die[0] = tmp;
}

void east(){
	int tmp;
	tmp = die[5];
	die[5] = die[3];
	die[3] = die[2];
	die[2] = die[1];
	die[1] = tmp;
}

void west(){
	int tmp;
	tmp = die[1];
	die[1] = die[2];
	die[2] = die[3];
	die[3] = die[5];
	die[5] = tmp;
}

void init(){
	die[0] = 2;
	die[1] = 3;
	die[2] = 1;
	die[3] = 4;
	die[4] = 5;
	die[5] = 6;
}

int main(){
	int n;
	while(cin >> n, n){
		init();
		for(int i = 0; i < n; i++){
			string s;
			cin >> s;
			if(s[0] == 'n') north();
			if(s[0] == 's') south();
			if(s[0] == 'w') west();
			if(s[0] == 'e') east();
		}
		cout << die[2] << endl;
	}
}

Measured memory_bytes: 1208
#include<iostream>
#include<cstdio>
#include<string>
#include<string.h>
#include<functional>
#include<algorithm>
#include<math.h>
#include<unordered_map>
#include<string.h>
#include<limits.h>
#include<list>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<unordered_set>
#include<deque>
#define int long long
#define P pair<int,int>
using namespace std;

P a[200000];
signed main() {
	int b; scanf("%lld", &b);
	for (int c = 0; c < b; c++) {
		scanf("%lld%lld", &a[c].first, &a[c].second);
	}
	int ans = LLONG_MAX / 3;
	if (1) {
		int n, m, x, y; n = x = 0; m = y = LLONG_MAX/3;
		for (int i = 0; i < b; i++) {
			if (a[i].first > a[i].second) {
				swap(a[i].first, a[i].second);
			}
			n = max(n, a[i].first);
			m = min(m, a[i].first);
			x = max(x, a[i].second);
			y = min(y, a[i].second);
		}
		ans = (x - y)*(n - m);
	}
	map<int, int>M, X;
	for (int i = 0; i < b; i++) {
		M[a[i].first]++;
		X[a[i].second]++;
	}
	sort(a, a + b);
	for (int i = 0; i < b; i++) {
		M[a[i].first]--;
		if (M[a[i].first] == 0) {
			M.erase(a[i].first);
		}
		X[a[i].second]--;
		if (X[a[i].second] == 0) {
			X.erase(a[i].second);
		}
		M[a[i].second]++;
		X[a[i].first]++;
		P S = *M.rbegin(),T=*M.begin();
		P p = *X.rbegin(), q = *X.begin();
		ans = min(ans, (p.first-q.first)*(S.first-T.first));
	}
	cout << ans << endl;
}

Measured memory_bytes: 28416
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,c,pos[100010],ca[100010],tor[100010],torm[100010],tolm[100010],tol[100010],now=0,ans=0;

int main()
{
	cin>>n>>c;
	rep(i,n) scanf("%lld%lld",&pos[i],&ca[i]);
	now=0;
	repn(i,n)
	{
		tor[i]=tor[i-1]-(pos[i-1]-now)+ca[i-1];
		torm[i]=max(torm[i],max(torm[i-1],tor[i]));
		now=pos[i-1];
	}
	now=c;
	for(int i=n-1,j=1;i>=0;i--,j++)
	{
		tol[j]=tol[j-1]-(now-pos[i])+ca[i];
		tolm[j]=max(tolm[j],max(tolm[j-1],tol[j]));
		now=pos[i];
	}
	rep(i,n+1)
	{
		ans=max(ans,tol[i]);
		ans=max(ans,tor[i]);
		ans=max(ans,tor[i]-(i==0 ? 0:pos[i-1])+tolm[n-i]);
		ans=max(ans,tol[n-i]-(c-pos[i])+torm[i]);
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#include <bitset>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1e9+7
using namespace std;
typedef long long ll;
const double pi=acos(-1);

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

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for(int i=0;i<n;i++) cin >> A[i];
    sort(A.begin(),A.end());
    ll ans=0;
    for(int i=n-1;i>n/2;i--) ans+=A[i];
    for(int i=n-2;i>=n/2;i--) ans+=A[i];
    if(n%2==0) ans+=A[n/2];
    cout << ans << endl;
}

Measured memory_bytes: 4048
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

string slice_vec(string s, int start, int end = 0)
{
    if (end == 0)
        end = s.size();
    string res = "";
    for (int i = start; i < end; i++)
    {
        if (start > end)
        {
            return "error";
        }
        res.push_back(s[i]);
    }
    return res;
}

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    int cnt = 0;
    rep(i, N)
    {
        int input = 0;
        cin >> input;
        if (input % 2 != 0)
        {
            cnt++;
        }
    }
    if (cnt % 2 == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


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

using namespace std;

#define X first
#define Y second
#define ll long long
#define inf (ll)1e18
const int mod = (int)1e9 + 7;
#define all(x) x.begin(), x.end()

const int N = 1000060;
const int MX = 200020;

int mx = (int)(1e5) + 10;
int p[MX];
int a[MX];

int main(){
/*
     ___     ___
    (^_^)   (^_^)
   /( | )\ /( | )\
     | |     | |
*/
    cin.tie(0);
    cin.sync_with_stdio(0);

    #ifdef Cyborg101
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    p[1] = 1;
    // p[0] = 1;
    for(int i = 2; i < mx; ++i){
    	if(!p[i])
    		for(int j = i + i; j < mx; j += i){
    			p[j] = 1;
    		}
    }

    for(int i = 1; i < mx; ++i){
    	if((i & 1) && !p[i] && !p[(i + 1) / 2])
    		a[i]++;
    	a[i] += a[i - 1];
    }

    int m;
    cin >> m;
    while(m--){
    	int l, r;
    	cin >> l >> r;
    	cout << a[r] - a[l - 1] << endl;
    }

   	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll h, n;
    cin >> h >> n;
    REP(i, 0, n) {
        int a;
        cin >> a;
        h -= a;
    }
    cout << (h <= 0 ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()
from collections import deque
N = int(input())
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

P = [-1] * N
Q = deque([0])
R = []
while Q:
    i = deque.popleft(Q)
    R.append(i)
    for a in X[i]:
        if a != P[i]:
            P[a] = i
            X[a].remove(i)
            deque.append(Q, a)

G = [0] * N
for i in R[::-1]:
    s = 0
    for j in X[i]:
        s ^= G[j]
    G[i] = s + 1

print("Bob" if G[0] == 1 else "Alice")

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

using namespace std;

const int max_n = 55, inf = 1000111222;
const int max_k = 18;

int n, k, a[max_n], need_or, need_and;
int cnt[1 << max_k];
long long c[max_n][max_n];

void get_all_c() {
    for (int i = 0; i < max_n; ++i) {
        c[i][0] = 1;
        for (int j = 1; j <= i; ++j) {
            c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
        }
    }
}

bool is_submask(int x, int y) {
    return (x & y) == x;
}

void no() {
    cout << 0 << endl;
    exit(0);
}

bool get_bit(int mask, int pos) {
    return (mask >> pos) & 1;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    get_all_c();
    cin >> n >> k >> need_and >> need_or;
    if (!is_submask(need_and, need_or)) {
        no();
    }
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (!is_submask(a[i], need_or) || !is_submask(need_and, a[i])) {
            --i;
            --n;
        }
    }
    vector<int> ids;
    for (int i = 0; i < 18; ++i) {
        if (get_bit(need_or, i) && !get_bit(need_and, i)) {
            ids.push_back(i);
        }
    }
    for (int i = 0; i < n; ++i) {
        int x = 0;
        for (int j = 0; j < ids.size(); ++j) {
            if (get_bit(a[i], ids[j])) {
                x += 1 << j;
            }
        }
        a[i] = x;
    }
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        memset(cnt, 0, sizeof(cnt));
        for (int j = i + 1; j < n; ++j) {
            a[j] ^= a[i];
            ++cnt[a[j]];
        }
        for (int j = 0; j < ids.size(); ++j) {
            for (int mask = 0; mask < (1 << ids.size()); ++mask) {
                if (!get_bit(mask, j)) {
                    cnt[mask | (1 << j)] += cnt[mask];
                }
            }
        }
        for (int mask = 0; mask < (1 << ids.size()); ++mask) {
            int z = 1;
            for (int j = 0; j < ids.size(); ++j) {
                if (!get_bit(mask, j)) {
                    z *= -1;
                }
            }
            for (int j = 0; j < k && j <= cnt[mask]; ++j) {
                ans += z * c[cnt[mask]][j];
            }
        }

        for (int j = i + 1; j < n; ++j) {
            a[j] ^= a[i];
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4672
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int A[300][300];
	bool B[300][300] = {};
	bool owari = false;
	rep(i, N) rep(j, N) A[i][j] = getint();

	rep(i, N) {
		rep(j, i) {
			rep(k, j) {
				if (A[i][j] == A[i][k] + A[j][k]) B[i][j] = true;
				else if (A[i][j] > A[i][k] + A[j][k]) owari = true;
			}
			for (int k = j + 1; k < i; k++) {
				if (A[i][j] == A[i][k] + A[j][k]) B[i][j] = true;
				else if (A[i][j] > A[i][k] + A[j][k]) owari = true;
			}
			for (int k = i + 1; k < N; k++) {
				if (A[i][j] == A[i][k] + A[j][k]) B[i][j] = true;
				else if (A[i][j] > A[i][k] + A[j][k]) owari = true;
			}
		}
	}

	if (owari) {
		printf("-1");
		return 0;
	}
	ll kotae = 0;
	rep(i, N) rep(j, i) {
		if (!B[i][j]) kotae += A[i][j];
	}
	printf("%lld", kotae);

	Would you please return 0;
}

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

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

    if (s.length() <= k) {
        cout << s << endl;
    } else {
        cout << s.substr(0, k) << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
using namespace std;

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

const ll MAX_N = 6e5 + 25, MAX_M = 1500000, MOD = 1e9 + 7;
ll n, ans;
ll Arr[MAX_N];
ll dp[MAX_N];
ll DP[MAX_N];
ll ind;
vector <ll> vec[MAX_N];
vector <pii> P[MAX_M];
unordered_map <ll, ll> Map;

ll _sum (ll a, ll b) {
	ll c = a + b;
	if (MOD <= c)
		c -= MOD;

	return c;
}

ll _mul (ll a, ll b) {
	ll c = 1LL * a * b % MOD;
	return c;
}

ll _pow (ll a, ll b) {
	if (!b)
		return 1;

	ll res = _pow(a, b >> 1);
	res = _mul(res, res);

	if (b & 1)
		res = _mul(res, a);

	return res;
}

void solve1(ll tmp) {
	ll a = 1, b = 0, x = 0;
	for (ll i = 0; i < n; i++) {
		x ^= Arr[i];

		if (x != 0 && x != tmp)
			continue;

		if (x == 0) {
			dp[i] = b;
			a = _sum(a, dp[i]);
		}
		else {
			dp[i] = a;
			b = _sum(b, dp[i]);
		}
	}

	cout << dp[n - 1] << "\n";
}

ll calc1() {
	ll x = 0, cnt = 0;
	for (ll i = 0; i < n; i++) {
		x ^= Arr[i];
		if (!x)
			cnt++;
	}

	return _pow(2, cnt - 1);
}

ll calc2(ll tmp) {
	ll res = P[tmp][0].second;
	DP[0] = 0;
	dp[0] = P[tmp][0].second;

	for (ll i = 1; i < P[tmp].size(); i++) {
		dp[i] = _mul(_mul(dp[i - 1], P[tmp][i].second), P[tmp][i].first - P[tmp][i - 1].first);
		ll f = _mul(dp[i - 1], _pow(P[tmp][i - 1].second, MOD - 2));
		f = _sum(f, _mul(P[tmp][i].first - P[tmp][i - 1].first, DP[i - 1]));
		dp[i] = _sum(dp[i], _mul(f, P[tmp][i].second));

		DP[i] = _sum(DP[i - 1], dp[i - 1]);
		res = _sum(res, dp[i]);
	}

	return res;
}

void process1() {
	ll x = 0;
	for (ll i = 0; i < n; i++) {
		vec[ind].push_back(Arr[i]);
		x ^= Arr[i];
		if (!x)
			ind++;
	}
}

void process2() {
	for (ll i = 0; i < ind; i++) {
		Map.clear();
		ll x = 0;
		for (ll j = 0; j + 1 < vec[i].size(); j++) {
			x ^= vec[i][j];
			Map[x]++;
		}

		for (auto t: Map)
			P[t.first].push_back({i, t.second});
	}
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (ll i = 0; i < n; i++)
		cin >> Arr[i];

	ll tmp = 0;
	for (ll i = 0; i < n; i++)
		tmp ^= Arr[i];

	if (tmp) {
		solve1(tmp);
		return 0;
	}

	ans = calc1();
	process1();
	process2();

	for (ll i = 0; i < MAX_M; i++)
		if (P[i].size())
			ans = _sum(ans, calc2(i));

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


Measured memory_bytes: 76288
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b):
    return a*b//gcd(a,b)

n = I()
a = LI()
l = 1
for i in range(n):
    l = lcm(l,a[i])

ans = 0
l %= mod
for i in range(n):
    ans += l *pow(a[i],mod-2,mod)
    ans %= mod
print(ans)


Measured memory_bytes: 71784
import itertools
import numpy as np
N,M,X=map(int, input().split())
book = []
for _ in range(N):
    book.append(list(map(int, input().split())))
book = np.array(book)
money=pow(10,7)
for i in itertools.product([0,1], repeat=N):
    book2=book
    dellist = []
    for n,l in enumerate(i):
        if l==0:
            dellist.append(n)
    book2=np.delete(book2, dellist, 0)
    ansar = np.sum(book2,axis=0)
    if np.sum(ansar[1:]>=X)==M:
        if money>ansar[0]:
            money = ansar[0]
if money == pow(10,7):
    print(-1)
else:
    print(money)


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

long long int rec(int* arr, int i, int j, vector<vector<long long int>>& dp, vector<vector<bool>>& vis){
    if(vis[i][j])
        return dp[i][j];
    vis[i][j]=1;
    if(i==j) return dp[i][j] = arr[i];
    return dp[i][j] = max(arr[i]-rec(arr,i+1,j,dp,vis),arr[j]-rec(arr,i,j-1,dp,vis));
}

int main() {
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    vector<vector<long long int>> dp(n+1, vector<long long int>(n+1, -1));
    vector<vector<bool>> vis(n+1, vector<bool>(n+1, false));
    cout<<rec(arr,0,n-1,dp,vis)<<"\n";
}

Measured memory_bytes: 75632
N[]={ 6, 14, 18, 10,  2,  9, 22, 15,  1, 17, 23,  7,  3,  5, 21, 19,  0, 13, 20, 11,  4,  8, 16, 12};
E[]={13, 17,  9,  5,  8, 21, 14,  1, 16, 22,  6,  0,  4, 20, 18,  2, 12, 23, 10,  3, 11, 19, 15,  7};
R[]={ 3,  0,  1,  2,  7,  4,  5,  6, 11,  8,  9, 10, 15, 12, 13, 14, 19, 16, 17, 18, 23, 20, 21, 22};
a=-1;
d;
char s[9];
main(c)
{
	for(;c-48&&scanf("%s",s);a+=d/4+1)
	{
		if((c=*s)<60)
			~a&&printf("%d\n",a),
			a=d=0;
		if(c=='N')d=N[d];
		if(c=='S')d=N[N[N[d]]];
		if(c=='E')d=E[d];
		if(c=='W')d=E[E[E[d]]];
		if(c=='R')d=R[d];
		if(c=='L')d=R[R[R[d]]];
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18;
const int iINF = 1e9;
int main(){
    ll n,F[101][11],P[101][11];
    cin>>n;
    rep(i,n)rep(j,10)cin>>F[i][j];
    rep(i,n)rep(j,11)cin>>P[i][j];
    ll ans = -iINF,bit = pow(2,10);
    repi(i,1,bit){
        ll tmp = 0;
        rep(j,n){
            ll cnt = 0;
            rep(k,10)if(i&(1<<k)&&F[j][k])cnt++;
            tmp += P[j][cnt];
        }   
        ans = max(ans,tmp);
    }
    cout<<ans<<endl;
}




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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    long long r, d, x;
    cin>>r>>d>>x;
    int i, j;
    for(i=0; i<10; i++){
        cout<<r*x-d<<endl;
        x = r*x-d;   
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }


int main() {
  i64 N, K;
  cin >> N >> K;
  vector<i64> A(N);
  rep(i,0,N) cin >> A[i];
  rep(k,0,K) {
    bool OK = true;
    rep(i,0,N) {
      if(A[i] != N) {
        OK = false;
        break;
      }
    }
    if(OK) {
      break;
    }
    vector<i64> B(N);
    rep(i,0,N) {
      i64 l = std::max(i - A[i], 0ll);
      i64 r = std::min(N - 1, i + A[i]);
      B[l] += 1;
      if(r + 1 < N) {
        B[r + 1] -= 1;
      }
    }
    rep(i,1,N) {
      B[i] += B[i - 1];
    }
    swap(B, A);
  }
  rep(i,0,N) {
    cout << A[i] << " \n"[i + 1 == N];
  }
}


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

int main(void){
    double n, t, a;
    cin >> n >> t >> a;

    double score, dis;
    double min = 10000,log;

    vector<int> height(n);
    for (int i = 0; i < n;i++){
        score = 0, dis = 0;
        cin >> height.at(i);

        score = t - height.at(i) * 0.006;
        dis = abs(a-score);
        if(min>dis){
            min = dis;
            log = i+1;
        }
    }
    cout << log << endl;
    return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc150/submissions/9394047

from itertools import permutations

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

perms = tuple(permutations(range(1, N + 1)))
p = perms.index(P)
q = perms.index(Q)
print(abs(p - q))


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 1000000000000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    ll A,B,Q; cin>>A>>B>>Q;
    vector<ll> S(A+2);
    vector<ll> T(B+2);
    rep1(i,A)cin>>S.at(i);
    rep1(i,B)cin>>T.at(i);
    S.at(0) = T.at(0) = -INF;
    S.at(A+1) = T.at(B+1) = INF;
    rep(i,Q){
        ll x; cin>>x;
        auto iter1 = lower_bound(S.begin(),S.end(),x);
        auto iter2 = lower_bound(T.begin(),T.end(),x);
        auto ind1 = distance(S.begin(),iter1);
        auto ind2 = distance(T.begin(),iter2);
        ll s_b,s_f,t_b,t_f;
        s_f=(S.at(ind1)-x);
        s_b=x-S.at(ind1-1);
        t_f=(T.at(ind2)-x);
        t_b=x-T.at(ind2-1);
        ll r1 = max(s_f,t_f);
        ll r2 = max(s_b,t_b);
        ll r3 = min(2*s_b+t_f,2*t_b+s_f);
        ll r4 = min(2*s_f+t_b,2*t_f+s_b);
        cout<<min({r1,r2,r3,r4})<<endl;
    }
}


Measured memory_bytes: 2944
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcd(long long a,long long b){return a*b / gcd(a,b) / gcd(a,b);}
int main()
{
	int S,W;
	cin>>S>>W;
	if(S>W)
	{
		cout<<"safe"<<endl;
	}
	else
	{
		cout<<"unsafe"<<endl;
	}
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	ll x = 0,y = 0;
	ll index = 0;
	for (int i = n - 1; i > 0; i--) {
		if (a[i] == a[i - 1]) {
			x = a[i];
			index = i - 2;
			break;
		}
	}

	for (int i = index; i > 0; i--) {
		if (a[i] == a[i - 1]){
			y = a[i];
			break;
		}
	}
	cout << x * y << endl;
	return 0;
}


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

using std::cerr;
using std::endl;

const int N = 5e5 + 233;

int n, K, P[N], ans[N];

#define ls (p << 1)
#define rs (ls | 1)
#define mid ((L + R) >> 1)

int max[N * 4];

void build(int p, int L, int R) {
  if (L == R)
    return max[p] = L, void();
  build(ls, L, mid);
  build(rs, mid + 1, R);
  max[p] = P[max[ls]] > P[max[rs]] ? max[ls] : max[rs];
}

void remove(int p, int x, int L, int R) {
  if (L == R)
    return max[p] = 0, void();
  if (x <= mid)
    remove(ls, x, L, mid);
  else
    remove(rs, x, mid + 1, R);
  max[p] = P[max[ls]] > P[max[rs]] ? max[ls] : max[rs];
}

int query(int p, int l, int r, int L, int R) {
  if (l <= L && r >= R)
    return max[p];
  if (l <= mid && r > mid) {
    int x = query(ls, l, r, L, mid),
        y = query(rs, l, r, mid + 1, R);
    return P[x] > P[y] ? x : y;
  }
  if (l <= mid)
    return query(ls, l, r, L, mid);
  else
    return query(rs, l, r, mid + 1, R);
}

std::priority_queue<int> que;
bool vis[N];

inline void check(int x) {
  if (!vis[x]) {
    int l = std::max(1, x - K + 1),
        r = std::min(n, x + K - 1);
    if (query(1, l, r, 1, n) == x) {
      que.push(x);
      vis[x] = 1;
    }
  }
}

int main() {
  // freopen("data", "r", stdin);
  scanf("%d %d", &n, &K);
  for (int i = 1; i <= n; ++i)
    scanf("%d", P + i);
  P[0] = -1e9;
  build(1, 1, n);
  for (int i = 1; i <= n; ++i)
    check(i);
  for (int i = n; i; --i) {
    int x = que.top(); que.pop();
    ans[x] = i;
    remove(1, x, 1, n);
    int tmp, l, r;
    l = std::max(1, x - K + 1);
    r = std::max(l, x - 1);
    tmp = query(1, l, r, 1, n);
    if (tmp) check(tmp);
    r = std::min(n, x + K - 1);
    l = std::min(r, x + 1);
    tmp = query(1, l, r, 1, n);
    if (tmp) check(tmp);
  }
  for (int i = 1; i <= n; ++i)
    printf("%d\n", ans[i]);
  return 0;
}



Measured memory_bytes: 15856
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	string n;
	cin>>n;
	cout<<(n.at(0)=='9'||n.at(1)=='9'?"Yes":"No")<<endl;
}


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

int main(void) {
    int a, b, c;
    int cnt = 0;
    cin >> a >> b >> c;
    for (int i = a; i <= b; i++) {
        if (c % i == 0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <cmath>
using namespace std;

int main(){
    long long A,B,N;
    cin>>A>>B>>N;
    long long min_=min(B-1,N);
    long result=floor(A*min_/B)- A*floor(min_/B);
    cout<<result<<endl;

}



Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<climits>

using namespace std;

typedef long long ll;

ll A,B,C,D,N; vector<ll>l;

ll dfs(ll depth, ll LA, ll LB, ll LC){
  if( depth == N ){ 
    if(LA == 0 || LB == 0 || LC == 0){ return INT_MAX;}
     else{ return abs( LA - A) + abs( LB - B ) + abs( LC - C) - 30 ;}}
  
   ll ret1 = dfs( depth+1, LA + l[depth],LB,LC) + 10 ;
   ll ret2 = dfs( depth+1, LA, LB + l[depth], LC) + 10;
   ll ret3 = dfs( depth+1, LA, LB, LC + l[depth]) + 10;
   ll ret4 = dfs( depth+1, LA,LB,LC);
  
   return min(min(ret1,ret2),min(ret3,ret4));}
  

int main(){
 cin >> N >> A >> B >> C;
 l.resize(N);
  for(ll i = 0; i < N; i++){ cin >> l[i];}
  cout << dfs(0,0,0,0) << endl; return 0;}
  
  
  
  

Measured memory_bytes: 256
import collections
import numpy as np

def prime_factorize(n):
	a = 0   
	while n % 2 == 0:
		a+=1
		n //= 2
	return a

N =int(input())

a = [int(i) for i in input().split()]

ans_array = np.zeros(N)

for i in range(N):
    dummy = prime_factorize(a[i])
  
    ans_array[i] = dummy
ans = int(sum(ans_array))
print(ans)


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

int main(void)
{
  string S; cin>>S;
  int ans=0;
  for(int i=0;i<3;i++){
  	if(S[i]=='o')ans++;
  }
  cout<<700+ans*100<<endl;

  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
ia = ib = 0
ans = 1
mod = 10**9 + 7
for n in range(N*M, 0, -1):
    i = N*M - n
    if ia < N and ib < M and A[ia]==B[ib]==n:
        ia += 1
        ib += 1
    elif ia < N and A[ia]==n:
        ia += 1
        ans *= ib
    elif ib < M and B[ib]==n:
        ib += 1
        ans *= ia
    else:
        ans *= ia * ib - i
    #print(ia, ib, ia*ib-i)
    ans %= mod
print(ans)


Measured memory_bytes: 3188
parseInt(x) = parse(Int, x)

function main()
	n = parseInt(readline())
	a = map(parseInt, split(readline()))
	d = zeros(Int, n)
	for i in 1:n
		d[a[i]+1] += 1
	end
	flg = 0
	if n%2 == 0
		for i in 1:n
			if i%2 == 0 && d[i] != 2
				flg = 1
			elseif i%2 == 1 && d[i] != 0
				flg = 1
			end
		end
	else
		d[1] += 1
		for i in 1:n
			if i%2 == 0 && d[i] != 0
				flg = 1
			elseif i%2 == 1 && d[i] != 2
				flg = 1
			end
		end
	end
    
	if flg == 1
		print(0)
	else
		x = 1
		for i in 1:div(n,2)
			x=(x*2)%1000000007
		end
		print(x)
	end
end

main()

Measured memory_bytes: 167136
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string s;
  cin >> s;

  int n = (int)s.size();
  if (s[0] != 'A') {
    cout << "WA" << endl;
    return 0;
  }

  int tc = 0;
  int cok = false;
  rep(i, 1, n) {
    if (isupper(s[i]))
      tc++;
    if (i >= 2 && i <= n - 2) {
      if (s[i] == 'C')
        cok = true;
    }
  }

  if (cok && tc == 1)
    cout << "AC" << endl;
  else
    cout << "WA" << endl;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MOD=1e9+7;
int inv(int a)

{

	return a==1?1:(long long)(MOD-MOD/a)*inv(MOD%a)%MOD;

}

LL C(LL n,LL m)

{

	if(m<0)return 0;

	if(n<m)return 0;

	if(m>n-m)m=n-m;

	LL up=1,down=1;

	for(LL i=0;i<m;i++)

	{

		up=up*(n-i)%MOD;

		down=down*(i+1)%MOD;

	}

	return up*inv(down)%MOD;

}

//LL comb(LL m,LL n){
//	return (m==0 || n==0)?1:comb(m-1,n-1)*n/m;
//}
int main(){
	LL x,y;
	cin>>x>>y;
	if(x>y) swap(x,y);
	if((2*y-x)%3!=0){
		printf("%d\n",0);
	}
	else{
		LL a=(2*y-x)/3;
		LL b=(x-a)/2;
		printf("%lld\n",C(a+b,a));
	}
} 

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

using namespace std;

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

    long long ans = 11;
    for(long long i = 1; i < sqrt(N)+1; i++){
        if(N % i == 0){
            // cout << "i : " << i << " N/i : " << N/i << endl;
            // cout << (long long)log10(i)+1LL << " " <<  (long long)log10(N/i)+1LL << endl;
            ans = min(ans, max((long long)log10(i)+1LL, (long long)log10(N/i)+1LL));
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  string W[N];
  for (int i = 0; i < N; i++){
    cin >> W[i];
  }

  int flg = 0;
  for (int i = 1; i < N; i++){
    if(W[i-1].back() != W[i].front()) flg = 1;
  }
  
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      if (i != j && W[i] == W[j]) flg = 1;
    }
  }
  
  if (flg==0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
}


Measured memory_bytes: 3560
#include <iostream>
#include <vector>

using namespace std;

int n, t;
vector<int> G[101];
int d[101], f[101];
bool used[101];

void dfs(int v) {
	used[v] = true;
	d[v] = ++t;
	for (int i = 0; i < G[v].size(); ++i) {
		int e = G[v][i];
		if (!used[e]) dfs(e);
	}
	f[v] = ++t;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int u, k; cin >> u >> k;
		while (k--) {
			int v; cin >> v;
			G[u].push_back(v);
		}
	}

	for (int i = 1; i <= n; ++i)
		if(!used[i]) dfs(i);

	for (int i = 1; i <= n; ++i)
		cout << i << " " << d[i] << " " << f[i] << endl;

	return 0;
}


Measured memory_bytes: 3160
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**10
mod = 10 ** 9 + 7

class Dinic:
    def __init__(self, v, inf=10**10):
        self.v = v
        self.inf = inf
        self.G = [[] for _ in range(v)]
        self.level = [-1]*v  # 深さ
        self.ite = [0]*v  # DFSでの探索が済んでいるか
    def add_edge(self, fr, to, cap):
        self.G[fr].append([to, cap, len(self.G[to])])
        self.G[to].append([fr, 0, len(self.G[fr])-1])
    def bfs(self, s):  # BFSで深さ決定,sがstart
        self.level = [-1]*self.v  # 必要
        self.level[s] = 0
        Q = deque()
        Q.append(s)
        while Q:
            v = Q.popleft()
            for i in range(len(self.G[v])):
                e = self.G[v][i]
                if e[1]>0 and self.level[e[0]]<0: ###capacity>0かつtoの深さ未定
                    self.level[e[0]] = self.level[v]+1
                    Q.append(e[0])
    def dfs(self, v, t, f):  # DFSで増加パス探索,v開始、t終点、総フローf
        if v==t:
            return f
        for i in range(self.ite[v], len(self.G[v])):
            self.ite[v] = i
            e = self.G[v][i]
            if e[1]>0 and self.level[v]<self.level[e[0]]:
                d = self.dfs(e[0], t, min(f, e[1]))
                if d>0:
                    e[1] -= d  # cap減少
                    self.G[e[0]][e[2]][1] += d  # 逆辺のcap増加
                    return d
        return 0
    def max_flow(self, s, t):
        flow = 0
        while True:
            self.bfs(s)
            if self.level[t]<0:
                return flow
            self.ite = [0]*self.v  # DFSでの探索が済んでいるか否か
            f = self.dfs(s,t,self.inf)
            while f>0:
                flow += f
                f = self.dfs(s,t,self.inf)

R, C = MAP()
S = [input() for _ in range(R)]

D = Dinic(3*R*C+2)
s = 3*R*C
t = s+1

block = 0
adj = 0

for i in range(R):
    for j in range(C):
        if S[i][j] == ".": continue
        block += 1
        if i+1 < R and S[i+1][j] == "#":  # 縦
            adj += 1
            newv = R*C+C*i+j
            D.add_edge(newv, t, 1)
            D.add_edge(C*i+j, newv, INF)
            D.add_edge(C*(i+1)+j, newv, INF)

        if j+1 < C and S[i][j+1] == "#":  # 横
            adj += 1
            newv = 2*R*C+C*i+j
            D.add_edge(s, newv, 1)
            D.add_edge(newv, C*i+j, INF)
            D.add_edge(newv, C*i+(j+1), INF)

print(block-(adj-D.max_flow(s, t)))



Measured memory_bytes: 7816
X = int(input())

if X % 7 == 0:
    print("thu")
elif X % 7 ==1:
    print("fri")
elif X % 7 ==2:
    print("sat")
elif X % 7 ==3:
    print("sun")
elif X % 7 ==4:
    print("mon")
elif X % 7 ==5:
    print("tue")
elif X % 7 ==6:
    print("wed")


Measured memory_bytes: 5592
#include<stdio.h>
int main(void)
{
	int a,b;
	int x;
	scanf("%d %d",&a,&b);
	x=a+b;
	if(a%3==0||b%3==0||x%3==0){
		printf("Possible\n");
	}
	else{
		printf("Impossible\n");
	}
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		int[] a = {1, 2, 5, 7, 9, 11, 15, 19, 21, 23, 25};
		for(int i = 0; i < n; i++) {
			String[] s = sc.nextLine().split(" ");
			int l = s.length;
			String[] k = new String[l];
			boolean flag = false;
			loop: for(int m : a) {
				for(int j = 0; j < 26; j++) {
					for(int o = 0; o < l; o++) {
						k[o] = afin(s[o], m, j);
						if(check(k[o])) {
							flag = true;
						}
					}
					if(flag) {
						for(int o = 0; o < l; o++) {
							if(o != l - 1) {
								System.out.print(k[o] +" ");
							}else {
								System.out.println(k[o]);
							}
						}
						break loop;
					}
				}
			}
		}
		sc.close();
	}
	static String afin(String s, int a, int b) {
		int l = s.length();
		String ret = "";
		for(int i = 0; i < l; i++) {
			char c = s.charAt(i);
			int t = (c - 'a') * a + b;
			t %= 26;
			char c1 = (char)(t + 'a');
			ret += c1;
		}
		return ret;
	}
	static boolean check(String s) {
		if(s.equals("that") || s.equals("this")){
			return true;
		}else {
			return false;
		}
	}
}


Measured memory_bytes: 36704
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  int a , b , c;
  cin >> a >> b >> c;
  if(a + b >= c)cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main()
{
	
	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;
	}
    return 0;

}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

// 300, 15min

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

string S;

signed main()
{
    cin >> S;
    string new_s;
    char prev;
    REP(i, S.length()) {
        if(i == 0) {
            new_s += S[i];
            prev = S[i];
            continue;
        }
        if(prev != S[i]) {
            new_s += S[i];
        }
        prev = S[i];
    }
    printf("%lld\n", new_s.length()-1);
    return 0;
}


Measured memory_bytes: 512