akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

ll N, K; 
VVL G;
constexpr ll mod = 1e9+7;

ll dfs(ll from, ll to){
    if(K < G[to].size()) return 0;
    ll usable;
    if(from == -1) usable = K - 1;
    else usable = K - 2;
    ll case_num = 1;
    // usable P #children
    for(auto g : G[to]){
        if(g == from) continue;
        case_num *= usable;
        usable--;
        case_num %= mod;
    }
    for(auto g : G[to]){
        if(g == from) continue;
        case_num *= dfs(to, g);
        case_num %= mod;
    }
    return case_num;
}

int main(){
    cin >> N >> K;
    G.resize(N+1);
    rep(i, 0, N-1){
        ll v, u;
        cin >> v >> u;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    ll ans = K * dfs(-1, 1);
    ans %= mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10368
#include<stdio.h>
int main(void){
	int i,sum;
	char num[1001];

	while(1){
		scanf("%s",num);
		if(num[0] == '0')
			break;
		sum = 0;
		for(i=0;num[i];i++)
			sum += num[i] - '0';
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 536
#include <bits/stdc++.h>
using namespace std;
  
int main()
{
  int n;
  cin >>n;
  int arr[n],dp[n];
  for(int i=0;i<n;i++)
    cin >>arr[i];
  dp[0]=0;
  dp[1]=abs(arr[1]-arr[0]);
  for(int i=2;i<n;i++)
  {
    dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),
              dp[i-2]+abs(arr[i]-arr[i-2]));
  }
  cout <<dp[n-1] <<endl;
}

Measured memory_bytes: 1024
K, N = map(int, input().split())
MOD = 998244353

P = N+K
fact = [1]*(P+1)
rfact = [1]*(P+1)
for i in range(P):
    fact[i+1] = r = ((i+1) * fact[i]) % MOD
    rfact[i+1] = pow(r, MOD-2, MOD)

def comb(n, k):
    return fact[n] * rfact[k] * rfact[n-k] % MOD

V = [1]*(P+1)
r = 1
for i in range(P):
    r = (r * 2) % MOD
    V[i+1] = r * rfact[i+1] % MOD

memo = {}
def calc(A):
    if A in memo:
        return memo[A]
    M = A//2
    r = 0
    if A % 2:
        p = K - 2*M + N - 2
        for m in range(max(0, 2*M+2-K), min(M, N-1)+1):
            r += V[m] * rfact[M-m] * (fact[p]*rfact[N-m] + fact[p-1]*rfact[N-m-1])*rfact[p-N+m] % MOD

        if 2*M+2-K <= N <= M:
            r += V[N] * rfact[M-N] % MOD
        r *= fact[M]
    else:
        p = K - 2*M + N - 1
        for m in range(max(0, 2*M+1-K), min(N, M)+1):
            r += V[m] * rfact[M-m] * rfact[N-m] * rfact[p-N+m] % MOD
        r *= fact[M] * fact[p]
    r = memo[A] = r % MOD
    return r
ans = []
for i in range(2, 2*K+1):
    if i <= K:
        ans.append(calc(i - 1))
    else:
        ans.append(calc(2*K - i + 1))
print(*ans, sep='\n')


Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
template<class T> istream& operator>>(istream &is,vector<T> &st){
  for(size_t i=0;i<st.size();++i) is >> st[i];
  return is;
}
template<class T> istream& operator>>(istream &is,vector<vector<T>> &st){
  for(size_t i=0;i<st.size();++i) is >> st[i];
  return is;
}
template<class T> ostream& operator<<(ostream &os, const vector<T> &st){
  for(size_t i=0;i<st.size();++i){
    if(i==st.size()-1) os << st[i];
    else os << st[i] << " ";
  }
  return os;
}
template<class T> ostream& operator<<(ostream &os, const vector<vector<T>> &st){
  for(size_t i=0;i<st.size();++i){
    os << st[i];
    if(i!=st.size()-1) os << endl;
  }
  return os;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  //sort(ALL(s));
  REP(i,3){
    if(s[i]==s[i+1]){
      puts("Bad");
      return 0;
    }
  }
  puts("Good");
}


Measured memory_bytes: 256
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      s: chars,
    }
    const MOD: usize = 1e9 as usize + 7;
    let n = s.len();
    let mut dp = vec![vec![0; 13]; n+1];
    dp[0][0] = 1;
    for i in 0..n {
        let c = s[i];
        for m in 0..13 {
            if c == '?' {
                for v in 0..10 {
                    let idx = (m*10 + v) % 13;
                    dp[i+1][ idx ] += dp[i][m];
                    dp[i+1][ idx ] %= MOD;
                }
            } else {
                let v = (c as u8 - '0' as u8) as usize;
                let idx = (m*10 + v) % 13;
                dp[i+1][ idx ] += dp[i][m];
                dp[i+1][ idx ] %= MOD;
            }
        }
    }
    puts!("{}\n", dp[n][5]);
}


Measured memory_bytes: 18684
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) lli(x.size())
#define mp(i,a) make_pair(i,a)
#define pb(a) push_back(a)
#define bit(x,b) (x&(1LL<<b))

