akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
 
int main(){
    int n,i,j,l;
    double s[10020];
    double a2,m,a;
   
    while(1) {
        m=0;
        a2=0;
        scanf("%d" ,&n);
        if(n == 0){
            break;
        }
 
        for(i=0;i<n;i++){
            scanf("%lf",&s[i]);
            m=m+s[i];
        }
        m=m/n;
 
        for(i=0;i<n;i++){
            a2=a2+(s[i]-m)*(s[i]-m);
        }
        a2=a2/n;
 
        printf("%.11lf\n",sqrt(a2));
 
    }
 
    return 0;
}


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

int main(void) {

  double a,b,x;
  scanf("%lf %lf %lf", &a, &b, &x);
  double max = a*a*b;
  if (x*2 == max) {
    printf("%.10lf\n", 180*atan(b/a)/M_PI);
    return 0;
  }
  if (x*2 > max) {
    x = max-x;
    max /= 2;
    printf("%.10lf\n", 180*atan(b*(x/max)/a)/M_PI);
  } else {
    max /= 2;
    printf("%.10lf\n", 90-(180*atan(a*(x/max)/b)/M_PI));
  }

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
	int n;
	cin>>n;
	if(n==0)
	{
		cout<<'0'<<endl;
		return 0;  //在这个地方return 0;	
	}
	string ans="";
	while(n!=0)
	{
		if(n&1) //二进制取与，此处等同于 n%2==1
		{
			--n;
			ans+="1";//string真的是太方便了！！！ 
		}
		else
		{
			ans+="0";
		}
		n/=-2;
	}
	int len=ans.size();
	for(int i=len-1;i>=0;i--)
		cout<<ans[i];
	cout<<endl;
	return 0;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N, K;
int dp[52][52][52 * 52];
const int mod = 1000000007;

signed main() {
    cin >> N >> K;
    dp[0][0][0] = 1;
    for (int i = 1; i <= N; ++i) {
        for (int j = 0; j <= i; ++j) {
            for (int k = 0; k + 2 * j <= K; ++k) {
                int prev = dp[i - 1][j][k];
                dp[i][j][k + 2 * j] += prev;
                dp[i][j + 1][k + 2 * j] += prev;
                dp[i][j][k + 2 * j] += j * prev;
                if (j >= 1)dp[i][j - 1][k + 2 * j] += j * j * prev;
                dp[i][j][k + 2 * j] += j * prev;
            }
        }
        for (int j = 0; j <= i; ++j) {
            for (int k = 0; k <= K; ++k) {
                dp[i][j][k] %= mod;
            }
        }
    }
    cout << dp[N][0][K] << endl;
    return 0;
}


Measured memory_bytes: 54272
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <stdio.h>
#include <queue>
#include <cmath>
#include <utility>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	string S;
	cin >> S;
	const int X = 753;
	int ans = 100000;
	for (int i = 0; i < S.size() - 2; i++) {
		int p = -X +(S[i] - '0') * 100 + (S[i + 1] - '0') * 10 + S[i + 2] - '0';
		p = abs(p);
		if (p < ans)ans = p;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long int
using namespace std;
int flg1[1000][1000],flg2[1000][1000];
int main(void)
{
	int i,j,k,c,n,cnt,d,x,y,sum;
	string s[1000];
	cin>>c>>n;
	for(i=0;i<n;i++) cin>>s[i];
	for(i=0;i<n;i++) {
		for(j=0;j<n;j++) {
			flg1[i][j]=flg2[i][j]=0;
		}
	}
	cnt=0;
	for(i=0;i<n;i++) {
		for(j=0;j<n/2;j++) {
			if(s[i][j]!=s[i][n-1-j]) flg1[i][j]=1,flg1[i][n-1-j]=1,cnt++;
		}
	}
	for(i=0;i<n/2;i++) {
		for(j=0;j<n;j++) {
			if(s[i][j]!=s[n-1-i][j]) flg2[i][j]=1,flg2[n-1-i][j]=1,cnt++;
		}
	}
	if(cnt==0) sum=1;
	else sum=0;
	for(i=0;i<c-1;i++) {
		cin>>d;
		for(j=0;j<d;j++) {
			cin>>y>>x;
			y--,x--;	
			if(flg1[y][x]==1) {
				cnt--;
				flg1[y][x]=0,flg1[y][n-1-x]=0; 
			}
			else {
				cnt++;
				flg1[y][x]=1,flg1[y][n-1-x]=1;
			}
			if(flg2[y][x]==1) {
				cnt--;
				flg2[y][x]=0,flg2[n-1-y][x]=0;
			}
			else {
				cnt++;
				flg2[y][x]=1,flg2[n-1-y][x]=1;
			}
		}
		if(cnt==0) sum++;
	}
	cout<<sum<<endl;
}
	

Measured memory_bytes: 11904
s = str(input())
t = str(input())
s_l =[]
for i in range(len(s)):
    s_l.append(s[i])

if len(s) < len(t):
    print("UNRESTORABLE")
    exit()

a = len(s) - len(t)

while a >= 0:
    insert = False
    string = True
    i = 0
    while i < len(t):
        if s[a + i] != "?" and s[a + i] != t[i]:
            string = False
            break
        i += 1
        
    if string == True:
        for i in range(len(t)):
                s_l[a+i] = t[i]
        insert = True
        break
    a -= 1

f = ""
if insert == True:
    for i in range(len(s)):
        if s_l[i] == "?":
            f += "a"
        else:
            f += s_l[i]
    print(f)
else:
    print("UNRESTORABLE")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a <= c && c <= b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21716
N = int(input())
S = input()
ans = ""
l = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
for i in range(len(S)):
    index = l.index(S[i])
    if index + N >= 26:
        ans += l[index+N-26]
    else:
        ans += l[index+N]
print(ans)

Measured memory_bytes: 40684
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            Dictionary<int,int> dic = new Dictionary<int, int>();
            for (int i = 0; i < N; i++)
            {
                var r = int.Parse(Console.ReadLine());
                if (!dic.ContainsKey(r))
                {
                    dic[r] = 1;
                }
                else
                {
                    if (dic[r] == 1)
                    {
                        dic[r] = 2;
                    }
                    else
                    {
                        dic[r] = 1;
                    }
                    
                }
            }
            Console.WriteLine(dic.Values.Where(x => x % 2 != 0).Sum());
        }
        
    }
}

