akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)

int parent(int i){
    return i/2;
}

int left(int i){
    return i*2;
}

int right(int i){
    return i*2 + 1;
}

void maxHeapify(int A[], int i, int n){
    int l = left(i);
    int r = right(i);
    // 左の子、自分、右の子で値が最大のノードを選ぶ
    int largest;
    if(l <= n && A[l] > A[i])
        largest = l;
    else 
        largest = i;
    
    if(r <= n && A[r] > A[largest])
        largest = r;

    if(largest != i){  // i の子の方が値が大きい場合
        int tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        maxHeapify(A, largest, n); // 再帰的に呼び出し
    }
}

void buildMaxHeap(int A[], int n){
    for(int i=n/2; i>=1; i--){
        maxHeapify(A, i, n);
    }
}

int main() {
    
    int n;
    cin >> n;
    int a[500001];
    for(int i=1; i<=n; i++){
        cin >> a[i];
    }

    buildMaxHeap(a, n);

    for(int i=1; i<=n; i++){
        cout << " " << a[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 5036
s = gets.chomp.chars
s.pop
ans = s.length

l = s[0..(ans / 2) - 1]
r = s[(ans / 2)..ans - 1]

until l == r
  s.pop
  ans -= 1
  next if ans.odd?

  l = s[0..(ans / 2) - 1]
  r = s[(ans / 2)..ans - 1]
end

puts ans


Measured memory_bytes: 1788
use std::io;
use std::str;

fn solve<R: io::BufRead, W: io::Write>(scan: &mut Scanner<R>, out: &mut W) {
    let n: usize = scan.token();
    let mut p = Vec::new();
    for _ in 0..n {
        p.push(scan.token::<f64>());
    }

    // dp[n][nh]: the probability of obtaining nh heads from n coin tosses
    let mut dp = vec![0.0; n + 1];
    dp[0] = 1.0;
    for i in 0..n {
        let mut new_dp = vec![0.0; n + 1];
        for ih in 0..=i {
            new_dp[ih + 1] += dp[ih] * p[i];
            new_dp[ih] += dp[ih] * (1.0 - p[i]);
        }
        dp = new_dp;
    }
    let mut ans = 0.0;
    for ih in (n / 2 + 1)..=n {
        ans += dp[ih];
    }
    writeln!(out, "{}", ans).ok();
}

fn main() {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = Scanner::new(stdin.lock());
    let mut out = io::BufWriter::new(stdout.lock());
    solve(&mut scan, &mut out);
}

pub struct Scanner<R> {
    reader: R,
    buffer: Vec<String>,
}

impl<R: io::BufRead> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buffer: vec![],
        }
    }

    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }

    pub fn tokens<T: str::FromStr>(&mut self) -> Vec<T> {
        assert!(self.buffer.is_empty());
        let mut input = String::new();
        self.reader.read_line(&mut input).expect("Failed read");
        input
            .split_whitespace()
            .map(|x| x.parse().ok().expect("Failed parse"))
            .collect()
    }
}


Measured memory_bytes: 2468
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    string s;cin>>s;
    sort(s.begin(),s.end());
    if(s[0]==s[1]&&s[2]==s[3]&&s.length()==4&&s[1]!=s[2])cout<<"Yes";
    else cout<<"No";
}

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

#define F first
#define S second

using namespace std;

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

const int N = 100010, M = 110;

int n, k;
LL s[N];
char g[N];
vector<int> seq;

int main()
{
	scanf("%d%d", &n, &k);
	scanf("%s", g);
	seq.push_back(0);
	for (int i = 0; i < n; i ++ )
	{
		int j = i, cnt = 0;
		while (j < n && g[i] == g[j]) j ++ , cnt ++ ;
		seq.push_back(cnt);
		i = j - 1;
	}
	
	int m = seq.size() - 1;
	for (int i = 1; i <= m; i ++ ) s[i] = s[i - 1] + seq[i];
	int st = g[0] == '0' ? 1 : 2, ed = max(min(m, st + 2 * k - 1), st);
	// cout << s[0] << endl;
	LL res = 0;
	for (int i = st, j = ed; i <= m; i += 2, j = min(j + 2, m))
	{
		// cout << i << ' ' << j << ' ';
		// cout << s[min(0, i - 2)] << ' ' << s[j] << endl;
		res = max(res, s[j] - s[max(1, i - 1) - 1]);
	}
	printf("%lld\n", max(res, s[1]));
	return 0;
}

Measured memory_bytes: 1656
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-08-17 17:23
# @url:https://atcoder.jp/contests/abc059/tasks/arc072_a