typedef long long int lli;
typedef pair <lli,lli> ii;
typedef pair <lli,ii> iii;
typedef vector <lli> vi;
lli arr[64][64]={};
vector<ii> v;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lli n;
  cin>>n;
  for(lli i=0;i<n;++i)
  {
  	string f;
  	lli s=0,t=0,fo=0,ch=0,co=9;
  	cin>>f;
  	for(int j=0;j<f.size();++j)
  	{
  		if(f[j]=='.')
  		{
  			ch=1;
  			continue;
  		}
  		if(ch)
  			co--;
  		s*=10;
  		s=s+(f[j]-'0');
  	}
  	for(int i=0;i<co;++i)
  		s*=10;
  	while(s%5==0)
  	{
  		s/=5;
  		t++;
  	}
  	while(s%2==0)
  	{
  		s/=2;
  		fo++;
  	}
  	v.pb(mp(t,fo));
  }
  for(lli i=0;i<v.size();++i)
  {
  	for(lli j=v[i].F;j>=0;--j)
  	{
  		for(lli k=v[i].S;k>=0;--k)
  		{
  			arr[j][k]++;
  		}
  	}
  }
  lli ans=0;
  for(lli i=0;i<n;++i)
  {
  	lli f=v[i].F,s=v[i].S;
  	f=max(0*1LL,18-f);
  	s=max(0*1LL,18-s);
  	ans+=arr[f][s];
  	if(f<=v[i].F&&s<=v[i].S)
  		ans--;
  }
  cout<<ans/2<<endl;
  return(0);
}

Measured memory_bytes: 7416
using System;
using System.Linq;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var r = a[0];
            var d = a[1];
            var x = a[2];
            for (int i = 0; i < 10; i++)
            {
                x = x * r - d;
                Console.WriteLine(x);
            }
        }
    }
}


Measured memory_bytes: 13268
n=int(input())
for i in range(1,3501):
	for j in range(1,3501):
		if 4/n-1/i-1/j==0:
			continue
		if abs((1/(4/n-1/i-1/j)-int(1/(4/n-1/i-1/j))))<10**-12:
			if 10**7>(1/(4/n-1/i-1/j))>0:
				print(i,j,int(1/(4/n-1/i-1/j)))
				exit()


Measured memory_bytes: 41452
import java.util.Scanner;

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

	Scanner sca = new Scanner(System.in);
	// 入力

	int n = sca.nextInt();
	int[] pi = new int[n];
	for(int i = 0; i < n; i++) {
		pi[i] = sca.nextInt();
	}

	int ans = 0;
	int min = 300000;
	for(int i = 0; i < n; i++) {
		if(min > pi[i]) {
			min = pi[i];
			ans++;
		}
		else {

		}
	}

	System.out.println(ans);

	// 後始末
	sca.close();
	}
}

