akhauriyash/Code-Regression huggingface dataset:
//main関数

#include <bits/stdc++.h>
using namespace std;
 
void solve(int a,int b,int c,int d,int &p,int &q,int &r){
    for(p=0;p<2;p++){
        for(q=0;q<2;q++){
            for(r=0;r<2;r++){
                int B,C,D;
                if(p) B=-b;
                else B=b;
                if(q) C=-c;
                else C=c;
                if(r) D=-d;
                else D=d;
                if(a+B+C+D==7) return;
            }
        }
    }
}
int main() {
    int x;
	int a,b,c,d;
    cin>>x;
    d=x%10;
    x/=10;
    c=x%10;
    x/=10;
    b=x%10;
    x/=10;
    a=x;
    int p=0,q=0,r=0;
    solve(a,b,c,d,p,q,r);
    cout<<a;
    if(p) cout<<"-";
    else cout<<"+";
    cout<<b;
    if(q) cout<<"-";
    else cout<<"+";
    cout<<c;
    if(r) cout<<"-";
    else cout<<"+";
    cout<<d<<"=7"<<endl;
}

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

long long mo=1000000000+7;
long long dp[2][100001];

int main(){
  int N;
  int K;
  std::cin>>N>>K;
  int a[100];
  for(int i=0;i<N;++i){
    std::cin>>a[i];
  }
  for(int t=0;t<2;++t){
    for(int i=0;i<=100000;++i){
      dp[t][i]=0;
    }
  }
  dp[0][0]=1;
  for(int i=0;i<N;++i){
    long long sum=0;
    for(int j=0;j<=K;++j){
      sum=(sum+dp[i%2][j])%mo;
      if(j-a[i]-1>=0)
	sum=(sum-dp[i%2][j-a[i]-1]+mo)%mo;
      dp[(i+1)%2][j]=(dp[(i+1)%2][j]+sum)%mo;
    }
    for(int j=0;j<=K;++j){
      dp[i%2][j]=0;
    }
  }
  
  printf("%ld\n",dp[N%2][K]);
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y<a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[100111];
int l[100101];
int j[1];

long long x,y,z,mod=1000000007;
//string r;
char r[1];

P u[1];
queue<int> q;
stack<int> s;

vector<int> v[100101];

bool as(P a,P b)
{
  return a.x>b.x;
}
void f(int n,int m)
{
  vector<int> s;
  for(int h=0;h<v[n].size();h++)
  if(v[n][h]!=m)
  {
    f(v[n][h],n);
    s.push_back(l[v[n][h]]+1);
  }
  if((s.size()%2==0&&m>0)||(s.size()%2&&m==0)) s.push_back(0);
  sort(s.begin(),s.end());
  
  if(m==0)
  {
    int c=0,d=s.size()-1;
    o[n]=0;
    for(;c<d;c++,d--)
    o[n]=max(o[n],s[c]+s[d]);
    return;
  }
  int a=0,b=s.size()-1;
  for(;a<b;)
  {
    int h=(a+b)/2;
    int x=0,c=0,d=s.size()-1;
    for(;c<d;)
    if(c==h) c++;
    else if(d==h) d--;
    else
    {
      x=max(x,s[c]+s[d]);
      c++,d--;
    }
    if(x<=k) b=h;
    else a=h+1;
  }
  l[n]=s[a];
  int x=0,c=0,d=s.size()-1;
  for(;c<d;)
  if(c==a) c++;
  else if(d==a) d--;
  else
  {
    x=max(x,s[c]+s[d]);
    c++,d--;
  }
  o[n]=x;
}

int main()
{
  scanf("%d",&a);
  for(int t=1;t<a;t++)
  {
    scanf("%d %d",&n,&m);
    v[n].push_back(m);
    v[m].push_back(n);
  }
  for(int t=1;t<=a;t++)
    e+=v[t].size()%2;
  printf("%d ",e/2);
  n=1,m=a-1;
  for(;n<m;)
  {
    k=(n+m)/2;
    f(1,0);
    //for(int t=1;t<=a;t++)
    //  printf("%d ",o[t]);
    //puts("");
    for(int t=1;t<=a;t++)
      if(o[t]>k)
      {
        n=k+1;
        goto qwe;
      }
    m=k;
    qwe:;
  }
  printf("%d",n);
}


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

using namespace std;

const int N = 10000 + 5;
const int INF = 0x3f3f3f3f;
using LL = long long;
using P = pair<int, int>;
map<int, int> mp;
set<int> S;

int a[N];

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

    for(int i = 0; i < n; i++){
        if(x >= a[i]){
            x -= a[i];
            cnt++;
        }
    }
    cnt += x / a[0];
    cout << cnt << endl;
}


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

using namespace std;

