akhauriyash/Code-Regression huggingface dataset:
use proconio::input;
use std::collections::VecDeque;
fn main() {
    input!{
        n:usize,
        m:usize,
        abs: [(usize,usize);m]
    }   

/*    let n = 4usize;
    let m = 4usize;
    let abs = vec![(1,2),(2,3),(3,4),(4,2)];
    */
    let mut graph:Vec<Vec<usize>> = vec![Vec::new();n + 1];
    for &(a,b) in abs.iter(){
        graph[a].push(b);
        graph[b].push(a);
    }

    let mut que:VecDeque<usize> = VecDeque::new();

    let mut dest:Vec<isize> = vec![-1;n + 1];

    dest[1] = 0;
    que.push_back(1);
    while !que.is_empty() {
        let v = que.pop_front().unwrap();
        for &nv in graph[v].iter(){
            if dest[nv] != -1 {
                continue;
            }
            dest[nv] = v as isize;
            que.push_back(nv);
        }
    }
    if dest[1..].iter().find(|&&x|x == -1) != None{
        println!("No");
        return;
    }
    
    println!("Yes");
    for i in 2..=n {
        println!("{}",dest[i]);
    }
}


Measured memory_bytes: 17284
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<pair<int, int> > VPII;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	string s;
	string y = "YAKI";
	cin >> s;
	string ans = "Yes";
	FOR(i, 0, 4) {
		if (s[i] != y[i])
			ans = "No";
	}
	O(ans);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

static int
solve(int N, int M, int *s, int *c)
{
  int d[3];
  for (int i = 0; i < 1000; i++)
  {
    if (N == 1 && i < 10)
    {
      d[0] = i;
    }
    else if (N == 2 && (10 <= i && i < 100))
    {
      d[0] = i / 10;
      d[1] = i % 10;
    }
    else if (N == 3 && (100 <= i && i < 1000))
    {
      d[0] = i / 100;
      d[1] = i / 10 % 10;
      d[2] = i % 10;
    }
    else
    {
      continue;
    }
    int miss = 0;
    for (int m = 0; m < M; m++)
    {
      if (d[s[m] - 1] != c[m])
      {
        miss = 1;
        break;
      }
    }
    if (miss == 0)
    {
      return i;
    }
  }
  return -1;
}

int
main()
{
  int N, M;
  cin >> N >> M;
  int s[5];
  int c[5];
  for (int m = 0; m < M; m++)
  {
    cin >> s[m] >> c[m];
  }
  cout << solve(N, M, s, c) << endl;
  return 0;
}


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

int main() {
	// your code goes here
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int ans1,ans2;
	ans1=a*b;
	ans2=c*d;
	if(ans1<ans2){
		cout<<ans2<<endl;
	}else {
		cout<<ans1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a<b?a:b)
inline int read(){
	int f=1,x=0;char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(c<='9'&&c>='0'){
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}

inline void file(){
	freopen("1.in","r",stdin);
	freopen("1.out","w",stdout);
}

using namespace std;
const int maxn=1000+10;
int a[maxn];
int main(){
	int n,y;
	int a=10000,b=5000,c=1000;
	scanf("%d%d",&n,&y);
	for(register int i=0;i<=n;++i)
		for(register int j=0;j<=n-i;++j){
			int k=n-i-j;
			if(a*i+b*j+c*k==y){
				cout<<i<<' '<<j<<' '<<k;
				return 0;
			}
		}
	cout<<-1<<' '<<-1<<' '<<-1;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define f(i, l, r) for (int i = l; i <= r; i++)
#define rf(i, r, l) for (int i = r; i >= l; i--)
#define all(x) (x).begin(), (x).end()
#define sf(a) scanf("%d",&a)
#define llsf(a) scanf("%lld", &a)
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
#define mid ((l + r) >> 1)
#define mem(x, y) memset(x, y, sizeof(x))

const int inf = 2e9 + 7;
const ll INF = INT64_MAX;
double eps = 1e-6;
int mod = 1e9 + 7;
const int N = 1e6 + 10;
const double pi = acos(-1.0);

int a[N][2];
	bool cmp(pii a, pii b) {
		return (a.second > b.second) || ((a.second == b.second) && a.first > b.first);
	}
vector<pii> g;
int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
#endif
	int n; sf(n);
	f(i, 1, n) {
		int tmp; sf(tmp);
		a[tmp][i % 2 == 0]++;
	}
	f(i, 1, 1e5) {
		g.push_back({ i,a[i][0] });
		g.push_back({ i,a[i][1] });
	}
	sort(g.begin(), g.end(),cmp);
	if (g[0].first == g[1].first)cout <<n-( g[0].second + g[2].second);
	else cout << n-(g[1].second + g[0].second);
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=1e9;
const double eps=1e-9;
const int maxn=2e5+10;
int a[maxn],b[maxn];
int n,ans=0;
inline int read(){
	int x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
int calc(int val){
	int num=0;
	for(int l=1,r=n;l<=n;l++){
		while(r && a[l]+b[r]>=val)--r;
		num^=(n-r)&1;
	}
	return num;
}
int main(){
	int i,j,k,m;
	n=read();
	for(i=1;i<=n;i++)a[i]=read();
	for(i=1;i<=n;i++)b[i]=read();
	for(i=28;i>=0;i--){
		for(j=1;j<=n;j++){
			a[j]&=((1<<(i+1))-1);
			b[j]&=((1<<(i+1))-1);
		}
		sort(a+1,a+n+1),sort(b+1,b+n+1);
		int x=calc(1<<i)^calc(2<<i)^calc(3<<i);
		ans|=x*(1<<i);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1792
<?php
fscanf(STDIN, "%d", $n);
$w = explode(" ", trim(fgets(STDIN)));
$sum1 = array_sum($w);
$sum2 = 0;
$ans = 1e9;
for ($i = 0; $i < $n; $i++) {
  $sum2 += $w[$i];
  $ans = min($ans, abs($sum2 * 2 - $sum1));
}
echo $ans;
?>

Measured memory_bytes: 4728
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  vector<int> b;
  b.push_back(a[0]);
  for(int i = 1; i < n; i++){
    if(i % 2 == 1) b.push_back(a[i]);
    else b.insert(b.begin(), a[i]);
  }
  if(n % 2 == 1){
    for(int i = 0; i < n; i++){
      cout << b[i] << " ";
    }
    cout << endl;
  }
  else{
    for(int i = n - 1; i >= 0; i--){
      cout << b[i] << " ";
    }
    cout << endl;
  }
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 3828
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			if (h == 0 && w == 0)
				break;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					System.out.print("#");
				}
				System.out.printf("\n");
			}
			System.out.printf("\n");
		}
	}

}



Measured memory_bytes: 38036
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, a[100000];
int cnt = 1;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i&&a[i - 1] >= a[i])cnt++;
	}
	cout << cnt << endl << n << endl;
}