Measured memory_bytes: 85308
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;
struct Edge {
	int from,to,cost;
	Edge(int _f,int _t,int _c) {from=_f,to=_t,cost=_c;}
};
int get(char str[5]) {
	if(str[0]=='H')return 0;
	if(str[0]=='D')return 107;
	if(str[0]=='C')return atoi(str+1);
	if(str[0]=='L')return 6+atoi(str+1);
}
int cake[6],cost[1<<6][108];
vector<Edge> edges;
int main() {
	int m,n,k,d;
	while(scanf("%d %d %d %d",&m,&n,&k,&d),m) {
		for(int i=0;i<m;i++) scanf("%d",&cake[i]);
		edges.clear();
		for(int i=0;i<d;i++) {
			char str1[5],str2[5],dist;
			scanf("%s  %s %d",str1,str2,&dist);
			edges.push_back(Edge(get(str1),get(str2),dist*k));
			edges.push_back(Edge(get(str2),get(str1),dist*k));
		}
		fill((int*)cost,(int*)(cost+(1<<6)),1<<27);
		cost[0][0]=0;
		while(true) {
			bool update=false;
			for(int i=0;i<edges.size();i++) {
				Edge es=edges[i];
				for(int j=0;j<(1<<m);j++) {
					int add=0;
					if(1<=es.from&&es.from<=6&&!(j&(1<<(es.from-1)))) continue;
					if(1<=es.to&&es.to<=6&&(j&(1<<(es.to-1)))) continue;
					int nj=j;
					if(1<=es.to&&es.to<=6) {nj|=(1<<(es.to-1)),add=-cake[es.to-1];}
					if(cost[nj][es.to]>(cost[j][es.from]+es.cost+add)) {
						cost[nj][es.to]=cost[j][es.from]+es.cost+add;
						update=true;
					}
				}
			}
			if(!update) break;
		}
		int ans=1<<27;
		for(int i=0;i<(1<<m);i++) {
			ans=min(ans,cost[i][107]);
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1072
using System;
using System.Collections.Generic;
using CompLib.Util;
using Microsoft.VisualBasic;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int[] a = sc.IntArray();

        int min = int.MaxValue;
        long sum = 0;
        int minus = 0;
        int zero = 0;
        foreach (int i in a)
        {
            min = Math.Min(min, Math.Abs(i));
            sum += Math.Abs(i);
            if (i < 0) minus++;
            if (i == 0) zero++;
        }

        if (minus % 2 == 1 && zero == 0)
        {
            Console.WriteLine(sum - min - min);
        }
        else
        {
            Console.WriteLine(sum);
        }
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 31964
program main
	implicit none
	integer :: N
	integer, allocatable :: A(:)
	integer :: i, ans
	
	read(*, *) N
	allocate(A(1:N+1))
	read(*, *) A(1:N)
	A(N+1) = 1000000
	ans = 1

	call heapsort(N+1,A)
	if(mod(N,2) == 0) then
		do i = 1, N/2
			if(A(2*(i-1)+1) /= A(2*i) .OR. A(2*(i-1)+1) /= 2*i-1) then
				write(*, *) 0
				goto 10
			end if
		end do
		do i = 1, N/2
			ans = mod(ans*2,1000000000+7)
		end do
		write(*, *) ans
	else
		if(A(1) /= 0) then
			write(*, *) 0
			goto 10
		end if
		do i = 1, (N-1)/2
			if(A(2*i) /= A(2*i+1) .OR. A(2*i) /= 2*i) then
				write(*, *) 0
				goto 10
			end if
		end do
		do i = 1, N/2
			ans = mod(ans*2,1000000000+7)
		end do
		write(*, *) ans	
	end if
	

	10 continue
	
	contains
	subroutine heapsort(n,array)
		implicit none
		integer,intent(in) :: n
		integer,intent(inout) :: array(1:n)
  
		integer ::i,k,j,l
		double precision :: t
  
		if(n.le.0)then
			write(6,*)"Error, at heapsort"; stop
		endif
		if(n.eq.1)return

		l=n/2+1
		k=n
		do while(k.ne.1)
			if(l.gt.1)then
				l=l-1
				t=array(L)
			else
				t=array(k)
				array(k)=array(1)
				k=k-1
				if(k.eq.1) then
					array(1)=t
					exit
				endif
			endif
			i=l
			j=l+l
			do while(j.le.k)
				if(j.lt.k)then
					if(array(j).lt.array(j+1))j=j+1
				endif
				if (t.lt.array(j))then
					array(i)=array(j)
					i=j
					j=j+j
				else
					j=k+1
				endif
			enddo
			array(i)=t
		enddo

		return
	end subroutine heapsort
end program main

Measured memory_bytes: 1152
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	x, n := scanInt(), scanInt()
	hash := map[int]bool{}
	for i := 0; i < n; i++ {
		hash[scanInt()] = true
	}

	var ans int
	for i := 0; i <= 100; i++ {
		if !hash[x-i] {
			ans = x - i
			break
		} else if !hash[x+i] {
			ans = x + i
			break
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long MOD = 1000000007;

void solve(string L){
    vector<ll> dp1(L.size());
    vector<ll> dp2(L.size());
    if (L[0]=='0'){
        dp1[0] = 0;
        dp2[0] = 1;

    }else{
        dp1[0] = 1;
        dp2[0] = 2;
    }
    for (int i=1;i<L.size();i++){
        if (L[i] == '0'){
            dp1[i] = (dp1[i-1]*3)%MOD;
            dp2[i] = (dp2[i-1])%MOD;
        }else{
            dp1[i] = (dp1[i-1]*3+dp2[i-1])%MOD;
            dp2[i] = (dp2[i-1]*2)%MOD;
        }
    }
    ll ans = dp1.back() + dp2.back();
    printf("%lld\n",ans%MOD);
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    string L;
    cin >> L;
    solve(L);
    return 0;
}


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

using namespace std;

bool check(vector<char>s)
{
    int i=0,j=(int)s.size()-1;
    while(i<=j)
    {
        if(s[i]!=s[j])
            return false;

        i++;
        j--;
    }

    return true;
}
//akasakalevel
void test()
{
   string s;
   cin>>s;

   vector<char>a,b,c;

   for(auto ch:s)
    a.push_back(ch);

   for(int i=0;i<((int)a.size()-1)/2;i++)
    b.push_back(a[i]);

   for(int i=((int)a.size()+2)/2;i<(int)a.size();i++)
   c.push_back(a[i]);//akasaka

   if(check(a) && check(b) && check(c))
    cout<<"Yes";
   else
    cout<<"No";

}

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

    test();

    return 0;
}


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

int main(){
    int N,M;
    int counter,counter_max = 0;

    cin >> N;
    vector<string> str_s(N);

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

    cin >> M;
    vector<string> str_t(M);

    for(int i = 0;i < M;i++){
        cin >> str_t[i];
    }

    for(int i = 0;i < N;i++){
        for(int j = 0;j < N;j++){
            if(str_s[i] == str_s[j])counter++;
        }
        for(int k = 0;k < M;k++){
           if(str_s[i] == str_t[k])counter--;
        }
        counter_max = max(counter,counter_max);
        counter = 0;
    }

    cout << counter_max << endl;
}

Measured memory_bytes: 256
s = input()
t = input()
ans = float('inf')
for i in range(len(s)-len(t)+1):
    c = 0
    for j in range(len(t)):
        
        if s[i+j] != t[j]:
            c+=1
    
    ans = min(ans,c)
    
print(ans)
        

Measured memory_bytes: 9104
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
bg1, bg2, bg3 = [0]*3, [0]*3, [0]*3
for i in range(N):
  b = int(input())
  for j in range(3):
    if b == A1[j]:
      bg1[j] = 1
    if b == A2[j]:
      bg2[j] = 1
    if b == A3[j]:
      bg3[j] = 1
if sum(bg1) == 3 or sum(bg2) == 3 or sum(bg3) == 3:
  print("Yes")
elif bg1[0]+bg2[0]+bg3[0]==3 or bg1[1]+bg2[1]+bg3[1]==3 or bg1[2]+bg2[2]+bg3[2]==3:
  print("Yes")
elif bg1[0]+bg2[1]+bg3[2]==3 or bg1[2]+bg2[1]+bg3[0]==3:
  print("Yes")
else:
  print("No")
  

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
int n,m;
const int maxn=101000;
typedef long long ll;
const int N=1e5+100;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
struct poi{
    ll L,R,len;
    bool operator<(const poi&t)const{
        if(R!=t.R)
            return R<t.R;
        else
            return len<t.len;
    }
};
poi a[N];
int main()
{
    int n;
    scanf("%d",&n);
    ll x,y;
    for(int i=0;i<n;i++){
        scanf("%lld%lld",&x,&y);
        a[i].L=x-y;a[i].R=x+y;
        a[i].len=2*y;
    }
    sort(a,a+n);
    ll maxe=-inf;

    int sum=0;
    for(int i=0;i<n;i++){
        if(a[i].L>=maxe){
            maxe=a[i].R;
            //cout<<i<<endl;cout<<"asd   "<<maxe<<endl;
        }else
            sum++;

    }
    cout<<n-sum<<endl;
    return 0;
}
/*
    fac[0]=1;
    for(int i=1; i<=n; i++)
    {
        fac[i]=fac[i-1]*i%mod;
    }
*/



Measured memory_bytes: 2560
import sys
n,a,b,c,d=map(int,input().split())
s=input()
if '##' in s[a:c]:
    print('No')
    sys.exit()
if '##' in s[b:d]:
    print('No')
    sys.exit()
if d<c:
    if s[b-2]==s[b]=='.':
        print('Yes')
        sys.exit()
    elif '...' in s[b-1:d+1]:
        print('Yes')
        sys.exit()
    else:
        print('No')
        sys.exit()
if s[b-2]=='#' and b+1==d and s[d]=='#':
    print
print('Yes')
    
    

Measured memory_bytes: 3636
n = int(input())
a = list(map(int, input().split()))

total = [0]

for i in range(n):
    total.append(total[i]+a[i])

total.append(10**20)
total.sort()

count = 1
ans = 0

for i in range(n+1):
    if(total[i]==total[i+1]):
        count+=1
    else:
        ans += count*(count-1)//2
        count = 1

print(ans)
    


Measured memory_bytes: 106064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int x = scan.nextInt();
		int a = scan.nextInt();

		int ans = 10;

		if (x < a) {
			ans = 0;
		}

		System.out.println(ans);

	}
}

Measured memory_bytes: 22228
x,y=map(int,input().split())
def cal(number,mod):
    m=mod-2
    mod2=""
    while m!=0:
        if m%2==0:
            mod2="0"+mod2
        else:
            mod2="1"+mod2
        m=m//2
    two=[]
    for i in range(len(mod2)):
        if mod2[len(mod2)-1-i]=="1":
            two.append(i)
    ret=1
    for i in two:
        v=i
        retsub=number
        while v>0:
            retsub=retsub**2
            retsub=retsub%mod
            v-=1
        ret*=retsub
    ret=ret%mod
    return ret
ans=0
M=10**9+7
if (2*x-y)%3==0:
    n=(x+y)//3
    r=(2*x-y)//3
    if n<r or r<0:
        print(0)
        exit()
    l=[1]
    num=1
    for i in range(1,n+1):
        p=(num*i)%(M)
        l.append(p)
        num=p
    a=l[n]
    b=cal(l[n-r],M)
    c=cal(l[r],M)
    ans=(a*b*c)%M
print(ans)


Measured memory_bytes: 29484
#include <bits/stdc++.h>
using namespace std;
long long n, m, dp[1005][1005]; char c;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m; dp[0][1]=1;
for (int i=1; i<=n; i++){
	for (int j=1; j<=m; j++){
		cin >> c;
		if (c=='.')
			dp[i][j]=(dp[i-1][j]+dp[i][j-1])%1000000007LL;
	}
} cout << dp[n][m];
return 0;
}


Measured memory_bytes: 11416
toInt :: (String -> Int)
toInt x = read x ::Int

getInts = do
    x <- getLine
    let y = (map$toInt)$words x
    return y

ret :: [Int] -> Int -> Int -> Int
ret ps x max
    | null ps = x
    | (head ps) > max = ret (tail ps) x max
    | otherwise = ret (tail ps) (x + 1) (head ps)

main = do
    ns <- getInts
    let n = head ns
    ps <- getInts
    let r = ret ps 0 n
    putStrLn $ show r


Measured memory_bytes: 38268
import itertools
N, M, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(Q)]

