akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>

int main(void){
    int i,j,k;
    int A,B;
    
    scanf("%d %d",&A,&B);
    
    int a,b,c;
    a = A + B;
    b = A - B;
    c = A * B;
    
    if(a >= b && a >= c){
        printf("%d\n",a);
    }else if(b >= a && b >= c){
        printf("%d\n",b);
    }else{
        printf("%d\n",c);
    }
    
    return 0;
}



Measured memory_bytes: 128
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll n;cin>>n;
    vl a(n);rep(i,n)cin>>a[i];

    vl ans(2),sum(2);
    rep(i,n)rep(j,2){
        sum[j]+=a[i];
        if((i+j)%2){
            if(sum[j]<1){
                ans[j]+=1-sum[j];
                sum[j]=1;
            }
        }else{
            if(sum[j]>-1){
                ans[j]+=sum[j]+1;
                sum[j]=-1;
            }
        }
    }
    cout<<min(ans[0],ans[1])<<endl;
}

Measured memory_bytes: 1024
using System;

namespace prime
{
    class Program
    {
        static void Main()
        {
            bool[] unPrime = MakeList();

            while (true)
            {
                int n, ans = 0;

                if (int.TryParse(Console.ReadLine(), out n))
                {
                    for (int i = 2; i <= n; ++i)
                    {
                        /*
                        if (IsPrime(i))
                            ++ans;
                        */

                        if (!unPrime[i])
                            ++ans;
                    }

                    Console.WriteLine(ans);
                }
                else
                    break;
            }
        }

        public static bool IsPrime(int a)
        {
            if (a == 1)
                return false;
            else if (a < 4)
                return true;
            else
            {
                bool prime = true;
                int ma = (int)Math.Sqrt(a + 1);
                int i = 3;
                if (a % 2 == 0)
                    prime = false;
                else
                {
                    for (; i <= ma; i += 2)
                    {
                        if (a % i == 0)
                        {
                            prime = false;
                            break;
                        }
                    }
                }
                return prime;
            }
        }

        public static bool[] MakeList() 
        {
            int M = 1000000;
            int rM = 1000;
            bool[] unPrime = new bool[M];

            for (int i = 2; i < rM; ++i) 
            {
                if (!unPrime[i]) 
                {
                    for (int j = i * i; j < M; j += i)
                        unPrime[j] = true; 
                }
            }
            return unPrime;
        }
    }
}

Measured memory_bytes: 6580
x=input().split()
y=list(map(int,x))
z=list(map(int,y))
a=y[0]
b=y[1]
c=y[2]
if a>b:
    a,b=b,a
if b>c:
    b,c=c,b
if a>b:
    a,b=b,a
print(a,b,c)


Measured memory_bytes: 5600
#include <stdio.h>
int  main()
{
  int a,cou;
  while(1){
    scanf("%d",&a);
    if(a==0)break;
    cou=0;
    while(a!=1){
      if(a%2==0){
	a=a/2;
	cou++;
      } else {
	a=a*3+1;
	cou++;
      }
    }
    printf("%d\n",cou);
  }
  return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define fo(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define MAXN 1000002
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod=1e9+7;

int main()
{
  fastio
  int n;
  cin>>n;
  ll sum=0;
  for(int i=1;i<=n;i++)
  {
    if(i%3!=0 && i%5!=0)
    sum+=i;
  }
  cout<<sum;
}


Measured memory_bytes: 3612
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# include <stack>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
ll counter;

int main() {
	ll a = 0, b = 0, c = 0, d = 0, n = 0, m = 0, counter = 0, maxi = 0, asum = 0, bsum = 0, counter2 = 0;
	ll x = 0, y = 0;
	ll A[10001], B[10001];
	priority_queue<ll> pque;
	std::string str, str2[4] = {"Sunny","Cloudy","Rainy","Sunny"};
	cin >> str;
	rep(i, 5) {
		if (str == str2[i]) {
			cout << str2[i + 1] << endl;
			return 0;
		}
	}

	
}


Measured memory_bytes: 384
#include<iostream>
 
using namespace std;
 
bool isprime (int x) {
 
    int i;
 
    if (x == 2) {
 
        return true;
 
    }
 
    if (x < 2 || x % 2 == 0) {
 
        return false;
 
    }
 
    for (i = 3; i * i <= x; i += 2) {
 
        if (x % i == 0) {
 
            return false;
 
        }
 
    }

    return true;
 
}
 
int main () {
 
    int n, i, x;
    int count = 0;
 
    cin >> n;
  
    for (i = 0; i < n; i++) {

        cin >> x;
 
        if (isprime (x)) {
 
            count += 1;
 
        }
 
    }
 
    cout << count << endl;
 
    return 0;
 
}

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

using namespace std;

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

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

using namespace std;


int main()
{
	int n;
	cin >> n;
	int max = 0;
	int second = 0;
	int num = 0;
	vector<int> a(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] > max) {
			num = i;
			second = max;
			max = a[i];
		}
		else if (second < a[i]) {
			second = a[i];
		}
	}

	for (int i = 0; i < n; i++) {
		if (num == i) {
			cout << second << endl;
		}
		else {
			cout << max << endl;
		}
	}
}


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

