akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp73
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] HW = Console.ReadLine().Split(' ');
            int H = int.Parse(HW[0]);
            int W = int.Parse(HW[1]);

            string[] Cs = new string[H];
            for(int i = 0; i < H; i++)
            {
                string[] Css = Console.ReadLine().Split(' ');
                Cs[i] = Css[0];
            }

            for(int i = 0; i < H; i++)
            {
                Console.WriteLine(Cs[i]);
                Console.WriteLine(Cs[i]);
            }
        }
    }
}

Measured memory_bytes: 13140
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($format:expr) => (write!(out,$format).unwrap());
        ($format:expr, $($args:expr),+) => (write!(out,$format,$($args),*).unwrap())
    }
    input!{
        n: usize,
        s: chars,
    }
    let mut acc = vec![0; n + 1];
    for i in 0 .. n {
        acc[i + 1] = acc[i] + (if s[i] == 'E' { 1 } else { 0 });
    }
    let mut mi = n + 1;
    for i in 0 .. n {
        let tmp = i - acc[i];
        let tmp = tmp + acc[n] - acc[i + 1];
        mi = min(mi, tmp);
    }
    puts!("{}\n", mi);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 14588
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

void solve(int n, vector<int> a, int &ans, vector<int> &res) {
	if (n % 2 == 0) {
		res.push_back(n - 1);
		n--;
		a.pop_back();
	}
	int any = 0;
	for (int i = n - 1; i >= 0; i -= 2) {
		any |= (a[i] >= 0);
	}
	if (!any) {
		ans = -1;
		return;
	}
	auto ers = [&] (int x) {
		res.push_back(x);
		if (x == 0 || x + 1 == (int)a.size()) {
			a.erase(a.begin() + x);
		} else {
			int v = a[x - 1] + a[x + 1];
			for (int i = 0; i < 3; i++) {
				a.erase(a.begin() + x - 1);
			}
			a.insert(a.begin() + x - 1, v);
		}
	};
	while (true) {
		if (a[0] < 0) {
			ers(0);
			ers(0);
		} else {
			break;
		}	
	}
	while ((int)a.size() > 1) {
		if (a[2] < 0) {
			if ((int)a.size() == 3) {
				ers(2);
				ers(1);
			} else {
				ers(2);
			}
		} else {
			ers(1);
		}
	}
	ans = a[0];
	return;
}

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

	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	if (*max_element(a.begin(), a.end()) < 0) {
		int v = max_element(a.begin(), a.end()) - a.begin();
		int pnt = n;
		cout << a[v] << '\n';
		cout << n - 1 << '\n';
		for (int i = 0; i < n - 1 - v; i++) {
			cout << pnt << '\n';
			pnt--;
		}
		for (int i = 0; i < v; i++) {
			cout << 1 << '\n';
		}
		return 0;
	}
	int fans = 0;
	vector<int> fv;
	solve(n, a, fans, fv);
	n--;
	a.erase(a.begin());
	int sans = 0;
	vector<int> sv = {0};
	solve(n, a, sans, sv);
	if (sans > fans) {
		swap(sans, fans);
		swap(fv, sv);
	}
	cout << fans << '\n';
	cout << fv.size() << '\n';
	for (auto t : fv) {
		cout << t + 1 << '\n';
	}
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    from itertools import product
    import sys
    input = sys.stdin.readline

    n, m, x = map(int, input().split())
    c = list()
    a = list()

    for i in range(n):
        bi = list(map(int, input().split()))

        ci = bi[0]
        c.append(ci)

        ai = bi[1:]
        a.append(ai)

    ans = float('inf')

    for p in list(product(range(2), repeat=n)):
        tmp = [0 for _ in range(m)]
        cost = 0

        for index, pi in enumerate(p):
            if pi == 1:
                for idx, aii in enumerate(a[index]):
                    tmp[idx] += aii

                cost += c[index]

        is_ok = True

        for t in tmp:
            if t < x:
                is_ok = False
                break

        if is_ok:
            ans = min(ans, cost)

    if ans == float('inf'):
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9444
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define lb long double
#define pb push_back
#define qwerty1 first
#define qwerty2 second
#define qwerty3 -> first
#define qwerty4 -> second
#define umap unordered_map
#define uset unordered_set
#define pii pair < int , int >
#define pq priority_queue

using namespace std;

const int N = 100005;
const int M = 1000000007;
const lb PI = acos(-1);

string s , t;

int main()
{
    ios_base::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);

    cin >> s;
    cin >> t;

    if(t.substr(0 , s.size()) == s)
        cout << "Yes";
    else cout << "No";

    return 0;
}


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

unsigned long int dec_to_oct(unsigned long int num)
{
  unsigned long int result = 0;
  for (int i = 1; num != 0; i *= 10)
  {
    result += (num % 8) * i;
    num = num / 8;
  }
  return result;
}

