akhauriyash/Code-Regression huggingface dataset:
n, k = map(int, raw_input().split())
d = {}
for i in range(k):
    a, b = map(int, raw_input().split())
    d[a] = b
dp =[[[[0]*(n+1) for i in range(4)] for j in range(4)] for k in range(4)]
def solve(a, b, c, i):
    if dp[a][b][c][i]: return dp[a][b][c][i]
    if a == b and b == c: return 0
    if i in d and d[i] != 0 and d[i] != c: return 0
    if i > n: return 0
    if i == n: return 1
    dp[a][b][c][i] = (solve(b,c,1,i+1) + solve(b,c,2,i+1) + solve(b,c,3,i+1)) % 10000
    return dp[a][b][c][i]
ans = (solve(0,0,1,1) + solve(0,0,2,1) + solve(0,0,3,1)) % 10000
print ans

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())
#define MIN(c) (*min_element(ALL(c))) 
#define MAX(c) (*max_element(ALL(c)))
#define ACC(c) (accumulate(ALL(c), 0))
#define SLL(x, n) ((x) << (n))
#define SRL(x, n) ((x) >> (n))
#define MP(a, b) (make_pair((a), (b)))
#define ENDL "\n"
#define PRINT(x) cout << (x) << ENDL

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

inline int in(int& a) {return scanf("%d", &a);}
inline void out(int n) {printf("%d\n", n);}
template<typename T> inline void swap(T& a, T& b) {T tmp = a; a = b; b = tmp;}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


signed main(){
    int P, Q, R;
    cin >> P >> Q >> R;
    PRINT(min(P + Q, min(P + R, Q + R)));
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
  
class Main{
  public static void main(String[] arg){
    String input;
 
    Scanner in = new Scanner(System.in);

    while(true){
        input = in.nextLine();

        if(input.equals("0")) break;

        int tmp=0;
        for(int i=0; i<input.length(); ++i){
            
            char ch = input.charAt(i);
            tmp += Character.getNumericValue(ch);

        }
        System.out.println(tmp);
    }

  }
}

Measured memory_bytes: 26544
N = int(input())

if N == 0:
    print(2)
elif N == 1:
    print(1)
    exit()

L0 = 2; L1 = 1
for _ in range(2, N+1):
    L2 = L1 + L0
    L1, L0 = L2, L1
print(L2)


Measured memory_bytes: 2940
//C
#include <bits/stdc++.h>
#define write(x) printf("%d\n", x)
using namespace std;
typedef long long ll;
template <typename T>
void read(T &x)
{
	x = 0;
	char c;
	while (!isdigit(c = getchar()));
	do
	{
		x = (x << 1) + (x << 3) + (c ^ 48);
	}while (isdigit(c = getchar()));
}
int n, k;
ll h[200005];
ll sum;
int main()
{
	read(n);read(k);
	for (int i = 0;i < n;++i)
	{
		read(h[i]);
	}
	if (k >= n)
	{
		puts("0");
		return 0;
	}
	sort(h, h + n);
	int r = n - k;
	for (int i = 0;i < r;++i)
		sum += h[i];
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stack>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <vector>
#include <cmath>
#define ll long long

using namespace std;


int main() {
    string s,t;
    cin>>s>>t;
    int n=(int)s.size();
    for(int i=0;i<=n;i++){
        if(s==t)
        {
            return cout<<"Yes",0;
        }
        s.push_back(s[0]);
        s.erase(s.begin());
    }
    cout<<"No";
}


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

int main()
{
    long long int q, h, s, d, count=0;
    cin>>q>>h>>s>>d;
    
    long long int min1=min(q*2, h);
    
    long long int min2=min(min1*2, s);
    
    long long int min3=min(min2*2, d);
    
    
    long long int n;
    cin>>n;
    
    while(n)
    { if(n%2==0)
     {count=((n/2)*min3);
     n=0;}
     
     else if(n%2==1)
     { count=(((n/2)*min3)+ min2);
     n=0;}
    }
    
    cout<<count;
}
    
    
    
    

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

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

  int result=0;
  for(int i=0;i<n;i++){
    if(v[i]==0){
      result++;
    }
  }
  printf("%d\n",result);

  return 0;
}


Measured memory_bytes: 1732
from fractions import gcd

A, B, C, D = map(int, input().split())

g = gcd(C, D)
E = C * D // g

num1 = B // C - (A - 1) // C
num2 = B // D - (A - 1) // D
num3 = B // E - (A - 1) // E
print(B - A + 1 - num1 - num2 + num3)

Measured memory_bytes: 68076
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

    int N;
    cin >> N;
    vector<ll> H(N);
    for(int i = 0; i < N; i++){
        cin >> H[i];
    }
    int cnt = 0, ans = 0;
    for(int i = 1; i < N; i++){
        if(H[i - 1] >= H[i]){
            cnt++;
            ans = max(ans, cnt);
        }
        else{
            cnt = 0;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        c: chars
    }

    //let mut red_count = 0;
    let mut red_induce: VecDeque<usize> = VecDeque::new();
    let mut is_red = vec![false; n];
    for i in 0..n {
        if c[i] == 'R' {
            red_induce.push_back(i);
            is_red[i] = true;
        }
    }

    let mut ans: usize = 0;

    if let Some(x) = red_induce.back() {
    } else {
        println!("{}", 0);
        return;
    }

    for i in 0..n {
        if !is_red[i] {
            // 白い石の場合
            if let Some(x) = red_induce.back() {
                if x > &i {
                    let whitize_index = red_induce.pop_back().unwrap();
                    ans += 1;
                    is_red[whitize_index] = false;
                } else {
                    ans += 1;
                }
            } else {
                ans += 1;
            }

            is_red[i] = true;
        }

        if let Some(x) = red_induce.back() {
            if x <= &i {
                break;
            }
        } else {
            break;
        }
    }

    println!("{:?}", ans);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
char a[1001][1001];
int co[1001][1001];

 int dp(int m,int n)
 {
 	if(m<0 || n<0)
 		return 0;
 	if(m==0 && n==0)
 		return 1;
 	if(co[m][n]==-1)
 	{
 		if(a[m][n]=='#')
 	 	{
 	 		co[m][n]=0;
 	 	}
 	 	else
 	 	{
 	 		co[m][n]=(dp(m-1,n)+dp(m,n-1))%1000000007;
 	 	}
 	 }
 	 return co[m][n];
 }
int main()
{
	int r,c;
	cin>>r>>c;
	memset(co,-1,sizeof(co));
	for(int i=0;i<r;i++)
		for(int j=0;j<c;j++)
			cin>>a[i][j];
 
	  	long int result[r][c]={0};
		memset(result,0,sizeof(result));
		cout<<dp(r-1,c-1);
		/*for(int i=0;i<r;i++)
		{
			if(a[i][0]=='.')
				{result[i][0]=1;}
			if(a[i][0]=='#')
				break;
		}
		for(int i=0;i<c;i++)
		{
			if(a[0][i]=='.')
				{result[0][i]=1; }
			if(a[0][i]=='#')
				break;
		}
 
			for(int i=1;i<r;i++)
					for(int j=1;j<c;j++)
					{
						if(a[i][j]=='.')
							result[i][j]=(result[i-1][j]+result[i][j-1])%1000000007;
						else
							result[i][j]=0;
					}
					/*for(int i=0;i<r;i++)
		{for(int j=0;j<c;j++)
			cout<<result[i][j];cout<<"\n";}*/
   //cout<<result[r-1][c-1];
				return 0;
}

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

unordered_multiset<int> s;
long long n,a[100005],r;


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

    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        s.insert(a[i]);
    }
    for(int i=0;i<100005;i++)
    {
        if(s.count(i-1)+s.count(i+1)+s.count(i)>r)
            r=s.count(i-1)+s.count(i+1)+s.count(i);
    }

    cout<<r<<endl;

    return 0;
}