ll solve() {
    ll X, Y;
    cin >> X >> Y;
    if ( X % Y == 0 ) return -1;
    else return X;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
#define int long long
const int inf=1e16;

int func(int b, int n){

   if(n<b) return n;
   return func(b, n/b)+(n%b);
}

int f1(int n, int s){

   int b=2;
   while(b*b<=n){
      if(func(b, n)==s) return b;
      b++;
   }
   return inf;
}

int f2(int n, int s){

   int b=inf;
   int p=1;
   while(p*p<=n-s){
      if((n-s+p)%p==0){
         int _b=(n-s)/p+1;
         if(func(_b, n)==s) b=min(b, _b);
      }
      p++;
   }
   return b;
}

signed main(){

   int n, s;
   cin>> n>> s;

   if(n==s){
      cout<< n+1<< endl;
      return 0;
   }
   int b=f1(n, s);
   b=min(b, f2(n, s));

   cout<< (b==inf? -1: b)<< endl;

   return 0;
}


Measured memory_bytes: 384
import sys
from decimal import Decimal

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
#read = sys.stdin.buffer.read

def main():
    N1 = list(readline().split())
    N = int(N1[0]); M = Decimal(N1[1])
    #M2 = float(N1[1])
    ans = int(N*M)
    print(ans)
    #print(int(N*M2))


if __name__ == "__main__":
    main()


Measured memory_bytes: 10036
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<functional>
#include<iostream>
#define MI 0
#define MIN 1000000000
#define rep(i,a) for(i=0;i<a;i++)
using namespace std;
int main(void)
{
	int i,j,k,a;
	int wcnt[51],rcnt[51],bcnt[51];
	int retuw,retur,retub,sum=MI,min=MIN;
	int n,m;
	char flag[51][51];
	cin>>n>>m;
	rep(i,n) cin>>flag[i];
	rep(i,n) {wcnt[i]=MI;rcnt[i]=MI;bcnt[i]=MI;}
	rep(i,n)rep(j,m){
		if(flag[i][j]=='W') wcnt[i]++;
		else if(flag[i][j]=='R') rcnt[i]++;
		else bcnt[i]++;
	}
	for(i=0;i<n-2;i++) {
		for(j=i+1;j<n-1;j++) {
			retuw=0;retur=0;retub=0;
			for(k=0;k<=i;k++) retuw+=m-wcnt[k];
			for(k=i+1;k<=j;k++) retub+=m-bcnt[k];
			for(k=j+1;k<n;k++) retur+=m-rcnt[k];
			sum=retuw+retur+retub;
			if(min>sum) min=sum;
		}
	}
	cout<<min<<endl;
	return 0;
}

Measured memory_bytes: 3092
lst = list(map(int,input().split()))
#print(lst)
lst.sort()
count = 0
while len(set(lst)) != 1:
    for i in range(len(lst)-2):
        if lst[i] <= lst[i+1]-2:
            lst[i] += 2
        elif lst[i] <= lst[i+2] and lst[i+1] <= lst[i-1]:
            lst[i] += 1
            lst[i+1] += 1
    count += 1
    lst.sort()
    #print(lst)
print(count)


Measured memory_bytes: 9132
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
using namespace std;

int N, M;
vector<int> S[10];
int P[10];
int dfs(int i, vector<int> bit) {
	if (i == N) {
		for (int i = 0; i < M; ++i) {
			int sum = 0;
			for (auto s : S[i]) {
				sum += bit[s - 1];
			}
			if (sum % 2 != P[i]) {
				return 0;
			}
		}
 		return 1;
	}
	bit[i] = 0;
	int a = dfs(i + 1, bit);
	bit[i] = 1;
	int b = dfs(i + 1, bit);
	return a + b;
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		int k;
		cin >> k;
		for (int j = 0; j < k; ++j) {
			int s;
			cin >> s;
			S[i].push_back(s);
		}
	}
	for (int i = 0; i < M; ++i) {
		cin >> P[i];
	}

	vector<int> bit(10, 0);
	cout << dfs(0, bit) << endl;
	return 0;
}


Measured memory_bytes: 256
import sys


def solv(roman):
    a = map(lambda x: roman_to_arabic(x), roman)
    arabic = reduce(roman_count, a, (0,0))[0]
    return arabic

def roman_to_arabic(s):
    tbl = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
    return tbl[s]

def roman_count(acc, y):
    x = acc[1]
    if x < y:
       a = acc[0] + y - 2 * x
    else:
       a = acc[0] + y
    return (a, y)


for line in sys.stdin:
    roman = line.rstrip("\n")
    print solv(roman)

