akhauriyash/Code-Regression huggingface dataset:
# import sys
# input = sys.stdin.readline
# import re
import math
import itertools

def main():
    h, w, k = input_list()
    maze = []
    for H in range(h):
        maze.append(list(input()))

    ans = []
    a = 0
    all = 0
    for l in maze:
        a += l.count('#')
        all += l.count('#')
    ans.append(a)
    hash_list_H = []
    kumi = 0
    for H in range(h):
        if maze[H].count('#') == k:
            kumi += 1
        # hash_list_H.append(maze[H].count('#'))

    hash_list_W = []
    for W in range(w):
        a = 0
        for H in range(h):
            if maze[H][W] == '#':
                a += 1
        if a == k:
            kumi += 1
        hash_list_W.append(a)
    # kumi = hash_list_W.count(k) + hash_list_H.count(k)
    # if all == k:
    #     kumi += 1
    # for H in range(1, h+1):
    #     for c in itertools.combinations(hash_list_H, H):
    #         if all - sum(list(c)) == k:
    #             kumi += 1
    # for W in range(1, w+1):
    #     for c in itertools.combinations(hash_list_W, W):
    #         if all - sum(list(c)) == k:
    #             kumi += 1
    # print(kumi)
    ss = 0
    # for H in range(1, h+1):
    #     for W in range(1, w+1):
    #         for hc in itertools.combinations(hash_list_H, H):
    #             for wc in itertools.combinations(hash_list_W, W):
    #                 if all - (sum(hc) + sum(wc)) == k:
    #                     ss += 1
    # print(kumi+ss)
    r = 0
    done = []
    for H in range(h+1):
        for W in range(w+1):
            for hc in itertools.combinations(range(h), H):
                for wc in itertools.combinations(range(w), W):
                    if (hc, wc) in done:
                        continue
                    done.append((hc, wc))
                    if count(maze, hc, wc) == k:
                        r += 1
    print(r)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def count(mazes, hc, wc):
    hc = list(hc)
    wc = list(wc)
    r = 0
    for hi, row in enumerate(mazes):
        if hi in hc:
            continue
        for wi, m in enumerate(row):
            if wi in wc:
                continue
            if m == '#':
                r += 1
    return r

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

def input_list_str():
    return list(map(str, input().split()))

if __name__ == '__main__':
    main()



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

typedef long long LL;

int n,m;

void into(){
  scanf("%d%d",&n,&m);
}

void work(){
}

void outo(){
  printf("%d\n",m==1?0:n-m);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 3720
N = int(input())
dis_list = [list(map(int,input().split())) for _ in range(N)]
ans = 0
for x1,y1 in dis_list:
    for x2,y2 in dis_list:
        ans += ((x1-x2)**2 + (y1-y2)**2)**0.5
print(ans/N)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
  int a,b;
  char op;
  while(cin >> a >> op >> b){
    switch(op){
      case '?':break;
      case '+':cout << a+b << endl;
               continue;
      case '-':cout << a-b << endl;
               continue;
      case '*':cout << a*b << endl;
               continue;
      case '/':cout << a/b << endl;
               continue;
    }
  }
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int L = in.nextInt();

            int sum = 0;
            for (int i = 0; i < N; i++) {
                sum += L + i;
            }

            int min = (int) 1e9;
            for (int i = 0; i < N; i++) {
                if (Math.abs(L + i) < Math.abs(min)) {
                    min = L + i;
                }
            }

            System.out.println(sum - min);
        }
    }
}


Measured memory_bytes: 27104
#include<bits/stdc++.h>
using namespace std;
#define    For(i,n) for(int i=0;i<n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    nl     "\n"
#define    test   int t;cin>>t;for(int l=0;l<t;l++)
#define    End    return 0
#define    gt     greater<int>()
#define    ll     long long int

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

    int c=0,mx=0;
    test
    {
        int a,b;
        cin>>a>>b;
        if(a==b)c++;
        else c=0;
        mx=max(mx,c);
    }
    if(mx>=3)cout<<"Yes";
    else cout<<"No";
    
}