Measured memory_bytes: 8004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  sort(p.begin(),p.end());
  reverse(p.begin(),p.end());
  int ans=p[0]/2;
  for(int i=1;i<n;i++){
    ans+=p[i];
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main()
{
	long long h, w, mi = 1 << 30;
	scanf("%lld%lld", &h, &w);	
	for(int k = 0; k < 2; ++k)
	{
		swap(h, w);
		long long f = h / 2, s = h - f;
		for(long long i = 1, smi, smx; i < w; ++i)
		{
			smi = min((w - i) * h, i * f);
			smx = max((w - i) * h, i * s);
			mi = min(mi, smx - smi);
		}
		f = h / 3;
		s = (h - f) / 2;
		long long t = h - f - s;
		mi = min(mi, w * (max(f, max(s, t)) - min(f, max(s, t))));
	}
	printf("%lld\n", mi);
}


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

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (a); i < (n); i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  //$B$3$N%3%s%F%9%H$G$O!"(B N $BLd$NLdBj$,=PBj$5$l$^$9!#(B
  //$B9b667/$O%3%s%F%9%HCf$K(B M $B2s$NDs=P$r9T$$$^$7$?!#(B
  int n,m;cin>>n>>m;
  //i=i+1$B$NLdBj(B,
  //check=bool
  vector<int> wa(n);
  vector<bool> check(n,false);
  //$B9b667/$N@5Ez?t$O!"(BAC $B$r(B 1 $B2s0J>e=P$7$?LdBj$N?t$G$9!#(B
  //$B9b667/$N%Z%J%k%F%#?t$O!"9b667/$,(B AC $B$r(B 1 $B2s0J>e=P$7$?(B
  //$B3FLdBj$K$*$$$F!"=i$a$F(B AC $B$r=P$9$^$G$K=P$7$?(BWA$B$N?t$NAmOB(B
  int p,ace=0,pna=0;
  string s;
  rep(i,m){
    cin>>p>>s;
    p--;
    if(check[p]==false && s=="WA"){
      wa[p]++;
    }else if(check[p]==false && s=="AC"){
      check[p]=true;
      pna+=wa[p];
      ace++;
    }
  }
  cout<<ace<<" "<<pna<<endl;
}