Measured memory_bytes: 4344
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    int n;
    string s;
    cin >> n;
    int ans = 0;
    REP(i,n){
        int l, r;
        cin >> l >> r;
        ans += (r - l + 1);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <bits/stdc++.h> // isupper, islower, isdigit, toupper, tolower
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pl;
typedef pair<int, int> P;

int main()
{
  ll M, N;
  ll ans = 0;
  ll total = 0;
  ll X = 0;
  cin >> N >> M;
  vector<ll> A(N);
  rep(i, N)
  {
    cin >> A.at(i);
    total += A.at(i);
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  X = total / (4 * M);
  rep(i, N)
  {
    if (4 * M* A.at(i) >= total)
    {
      ans++;
    }
  }
  if (ans >= M)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;

  }

  return 0;
}


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

int affine(int let,int A,int B) {
  return (A * let + B) % 26;
}

int main() {
  int n;
  string str;
  int x[257],y1;
  char y[257];
  scanf("%d\n",&n);
  for(int i=0;i<n;i++) {
    getline(cin,str);
    for(unsigned int j=0;j<str.size();j++) {
      char x1 = *str.substr(j,1).c_str();
      x[j] = (int)x1 - 97;
    }

    for(int j=1;j<27;j+=2) {
      if(j == 13) continue;
      for(int k=0;k<26;k++) {
        for(unsigned int l=0;l<str.size();l++) {
          if(0 <= x[l] && x[l] <= 25) {
            y1 = affine(x[l],j,k);
          }
          else {
            y1 = x[l];
          }
          y[l] =(char) (y1 + 97);
        }
        y[str.size()] = '\0';

        for(unsigned int l=0;l<str.size()-3;l++) {
          if(y[l] == 't') {
            if(y[l+1] == 'h') {
              if(y[l+2] == 'a') {
                if(y[l+3] == 't') {
                  cout << y << endl;
                  break;
                }
              }
              else if(y[l+2] == 'i'){
                if(y[l+3] == 's') {
                  cout << y << endl;
                  break;
                }
              }
            }
          }
        }

      }
    }

  }
}

Measured memory_bytes: 0
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r\
:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

  if(T[u].p == -1) printf("root, ");
  else if(T[u].l == NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for (i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");

}

void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].r != NIL) calcDepth(T[u].r, p);
  if(T[u].l != NIL) calcDepth(T[u].l, p+1);
}

int main(){
  int i, j, k;
  int n;
  int id, sib, child;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;

  for(i=0; i<n; i++){
    scanf("%d %d", &id, &k);
    for(j = 0, sib = NIL; j<k; j++){ //子を入力する (input children)            
      scanf("%d", &child);
      T[child].p = id;
      if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)  
      else T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)       
      sib = child;//次の子供の左の兄弟 (the left sibling of the next child)     
    }
  }

  //根を求める (find the root)                                                  
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }

  //それぞれのノードの深さを求める (find depth of each node)                    
  calcDepth(root, 0);

  //出力 (output)                                                               
  for(i=0; i<n; i++) print(i);

  return 0;
}



Measured memory_bytes: 6408
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;

typedef long long ll;

pair<ll, const char*> expr(const char*);
pair<ll, const char*> term(const char*);
pair<ll, const char*> fact(const char*);

pair<ll, const char*> expr(const char* p) {
  pair<ll, const char*> lhs = term(p);
  ll ret = lhs.first;
  const char* q = lhs.second;
  while (*q == '+' || *q == '-') {
    pair<ll, const char*> rhs = term(q + 1);
    if (*q == '+') { ret += rhs.first; }
    else { ret -= rhs.first; }
    q = rhs.second;
  }
  return make_pair(ret, q);
}

pair<ll, const char*> term(const char* p) {
  pair<ll, const char*> lhs = fact(p);
  ll ret = lhs.first;
  const char* q = lhs.second;
  while (*q == '*' || *q == '/') {
    pair<ll, const char*> rhs = fact(q + 1);
    if (*q == '*') { ret *= rhs.first; }
    else { ret /= rhs.first; }
    q = rhs.second;
  }
  return make_pair(ret, q);
}

pair<ll, const char*> fact(const char* p) {
  if (*p == '(') {
    pair<ll, const char*> inside = expr(p + 1);
    return make_pair(inside.first, inside.second + 1);
  } else {
    ll ret = 0;
    const char* q;
    for (q = p; '0' <= *q && *q <= '9'; ++q) {
      ret *= 10;
      ret += *q - '0';
    }
    return make_pair(ret, q);
  }
}

int main() {
  int T; scanf("%d", &T);
  while (T--) {
    char buffer[128]; scanf("%s", buffer);
    pair<ll, const char*> ret = expr(buffer);
    printf("%lld\n", ret.first);
  }
}

Measured memory_bytes: 0
# import sys
# input = sys.stdin.readline

N, *score = [int(x) for x in open(0)]
a = sum(score)
print(max([a - s for s in score + [0] if (a - s) % 10] + [0]))

# 最後の行は、scoreのなかの何か一つの要素を合計から引いたときと何も引かなかったとき（+ [0]は何も引かない場合のため)を
# それぞれ10で割ったあまりが0でない(0の論理値はFalse, 1以上の論理値はTrue) 物の中から最大値を出力する
# ややこしいが、もしaが10の倍数だった場合、scoreの要素がすべて10の倍数だったら最後の + [0] があることで 
# 0が出力され、そうではいなら少なくとも二つ以上は10の倍数ではない要素が存在するので、
# そのうち一つでもaから引いてしまえばそれは10の倍数ではなくなる。
# これを満たす物の中から最大値を出力すれば良いというわけだ


