akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>


#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;



int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

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

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int D;
ll G;
vector<ll> P, C;

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

	cin >> D >> G;
	P.resize(D);
	C.resize(D);
	rep(i, 0, D) {
		cin >> P[i] >> C[i];
	}

	ll res = 1 << 29;
	rep(bit, 0, (1 << D)) {
		ll sum = 0;
		ll num = 0;
		rep(i, 0, D) {
			if (bit & (1 << i))sum += C[i] + P[i] * 100 * (i + 1), num += P[i];
		}
		if (sum >= G) {
			res = min(res, num);

		}
		else {
			rrep(i, D - 1, 0) {
				if (bit & (1 << i))continue;
				rep(j, 0, P[i]) {
					if (sum >= G)break;
					sum += 100 * (i + 1);
					num++;
				}
			}
			res = min(res, num);

		}

	}
	
	cout << res << endl;


}
	

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

namespace AtCoder2020Ned
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ');
            var monster = new Monster(int.Parse(inputs[0]));
            var ultimate = Console.ReadLine().Split(' ');
            var ultimateAtk = new int[ultimate.Length];

            foreach (var item in ultimate.Select((atk, index) => new { Atk = atk, Index = index }))
            {
                ultimateAtk[item.Index] = int.Parse(item.Atk);
            }

            var raccoon = new Raccoon(int.Parse(inputs[1]), ultimateAtk);
            var result = CanRaccoonBeat(raccoon, monster);

            Console.WriteLine(result ? "Yes" : "No");
            Console.Read();
        }

        static bool CanRaccoonBeat(Raccoon raccoon, Monster monster)
        {
            var maxRaccoonAtk = 0;
            foreach (var item in raccoon.Ultimate)
            {
                maxRaccoonAtk += item;
            }

            if (maxRaccoonAtk >= monster.HP)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }

    class Raccoon
    {
        public int HP { get; set; } = 0;
        public int[] Ultimate { get; set; }

        private Raccoon()
        {

        }

        public Raccoon(int hp, int[] ultimate) : base()
        {
            HP = hp;
            Ultimate = ultimate;
        }
    }

    class Monster
    {
        public int HP { get; set; } = 0;

        private Monster()
        {

        }

        public Monster(int hp) : base()
        {
            this.HP = hp;
        }
    }
}


Measured memory_bytes: 23776
S = input()
T = input()
length =len(S)
S = "".join(S)
T = "".join(T)
listS=list(S)
listT=list(T)
num = len(T)
res = 0
for i in range(length):
    if (listS[num-1] != listT[num-1]):
        res +=1
    num -=1
print(res)

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

int main(){
  int S,W;
  cin >> S >> W;
  if(W >= S)
    cout << "unsafe" << endl;
  else
    cout << "safe" << endl;
}