Measured memory_bytes: 640
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n = int(input())
a = list(map(int,input().split()))
mina = min(a)
maxa = max(a)
print(abs(maxa) - abs(mina))

Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s; cin >> s ;
    rep(i, s.size()){
        cout << 'x';
    }
    cout << endl;


    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
int main(){
    int N;
    int a[200];
    int count = 0;
    scanf("%d",&N);
    int i;
    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
    }
    if(N%2==0){
        for(i=0;i<N/2;i++){
            if(a[2*i]%2==1){
                count++;
            }
        }
    }else{
        for(i=0;i<N/2+1;i++){
            if(a[2*i]%2==1){
                count++;
            }
        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 1696
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

typedef struct Edge {
    ll to, cost;
} Edge;

typedef struct Info {
    ll dist, from;
} Info;

vector<vector<Edge>> g;

void dijkstra(vector<Info> &dp, int s) {
    priority_queue<P> pq;
    dp[s].dist = 0;
    // P(dist, v)
    pq.push({0,s});

    while (!pq.empty()) {
        P p = pq.top(); pq.pop();
        int v = p.second;
        for (auto &&e: g[v]) {
            if (dp[e.to].dist > dp[v].dist+e.cost) {
                dp[e.to].dist = dp[v].dist+e.cost;
                dp[e.to].from = v;
                pq.push({dp[e.to].dist, e.to});
            }
        }
    }
}

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    g.resize(n);
    REP(i,n-1) {
        ll a, b, c;
        cin >> a >> b >> c;
        --a,--b;
        g[a].push_back({b,c});
        g[b].push_back({a,c});
    }

    int q,k;
    cin >> q >> k;
    --k;
    vector<Info> dp(n, {LINF,LINF});
    dijkstra(dp,k);

    REP(i,q) {
        int x,y;
        cin >> x >> y;
        --x,--y;
        cout << dp[x].dist+dp[y].dist << endl;
    }
    return 0;
}

Measured memory_bytes: 11888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
ll a[100010],b[100010];
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<=n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		ll now=min(a[i],b[i]);
		ans+=now;
		a[i]-=now;b[i]-=now;
		if(a[i]>0){
			continue;
		}
		ll next=min(a[i+1],b[i]);
		ans+=next;
		a[i+1]-=next;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1792
def make_divisors(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    #約数の小さい順にソートしたい場合
    #divisors.sort()
    #約数の大きい順にソートしたい場合
    divisors.sort(reverse=True)
    return divisors
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in make_divisors(sum(a)):
    x=[a[j]-(a[j]//i)*i for j in range(n)]
    x.sort(reverse=True)
    s=sum(x)
    compk=0
    for j in range(n):
        if s==0:
            break
        else:
            s-=i
            x[j]-=i
            compk+=abs(x[j])
    if compk<=k:
        print(i)
        break

Measured memory_bytes: 68884
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>


int main() {

    int a;
    scanf("%d", &a);

    int ans = a + (a*a) + (a*a*a);

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


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

typedef long long ll;
using namespace std;

class day{
public:
	int y,m,d;
	int cnt = 0;
	bool isU = false;
	int f[12] = {0,0,0,1,0,1,0,0,1,0,1,0};
	void next(){
		isU = false;
		if(y%4 == 0){
			if(y%400 == 0) isU = true;
			else if(y%100 == 0) isU = false;
			else isU = true;
		}
		d++;
		if(!isU && m == 2 && d == 29 ){ m++; d = 1;}
		else if(isU && m == 2 && d == 30){m++; d = 1;}
		else if(f[m-1] && d == 31){ m++; d = 1;}
		else if(f[m-1] == 0 && d == 32){ m++; d = 1;}
		if(m == 13){
			m = 1;
			y++;
			cnt++;
		}
	}
	bool isEq(int b, int c){
		if(b == m && c == d) return true;
		else return false;
	}
};

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

	int y[2],m[2],d[2];
	bool tn[2];
	for (int i = 0;i < 2;i++){
		cin >> y[i] >> m[i] >> d[i];
		tn[i] = false;
		if(m[i] == 2 && d[i] == 29) tn[i] = true;
	}

	day x;
	x.y = min(y[0],y[1]); x.m = 1; x.d = 0;

	int a[] = {x.y-y[0],x.y-y[1]};
	int ans = -1;

	while(x.cnt != 4000){
		x.next();
		for (int i = 0;i < 2;i++){
			if(x.isEq(m[i],d[i])){
				a[i]++;
			}
			if(!x.isU && tn[i] && x.isEq(3,1)){
				a[i]++;
			}
		}
		int dis = abs(a[0]-a[1]);
		ans = max(ans,dis);
	}

	cout << ans << endl;

	return 0;

}



Measured memory_bytes: 3196
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String st = sc.next();
        int max = 0;
        int curr = 0;
        for(int i = 0; i < n; i++){
            if(st.charAt(i) == 'D')
                curr -= 1;
            else
                curr += 1;
            if(curr > max)
                max = curr;
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll dp[62][3];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    ll N;
    cin >> N;
    dp[61][0] = 1;
    for(int i = 60; i >= 0; i--){
        ll m = (ll)1<<i;
        if(m&N){
            dp[i][0] = dp[i+1][0];
            dp[i][1] = (dp[i+1][0]+dp[i+1][1])%MOD;
            dp[i][2] = (2*dp[i+1][1]+3*dp[i+1][2])%MOD;
        }else{
            dp[i][0] = (dp[i+1][0]+dp[i+1][1])%MOD;
            dp[i][1] = (dp[i+1][1])%MOD;
            dp[i][2] = (dp[i+1][1]+3*dp[i+1][2])%MOD;
        }
    }
    cout << (dp[0][0]+dp[0][1]+dp[0][2])%MOD << endl;
}

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

#define pi 3.1415926535
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ll long long
#define llu unsigned long long
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define tc int test_case; cin >> test_case; while(test_case--)
#define f(i,a,n) for(int i = a ; i < n ; i++)
#define rf(i,n,a) for(int i = n-1 ; i >= a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define fast ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trace(x) cout << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cout<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

const int inf = 1e9;
const ll inf64 = 1e18;
const int mod = inf + 7;
const int N = 2e5 + 10;

int main()
{
    fast;
    string s, t;
    cin >> s >> t;
    int c = 0;
    f(i,0,sz(s))
    {
        if(s[i] != t[i])
            c++;
    }
    cout << c;
}


Measured memory_bytes: 3784
package main

import "fmt"

var (
	H, N, sum int
	a         []int
)

func main() {
	fmt.Scan(&H)
	fmt.Scan(&N)
	a = make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&(a[i]))
	}
	for _, v := range a {
		sum += v
	}
	if H > sum {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N; cin >> N;
	vector<string> gr(N);
	for (int i = 0; i < N; i++)
		cin >> gr[i];
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		bool flag = true;
		vector<string> gr2 =gr;
		for (int j = 0; j < N && flag; j++) {
			for (int k = 0; k < N; k++) {
				gr2[j][k] = gr[j][(k + i) % N];
			}
		}
		for (int j = 0; j < N&&flag; j++) {
			for (int k = 0; k < N; k++) {
				//cout << j << " " << (k + i) % N << " " << (k + i) % N << " " << j << endl;
				if (gr2[j][k] != gr2[k][j]) {
					flag = false;
					break;
				}				
			}
		}
		if (flag) cnt += N;// cout << "i=" << i << endl;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3812
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
typedef unsigned long long ull;
const int inf=103974182;
using namespace std;
char map[85][85];

int main()
{
//	freopen("input.txt","r",stdin);
	int a,b;
	cin>>a>>b;
	for(int i=0;i<80;i++)
	{
		for(int j=0;j<40;j++)
		{
			map[i][j]='.';
		}
		for(int j=40;j<80;j++)
		{
			map[i][j]='#';
		}
	}
	a--;
	b--;
	for(int i=0;i<80;i+=2)
	{
		for(int j=42;j<80;j+=2)
		{
			if(a==0) break;
			map[i][j]='.';
			a--;
			if(a==0) break;
		}
		if(a==0) break;
	}
	for(int i=0;i<80;i+=2)
	{
		for(int j=0;j<38;j+=2)
		{
			if(b==0) break;
			map[i][j]='#';
			b--;
			if(b==0) break;
		}
		if(b==0) break;
	}
	cout<<80<<' '<<80<<endl;
	for(int i=0;i<80;i++)
	{
		for(int j=0;j<80;j++)
		{
			cout<<map[i][j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int[] d = new int[6];
    int[] e = new int[6];
    int i;
    for(i = 0;i < 6;i++)d[i] = sc.nextInt();
    for(i = 0;i < 6;i++)e[i] = sc.nextInt();
    if(isisom(d, e))out.println("Yes");
    else out.println("No");

    sc.close();
  }
  private static boolean isisom(int[] d, int[] e){
    int i, j, k;
    for(i = 0;i < 6;i++){
      for(j = 0;j < 4;j++){
        for(k = 0;k < 6;k++)if(d[k] != e[k])break;
        if(k == 6)return true;
        rroll(d);
      }
      for(k = 0;k < 6;k++)if(d[k] != e[k])break;
      if(k == 6)return true;
      if(i % 2 == 0)nroll(d);
      else eroll(d);
    }
    return false;
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static void nroll(int[] dice){ //(1265)
    int tmp;
    tmp = dice[0]; dice[0] = dice[1]; dice[1] = dice[5];
    dice[5] = dice[4]; dice[4] = tmp;
    return;
  }
  private static void eroll(int[] dice){ //(1463)
    int tmp;
    tmp = dice[0]; dice[0] = dice[3]; dice[3] = dice[5];
    dice[5] = dice[2]; dice[2] = tmp;
    return;
  }
  private static void rroll(int[] dice){ //(2354)
    int tmp;
    tmp = dice[1]; dice[1] = dice[2]; dice[2] = dice[4];
    dice[4] = dice[3]; dice[3] = tmp;
    return;
  }
}

Measured memory_bytes: 26316
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> l(n);
   int MAX=0;
  int index=0;
  for(int i=0;i<n;i++) {
    cin >> l[i];
    if(MAX<=l[i]){
      MAX=l[i];
      index=i;
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(i!=index){
      ans+=l[i];
    }
  }
  if(ans>MAX) cout << "Yes" << endl;
  else cout << "No"<< endl;
  return 0;
}

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



int main() {
  int a[3][3];
  rep(i,3)rep(j,3){
    cin >> a[i][j];
  }
  int N;
  cin >> N;
  int b;
  rep(i,N){
    cin >> b;
    rep(i,3)rep(j,3){
      if(a[i][j] == b) a[i][j] = 0;
    }
  }
  bool ans = false;
  rep(i,3){
    if(a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0 ) ans = true; 
  }
  rep(i,3){
    if(a[0][i] == 0 && a[1][i] == 0 && a[2][i] == 0 ) ans = true; 
  }
  if(a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0 ) ans = true; 
  if(a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0 ) ans = true; 
  
  cout << (ans? "Yes": "No") << endl;
  







	return 0;
}



Measured memory_bytes: 3616
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;

int main(void){
  string a;
  cin>>a;
  if(a[2]==a[3]&&a[4]==a[5]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N];
int lowLeft[N * 2 - 1], lowRight[N * 2 - 1];
bool X[N][N];

void init() {
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			X[i][j] = false;
		}
	}
	for (int i = 0; i < N; ++i) {
		row[i] = col[i] = FREE;
	}
	for (int i = 0; i < N * 2 - 1; ++i) {
		lowLeft[i] = lowRight[i] = FREE;
	}
}

void printBoard() {
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (X[i][j] && row[i] != j)
				return;
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (row[i] == j) {
				cout << "Q";
			} else {
				cout << ".";
			}
		}
		cout << endl;
	}
}

void backTrack(int i) {
	if (i == N) {
		printBoard();
		return;
	}
	for (int j = 0; j < N; ++j) {
		if (col[j] == NOT_FREE || lowLeft[i + j] == NOT_FREE || lowRight[i - j + N - 1] == NOT_FREE)
			continue;
		row[i] = j;
		col[j] = lowLeft[i + j] = lowRight[i - j + N - 1] = NOT_FREE;
		backTrack(i + 1);
		row[i] = col[j] = lowLeft[i + j] = lowRight[i - j + N - 1] = FREE;
	}
}

int main() {

	init();

	int k;
	scanf("%d", &k);
	for (int i = 0; i < k; ++i) {
		int r, c;
		scanf("%d %d", &r, &c);
		X[r][c] = true;
	}
	backTrack(0);

	return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define pi(n,m) n.insert(n.begin(),m);
#define ee(n) n.erase(n.end()-1)
#define eb(n) n.erase(n.begin())
#define check(n) reverse(all(n));rep(z,0,n.size())cout<<n[z];co("");reverse(all(n));
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  ll b,c=0,d=0,e,n,k;
  cin>>n>>k;
  int a[n]={};
  rep(i,0,k){
    cin>>d;
    rep(j,0,d){
      cin>>b;
      a[b-1]++;
    }
  }
  rep(i,0,n){
    if(a[i]==0) c++;
  }
  co(c);
  
  return 0;
}

Measured memory_bytes: 3636
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0

for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if 500 * i + 100 * j + 50 * k == X:
                ans += 1
print(ans)


Measured memory_bytes: 67288
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
     Scanner scan = new Scanner(System.in);
     int[] a = new int[3];
     a[0] = scan.nextInt();
     a[1] = scan.nextInt();
     a[2] = scan.nextInt();
     
     java.util.Arrays.sort(a);
     
     System.out.println(a[0]+" "+a[1]+" "+a[2]);
   }
}

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

namespace AtCoder.ABC._123
{
    class B
    {
        public static void Solve()
        {
            int[] p = new int[5];
            int minDiff = 10;
            int minId = 0;
            for (int i = 0; i < 5; i++)
            {
                p[i] = int.Parse(Console.ReadLine());
                if(p[i]%10 != 0 && p[i] % 10 < minDiff)
                {
                    minDiff = p[i] % 10;
                    minId = i;
                }
            }

            int sum = 0;
            for (int i = 0; i < 5; i++)
            {
                if (minId == i || p[i] % 10 == 0)
                    sum += p[i];
                else
                    sum += (p[i] / 10 + 1) * 10;
            }
            Console.WriteLine(sum);
        }
    }

class Program
{
    static void Main(string[] args)
    {
        B.Solve();
    }
}

}

Measured memory_bytes: 13140
n = int(input())
arr = [int(i) for i in input().split()]

for d in arr :
  
  if d % 2 == 0 :
    
    if d % 3 == 0 or d % 5 == 0:

      pass
    
    else :

      print("DENIED")
      exit()
      
print("APPROVED")

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

const int INF = 1e9;

int main() {
  int r, d;
  long long x;
  cin>>r>>d>>x;

  for (int i=0; i<10; i++) {
    x = r * x - d;
    cout<<x<<endl;
  }

}

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

const int MX = 100000;
ll cnt[MX + 1];

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

    rep(i,n){
        int a, b;
        cin >> a >> b;
        cnt[a] += b;
    }

    for(int ans = 1; ans <= MX; ++ans){
        if(k <= cnt[ans]){
            cout << ans << endl;
            break;
        }
        k -= cnt[ans];
    }
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

typedef pair<int, int> P; 
bool kimari[3];
int suuji[3];

int main(){
    string s;
    cin >> s;
    if(s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
    else cout << "Yes" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
     
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define bp __builtin_popcountll
#define MOD 1000000007
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))

int main()
{
    ll a[3];
    for(ll i=0;i<3;i++)   cin >> a[i];
    sort(a,a+3);
    if(a[0]==a[1] && a[1]!=a[2])
    {
        cout<<"Yes\n";
    }
    else if(a[0]!=a[1] && a[1]==a[2])
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
}

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

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    long minimum = A * X + B * Y;
    for (int i = 0; i < 10e5; i++) {
        long total = A * max(0, X - i) + B * max(0, Y - i) + (long)C * i * 2;
        minimum = min(minimum, total);
    }
    cout << minimum << endl;
}


Measured memory_bytes: 256
// header file
#include <iostream>
#include <cstdio>
#include <vector>  //vector<T> vec; ランダムアクセスが速い、挿入は線形時間
#include <list>  //list<T> ls; 挿入・消去速い、アクセスは線形時間
#include <algorithm>
#include <functional> // greater<int>()を使える
#include <utility>
#include <string>
#include <map>
// macro
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define R_REP(i, n) for(int i = ((int)(n - 1)); i >= 0; i--)  // Reverse n-1 ~ 0
#define R_REPN(i, n) for(int i= ((int)(n));i > 0;i--)  // Reverse n ~ 1
#define FOR(i, m, n) for(int i = m;i < n;i++)  // 指定範囲loop m ~ n-1
#define pb(vec) push_back(vec)  // 配列の一番うしろに追加
// typedef
typedef long long ll;  // int64

using namespace std;

int main(void) {
    int A, B;
    char op;
    // 型が違っても入力はできる
    cin >> A >> op >> B;

    if (op == '+') {
        std::cout << A + B << std::endl;
    } else {
        std::cout << A - B << std::endl;
    }

    return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    int n, r;

    cin >> n >> r;

    if(n >= 10) {
        cout << r << endl;
        return 0;
    }

    cout << r + 100 * (10 - n) << endl;;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC144D_2
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadInt();
            double a = input[0];
            double b = input[1];
            double x = input[2];

            double ans = 0;
            if (x >= a * a * b / 2)
            {
                ans = Math.Atan(2 * (b / a - x / a / a / a));
            }
            else
            {
                ans = Math.Atan(a * b * b / x / 2);
            }

            Console.WriteLine(ans / Math.PI * 180);
            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


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

#define endl "\n"

typedef long long ll;
typedef pair <ll, ll> pii;
typedef long double ld;

const ll DIM = 100007;
const ll INF = 1000000007;
string s[1007];
ll a[1007][1007];
ll ans[1007][1007];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll n,m;
    cin>>n>>m;

    for(ll i=1;i<=n;i++)
        cin>>s[i];
        ans[1][1]=1;
    for(ll i=1;i<=n;i++)
        for(ll j=1;j<=m;j++)
            if(s[i][j-1]=='#')a[i][j]=1;else a[i][j]=0;

    for(ll i=1;i<=n;i++)
        for(ll j=1;j<=m;j++)
       if(i==1&&j==1)continue;else if(a[i][j])ans[i][j]=0;else ans[i][j]=(ans[i-1][j]+ans[i][j-1])%INF;

    cout<<ans[n][m]%INF;
    return 0;
}


Measured memory_bytes: 17152
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb       push_back
#define sz(x)    ((int)(x.size()))
#define all(x)   x.begin(),x.end()
#define clr(x)   memset(x,0,sizeof x)
const int inf = ( 1953125 << 9 );
const int maxn = 2 * 1e5 + 5;
bool vis[maxn];


int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//	freopen("input.in", "r", stdin); //freopen("output.txt", "w", stdout);
	clr(vis);

	string a,b;
	cin>>a>>b;
	set<char>s1,s2;
	map<char, int>m1,m2;
	for(auto it: a){s1.insert(it); m1[it]++;}
	for(auto it: b){s2.insert(it); m2[it]++;}

	vector<int>v1,v2;
	for(auto it: m1)v1.pb(it.second);
	for(auto it: m2)v2.pb(it.second);

	sort(all(v1));
	sort(all(v2));

	bool flag = sz(v1) == sz(v2);

	if(!flag)return cout<<"No", 0;

	for (int i = 0; i < sz(v1); ++i)
		if(v1[i] != v2[i]) return cout<<"No", 0;

	cout<<(sz(a) == sz(b) ? "Yes" : "No");
}


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