Measured memory_bytes: 3904
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>  //setprecision(桁)
using namespace std;
#define pb push_back
#define ll long long int
#define rep(i,n) for(int i = 0;i < (n);i++)
ll INF = 1000000010; 
const ll MOD = 1000000007;


int main(){ 
    int a, b, c, x, ans = 0;
    cin >> a >> b >> c >> x;
    rep(i,a+1) rep(j,b+1) rep(k,c+1) if(500 * i + 100 * j + 50 * k == x) ans++;

    cout << ans << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    double R;cin>>R;
    cout<<setprecision(25)<<2.0*R*M_PI<<endl;
}



Measured memory_bytes: 3848
while True:
	num=input().split()
	count=1
	h=int(num[0])
	w=int(num[1])
	if h==0 and w==0:
		break
	else:
		for i in range(h):
			if count%2!=0:
				if w%2!=0:
					print('#'+('.#'*int((w-1)/2)))
				else:
					print('#.'*int(w/2))
				count+=1
			else:
				if w%2!=0:
					print('.'+('#.'*int((w-1)/2)))
				else:
					print('.#'*int(w/2))
				count+=1
	print('')


Measured memory_bytes: 5616
# coding: utf-8
N = int(input())
H = list(map(int, input().split()))
flag = True
for i in range(1, N):
    if H[i] < H[i-1]:
        flag = False
        break
    else:
        if H[i-1] < H[i]:
            H[i] -= 1
print("Yes" if flag else "No")

Measured memory_bytes: 14396
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
typedef double db;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 105;
queue<int >st1[55];
int main()
{
	int n , m;
	int arr[55] , brr[55];
	cin >> n >> m;
	for(int i = 1 ; i <= m ; i++)
	{
		cin >> arr[i] >> brr[i];
		st1[arr[i]].push(brr[i]);
		st1[brr[i]].push(arr[i]);
	}
	for(int i = 1; i <= n ; i++)
	{
		cout << st1[i].size() << endl;
		}
	return 0;
	}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

unsigned long long f(unsigned long long x)
{
	switch(x%4){
		case 0:
			return x;
		case 1:
			return x^(x-1);
		case 2:
			return x^(x-1)^(x-2);
		case 3:
			return 0;
		default:
			abort();
	}
}

int main()
{
	unsigned long long a, b;
	scanf("%llu %llu", &a, &b);
	printf("%llu\n", f(b)^f(a-1));
	return 0;
}


Measured memory_bytes: 128
from math import factorial
# 素因数分解
def f(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())

mod = 10**9+7
fn = factorial(n)
# f = f(fn)
cnt = [0] * (n+1)

for i in range(1, n+1):
    # cnt[f[i][0]] += f[i][1]
    F = f(i)
    for j in range(len(F)):
        cnt[F[j][0]] += F[j][1]

ans = 1
for i in range(2, len(cnt)):
    ans *= cnt[i] + 1
    ans %= mod

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int h[101],ans;

