akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          string w = Input.ScanStr();
          bool f=false;
          int i;
          for(i=0;i<w.Length;i++) if(w[i]=='C') break;
          for(;i<w.Length;i++)
            if(w[i]=='F') f=true;
          
          Console.WriteLine(f ? "Yes" : "No");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


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

typedef long long LL;

const int N=200005;
const int MOD=924844033;

int n,cnt,last[N],size[N],a[N*4],b[N*4],rev[N*4],L,jc[N],ny[N];
struct edge{int to,next;}e[N*2];

int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

void addedge(int u,int v)
{
	e[++cnt].to=v;e[cnt].next=last[u];last[u]=cnt;
	e[++cnt].to=u;e[cnt].next=last[v];last[v]=cnt;
}

void dfs(int x,int fa)
{
	size[x]=1;a[n]++;
	for (int i=last[x];i;i=e[i].next)
	{
		if (e[i].to==fa) continue;
		dfs(e[i].to,x);
		size[x]+=size[e[i].to];
		a[size[e[i].to]]--;
	}
	if (n-size[x]) a[n-size[x]]--;
}

int C(int n,int m)
{
	return (LL)jc[n]*ny[m]%MOD*ny[n-m]%MOD;
}

int ksm(int x,int y)
{
	int ans=1;
	while (y)
	{
		if (y&1) ans=(LL)ans*x%MOD;
		x=(LL)x*x%MOD;y>>=1;
	}
	return ans;
}

void NTT(int *a,int f)
{
	for (int i=0;i<L;i++) if (i<rev[i]) swap(a[i],a[rev[i]]);
	for (int i=1;i<L;i<<=1)
	{
		int wn=ksm(5,f==1?(MOD-1)/i/2:MOD-1-(MOD-1)/i/2);
		for (int j=0;j<L;j+=(i<<1))
		{
			int w=1;
			for (int k=0;k<i;k++)
			{
				int u=a[j+k],v=(LL)a[j+k+i]*w%MOD;
				a[j+k]=u+v;a[j+k]-=a[j+k]>=MOD?MOD:0;
				a[j+k+i]=u+MOD-v;a[j+k+i]-=a[j+k+i]>=MOD?MOD:0;
				w=(LL)w*wn%MOD;
			}
		}
	}
	int ny=ksm(L,MOD-2);
	if (f==-1) for (int i=0;i<L;i++) a[i]=(LL)a[i]*ny%MOD;
}

int main()
{
	n=read();
	for (int i=1;i<n;i++)
	{
		int x=read(),y=read();
		addedge(x,y);
	}
	jc[0]=jc[1]=ny[0]=ny[1]=1;
	for (int i=2;i<=n;i++) jc[i]=(LL)jc[i-1]*i%MOD,ny[i]=(LL)(MOD-MOD/i)*ny[MOD%i]%MOD;
	for (int i=2;i<=n;i++) ny[i]=(LL)ny[i-1]*ny[i]%MOD;
	dfs(1,0);
	for (int i=0;i<=n;i++) b[i]=ny[i],a[i]+=a[i]<0?MOD:0,a[i]=(LL)a[i]*jc[i]%MOD;
	reverse(b,b+n+1);
	int lg=0;
	for (L=1;L<=n*2;L<<=1,lg++);
	for (int i=0;i<L;i++) rev[i]=(rev[i>>1]>>1)|((i&1)<<(lg-1));
	NTT(a,1);NTT(b,1);
	for (int i=0;i<L;i++) a[i]=(LL)a[i]*b[i]%MOD;
	NTT(a,-1);
	for (int i=1;i<=n;i++) printf("%d\n",(LL)ny[i]*a[n+i]%MOD);
	return 0;
}