int main(void)
{
  unsigned long int room_num;
  unsigned long int buf;
  unsigned long int new_room_num;
  unsigned long int num_table[8] = { 0, 1, 2, 3, 5, 7, 8, 9, };
  
  while (true)
  {
    cin >> room_num;
    if ( room_num == 0 ) break;
    buf = dec_to_oct(room_num);

    new_room_num = 0;
    for (int i = 1; buf != 0; i *= 10)
    {
      new_room_num += num_table[(buf % 10)] * i;
      buf /= 10;
    }

    cout << new_room_num << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
long long a [100010];
int main ()
{
    int n,Count=0;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]==0){Count++;}
    }
    if(Count>0){cout<<0<<endl;return 0;}
    long long sum=1;
    for(int i=0; i<n; i++)
    {
        if(a[i]<=1000000000000000000/sum )
        {
            sum=sum*a[i];
        }
        else
        {
           cout<<-1<<endl;
            return 0;
        }
    }
   cout<<sum<<endl;
}


Measured memory_bytes: 4364
n=int(input())
M=[[-1]*n for _ in[0]*n]
for _ in[0]*n:
 e=list(map(int,input().split()))
 for i in range(e[1]):k=2*-~i;M[e[0]][e[k]]=e[k+1]
d=[0]+[1e6]*n
c=[1]*n
while 1:
 m,u=1e6,-1
 for i in range(n):
  if m>d[i]and c[i]:m,u=d[i],i
 if u<0:break
 c[u]=0
 for v in range(n):
  if c[v]and 1+M[u][v]and d[v]>d[u]+M[u][v]:
   d[v]=d[u]+M[u][v]
for i in range(n):print(i,d[i])


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

using namespace std;

using ll = long long;

vector< vector<int> > g;

void dfs1(int cur, int par, vector<int>& dist) {
    for (int nex : g[cur]) {
        if (nex == par) continue;
        if (dist[nex] == -1) {
            dist[nex] = dist[cur] + 1;
            dfs1(nex, cur, dist);
        }
    }
}

void dfs2(int cur, int par, int d, vector<ll>& num) {
    ll cnt = 0;
    for (int nex : g[cur]) {
        if (nex == par) continue;
        cnt++;
        dfs2(nex, cur, d + 1, num);
    }
    num[d] = max(num[d], cnt);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    g.resize(n);
    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int u = 0;
    vector<int> dist(n, -1);
    dist[u] = 0;
    dfs1(u, -1, dist);
    for (int i = 0; i < n; i++) {
        if (dist[u] < dist[i]) {
            u = i;
        }
    }

    vector<int> dist2(n, -1);
    dist2[u] = 0;
    dfs1(u, -1, dist2);
    int v = u;
    for (int i = 0; i < n; i++) {
        if (dist2[v] < dist2[i]) {
            v = i;
        }
    }
    
    int ans1 = dist2[v] / 2 + 1;

    dist.assign(n, -1);
    dist[v] = 0;
    dfs1(v, -1, dist);

    vector<int> ce;
    for (int i = 0; i < n; i++) {
        if (dist2[i] + dist[i] == dist2[v] && (dist2[i] == dist2[v] / 2 || dist[i] == dist[u] / 2)) {
            ce.push_back(i);
        }
    }

    assert((int)ce.size() <= 2);
    if (ce.size() == 1) {
        ce.push_back(ce[0]);
    }

    vector<ll> num1(n, 1);
    dfs2(ce[0], ce[1], 0, num1);
    dfs2(ce[1], ce[0], 0, num1);
    ll ans2 = 1;
    for (int i = 0; i < n; i++) {
        ans2 *= num1[i];
    }

    if (dist2[v] % 2 == 0) {
        for (int nex : g[ce[0]]) {
            vector<ll> num2(n, 1);
            dfs2(ce[0], nex, 0, num2);
            dfs2(nex, ce[0], 0, num2);
            ll tmp = 1;
            for (int i = 0; i < n; i++) {
                tmp *= num2[i];
            }
            ans2 = min(ans2, tmp * 2);
        }
    } else {
        ans2 *= 2;
    }

    cout << ans1 << " " << ans2 << endl;
    return 0;
}