Measured memory_bytes: 2940
#include<stdio.h>

int gcd(int,int);

int main(){
  int x,y;

  scanf("%d%d",&x,&y);

  printf("%d\n",gcd(x,y));

  return 0;

}

int gcd(int x,int y){
  int tmp,r;
  
    if(x<y){
    tmp=x;
    x=y;
    y=tmp;
  }

  r=x%y;
  while(r!=0){
    x=y;
    y=r;
    r=x%y;
  }

  return y;
}


Measured memory_bytes: 2056
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(P: int, Q: int, R: int):
    print(P+Q+R-max([P, Q, R]))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    P = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    solve(P, Q, R)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
int isPal(string s){
    for(int i = 0; i < s.size()/2 ; ++i){
        if(s[i] != s[s.size() - 1 - i])
            return 0; 
    }
    return 1; 
}
void solve(){
    ll l;
    cin >> l;
    ll mx = 1;

    cout << fixed << setprecision(6) << (l/3.0L) * (l/3.0L)* (l/3.0L);
}
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

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


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

  vector<int> a(N);

  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }

  sort(a.begin(), a.end());

  int n = a.at(N-1);
  int m = n / 2;
  if(n%2==1) m++;

  int r = -1;
  int dmin = INT_MAX;

  for(int i=0;i<N-1;i++){
    int d = abs(m - a.at(i));
    if(d < dmin){
      dmin = d;
      r = a.at(i);
    }
  }
  cout << n << endl;
  cout << r << endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