import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def main():
    n=int(input())
    a=list(map(int,input().split()))
    prefix=[a[0]]
    for i in range(1,len(a)):
        prefix.append(prefix[-1]+a[i])
    s,t=0,0
    ans1,ans2=0,0
    for i in range(len(prefix)):
        if i%2==0:
            if prefix[i]+s<=0:
                ans1+=abs(prefix[i]+s)+1
                s=s+abs(prefix[i]+s)+1
        else:
            if prefix[i]+s>=0:
                ans1+=abs(prefix[i]+s+1)
                s=s-abs(prefix[i]+s+1)
    for i in range(len(prefix)):
        if i%2==1:
            if prefix[i]+t<=0:
                ans2+=abs(prefix[i]+t)+1
                t=t+abs(prefix[i]+t)+1
        else:
            if prefix[i]+t>=0:
                ans2+=abs(prefix[i]+t+1)
                t=t-abs(prefix[i]+t+1)
    print (min(ans1,ans2))
if __name__ == "__main__":
    main()

Measured memory_bytes: 96760
import java.util.Scanner;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			int n = sc.nextInt();
			String s = sc.next();
			String t = sc.next();
			
			if(calc(s,t,n)!=-1) {
				System.out.println(2*n-calc(s,t,n)-1);
			}else {
				System.out.println(2*n);
			}
		}	
		
		
		static int calc(String s, String t, int n) {
			int ret = -1;
			
			for(int i=0;i<n;i++) {
				String scut = s.substring(n-i-1, n);
				String tcut = t.substring(0, i+1);
				if(scut.equals(tcut)) {
					ret=Math.max(ret, i) ;
				}
			}
			return ret;
		}
		
		
	}


Measured memory_bytes: 21332
H, W = map(int, input().split())
X = [[[0, 1][a=="#"] for a in input()] for i in range(H)]
Y = [[0]*W for _ in range(H)]
Z = [[0]*W for _ in range(H)]

for i in range(H):
    t = 0
    for j in range(W):
        if X[i][j]:
            t = 0
        else:
            t += 1
            Y[i][j] = t

for i in range(H):
    t = 0
    for j in range(W)[::-1]:
        if X[i][j]:
            t = 0
        else:
            Y[i][j] += t
            t += 1

for j in range(W):
    t = 0
    for i in range(H):
        if X[i][j]:
            t = 0
        else:
            t += 1
            Z[i][j] = t

for j in range(W):
    t = 0
    for i in range(H)[::-1]:
        if X[i][j]:
            t = 0
        else:
            Z[i][j] += t
            t += 1

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, Y[i][j] + Z[i][j])

print(max(ans-1, 0))

Measured memory_bytes: 135388
N, M = map(int, input().split())
A = [int(i) for i in input().split()]

l = 0
ans = 0

while l % N != 0 or l == 0:
    min_ = 101
    max_ = -1

    for i in range(l, l + M):
        min_ = min(min_, A[i % N])
        max_ = max(max_, A[i % N])

    ans += max_ - min_
    l += M

print(ans)

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
 
int main(){
  ll q,h,s,d,n;
  cin >> q >>h >> s >> d >> n;
  ll H;
  H=min(q*2,h);
  ll S;
  S=min(H*2,s);
  if(S*2<=d) cout << n*S << endl;
  else{
    if(n%2==0){
      cout << (n/2)*d << endl;
    }
    else{
      cout << (n/2)*d+S << endl;
    }
  }
        
}

Measured memory_bytes: 256
use proconio::{input, fastout};
use std::collections::HashMap;

#[fastout]
fn main() {
    input!{
        n:u32,
    }

    let mut a: HashMap<u32, u32> = HashMap::new();

    for _i in 2..n+1 {
        input!{
            ai:u32,
        }
        match a.get_mut(&ai) {
            Some(x) => {*x += 1;},
            None => {a.insert(ai, 1);},
        }
    }

    for i in 1..n+1 {
        println!("{}",
                 match a.get(&i) {
                    Some(x) => *x,
                    None =>  0,
                 });
    }

}


Measured memory_bytes: 6828
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=1000000000000000003;
const int32_t LOG=21;
const int MOD=MOD1;

vector<int> v[200005];

int val[200005];
int ans[200005];
int fact[200005];
int inv_fact[200005];
int siz[200005];

int power(int x,int y)
{
	 if(y==0)return 1;
	 int temp=power(x,y/2);
	 temp=(temp*temp)%MOD;
	 if(y&1)temp=(temp*x)%MOD;
	 return temp;
}

int inv(int x)
{
	return power(x,MOD-2);
}

void init()
{
	 fact[0]=fact[1]=1;
	 inv_fact[0]=inv_fact[1]=1;
	 rep(i,2,200002)
	 {
	 	fact[i]=(i*fact[i-1])%MOD;
	 	inv_fact[i]=inv(fact[i]);
	 }
}

void dfs1(int i,int prev)
{
	 int sum=0;
	 for(auto it:v[i])
	 {
	 	 if(it!=prev)
	 	 {dfs1(it,i);sum+=siz[it];}	
	 }
	 sum++;
	 siz[i]=sum;
}

