akhauriyash/Code-Regression huggingface dataset:
import sys
input=sys.stdin.readline

A,B,C,D,E,F = list(map(int, input().split()))

wa = []
for a in range(0,F//(A*100)+1):
    for b in range(0,F//(B*100)+1):
        w = a*A*100 + b*B*100
        if w < F and w not in wa:
            wa.append(w)
wa.remove(0)
sa = []
for c in range(0,F//C+1):
    for d in range(0,F//D+1):
        s = c*C + d*D
        if s < F and s not in sa:
            sa.append(s)
md = 0
sw = 0
ss = 0
limit_dens = (100*E)/(100+E)
for w in wa:
    for s in sa:
        if w + s <= F:
            d = (100*s)/(w+s)
            if d <= limit_dens:
                if md <= d:
                    md = d
                    sw = w+s
                    ss = s
                    if d == limit_dens:
                        print(sw, ss)
                        exit()
print(sw, ss)

Measured memory_bytes: 3064
from collections import deque

N = 3
M = 3
board = []
expected = [[1, 2, 3], [4, 5, 6], [7, 8, 0]]

queue = deque()
bqueue = deque()

history = set()
# todo 数字で表す
# todo 2分担作にする


def swap(x1, y1, x2, y2, b):
    # 2次元配列を浅いコピーするなんて
    t = [x[:] for x in b]
    t[x1][y1], t[x2][y2] = t[x2][y2], t[x1][y1]
    return t


def p2i(b):
    tmp = 0
    for i in range(N):
        for j in range(M):
            tmp += b[i][j] * 10**(3*i+j)
    return tmp


def bfs():
    if expected == board:
        print(0)
        exit(0)

    while len(queue):
        pazzle = queue.popleft()
        cost = bqueue.popleft()
        # 0の場所を探す
        xz = None
        yz = None
        for i in range(N):
            for j in range(M):
                if pazzle[i][j] == 0:
                    xz, yz = i, j
        # 動かすことのできる方向を全て調べる
        xm = [1, 0, 0, -1]
        ym = [0, -1, 1, 0]
        for k in range(4):
            if 0 <= xz + xm[k] < N and 0 <= yz + ym[k] < N:
                # １手動かしてあったら終了。なかったら次の手に行く。
                t = swap(xz, yz, xz + xm[k], yz + ym[k], pazzle)
                ipz = p2i(t)
                if 87654321 == ipz:
                    print(cost+1)
                    exit(0)
                # 今までに出てないならキューに追加
                if ipz not in history:
                    queue.append(t)
                    history.add(ipz)
                    bqueue.append(cost+1)


for i in range(N):
    board.append(list(map(int, input().split())))
queue.append(board)
bqueue.append(0)
bfs()


Measured memory_bytes: 32048
N = int(input())
W = []
for i in range(N):
    W.append(input())

tmp = []
tmp.append(W[0])
for i in range(N-1):
    if W[i][-1] == W[i+1][0] and W[i+1] not in tmp:
        tmp.append(W[i+1])
        if i == N-2:
            print('Yes')
    else:
        print('No')
        break

Measured memory_bytes: 3060
l = int(input())
rlist = []
for i in range(l):
    li = list(map(int, input().split()))
    rlist.append(li[2:])

result = []
for i in range(l):
    rcell = [0] * l
    for rl in rlist[i]:
        rcell[rl-1] = 1

    result.append(rcell)

for r in result:
    re = ''
    for rr in r:
        re += str(rr) + ' '

    print(re[:-1])


Measured memory_bytes: 5668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int H,W;
string s[500];
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int k=0;
int f[405][405];
ll num[200000][2];
void dfs(int x,int y){
	f[x][y]=k;
	if(s[x][y]=='#')num[k][0]++;
	else num[k][1]++;
	for(int d=0;d<4;d++){
		int nx = x+dx[d];
		int ny = y+dy[d];
		if(nx<0||nx>=H||ny<0||ny>=W)continue;
		if(f[nx][ny]!=-1)continue;
		if(s[nx][ny]==s[x][y])continue;
		dfs(nx,ny);
	}
}
int main(){
	cin >> H >> W;
	for(int i=0;i<H;i++)cin >> s[i];
	memset(f,-1,sizeof(f));
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(f[i][j]==-1&&s[i][j]=='#'){
				k++;
				dfs(i,j);
			}
		}
	}
	ll ans = 0ll;
	for(int i=0;i<=H*W;i++){
		ans += num[i][0]*num[i][1];
	}
	cout << ans << endl;
	return 0;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

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

    int a[4] = {};
    int i = 0;
    while (N != 0) {
        a[i++] = N % 10;
        N /= 10;
    }
    if ((a[0] == a[1] && a[1] == a[2]) || (a[1] == a[2] && a[2] == a[3])) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
package main


import (
    "fmt"
)

func main() {
  var N int64
  var S int64 = 0
  var i int64

  fmt.Scan(&N)

  var X int64 = N

  for  i = 100000000; i >= 1 ; i /= 10 { 
    S += N/i
    N  = N%i
    
    //fmt.Println("i:",i)
    //fmt.Println("N:",N)

  }

  if X % S == 0 {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }

}


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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
    string S,T,U;
    cin>>S>>T;
    ll a,b;
	cin>>a>>b;

    cin>>U;
    if(S==U){
        --a;
    }else{
        --b;
    }
    cout<<a<<" "<<b<<"\n";
	
	
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int n=s.size();
  int count=0,max=0;
  
  for(int i=0; i<n; i++){
    if(s.at(i)=='A'||s.at(i)=='C'||s.at(i)=='G'||s.at(i)=='T'){
      count++;
      if(max < count){
        max=count;
      }
    }else{
      if(max < count){
        max = count;
      }
      count = 0;
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int64_t N, K; cin >> N >> K;

cout << (N - 1 + K - 2) / (K - 1) << endl;

}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
n, m, q = map(int, input().split())
#line = [list(map(int, input().split())) for _ in range(m)]
ans = [[0] * (n + 1) for _ in range(n + 1)]
for _ in range(m):
	l, r = map(int, input().split())
	l -= 1
	r -= 1
	ans[0][r] += 1
	ans[l + 1][n] += 1
	ans[0][n] -= 1
	ans[l + 1][r] -= 1

for i in range(n + 1):
	for j in range(n):
		ans[i][j + 1] += ans[i][j]

for j in range(n + 1):
	for i in range(n):
		ans[i + 1][j] += ans[i][j]

for _ in range(q):
	p, q = map(int, input().split())
	print(ans[p - 1][q - 1])

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

using namespace std;
using ll = long long;

int main() {
    int A, B;
    cin >> A >> B;
    
    for(int i = 0; i < 20*A; i++) {
        if((i*8)/100 == A && (i*10)/100 == B) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

typedef long long LL;
typedef unsigned long UL;

using namespace std;


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

	string o, e;
	cin >> o >> e;

	int length = e.size();

	REP(i, length)
	{
		cout << o[i] << e[i];
	}

	if (o.size() - e.size() == 1)
	{
		cout << o[o.size() - 1];
	}

	cout << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int mod = 1e9+7;
int main() {
    fast_cin();
    int n,mx=0;cin>>n;
    string s;
    map<string,int>mp;
    for(ll i=0;i<n;i++) {
        cin>>s;
        mp[s]++;
        if(mp[s]>mx)
        mx=mp[s];
    }
    for(auto i=mp.begin();i!=mp.end();i++)
    {
        if(i->second==mx)
        {
            cout<<i->first<<'\n';
        }
    }
}    

Measured memory_bytes: 23808
#include<stdio.h>
#include<string.h>


int main ()
{
     char x[7];
     int b;
     scanf("%s",x);
     b=strlen(x);
     if(x[2]>=97 && x[2]<=122 && b==6)
     {
         if(x[2]==x[3] && x[4]==x[5])
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
     }


    return 0;


}


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)

#define MOD 1000000007ll

li x, y, z, k;
li a[1111];
li b[1111];
li c[1111];

int main() {
	cin >> x >> y >> z >> k;
	rep(i, x) {
		cin >> a[i];
	}
	sort(a, a + x);
	rep(i, y) {
		cin >> b[i];
	}
	sort(b, b + y);
	rep(i, z) {
		cin >> c[i];
	}
	sort(c, c + z);

	priority_queue<pair<pair<li, li>, pair<li, li>>> pq;
	pq.push({{ a[x - 1] + b[y - 1] + c[z - 1], x - 1}, {y - 1, z - 1}});
	li cnt = 0;
	set<pair<li, pair<li, li>>> visited;
	while (!pq.empty()) {
		li now = pq.top().first.first;
		li ia = pq.top().first.second;
		li ib = pq.top().second.first;
		li ic = pq.top().second.second;
		pq.pop();
		if (visited.count({ia, {ib, ic}}) > 0) {
			continue;
		}
		visited.insert({ia, {ib, ic}});
		cout << now << endl;
		cnt++;
		if (cnt == k) {
			break;
		}
		if (ia > 0) {
			pq.push({{ a[ia - 1] + b[ib] + c[ic], ia - 1}, {ib, ic}});
		}
		if (ib > 0) {
			pq.push({{ a[ia] + b[ib - 1] + c[ic], ia}, {ib - 1, ic}});
		}
		if (ic > 0) {
			pq.push({{ a[ia] + b[ib] + c[ic - 1], ia}, {ib , ic - 1}});
		}
	}

	return 0;
}


Measured memory_bytes: 640
/*input
P?P?
*/ 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<ll,ll>;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define MP make_pair
const ll INF64=4e17;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
const ll maxn=1e6+5;
const ll maxlg=__lg(maxn)+5;
int main(){
    string s;
    cin>>s;
    REP(i,sz(s)){
        if(s[i]=='?') s[i]='D';
    }
    cout<<s;
}

Measured memory_bytes: 3764
#include<stdio.h>

int main(){
   int n;
  long long int k;
  scanf("%d%lld",&n,&k);
 
  long long int num[100001] = {0};
  for(int i = 0; i < n; ++i){
    int a,b;
    scanf("%d%d",&a,&b);
    num[a] += b;
  }
 
  int ans = 0;
  for(int i = 1; i <= 100000; ++i){
    k = k-num[i];
    if( k <= 0 ){
      printf("%d",i);
      return 0;
    }
  }
 
  return 0;
 
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
const LL MOD=1000000007ll;
const LL INF=2000000000ll;

long power(long a,long b){return b?power(a*a%MOD,b/2)*(b%2?a:1)%MOD:1;}
long comb(int N,int K)
{
    long x=1,y=1;
    for(int i=1;i<=K;i++)
    {
        x=x*(N-i+1)%MOD;
        y=y*i%MOD;
    }
    return x*power(y,MOD-2)%MOD;
}

long hcomb(int N, int K){
    return comb(N+K-1, N-1);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    int N, M, t1,t2;
    cin >> N >> M;
    VVI e(N, VI(N,0));
    REP(i,M){
        cin >> t1 >> t2;
        e[t1-1][t2-1] = 1;
        e[t2-1][t1-1] = 1;
    }

    VI order(N-1);
    REP(i,N-1) order[i] = i+1;

    int ans = 0;

    do {
        int cnt = 1;
        if (!e[0][order[0]]) cnt = 0;
        REP(i,N-2){
            if (!e[order[i]][order[i+1]]) cnt = 0;
        }
        if (cnt) ans++;
    } while(next_permutation(ALL(order)));

    cout << ans << endl;
}


Measured memory_bytes: 256
/* ex2_3
   ruuu0048 */
#include <stdio.h>
 
int main(void){
 
    int N,A; //マス目とAを宣言
 
    scanf("%d",&N); //マス目の入力
    scanf("%d",&A); //Aの入力
 
    printf("%d\n",N * N - A); //計算結果を出力
 
    return 0; 
 
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
int main () {
  int N, M;
  cin >> N >> M;
  int min = 0;
  int max = N+1;
  for (int igate = 0; igate < M; igate++) {
    int L, R;
    cin >> L >> R;
    if (L > min) {
      min = L;
    }
    if (R < max) {
      max = R;
    }
  }
  int ncards = max - min + 1;
  if (ncards < 0) {
    ncards = 0;
  }
  cout<<ncards<<endl;
  return 0;
}


Measured memory_bytes: 384
import bisect
primes = [0, 0] + [1] * 49999
for i in range(2, 224):
    if primes[i]:
        for j in range(i*i, 50001, i):
            primes[j] = 0
values = [i for i, k in enumerate(primes) if k]
while True:
    n = int(input())
    if n == 0:
        break
    I = bisect.bisect(values, n//2)
    print(sum(1 for v in values[:I] if primes[n-v]))

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

typedef long long ll;
using namespace std;

int main()
{
    int A, B, C, K, MAX, tmp;
    cin >> A >> B >> C;
    cin >> K;

    MAX = max(A, max(B, C));
    tmp = A + B + C - MAX;

    for (int i = 0; i < K; i++) {
        MAX *= 2;
    }
    cout << MAX + tmp  << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll k;
    cin>>k;
    queue<ll> l;
    rep(1,i,10)l.push(i);
    ll x;
    rep(0,i,k){
        x=l.front();
        l.pop();
        if(x%10!=0){
            l.push(x*10+x%10-1);
        }
        l.push(x*10+x%10);
        if(x%10!=9){
            l.push(x*10+x%10+1);
        }
    }
    cout<<x;
}

Measured memory_bytes: 1792
import sys

n = int(input())
ds = [list(map(int, input().split())) for _ in range(n)]
mod = (ds[0][0] + ds[0][1]) % 2
for i in range(2, n):
	if (ds[i][0] + ds[i][1]) % 2 != mod:
		print(-1)
		sys.exit()

if mod == 1:
	m = 31
	arms = [1<<i for i in range(31, 0, -1)]
else:
	m = 32
	arms = [1<<i for i in range(31, 0, -1)] + [2]

print(m)
print(*[a//2 for a in arms])

for q in range(n):
	x, y = ds[q][0], ds[q][1]
	ans = ""
	u, v = x+y + (1<<31) - 1, x-y + (1<<31) - 1
	if mod == 0:
		u, v = u-1, v-1
	u_li = []
	v_li = []
	for i in range(31, 0, -1):
		if u >= (1<<i):
			u_li.append(1)
			u -= (1<<i)
		else:
			u_li.append(0)
		if v >= (1<<i):
			v_li.append(1)
			v -= (1<<i)
		else:
			v_li.append(0)

	for i in range(31):
		if u_li[i] and v_li[i]:
			ans += "R"
		elif u_li[i]:
			ans += "U"
		elif v_li[i]:
			ans += "D"
		else:
			ans += "L"

	if mod == 0:
		ans += "R"

	print(ans)

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

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {
            String n;

            n = Console.ReadLine();

            if (n[0] == '9' || n[1] == '9')
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
int main(void){
  int x,i;
  long int sum=0;
  scanf("%d",&x);
  int num[x];
  for(i=0;i<x;i++){
    num[i]=i+1;
  }
  for(i=0;i<x;i++){
    if(num[i]%3==0||num[i]%5==0) num[i]=0;
  }
  for(i=0;i<x;i++){
    sum+=num[i];
  }
  printf("%10ld",sum);
  return 0;
}

Measured memory_bytes: 5552
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner *bufio.Scanner

func printIt() {
	dices := make([]int, 6)
	for i := 0; i < 6; i++ {
		dices[i] = nextInt()
	}
	command := []byte(nextString())
	for _, ch := range command {
		if ch == 'S' {
			dices[0], dices[1], dices[5], dices[4] = dices[4], dices[0], dices[1], dices[5]
		}
		if ch == 'N' {
			dices[0], dices[1], dices[5], dices[4] = dices[1], dices[5], dices[4], dices[0]
		}
		if ch == 'W' {
			dices[0], dices[2], dices[5], dices[3] = dices[2], dices[5], dices[3], dices[0]
		}
		if ch == 'E' {
			dices[0], dices[2], dices[5], dices[3] = dices[3], dices[0], dices[2], dices[5]
		}
	}
	fmt.Println(dices[0])
}

func nextInt() int {
	scanner.Scan()
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(1)
	}
	return num
}

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	printIt()
}



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

char la;
string s;
map<string,bool> M;

int main()
{
	int n;
	cin >> n;
	
	cin >> s;
	M[s] = 1;
	la = s[s.size()-1];
	for(int i=2;i<=n;i++)
	{
		cin >> s;
		if(s[0] != la || M[s])
		{
			puts("No");
			return 0;
		}
		la = s[s.size()-1];
		M[s] = 1;
	}
	puts("Yes");
	return 0;
}

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

struct Num{
	vector<bool>potes;
	Num() :potes(256) {
	}
	Num(int l, int r):potes(256) {
		for (int i = l; i <= r; ++i) {
			potes[i] = true;
		}
	}
	Num operator +(const Num& r) {
		Num nnum;
		for (int i = 0; i < 256; ++i) {
			for (int j = 0; j < 256; ++j) {
				if (potes[i] && r.potes[j]) {
					nnum.potes[(i + j)%256] = true;
				}
			}
		}
		return nnum;
	}
	Num operator -(const Num& r) {
		Num nnum;
		for (int i = 0; i < 256; ++i) {
			for (int j = 0; j < 256; ++j) {
				if (potes[i] && r.potes[j]) {
					nnum.potes[(256+ i - j) % 256] = true;
				}
			}
		}
		return nnum;
	}
	Num operator *(const Num& r) {
		Num nnum;
		for (int i = 0; i < 256; ++i) {
			for (int j = 0; j < 256; ++j) {
				if (potes[i] && r.potes[j]) {
					nnum.potes[(i * j) % 256] = true;
				}
			}
		}
		return nnum;
	}
	Num operator /(const Num& r) {
		if (r.potes[0]) {
			throw(0);
		}
		Num nnum;
		for (int i = 0; i < 256; ++i) {
			for (int j = 0; j < 256; ++j) {
				
				if (potes[i] && r.potes[j]) {
					nnum.potes[(i / j) % 256] = true;
				}
			}
		}
		return nnum;
	}
};

map<string, Num>mp;

void input() {
	vector<Num>stack;
	int n; cin >> n;
	for (int i = 0; i < n; ++i) {
		string ch; cin >> ch;

		if (ch == "+"|| ch =="-"|| ch =="*"|| ch =="/") {
			Num b(stack.back());
			stack.pop_back();
			Num a(stack.back());
			stack.pop_back();
			Num next;
			if (ch == "+") {
				next = a+b;
			}
			if (ch == "-") {
				next =a-b;
			}
			if (ch == "*") {
				next =a*b;
			}
			if (ch == "/") {
				next = a/b;
			}
			stack.push_back(next);
		}
		else if (ch[0] >= '0'&&ch[0] <= '9') {
			int chnum = stoi(ch);
			Num anum(chnum, chnum);
			stack.push_back(anum);
		}
		else {
			stack.push_back(mp[ch]);
		}
	}
}

int main() {
	int m; cin >> m;
	for (int i = 0; i < m; ++i) {
		string name; int l, r; cin >> name >> l >> r;
		mp[name] = Num(l, r);
	}
	bool ok = true;
	try {
		input();
	}
	catch (...) {
		ok = false;
	}
	if (ok) {
		cout << "correct" << endl;

	}
	else {
		cout << "error" << endl;
	}
	return 0;
}

Measured memory_bytes: 3240
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(long long int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); vect(A);for(long long i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

int main()
{
	fio;
    string s,t;
    cin>>s>>t;
    cout<<t<<s<<endl;
}

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

int main(){

    int a[3][3];
    bool check[3][3]={false};

    for(int i=0;i<3;i++) for(int j=0;j<3;j++) cin>>a[i][j];

    int n;
    cin>>n;
    vector<int> b(n);
    for(int i=0;i<n;i++){
        cin>>b.at(i);
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(a[j][k]==b.at(i)) check[j][k]=true;
            }
        }
    }


    if(check[0][0]&&check[0][1]&&check[0][2]
    ||check[1][0]&&check[1][1]&&check[1][2]
    ||check[2][0]&&check[2][1]&&check[2][2]
    ||check[0][0]&&check[1][0]&&check[2][0]
    ||check[0][1]&&check[1][1]&&check[1][1]
    ||check[0][2]&&check[1][2]&&check[2][2]
    ||check[0][0]&&check[1][1]&&check[2][2]
    ||check[2][0]&&check[1][1]&&check[0][2]) cout<<"Yes"<<endl;

    else cout<<"No"<<endl;

   






    return 0;
}

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

					using namespace std;
					int main()
					{
                      int n, t = 1;
                      cin >> n;
                      int a[n];
                      for(int i = 1; i <= n; i++)
                        	cin >> a[i];
                      for(int i = 1; i <= n; i++)
                        	if(t == a[i])
                              	t++;
                      if(t == 1)
                        	cout << -1;
                      else
                      		cout << n-t+1;
                    }

Measured memory_bytes: 1024
#include <stdio.h>
int main(int argc, char const *argv[])
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if (a+b==c)
	{
		printf("Yes\n");
	}else if (b+c==a)
	{
		printf("Yes\n");
	}else if (a+c==b)
	{
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[4];
int cnt=0;
int main()
{
	for(int i=1;i<=3;i++)
		scanf("%d",&a[i]);
	int cnt=0;
	int f=1;
	while(f)
	{
		if(a[1]==a[2]&&a[2]==a[3]) break;
		sort(a+1,a+1+3);
		while(a[1]+2<=a[3])a[1]+=2,cnt++;
		if(a[1]==a[2]&&a[2]==a[3]) break;
		while(a[2]+2<=a[3])a[2]+=2,cnt++;
		if(a[1]==a[2]&&a[2]==a[3]) break;
		if(a[2]==a[3]&&a[1]!=a[2]) a[1]+=2,a[2]+=1,a[3]+=1,cnt+=2;\
		if(a[1]==a[2]&&a[2]==a[3]) break;
		if((a[1]+1<=a[3]&&a[2]+1<=a[3]))a[1]+=1,a[2]+=1,cnt++;
	}
	printf("%d",cnt);
}

Measured memory_bytes: 128
import sys
input=sys.stdin.readline
n=int(input())
s_list=[]
for i in range(n):
    s=input().rstrip()
    s=list(s)
    s.sort()
    s_list.append(str(s))
s_list.sort()
pre='X'
count=0
ans=0
for i in s_list:
    if i==pre:
        count+=1
    else:
        ans+=count*(count+1)//2
        count=0
    pre=i
ans+=count*(count+1)//2
print(ans)


Measured memory_bytes: 79452
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element


int N, K;
int A[200010];
vector<int> minus_ary;
vector<int> plus_ary;

int GetCnt(int n)
{
	int cnt = 0;

	if (n < 0)
	{
		int d = 0;
		for (int s = plus_ary.size() - 1; s >= 0; s--)
		{
			while (d < minus_ary.size())
			{
				int a = plus_ary[s] * minus_ary[d];
				if (a <= n)
				{
					break;
				}
				d++;
			}
			cnt += (minus_ary.size() - d);
		}
	}
	else
	{
		cnt += minus_ary.size() * plus_ary.size();

		if (plus_ary.size() > 0)
		{
			int sum = 0;
			int d = 0;
			for (int s = plus_ary.size() - 1; s >= 0; s--)
			{
				while (d < plus_ary.size())
				{
					int a = plus_ary[s] * plus_ary[d];
					if (a > n)
					{
						break;
					}
					d++;
				}
				if (d > s && d > 0)
				{
					d--;
				}
				sum += d;
			}
			cnt += sum / 2;
		}

		if (minus_ary.size() > 0)
		{
			int sum = 0;
			int d = 0;
			for (int s = minus_ary.size() - 1; s >= 0; s--)
			{
				while (d < minus_ary.size())
				{
					int a = minus_ary[s] * minus_ary[d];
					if (a > n)
					{
						break;
					}
					d++;
				}
				if (d > s && d > 0)
				{
					d--;
				}
				sum += d;
			}
			cnt += sum / 2;
		}
	}

	return cnt;
}

//---------- にぶたん[f,f,f,f,'t',t,t,t] ----------
bool isOK(int n)
{
	int cnt = GetCnt(n);
	return cnt >= K;
}

int binary_search(int l, int r)
{
	int left = l;
	int right = r;
	while (right - left > 1)
	{
		int mid = left + (right - left) / 2;
		if (isOK(mid))
			right = mid;
		else
			left = mid;
	}
	return right;
}


signed main()
{
	cin >> N >> K;
	REP(i, N)
	{
		cin >> A[i];
	}

	for (int i = 0; i < N; i++)
	{
		int a = A[i];
		if (a < 0)
		{
			minus_ary.push_back(a);
		}
		else
		{
			plus_ary.push_back(a);
		}
	}
	RSORT(minus_ary);
	SORT(plus_ary);

	int ans = binary_search(-1000000000000000000, 1000000000000000000);
	cout << ans << endl;

	//cout << GetCnt(-13) << endl;
}




Measured memory_bytes: 4084
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e6+5;
const int INF=0x3f3f3f3f3f;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        int ans=INF;
        for(int i=MAXN;i>=1;i--)
        {
            int x=i*0.08;
            int y=i*0.1;
            if(x==a&&y==b)
            {
                ans=i;
            }
        }
        if(ans!=INF)cout<<ans<<endl;
        else cout<<-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N, Min=100, Sum1=0, Sum2=0;
  cin >> N;
  vector<int> W(N);
  rep(i, N) cin >> W[i];
  for(int i=1; i<N; i++){
    rep(j, i) Sum1+=W[j];
    for(int k=i; k<N; k++)Sum2+=W[k];
    if(Min>abs(Sum1-Sum2)) Min=abs(Sum1-Sum2);
    Sum1=0;
    Sum2=0;
  }
  cout << Min << endl;
}

Measured memory_bytes: 256
N = gets.chop.to_i
A = gets.chop.split.map(&:to_i)

colors = {grey: false, brown: false, green: false, water: false, blue: false, yellow: false, orange: false, red: false}
wild = 0

A.each do |i|
  if 1 <= i && i <= 399
    colors[:grey] = true
  elsif 400 <= i && i <= 799
    colors[:brown] = true
  elsif 800 <= i && i <= 1199
    colors[:green] = true
  elsif 1200 <= i && i <= 1599
    colors[:water] = true
  elsif 1600 <= i && i <= 1999
    colors[:blue] = true
  elsif 2000 <= i && i <= 2399
    colors[:yellow] = true
  elsif 2400 <= i && i <= 2799
    colors[:orange] = true
  elsif 2800 <= i && i <= 3199
    colors[:red] = true
  else
		wild += 1
  end
end

color_count = 0
colors.each do |k, v|
  color_count += 1 if v == true
end

min, max = 0, 0

if color_count >= 1
  min = color_count
else
  min = 1
end

max = color_count + wild

puts "#{min} #{max}"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
    const int MAX =200002;
const int MOD =1000000007;
   
     signed main(){
 int d,t,s;
 cin>>d>>t>>s;
 if(d>s*t)cout<<"No"<<endl;
 else cout<<"Yes"<<endl;
 
   }
     


 


 






    





      

        


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

int main() {
  int N;
  cin>>N;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  int64_t G=1000;
  int sta=vec.at(0);
  for(int i=1;i<N-1;i++){
    if(vec.at(i-1)<=vec.at(i)) continue;
    else{
      G+=(G/sta)*(vec.at(i-1)-sta);
      sta=vec.at(i);
    }
  }
  if(vec.at(N-2)<vec.at(N-1)){
    G+=(G/sta)*(vec.at(N-1)-sta);
  }
  else{
    G+=(G/sta)*(vec.at(N-2)-sta);
  }
  cout<<G<<endl;
            
  
  
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

const int MAX_N = 200010;

vector<bool> seen;  // 訪問済みの点
vector<ll> ans(MAX_N, 0);
ll dp[MAX_N];
ll A[MAX_N];

void dfs(const Graph &G, int v) {
    seen[v] = true;
    
    ll i = lower_bound(dp, dp+MAX_N, A[v]) - dp;
    ll old = dp[i];
    dp[i] = A[v];

    ans[v] = lower_bound(dp, dp+MAX_N, INF) - dp - 1;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v); // 再帰的に値を追加していく
    }
    dp[i] = old;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    REP(i, N){
        cin >> A[i];
    }

    // グラフ
    Graph G(N);

    REP(i, MAX_N){
        dp[i] = INF;
    }
    seen.assign(N, false);

    REP(i, N-1){
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    dfs(G, 0);

    REP(i, N){
        cout << ans[i] + 1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 33320
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

//=============modpow============================
ll modpow(ll a, ll n, ll mod)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//=================================================


int main()
{
  ll mod = 2019;
  string S;
  cin >> S;
  ll N = S.size();
  vector<ll> remain(2019, 0);
  ll temp = 0;
  for (ll i = N - 1; i >= 0; --i) {
    temp += modpow(10, N - i - 1, mod) * (S[i] - '0');
    temp %= 2019;
    // cout << temp << endl;
    remain.at(temp) += 1;
  }
  ll ans = 0;
  for (ll i = 0; i < 2019; ++i) {
    ans += remain.at(i) * (remain.at(i) - 1) / 2;
  }
  ans += remain.at(0);
  cout << ans << endl;
}


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

int main(){
  char grid[100][100],newgrid[100][100],masu[100][100];
  int n,m,c=0,array[100]={},array2[100]={},d=0;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin>>grid[i][j];
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(grid[i][j]=='#'){
        for(int k=0;k<m;k++){
          newgrid[i-c][k]=grid[i][k];
        }
        break;
      }
      c+=(j==m-1);
    }
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<n-c;j++){
      if(newgrid[j][i]=='#'){
        for(int k=0;k<n-c;k++){
          masu[k][i-d]=newgrid[k][i];
      }
        break;
      }
      d+=(j==n-c-1);
    }
  }
  for(int i=0;i<n-c;i++){
    for(int j=0;j<m-d;j++){
      cout<<masu[i][j];
      if(j==m-d-1){
        cout<<endl;
      }
    }
  }
}

Measured memory_bytes: 256
object Main extends App {
	// your code goes here
	import scala.io.StdIn.readLine
	while(true) {
		val n = readLine().toInt
		if (n == 0) System.exit(0)
		val list = readLine().split(" ").map(_.toInt)
		println(list.sorted.sliding(2).map{case Array(_1, _2) => _2 - _1}.min)
	}
}



Measured memory_bytes: 79256
S = input()
if 1 <= int(S[:2]) <= 12 and 1 <= int(S[2:]) <= 12:
  print("AMBIGUOUS")
elif 1 <= int(S[:2]) <= 12:
  print("MMYY")
elif 1 <= int(S[2:]) <= 12:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 3060
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define fir first
#define sec second
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define maxd 1000000007
#define eps 1e-6
typedef long long ll;
const int N=100000;
const double pi=acos(-1.0);
int n,m,k,nx,ny,x,y;
char s[200200],t[200200];

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

int main()
{
	n=read();m=read();k=read();
	x=read(),y=read();
	scanf("%s%s",s+1,t+1);
	int nd=n,nu=1,nl=1,nr=m;
	per(i,k,1)
	{
		if (t[i]=='U') nd=min(nd+1,n);
		else if (t[i]=='D') nu=max(nu-1,1);
		else if (t[i]=='L') nr=min(nr+1,m);
		else if (t[i]=='R') nl=max(nl-1,1);
		if (s[i]=='U') nu++;
		else if (s[i]=='D') nd--;
		else if (s[i]=='L') nl++;
		else if (s[i]=='R') nr--;
		if ((nu>nd) || (nl>nr)) {puts("NO");return 0;}
	}
	if ((x>nd) || (x<nu) || (y<nl) || (y>nr)) puts("NO");
	else puts("YES");
	return 0;
}


Measured memory_bytes: 764
s_list = list(map(int,list(input())))

def check(start,s_list):
    cnt = 0
    for s in s_list:
        if start != s:
            cnt += 1
        if start == 0:
            start = 1
        else:
            start = 0
    return cnt

print(min(check(0,s_list),check(1,s_list)))

Measured memory_bytes: 49520
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define Little 1
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,w=0,n=0,m=0,o=0;
  std::cin >> x>>y;
  rep(i,x+1){
    if((x-i)*2+i*4==y){
      std::cout << "Yes" << '\n';
      return 0;
    }
  }
  std::cout << "No" << '\n';
}


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

int main() {
  int N,A;
  cin >> N >> A;
  int R;
  R = N % 500;
  if (A >= R) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  } 
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);       
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int[] a = new int[m];
		int[] b = new int[n+1];
		for(int i=0; i<m; i++) {
		    a[i] = Integer.parseInt(sc.next());
		    b[a[i]] = 1;
		}
		int[] dp = new int[n+1];
		dp[0] = 1;
		if(b[1] == 1) dp[1] = 0;
		else dp[1] = 1;
		if(n > 1) {
		    for(int i=2; i<n+1; i++) {
		        if(b[i] == 1) dp[i] = 0;
		        else dp[i] = (dp[i-1]+dp[i-2]) % 1000000007;
		    }
		}else {
		    dp[1] = 1;
		}
		System.out.println(dp[n]);
	}
}

Measured memory_bytes: 46060
#include <stdio.h>
#include <string.h>

int main (){
	int k;
	char str[160];
	
	scanf("%d", &k);
	scanf("%s", str);
	getchar();
	
	int len = strlen(str);
	if (len <= k){
		printf("%s\n", str);
	}
	else{
		for (int i = 0; i < k; i++){
			printf("%c", str[i]);
		}
		puts("...");
	}
	return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
int main(){
	int i,j,N;
	int A[100];
	int v;
	
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	for(j=0;j<N;j++){
		printf("%d",A[j]);
		if(j!=N-1)printf(" ");
	}
	printf("\n");
	for(i=1;i<N;i++){
		v=A[i];
		j=i-1;
		while(j>=0&&A[j]>v){
			A[j+1]=A[j];
			j--;
		}
		A[j+1]=v;
		
		for(j=0;j<N;j++){
			printf("%d",A[j]);
			if(j!=N-1)printf(" ");
		}
		printf("\n");
	}
	return 0;
}




Measured memory_bytes: 1848
#include <bits/stdc++.h> 
using namespace std; 
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI1 3.14159265358979311599796346854418516159057617187500

typedef long long int ll;

int main() 
{ 
    FIO
    ll t;
    t=1;

    while(t--)
    {
        long double r;
        cin >> r;

        long double ans = (2.0)*PI1*r;


        cout << setprecision(19) << ans << '\n';

    }
    return 0; 
} 


Measured memory_bytes: 3804
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <list>
#include <set>
#include <map>
#define F first
#define S second
#define pb push_back
#define PI 3.14159265
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m, ans = 0, sum = 0;
    cin >> n >> m;
    vll a(n);
    map<ll, ll> M;
    fr(i, 0, n)
    {
        cin >> a[i];
    }
    fr(i, 0, n)
    {
        sum = (sum + a[i]) % m;
        if (sum == 0)
        {
            ans++;
        }
        if (M.find(sum) != M.end())
        {
            ans += M.find(sum)->S;
        }
        M[sum]++;
    }
    cout << ans << "\n";
    return 0;
}

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

int main() {
    int a, b, c, x; // 500, 100, 50, goal
    cin >> a >> b >> c >> x;
    int ans = 0, tmp;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                tmp = i * 500 + j * 100 + k * 50;
                if (tmp == x) ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/*********বিসমিল্লাহির রাহমানির রাহিম**********/

#include <bits/stdc++.h>
#define ll long long
#define PI 2 * acos(0)
#define FAST ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define MAX 200000
#define MOD 1e7
#define all(x) (x).begin(), (x).end()
using namespace std;
/*................OMI.................*/

vector<ll> prime;
bool isPrime(ll n)
{
   if (n <= 1)
      return false;
   if (n <= 3)
      return true;

   if (n % 2 == 0 || n % 3 == 0)
      return false;

   for (ll i = 5; i * i <= n; i = i + 2)
      if (n % i == 0)
         return false;

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

ll lcm(ll a, ll b)
{
   ll g = gcd(a, b);
   ll ans = (a * b) / g;
   return ans;
}
void primes(ll m)
{
   bool isprime[m];

   for (int i = 0; i <= m; i++)
      isprime[i] = true;

   for (int i = 3; i * i <= m; i++)
   {
      if (isprime[i])
      {

         for (int j = i * i; j <= m; j += i)
            isprime[j] = false;
      }
   }
   prime.push_back(2);
   for (int i = 3; i <= m; i += 2)
      if (isprime[i])
         prime.push_back(i);
}

/************MAIN_FUNCTION***********/

int main(int argc, char *argv[])
{

   FAST;
   int n;
   cin >> n;
   int ara[n+10]={0};
   int number;
   for (int i = 0; i < n-1; i++)
   {
      cin >> number;
      ara[number]++;
   }

   for (int i = 1; i <=n; i++)
      cout << ara[i] <<endl;
   
}

Measured memory_bytes: 4400
import sys
input = lambda: sys.stdin.readline().rstrip()
from heapq import heapify, heappush as hpush, heappop as hpop
H, W, K = map(int, input().split())
x1, y1, x2, y2 = map(int, input().split())
X = [1] * (W + 2)
for _ in range(H):
    X += [1] + [1 if a == "@" else 0 for a in input()] + [1]
X += [1] * (W + 2)
X += X[:]
H, W = H+2, W+2
HW = H * W
s, t = x1 * W + y1, x2 * W + y2
ss, tt = s + HW, t + HW
def dijkstra():
    n = 2 * H * W
    h = [s, ss]
    D = [-1] * n
    done = [0] * n
    D[s] = 0
    D[ss] = 0
    kk = 21
    m = (1 << kk) - 1
    while h:
        x = hpop(h)
        d, i = x >> kk, x & m
        done[i] = 1
        if i < HW:
            for j in (i+1, i-1):
                nd = d + 1
                if X[j]: continue
                if D[j] < 0 or D[j] > nd:
                    if done[j] == 0:
                        hpush(h, (nd << kk) + j)
                        D[j] = nd
        else:
            for j in (i+W, i-W):
                nd = d + 1
                if X[j]: continue
                if D[j] < 0 or D[j] > nd:
                    if done[j] == 0:
                        hpush(h, (nd << kk) + j)
                        D[j] = nd
            
        j = i + HW if i < HW else i - HW
        nd = (d + K - 1) // K * K
        if X[j]: continue
        if D[j] < 0 or D[j] > nd:
            if done[j] == 0:
                hpush(h, (nd << kk) + j)
                D[j] = nd
    return [-(-a//K) for a in (D[t], D[tt]) if a >= 0]

di = dijkstra()
print(min(di) if di else -1)

Measured memory_bytes: 217536
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (int)(s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
constexpr long long INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}

template<class T>
class SegmentTree{
	private:
	int N;
	T initVal;
	std::vector<T>ary;
	std::function<T(T&,T&)>merge;
	void init(int n){
		while(N < n)N <<= 1;
		ary.resize(N << 1,initVal);
	}
	public:
		SegmentTree(int n,T initVal,std::function<T(T&,T&)>f):
			N(1),initVal(initVal),merge(f){init(n);}
	// -- a[i] = val;
	inline void update(int i,T val){
		ary[i += N] = val;
		while(i > 1){
			i >>= 1;
			ary[i] = merge(ary[i << 1],ary[(i << 1) + 1]);
		}
	}
	// -- a[i] += val;
	inline void add(int i,T val){
		update(i,ary[i + N] + val);
	}
	// -- [l,r)
	inline T query(int l,int r){
		if(l >= r)return initVal;
		T vr = initVal,vl = initVal;
		for(l += N,r += N;l != r;l >>= 1,r >>= 1){
			if(l & 1)vl = merge(vl,ary[l++]);
			if(r & 1)vr = merge(vr,ary[--r]);
		}
		return merge(vl,vr);
	}
};

signed main(){
	int N;
	cin >> N;
	vector<int>a(N);
	vector<pair<int,int>>ans;
	REP(i,N)cin >> a[i];
	auto odd = SegmentTree<pair<int,int>>(N,{INF,INF},[&](pair<int,int> a,pair<int,int> b){return min(a,b);});
	auto even = SegmentTree<pair<int,int>>(N,{INF,INF},[&](pair<int,int> a,pair<int,int> b){return min(a,b);});
	REP(i,N){
		if(i&1)odd.update(i,{a[i],i});
		else even.update(i,{a[i],i});
	}
	priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>>que;
	que.push({-INF,{0,N}});
	auto f = [&](int l,int r)->pair<int,pair<int,int>>{
		if(l & 1)return {odd.query(l,r).first,{l,r}};
		else return {even.query(l,r).first,{l,r}};
	};
	while(!que.empty()){
		auto q = que.top();
		que.pop();
		int l = q.second.first,r = q.second.second;
		if(r - l < 2)continue;
		if(l & 1){
			auto lid = odd.query(l,r);
			odd.update(lid.second,{INF,INF});
			auto rid = even.query(lid.second,r);
			even.update(rid.second,{INF,INF});
			ans.push_back({lid.first,rid.first});
			que.push(f(l,lid.second));
			que.push(f(lid.second+1,rid.second));
			que.push(f(rid.second+1,r));
		}else{
			auto lid = even.query(l,r);
			even.update(lid.second,{INF,INF});
			auto rid = odd.query(lid.second,r);
			odd.update(rid.second,{INF,INF});
			ans.push_back({lid.first,rid.first});
			que.push(f(l,lid.second));
			que.push(f(lid.second+1,rid.second));
			que.push(f(rid.second+1,r));
		}
	}
	for(auto e:ans){
		cout << e.first << " " << e.second << " ";
	}
	cout << endl;
}


Measured memory_bytes: 29484
#include<iostream>

using namespace std;
int main(){
	int x;
	cin >> x;
	for(int i=0; i<x; i++){
		int y,m,d,ans=0;
		cin>>y>>m>>d;
		int big = 333 - y/3;
		int small = 999 - y - big;
		//cout << big << " " << small << endl;
		ans += big*200+small*(20+19)*5;
		if(y%3==0){
			ans+=(20-d+1)+(10-m)*20;
		}else{
			int smallm = 10/2 - m/2;
			int bigm = 10 - m - smallm;
			//cout << bigm << " " << smallm << endl;
			ans+=bigm*20+smallm*19 + (m%2==0 ? 19 : 20) - d+1;
			
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 0