int a[maxn];
int main()
{
    int n, m, k;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
    	scanf("%d",&a[i]);
    }
    sort(a,a+n);
	int cnt =n-2;
    ll ans =a[n-1];
    for (int i=n-2; i>=0; i--) {
        if(cnt == 0) break;
        ans += a[i];
        cnt--;
        if(cnt == 0) break;
        ans += a[i];
        cnt--;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4544
# include <bits/stdc++.h>
# define int        long long
# define all(vc)   vc.begin(),vc.end()
# define all2(vc)  vc.rbegin(),vc.rend()
# define pb        push_back
# define fi        first
# define se        second
# define speed     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define time      cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
 
using namespace std;

void solve(){
    int n, k = 1;
    cin >> n >> k ;
    int ar[n + 5];
    long double sum = 0;
    for (int i = 0; i < n; ++i){
        cin >> ar[i];
        sum += ar[i];
    }
    long double p = sum / (4 * k);
    sum = 0;
    for (int i = 0; i < n; ++i){
        if( ar[i] >= p ) sum ++;
        if( sum == k ){
            cout << "Yes";
            return;
        }
    }
    cout <<"No";
}

int32_t main(){
    speed;
    cout<<fixed<<setprecision(0);
    int t = 1;
    //cin >> t;
    while( t-- ){
         solve();
         cout<<'\n';
    }

    time;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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; }

int main() {
	int N;
	cin >> N;
	vector<string> S(N);
	ll ans = 0, counta = 0, countb = 0, countab=0;
	rep(i,N) {
		cin >> S[i];
		int n = S[i].length();
		if(S[i][0] == 'B') countb++;
		if(S[i][n-1] == 'A') counta++;
		if(S[i][0] == 'B' && S[i][n-1] == 'A') countab++;
	}
	rep(i,N) rep(j,S[i].length()-1) {
		if(S[i][j] == 'A' && S[i][j+1] == 'B') ans++;
	}
	if(countab == 0) ans += min(counta, countb);
	else if(countab == counta && countab == countb) ans += countab-1;
	else {
		if(counta > countab) {
			ans += 1;
			counta--;
		}
		if(countb > countab) {
			ans += 1;
			countb--;
		}
		ans += countab-1;
		counta -= countab;
		countb -= countab;
		ans += min(counta,countb);
	}

	cout << ans << endl;

  return 0;
}


Measured memory_bytes: 768
import numpy as np

n = int(input())
a = list(map(int, input().split()))
z = np.ones(n) * 2
count = 0

for i in range(1000000000) :
  b = filter(lambda x: x%2 == 1, a)
  if len(list(b)) >= 1 :
    break
  else :
    a = a / z
    count += 1

print (count)

Measured memory_bytes: 12396
#include <stdio.h>

int check(char *str1,char *str2)
{
  while(*str1 != '\0' && *str2 != '\0'){
    if(*str1++ != *str2++)
      return 0;
  }
  return 1;
}

int main(void)
{
  int n;
  int c[4] = {0};
  char str[4];
  scanf("%d",&n);
  
  
  for(int i=0; i<n; i++){
    scanf("%s",str);
    
    if(check(str,"AC"))
      c[0]++;
    else if(check(str,"WA"))
      c[1]++;
    else if(check(str,"TLE"))
      c[2]++;
    else if(check(str,"RE"))
      c[3]++;
  }
  
  printf("AC x %d\n",c[0]);
  printf("WA x %d\n",c[1]);
  printf("TLE x %d\n",c[2]);
  printf("RE x %d\n",c[3]);
  
  return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <vector>
using namespace std;
int main(){
	bool prime[1000001];
	prime[1]=false;
	for(int i=2;i<=1000000;i++){
		prime[i]=true;
	}
	for(int i=2;i<=1000000;i++){
		if(prime[i]==true){
			for(int j=i*2;j<=1000000;j+=i){
				prime[j]=false;
			}
		}
	}
	int a,d,n;
	while(cin>>a>>d>>n){
		if(a==0 && d==0 && n==0) break;
		vector<int> p;
		for(int k=a;k<=1000000;k+=d){
			if(prime[k]==true) p.push_back(k);
		}
		cout<<p[n-1]<<endl;
	}
	return 0;
}

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

class Program {
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return Console.ReadLine().Split(); }

    static void Main() {
        int a = ReadInt();
        int b = ReadInt();
        int h = ReadInt();

        int ans = (a + b) * h / 2;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 2776
n = int(input())
arr = list(map(int,input().split()))

cnt = 0
track = 1

for i in range(n) :
	if cnt!=1 :
		if arr[i]!=track :
			arr[i] = -1
		else :
			track+=1
			cnt = 1
	else :
		if arr[i] == track :
			track+=1
		elif arr[i] == track - 1 :
			continue
		else:
			arr[i] = -1



res = set(arr)

# print(res)

if -1 in res :
	res.remove(-1)

ans = n - len(res)

if ans == n :
	print(-1)
else :
	print(ans)


Measured memory_bytes: 26148
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
using namespace std;
typedef long long ll;
const int maxn = 100005;


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "w", stdout);
#endif
  int n,m;
  vector<int> a;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int x;
    cin>>x;
    a.push_back(x);
  }
  sort(a.begin(),a.end());
  vector<int> b;
  for(int i=0;i<m-1;i++)b.push_back(a[i+1]-a[i]);
  sort(b.begin(),b.end());
  int ret = 0;
  for(int i=b.size()-n;i>=0;i--){
    ret+=b[i];
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 1400
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	
	char s[128];
	scanf("%s", s);
	int namelen = strlen(s);
	
	int num = 0;
	
	for (int i = 0; i < n; i++){
		char t[128];
		scanf("%s", t);
		int oldlen = strlen(t);
		
		bool f = false;
		for (int j = 0; j < oldlen && f == false; j++){
			for (int k = 1; j + k * (namelen - 1) < oldlen && f == false; k++){
				int cnt = 0;
				for (int l = 0; l < namelen; l++){
					if (t[j + k * l] == s[l]){
						cnt++;
					}
				}
				
				if (cnt == namelen){
					f = true;
				}
			}
		}
		
		num += f;
	}
	
	printf("%d\n", num);
	
	return 0;
}

Measured memory_bytes: 1028
# vim: fileencoding=utf-8


def main():
    n = int(input())
    li = list(map(int, input().split()))
    odd = 0
    even = 0
    for i in li:
        if i % 2 == 0:
            even += 1
        else:
            odd += 1
    if odd == 1 and even == 0:
        print("YES")
        return
    if odd % 2 == 1:
        print("NO")
        return
    if odd % 2 == 0 and (even + odd // 2) == 0:
        print("NO")
        return
    print("YES")


if __name__ == "__main__":
    main()


Measured memory_bytes: 85380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int N,M;cin >> N >> M;
    int p[11];
    int s[11][11];
    rep(i,10)rep(j,10)s[i][j] = -1;
    int k[11];
    rep(i,M){
        cin >> k[i];
        rep(j,k[i])cin >> s[i][j];
    }
    rep(i,M)cin >> p[i];
    ll ans = 0;
    for(int i=0;i<(1<<N);i++){
        bool flag = true;
        int tmp[12];
        memset(tmp,0,11*sizeof(int));
        for(int bit=0;bit<N;bit++){
            if(i&(1<<bit)){
                tmp[bit] = 1;
            }
        }
        rep(i,M){
            int count = 0;
            rep(j,k[i]){
                if(tmp[s[i][j]-1]==1){
                    count++;
                }
            }
            if((count%2)!=p[i])flag=false;
        }
        
        if(flag)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for(int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)
 
#define rsz resize
#define eb emplace_back
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define f first
#define s second
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); 
  int n;
  cin >> n;
  int ans = 0;
  F0R (i, n) {
    int foo;
    cin >> foo;
    ans = __gcd (ans, foo);
  }
  cout << ans << '\n';
  return 0; 
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}


int main(int argc,char* argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG=1;}
  dprint("start");

  int N,K; cin>>N>>K;
  
  int h[N+1]; 
  for(int i=1;i<=N;++i){ cin >> h[i]; }

  int dp[N+1];
  FILL(dp,N+1,1e9+10);
  dp[1] = 0;

  for(int i=1;i+1<=N;++i){
    dprint(i);
    for(int j=i+1;j<=i+K;++j){
      if(j>N){break;}
      int temp = dp[i]+abs(h[j]-h[i]);
      dprint(temp);
      chmin(dp[j],temp);
    }
    dprint("--");
  }
  cout << dp[N] << "\n";
}