ans = 0
for A in itertools.combinations_with_replacement(range(1, M+1), N):
    tmp = sum([x[3] for x in X if A[x[1]-1] - A[x[0]-1] == x[2]])
    if tmp > ans:
        ans = tmp
print(ans)

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

using namespace std;

#define foru(i, l, r) for (int i = l; i <= r; i++)
#define ford(i, r, l) for (int i = r; i >= l; i--)

char ch[50000];
map<char, int> mp;
int hhw;

int main() {
  //  freopen("a.in", "r", stdin);
  //  freopen("a.out", "w", stdout);
  mp['N'] = 0, mp['S'] = 1;
  mp['E'] = 2, mp['W'] = 3;
  scanf("%s", ch + 1);
  int N = strlen(ch + 1);
  for (int i = 1; i <= N; i++) hhw |= 1 << mp[ch[i]];
  hhw = ((hhw & 1) ^ (hhw >> 1 & 1)) | ((hhw >> 2 & 1) ^ (hhw >> 3 & 1));
  puts(!hhw ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	s := next()
	k := nextInt()

	index := 0
	for i := 0; i < len(s) && i < k; i++ {
		if s[i] != '1' {
			index = i
			break
		}
	}

	fmt.Println(string(s[index]))
}


Measured memory_bytes: 640
//求树的直径
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

//图的邻接表
vector<pair<int,int> > *Graph;
//图的规模
int n;

int *d;//记录节点的距离

bool *visited;

//此数字一定要保证足够大
const int INFTY = 1 << 30;

//本题不包含负权路径，使用狄克斯特拉算法
void dijkstra(int u) {
	priority_queue<pair<int,int> > PQ;

	for (int i=0; i<n; i++) {
		d[i] = INFTY;
		visited[i] = false;
	}

	d[u] = 0;
	PQ.push(make_pair(0,u));

	while (!PQ.empty()) {
		pair<int,int> f = PQ.top();
		PQ.pop();
		int u = f.second;

		visited[u] = true;

		const vector<pair<int,int> > & n_points = Graph[u];

		for (int i = 0; i<n_points.size(); i++) {
			pair<int,int> p = n_points[i];
			int & v = p.first;
			int & w = p.second;
			if (!visited[v] && d[v] > d[u] + w) {
				d[v] = d[u] + w;
				PQ.push(make_pair(-1*d[v],v));
			}
		}
	}
}

void solve() {
	dijkstra(0);

	int maxV1 = 0;

	for (int i=1; i<n; i++) {
		if (d[i] > d[maxV1]) {
			maxV1 = i;
		}
	}

	dijkstra(maxV1);

	int ans = -1;

	for (int i=0; i<n; i++) {
		if (d[i] > ans) {
			ans = d[i];
		}
	}
	cout << ans << endl;

}
int main() {
	cin >> n;
	Graph = new vector<pair<int,int> >[n];
	d = new int[n];
	visited = new bool[n];

	int e = n -1;//树的边数等于点数减去1
	for (int i=0; i<e; i++) {
		int s,t,w;
		cin >> s >> t >> w;
		Graph[s].push_back(make_pair(t,w));
		Graph[t].push_back(make_pair(s,w));
	}

	solve();

	delete[] Graph;
	delete[] d;
	delete[] visited;

	return 0;
}


Measured memory_bytes: 9724
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef complex<ld> Point;
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int d[100][100][4][11][11];
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };

char mp[100][100];
struct status {
	int x, y, k, a, b;
};
void solve() {
	int n, m, a; cin >> n >> m >> a;
	int rx, ry;
	int gx, gy;
	rep(i, n) {
		rep(j, m) {
			cin >> mp[i][j];
			if (mp[i][j] == 'S') {
				rx = i, ry = j; mp[i][j] = '.';
			}
			if (mp[i][j] == 'G') {
				gx = i, gy = j; mp[i][j] = '.';
			}
		}
	}
	rep(i, n) {
		rep(j, m) {
			rep(k, 4) {
				rep(l, a + 1) {
					rep(x, a + 1) {
						d[i][j][k][l][x] = mod;
					}
				}
			}
		}
	}
	queue<status> q;
	rep(k, 1) {
		d[rx][ry][2][0][0] = 0;
		q.push({ rx,ry,2,0,0 });
	}
	while (!q.empty()) {
		status s = q.front(); q.pop();
		if (s.x == rx && s.y == ry && s.k == 0)continue;
		int nx = s.x + dx[s.k];
		int ny = s.y + dy[s.k];
		if (nx < 0 || ny < 0 || nx >= n || ny >= m)continue;
		if (mp[nx][ny] == '#')continue;
		int nd = d[s.x][s.y][s.k][s.a][s.b]+1;
		if (nd < d[nx][ny][s.k][s.a][s.b]) {
			d[nx][ny][s.k][s.a][s.b] = nd;
			q.push({ nx,ny,s.k,s.a,s.b });
		}
		if (s.a < a) {
			int k = s.k;
			if (k < 2)k = 1 - k;
			else k = 5 - k;
			if (nd < d[nx][ny][k][s.a+1][s.b]) {
				d[nx][ny][k][s.a+1][s.b] = nd;
				q.push({ nx,ny,k,s.a+1,s.b });
			}
		}
		if (s.b < a) {
			int k = s.k; k = 3 - k;
			if (nd < d[nx][ny][k][s.a][s.b+1]) {
				d[nx][ny][k][s.a][s.b+1] = nd;
				q.push({ nx,ny,k,s.a,s.b+1 });
			}
		}
	}
	int ans = mod;
	rep(i, 4) {
		rep(j, a + 1) {
			rep(k, a + 1) {
				if (d[gx][gy][i][j][k] < mod) {
					ans = min(ans, j + k);
				}
			}
		}
	}
	if (ans == mod)ans = -1;
	cout << ans << endl;
}
int main() {
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 18704
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		Set<Integer> setA = new TreeSet<>();
		Set<Integer> setB = new TreeSet<>();

		int n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			setA.add(sc.nextInt());
		}

		int m = sc.nextInt();
		for(int i = 0; i < m; i++) {
			setB.add(sc.nextInt());
		}


		setA.retainAll(setB);

		for(int value : setA) {
			System.out.println(value);
		}
	}

}



Measured memory_bytes: 162648
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
ll ans;
ll N,K;
ll Sei[200005];
ll Hu[200005];
ll r,l;
ll cntzero;
ll cnthu;
ll cntsei;