int main(){
    int w,a[2];
    cin >> w >> a[0] >> a[1];
    sort(a,a+2);
    if(a[0] <= a[1] && a[1] <= a[0]+w)cout << 0;
    else if(fabs(a[0]-a[1]) > fabs((a[0]+w)-a[1]))cout << fabs((a[0]+w)-a[1]);
    else cout << fabs(a[0]-a[1]);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
int main(){
    vb v(100,false);
    int temp;
    rep(i,30){cin>>temp; v[temp]=true;}
    rep(i,30)if(!v[i+1])cout<<i+1<<endl;
}

Measured memory_bytes: 3116
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
	int n, m, i, sum=0;

	scanf("%d", &n);
	m=n;

	while(n!=0)
	{
		sum += n%10;
		n/=10;
	}
	if(m%sum==0)
		printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	ans := 1
	for i := 0; i < n; i++ {
		var v int
		fmt.Scan(&v)
		ans = lcm(ans, v)
	}
	fmt.Println(ans)
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}


Measured memory_bytes: 512
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
S = list(map(int,readline().rstrip().split()))
Q = int(readline())
T = list(map(int,readline().rstrip().split()))
cnt = 0
for i in range(Q):
    low = 0
    high = N-1
    while low <= high:
        mid = (low+high)//2
        guess = S[mid]
        if T[i] == guess:
            cnt += 1
            break
        elif T[i] < S[mid]:
            high = mid-1
        else:
            low = mid+1