Measured memory_bytes: 4412
import java.util.HashSet;
import java.util.Scanner;

class Main {

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

		int N = scanner.nextInt();

		boolean flag = true;
		HashSet<Integer> set = new HashSet<>();

		for (int i = 0; i < N; i++) {
			int n = scanner.nextInt();
			if (set.contains(n)) {
				flag = false;
				break;
			}
			set.add(n);
		}
		
		scanner.close();

		if (flag) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}	
	}
}

Measured memory_bytes: 100604
s = input()
s_sorted = ''.join(sorted(s))
t = input()
t_sorted = ''.join(sorted(t,reverse = True))
if s_sorted < t_sorted:
	print("Yes")
else:
	print("No")

"""
'間に挿入する文字列'.join([連結したい文字列のリスト])
発想
sを辞書順で一番早くなるよう並び替え
tを辞書順で一番遅くなるよう並び替え
それらを比較
"""

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

#define     ll      long long
#define     pb      push_back
#define     eps     1e-9
#define     bug     cout<<"debug"<<endl;
using namespace std;
typedef long double ld;

int main()
{
    int n;
    cin>>n;
    double x=0;
    for(int i=0;i<n;i++)
    {
        int r;
        cin>>r;
        x+=1.0/(r*1.0);
    }
    cout<<1.0/x<<endl;
    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}

module Main where

import qualified Data.ByteString.Char8 as B8
import Data.Maybe (fromJust)
import Data.Char (toUpper)
import Data.List
import qualified Data.Map as M
import Data.Ix (range)
import Control.Monad
import Control.Applicative
import Text.Printf

readDigits = map read <$> words <$> getLine :: IO [Int]

main :: IO ()
main = do
    s <- concat <$> map (\(c:_) -> toUpper c:[]) <$> words <$> getLine
    putStrLn s

Measured memory_bytes: 508
n = gets.to_i
arr = Array.new(n).map{Array.new(2, 0)}

(0..n-1).each do |i|
  x, l = gets.split.map(&:to_i)
  arr[i][0] = x - l
  arr[i][1] = x + l
end
arr.sort_by! { |a| a[1] }
ans = 0
cur = -1e9
(0..n-1).each do |i|
  next if cur > arr[i][0]
  ans += 1
  cur = arr[i][1]
end
puts ans

Measured memory_bytes: 13176
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N; 
	int X[100010] = {}; 
	for(int i = 0; i < N; i++) cin >> X[i]; 
	int L, Q; cin >> L >> Q; 
	int A[100010][18] = {}; //A[iから始めて][2^j日で進める]
	for(int i = 0; i < N; i++){
		int a = upper_bound(X, X+N, X[i] + L) - X; 
		A[i][0] = a - 1; 
	}
	for(int j = 1; j < 18; j++){
		for(int i = 0; i < N; i++){
			A[i][j] = A[A[i][j-1]][j-1]; 
		}
	}
	for(int q = 0; q < Q; q++){
		int a, b; cin >> a >> b; 
		a--; b--; 
		if(a > b) swap(a, b); 
		int now = a; 
		int ans = 0; 
		for(int i = 17; i >= 0; i--){
			if(A[now][i] >= b) continue;  
			now = A[now][i]; 
			ans += (1 << i); 
		}
		cout << ans + 1 << endl; 
	}
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1000000007;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)

int main(void){
    int x;
    cin>>x;
    cout<<(x^1)<<endl;
    return 0;
}


Measured memory_bytes: 3588
/*
????°??????????????£? = ??????????????????
while(?????? == false){
    ????°??????????????£?++;
}

?????????:1 2 3 4 5 6 
???  ???:X X X O O O
X???1???????????????O???????°??????????

????°????O??¨?????§???X?????????????????????
??????????????????????????°??????
*/
//--- --- --- debug function --- --- ---
// #define DEBUG // switch this macro
#ifdef DEBUG
#include <cstdio>
typedef int (*printf_t)(const char* format, ...);
printf_t printfd = std::printf;
#else
int printfd(const char* format, ...){return 0;}
#endif
//--- --- --- debug function --- --- ---
#include <cassert>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

