akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N, M;
    int A[100];
    cin >> N >> M;
    int voteSum = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        voteSum += A[i];
    }
    sort(A, A + N, greater<int>());
    double needed = (double) voteSum / (M * 4);
    bool canSelect = 0;
    for(int i = 0; i < M; i++){
    if (A[i] >= needed) canSelect = 1;
    else {
        canSelect = 0;
        break;
    }
    }
    if (canSelect) cout << "Yes";
    else cout << "No";
    return 0;
}


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;
const int INF = INT_MAX / 2;
const int MOD = 1e9 + 7;

int main() {
	string s; cin >> s;
	int N = s.length();
	if (N > 9) {
		cout << "NO" << endl;
		return 0;
	}
	string akb = "AKIHABARA";
	vector<bool> a(9);
	rep(i, N) a[8 - i] = true;
	do {
		bool ok = true;
		int j = 0;
		rep(i, 9) {
			if (a[i] && s[j] != akb[i]) ok = false;
			if (a[i]) j++;
			if (!a[i] && akb[i] != 'A') ok = false;
		}
		if (ok) {
			cout << "YES" << endl;
			return 0;
		}
	} while (next_permutation(a.begin(), a.end()));
	cout << "NO" << endl;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    string s;
    cin >> s;

    int n = s.size();

    cout << s[0] << n - 2 << s[n - 1] << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = list(s())
if ''.join(reversed(N)) == ''.join(N):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9864
//In The Name Of God
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<double, double> dd;
typedef pair<dd, double> ddd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<dd> vdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ii> vii;
typedef vector<vii> vvii;

#define forn(i, n) for (int i = 0; i < n; i++)
#define forr(i, n) for (int i = n; i >= 0; i--)
#define forne(i, x, n) for (int i = x; i < n; i++)
#define forre(i, x, n) for (int i = n; i >= x; i--)
#define all(a) (a).begin(), (a).end()
#define inf 1000000000
#define eps 1e-9
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());

set<string> bad;
string good = "ACGT";

bool cont(string s) {
    forn(i, s.size()) {
        if (i + 2 > s.size()) return false;
        if (s.substr(i, 3) == "AGC") return true;
    }
    return false;
}

void fin(string &s) {
    if (s.size() >= 3) {
        bool ok = cont(s);
        forne(i, 1, s.size()) {
            swap(s[i], s[i - 1]);
            if (cont(s)) {
                ok = true;
                swap(s[i], s[i - 1]);
                break;
            }
            swap(s[i], s[i - 1]);
        }
        if (ok) bad.insert(s);
    }
    if (s.size() == 5) return;
    for (auto &e : good) {
        s += e;
        fin(s);
        s.pop_back();
    }
}

ll mod = 1e9 + 7, n;
map<pair<string, int>, ll> dp;

ll solve(string lst, int i) {
    if (bad.count(lst)) return 0;
    if (i == n) return 1;
    if (dp.count({lst, i}))
        return dp[{lst, i}];
    dp[{lst, i}] = 0;
    ll &cur = dp[{lst, i}];
    if (lst.size() == 5)
        lst = lst.substr(1, 4);
    for (auto &e : good) {
        lst += e;
        cur = (cur + solve(lst, i + 1)) % mod;
        assert(lst.size());
        lst.pop_back();
    }
    return cur;
}

int main() {
    ios::sync_with_stdio(0);
    string tmp;
    fin(tmp);
    bad.insert("AGC");
//    for (auto &e : bad) if (e.size() == 3)
//        cout << e << endl;
//    cout << bad.size() << endl;
    tmp.clear();
    cin >> n;
    cout << solve(tmp, 0) << endl;

    return 0;
}


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

using namespace std;

map <int,int> m;

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

    for(int i=0;i<k;i++)
    {
        cin >> x;
        m[x]++;
    }

    while(true)
    {
        int temp = n;
        bool flag = true;

        while(temp)
        {
            if(m[temp%10] == 1)
            {
                flag = false;
                break;
            }

            temp /= 10;
        }

        if(flag)
            break;

        n++;
    }

    cout << n << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
main(){
    ll n,turn=0,ans=0;
    cin>>n;
    ll a[n],b[n];
    pair<ll,ll>c[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        c[i].first=a[i]+b[i];
        c[i].second=i;
    }
  sort(c, c+n, [](pair<int, int>p, pair<int,int>q){
  return p.first > q.first;
});
    for(int i=0;i<n;i++){
        if(turn==0){
            ans+=a[c[i].second];
            turn=1;
        }
        else{
            ans-=b[c[i].second];
            turn=0;
        }
    }
 
    cout<<ans<<endl;
 
 
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;
}

Measured memory_bytes: 3628
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1 << 30;