Measured memory_bytes: 3580
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[10012],ans=0,sum=0,n;
int main() {
	scanf("%lld",&n);
	for(int i=1;i<=2*n;i++) {
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+1+2*n);
	for(int i=1; i<=2*n; i+=2) {
		sum+=a[i];
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 256
/*
 * ABC095_B.cpp
 *
 *  Created on: May 21, 2018
 *      Author: 13743
 */
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}



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

	int N, X;
	cin >> N >> X;

	int m;
	int minM = 1<<30;
	int sumM = 0;
	REP(i, N) {
		cin >> m;
		sumM += m;
		minM = min(m, minM);
	}

	int ans = N;
	X -= sumM;
	while(X >= minM) {
		++ans;
		X -= minM;
	}

	cout << ans << endl;
}






Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if(s[0] == 'S') {
        cout << "Cloudy" << endl;
    } else if(s[0] == 'C') {
        cout << "Rainy" << endl;
    } else {
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 3508
using System;

namespace AtCoder
{
    class Curtain
    {
        static void Main(string[] args)
        {
            string line = System.Console.ReadLine();
            string[] stArrayData = line.Split(' ');
            int A = int.Parse(stArrayData[0]);
            int B = int.Parse(stArrayData[1]);

            int C = A - B * 2;

            if(C < 0)
            { 
                C = 0;
            }
            
            Console.WriteLine(C);
        }
    }
}


Measured memory_bytes: 11092
#include<map>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define mp make_pair
using namespace std;

map<pair<int,int>,int> m;

struct dsu
{
	int fa[200010],rank[200010];
	
	void init(int n)
	{
		for(int i=1;i<=n;i++)
		{
			fa[i]=i;
		}
	}
	
	int find(int x)
	{
		if(fa[x]==x)
		{
			return x;
		}
		return fa[x]=find(fa[x]);
	}
	
	void union_(int x,int y)
	{
		int fx=find(x);
		int fy=find(y);
		if(fx==fy)
		{
			return ;
		}
		if(rank[fx]<rank[fy])
		{
			fa[fx]=fy;
		}
		else
		{
			fa[fy]=fx;
			if(rank[fx]==rank[fy])
			{
				rank[x]++;
			}
		}
	}
	
	int same(int x,int y)
	{
		return find(x)==find(y);
	}
}a,b;

int main()
{
	//give the fucking vjudge a flying fucking
	int n,x,y;
	scanf("%d%d%d",&n,&x,&y);
	a.init(n);
	b.init(n);
	int from,to;
	for(int i=1;i<=x;i++)
	{
		scanf("%d%d",&from,&to);
		a.union_(from,to);
	}
	for(int i=1;i<=y;i++)
	{
		scanf("%d%d",&from,&to);
		b.union_(from,to);
	}
	for(int i=1;i<=n;i++)
	{
		m[mp(a.find(i),b.find(i))]++;
	}
	for(int i=1;i<=n;i++)
	{
		printf("%d ",m[mp(a.find(i),b.find(i))]);
	}
}

Measured memory_bytes: 13696
n = input()

if int(n[0]) > int(n[1]):
    print(n[0]+n[0]+n[0])
elif n[0] == n[1]:
    if n[1] == n[2]:
        print(n[0]+n[0]+n[0])
    elif int(n[1]) > int(n[2]):
        print(n[0]+n[0]+n[0])
    else:
        nn = int(n[0]) + 1
        print(str(nn)+str(nn)+str(nn) )
else:
    nn = int(n[0]) + 1
    print(str(nn)+str(nn)+str(nn) )

Measured memory_bytes: 3064
//Jai Shree Krishna
#include <bits/stdc++.h>
using namespace std;
#define  ll long long int
#define loop(i,n) for(int i =0 ;i<n;i+=1)
#define loop2(i,n) for(int i = 1;i<=n;i+=1)

vector<ll>x(5e5+100);
vector<ll>ds(5e5+100);
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);
    //equivalent to finding minimum number that can not be formed
    ll n,d;
    cin>>n>>d;
    loop(i,n)
    {
        cin>>x[i];
    }
    ds[0]  = d;
    loop(i,n)
    {
        ds[i+1] = min(ds[i],abs(ds[i]-x[i]));
    }
    vector<bool>res(n);
    ll b = 1;
    for(ll  i = n-1;i>-1;--i)
    {
        res[i] = (b<=ds[i]);
        if(x[i]<2*b)
        {
            b+=x[i];
        }
    }
    ll q;
    cin>>q;
    while (q--) {
        ll temp;
        cin>>temp;
        if(res[temp-1])
        {
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 11648
import java.util.*; 

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

  		long[] a=new long[n];
  		long ans=0;
		for(int c=0;c<n;c++){
    		a[c]=sc.nextInt();
            ans+=a[c]-1;
    	}
  

    	System.out.println(ans);
    }

}

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

a = list(map(int, input().split()))
ave = int(sum(a))/len(a)
total0, total1 = 0, 0
for i in a:
    total0 += (i-int(ave+1))**2
    total1 += (i-int(ave))**2