Measured memory_bytes: 3648
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

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

    deque<ll> V;
    REP(i, N) {
        ll tmp;
        cin >> tmp;
        V.push_back(tmp);
    }

    ll ans = 0;
    for(int a=0; a<=min(N, K); a++) {
        for(int b=0; b<=min(N, K)-a; b++) {
            multiset<ll> bucket;
            REP(i, a) bucket.insert(V[i]);
            REP(i, b) bucket.insert(V[N-i-1]);
            ll value = 0;
            int stolen = 0;
            for(ll x: bucket) {
                if(x < 0 && stolen < K-a-b) {
                    stolen++;
                } else {
                    value += x;
                }
            }

            if(value > ans) ans = value;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
// typedef pair<int, int> P;
// typedef pair<int, P> PP;
// typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int MAX = 3e3;

typedef pair<string, string> P;
string str;
map<P, int> mp;
signed main(){
  int n;
  cin >> n >> str;
  rep(s,1<<n){
    string s1 = "", s2 = "";
    rep(j,n){
      if(s & (1<<j))s1.pb(str[n+j]);
      else s2.pb(str[n+j]);
    }
    reverse(all(s1));
    reverse(all(s2));
    mp[P(s2, s1)]++;
  }
  int ans = 0;
  rep(s,1<<n){
    string s1 = "", s2 = "";
    rep(j,n){
      if(s & (1<<j))s1.pb(str[j]);
      else s2.pb(str[j]);
    }
    ans += mp[P(s1, s2)];
  }
  printf("%lld\n", ans);
  return 0;
}

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

namespace ALDS1_8B{
    public class Program{
        public static void Main(string[] args){
            var N = int.Parse(Console.ReadLine());
            var tree = new Tree();
 
            for(var i = 0; i < N; i++){
                var rl = Console.ReadLine().Split(' ');
                if(rl[0] == "insert"){
                    var id = int.Parse(rl[1]);
                    tree.Add(id);
                }
                if(rl[0] == "find"){
                    var id = int.Parse(rl[1]);
                    Console.WriteLine(tree.Find(id) ? "yes" : "no");
                }
                if(rl[0] == "print"){
                    Console.WriteLine(" " + string.Join(" ", tree.Order(TreeWalk.InOrder).Select(n => n.Id.ToString()).ToArray()));
                    Console.WriteLine(" " + string.Join(" ", tree.Order(TreeWalk.PreOrder).Select(n => n.Id.ToString()).ToArray()));
                }
            }
        }
    }
 
    public enum TreeWalk{
        PreOrder,
        InOrder,
        PostOrder
    }
 
    public class Tree{
        public Dictionary<int, Node> Nodes = new Dictionary<int, Node>();
        public Node Root;
 
        public void Add(int id){
            Nodes.Add(id, new Node(id));
 
            if(Root == null){
                Root = Nodes[id];
                return;
            }
 
            var curNode = Root;
            while(true){
                if(curNode.Id > id){
                    if(curNode.Left == null){
                        curNode.Left = Nodes[id];
                        Nodes[id].Parent = curNode.Left;
                        break;
                    }
                    curNode = curNode.Left;
                }
 
                if(curNode.Id < id){
                    if(curNode.Right == null){
                        curNode.Right = Nodes[id];
                        Nodes[id].Parent = curNode.Right;
                        break;
                    }
                    curNode = curNode.Right;
                }
            }
 
        }

        public bool Find(int id){
            return Nodes.ContainsKey(id);
        }

        public List<Node> Order(TreeWalk tw){
            var res = new List<Node>();
 
            Action<Node> parse = null;
            parse = node =>{
                if(node == null) return;
 
                if(tw == TreeWalk.PreOrder) res.Add(node);
                parse(node.Left);
                if(tw == TreeWalk.InOrder) res.Add(node);
                parse(node.Right);
                if(tw == TreeWalk.PostOrder) res.Add(node);
            };
            parse(Nodes.Single(n => n.Value.Parent == null).Value);
 
            return res;
        }
    }
 
    public class Node{
        public int Id;
        public Node Parent;
        public Node Left;
        public Node Right;
 
        public Node(int id){
            Id = id;
        }
    }
}

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

const int INF=1e6;

const int maxn=60010;
const int maxm=200010;

int n,m,SS,TT,tot,tote=1,Ans,row[110],line[110];
int FIR[maxn],NEXT[maxm],CAP[maxm],TO[maxm];

void addedge(int u,int v,int w)
{
//	printf("%d ----%d--->%d\n",u,w,v);
	TO[++tote]=v;
	NEXT[tote]=FIR[u];
	CAP[tote]=w;
	FIR[u]=tote;

	TO[++tote]=u;
	NEXT[tote]=FIR[v];
	CAP[tote]=0;
	FIR[v]=tote;
}

int q[maxn],dis[maxn],_FIR[maxn];

bool build()
{
	memset(dis,0,sizeof(dis));
	int H=0,T=1;
	q[1]=SS; dis[SS]=1;
	while (H-T)
	{
		int u=q[++H];
		for (int p=FIR[u];p;p=NEXT[p]) if (CAP[p])
		{
			int v=TO[p];
			if (!dis[v])
			{
				dis[v]=dis[u]+1;
				q[++T]=v;
			}
		}
	}
	return dis[TT];
}

int dfs(int u,int lim)
{
	if (u==TT||!lim) return lim;
	int res=lim,use=0;
	for (int &p=_FIR[u];p;p=NEXT[p])
	{
		int v=TO[p],w=CAP[p];
		if (dis[u]+1!=dis[v]) continue;
		int flow=dfs(v,min(res,w));
		res-=flow;
		use+=flow;
		CAP[p]-=flow;
		CAP[p^1]+=flow;
		if (!res) break;
	}
	return use;
}

int main()
{
#ifdef h10
	freopen("F.in","r",stdin);
	freopen("F.out","w",stdout);
#endif
	int i,j;
	scanf("%d%d",&n,&m);

	for (i=1;i<=n;i++) row[i]=++tot;
	for (i=1;i<=m;i++) line[i]=++tot;

	for (i=1;i<=n;i++)
	for (j=1;j<=m;j++)
	{
		char c=getchar();
		while (c!='.'&&c!='o'&&c!='S'&&c!='T') c=getchar();
		if (c=='o')
		{
			int x=++tot,y=++tot;
			addedge(x,y,1);
			addedge(row[i],x,INF);
			addedge(line[j],x,INF);
			addedge(y,row[i],INF);
			addedge(y,line[j],INF);
		}
		if (c=='S')
		{
			SS=++tot;
			addedge(SS,row[i],INF);
			addedge(SS,line[j],INF);
		}
		if (c=='T')
		{
			TT=++tot;
			addedge(row[i],TT,INF);
			addedge(line[j],TT,INF);
		}
	}

	while (build())
	{
		memcpy(_FIR,FIR,sizeof(FIR));
		Ans+=dfs(SS,INF);
	}
	if (Ans<=10000)
		printf("%d\n",Ans);
	else
		puts("-1");
}


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

int main() {
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
  string S,T;
  cin>>S>>T;
  int a=S.size();
  int b=T.size();
  int c=0;
  int d=0;
  rep(i,a-b+1){
    rep(j,b){
      if(S[i+j]==T[j])
        c++;
    }
    d=max(c,d);
    c=0;
  }
  cout<<b-d;
}

Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = ReadString();
            var result = true;
            for (int i = 0; i < s.Length; i++)
            {
                if ((i + 1) % 2 == 0)
                {
                    if (!new char[] { 'L', 'U', 'D' }.Contains(s[i]))
                    {
                        result = false;
                        break;
                    }
                }
                else
                {
                    if (!new char[] { 'R', 'U', 'D' }.Contains(s[i]))
                    {
                        result = false;
                        break;
                    }
                }
            }
            if (result)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        public static string ReadString()
        {
            return Console.ReadLine();
        }

        public string[] ReadStringArray()
        {
            return ReadString().Split(' ');
        }

        public int[] ReadIntArray()
        {
            return ReadStringArray().Select(x => int.Parse(x)).ToArray();
            
        }

        public static int ReadInt()
        {
            return int.Parse(ReadString());
        }
    }
}


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