int main(){
  int l,r,n;
  
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  
  for(l=0,r=0;l<n || h[n-1]!=0;ans++){
    
    for(l=0;l<n && h[l]==0;l++){}
    for(r=l;r<n && h[r]!=0;r++){
      h[r]--;
    }
    
    //cout << ans << " : ";
    //for(int i=0;i<n;i++) cout << h[i] << " ";
    //cout << endl;
  }
  
  cout << ans-1 << endl;
  
  return 0;
}

Measured memory_bytes: 256
# import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
# import collections # queue
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    n = int(input())
    ans = 1
    for i in range(1,n+1):
        ans *= i
        ans %= mod
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N, M;
    cin >> N >> M;
    vector<vector<int> > work(M+1,vector<int>(0));
    priority_queue<int> que;

    for(int i=0; i<N; i++){
        int A,B;
        cin >> A >> B;
        if(A>M)continue;
        work[A].push_back(B);
    }

    long long ans=0;
    for(int i=1; i<=M; i++){
        for(int j=0; j<work[i].size(); j++){
            que.push(work[i][j]);
        }
        if(que.size()==0)continue;
        ans+=(long long) que.top();
        que.pop();
        //cout << ans << endl;
    }

    cout << ans << endl;


}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define ll long long 

const int maxn = 3e5 + 10;
const int mod = 1e9 + 7;

int n;
ll a[maxn];
int cnt[maxn][60],sum[maxn][60];

int main()
{	
	
	std::ios::sync_with_stdio(false);cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		for(int j = 0; j < 60; j++){
			cnt[i][j] = ((a[i] >> j) & 1ll);
		}
	}
	//cout << cnt[0][1] << " " << cnt[1][1] << " " << cnt[2][1] << endl;
	ll ans = 0;
	for(ll i = 0; i < 60; ++i){
		for(int j = n - 1; j >= 0; --j){
			sum[j][i] = sum[j + 1][i] + cnt[j + 1][i];
		}
		//if(i == 0) cout << sum[0][0] << endl;
		//if(i == 1) cout << sum[0][1] << endl;
		for(int j = 0; j < n - 1; ++j){
			if(cnt[j][i] == 0) {
				ans = (ans + 1ll * sum[j][i] * ((1ll << i) % mod) % mod) % mod;
			}
			else {
				ans = (ans + 1ll * (n - sum[j][i] - 1 - j) * ((1ll << i) % mod) % mod) % mod;
			}
			//cout << j << " " << i << " " <<  ans << endl;
		}
	}
	//assert(ans < 0);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 143232
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    cout << (a*b % 2 == 0 ? "Even" : "Odd") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>