print(cnt)


Measured memory_bytes: 16708
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>
#include <tuple>
using namespace std;

int N, M, C, B[102], cnt;

int main() {
	cin >> N >> M >> C;
	for (int i = 1; i <= M; i++) cin >> B[i];
	for (int i = 1; i <= N; i++) {
		int sum = C;
		for (int j = 1; j <= M; j++) {
			int a; cin >> a; sum += a * B[j];
		}
		if (sum > 0) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

const int MAXN = 1e5 + 100;

int n, m, Q;
int x[MAXN], d[MAXN], c[MAXN];

std::vector<int> edge[MAXN << 1];

int col[MAXN][20];

void Dfs(int x, int d, int c) {
	if (d == -1 || col[x][d])
		return;
	col[x][d] = c;
	for (int i = 0; i < edge[x].size(); ++i) {
		int y = edge[x][i];
		Dfs(y, d - 1, c);
	}
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i) {
		int u, v;
		scanf("%d%d", &u, &v);
		edge[u].push_back(v), edge[v].push_back(u);
	}
	for (int i = 1; i <= n; ++i)
		edge[i].push_back(i);

	scanf("%d", &Q);
	for (int i = 1; i <= Q; ++i)
		scanf("%d%d%d", &x[i], &d[i], &c[i]);

	for (int i = Q; i; --i)
		Dfs(x[i], d[i], c[i]);
	
	for (int i = 1; i <= n; ++i)
		printf("%d\n", col[i][0]);
	return 0;
}

Measured memory_bytes: 17784
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		int rigth = Integer.parseInt(S.substring(0,2));
		int left = Integer.parseInt(S.substring(2,4));
		
		if(rigth == 0) {
			if(left == 0) {
				System.out.println("NA");
			}else if (left <= 12) {
				System.out.println("YYMM");
			}else {
				System.out.println("NA");
			}
		}else if (rigth <= 12) {
			if(left == 0) {
				System.out.println("MMYY");
			}else if(left <= 12){
				System.out.println("AMBIGUOUS");
			}else {
				System.out.println("MMYY");
			}
		}else {
			if(left == 0) {
				System.out.println("NA");
			}else if(left <= 12){
				System.out.println("YYMM");
			}else {
				System.out.println("NA");
			}
		}
		
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
int dp[1001][7];
int main(void)
{
	int n,i,j,k,M,Jflg,Oflg,Iflg,sum;
	char s[1001];
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		for(j=1;j<=7;j++) dp[i][j]=0;
	}
	scanf("%s",s);
	M=4;
	if(s[0]=='O') M=2;
	if(s[0]=='I') M=1;
	for(i=1;i<=7;i++){
		if((i&4)!=0 && (i&M)!=0) dp[1][i]=1;
	}
	for(i=1;i<n;i++){
		for(j=1;j<=7;j++){
			if(dp[i][j]!=0){
				Jflg=0; Oflg=0; Iflg=0;
				if(s[i]=='J') M=4;
				if(s[i]=='O') M=2;
				if(s[i]=='I') M=1;
				if((j&4)!=0) Jflg=1;
				if((j&2)!=0) Oflg=1;
				if((j&1)!=0) Iflg=1;
//				printf("%d %d %d\n",Jflg,Oflg,Iflg);
				for(k=1;k<=7;k++){
					if((k&M)!=0){
						if((k&4)!=0 && Jflg==1)dp[i+1][k]+=dp[i][j]%10007;
						else if((k&2)!=0 && Oflg==1)dp[i+1][k]+=dp[i][j]%10007;
						else if((k&1)!=0 && Iflg==1)dp[i+1][k]+=dp[i][j]%10007;
					}
				}
			}
		}
	}
/*	for(i=1;i<=n;i++){
		for(j=1;j<=7;j++) printf("%d ",dp[i][j]);
		printf("\n");
	}*/
	sum=0;
	for(i=1;i<=7;i++) sum+=dp[n][i];
	sum%=10007;
	printf("%d\n",sum);
	return 0;
}
	

