akhauriyash/Code-Regression huggingface dataset:
#include                            <iostream>
#include                            <list>
#include                            <stdio.h>
#include                            <math.h>
#include                            <string.h>
#include                            <time.h>
#include                            <stdlib.h>
#include                            <string>
#include                            <bitset>
#include                            <vector>
#include                            <set>
#include                            <map>
#include                            <queue>
#include                            <algorithm>
#include                            <sstream>
#include                            <stack>
#include                            <iomanip>
#include                            <numeric>
#include                            <unordered_map>



using namespace                     std;
#define                             int long long int




signed main()
{
    int t = 1; //cin >> t;
    for (int test = 1; test <= t; test++)
    {
        int x; cin >> x;
        if(!x)
            cout<<1;
        else
            cout<<0;

    }
    return 0;
}

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

int main(){
    long long a,b,k;
    cin >>a>>b>>k;
    long long ans=0;
    if(a <=k){
        if(b-(k-a) >0){
            ans=b-(k-a);
        }else{
            ans=0;
        }
        cout<<0<<" "<<ans<<endl;
    }else{
    cout<<a-k<<" "<<b<<endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(void){
	char s[5],t[5];
	chin(s);
	chin(t);
	if(s[0]==t[2]&&s[1]==t[1]&&s[2]==t[0])puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 128
using System;
using System.IO;
using System.Text;

public class Program
{
	static void Main(string[] args)
	{
		new Program();
	}

	private bool isDebug = false;
	private IReader reader;

	public Program()
	{
		reader = new ConsoleReader();
		if (isDebug) {
			reader = new FileReader("test.txt");
		}

		int n = int.Parse(reader.ReadLine());
		double res = Math.Pow(n, 3);
		Console.WriteLine(res);
	}
}

// ------------------------------------------------------------------
public interface IReader
{
	string ReadLine();
}

//
public class ConsoleReader : IReader
{
	string IReader.ReadLine()
	{
		return Console.ReadLine();
	}
}

//
public class FileReader : IReader
{
	private StreamReader streamReader;

	public FileReader(string path)
	{
		try {
			streamReader = new StreamReader(path, Encoding.UTF8);
		}
		catch (Exception ex) {
			Console.WriteLine(ex);
		}
	}

	string IReader.ReadLine()
	{
		return streamReader.ReadLine();
	}
}


Measured memory_bytes: 13140
from collections import Counter


def GCD(a: int, b: int) -> int:
    return a if b == 0 else GCD(b, a % b)


def check_pairwise_coprime(a):
    m = max(a)
    cnt_a = Counter(a)
    is_prime = [True] * (m + 1)
    for i in range(2, m // 2 + 1):
        if is_prime[i]:
            cnt = cnt_a[i]
            for j in range(2, m // i + 1):
                cnt += cnt_a[i * j]
                is_prime[i * j] = False
            if cnt > 1:
                return False
    return True


def check_setwise_coprime(a):
    gcd_all = a[0]
    for i in range(1, n):
        gcd_all = GCD(gcd_all, a[i])
    return gcd_all == 1


n = int(input())
a = list(map(int, input().split()))

if check_pairwise_coprime(a):
    print('pairwise coprime')
elif check_setwise_coprime(a):
    print('setwise coprime')
else:
    print('not coprime')


Measured memory_bytes: 242028
import heapq
ls = list(map(int, input().split()))
cnt = 0
heapq.heapify(ls)
a = heapq.heappop(ls)
b = heapq.heappop(ls)
c = heapq.heappop(ls)
cnt += (c - a) // 2
a += (c - a) // 2 * 2
cnt += (c - b) // 2
b += (c - b) // 2 * 2
if a == b == c:
    print(cnt)
else:
    if a == c or b == c:
        print(cnt + 2)
    else:
        print(cnt + 1)


Measured memory_bytes: 3064
# coding: utf-8
import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))


def main():
    k = ni()
    s = ns()
    if len(s)<= k:
        print(s)
    else:
        print(s[:k]+'...')
    return


if __name__ == '__main__':
    main()

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

int main() {
	int a, b;
	scanf("%d %d", &a, &b);

	if (a < b) {
		printf("a < b\n");
	}
	else if (a > b) {
		printf("a > b\n");
	}
	else {
		printf("a == b\n");
	}

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef map<int,int> mi;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;


int main()
{
    int n,x;
    cin >> n;
    vector<int> one,two;
    for(int i=0;i<n;++i) cin >> x, one.push_back(x);
    for(int i=0;i<n;++i) cin >> x, two.push_back(x);
    for(int i=1;i<n;++i) one[i]+=one[i-1];
    for(int i=n-2;i>=0;--i) two[i]+=two[i+1];
    int mx(0);
    for(int i=0;i<n;++i) mx=max(mx,one[i]+two[i]);
    cout << mx;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int             long long
#define ld              long double
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(int i=1;i<=n;i++)
#define fok(i,k,n)      for(int i=k;i<=n;i++)
#define rfo(i,n)        for(int i=n;i>=0;i--)
#define rfo1(i,n)       for(int i=n;i>0;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x,y)         fixed<<setprecision(y)<<x
#define setbits(x)      __builtin_popcount(x)
#define zerobits(x)     __builtin_ctz(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define endl            '\n'
#define PI              3.14159265358979323846
#define mod             1000000007
#define inf             1e18
using namespace std;
void __p(int x) {cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}void _p() {cout << "]\n";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif


const int N=1e6+6;
int n,m,k,x,y,z,a1,b,c,d,i,j,l,r;





void sol()
{   
    cin>>n;
    int a,b,c,a1,b1,c1;
    a=b=c=0;
    fo1(i,n)
    {
        cin>>x>>y>>z;
        a1=x+max(b,c);
        b1=y+max(a,c);
        c1=z+max(a,b);
        a=a1;
        b=b1;
        c=c1;
    }
    
    
    
    cout<< max({a,b,c}) <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 10;

int ans[10001];

int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= 100; i++){
        if(i*i > n) break;
        for(int j = 1; j <= 100; j++){
            if(i*i + j*j + i*j > n) break;
            for(int k = 1; k <= 100; k++){
                int tmp = i * i + j * j + k * k + i * j + i * k + j * k;
				if (tmp > n) break;
				ans[tmp]++;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 3564
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int main(){
	char ca[20];
	int i,j,k;
	int a,b,c;
	cin>>ca;
	for(i=0,a=0;i<strlen(ca);i++){
		if(ca[i]=='o')a++;
	}
	a+=15-strlen(ca);
	print_YES_NO(a>=8);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int fir[5010],dis[10010],nxt[10010],id;
void link(int a,int b){nxt[++id]=fir[a],fir[a]=id,dis[id]=b;}
int f[5010][5010],siz[5010],fx[5010],g[5010];
void DFS(int x,int fa=-114514){
	siz[x]=1;f[x][1]=1;
	for(int t,_=fir[x];_;_=nxt[_]){
		if(fa==(t=dis[_]))continue;
		DFS(t,x);
		for(int i=0;i<=siz[x];++i)
			for(int j=0;j<=siz[t];++j)
				inc(fx[i+j],1ll*f[x][i]*f[t][j]%mod);
		siz[x]+=siz[t];
		memcpy(f[x],fx,siz[x]+1<<2);
		memset(fx,0,siz[x]+1<<2);
	}
	for(int i=2;i<=siz[x];i+=2)inc(f[x][0],mod-1ll*g[i]*f[x][i]%mod);
}
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int n=gi(),a,b;
	for(int i=1;i<n;++i)a=gi(),b=gi(),link(a,b),link(b,a);
	g[0]=1;for(int i=2;i<=n;i+=2)g[i]=1ll*g[i-2]*(i-1)%mod;
	DFS(1);
	printf("%d\n",mod-f[1][0]);
	return 0;
}


Measured memory_bytes: 97280
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)

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

#define MAX_N (123456 * 2 + 1)

bool sieve[MAX_N];

int main() {
    sieve[0] = sieve[1] = true;
    FOR(i, 2, MAX_N) {
        if (sieve[i]) continue;
        for (int j = i + i; j <= MAX_N; j += i) {
            sieve[j] = true;
        }
    }

    int n;
    while (cin >> n, n) {
        int count = 0;
        FOR(i, n + 1, n * 2) {
            if (!sieve[i]) count++;
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 1400
def main():
    N = int(input())
    V = [int(v) for v in input().split()]
    C = [int(c) for c in input().split()]

    tot = 0
    for i in range(N):
        if V[i] > C[i]:
            tot += V[i] - C[i]
    return tot


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 3003;
const ll MOD = 998244353;

ll dp[MAX][MAX];

int main()
{
    fastRead;
    int r1 , c1, r2, c2;
    cin>>r1>>c1>>r2>>c2;
    
    dp[r1][c1] = 1;
    
    for(int i = r1 ; i <=r2 ; i++ ) {
        for(int j = c1 ; j <= c2 ; j++ ) {
            
            if(i > r1) dp[i][j] = (dp[i][j] + dp[i-1][j]*j ) % MOD;
            if(j > c1) dp[i][j] = (dp[i][j] + dp[i][j-1]*i ) % MOD;
            if(i > r1 && j > c1 ) dp[i][j] = (dp[i][j] - dp[i-1][j-1]*(i-1)*(j-1)) % MOD;
            if(dp[i][j] < 0 ) dp[i][j] += MOD;
        }
    }
    
    cout<<dp[r2][c2]<<'\n';
    return 0;
}

Measured memory_bytes: 73880
#include <stdio.h>
int main()
{
char str[10000];
int N;
scanf("%d",&N);
scanf("%s",str);
for (int count=0;count<10000;count++)
{
	if((str[count]>='A')&&(str[count]<='Z'))
	{
		str[count]+=N;
		if(str[count]>'Z')
		{
			str[count]-=26;
		}
		printf("%c",str[count]);
	}
	else break;
}
}


Measured memory_bytes: 128
s=input()
al=[chr(ord('a')+i) for i in range(26)]
f=False
if s[0]=='A':
    s_ = s[2:-1]
    Ccount=0
    for a in s_:
        if a in al:
            continue
        elif a=='C':
            if Ccount==1:
                Ccount+=1
                break
            else:
                Ccount+=1
        else:
            break
    if Ccount==1:
        f=True
    if s[-1] not in al:
        f=False
    if s[1] not in al:
        f=False
print('AC' if f else 'WA')

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

int main(){
  int N; string S; cin >> N >> S;
  
  int lad = 0, rad = 0;
  int lre = 0, rre = 0;
  
  for(int i = 0; i < N; i++){
    if(S[i] == '(') lre++;
    else {
      if(lre > 0) lre--;
      else lad++;
    }
  }
  for(int i = N-1; i >= 0; i--){
    if(S[i] == ')') rre++;
    else {
      if(rre > 0) rre--;
      else rad++;
    }
  }
  for(int i = 0; i < lad; i++){
    S = "(" + S;
  }
  for(int i = 0; i < rad; i++){
    S = S + ")";
  }
  cout << S;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

size_t N;
vector<int> a, b, c;

auto dp = make_v(-1, int(1e5), 4);

int rec(size_t idx, int tail) {
    if (idx == N) return 0;
    if (~dp[idx][tail]) return dp[idx][tail];
    int ret = 0;
    if (tail != 0) chmax(ret, rec(idx + 1, 0) + a[idx]);
    if (tail != 1) chmax(ret, rec(idx + 1, 1) + b[idx]);
    if (tail != 2) chmax(ret, rec(idx + 1, 2) + c[idx]);
    return dp[idx][tail] = ret;
}

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

    cin >> N;
    a.resize(N), b.resize(N), c.resize(N);

    for (size_t i = 0; i < N; ++i) {
        cin >> a[i] >> b[i] >> c[i];
    }

    cout << rec(0, 3) << "\n";

    return 0;
}


Measured memory_bytes: 11648
import sys
import math


def main():
    N = int(sys.stdin.readline().rstrip())

    sum_ = 0

    for i in range(1, int(math.sqrt(N)) + 1):

        sum_ += i**2

        k1 = N // i
        # k2 = i

        k1_sum = k1 * (k1 + 1) // 2
        k2_sum = i * (i + 1) // 2
        sum_ += 2 * i * (k1_sum - k2_sum)

    print(sum_)


main()


Measured memory_bytes: 9092
from collections import deque

n, m = map(int, input().split())
paths = [[] for _ in range(n + 1)]

for i in range(m):
    a, b = map(int, input().split())
    paths[b].append(a)
    paths[a].append(b)

q = deque()
q.append(1)
l = [-1]*(n + 1)
l[1] = 0

while q:
    v = q.popleft()
    for i in paths[v]:
        if l[i] == -1:
            l[i] = v
            q.append(i)

print("Yes")

for i in l[2:]:
    print(i)

Measured memory_bytes: 34912
string = input()
count_array = [0]*26
alphabets = "abcdefghijklmnopqrstuvwxyz"
cha_to_idx = {cha: i for i, cha in enumerate(alphabets)}
for cha in string:
    count_array[cha_to_idx[cha]] = 1

for i, count in enumerate(count_array):
    if count == 0:
        print(alphabets[i])
        break
    elif (count>=1) & (i == 25):
        print("None")

Measured memory_bytes: 3188
import sys, math
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
M = list(map(int, input().split()))
memo = [[None] * 2000 for _ in range(N+1)]

def check(i, m):
    if memo[i][m] is not None:
        return memo[i][m]
    if (m == 0):
        memo[i][m] = True
        return True
    elif (i == N):
        memo[i][m] = False
        return False
    else:
        ans = check(i+1, m) or check(i+1, m - A[i])
        memo[i][m] = ans
        return ans

for m in M:
    if (check(0, m)):
        print('yes')
    else:
        print('no')


Measured memory_bytes: 6032
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] arr = new int[n][3];
        for (int i = 0; i < n; i++) {
            arr[i] = new int[]{sc.nextInt(), sc.nextInt(), sc.nextInt()};
        }

        int N = 393;
        // dp[i] ... iの長さのメロディの最高得点
        int[] dp = new int[N + 1];
        Arrays.fill(dp, 0);
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < n; j++) {
                int s = arr[j][0];
                int l = arr[j][1];
                int p = arr[j][2];
                for (int k = s; k <= Math.min(i + 1, l); k++) {
//                    debug(i, j, k, dp);
                    dp[i + 1] = Math.max(dp[i], Math.max(dp[i + 1], dp[i + 1 - k] + p));
                }
            }
        }
//        debug(dp);
        int m = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            int x = sc.nextInt();
            if (dp[x] == 0) {
                System.out.println(-1);
                return;
            }
            list.add(dp[x]);
        }

        for(int x : list) {
            System.out.println(x);
        }
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}



Measured memory_bytes: 32696
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cout<<fixed<<setprecision(20);
	cin.tie(0);ios::sync_with_stdio(false);
	int i,n,K,ans=1;cin>>n>>K;
	vector<int>P(n);
	for(i=0;i<n;i++){cin>>P[i];}
	//「変わらない」を状態に含めるかどうか
	set<int> you;
	for(i=0;i<K;i++){you.ins(P[i]);}
	bool nanimo=false;
	int henka=0;
	for(i=0;i<K-1;i++){
		if(P[i]>P[i+1]){henka++;}
	}
	if(henka==0){nanimo=true;}
	for(i=K;i<n;i++){
		bool fe=false;
		if(P[i-K]>P[i-K+1]){henka--;}
		if((*you.begin())!=P[i-K]){fe=true;}
		you.era(P[i-K]);
		you.ins(P[i]);
		if((*you.rbegin())!=P[i]){fe=true;}
		if(P[i-1]>P[i]){henka++;}
		if(fe){
			if(henka>0){ans++;}
			else if(!nanimo){nanimo=true;ans++;}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 10368
use strict;
use warnings;
package ZAlgorithm;
sub z_algorithm(@){
	my$n=@_;
	return()if$n==0;
	my@z=(0);
	my$j=0;
	for my$i(1..$n-1){
		$z[$i]=$j+$z[$j]<=$i?0:$j+$z[$j]-$i<$z[$i-$j]?$j+$z[$j]-$i:$z[$i-$j];
		$z[$i]++while$i+$z[$i]<$n&&$_[$z[$i]]==$_[$i+$z[$i]];
		$j=$i if$j+$z[$j]<$i+$z[$i];
	}
	$z[0]=$n;
	return@z;
}
package main;
my$N=<>;
my@A=map int,split$",<>;
my@B=map int,split$",<>;
my@T;
for(0..$N-1){
	$T[$_]=$B[$_]^$B[($_+1)%$N];
	$T[$_+$N]=$T[$_+2*$N]=$A[$_]^$A[($_+1)%$N];
}
my@z=ZAlgorithm::z_algorithm(@T);
for(0..$N-1){
	print$_,$",$A[$_]^$B[0],$/if$z[$_+$N]>=$N;
}


Measured memory_bytes: 109388
while True:
    a,b = map(int, input().split())
    if a == 0 and b == 0: break

    for j in range(a):
        for i in range(b):
            if i==0 or j==0 or i==b-1 or j==a-1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7000
#include <iostream>

int main() {
    int n, k;
    std::cin >> n >> k;

    char chars[n];
    std::cin >> chars;

    switch (chars[k - 1]) {
        case 'A': 
            chars[k - 1] = 'a';
            break;
        case 'B':
            chars[k - 1] = 'b';
            break;
        case 'C':
            chars[k - 1] = 'c';
            break;
    }

    std::cout << chars << std::endl;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int R = scan.nextInt();

        os.println(2 * R * Math.PI);
    }
}

Measured memory_bytes: 27112
/*
======================
[     ___T_          ]
[    | 6=6 | =>HI :-)] 
[    |__o__|         ]
[ >===]__o[===<      ]
[     [o__]          ]
[      .".           ]
[      |_|           ]
[                    ]
======================
 */

#include<bits/stdc++.h>
using namespace std;
using lli = int64_t;
int main(){
	 ios::sync_with_stdio(false);
	 cin.tie(nullptr);
	 cout.tie(nullptr);
	 int T = 1;
	 for(int t = 1; t <= T; t++){
		 int x;
		 cin >> x;
		 if(x == 2){
			 cout << x << "\n";
			 return 0;
		 }
		 if(x == 3){
			 cout << x << "\n";
			 return 0;
		 }
		 for(int i = x; ; i++){
			 bool yes = true;
			 for(int j = 2; j * j <= i; j++){
				 if(i % j == 0){
					 yes = false;
					 break;
				 }
			 }
			 if(yes){
				 cout << i << "\n";
				 return 0;
			 }
		 }
	 }
}



Measured memory_bytes: 3608
#include <stdio.h>

int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);

	if (a < b) {
		printf("a < b\n");

	}
	else if (a > b) {
		printf("a > b\n");
	}else {
		printf("a == b\n");
	}

return 0;
} 


Measured memory_bytes: 2104
s = list(input())
T_g = s.count("g")
T_p = s.count("p")

if T_g == T_p or T_g == T_p+1:
  result = 0
  print(result)
  exit()
else:
  P = (T_g + T_p) // 2
  result = P - T_p
  print(result)


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

Measured memory_bytes: 256
d, n = map(int,input().split())
if d == 0:
    if n == 100:
        print(n + 1)
    else:
        print(n)
elif d == 1:
    if n == 100:
        print(n * 101)
    else:
        print(n * 100)
else:
    if n == 100:
        print(101 * 10000)
    else:
        print(n * 10000)

Measured memory_bytes: 3060
import math
N,D = map(int,input().split())
X = [list(map(int,input().split())) for _ in range(N)]
count = 0
for i in range(N-1):
  for j in range(i+1,N):
    dis = 0
    for d in range(D):
      dis += (X[j][d]-X[i][d])**2
    if math.sqrt(dis)%1 == 0:
      count += 1
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;

struct Node{
  int key;
  Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z -> key = k;
  z -> right = NIL;
  z -> left = NIL;

  while(x != NIL){ // xとNILのアドレスが違うかぎりループする。
    y = x;
    if(z -> key < x -> key){
      x = x -> left;
    }else{
      x = x -> right;
    }
  }
  z -> parent = y;

  if(y == NIL){ // 最初のkeyはrootにする。
    root = z;
  }else{
    if(z -> key < y -> key){
      y -> left = z;
    }else{
      y -> right = z;
    }
  }
  return;
}

void inPerse(Node *u){
  if(u == NIL) return;
  inPerse(u -> left);
  cout << " " << u -> key;
  inPerse(u -> right);
}

void prePerse(Node *u){
  if(u == NIL) return;
  cout << " " << u -> key;
  prePerse(u -> left);
  prePerse(u -> right);
}

int main(void){
  int n, key;
  string order;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> order;
    if(order[0] == 'i'){
      cin >> key;
      insert(key);
    }else if(order[0] == 'p'){
      inPerse(root);
      cout << endl;
      prePerse(root);
      cout << endl;
    }
  }
  return 0;
}



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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_DIGIT 30

i64 dp[MAX_DIGIT + 1][2][2][10]; // [決定した桁数][未満フラグ][leading zeros][その桁の数字]


i64 count_lum(i64 n) {
    string ns = to_string(n);
    i64 L = ns.length();
    REP(i, L + 1) REP(j, 2) REP(k, 2) REP(d, 10) dp[i][j][k][d] = 0;
    dp[0][0][1][0] = 1;

    REP(i, L) {
        i64 D = ns[i] - '0';
        REP(smaller, 2) {
            REP(zeros, 2) {
                REP(d_prev, 10) {
                    for (i64 d = 0; d <= (smaller ? 9 : D); d++) {
                        if (zeros) {
                            dp[i + 1][smaller || d < D][d == 0][d] += dp[i][smaller][zeros][d_prev];
                        } else if (abs(d - d_prev) <= 1) {
                            dp[i + 1][smaller || d < D][0][d] += dp[i][smaller][zeros][d_prev];
                        }
                    }
                }
            }
        }
    }

    i64 res = 0;
    REP(i, 10) res += dp[L][0][0][i] + dp[L][1][0][i];
    return res;
}


#define INF 1152921504606846976

int main() {
    i64 K; cin >> K;
    // x以下のるんるん数を数える

    i64 lb = 0, ub = INF;
    while (ub - lb > 1) {
        i64 mid = (lb + ub) / 2;
        if (count_lum(mid) >= K) {
            ub = mid;
        } else {
            lb = mid;
        }
    }

    cout << ub << endl;

    return 0;
}

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

int N;

int main() {
  int Q; cin >> N >> Q;
  fenwick_tree<long> fw(N);
  int a;
  for (int i = 0; i < N; i++) { cin >> a; fw.add(i, a); }
  int t, arg1, arg2;
  for (int q = 0; q < Q; q++) {
    cin >> t >> arg1 >> arg2;
    if (t == 0) {
      fw.add(arg1, arg2);
    } else {
      cout << fw.sum(arg1, arg2) << endl;
    }
  }
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int N, K;
	cin >>N >>K;
	vector<int> P(N, 0);
	for (int i=0; i<N; i++)
		cin >>P.at(i);
	if (N==K) {
		cout <<1 <<endl;
		return 0;
	}
	vector<bool> m(N, false);
	int SS=0;
	for (int i=1, k=1; i<N; i++) {
		if (P.at(i)>P.at(i-1)) {
			k++;
			if (k>=K) {
				m.at(i-k+1)=true;
				SS=1;
			}
		} else
			k=1;
	}
	priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> LL;
	vector<bool> l(N, false);
	for (int i=N-1; i>=0; i--) {
		LL.push({P.at(i), i});
		while(LL.top().at(1)>=i+K)
			LL.pop();
		if(P.at(i)==LL.top().at(0))
			l.at(i)=true;
	}
	priority_queue<vector<int>, vector<vector<int>>, less<vector<int>>> RR;
	vector<bool> r(N, false);
	for (int i=0; i<N; i++) {
		RR.push({P.at(i), i});
		while(RR.top().at(1)<=i-K)
			RR.pop();
		if(P.at(i)==RR.top().at(0))
			r.at(i)=true;
	}
	for (int i=0; i<N-K; i++) 
		if((l.at(i))&&(r.at(i+K)))
			m.at(i+1)=true;
	int S=N-K+1;
	for (int i=0; i<N-K+1; i++)
		if(m.at(i))
			S--;
	S +=SS;
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 26796
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <stack>

using namespace std;

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repl(i, n) for(LL i = 0; i < (LL)(n); i++)

int main(void){
  int a, b, c, k;
  int sum;
  cin >> a >> b >> c >> k;

  if ((a - k) >= 0) {
    sum = k;
  } else {
    sum = a;
  }

  if ((k - (a + b)) >= 0) {
    sum -= (k - (a + b));
  }

  cout << sum;

  return 0;
};

Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
	int nm[2];
	int dice[2][1000];
	int now;
	int i, j;
	int dd, count;
	
	while (scanf("%d %d", &nm[0], &nm[1])){
		if (nm[0] == 0 && nm[1] == 0){
			break;
		}
		
		count = dd = 0;
		for (i = 0; i < 2; i++){
			for (j = 0; j < nm[i]; j++){
				scanf("%d", &dice[i][j]);
			}
		}
		
		now = 1;
		while (1){
			if (now >= nm[0]){
				break;
			}
			now += dice[1][dd];
			now += dice[0][now - 1];
			dd++;
			count++;
		}
		
		printf("%d\n", count);
	}
	
	return (0);
}

Measured memory_bytes: 604
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
class DisjointSet {
public:
	// ???????????°??????????????????????????¨???????????¨???2??????????´????????????°????????????????±????????????????????????????????????????
	vector<T>rank, p, S; // p->parent  S[findSet(v)] ->??£??????????????§??????
	DisjointSet() {}
	DisjointSet(int size) {
		S.resize(size, 1);
		rank.resize(size, 0);
		p.resize(size, 0);
		rep(i, 0, size)makeSet(i);
	}
	void makeSet(int x) {
		p[x] = x;
		rank[x] = 0;
	}
	bool same(int x, int y) {   // ????????????
		return findSet(x) == findSet(y);
	}
	void unite(int x, int y) { // ??£???????????¨????????????????????????
		if (same(x, y))return;
		link(findSet(x), findSet(y));
	}
	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			if (rank[x] == rank[y]) {
				rank[y]++;
			}
		}

		S[x] = S[y] = S[x] + S[y];
	}
	int findSet(int x) {
		if (x != p[x]) {
			p[x] = findSet(p[x]);// path compression
		}
		return p[x];
	}
	int connectedComponentSize(int x) {
		return S[findSet(x)];
	}
};


class Edge {
public:
	int source, target, cost;
	Edge(int source = 0, int target = 0, int cost = 0):
		source(source), target(target), cost(cost) {};

	bool operator < (const Edge &e)const {
		return cost < e.cost;
	}
};

int kruskal(int N, vector<Edge> edges) {
	int totalCost = 0;
	sort(all(edges));
	DisjointSet<int> dset(N);
	rep(i, 0, edges.size()) {
		Edge e = edges[i];
		if (!dset.same(e.source, e.target)) {
			// MST.pushbadk(e);
			totalCost += e.cost;
			dset.unite(e.source, e.target);
		}
	}
	return totalCost;
}

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

	int N, M; cin >> N >> M;
	vector<Edge>edges;
	rep(i, 0, M) {
		int source, target, cost; cin >> source >> target >> cost;
		edges.push_back(Edge(source, target, cost));
	}

	cout << kruskal(N, edges) << endl;
	return 0;
}

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

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

    sort(a, a + n);

    cout << a[n - 1] - a[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
int n, a[1234], q;
signed main() {
	cin >> n; for0(i, n)cin >> a[i]; cin >> q;
	for1(valsqotch, q) {
		int b, m, e; cin >> b >> m >> e;
		int a1[1234];
		for0(i, n)a1[i] = mod;
		for0(k, e - b)a1[b + (k + e - m) % (e - b)] = a[b + k];
		for0(i, n)if (a1[i] != mod)a[i] = a1[i];
	}
	for0(i, n) { if (i)cout << ' '; cout << a[i]; }cout << endl;
}


Measured memory_bytes: 3112
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        long x=Long.parseLong(br.readLine());
        long sum=100;
        int cntr=0;
        while(sum<x)
        {
            sum=sum+sum/100;
            cntr++;
        }
        pw.println(cntr);
        /*for(int x=0;x<q;x++)
        {
            String str[]=br.readLine().split(" ");
            int n=Integer.parseInt(str[0]);
            int m=Integer.parseInt(str[1]);
            String s=br.readLine();
        }*/
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 32592
main :: IO ()
main = do
    a <- map toInt . words <$> getLine
    let a0 = a !! 0
        a1 = a !! 1
    print $ if a1 `mod` a0 == 0
        then a1 + a0
        else a1 - a0

toInt :: String -> Int
toInt x = read x :: Int

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

typedef long long ll;

#define fio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout);
#define cio() ios::sync_with_stdio(0); cin.tie(0);
#define endl '\n'

const int mod = 1e9+7;
template<typename T>
void amax(T& a, T b) { a=a>b?a:b; }
template<typename T>
void amin(T& a, T b) { a=a<b?a:b; }

using namespace std;

const int mxN =1e2+1;
bool vis[mxN];
int main() {
    cio();
    int n, x;
    int a;
    cin >> x >> n;
    for(int i=0; i<n; ++i)
        cin >> a, vis[a] = true;

    int mn = 0x3f3f3f3f;
    for(int i=0; i<=101; ++i)
        if(i==101 || !vis[i]) if(abs(x-i) < abs(x-mn)) mn = i;

    cout << mn << endl;

    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long
#define db long double
#define fi first
#define se second
#define  pb push_back
#define  pob pop_back
#define W while
#define fn(i,x) for(int i=0;i<x;i++)
#define fs(i,s,x) for(int i=s;i<x;i++)
#define fr(i,x) for(int i=x;i>=0;i--)
#define fit(it,s) for(auto it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 1000000007
#define MAX 1005

// cout << "Case #" << i << ": " << "Your Ans" <<  "\n";

using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 
    // freopen("in.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    
    ll n,a,b;
    cin >> n >> a >> b;
    cout << min(a*n,b);
 
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n, a;
    cin >> n >> a;
    vector<vector<ll>> dp(n+1, vector<ll>(3000));
    dp[0][0] = 1;
    REP(i, n){
        int x;
        cin >> x;
        RREP(j, i+1){
            REP(k, 3000-x){
                dp[j+1][k+x] += dp[j][k];
            }
        }
    }

    ll ans = 0;
    REP(i, n){
        ans += dp[i+1][a*(i+1)];
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

using ll = long long;
using ii = pair<int,int>;

#define ff first
#define ss second

const int maxn = 1e5+10;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	bool ok = false;
	cin >> n;
	for(int i=1;i<=9;++i){
		for(int j=1;j<=9;++j){
			if(i*j == n)
				ok = true;
		}
	}
	cout << (ok ? "Yes" : "No") << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Segment_Tree{
	private:
	int n;
	vi date;
	int Rec(int a,int b,int k,int l,int r){
		if(r<=a||b<=l) return 0;
		if(a<=l&&r<=b) return date[k];
		int m=(l+r)/2;
		return Rec(a,b,k*2+1,l,m)+Rec(a,b,k*2+2,m,r);
	}
	public:
	Segment_Tree(int n_){
		n=1;
		while(n<n_) n*=2;
		date=vi(2*n-1);
	}
	void Update(int k,int x){
		k+=n-1;
		date[k]+=x;
		while(k>0){
			k=(k-1)/2;
			date[k]=date[k*2+1]+date[k*2+2];
		}
	}
	int Query(int a,int b){
		return Rec(a,b,0,0,n);
	}
	int Open(int k){
		return date[k+n-1];
	}
};

const int M=26;
string s;
int n,m,b[M];
vi a[M];

int main(){
	cin>>s>>m;
	n=s.size();
	Segment_Tree st(n);
	for(int i=0;i<n;i++){
		a[s[i]-'a'].push_back(i);
		st.Update(i,1);
	}
	for(int i=0;i<n;i++) for(int j=0;j<M;j++) if(b[j]<a[j].size()){
		int t=st.Query(0,a[j][b[j]]);
		if(t<=m){
			m-=t;
			st.Update(a[j][b[j]++],-1);
			cout<<(char)('a'+j);
			break;
		}
	}
	cout<<endl;
}


Measured memory_bytes: 5856
s=input()
def chk_palin(s):
    i=0
    j=len(s)-1
    while i<j:
        if s[i]!=s[j]:
            return False
        i+=1
        j-=1
    return True
n=len(s)
if chk_palin(s) and chk_palin(s[:(n-1)//2]) and chk_palin(s[(n+3)//2-1:]):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=300000+5;
char s[200005];
int main()
{
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    int ok=1;
    scanf("%s",s+1);
    if(d>b&&b>c || d>c&&c>b)
    {
        for(int i=a;i<c;i++)
            if(s[i]=='#' && s[i+1]=='#')
            {
                ok=0;
                break;
            }
        for(int i=b;i<d;i++)
            if(s[i]=='#' && s[i+1]=='#')
            {
                ok=0;
                break;
            }
        puts(ok?"Yes":"No");
    }
    else
    {
        for(int i=a;i<c;i++)
        if(s[i]=='#' && s[i+1]=='#')
        {
            puts("No");return 0;
        }

        for(int i=b-1;i<=d-1;i++)
        {
            if(s[i]=='.' && s[i+1]=='.' && s[i+2]=='.')
            {
                puts("Yes");return 0;
            }
        }

        puts("No");
    }

    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int as[100000+10];

int main(void) {
  int n, m;
  scanf("%d%d", &n, &m);
  REP(i, m) {
    int a, b;
    scanf("%d%d", &a, &b);
    as[b] = max(as[b], a);
  }
  int res = 0;
  int last = -1;
  REP(i, n+1) {
    if(as[i] && as[i] >= last) {
      res++;
      last = i;
    }
  }
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 512
n=int(input())
s=input()
if n==0:
    print(s)
else:
    m=len(s)
    ch=''
    for i in range(m):
        a=ord(s[i])+n
        if a>90:
            b=65+a-91
            b=chr(b)
            ch+=b
        else:
            ch+=chr(a)
    print(ch)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <vector>


using namespace std;

void b()
{
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}

	int count = 0;
	for (int i = 1; i < n - 1; i++) {
		if ((p[i - 1] < p[i] && p[i] < p[i + 1])
			|| (p[i + 1] < p[i] && p[i] < p[i - 1])) {
			count++;
		}
	}
	cout << count << endl;
}
int main()
{
	b();
}


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

using namespace std;

const int N = 1e5 + 100;

int n, L, pos = 0, a[N];

int main() {
	cin >> n >> L;
	for(int i = 1;i <= n; ++i) cin >> a[i];
	for(int i = 1;i <  n; ++i) 
		if(a[i] + a[i + 1] >= L) 
			pos = i;
	if(pos) {
		puts("Possible");
		for(int i = 1;i < pos; ++i)
			cout << i << endl;
		for(int i = n - 1;i > pos; --i)
			cout << i << endl;
		cout << pos << endl;
	} else {
		puts("Impossible");
	}
	return 0;
}

Measured memory_bytes: 4024
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
unordered_set<string> a;
int main(){
	int n;
	cin>>n;
	string s[n],t;
	r(i,n)cin>>s[i];
	r(i,6)r(j,n)r(k,s[j].size())
		if(k+i<=s[j].size())a.insert(s[j].substr(k,i));
	r(i,27)r(j,27)r(k,27)r(l,26){
		t="";
		if(i)t+='a'-1+i;
		if(j)t+='a'-1+j;
		if(k)t+='a'-1+k;
		t+='a'+l;
		if(!a.count(t))cout<<t<<endl,exit(0);
	}
}

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

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

  int n, m; cin >> n >> m;
  int t = (1900 * m + 100 * (n - m)) * pow(2, m);
  cout << t << '\n';
  return 0;
}

Measured memory_bytes: 256