Measured memory_bytes: 18396
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;

int main(){
    double x=0,y,d=0,n,h,w,k,m,ans=0,ptr=0;
    string s,s1,s2;
    bool f=true;
    cin >> s;
    VI a(3);
    for(int i=0;i<s.size();i++){
        if(s[i]=='a') a[0]++;
        else if (s[i]=='b') a[1]++;
        else a[2]++;
    }
    for(int i=0;i<2;i++){
        for(int j=i+1; j<3;j++){
            if(abs(a[i]-a[j]) >1)
                f = false;
        }
    }
    if(f)
        cout << "YES" << endl;
    else  cout << "NO" << endl;
    return 0;
}






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

list.sort(reverse=True)

ans = 0
if n % 2 == 0:
  for i in range(n//2):
    ans += 2* list[i]
  ans -= list[0]
else:
  for i in range((n-1)//2):
    ans += 2*list[i]
  ans += list[(n-1)//2]
  ans -= list[0]
print(ans)




Measured memory_bytes: 31488
N = int(input())
A = list(map(int, input().split()))

cnt = [0 for _ in range(100005)]
for a in A:
    cnt[a] += 1

ans = 0
for i in range(1, len(cnt) - 1):
    ans = max(ans, cnt[i - 1] + cnt[i] + cnt[i + 1])

print(ans)


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

// del

const i64 MAXN = 100005;

i64 n;

i64 a[MAXN];
i64 b[MAXN];

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n;

    for (i64 i = 0; i < n; i++) {
        cin >> a[i];
    }

    for (i64 i = 1; i < n; i++) {
        b[i] = a[i - 1] - b[i - 1];
    }

    b[0] = (a[n - 1] - b[n - 1]) / 2;
    for (i64 i = 1; i < n; i++) {
        b[i] = a[i - 1] - b[i - 1];
    }

    for (i64 i = 0; i < n; i++) {
        cout << 2 * b[i] << " ";
    }

    return 0;
}


Measured memory_bytes: 2944
# -*- coding: utf-8 -*-
n, a, b = map(int, input().split())

lst = []
for i in range(n + 1):
  x = 0
  for j in range(len(str(i))):
    x = x + int(str(i)[j])
  if (x >= a) and (x <= b):
    lst.append(i)
print(sum(lst))


Measured memory_bytes: 3404
#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define D                double
#define F                first
#define S                second
#define pb               push_back
#define pf               push_front
#define MP               make_pair
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define it(it,mp)        for(auto it=mp.begin() ; it!=mp.end() ; it++)
#define IOS              ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair<int,int>                   PII;
#define ordered_set Tree<PII, null_type,less<PII>, rb_Tree_tag,Tree_order_statistics_node_update>
const int N = 1e5 + 5;
const int inf = 1e9 + 1;
const double eps = 1e-15;
const double EPS = 1e-9;
const double PI = acos(-1.0);
#define mx 100005
int arr[mx], n, q, l, r, chk, val, Tree[3 * mx];
int main()
{
    IOS
    //READ("0test.txt");
    // WRITE("0out.txt");
    ll n ;
    cin >> n ;
    cout<<((n & 1)? (n/2) * ((n /2) + 1 ) : (n/2) * (n /2))<<endl;

}


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

#define _GLIBCXX_DEBUG

//vector<int> A(M), B(M);
//vector<vector<char>> answer(N, vector<char>(N, '-'));

int main() {
  string s;
  cin >> s;
  if(s == "Sunny") cout << "Cloudy" << endl;
  else if(s == "Cloudy") cout << "Rainy" << endl;
  else if(s == "Rainy") cout << "Sunny" << endl;
  
  return 0;
}

Measured memory_bytes: 3524
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    A = list(map(int,input().split())) #深さiの葉の数
    B = [0] * (n + 1)   #深さiの、葉でない頂点の数
    sum_A = sum(A[1:]) # その深さ以上の葉の数の和

    B[0] = 1 - A[0]
    if sum_A == 0:
        if B[0] == 0:
            print(1)
        else:
            print(-1)
        sys.exit()
    ans = 1
    for i in range(1, n + 1):
        sum_A -= A[i]
        max_b = min(2*B[i-1] - A[i], sum_A)
        if max_b + A[i] < B[i-1] or max_b < 0:
            print(-1)
            sys.exit()
        else:
            B[i] = max_b
        ans += A[i] + max_b

    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 20032
n = int(input())
f, p = [], []
scores = []
for i in range(n):
    f.append(int(int("".join(list(input().split())), 2)))
for i in range(n):
    p.append(list(map(int,input().split())))
for i in range(1,1024):
    score = 0
    for j in range(n):
        double = bin(i & f[j]).count("1")
        score += p[j][double]
    scores.append(score)
print(max(scores))

Measured memory_bytes: 41452
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define rep(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288

int main(){
    int n,x,y;
    cin>>n>>x>>y;
    int right=n-y+1;
    int left=x;
    vector<int>ans(n);
    ans[0]=0;
    for(int i=1;i<n;i++)ans[i]=n-i;
    int chg=y-x-1;
    //左から右中、右
    for(int i=left;i>0;i--){
        int stn=y-i;
        for(int j=(y+x+3)/2-y;j<right;j++){
            ans[stn+j]--;
           // if(stn+j==3)cout<<i<<"a::"<<j<<endl;
            ans[stn+abs(j)-chg]++;
        }
    }
    //左中から右中、右
    for (int i = x + 1; 2 * i < x + y; i++) {
        for (int j=right-1; 2*j>=2*i+1-x-y; j--) {
            ans[y - i + j]--;
            //if (y - i + j == 3)cout << i << "b::" << j << endl;
            ans[i - x + 1 + abs(j)]++;
        }
    }
    
    for(int i=1;i<n;i++)cout<<ans[i]<<endl;
    return 0;
}

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

if N % 2 == 1:
    print((N - 1) ** 2 // 2)
else:
    print(N * (N-2)//2)
for i in range(1, N+1):
    for j in range(i+1, N + 1):
        if j != N + 1 - i - N % 2:
            print("{} {}".format(i, j))

Measured memory_bytes: 3336
import sys

S = input()

def ticket_sum(i, s, num):
    if i == len(S):
        if num == 7:
            print(s+"=7")
            sys.exit()
        else:
            return False
    
    # 数字を分ける場所
    pos = i - len(S)

    # "+"を入れる場合
    s1 = s[:pos]+"+"+s[pos:]
    num1 = num+int(s[pos])
    # "-"を入れる場合
    s2 = s[:pos]+"-"+s[pos:]
    num2 = num-int(s[pos])
    
    if ticket_sum(i+1, s1, num1):
        return
    elif ticket_sum(i+1, s2, num2):
        return
    
    return False

ticket_sum(1, S, int(S[0]))

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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp1, tmp2;

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) {
        ll a, b;
        cin >> a >> b;
        tmp1 = a*b;
        tmp2 = sqrt(tmp1);
        //cout << tmp << endl;
        tmp1 = tmp1/tmp2;
        ans = 2*tmp2-1;
        if(tmp1!=tmp2) {
            ans++;
            tmp1 = tmp2+1;
        }
        if(a==b) {
            cout << 2*a-2 << endl;
            continue;
        }
        if(a<=tmp2) ans--;
        if(b<=tmp2) ans--;
        if(tmp1*tmp2==a*b) ans--;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
/*  
    tanuj_johal :: gla_clg_sync_with_CSE(true);
    bonding.tie(true);
    hardwork.tie(true);
    
    ::::::::--------------------::::::::
*/

#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 fio         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define vi          vector<ll>
#define pp          push_pop
#define pll         pair<ll,ll>
#define in          insert
#define f(i,a,b)    for(ll i=a;i<b;i++)
#define f0(i,n)     f(i,0,n)
#define arr(a,n)    int a[n];f0(i, n) cin >> a[i];
#define ini(a,n)    memset(a,n,sizeof(a))
#define ff          first
#define ss          second
#define inf         10000000000000000
#define all(p)      p.begin(), p.end()
#define que_max     priority_queue <int>
#define que_min     priority_queue <int, vi, greater<int>>
#define print(a)    for(auto i:a){cout<<i<<" ";}
#define print1(a)   for(auto i:a){cout<<i.ff<<" "<<i.ss<<endl;}

typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> Set;


const ll mod = 1e9+7;

ll power(ll x,ll y,ll p){ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;}
bool imp = false;
ll n,m;
unordered_map<ll,vi> g;   
unordered_map<ll,ll> vis;
ll rep = 0;
ll dfs(ll s){
    // cout<<s<<" ";
    if(m==0){
        return s;
    }
    if(vis[s]!=0)
    {
        rep = s;
        return -1;
    }
    vis[s] = 1;
    ll ans = 0;
    for(ll i=0;i<g[s].size();i++){
        m--;
        ans = dfs(g[s][i]);
    }
    return ans;
}

vi v;
void dfs1(ll s)
{
    for(ll i=0;i<g[s].size();i++){
        if(vis[g[s][i]]==0){
            vis[g[s][i]]=1;
            v.pb(g[s][i]);
            dfs1(g[s][i]);
        }
    }
}

void solve()
{
    cin>>n>>m;
    // swap(n,m);
    
    for(ll i=0;i<n;i++){
        ll t;
        cin>>t;
        g[i+1].pb(t);
    }
    vis.clear();
    ll x = dfs(1);
    // cout<<x<<endl;
    if(x!=-1){
        cout<<x<<endl;
        return;
    }
    
    vis.clear();
    vis[rep] = 1;
    v.pb(rep);
    dfs1(rep);
    // cout<<endl;
    // print(v);
    // cout<<m<<" "<<v.size()<<endl;
    
    ll t = m%v.size();
    cout<<v[t]<<endl;
    

}

int main()
{
    fio
    int t=1;
    if(imp) cin>>t;
    while(t--)
    {
        // cout<<"Case #"<<tc<<": ";
        solve();
        // tc++;
    }
    
}


Measured memory_bytes: 37860
#include<bits/stdc++.h>
using namespace std;
int c[101][101] = {{0}};
bool b[101][101];

int main(){
  int n, cx=0, cy=0, H = 0;
  int x,y,h;
  bool first = true;
  vector<int> xv(0),yv(0),hv(0);
  for(int i = 0;i<101;i++){
    for(int j = 0;j<101;j++){
      b[i][j] = true;
    }
  }
  cin >> n;
  for(int i = 0;i<n;i++){
    cin >> x >> y >> h;
    if(h == 0){
      xv.push_back(x);
      yv.push_back(y);
      hv.push_back(h);
      continue;
    }
    if(first){
      c[x][y] = h;
      for(int ti = 0; ti < 101; ti++){
        for(int tj = 0; tj < 101; tj++){
          c[ti][tj] = h + abs(ti-x) + abs(tj-y);
        }
      }
      first = false;
    }else{
      for(int ti = 0; ti < 101; ti++){
        for(int tj = 0; tj < 101; tj++){
          if(c[ti][tj] != h + abs(ti-x) + abs(tj-y))
            b[ti][tj] = false;
        }
      }
    }
  }
  for(int i = 0; i< xv.size();i++){
    x = xv[i];y=yv[i];h=hv[i];
    for(int ti = 0; ti < 101; ti++){
      for(int tj = 0; tj < 101; tj++){
        if(c[ti][tj] - abs(ti-x) - abs(tj-y) > 0)
          b[ti][tj] = false;
      }
    }
  }
  for(int i = 0;i<101;i++){
    for(int j = 0;j<101;j++){
      if(b[i][j] && H < c[i][j]){
        cx = i;cy = j;H = c[i][j];
      }
    }
  }
  cout << cx << " " << cy << " " << H << endl;
}

Measured memory_bytes: 256
def Time_Limit_Exceeded(n , t , ctl):

    ans = 0
    count = []

    for i in ctl:
        if i[1] <= t:
            count.append(i[0])

    return min(count) if len(count) != 0 else "TLE"

def main():
    n , t = map(int , input().split())
    ctl = [list(map(int , input().split())) for i in range(n)]
    print(Time_Limit_Exceeded(n , t , ctl))

if __name__ == '__main__':
    main()

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

using namespace std;
typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define P 1000000007

#define N 310
int n, m;
int f[N][N][N];

int main() {
	cin >> n >> m;
	f[0][1][0] = 1;
	for (int i = 0; i < m; i ++)
		for (int j = 1; j <= n; j ++)
			for (int k = 0; k <= n-j; k ++) if (f[i][j][k]) {
				(f[i+1][j+k][0] += (ll)f[i][j][k]*j%P) %= P;
				(f[i+1][j][k] += (ll)f[i][j][k]*k%P) %= P;
				(f[i+1][j][k+1] += (ll)f[i][j][k]*(n-j-k)%P) %= P;
			}
	cout << f[m][n][0] << endl;
	return 0;
}

Measured memory_bytes: 55808
#include <iostream>
#include <string>

using namespace std;

int main(){
  int N;
  int ans=0;
  string S;
  cin >> N >> S;
  for(int i=0; i<S.size()-2; i++){
    if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C') ans++;
  }
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

int main(void) {
	int a[4], b[4];
	int hit, blo;

	while (true) {
		for (int i = 0; i < 2; ++i) {
			for (int j = 0; j < 4; ++j) {
				if (i == 0) {
					cin >> a[j];
				} else {
					cin >> b[j];
				}
				if (cin.eof()) {
					return 0;
				}
			}
		}
		hit = blo = 0;
		
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (a[i] == b[j]) {
					if (i == j) {
						hit++;
					}
					else {
						blo++;
					}
				}
			}
		}
		cout << hit << " " << blo << endl;
	}
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void read(int &x){
	char ch=getchar();x=0;
	for (;ch==' '||ch=='\n';ch=getchar());
	for (;ch!=' '&&ch!='\n';x=x*10+ch-'0',ch=getchar());
}
void readi(ll &x){
	char ch=getchar();x=0;
	for (;ch==' '||ch=='\n';ch=getchar());
	for (;ch!=' '&&ch!='\n';x=x*10+ch-'0',ch=getchar());
}
void write(int x){
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
const int MOD=1e9+7;
int n;
int ld[17],lf[100004];
ll a[100004],st[100004][17],A[2];
int dp[100004][2][2],g[1000004][2];
void init(){
	int now=1,cnt=0;
	ld[0]=1;
	for (int i=1;i<17;i++) ld[i]=ld[i-1]<<1;
	for (int i=1;i<=n;i++){
		lf[i]=cnt;
		if (now*2==i+1){
			cnt++;
			now<<=1;
		}
	}
}
ll check(int l,int r){
	if (l==r) return 1e18;
	int len=r-l;
	int got=lf[len];
	return min(st[l][got],st[r-ld[got]][got]);
}
int main(){
	read(n);init();for (int i=0;i<2;readi(A[i]),i++);
	for (int i=1;i<=n;i++){
		readi(a[i]);
		st[i-1][0]=a[i]-a[i-1];
	}
	for (int j=1;j<17;j++)for (int i=1;i<=n;i++)if(i+ld[j]<=n){
		st[i][j]=min(st[i][j-1],st[i+ld[j-1]][j-1]);
	}
	dp[1][0][1]=dp[1][1][1]=g[1][0]=g[1][1]=1;
	for (int i=2;i<=n;i++)for (int j=0;j<2;j++){
		if(a[i]-a[i-1]>=A[j])dp[i][j][1]=(dp[i-1][j][1]+dp[i-1][j][0])%MOD;
		int l=0,r=i;
		while (r>l+1){
			int mid=(l+r)/2;
			if (check(mid,i-1)>=A[1^j]) r=mid;
			else l=mid;
		}
		int l1=0,r1=i-1;
		while (r1>l1+1){
			int mid=(l1+r1)/2;
			if (a[i]-a[mid]>=A[j]) l1=mid;
			else r1=mid;
		}
		l1++;
		if (l1>=r){
			dp[i][j][0]=(g[l1][j^1]-g[r-1][j^1]+MOD+dp[i][j][0])%MOD;
		}
		g[i][j]=(dp[i][j][0]+g[i-1][j])%MOD;
	}
	int ans=0;
	for(int i=0;i<2;i++)for(int j=0;j<2;j++)ans=(ans+dp[n][i][j])%MOD;
	write(ans);
}

Measured memory_bytes: 18816
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <string.h>


int L_in;


int main(int argc, char* argv[]){
    int i,j;
    scanf("%d",&L_in);
    if(L_in >=30){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 1712
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  if (S == U) A--;
  else B--;
  cout << A << " " << B << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll a,z;
  string s;
  cin >> s;
  rep(i,s.length()){
    if(s[i]=='A'){
      a=i;
      break;
    }
  }
  per(i,s.length()){
    if(s[i]=='Z'){
      z=i;
      break;
    }
  }
  printf("%lld",z-a+1);
}

Measured memory_bytes: 640
/*
        FFFFFFFFFFFFFFFFFFFFFF
        F::::::::::::::::::::F
        F::::::::::::::::::::F
        FF::::::FFFFFFFFF::::F
          F:::::F       FFFFFF
          F:::::F
          F::::::FFFFFFFFFF
          F:::::::::::::::F
          F:::::::::::::::F
          F::::::FFFFFFFFFF
          F:::::F
          F:::::F
        FF:::::::FF
        F::::::::FF
        F::::::::FF
        FFFFFFFFFFF
*/
#include <bits/stdc++.h>
using namespace std;
#define debug(...) cout<<__FUNCTION__<<":"<<__LINE__<<": ";debugger(#__VA_ARGS__, __VA_ARGS__);
template<typename arg>
void debugger(const char* varname, arg&& var) { cout<<varname<<" = "<<var<<endl; }
template<typename arg, typename... args>
void debugger(const char* varnames, arg&& var, args&&... vars) {
    const char* comma = strchr(varnames + 1, ',');
    cout.write(varnames, comma - varnames)<<" = "<<var<<" | ";
    int sz = 1; if(isspace(comma[sz])) sz++;
    debugger(comma + sz, vars...);
}
#define forr(i, s, n) for(ll i=(ll)(s); i<(ll)(n); ++i)
#define forn(i, n) forr(i, 0, n)
#define eb(n) emplace_back(n)
#define endl '\n'
#define fst first
#define snd second
using ll = long long;
using ii = pair<ll,ll>;
using vi = vector<ll>;
extern const int INF = INT_MAX - 5;
extern const ll LINF = LLONG_MAX - 5;
extern const int MOD = 1e9 + 7;
extern const int N = 2e5 + 200;
int n;
int main() {
    cin >> n;
    int ans = 0;
    map<ii, int> mp;
    for(int i = 1; i <= n; ++i) {
        int p = log10(i);
        int tn = pow(10, p);
        int f = i / tn;
        int l = i % 10;
        // cout<<f<<" "<<l<<endl;
        if(mp.count({l, f})) ans += (2 * mp[{l, f}]);
        if(f == l) ans++;
        mp[{f, l}]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = int(input())
ans = 0
for i in range(1, n+1):
    if len(str(i)) % 2 == 0:
        continue
    ans += 1
print(ans)


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

using namespace std;

const int MaxN = 1e5 + 15;

int n;
vector <int> v[MaxN];
int dp[MaxN];

int getDp(int x)
{
    if(!dp[x])
    {
        dp[x] = 1;
        for(int to : v[x])
            dp[x] = max(dp[x], 1 + getDp(to));
    }
    return dp[x];
}

int ans;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 ///   freopen("input.txt", "r", stdin);

    int m;
    cin >> n >> m;

    for(int i = 1; i <= m; ++i)
    {
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
    }

    for(int i = 1; i <= n; ++i)
        ans = max(ans, getDp(i) - 1);

    cout << ans << '\n';

    return 0;
}



Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define fastio  cin.sync_with_stdio(0); cin.tie(0);cin.exceptions(cin.failbit);
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a,v) memset(a, v, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1e9+7;
const int N=2e5+5;
int main() {
  
    fastio;
    int T=1;
    // cin>>T;
    while(T--){
        ll n;cin>>n;
        ll a[n];
        rep(i,n)cin>>a[i];
        ll ans=0;
        sort(a,a+n);
        map<int,int> m;
        rep(i,n){
            m[a[i]]++;
        }
        int flag[a[n-1]+1]={0};
        rep(i,n){
            if(flag[a[i]]==0){
                if(m[a[i]]==1){
                    ans++;
                }
                for(int j=a[i];j<=a[n-1];j=j+a[i]){
                    flag[j]=1;
                }
            }
        }
        cout<<ans;
    }   
    timecalculater();
    return 0;   
} 

Measured memory_bytes: 18464
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/21 8:23:51
File Name     :TEST.cpp
************************************************ */

#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <cmath>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define INF 0x3f3f3f3f
#define rep(i,x,y) for(int i = x;i <= y;++i)
#define fori(i,x,y) for(int i = x;i >= y; -- i)
#define bug puts("--------------")
#define out(x) cout<<x<<'\n';
inline char gc(){char op[2];scanf("%s",op);return op[0];}
const int N = 1e5+10;
const double eps = 0.00000001;
const ll mod = 1e9 + 7 ;
using namespace std;
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
    int a = read(),b = read();
    cout<<(a-1)*a/2 + b*(b-1)/2;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#define p pair<int,int>
#define P pair<int,p>
using namespace std;

P g[100000];
int Par[100000], Rank[100000];
int saiki(int a) {
	if (Par[a] == a)return a;
	return Par[a] = saiki(Par[a]);
}
void unite(int a, int b) {
	a = saiki(a);
	b = saiki(b);
	if (Rank[a] > Rank[b]) {
		Par[b] = a;
	}
	else if (Rank[a] < Rank[b]) {
		Par[a] = b;
	}
	else {
		Par[b] = a;
		Rank[a]++;
	}
}
int main() {
	int a, b;
	while (cin >> a, a) {
		cin >> b;
		for (int c = 0; c < b; c++) {
			int d, e, f;
			scanf("%d,%d,%d", &d, &e, &f);
			g[c] = P(f, p(d, e));
		}
		for (int c = 0; c < a; c++) {
			Par[c] = c;
			Rank[c] = 0;
		}
		sort(g, g + b);
		int ans = 0;
		for (int i = 0; i < b; i++) {
			if (saiki(g[i].second.first) != saiki(g[i].second.second)) {
				ans += g[i].first / 100 - 1;
				unite(g[i].second.first, g[i].second.second);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3124
import itertools
import numpy as np

n, m, x = map(int, input().split())
books = [list(map(int, input().split())) for i in range(n)]

coin = []
for i in range(1, n+1):
  for v in itertools.combinations(books, i):
    comb = list(v)
    result = np.sum(comb, axis = 0)
    
    flag = True
    for j in range(1,m+1):
      if result[j] < x:
        flag = False
        break
    if flag:
      coin.append(result[0])

if len(coin) > 0:
  coin.sort(reverse=False)
  print(coin[0])
else:
  print(-1)

Measured memory_bytes: 27360
#include <stdio.h>
#include <algorithm>
using namespace std;

int N;

int main() {
    int x, max1, max2, idx;
    max1 = max2 = 0;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &x);
        if (max2 < x) {
            max2 = x;
        }
        if (max1 < max2) {
            swap(max1, max2);
            idx = i;
        }
    }
    for (int i = 0; i < N; i++) {
        if (i == idx) printf("%d\n", max2);
        else printf("%d\n", max1);
    }
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int H, W;
string A[8];

int main(){
  cin >> H >> W;
  REP(i, H) cin >> A[i];
  int ct = 0;
  REP(i, H) REP(j, W) if(A[i][j] == '#') ct++;

  if(ct == H + W - 1) cout << "Possible" << endl;
  else cout << "Impossible" << endl;


  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		int ans = Integer.MAX_VALUE;
		for (int i = -100; i <= 100; i++) {
			int sum = 0;
			for (int j = 0; j < a.length; j++) {
				int val = a[j] - i;
				val *= val;
				sum += val;
			}
			ans = Math.min(ans, sum);
		}
		System.out.println(ans);
	}
}


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

int top, S[1000];

void push(int x){
  S[++top]=x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a, b;
  top = 0;
  char s[100];

  while(scanf("%s", s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }

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


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

#define mod1 2019
#define ll long long

int main()
{
    ll i, n, x, y, ans;
    string s;

    cin >> s;

    n=s.size();
    int a[n], val[n], count[2019];

    memset(count, 0, sizeof(count));
    for(i=0; i<n; i+=1)
        a[i]=(int)(s[n-1-i])-48;

    x=1;
    val[0]=a[0];

    for(i=1; i<n; i+=1)
    {
        x*=10;
        x%=mod1;
        y=(a[i]*x)%mod1;
        val[i]=(val[i-1]+y)%mod1;
    }

    for(i=0; i<n; i+=1)
        count[val[i]]+=1;

    ans=count[0];
    for(i=0; i<2019; i+=1)
    {
        if(count[i]>=2)
            ans+=(count[i]*(count[i]-1))/2;
    }

    cout << ans << endl;
}

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

long long func(long long n){
  if(n<0){
    return 0;
  }
  if(n%2==0){
    return (n^((n/2)%2));
  }else{
    return ((n+1)/2)%2;
  }
  return 0;
}

int main(){
  long long A,B;
  cin >> A >> B;
  cout << (func(A-1)^func(B)) << endl;
 
  return 0;
}

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

int main(){
  
  int X,Y,Z;

cin>>X>>Y>>Z;

for(int i=0;i<X;i++){
  if(X-Y*i-Z*(i+1)<0){
    cout<<i-1<<endl;
    break;
  }
}
}

    
    

Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    X[x].append(y)
    X[y].append(x)

def EulerTour(n, X, i0):
    def bl(k):
        l, r = -1, n
        while r - l > 1:
            m = (l + r) // 2
            if L[m][-1] < k:
                l = m
            else:
                r = m
        return l + 1

    inf = 1 << 30
    P = [-1] * n
    Q = [~i0, i0]
    ANS = [0] * n
    L = [[inf] for _ in range(n)]
    I = [0] * n
    while Q:
        i = Q.pop()
        if i < 0:
            i = ~i
            L[I[i]].pop()
            continue
        if i >= 0:
            k = A[i]
            b = bl(k)
            L[b].append(k)
            I[i] = b
            ANS[i] = bl(inf)
        for a in X[i][::-1]:
            if a != P[i]:
                P[a] = i
                for k in range(len(X[a])):
                    if X[a][k] == i:
                        del X[a][k]
                        break
                Q.append(~a)
                Q.append(a)
    return ANS

print("\n".join(map(str, EulerTour(N, X, 0))))

Measured memory_bytes: 169768
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
#define mod 1000000007 
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
using namespace __gnu_pbds;
using namespace std;
 
// PMAMP :)
// INL , IIWOIL
 
ll power(ll base, ll exp)
{
    ll ans=1;
    while(exp>0)
    {
        if(exp&1) ans=(ans*base)%mod;
        base=(base*base)%mod;
        exp/=2;
    }
    return ans;
}
ll func(ll n,ll r)
{
    ll ans=1;
    for(int i=1;i<=r;i++)
    {
        //ans = ((ans*(n-i+1))%mod * )
        ans = (ans*(n-i+1)%mod * power(i,mod-2)%mod)%mod;
        //trace(ans);
    }
    return ans;
}
int main()
{
    jaldi
    ll n,a,b;
    cin>>n>>a>>b;
    ll total = power(2,n)-1;
    //trace(total);
    a=n-a<a?n-a:a;
    b=n-b<b?n-b:b;
    ll r1 = func(n,a);
    ll r2 = func(n,b);
    ll final = (total-r1-r2+2*mod)%mod;
    cout<<final;
    return 0;
}

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

int main(void) {
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i = 0; i < n; i++) {
    cin >> h.at(i);
  }
  for(int i = 0; i < n-1; i++) {
    if(h.at(i) < h.at(i+1)) {
      h.at(i+1) = h.at(i+1) - 1;
    }
  }
  for(int i = 0; i < n-1; i++) {
    if(h.at(i) > h.at(i+1)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main() {
    int N,n = 0;
    cin >> N;
    int a;
    for (int i = 0; i < N; i++) {
        cin >> a;
        if (a == (n+1)) {
            n++;
        }
    }
    if (n == 0) { cout << -1 << endl; }
    else { cout << (N-n) << endl; }

    return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e15 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve() {
   int k, a , b; cin >> k >> a >> b;
   for(int i = a; i <= b; i++) {
     if(i%k == 0) {
       cout << "OK\n"; return;
     }
   }
   cout << "NG\n";
}

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

    #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif
    int t = 1; // cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }
}    


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){int b=0;for(auto itr :a){if(b++!=0)cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
#define int ll
signed main(){
    int n; cin >> n;
    vector<int>v;
    v.push_back(1);
    for(int i = 1; i <=10;i++){
        v.push_back((int)pow(6, i));
        v.push_back((int)pow(9, i));
    }
    vector<int>dp(n+1,INF);
    dp[n] = 0;
    for(int i = n; i >=0;i--){
        if(dp[i] == INF)continue;
        rep(k,v.size()){
            if(i - v[k] < 0)continue;
            cmin(dp[i-v[k]],dp[i]+1);
        }
    }
    cout << dp[0] << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    sort(all(a), greater<ll>());
    ll alice = 0, bob = 0;
    rep(i, n) (i%2 == 0) ? alice += a[i] : bob += a[i];
    cout << alice - bob << endl;
}

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            var N = int.Parse(ss[0]);
            var K = int.Parse(ss[1]);

            Console.WriteLine(N - K + 1);
        }
    }
}

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

using namespace std;

#define MOD (int)(1e9 + 7)

using ll = long long;

ll powMod(ll x, int k) {
    if (k == 0)
        return 1;
    if (k % 2 == 0)
        return powMod(x * x % MOD, k / 2);
    else
        return x * powMod(x, k - 1) % MOD;
}

int calc(int a, int b) {
    ll t = 1, av = 1, bv = 1;
    for (int i = 1; i <= a + b; ++i)
        (t *= i) %= MOD;
    for (int i = 1; i <= a; ++i)
        (av *= i) %= MOD;
    for (int i = 1; i <= b; ++i)
        (bv *= i) %= MOD;
    (t *= powMod(av, MOD - 2)) %= MOD;
    (t *= powMod(bv, MOD - 2)) %= MOD;
    return t;
}

int main() {
    int x, y;
    ll ans = 0;
    cin >> x >> y;
    for (int i = 0; i <= y && i * 2 <= x; ++i) {
        if (y - i == 2 * (x - 2 * i))
            (ans += calc(i, x - 2 * i)) %= MOD;
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
const ll INF = 1e9;

int main() {
    int H, W, ans = 999999;
    cin >> H >> W;
    vector<string> F(H);
    for (int i = 0; i < H; i++) cin >> F[i];

    for (int bTop = 1; bTop < H - 1; bTop++) {
        int wCnt = 0;
        for (int i = 0; i < bTop; i++) {
            for (int j = 0; j < W; j++) {
                if (F[i][j] != 'W') wCnt++;
            }
        }
        for (int rTop = bTop + 1; rTop < H; rTop++) {
            int bCnt = 0, rCnt = 0;
            for (int i = bTop; i < rTop; i++) {
                for (int j = 0; j < W; j++) {
                    if (F[i][j] != 'B') bCnt++;
                }
            }
            for (int i = rTop; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (F[i][j] != 'R') rCnt++;
                }
            }

            ans = min(ans, wCnt + bCnt + rCnt);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <string>

using namespace std;

int W, H, steps, dx, dy, posx, posy;
string cmd;

int main()
{
	while( 1 )
	{
		cin >> W >> H;
		if(W==0 && H==0)
			break;

		dx = 0;
		dy = 1;
		posx = 1;
		posy = 1;
		while( 1 )
		{
			cin >> cmd;
			if(cmd == "FORWARD")
			{
				cin >> steps;
				posx += dx * steps;
				posy += dy * steps;
				posx = (posx <= 0) ? 1 : posx;
				posy = (posy <= 0) ? 1 : posy;
				posx = (posx > W) ? W : posx;
				posy = (posy > H) ? H : posy;
			}
			else if(cmd == "BACKWARD")
			{
				cin >> steps;
				posx -= dx * steps;
				posy -= dy * steps;
				posx = (posx <= 0) ? 1 : posx;
				posy = (posy <= 0) ? 1 : posy;
				posx = (posx > W) ? W : posx;
				posy = (posy > H) ? H : posy;

			}
			else if(cmd == "LEFT")
			{
				int newdx = (dx==0) ? -dy : 0;
				int newdy = (dy==0) ?  dx : 0;
				dx = newdx;
				dy = newdy;
			}
			else if(cmd == "RIGHT")
			{
				int newdx = (dx==0) ?  dy : 0;
				int newdy = (dy==0) ? -dx : 0;
				dx = newdx;
				dy = newdy;
			}
			else if(cmd == "STOP")
			{
				break;
			}
		}
		printf("%d %d\n", posx, posy);
	}	
}

Measured memory_bytes: 0