int main(void){
    int n, a, x, y;

    std::cin >> n;
    std::vector<std::vector<std::pair<int, int>>> st(n);
    std::set<int> ss;

    for(int i = 0; i < n; i++){
	std::cin >> a;
	for(int j = 0; j < a; j++){
	    std::cin >> x >> y;
	    x--;
	    st[i].push_back(std::make_pair(x, y));
	}
    }

    bool f;
    int ans = 0;
    int cnt;
    for(int i = 0; i < 1<<n; i++){
	f = true;
	ss.clear();
	for(int j = 0; j < n; j++){
	    if(i & (1<<j)){
		ss.insert(j);
	    }
	}
	for(auto j = ss.begin(); j != ss.end(); j++){
	    for(int k = 0; k < st[*j].size(); k++){
		int tx = st[*j][k].first;
		int ty = st[*j][k].second;
		if(ty == 0 && ss.find(tx) != ss.end()){
		    f = false;
		    break;
		} 
		if(ty == 1 && ss.find(tx) == ss.end()){
		    f = false;
		    break;
		} 
	    }
	} 
	if(f){
	    int size = ss.size();
	    ans = std::max(ans, size);
	} 
    }
    std::cout << ans << std::endl;
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll n,a,b;
vector<ll> s(100001);

bool C(ll mid){
	ll bb = b*mid;
	ll cnt = 0;
	rep(i,n){
		if(s[i] - bb <= 0)continue;
		cnt += (s[i] - bb)/(a-b) + ((s[i] - bb)%(a-b) != 0);
	}
	return cnt <= mid;
}

int main(){
	cin >> n >> a >> b;
	ll ma = 0;
	rep(i,n)cin >> s[i];
	ll lb = 0,ub = 1e9;
	while(ub - lb > 1){
		ll mid = (ub+lb)/2;
		if(C(mid))ub = mid;
		else lb = mid;
	}
	cout << ub << endl;
}

Measured memory_bytes: 1024
/*BY-ADITYA OJHA
  LEARN DSA SINCERELY*/
#include <bits/stdc++.h>
#define ll long long int
#define forin for(int i=0;i<n;i++)
#define forjn for(int j=0;j<n;j++)
#define pb push_back
#define vx vector<ll> x
#define fas1  ios_base::sync_with_stdio(false)
#define fas2   cin.tie(NULL)
using namespace std;


int main()
{
     fas1;
     fas2;
     ll n;
     cin>>n;
     ll a[n];
     forin cin>>a[i];
     ll flag=0;
     forin
     {
        if(a[i]%2==0 &&a[i]%3!=0 && a[i]%5!=0)
        {
          cout<<"DENIED"<<endl;
          return 0;

            }

     }
     cout<<"APPROVED"<<endl;

     return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define Set set<int>
#define int long long
#define P pair<int,int>
const int maxn = 1e5+5;
const int INF = 1e17 +6;
using namespace std;
int n,m,a[maxn],b[maxn],c[maxn],ans;
const int tt=1e9+7;
#define mod(x) ((x)%tt)
int32_t main()
{
    IOS;
    cin>>n>>m;
    fu(i,1,m)
    {
        int x;
        cin>>x;
        a[x]=1;
    }
    if(!a[1] && !a[2]){
        b[1]=1;
        b[2]=2;
    }else if(a[1] && !a[2])
    {
        b[2]=1;
    }else if(!a[1] && a[2])
    {
        b[1]=1;
    }
    fu(i,3,n)
    {
        if(a[i])continue;
        b[i]=b[i-1]+b[i-2];
        b[i]=mod(b[i]);
    }
    cout<<mod(b[n]);
    return 0;
}


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

int main(){
    int N, X, m[101];
    cin >> N >> X;
    int S = 0, M = 1001001001;
    for(int i = 0; i < N; i++){
        cin >> m[i];
        S += m[i];
        if(m[i] < M){
            M = m[i];
        }
    }
    int ans = N + (X - S) / M;
    cout << ans << endl;
    return 0;
}

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

main(){
  int N, K, x, ans=0;
  cin >> N >> K;
  
  for(int i=0; i<N; i++){
    cin >> x;
    if(x <= K-x){
      ans += x*2;
    }
    else{
      ans += (K-x)*2;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    int n = 0;
    while(n*n <= N){
        n++;
    }
    --n;
    cout << n*n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define mod 1000000007
#define len length()
double doINF = 1.0/0.0 ;
ostream_iterator <int> outp(cout," ");
//copy(v.beg,v.en,outp);
inline ll modadd(ll n,ll m){
    ll sum = ((n+m)%mod+mod)%mod;
    return sum;
}
 
inline ll modsub(ll n,ll m){
    ll diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}
 
inline ll modpro(ll n,ll m){
    ll pro = ((n*m)%mod+mod)%mod;
    return pro;
}

inline ll pow(int x,int y){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}

inline ll powmod(ll x,ll y){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x);
        y = y >> 1;
        x = modpro(x , x);
    }
    return res;
}
ll min(ll a, ll b){
    if(a>b){
        return b;
    }
    return a;
}

bool pairdec(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 		if(a.fi!=b.fi)
       	return (a.fi> b.fi);
		else return a.se>b.se;  
} 
int main()
{	
	ll n,w;
	cin>>n>>w;
	ll arr[n][2];
	forl(i,0,n)
	{
		forl(j,0,2) cin>>arr[i][j];
	}
	ll dp[n+1][w+1]={};
	
	forl(i,0,n+1)
	{	
		forl(j,0,w+1)
		{
				if(i==0 || j==0) 
				{
					dp[i][j]=0;
				}
				else if(j>=arr[i-1][0])dp[i][j]=max(dp[i-1][j-arr[i-1][0]]+arr[i-1][1],dp[i-1][j]);
				else dp[i][j]=dp[i-1][j];
			}		
	}
	
	cout<<dp[n][w]<<endl;
}

Measured memory_bytes: 79104
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

//?°???\????????????????????????
int main(){
	int n;
	cin >> n;
	int ans = 0;
	if(n==0)
		ans = 1;
	else if(n==1)
		ans = 2;
	else if(n==2)
		ans = 1;
	else
		ans = 0;
	cout << ans << endl;
}

Measured memory_bytes: 1164
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    V vec(n);
    rep(i, n) cin >> vec[i];
    sort(all(vec));
    cout << vec.back() << " ";
    ll k = lower_bound(all(vec), vec.back() / 2)-vec.begin();
    ll s1 = vec[k];
    if(k!=0){
        if (abs(vec[k - 1] - vec.back() / 2) < abs(vec[k] - vec.back() / 2)){
            s1 = vec[k - 1];
        }
        if(s1==vec.back()){
            s1=vec[vec.size()-2];
        }
    }
    cout << s1 << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1 << 20;

typedef long long ll;




int main(){
  int h,w;
  cin >> h >> w;
  string s[h];
  int num[26] = {0};
  REP(i,h){
    cin >> s[i];
    REP(j,w){
      num[s[i][j]%26]++;
    }
  }
  int four = 0,two = 0,one = 0;
  if(h%2 == 0 && w%2 == 0){
    four = h*w/4;
  }
  else if(h%2 == 1 && w%2 == 1){
    four = (h-1)*(w-1)/4;
    two = (h-1)/2 + (w-1)/2;
    one = 1;
  }
  else{
    if(h%2 == 1){
      four = (h-1)*w/4;
      two = w/2;
    }
    else{
      four = h*(w-1)/4;
      two = h/2;
    }
  }
  REP(i,26){
    four -= num[i]/4;
    num[i] = num[i]%4;
    if(four < 0){
      num[i] += 4*abs(four);
      four = 0;
      break;
    }
  }
  REP(i,26){
    two -= num[i]/2;
    num[i] = num[i]%2;
    if(two < 0){
      num[i] += 2*abs(two);
      two = 0;
      break;
    }
  }
  REP(i,26){
    one -= num[i];
    num[i] = 0;
    if(one < 0){
      num[i] += abs(one);
      one = 0;
      break;
    }
  }
  bool f = true;
  REP(i,26){
    if(num[i] > 0)
      f = false;
  }
  if(f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 384
/* ex4_2
   UMAboogie */

#include<stdio.h>
#include<math.h>
#define PI 3.14159265358979 //円周率を定義

int main(void){
  int length_h, length_m, hour, minute;
  scanf("%d %d %d %d", &length_h, &length_m, &hour, &minute); //時針の長さと分針の長さと時間と分を入力

  double angle_h = hour * PI / 6 + minute * PI / 360; //時針が進む角度を計算
  double angle_m = minute * PI / 30; //分針が進む角度を計算
  double angle_bet = fabs(angle_h - angle_m); //時針と分針の間の角度を計算

  double answer = sqrt(length_h*length_h + length_m*length_m - 2*length_h*length_m*cos(angle_bet)); //余弦定理を用いて2本の針の端点の距離を計算
  printf("%.10f",answer); //答えを出力(小数点以下10桁まで表示)
  return 0;
}


Measured memory_bytes: 2604
#include<stdio.h>
int main(){
	int data[5]={0};
	int i,ave=0;
	for(i=0;i<5;i++){
		scanf("%d",&data[i]);
		if(data[i]<40){
			data[i]=40;
		}
		//printf("data[%d]=%d\n",i,data[i]);
		ave += data[i];
	}
	//printf("sum=%d\n",ave);
	ave = ave/5;
	printf("%d\n",ave);

	return 0;
}

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

ll n;
ll a[3005];
ll dp[3005][3005];

ll solve(int i, int j){
    if(i>j)
        return 0;
    
    if(dp [i][j] != -1) 
        return dp[i][j];

    ll op1 = a[i] - solve(i+1,j);
    ll op2 = a[j] - solve(i,j-1);

    return dp[i][j] = max(op1,op2);
}
int main() {
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    memset(dp,-1,sizeof dp);
    cout<<solve(0,n-1);
}


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

using namespace std;

int main(){
  long long n,a,b; cin >>n >>a >>b;
  if(n - (n/(a+b))*(a+b)>a)
  {cout << (n/(a+b))*a + a;}
  else{cout << n - (n/(a+b))*b;} 
return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<vector<pii>> G(N);
    rep(i,N) {
        int A; cin >> A;
        rep(j,A) {
            int x,y; cin >> x >> y;
            --x;
            G[i].emplace_back(x,y);
        }
    }

    int ans = 0;
    rep(mask,1<<N) {
        bitset<15> s(mask);
        bool ok = true;
        rep(i,N) {
            if (s.test(i)) {
                for (auto j : G[i]) {
                    if (j.second && !s.test(j.first)) ok = false;
                    if ((1-j.second) && s.test(j.first)) ok = false;
                }
            }
        }
        int val = s.count();
        if (ok) chmax(ans,val);
    }

    cout << ans << ln;
}

Measured memory_bytes: 256
import java.awt.geom.*;
import java.io.*;
import java.util.*;
public class Main {
	
	//0115 start
	//0130 cording end
	
	int n;
	int [][][] data;
	boolean ans ;
	int [] vx = {0,0,1,0,-1};
	int [] vy = {0,1,0,-1,0};
	int [] dx = {0,0,1,1};
	int [] dy = {0,1,0,1};
	HashSet<String> close;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			n = sc.nextInt();
			if(n == 0)break;
			data = new int[n][4][4];
			for(int i  =0; i < n; i++){
				for(int j = 0; j < 4; j++){
					for(int k = 0; k < 4; k++){
						data[i][j][k] = sc.nextInt();
					}
				}
			}
			
			ans = false;
			boolean first = false;
			close = new HashSet<String>();
			for(int i = 0; i < dx.length; i++){
				if(data[0][1 + dy[i]][1 + dy[i]] == 1){
					first = true;
					break;
				}
			}
			if(first){
				System.out.println(0);
				continue;
			}
			dfs(1,1,1,6,6,6,6);
			
			System.out.println(ans ? 1 : 0);
		}
	}

	int max = 0;
	
	private void dfs(int deep, int x, int y, int lt, int lb, int rt, int rb) {
		if(deep == n){
			ans = true;
			return;
		}
		
		for(int i = 0; i < vx.length; i++){
			for(int j = 1; j <= 2; j++){
				int xx = x + vx[i] * j;
				int yy = y + vy[i] * j;
				if(! isOK(xx, yy))continue;
				boolean flg = true;
				for(int  k = 0; k < dx.length;k++){
					int xxx = xx + dx[k];
					int yyy = yy + dy[k];
					if(data[deep][yyy][xxx] == 1){
						flg = false;
						break;
					}
				}
				if(! flg)continue;
				
				int nlt = lt-1, nlb = lb-1, nrt = rt-1, nrb = rb-1;
				if(xx == 0 && yy == 0){
					nlt = 7;
				}
				if(xx == 0 && yy == 2){
					nlb = 7;
				}
				if(xx == 2 && yy == 0){
					nrt = 7;
				}
				if(xx == 2 && yy == 2){
					nrb = 7;
				}
				
				if(nlt == 0 || nlb == 0 || nrt == 0 || nrb == 0) continue;
				String next = (deep+1) + " " + xx+yy+nlt+nlb+nrt+nrb;
				if(close.contains(next)) continue;
				close.add(next);
				dfs(deep +1, xx,yy, nlt, nlb, nrt, nrb);
			}
		}
	}

	private boolean isOK(int xx, int yy) {
		if(0<= xx && xx < 3 && 0<= yy && yy < 3){
			return true;
		}
		return false;
	}

	public static void main(String [] args){
		new Main().doit();
	}
}

Measured memory_bytes: 19000
N = int(input())
P = [i for i in map(int,input().split())]
check = 0
Model = [i for i in range(1,N+1)]
for i in range(N):
  if P[i] != Model[i]:
    check += 1
if check > 2:
  print('NO')
else:
  print('YES')
    


    
   
       

Measured memory_bytes: 3064
a, b, c, x, y = map(int, input().split())
if (a+b) < 2*c:
    print(a*x + b*y)
else:
    if x >= y:
        if a <= 2*c:
            print(2*c*y + a*(x-y))
        else:
            print(2*c*x)
    else:
        if b <= 2*c:
            print(2*c*x + b*(y-x))
        else:
            print(2*c*y)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define PI 2 * acos(0.0)
#define MAX 1000000
#define INF 1000000 
#define M 1000000007
using namespace std;
/*
bool isPowerOfTwo(ll x){
    return (x && !(x & (x - 1)));
}
// counts no. of 1 in binary representation
ll count_one (ll n){
    ll count = 0;
    while( n ){
        n = n&(n-1);
        count++;
    }
    return count;
}
// checks ith bit is set 
bool is_bit_set(ll n ,ll i){
    if( n & (1<<i) ){
        return true;
    }
    else{
        return false;
    }
}
// generating subset using bit technique ; n -> no. of elements
void subset(char a[], ll n){
   for(ll i = 0;i < (1<<n);i++){
         for(ll j = 0;j<n;j++){
             if(i & (1 << j)){
                 cout<<a[j]<<" ";
             }
         }
         cout<<endl;
   }
}
// Properties  of Modular:
//  1. (a+b)%c = (a%c + b%c)%c
//  2. (a*b)%c = (a%c * b%c)%c
//  3. (a-b)%c = (a%c - b%c)%c
//  4. (a/b)%c = ((a%c) * ( inverse(b)%c ))%c

ll binaryExponentiation(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=result * x;
        x=x*x;
        n=n/2;
    }
    return result;
}
ll modularExponentiation(ll x,ll n,ll m)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%m;
        x=(x*x)% m;
        n=n/2;
    }
    return result;
}
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else{
        return gcd(b,a%b);
    }
}
ll d, x, y;
void extendedEuclid(ll A, ll B) {
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else {
        extendedEuclid(B, A%B);
        ll temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}
// when a and m are co prime
ll modInverse(ll A, ll m){
    extendedEuclid(A,m);
    return (x%m+m)%m;   
}
ll countDivisors(ll n) 
{ 
    int cnt = 0; 
    for (int i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) 
                cnt++; 
            else 
                cnt = cnt + 2; 
        } 
    }
    return cnt; 
} 
*/
int main(){
    FAST
    string s;
    cin>>s;
    ll ans = 0;
    ll sum = 0;
    for(ll i = 0;i<s.length();i++){
        if(s[i] == 'R'){
            ans++;
        }
        else{
            sum = max(sum,ans);
            ans = 0;
        }
    }
    sum = max(ans,sum);
    cout<<sum<<endl;
   return 0;
}

Measured memory_bytes: 3644
n=int(input())
cnt=0
data=[[0 for j in range(10)] for i in range(10)]
for ii in range(1,n+1):
    i=str(ii)
    if i[-1]!=0:
        data[int(i[-1])][int(i[0])]+=1

for i in range(9):
    for j in range(9):
        cnt+=data[i+1][j+1]*data[j+1][i+1]
print(cnt)

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef pair<int, pii > piii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N;
int a[100100];
vector<int> V;

signed main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        V.push_back(a[i]);
    }
    sort(V.begin(), V.end());
    if(V[(int)V.size() - 1] == 0){
        printf("Yes\n");
        return 0;
    }
    V.erase(unique(V.begin(), V.end()), V.end());
    if((int)V.size() > 3 || (int)V.size() < 2){
        printf("No\n");
        return 0;
    }
    V.push_back(V[1]);
    if((V[0]^V[1]) == V[2]){
        V.pop_back();
        int b[3] = {0};
        for(int i = 0; i < N; i++){
            if(a[i] == V[0]){
                b[0]++;
            }
            else if(a[i] == V[1]){
                b[1]++;
            }
            else if((int)V.size() > 2){
                if(a[i] == V[2]){
                    b[2]++;
                }
            }
        }
        if((int)V.size() > 2){
            if(b[0] == b[1] && b[1] == b[2]){
                printf("Yes\n");
                return 0;
            }
            else {
                printf("No\n");
                return 0;
            }
        }
        else {
            if(b[0] * 2 == b[1]){
                printf("Yes\n");
                return 0;
            }
            else {
                printf("No\n");
                return 0;
            }
        }
    }
    else {
        printf("No\n");
        return 0;
    }



    return 0;
}

/*

*/

Measured memory_bytes: 1148
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

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

    int n;
    cin >> n;

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

    vector<pair<int, int>> ca(n);
    vector<pair<int, int>> cb(n);
    for (int i = 0; i < n; i++)
    {
        ca[i] = {a[i], i};
        cb[i] = {b[i], i};
    }

    sort(ca.begin(), ca.end());
    sort(cb.begin(), cb.end());

    for (int i = 0; i < n; i++)
        if (ca[i].first > cb[i].first)
        {
            cout << "No\n";
            return 0;
        }

    for (int i = 0; i < n - 1; i++)
        if (ca[i].first <= cb[i + 1].first && ca[i + 1].first <= cb[i].first)
        {
            cout << "Yes\n";
            return 0;
        }

    vector<int> p(n);
    for (int i = 0; i < n; i++)
        p[ca[i].second] = cb[i].second;

    int x = p[0];
    int cnt = 1;

    while (x != 0)
    {
        cnt++;
        x = p[x];
    }

    if (cnt == n)
        cout << "No\n";
    else
        cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 2944
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;

namespace kyoupuro {

    class MainClass {
        
        public static void Main() {
            var N = NextLong();
            var M = NextLong();

            if(N == 2 || M == 2) {
                Console.WriteLine(0);
            } else if(N == 1 && M == 1) {
                Console.WriteLine(1);
            } else if(N == 1) {
                Console.WriteLine(M - 2);
            } else if(M == 1) {
                Console.WriteLine(N - 2);
            } else {
                Console.WriteLine((N - 2) * (M - 2));
            }
        }
    }

    class MyMath {
        static long Gcd(long a, long b) {
            return b == 0 ? a : Gcd(b, a % b);
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 13268
ans = 0
while True :
    try :
        s = list(input())
    except EOFError :
        break
    
    pal = "True"
    for i in range(len(s)//2) :
        if s[i] != s[-i-1] :
            pal = "False"
            break
    if pal == "True" :
        ans += 1
print(ans)


Measured memory_bytes: 5556
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>

using namespace std;
typedef long long ll;

int N, M;
vector<ll> A;
ll num[9] = {2,5,5,4,5,6,3,7,6};

int main(){
    cin >> N >> M;

    ll t = 0;
    for(ll i = 0; i < M; i++){
        cin >> t;
        A.push_back(t);
    }
    sort(A.rbegin(),A.rend());

    vector<ll > dp(N + 1, -1);
    dp[0] = 0;

    //最大桁数
    int flag = 0;
    for(ll i = 0; i < N; i++){
        if(dp[i] > -1){
            for(ll j = 0; j < A.size(); j++){
                if(i + num[A[j]-1] <= N && dp[i + num[A[j]-1]] < dp[i] + 1){
                    dp[i + num[A[j]-1]] = dp[i] + 1;    
                }
            }   
        }
    }
    ll mx = dp[dp.size() - 1];

    //たどる
    string ans;
    for(ll i = 1; i <= mx; i++){
        for(ll j = 0; j < A.size(); j++){
            if((dp[N - num[A[j]-1]]) == (mx - i) && N >= num[A[j]-1]){
                //cout << j << ":" << mx - i << ":" << dp[N - num[A[j]-1]] << ":" << A[j] << endl;
                ans += to_string(A[j]);
                N = N - num[A[j]-1];
                break;
            }
        }
    }

    /*
    for(ll i = 0; i < dp.size(); i++){
        cout << dp[i] << " ";
    }
    cout << endl;
    */
    
    

    //cout << dp[dp.size() - 1] << endl;
    cout << ans << endl;
    


    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Text;

namespace ITP1_11_A
{
	class Program
	{
		static void Main(string[] args)
		{
			string s1 = Console.ReadLine();
			string s2 = Console.ReadLine();
			string[] str = s1.Split();
			int[] faces = new int[6];
			for (int i = 0; i < 6; i++) {
				faces[i] = int.Parse(str[i]);
			}
			Dice d = new Dice(faces);
			foreach (char c in s2) {
				switch (c) {
				case 'N':
					d.MoveN();
					break;
				case 'S':
					d.MoveS();
					break;
				case 'E':
					d.MoveE();
					break;
				case 'W':
					d.MoveW();
					break;
				}
			}
			Console.WriteLine(d.Top);
		}
	}

	class Dice
	{
		public int Top { get; private set; }
		public int North { get; private set; }
		public int South { get; private set; }
		public int East { get; private set; }
		public int West { get; private set; }
		public int Bottom { get; private set; }
		public Dice(int[] faces)
		{
			Top = faces[0];
			North = faces[4];
			South = faces[1];
			East = faces[2];
			West = faces[3];
			Bottom = faces[5];
		}
		public void MoveN()
		{
			// T<-S<-B<-N<-T
			int tmp = Top;
			Top = South;
			South = Bottom;
			Bottom = North;
			North = tmp;
		}
		public void MoveS()
		{
			// T<-N<-B<-S<-T
			int tmp = Top;
			Top = North;
			North = Bottom;
			Bottom = South;
			South = tmp;
		}
		public void MoveE()
		{
			// T<-W<-B<-E<-T
			int tmp = Top;
			Top = West;
			West = Bottom;
			Bottom = East;
			East = tmp;
		}
		public void MoveW()
		{
			// T<-E<-B<-W<-T
			int tmp = Top;
			Top = East;
			East = Bottom;
			Bottom = West;
			West = tmp;
		}
	}
}

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

int main(void){
  int x,a; cin >> x >> a;
  if(x < a) cout << 0 << endl;
  else cout <<10<< endl;
  return 0;
}


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

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

Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e18;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

vector<Pa> ans;

int main() {
	ll md = 0, range = 0;
	cin >> Q;
	ll cnt = 0;
	while (A != 1 && cnt != Q) {
		cin >> A;
		if (A == 1) {
			cin >> B >> C;
			md = B;
			range += C;
		}
		else {
			ans.push_back(Pa(0, 0));
		}
		cnt++;
	}
	priority_queue<ll> lower;
	priority_queue<ll, vector<ll>, greater<ll>> upper;
	for (int i = cnt; cnt < Q; cnt++) {
		cin >> A;
		if (A == 1) {
			cin >> B >> C;
			if (md < B) {
				upper.push(B);
				if (upper.size() - lower.size() > 1) {
					int prev = md;
					lower.push(md);
					md = upper.top(); upper.pop();
				}
				range += abs(md - B);
			}
			else {
				lower.push(B);
				if (lower.size() - upper.size() > 0) {
					int prev = md;
					upper.push(md);
					md = lower.top(); lower.pop();
					range += abs(md - prev);
				}
				range += abs(md - B);
			}
			range += C;
		}
		else {
			ans.push_back(Pa(md, range));
		}
	}
	rep(i, ans.size()) {
		cout << ans[i].first << " " << ans[i].second << endl;
	}
}


Measured memory_bytes: 5748
MOD = 10**9 + 7
max = 10**5 + 1
facts = [1 for i in range(max)]
invs = [1 for i in range(max)]

def inv(x):
    return pow(x,MOD-2,MOD)

for i in range(1,max):
    facts[i] = facts[i-1]*i%MOD
    invs[i] = inv(facts[i])

def comb(n,r):
    return facts[n]*invs[r] * invs[n-r] % MOD

n,m = map(int,input().split())
if m > n:
    n,m = m,n
if n-m >= 2:
    print(0)
elif n-m == 1:
    print(facts[m]*facts[n] % MOD)
else:
    print(facts[m]*facts[n]*2 % MOD)

Measured memory_bytes: 11068
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n, m, l, r;
    cin >> n >> m >> l >> r;

    int lmax = l, rmin = r;
    for (int i = 1; i < m; i++) {
        cin >> l >> r;
        lmax = max(l, lmax);
        rmin = min(r, rmin);
    }

    cout << max(0, rmin - lmax + 1) << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();
        int N = r.i();
        String[] s = r.ss();
        int b = 0;
        for(String a : s)
            b ^= Int(a);
        println(b == 0 ? "Yes" : "No");
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 35028