bool Check(const std::vector<int> Wi, int k, int P)
{
    if(*std::max_element(Wi.begin(), Wi.end()) > P) return false;
    int p = 0;
    --k;
    for(int i = 0; i < Wi.size(); ++i){
        if(P - p >= Wi[i]){
            p += Wi[i];
        }else{
            p = Wi[i];
            --k;
        }
    }
    return k >= 0;
}
int main()
{
    int n,k;
    std::cin >> n >> k;
    std::vector<int> Wi(n);
    for(int i = 0; i < n; ++i){
        std::cin >> Wi[i];
    }

    int MaxValue = *std::max_element(Wi.begin(), Wi.end());
    int MaxBad  = std::accumulate(Wi.begin(), Wi.end(), 0) / k - 1;
    int MinGood = std::ceil(((double)n / k)) * MaxValue;
    int P = (MaxBad + MinGood) / 2;
    printfd("Max:%d, Min:%d, P:%d\n", MaxBad, MinGood, P);
    while(MaxBad + 1 != MinGood){
        if(MaxValue <= P && Check(Wi, k, P)){
            MinGood = P;
        }else{
            MaxBad = P;
        }
        P = (MaxBad + MinGood) / 2;
        printfd("Max:%d, Min:%d, P:%d\n", MaxBad, MinGood, P);
    }
    std::cout << MinGood << std::endl;
    return 0;
}

Measured memory_bytes: 1796
def ex_sum(n):
    r=n%4
    if r==0:
        return n
    elif r==1:
        return 1
    elif r==2:
        return n+1
    else:
        return 0

A,B=map(int,input().split())
ans=ex_sum(A-1)^ex_sum(B)
print(ans)


Measured memory_bytes: 2940
n = int(input())
fib = [0] * (n + 1)
if n == 0 or n == 1:
    print(1)
    exit()
    
fib[0] = 1
fib[1] = 1
for i in range(2, n + 1):
    fib[i] = fib[i - 1] + fib[i -2]

print(fib[-1])


Measured memory_bytes: 5600
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
typedef unsigned long long ll;

// 最大公約数求める関数
int my_gcd(int n , int m){
  if(n < m){
    int tmp = n;
    n = m;
    m = tmp;
  }
  int l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return m;
}

//char⇒int関数
 int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}



int main(){
int N; cin >> N;
vector<int> A(101);
int flag = true;
rep(i,N){
  cin >> A[i];
  if(A[i] % 2 == 0){
    if(A[i] % 3 == 0 || A[i] % 5 == 0){

    }
    else {
      flag = false;
    }
  }
}
if(flag) cout << "APPROVED" << endl;
else cout << "DENIED" << endl;
  }


Measured memory_bytes: 256
//For fast competitive programming

//INCLUDE
#include <bits/stdc++.h>
using namespace std;

//DATA_TYPES
typedef long long ll; 
typedef vector<int> vi;
typedef pair<int, int> ii; 
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f; //Infinity

//INITIALISING
//memset(arr, 0, sizeof arr);
//vi v(N, 0);