using namespace std;

typedef long long ll;

int main(){
	ll  n;
	cin >> n;
	ll a[n];
	ll i;
	ll f4, even, odd;
	f4 = even = odd = 0;
	for(i = 0 ;  i < n ; i ++){
		cin >> a[i];
		if(a[i] % 4 == 0){
			f4++;
		}else if(a[i] & 1){
			odd++;
		}else{
			even++;
		}
	}
	if(even){
		if(odd <= f4){
			cout << "Yes\n";
		}else{
			cout << "No\n";
		}
	}else
		if(odd <= f4 + 1){
			cout << "Yes\n";
		}else{
			cout << "No\n";
		}

}

Measured memory_bytes: 1024
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;
int main()
{
	int num;
	int play[201][4], ans[201];
	int used[101][4] = { { 0 } };

	fill(ans, ans+200, 0);

	cin >> num;

	for(int i = 0; i < num; i++)
	{
		for(int j = 0; j < 3; j++)
		{
			cin >> play[i][j];
			used[ play[i][j] ][j]++;
		}
	}

	for(int i = 0; i < num; i++)
	{
		for(int j = 0; j < 3; j++)
		{
			if(used[ play[i][j] ][j] < 2)
			{
				ans[i] += play[i][j];
			}
		}
	}

	for(int i = 0; i < num; i++)
	{
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define vll vector<ll>
using namespace std;
 
 
int main(){
    ios_base::sync_with_stdio(true);
    cin.tie(NULL);
    
    ll n, ans = 1, a;
    cin >> n;
    vll x;
    for(ll i=0; i<n; i++){
        cin >> a;
        x.push_back(a);
    }
    ll mini = x[0];
    for(ll i=1; i<n; i++){
        mini = min(x[i-1], mini);
        //cout << mini << " " << x[i] << endl;
        if(mini > x[i]){
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define mxn 100005
using namespace std;

int main()
{
    FLASH
    ll n,k;
    cin >> n >> k;
    ll x = k / 4;
    ll x2 = k % 4;
    if(x2 == 2 || x2 == 0);
    else
    {
        cout << "No";
        return 0;
    }
    x2 /= 2;
    x = x + x2;

    x2 = k / 2;
    if(x <= n && n <= x2)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 3612
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    g[l - 1].append((r - 1, d))
    g[r - 1].append((l - 1, -d))
l = [None] * n
for i in range(n):
    if l[i] != None:
        continue
    l[i] = 0
    stack = [i]
    while stack:
        d = stack.pop()
        for node, cost in g[d]:
            if l[node] == None:
                l[node] = l[d] + cost
                stack.append(node)
            else:
                if l[node] != l[d] + cost:
                    print('No')
                    exit(0)
print('Yes')


Measured memory_bytes: 83360
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

int main()
{
    ll n;
    cin >> n;
    vll s(n);
    rep(i, n) cin >> s[i];
    ll ans = 0;
    repf(c,1,1+n/2){
        ll res = 0;
        repf(k,1,n){
            if (n-1-k*c<=c)
                break;
            if ((n-1)%c==0 && k*c>=n-1-k*c)
                break;
            res += s[k * c] + s[n - 1 - k * c];
            ans = max(ans, res);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <map>


using namespace std;


int main()
{
  long a , b;
  cin >> a ;//１万から99999
  char s;

  bool isthree = true;
  for (int i = 0; i < a; i++) {
    cin >> s;
    if (s == 'Y')isthree = false;
  }


  cout << (isthree ? "Three" : "Four") << endl;


  return 0;
}

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

string s;
ll sum;

int main()
{
	cin >> s;
	int n = 1 << (s.size() - 1);
	for(int i = 0; i < n; i++){
        ll a = 0;
        for(int j = 0; j < s.size(); j++){
            if((i >> j) & 1 || j == s.size() - 1){
                a += (s[j] - '0');
                sum += a;
                //printf("a %lld %lld\n", a, sum);
                a = 0;
            }
            else{
                a += (s[j] - '0');
                a *= 10;
            }
            //printf("b %lld %lld\n", a, sum);
        }
	}
    cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map> 
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int maxn=2e5+6;
const int mod=1e9+7;
const double pi=acos(-1.0);
int n,m; 
string s;
int read(){        
    int s = 0, f = 1;        
    char ch = getchar();        
    while(!isdigit(ch)) {        
        if(ch == '-') f = -1;        
        ch = getchar();        
    }        
    while(isdigit(ch)) {        
        s = s * 10 + ch - '0';        
        ch = getchar();        
    }        
    return s * f;        
}        
void write(int x){        
    if(x < 0) {        
        putchar('-');        
        x = -x;        
    }        
    if(x > 9)        
        write(x/10);        
    putchar(x % 10 + '0');        
    return;        
}   
signed main(){
	cin>>s;
	int len=s.length();
	for(int i=0;i<len;i++){
		if(s[i]=='?'){
			if(i>0&&s[i-1]=='P')
				s[i]='D';
			else if(i<len-1){
				if(s[i+1]=='D'||s[i+1]=='?')
				   s[i]='P',s[i+1]='D';
				else s[i]='D';
			} 
			else s[i]='D';
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll a,b,c;
int main() {
	cin>>a>>b>>c;
	ll t=min(a,c);
	a-=t; c-=t;
	t=min(b,c);
	b-=t; c-=t;
	cout<<a<<" "<<b;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, arr[401];
long long dp[401][401];

long long sums(int a, int b){
	long long ans=0;
	for(int i=a;i<=b;i++){
		ans+=arr[i];
	}
	return ans;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> arr[i];
	}
	for(int l=2;l<=n;l++){
		for(int i=1;i<=n-l+1;i++){
			int j=i+l-1;
			if(i==j){
				dp[i][j]=0;
			}
			else{
				dp[i][j]=LLONG_MAX;
				for(int k=i;k<j;k++){
					dp[i][j]=min(dp[i][j], dp[i][k]+dp[k+1][j]+sums(i, k)+sums(k+1, j));
				}
			}
		}
	}
	cout << dp[1][n] << '\n';
}

Measured memory_bytes: 1536
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;
use std::cmp::Ordering;

fn comp_f64(a: &f64, b: &f64) -> Ordering {
    if a < b {
        return Ordering::Less;
    } else if a > b {
        return Ordering::Greater;
    }
    Ordering::Equal
}

fn main() {

    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let N = buf_it.next().unwrap().parse::<usize>().unwrap();
    let M = buf_it.next().unwrap().parse::<usize>().unwrap();
    let S = buf_it.next().unwrap().parse::<usize>().unwrap();
    let UVAB = (0..M).map(|_|
        (buf_it.next().unwrap().parse::<usize>().unwrap()-1,
        buf_it.next().unwrap().parse::<usize>().unwrap()-1,
        buf_it.next().unwrap().parse::<usize>().unwrap(),
        buf_it.next().unwrap().parse::<isize>().unwrap())
    ).collect::<Vec<_>>();

    let CD = (0..N).map(|_|
        (buf_it.next().unwrap().parse::<usize>().unwrap(),
        buf_it.next().unwrap().parse::<isize>().unwrap())
    ).collect::<Vec<_>>();

    let mut E = (0..N).map(|_| Vec::new()).collect::<Vec<_>>();
    for &(u,v,a,b) in &UVAB{
        E[u].push((v,a,b));
        E[v].push((u,a,b));
    }

    let mut d = (0..N).map(|_| (0..(M*50+1)).map(|_| -1).collect::<Vec<_>>()).collect::<Vec<_>>();
    let mut q = BinaryHeap::new();
    q.push((0,S,0));
    while q.len()>0{
        let (c,s,i) = q.pop().unwrap();
        let si = min(s,M*50);
        if d[i][si] != -1{ continue;}
        d[i][si] = -c;
        let (C,D) = CD[i];
        q.push((c-D,s+C,i));
        for &(j,a,b) in &E[i]{
            if s<a { continue;}
            q.push((c-b,s-a,j));
        }
    }
    for i in 1..N{
        let mut ans = 1e18 as isize;
        for &e in &d[i]{
            if e == -1 { continue;}
            ans = min(ans,e);
        }
        println!("{}",ans);
    }

}


Measured memory_bytes: 15956
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i <= int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    ll n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];

    ll ans = 0;
    ll right = 0;
    ll sum = 0;
    rep(left,n){
        while( right < n && (sum ^ a[right]) == (sum + a[right]) ){
            sum ^= a[right];
            right++;
        }
        ans += right - left;
        sum ^= a[left];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4836
// #define _DEBUG 1

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

void solve(ll N, std::vector<ll> s) {
  ll sum = 0;
  sort(all(s));

  for (ll l : s)
    sum += l;

  if (sum % 10 != 0) {
    cout << sum << endl;
    return;
  } else {
    bool found = false;
    for (ll l : s) {
      if (l % 10 != 0) {
        cout << sum - l << endl;
        return;
      }
    }
    cout << 0 << endl;
    return;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  ll N;
  scanf("%lld", &N);
  std::vector<ll> s(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &s[i]);
  }
  solve(N, std::move(s));
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<numeric>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

bool prime(ll x) {
	bool pr = true;
	if (x > 2 && x % 2 == 0) pr = false;
	if (x % 2 != 0) {
		for(int i=3;i<=sqrt(x);i+=2) {
			if (x%i == 0) {
				pr = false;
				break;
			}
		}
	}
	return pr;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<ll> a(n);
	REP(i, n) cin >> a[i];
	int res = 0;
	REP(i, n)if (prime(a[i])) res++;
	cout << res << "\n";

	return 0;
}


Measured memory_bytes: 3192
#!/usr/bin/env python3
s = input()
a = [int(c) for c in s]

for i in range(2 ** 3):
    ptn = []
    num = a[0]

    for j in range(3):
        if (i >> j) & 1:
            ptn.append("+")
            num += a[j + 1]

        else:
            ptn.append("-")
            num -= a[j + 1]
    
    if num == 7:
        print("{}{}{}{}{}{}{}=7".format(a[0], ptn[0], a[1], ptn[1], a[2], ptn[2], a[3]))
        break


Measured memory_bytes: 9040
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 40000


struct Info{
	ll HP,attack,guard,speed;
};

struct Data{
	Data(int arg_enemy_index,ll arg_rest_count,double arg_average_damage){
		enemy_index = arg_enemy_index;
		rest_count = arg_rest_count;
		average_damage = arg_average_damage;
	}
	bool operator<(const struct Data &arg) const{
 		return average_damage < arg.average_damage;
	}
	int enemy_index;
	ll rest_count;
	double average_damage;
};

int N;
Info Hero,monster[NUM];
ll start_HP,to_hero_damage[NUM];

int main(){

	scanf("%d",&N);

	scanf("%lld %lld %lld %lld",&Hero.HP,&Hero.attack,&Hero.guard,&Hero.speed);
	start_HP = Hero.HP;

	ll give_damage,promised_count;

	priority_queue<Data> Q;

	for(int i = 0; i < N; i++){
		scanf("%lld %lld %lld %lld",&monster[i].HP,&monster[i].attack,&monster[i].guard,&monster[i].speed);
		if(monster[i].attack <= Hero.guard){
			continue;
		}

		to_hero_damage[i] = monster[i].attack-Hero.guard;
		give_damage = Hero.attack-monster[i].guard;

		if(monster[i].guard >= Hero.attack){
			printf("-1\n");
			return 0;
		}

		if(monster[i].HP%give_damage == 0){
			promised_count = monster[i].HP/give_damage;
		}else{
			promised_count = monster[i].HP/give_damage+1;
		}
		Q.push(Data(i,promised_count,(double)to_hero_damage[i]/(double)promised_count));
	}

	ll turn = 0;

	while(!Q.empty()){

		turn += Q.top().rest_count;

		if(Hero.speed < monster[Q.top().enemy_index].speed){
			Hero.HP -= turn*to_hero_damage[Q.top().enemy_index];
		}else{
			Hero.HP -= (turn-1)*to_hero_damage[Q.top().enemy_index];
		}

		if(Hero.HP <= 0)break;

		Q.pop();
	}

	if(Hero.HP <= 0){
		printf("-1\n");
	}else{
		printf("%lld\n",start_HP-Hero.HP);
	}

	return 0;
}



Measured memory_bytes: 5580
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

def edges_to_pt(s,t,n,directed=False):
    pt = [[] for _ in range(n)]
    for i in range(len(s)):
        pt[s[i]-1].append(t[i]-1)
        if directed == False:
            pt[t[i]-1].append(s[i]-1)
    return pt

def bfs(pt,s):
    n = len(pt)
    d = [-1]*n
    d[s] = 0
    q = [s]
    c = 1
    while q:
        q1 = []
        for v in q:
            for u in pt[v]:
                if d[u] == -1:
                    d[u] = c
                    q1.append(u)
        q = q1
        c += 1
    return d

N = I()
a,b = LIR(N-1,2)

if N%3 == 0:
    one_num,two_num,zero_num = N//3,N//3,N//3
elif N%3 == 1:
    one_num,two_num,zero_num = N//3+1,N//3,N//3
else:
    one_num,two_num,zero_num = N//3+1,N//3+1,N//3

pt = edges_to_pt(a,b,N)
d = bfs(pt,0)

# 根からの距離の偶奇で群分け
odd = []
even = []
for i in range(N):
    if d[i]%2 == 0:
        even.append(i)
    else:
        odd.append(i)

max_ = max(len(even),len(odd))
min_ = min(len(even),len(odd))
if max_ == len(even):
    max_index = even
    min_index = odd
else:
    max_index = odd
    min_index = even

ans = [0]*N

# 各群の個数が十分多ければ，1と2を各群に振り分ける
if max_ >= one_num and min_ >= two_num:
    for i in range(one_num):
        ans[max_index[i]] = 1
    for i in range(two_num):
        ans[min_index[i]] = 2
# 片側の群の個数が少なければ，そちらに0を固める
else:
    for i in range(one_num):
        ans[max_index[i]] = 1
    for i in range(one_num,one_num+two_num):
        ans[max_index[i]] = 2

one_p = 0
two_p = 0
zero_p = 1
for i in range(N):
    if ans[i] == 1:
        ans[i] = 3*one_p+1
        one_p += 1
    elif ans[i] == 2:
        ans[i] = 3*two_p+2
        two_p += 1
    else:
        ans[i] = 3*zero_p
        zero_p += 1

print(*ans)

Measured memory_bytes: 120712
#include<iostream>
#include<cstdlib>
#include<stack>
using namespace std;

int main(){
  stack<int> S;
  int a, b;
  string s;

  while(cin >> s){
    if(s[0] == '+'){
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a+b);
    }else if(s[0] == '-'){
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(b-a);
    }else if(s[0] == '*'){
      a = S.top(); S.pop();
      b = S.top(); S.pop();
      S.push(a*b);
    }else {
      S.push(atoi(s.c_str()));
    }
  }

  cout << S.top() << endl;

  return 0;
}

Measured memory_bytes: 3220
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];

        for(int i = 0; i<n; i++) a[i] = sc.nextInt();
        for(int i = 0; i<n; i++) b[i] = sc.nextInt();
        long gcount = 0;
        for(int i = 0; i<n; i++) {
            if(a[i]>b[i]) gcount+= a[i]-b[i];
            else {
                gcount -= (b[i]-a[i])/2;
            }
        }
        if(gcount<=0) {
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 42832
#include <iostream>
#define rep(i,a) for (int i = 0; i < (a); i++)
using namespace std;

int n, m, l, s, e;
int L[100], T[100], dp[1 << 17];

int main(void){
    while (cin >> n, n) {
        rep(i, 1 << 17) dp[i] = 0;
        rep(i, n) {
            cin >> m >> l;
            L[i] = l;
            int t = 0;
            rep(j, m) {
                cin >> s >> e;
                t |= (1 << (e-6)) - (1 << (s-6));
            }
            T[i] = t;
        }
        
        rep(i,n) {
            rep(bit,1 << 17) {
                if ((bit & T[i]) == 0 && dp[bit]) dp[bit | T[i]] = max(dp[bit | T[i]], dp[bit] + L[i]);
                dp[T[i]] = max(dp[T[i]], L[i]);
            }
        }
        int ans = 0;
        rep(i, 1 << 17) ans = max(ans, dp[i]);
        cout << ans << endl;
    }
    return 0;
}

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

int main(void) {
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  double mangle = 6 * M;
  double hangle = 30 * H + M / 2.0;
  double angleDiff = min(360 - abs(mangle - hangle), abs(mangle - hangle));
  double rad = angleDiff / 360.0 * 2 * M_PI;
  double ans = sqrt(A * A + B * B - 2 * A * B * cos(rad));
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int gcd(int x, int y) {
    int tmp = x % y;
    while (tmp != 0) {
        x = y;
        y = tmp;
        tmp = x % y;
    }
    return y;
}

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    vector<int> vec(n);
    rep(i, n) {
        int flag = 1;
        int x;
        cin >> x;
        for (int j = 2; j <= sqrt(x); ++j) {
            if (x % j == 0) flag = 0;
        }
        if (flag) cnt += 1;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
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<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
const int DX[8]={-1,0,1,0,-1,-1,1,1},DY[8]={0,-1,0,1,-1,1,-1,1};

const int NPrime=3000000;
bool prime[NPrime+1];
vi EnumeratePrime(){
	fill(prime+2,prime+NPrime+1,true);
	vi a;
	for(int i=2;i<=NPrime;i++) if(prime[i]){
		a.emplace_back(i);
		for(int j=2*i;j<=NPrime;j+=i) prime[j]=0;
	}
	return a;
}

int h,w;
vvi a;

void dfs(int i,int j){
	a[i][j]=0;
	for(int k=0;k<8;k++){
		int x=i+DX[k],y=j+DY[k];
		if(x>=0&&x<h&&y>=0&&y<w&&a[x][y]) dfs(x,y);
	}
}

int main(){
	while(1){
		cin>>w>>h;
		if(h==0) break;
		a=vvi(h,vi(w));
		for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin>>a[i][j];
		int res=0;
		for(int i=0;i<h;i++) for(int j=0;j<w;j++) if(a[i][j]){
			dfs(i,j);
			res++;
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 3148
n = int(input())
nums = list(map(int, input().split(" ")))

nums = [n for n in nums if n%2==0]
f = True

for i in nums:
  if i%3!=0:
    if i%5!=0:
      print("DENIED")
      f = False
      break
if f:
  print("APPROVED")

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

struct node{
  int key;
  node *parent,*left,*right;
};
node *root,*nil;

void insert(int k){
  node *p;
  p = (node *)malloc(sizeof(node));
  p->key = k;
  p->left = nil;
  p->right = nil;

  node *v = root,*u = nil;
  //if(v == nil) return;
  while(v != nil){
    u = v;
    if(p->key < v->key) v = v->left;
    else v = v->right;
  }
  p->parent = u;
  if(u == nil) root = p;
  else {
    if(p->key < u->key) u->left = p;
    else u->right = p;
  }
}

void preorder(node *u){
  if(u == nil) return;
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}

void inorder(node *u){
  if(u == nil) return;
  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);
}

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

  int m; cin >> m;
  for(int i = 0; i < m; i++){
    string s; cin >> s;
    if(s[0] == 'p'){
      inorder(root);
      cout << '\n';
      preorder(root);
      cout << '\n';
      continue;
    }
    int k; cin >> k;
    insert(k);
  }

  return 0;
}



Measured memory_bytes: 26624
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
#define MOD (ll)(1e9+7)
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

bool is_prime(ll n){
    if(n <= 1) return false;

    rep(i,2,sqrt(n)+1){
        if(n % i == 0) return false;
    }

    return true;
}


signed main(){
    ll n;
    cin >> n;
    map<ll,ll> m;
    vector<ll> prime_list;

    rep(i,2,n+1){
        ll temp = i;
        while(temp > 1){
            rep(j,2,sqrt(temp)+1){
                if(temp % j == 0){
                    if(m.count(j) == 0){
                        m[j] = 1;
                        prime_list.push_back(j);
                    }
                    else{
                        m[j]++;
                    }
                    temp /= j;
                    break;
                }
            }

            if(is_prime(temp)){
                if(m.count(temp) == 0){
                    m[temp] = 1;
                    prime_list.push_back(temp);
                }
                else{
                    m[temp]++;
                }
                break;
            }
        }
    }

    ll ans = 1;
    rep(i,0,prime_list.size()){
        ans *= m[prime_list[i]]+1;
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

vector<string> v;
ll n;
void dfs(string s, ll num){
  if(s.size()==n){
    v.push_back(s);
    return ;
  }

  rep(i,num+1){
    dfs(s+(char)('a'+i),num+(i==num ? 1 : 0));
  }
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  dfs("a",1);
  sort(all(v));
  rep(i,v.size()){
    cout << v[i] << '\n';
  }

}

Measured memory_bytes: 7796
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n, k; cin >> n >> k;
  vector<pair<int, int>> v(n);
  long long sum = 0;
  int index;
  for(int i = 0; i < n; ++i){
    cin >> v[i].first >> v[i].second;
  }
  sort(v.begin(), v.end());
  for(int i = 0; i < n; ++i){
    sum += v[i].second;
    if(sum >= k){
      index = i;
      break;
    }
  }
  cout << v[index].first << endl; 
}

Measured memory_bytes: 1024
#include <cstdlib>
#include <iterator>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <functional>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if(a % 3 == 0 | b % 3 == 0 | (a + b) % 3 == 0) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
  }


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

using namespace std;

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

    string s;
    string t;
    cin >> s >> t;
    size_t f;
    if(t.size() - s.size() == 1){
        f = t.find(s);
    }
    if(f == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 3612
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(len(p)-1):
    if i == 0:
        continue
    if (p[i] > p[i-1] and p[i] < p[i+1]) or (p[i] < p[i-1] and p[i] > p[i+1]):
        count += 1
print(count)


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
ll d[100005];
int main() {
  int N;
  cin >> N;
  ll a, b;
  ll ret = 0;
  for (int i=0; i<N; i++) {
    cin >> a >> b;
    ret -= b;
    d[i] = a + b;
  }
  sort(d, d+N, greater<ll>());
  for (int i=0; i<N; i+=2) {
    ret += d[i];
  }
  cout << ret << endl;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    X,Y,Z=map(int,input().split())
    print((X-Z)//(Y+Z))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>

using namespace std;
using ll = long long int; 

void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;

    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}


ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

ll keta(ll a){
  ll ans = 1;
  while(1){
    if(a/10 > 0){
      ans++;
      a = a/10;
    }
    if(a<10) break;
  }
  return ans;
}

const int MAX = 50;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){

  int n, m;
  cin>>n>>m;
  if(m==n){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
    
    return 0;
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int x = 0;
    int res = 0;
    REP(i, N) {
        if(S[i] == 'I') {
            x++;
        }
        if(S[i] == 'D') {
            x--;
        }
        res = max(res, x);
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int x, y, W, H, r;
    cin >> W >> H >> x>> y >>r;
	//No????????¶
	if(x+r > W || x-r < 0 || y+r > H || y-r < 0){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
s = input()
K = int(input())

ct = 0
alp = 'abcdefghijklmnopqrstuvwxyz'
for i in alp:
    ct += s.count(i)
    if ct >= K:
        break

key = i

list_rank = []
for i in range(len(s)):
    if s[i] > key:
        continue
    if i < len(s) - K + 1:
        for j in range(K):
            if s[i:i+j+1] not in list_rank:
                list_rank.append(s[i:i+j+1])
    else:
        for j in range(len(s)-i):
            if s[i:i+j+1] not in list_rank:
                list_rank.append(s[i:i+j+1])

list_rank.sort()
print(list_rank[K-1])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
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; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    LL A,B,K;cin >> A >> B >> K;
    LL ta = A;
    LL ao = B;

    rep(i,K){
        if(i % 2 == 0){
            ta /= 2;
            ao += ta;
        }
        else{
            ao /= 2;
            ta += ao;
        }
    }

    cout << ta << " " << ao << endl;
}


Measured memory_bytes: 256
n = gets.to_i
r1 = gets.strip.split.map(&:to_i)
r2 = gets.strip.split.map(&:to_i)
i = 0
h = 0
while i < n do
  d = r1.slice(0..i).sum + r2.slice(i..n-1).sum
  if d > h
    h = d
  end
  i += 1
end
puts h

Measured memory_bytes: 14332
fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    var s = readLine()!!.toString()
    var c = mutableMapOf<Char, Int>('R' to 0, 'G' to 0, 'B' to 0)
    var num: Int
    for (i in s) {
        num = c[i]!!
        c[i] = num + 1
    }
    var diff = 0
    var ans = 1L
    for (d in 1..((n-1)/2)){
        for (i in 0..(n-d-d-1)) {
            if (s[i] != s[i+d] && s[i+d] != s[i+d+d] && s[i+d+d] != s[i]) {
                diff += 1
            }
        }
    }
    for ((x, y) in c){ans *= y}
    println(ans-diff)
}


Measured memory_bytes: 36780