akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 20:59:09 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

X = int(input())
#X, Y = map(int,input().split())
#A = list(map(int,input().split()))
#graph = [[] for _ in range(N+1)]
#for _ in range(N-1):
#    a, b = map(lambda x : int(x)-1, input().split())
#    graph[a].append(b)
#    graph[b].append(a)
m = 100
for ans in range(1,10**5):
    m += m//100
#    print(ans,m)
    if m >= X:
        break

print(ans)

Measured memory_bytes: 9176
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

n,m,s=l_in()

uvab=[]
edges = [[] for _ in range(n)]
for _ in range(m):
    u,v,a,b = l_in()
    edges[u-1].append((v-1,a,b))
    edges[v-1].append((u-1,a,b))

cd = [l_in() for _ in range(n)]

# dp[i][g] city i で g まいの銀貨をもつための最小時間
m = 50*n+1
#m = 4
dp = [[-1]*m for _ in range(n)]


from heapq import heappush,heappop
h = []

for g in range(min(s+1,m+3)):
    heappush(h, (0,-g,0))

while len(h) > 0:
    t,g,i = h[0]
    g = -g
#    print("t,g,i", t,g,i)
    #

    heappop(h)
    if dp[i][min(g,m-1)] != -1:
        continue

    
    dp[i][min(g,m-1)] = t
    
    for v,a,b in edges[i]:
        if g-a >= 0 and dp[v][min(g-a,m-1)] == -1:
            heappush(h,(t+b,-(g-a),v))
#            print("push", t+b,-g+a,v)

    c,d = cd[i]
    heappush(h,(t+d,-(g+c),i))
    
#    if dp[i][min(g+c,m-1)] == -1:

for d in dp:
    pass
#    print(d)


for i in range(1, n):
    res = -1
    for v,a,b in edges[i]:
        min_t = -1
        for g in range(a,m):
            t = dp[v][g]
            if t == -1:
                continue
            if min_t == -1 or min_t > t:
                min_t = t
#                print("min_t", v,g,min_t)

        if res == -1 or res > min_t+b:
            res = min_t+b

#    print(dp[i])
    for t in dp[i]:
        if t == -1:
            continue
        if res == -1  or t < res:
            continue
            res = t
            
    print(res)
        


Measured memory_bytes: 118916
#include<iostream>
 
using namespace std;
 
