akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define li long long int
int ans=0;
char a[1001][1001];
int sol[1001][1001];
int solve(char a[][1001],int i,int j,int n,li mod)
{
    //BaseCase
    if(i==n-1 && j==n-1)
    {
        return 1;
    }
    if(sol[i][j]!=0)
    {
        return sol[i][j];
    }
    //RecurCase
    if(a[i+1][j]!='*' && i+1<n)
    {
        sol[i][j]= (solve(a,i+1,j,n ,mod) )%mod;
    }
    if(a[i][j+1]!='*' && j+1<n)
    {
        (sol[i][j]+=solve(a,i,j+1,n,mod))%=mod;
    }
    return sol[i][j];
}


int main()
{
    li n,i,j,m;
    scanf("%lld%lld",&n,&m);
    memset(sol,0,sizeof(sol));



    li mod=1000000000+7;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }

    for(i=m-2;i>=0;i--)
    {
        if(a[n-1][i+1]!='#' && a[n-1][i]!='#')
        {
            sol[n-1][i]=1;
        }else
        {
            break;
        }
    }
    for(i=n-2;i>=0;i--)
    {
        if(a[i+1][m-1]!='#' && a[i][m-1]!='#')
        {
            sol[i][m-1]=1;
        }else
        {
            break;
        }
    }
    if(a[n-1][m-1]=='#')
    {cout<<0;return 0;}

    for(i=n-2;i>=0;i--)
    {
        for(j=m-2;j>=0;j--)
        {
            if(a[i][j]!='#')
                sol[i][j]=(sol[i+1][j]+sol[i][j+1])%mod;
        }
    }

    cout<<sol[0][0];
    return 0;
}


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

using namespace std;

const int MAX = 999984;
vector<int> v;
bool prime[MAX];

void sieve(){
    fill(prime, prime+MAX, true);
    prime[0] = prime[1] = false;

    for(int i=0; i < MAX; i++){
        if(!prime[i]) continue;
        v.push_back(i);
        for(int j=i+i; j < MAX; j += i){
            prime[j] = false;
        }
    }
}

int main(){
    sieve();
    int n;
    while(cin >> n, n){
        int ans = 0;
        for(int i=0; i< n; i++){
            int a, b;
            cin >> a >> b;
            int p = lower_bound(v.begin(), v.end(), a+b+1) - lower_bound(v.begin(), v.end(), a-b);
            ans += p;
        }
        ans -= n;
        cout << ans << endl;
    }
}