Measured memory_bytes: 620
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;
 
namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var abc = ReadIntArray();
            var a = abc[0];
            var b = abc[1];
            var c = abc[2];
            var ans = b - a == c - b ? "YES" : "NO";
            Console.WriteLine($"{ans}");
        }
    }
 
    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e2 + 5;
const int INF = 1e9 + 7;

int n, k, d, a;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> k;
	map<int, int> mp;
	while (k--)
	{
		cin >> d;
		while (d--)
		{
			cin >> a;
			mp[a] = 1;
		}
	}
	cout << n - mp.size();
	return 0;
}
//11-09-2020 17:37:32

Measured memory_bytes: 3568
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

void solve(){
    string s;
    cin >> s;
    int n = s.length();

    if(s[0]=='0' || s[n-2]=='0' || s[n-1]=='1'){
        cout << "-1\n";
        return;
    }
    for(int i = 0; i < n-1; ++i){
        if(s[i]!=s[n-2-i]){
            cout << "-1\n";
            return;
        }
    }

    vector<pair<int, int>> ans;
    int head = 1;
    for(int i = 0; i < n-1; ++i){
        int last = i+2;
        if(s[i]=='1'){
            ans.push_back({last, head});
            head = last;
        }
        else{
            ans.push_back({head, last});
        }
    }

    for(auto& a : ans){
        cout << a.F << " " << a.S << "\n";
    }
}

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