int main(){
  int a, b;
  cin >> a >> b;
  int n = a + b;
  
  if (n % 2 == 1) {
    cout << n / 2 + 1;
  }
  else {
    cout << n / 2;
  }
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

int main ()
{
	int n;
	cin >> n;
	vector<vector<char>> s(n);
	for (int i=0; i<n; ++i)
	{
		s[i].resize(n * 2);
		for (int j=0; j<n; ++j)
		{
			cin >> s[i][j];
			s[i][j+n] = s[i][j];
		}
	}

	int count = 0;
	int begin = 0, end = n;
	for (int i=0; i<n; ++i)
	{
		bool isWellTable = true;

		for (int j=0; j<n; ++j)
		{
			for (int k=j+1; k<n; ++k)
			{
				if (s[j][begin+k] != s[k][begin+j])
				{
					isWellTable = false;
					goto loop_end;
				}
			}
		}

	loop_end:
		count += (isWellTable ? n : 0);

		++begin;
		++end;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 384
#input
N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())

#output
import numpy as np
dp = np.zeros((N+1, W+1), int)

for i in range(N):
    dp[i+1, w[i]:] = np.maximum(dp[i, w[i]:], dp[i, :-w[i]] + v[i])
    dp[i+1, :w[i]] = dp[i, :w[i]]

print(dp[-1, -1])


Measured memory_bytes: 92660
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try (Scanner sc = new Scanner(System.in)) {
			final long N = sc.nextLong();
			final long A = sc.nextLong();
			final long B = sc.nextLong();
			
			System.out.println(Math.min(N * A, B));
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21076
#include<iostream>
#include<cstdio>
using namespace std;
int n,b[105],op[105],flag;
int main(){
	ios::sync_with_stdio(false);
	int i,j,cnt;
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>b[i];
	for(i=n;i;i--){
		cnt=0;
		for(j=1;j<cnt+b[i]+(bool)op[j];j++)
			cnt+=(bool)op[j];
		op[j]=b[i];
	}
	for(i=1;i<=n;i++)
		flag|=op[i]==0;
	if(flag)
		cout<<-1;
	else
		for(i=1;i<=n;i++)
			cout<<op[i]<<endl;
	return 0;
}

Measured memory_bytes: 3576
#include <cstdio>
#include <cstring>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
int n,m;
vector<int> xindex;
vector<int> yindex;
int fie[5001][5001];
int x[5001],y[5001];

int main(void){
	scanf("%d %d",&n,&m);
	xindex.push_back(-2e9);
	yindex.push_back(-2e9);
	for(int i=0;i<n;i++){
		scanf("%d %d",&x[i],&y[i]);
		xindex.push_back(x[i]);
		yindex.push_back(y[i]);
	}
	sort(xindex.begin(),xindex.end());
	xindex.erase(unique(xindex.begin(),xindex.end()),xindex.end());
	sort(yindex.begin(),yindex.end());
	yindex.erase(unique(yindex.begin(),yindex.end()),yindex.end());
	for(int i=0;i<n;i++){
		x[i]=lower_bound(xindex.begin(),xindex.end(),x[i])-xindex.begin();
		y[i]=lower_bound(yindex.begin(),yindex.end(),y[i])-yindex.begin();
		fie[x[i]][y[i]]++;
	}
	for(int i=0;i<yindex.size();i++){
		for(int j=1;j<xindex.size();j++){
			fie[j][i]+=fie[j-1][i];
		}
	}
	for(int i=0;i<xindex.size();i++){
		for(int j=1;j<yindex.size();j++){
			fie[i][j]+=fie[i][j-1];
		}
	}
	for(int i=0;i<m;i++){
		int lx,rx,ly,ry;
		scanf("%d %d %d %d",&lx,&ly,&rx,&ry);
		lx=upper_bound(xindex.begin(),xindex.end(),lx-1)-xindex.begin();
		rx=upper_bound(xindex.begin(),xindex.end(),rx)-xindex.begin();
		ly=upper_bound(yindex.begin(),yindex.end(),ly-1)-yindex.begin();
		ry=upper_bound(yindex.begin(),yindex.end(),ry)-yindex.begin();
		lx--;
		rx--;
		ly--;
		ry--;
		printf("%d\n",fie[rx][ry]-fie[lx][ry]-fie[rx][ly]+fie[lx][ly]);
	}
	return 0;
}

Measured memory_bytes: 98864
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;

    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
        cout << "Bad" << endl;
        return 0;
    }

    cout << "Good" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
long long ijk[110000];
int v[110000];
pair<pair<long long ,long long>,long long> edge[210000];
int L[210000];
int R[210000];
int dis[210000];
vector<pair<int,int> > g[110000];
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	long long sum=0;
	for(int i=0;i<b;i++){
		int p,q,r;scanf("%d%d%d",&p,&q,&r);
		p--;q--;
		g[p].push_back(make_pair(q,r));
		g[q].push_back(make_pair(p,r));
		L[i]=p;R[i]=q;
		dis[i]=r;
		sum+=r;
	}
	for(int i=0;i<a;i++)ijk[i]=999999999999999LL;
	ijk[0]=0;
	priority_queue<pair<long long,int> >Q;
	Q.push(make_pair(0,0));
	while(Q.size()){
		long long cost=-Q.top().first;
		int at=Q.top().second;
		Q.pop();
		if(v[at])continue;
		v[at]=1;
		for(int i=0;i<g[at].size();i++){
			if(!v[g[at][i].first]&&ijk[g[at][i].first]>cost+g[at][i].second){
				ijk[g[at][i].first]=cost+g[at][i].second;
				Q.push(make_pair(-ijk[g[at][i].first],g[at][i].first));
			}
		}
	}
	for(int i=0;i<b;i++){
		edge[i]=make_pair(make_pair(max(ijk[L[i]],ijk[R[i]]),min(ijk[L[i]],ijk[R[i]])),dis[i]);
	}
	std::sort(edge,edge+b);
	long long ret=sum;
	for(int i=0;i<b;i++){
		sum-=edge[i].second;
		ret=min(ret,(long long)c*edge[i].first.first+sum);
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 19128
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int a,b,c;
   cin >> a >> b >> c;

   bool flg = 0;
   if((a == b+c) || (b == a+c) || (c == a+b)) cout << "Yes" << endl;
   else cout << "No" << endl;



   return 0;
}

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

typedef long long int ll;
typedef pair<ll,ll> P;

int main(){
    int k,a,b;
    cin>>k>>a>>b;
    if(a/k!=b/k||(a%k)*(b%k)==0){
        cout<<"OK";
    }else{
        cout<<"NG";
    }


    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P       = pair<int, int>;

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

bool check(string &s, string t, int si) {
    for (int ti = 0; ti < (int)t.size(); ti++, si++) {
        if (s[si] != '?' && s[si] != t[ti]) {
            return false;
        }
        if (s[si] == '?') {
            s[si] = t[ti];
        }
    }
    return true;
}

signed main() {
    string s, t;
    cin >> s >> t;
    const int s_len = (int)s.size();
    set<string> st;
    rep(i, 0, s_len) {
        if (s[i] == '?' || s[i] == t[0]) {
            string ss = s;
            if (check(ss, t, i)) {
                rep(j, 0, s_len) {
                    if (ss[j] == '?') ss[j] = 'a';
                }
                st.insert(ss);
            }
        }
    }

    if (st.empty()) {
        puts("UNRESTORABLE");
    } else {
        cout << *st.begin() << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
//io
#define s(x) scanf(" %d",&x)
#define si(x) scanf(" %d",&x)
#define sll(x) scanf(" %lld",&x)
#define sf(x) scanf(" %lf",&x)
#define ss(x) scanf(" %s",x)
#define sl(x) scanf(" %[^\n]",x)
#define sc(x) scanf("%c",&x)
#define p(x) printf(x)
#define pi(x) printf("%d",x)
#define ps(x) printf("%s",x)
#define pll(x) printf("%lld",x)
#define pf(x) printf("%lf",x)
#define pc(x) printf("%c",x)
#define endl "\n"
#define pn() printf("\n")
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL)
//loops
#define F(x,n) for(int i=x;i<n;i++)
#define Fr(x,n,c) for(int i=x;i<n;i+=c)
#define R(x,n) for(int j=x;j<n;j++)
#define Rr(x,n,c) for(int j=x;j<n;j+=c)
#define V(x,n) for(int k=x;k<n;k++)
#define Vr(x,n,c) for(int k=x;k<n;k+=c)
//ds
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define test() int __T;scanf("%d",&__T);for(int __t=1;__t<=__T;__t++)
#define mem0(x) memset(x,0,sizeof(x))
#define memdp(x) memset(x,-1,sizeof(x))
#define mp(x,y) make_pair(x,y)
#define int long long
int DP[1005][10005];
int h,n;
int a[1005],b[1005];
int dp(int magic,int health) {
	if(health<=0) return 0;
	if(magic>=n) return LLONG_MAX;
	if(DP[magic][health]!=-1) return DP[magic][health];
	int A=LLONG_MAX;
	A=min(A,dp(magic,health-a[magic])+b[magic]);
	A=min(A,dp(magic+1,health));
	return DP[magic][health]=A;
}
int32_t main() {
	cin>>h>>n;
	F(0,n) {
		cin>>a[i]>>b[i];
	}
	memdp(DP);
	cout<<dp(0,h);
}























Measured memory_bytes: 79360
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll ans=inf;
    ll n;cin>>n;
    ll a[n];rep(i,0,n)cin>>a[i];
    rep(i,-100,101){
        ll sum=0;
        rep(j,0,n)sum+=(a[j]-i)*(a[j]-i);
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
n, m, c = [int(i) for i in input().split()]
bs = [int(i) for i in input().split()]
ans = 0
for _ in range(n):
    a_list = [int(i) for i in input().split()]
    cond = sum(a*b for a, b in zip(a_list, bs)) + c
    if cond > 0:
        ans += 1
print(ans)


Measured memory_bytes: 9184
N,D = map(int,input().split())
X = [list(map(int,input().split())) for n in range(N)]
a = 0

for i in range(N):
  for j in range(i):
    d = sum([(X[i][d]-X[j][d])**2 for d in range(D)])**0.5
    if d.is_integer():
      a+=1

print(a)

Measured memory_bytes: 9388
#include<stdio.h>
int main(){
  int a,b,c,n;
  n=0;
  for(scanf("%d %d %d",&a,&b,&c); a<=b; a++){
      if(c%a==0){
	n++;
    }
   
  }
  printf("%d\n",n);
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long,long>> vpll;
typedef vector<pair<int,int>> vpii;
int main(){
	oneforall
	int n;
	cin>>n;
	int a,b,c;
	int dp[100000][3];
	dp[0][0] = dp[0][1] = dp[0][2] = 0;
	FOR(i,1,n+1){
		cin>>a>>b>>c;
		int x1,x2,x3;
		x1 = a+max(dp[i-1][1],dp[i-1][2]);
		x2 = b+max(dp[i-1][0],dp[i-1][2]);
		x3 = c+max(dp[i-1][0],dp[i-1][1]);
		dp[i][0] = x1;
		dp[i][1] = x2;
		dp[i][2] = x3;
	}
	cout<<max({dp[n][0],dp[n][1],dp[n][2]});
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main()
{
	for (int i = 0; i < 5; i++)
	{
		int x;
		scanf("%d", &x);
		if (x == 0)
		{
			printf("%d\n", i + 1);
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 1680
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  vector<int> R(N,0);
  int a,b;
  for (int i = 0; i < M; i++){
    cin >> a >> b;
    R[a - 1]++;
    R[b - 1]++;
  }
  for (int i = 0; i < N; i++){
    cout << R[i] << endl;
  }
}


Measured memory_bytes: 256
program abc19
 implicit none
 integer::X,s
 read(*,*)X
 if(X<=599)then
  s=8
 else if(X<=799)then
  s=7
 else if(X<=999)then
  s=6
 else if(X<=1199)then
  s=5
 else if(X<=1399)then
  s=4
 else if(X<=1599)then
  s=3
 else if(X<=1799)then
  s=2
 else
  s=1
 end if
 print'(i0)',s
end program abc19

Measured memory_bytes: 2864
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::*;
use std::collections::VecDeque;
use std::io::stdin;
use std::str::FromStr;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let mut sc = Scanner::new();
    let a = sc.next_usize() as f64;
    let b = sc.next_usize() as f64;
    let x = sc.next_usize() as f64;

    let s = x / a;
    if s * 2.0 / a <= b {
        let aa = s * 2.0 / b;
        println!("{}", 90.0 - (aa / b).atan().to_degrees());
    } else {
        let ss = a * b - s;
        let bb = ss * 2.0 / a;
        println!("{}", 90.0 - (a / bb).atan().to_degrees());
    }
}

pub struct Scanner {
    buf: VecDeque<String>,
}

impl Scanner {
    pub fn new() -> Self {
        Self {
            buf: VecDeque::new(),
        }
    }

    fn scan_line(&mut self) {
        let mut flag = 0;
        while self.buf.is_empty() {
            let mut s = String::new();
            stdin().read_line(&mut s).unwrap();
            let mut iter = s.split_whitespace().peekable();
            if iter.peek().is_none() {
                if flag >= 5 {
                    panic!("There is no input!");
                }
                flag += 1;
                continue;
            }

            for si in iter {
                self.buf.push_back(si.to_string());
            }
        }
    }

    pub fn next<T: FromStr>(&mut self) -> T {
        self.scan_line();
        self.buf
            .pop_front()
            .unwrap()
            .parse()
            .unwrap_or_else(|_| panic!("Couldn't parse!"))
    }

    pub fn next_usize(&mut self) -> usize {
        self.next()
    }

    pub fn next_isize(&mut self) -> isize {
        self.next()
    }

    pub fn next_chars(&mut self) -> Vec<char> {
        self.next::<String>().chars().collect_vec()
    }

    pub fn next_string(&mut self) -> String {
        self.next()
    }

    pub fn fill_vec_line<T: FromStr>(&mut self, v: &mut Vec<T>) {
        for vi in v {
            *vi = self.next();
        }
    }

    pub fn fill_vec<T: FromStr>(&mut self, v: &mut Vec<Vec<T>>) {
        for vi in v {
            for vii in vi {
                *vii = self.next();
            }
        }
    }

    pub fn make_vec_line<T: FromStr + Default + Clone>(&mut self, i: usize) -> Vec<T> {
        let mut v = vec![Default::default(); i];
        self.fill_vec_line(&mut v);
        v
    }

    pub fn make_vec<T: FromStr + Default + Clone>(&mut self, i: usize, j: usize) -> Vec<Vec<T>> {
        let mut v = vec![vec![Default::default(); j]; i];
        self.fill_vec(&mut v);
        v
    }
}


Measured memory_bytes: 2684
N=int(input())
A=list(map(int,input().split()))
Ave=int(sum(A)/N)

cnt1=0
for i in range(N):
    cnt1+=(A[i]-Ave)**2
    
cnt2=0
for j in range(N):
    cnt2+=(A[j]-(Ave+1))**2
print(min(cnt1,cnt2))


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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return result;
}

int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    ll k;
    cin>>k;

    ll temp=7,cnt=1;
    bool ans=0;
    while(cnt<=k)
    {
    	if(temp%k == 0)
    	{
    		ans=1;
    		break;
    	}

    	temp=(temp%k)*10+7;
    	cnt++;
    }

    if(ans)
    	cout<<cnt<<endl;
    else
    	cout<<-1<<endl;
    
    return 0;
}

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

int main() {
  vector<vector<int>> c(3, vector<int>(3));
  for (int i = 0; i < 3; i++){
    for (int j = 0; j < 3; j++){
      cin >> c.at(i).at(j);
    }
  }
  
  for (int a1 = 0; a1 <= 100; a1++){
    int b1 = c.at(0).at(0) - a1;
    int b2 = c.at(0).at(1) - a1;
    int b3 = c.at(0).at(2) - a1;
    int a2 = c.at(1).at(0) - b1;
    int a3 = c.at(2).at(0) - b1;
    if (c.at(1).at(1) == a2 + b2 && c.at(1).at(2) == a2 + b3
        && c.at(2).at(1) == a3 + b2 && c.at(2).at(2) == a3 + b3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  return 0;
}

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

int main() {
    int N,C;
    cin >> N >> C;
    int D[30][30];
    int c[500][500];
    for(int i=0; i<C; ++i) {
        for(int j=0; j<C; ++j) cin >> D[i][j];
    }
    for(int i=0; i<N; ++i) {
        for(int j=0; j<N; ++j) cin >> c[i][j];
    }
    
    int color[3][30] = {};
    for(int i=0; i<N; ++i) {
        for(int j=0; j<N; ++j) {
            int x = i+1, y= j+1;
            color[(x+y)%3][c[i][j]-1] += 1;
        }
    }
    
    int ans = 1001001001;
    for(int i=0; i<C; ++i) {
        for(int j=0; j<C; ++j) {
            for(int k=0; k<C; ++k) {
                if(i == j || j == k || k == i) continue;
                int tmp = 0;
                for(int m=0; m<30; ++m) {
                    tmp += color[0][m] * D[m][i];
                    tmp += color[1][m] * D[m][j];
                    tmp += color[2][m] * D[m][k]; 
                }
                ans = min(ans, tmp);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define mp           make_pair
#define int          long long
#define uint         unsigned long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define repr(i,x,m)  for(int i=x;i>=m;i--)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define vs           vector<string>
#define pi           pair<int,int>
#define di           deque<int>
#define pq           priority_queue<int>
#define pqs          priority_queue<int,vi,greater<int> >
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define noob         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int fac[2000005]={0};
void factorial(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=((i%MOD)*(fac[i-1]%MOD))%MOD;}
int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}
int ncr(int n,int r){return ((fac[n]*power(fac[r],MOD-2))%MOD*power(fac[n-r],MOD-2))%MOD;}

void ram5564()
{
    int n,m,x;
    cin>>n>>m>>x;
    int a[n];
    int b[n][m];
    rep(i,0,n)
    {
      cin>>a[i];
      rep(j,0,m)
      cin>>b[i][j];
    }
    int mx=(1e18);
    for(int i=0;i<(1<<n);++i)
    {
      vi v;
      for(int j=0;j<n;++j)
      {
         if(i&(1<<j))
          v.pb(j);
      }
      int sum[m];
      memset(sum,0,sizeof(sum));
      for(auto x:v)
      {
        rep(j,0,m)
        sum[j]+=b[x][j];
      }
      sort(sum,sum+m);
      if(sum[0]>=x)
      {
        int cnt=0;
        for(auto x:v)
          cnt+=a[x];
        mx=min(cnt,mx);
      }
    }
    if(mx==1e18)
    {
      cout<<-1;return;
    }
    cout<<mx;
    

}

signed main()
{
    noob
    // #ifndef ONLINE_JUDGE
    //    freopen("input.txt","r",stdin);
    //    freopen("output.txt","w",stdout);
    //    #endif   
        
        int t=1;
        //cin>>t;
        while(t--)
        ram5564();
        return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int K, X;
  cin >> K >> X;
  int k = K-1;
  int x = X-k;
  
  for(int i=x; i<=X+k; i++){
    cout << i <<" ";
    if(i==X+k){
      cout << endl;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int bubbleSort(int A[], int N){
    int sw = 0;
    bool flag = 1;

    for(int i = 0; flag; i++){       
        flag = 0;
        for(int j = N-1; j >= i+1; j--){
            if(A[j] < A[j-1]){
                swap(A[j], A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }

    return sw;
}

int main(){
    int A[100], N, sw;

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

    sw = bubbleSort(A, N);

    for(int i = 0; i < N; i++) {
        if(i) cout << " ";
        cout << A[i];
    }

    cout << endl;
    cout << sw << endl;

    return 0;
}



Measured memory_bytes: 3100
def solve():
    s = input()
    C_index, F_index = -1, -1
    for i, c in enumerate(s):
        if c == "C" and C_index == -1:
            C_index = i
        if c == "F":
            F_index = i
    if C_index < F_index and C_index > -1 and F_index > -1:
        print("Yes")
    else:
        print("No")
        
solve()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int x,n;
int a[111];
bool u[111];
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	memset(u,1,sizeof(u));
	cin>>x>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)u[a[i]]=0;
	for(int d=0;d<=50;d++)
	{
		if(u[x-d])
		{
			cout<<x-d<<endl;
			return 0;
		}
		else if(u[x+d])
		{
			cout<<x+d<<endl;
			return 0;
		}
	}
	return 0;
}



Measured memory_bytes: 3652
import math

def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
  
N = int(input())
while(True):
  if(is_prime(N)):
    print(N)
    break
  else:
    N += 1

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>

using namespace std;
typedef long long ll;

int main() {
	int N;
	cin >> N;
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < N; i++) {
		if (s.substr(i) == t.substr(0, N-i)) {
			cout << N+i << endl;
			return 0;
		}
	}
	cout << 2*N << endl;
	return 0;
}


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



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

	std::vector<bool> rate(8);
	int over3199 = 0;
	rep(i,N){
		int ra;
		cin >> ra;
		if(ra < 3200){
			rate.at(ra/400)=true;
		}else{
			over3199 += 1;
		}
	}

	int minCnt = 0;
	int maxCnt = 0;
	rep(i,rate.size()){
		if(rate.at(i)){
			minCnt++;
		}
	}

	maxCnt = minCnt + over3199;
	if(minCnt == 0 && over3199 > 0 )minCnt = 1;
	

	cout << minCnt <<' '<< maxCnt << endl;
	
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;
    cin >> n;
    ll power = -2;
    vector<ll> ans;
    if(n==0){
        cout << 0 << endl;
        return 0;
    }
    while(abs(n)>0){
        ll t = n % 2;
        if (t < 0) t += 2;
        if (t == 0) ans.push_back(0);
        else
            ans.push_back(1);
        n -= t;
        n /= -2;
    }
    reverse(ans.begin(), ans.end());
    for (ll i=0;i<ans.size();i++){
        cout << ans[i];
    }
    cout << endl;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <limits.h>
#include <algorithm>

using namespace std;

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

    char b = S[0];
    for (int i = 1; i < S.size(); i++) {
         if (b == S[i]) {
             cout << "Bad" << endl;
             return 0;

         };
         b = S[i];
    }


    cout << "Good" << endl;


    return 0;
}

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

using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back
#define int long long
const int MAX=1e9;

signed main(){


	int n;
	cin>>n;
	int count=1;
	int ans=0;
	int a[n+1]={0};

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

	sort(a,a+n);

	// for(int i=0;i<n;i++){
	// 	cout<<a[i]<<" ";
	// }cout<<endl;



	for(int i=0;i<n;i++){

		// cout<<"a[i],a[i+1]→  "<<a[i]<<":"<<a[i+1]<<endl;



		if(a[i]!=a[i+1]){
			if(count%2==1)ans++;
			count=1;
		}else{
			count++;
		}

		// if(i==n-2){
		// 	if(a[n-2]!=a[n-1]){
		// 		ans++;
		// 		break;
		// 	}
		// }


	}

	// cout<<"ans:"<<ans<<endl;
	cout<<ans<<endl;

	
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>



using namespace std;

static int CalcMax(int* array, int num) {

	int max=0;
	int index = 0;
	for (int i = 0; i < num; i++) {

		if (array[i] > max) {
			max = array[i];
			index = i;
		}
	}

	return index;
}

int main() {

	int num = 0;
	cin >> num;

	int array[100];
	for (int i = 0; i < num; i++) {

		cin >> array[i];
	}


	int MaxIndex=CalcMax(array, num);

	int sum = 0;
	for (int i = 0; i < num; i++) {

		if (i==MaxIndex) {
			continue;
		}

		sum += array[i];
	}


	if (sum > array[MaxIndex]) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	

}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
if N == K:
    ans = 1
    for a in A:
        ans *= a
        ans %= mod
    print(ans)
    exit()
A.sort()
B = []
flag = False
F = False
tmp = 0
num = -1
ans = 1
tmp_ = -1
for i, a in enumerate(A):
    if a < 0:
        if flag:
            B.append(tmp * a)
            flag = False
        else:
            tmp = a
            flag = True
    elif a == 0:
        num = i
        F = True
    else:
        tmp_ = tmp
        num = i
        break

if num == -1:
    if K % 2 == 1:
        for i, a in enumerate(A[::-1]):
            ans *= a
            ans %= mod
            if i == K-1:
                print(ans)
                exit()
    else:
        B.sort(reverse=True)
        K //= 2
        for i, b in enumerate(B):
            ans *= b
            ans %= mod
            if i == K-1:
                print(ans)
                exit()
A = A[num:]
A.sort(reverse=True)
if K % 2 == 1:
    ans = A[0]
    A = A[1:]
    K -= 1
ans %= mod
flag = False
for a in A:
    if flag:
        B.append(tmp * a)
        flag = False
    else:
        tmp = a
        flag = True
K //= 2
if len(B) < K:
    if F:
        print(0)
        exit()
    else:
        ans *= tmp_

B.sort(reverse=True)
for i, b in enumerate(B):
    if K == i:
        break
    ans *= b
    ans %= mod

print(ans % mod)


Measured memory_bytes: 97584
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
#define FF first
#define SS second
using namespace std ;
 
const lli dx4[] = {-1, 0, 1, 0};
const lli dy4[] = {0, 1, 0, -1};
const lli dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const lli dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

#define N 1000004

void solve()
{
	lli n;
	cin>>n;

	lli a[n];
	loopl(i,0,n) cin>>a[i];

	lli left = 1000;

	loopl(i,1,n)
	{
		if(a[i] > a[i-1])
		{
			lli st = left/a[i-1];
			lli pr = st *(a[i]-a[i-1]);
			left += pr;
		}
	}

	cout<<left<<endl;

}

int main()
{
/////////////////////////////////////
    fastio;
/////////////////////////////////////  

    lli t;
    t=1;
    
    loopl(i,1,t+1)
    {
    	//cout<<"Case #"<<i<<": ";
    	solve();
    }  
}	
   


Measured memory_bytes: 3656
X,N = map(int,input().split())
if N == 0:
    print(X)
else:
    P = list(map(int,input().split()))
    i = 0
    while(1):
        if X-i not in P:
            m = X-i
            break
        i += 1
    for i in range(X-m):
        if X+i not in P:
            m = X+i
            break
    print(m)

Measured memory_bytes: 61788
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int h,w; cin >> h >> w;
  vector<string> s(h); rep(i,h) cin >> s[i];
  queue<pair<int,int>> q;
  q.push({0,0});
  vector<string> tmp = s;
  tmp[0][0] = '#';
  vector<vi> dist(h,vi(w));
  map<int,int> cnt;
  while(!q.empty()){
    pair<int,int> p = q.front(); q.pop();
    int x = p.second, y = p.first;
    rep(i,4){
      if(x+dx[i]<0 || w<=x+dx[i] || y+dy[i]<0 || h<=y+dy[i]) continue;
      if(tmp[y+dy[i]][x+dx[i]] == '.'){
        dist[y+dy[i]][x+dx[i]] += dist[y][x]+1;
        tmp[y+dy[i]][x+dx[i]] = '#';
        cnt[dist[y+dy[i]][x+dx[i]]]++;
        q.push({y+dy[i],x+dx[i]});
      }
    }
  }
  if(dist[h-1][w-1] == 0) cout << -1;
  else{
    int ans = 0;
    for(auto x : cnt){
      if(x.first <= dist[h-1][w-1]) ans += x.second-1;
      else ans += x.second;
    }
    rep(i,h) rep(j,w) if(s[i][j] != '#' && dist[i][j] == 0) ans++;
    cout << ans-1;
  }
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,n) for(ll i=a;i<n;i++)
#define all(x) x.begin(),x.end()
#define bs binary_search
#define gcd(a,b) __gcd(a,b)
#define PI 3.1415926535897932384626
#define lp lower_bound
#define up upper_bound
#define minimum(a)	*min_element(a.begin(), a.end())
#define maximum(a)	*max_element(a.begin(), a.end())
#define UNIQUE(x) (x).resize(unique(all(x))-(x).begin())
#define bp(x)  __bulitin_popcount(x)
using namespace std;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}


const int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
ll f(ll i,ll j,string s){
    ll k=0;
    ll a=i,b=j;
    bool ok=true;
    while(i<j){
        if(s[i++]!=s[j--])ok=false;
        
    }
    if(ok)return 1;
    else return 0;
    
}
int main()
{
boost
ll n;
cin>>n;
ll a[n];
loop(i,0,n)cin>>a[i];
ll f[1000006];
memset(f,0,sizeof(f));
for(int x:a)f[x]++;
ll ans=0;
loop(i,0,1000005){
    ll k=f[i];
    ans+=k*(k-1)/2;
}
loop(i,0,n){
    ll j=f[a[i]],m=j;
j--;
ll h=ans;
if(j>0)h=h-m*(m-1)/2 +j*(j-1)/2;
cout<<h<<"\n";
}
return 0;
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector< char > t(q), d(q);
  for (int i=0; i<q; ++i) cin >> t[i] >> d[i];
  int tp=n, b=-1;
  while (tp-b>1) {
    int piv=(tp+b)/2;
    int cur=piv;
    bool flg=false;
    for (int i=0; i<q; ++i) {
      if (s[cur]==t[i]) {
        if (d[i]=='L') cur--;
        else cur++;
      }
      if (cur < 0) {
        flg=true;
        break;
      }
    }
    if (flg) b=piv;
    else tp=piv;
  }
  int ans = b+1;
  b=-1, tp=n;
  while (tp-b>1) {
    int piv=(tp+b)/2;
    int cur=piv;
    bool flg=false;
    for (int i=0; i<q; ++i) {
      if (s[cur]==t[i]) {
        if (d[i]=='L') cur--;
        else cur++;
      }
      if (cur >=n) {
        flg=true;
        break;
      }
    }
    if (flg) tp=piv;
    else b=piv;
  }
  ans += n-tp;
  cout << n-ans << endl;
  return 0;
}


Measured memory_bytes: 976
N = int(input())
Ps = list(map(int, input().split()))
Ps.insert(0, 0)

c = 0
for i in range(1, N + 1):
    if Ps[i] != i:
        c += 1
if c == 2 or c == 0:
    print("YES")
else:
    print("NO")

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

int main(){

string s1;
cin>>s1;
ll i,cnt=0;
set<ll>s;
for(i=0;i<s1.size();i++){
    if(s1[i]=='R')
        cnt++;
    else {
        s.insert(cnt);
        cnt=0;
    }
}
s.insert(cnt);
auto it=s.crbegin();
cout<<*it<<endl;
    return 0;

}


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

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  double s = x / a;
  double rad;
  if (s >= a * b / 2) {
    double h = (a * b - s) * 2 / a;
    rad = atan2(h, a);
  } else {
    double w = s * 2 / b;
    rad = atan2(b, w);
  }
  double PI = acos(-1);
  double deg = rad / (2 * PI) * 360;
  printf("%.10f\n", deg);
  return 0;
}

Measured memory_bytes: 4092
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 1e5; int n, k, r, s, p;
char t[maxN + 1];
bool safe[maxN];

int getValue(char hand)
{
  if (hand == 'r')
    return p;
  else if (hand == 's')
    return r;
  else
    return s;
}

int main()
{
  while (scanf("%d %d", &n, &k) != EOF)
  {
    memset(safe, false, sizeof(safe));
    scanf("%d %d %d", &r, &s, &p);
    scanf(" %s", t);

    lli ans = 0;
    for (int i = 0; i < n; i++)
      ans += getValue(t[i]);

    for (int i = 0; i + k < n; i++)
      if (!safe[i] && t[i] == t[i + k])
      {
        ans -= getValue(t[i]);
        safe[i + k] = true;
      }

    printf("%lld\n", ans);
  }
  return 0;
}

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

using namespace std;

int main()
{
	int d;
	cin >> d;
	switch (d)
	{
	case 25:
		cout << "Christmas" << endl;
		break;
	case 24:
		cout << "Christmas Eve" << endl;
		break;
	case 23:
		cout << "Christmas Eve Eve" << endl;
		break;
	case 22:
		cout << "Christmas Eve Eve Eve" << endl;
		break;
	}

	return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BHomework {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N, M;
        cin >> N >> M;
        int sum = 0;
        REP(i, M) {
            int a;
            cin >> a;
            sum += a;
        }
        if (sum > N) {
            cout << -1 << endl;
        } else {
            cout << N - sum << endl;
        }

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BHomework solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3656
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner src = new Scanner(System.in);
		
		int n=Integer.parseInt(src.next());

		List<Contents> list = new ArrayList<>();

		for (int i=0; i<n; i++) {
			int value = Integer.parseInt(src.next());
			int weight = Integer.parseInt(src.next());
			char type = src.next().charAt(0);
			long time = Long.parseLong(src.next());
			String name = src.next();
			
			list.add(new Contents(value, weight, type, time, name));
		}

		list.sort(Comparator.comparingInt(Contents :: getX)
				.thenComparingInt(Contents :: getY)
				.thenComparing(Contents :: getX2)
				.thenComparingLong(Contents :: getZ)
				.thenComparing(Contents :: getY2));

		for(int i=0; i<n; i++) {

			System.out.println(list.get(i).x + " " + list.get(i).y + " " + list.get(i).x2 + " " + list.get(i).z + " " + list.get(i).y2);

		}

	}
}

class Contents{

	int x, y;
	long z;
	char x2;
	String y2;

	Contents(int a, int b, char c, long d, String e){

		x = a;
		y = b;
		z = d;
		x2 = c;
		y2 = e;

	}

	int getX() {
		return x;
	}

	int getY() {
		return y;
	}
	
	long getZ() {
		return z;
	}
	
	char getX2() {
		return x2;
	}
	
	String getY2() {
		return y2;
	}
}




Measured memory_bytes: 137136
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=51 ;
ll n,m,s ;
vector< pair<ll,pll> >v[N] ;
ll c[N],d[N] ;
struct node
{
    ll tim,sil,id ;
    bool operator < (const node& rhs) const
    {
        if(tim!=rhs.tim)
            return tim>rhs.tim ;
        else
            return sil<rhs.sil ;
    }

};

int main()
{
   fast ;
   cin>>n>>m>>s ;
   s=min(s,(ll)10000) ;
   for(ll i=0;i<m;i++)
   {
       ll u,w,a,b ;
       cin>>u>>w>>a>>b ;

       v[u].pb({w,{a,b}}) ;
       v[w].pb({u,{a,b}}) ;
   }
   for(ll i=1;i<=n;i++)
   {
       cin>>c[i]>>d[i] ;
   }

   priority_queue<node>q ;
   /*q.push({1,2,3}) ;
   q.push({2,3,2}) ;
   q.push({2,2,1}) ;
   /*while(!q.empty())
   {
       cout<<q.top().tim<<" "<<q.top().sil<<" "<<q.top().id<<endl ;
       q.pop() ;

   }*/

   q.push({0,s,1}) ;
   ll dp[N][10001] ;
   for(ll i=0;i<N;i++)
   {
       for(ll j=0;j<10001;j++)
        dp[i][j]=inf ;
   }

   dp[1][s]=0 ;

   while(!q.empty())
   {
       node noob=q.top() ;
       q.pop() ;

       ll si=noob.sil ;
       ll ti=noob.tim ;
       ll ii=noob.id ;

       //cout<<ii<<" "<<si<<" "<<ti<<endl ;

       ll ns=min(si+c[ii],(ll)10000) ;

       if(dp[ii][ns]>ti+d[ii])
       {
           dp[ii][ns]=ti+d[ii] ;
           q.push({ti+d[ii],ns,ii}) ;
       }

       for(ll j=0;j<v[ii].size();j++)
       {
           ll to=v[ii][j].ff ;
           ll aa=v[ii][j].ss.ff ;
           ll bb=v[ii][j].ss.ss ;

           if(dp[ii][si]!=inf&&si>=aa&&dp[to][si-aa]>dp[ii][si]+bb)
           {
               dp[to][si-aa]=dp[ii][si]+bb  ;
               //cout<<ii<<" g "<<to<<" "<<dp[to][si-aa]<<endl ;
               q.push({dp[to][si-aa],si-aa,to}) ;
           }


       }
   }
   for(ll i=2;i<=n;i++)
   {
       ll ans=inf ;
       for(ll j=0;j<10001;j++)
       {
           ans=min(ans,dp[i][j]) ;

       }
       cout<<ans<<endl ;
   }



}


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

int main()
{
  int card[4][13]={0};
  int n;

  cin >> n;

  for(int i=0;i<n;i++){
    char pic;
    int num;
    
    cin >> pic >> num;

    if(pic=='S') card[0][num-1]++;
    else if(pic=='H') card[1][num-1]++;
    else if(pic=='C') card[2][num-1]++;
    else card[3][num-1]++;
  }

  for(int i=0;i<4;i++){
    for(int j=0;j<13;j++){
      if(!card[i][j])
	switch(i){
	case 0:
	  cout << "S " << j+1 << endl;
	  break;
	case 1:
	  cout << "H " << j+1 << endl;
	  break;
	case 2:
	  cout << "C " << j+1 << endl;
	  break;
	default:
	  cout << "D " << j+1 << endl;
	  break;
	}
    }
  }
  return 0;
}

Measured memory_bytes: 3072