int main()
{
	std::ios_base::sync_with_stdio(0);
	std::cin.tie(NULL);
	
	//write your code here
	ll t;
	cin>>t;
    int ans=0;
    
    for (ll i=100;i<t;)
    {
        i=i+(0.01)*i;
        ans++;
       // cout<<i<<endl;
    }

	cout<<ans;
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

	bool b = true;
	for (int i = 0; i < s.length(); i++)
	{
		if (i % 2 != 0)
		{
			if (s.substr(i, 1) == "R")
			{
				b = false;
				break;
			}
		}
		else
		{
			if (s.substr(i, 1) == "L")
			{
				b = false;
				break;
			}
		}
	}

	cout << (b ? "Yes" : "No") << endl;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
from bisect import *

N = int(input())
A = list(map(int, input().split()))
acc = [0]

for Ai in A:
    acc.append(acc[-1]+Ai)

ans = 10**18
P_idx = 0
R_idx = 2

for i in range(1, N-2):
    PQ = acc[i+1]
    
    while abs(PQ-2*acc[P_idx+1])<abs(PQ-2*acc[P_idx]):
        P_idx += 1
    
    P = acc[P_idx]
    Q = PQ-P
    
    RS = acc[-1]-PQ
    
    while abs(RS-2*(acc[R_idx+1]-acc[i+1]))<abs(RS-2*(acc[R_idx]-acc[i+1])):
        R_idx += 1
        
    R = acc[R_idx]-acc[i+1]
    S = RS-R
    
    ans = min(ans, max(P, Q, R, S)-min(P, Q, R, S))

print(ans)

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

int main() {
  char s[101];
  scanf("%s", s);

  int n = strlen(s);
  for (int i = 0; i < n; i++) {
    if ((i+1)%2 == 1 && s[i] == 'L') {
      printf("No\n");
      return 0;
    } else if ((i+1)%2 == 0 && s[i] == 'R') {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
ll n,cnt=0;
string s1,s2;
int main() {
 //   freopen("../in.in", "r", stdin);
//    freopen("../out.out","w",stdout);
    ios::sync_with_stdio(false);
    ll t, i, j = 0;
    ll m, x, y,k;
    cin>>s1>>s2;
    ll maxn=0;
    for(i=0;i<=s1.length()-s2.length();i++){
        cnt=0;
        for(j=0;j<s2.length();j++){
            if(s1[i+j]==s2[j]) cnt++;
        }
        maxn=max(maxn,cnt);
    }
    cout<<s2.length()-maxn<<endl;
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
char n[4];
cin >> n;
int flg = -1;
REP(i,2) {
  if(n[i]==n[i+1]&&n[i+1]==n[i+2]) flg++;
}
if(flg!=-1) {
  cout << "Yes" << endl;
} else {
  cout << "No" << endl;
}
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 250

int parent(int);
int left(int);
int right(int);

int A[N];

main()
{
  
  
  int n,i;
  
  
  
  
  scanf("%d",&n);
  
  for(i = 1; i <= n; i++){
    scanf("%d",&A[i]);
  }
  
  for(i = 1; i <= n; i++){ 
    if(parent(i) == 0){ 
      if(n >= right(i)){  
	printf("node %d: key = %d, left key = %d, right key = %d, \n",i,A[i],A[left(i)],A[right(i)]);
      }
      else if(n >= left(i) && n < right(i)){
	printf("node %d: key = %d, left key = %d, \n",i,A[i],A[left(i)]);
      }
      else if(n < left(i)){
	printf("node %d: key = %d, \n",i,A[i]);
      }
    }
    else{
	if(n >= right(i)){  
	  printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, \n",i,A[i],A[parent(i)],A[left(i)],A[right(i)]);
	}
	else if(n >= left(i) && n < right(i)){
	  printf("node %d: key = %d, parent key = %d, left key = %d, \n",i,A[i],A[parent(i)],A[left(i)]);
	}
	else if(n < left(i)){
	  printf("node %d: key = %d, parent key = %d, \n",i,A[i],A[parent(i)]);
	}
    }
  }
    
  return 0;
  
}

int parent(int a)
{
  return a/2;
}

int left(int a)
{
  return 2*a;
}

int right(int a)
{
  return 2*a + 1;
}

Measured memory_bytes: 596
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;

class Segment_Tree {
	vector<long long int>v;
	vector<int>l;
	vector<int>r;
	int num;
	long long int ret;
	bool is_min;
	long long int Update(int place) {
		if (place >= (int)v.size() / 2) {
			return v[place];
		}
		if (is_min) {
			v[place] = min(Update(place * 2), Update(place * 2 + 1));
			return v[place];
		}
		v[place] = max(Update(place * 2), Update(place * 2 + 1));
		return v[place];
	}
	void RMQ(int a, int b, int place) {
		if (l[place] >= a&&r[place] <= b) {
			if (is_min)ret = min(ret, v[place]);
			else ret = max(ret, v[place]);
			return;
		}
		if (l[place]>b || r[place]<a) return;
		RMQ(a, b, place * 2);
		RMQ(a, b, place * 2 + 1);
		return;
	}
public:
	void Left(int place) {
		if (place >= (int)v.size() / 2) {
			l[place] = place - v.size() / 2;
			return;
		}
		Left(place * 2);
		Left(place * 2 + 1);
		l[place] = l[place * 2];
		return;
	}
	void Right(int place) {
		if (place >= (int)v.size() / 2) {
			r[place] = place - v.size() / 2;
			return;
		}
		Right(place * 2);
		Right(place * 2 + 1);
		r[place] = r[place * 2 + 1];
		return;
	}
	Segment_Tree(int n, bool min) {
		num = 1;
		while (num < n * 2) {
			num *= 2;
		}
		l.resize(num);
		r.resize(num);
		if (min) {
			v.resize(num, LLONG_MAX);
			is_min = true;
		}
		else v.resize(num, LLONG_MIN);
		Left(1);
		Right(1);
	}
	void Insert(int place, long long int num, bool update) {
		place += v.size() / 2;
		v[place] = num;
		if (!update)return;
		place /= 2;
		while (place) {
			if (is_min)v[place] = min(v[place * 2], v[place * 2 + 1]);
			else v[place] = max(v[place * 2], v[place * 2 + 1]);
			place /= 2;
		}
	}
	void TopDown() {
		Update(1);
	}
	long long int RMQ(int a, int b) {
		if (is_min)ret = LLONG_MAX;
		else ret = LLONG_MIN;
		RMQ(a, b, 1);
		return ret;
	}
};


int main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
	return 0;
}



Measured memory_bytes: 256
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,q=map(int,input().split())
query=[list(map(int,input().split())) for i in range(q)]

tate=deque([(n,n-2)])
yoko=deque([(n,n-2)])
ans=(n-2)*(n-2)
for i,j in query:
    if i==1:
        a,b=tate,yoko
    else:
        b,a=tate,yoko
    tmp=bisect.bisect_left(a,(j,0))
    # print(a[tmp][1])
    ans-=a[tmp][1]
    if tmp==0:
        b.appendleft((a[tmp][1]+2,j-2))
        a.appendleft((j,a[tmp][1]))
    # print(tate,yoko)
print(ans)

Measured memory_bytes: 116112
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

void solve(){
    ll n,k;
    cin>>n>>k;
    set<ll> s;
    rep(i,0,k){
        ll d;
        cin>>d;
        rep(j,0,d){
            ll x;
            cin>>x;
            s.insert(x);
        }
    }
    cout<<n-s.size()<<endl;
    return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll no;
    // cin>>no;
    no = 1;
    while(no--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3536