Measured memory_bytes: 4496
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<n; ++i)
using namespace std;
using ll=long long;
int main() {
    ll a,b,c,d;
    cin>>a>>b>>c>>d;    
    cout<<max({a*c,a*d,b*c,b*d});
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	int n,q; cin >> n >> q;
	vector<pair<int,string> > v;
	v.push_back(make_pair(0,"kogakubu10gokan"));
	for(int i=0;i<n;i++){
		int m; cin >> m;
		string s; cin >> s;
		v.push_back(make_pair(m,s));
	}
	for(int i=0;i<n;i++){
		if(v[i].first<=q&&v[i+1].first>q){
			cout << v[i].second << endl;
			return 0;
		}
	}
	cout << v[n].second << endl;
}



Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,a[10]={0},x,ans=0;
	for(cin>>n;n--;a[min(8,x/400)]++) cin>>x;
	for(int i=0;i<8;ans+=!!a[i++]);
	cout<<max(ans,1)<<" "<<ans+a[8];
}


Measured memory_bytes: 256
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

N,M = map(int, input().split())

#S[i]は、電球iのスイッチ接続の様子
S = np.array([np.zeros(N,int) for _ in range(M)])
for i in range(M):
    L = list(map(int, input().split()))
    for j in range(L[0]):
        S[i][L[j+1]-1] = 1