print(min(total0, total1))


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

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

    for (int i = 0; i < N - 1; i++) {
        if(D.at(i) < D.at(i + 1)){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
"use strict";
const Main = (input) =>{
	let xs = input.trim().split('\n');
    let N = parseInt(xs[0]);
    let str = xs[1];
    let count = 0;
    let ans = [];
    for(let i=0; i<N; i++){
    	if (str.charAt(i) == 'I') {
			count++;
		}else if(str.charAt(i) == 'D') {
			count--;
		} 
        ans.push(count);
    }
    let max = Math.max(...ans);
    
    if(max<0){
      console.log(0);
    }else{
      console.log(max);
    }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

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

int main()
{
    int N, Q, l, r;
    string S;
    cin >> N >> Q >> S;
    int tmp = 0;
    vector<int> list(N);

    for (int i = 1; i < N ; i++)
    {
        if (S[i - 1] == 'A' && S[i] == 'C')
            tmp++;

        list[i] = tmp;
    }

    for (int i = 0; i < Q; i++)
    {
        cin >> l >> r;
        cout << list[r - 1] - list[l - 1];
        if (i != Q - 1)
            cout << endl;
    }
}

Measured memory_bytes: 1408
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        ArrayList<Double> ald = new ArrayList<>();
        while(scn.hasNextDouble()) {
            ald.add(scn.nextDouble());
        }
        Collections.sort(ald);
        System.out.println(ald.get(ald.size() - 1) - ald.get(0));
    }
}

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

int main()
{
	int n;
	int a[1000] = { 0 };
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	bool suc = true;
	for (int i = 0; i < n; i++) {
		if (a[i] % 2 == 1)
			continue;
		else
		{
			if ((a[i] % 3 != 0) && (a[i] % 5 != 0)) {
				suc = false;
					break;
			}
		}
	}
	cout << (suc ? "APPROVED" : "DENIED") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll a,b,n;
int main()
{
	scanf("%lld %lld %lld",&a,&b,&n);
	if(n<b) printf("%lld\n",a*n/b);
	else printf("%lld\n",a*(b-1)/b);
	return 0;
}

Measured memory_bytes: 3824
#include <stdio.h>

int main(void)
{
	int a, b, c, d, e;
	scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
	int min = 10, time = 0;

	if ( (a % 10) && ( (a % 10) < min) ) min = a % 10;
	if ( (b % 10) && ( (b % 10) < min) ) min = b % 10;
	if ( (c % 10) && ( (c % 10) < min) ) min = c % 10;
	if ( (d % 10) && ( (d % 10) < min) ) min = d % 10;
	if ( (e % 10) && ( (e % 10) < min) ) min = e % 10;

	time += ( (a + 9) / 10 ) * 10; // 一の位で切り上げをする処理
	time += ( (b + 9) / 10 ) * 10;
	time += ( (c + 9) / 10 ) * 10;
	time += ( (d + 9) / 10 ) * 10;
	time += ( (e + 9) / 10 ) * 10;

	printf("%d\n", time - 10 + min);


	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

struct S {
  int w, h;
  bool operator<(const S& r) const { return w * h < r.w * r.h; }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  while (true) {
    int n, w, h; cin >> n >> w >> h;
    if (!w) break;
    V<S> v{S{w, h}};
    while (n--) {
      int p, s; cin >> p >> s, --p;
      s %= v[p].w + v[p].h;
      if (s < v[p].w) {
        S x{s, v[p].h}, y{v[p].w - s, v[p].h};
        if (y < x) swap(x, y);
        v.push_back(x);
        v.push_back(y);
      } else {
        s -= v[p].w;
        S x{v[p].w, s}, y{v[p].w, v[p].h - s};
        if (y < x) swap(x, y);
        v.push_back(x);
        v.push_back(y);
      }
      v.erase(begin(v) + p);
    }
    sort(begin(v), end(v));
    n = v.size();
    for (int i = 0; i < n; ++i) {
      cout << v[i].w * v[i].h << " \n"[!(n + ~i)];
    }
  }
}


Measured memory_bytes: 3240
#include "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999


int main(){
    int h,w;
    while(cin>>h>>w){
        string data[1200];
        rep(i,h) cin>>data[i];
        
        static int num[1200][1200]={};
        queue<pii> que;
        for(int i=1;i<h-1;i++){
            for(int j=1;j<w-1;j++){
                for(int x=-1;x<=1;x++){
                    for(int y=-1;y<=1;y++){
                        if(x==0&&y==0)continue;
                        if(data[i+y][j+x]=='.'){
                            num[i][j]++;
                        }
                    }
                }
            if(isdigit(data[i][j]) && num[i][j]>=data[i][j]-'0')que.push(pii(i,j));
            }
        }
        int c=1;
        queue<pii> a,b;
        a=que;
        while(1){
            int y=a.front().first, x=a.front().second;
            a.pop();
            data[y][x]='.';
            for(int k=-1;k<=1;k++){
                for(int l=-1;l<=1;l++){
                    if(k==0&&l==0)continue;
                    num[y+k][x+l]++;
                }
            }

            for(int i=-1;i<=1;i++){
                for(int j=-1;j<=1;j++){
                    if(i==0&&j==0)continue;
                    if( isdigit(data[y+i][x+j]) && num[y+i][x+j]==data[y+i][x+j]-'0'){
                        b.push(pii(y+i,x+j));
                    }
                }
            }
            if(a.empty()){
                if(b.empty())break;
                else{
                    a=b;
                    while(b.size())b.pop();
                    c++;
                }
            }
        }
        cout<<c<<endl;
        
    }
}

Measured memory_bytes: 6972
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    int a[n + 10], b[n + 10];
    int sum = 0;
    REP(i, n)
    {
        cin >> a[i + 1];
        b[i + 1] = 0;
    }

    for (int i = n; i >= 1; i--)
    {
        int mod = 0;
        for (int j = 2 * i; j <= n; j += i)
        {
            mod = (mod + b[j]) % 2;
        }
        b[i] = (a[i] + mod) % 2;
        sum += b[i];
    }
    cout << sum << endl;
    if (sum == 0)
        return 0;
    bool fst = true;
    for (int i = 1; i <= n; i++)
    {
        if (b[i] == 0)
            continue;
        if (fst)
        {
            cout << i;
            fst = false;
        }
        else
        {
            cout << " " << i;
        }
    }
    cout << endl;
}

Measured memory_bytes: 2432
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    long x;
    scanf("%ld", &x);

    ll i;
    for(i=1; i<100000; i++) {
        ll tmp = i*(i+1)/2;
        if(tmp>=x) {
            printf("%lld\n", i);
            return 0;
        }
    }


    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<long> A(N);
  for (int i=0;i<N;i++) {
    cin >> A.at(i);
  }
  
  sort(A.begin(), A.end());
  
  cout << A.at(N-1)-A.at(0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;


int main() {
    int n,x,y;
    cin >> n >> x >> y;
    --x; --y;
    vector<int> ans(n);
    int m=x+(y-x)/2;
    rep(i,n) {
        repr(j,i+1,n) {
            int c=min(j-i,abs(i-x)+abs(y-j)+1);
            ++ans[c];
        }
    }
    repr(i,1,n) cout << ans[i] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <deque>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin >> s;
	deque<char> smth;
	for (char c: s) smth.push_back(c);
	int F, Q, T;
	char c;
	cin >> Q;
	bool rev = false;
	for (int i = 0; i < Q; ++i) {
		cin >> T;
		if (T == 1) rev = !rev;
		else {
			cin >> F >> c;
			if (rev) F = 3 - F;
			if (F == 1) smth.push_front(c);
			else smth.push_back(c);
		}
	}
	if (rev) reverse(smth.begin(), smth.end());
	for (char c: smth) cout << c;
	return 0;
}

Measured memory_bytes: 976
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	int cnt4mul = 0;
	int cnt2mul = 0;
	for(int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		if( a % 2 == 0 && a % 4 != 0 ) cnt2mul++;
		if( a % 4 == 0 ) cnt4mul++;
	}
	
	if( cnt2mul == 0 ) {
		if( 2 * cnt4mul >= n - 1 ) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	} else {
		if( 2 * cnt4mul >= n - cnt2mul ) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
	
	return 0;
}


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

int main() {
  int ls;
  int h, m, s;
  cin >> ls;
  h = ls / (60 * 60);
  m = (ls - h * (60 * 60)) / 60;
  s = ls - h * (60 * 60) - m * 60;
  cout << h << ":" << m << ":" << s << endl;
}

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

ll nCr(ll n, ll r)
{
    ll num = 1;
    for (ll i = 1; i <= r; i++)
    {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int main()
{
    string s;
    cin >> s;
    ll n = s.length();
    reverse(s.begin(), s.end());

    //累積和
    vector<ll> rui(n);
    rui[0] = s[0] - '0';
    ll x = 10;
    rep(i, n - 1)
    {
        rui[i + 1] = rui[i] + (s[i + 1] - '0') * x;
        rui[i + 1] %= 2019;
        x = x * 10 % 2019;
    }

    map<ll, ll> M;
    rep(i, n)
    {
        M[rui[i]]++;
    }

    ll ans = 0;
    for (auto m : M)
    {
        ans += nCr(m.second, 2);
        if (m.first == 0)
            ans += m.second;
    }

    cout << ans << endl;
}

//なぜかだめ
//サンプルはおｋ

Measured memory_bytes: 5164
while True:
    c=0
    islands=[]
    islandsID=[]
    ID=0

    def dfs(row,col):
        global ID
        if 0<=row<12 and 0<=col<12:
            if islands[row][col]==1 and islandsID[row][col]==0:
                islandsID[row][col]=ID
                for dr, dc in [[0,1],[1,0],[0,-1],[-1,0]]:
                    dfs(row+dr,col+dc)

    for i in range(12):
        islands.append(list(int(k) for k in input()))
    for _ in range(12):
        islandsID.append([0 for i in range(12)])

    for i in range(12):
        for j in range(12):
            if islands[i][j]==1 and islandsID[i][j]==0:
                ID+=1
                dfs(i,j)
    print(ID)
    try:
        c=input()
    except:
        break


Measured memory_bytes: 5724
import sys

input = sys.stdin.readline
n = int(input())
adj_list = [[0]*n for _ in range(n)]
for _ in range(n):
    input_list = list(map(int, input().split()))
    u = input_list[0] - 1
    e_num = input_list[1]
    if e_num > 0:
        for i in range(e_num):
            adj_list[u][input_list[i+2] - 1] = 1

for adj in adj_list:
    print(' '.join(map(str, adj)))



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

#define MOD 1000000007

int main()
{
    long long n;
    cin>>n;
    long long i;
    long long ans=1e+18;
    for(i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            if(i+n/i<ans)ans = i+n/i;
        }
    }
    cout << ans-2 << endl;
}

Measured memory_bytes: 384
"""
import math
n=int(input())
a=list(map(int,input().split()))
m1=min(a)

def a_gcd(t,y):
    return math.gcd(t,y)

if m1==1:
    print(m1)
    exit()
for i in range(n):
    m1=a_gcd(m1,a[i])
    if m1==1:
        break

print(m1)
"""
import fractions
n=int(input())
a=list(map(int,input().split()))
m1=min(a)

def a_gcd(t,y):
    return  fractions.gcd(t,y)

if m1==1:
    print(m1)
    exit()
for i in range(n):
    m1=a_gcd(m1,a[i])
    if m1==1:
        break

print(m1)

Measured memory_bytes: 16280
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(i, a)  for (auto i : a)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define PI acos(-1)

template<class T>
bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }

template<class T>
bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

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

const int MOD = 998244353;
const ll oo = 1e18;
const int MX = 1e5 + 5, N = 2e5 + 5;

int n;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    int ans = 0;
    F0R(i, n) {
        int a;
        cin >> a;
        if (i % 2 == 0 and a % 2 == 1) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

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

    ll _max(-1);
    for (ll i=0; i<n; i++)
    {
        ll cm (0);
        vector<ll> hash1(26, 0);
        vector<ll> hash2(26, 0);

        for (ll k=0; k<i; k++)
            hash1[s[k]-97]=1;

        for (ll k=i; k<n; k++)
            hash2[s[k]-97]=1;

        for (ll j=0; j<26; j++)
            if (hash1[j] == hash2[j] && hash1[j] > 0)
                cm++;

        if (_max < cm)
            _max = cm;
    }

    cout << _max << endl;

    return 0;
}


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

typedef long long ll;
const ll maxn=1e5;
int a[maxn],b[maxn],c[maxn];

int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    int n;
    while(cin>>n){
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        for(int i=0;i<n;i++){
            cin>>b[i];
        }
        for(int i=0;i<n;i++){
            cin>>c[i];
        }
        sort(a,a+n);
        sort(b,b+n);
        sort(c,c+n);
        ll ans=0;
        for(int i=0;i<n;i++){
            int temp=b[i];
            ll p1=lower_bound(a,a+n,temp)-a;
            ll p2=upper_bound(c,c+n,temp)-c;
            ans+=(ll)(p1*(n-p2));
        }
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,ans;
  ans=0;
  string str;
  cin>>n>>str;
  vector<long> r(n);
  vector<long> g(n);
  vector<long> b(n);
  for(int i=0; i<n; i++){
    if(str.at(i)=='R'){
      r.at(i)=1;
    }
    if(str.at(i)=='G'){
      g.at(i)=1;
    }
    if(str.at(i)=='B'){
      b.at(i)=1;
    }
  }
  for(int i=1; i<n; i++){
    r.at(i)=r.at(i)+r.at(i-1);
    g.at(i)=g.at(i)+g.at(i-1);
    b.at(i)=b.at(i)+b.at(i-1);
  }
  
  for(int i=0; i<n-2; i++){
    for(int j=i+1; j<n-1; j++){
      if(str.at(i)==str.at(j)){
      }
      else if(str.at(i)!='R' && str.at(j)!='R'){
        ans=ans+r.at(n-1)-r.at(j);
         if(2*j-i<n){
           if(r.at(2*j-i)-r.at(2*j-i-1)==1){
             ans=ans-1;
           }
         }
      }
      else if(str.at(i)!='G' && str.at(j)!='G'){
        ans=ans+g.at(n-1)-g.at(j);
        if(2*j-i<n){
           if(g.at(2*j-i)-g.at(2*j-i-1)==1){
             ans=ans-1;
           }
         }
      }
      else if(str.at(i)!='B' && str.at(j)!='B'){
        ans=ans+b.at(n-1)-b.at(j);
        if(2*j-i<n){
           if(b.at(2*j-i)-b.at(2*j-i-1)==1){
             ans=ans-1;
           }
         }
      }
    }
  }
  cout<<ans;
}
        

Measured memory_bytes: 3704
#include <cstdio>

int W,H;
int N;
const int MAX_N = 10010;
int a[MAX_N];

int b[111][111];
int st[MAX_N],sz;

int main(){
	scanf("%d%d",&H,&W);
	scanf("%d",&N);
	for(int i=1,x;i<=N;i++){
		scanf("%d",&x);
		while(x--){
			st[sz++]=i;
		}
	}

	for(int i=0;i<H;i++){
		if(i&1){
			for(int j=0;j<W;j++){
				b[i][j]=st[--sz];
			}
		}else{
			for(int j=W-1;j>=0;j--){
				b[i][j]=st[--sz];
			}
		}
	}

	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			printf("%d ",b[i][j]);
		}puts("");
	}
	return 0;
}


Measured memory_bytes: 256
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
MOD = 10**9+7

N = int(input())
A = list(map(int,input().split()))
d = defaultdict(int)
for i in range(N):
    d[A[i]] += 1

S = sum(A)

Q = int(input())
for i in range(Q):
    B,C = map(int,input().split())
    S += (C-B)*d[B]
    d[C] += d[B]
    d[B] = 0
    print(S)

Measured memory_bytes: 90296
N = gets.chomp.to_i
a = []
n = 1
while n <= N
  x = gets.chomp.split
  a << [x[0],x[1].to_i*-1,n]
  n = n + 1
end
#p a
v = a.sort
#p v
v.each do |m|
  puts m[2]
end


Measured memory_bytes: 1788
#include <stdio.h>
#define PremiumNumber 111

int main(void) {
    int N;
    scanf("%d", &N);
    int Hyaku, Ju, Ichi;
    int ans;

    Hyaku = (N/100);
    Ju = (N - Hyaku * 100) / 10;
    Ichi = N % 10;

    // 550 650

    if ((Hyaku == Ju) && (Ju == Ichi)) 
        ans = N;
    else if (Hyaku <= Ju) {
        if ((Hyaku == Ju) && (Ju > Ichi)) {
            ans = Hyaku*PremiumNumber;
        } else 
            Hyaku++;
            ans = Hyaku*PremiumNumber;
    } else if (Hyaku > Ju) {
        ans = Hyaku*PremiumNumber;
    } 
    
    printf("%d\n", ans);
    return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string oper;
    cin>>oper;
    int l = oper.length();
    stack<char> text, tmp;
    for(int i=0;i<l;i++)
    {
        if(oper[i] != 'B') text.push(oper[i]);
        else
        {
            if(!text.empty()) text.pop();
        }
    }
    while(!text.empty())
    {
        tmp.push(text.top());
        text.pop();
    }
    while(!tmp.empty())
    {
        cout<<tmp.top();
        tmp.pop();
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define rFOR(i, a, b) for(int i=b-1; i>=a; i--)
#define MAX 50
typedef long long ll;
using namespace std;

int main(void){
  string atcoder;
  string s;
  string contest;
  cin >> atcoder >> s >> contest;
  cout << atcoder[0]<<s[0]<<contest[0] << endl;

  return 0;
}


Measured memory_bytes: 256
def main():
    INF = 10**9
    N = int(input())
    h = list(map(int,input().split()))
    dp = [INF]*N
    dp[0] = 0
    dp[1] = abs(h[0]-h[1])
    for i in range(2,N):
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
    print(dp[N-1])

if __name__ == '__main__':
    main()

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

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

  string s, t;
  cin >> s >> t;

  t.pop_back();
  if (s == t) cout << "Yes" << '\n';
  else cout << "No" << '\n';

  return (0);
}


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n,d;
    cin>>n>>d;
    ll ct=0;
    fr(i,0,n)
    {
        ll x,y;
        cin>>x>>y;
        if((x*x+y*y)<=d*d)
            ct++;
    }
    cout<<ct<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

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

int main(){
  int n,a[330000];
  long long int sum=0;
  cin>>n;
  for(int i=0;i<3*n;i++){
    cin>>a[i];
  }
  sort(a,a+3*n,greater<int>());
  for(int i=1;i<2*n;i+=2){
    sum+=a[i];
  }
  cout<<sum;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
   int r; cin >> r;
   long double ans = 2 * r * M_PI;
   cout << setprecision(12) << ans << endl;
}


Measured memory_bytes: 3792
import java.util.*;

public class Main { //AOJ0610
    Scanner sc = new Scanner(System.in);
    public int h = sc.nextInt();
    public int w = sc.nextInt();
    public int[][] cloud = new int [h][w];
	public char[][] weather = new char [h][w];
	void doIt(){
        for(int i = 0; i < h; i++){
            weather[i]= sc.next().toCharArray();
        }
		for(int i = 0; i < h; i++){
    	   int minutes = -1;
    	   for(int k = 0; k < w; k++){
    		   if(weather[i][k] == 'c'){		//??????????????°????????????
    			   minutes = 0;
    			   cloud[i][k] = minutes;
    			   minutes++;
    		   }else if(minutes >= 0){		//??????????????°??????????????????????????????????????????
    			   cloud[i][k] = minutes;
    			   minutes++;
    		   }else{		//????????\??????
    			   cloud[i][k] = minutes;
    		   }
    	   }
       }
       for(int i = 0; i < h; i++){
    	   for(int k = 0; k < w; k++){
    		   if(k == w - 1){
    			   System.out.print(cloud[i][k]);
    		   }else{
    			   System.out.print(cloud[i][k] + " ");
    		   }
    	   }
    	   System.out.println();
       }
	}
    public static void main(String[] args) {
    	new Main().doIt();
    }
}

Measured memory_bytes: 33832
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a[3];
    for(int i=0;i<3;i++)
    {
        cin>>a[i];
    }
    sort(a,a+3);
    for(int i=0;i<2;i++)
    {
        cout<<a[i]<<' ';
    }
    cout<<a[2]<<endl;
    return 0;
}

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

bool isp(string s){
    int n=s.size();
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1])
            return false;
    }
    return true;
}