int n;
int a[1233];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++)scanf("%d",&a[i]);
	sort(a+1,a+2*n+1);
	int ans=0;
	for(int i=1;i<=2*n;i+=2)
		ans+=a[i];
	printf("%d\n",ans);

	return 0;
}


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

struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int N,X,T;cin >> N >> X >> T;
    if(N%X==0)cout << (N/X)*T << endl;
    else cout << ((N/X)+1)*T << endl;
    return 0;
}

Measured memory_bytes: 3548
/*
------------------------------|بسم الله الرحمن الرحيم|------------------------------//
------------"IN THE NAME OF ALLAH, THE MOST GRACIUOS, THE MOST MERCIFUL"-------------//
__________________________________ShahnawazShaikh_____________________________________
*/
 
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define int int64_t
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);	
int n,d;
int cnt=0;
cin>>n>>d;
while(n--){
int x,y;
 cin>>x>>y;
 if(x*x+y*y<=d*d)
 	 cnt+=1;
}
cout<<cnt;
return 0;	
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int K,N;
void print(vector<int> &vec){
	for(int i=0;i<vec.size();i++){
		cout << vec[i];
		if(i+1<vec.size())cout << ' ';
		else cout << endl;
	}
	return;
}
int main(){
	cin >> K >> N;
	vector<int> ans;
	if(K%2==0){
		ans.pb(K/2);
		for(int i=0;i<N-1;i++)ans.pb(K);
		print(ans);
		return 0;
	}
	for(int i=0;i<N;i++){
		ans.pb((K+1)/2);
	}
	for(int i=0;i<N/2;i++){
		if(ans.back()==1){
			ans.pop_back();
		}else{
			ans.back()--;
			while(ans.size()<N)ans.pb(K);
		}
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 3568
#include <stdio.h>
#include <stdlib.h>
 
int main(void) {
  char a, b, c;
  scanf("%c%c%c", &a,&b,&c);
  a-='0';
  b-='0';
  c-='0';
 
  printf("%d", a+b+c);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 40, MOD = 1e9 + 7;

int N, M, L;

const int MXV = 305;
int d[305][305];
int wd[305][305];
int Q;
vector<pii> vq;

void input() {
  cin >> N >> M >> L;
  int a, b, c;
  rep(i, 0, 304) {
    rep(j, 0, 304) {
      wd[i][j] = INF;
      if (i == j) wd[i][j] = 0;
    }
  }
  rep(i, 1, M) {
    cin >> a >> b >> c;
    if (c > L) {
      continue;
    }
    d[a][b] = c;
    d[b][a] = c;
    wd[a][b] = c;
    wd[b][a] = c;
  }

  //=
  cin >> Q;
  vq.resize(Q);
  rep(i, 0, Q - 1) { cin >> vq[i].first >> vq[i].second; }
}

int nxtg[MXV][MXV];
void solve() {
  rep(k, 1, N) {
    rep(i, 1, N) {
      rep(j, 1, N) {
        // if (wd[i][k] == INF || wd[k][j] == INF) continue;  // 道がない場合
        wd[i][j] = min(wd[i][j], wd[i][k] + wd[k][j]);
      }
    }
  }

  rep(i, 1, N) {
    rep(j, 1, N) {
      if (i == j) {
        nxtg[i][j] = 0;
      } else {
        nxtg[i][j] = INF;
      }
    }
  }

  rep(i, 1, N) {
    rep(j, 1, N) {
      if (i == j) continue;
      if (wd[i][j] <= L) {
        nxtg[i][j] = 1;
      }
    }
  }

  rep(k, 1, N) {
    rep(i, 1, N) {
      rep(j, 1, N) {
        // if (nxtg[i][k] == INF || nxtg[k][j] == INF) continue;
        nxtg[i][j] = min(nxtg[i][j], nxtg[i][k] + nxtg[k][j]);
      }
    }
  }

  for (auto query : vq) {
    int asa = nxtg[query.first][query.second];
    if (asa < INF) {
      cout << asa - 1 << endl;
    } else {
      cout << -1 << endl;
    }
  }
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <cmath>
#include <limits>
#define ll long long
using namespace std;
int main(){
    int N;
    cin >> N;
    int ans=0;
    for(int i=1;i<=N;i++){
        ans = ans + i;
    }
    cout << ans << endl;
}

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

int main() {
    ll N;
    cin >> N;
    vector<double> A(N);
    for (auto& a : A) {
        cin >> setprecision(9) >> a;
    }

    vector<vector<ll>> mat(100, vector<ll>(100));
    for (ll i = 0; i < N; ++i) {
        ll a = (ll)(A[i] * 1e9+0.5);
        int n5 = 0;
        while (a % 5 == 0) {
            a /= 5;
            ++n5;
        }
        int n2 = 0;
        while(a % 2 == 0) {
            a /= 2;
            ++n2;
        }
        mat[n2][n5] += 1;
    }

    vector<vector<ll>> count(100, vector<ll>(100));
    for (int k = 0; k < 100; ++k) {
        for (int l = 0; l < 100; ++l) {
            for (int i = k; i < 100; ++i) {
                for (int j = l; j < 100; ++j) {
                    count[k][l] += mat[i][j];
                }
            }
        }
    }
    
    ll num = 0;
    for (int k = 0; k < 9; ++k) {
        for (int l = 0; l < 100; ++l) {
            num += mat[k][l] * count[18-k][18-l];
        }
    }
    for (int k = 9; k < 100; ++k) {
        for (int l = 0; l < 9; ++l) {
            num += mat[k][l] * count[9][18-l];
        }
    }
    ll num99 = count[9][9] * (count[9][9] - 1) / 2;
    num += num99;

    cout << num << endl;

}

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

int main(void){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans = 1001001001;
  rep(i,n) {
    int cnt = 0;
    while(a[i] % 2 == 0) {
      a[i] /= 2;
      cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let s = sc.chars();
    let mut sum = 0;
    for c in s {
        sum += c.to_string().parse::<u128>().unwrap();
    }
    put!(if sum % 9 == 0 { "Yes" } else { "No" });
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


Measured memory_bytes: 3132
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	string s;
	
	cin >> s;

	ll dp[200010][4];

	int len = s.size();

	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;

	rep(i, len)
	{
		rep(j, 4)
		{
			if (s[i] == '?')
			{
				dp[i+1][j] += (3 * dp[i][j] % MOD);
				dp[i+1][j] = dp[i+1][j] % MOD;
			}
			else
			{
				dp[i+1][j] += dp[i][j];
				dp[i+1][j] = dp[i+1][j] % MOD;
			}
		}
		if (s[i] == '?')
		{
			dp[i+1][1] += dp[i][0];
			dp[i+1][1] = dp[i+1][1] % MOD;
			
			dp[i+1][2] += dp[i][1];
			dp[i+1][2] = dp[i+1][2] % MOD;
		
			dp[i+1][3] += dp[i][2];
			dp[i+1][3] = dp[i+1][3] % MOD;
		}
		else if (s[i] == 'A')
		{
			dp[i+1][1] += dp[i][0];
			dp[i+1][1] = dp[i+1][1] % MOD;
		}
		else if (s[i] == 'B')
		{
			dp[i+1][2] += dp[i][1];
			dp[i+1][2] = dp[i+1][2] % MOD;
		}
		else if (s[i] == 'C')
		{
			dp[i+1][3] += dp[i][2];
			dp[i+1][3] = dp[i+1][3] % MOD;
		}
	}
	/*
	rep(i, len)
	{
		if (s[i] == '?')
		{
			dp[i+1][1] += dp[i][0];
			dp[i+1][2] += dp[i][1];
			dp[i+1][3] += dp[i][2];
		}
		else if (s[i] == 'A')
		{
			dp[i+1][1] += dp[i][0];
		}
		else if (s[i] == 'B')
		{
			dp[i+1][2] += dp[i][1];
		}
		else if (s[i] == 'C')
		{
			dp[i+1][3] += dp[i][2];
		}
	}
	*/

	/*
	rep(i, len+1)
	{
		rep(j, 4)
		{
			cout << dp[i][j]<<" ";
		}
		cout << endl;
	}
	*/
	cout << dp[s.size()][3] << endl;
	
	return 0;
}


Measured memory_bytes: 6736
def gcd(a,b):
    if a == 0:
        return b
    else:
        return gcd(b%a,a)
t = int(input())
while t:
    t -= 1
    a,b = map(int, input().split())
    c = gcd(a,b)
    a = a//c
    b = b//c
    if a == b:
        ans1 = 1
        ans2 = 0
    elif a % 2 == 0 or b % 2 == 0:
        ans1 = 1
        ans2 = 1
    else:
        ans1 = a*b//2+1
        ans2 = a*b//2
    print(ans1,ans2)


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

int main()
{
    long long a,b,c,d,e;
    cin>>a>>b>>c;
    d=max(a,b);
    if(c%d==0) e=c/d;
    else e=c/d+1;
    cout<<e<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 200000

int main(){

    int k, n;
    int a[N];
    int max;
    int i;
    int index = 0;

    scanf("%d %d", &k, &n);
    for(i=0;i<n;i++){
        scanf("%d", &a[i]);
    }

    max = k - a[n-1] + a[0];
    index = 0;

    for(i=1;i<n;i++){
        if(a[i]-a[i-1] > max){
            max = a[i]- a[i-1];
            index = i;
        }
    }

    printf("%d\n", k-max);
    
    
    

    return 0;
}

Measured memory_bytes: 896
def e_bullet(MOD=10**9 + 7):
    from math import gcd
    from collections import defaultdict
    N = int(input())

    zero_all = 0
    pair = defaultdict(int)
    for _ in range(N):
        a, b = [int(i) for i in input().split()]
        if a == 0 and b == 0:
            zero_all += 1
            continue

        g = gcd(a, b)
        if b == 0:
            pair[(1, 0)] += 1
        elif b > 0:
            pair[(a // g, b // g)] += 1
        else:
            pair[(-a // g, -b // g)] += 1

    is_checked = set()
    total = 1
    for (a, b), v in list(pair.items()):
        if (b, -a) in is_checked or (-b, a) in is_checked:
            continue  # a/b に対応するものがあるかはすでに調べた
        is_checked.add((a, b))
        # a/b に対応する b/(-a) か (-b)/a に注目する
        w = pair[(b, -a)] + pair[(-b, a)]
        # 両方を選ぶと仲が悪いので、a/b となるものだけ選ぶか [b/(-a) または (-b)/a]
        # となるものだけ選ぶか、どちらか一方だけ選択したときに仲が悪くならない
        # これまでの選び方に対して仲が悪くならない選び方を決めるので、total は積を取る
        # ただし、両方とも 1 つも選ばないということはできないため、-1 する
        total *= pow(2, v, MOD) + pow(2, w, MOD) - 1
        total %= MOD

    ans = (total + zero_all - 1) % MOD
    return ans

print(e_bullet())

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

#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

typedef long long ll;

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> field(H);
    rep(i, H) {
        cin >> field[i];
    }

    int ans = 0;
    for (int hbit = 0; hbit < (1 << H); hbit++) {
        for (int wbit = 0; wbit < (1 << W); wbit++) {
            int cnt = 0;
            for (int h = 0; h < H; h++) {
                for (int w = 0; w < W; w++) {
                    if (hbit & (1 << h) || wbit & (1 << w)) {
                        continue;
                    }
                    if (field[h][w] == '#') {
                        cnt++;
                    }
                }
            }
            if (cnt == K) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
from collections import deque
inf = 10 ** 15
mod = 10 ** 9 + 7
n,a,b = map(int, input().split())
if b <= a:
    print(b*(n-1))
    sys.exit()
x = list(map(int, input().split()))
dp = [inf for i in range(n+1)] # iにつく時の最小の消費量
dp[1] = 0
for i in range(1,n):
    dp[i+1] = dp[i] + min((x[i]-x[i-1])*a, b)
print(dp[n])

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;

template <typename T> istream& operator>>(istream& i, vector<T>& o) { rep(j, o.size()) i >> o[j]; return i;}
static const long long INF = 1e18;
static const long long mo = 1e9+7;

template<class T>
struct SegmentTreeSum {
    int n;
    T inf;
    vector<T> dat;
    SegmentTreeSum(int n_ = 0) : n(n_){
        inf = 0;
        for(n = 1; n < n_; n <<= 1);
        dat.resize(n*2, inf);
    }
    T sum(int v, int w, int l, int r){
        if(r <= l || w == 0) return inf;
        if(r - l == w) return dat[v]; // assert(l == 0 && r == w);
        int m = w/2;
        return (sum(v*2, m, l, min(r,m)) + sum(v*2+1, m, max(0,l-m), r-m)) % mo;
    }
    void assign(int i, const T &x){
        dat[i+=n] = x;
        for(; i!=1; i/=2) dat[i/2] = (dat[i] + dat[i^1]) % mo;
    }
    T sum(int l, int r){ return sum(1,n,l,r); }
    size_t size() const { return n; }
    T operator [] (const int &idx) { return sum(idx, idx + 1); }
};

int main(void) {
    ll n; cin >> n;
    ll x, y; cin >> x >> y; if (x > y) swap(x, y);
    vll a;
    a.pb(-INF);
    rep(i, n) {
        ll tmp; cin >> tmp;
        a.pb(tmp);
    }
    n = a.size();
    SegmentTreeSum<ll> dp(n+1);
    dp.assign(0, 1);

    rep(i, n-2) 
        if (a[i] + x > a[i+2]) 
            return cout << 0 << endl, 0;

    ll j = 0; 
    vll z(n+1), js(n+1);

    // 集めるDP
    repi(i, 2, n+1) {
        if (a[i-1] - a[i-2] < x) 
            z[i] = i - 2;
        else 
            z[i] = z[i-1];

        while (j < i - 1 && a[i-1] - a[j] >= y) {
            j++;
        }
        js[i] = j;

        dp.assign(i-1, dp.sum(z[i-1], js[i]));
    }
    cout << dp.sum(z[n], n+1) << endl;
    return 0;
}


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

main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<=0&&0<=b)
		printf("Zero");
	else if(a>0)
		printf("Positive");
	else
	{
		int dif=b-a;
		if(dif%2==0)
			printf("Negative");
		else
			printf("Positive");
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

// MOD確認

int main(){
   ll D,T,S;
   cin >> D >> T >> S;
   if(D > S * T) cout << "No" << endl;
   else cout << "Yes" << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<math.h>


void swap(int *,int *);

int main(){
  int x,y,r;

  while(1){
  scanf("%d %d",&x,&y);

  if(x>=1&&x<=pow(10,9)&&y>=1&&y<=pow(10,9)) break;
  }
  if(x<y) swap(&x,&y);

  while(y>0){
    r = x%y;
    x = y;
    y = r;

  }
  printf("%d\n",x);

  return 0;
}


void swap(int *x,int *y){
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;


}




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

const int INF = 1001001001;
//const ll INF = 1000000000000000000;

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	vector<vector<char>> c(h, vector<char>(w));
	rep(i,h) rep(j,w) cin >> c[i][j];

	int ans = 0;
	rep(bith, (1<<h)) rep(bitw, (1<<w)) {
		bitset<6> bsh(bith), bsw(bitw);
		int cnt = 0;
		rep(i,h) rep(j,w) {
			if (bsh[i] == 1 or bsw[j] == 1) continue;
			if (c[i][j] == '#') cnt++;
		}
		if (cnt == k) ans++;
	}
 	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3584
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	vector<int>c(256);
	c['a'] = 1;
	c['i'] = 1;
	c['u'] = 1;
	c['e'] = 1;
	c['o'] = 1;
	cin >> N;
	while (N) {
		vector<string>s(N);
		for (int i = 0; i < N; i++) {
			cin >> s[i];
		}
		int ans = -1;
		for (int i = 1; i <= 50; i++) {
			set<string>st;
			for (int j = 0; j < N; j++) {
				string t;
				t.push_back(s[j][0]);
				for (int k = 0; k < s[j].size() - 1; k++) {
					if (t.size() == i)break;
					if (c[s[j][k]])t.push_back(s[j][k + 1]);
				}
				st.insert(t);
			}
			if (st.size() == N) {
				ans = i;
				break;
			}
		}
		cout << ans << endl;
		cin >> N;
	}
	return 0;
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) rep2(i,0,n)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
string s;
int main()
{
	cin>>s;
	if(s=="SSS") re(0)
	if(s=="SSR"||s=="SRS"||s=="RSS"||s=="RSR")re(1)
	if(s=="RRS"||s=="SRR")re(2)
	if(s=="RRR")re(3)
	return 0;}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

  int n; cin >> n;

  int ans = 1e9;
  for(int i = 0; i <= n; ++i) {
    int cnt = 0;
    int cost9 = i;
    while(true) {
      if(cost9 == 0) break;
      cnt += cost9%9;
      cost9 /= 9;
    }
    int cost6 = n-i;
    while(true) {
      if(cost6 == 0) break;
      cnt += cost6%6;
      cost6 /= 6;
    }

    ans = min(ans, cnt);
  }
  
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"errors"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scan := bufio.NewScanner(os.Stdin)
	scan.Scan()
	in := strings.Split(scan.Text(), " ")
	s := NewStackV2(len(in))

	for _, value := range in {
		switch value {
		case "+":
			b, _ := s.Pop()
			a, _ := s.Pop()
			_ = s.Push(a + b)
		case "-":
			b, _ := s.Pop()
			a, _ := s.Pop()
			_ = s.Push(a - b)
		case "*":
			b, _ := s.Pop()
			a, _ := s.Pop()
			_ = s.Push(a * b)
		default:
			x, _ := strconv.Atoi(value)
			_ = s.Push(x)
		}
	}
	res, _ := s.Pop()
	fmt.Println(res)
}

// 参考书籍实现版本
type StackV2 struct {
	top int
	capacity int
	bucket []int
}

func NewStackV2(capacity int) StackV2 {
	return StackV2{
		top: 0,
		capacity: capacity,
		bucket: make([]int, capacity),
	}
}

func (s *StackV2) Push(x int) error {
	if s.IsFull() {
		return errors.New("栈空间已满")
	}

	s.bucket[s.top] = x
	s.top++

	return nil
}

func (s *StackV2) Pop() (int, error) {
	if s.IsEmpty() {
		return 0, errors.New("栈空间已空")
	}

	x := s.bucket[s.top - 1]
	s.top--

	return x, nil
}

func (s *StackV2) IsFull() bool {
	return s.top >= s.capacity
}

func (s *StackV2) IsEmpty() bool {
	return s.top <= 0
}

// 自行实现版本
type Stack struct {
	//top int
	bucket []int
}

func NewStack() Stack {
	return Stack{}
}

func (s *Stack) Push(x int) {
	s.bucket = append(s.bucket, x)
	//s.top++
}

func (s *Stack) Pop() (x int, success bool) {
	if len(s.bucket) == 0 {
		return 0, false
	}

	lastIndex := len(s.bucket) - 1
	x = s.bucket[lastIndex]
	s.bucket = s.bucket[:lastIndex]

	return x, true
}

func (s *Stack) IsFull() bool {
	return false
}

func (s *Stack) IsEmpty() bool {
	if len(s.bucket) == 0 {
		return true
	} else {
		return false
	}
}


Measured memory_bytes: 1112
#include <iostream>
#include <cmath>
#include <sstream>
#include <string>

#if defined SUBLIME
#  define ISTREAM ss
#else
#  define ISTREAM cin
#endif


using namespace std;
int main()
{
	#if defined SUBLIME
		string str = "9876543210";
		stringstream ss;
		ss << str;
	#endif
	long long n;
	ISTREAM >> n;
	long long m = sqrt(n);
	int min = 10;
	for(int i = 1; i < m+1; i++){
		if(n % i == 0){
			int a = max((int)log10(i)+1, (int)log10(n/i)+1);
			if(a<min){
				min = a;
			}
		}
	}
	cout << min << endl;
}

Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n, m; cin >> n >> m;
	int INF = 1e9;
	vector<vector<int>> v(n, vector<int>(n, INF)), u;
	rep(i, n)v[i][i] = 0;
	rep(i, m)
	{
		int a, b, c; cin >> a >> b >> c;
		--a, --b;
		v[a][b] = v[b][a] = c;
	}
	u = v;
	rep(k, n)rep(i, n)rep(j, n)chmin(u[i][j], u[i][k] + u[k][j]);
	int cnt = 0;
	rep(i, n)for (int j = i + 1; j < n; ++j)
	{
		if (v[i][j] == INF)continue;
		if (v[i][j] != u[i][j])++cnt;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n, d;
	cin >> n >> d;
	d *= d; //(becomes d^2)
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ll x, y;
		cin >> x >> y;
		if (x*x + y*y <= d) {
			ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n;
  cin >> n;
  vi C(n-1);
  vi S(n-1);
  vi T(n-1);
  rep(i,n-1) cin >> C.at(i) >> S.at(i) >> T.at(i);
  rep(i,n){
    if(i == n-1){
      cout << 0 << endl;
      return 0;
    }
    int time = 0;
    for(int j=i;j<n-1;j++){
      int c = C.at(j);
      int s = S.at(j);
      int t = T.at(j);
      if(time < s) time = s;
      int tmp = (time + t - 1)/t;
      time = tmp * t;
      time += c;
    }
    cout << time << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{   int A, B, C, D;
    scanf("%d %d %d %d", &A,&B,&C,&D);
    if((A+B)>(C+D)){
        printf("Left");
    }
    else if((A+B)<(C+D)){
        printf("Right");
    }
    else printf("Balanced");
        return 0;
}



Measured memory_bytes: 1708
from bisect import bisect_left, bisect_right

n,q = map(int, input().split())

hori_cnt = [n-2]*(n+2) # 2から

ql = []
for _ in range(q):
    c,x = map(int, input().split())
    ql.append((c,x))

tate_min = n
yoko_min = n
yoko_kyokai = []
ans1 = 0
for c,x in ql:
    if c == 1:
        if x < tate_min: 
            hori_cnt[yoko_min] = x-2
            yoko_kyokai.append(yoko_min*(-1))
            tate_min = x
    else:
        # print(c,x,'---------')
        if x < yoko_min:
            yoko_min = x
        # print(yoko_kyokai)
        ind = bisect_left(yoko_kyokai, x*(-1))-1
        # print(x,ind)
        if ind == -1:
            if x < yoko_min:
                ans1 += (tate_min-2)
            else:
                ans1 += (n-2)
            # print(tate_min-2,'++')
        else:
            val = yoko_kyokai[ind]
            ans1 += hori_cnt[val*(-1)]
            # print(hori_cnt[val*(-1)],'++s')


tate_cnt = [n-2]*(n+2) # 2から
yoko_min = n
tate_min = n
tate_kyokai = []
ans2 = 0
for c,x in ql:
    if c == 2:
        if x < yoko_min: 
            tate_cnt[tate_min] = x-2
            tate_kyokai.append(tate_min*(-1))
            yoko_min =x
            
    else:
        # print(c,x,'---------')

        if x < tate_min:
            tate_min = x

        ind = bisect_left(tate_kyokai, x*(-1))-1
        # print(tate_kyokai,'aaa')
        if ind == -1:
            if x < tate_min:
                ans2 += (yoko_min-2)
            else:
                ans2 += (n-2)
            # print(yoko_min-2,'+++')
        else:
            val = tate_kyokai[ind]
            ans2 += tate_cnt[val*(-1)]
            # print(tate_cnt[val*(-1)],'+++s')

print((n-2)*(n-2)-ans1-ans2)

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

namespace Test
{
	class Program
	{
		static void Main(string[] args) {
			int N = Int32.Parse(Console.ReadLine());
			var dic=new Dictionary<int,int>();
			int max = 0;
			for (int i = 0; i < N; i++) {
				int A, B;
				var read = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				A = read[0];
				B = read[1];
				max = Math.Max(A, max);
				dic.Add(A,B);
			}
			Console.WriteLine(max+dic[max]);
		}
	}
}


Measured memory_bytes: 23356
import java.util.Scanner;

public class Main{

	
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());		
		
		int[][] matrix = new int[n][m];
		
		for(int i=0; i<n;i++){
			
			for(int j=0; j<m;j++){
				
				matrix[i][j] = Integer.parseInt(sc.next());
				
			}
			
		}
		
		int[] vector = new int[m];
		for(int i=0; i<m;i++){
			
			vector[i] = Integer.parseInt(sc.next());
			
		}
		
		for(int i=0; i<n;i++){
			int sum = 0;
			for(int j= 0; j<m ;j++){
				
				sum += matrix[i][j] * vector[j];
			}
			System.out.print(sum +"\n");
		}
		
		
		
		sc.close();
	}

}


Measured memory_bytes: 38780
import java.io.*;
import java.util.*;
public class Main {
    private static void solver(InputReader sc, PrintWriter out) {
        String s = sc.next();
        char ch = s.charAt(s.length()-1);
        if(ch == '2' || ch == '4' || ch=='5' || ch == '7' || ch == '9')
            out.println("hon");
        else if(ch=='0' || ch=='1' || ch=='6' || ch=='8')
            out.println("pon");
        else
            out.println("bon");
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int[] readIntArray(int n){
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        }
    }
}
class Pair{
    int x,y;
    Pair(int x, int y){
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return x == pair.x &&
                y == pair.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
}

Measured memory_bytes: 32788
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = list(input())
r =[0]*100001
s=[0]*100001
p=[0]*100001
for i in range(N):
  if T[i]=='r':
    r[i]=1
    if i>=K:
      if r[i-K]==1:
        r[i]=0
  elif T[i] =='s':
    s[i]=1
    if i>=K:
      if s[i-K]==1:
        s[i]=0
  elif T[i]=='p':
    p[i]=1
    if i>=K:
      if p[i-K]==1:
        p[i]=0
count=0
for i in range(N):
  if r[i]==1:
    count+=P
  elif s[i]==1:
    count+=R
  elif p[i]==1:
    count+=S
print(count)
    


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

int main() {
  int h, w, k; cin >> h >> w >> k;
  vector<vector<char>> s(h, vector<char>(w));
  vector<vector<int>> ans(h, vector<int>(w));
  rep(i, h) rep(j, w) cin >> s[i][j];
  int num = 1;
  vector<int> cnt(h);
  rep(i, h) {
    rep(j, w) {
      if (s[i][j] == '#') {
        cnt[i]++;
        ans[i][j] = num;
        for (int m = j-1; m >= 0 && s[i][m] != '#'; m--)
          if (ans[i][m] == 0) ans[i][m] = num;
        for (int m = j+1; m < w && s[i][m] != '#'; m++) {
          ans[i][m] = num;
          j = m;
        }
        num++;
      }
    }
  }
  rep(i, h) {
    if (!cnt[i]) {
      if (0 < i)
        rep(m, w) if (!ans[i][m]) ans[i][m] = ans[i-1][m];
    }
  }
  for (int i = h; i >= 0; i--) {
    if (!cnt[i]) {
      if (i < h)
        rep(m, w) if (!ans[i][m]) ans[i][m] = ans[i+1][m];
    }
  }
  rep(i, h) {
    rep(j, w) {
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <cmath>
#define ll long long

using namespace std;

int main() {
    int x, y, k_o;
    cin >> y >> x >> k_o;
    cin.get();
    vector<vector<char>> map(x, vector<char>(y));
    int no_black = 0;
    for (int i = 0; i < y; i++) {
        for (int j = 0; j < x; j++) {
            cin.get(map[j][i]);
            if (map[j][i] == '#') {
                no_black++;
            }
        }
        cin.get();
    }
    //Complete search
    int ans = 0;
    for (int i = 0; i < (int)pow(2, x + y); i++) {
        int temp_black = no_black;
        int column = i & ((int)pow(2, x) - 1);
        int row = i >> x;
        for (int j = 0; j < x; j++) {
            bool get_c = column & 1;
            column >>= 1;
            if (get_c) {
                for (int k = 0; k < y; k++) {
                    if (map[j][k] == '#') {
                        temp_black--;
                        map[j][k] = 'r';
                    }
                }
            }
        }
        for (int k = 0; k < y; k++) {
            bool get_r = row & 1;
            row >>= 1;
            if (get_r) {
                for (int j = 0; j < x; j++) {
                    if (map[j][k] == '#') {
                        temp_black--;
                        map[j][k] = 'r';
                    }
                }
            }
        }
        if (temp_black == k_o) {
            ans++;
        }
        for (int c = 0; c < x; c++) {
            for (int r = 0; r < y; r++) {
                if (map[c][r] == 'r') {
                    map[c][r] = '#';
                }
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 4000
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] ary = new int[n];

        for (int i = 0; i < n; i++) {
            ary[i] = Integer.parseInt(sc.next());
        }
        Arrays.sort(ary);

        if (ary[ary.length/2] == ary[ary.length/2 -1]) {
            System.out.print("0");
        } else {
            System.out.print(ary[ary.length/2] - ary[ary.length/2 - 1]);
        }
    }
}


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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

using namespace std;
using ll =  long long;
using P = pair<ll, ll>;

int main( void )
{
	ll k;
	cin >> k;

	string s;
	cin >> s;

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

	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    if (n % 2 == 0){
        cout << n / 2 << "\n";
    }
    else {
        cout << n / 2 + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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 print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};




int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll N;
    cin >> N;
    vector<ll> h(N+10);
    rep(i,N) cin >> h[i];
    vector<ll> dp(N+10, LLINF);
    dp[0] = 0;
    rep(i,N){
      chmin(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
      chmin(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
    }
    print(dp[N-1]);
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
long int int_sort(const void * a, const void * b)
{
    if(*(long int*)a<*(long int*)b)
    {
        return -1;
    }
    else if(*(long int*)a==*(long int*)b)
    {
        return 0;
    }
    return 1;
}

int main(void)
{
    int n;
    scanf("%d",&n);
    long int a[n];
    long int b[n];
    long int c[n];
    for(int p=0;p<n;p++)scanf("%ld",&a[p]);
    for(int q=0;q<n;q++)scanf("%ld",&b[q]);
    for(int r=0;r<n;r++)scanf("%ld",&c[r]);
    qsort(a,n,sizeof(a[1]),int_sort);
    qsort(b,n,sizeof(b[1]),int_sort);
    qsort(c,n,sizeof(c[1]),int_sort);
    long long int ans=0;
    long int checka=0;
    long int checkb=-1;
    long int sumb[n];
    for(int s=0;s<n;s++)
    {
        while(b[s]>a[checka] && checka!=n)
          checka++;
        if(s==0)sumb[s]=checka;
        else sumb[s]=checka+sumb[s-1];
    }
    for(int t=0;t<n;t++)
    {
        while(c[t]>b[checkb+1] && checkb!=n-1)
          checkb++;
        if(checkb>-1)ans+=sumb[checkb];
        //if(checkb>-1)printf("##%ld##\n",sumb[checkb]);
    }
    printf("%lld",ans);
}


Measured memory_bytes: 4080
N = int(input())
S = input()

r = S.count('R')
g = S.count('G')
b = S.count('B')
sum_rgb = r*g*b

# rgbの組み合わせの総数から距離が等しいものを引く
for i in range(N-2):
    for j in range(i+1, N-1):
        k = j + (j-i)
        if k > N-1:
            continue
        if len(set([S[i], S[j], S[k]])) == 3:
            sum_rgb -= 1
print(sum_rgb)


Measured memory_bytes: 68312
n=int(input())
v=list(map(int,input().split()))
odd=v[0::2]
even=v[1::2]
from collections import Counter
o=Counter(odd).most_common(2)
e=Counter(even).most_common(2)
if len(set(v))==1:
    print(int(n//2))
elif o[0][0]!=e[0][0]:
    print(n-o[0][1]-e[0][1])
else:
    if o[0][1]==e[0][1]:
        print(n-o[0][1]-max(o[1][1],e[1][1]))
    elif o[0][1]>e[0][1]:
        print(n-o[0][1]-e[1][1])
    else:
        print(n-e[0][1]-o[1][1])

Measured memory_bytes: 16524