int main() {
    int ans = 0;
    int N = 0;
    cin >> N;
    int n = N;

    while(N) {
        ans += N%10;
        N /= 10;
    }
    if(n%ans) {
    cout << "No" << endl;
    } else {
    cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 3544
let (n1, n2) = (4, 16)
let n_limit = 100
let mdt = Array.make_matrix n2 n2 0
let dx = [| 0; -1; 0; 1 |]
let dy = [| 1; 0; -1; 0 |]

type puzzle = { tbl : int array; space : int; md : int }

let dfs puzzle limit =
  let rec doit depth prev pzl =
    if pzl.md = 0 then true
    else if depth + pzl.md > limit then false
    else begin
      let (sx, sy) = (pzl.space / n1, pzl.space mod n1) in
      let { tbl; md } = pzl in
      let swap tbl i j = let t = tbl.(i) in tbl.(i) <- tbl.(j); tbl.(j) <- t in
      let rec move r =
        if r = 4 then false
        else
          let (tx, ty) = (sx + dx.(r), sy + dy.(r)) in
          if tx < 0 || ty < 0 || tx >= n1 || ty >= n1 then move (r + 1)
          else if max prev r - min prev r = 2 then move (r + 1)
          else begin
            let (space, num) = (tx * n1 + ty, sx * n1 + sy) in
            let md = md - mdt.(space).(tbl.(space) - 1) in
            let md = md + mdt.(num).(tbl.(space) - 1) in
            let tbl = Array.copy tbl in
            swap tbl space num;
            if doit (depth + 1) r { tbl; space; md } then true
            else move (r + 1)
          end in
      move 0
    end in
  doit 0 (-n_limit) puzzle

let idastar tbl space =
  let (_, md) =
    Array.fold_left (fun (i, sum) e ->
      (i + 1, if e = n2 then sum else sum + mdt.(i).(e-1)))
      (0, 0) tbl in
  let pzl = { tbl; space; md } in
  let rec doit limit =
    if limit > n_limit then assert false
    else if dfs pzl limit then limit
    else doit (limit + 1) in
  doit pzl.md

let () =
  for i = 0 to n2 - 1 do
    for j = 0 to n2 - 1 do
      mdt.(i).(j) <- abs (i / n1 - j / n1) + abs (i mod n1 - j mod n1)
    done
  done;
  let tbl = Array.make n2 0 in
  let rec doit i space =
    if i = n2 then space
    else begin
      let x = Scanf.scanf "%d " (fun i -> i) in
      let (x, space) = if x = 0 then (n2, i) else (x, space) in
      tbl.(i) <- x;
      doit (i + 1) space
    end in
  doit 0 0 |> idastar tbl |> Printf.printf "%d\n"

Measured memory_bytes: 4552
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define N 1005
#define inf 1e18
#define ll long long
#define db double
#define dbg1(x) cout<<#x<<"="<<x<<" "
#define dbg2(x) cout<<#x<<"="<<x<<"\n"
int n,A[N],g[N],Max,now,cnt,ans[N];ll f[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&A[i]),f[i]=-inf;
	for(int i=1;i<=n;i++)
	{
		for(int j=i-2;j>0;j-=2)
			if(f[j]+A[i]>f[i]) f[i]=f[j]+A[i],g[i]=j;
		if(A[i]>f[i]) f[i]=A[i],g[i]=0;
	}
	for(int i=1;i<=n;i++) if(f[i]>f[Max]||!Max) Max=i;
//	dbg1("f");for(int i=1;i<=n;i++) dbg1(f[i]);puts("");
//	dbg1("g");for(int i=1;i<=n;i++) dbg1(g[i]);puts("");
//	for(int i=Max;i;i=g[i]) dbg1(i);puts("");
	for(int i=n;i>Max;i--) ans[++cnt]=i;
//	cout<<g[Max]<<"aa\n";
	for(now=Max;g[now];now=g[now])
	{
		for(int i=1;i<(now-g[now])/2;i++) ans[++cnt]=g[now]+2;
		ans[++cnt]=g[now]+1;
	}
	for(int i=1;i<now;i++) ans[++cnt]=1;
//	printf("%lld\n",f[Max]);
	cout<<f[Max]<<"\n";
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++) printf("%d\n",ans[i]);
//	dbg1(st),dbg2(ed);
	/*printf("%lld\n",Max);
	printf("%d\n",n-ed+st-1+(ed-st)/2);
	for(int i=n;i>ed;i--) printf("%d\n",i);
	for(int i=st;i<ed;i+=2) printf("%d\n",st+1);
	for(int i=1;i<st;i++) printf("%d\n",1);*/
	return 0;
}

Measured memory_bytes: 256
n,k =map(int,input().split())
h = list(map(int,input().split()))
#print(n,k,h)
 
ans = [0]*n
 
for i in range(n):
  s = float("inf")
  for j in range(1,k+1):
    if i == 0:
      s = 0
    if (i - j) >= 0:
      x = abs(h[i] - h[i-j]) + ans[i-j]
      if s > x:
        s = x
  ans[i] = s
 
 
#print(ans)
print(ans[n-1])

Measured memory_bytes: 52448
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Text;

namespace AtCoder.ABC
{
	class QuestionD
	{
		public static void Main(string[] args)
		{
			var n = long.Parse(Console.ReadLine());
			var a = Console.ReadLine().Split(" ").Select(x => long.Parse(x)).ToArray();

			var isUp = a[0] < a[1];
			var money = 1000L;
			var kabuNum = 0L;

			if (isUp) {
				kabuNum += money / a[0];
				money -= kabuNum * a[0];
			}

			for(int i = 1; i < n; i++) {
				if(a[i] > a[i - 1]) {
					if(isUp == false) {
						kabuNum += money / a[i - 1];
						money -= kabuNum * a[i - 1];
					}

					isUp = true;
				}else if(a[i - 1] > a[i]) {
					if (isUp) {
						money += kabuNum * a[i- 1];
						kabuNum = 0;
					}

					isUp = false;
				}

				if(i == n - 1 && isUp) {
					money += kabuNum * a[i];
					kabuNum = 0;
				}
			}

			Console.WriteLine(money);
		}
	}
}


