akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N,M;
    cin >> N >> M;
    string S;
    cin >> S;
    
    ll now=N;
    vl ans;

    while(now>0){
        ll next = -1;
        repe(l,1,M+1){
            if (now - l < 0) break;
            if(S[now-l]=='0'){
                next = l;
            }
        }

        if (next == -1){
            cout << -1 << endl;
            return 0;
        }

        ans.eb(next);
        now -= next;
    }

    reverse(all(ans));
    rep(i, ans.size()) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 1480
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef unsigned long long ull;
ll solve(int n, int k){
  ll res = 0;
  for(int i = k + 1;i <= n;i++){
    int segs = n / i;
    res += segs * (i - k) + max(0, (n - segs * i - max(0, k - 1)));
  }
  return res;
}
int brute(int n, int k){
  int res = 0;
  for(int i = 1;i <= n;i++)
    for(int j = 1;j <= n;j++)
      if(i % j >= k)res++;
  return res;
}
int main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n, k;
  cin >> n >> k;
  cout << solve(n, k);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using lb=long double;
using db=double;
const ll mod=1e9+7;
const int maxn=2e5+7;
int a[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int temp;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(i==a[i])
            ans++,i++;
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>

int main()
{
    int n,e,r;
    scanf("%d %d",&n,&r);
    e=100*(10-n);
    e =e+r;
    if(n>=10){
        printf("%d\n",r);
    }
    else printf("%d\n",e);
    return 0;
}


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

int main() {
  int N;
  int R = 0;
  cin >> N;

  for(int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    R += r - l + 1;
//    while(l <= r){
 //     R++;
  //    l++;
   // }
  }
  cout << R << endl;
}

Measured memory_bytes: 3564
import java.util.*;
public class Main{
  public static void main(String[] args){
    
    Scanner input = new Scanner(System.in);
    int n = input.nextInt();
    String s = input.next();
    
    for(int i=0;i<s.length();i++)
    {
        int x = s.charAt(i)-'A';
        x = (x+n)%26;
        System.out.print((char)('A'+x));
    }
    
    System.out.println();
    
  }
}

Measured memory_bytes: 25684
package main

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

func main() {
	sc := NewScanner(os.Stdin)
	T, X := sc.NextFloat64(), sc.NextFloat64()
	fmt.Printf("%f\n", T/X)
}

func lcm(x, y int) int {
	x, y = max(x, y), min(x, y)
	if y == 0 {
		return x
	}
	return lcm(y, x%y)
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextFloat64() float64 {
	i, err := strconv.ParseFloat(s.Next(), 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <numeric>
#include <iomanip>
#define FI first
#define SE second
#define EB emplace_back
#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 1100000000
#define LLINF 1100000000000000000LL
#define Decimal fixed << setprecision(20)
#define ALL(c) c.begin(),c.end()
#define SHOWVEC(v, sz) for(int i = 0; i < sz; i++) cerr << v[i] << ' '; cerr << endl;
#define SHOWX(x) cerr << #x << ": " << x << endl;
#define SHOWP(p) cerr << "[" << p.first << ',' << p.second << "]";

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

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

  if (s == "SUN") cout << 7 << endl;
  else if (s == "MON") cout << 6 << endl;
  else if (s == "TUE") cout << 5 << endl;
  else if (s == "WED") cout << 4 << endl;
  else if (s == "THU") cout << 3 << endl;
  else if (s == "FRI") cout << 2 << endl;
  else if (s == "SAT") cout << 1 << endl;

  return 0;
}


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

int main() {
    int n; cin >>n;
    int ans = 0;
    int a;
    for (int i = 0; i < n; i++) {
        cin >>a;
        while (a%2==0) {ans++;a/=2;}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(){
	int a, b, c, d, e, f, ans1, ans2;
	double t = 0;
	cin >> a >> b >> c >> d >> e >> f;
	for(int i = 0; 100 * i * a <= f; i++){
		for(int j = 0; 100 * (i * a + j * b) <= f; j++){
			int x = i * a + j * b;
			for(int k = 0; k * c <= e * x; k++){
				for(int l = 0; (k * c + l * d) <= e * x; l++){
					int y = k * c + l * d;
					if(100 * x + y > f) continue;
					if(t <= 1.0 * y / (100 * x + y)){
						t = 1.0 * y / (100 * x + y);
						ans1 = 100 * x + y; ans2 = y;
					}
				}
			}
		}
	}
	cout << ans1 << " " << ans2 << endl;
	return 0;
}


Measured memory_bytes: 256
from itertools import groupby
class Combination:
    def __init__(self, n, mod):
        self.n = n
        self.mod = mod
        self.fac = [1 for i in range(self.n + 1)]
        self.finv = [1 for i in range(self.n + 1)]
        for i in range(2, self.n+1):
            self.fac[i] = (self.fac[i - 1] * i) % self.mod
            self.finv[i] = (self.finv[i - 1] * pow(i, -1, self.mod)) % self.mod

    def comb(self, n, m):
        return self.fac[n] * (self.finv[n - m] * self.finv[m] % self.mod) % self.mod
        
def iparse():
    return list(map(int, input().split()))


# RUN LENGTH ENCODING str -> tuple


def runLengthEncode(S: str):
    grouped = groupby(S)
    res = []
    for k, v in grouped:
        res.append((k, str(len(list(v)))))
    return res


if __name__ == "__main__":
    s = input()
    if s[-1] == 's':
        s += 'es'
    else:
        s += 's'
    print(s)

    


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

int n,k,ans=0;
int tot=0,h[100005],a[100005];
struct Edge{
    int x,next;
}e[200005];

inline void add_edge(int x,int y){
    e[++tot].x=y;
    e[tot].next=h[x],h[x]=tot;
}

int dfs(int x,int deep){
    int ret=deep;
    for(int i=h[x];i;i=e[i].next)
        ret=max(ret,dfs(e[i].x,deep+1));
    if(a[x]!=1&&ret-deep==k-1)return ans++,0;
    else return ret;
}

int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)scanf("%d",a+i);
    if(a[1]!=1)ans=a[1]=1;
    for(int i=2;i<=n;i++)add_edge(a[i],i);
    dfs(1,0),printf("%d",ans);
}

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


int main(){
    int n;
    cin >> n;
    int a[4][3][10]={{{}}};
    int b,f,r,v;
    for(int i=0; i<n; i++){
        cin >> b >> f >> r >> v;
        a[b-1][f-1][r-1]+=v;
    }
    for(int i=0; i<4; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<10; k++){
                cout << ' ' << a[i][j][k];

            }
            cout << endl;
        }
        if(i<3){
            cout << "####################" << endl;
        }

    }
}


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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(long long N, long long A, long long B){
    cout << max(B * (N - 1) + A - (A * (N - 1) + B) + 1, 0LL) << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    for i in 0..s.len() {
        if (i % 2 == 0 && s[i] == 'L') || (i % 2 == 1 && s[i] == 'R') {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 2116
"""
author : halo2halo
date : 11, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A,B = map(int,read().split())
print(max(A+B,A-B,A*B))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll cl(ll a,ll b)
{
    return (a/b)+(!(!(a%b)));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;cin >> n;ll a[n];
    ll b[n];
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i] >> b[i];
    }
    sort(a,a+n);sort(b,b+n);
    if(n&1)cout << b[n/2]-a[n/2]+1;
    else
    {
        double d1=(b[n/2]+b[n/2-1]);
        d1/=2;
        double d2=(a[n/2]+a[n/2-1]);
        d2/=2;
        int ans=d1-d2+1;
        if(ans==d1-d2+1)cout << ans+ans-1;
        else cout << 2*ans;
    }
    }

Measured memory_bytes: 6768
fun solvePrimes(max: Int): List<Int> {
    val primes = mutableListOf<Int>()

    for (i in 2..max) {
        if (primes.none { prime -> i % prime == 0 }) primes += i
    }

    return primes
}

fun main(args: Array<String>) {
    val primes = solvePrimes(100_600)

    while (true) {
        val (N, P) = readLine()!!.split(" ").map { it.toInt() }
        if (N == -1 && P == -1) return

        val limitedPrimes = primes.filter { it > N }.take(P + 5)

        (0 until limitedPrimes.size)
                .asSequence()
                .map { left ->
                    (left until limitedPrimes.size).map { right ->
                        limitedPrimes[left] + limitedPrimes[right]
                    }
                }
                .flatten()
                .sorted()
                .drop(P - 1)
                .firstOrNull()
                .run(::println)
    }
}


Measured memory_bytes: 104932
from collections import deque
n = int(input())
graph = [[] for _ in range(n+1)]
for i in range(n-1):
    u,v,w = map(int,input().split())
    graph[u].append([v,w])
    graph[v].append([u,w])
dist = [0]*(n +1)
visited = [0]*(n + 1)
que = deque([[1,0]])
while que:
    node,weight = que.popleft()
    if visited[node] == 1:
        continue
    else:
        visited[node] = 1
        dist[node] = weight
        for x,y in graph[node]:
            if visited[x] ==1:
                continue
            else:
                que.append([x,weight+y])
for i in range(1,n+1):
    print(dist[i]%2)

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

#define int long long

signed main() {
  i64 k,a,b;
  cin >> k >> a >> b;
  if(a + 1 >= b) {
    cout << k + 1 << endl;
  }
  else if(k + 1 <= a) {
    cout << k + 1 << endl;
  }
  else {
    k -= a - 1;
    int ans = a + (k / 2) * (b - a);
    if(k & 1) ans++;
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
sa = list(str(input()))
sb = list(str(input()))
sc = list(str(input()))
 
tmp = 'a'
while True:
    if tmp == 'a':
        tmp = sa.pop(0)
    elif tmp == 'b':
        tmp = sb.pop(0)
    elif tmp == 'c':
        tmp = sc.pop(0)
    if len(sa) == 0 and tmp == 'a':
        print('A')
        exit()
    elif len(sb) == 0 and tmp == 'b':
        print('B')
        exit()
    elif len(sc) == 0 and tmp == 'c':
        print('C')
        exit()

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
def gcd(a,b):
	if(a==0 or b==0):
		return a+b
	return gcd(b,a%b)
yo = input()
if(yo[-1]=='\n'):
	yo=yo[:-1]
k=int(yo)
ans=0
for i in range(1,k+1):
	for j in range(1,k+1):
		hcf = gcd(i,j)
		for m in range(1,k+1):
			ans+=(gcd(hcf,m))
print(ans)

Measured memory_bytes: 71816
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

vector<bool> P;
map<ll, ll> M;

void prime_factor(ll N){

bool C = 1;

while(C){

C = 0;

    rep(i, 2, sqrt(N)){

    if(N%i == 0){M[i]++;N /= i;C = 1;break;}
   
    }

}

M[N]++;

}

ll gcd(ll N, ll M){

if(N%M == 0)return M;

else return gcd(M, N%M);

}

int main(){
ll N;cin >> N;
vector<ll> A(N);
vector<ll> Prime;
map<ll, bool> m;
  
bool C = 0, D = 1;

rep(i, 0, N)cin >> A[i];
  
ll G = A[0];
  
rep(i, 0, N){

  ll a = A[i];
  
  if(a != 1)prime_factor(a);

  for(auto x : M ){

    if(!m[x.first])m[x.first] = 1;

    else{C = 1;break;}

  }

  M.clear();

  if(C)break;

}

rep(i, 0, N - 1){

  G = gcd(G, A[i + 1]);

  if(G == 1){D = 0;break;}

}

//cout << G << endl;
  //for(auto x : M)cout << x.first << " " << x.second << endl;
  
if(!C)cout << "pairwise coprime";
else{

  if(D)cout << "not coprime";
  
  else cout << "setwise coprime";

}
}

Measured memory_bytes: 11176
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,m,x,y,z;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	if(a<0){
		m=a*-1;
		x=c*m;
		y=e*b;
		z=x+y+d;
		printf("%d\n",z);
	}
	else if(0<a){
		x=b-a;
		y=x*e;
		printf("%d\n",y);
	}
	else{
		x=b*e;
		y=x+d;
		printf("%d\n",y);
	}
	return 0;
}


Measured memory_bytes: 2724
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
const int inf = numeric_limits<int>::max();
typedef long long ll;
int main()
{
    int n,l;
    cin >> n >> l;
    int taste_max = 0;
    for(int i=1; i<=n; i++){
        taste_max += l+i-1;
    }
    int ans;
    int taste_diff = inf;
    for(int i=1; i<=n; i++){
        int taste = l+i-1;
        if (abs(taste) < abs(taste_diff)){
            taste_diff = taste;
            ans = taste_max - taste;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string S, T;
	cin >> S >> T;
	int N = (int)S.size();
	int cnt = 0;
	for(int i = 0;i<N;i++){
		if(S[i] != T[i])cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3856
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int H,W,M; cin >> H >> W >> M;
    vector<pair<int,int>> c(M);
    vector<int> h(H,0);
    vector<int> w(W,0);
    int outx=-1;
    int outy=-1;
    for(int i=0;i<M;i++){
        int x,y; cin >> y >> x;
        y--; x--;
        c[i] = make_pair(y,x);
        h[y]++; w[x]++;
    }
    int numy=0,numx=0;
    int out=0;

    for(int i=0;i<H;i++){
        if(outy==h[i]) numy++;
        if(outy<h[i]){
            outy = h[i];
            numy=1;
        }
    }

    for(int i=0;i<W;i++){
        if(outx==w[i]) numx++;
        if(outx<w[i]){
            outx = w[i];
            numx=1;
        }
    }
    int num=numx*numy;
    for(int i=0;i<M;i++){
        int y=c[i].first;
        int x=c[i].second;
        if(h[y]==outy && w[x]==outx){
            num--;
        }
    }
    if(num==0) out=-1;
    cout << outx+outy+out << endl;
    return 0;
}


Measured memory_bytes: 7996
/**
*    author:  yuya1234
*    created: 09.07.2020 15:18:24
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define ALL(v) (s).begin(), (s).end()
#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  int n;
  cin>>n;

  int a[n];
  int cnt0,cnt2,cnt4;
  cnt0=cnt2=cnt4=0;
  REP(i,n)
  {
    cin>>a[i];
    if(a[i]%4==0)cnt4++;
    else if(a[i]%2==0)cnt2++;
    else cnt0++;
  }

  if(cnt2>=1 && cnt0+1>cnt4+1)cout<<"No"<<endl;
  else if(cnt0>cnt4+1)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;

  return 0;
}

Measured memory_bytes: 4004
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define Sort(a)	sort(a.begin(),a.end())
#define rev(a)	reverse(a.begin(),a.end())
#define all(a)	(a).begin(),(a).end()
#define vll vector<long long int>
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 1e18

#define MAX 200005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}
lli power(lli a,lli b,lli m){if(b==0)	return 1;if(b==1)	return a%m;lli res=1;a=a%m;while(b){if(b&1){res=(res*a)%m;}a=((a%m)*(a%m))%m;b>>=1;}return res;}
lli Ceil(lli a,lli b){lli res=a/b;if(a%b!=0)	res++;return res;}

template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

lli dxx[]={1,1,0,-1,-1,-1,0,1};
lli dyy[]={0,1,1,1,0,-1,-1,-1};
lli dx[]={1,0,-1,0};
lli dy[]={0,1,0,-1};

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void solve(lli the)
{
	char ch;
	db aa,bb,cc,dd,xx;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,d,n,m,l,r,x,y,z,low,high,mid,sum=0,ans=0,temp,t;
    cin >> x;
    if(x==0)
    cout << 1;
    else	cout << 0;
    
    
}















int main()
{
	long long int t=1,c=1;
	// scanf("%lld",&t);
	while(t--){
		solve(c);
		c++;
	}
	return 0;
}
/* UJJWAL KESHRI */

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int mxL[200][200], mxR[200][200];
int main() {
    int n, k;
    cin >> n >> k;
    deque<int> dq;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        dq.push_back(a);
    }
    vector<int> vec;
    int cnt = 0;
    for (int i = 1; i <= min(n, k); i++) {
        cnt += dq[i - 1];
        mxL[i][0] = max(mxL[i][0], cnt);
        int lft = k - i;
        vec.push_back(dq[i - 1]);
        sort(vec.begin(), vec.end());
        int tmp = cnt;
        for (int j = 0; j < min(lft, (int)vec.size()); j++) {
            tmp -= vec[j];
            mxL[i][j + 1] = max(mxL[i][j + 1], tmp);
        }
    }
    reverse(dq.begin(), dq.end());
    cnt = 0;
    vec.clear();
    for (int i = 1; i <= min(n, k); i++) {
        cnt += dq[i - 1];
        mxR[i][0] = max(mxR[i][0], cnt);
        int lft = k - i;
        vec.push_back(dq[i - 1]);
        sort(vec.begin(), vec.end());
        int tmp = cnt;
        for (int j = 0; j < min(lft, (int)vec.size()); j++) {
            tmp -= vec[j];
            mxR[i][j + 1] = max(mxR[i][j + 1], tmp);
        }
    }
    int res = 0;
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= i; j++) {
            for (int q = 0; q <= k; q++) {
                for (int w = 0; w <= q; w++) {
                    int cntL = i - j, cntR = q - w;
                    if (i + q > n) continue;
                    if (i + j + q + w > k) continue;
                    res = max(res, mxL[i][j] + mxR[q][w]);
                    //cout << i << ' ' << j << ' ' << q << ' ' << w << ' ' << mxL[i][j] + mxR[q][w] << '\n';
                }
            }
        }
    }
    cout << res;
    return 0;
}

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

int main() {
  
  int n;
  cin >> n;
  
  long long sum = 0;
  
  for ( int i = 1; i <= n; i++){
    if ( i % 3 == 0 || i % 5 == 0 ){
      continue;
    }else{
      sum += i;
    }
  }
  
  cout << sum << endl; 
  
}



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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //



// --------- library end - //


int main(){

  ll N, K;
  cin >> N >> K;

  if (K == 0){
    cout << N * N << endl;
    return 0;
  }

  // K >= 1

  ll ans = 0;
  REP(b, 1, N+1){
    // 各ループで b を 1 ~ N に固定して、mod b >= Kとなるようなaの数を求める
    if (K >= b) continue;
    else{
      // まず、bの倍数までの間には、K周期で (b-1)-(K-1)=b-K 個ずつある
      // 正確には、bの倍数それ自身は余り0なので当てはまらないが、影響しないので無視

      // 他に、例えばN%b=5で、K=3なら、a%b=3,4,5となるものがあるので、仕上げにそれを足す
      ans += (b-K) * (N/b) + max(0LL, N%b-(K-1));
    }
    
  }

  cout << ans << endl;

}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>


#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

#define int long long

vector<int> sieve(int n){
  vector<int> ret;
  bool is_prime[n+1];
  memset(is_prime, true, sizeof(is_prime));
  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<n+1;i++){
    if(is_prime[i]){
      ret.push_back(i);
      for(int j=2*i;j<n+1;j+=i)is_prime[j]=false;
    }
  }
  return ret;
}

signed main(){
  vector<int> prime = sieve(1000010);
  int N;
  cin >> N;

  int mini = 0, maxi = 1;
  for(auto x : prime){
    if(N % x == 0) mini++;
    int cnt = 0;
    while(N % x == 0){
      cnt++;
      N /= x;
    }
    maxi = maxi * (cnt + 1);
  }

  if(N > 1){
    maxi *= 2;
    mini++;
  }
  cout << mini << " " << maxi - 1 << endl;
  return 0;
}


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

int main(){
  char S;
  cin >> S;
  if(S=='a' || S=='i' || S=='u' || S=='e' || S=='o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a[4],b[4],g,h,i,j;
  while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3])!=EOF){
    scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);
    g=h=0;
    for(i=0;i<4;i++){
      h+=(a[i]==b[i]);
      for(j=0;j<4;j++) g+=(a[i]==b[j]);
    }
    g-=h;
    printf("%d %d\n",h,g);
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		char[] s = sc.next().toCharArray();
		int N = s.length;
		
		long ans = 0;
		
		int acount = 0;
		for(int i=0; i<N; i++) {
			if(s[i]=='A') {
				acount++;
			} else if(s[i]=='B') {
				if(i+1<N && s[i+1]=='C') {
					ans += acount;
					i++;
				} else {
					acount = 0;
				}
			} else {
				acount = 0;
			}
		}
		
		System.out.println(ans);
		sc.close();
	}
}

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

int main(){
    int N;
    int *C=new int[100001];
    for(int i=0;i<=100000;i++) C[i]=0;

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

    for(int i=0;i<=100000;i++) C[i]=(C[i]==0?0:((C[i]+1)%2)+1);
    
    int k=0, d=0;
    for(int i=0;i<=100000;i++){
        if(C[i]!=0) k++;
        if(C[i]==2) d++;
    }

    cout << k-(d%2) << endl;

    delete[] C;
    return 0;
}

Measured memory_bytes: 768
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <stack>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <iterator>

using namespace std;

typedef unsigned long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> point;
typedef pair<int, int> pointI;

#define PI 3.1415926535897932384626433832795

const ll mod=1000000007LL;


int main() {
    iostream::sync_with_stdio(false);
    int n; cin>>n;
    vector<ll> input(n+1, 0); for (int i=0; i<n; i++) cin>>input[i];

    ll ans=0;
    for (int i=0; i<n; i++) {
        ans+=input[i]/2;
        if ((input[i]%2==1)&&(input[i+1]>0)) ans+=1, input[i+1]-=1;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using ll = long long;
int main() {
	int n, res = 0; std::cin >> n;
	std::vector<int> x(n, 0), a(n, 0);
	for (int i = 0; i < n; i++) {
		std::cin >> a[i];
		res ^= a[i];
	}
	for (int i = 0; i < n; i++) std::cout << (res ^ a[i]) << ' ';
}

Measured memory_bytes: 4836
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    int count = 0;
    boolean check = false;
    for (int i = 0; i < n; i++) {
      int d1 = sc.nextInt();
      int d2 = sc.nextInt();

      if (d1 == d2) {
        count++;
      } else {
        count = 0;
      }

      if (count > 2) {
        check = true;
      }
    }
    System.out.println(check ? "Yes" : "No");
  }
}


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

//.define
// #define FILE_IN_OUT
#define RET(_x)                       return cout << (_x) << '\n', 0;
#define all(_obj)                     (_obj).begin(), (_obj).end()
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define CeilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define sz(_obj)                      static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)                     std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)                     {}
#endif
#define endl "\n"
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
bool HasBit(ll x, int b) {
    return (x >> b) & 1;
}

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n;
    cin >> n;
    vector<ll> arr(n);
    ll xorsum = 0;
    loop(n) {
        cin >> arr[i];
        xorsum ^= arr[i];
    }
    if (xorsum == 0) {
        RET(0);
    }
    xorsum ^= arr[0] ^ arr[1];
    ll sum = arr[0] + arr[1];
    if ((sum - xorsum) & 1) {
        RET(-1);
    }
    ll andval = (sum - xorsum) >> 1;
    if (xorsum & andval) {
        RET(-1);
    }
    ll a = 0;
    vector<ll> val(51, 0);
    for (int i = 0; i <= 50; ++i) {
        if (HasBit(xorsum, i)) {
            val[i] = 1LL << i;
        }
        if (i) {
            val[i] += val[i - 1];
        }
        if (!HasBit(xorsum, i) && HasBit(andval, i)) {
            a |= 1LL << i;
        }
    }
    for (int i = 50; i >= 0; --i) {
        if (a >= arr[1]) {
            break;
        }
        if (HasBit(xorsum, i) && a + val[i] - (1LL << i) < arr[1]) {
            a |= 1LL << i;
        }
    }
    ll ans = a - arr[1];
    if (ans < 0 || ans >= arr[0]) {
        RET(-1);
    }
    cout << ans << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

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

/*
2行で移動方向は右か下のみ, つまり1行目の何列目まで進んでから下に進むかのみ考えれば良い.
各行の累積和を予め求めておけば, ある経路を辿ったときのアメの合計は,
1行目i列目までの1行目の累積和 
+ (終点(2行目n列目)までの2行目の累積和 
- 2行目i-1列目までの2行目の累積和)
で求まる.
*/

int main() {
  int n;
  cin >> n;
  vector<vector<int>> table(2, vector<int>(n+1));
  for (int i = 0; i < 2; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> table[i][j];
      table[i][j] += table[i][j-1];  // 現在の行のj列目までの累積和
    }
  }
  
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, table[0][i] + table[1][n] - table[1][i-1]);
  }  
  
  cout << ans << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define o(a) cout<<a<<endl
using namespace std;

int main(){
	int a;
	while(scanf("%d",&a)!=EOF){
		int d[14]={},p=0,m=0;
		char c;
		vector<int> n(5);
		n[0]=a;
		d[n[0]]++;
		rep(i,1,5){
			cin>>c>>n[i];
			d[n[i]]++;
		}
		sort(n.begin(),n.end());
		rep(i,1,14){
			m=max(m,d[i]);
			if(d[i]>=2) p++;
		}
		if(m==4){
			o("four card");
		}else if(m==3 && p==2){
			o("full house");
		}else if(m==3){
			o("three card");
		}else if(p==2){
			o("two pair");
		}else if(p==1){
			o("one pair");
		}else{
			bool f=1;
			rep(i,0,4){
				if(n[i+1]!=n[i]+1 && !(n[0]==1 && n[1]==10 && n[4]==13)){
					f=0; break;
				}
			}
			if(f) o("straight");
			else o("null");
		}
	}
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
#define i64 long long
#define maxn (int)(1e5)
#define pii pair<int,int>
#define L first 
#define R second
#define all(x) x.begin(),x.end()
using namespace std;


int main(){
	string s;
	cin>>s;
	int n = s.length();
	int minDif = INT_MAX, num;
	for(int i=2;i<n;i++){
		num = 100*(s[i-2]-'0') + 10*(s[i-1]-'0') + (s[i]-'0');
		minDif =  min(minDif, abs(num-753));
	}
	printf("%d\n",minDif);
	return 0;
}

Measured memory_bytes: 256
N = input().rstrip()
N = int(N)
num = N-1
Line = input().rstrip().split()
line = [int(s) for s in Line]
line.sort()
MAX = line[num]
line.pop(num)

SUM = sum(line)

if MAX < SUM :
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <stdio.h>
 
int main(void)
{
	int n;
	int sum = 0;
	int i;
	
	scanf("%d", &n);
	
	for(i=n; i!=0; i/=10)
		sum += i%10;
	
	if(n%sum == 0)
		printf("Yes");
	else
		printf("No");
	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main() {

  int M[100][100];
  int n, u, k, i, j, v;

  scanf("%d", &n);

  for (i=0; i<n; i++)
    for (j=0; j<n; j++)
      M[i][j]=0;

  for (i=0; i<n; i++) {
    scanf("%d %d", &u, &k);
    u=u-1;
    for (j=0; j<k; j++) {
      scanf("%d", &v);
      v=v-1;
      M[u][v]=1;
    }
  }

  for (i=0; i<n; i++) {
    for (j=0; j<n; j++) {
      if (j!=0) printf(" ");
      
      printf("%d", M[i][j]);
    }
    printf("\n");
  }

  return 0;

}

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

#define REP(i, start, count) for (int i = (start); i < (int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

using ll = long long;
using ull = unsigned long long;
using veci = vector<int>;
using vecll = vector<ll>;
using vecull = vector<ull>;

int main(void)
{
    ll N, W;
    cin >> N >> W;
    vecll w(N + 1);
    vecll v(N + 1);
    rep(i, N) {
        cin >> w[i + 1] >> v[i + 1];
    }

    vector<vecll> dp(N + 1, vecll(W + 1, 0));

    for (int i = 1; i <= N; ++i) {
        for (int k = 0; k <= W; ++k) {
            // そもそも入らない
            if (w[i] > k) {
                dp[i][k] = dp[i - 1][k];
                continue;
            }
            // iまで使ってよいとき、wの容量に詰め込める価値の最大値は…
            // 何も入れない : iが勘定に入っていない場合の同容量の最適解
            // 入れる : kからw引いたときの最適解 + 今回の荷物の価値
            dp[i][k] = max(dp[i - 1][k], dp[i - 1][k - w[i]] + v[i]);
        }
    }

    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 80256
mod = 10**9 + 7
h, w = map(int, input().split())
grid = []
for _ in range(h):
    tem = list(input())
    grid.append(tem)

dp = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        if grid[i][j] != '#':
            if i == 0 and j == 0:
                dp[i][j] = 1
            elif i == 0 and grid[i][j-1] != '#':
                dp[i][j] = dp[i][j - 1]
            elif j == 0 and grid[i - 1][j] != '#':
                dp[i][j] = dp[i - 1][j]
            else:
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % (mod)

print(dp[-1][-1])


Measured memory_bytes: 89820
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mod 1000000007
#define inp(arr,n) for(int i=0;i<n;i++) cin>>arr[i]
#define soa(arr,n) sort(arr,arr+n)
#define sov(arr) sort(arr.begin(),arr.end())
#define fr(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t=1;
    while(t--){
       string s;
       cin>>s;
       int n;
        if(s=="SSS") n=0;
        else if(s=="RSS" || s=="SRS"|| s=="SSR"|| s=="RSR") n=1;
        else if(s=="RRS" || s=="SRR") n=2;
        else n=3;
        cout<<n<<endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
using namespace std;
int num;
string a,ans;
void deal()
{
    for(int i=2; i<num; i++)
    {
        if(ans[i-1]=='S')
        {
            if(a[i-1]=='o')
                ans+=ans[i-2];
            else
            {
                if(ans[i-2]=='S')
                    ans+='W';
                else
                    ans+='S';
            }
        }
        else
        {
            if(a[i-1]=='x')
                ans+=ans[i-2];
            else
            {
                if(ans[i-2]=='S')
                    ans+='W';
                else
                    ans+='S';
            }
        }
    }
}
bool check()
{
    if(ans[0]=='S')
    {
        if(a[0]=='o'&&ans[num-1]!=ans[1])
            return false;
        else if(a[0]=='x'&&ans[num-1]==ans[1])
            return false;
    }
    if(ans[0]=='W')
    {
        if(a[0]=='x'&&ans[num-1]!=ans[1])
            return false;
        else if(a[0]=='o'&&ans[num-1]==ans[1])
            return false;
    }
    if(ans[num-1]=='S')
    {
        if(a[num-1]=='o'&&ans[num-2]!=ans[0])
            return false;
        else if(a[num-1]=='x'&&ans[num-2]==ans[0])
            return false;
    }
    if(ans[num-1]=='W')
    {
//        cout<<ans[num-2]<<ans[1]<<endl;
        if(a[num-1]=='x'&&ans[num-2]!=ans[0])
            return false;
        else if(a[num-1]=='o'&&ans[num-2]==ans[0])
            return false;
    }
    return true;
}
int main()
{
    cin>>num;
    cin>>a;
    ans="SS";
    deal();
    if(check())
        cout<<ans<<endl;
    else
    {
        ans="SW";
        deal();
        if(check())
            cout<<ans<<endl;
        else
        {
            ans="WS";
            deal();
            if(check())
                cout<<ans<<endl;
            else
            {
                ans="WW";
                deal();
                if(check())
                    cout<<ans<<endl;
                else
                    cout<<"-1"<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fo(i,n) for(i=0;i<n;i++)
#define fok(i,k,n) for(i=k;i<n;i++)
#define ci(x) cin>>x;
#define ci2(x,y) cin>>x>>y;
#define co(x) cout<<x<<"\n";
#define co2(x,y) cout<<x<<" "<<y<<"\n";
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;

int main() {
	int n;
	ci(n);
	int i;
	vl h;
	fo(i,n){
		ll temp;
		ci(temp);
		h.pb(temp);
	};
	sort(h.begin(),h.end());
	
	co(h[n-1]-h[0]);
	
	return 0;
}





Measured memory_bytes: 256
N= int(input())
S = input()
ans = 0
#find(探す文字、開始位置、終了位置)
for i in range(10):
  x = S.find(str(i))
  if x == -1:
    continue
  for j in range(10):
    y = S.find(str(j), x+1)
    if y == -1:
      continue
    for k in range(10):
      z = S.find(str(k), y+1)
      if z != -1:
        ans += 1
      
print(ans)


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

using namespace std;

vector<int> v[200005];

int main(){
	int n;
	cin>>n;
	
	
	for(int i=2;i<=n;i++){
		int tp;
		cin>>tp;
		v[tp].push_back(i);
	}
	
	for(int i=1;i<=n;i++){
		cout<<v[i].size()<<endl;
	}
	
}

Measured memory_bytes: 14512
from collections import deque

N,M = map(int,input().split())
grap = [[] for _ in range(N+1)]
for i in range(M):
    a,b = map(int,input().split())
    grap[a].append(b)
    grap[b].append(a)

dist = [-1] * (N +1)
dist[0] = 0
dist[1] = 0

d = deque()
d.append(1)

while d:
    v = d.popleft()
    for i in grap[v]:
        if dist[i] != -1:
            continue
        dist[i] = v
        d.append(i)

if -1 in dist:
    print('No')
else:
    print('Yes',*dist[2:],sep='\n')



Measured memory_bytes: 36420
/*
    C - Iroha's Obsession
    https://atcoder.jp/contests/abc042/tasks/arc058_a
*/

#include <iostream>

using namespace std;

#define ll long long
#define forn(i, s, n) for (int i = s; i < n; i++)
#define whilen(val, n) while(n-- && cin >> val)

bool isValid(int n, int ds[]) {
    while (n > 0) {
        if (ds[(n % 10)] == -1) return false;
        n /= 10;
    }
    return true;
}

int main() {
    int n, k, d;
    int ds[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    cin >> n >> k;
    forn(i, 0, k) {
        cin >> d;
        ds[d] = -1;
    }
    while(!isValid(n, ds)) n++;
    cout << n;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = N;
		int sum = 0;
		while (X != 0) {
			sum += X % 10;
			X /= 10;
		}
		if (N % sum == 0)
			System.out.println("Yes");
		else
			System.out.println("No");
		sc.close();
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define pb emplace_back
#define mp make_pair

using namespace std;

int pl[3000][3000];
int pu[3000][3000];
int pr[3000][3000];
int pd[3000][3000];

int32_t main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10);
	int h; cin >> h;
	int w; cin >> w;
	string s[h];
	for (int i = 0; i < h; ++i) cin >> s[i];
	for (int i = 1; i <= h; ++i) {
		pl[i][0] = 0;
		pr[i][0] = 0;
		pd[i][0] = 0;
		pu[i][0] = 0;
		pl[i][w + 1] = 0;
		pr[i][w + 1] = 0;
		pd[i][w + 1] = 0;
		pu[i][w + 1] = 0;
	}
	for (int i = 1; i <= w; ++i) {
		pl[0][i] = 0;
		pr[0][i] = 0;
		pd[0][i] = 0;
		pu[0][i] = 0;
		pl[h + 1][i] = 0;
		pr[h + 1][i] = 0;
		pd[h + 1][i] = 0;
		pu[h + 1][i] = 0;
	}
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			if (s[i - 1][j - 1] == '#') {
				pl[i][j] = 0;
				pu[i][j] = 0;
			} 
			else {
				pl[i][j] = pl[i][j - 1] + 1;
				pu[i][j] = pu[i - 1][j] + 1;
			}
		}
	}
	for (int i = h; i >= 1; --i) {
		for (int j = w; j >= 1; --j) {
			if (s[i - 1][j - 1] == '#') {
				pr[i][j] = 0;
				pd[i][j] = 0;
			} 
			else {
				pr[i][j] = pr[i][j + 1] + 1;
				pd[i][j] = pd[i + 1][j] + 1;
			}
		}
	}
	int su = 0;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			su = max(su, (pl[i][j] + pr[i][j] + pu[i][j] + pd[i][j]) - 3);
		}
	}
	cout << su;
}

Measured memory_bytes: 102784
n = int(input())
a = list(map(lambda x: int(x)-1,input().split()))

cnt = 0
for idx in range(len(a)):
    lovers_love = a[a[idx]]
    if lovers_love == -1:
        continue
    if lovers_love == idx:
        cnt += 1
        a[a[idx]] = -1

print(cnt)


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];

// template starts
typedef long long int ll;

vector<bool> vis;
vector<int> ans;
vector<int> d;

void bfs(vector<vector<int>> &adj){
	queue<int> q;
	q.push(1);
	vis[1] = true;
	
	while(q.size() > 0){
		int root = q.front();
		q.pop();
		

		//cout << root << ": ";
		for(int i = 0; i < (int)adj[root].size(); i++){
			int node = adj[root][i];
			if(vis[node]) continue;
			
			//cout << node << " ";
			
			vis[node] = true;
			ans[node] = root;
			
			q.push(node);
		}
		//cout << endl;
	}
}

void solve(){
	// code starts from here
	int N, M;
	cin >> N >> M;
	vector<vector<int>> adj(N+1);
	
	for(int i = 0; i <= N; i++){
		ans.pb(-1);
		vis.pb(false);
	}
	
	for(int i = 0; i < M; i++){
		int t1,t2;
		cin >> t1 >> t2;
		adj[t1].pb(t2);
		adj[t2].pb(t1);
			
	}
	bfs(adj);
	
	for(int i = 2; i <= N; i++){
		if(ans[i] == -1){
			cout << "No" << endl;
			return;
		}
	}
	
	cout << "Yes" << endl;
	for(int i = 2; i <= N; i++) cout << ans[i] << endl;
}

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

	int T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


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

int arr[11];

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    arr[a]++;
    arr[b]++;
    arr[c]++;
    if(arr[5] == 2 && arr[7] == 1)
        printf("YES");
    else
        printf("NO");
    return 0;
}


Measured memory_bytes: 256