int main(){
    cin >> N >> K;
    for(int i = 0;i<N;i++){
        int a;
        cin >> a;
        if(a<0){
            Hu[cnthu] = -a;
            cnthu++;
        } else if (a == 0){
            cntzero++;
        } else {
            Sei[cntsei] = a;
            cntsei++;
        }
    }
    sort(Hu,Hu+cnthu);
    sort(Sei,Sei+cntsei);
    ll ze = N*(N-1)/2 -(N-cntzero)*(N-cntzero-1)/2;
    ll x = 500000000000000009;
    if(K<=cntsei*cnthu){
        r = 1000000000000000009;
        l = 0;
        while(r - l>1){
            ll k=0;
            ll i=0;
            ll j=cntsei-1;
            while(true){
                if(Hu[i]*Sei[j]>x && j>0){
                    k+=cnthu - i;
                    j--;
                }else if(Hu[i]*Sei[j]>x){
                    k+=cnthu - i;
                    break;
                }else if(i<cnthu-1){
                    i++;
                } else {
                    break;
                }
            }
            if(k<=K-1){
                r = x;
                x = (l+r)/2;
            }else if(k>K-1){
                l = x;
                x = (l+r)/2;
            }
        }
        x += 1;
        x = -x;
    } else if(K>cntsei*cnthu + ze){
        K -= cntsei*cnthu + ze;
        r = 1000000000000000009;
        l = 0;
        while(r - l>1){
            ll k=0;
            ll i=0;
            ll j=cnthu-1;
            while(true){
                if(Hu[i]*Hu[j]<x && i<cnthu-1){
                    if(i<=j){
                      k+=j;
                    }else{
                      k+=j+1;
                    }
                    i++;
                }else if(Hu[i]*Hu[j]<x){
                    if(i<=j){
                      k+=j;
                    }else{
                      k+=j+1;
                    }
                    break;
                }else if(j>0){
                    j--;
                } else {
                    break;
                }
            }
            i=0;
            j=cntsei-1;
            while(true){
                if(Sei[i]*Sei[j]<x && i<cntsei-1){
                    if(i<=j){
                      k+=j;
                    }else{
                      k+=j+1;
                    }
                    i++;
                }else if(Sei[i]*Sei[j]<x){
                    if(i<=j){
                      k+=j;
                    }else{
                      k+=j+1;
                    }
                    break;
                }else if(j>0){
                    j--;
                } else {
                    break;
                }
            }
            k/=2;
            if(k<=K-1){
                l = x;
                x = (l+r)/2;
            }else if(k>K-1){
                r = x;
                x = (l+r)/2;
            }
        }
    }else{
        x = 0;
    }
    cout << x << endl;
}



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



int main(void){

	//??´?§?????§???¢??§????????????????????¶???a^2+b^2=c^2
	int N, a, b, c,L,M,S;

	cin >> N;

	
	for (int i = 0; i < N; i++){
		cin >> a >> b >> c;
		if ((a*a + b*b == c*c) || (a*a + c*c == b*b) || (c*c + b*b == a*a)){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}

	
	}
	return 0;
}

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

int main(){
	int r; cin>>r;
	if(r<1200) cout << "ABC" << endl;
	else if(r>=1200&r<2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;	
}

Measured memory_bytes: 256
int main(){
  int n,max=0,count=0;
  scanf("%d",&n);
  int d[n];
  for(int i=0;i<n;i++){
    scanf("%d ",&d[i]);
  }
  int h[n-1];
  int i=0;
  while(i<n-1){
      if(d[i]<d[i+1]){
        h[i]=0;
      }else{
        h[i]=1;
      }
    i++;
  }
  for(int j=0;j<n-1;j++){
   if(h[j]==1){
     count++;
   }else{
     if(max<count){
       max=count;
     }
     count=0;
   }
  }
  if(max<count){
       max=count;
     }
  printf("%d",max);
}

Measured memory_bytes: 896
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <map>


using namespace std;


int main(int argc, const char * argv[]) {
  // input from txt （提出時にこの箇所は削除すること）
  std::ifstream in("input.txt");
  std::cin.rdbuf(in.rdbuf());
  
  cin.tie(0);
  ios::sync_with_stdio(false);

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

  sort(a.begin(), a.end());
  int ans = 0;
  int tmpcnt = 1;

  long long prev = a[0];
  for(int i = 1; i < n; i++){
    if(prev == a[i]){
      tmpcnt++;
    }else{
      ans += tmpcnt % 2;
      tmpcnt = 1;
    }
    prev = a[i];
  }
  ans += tmpcnt %2;
  cout << ans << endl;
  return 0;
}


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

using namespace std;

constexpr int MAXHW = 100;

char s[MAXHW + 2][MAXHW + 2];
int dp[MAXHW + 2][MAXHW + 2];

int main() {
	int H, W;
	cin >> H >> W;
	for(int i = 0; i < H; i++)
		cin >> s[i];
	dp[0][0] = s[0][0] == '#';
	for(int i = 1; i < W; i++)
		dp[0][i] = dp[0][i - 1] + (s[0][i] != s[0][i - 1]);
	for(int i = 1; i < H; i++) {
		dp[i][0] = dp[i - 1][0] + (s[i][0] != s[i - 1][0]);
		for(int j = 1; j < W; j++)
			dp[i][j] = min(dp[i][j - 1] + (s[i][j] != s[i][j - 1]), dp[i - 1][j] + (s[i][j] != s[i - 1][j]));
	}
	int ans = dp[H - 1][W - 1];
	ans = (ans + 1) / 2;
	cout << ans << '\n';
}


Measured memory_bytes: 256
N,A,B=map(int,input().split())
M=N
if A==0:
    print(0)
    exit()
if A+B>=N:
    print(min(A,N))
    exit()
ans=(N//(A+B))*A
amari=N%(A+B)
ans+=min(amari,A)
print(ans)


Measured memory_bytes: 3060
#include<iostream>

using namespace std;


int main() {
	int n;

	cin >> n;

	if (n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9) cout << "hon" << endl;
	else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) cout << "pon" << endl;
	else cout << "bon" << endl;


	return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) static_cast<int>((x).size())

using LL = long long;
template<class T, size_t D>
struct vec : vector<vec<T, D - 1>> {
  template<class... Args>
  vec(size_t n = 0, Args... args)
    : vector<vec<T, D - 1>>(n, vec<T, D - 1>(args...)) {}
};
template<class T>
struct vec<T, 1> : vector<T> {
  template<class... Args>
  vec(Args... args)
    : vector<T>(args...) {}
};

template<class T>
inline bool asMn(T& a, const T& b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T& a, const T& b) { return a < b ? a = b, true : false; }
inline int nex(int i, int n) { return i == n - 1 ? 0 : i + 1; }
inline int pre(int i, int n) { return !i ? n - 1 : i - 1; }

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

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

//  freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vec<int, 2> candy(2, n);
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> candy[i][j];
    }
  }

  for (int j = 1; j < n; ++j) {
    candy[0][j] += candy[0][j - 1];
  }
  for (int j = n - 2; ~j; --j) {
    candy[1][j] += candy[1][j + 1];
  }

  int ans = 0;
  for (int j = 0; j < n; ++j) {
    asMx(ans, candy[0][j] + candy[1][j]);
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3632
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
      .map(|e| e.parse().ok().unwrap()).collect()
}