int dfs(int i,int prev)
{
     int mul=fact[siz[i]-1];
     for(auto it:v[i])
     {
     	 if(it!=prev)
     	 {
            mul=(mul*dfs(it,i))%MOD;
            mul=(mul*inv_fact[siz[it]])%MOD;
     	 }	
     }
     val[i]=mul;
     return mul;	
}
int n;
void dfs2(int i,int prev,int prev_val)
{
      int mul=(siz[i]*prev_val)%MOD;
      mul=(mul*inv(n-siz[i]))%MOD;
      ans[i]=mul;
      for(auto it:v[i])
      {
      	 if(it!=prev)
      	 {
      	 	dfs2(it,i,ans[i]);
      	 }	
      }	
}

int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      { 
          init(); 
          cin>>n;
          rep(i,0,n-1)
          {
          	 int x,y;
          	 cin>>x>>y;
          	 v[x].push_back(y);
          	 v[y].push_back(x);
          }
          dfs1(1,-1);
          
          ans[1]=dfs(1,-1);

          for(auto it:v[1])
          {
          	 dfs2(it,1,ans[1]);
          }

          rep(i,1,n+1)
          cout<<ans[i]<<endl;

      }

      return 0;     
}

/*
 TIPS(FOR ME):
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/


Measured memory_bytes: 22512
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  string s; cin >>s;
  sort(s.begin(),s.end());
  if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]) cout <<"Yes";
  else cout <<"No";
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  solve();
return 0;}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a==b) {
        for(int i=1;i<=a;i++)printf("%d",a);
    }
    else if(a<b){
        for(int i=1;i<=b;i++)printf("%d",a);
    }
    else for(int i=1;i<=a;i++)printf("%d",b);
	return 0;
}



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

typedef long long ll;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)

const int mod = 998244353;

void add(int& a, int b){
    a += b;
    if(a >= mod)
        a -= mod;
}

void solve(){
    
    int n, s; cin >> n >> s;
    vi a(n+1);
    for(int i = 0; i < n; i++)
        cin >> a[i+1];
    vvi dp(n+1, vi(s+1, 0));
    for(int i = 1; i <= s; i++)
        dp[0][i] = 0;
    dp[0][0] = 1;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= s; j++){
            if(j - a[i] >= 0){
                add(dp[i][j], dp[i-1][j-a[i]]);
            }
            add(dp[i][j], dp[i-1][j]);
        }
        for(int j = 0; j <= s; j++)
            add(dp[i][j], dp[i-1][j]);
    }
    cout << dp[n][s];
}


int main(){
	boost;
	int t = 1;
// 	cin >> t;
	
	while(t--){
		solve();
	}
	
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 61;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

llong dp[1100][5000];

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vector<int> A(m), B(m);
    vector<vector<int> > C(m, vector<int>());
    rep(i, m) {
        cin >> A[i] >> B[i];
        rep(j, B[i]) {
            int c;
            cin >> c;
            --c;
            C[i].push_back(c);
        }
    }

    rep(i, 1100) {
        rep(j, 5000) {
            dp[i][j] = inf;
        }
    }
    dp[0][0] = 0;
    rep(i, m) {
        rep(j, 1 << n) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            int mask = j;
            rep(k, B[i]) mask |= 1 << C[i][k];
            dp[i + 1][j | mask] = min(dp[i + 1][j | mask], dp[i + 1][j] + A[i]);
        }
    }

    if (dp[m][(1 << n) - 1] == inf) cout << -1 << endl;
    else cout << dp[m][(1 << n) - 1] << endl;
    
    return 0;
}

Measured memory_bytes: 43520
#include <cstdio>
#include <numeric>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <queue>
#include <sstream>
#include <deque>

using namespace std;

#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); i++)
#define re return
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqrt(x) sqrt(abs(x))
#define y0 y3487465
#define y1 y8687969
#define fill(x,y) memset(x,y,sizeof(x))
#define prev PREV
#define next NEXT
                         
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef double D;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<vi> vvi;

template<class T> T abs(T x) { re x > 0 ? x : -x; }
template<class T> inline T sqr (T x) { re x * x; }

#define filename ""

int n;
int m;
string s;

int main () {
	cin >> s >> m;
	n = sz (s);
	for (int i = 0; i < n; i++)
		if (s[i] != 'a' && 'z' - s[i] + 1 <= m) {
			m -= 'z' - s[i] + 1;
			s[i] = 'a';
		}
	m %= 26;	
	s[n - 1] = (s[n - 1] - 'a' + m) % 26 + 'a';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int dp[200004];
//main
signed main(){
  int N;cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  std::vector<int> color[200001];
  for(int i=0;i<N;i++)color[v[i]].push_back(i);
  std::vector<int> pa(200003,0);
  for(int i=0;i<200001;i++){
    for(int j=0;j+1<color[i].size();j++){
      if(color[i][j+1]-color[i][j]>1)pa[color[i][j+1]+1]=color[i][j]+1;
    }
  }
  dp[0]=1;
  for(int i=1;i<=N;i++){
    dp[i]=dp[i-1];
    if(pa[i])dp[i]+=dp[pa[i]];
    dp[i]%=MOD;
  }
  cout<<dp[N]<<endl;
}


Measured memory_bytes: 15872
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,a[300005]={},ans=0;
  cin >> n;
  for(int i=0; i<3*n; i++) {
    cin >> a[i];
  }
  sort(a,a+3*n);
  for(int i=3*n-2; i>=n; i-=2) {
    ans+=a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;

int main(void)
{
    int h, w, a, b;
    int i, j;

    scanf("%d %d %d %d", &h, &w, &a, &b);

    for(i = 0; i < b; i ++)
    {
        for(j = 0; j < a; j ++)
            putchar('0');
        for(j = a; j < w; j ++)
            putchar('1');
        putchar('\n');
    }
    for(i = b; i < h; i ++)
    {
        for(j = 0; j < a; j ++)
            putchar('1');
        for(j = a; j < w; j ++)
            putchar('0');
        putchar('\n');
    }

    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

using namespace chrono;
auto start_t = steady_clock::now();
void start() { start_t = steady_clock::now(); }
int split(const string& s = "") {
  int res = duration_cast<milliseconds>(steady_clock::now() - start_t).count();
  // if (!s.empty()) cerr << s << ": " << res << " ms\n";
  return res;
}

int main() {
  constexpr int B = 400;
  V<lint> ten(19, 1);
  for (int l = 1; l < 19; ++l) {
    ten[l] = 10 * ten[l - 1];
  }
  auto len = [&](lint x) -> int {
    for (int l = 19; l; --l) if (x >= ten[l - 1]) {
      return l;
    }
    return 0;
  };

  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  int w = (m + B - 1) / B;
  V<lint> a(n); for (auto&& e : a) cin >> e;
  V<lint> b(m); for (auto&& e : b) cin >> e;
  V<> la(n);
  for (int i = 0; i < n; ++i) {
    la[i] = len(a[i]);
  }

  V<> idx(n);
  {
    auto _a = a;
    for (auto&& e : _a) {
      while (e >= ten[9]) {
        e /= 10;
      }
      while (e < ten[8]) {
        e *= 10;
      }
    }
    iota(begin(idx), end(idx), 0);
    sort(begin(idx), end(idx), [&](int i, int j) { return _a[i] > _a[j]; });
  }
  V<lint> c(n * w);
  for (int k = 0; k < w; ++k) {
    V<lint> v;
    lint sc = 0;
    for (int j = k * B; j < min((k + 1) * B, m); ++j) {
      sc += len(b[j]);
      v.push_back(b[j]);
      while (v.back() >= ten[9]) {
        v.back() /= 10;
      }
      while (v.back() < ten[8]) {
        v.back() *= 10;
      }
    }
    sort(begin(v), end(v));

    int r = 0;
    for (int i : idx) {
      lint lb = (ten[la[i] + 8] + a[i] - 1) / a[i];
      while (r < (int)v.size() and v[r] < lb) {
        ++r;
      }
      c[i * w + k] = la[i] * (int)v.size() + sc - r;
    }
  }
  partial_sum(begin(c), end(c), begin(c));
  c.insert(begin(c), 0);
  split("pre");

  int q; cin >> q;
  while (q--) {
    lint d; cin >> d, --d;
    int t = prev(upper_bound(begin(c), end(c), d)) - begin(c);
    int i = t / w, k = t % w;
    d -= c[t];
    if (i < n) {
      for (int j = k * B; j < min((k + 1) * B, m); ++j) {
        int l = len(a[i] * b[j]);
        if (d < l) {
          cout << to_string(a[i] * b[j])[d];
          break;
        }
        d -= l;
      }
    } else {
      cout << 'x';
    }
  }
  cout << '\n';
  split("time");
}


Measured memory_bytes: 395852
#include <bits/stdc++.h>
using namespace std;
struct activity{
    public:
    int A,B,C;
};
int a[100000];
int dp[100000][3];

int solve(vector<activity> &ar,int n){
   memset(dp, 0, sizeof dp);
   dp[0][0]=ar[0].A;
   dp[0][1]=ar[0].B;
   dp[0][2]=ar[0].C;


      for(int i=1;i<n;++i){
      dp[i][0]= ar[i].A  + max(dp[i-1][1], dp[i-1][2]);
      dp[i][1]= ar[i].B  + max(dp[i-1][0], dp[i-1][2]);
      dp[i][2]= ar[i].C  + max(dp[i-1][1], dp[i-1][0]);
      }

  
  return max(dp[n-1][0],max(dp[n-1][1], dp[n-1][2])); 
}
int main() {
    vector<activity> ar;
    int n; cin>>n;
    for(int i=n;i>0;--i){
       activity ac;
       cin>>ac.A>>ac.B>>ac.C;
       ar.push_back(ac);
    }
    cout<<solve(ar, n);

    return 0;
}


Measured memory_bytes: 5544
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    R, C, K = map(int, input().split())

    field = [[0 for j in range(C)] for i in range(R)]

    for _ in range(K):
        r, c, v = map(int, input().split())
        field[r - 1][c - 1] = v

    dp = [[[0] * C for j in range(R)] for i in range(4)]

    for i in range(R):
        for j in range(C):
            ct = field[i ][j ]
            pm = max(dp[0][i-1][j],dp[1][i-1][j],dp[2][i-1][j],dp[3][i-1][j])
            if ct == 0:
                dp[0][i][j] = max(dp[0][i][j-1],pm)

                for k in range(1, 4):
                    if j>0:
                        dp[k][i][j] = dp[k][i][j - 1]
            else:
                dp[0][i][j] = max(dp[0][i][j - 1],pm)
                dp[1][i][j] = max(ct + max(dp[0][i][j - 1], pm),dp[1][i][j-1])
                for k in range(2, 4):
                    if j >0:
                        dp[k][i][j] = max(dp[k - 1][i][j - 1] +ct,dp[k][i][j-1])

    print(max(dp[0][R-1][C-1],dp[1][R-1][C-1],dp[2][R-1][C-1],dp[3][R-1][C-1]))

if __name__ == "__main__":
    main()


Measured memory_bytes: 437168
#include<cstdio>
int main(){
	int a=0,b=0,c=0;
	scanf("%d %d %d",&a,&b,&c);
	if(a==5 && b==5 && c==7)  printf("YES\n");
	else if(a==7 && b==5 && c==5) printf("YES\n");
	else if(a==5 && b==7 && c==5) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
ll ans;
void work(ll n,ll m){
	ll x=n%m;
	ans+=(n/m)*2*m;
	if(x==0) ans-=m;
	else work(m,x);
}
int main(){
	ll n=readll(),m=readll();
	m=max(m,n-m);
	ans+=n;
	work(m,n-m);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n, m;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>m;
    if(n==2||m==2){
        cout <<0<< "\n";
        return 0;
    }
    if(n==1&&m==1){
        cout <<1<< "\n";
        return 0;
    }
    if(n==1||m==1){
        cout <<n+m-3<< "\n";
        return 0;
    }
    cout << ll(m-2)*(n-2)<< "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n,x,c=0;
	scanf("%d",&n);
	long int a[n];
	for(int i=0;i<n;i++){
		scanf("%ld",&a[i]);
		c+=a[i];
		if(i%2!=0)
			c-=a[i]*2;
	}
	x=c;
	for(int i = 0;i<n;i++){
		printf("%ld ",x);
		x=a[i]*2-x;
	}
	return 0;
}

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

struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;


template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<double> p(n),q(n+1);
  for(Int i=0;i<n;i++) cin>>p[i];
  for(Int i=0;i<=n;i++) cin>>q[i];

  static double dp[555][555];
  for(Int i=0;i<555;i++)
    for(Int j=0;j<555;j++) dp[i][j]=-1;

  function<double(Int, Int)> dfs=
    [&](Int l,Int r)->double{
      double &res=dp[l][r];
      if(res>=0) return res;
      res=1e18;
      
      double s=0;
      for(Int i=l;i<r;i++) s+=p[i];
      for(Int i=l;i<=r;i++) s+=q[i];

      for(Int i=l;i<r;i++){
	double tmp=s;
	tmp+=i==l?q[l]:dfs(l,i);
	tmp+=i+1==r?q[r]:dfs(i+1,r);
	chmin(res,tmp);
      }
      
      return res;
    };
  
  cout<<dfs(0,n)<<endl;  
  return 0;
}



Measured memory_bytes: 5740
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		String op = sc.next();
		int b = sc.nextInt();
		
		System.out.println(op.equals("+") ? a + b : a- b);
	}
}

Measured memory_bytes: 35760
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e17;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)



int main() {
    ll a, b, c, x, y;
    
    cin >> a >> b >> c >> x >> y;
    
    cout << min(a * x + b * y, min(max(x, y) * c * 2, (x > y)? y * c * 2 + (x - y) * a : x * c * 2 + (y - x) * b)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define en "\n"
#define ITER(i,a) for( typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define mod 1000000007
#define mpp make_pair
#define mes(a,b) memset((a),(b),sizeof((a))
typedef map<int,int> MI;
typedef pair<int,int>   PI;
typedef vector<int> VI;
typedef long long int LL;

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    int l=s.size();
    l=l-2;
    for(int i=0;i<=l;i++)
    {
          int a[26]={0};
          for(int j=i;j<i+2;j++)
          a[s[j]-'a']++;
          for(int k=0;k<26;k++)
          {
              if(a[k]>1)
              {
                cout<<i+1<<" "<<i+2;
                return 0;
              }
          }
    }
    l++;
    for(int i=0;i<=l;i++)
    {
          int a[26]={0};
          for(int j=i;j<i+3;j++)
          a[s[j]-'a']++;
          for(int k=0;k<26;k++)
          {
              if(a[k]>=2)
              {
                cout<<i+1<<" "<<i+3;
                return 0;
              }
          }
    }
    cout<<"-1 -1";
	return 0;
}

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

typedef long long ll;
const int N=100100;
int n,Q;
ll q[N],g[N],f[N];
void solve(ll x,ll y){
	int i=lower_bound(q,q+Q+1,y)-q-1;
	if(i<0)g[y]+=x;
	else f[i]+=x*(y/q[i]),solve(x,y%q[i]);
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>Q;
	q[0]=n;
	for(int i=1;i<=Q;++i)
		for(cin>>q[i];i&&q[i]<=q[i-1];--i,--Q)q[i-1]=q[i];
	f[Q]=1;
	for(int i=Q;i>=0;--i)if(f[i])solve(f[i],q[i]);
	for(int i=n;i;--i)g[i]+=g[i+1];
	for(int i=1;i<=n;++i)cout<<g[i]<<'\n';
	return 0;
}


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

//????????????????¨???????
int dx[8]={0,1,1,1,0,-1,-1,-1};
int dy[8]={1,1,0,-1,-1,-1,0,1};

//f?????¶?????§x,y???c??????????????????????????£????????????????????°
int revnums(char f[8][9], int x, int y, char c, int flag){
  int ret=0;

  char e_cookie;
  if(c=='o') e_cookie='x';
  else e_cookie='o';

  if(f[x][y]=='.'){ //??????????????????????????§??????????????????????????????
    //8??????????????????
    for(int i=0; i<8; ++i){
      int r=1;

      while(0<=x+r*dx[i] && x+r*dx[i]<8 && 0<=y+r*dy[i] && y+r*dy[i]<8){
        char focus=f[x+r*dx[i]][y+r*dy[i]];
        if(focus==c){ //?????????????????????
          //???????????????????????????????????£????????????????????°?????????

          //??????????????£????????????
          if(flag==1){
            //????????????
            f[x][y]=c;
            //?????£????????????
            for(int j=1; j<r; ++j){
              f[x+j*dx[i]][y+j*dy[i]] = c;
            }
          }

          ret+=r-1;
          break;
        }
        else if(focus==e_cookie){ //??????????????????????????????
          r++;
        }
        else{ //?????????????????????????????£???
          break;
        }
      }

    }

  }
  return ret;
}

bool charlotte(char f[8][9]){
  int rev=0;
  int x=-1,y=-1;
  char c='x';
  //????????????
  for(int i=7; i>=0; --i){
    for(int j=7; j>=0; --j){
      int tmp=revnums(f,i,j,c,0);
      if(rev<tmp){
        rev=tmp;
        x=i;
        y=j;
      }
    }
  }

  //???????????´???????????£??????????????´?????????????????????????????´
  if(x>=0){
    revnums(f,x,y,c,1);
  }

  return (rev>0);
}

bool tomoe(char f[8][9]){
  int rev=0;
  int x=-1,y=-1;
  char c='o';
  //????????????
  for(int i=0; i<8; ++i){
    for(int j=0; j<8; ++j){
      int tmp=revnums(f,i,j,c,0);
      if(rev<tmp){
        rev=tmp;
        x=i;
        y=j;
      }
    }
  }

  //???????????´???????????£??????????????´?????????????????????????????´
  if(x>=0){
    revnums(f,x,y,c,1);
  }

  return (rev>0);
}

void print_field(char f[8][9]){
  for(int i=0; i<8; ++i){
    for(int j=0; j<8; ++j){
      printf("%c", f[i][j]);
    }
    printf("\n");
  }
}

int main(){
  char f[8][9];

  for(int i=0; i<8; ++i)
  for(int j=0; j<8; ++j)
  scanf(" %c", &f[i][j]);

  bool c=true, t=true;
  while(c || t){
    t=tomoe(f);
    c=charlotte(f);
  }

  print_field(f);
}

Measured memory_bytes: 1104
import java.math.BigDecimal;
import java.util.*;
public class Main {
	public static void main(String[] args){
		// get numbers
		Scanner sc = new Scanner(System.in);     
        int sx = sc.nextInt();
        int sy = sc.nextInt();
        int tx = sc.nextInt();
        int ty = sc.nextInt();
        
        StringBuffer str = new StringBuffer();

        int x = tx - sx, y = ty - sy;
        int cx = Math.abs(x), cy = Math.abs(y);

        // go
        if (x >= 0) {
            for (int i = 0; i < cx; i++) {
                str.append("R");
            }
        } else {
            for (int i = 0; i < cx; i++) {
                str.append("L");
            }
        }

        if (y >= 0) {
            for (int i = 0; i < cy; i++) {
                str.append("U");
            }
        } else {
            for (int i = 0; i < cy; i++) {
                str.append("D");
            }
        }
        String go = str.toString();
        str = new StringBuffer();

        // return
        if (x >= 0) {
            for (int i = 0; i < cx; i++) {
                str.append("L");
            }
        } else {
            for (int i = 0; i < cx; i++) {
                str.append("R");
            }
        }

        if (y >= 0) {
            for (int i = 0; i < cy; i++) {
                str.append("D");
            }
        } else {
            for (int i = 0; i < cy; i++) {
                str.append("U");
            }
        }
        String ret = str.toString();
        str = new StringBuffer();

        // second go
        if (x >= 0) {
            str.append("D");
        } else {
            str.append("U");
        }

        if (y >= 0) {
            str.append("R");
        } else {
            str.append("L");
        }

        str.append(go);

        if (x >= 0) {
            str.append("U");
        } else {
            str.append("D");
        }

        if (y >= 0) {
            str.append("L");
        } else {
            str.append("R");
        }

        // second return
        if (x >= 0) {
            str.append("U");
        } else {
            str.append("D");
        }

        if (y >= 0) {
            str.append("L");
        } else {
            str.append("R");
        }

        str.append(ret);

        if (x >= 0) {
            str.append("D");
        } else {
            str.append("U");
        }

        if (y >= 0) {
            str.append("R");
        } else {
            str.append("L");
        }


        System.out.println(go + ret + str.toString());
        sc.close();
	}
}

Measured memory_bytes: 23252
# coding: utf-8
import itertools
n,W,H=map(int,input().split())
tx = [0 for i in range(W)]
ty = [0 for i in range(H)]
for i in range(n):
    x,y,w=map(int,input().split())
    tx[x-(w if x-w>=0 else x)]+=1
    if x+w<W:
        tx[x+w]-=1
    ty[y-(w if y-w>=0 else y)]+=1
    if y+w<H:
        ty[y+w]-=1
tx=list(itertools.accumulate(tx))
ty=list(itertools.accumulate(ty))

f=True
for n in tx:
    if n<=0:
        f=False
if f:
    print('Yes')
    exit()
f=True
for n in ty:
    if n<=0:
        f=False
print('Yes' if f else 'No')


Measured memory_bytes: 14984
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] vs = RArInt();

            int cnt = 0;
            for (int i = vs[0]; i < vs[2] + 1; i += vs[0])
            {
                cnt += vs[1];
            }
            Console.WriteLine(cnt);
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define ld long double
#define int long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
//#define M   1000000007 // 1e9 + 7
#define MAXN 3030
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
	
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);

}

const int M = 998244353;
int a[3010];
int dp[MAXN][MAXN][3];
int n,s;
int res=0;

int32_t main(){
	fastio;
	cin>>n>>s;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	// t==0 -> nao definiu L nem R;
	// t==1 -> já definiu L;
	// t==2 -> ja definiu L e R;
	dp[0][0][0] = 1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=s;j++){
			dp[i+1][j][0]=mod(dp[i+1][j][0] + dp[i][j][0],M);
			dp[i+1][j][1]=mod(dp[i+1][j][1] + dp[i][j][1]+dp[i][j][0],M);// oq já tinha mais define L agr
			dp[i+1][j][2]=mod(dp[i+1][j][2] + dp[i][j][2] + dp[i][j][1],M);// oq já tinha mais define R agr (L tava definido)
			if(j+a[i]<=s){
				dp[i+1][j+a[i]][1]=mod(dp[i+1][j+a[i]][1] + dp[i][j][0] + dp[i][j][1],M);
				dp[i+1][j+a[i]][2]=mod(dp[i+1][j+a[i]][2] + dp[i][j][0] + dp[i][j][1],M);
			}
		}
	}
	cout<<dp[n][s][2]<<endl;
}

Measured memory_bytes: 215296
n = int(input())
l = list(map(int, input().split()))
k = []
for i in range(len(l)):
    k.append(l[i] - i - 1)
k.sort()
if len(k) % 2 == 0:
    middle = len(k) // 2
    median = (k[middle - 1] + k[middle]) / 2
else:
    middle = len(k) // 2
    median = (k[middle])
ans = 0
for j in range(n):
    ans += abs(l[j] - (median + j + 1))
print(int(ans))

Measured memory_bytes: 26180
n,x,y = map(int,input().split())
ans = [0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
        dis = min(j-i, abs(j-x)+1+abs(y-i), abs(j-y)+1+abs(x-i))
        ans[dis-1] += 1
for i in range(n-1):
    print(ans[i])

Measured memory_bytes: 3444
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N, D, K;
	cin >> N >> D >> K;
	int ans = K;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		ans += (D + tmp - 1) / tmp;
	}

	cout << ans << endl;

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
from math import gcd


def normal(x, y):
    if x == 0:
        return (0, 1)
    elif y == 0:
        return (1, 0)
    g = gcd(x, y)
    x, y = x // g, y // g
    if x < 0:
        x, y = -x, -y
    return (x, y)


def orthogonal(T):
    if T[0] == 0:
        return (1, 0)
    elif T[1] == 0:
        return (0, 1)
    if T[1] > 0:
        return (T[1], -T[0])
    else:
        return (-T[1], T[0])


N = int(input())
C = defaultdict(int)
z = 0
for i in range(N):
    Ai, Bi = map(int, input().split())
    if Ai == Bi == 0:
        z += 1
        continue
    n = normal(Ai, Bi)
    C[n] += 1

MOD = 1000000007
B = [1] * (N + 1)
for i in range(1, N + 1):
    B[i] = B[i - 1] * 2 % MOD

ans = 1
calc = set()
for n, c in C.items():
    if n in calc:
        continue
    a = B[c]
    calc.add(n)
    no = orthogonal(n)
    if no in C:
        co = C[no]
        a += B[co] - 1
        calc.add(no)
    ans *= a
    ans %= MOD
print((ans - 1 + z) % MOD)


Measured memory_bytes: 67624
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int[] a = new int[n];
		boolean[] flg = new boolean[n];
		for(int i = 0;i <n;i++){
			a[i] = saori.saori_hayami();
		}
		int num = a[0];
		int ans = 1;
		while(true){
			if(num == 2){
				break;
			}
			flg[num-1] = true;
			num = a[num-1];
			ans++;
			if(flg[num-1]){
				ans = -1;
				break;
			}
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22416
#include "bits/stdc++.h"
using namespace std;

int main() {
  int x[3];
  for (int i = 0; i < 3; i++) {
    cin >> x[i];
  }
  sort(x, x+3);
  int s = (x[2]-x[1])+(x[1]-x[0]);
  cout << s << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int k;
	cin >> k;
	
	if( k < 10 ) {
		cout << k << endl;
		return 0;
	}
	
	queue<ll> q;
	vector<ll> lunlun;
	for(ll i = 1; i < 10; ++i) {
		q.push(i);
		lunlun.push_back(i);
	}
	
	int cnt = 9;
	while( cnt < k ) {
		ll now = q.front();
		q.pop();
		
		ll add = 10LL * now + (now % 10);
		
		if( now % 10 != 0 ) {
			lunlun.push_back(add - 1LL);
			q.push(add - 1LL);
			cnt++;
		}
		
		lunlun.push_back(add);
		q.push(add);
		
		if( now % 10 != 9 ) {
			lunlun.push_back(add + 1LL);
			q.push(add + 1LL);
			cnt++;
		}
		
		cnt++;
	}

	cout << lunlun[k - 1] << endl;
	
	return 0;
}


Measured memory_bytes: 4560
#include <bits/stdc++.h>
using namespace std;
#define fi           first
#define se           second
#define ll           long long
#define pb           push_back
#define mp           make_pair
#define pll          pair<ll,ll>
#define pii          pair<int,int>
#define all(x)       (x).begin(),(x).end()
#define isWorking()  cout<<"Wroking"<<endl
#define FOR(i,x,y)   for(int i=x; i<y; i++)
#define SORT(x)      sort(x.begin(),x.end())
#define PRINT(ok)    cout<<(ok? "YES":"NO")<<endl
#define Fast_Input   ios_base :: sync_with_stdio(false), cin.tie(NULL);
typedef vector < int > VI;
const ll mod= 1e9+7,INF=1e18,mx= 5e6+5,mn=100;
int testCase=1,cas=0;

vector <ll> Divisor;

void Make(ll n) {

    ll val=sqrt(n);

    for(ll i=1; i<=val; i++) {
        if(n%i==0) {
            Divisor.push_back(i);
            Divisor.push_back(n/i);
        }
    }

}

ll Find(ll x) {
    ll cnt=0;
    while(x>0) {
        cnt++;
        x/=10;
    }
    return cnt;
}

int main() {
    Fast_Input

    //cin>>testCase;
    while(testCase--) {
        ll n;
        cin>>n;
        Make(n);
        ll cnt=INF;
        sort(all(Divisor));
        ll lim=Divisor.size();

        for(ll i=0; i<lim; i++) {
            for(ll j=i+1; j<lim; j++) {
                if(Divisor[i]*Divisor[j]==n) {
                    ll x= Find(Divisor[i]);
                    ll y= Find(Divisor[j]);
                    cnt=min(cnt,max(x,y));
                    //cout<<x<<" "<<Divisor[i]<<" "<<Divisor[j]<<endl;
                }
            }

        }
        cout<<cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#ifdef LOC
#include "debuglib.h"
#else
#define deb(...)
#define DBP(...)
#endif
using namespace std;
using   ll         = long long;
using   Vi         = vector<int>;
using   Pii        = pair<int, int>;
#define pb           push_back
#define mp           make_pair
#define x            first
#define y            second
#define rep(i, b, e) for (int i = (b); i < (e); i++)
#define each(a, x)   for (auto& a : (x))
#define all(x)       (x).begin(), (x).end()
#define sz(x)        int((x).size())

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(18);

	int A, B, M;
	cin >> A >> B >> M;

	Vi a(A), b(B);
	each(k, a) cin >> k;
	each(k, b) cin >> k;

	int ma = INT_MAX, mb = INT_MAX;
	each(k, a) ma = min(ma, k);
	each(k, b) mb = min(mb, k);

	int ans = ma+mb;

	rep(i, 0, M) {
		int x, y, c;
		cin >> x >> y >> c;
		ans = min(ans, a[x-1]+b[y-1]-c);
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024