Measured memory_bytes: 256
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest=arguments,v=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<v)v=rest[i];return v}
function max(){var rest=arguments,v=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>v)v=rest[i];return v}
function gcd(){var rest=arguments,v=rest[0],temp=(a,b)=>b?temp(b,a%b):a;for(var i=1;i<rest.length;i++)v=temp(v,rest[i]);return v}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n').map((el,ind,arr)=>toIntArr(el.split(' ')));
	var n = input[0][0];
	var vs = input[1].sort((a,b)=>a-b);
	var pows = [1];
	//console.log(n,vs);
	ans = vs[0]+vs[1];
	ans /= 2;
	for(var i = 2; i < n; i++){
		ans += vs[i];
		ans /= 2;
	}
	console.log(ans);
	return 0;
}

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
int h[100005];
vector<int>v[100005];
int main()
{
	int n,m,cnt=0;
	cin>>n>>m;
	for(int i=0;i<n;i++)
		cin>>h[i];
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		x--;
		y--;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	for(int i=0;i<n;i++)
	{
		bool ok=false;
		for(int j=0;j<v[i].size();j++)
		{
			if(h[i]<=h[v[i][j]])
				ok=true;
		}
		if(!ok)
			cnt++;
	}
	cout<<cnt;

	return 0;
}

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int H, W, K;
	cin >> H >> W >> K;
	int sty, stx, edy, edx;
	cin >> sty >> stx >> edy >> edx;
	--sty; --stx; --edy; --edx;
	vector<string> maps(H);
	REP(i, H) cin >> maps[i];
	
	vector<vector<int>> d[4], done[4];
	REP(i, 4) {
		d[i] = vector<vector<int>>(H, vector<int>(W, INF));
		done[i] = vector<vector<int>>(H, vector<int>(W));
	}
	
	struct Data {
		int y, x, pdir, d, res;
		
		bool operator >(const Data &rhv) const {
			return d > rhv.d || (d == rhv.d && res < rhv.res);
		}
	};
	
	auto ok = [&](int y, int x) {
		return y >= 0 && y < H && x >= 0 && x < W && maps[y][x] == '.';
	};
	
	int dx[4]{1,0,-1,0}, dy[4]{0,1,0,-1};
	
	priority_queue<Data, vector<Data>, greater<Data>> pq;
	REP(dir, 4) {
		d[dir][sty][stx] = 0;
		pq.emplace(Data{sty, stx, dir, 0, 0});
	}
	
	while (!pq.empty()) {
		Data cur = pq.top(); pq.pop();
		if (!chmax(done[cur.pdir][cur.y][cur.x], 1)) continue;
		
		REP(dir, 4) {
			int ny = cur.y + dy[dir], nx = cur.x + dx[dir];
			if (!ok(ny, nx)) continue;
			if (cur.pdir != dir || cur.res == 0) {
				if (chmin(d[dir][ny][nx], cur.d + 1)) pq.emplace(Data{ny, nx, dir, cur.d + 1, K - 1});
			}
			else {
				if (chmin(d[dir][ny][nx], cur.d)) pq.emplace(Data{ny, nx, dir, cur.d, cur.res - 1});
			}
		}
	}
	
	int ans = INF;
	REP(dir, 4) chmin(ans, d[dir][edy][edx]);
	if (ans == INF) ans = -1;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 41216
#include <iostream>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int r, g, b; cin >> r >> g >> b;
	if((10 * g + b) % 4 == 0)
		cout << "YES";
	else
		cout << "NO";
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 2000000
int H,A[MAX];
void maxHeapify(int i){
  int x,l,r,largest;
  l=i*2;
  r=2*i+1;
  if(l<=H&&A[l]>A[i])largest=l;
  else largest=i;
  if(r<=H&&A[r]>A[largest])largest=r;

  if(largest!=i){
    x=A[i];
    A[i]=A[largest];
    A[largest]=x;
    maxHeapify(largest);
}
}
  void  buildMaxHeap(void){
    int i;
    for(i=H/2;i>=1;i--)maxHeapify(i);


  }