P = list(map(int, input().split()))
ans = 0

for i in range(2**N):
    #Bはiの2進数表示
    B = np.zeros(N)
    for j in range(N):
        if (1<<j)&i != 0:
            B[j] = 1
    
    flg = 1
    for j in range(M):
        dot = np.dot(B,S[j])
        if dot%2 != P[j]:
            flg = 0
            break
    
    if flg==1:
        ans += 1

print(ans)

Measured memory_bytes: 12096
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

struct UnionFind{
  vector<int> par,num;

  UnionFind(int N) : par(N),num(N){
    for(int i=0;i<N;i++){
      par[i] = i;
      num[i] = 1;
    }
  }

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

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    par[rx] = ry;
    num[ry] = num[ry]+num[rx]; 
  }

  int get_num(int x){
    int rx = root(x);
    return num[rx];
  }

  bool same(int x, int y){
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};


int main(void){
  string s;
  cin >> s;
  if(s == "ABC"){
    cout << "ARC" << endl;
  }
  else{
    cout << "ABC" << endl;
  }
  return 0;
}


Measured memory_bytes: 3548
#include <stdio.h>

int main(void) {
	int D;
	scanf("%d", &D);
	if (D == 25) {
		printf("Christmas\n");
	}
	else if (D == 24){
		printf("Christmas Eve\n");
	}
	else if (D == 23) {
			printf("Christmas Eve Eve");
	}
	else {
		printf("Christmas Eve Eve Eve");
	}







	return 0;

}

Measured memory_bytes: 128