int main(){
    string s;
    cin>>s;
    int n=s.size();
    string s1=s.substr(0,(n-1)/2);
    string tmp=s;
    tmp.erase(0,(n-1)/2+1);
    if(isp(s1) && isp(tmp) && isp(s))
        cout<<"Yes\n";
    else
        cout<<"No\n";
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int taka = sc.nextInt();
		int aoki = sc.nextInt();
		int times = sc.nextInt();


		for (int i = 0; i < times; i++) {
			if (i % 2 == 0) {
				if ((taka % 2) != 0) {
					taka--;
				}
				int give = taka / 2;
				taka -= give;
				aoki += give;

			} else {

				if ((aoki % 2) != 0) {
					aoki--;
				}
				int give = aoki / 2;
				aoki -= give;
				taka += give;

			}
		}
		System.out.println(taka+" "+aoki);

	}
}

Measured memory_bytes: 21972
N, M, K = map(int, input().split())

MOD = 998244353
MAX = 5 * 10 ** 5 + 1

# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1

# Inverse
inv = [0] * (MAX + 1)
inv[1] = 1

# Inverse factorial
finv = [0] * (MAX + 1)
finv[0] = 1
finv[1] = 1

for i in range(2, MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD


def comb(n, k):
    if n < k or k < 0:
        return 0
    return (fac[n] * finv[k] * finv[n - k]) % MOD


ans = 0
for k in range(K + 1):
    tmp = comb(N - 1, k) * M * pow(M - 1, N - k - 1, MOD) % MOD
    ans = (ans + tmp) % MOD
print(ans)


Measured memory_bytes: 87868
#include<stdio.h>
int main(){
  int n,ans = 0;
  scanf("%d",&n);
  n *= 2;
  int a[n];
  for(int i = 0;i < n;i++){
    scanf("%d",&a[i]);
  }
  for(int i = 0;i < n - 1;i++){
    for(int j = 0;j < n - 1;j++){
      if(a[j] > a[j + 1]){
        int t = a[j + 1];
        a[j + 1] = a[j];
        a[j] = t;
      }
    }
  }
  for(int i = 0;i < n;i += 2){
    ans += a[i];
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<iostream>
#define MAXN 100000
#define clear(x) memset(x,0,sizeof(x))
using namespace std;
int q[MAXN+1],cnt,sec;
int get_max(int *p,int last){
	int ans=0,qwq=0;clear(q);
	for(int i=1;i<=cnt;i++)
		q[p[i]]++;
	for(int i=1;i<=MAXN;i++)
		if(i!=last&&q[i]>ans) qwq=i,ans=q[i];
	return qwq;
}
int a[MAXN+1],b[MAXN+1];
int main(){
//	freopen("c.in","r",stdin);
//	freopen("c.out","w",stdout);
	int n,x,ans1,ans2;
	cin>>n;cnt=n/2;
	for(int i=1;i<=n;i++){
		if(i&1)scanf("%d",&a[(i+1)>>1]);
		else scanf("%d",&b[i>>1]);
	}
	x=get_max(a,0);ans1=n-q[x]-q[get_max(b,x)];
	x=get_max(b,0);ans2=n-q[x]-q[get_max(a,x)];
	cout<<min(ans1,ans2)<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int A,B;
    cin>> A >> B;
    int a=A+B,b=A-B,c=A*B,s;
    if(a>=b){
        if(a>=c){
            s=a;
        }else{
            s=c;
        }
    }else{
        if(b>=c){
            s=b;
        }else{
            s=c;
        }
    }

    cout << s;
}

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

// from the last
int main() {
  int n;
  cin >> n;
  vector<int> a(n+1);
  rep(i, n) cin >> a[i+1];
  vector<int> box(n+1);
  for (int i = n; i > 0; --i) {
    int cur = 0 ^ a[i];
    for (int j = i+i; j <= n; j += i) {
      cur ^= box[j];
    }
    box[i] = cur;
  }
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    if (box[i]) {
      ans.push_back(i);
    }
  }
  cout << ans.size() << '\n';
  rep(i, ans.size()) {
    printf("%d%c", ans[i], i+1==ans.size() ? '\n' : ' ');
  }
  return 0;
}

Measured memory_bytes: 5376
N, K = map(int, input().split())

ANS = [False] * N

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for i in range(d):
        if ANS[A[i] - 1] == False:
            ANS[A[i] - 1] = True

print(ANS.count(False))


Measured memory_bytes: 9152
S = input()

total = 0
max = len(S)

for i, s in enumerate(S):
  if i % 2 == 0:
    if s =="R" or s =="U" or s == "D":
      total +=1
  elif i % 2 ==1:
    if s =="L" or s =="U" or s == "D":
      
      total +=1
      
if total == max:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
/*
 N/(K + (K-1) + (K-1)…)切り上げ
 (N-1)/(K-1)
 ((N-1)+(K-1)-1)/(K-1)
 */
#include <iostream>
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    cout << ((N-1)+(K-1)-1)/(K-1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/* Karen {{{
  ___  ____
 |_  ||_  _|
   | |_/ /    ,--.   _ .--.  .---.  _ .--.
   |  __'.   `'_\ : [ `/'`\]/ /__\\[ `.-. |
  _| |  \ \_ // | |, | |    | \__., | | | |
 |____||____|\'-;__/[___]    '.__.'[___||__]
}}} */
/* cpp template {{{*/
using namespace std;

#define endl '\n'

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()

typedef double D;
typedef long long ll;
typedef long double lb;
typedef complex<D> P;
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);}
inline int in() {int x; std::cin >> x; return x;}

template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
/* }}} */
/* ?????° {{{*/
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS  = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
/* }}} */

int d[100][100];

int w, h;
int co;

void dfs(int x, int y, int c)
{
  if (!inside(y, x, h, w)) return;
  if (d[x][y] != c) return;

  d[x][y] = 0;
  REP(i, 4) {
    dfs(x + dx[i], y + dy[i], c);
  }
}

void update(int x, int y, int c)
{
  d[x][y] = d[x][y + 1] = d[x + 1][y] = d[x + 1][y + 1] = c;
}

int color(int x, int y) { return d[x][y];}

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

  while (cin >> w >> h, w){
    memset(d, -1, sizeof(d));

    int sx = in() - 1, sy = in() - 1;
    int gx = in() - 1, gy = in() - 1;
    int n = in();

    REP(_, n){
      int c = in(), D = in(), x = in() - 1, y = in() - 1;
      update(x, y, c);
      if (D) {
        update(x, y + 2, c);
      } else {
        update(x + 2, y, c);
      }
    }

    dfs(sx, sy, color(sx, sy));

    cout << (d[gx][gy] ? "NG" : "OK") << endl;
  }
}