Measured memory_bytes: 25728
#include "bits/stdc++.h"
using namespace std;
int main() {
	while (1) {
		long long int A, B, D; cin >> A >> B >> D;
		if (!A)break;
		pair<long long int, long long int >ans = make_pair(1e9, 1e9);
		for (int i = -100000; i < 100000; ++i) {
			const int anum = abs(i);
			if (!((D - A*i)%B)) {
				long long int bnum = abs((D - A*i) / B);
				if (anum + bnum < ans.first + ans.second|| anum*A + bnum*B < ans.first*A + ans.second*B)ans = make_pair(anum, bnum);
			}
		}
		cout << ans.first << " " << ans.second << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
# 5_B
while(True):
    h,w=map(int, input().split())
    if h == 0 and w == 0:
        break
    i=0
    while(i<h):
        if i == 0:
            print("#"*w)
        elif i == (h-1):
            print("#"*w)
        else:
            print("#", end='')
            print("."*(w-2), end='')
            print("#")
        i+=1
       
    print()


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

int main(){
    int a,b,c,d,e,k;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    scanf("%d",&e);
    scanf("%d",&k);
    if(e-a<=k) printf("Yay!");
    else printf(":(");
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  bool can=true;
  for(int i=0;i<s.size();i++){
    if(i%2==0){
      if(s[i]=='L'){
        can=false;
        break;
      }
    }else if(i%2==1){
      if(s[i]=='R'){
        can=false;
        break;
      }
    }
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int i, n, minv, maxv;
  int R[200000];

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

  minv = R[0];
  maxv = R[1]-R[0];
  for(i=1; i<n; i++) {
    if(maxv < R[i]-minv)
      maxv = R[i]-minv;
    if(minv > R[i])
      minv = R[i];
  }
  printf("%d\n", maxv);
  return 0;
}

Measured memory_bytes: 1376
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

vector<int> gen(int N){
    vector<int> res;
    set<int> S;
    int last = 1;
    for(int i=0;i<N;i++){
        while(true){
            bool ok = !S.count(last);
            if(ok){
                for(auto& t : res){
                    if(S.count(t + last)){
                        ok = false;
                        break;
                    }
                }
            }
            if(ok){
                S.insert(last);
                for(auto& t : res) S.insert(t + last);
                res.push_back(last);
                ++last;
                break;
            }
            ++last;
        }
    }
    return res;
}

long long longest(const vector<vector<long long>>& cost, int N){
    vector<int> a(N);
    for(int i=0;i<N;i++) a[i] = i;
    long long res = 1;
    do {
        long long sum = 0;
        for(int i=0;i+1<N;i++) sum += cost[a[i]][a[i+1]];
        res = max(res, sum);
    } while(next_permutation(a.begin(), a.end()));
    return res;
}

vector<vector<long long>> solve(int N){
    vector<int> g = gen(N);
    vector<vector<long long>> res(N, vector<long long>(N, 0));
    res[0][1] = res[1][0] = 1;
    for(int i=2;i<N;i++){
        long long l = longest(res, i);
        for(int j=0;j<i;j++) res[i][j] = res[j][i] = g[j] * (l+1);
    }
    return res;
}

int main(){
    int N;
    while(cin >> N){
        auto l = solve(N);
        for(auto& v : l){
            cout << v[0];
            for(int i=1;i<v.size();i++) cout << " " << v[i];
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>

int n,a[100];
int b,i,j;
unsigned long long int dp[102][22];

int main(void){
	scanf("%d",&n);
	for(b=0;b<n;b++){
		scanf("%d", &a[b]);
	}
	dp[1][a[0]]=1;
	for(i=1;i<n-1;i++){
		for(j=0;j<=20;j++){
			if(dp[i][j]>0){
				int plus=j+a[i];
				int minus=j-a[i];
        	                if(plus>=0 && plus<=20){
					dp[i+1][plus]+=dp[i][j];
				}
				if(minus>=0 && minus<=20){
					dp[i+1][minus]+=dp[i][j];
				}
			}
		}
	}
	
	printf("%llu\n",dp[n-1][a[n-1]]);
	return 0;
}

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

typedef long long ll;

#define rep(a,b,c) for(int a=b,a##end=c;a<=a##end;++a)
#define drep(a,b,c) for(int a=b,a##end=c;a>=a##end;--a)


char IO;
int rd(){
	int s=0,f=0;
	while(IO=getchar(),IO<'0'||IO>'9')if(IO=='-')f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(IO=getchar(),IO>='0'&&IO<='9');
	return f?-s:s;
}

const int N=1e5+10,P=1e9+7;

int n,m;

int dis[N][3];



struct Edge{
	int to,nxt;
}e[N];
int head[N],ecnt;
void AddEdge(int u,int v){
	e[++ecnt]=(Edge){v,head[u]};
	head[u]=ecnt;
}

int inq[N][3];
queue<pair<int,int> >Q;
void SPFA(int st){
	Q.push((pair<int,int>){st,0});dis[st][0]=0;
	while(!Q.empty()){
		int u=Q.front().first,k=Q.front().second;
		Q.pop();
		int nk=(k+1)%3;
		inq[u][k]=0;
		for(int i=head[u];i;i=e[i].nxt){
			int v=e[i].to;
			if(dis[v][nk]>dis[u][k]+1){
				dis[v][nk]=dis[u][k]+1;
				if(!inq[v][nk]) Q.push((pair<int,int>){v,nk}),inq[v][nk]=1;
			}
		}
	}
}


int main(){
	memset(dis,127,sizeof dis);
	n=rd(),m=rd();
	rep(i,1,m){
		int u=rd(),v=rd();
		AddEdge(u,v);
	}
	int s=rd(),t=rd();
	SPFA(s);
	int ans=dis[t][0];
	if(ans<1e9) printf("%d\n",ans/3);
	else puts("-1");
}








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

int main(){
  int N, M;
  cin >>N>>M;
  vector<int> A(M);
  for (int i=0;i<M;i++)cin >> A[i];
  A.push_back(N+1);
  
  vector<long long> fibo(N+2);
  int i = 0;
  while (i<=N+1){
    if(i==0) fibo[0] = 0;
    if(i==1) fibo[1] = 1;
    if(i>1){
      fibo[i] = fibo[i-1] + fibo[i-2];
      fibo[i] %= 1000000007;
    }
    i++;
  }
  
  long long ans = 1;
  for (int i=0;i<M+1;i++){
    int dist;
    if (i==0) dist = A[0];
    else dist = A[i] - A[i-1] - 1;
    ans *= fibo[dist];
    ans %= 1000000007;
  }
  cout << ans << endl;
}

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

int main() {
  int N;
  cin >>N;
  int c0=0,c1=0,c2=0,c3=0;
  
  for(int i = 0;i<N;i++){
    string tmp;
    cin >>tmp;
    if(tmp=="AC"){
	c0++;
    }else if(tmp=="WA"){
	    c1++;
    }else if(tmp=="TLE"){
	    c2++;
    }else if(tmp=="RE"){
	    c3++;
    }
}
    cout<<"AC x "<<c0<<endl;
    cout<<"WA x "<<c1<<endl;
    cout<<"TLE x "<<c2<<endl;
    cout<<"RE x "<<c3<<endl;

} 


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

int main()
{
    int N,X;
    cin >> N >> X;
    int m[110];
    int sum = 0;
    for(int i = 0;i < N;i++){
        cin >> m[i];
        sum += m[i];
    }
    int out = N;
    X -= sum;
    std::sort(&m[0],&m[N]);
    while(X>=0){
        X -= m[0];
        out++;
    }
    out--;
    cout << out;
    return 0;
}


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

int main() {
	int row,col;
	cin>>row>>col;
//	char a[row+1][col+1];
char q;


	long long u=(pow(10,9)+7);
	vector<vector<long long>> dp(row+1,vector<long long> (col+1,-1));
	for(int i=1;i<=row;i++){
		for(int j=1;j<=col;j++){
			cin>>q;
			if(q=='#')
			dp[i][j]=0;
		}
	}
	dp[row][col]=0;
	if(dp[row-1][col]!=0)
	dp[row-1][col]=1;
	
	if(dp[row][col-1]!=0)
	dp[row][col-1]=1;
	for(int i=row-2;i>=0;i--){
		if(dp[i][col]!=0)
		dp[i][col]=dp[i+1][col];
	}
	
	for(int i=col-2;i>=0;i--){
		if(dp[row][i]!=0)
		dp[row][i]=dp[row][i+1];
	}
	
	
	for(int i=row-1;i>=1;i--){
		for(int j=col-1;j>=1;j--){
			if(dp[i][j]!=0)
			dp[i][j]=dp[i+1][j]+dp[i][j+1];
			dp[i][j]=dp[i][j]%u;
		}
	}
	cout<<dp[1][1];
	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }



void solve(long long N, std::vector<long long> H){
	ll max = 0, now = 0;
	REP(i, N-1) {
		if (H[i] >= H[i+1]) {
			now++;
			chmax(max, now);
		} else {
			now = 0;
		}
	}
	cout << max << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, std::move(H));
    return 0;
}


Measured memory_bytes: 1024
n, k = map(int, input().split())
uni = [[] for i in range(n)]
ans = []

if n == 2 and k == 0:
    print(1)
    print(1, 2)
    exit()

for i in range(1,n):
    ans.append([1, i+1])

max_k = 0
for i in range(n-2):
    max_k += i + 1
if k > max_k:
    print(-1)
else:
    cnt = max_k - k
    while True:
        for i in range(1,n):
            for j in range(i+1, n):
                if cnt == 0:
                    print(len(ans))
                    for num in ans:
                        print(" ".join(map(str, num)))
                    exit()
                ans.append([i+1, j+1])
                cnt -= 1

Measured memory_bytes: 42096
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)
 
func run() {

	var r int64;
    r = nextInt();
	solve(r);

}

func solve(r int64){
	Println(3 * r*r)
}


// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int64 {
	a, err := strconv.ParseInt(next(),10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}

func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}


type IntHeap []int
func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	// Push and Pop use pointer receivers because they modify the slice's length,
	// not just its contents.
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

/////数字と文字
// 基本クラス
type NS struct {
    Num int
    Str string
}

//////　数字と数字
// 基本クラス
type NN struct {
    Num1 int
    Num2 int
}

 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}



Measured memory_bytes: 2816
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

X,Y = inpl()
if X%Y == 0:
	print(-1)
else:
	print(X*(Y+1))


Measured memory_bytes: 4580
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int N;
    cin >> N;
    map<string,ll> m;
    for(int i = 0; i < N; i++){
        string a;
        cin >> a;
        sort(a.begin(),a.end());
        m[a]++;
    }
    ll ans = 0;
    auto ite = m.begin();
    for(;ite != m.end(); ite++){
        ans += ite->second * (ite->second - 1) / 2 ;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11408
import numpy as np
from sys import stdin

def getval():
    n,m = map(int,input().split())
    path = [[] for i in [0]*(n+1)]
    for i in [0]*m:
        a,b = map(int, stdin.readline().split())
        path[a].append(b)
        path[b].append(a)
    return n,m,path

def solve(n,m,p):
    prev = np.zeros((n+1))
    q = [1]
    while q:
        idx = q.pop(0)
        adj = p[idx]
        for i in adj:
            if prev[i]:
                continue
            prev[i] = idx
            q.append(i)
    print("Yes")
    for i in range(2,n+1):
        print(int(prev[i]))

if __name__=="__main__":
    n,m,p = getval()
    #print(p)
    solve(n,m,p)

Measured memory_bytes: 52296
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define for1(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define endl '\n'
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, l[201];
    cin >> n;
    rep(i, 2 * n) {
        cin >> l[i];
    }
    sort(l, l + 2 * n);
    int sum = 0;
    for (int i = 0; i < 2 * n; i += 2) {
        sum += l[i];
    }
    cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <utility>

using namespace std;

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

int main(){
    int R, C;
    int sx, sy, gx, gy;
    int dst[50][50];
    int count_white = 0;
    char c[50][50];
    queue<pair<int,int>> que;
    cin >> R >> C;
    sy = 1; sx = 1; gy = R; gx = C;
    for(int i = 0; i < R; i++){
        for(int j = 0; j < C; j++){
            cin >> c[i][j];
            if(c[i][j] == '.'){
                count_white++;
            }
            dst[i][j] = -1;
        }
    }
    que.push(pair<int, int>(sy-1, sx-1));
    dst[sy-1][sx-1] = 0;
    
    while(que.size()){
        pair<int, int> p = que.front();
        if(p.first == gy-1 && p.second == gx-1){
            cout << count_white - dst[p.first][p.second] - 1 << endl;
            return 0;
        }
        que.pop();
        for(int i = 0; i < 4; i++){
            if(p.first + dy[i] >= 0 && p.first + dy[i] <= R-1 && p.second + dx[i] >= 0 && p.second + dx[i] <= C-1 && dst[p.first+dy[i]][p.second+dx[i]] == -1 && c[p.first+dy[i]][p.second+dx[i]] == '.'){
                dst[p.first+dy[i]][p.second+dx[i]] = dst[p.first][p.second] + 1;
                que.push(pair<int, int>(p.first+dy[i], p.second+dx[i]));
            }
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <cstdio>

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    if(A >= 13) {
        cout << B << endl;
    } else if(A >= 6 && A <= 12) {
        cout << B/2 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

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

#define printl(s) cout << s << endl;
#define print(s) cout << s << endl; return 0;
#define yes cout << "Yes" << endl; return 0;
#define no cout << "No" << endl; return 0;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n)+1; ++i)
using ll = long long;

const ll modseed = pow(10,9) + 7;

template <typename T>
vector<T> getValues(ll num){
    vector<T> values(num);
    for(ll i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

ll calculateDivNums(ll tg){
	ll ans = 0;
	for(ll a=1;a*a<=tg;a++){
      if(tg%a!=0){
        continue;
      }
      ll b = tg/a;
      ll tmp = max(a,b);
      if(a==1){
        ans = tmp;
      }else{
        ans = min(tmp,ans);
      }
    }
  return ans;
 }   

string S;
ll A,B,C,K,N, cnt;

int main(){
  cin >> N;
  ll ans = calculateDivNums(N);
  int dig = log10(ans)+1;
  printl(dig);
}


Measured memory_bytes: 3848
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int K, num;
string str, ans;

vector<char> inc;


void dfs(string s) {
	for (int i = 0; num < K && i < inc.size(); i++) {
		if (str.find(s + inc[i]) != -1) {
			num++;
			if (num == K) {
				ans = s + inc[i];
			}
			else {
				dfs(s + inc[i]);
			}
		}
	}
}


int main() {
	cin >> str >> K;

	num = 0;
	for (int i = 0; i < str.length(); i++) {
		int j;
		for (j = i - 1; j >= 0; j--) {
			if (str[i] == str[j])
				break;
		}
		if (j == -1)
			inc.push_back(str[i]);
	}

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

	dfs("");

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
typedef tree<string,null_type,less<string>,rb_tree_tag,tree_order_statistics_node_update> indexed_set2;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

int main()
{
    ll n;
    cin>>n;
    ll arr[n];
    REP(i,0,n){
        cin>>arr[i];
    }
    vector<pair<ll,ll>> v;
    REP(i,0,n-1){
        if(arr[i] < arr[i+1]){
            v.push_back({arr[i],arr[i+1]});
        }
    }
    ll curr = 1000;
    REP(i,0,v.size()){
        ll rem = curr % v[i].first;
        ll p = curr / v[i].first;
        curr = rem + p*v[i].second;
    }
    cout<<curr<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mk make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pf(a) printf("%d\n",a);
#define pfl(a) printf("%lld\n",a);
#define TEST int test; cin >> test;while(test--)
#define ii pair<int,int>
#define iil pair<ll,ll>
#define loop(i,a,b) for(int i = a ; i < b ; i++)
#define INF 2147483647


int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const double pi = acos(-1.0);

map<ll,ll>mp;
void solve()
{

    string s;
    cin >> s;
    int l = s.size();
    int c = 0, c1 = 0;
    for(int i = 0 ; i < l ; i++)
    {
        if(i % 2 == 0)
        {
            if(s[i] != '1') c++;
        }
        else
        {
            if(s[i] != '0') c++;
        }
    }

    for(int i = 0 ; i < l ; i++)
    {
        if(i % 2 == 0)
        {
            if(s[i] != '0') c1++;
        }
        else
        {
            if(s[i] != '1') c1++;
        }
    }
    cout << min(c1,c) << endl;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //TEST
    solve();
    return 0;
}


Measured memory_bytes: 512
from bisect import bisect

def indexes(L, x):
    INDEXES = []
    for i in range(len(L)):
        if L[i] == x:
            INDEXES.append(i)
    return INDEXES


s = input()
t = input()

ss = s * 2
alphabets = "abcdefghijklmnopqrstuvwxyz"
INDEXES = {c:indexes(ss, c) for c in alphabets}

def index(i, c):
    return INDEXES[c][bisect(INDEXES[c], i)]

if not INDEXES[t[0]]:
    print(-1)
    exit()
now = INDEXES[t[0]][0]

answer = now + 1
mod = len(s)
for c in t[1:]:
    if not INDEXES[c]:
        print(-1)
        exit()
    next = index(now, c)
    answer += next - now
    now = next % mod

print(answer)


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

int main()
{    
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();

    vector<vector<int>> x(26);
    rep(i,n) {
        char si = s[i];
        x[si-'a'].push_back(i);
    }
    int cp = -1;
    ll rcnt = 0;
    rep(i,m) {
        char ti = t[i];
        int dt = ti - 'a';
        if(x[dt].size() == 0) {
            cout << -1 << endl;
            return 0;
        }
        auto itr = lower_bound(x[dt].begin(),x[dt].end(),cp+1);
        if(itr != x[dt].end()) {           
            cp = *itr;
        }
        else {
            rcnt++;
            cp = x[dt][0];
        }
    }

    cout << rcnt*n+cp+1 << endl;
    return 0;
}

Measured memory_bytes: 1344
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int N, A[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) {
        cin >> A[i];
        A[i] -= (i + 1);
    }
    sort(A, A + N);

    int b;
    if (N % 2 == 1) b = A[N / 2];
    else b = (A[N / 2 - 1] + A[N / 2]) / 2;

    ll ans = 0;
    rep(i, 0, N) ans += abs(A[i] - b);
    cout << ans << endl;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>
#include <limits>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

using ll = long long;

constexpr int MAX_M = 2000, MAX_N = 1000;
constexpr ll INF = 1e18;

ll N, M;
ll a[MAX_M], b[MAX_M], c[MAX_M];
ll d[MAX_N];

int main()
{
	scanf("%lld%lld", &N, &M);
	rep(i, M)
		scanf("%lld%lld%lld", a + i, b + i, c + i), --a[i], --b[i];

	std::fill(d, d + N, -INF);
	d[0] = 0;

	bool upd = true;
	int cnt = 0;

	while (upd)
	{
		upd = false;

		++cnt;

		rep(i, M)
		{
			if (d[a[i]] != -INF && d[b[i]] < d[a[i]] + c[i])
			{
				d[b[i]] = d[a[i]] + c[i], upd = true;
			
				if (cnt > N)
				{
					d[b[i]] = INF;
				}
			}
		}

		if (cnt > N)
			break;
	}

	if (d[N - 1] == INF)
		puts("inf");
	else
		printf("%lld\n", d[N - 1]);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main(){
  int N;
  int H;
  cin >> N >> H;

  int a[100000];
  int b[100000];
  int num = 0;
  int a_max = 0;
  for(num = 0;num < N;num++){  
    cin >> a[num] >> b[num];
    if(a[num] > a_max){
      a_max = a[num];
    }
  }
  sort(b, b+N);

  int result = 0;
  for(num = N-1;num > -1;num--){  
    if(b[num] > a_max){
      result = result + 1;
      H = H - b[num];
    }
    if(H <= 0) break;
  }

  if(H > 0){
    if(H % a_max != 0) result = result + 1;
    result = result + (H / a_max);
  }

  cout << result << endl;
  return 0;
}

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

int main() {
	int n;
	cin >> n;
	if (n / 10 == 9 || n % 10 == 9) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;

}


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

int main() {
    int n;
    cin >> n;
    int s[n], sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        sum += s[i];
    }
    if (sum % 10 != 0) {
        cout << sum << endl;
        return 0;
    }
    sort(s, s + n);
    for (int i = 0; i < n; i++) {
        if ((sum - s[i]) % 10 != 0) {
            cout << sum - s[i] << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

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

using namespace std;

int main() {
    string S;
    cin >> S;
    int i, j;
    for (i = 0; i < 'z' - 'a' + 1; i++){
        bool flag = true;
        for (j = 0; j < S.length(); j++) {
            if (S[j] == 'a' + i) flag = false;
        }
        if (flag == true) {
            cout << (char)('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" <<endl;
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		String t=sc.next();
		int[][] kk=new int[26][s.length()+1];
		for(int i=0; i<26; i++){
			int k=s.length()+1;
			for(int j=s.length(); j>=1; j--){
				if(s.charAt(j-1)-'a'==i){
					kk[i][j]=k;
					k=j;
					continue;
				}
				kk[i][j]=k;
			}
			kk[i][0]=k;
		}
		int c=0;
		int count=0;
		for(int i=0; i<t.length(); i++){
			if(c==0 && kk[t.charAt(i)-'a'][0]==s.length()+1){
				System.out.println(-1);
				return;
			}
			c=kk[t.charAt(i)-'a'][c];
			if(c==s.length()+1){
				count++;
				c=0;
				i--;
			}
		}
		System.out.println((long)count*s.length()+c);
	}
}


Measured memory_bytes: 39176
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

constexpr ll N_MAX = 100000;

ll N;
string s;

void input() {
	cin>>N;
	cin>>s;
}

char r(char a){
	return a=='S'?'W':'S';
}

void solve() {
	vector<char> ans(N,'?');
	rep(i,2){
		rep(j,2){
			ans[0]=i==0?'S':'W';
			ans[1]=j==0?'S':'W';

			for(ll k=1;k<N-1;k++){
				char t;
				if(s[k]=='o'){
					t=ans[k]=='S'?ans[k-1]:r(ans[k-1]);
				}else{
					t=ans[k]=='S'?r(ans[k-1]):ans[k-1];
				}
				ans[k+1]=t;
			}

			if(s[0]=='o' && !(ans[0]=='S'&&ans[1]==ans[N-1] || ans[0]=='W'&&ans[1]!=ans[N-1]))continue;
			if(s[0]=='x' && !(ans[0]=='S'&&ans[1]!=ans[N-1] || ans[0]=='W'&&ans[1]==ans[N-1]))continue;
			if(s[N-1]=='o' && !(ans[N-1]=='S'&&ans[N-2]==ans[0] || ans[N-1]=='W'&&ans[N-2]!=ans[0]))continue;
			if(s[N-1]=='x' && !(ans[N-1]=='S'&&ans[N-2]!=ans[0] || ans[N-1]=='W'&&ans[N-2]==ans[0]))continue;
			rep(i,N)cout<<ans[i];
			cout<<endl;
			return;
		}
	}
	p(-1);
}

signed main() {
	input();
	solve();
	return 0;
}


Measured memory_bytes: 512
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val a = new Array[Long](n)
    for (i <- 0 until n) {
      a(i) = sc.nextLong
    }

    val ans: Long = a.map(_ - 1).sum
    println(ans)
  }
}


Measured memory_bytes: 29696
#include <iostream>
#include <vector>
#include <string.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;
char num[10010];
ll dp[10010][2][101];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>num; int len = strlen(num);
	vector<int> digit;
	for(int i=0; i<len; i++) digit.push_back(num[i]-'0');

	int D; cin>>D;
	dp[len][0][0]=dp[len][1][0] = 1ll;

	for(int idx=len-1; idx>=0; idx--)
		for(int k =0; k<2; k++)
			for(int md = 0; md<D; md++) {
				int lmt = k? digit[idx]:9;
				for(int i=0; i<=lmt; i++) {
					dp[idx][k][(md+i)%D]+=dp[idx+1][k and i==lmt][md];
					if(dp[idx][k][(md+i)%D]>=mod) dp[idx][k][(md+i)%D]-=mod;
				}
			}

	ll ans = dp[0][1][0]-1ll;
	if(ans<0ll) ans+=mod;
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 16128
import sys
n,y = list(map(int,input().split()))

for i in range(n+1):
    for j in range(n+1-i):
        if 10000*i + 5000*j + (n-i-j)*1000 == y:
            print(i,j,n-i-j)
            sys.exit()
print('-1 -1 -1')


Measured memory_bytes: 40812
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int N = s.size();
	int ans = N;
	int Scnt=0,Tcnt=0;
	int i=0;
	for(int i=0;i<N;i++){
		if(s[i]=='S')Scnt++;
		if(s[i]=='T'){
			if(Scnt){
				ans -=2;
				Scnt--;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 720
package main

import (
	"fmt"
)

func main() {
	var N, M, X, Y int
	fmt.Scan(&N, &M, &X, &Y)

	xs := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&xs[i])
	}
	ys := make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Scan(&ys[i])
	}

	is_war := true
	for Z := X + 1; Z <= Y; Z++ {
		if max(xs) < Z && min(ys) >= Z {
			is_war = false
			break
		}
	}

	if is_war {
		fmt.Println("War")
	} else {
		fmt.Println("No War")
	}

}

func max(a []int) int {
	M := -100
	for _, x := range a {
		if x > M {
			M = x
		}
	}
	return M
}

func min(a []int) int {
	m := 100
	for _, x := range a {
		if x < m {
			m = x
		}
	}
	return m
}


Measured memory_bytes: 512
#include<stdio.h>


int func( int val ,int limit )
{
	if( val > limit )
	{
		return val - limit ;
	}

	return 0 ;
}


int use ;

int kale ;

#define X kale * use


int base ,over_kale ,limit ;


#define Y base + over_kale * func( use ,limit )



int main()
{
	scanf( "%d %d %d %d %d" ,&kale ,&base ,&limit ,&over_kale ,&use ) ;

	if( X > Y )
	{
		printf( "%d\n" ,Y ) ;
	}

	else
	{
		printf( "%d\n" ,X ) ;
	}


	return 0 ;
}

Measured memory_bytes: 1764
#include<iostream>
#include<algorithm>
 
using namespace std;
 
int main(){
int A[3];
 
cin >> A[0] >> A[1] >> A[2];
 
sort(A,A+3);
 
cout << A[0]  << " "<< A[1] << " " <<A[2] << endl;
 
}

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

int N, A, B, C;
vector<int> l(8);
int min_cost = 99999999;

int natural_num(int i)
{
    if (i < 0)
    {
        return 0;
    }
    else
    {
        return i;
    }
}

void calc(vector<int> v)
{
    int a = 0, b = 0, c = 0;
    int dA = 0, dB = 0, dC = 0;
    for (int i = 0; i < v.size(); i++)
    {
        if (v[i] == 0)
        {
            a++;
            dA += l[i];
        }
        else if (v[i] == 1)
        {
            b++;
            dB += l[i];
        }
        else if (v[i] == 2)
        {
            c++;
            dC += l[i];
        }
    }
    dA = abs(dA - A);
    dB = abs(dB - B);
    dC = abs(dC - C);
    if (a != 0 & b != 0 & c != 0)
    {
        dA += natural_num(a - 1) * 10;
        dB += natural_num(b - 1) * 10;
        dC += natural_num(c - 1) * 10;
        int cost = dA + dB + dC;
        min_cost = min(min_cost, cost);
    }
}

int main()
{
    cin >> N >> A >> B >> C;
    vector<int> v(N);
    for (int i = 0; i < N; i++)
    {
        cin >> l[i];
    }
    for (int i = 0; i < 2 << (N * 2); i++)
    {
        for (int k = 0; k < N; k++)
        {
            // 4進数なので2ビットずつ右シフト
            // 右端の値を取り出すので3=11bで論理積をとる
            v[k] = i >> 2 * k & 3;
        }
        calc(v);
    }
    cout << min_cost << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, m,a,b,i,num = 0;
  cin >> n >> m;
  int h[n];
  int ab[m][2];
  bool ishashi[n];
  for (i = 0; i < n; i++){
    cin >> h[i];
    ishashi[i] = true;
  }
  for (i = 0; i < m; i++){
    cin >> a >> b;
    if (h[a-1] < h[b-1])
      swap(a,b);
    if (h[a-1] == h[b-1]){
      ishashi[a - 1] = false;
      ishashi[b - 1] = false;
    }
    ishashi[b - 1] = false;
  }
  for (i = 0; i < n; i++){
    if (ishashi[i])
      num++;
  }
  cout << num << endl;
}

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

int main() {
  int a, b;
  int taxa, taxb;
  int prise;
  bool flag = false;
  cin >> a >> b;
  
  for (int i = 0; i < 1009; i++) {
    taxa = i * 0.08;
    taxb = i * 0.1;
    if (taxa == a && taxb == b) {
      prise = i;
      flag = true;
      break;
    }
  }
  if (flag) cout << prise << endl;
  else cout << "-1" << endl;
  return 0;
}

Measured memory_bytes: 256
x1,y1,x2,y2 = map(int,input().split())

dx = x2 - x1
dy = y2 - y1
x3 = x2 - dy
y3 = y2 + dx
x4 = x1 - dy
y4 = y1 + dx


print(x3,y3,x4,y4)


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
typedef long long ll;
#define int long long
#define ff first
#define ss second
#define md 1000000007
#define md1 998244353
#define pb push_back
#define in insert
#define mkp make_pair
#define f(i,yha,wha) for(ll i=yha;i<wha;i++)
#define rf(i,wha,yha) for(ll i=wha;i>=yha;i--)
#define f0(n) for(ll i=0;i<n;i++)
#define f1(n) for(ll i=1;i<=n;i++)
#define fg(i,yha,wha,gap) for(ll i=yha;i<wha;i+=gap)
#define mpll map<ll,ll>
#define len(p) (ll)p.size()
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mem(a,t) memset(a,t,sizeof(a))
#define endl "\n"
#define ar array
#define vl vector<ll>
#define vpll vector<pair<ll,ll>>


void flash()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}

void solve()
{
 	ll n,m;
 	cin>>n>>m;
 	ll ans=0,tmp;
 	f(i,0,m)
 	{
 		cin>>tmp;
 		ans+=tmp;
	}
 	if(ans>n)
 	  cout<<"-1";
 	else
 	  cout<<n-ans;
 	  
}


int32_t main()
{
  flash();
  int t;
  t = 1;
//  cin >> t;
  while (t--)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3656
import sys
Ar1 = list(map(int, input().split()))
Ar2 = list(map(int, input().split()))
Ar3 = list(map(int, input().split()))
N = int(input())
b = []

Ac1 = [Ar1[0], Ar2[0], Ar3[0]]
Ac2 = [Ar1[1], Ar2[1], Ar3[1]]
Ac3 = [Ar1[2], Ar2[2], Ar3[2]]

naname1 = [Ar1[0], Ar2[1], Ar3[2]]
naname2 = [Ar1[2], Ar2[1], Ar3[0]]

for i in range(N) :
  b.append(int(input()))

for lines in [Ar1, Ar2, Ar3, Ac1, Ac2, Ac3, naname1, naname2] :
  if lines[0] in b and lines[1] in b and lines[2] in b :
    print("Yes")
    sys.exit()
  else :
    next
    
print("No")

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

using namespace std;

priority_queue<int>q;

int n,m,ans,pos;

struct node{
	int timp,money;
}w[100001];

inline bool cmp(node x,node y){
	return x.timp<y.timp;
}

int main(){
	cin>>n>>m;
	for(register int i=1;i<=n;i++){
		cin>>w[i].timp;
		cin>>w[i].money;	
	}
	sort(w+1,w+1+n,cmp);
/**	for(int i=1;i<=n;i++){
	    cout<<w[i].timp<<" "<<w[i].money<<endl;
	}
    */
	pos=1;
	for(register int i=1;i<=m;i++){
		while(w[pos].timp<=i)q.push(w[pos++].money);
		if(!q.empty()){
		 //   cout<<"#"<<i<<" "<<q.top()<<" ";
			ans+=q.top();
			q.pop();
		}
		//cout<<endl;
	}
	cout<<ans;
}

Measured memory_bytes: 1660
# include <bits/stdc++.h>
 
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
# define forn(i, n) for (ll i = 0; i < int(n); i++)
# define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
# define all(V) V.begin(), V.end()
# define rall(V) V.rbegin(), V.rend()
# define len(V) (int)V.size()
# define ll long long
# define ld long double
# define ff first
# define ss second
# define pb push_back
# define mp make_pair
# define endl '\n'
# define M_PI 3.14159265358979323846
 
void solve()
{
        int n; cin >> n;
        vector<ll> a(n);
        forn(i, n) cin >> a[i];
        sort(all(a));
        double temp = a[0];
        ll res = 0;
        for(int i = 1; i < n; ++i)
        {
                temp = (temp + a[i]) / 2.0;
        }
        cout << temp;
}
 
int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        solve();
}

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

//計算量をへらすために，累積和の利用，収束する値の見積もり
int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  REP(i, n) cin >> a[i];

  REP(ki,k){
    vector<int> b(n+1);
    REP(i,n){
      //ライトがテラス範囲の始点に；＋１　終点に−１　後で累積和
      int l = max(0            , i - a[i]);
      int r = min(i  + a[i] + 1, n       );
      b[l]++;
      b[r]--;
    }
    REP(i,n) b[i+1] += b[i]; //累積和
    b.pop_back();               //n+1番目の配列削除

    //収束する点, ステップ数抑えられる
    if(a == b) break;
    a = b;

  }

  REP(i, n) cout << a[i] << endl;
  return 0;


}

Measured memory_bytes: 4780
// abca29c.cpp : Typical Stairs
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)

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

	vector<bool> ok(n+1,true);
	rp(i,m){
		int a; cin>>a;
		ok[a] = false;
	}

	vector<ll> dp(n+1);
	dp[0] = 1;
	rp(now,n)
		for(int next=now+1; next<=min(n, now+2); next++)
			if(ok[next]) dp[next] = (dp[next] + dp[now]) % MOD;

	cout<< dp[n] <<endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

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

	int c[502], s[502], f[502];

	for (int i = 0; i < n - 1; i++)
	{
		cin >> c[i] >> s[i] >> f[i];
	}

	for (int j = 0; j < n - 1; j++)
	{
		int time = 0;

		for (int i = j; i < n - 1; i++)
		{
			int start = s[i];

			while (start < time)
			{
				start += f[i];
			}

			time = start;
			time += c[i];
		}

		cout << time << endl;
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int H, W;
	while(scanf("%d %d", &H, &W), (W || H))
	{
		for(int y = 0; y < H; ++y)
		{
			for(int x = 0; x < W; ++x)
			{
				if((x == 0) || (y == 0) || (x == W-1) || (y == H-1))
				{
					putchar('#');
				}
				else
				{
					putchar('.');
				}
			}
			putchar('\n');
		}
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 2044
/*    ####################  */
/*   # I_LOVE_THUY_LINH #  */
/*  ####################  */
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define ii pair<int,int>
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define matrix vector<vector<ll>>
#define fir first
#define sec second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define sz(a) int((a).size())
#define ms(s,val) memset(s,val,sizeof(s))
#define bitcount(n) __builtin_popcountll(n)
#define getbit(s,k) ((s >> k)&1)
#define turnbit(s,k) (s | (1<<k))
#define offbit(s,k) (s & ~(1<<k))
#define flipbit(s,k) (s ^ (1<<k))
#define prec(n) fixed<<setprecision(n)
#define sqr(x) (ll)(x)*(ll)(x)
#define lcm(a,b) ((ll)a/__gcd((ll)a,(ll)b)*(ll)(b))
#define gcd(a,b) __gcd(a,b)
using namespace std;
const int INF = int(1e9);

// dp[i][0..1] la xet toi vi tri so thu i thi dung phep s[i] hay 10 - s[i]
// dp[i][0] = dp[i - 1][0] + dg 
// dp[i][0] = dp[i - 1][1] + dg + 1  , vi (i - 1) muon 10 nen i phai cong them 1
// dp[i][1] = dp[i - 1][0] + 10 - dg
// dp[i][1] = dp[i - 1][1] + 10 - dg - 1, vi (i - 1) muon 10 nen i phai cong them 1

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    vector<vector<int>> dp(n,vector<int> (2));
    dp[n - 1][0] = s[n - 1] - '0';
    dp[n - 1][1] = 10 - (s[n - 1] - '0');

    for (int i = n - 2; i >= 0; i--){
        int dg = s[i] - '0';
        dp[i][0] = min(dp[i + 1][0] + dg,dp[i + 1][1] + dg + 1);
        dp[i][1] = min(dp[i + 1][0] + 10 - dg,dp[i + 1][1] + 10 - dg - 1);
    }
    cout << min(dp[0][0],dp[0][1] + 1);
    return 0;
}

Measured memory_bytes: 55964