Measured memory_bytes: 2564
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  if(a%2==1 && b%2==1 && c%2==1){
    long long ans=0;
    ans = min (a*b, b*c);
    ans = min (ans, c*a);
    cout << ans << endl;
  }
  else cout << 0 << endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  int ans = 0;
  for(int i = 0;i<n;i++){
    cin >> a[i];
    if(i!=0){
      if(a[i] == a[i-1]){
        ans++;
        a[i] = 0;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  ll N;
  string S;
  cin >> N >> S;
  ll numR = count(S.begin(), S.end(), 'R');
  ll numG = count(S.begin(), S.end(), 'G');
  ll numB = count(S.begin(), S.end(), 'B');
  ll res = numR*numG*numB;
  for (ll i=0; i<N; i++) {
    for (ll j=i+1; j<N; j++) {
      if (j<2*j-i&&2*j-i<N) {
        ll k = 2*j-i;
        if (S[i]!=S[j]&&S[i]!=S[k]&&S[j]!=S[k]) res--;
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 3584
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

bool saur(const string &a , const string &b)
{
    string x=a+b,y=b+a;
	if(x<y)
	{
		return 1;
	}
	
	else
	return 0;
	
}


int main()
{
    
    int n,l;
    scf(n),scf(l);
    
    vector<string>v(n);
    
    rep(i,0,n)
    cin>>v[i];
    
    sort(all(v));
    
    
    sort(all(v),saur);
    
    for(auto it:v)
    cout<<it;
    
 
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#ifdef LOCAL
#include "debug.h"
#define dump(...)                                                    \
    cout << "   " << string(#__VA_ARGS__) << ": "                    \
         << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" \
         << endl                                                     \
         << "   ",                                                   \
        dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif

#define ll long long
#define int ll
#define BUF 1e5
#define INF 1 << 30
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
constexpr ll mod = 1e9 + 7;
using namespace std;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    cin >> A >> B >> Q;
    vi s(A), t(B);
    for (int i = 0; i < A; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < B; i++) {
        cin >> t[i];
    }
    for (int i = 0; i < Q; i++) {
        ans = 1e17;
        int x;
        cin >> x;
        int sind = lower_bound(all(s), x) - s.begin();
        int tind = lower_bound(all(t), x) - t.begin();
        int sd[2], td[2];
        sd[0] = s[sind];
        if (sind > 0) {
            sd[1] = s[sind - 1];
        } else {
            sd[1] = s[sind];
        }
        td[0] = t[tind];
        if (tind > 0) {
            td[1] = t[tind - 1];
        } else {
            td[1] = t[tind];
        }
        for (int bit = 0; bit < (1 << 2); bit++) {
            int sb = (bit >> 1) & 1;
            int tb = bit & 1;
            ll tmp = min(abs(sd[sb] - x) + abs(td[tb] - sd[sb]), abs(td[tb] - x) + abs(sd[sb] - td[tb]));
            ans = min(ans, tmp);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 2944
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        index = bisect.bisect_left(L, L[i] + L[j])
        ans += max(0, index - j - 1)
print(ans)


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

int main()
{
	int a = {};
	int b = {};
	int c = {};
	int d = {};
	cin >> a >> b >> c >> d;
	if (a <= b) {
		if (c <= d) {
			cout << a + c << endl;
		}
		else {
			cout << a + d << endl;
		}
	}
	else {
		if (c <= d) {
			cout << b + c << endl;
		}
		else {
			cout << b + d << endl;
		}
	}

    return 0;
}

Measured memory_bytes: 256
(defun mmp (s)
  (and (>= (parse-integer s) 1 ) (<= (parse-integer s) 12)))

(defun ans (s)
  (cond
    ((and (mmp (subseq s 0 2)) (mmp (subseq s 2 4)))
     "AMBIGUOUS")
    ((and (not (mmp (subseq s 0 2))) (mmp (subseq s 2 4)))
     "YYMM")
    ((and (mmp (subseq s 0 2)) (not (mmp (subseq s 2 4))))
     "MMYY")
    (t "NA")))

(format t "~a~%" (ans (read-line)))


Measured memory_bytes: 10464
#include<stdio.h>
#include<string.h>
#define OK 1;
#define False 0;
typedef struct pp
{
	char name[20];
	int num;
}Qu;
Qu Q[100000];
int head, tail, MAXSIZE = 100000;
void Initialize()
{
	head = tail = 0;
}

int IsEmpty()
{
	if(head == tail)
	{
		return OK;	
	}		
	else
	{
		return False;
	}
		
}

int IsFull()
{
	if(head = (tail + 1) % MAXSIZE) 
		return OK;
}

void EnQueue(Qu x)
{
	if(!IsFull)
		printf("上溢!\n");
	Q[tail] = x;
	tail = (tail + 1) % MAXSIZE;
}

Qu DeQueue()
{
	if(!IsEmpty)
		printf("下溢！\n");
	Qu x = Q[head];
	head = (head + 1) % MAXSIZE;
	return x;
}

int Min(int x, int y)
{
	return x < y ? x: y; 
}
int main()
{
	int sum = 0, n, q, c;
	scanf("%d%d", &n, &q);
	for(int i = 0; i < n; i++)
	{
		scanf("%s%d", Q[i].name, &Q[i].num);
	}
	head = 0;
	tail = n;
	Qu tmp;
	while(!IsEmpty())
	{
		tmp = DeQueue();
		c = Min(q, tmp.num);
		tmp.num = tmp.num - c;
		sum = sum + c;
		if(tmp.num > 0)
			EnQueue(tmp);
		else
			printf("%s %d\n", tmp.name, sum);
		
	}
	return 0;
}



Measured memory_bytes: 4912
import Data.List

type Point = (Int, Int)
type Rect = ((Int, Int), (Int, Int))

main :: IO ()
main = do
    [n, k] <- map read . words <$> getLine :: IO [Int]
    ps <- map (\[x, y] -> (read x, read y)) . map words . lines <$> getContents :: IO [Point]

    let xs = nub . sort . map fst $ ps :: [Int]
    let ys = nub . sort . map snd $ ps :: [Int]

    let rs = [((x0, y0), (x1, y1)) | x0 <- xs, x1 <- xs, x0 < x1, y0 <- ys, y1 <- ys, y0 < y1] :: [Rect]
    let rs_ge_k = filter (\r -> (count r ps) >= k) rs :: [Rect]
    print $ minimum . map area $ rs_ge_k

count :: Rect -> [Point] -> Int
count r = length . filter (in_rect r)

in_rect :: Rect -> Point -> Bool
in_rect ((x0, y0), (x1, y1)) (s, t) = x0 <= s && s <= x1 && y0 <= t && t <= y1

area :: Rect -> Integer
area ((x0, y0), (x1, y1)) = (x1' - x0') * (y1' - y0')
    where x0' = toInteger x0
          x1' = toInteger x1
          y0' = toInteger y0
          y1' = toInteger y1


Measured memory_bytes: 2428
N = int(input())
values = [ int(v) for v in input().split(" ") ]

left = None
right = None
n = 0

for i in range(N):
  if values[i] == i+1: # NG pattern
    if i == 0:
      values[i], values[i+1] = values[i+1], values[i] # exchange right
    elif i == N-1:
      values[i], values[i-1] = values[i-1], values[i] # exchange left
    elif left == i+1:
      values[i], values[i+1] = values[i+1], values[i] # exchange right
    elif right == i+1:
      values[i], values[i-1] = values[i-1], values[i] # exchange left
    else:
      values[i], values[i+1] = values[i+1], values[i] # exchange right
      
    n += 1
    
#print(values)
print(n)

Measured memory_bytes: 20696
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cstring>
using namespace std;
typedef long long int ll;

void solve(int n){
	int mx=0,mx2=0;
	map<char,int> mp;
	vector<char> s(n);
	int cnt[26]={};
	int ma=0;
	char c;
	for(int i=0;i<n;i++){
		cin >> s[i];
		cnt[s[i]-'A']++;
		ma=max(ma,cnt[s[i]-'A']);
	}
	for(int i=0;i<26;i++){
		if(ma==cnt[i])c=(char)('A'+i);
	}
	sort(cnt,cnt+26);
	if(cnt[24]==cnt[25]){
		printf("TIE\n");
		return;
	}
	ma=0;
	int ma2=0;
	for(int i=0;i<n;i++){
		mp[s[i]]++;
		if(s[i]==c){
			ma++;
		}else{
			ma2=max(ma2,mp[s[i]]);
		}
		if(ma2+(n-i-1)<ma){
			printf("%c %d\n",c,i+1);
			return;
		}
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1){
		int n;cin >> n;
		if(n==0)break;
		solve(n);
	}
}


Measured memory_bytes: 3300
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;


int main(void) {

  int n, k, s;
  while(cin >> n >> k >> s){
    if( n == 0 ) break;

    int dp[21][21][156] = {};
    dp[0][0][0] = 1;
    for(int i=1; i<=n; i++){
      for(int j=0; j<=k; j++){
        for(int l=0; l<=s; l++){
          if( l >= i && j != 0 ) dp[i][j][l] += dp[i-1][j-1][l-i];
          dp[i][j][l] += dp[i-1][j][l];
        }
      }
    }
    cout << dp[n][k][s] << endl;

  }


  return 0;
}

// EOF

Measured memory_bytes: 3348
// Problem : 
// 			E - Almost Everywhere Zero
// 			Editorial
// 		
// Contest : AtCoder - AtCoder Beginner Contest 154
// URL : https://atcoder.jp/contests/abc154/tasks/abc154_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
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;
 
#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,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#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
 
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 ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
string str;
int K;
int N;
map<pi,ll> m1,m2;
ll calc(bool eq,int k,int level) 
{
	if(k==0)
		return 1;
	if(level==N)//?
		return 0;//?
	if(str[level]=='0')
	{
		if(eq)
			return calc(true,k,level+1);
		else
			return 9*calc(false,k-1,level+1)+calc(false,k,level+1);
	}
	
	if(eq)
	{
		if(m1.find({k,level})!=m1.end())
			return m1[{k,level}];
		return m1[{k,level}]=calc(true,k-1,level+1)+calc(false,k,level+1)+(str[level]-'0'-1)*calc(false,k-1,level+1);
		// return m1[{k,level}];
	}
	else
	{
		if(m2.find({k,level})!=m2.end())
			return m2[{k,level}];
		return m2[{k,level}]=9*calc(false,k-1,level+1)+calc(false,k,level+1);
	}
}
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	cin>>str;
	cin>>K;
	N=sz(str);
	cout<<calc(true,K,0);
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3636
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    string n;
    cin >> n;
    cout << (n[0] == '7' || n[1] == '7' || n[2] == '7' ? "Yes" : "No");
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
const int N = 200010;
int n;
char s[N];
int main() {
  scanf("%d", &n);
  scanf("%s", s + 1);
  int cnt = 0, c = 0;
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'R') ++cnt;
  }
  for (int i = 1; i <= cnt; i++) {
    if (s[i] == 'R') ++c;
  }
  printf("%d", cnt - c);
  return 0;
}

Measured memory_bytes: 4004
#include <iostream>
#include <vector>


using namespace std;

int main()
{
	long long A;
	double dB;
	long long B;
	long long tmp;
	int diff;

	// Input
	cin >> A >> dB;

	B = (long long)(dB * 100);
	tmp = A * B;
	diff = (tmp % 100);
	cout << ((tmp - diff) / 100) << endl;

	return 0;
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf (1ll<<60)

ll dp[405][405];
ll sum[405][405];

ll solve(std::vector<ll>& v, ll i, ll j)
{
	//base case
	if (i == j)
		return 0;
	//when answer is calculated before
	if (dp[i][j] != -1)
		return dp[i][j];

	//recursive
	ll minCost = inf;//store the minm value
	for (int k = i; k < j; k++)
	{
		minCost = min(minCost, sum[i][j] + solve(v, i, k) + solve(v,  k + 1, j));
	}

	return dp[i][j] = minCost;
}

void preprocess(vector<ll>& v, ll n)
{
	for (int i = 1; i <= n; i++ )
	{
		for (int j = i; j <= n; j++)
		{
			sum[i][j] = v[j] + ((j == i) ? 0 : sum[i][j - 1]);
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin >> n;
	memset(dp, -1, sizeof dp);
	vector<ll> v(n + 1);//store height of slime

	for (int i = 1; i <= n; i++)
		cin >> v[i];

	preprocess(v, n);

	cout << solve(v, 1, n);
}

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


int main(){
    ll N, M, C, ans = 0;
    cin >> N >> M >> C;
    ll B[M];
    ll A[N][M];
    for(int i = 0; i < M; i++){
        cin >> B[i];
    }

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

    for(int i = 0; i < N; i++){
        ll tmp = 0;
        for(int j = 0; j < M; j++){
            tmp += A[i][j] * B[j];
        }

        if(tmp + C > 0){
            ans++;
        }
    }

    cout << ans << endl;
}

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

int main() {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  if(a1 + a2 + a3 <= 21) {
    cout << "win" << endl;
  } else {
    cout << "bust" << endl;
  }
  
  // cout << a1 << endl;
  return 0;
}


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

int main(void){
  int i, j, k = 3, n, s, sosu[78500];
  int max, min, mid;

  sosu[0] = 1;
  sosu[1] = 2;
  sosu[2] = 3;
  for(i = 5; i <= 999999; i += 2){
    s = 0;
    for(j = 2; sosu[j] <= sqrt((double)i); j++){
      if(i % sosu[j] == 0){
	s++;
	break;
      }
    }
    if(s == 0){
      sosu[k++] = i;
    }
  }
  
  while(scanf("%d", &n) != EOF){
    min = 0;
    max = k;
    mid = (min + max) / 2;
    while(min+1 != max){
      if(sosu[mid] < n){
	min = mid;
      }else if(sosu[mid] > n){
	max = mid;
      }else{
	break;
      }
      mid = (min + max) / 2;
    }
    printf("%d\n", mid);
  }
  return 0;
}

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

namespace V0105_2{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var list = new List<string[]>();
            string input;

            while((input = sr.Next<string>()) != null){
                var num = sr.Next<string>();
                list.Add(new[]{input, num});
            }

            list
                .GroupBy(s => s[0])
                .OrderBy(g => g.Key)
                .ToList()
                .ForEach(g =>{
                    Console.WriteLine(g.Key);
                    Console.WriteLine(string.Join(" ",
                        g.Select(s => int.Parse(s[1]))
                            .OrderBy(s => s)
                            .Select(x => x.ToString())
                            .ToArray()
                            ));
                });
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = Console.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var result = new T[x];
            for(var i = 0; i < x; ++i) result[i] = Next<T>();
            return result;
        }

        public T[][] Next<T>(int y, int x){
            var result = new T[y][];
            for(var i = 0; i < y; ++i) result[i] = Next<T>(x);
            return result;
        }
    }
}

Measured memory_bytes: 11092
#include<stdio.h>

int main()
{
	int a, b, c;
	int cnt = 0;
	
    scanf("%d%d%d", &a, &b, &c);

	for (int i = 1; i < c+1; i++)
	{
		if (c%i == 0)
		{
			if (i >= a && i <= b)
			{
				cnt++;
			}
		}
	}

	printf("%d\n", cnt);
	
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int n, k;
  cin >> n >> k;
  int d, a;
  vi s(n);
  re(i, k) {
    cin >> d;
    re(j, d) {
      cin >> a;
      s[a-1]++;
    }
  }
  int cnt = 0;
  re(i, n) {
    if(s[i] == 0) cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include<algorithm>
#include <set>
#include <map>
#include<bits/stdc++.h>

using namespace std;

int main(){
   int N;
   cin >> N;
   map<int,int>mp;
   for(int i=0;i<N;i++){
       int a;
       cin >> a;
       mp[a-1] +=1;
       mp[a  ] +=1;
       mp[a+1] +=1;
   }
   int ans = 0;
   for(auto &x : mp){
       ans = max(ans, x.second);
   }
   cout << ans << endl;
}


Measured memory_bytes: 4736
# -*- coding: utf-8 -*-

S = input()

odd = 'R'
even = 'L'

end = len(S)

flag = True

for i in range(0, end, 2):
    if S[i] == even:
        flag = False


for i in range(1, end, 2):
    if S[i] == odd:
        flag = False


if flag:
    print('Yes')
else:
    print('No')


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

using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

#ifdef _LOCAL
struct Tester {
    Tester() { freopen("sample.in", "r", stdin); }
    ~Tester() { fprintf(stderr, "\nTime: %d ms\n", int(1000.0 * clock() / CLOCKS_PER_SEC)); }
} _tester;
#endif

const int INF = 0x3F3F3F3F;
const LL INFLL = 0x3F3F3F3F3F3F3F3FLL;
const int N = 2550;

struct aP
{
    int a, b;
    aP(){}
    aP(int a, int b):a(a), b(b){}
    bool operator < (const aP &c) const{
        if(a == c.a) return b > c.b;
        return a > c.a; 
    }
};

struct bP
{
    int a, b;
    bP(){}
    bP(int a, int b):a(a), b(b){}
    bool operator < (const bP &c) const{
        if(b == c.b) return a > c.a;
        return b > c.b; 
    }
};

priority_queue<aP> input;
priority_queue<bP> already;

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i ++){
        int a, b;
        scanf("%d%d", &a, &b);
        input.push(aP(m - a, b));
    }
    while(!input.empty()){
        if(input.top().a >= (int)already.size()){
            // printf("[%d,%d]\n", input.top().a, input.top().b);
            already.push(bP(input.top().a, input.top().b));
        }else if((int)already.size() - 1 >= 0 && input.top().a == (int)already.size() - 1 && input.top().b > already.top().b){
            // printf("[%d,%d]->[%d,%d]\n", already.top().a, already.top().b, input.top().a, input.top().b);
            already.pop();
            already.push(bP(input.top().a, input.top().b));
        }
        input.pop();
    }
    LL ans = 0;
    while(!already.empty()){
        ans += 1LL * already.top().b;
        already.pop();
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2548
h,w = map(int,input().split())
s = [input() for _ in range(h)]
dp = [[float('inf')]*w for i in range(h)]
dp[0][0] = 1 if s[0][0]=='#' else 0
for x in range(h):
    for y in range(w):
        if x+1<h:
            a = 1 if s[x][y]=='.' and s[x+1][y]=='#' else 0
            dp[x+1][y] = min(dp[x][y]+a,dp[x+1][y])
        if y+1<w:
            a = 1 if s[x][y]=='.' and s[x][y+1]=='#' else 0
            dp[x][y+1] = min(dp[x][y]+a,dp[x][y+1])

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



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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 100007;

int n;
int a[MAXN];

void init ();
void input ();
void work ();

int getcur ()
{
	int cc = 0;
	lpi ( i, 1, n ) cc ^= ( a[i] - 1 ) & 1;
	return cc;
}

int gcd ( int x, int y )
{
	return y ? gcd ( y, x%y ) : x;
}



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here
	
	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method
	
	scanf ( "%d", &n );
	lpi ( i, 1, n ) scanf ( "%d", &a[i] );
}

void work ()
{
	// main work
	
	if ( n == 1 ){
		cout << "Second" << endl;
		return;
	}else if ( n == 2 ){
		cout << ( ( ( a[1] ^ a[2] ) & 1 ) ? "First" : "Second" ) << endl;
		return;
	}
	
	if ( getcur () ) cout << "First" << endl;
	else{
		int t = 0, cc, g;
		while ( 1 ){
			cc = 0;
			if ( getcur () ){
				cout << ( t ? "Second" : "First" ) << endl;
				break;
			}
			lpi ( i, 1, n ) cc += a[i] & 1;
			if ( cc > 1 || ( *min_element ( a+1, a+1+n ) == 1 ) ){
				cout << ( t ? "First" : "Second" ) << endl;
				break;
			}
			lpi ( i, 1, n ) if ( a[i] & 1 ) --a[i];
			g = a[1];
			lpi ( i, 2, n ) g = gcd ( g, a[i] );
			lpi ( i, 1, n ) a[i] /= g;
			t ^= 1;
		}
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n,m;
    in(n,m);
    if(m<=n){
        out(0);
        return 0;
    }
    vector<int> x(m);
    vector<pair<int,int>> def(m-1); 
    in(x);
    sort(all(x));
    rep(i,m-1){
        def[i]=make_pair(x[i+1]-x[i],i+1);
    }
    sort(rall(def));
    vector<int> devide_index;
    devide_index.push_back(0);
    rep(i,n-1){
        devide_index.push_back(def[i].second);
    }
    devide_index.push_back(m);
    sort(all(devide_index));
    ll ans=0;
    rep(i,n){
        ans+=(ll)x[devide_index[i+1]-1]-(ll)x[devide_index[i]];
    }
    out(ans);
}

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

int main() {
  
  int a , b , c;
  
  cin >> a >> b >> c;
  
  if (a < b) {
    
    if (b < c) {
      
      cout << a + b << endl;
      
    }
    
    else {
      
      cout << a + c << endl;
      
    }
  }
  
  else {
    
    if ( a > c) {
      
      cout << b + c << endl;
      
    }
    
    else {
      
      cout << a + b << endl;
    }
  }
}
      

Measured memory_bytes: 256
def getIntList(inp):
	return [int(_) for _ in inp]


from sys import stdin
import sys
sys.setrecursionlimit(10**8)

def getInputs():
	inputs=[]
	for line in stdin:
		line=line.split()
		inputs.append(line)
	return inputs



def main(inputs):
	n,m=getIntList(inputs[0])
	
	ans=n*(n-1)//2+m*(m-1)//2
	print(ans)
	
	

if __name__=="__main__":
	inputs=getInputs()
# 	inputs=simInputs()
	main(inputs)


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

int main(){
 	int n, m;
  	cin>>n>>m;
  	
  	string s1(n, 48 + m);
  	string s2(m, 48 + n);
	cout<<(s1<s2?s1:s2);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int q = sc.nextInt();
		int[] L = new int[m];
		int[] R = new int[m];
		
		int[][] map = new int[n+1][n+1];
		for(int i= 0;i < m;i++){
			L[i] = sc.nextInt();
			R[i] = sc.nextInt();
			map[L[i]][R[i]]++;
		
		}
		int[][] sum =new int[n+1][n+1];
		for(int i = 1;i <= n;i++){
			for(int j = 1;j <= n;j++){
				sum[i][j] = sum[i][j-1]+map[i][j];
			}
		}
		
		
		
		
		
		int[] P = new int[q];
		int[] Q = new int[q];
		for(int i= 0;i < q;i++){
			P[i] = sc.nextInt();
			Q[i] = sc.nextInt();
			long ans = 0;
			for(int j = P[i];j <= Q[i];j++){
				ans += sum[j][Q[i]] - sum[j][P[i]-1];
			}
			System.out.println(ans);
		}

		

		
	
	}


}

class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



Measured memory_bytes: 157536
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;

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

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

	VVI dp(3, VI(n + 1, 0)); // [abcのうちどれか][i日目終了時点の最大幸福度]

	for (int i = 0; i < n; i++) {
		dp[0][i+1] = max({dp[0][i], dp[1][i] + a[i], dp[2][i] + a[i]});
		dp[1][i+1] = max({dp[1][i], dp[0][i] + b[i], dp[2][i] + b[i]});
		dp[2][i+1] = max({dp[2][i], dp[0][i] + c[i], dp[1][i] + c[i]});
	}

	int ans = max({dp[0][n], dp[1][n], dp[2][n]});
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);

  unsigned long n;
  cin >> n;
  bitset<32> bs(n);

  cout << bs << endl;
  cout << ~bs << endl;
  cout << (bs << 1) << endl;
  cout << (bs >> 1) << endl;
}




Measured memory_bytes: 3240
#include<bits/stdc++.h>
#define lowbit(a) ((a)&(-(a)))
using namespace std;

void file(bool opt)
{
	if (opt&&fopen("in.txt", "r"))
	{
		freopen("in.txt", "r", stdin);
		//freopen("out.txt", "w", stdout);
	}
}

int a[105];
long long sum=0, temp=0;
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> a[i],sum+=a[i];
	long long ans = sum;
	for (int i = 1; i <= n; i++)
	{
		temp += a[i];
		ans = min(ans, abs(temp - (sum - temp)));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
nums = []
flg = True
for _ in range(5):
    nums.append(int(input()))
k = int(input())
nums = nums[::-1]
for i in range(5):
    for j in range(i,5):
        if k < nums[i]-nums[j]:
            flg = False
if flg:
    print("Yay!")
else:
    print(":(")


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


int x[15][15];
int y[15][15];
int a[15];


int ret(int f[15], int num, int max){

	int ret_p,ret_n;
	int ret_val;
	int i,j;
	int f_ok;

	ret_val = 0;
	f_ok = 1;

	if(max == num){

//		printf("===============\n");
//		printf("f :");

//		for(i=0;i<max;i++){
//			printf("%d ",f[i]);
//		}
//		printf("\n");


		for(i=0;i<max;i++){
			if(f[i] == 1){
				for(j=0;j<a[i];j++){
					if(f[x[i][j]-1] != y[i][j]){
						f_ok = 0;
					}
				}
//				printf("f_ok : %d\n",f_ok);
			}
		}

		if(f_ok == 0){
			ret_val = 0;
		}else{
			for(i=0;i<max;i++){
				ret_val += f[i];
			}
		}

//		printf("f_ok : %d  ret_val = %d\n",f_ok,ret_val);


	}else{
		f[num] = 1;
		ret_p = ret(f,num+1,max);
		f[num] = 0;
		ret_n = ret(f,num+1,max);

		
		if(ret_p > ret_n){
			ret_val = ret_p;
		}else{
			ret_val = ret_n;
		}

	}


	return ret_val;
}

int main(void){


	int n;

	int i;
	int j;

	int f[15] = {};
	int ret_val;



	scanf("%d",&n);


	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		for(j=0;j<a[i];j++){
			scanf("%d %d",&x[i][j],&y[i][j]);
		}
	}

	ret_val = ret(f,0,n);

	printf("%d\n",ret_val);



	return 0;
}





Measured memory_bytes: 256
result = []
while nil != buf = gets
	arr = []
	arr = buf.split(" ").collect do |s| s.to_i end
	result.push arr
end

i=0


for i in (0..result.length-1)
	result[i]=result[i][0]+result[i][1]
end

j=0

for j in (0..result.length-1)
	print result[j].to_s.length, "\n"
end

Measured memory_bytes: 8668
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid  + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left; k<right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if(p<r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++) {
    // マージソートとクイックソートの結果を比べる
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}


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

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	rep(i,s.size()){
		int c = (s[i]-'A' + n)%26;
		cout << char('A' + c);
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int n,B[26][500010]={0};
//BITのadd関数
//i番めの数値にnを足す
void badd(int j,int i,int a){for(;i<=n;i+=i&-i)B[j][i]+=a;}
//BITのsum関数
//1からi番めの数の総和を返す
int bsum(int j,int i){
  int s=0;
  for(;i;i-=i&-i)s+=B[j][i];
  return s;
}
int main(){
  int m,a,b,d,q,i;
  char c,s[500010]={};
  scanf("%d %s",&n,s);//printf("a\n");
  for(i=0;s[i];i++)badd(s[i]-'a',i+1,1);//printf("b\n");
  //printf("%d\n",bsum(0,1));
  scanf("%d",&m);
  while(m--){//printf("%d\n",m);
    scanf("%d",&q);
    if(q==1){
      scanf("%d %c",&a,&c);
      badd(s[a-1]-'a',a,-1);
      s[a-1]=c;
      badd(s[a-1]-'a',a, 1);
    }
    else{
      scanf("%d %d",&a,&b);
      for(i=d=0;i<26;i++){//printf("%d %d\n",bsum(i,b),bsum(i,a-1));
	if(bsum(i,b)!=bsum(i,a-1))d++;
      }
      printf("%d\n",d);
    }
  }
  return 0;
}


Measured memory_bytes: 51456
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    a[--u]++;
    a[--v]++;
  }
  for (int i = 0; i < n; i++) {
    if (a[i] % 2) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

#define INPUT_NUMBER 3

int main(void){
    int x,y,W,H,r;
    scanf("%d",&W);
    scanf("%d",&H);
    scanf("%d",&x);
    scanf("%d",&y);
    scanf("%d",&r);

    if(r<=x && x<=W-r && r<=y && y<=H-r){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 1952
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define stop exit(0)
#define dd double
#define po pop_back
#define pb push_back
#define ub upper_bound
#define lb lower_bound
int main(){
    vector <long long> v;
    ll a,b,c,d=0,e=0,f=0,g=0,i,j,k=1,l=1,r=1,n,m[300001],z[400001],h[600001],p[600001];
    string s,t,x[1001],y[1001];
    dd q,u,w;
    cin>>a;
    for(i=1;i<=a;i++){
        for(j=1;j<=a;j++){
            for(k=1;k<=a;k++){
                d+=gcd(i,gcd(j,k));
            }
        }
    }
    cout<<d;
}

Measured memory_bytes: 3676
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

N, A, B = map(int, input().split())

MOD = 10 ** 9 + 7

def myPow(x, n, MOD):
    if n == 0:
        return 1

    res = 1
    while(n > 0):
        if n & 1 == 1:
            res = res * x % MOD

        x = x * x % MOD
        n = n >> 1

    return res


ans = myPow(2, N, MOD)
ans -= 1

def cumprod(arr, MOD):
    L = len(arr)
    Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]
        arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]
        arr[n] %= MOD
    return arr.ravel()[:L]


def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64)
    x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64)
    x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv


fact, fact_inv = make_fact(B + 10, MOD)

arr = cumprod(list(range(N, N-B, -1)), MOD)

a = arr[A - 1] * fact_inv[A]
a %= MOD
b = arr[B-1] * fact_inv[B]
b %= MOD

# print(mb)
# print(fact_inv)

'''
a = ma * fact_inv[A]
a %= MOD

b = mb * fact_inv[B]
b %= MOD
'''

ans -= (a + b)
ans %= MOD

print(ans)


Measured memory_bytes: 30828
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

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

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int dp[1050][8];
int n;
const int MOD =10007;
int main(){
    cin>>n;
    dp[0][1]=1;
    char c;
    
    for(int i =1;i <= n;i++){
        cin>>c;
        int x;
        if(c=='J'){
            x =0;
        }else if(c=='O'){
            x = 1;
        }else{
            x =2;
        }
        for(int j =1;j <(1<<3);j++){//今日の状態
            if(!(j>>x&1))continue;//含んでないなら
            for(int k =1;k < (1<<3);k++){//前日の状態
                if((j&k)==0)continue;//含んでない
                dp[i][j]=(dp[i][j]+dp[i-1][k])%MOD;
            }
        }
    }
    int ans =0;
    for(int i =0;i < (1<<3);i++){
        ans =(ans+dp[n][i])%MOD;
    }
    cout <<ans<<endl;
    return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, t;
	double res = 0;
	cin >> n >> t;
	rep(i, n){
		int x, h; cin >> x >> h;
		res = max(res, h * 1.0 / x * t);
	}
	printf("%.20f\n", res);
	return 0;
}


Measured memory_bytes: 3244
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int r,g;
	cin>>r>>g;
	cout<<2*g-r<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS

    const double PI = 3.1415926535;
    double r; cin >> r;
    cout << fixed << setprecision(10) << r*2*PI << '\n';


    return 0;
}

Measured memory_bytes: 3804
import sys
n = int(input())
data = [list(map(int,input().split())) for i in range(n)]

for i in range(n):
    if i>0:
        distance = abs(data[i][1]-data[i-1][1])+abs(data[i][2]-data[i-1][2])
        time = abs(data[i][0]-data[i-1][0])
    else:
        distance = abs(data[i][1])+abs(data[i][2])
        time = abs(data[i][0])
    
    if distance <= time:
        if (data[i][0] + data[i][1] + data[i][2])% 2 == 0:
            continue
        else:
            break
    else:
        break
else:
    print("Yes")
    sys.exit()

print("No")


Measured memory_bytes: 90104
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
using ll = long long;
int n;
ll a[nax];

ll dp[65][2];

int main () {

    scanf("%d", &n);

    for (int i = 1 ; i <= n ; ++ i) {
        scanf("%lld", a + i);
    }

    ll tar = 0;

    for (int i = 3 ; i <= n ; ++ i) {
        tar ^= a[i];
    }

    ll x = a[1], y = a[2];

    ll sum = x + y;

    if (sum < tar) return !printf("-1");
    if ((sum - tar) % 2) return !printf("-1");

    ll and_sum = ((sum) - (tar)) / 2;

    fprintf(stderr, "and = %lld xor = %lld\n", and_sum, tar);

    int mx_bit = 0;

    for (int j = 0 ; j <= 60 ; ++ j) {
        if (x >> j & 1) mx_bit = j;
    }

    for (int i = 0 ; i <= 60 ; ++ i)
        dp[i][0] = dp[i][1] = -5;


    function <ll(int, bool)> rec = [&] (int pos, bool eq) -> ll{
           ll an = and_sum >> pos & 1;
           ll exor = tar >> pos & 1;
           ll this_bit = x >> pos & 1;

           if (dp[pos][eq] != -5) return dp[pos][eq];

           if (pos == 0) {
                if (an == 1) {
                    if (exor) return -1LL;
                    if (eq && this_bit == 0) return -1LL;
                    return 1;
                } else {
                    if (eq) {
                        return exor ? this_bit : 0LL;
                    } else {
                        return exor ? 1LL : 0LL;
                    }
                }
           }

           ll res = -1;

           if (an == 1) {
                if (exor) return -1LL;
                if (eq && this_bit == 0) return -1LL;
                ll get = rec(pos - 1, eq & (this_bit == 1));
                if (get != -1) {
                    res = max(res, get ^ (1LL << pos));
                }
           } else if (an == 0) {
                if (exor == 0) {
                    ll get = rec(pos - 1, eq & (this_bit == 0));
                    if (get != -1) res = max(res, get);
                } else if (exor == 1) {
                    if (eq) {
                        if (this_bit == 1) {
                            ll get = rec(pos - 1, eq);
                            if (get != -1) {
                                res = max(res, get ^ (1LL << pos));
                            }
                        }
                        ll get = rec(pos - 1, eq & (this_bit == 0));
                        if (get != -1)
                            res = max(res, get);
                    } else {
                        ll get = rec(pos - 1, false);
                        if (get != -1) res = max(res, get ^ (1LL << pos));
                    }
                }
           } else assert(false);
            return dp[pos][eq] = res;
    };

    ll ans = rec(mx_bit, true);
  ///  printf("%lld\n", ans);

    if (ans > 0 && ans <= x && ((ans ^ (sum - ans)) == tar) && (( ans & (sum - ans)) == (and_sum))) {
        printf("%lld\n", x - ans);
    } else return !printf("-1");

}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 3788
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

#define MAX 300000

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

void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long ncr(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main(void) {
    init();
    int n,m,k;
    cin >> n >> m >> k;
    int ret = 0;
    int mm = m*m%MOD;
    int nn = n*n%MOD;
    rep(i,n){
        int d = i*(i+1)/2%MOD;
        ret += (d*mm)%MOD;
        ret %= MOD;
    }
    rep(i,m){
        int d = i*(i+1)/2%MOD;
        ret += (d*nn)%MOD;
        ret %= MOD;
    }
    cout << ret*ncr(n*m-2,k-2)%MOD << endl;
}


Measured memory_bytes: 7296