Measured memory_bytes: 3164
// A. 

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;

int main(int argc, char *argv[])
{
	string s;
	cin >> s;
	int u[26] = {};
	for (char c : s) {
		++u[c - 'a'];
	}
	string ans;
	if (s.length() < 26) {
		for (int i = 0; i < 26; ++i) {
			if (!u[i]) {
				ans = s + char('a' + i);
				break;
			}
		}
	} else {
		for (int i = s.length() - 1; ans.empty() && i >= 0; --i) {
			for (int j = 0; j < 26; ++j) {
				if (!u[j] && j > (s[i] - 'a')) {
					ans = s.substr(0, i) + char('a' + j);
					break;
				}
			}
			--u[s[i] - 'a'];
		}
	}
	cout << (ans.empty() ? "-1" : ans) << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void dfs(vector<vector<char>> &s, VVI &c, int x, int y, int h, int w, int cnt) {
    if (s[x][y] != '.') return;
    if (c[x][y] <= cnt) return;
    c[x][y] = cnt;
    if (x == h - 1 && y == w - 1) return;
    int dx[] = {0,1,0,-1};
    int dy[] = {1,0,-1,0};
    REP(i,0,4) {
        if (x + dx[i] < 0) continue;
        if (x + dx[i] >= h) continue;
        if (y + dy[i] < 0) continue;
        if (y + dy[i] >= w) continue;
        dfs(s,c,x+dx[i],y+dy[i],h,w,cnt+1);
    }
}

void solve() {
    int h,w;
    cin >> h >> w;
    int n = h * w;
    vector<vector<char>> s(h, vector<char>(w));
    REP(i,0,h) REP(j,0,w) cin >> s[i][j];
    // start (1, 1) => (0, 0)
    int white_cnt = 0;
    REP(i,0,h) REP(j,0,w) if (s[i][j] == '.') ++white_cnt;
    VVI cnts(h, VI(w,n));
    dfs(s,cnts,0,0,h,w,1);
    if (cnts[h-1][w-1] == n) {
        cout << -1 << endl;
    } else {
        cout << white_cnt - cnts[h-1][w-1] << endl;
    }
    return;
    REP(i,0,h) {
        REP(j,0,w) cerr << cnts[i][j] << " ";
        cerr << endl;
    } 
}

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


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

const int N = 100000;
int par[N], runk[N];

void init(int n)
{
	for(int i = 0; i < n; ++i){
		par[i] = i;
		runk[i] = 0;
	}
}

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

void unite(int x, int y)
{
	x = find(x);
	y = find(y);
	if(x == y) return;
	
	if(runk[x] > runk[y])
		par[y] = x;
	else {
		par[x] = y;
		if(runk[x] == runk[y])
			runk[x] ++;
	}
}

bool same(int x, int y)
{
	return find(x) == find(y);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, q;
	cin >> n >> q;
	
	init(n);
	
	int c, x, y;
	for(int i = 0; i < q; ++i){
		cin >> c >> x >> y;
		if(c == 0)
			unite(x, y);
		else
			cout << same(x, y) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1400
import itertools as ite
import math
import random

INF = 10 ** 18
MOD = 10 ** 9 + 7

def func(diff, cnt9, cnt0):
    if cnt9 <= 0:
        return (diff == 0)
    num = int("9" * cnt9 + "0" * cnt0)
    return sum(func(diff + i * num, cnt9 - 2, cnt0 + 1) * (9 - abs(i) + 1 - (cnt0 < 1)) for i in range(-9, 10) if abs(diff + i * num) < num)

D = input()

ans = 0
for d in range(1, 21):
    MUL = 1 if d % 2 == 1 else 10
    ans += func(D, d, 0) * MUL
print ans


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
#define pb push_back
#define fst first
#define snd second
#define INF 0x7fffffff
#define INFLL 0x7FFFFFFFFFFFFFFF
#define lenA(ar) sizeof(ar)/sizeof(*ar)
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define foreI(i,x,y) for(ll i=x-1;i>=y;i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef long long ll;
typedef unsigned long long ull;
 
using namespace std;
int n;
const int MAXN= 105;
ll dp[MAXN][100005];
ll val[MAXN];
ll we[MAXN];
ll solve(int pos,int w){
    if(pos==n-1){
        if(we[pos]<=w)
            return val[n-1];
    }
 
    if(pos>=n)return 0;
    ll &r = dp[pos][w];
    if(r)return r;
    ll a = 0; ll b=0;
    if(we[pos]<=w)
         a =solve(pos+1,w-we[pos])+val[pos];
    b = solve(pos+1,w);
    r = max(a,b);
   /*  cout<<pos<<" "<<w<<"::"<<"\n";
    cout<<"a: "<<a<<" b: "<<b<<"\n"<<"\n";*/
    return r;
}
int main() {FIN;
   
    cin>>n;
    ll weight;cin>>weight;
    fill(dp,0);
    fore(i,0,n){
       cin>>we[i]; cin>>val[i];
    }
    cout<<solve(0,weight)<<"\n";
    return 0;
}
 
 

Measured memory_bytes: 85616