int main() {
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++)scanf("%d",&A[i]);
  buildMaxHeap();
  for(i=1;i<=H;i++)printf(" %d",A[i]);
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  vector<int> a(3);
  for(int i = 0; i < 3; ++i){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int gap1 = a[2] - a[1];
  int gap2 = a[2] - a[0];
  if(gap1 % 2 == 0 && gap2 % 2 == 0){
    cout << gap1 /2 + gap2 / 2  << endl;
  }else if(gap1 % 2 == 0 && gap2 % 2 != 0){
    cout << gap1 / 2 + (gap2 + 1) / 2  + 1 << endl;
  }else if(gap1 % 2 != 0 && gap2 % 2 == 0){
    cout << (gap1 + 1) / 2 + gap2 /2 + 1 << endl;
  }else{
    cout << (gap1 - 1)/2 + (gap2 - 1)/2 + 1 << endl;
  }
  
  
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import deque

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

graph = [deque([]) for _ in range(n + 1)]
for _ in range(n-1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

a = [0] * -~n
b = [True] * -~n
for i in range(q):
    p, x = map(int, input().split())
    a[p] += x

d = deque([1])
b[1] = False

while len(d):
    p = d.popleft()
    for i in graph[p]:
        if b[i]:
            a[i] += a[p]
            b[i] = False
            d.append(i)
print(*a[1:])


Measured memory_bytes: 164476
import java.util.*;
import java.io.*;
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt();
        int m=sc.nextInt();
        n--;m--;
        out.println(m*n);
        out.flush();
    }


    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

class P implements Comparable<P>{
    int id, d;
    P(int  id, int d) {
        this.id=id;
        this.d=d;
    }
    public int compareTo(P p){
        return d-p.d; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

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

int main(void){
	int N;
	cin >> N;
	ll A[N];
	rep(i,N) cin >> A[i];
	ll ans = 0;
	for (int i = 1; i < N; i++) {
		if (A[i-1]>A[i]) {
			ans += A[i-1] - A[i];
			A[i] = A[i-1];
		}
	}
	cout << ans << endl;
return 0;
}


Measured memory_bytes: 5180
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));



int main(){
    int a, b;
    cin >> a >> b;
    if(a < b) puts("a < b");
    else if(b < a) puts("a > b");
    else puts("a == b");
}


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

int main() {
	int n, swap=0;
	cin >> n;
	int *a = new int[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n -1; i++)
		for(int j = n - 1; j > i; j--)
			if (a[j] < a[j - 1]) {
				a[j] = a[j - 1] - a[j];
				a[j - 1] -= a[j];
				a[j] += a[j - 1];
				swap += 1;
			}
	for (int i = 0; i < n-1; i++)
		cout << a[i] << ' ';
		cout << a[n - 1] << endl;
		cout << swap << endl;
	return 0;
}

Measured memory_bytes: 3092
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int N,M;

    private class P implements Comparable<P> {
        int s, t;

        public P(int s, int t) {
            this.s = s;
            this.t = t;
        }

        public int compareTo(P other) {
            return this.t - other.t;
        }
    }

    private void solve() {
        N = nextInt();
        M = nextInt();

        P[] ps = new P[M];
        for(int i = 0;i < M;i++) {
            int a = nextInt() - 1;
            int b = nextInt() - 1;
            ps[i] = new P(a, b);
        }

        Arrays.sort(ps);

        int ans = 0;
        int prev = -1;
        for(int i = 0;i < M;i++) {
            if (prev < ps[i].s) {
                prev = ps[i].t - 1;
                ans++;
            }
        }

        out.println(ans);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 45056
#include <iostream>
using namespace std;
int main(){
  int N;
  int A[200];
  int counter=-1;
  cin >> N;
  for(int i=0;i<N;i++){
  cin >>A[i];
  }
  bool flag = true;
  while(flag){
  for(int i=0;i<N;i++){
  if(A[i]%2){
  flag = false;
  }else{
  A[i]=A[i]/2;
  }
  }
  counter++;
  }
  cout << counter << endl;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  int A[N], B[N];
  ll sum_A = 0;
  ll sum_B = 0;
  for (int i = 0; i < N; i++) { cin >> A[i]; sum_A += A[i]; }
  for (int i = 0; i < N; i++) { cin >> B[i]; sum_B += B[i]; }

  if (sum_A < sum_B) { cout << -1 << endl; return 0;}

  vector<int> sub_neg, sub_pos;
  ll sum_neg = 0;
  for (int i = 0; i < N; i++) {
    ll sub = A[i] - B[i];
    if (sub < 0) { sub_neg.push_back(sub); sum_neg += sub; }
    else sub_pos.push_back(sub);
  }

  ll ans = sub_neg.size();
  sort(sub_pos.begin(), sub_pos.end(), greater<ll>());

  ll sum_pos = 0;
  int i = 0;
  while (sum_pos < -sum_neg) {
    ans ++;
    sum_pos += sub_pos[i];
    i ++;
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
int main()
{
	sync;
	ll n,m;
	cin>>n>>m;
	ll tot=1<<n;
	ll dp[tot],val[m]={0};
	for(ll i=0;i<tot;i++)
	dp[i]=1e18;
	
	for(ll i=0;i<m;i++)
	{
		ll a,b;
		cin>>a>>b;
		for(ll j=0;j<b;j++)
		{
			ll x;cin>>x;x--;
			val[i]|=1<<x;
		}
		dp[val[i]]=min(dp[val[i]],a);
	}
	
	
	for(ll i=0;i<tot;i++)
	{
		for(ll j=0;j<m;j++)
		dp[i|val[j]]=min(dp[i|val[j]],dp[i]+dp[val[j]]);
	}
	
	if(dp[tot-1]==1e18)
	cout<<-1;
	else
	cout<<dp[tot-1];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

/*
1 x y
    s[x]=y
2 x y
    文字種を答える
*/

template<typename Monoid>
struct SegmentTree{
    using F = function< Monoid(Monoid, Monoid) >;
    //sz:size->完全二分木なのでszはnよりも大きい最小の2のべき乗数
    int sz;
    vector<Monoid> seg;
 
    const F f;
    const Monoid M1;
    SegmentTree(int n,const F f,const Monoid &M1) : f(f), M1(M1) {

    sz=1;
    while(sz<n) sz<<=1;
    seg.assign(2*sz, M1);
    }
 
    void set(int k, const Monoid &x){
        seg[k+sz] = x;
    }
 
    void build(){
        for(int k=sz-1;k>0;k--){
        seg[k]=f(seg[2*k+0], seg[2*k+1]);
        }
    }
 
    void update(int k,const Monoid &x){
        k+=sz;
        seg[k]=x;
        
    while(k>>=1){
        seg[k]=f(seg[2*k+0],seg[2*k+1]);
        }
    }
    //query聞くときは区間は[a,b)で(a<=x<b)
    Monoid query(int a, int b) {
        Monoid L=M1,R=M1;
        for(a+=sz,b+=sz;a<b;a>>=1,b>>=1){
            if(a&1) L=f(L, seg[a++]);
            if(b&1) R=f(seg[--b], R);
        }
        return f(L,R);
    }   
    Monoid operator[](const int &k) const{
        return seg[k+sz];
    }
};
int f(int a,int b){return a+b;}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;cin>>n;
    string s;cin>>s;
    int q;cin>>q;

    vector<SegmentTree<int>> segs;
    rep(i,26){
        char x='a'+i;
        SegmentTree<int> seg(n,f,0);
        rep(j,n){
            if(s[j]==x) seg.set(j,1);
            else        seg.set(j,0);
        }
        seg.build();
        segs.push_back(seg);
    }

    while(q--){
        int t;cin>>t;
        if(t==2){
            int x,y;cin>>x>>y;
            x--;
            int ans=0;
            rep(i,26){
                if(segs[i].query(x,y)>0) ans++;
            }
            cout<<ans<<endl;
        }
        else{
            int x;char y;cin>>x>>y;
            x--;
            segs[s[x]-'a'].update(x,0);
            segs[y-'a'].update(x,1);
            s[x]=y;
        }
    }
    return 0;
}


Measured memory_bytes: 144276
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_map>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll powmod(ll a, ll b) {
	a %= MOD;
	ll res = 1;
	while (b > 0) {
		if (b % 2 == 1)res = res * a % MOD;
		a = a * a % MOD;
		b /= 2;
	}
	return res;
}
ll f[210000];
void cominit() {
	f[0] = 1;
	REP(i, 201000)f[i + 1] = f[i] * (i + 1) % MOD;
}

ll com(ll n, ll r) {
	if (n < r)return 0;
	if (n < 0 or r < 0)return 0;
	return f[n] * powmod(f[r] * f[n - r], MOD - 2) % MOD;
}

ll perm(ll n, ll r) {
	if (n < r)return 0;
	if (n < 0 or r < 0)return 0;
	return f[n] * powmod(f[n - r], MOD - 2) % MOD;
}

ll dp[210000], sz[210000];
vector<ll> g[210000], ans(210000);
ll n;

void dfs1(ll a, ll p) {
	vector<ll> v;
	sz[a]++;
	dp[a] = 1;
	ll now = 0;
	REP(i, g[a].size()) {
		if (g[a][i] == p)continue;
		dfs1(g[a][i], a);
		sz[a] += sz[g[a][i]];
		dp[a] *= dp[g[a][i]];
		dp[a] %= MOD;
		v.push_back(sz[g[a][i]]);
		now += sz[g[a][i]];
	}
	REP(i, v.size()) {
		dp[a] *= com(now, v[i]);
		dp[a] %= MOD;
		now -= v[i];
	}
}

void dfs2(ll a, ll p, ll vp) {
	ans[a] = dp[a];
	//cout << a << " " << p << " " << vp << endl;
	if (p != -1) {
		ans[a] *= com(n - 1, n - sz[a]);
		ans[a] %= MOD;
		ans[a] *= vp;
		ans[a] %= MOD;
	}
	REP(i, g[a].size()) {
		if (g[a][i] == p)continue;
		ll t = ans[a] * powmod(dp[g[a][i]] * com(n - 1, sz[g[a][i]]), MOD - 2) % MOD;
		//cout << a << " " << t << endl;
		dfs2(g[a][i], a, t);
	}
}
int main() {
	cominit();
	
	cin >> n;
	REP(i, n - 1) {
		ll a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs1(0, -1);
	dfs2(0, -1, 0);
	REP(i, n)cout << ans[i] << endl;
}


Measured memory_bytes: 22512
N = int(input())
p =list(map(int, input().split()))

strange=[]
for i in range(1,1+N):
  if p[i-1]!=i:
    strange.append(i)
if len(strange)==2:
	flag1=strange[0]==p[strange[1]-1]
	flag2=strange[1]==p[strange[0]-1]
	flag=flag1*flag2
if len(strange)==0:
  print('YES')
elif len(strange)!=2:
  print('NO')
elif flag:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a2,a3,b1,b2,b3;
  int c[3][3];
  for(int i=0;i<3;i++)for(int j=0;j<3;++j)cin>>c[i][j];
  for(int a1=0;a1<=100;a1++){
    b1=c[0][0]-a1;b2=c[0][1]-a1;b3=c[0][2]-a1;
    a2=c[1][0]-b1;a3=c[2][0]-b1;
    if(c[1][1]==a2+b2&&c[1][2]==a2+b3&&c[2][1]==a3+b2&&c[2][2]==a3+b3)return cout<<"Yes",0;
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8').trim()
const lines = input.trim().split("\n")
while (lines.length > 1) {
    const [c1, c2] = lines.shift().trim().split(" ").map(Number)
    const d1 = [], d2 = []
    while (d1.length < c1) {
        d1.push(parseInt(lines.shift().trim()))
    }
    while (d2.length < c2) {
        d2.push(parseInt(lines.shift().trim()))
    }

    const sD1 = d1.reduce((s, v) => s + v, 0)
    const sD2 = d2.reduce((s, v) => s + v, 0)
    if(sD1 === sD2) {
        d1.sort((a,b) =>  a - b)
        let rs = -1, i = 0
        while (rs === -1 && i < c1) {
            if(d2.includes(d1[i])) {
                rs = d1[i]
            }
            i++
        }
        if(rs === -1) {
            console.log(-1)
        } else {
            console.log(rs + ' ' + rs)
        }
    } else if((sD1 + sD2)%2){
        console.log(-1)
    } else {
        const sD = (sD1 + sD2) / 2
        let m1, m2, sum = 201
        for (let i = 0; i < c1; i++) {
            const t1 = d1[i], t2 = sD - sD1 + t1
            if(d2.includes(t2) && sum > t1 + t2) {
                sum = t1 + t2
                m1 = t1
                m2 = t2
            }
        }
        if(sum < 201) {
            console.log(m1 + ' ' + m2)
        } else {
            console.log(-1)
        }
    }
}


Measured memory_bytes: 16148
N  = int(input())
S1 = list(input())
S2 = list(input())

if S1[0] == S2[0]:
    result = 3
    skip   = False
    tate   = True
else:
    result = 6
    skip   = True
    tate   = False

for n in range(1, N):
    if skip == True:
        skip = False
        continue
    elif S1[n] == S2[n]:
        if tate == True:
            result *= 2
        else:
            tate = True
    else:
        if tate == True:
            result *= 2
        else:
            result *= 3
        skip    = True
        tate    = False
    if result  >= 1000000007:
        result %= 1000000007

print(result)


Measured memory_bytes: 3064
import string
import sys

S = string.ascii_uppercase + string.ascii_lowercase + string.digits + "+/"

mod = 10**9 + 9; p = 13; q = 19
L = 1000
p_table = [1]*(L+1); q_table = [1]*(L+1)
for i in range(L):
    p_table[i+1] = p_table[i] * p % mod
    q_table[i+1] = q_table[i] * q % mod
readline = sys.stdin.readline
write = sys.stdout.write
def to_hash(S, W, H):
    D = [[0]*(W+1) for i in range(H+1)]
    for i in range(H):
        su = 0
        dp = D[i]
        di = D[i+1]
        si = S[i]
        for j in range(W):
            su = (su*p + si[j]) % mod
            di[j+1] = (su + dp[j+1]*q) % mod
    return D
mod = 10**9 + 9; p = 13; q = 19
def get(S, x0, y0, x1, y1):
    P = p_table[x1 - x0]; Q = q_table[y1 - y0]
    return (S[y1][x1] - S[y1][x0] * P - S[y0][x1] * Q + S[y0][x0] * (P * Q) % mod) % mod
def rotate(S, W, H):
    T = [[0]*H for i in range(W)]
    for i in range(H):
        for j in range(W):
            T[j][H-1-i] = S[i][j]
    return T
def mirror(S, W, H):
    T = [[0]*W for i in range(H)]
    for i in range(H):
        for j in range(W):
            T[i][W-1-j] = S[i][j]
    return T


def solve():
    W, H, P = map(int, readline().split())
    if W == H == P == 0:
        return False
    D = S.index
    C = []
    for i in range(H):
        data = readline().strip()
        cs = []
        for c in data:
            v = D(c)
            for k in range(5, -1, -1):
                cs.append(v & (1 << k) > 0)
        C.append(cs)
    E = []
    for i in range(P):
        data = readline().strip()
        es = []
        for c in data:
            v = D(c)
            for k in range(5, -1, -1):
                es.append(v & (1 << k) > 0)
        E.append(es)
    E0 = E
    sv = set()
    for k in range(4):
        sv.add(to_hash(E, P, P)[-1][-1])
        E = rotate(E, P, P)
    E = mirror(E0, P, P)
    for k in range(4):
        sv.add(to_hash(E, P, P)[-1][-1])
        E = rotate(E, P, P)
    F = to_hash(C, W, H)
    ans = 0
    for i in range(H-P+1):
        for j in range(W-P+1):
            if get(F, j, i, j+P, i+P) in sv:
                ans += 1
    write("%d\n" % ans)
    return True
while solve():
    ...


Measured memory_bytes: 55428
#include<bits/stdc++.h>
#define INF 1000000000
using namespace std;
int main(){
  vector<int> a(5);
  for(int i=0;i<5;i++)cin >> a[i];
  vector<int> P  = {0,1,2,3,4};
  int ans=INF;
  do{
    int sum=0;
    for(int i=0;i<5;i++){
      while(sum%10!=0)sum++;
      sum+=a[P[i]];
    }
    ans=min(ans,sum);
  }while(next_permutation(P.begin(),P.end()));
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(x) cout<<x<<endl
#define Gput(a,b) G[a].push_back(b)
int main() {
  cout << fixed << setprecision(16);
  ll n;
  cin>>n;
  ll f[n][10];
  ll p[n][11];
  loop(i,n){
    loop(j,10){
      cin>>f[i][j];
    }
  }
  loop(i,n){
    loop(j,11){
      cin>>p[i][j];
    }
  }
  ll count=0;
  ll sum=0;
  ll ans=MIN;
  Loop(bit,flag(0),flag(10)){
    sum=0;
    loop(j,n){
      count=0;
    loop(k,10){
    if(flagon(bit,k)){
      if(f[j][k])count++;
    }
   }
      
     sum+=p[j][count];
    }
    ans=max(ans,sum);
  }
  putout(ans);
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
long long ans=2;
void work(int n);
int main(){
	int x;
	scanf("%d",&x);
	work(x);
	printf("%lld",ans);
	return 0;
}
void work(int n){
	for(int i=1;i<=n;i++)
		ans=(ans+1)*2;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int m, k;
    cin >> m >> k;
    int tmp = m, b = 1;
    while(tmp){
        b *= 2;
        --tmp;
    }
    if(b <= k || (m == 1 && k == 1)) {
        cout << "-1\n";
        return 0;
    }
    if(m == 1){
        cout << "0 0 1 1\n";
        return 0;
    }

    for(int i = b - 1; i >= 1; --i){
        if(i == k) continue;
        cout << i << " ";
    }
    cout << k << " ";
    for (int  i = 1; i < b; i++){
        if(i == k) continue;
        cout << i << " ";
    }
    if(k == 0) cout << "0\n";
    else cout << "0 " << k << " 0\n";
    
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef int64_t Int;
#define dump(x) cout << (x) << '\n'
Int mod = 1e9+7;
//Int mod = 998244353; 
Int INF = 1e9+7;

int main() {    
    Int h, w, n;
    cin >> h >> w >> n;
    Int sr, sc;
    cin >> sr >> sc;
    string s, t;
    cin >> s >> t;
    Int xl = 1;
    Int xr = w;
    Int xu = 1;
    Int xd = h;
    for (Int i = n - 1; i >= 0; i--) {
        if (t[i] == 'R') xl = max(1L, xl - 1L);
        if (t[i] == 'L') xr = min(w, xr + 1L);
        if (t[i] == 'D') xu = max(1L, xu - 1L);
        if (t[i] == 'U') xd = min(h, xd + 1L);
        if (s[i] == 'L') xl++;
        if (s[i] == 'R') xr--;
        if (s[i] == 'U') xu++;
        if (s[i] == 'D') xd--;
        if (xl > xr || xu > xd) {
            dump("NO");
            return 0;
        }
    }
    /* cout << "h " << xu << " " << xd << endl;
    cout << "w " << xl << " " << xr << endl; */
      if (xl <= sc && sc <= xr && xu <= sr && sr <= xd) {
            dump("YES");
            return 0;
        }
        else {
            dump("NO");
        }
    return 0;  
}

Measured memory_bytes: 776
package main

import (
	"bufio"
	"fmt"
	"os"
)

type State struct {
	ID, D int
}

func main() {
	H, W := ReadInt(), ReadInt()
	grid := make([]string, H)
	for i := 0; i < H; i++ {
		grid[i] = ReadString()
	}
	toID := func(x, y int) int {
		return x + y*W
	}
	fromID := func(id int) (x, y int) {
		return id % W, id / W
	}
	q := make([]State, 0)
	for y := 0; y < H; y++ {
		for x := 0; x < W; x++ {
			if grid[y][x] == '#' {
				q = append(q, State{
					ID: toID(x, y),
					D:  0,
				})
			}
		}
	}
	ans := -1
	seen := make([]bool, H*W)
	var dx = []int{1, 0, -1, 0}
	var dy = []int{0, 1, 0, -1}
	for len(q) > 0 {
		now := q[0]
		q = q[1:]
		if seen[now.ID] {
			continue
		}
		seen[now.ID] = true
		if ans < now.D {
			ans = now.D
		}
		x, y := fromID(now.ID)
		for i := 0; i < 4; i++ {
			nx, ny := x+dx[i], y+dy[i]
			if 0 <= nx && nx < W && 0 <= ny && ny < H {
				q = append(q, State{
					ID: toID(nx, ny),
					D:  now.D + 1,
				})
			}
		}
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 275112
#include<bits/stdc++.h>
/* #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<stdio.h>
#include<stack>
#include<math.h>
#include<utility>
#include<tuple>
 */
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,n) for(int i=1;i<=(n);i++)
#define brep(i,n) for (int i=n-1;i>=0;i--)
#define LL long long int
 
 /* 
 greater<int>() 
 sortの第三因数に入れて降順 
sqrt(double) √を求める 
pair<int,int> x=make_pair(a,b)
x.first
tuple  get<番目>(変数名)

stack<int> s;//いきどまり
s.push(x) //先頭に入れる
s.pop() //先頭を消す
s.top() //先頭にアクセス
s.empty() //中身があれば0,空なら1
s.size() //中身の数

queue <int> q;//一方通行
q.push(x) //先頭に入れる
q.pop() //先頭を消す
q.front() //先頭にアクセス
q.empty() //中身があれば0,空なら1
q.size() //中身の数

 */
using namespace std;
 
LL lcm(LL n, LL m)
{
	LL u;
	LL ansl = 0;
	for(u=m; u>=m; u++){
		if(u%n == 0){
			if(u%m == 0){
				ansl = u;
				break;
			}
		}
	}
	return ansl;
}
 

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

    vector<LL>d(n);
    rep(i,n){
        cin >>d[i];
    }
LL now =0;
bool ans=true;
    rep(i,n){
/*         if(now<=d[i]){
            now=d[i];
        }
        */
       now=max(d[i],now);
        if(now<10){
            ans=false;
            break;
        }
        now-=10;
    }
    now=0;
    if(ans==true){
        brep(i,n){
            now=max(d[i],now);
            
            if(now<10){
                ans=false;
                break;
            
            }
            now-=10;
        }
    }
    if (ans==true)cout <<"yes"<<endl;
    else cout <<"no"<<endl;
    return 0;
}
/*
4
20
5
10
1


3
10
5
10


4
20
30
1
20

 */


Measured memory_bytes: 5216
#include<stdio.h>
int main()
{  int n,i,a[100];
   scanf("%d",&n);
   for(i=0;i<n;i++)
   scanf("%d",&a[i]);
   for(i=0;i<n;i++)
   {  if(a[i]%2==0) 
      {  if(a[i]%3==0||(a[i]%5==0))
         ;
         else { printf("DENIED");i=n+1;}
	  }
   }
   if(i==n) printf("APPROVED");
} 

Measured memory_bytes: 128
(function(input) {
  var p = input.replace(/\n$/, '').split('\n');
  var n = Number(p.shift());
  for (var i = 0; i < n; i++) {
    var a = p.shift().split(' ').map(Number);
    console.log(order(a));
  }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

function order(a) {
  var r = [];
  var x;
  var c = a.shift();
  while (x = a.shift()) {
    if (x > c) {
      c = x;
      continue;
    }
    r.push(x);
  }
  var m = - Infinity;
  while (x = r.shift()) {
    if (x > m) {
      m = x;
      continue;
    }
    return 'NO';
  }
  return 'YES';
}

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

int main(){
  int N;
  cin >> N;
  vector<int> D(N);
  for(int i=0;i<N;i++){
    cin >> D.at(i);
  }
  sort(D.begin(),D.end());
  cout << D.at(N/2)-D.at(N/2-1) << endl;
}

Measured memory_bytes: 3788
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
typedef long long ll;
using namespace std;
int main()
{
	string a, b;
	cin >> a >> b;
	if (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

 #最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

N=int(input())
A=list(map(int,input().split()))
a_lcm=A[0]
Mod=10**9+7

for i in range(1,N):
    a_lcm=lcm(a_lcm,A[i])

#a_lcm%=Mod

result=0
for i in range(N):
    result+=a_lcm*pow(A[i],Mod-2,Mod)
print(result%1000000007)


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

int main() {
    int n; cin >> n;
    vector<vector<int>> vec(n, vector<int>(n, 0));

    for (int i = 0; i < n; i++)
    {
        int u, k, tmp; cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            cin >> tmp;
            vec.at(i).at(tmp-1)=1;
        }
        
    }
    
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cout << vec.at(i).at(j) ;
            if(j!=n-1) cout << " ";
        }
        cout << endl;
    }
    
}
//g++ -o a.exe a.cpp


Measured memory_bytes: 3168
from functools import reduce
import math
import copy
def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    X = list(int(_) for _ in input().split())
    X_tmp = copy.deepcopy(X)
    X_tmp.sort()
    X_avg = (X_tmp[(N//2)-1] + X_tmp[(N//2)])/2
    for i in range(N):
        if X[i] > X_avg:
            print(X_tmp[(N//2)-1])
        else:
            print(X_tmp[(N//2)])
            
if __name__ == '__main__':
    main()


Measured memory_bytes: 27268
#include <stdio.h>

int main(void)
{
    double a, b, c, d, e, f;
    double x, y;

    while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF){
        y = (a * f - c * d) / (a * e - b * d);
        x = (c - b * y) / a;
        printf("%.3lf %.3lf\n", x, y);
    }

    return (0);
}

Measured memory_bytes: 652
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<int> ans(n,0);
  (n==1?ans.at(0)=0:ans.at(0)=1);
  vector<int> check(n,-1);
  rep(i,m){
    int s,c;
    cin>>s>>c;
    s--;
    if((check.at(s)>0&&c!=ans.at(s))||(s==0&&c==0&&n!=1)){
      cout<<-1;
      return 0;
    }
    else{
      check.at(s)*=-1;
      ans.at(s)=c;
    }
  }
  rep(i,n) cout<<ans.at(i);
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
struct A {
	int p, y, x;
	bool operator<(A a) {
		return y < a.y;
	}
};
int n, m;
A a[200000];
string b[200000];
int c[200000];
signed main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i].p >> a[i].y;
		a[i].x = i;
	}
	sort(a, a + m);
	for (int i = 0; i < m; i++) {
		string h = to_string(++c[a[i].p]);
		while (h.size() < 6) h = "0" + h;
		h = to_string(a[i].p) + h;
		while (h.size() < 12) h = "0" + h;
		b[a[i].x] = h;
	}
	for (int i = 0; i < m; i++) cout << b[i] << endl;
}

Measured memory_bytes: 11520