fn format_output(xs: &Vec<i32>) -> String {
    xs.iter()
        .map(|&x| x.to_string())
        .collect::<Vec<String>>()
        .join(" ")
}

fn main() {
    let n: usize = read();
    let mut xs: Vec<i32> = read_vec();
    let mut count = 0;

    for i in 0..n {
        let mut minj = i;

        for j in i..n {
            if xs[j] < xs[minj] {
                minj = j;
            };
        };

        if i != minj {
            let tmp = xs[i];
            xs[i] = xs[minj];
            xs[minj] = tmp;
            count += 1;
        }
    };

    println!("{}", format_output(&xs));
    println!("{}", count);
}



Measured memory_bytes: 5040
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll n;
	cin>>n;
	ll a[n+1][2];
	lp(i,1,n)
		cin>>a[i][0]>>a[i][1];
	ll cnt=0,ma=0;
	lp(i,1,n){
		if(a[i][0]==a[i][1])
			cnt++;
		else{
			ma=max(ma,cnt);
			cnt=0;
		}
	}
	if(ma>=3 || cnt>=3)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	return 0;	
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

void bottomleft(vector<vector<int> > &fp){
    int h = fp.size();
    int w = fp[0].size();
    int b=inf, l=inf;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(fp[i][j] > 0){
                b = min(b, i);
                l = min(l, j);
            }
        }
    }
    for(int i=0; i<h-b; i++){
        for(int j=0; j<w-l; j++){
            fp[i][j] = fp[i+b][j+l];
            fp[i+b][j+l] = 0;
        }
    }
}

void foldLtoR(vector<vector<int> > &fp, int c){
    int h = fp.size();
    for(int i=0; i<h; i++){
        for(int j=0; j<c; j++){
            fp[i][2*c-j-1] += fp[i][j];
            fp[i][j] = 0;
        }
    }
    bottomleft(fp);
}

void foldBtoU(vector<vector<int> > &fp, int c){
    int w = fp[0].size();
    for(int i=0; i<c; i++){
        for(int j=0; j<w; j++){
            fp[2*c-i-1][j] += fp[i][j];
            fp[i][j] = 0;
        }
    }
    bottomleft(fp);
}

int main(){
    while(1){
        int w,h,t,p;
        cin >> w >> h >> t >> p;
        if(w == 0) break;

        vector<vector<int> > fp(2*h, vector<int>(2*w, 0));
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                fp[i][j] = 1;
            }
        }
        for(int i=0; i<t; i++){
            int d,c;
            cin >> d >> c;
            if(d == 1) foldLtoR(fp, c);
            else foldBtoU(fp, c);
        }
        for(int i=0; i<p; i++){
            int x,y;
            cin >> x >> y;
            cout << fp[y][x] << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n;
	cin >> n;
	vector<int> v(n), u(n);
	rep(i,n) cin >> v[i] >> u[i];
	vector<pair<ll, pii>> w(n);
	rep(i,n) {
		w[i].first = (ll) v[i] + u[i];
		w[i].second.first = v[i];
		w[i].second.second = u[i];
	}
	ll ans = 0;
	sort(ALL(w), greater<>());
	rep(i,n) {
		if (i % 2 == 0) ans += w[i].second.first;
		else ans -= w[i].second.second;
	}
	cout << ans << endl;
}

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

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

  int ans = 0;
  for(int i = 1; i < n-1; i++){
    vector<int> ps = { p[i-1], p[i], p[i+1] };
    sort(ps.begin(),ps.end());
    ans += p[i] == ps[1];
  }

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

Measured memory_bytes: 256
import sys
from fractions import gcd

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def merge(a, b):
    g = gcd(a, b)
    a //= g
    b //= g
    if a % 2 == 0:
        return 0
    if b % 2 == 0:
        return 0
    n = a * b * g
    if n > 10 ** 9:
        return 0
    return n


n, m = map(int, readline().split())
a = list(map(int, readline().split()))

a = [x >> 1 for x in a]

for i in range(n-1):
    a[i+1] = merge(a[i], a[i+1])

z = a[n-1]

if z == 0:
    print("0")