Measured memory_bytes: 28212
//ABC070B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans = max(0,min(b,d)-max(a,c));
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

map <LL, int> cnt;
LL ans, sum;
int n;

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  Read(n), cnt[0] = 1;
  for (int i = 1, x; i <= n; ++i) {
    Read(x), sum += x, ans += cnt[sum]++;
  }
  printf("%lld\n", ans);
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


Measured memory_bytes: 12800
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int k;
  cin >> k;
  int x = 7 % k;
  for (int it = 0; it < 3 * k; it++) {
    if (!x) {
      cout << it + 1 << endl;
      return 0;
    }
    x = (x * 10 + 7) % k;
  }
  cout << -1 << endl;
}



Measured memory_bytes: 3652
import java.io.*;
import java.util.*;
import java.lang.Math.*;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        String s = scanner.next();
        int N = s.length();
        Set<String> set = new HashSet<String>();
        for (int i = 0; i < N; i++) {
            if (set.contains(""+s.charAt(i))) {
                System.out.println("no");
                return;
            }
            set.add(""+s.charAt(i));
        }
        System.out.println("yes");
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";

        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {
                    line = br.readLine();
                }
                s = line.split(reg, 0);
                i = 0;
                return s[i++];
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public int nextInt() {
            try {
                return Integer.parseInt(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public double nextDouble() {
            try {
                return Double.parseDouble(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }

        public long nextLong()  {
            try {
                return Long.parseLong(next());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return -1;
        }
    }
}


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

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

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

    int i = 0;
    int ans = 0;
    int cnt = 1;
    while(true){
        if(i == n){
            break;
        }
        if(a[i] == a[i + 1]){
            cnt++;
        }
        else if(a[i] != a[i + 1] || i == n - 1){
            if(a[i] > cnt){
                ans += cnt;
            }
            else if(a[i] < cnt){
                ans += (cnt - a[i]);
            }
            cnt = 1;
        }
        i++;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a==b && b==c){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
//Arayi
//#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <ctime>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <climits>
#include <cassert>
#include <chrono>
#include <random>
#include <complex>

#define fr first
#define sc second
#define MP make_pair
#define ad push_back
#define PB push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define lli long long int
#define y1 arayikhalatyan
#define j1 jigglypuff
#define ld long double
#define itn int
#define pir pair<int, int> 
#define all(x) (x).begin(), (x).end()
#define str string
#define enl endl
#define en endl
#define cd complex<long double>
#define vcd vector<cd>
#define vii vector<int>
#define vlli vector<lli>
using namespace std;

lli gcd(lli a, lli b) { return (b == 0LL ? a : gcd(b, a % b)); }
ld dist(ld x, ld y1, ld x2, ld y2)
{
    return sqrt((x - x2) * (x - x2) + (y1 - y2) * (y1 - y2));
}
lli S(lli a)
{
    return (a * (a + 1LL)) / 2;
}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
char vow[] = { 'a', 'e', 'i', 'o', 'u' };
int dx[] = { 1, -1, 0, 0, -1, -1, 1, 1, 0 };
int dy[] = { 0, 0, 1, -1, -1, 1, -1, 1, 0 };


const int N = 2e5 + 30;
const lli mod = 36000;
const ld pi = acos(-1);
const int T = 238;
const ld e = 1e-13;

lli bp(lli a, lli b = mod - 2LL)
{
    lli ret = 1;
    while (b)
    {
        if (b & 1) ret *= a, ret %= mod;
        a *= a;
        a %= mod;
        b >>= 1;
    }
    return ret;
}
ostream& operator<<(ostream& c, pir a)
{
    c << a.fr << " " << a.sc;
    return c;
}
struct pt
{
    lli x, y;
    int ind;
    int bl;
    bool operator==(const pt& a)
    {
        return ind == a.ind;
    }
    bool operator<(const pt& b)
    {
        if (x == b.x) return y < b.y;
        return x < b.x;
    }
};




int l, r, d, pat;
int main()
{
    fastio;
    cin >> l >> r >> d;
    for (int i = l; i <= r; i++)
    {
        if (i % d == 0) pat++;
    }
    cout << pat << endl;
    return 0;
}

/*


  __
*(><)*
  \/ /
  ||/
--||
  ||
  /\
 /  \
/    \
*/

Measured memory_bytes: 3636
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

string s,t;

int main() {
    std::cin >> s>>t;
    ll key = -1;
    for (int i =  0; i <s.length(); i++) {
        ll count =0;
        for (int j = 0; j < t.length(); j++) {
            if(s.length() - t.length() -i+j>s.length()-1 || (ll)(s.length() - t.length() -i+j) < 0){
                i=100;
                break;
            }
            if(s[s.length() - t.length() -i+j] == t[j] || s[s.length() - t.length() -i+j] == '?'){
                count++;
            }else{
                break;
            }
            if(count==t.length()){
                key = s.length() - t.length() -i;
                i = 100;
                break;
            }
        }
    }
    if(key==-1){
        std::cout << "UNRESTORABLE" << std::endl;
    }else{
        for (int i = 0; i < s.length(); i++) {
            if(key<=i && i<key+t.length()){
                s[i] = t[i-key];
            }
            if(s[i]=='?'){
                s[i]='a';
            }
        }
        std::cout << s << std::endl;
    }
}



Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;



//bit全探索
vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b;
}



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

using namespace std;

int main() {
    int N;
    cin >> N;
    for (int i=0; i<N; i++) {
        string a, b;
        cin >> a >> b;
        int sum, ret=0;
        if (a.length() < b.length()) swap(a,b);
        int l = b.length()-1;
        for (int i=a.length()-1; i>=0; i--) {
            if (l >= 0) {
                sum = (a[i]-'0')+(b[l]-'0')+ret;
                l--;
            } else {
                sum = (a[i]-'0')+ret;
            }
            if (sum>=10) {
                ret = 1;
                sum -= 10;
            } else {
                ret = 0;
            }
            a[i] = sum+'0';
        }
        if (ret != 0) {
            a.insert(a.begin(), ret+'0');
        }
        if (a.length() > 80) cout << "overflow" << endl;
        else cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ep emplace_back
#define st first
#define sc second

using namespace std;

const ll mod = 998244353;
const int e = 1e6 + 69;
const int base = 311;

// dung igt thay cho gt luc tinh giai thua
// 3
// cach tao hoan vi tu n so : n*(n+1)/2;

int main()
{
    int n;
    cin >> n;
    ll minn = 1e18;
    ll ans = 0;
    vector<ll>cur;
    for(int i=1; i<=n; i++)
    {
        ll x;
        cin >> x;
        ans += x;
        if(x % 10 != 0)
        {
            minn = min(minn, x);
        }
    }
    if(ans % 10 == 0) ans -= minn;
    cout << max(0LL, ans);
}


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


int main()
{
    string s;
    cin>>s;
    map<char,int>m;
    for(int i=0;i<4;i++)
        m[s[i]]++;
    if(m.size()!=2)
    {
        cout<<"No";
        return 0;
    }
    else
    {
        for(int i=0;i<4;i++)
            if(m[s[i]]!=2)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;

void solve(){
	int n,m;
	cin >> n >> m;
	vector<bool> cor(n+1,0);
	vector<int> pen(n+1,0);
	for(int i = 1; i <= n; ++i){
		cor[i] = 0;
		pen[i] = 0;
	}
	int p;
	string s;
	for(int i = 0; i < m; ++i){
		cin >> p >> s;
		if(s == "AC"){
			cor[p] = 1;
		}else{
			if(!cor[p]){
				pen[p]++;
			}
		}
	}
	int cc = 0, penc = 0;
	for(int i = 1; i <= n; ++i){
		cc += cor[i];
		if(cor[i])penc += pen[i];
	}
	cout << cc << " " << penc << endl;
}

int32_t main(){
	IO;
	
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


Measured memory_bytes: 1024
import copy

def cmb(n, r, mod):#コンビネーションの高速計算　
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 2*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


N=int(input())
A=list(map(int,input().split()))

B=copy.copy(A)
B.sort()
x=0
for i in range(0,N):
    if B[i]==B[i+1]:
        x=B[i]
        break

first=-1
second=-1
for i in range(0,N+1):
    if A[i]==x:
        if first==-1:
            first=i
        else:
            second=i

for k in range(1,N+2):
    if N-1>=k:
        if first+N-second>=k-1:
            ans=2*cmb(N-1,k-1,mod)-cmb(first+N-second,k-1,mod)+cmb(N-1,k,mod)+cmb(N-1,k-2,mod)
            print(ans%mod)
        else:
            ans=2*cmb(N-1,k-1,mod)+cmb(N-1,k,mod)+cmb(N-1,k-2,mod)
            print(ans%mod)
    elif N==k:
        if first+N-second>=k-1:
            ans=2*cmb(N-1,k-1,mod)-cmb(first+N-second,k-1,mod)+cmb(N-1,k-2,mod)
            print(ans%mod)
        else:
            ans=2*cmb(N-1,k-1,mod)+cmb(N-1,k-2,mod)
            print(ans%mod)
    else:
        if first+N-second>=k-1:
            ans=-cmb(first+N-second,k-1,mod)+cmb(N-1,k-2,mod)
            print(ans%mod)
        else:
            ans=cmb(N-1,k-2,mod)
            print(ans%mod)


Measured memory_bytes: 84720
#include <iostream>

using namespace std;

int main() {
  string in;
  cin >> in;
  long res = 0;
  for (long i = 0; i < in.size(); i++) {
    if (in[i] == 'B' || in[i] == 'C') continue;
    long acnt = 0;
    while (in[i] == 'A') {
      acnt++;
      i++;
    }
    long bccnt = 0;
    while (in[i] == 'B' && in[i+1] == 'C') {
      bccnt++;
      i=i+2;
    }
    i--;
    res += acnt*bccnt;
    if (bccnt > 0) {
      for (long j = 0; j < acnt; j++) {
        if (i < in.size()-1) {
          in[i] = 'A';
          i--;
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 640
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0;
    cin>>n;
    lli a[n+1];
    for(int i=1;i<=n;++i)
        cin>>a[i];
    lli pre[n+1];
    pre[1]=a[1];
    for(int i=3;i<=n;i+=2)
        pre[i]=pre[i-2]+a[i];
    lli dp[n+1]={0};
    for(int i=2;i<=n;++i)
    {
        if(i%2==0)
            dp[i]=max(dp[i-2]+a[i],pre[i-1]);
        else
            dp[i]=max(dp[i-1],dp[i-2]+a[i]);
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 8284
package main

import (
	"fmt"
)

func main() {
	var n, a int
	var cnt [222222]int
	fmt.Scan(&n)
	for i := 0; i < n-1; i++ {
		fmt.Scan(&a)
		cnt[a-1]++
	}
	for i := 0; i < n; i++ {
		fmt.Println(cnt[i])
	}
}


Measured memory_bytes: 8140
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll P = 1e9+7;
const ll N = 2e6+7;

//Modifiable-DSU
//Using path compression and union by size

vector<ll> parent(N);
vector<ll> SS(N);
void initialize(ll node)
{
	parent.at(node) = node;
	SS.at(node) = 1;
}
ll find_parent(ll node)
{
	if(parent.at(node) == node) return node;
	return parent.at(node) = find_parent(parent.at(node));
}
void merge_set(ll a, ll b)
{
	a = find_parent(a);
	b = find_parent(b);

	if(a != b)
	{
		if(SS.at(a) < SS.at(b))
			swap(a,b);
		parent.at(b) = a;
		SS.at(a) += SS.at(b);
	}
}

int main(){

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

	ll t=1;
	// cin>>t;

	while(t--){
		ll n,q;
		cin>>n>>q;

		ll x,a,b;
		for(ll i=1;i<=n;++i) initialize(i);
		while(q--){
			cin>>x>>a>>b;
			++a, ++b;
			if(!x){
				merge_set(a,b);
			}
			else{
				ll x = find_parent(a) , y = find_parent(b);
				if(x == y and x != 0) cout<<"1\n";
				else cout<<"0\n";
			}
			
		}

	}	

	return 0;
}	

Measured memory_bytes: 34528
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
  int n;  cin >> n;
  for (int i = n / 25; i >= 0; --i) {
    int money = n;
    money -= i * 25;
    for (int j = money / 10; j >= 0; --j) {
      money -= j * 10;
      for (int k = money / 5; k >= 0; --k) {
        money -= k * 5;
        if (money >= 0) {
          cout << i + j + k + money << '\n';
          return 0;
        }
      }
    }
  }
  return 0;
}



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

int main(){
    int m, n, s, c;
    map<int,int> con;
    cin >> n >> m;

    rep(i,m){
        cin >> s >> c;

        if(con.count(s)){
            if(con[s]!=c){
                cout << -1 << endl;
                return 0;
            }
        }
        else{
            con[s] = c;
        }
    }

    if(con.count(1)){
        if(con.at(1)==0 and n>1){
            cout << -1 << endl;
            return 0;
        }
    }
    else{
        if(n==1){
            cout << 0 << endl;
            return 0;
        }
        con[1]=1;
    }
    int ans = 0;
    for (auto p : con) {
        auto s = p.first;
        auto c = p.second;
        
        ans = ans + c * pow(10, n-s);
        // cout << s << " " << c << " " << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define ff first
#define ss second
#define N 2000001
#define M 1000000007
#define INF 1000000000000000

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



int main()
{
    ll n,ans=0;
    cin>>n;
    ll a[n];
    ll inv[2];
    inv[1] = 1;ll i;
for ( i=2; i<=2; ++i)
	inv[i] = (M - (M/i) * inv[M%i] % M) % M;
    ll sum1=0,sum2=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum1=sum1%M+a[i]%M;
        sum1=sum1%M;
        sum2=sum2+(a[i]%M*a[i]%M)%M;
        sum2=sum2%M;
    }
    sum1=(sum1*sum1)%M;
    cout<<((sum1-sum2+M)%M*inv[2])%M;
    
}

Measured memory_bytes: 5160
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N,M;
  cin>>N>>M;
  
  vector<vector<int>> S(N,vector<int>(2));
  for(int i=0;i<N;i++){
    cin>>S[i][0]>>S[i][1];
  }
  
  vector<vector<int>> check(M,vector<int>(2));
  for(int j=0;j<M;j++){
    cin>>check[j][0]>>check[j][1];
  }
  
  
  for(int i=0;i<N;i++){
    long long res=1000000000000000000;
    for(int j=0;j<M;j++){
      long long D=abs(check[j][0]-S[i][0])+abs(check[j][1]-S[i][1]);
      res=min(res,D);
    }
    for(int j=0;j<M;j++){
      if((abs(check[j][0]-S[i][0])+abs(check[j][1]-S[i][1]))==res){
        cout<<j+1<<endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
ll X,Y;
int main(){
	cin>>X>>Y;
	cout<<(llabs(X-Y)<=1 ? "Brown" : "Alice")<<endl;
	return 0;
}

Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    cnt = 0
    ma = 0
    for _ in range(N):
        a, b = map(int, input().split())
        if a == b:
            cnt += 1
            ma = max(ma, cnt)
        else:
            cnt = 0
    if ma >= 3:
        print("Yes")
    else:
        print("No")



if __name__ == '__main__':
    main()


Measured memory_bytes: 62244
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	map<ll,int> mp;
	rep(i,n){
		ll a;
		cin >> a;
		++mp[a];
	}
	bool yes = false;
	if((mp[0] == n) || (mp[0] == n/3 && mp.size() == 2)){
		yes = true;
	}
	if(mp.size() == 4){
		bool ok = true;
		vector<ll> v(3);
		int idx = 0;
		for(auto p : mp){
			if(p.first == 0) continue;
			if(p.second != n/3) ok = false;
			v[idx++] = p.first;
		}
		if((v[0]^v[1]^v[2]) != 0) ok = false;
		if(ok) yes = true;
	}
	cout << (yes ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 8404
void main() {
	alias Cont = Tuple!(int, "sx", int, "sy", int, "gx", int, "gy");
	auto ip = readAs!(int[]), H = ip[0], W = ip[1];
	auto a = readMatrix!int(H, W);
	ulong cnt;
	Cont[] conts;

	auto dx = [1,0,-1,0], dy = [0,1,0,-1];
	foreach(i; 0..H) {
		foreach(j; 0..W) {
			foreach(k; 0..4) {
				auto ry = i + dy[k], rx = j + dx[k];
				if(0 <= ry && ry < H && 0 <= rx && rx < W &&
					a[i][j]%2 != 0) {
					a[ry][rx]++;
					a[i][j]--;
					cnt++;
					conts ~= Cont(i+1, j+1, ry+1, rx+1);
					continue;
				}
			}
		}
	}
	cnt.writeln;
	conts.each!(i => writefln("%d %d %d %d", i.sx, i.sy, i.gx, i.gy));
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 12796
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;

int main(){
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;
  int ans = 0;
  rep(i, n - 1){
    if(s[i] == s[i + 1])  ans++;
  }

  ans = min(ans + 2 * k, n - 1);
  cout << ans << endl;
}

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

using namespace std;

int main()
{
	long long total=0;
	int top,cants[100001],minim;
	cin>>top;
	//memset(cants,0,100001);
	for(int i=0;i<100001;i++)
		cants[i]=0;
	for(int i=1;i<=top;i++)
	{
		cin>>cants[i];
	}	
	for(int i=1;i<=top;i++)
	{
		if(cants[i])
		{			
			if(cants[i-1])
			{
				minim=min(cants[i],cants[i-1]);
				total+=minim;
				cants[i]-=minim;
				cants[i-1]-=minim;
			}	
			if(cants[i]>1)
			{
				total+=cants[i]/2;
				cants[i]%=2;
			}
		}		
	}
	cout<<total<<endl;
	
	//system("pause");
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
char s[300];int n;
struct Node {int x,y;Node(){}Node(int _x,int _y){x=_x;y=_y;}};
vector<Node> V;
inline string inv(string s)
{
	reverse(s.begin(),s.end());
	for(int i=0;i<(int)s.size();i++)
	{
		if(s[i]>='A'&&s[i]<='Z') s[i]+='a'-'A';
		else s[i]-='a'-'A';
	}
	return s;
}
int main()
{
	scanf("%d%s",&n,s);
	for(int i=0;i<(1<<n);i++) for(int j=0;j<(1<<n);j++)
		if((i&j)==(s[i]=='1'?j:i)&&s[j]!=s[i]) return puts("Impossible"),0;
	puts("Possible");
	V.push_back(Node(0,0));
	for(int i=0;i<(1<<n);i++) if(s[i]=='0')
	{
		bool flag=1;
		for(int j=0;j<i;j++) if((i&j)==j&&s[j]=='0'){flag=0;break;}
		if(!flag) continue;
		string S;
		for(int j=0;j<n;j++) if((i>>j)&1)
		{
			if(S.size()==0)S+='a'+j;
			else S=(char)('a'+j)+S+(char)('A'+j)+inv(S);
		}
		int lstv=0;
		for(int j=0;j<(int)S.size();j++)
		{
			int now,fv;
			if(S[j]>='A'&&S[j]<='Z') now=S[j]-'A',fv=0;
			else now=S[j]-'a',fv=1;
			for(int k=lstv+1;k<=now;k++) V.push_back(Node(k,0));
			for(int k=lstv-1;k>=now;k--) V.push_back(Node(k,0));
			if(fv)
			{
				V.push_back(Node(now,1));V.push_back(Node(now+1,1));
				V.push_back(Node(now+1,0));V.push_back(Node(now,0));
			}
			else
			{
				V.push_back(Node(now+1,0));V.push_back(Node(now+1,1));
				V.push_back(Node(now,1));V.push_back(Node(now,0));
			}
			lstv=now;
		}
		for(int j=lstv-1;j>=0;j--) V.push_back(Node(j,0));
	}
	cout<<V.size()-1<<endl;
	for(int i=0;i<(int)V.size();i++) printf("%d %d\n",V[i].x,V[i].y);
	return 0;
}

Measured memory_bytes: 3880
import math
sosu=[]
def seisei(N):
    global sosu
    sosu.append(2)
    for p in range(3,N+1):
        c=0
        for i in sosu:
            if i<=math.floor(p**(0.5)):
                if p%i==0:
                    c=1
                    break
            else:
                break
        if c==0:
            sosu.append(p)
N=int(input())
seisei(55555)
a=[]
for x in sosu:
    if x%5==1:
        a.append(str(x))
print(' '.join(a[:N]))


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
const ll MOD = (1e+9)+7;
typedef pair<ll, ll> LP;
ll POW(ll m,ll n)
{
  if(n<0) return 0;
  if(n==0) return 1;
  return m*POW(m,n-1);
}
int main()
{
  int a,b;
  cin >> a >> b;
  printf("%d",a-b+1);
}

Measured memory_bytes: 256
#include <stdio.h>

const int Mod = 998244353;

int main()
{
	int N;
	char S[300001];
	scanf("%d", &N);
	scanf("%s", S);
	
	int i, j, k, count[3] = {};
	long long ans = 1;
	for (i = 1; i <= N * 3; i++) {
		if (S[i-1] == 'R') {
			if (count[0] >= count[1] && count[0] >= count[2]) ans = ans * (N - count[0]) % Mod;
			else if (count[0] < count[1] && count[0] >= count[2]) ans = ans * (count[1] - count[0]) % Mod;
			else if (count[0] >= count[1] && count[0] < count[2]) ans = ans * (count[2] - count[0]) % Mod;
			else if (count[1] <= count[2]) ans = ans * (count[1] - count[0]) % Mod;
			else ans = ans * (count[2] - count[0]) % Mod;
			count[0]++;
		} else if (S[i-1] == 'G') {
			if (count[1] >= count[0] && count[1] >= count[2]) ans = ans * (N - count[1]) % Mod;
			else if (count[1] < count[0] && count[1] >= count[2]) ans = ans * (count[0] - count[1]) % Mod;
			else if (count[1] >= count[0] && count[1] < count[2]) ans = ans * (count[2] - count[1]) % Mod;
			else if (count[0] <= count[2]) ans = ans * (count[0] - count[1]) % Mod;
			else ans = ans * (count[2] - count[1]) % Mod;
			count[1]++;
		} else {
			if (count[2] >= count[0] && count[2] >= count[1]) ans = ans * (N - count[2]) % Mod;
			else if (count[2] < count[0] && count[2] >= count[1]) ans = ans * (count[0] - count[2]) % Mod;
			else if (count[2] >= count[0] && count[2] < count[1]) ans = ans * (count[1] - count[2]) % Mod;
			else if (count[0] <= count[1]) ans = ans * (count[0] - count[2]) % Mod;
			else ans = ans * (count[1] - count[2]) % Mod;
			count[2]++;
		}
	}
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define INF  numeric_limits<int>::max()
#define NINF numeric_limits<int>::min()

using namespace std;
using ll = long long;

using coordinate = struct {
    int x;
    int y;
};

int H, W, N;
char world_map[1000][1000];
int  cost_map[1000][1000];

bool update_map(const coordinate& target, const int& cost) {
    if(0 <= target.x && target.x < W &&
       0 <= target.y && target.y < H ) {
        if(world_map[target.y][target.x] != 'X' && cost_map[target.y][target.x] == -1) {
            cost_map[target.y][target.x] = cost;
            return true;
        }
    }
    return false;
}

int get_shortest_path_length(const coordinate& s, const coordinate& g) {
    REP(hi, H) {
        REP(wi, W) {
            cost_map[hi][wi] = -1;
        }
    }

    std::queue<coordinate> queue;
    queue.push(s);
    cost_map[s.y][s.x] = 0;

    while(true) {
        coordinate dst;
        coordinate src = queue.front();
        queue.pop();

        int cost = cost_map[src.y][src.x] + 1;

        dst = coordinate{src.x + 1, src.y};
        if(update_map(dst, cost)) {
            queue.push(dst);
        }

        dst = coordinate{src.x - 1, src.y};
        if(update_map(dst, cost)) {
            queue.push(dst);
        }

        dst = coordinate{src.x, src.y + 1};
        if(update_map(dst, cost)) {
            queue.push(dst);
        }

        dst = coordinate{src.x, src.y - 1};
        if(update_map(dst, cost)) {
            queue.push(dst);
        }

        if(cost_map[g.y][g.x] != -1) {
            break;
        }
    }

    return cost_map[g.y][g.x];
}

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

    std::cin >> H >> W >> N;

    coordinate pos;
    vector<coordinate> factories(N);

    REP(hi, H) {
        REP(wi, W) {
            std::cin >> world_map[hi][wi];
            if(world_map[hi][wi] == 'S') {
                pos = coordinate{wi, hi};
            }
            else if('1' <= world_map[hi][wi] && world_map[hi][wi] <= '9') {
                factories[(int)(world_map[hi][wi] - '1')] = coordinate{wi, hi};
            }
        }
    }

    int ans = 0;
    for(const auto& factory : factories) {
        ans += get_shortest_path_length(pos, factory);
        pos = factory;
    }

    std::cout << ans << std::endl;

    return 0;
}



Measured memory_bytes: 7976
# -*- coding: utf-8 -*-

N, Y = map(int, input().split())

moneys = [10000, 5000, 1000]

man = 0
gosen = 0
sen = 0
'''
方針：とりあえず、できるかの計算
その後は、１万円札から５０００円に両替
その次に５０００円札を１００００円に両替していく
'''

max_man = Y//10000
max_gosen = Y//5000

for m in range(max_man, -1, -1):
    for g in range(max_gosen, -1, -1):
        s = N - m - g
        if s < 0:
            continue
        if 10000*m + 5000*g + 1000*s == Y:
            print(m,g,s)
            exit()
print(-1,-1,-1)

Measured memory_bytes: 3064
x1,y1,x2,y2=gets.strip.split(' ').map(&:to_i)
a=x2-x1
b=y2-y1
x3=x2-b
y3=y2+a
x4=x3-a
y4=y3-b
puts x3
puts y3
puts x4
puts y4

Measured memory_bytes: 1788
#include <stdio.h>

#define N 100

static int  w;
static int  h;
static char d[ N ][ N ];

static void
nekomimi (
  int   x,
  int   y,
  char  ch
  )
{
  if ( x < 0 || x >= w
    || y < 0 || y >= h
    || d[ y ][ x ] != ch ) return ;

  d[ y ][ x ] = ' ';
  nekomimi ( x - 1, y, ch );
  nekomimi ( x + 1, y, ch );
  nekomimi ( x, y - 1, ch );
  nekomimi ( x, y + 1, ch );

  return ;
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    int res = 0;

    scanf ( " %d %d", &h, &w );
    if ( !( w | h ) ) break ;

    for ( i = 0; i < h; ++i )
    for ( j = 0; j < w; ++j )
    {
      scanf ( " %c", &d[ i ][ j ] );
    }

    for ( i = 0; i < h; ++i )
    for ( j = 0; j < w; ++j )
    {
      if ( d[ i ][ j ] == ' ' ) continue ;
      nekomimi ( j, i, d[ i ][ j ] );
      ++res;
    }

    printf ( "%d\n", res );
  }

  return ( 0 );
}

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

int main(){
  int A, B;
  int a, b, c;
  cin >> A >> B;
  
  a = A + B;
  b = A - B;
  c = A * B;

  a = a > b ? a : b;
  
  cout << (a > c ? a : c);
}

Measured memory_bytes: 256
require 'set'

n = gets.to_i
n.times do
	h, w = gets.split.map(&:to_i)
	a = (1..h).map { gets.chomp }
	chars = a.join.split("").uniq - [?.]
	prior = {}
	
	safe = true
	catch :exit do
		chars.each do |c|
			prior[c] = Set.new
			y1 = a.index {|row| row =~ /#{c}/}
			y2 = a.rindex {|row| row =~ /#{c}/}
			x1 = a.map {|row| (row =~ /#{c}/) || w}.min
			x2 = a.map {|row| w - 1 - (row.reverse =~ /#{c}/ || w)}.max
			(y1..y2).each do |i|
				(x1..x2).each do |j|
					if a[i][j] == ?.
						safe = false
						throw :exit
					elsif a[i][j] != c
						prior[c] << a[i][j]
					end
				end
			end
		end
	end

	if !safe
		puts 'SUSPICIOUS'
		next
	end

	safe = chars.empty? ? true : false
	chars.permutation(chars.size) do |perm|
		order = {}
		perm.each.with_index {|c, i| order[c] = i}
		
		if chars.all? {|c| prior[c].all?{|p| order[p] < order[c]}}
			safe = true
			break
		end
	end
	puts safe ? 'SAFE' : 'SUSPICIOUS'
end

Measured memory_bytes: 11004
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<N;i++)
using namespace std;

int main(){
  int N;
  cin >>N;
  
  int n;
  if(N%2==0) n=N/2;
  else n = N/2+1;
  
  float ans = (float)n/N;
  cout <<ans<< endl;
}

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

long long int fgcd(long long int ,long long int );

int main(void)
{
    long long int a,b;
    cin>>a>>b;
    cout<<fgcd(a,b)<<endl;
    return 0;
}

long long int fgcd(long long int a,long long int b)
{
    if(a%b==0)
    {
        return b;
    }
    else
    {
        return fgcd(b,a%b);
    }
}



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

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#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 REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;
string s;

int main(void){
  
  IN(s);
  if (s == "ABC") {
    PRINT("ARC");
  } else {
    PRINT("ABC");
  }

}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
 ll a,b,c;
 cin>>a>>b>>c;
 cout<<c<<" "<<a<<" "<<b<<endl;
}
   



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

int main(void){
    string s;
    cin >> s;
    
    int ans0 = 0;
    int ans1 = 0;
    
    for (int i = 0; i < 2; i++){
        if (i == 0){
            for (int j = 0; j < s.size(); j++){
                if (j % 2 == 0 && s[j] != (char)(i + '0')) ans0++;
                if (j % 2 != 0 && s[j] == (char)(i + '0')) ans0++;
            }
        }
        else{
            for (int j = 0; j < s.size(); j++){
                if (j % 2 == 0 && s[j] != (char)(i + '0')) ans1++;
                if (j % 2 != 0 && s[j] == (char)(i + '0')) ans1++;
            }
        }
    }
    
    cout << min(ans0, ans1) << endl;
}

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

int main() {
	string S;  cin >> S;
	for (int i = 0; i < 4; i++) {
		cout << S.at(i);
	}
	cout << ' ';
	for (int i = 4; i < 12; i++) {
		cout << S.at(i);
	}
	cout << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int A, B, C, mili=0;
		A = reader.nextInt();
		B = reader.nextInt();
		C = reader.nextInt();
		mili = (B+C)-A;
		if(mili>0) {
			System.out.println(mili);
		}else {
			System.out.println(0);
		}
	}

}


Measured memory_bytes: 21844
#!/usr/bin/env python3
import sys

def warshall_floyd(d, V): 
    for k in range(V):
        for i in range(V):
            for j in range(V):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])

    return d #d[i][j]に頂点i, j間の最短距離を格納

def solve(H: int, W: int, c: "List[List[int]]", A: "List[List[int]]"):
    min_cost = warshall_floyd(c,10)
    answer = 0

    for h in range(H):
        for w in range(W):
            if A[h][w] == -1:
                continue

            answer += min_cost[A[h][w]][1]
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    c = [[int(next(tokens)) for _ in range(9 - 0 + 1)] for _ in range(9 - 0 + 1)]  # type: "List[List[int]]"
    A = [[int(next(tokens)) for _ in range(W)] for _ in range(H)]  # type: "List[List[int]]"
    solve(H, W, c, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
N, M = list(map(int, input().split()))
A = {i: 0 for i in range(N+1)}
mod = 10 ** 9 + 7
for _ in range(M):
    A[int(input())] = 1
 
dp = [0 for _ in range(N+1)]
dp[0] = 1
 
for i in range(N+1):
    if A.get(i+1) == 0:
        dp[i + 1] += dp[i]
    if A.get(i+2) == 0:
        dp[i + 2] += dp[i]
 
print(dp[N]%mod)

Measured memory_bytes: 474256