else:
    ans = (m//z) - (m//(z+z))
    print(ans)


Measured memory_bytes: 14560
class Graph(): #directed
    def __init__(self, n, edge, indexed=1):
        self.n = n
        self.graph = [[] for _ in range(n)]
        self.rev = [[] for _ in range(n)]
        self.deg = [0 for _ in range(n)]
        for e in edge:
            self.graph[e[0] - indexed].append(e[1] - indexed)
            self.rev[e[1] - indexed].append(e[0] - indexed)
            self.deg[e[1] - indexed] += 1

    def strongry_connected(self):
        group = [None for _ in range(self.n)]
        used = [0 for _ in range(self.n)]
        order = []
        for s in range(self.n):
            if not used[s]:
                stack = [s]
                used[s] = 1
                while stack:
                    node = stack.pop()
                    movable = False
                    for adj in self.graph[node]:
                        if not used[adj]:
                            movable = True
                            used[adj] = 1
                            stack.append(node)
                            stack.append(adj)
                            break
                    if not movable:
                        order.append(node)
        used = [0 for _ in range(self.n)]
        count = 0
        for s in order[::-1]:
            if not used[s]:
                stack = [s]
                group[s] = count
                while stack:
                    node = stack.pop()
                    used[node] = 1
                    for adj in self.rev[node]:
                        if not used[adj]:
                            group[adj] = count
                            stack.append(adj)
                count += 1
        return group, count

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
E = [tuple(map(int, input().split())) for _ in range(M)]

g = Graph(N, E, 1)
group, count = g.strongry_connected()

res = []

Q = int(input())

for _ in range(Q):
    a, b = map(int, input().split())
    if group[a - 1] == group[b - 1]:
        res.append(1)
    else:
        res.append(0)

print('\n'.join(map(str, res)))


Measured memory_bytes: 18964
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define len(s) s.length()
#define forp(i,a,b) for( i=a;i<=b;i++)
#define rep(i,n)    for( i=0;i<n;i++)
#define ren(i,n)    for( i=n-1;i>=0;i--)
#define forn(i,a,b) for( i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define b(v) v.begin()
#define e(v) v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define pll pair<long long,long long>
#define vii vector<int>
#define vll vector<long long>
#define gl(cin,s)  getline(cin,s);
#define bitc(n) __builtin_popcountll(n)
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define SIZE 3010
#define SZ 110

typedef long long  ll;
typedef unsigned long long ull;
typedef long double  ldo;
typedef double  db ;
using namespace std;
int dp[SIZE][SIZE];
int from[SIZE][SIZE];
string s,t;
int main()
{  	
	/* #ifndef ONLINE_JUDGE
	freopen(fi, "r", stdin);
	#endif */
	//freopen("route.in","r",stdin);
	//freopen("route.out","w",stdout);
	//cin.ignore();
	//cin.clear();
	boost;
	//cin.tie(0);
	//cout<<"Case "<<tt<<": ";
	cin>>s>>t;
	s = "#" + s;
	t = "#" + t;
	dp[0][0] = 0;
	for(int i=1;i<(int)s.length();i++){
	    for(int j=1;j<(int)t.length();j++){
	        if(s[i] == t[j]){
	            dp[i][j] = 1+dp[i-1][j-1];
	            from[i][j] = 0;
	        }
	        else{
	            if(dp[i-1][j] >= dp[i][j-1]){
	                dp[i][j] = dp[i-1][j];
	                from[i][j] = 1;
	            }
	            else{
	                dp[i][j] = dp[i][j-1];
	                from[i][j] = 2;
	            }
	        }
	    }
	}
	string fans = "";
	int currX = s.length()-1;
	int currY = t.length()-1;
	while(true){
	    if(!currX or !currY)
	    break;
	    if(from[currX][currY] == 1){
	        currX--;
	    }
	    else if(from[currX][currY] == 2){
	        currY--;
	    }
	    else{
	        fans += s[currX];
	        currX--;
	        currY--;
	    }
	}
	reverse(all(fans));
	cout<<fans<<endl;
	return 0;
}

Measured memory_bytes: 70912
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A, B;
    
    cin >> A >> B;
    
    if((A + B) % 2 == 0){
        cout << (A + B) / 2 << endl;
    }
        
    else
        cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h,w,n;
	cin>>h>>w>>n;
	int k=max(h,w);
	if(n%k==0){
		cout<<n/k;
	}else{
		cout<<n/k+1;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARestricted solver = new ARestricted();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARestricted {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int s = in.nextInt() + in.nextInt();
            out.println(s >= 10 ? "error" : Integer.toString(s));
        }

    }
}



Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define vll vector<ll>
#define fast ios:: sync_with_stdio(false),cin.tie(0);
#define COUT cout<<fixed<<setprecision(12)
#define SET set<ll,greater<ll>>gquiz
#define ITERATOR set<ll,greater<ll>> :: iterator itr
#define V vector<ll>vector
#define sz size()
#define A vector<pair<ll,ll>>vect
ll N=100000,M=100000;
#define B vect.push_back(make_pair(N,M));
ll MOD=1000000007;
 
ll gcd(ll a,ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll ncr(ll n,ll r)
{
	if(n==1 || r==0)
	return 1;
	if(r>n/2)
	r=n-r;
	ll ans=1;
	for(ll i=1;i<=r;i++)
	{
		ans=((ans * n )/i);
		n--;
	}
	return ans;
}
int main()
{
	ll n,r;
	cin>>n>>r;
	if(n>=10)
	cout<<r;
	else
	{
		ll k=100*(10-n);
		r=r+k;
		cout<<r;
	}
}

Measured memory_bytes: 256