akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int main(){
    nimble
    ll a,b,n;
    cin>>a>>b>>n;
    ll id=b-1;
    if(n>=b-1){
        n=b-1;
    }
    ll mx=(a*n/b)-a*(n/b);
    cout<<mx<<nl;
    return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        String S = sc.next();
        int cnt = 0;

        for (int i = 0; i < N - 2; i++) {
            if (S.substring(i, i + 3).equals("ABC")) {
                cnt++;
            }
        }

        System.out.println(cnt);
    }
}


Measured memory_bytes: 21844
import sys
input = sys.stdin.readline
N,M = map(int,input().split())
#低いやつを引いていく感じ
Hlist = list(int(x) for x in input().split())

flag = [1]*N

for i in range(M):
    A,B = map(int, input().split())
    A -= 1
    B -= 1
    if(Hlist[A] == Hlist[B]) :
        flag[A] = 0
        flag[B] = 0
    elif(Hlist[A] > Hlist[B]) :
        flag[B] = 0
    else:
        flag[A] = 0
print(sum(flag))


Measured memory_bytes: 20336
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	int n=s.size();
	int ret=0;
	for (int i=0; i<n/2; i++)
		if(s[i]!=s[n-1-i])
			ret++;
	cout<<ret<<"\n";
	return 0;
}

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

#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int mainD()
{
	string str1, str2;
	cin >> str1 >> str2;
	int n = stoi(str1);
	int m = stoi(str2);

	vector<vector<int> > pays(m+1);

	for (int i = 0; i < n; ++i)
	{
		cin >> str1 >> str2;
		int a = stoi(str1);
		int b = stoi(str2);
		if(a <= m)
			pays[a].push_back(b);
	}
	for (auto& x : pays)
		sort(x.begin(), x.end());

	int total = 0;
	multiset<int> paySet;
	for (int i = 1; i <= m; ++i)
	{
		paySet.insert(pays[i].begin(), pays[i].end());
		if (!paySet.empty())
		{
			total += *paySet.rbegin();
			paySet.erase(--paySet.end());
		}
	}
	cout << total << endl;
	return 0;

}

int main()
{
	return mainD();
}

Measured memory_bytes: 7808
#include <iostream>

#include <string>

using namespace std;

int main()

{

	long long n;	cin >> n;

	string s = "", s1 = "z";

	for (char i = 'a'; i < 'z'; i++)

		s1 += i;

	if (n == 26)

		cout << 'z';

	else if (n < 26)

		cout << s1[n];

	else

	{

		while (n > 0)

		{

			int k = (n % 26);

			s += s1[k];

			n--;

			n = (n / 26);

		}

		for (int i = s.size() - 1; i >= 0; i--)

			cout << s[i];

	}

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    // Your code here!
    // int n;
    // cin >> n;
    int a,b;
    cin >> a >> b;
    if(a > b) cout << "safe" << endl;
    else if(a <= b) cout << "unsafe" << endl;
    return 0;
}


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

using namespace std;

int main(){
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  long long ans = 0;
  int maxr = N / R;
  int maxg = N / G;
  //int maxb = N / B;
  for(int r=0; r <= maxr; r++){
    for(int g=0; g <= maxg; g++){
      if((N - r*R - g*G) >= 0 && (N - r*R - g*G) % B == 0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {

int A,B,C;  cin>>A>>B>>C;
  vector<int> mB(B+1);

  for(int i=1;i<=B;i++){
    mB.at(i)=(A*i)%B;}
  
  for(int i=0; i<B;i++){
    if(mB.at(i)==C){cout<<"YES"<<endl;break;}
  if(i==B-1){cout<<"NO"<<endl;}}
}



Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		String result = "No";
		int n = 0;
		for(int i = 0; i < s.length(); i++){
		    n += s.charAt(i) - '0';
		}
		if(Integer.valueOf(s)%n == 0) result = "Yes";
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  vector<int> MY(3);
  for (int i=0; i<3;i++){
    cin >> MY.at(i);
  }
  sort(MY.begin(), MY.end());
  cout << MY.at(2)*10+MY.at(1)+MY.at(0) << endl;
  return 0;
}

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

int main(){
  string S;
  cin >> S;
  if(S=="Sunny") cout << "Cloudy" << endl;
  else if(S=="Cloudy") cout << "Rainy" << endl;
  else if(S=="Rainy") cout << "Sunny" << endl;
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
# 0.5考慮のため*2、終了時0のため番兵
A = [a*2 for a in LIST()] + [1]
B = [b*2 for b in LIST()] + [0]

def check1(i, t):
    nxtt = cur
    for j in range(i+1, N+1):
        nxtt += A[j-1]
        dist = nxtt - t
        # 1つ先で+1の状態でいても大丈夫かどうか
        if spd + 2 - dist > B[j]:
            return False
    return True

def check2(i, t):
    nxtt = cur
    for j in range(i+1, N+1):
        nxtt += A[j-1]
        dist = nxtt - t
        # 1つ先で今と同じ(+-0)の状態でいても大丈夫かどうか
        if spd + 1 - dist > B[j]:
            return False
    return True

cur = spd = sm = 0
for i, a in enumerate(A[:N]):
    b = B[i]
    # 各時点tにおいて加速、維持が可能かどうか確認
    for t in range(cur, cur+a):
        # 加速OK
        if spd + 1 <= b and check1(i, t):
            # この瞬間の加算分は増減の半分にする
            sm += spd + 0.5
            spd += 1
        # 維持OK
        elif spd <= b and check2(i, t):
            sm += spd
        # 減速必須
        else:
            sm += spd - 0.5
            spd -= 1
    cur += a
print(sm / 4)


Measured memory_bytes: 3188
using System;

namespace AC_Pra6
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            string s = Console.ReadLine();
            if (a >= 3200)
            {
                Console.Write(s);
            }
            else
            {
                Console.Write("red");
            }
        }
    }
}

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


int N;
long long res = 0;
string S;

void dfs(int depth, bool A[]){
	if(depth == N-1){
		long long tmp = 0;
		for(int i=0; i<(N-1); i++){
			if(A[i]==true){
				tmp += S[i] - '0';
				tmp *= 10;
			}
			else{
				tmp += S[i] - '0';
				res += tmp;
				tmp = 0;
			}
		}
		res += tmp;
		res += S[N-1] - '0';
	}
	if(depth != N-1){
		A[depth]=true;
		dfs(depth+1,A);
	}
	if(depth != N-1){
		A[depth]=false;
		dfs(depth+1,A);
	}
}


int main(){
	cin >> S;
	N = S.size();
	bool array[N-1];
	dfs(0,array);

	cout << res << endl;
	return 0;
}

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

int main()
{
	int a,b,r;
	string op;
	while (1) {
		cin >> a >> op >> b;
		if (op == "?")
			break;
		else {
			if (op == "+") {
				r = a + b;
			}
			else if (op == "-") {
				r = a - b;
			}
			else if (op == "*") {
				r = a * b;
			}
			else if (op == "/") {
				r = a / b;
			}
			cout << r << endl;
		}

	}

	return 0;
}



Measured memory_bytes: 3124
import math
import sys
sys.setrecursionlimit(1000000)
N = int(input())
graph = {}
SCORE = 0
def dfs(visited,v,depth):
    visited[v] = depth
    for next_v in graph[v]:
        if  visited[next_v]  == -1 :
            dfs(visited,next_v,depth + 1)




for _ in range(N-1):
    a,b = map(int,input().split())
    if a not in graph:
        graph[a] = [b]
    else:
        graph[a].append(b)

    if b not in graph:
        graph[b] = [a]
    else:
        graph[b].append(a)

vF = [-1] * (N + 1)
vF[1] = 0
dfs(vF,1,0)
# print(vF)

vS = [-1] * (N + 1)
vS[N] = 0

dfs(vS,N,0)
# print(vS)

fc = 0
sc = 0

for f,s in zip(vF[1:N + 1],vS[1:N + 1]):
    if f <= s:
        fc += 1
    else:
        sc += 1

# print(fc,sc)
if fc > sc:
    print("Fennec")
else:
    print("Snuke")


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

int main() {
  long long H;
  int N;
  cin >> H >> N;
  vector<int>A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += A.at(i);
  }
  if (sum >= H) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            decimal dSum = 0;
            for (int i = 0; i < iN; i++)
            {
                sS = System.Console.ReadLine().Trim().Split(' ');
                decimal dV = decimal.Parse(sS[0]);
                if (sS[1] == "JPY") { dSum += dV; }
                else { dSum += dV * 380000; }
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            // 出力
            System.Console.WriteLine("{0}", dSum.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
<?php
/*
    URL    : http://kupc2016.contest.atcoder.jp/tasks/kupc2016_a

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

$ans = 0;

fscanf(STDIN, "%d %d %d", $N, $A, $B);
for ($i = 0; $i < $N; $i++) {
	fscanf(STDIN, "%d", $t);
	if ($t < $A || $t >= $B) {
		$ans++;
	} 
	// echo $t . " " . $A . " " . $B . " " . $ans . PHP_EOL;
}

echo $ans . PHP_EOL;

Measured memory_bytes: 3704
n = int(input())
h = list(map(int, input().split()))
h.append(10**10)

now = 0
count = 0
temp = 0

for i in h:
        if i > now:
                count = max(count, temp)
                temp = 0
                now = i
        else:
                now = i
                temp += 1
              
print(count)

Measured memory_bytes: 14252
#include<stdio.h>
long long int dp[100][21];
int main(void)
{
	int i,j,n,suu[101];
	scanf("%d",&n);
	for(i=0;i<=n;i++){
		for(j=0;j<=20;j++) dp[i][j]=0;
	}
	for(i=1;i<=n;i++) scanf("%d",&suu[i]);
	dp[2][suu[1]]=1;
	for(i=2;i<n;i++){
		for(j=0;j<=20;j++){
			if(dp[i][j]!=0){
				if(j+suu[i]<=20) dp[i+1][j+suu[i]]+=dp[i][j];
				if(j-suu[i]>=0) dp[i+1][j-suu[i]]+=dp[i][j];
			}
		}
	}
	printf("%lld\n",dp[n][suu[n]]);
	return 0;
}

Measured memory_bytes: 616
;; -*- coding:utf-8 -*-

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 1))
    #-swank '(optimize (speed 3) (safety 0) (debug 0))))

(defmacro print-line (obj &optional (stream '*standard-output*))
  `(prog1 (princ ,obj ,stream) (terpri ,stream)))


;; Hauptteil

(declaim (inline dict<))
(defun dict< (str1 str2)
  (declare #.OPT
           (string str1 str2))
  (let* ((len1 (length str1))
         (len2 (length str2))
         (len (min len1 len2)))
    (loop for i below len
          for c1 = (aref str1 i)
          for c2 = (aref str2 i)
          do (cond ((char< c1 c2) (return t))
                   ((char> c1 c2) (return nil)))
          finally (return (if (< len1 len2) t nil)))))

(declaim (inline enum-words))
(defun enum-words (source)
  (declare #.OPT
           (string source))
  (let ((len (length source))
        res)
    (dotimes (idx1 len res)
      (loop for width from 1 to 5
            while (<= (+ idx1 width) len)
            do (push (make-array width
                                 :element-type 'character
                                 :displaced-to source
                                 :displaced-index-offset idx1)
                     res)))))

(defun get-min (tmp-min lst)
  (cond ((null lst) tmp-min)
        ((dict< (car lst) tmp-min) (get-min (car lst) (cdr lst)))
        (t (get-min tmp-min (cdr lst)))))

(defun get-nth-min (n lst)
  (let ((min (get-min (car lst) lst)))
    (if (= n 1)
        min
        (get-nth-min (- n 1)
                     (delete min lst :test #'string=)))))

(deftype uint nil `(integer 0 ,(expt 10 9)))
(defun main ()
  (declare #.OPT)
  (let ((str (coerce (read-line) 'string))
        (n (read)))
    (write-line (get-nth-min n (enum-words str)))))

#-swank(main)


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

int main() {
    // prepare variables
    int multiplier, lb, ub;
    cin >> multiplier >> lb >> ub;
    bool is_achievable = false;

    // determines search upper boundary
    int ub_search = lb + multiplier - 1;
    ub_search = ub < ub_search ? ub : ub_search;
    for(int i = lb; i <= ub_search; ++i) {
        int mod = i%multiplier;
        if(mod == 0){
            is_achievable = true;
            break;
        }
    }

    if(is_achievable)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int[] dp=new int[100001];
        dp[0]=0;
        int n=scan.nextInt();
        int i=1;
        int num=0;
        int[] element=new int[100];
        while(i*9<=n){
            i*=9;
            element[num]=i;
            num++;
        }
        i=1;
        while(i*6<=n){
            i*=6;
            element[num]=i;
            num++;
        }
        int flag=0;
        for(int k=1;k<=n;k++){
            dp[k]=100000;
            flag=0;
            for(int l=0;l<num;l++){
                if((k-element[l])>=0){
                    int box=Math.min(dp[k-1],dp[k-element[l]])+1;
                    dp[k]=Math.min(dp[k],box);
                    flag++;
                }
            }
            if(flag==0) dp[k]=dp[k-1]+1;
        }
        System.out.println(dp[n]);
    }
}

Measured memory_bytes: 23764
import sys, heapq
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

def kruskal(es, V):
    es.sort(key=lambda x:x[2])
    uf = UnionFind(V)
    res = 0
    for e in es:
        if not uf.same(e[0], e[1]):
            uf.union(e[0], e[1])
            res += e[2]
    return res

def resolve():
    V, E = LI()
    es = [[[]] for _ in range(E)]
    for i in range(E):
        s, t, w = LI()
        es[i] = [s, t, w]

    print(kruskal(es, V))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 32244
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int dp[10][10];
//vector<vector<int>> dp(10, vector<int>(10));

int main() {
  int N;
  cin >> N;
  ll ans = 0;
  rep(i, 10) rep(j, 10) dp[i][j] = 0;
  for (int i = 1; i < N+1; i++) {
    int back = i % 10;
    int j = i;
    while (j >= 10) {
      j /= 10;
    }
    int top = j;
    dp[top][back]++;
  }
  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      ans += dp[i][j] * dp[j][i];
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3620
n = gets.to_i
abc = n.times.map { gets.split.map(&:to_i) }

dp = Array.new(n) { Array.new(3) { 0 }}

dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]

1.upto(n - 1) do |i|
  dp[i][0] = [dp[i - 1][1], dp[i - 1][2]].max + abc[i][0]
  dp[i][1] = [dp[i - 1][0], dp[i - 1][2]].max + abc[i][1]
  dp[i][2] = [dp[i - 1][1], dp[i - 1][0]].max + abc[i][2]
end

puts [dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]].max


Measured memory_bytes: 16124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
#define FRO freopen("in.txt","r",stdin);


int main()
{
        ios::sync_with_stdio(0);
        cin.tie(0);
        int a,b,c;
        cin>>a>>b>>c;
        if(min(a,b)<c && c<max(a,b)) cout<<"Yes";
        else cout<<"No";


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#define ll long long int

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    int N; cin>>N;
    set<int> st;
    for(int i = 0; i < N; i++){
        int a; cin>>a;
        if(st.count(a) == 0) st.insert(a);
        else st.erase(a);
    }
    cout<<st.size()<<endl;
    return 0;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int r = sc.nextInt();
		int s = sc.nextInt();
		int p = sc.nextInt();
		char[] t = sc.next().toCharArray();
		sc.close();

		boolean[] win = new boolean[n];
		int ans = 0;
		for (int i = 0; i < n; i++) {
			if (i >= k && t[i - k] == t[i] && win[i - k]) {
				continue;
			}
			if (t[i] == 'r') {
				ans += p;
			}
			if (t[i] == 's') {
				ans += r;
			}
			if (t[i] == 'p') {
				ans += s;
			}
			win[i] = true;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 28116
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if ((a==5 && b==5 && c == 7) || (a==5 && b==7 && c == 5) || (a==7 && b==5 && c == 5)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
        

    }
}


Measured memory_bytes: 21584
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<ll>>;
#define MAX 1000000007

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

    vector<int> w(N+1);vector<ll> v(N+1);

    rep(i,N)cin >> w[i+1] >> v[i+1];
    Graf dp(N+1,vector<ll>(W+1));
    rep(i,W+1){
        dp[0][i]=0;
    }
    rep(i,N+1){
        dp[i][0]=0;
    }
    for(int i=1;i<=N;++i){
        for(int j=1;j<=W;++j){
            if(w[i]<=j){
                dp[i][j]=max(dp[i-1][j-w[i]]+v[i],dp[i-1][j]);
            }else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout << dp[N][W] << endl;


}

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

typedef long long ll;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> Fib(n+1,1);
    for(i = 2;i <= n;++i){
        Fib.at(i) = Fib.at(i-1) + Fib.at(i-2);
    }
    cout << Fib.at(n) << endl;

    return 0;
}


Measured memory_bytes: 3104
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    
    class Solve
    {
        const int mod = 1000000007;
        static long ans;
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            //var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];
            List<List<int>> G = new List<List<int>>();
            bool[] seen = new bool[N];
            for(var i = 0; i < N; i++)
            {
                G.Add(new List<int>());
                seen[i] = false;
            }

            for(var i = 0; i < M; i++)
            {
                var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
                G[ab[0] - 1].Add(ab[1] - 1);
                G[ab[1] - 1].Add(ab[0] - 1);
            }
            



           
            seen[0] = true;
            var g = new Solve();
            g.Dfs(G, seen, 0);

            Console.WriteLine(ans);

           
            

            //Console.Out.Flush();

        }

        public void Dfs(List<List<int>> G, bool[] seen, int cv)
        {
            
            bool all = true;
            for (var i = 0; i < seen.Length; i++)
            {
                if (seen[i] == false) { all = false; }
                
            }
            if (all) { ans++; }
            



            foreach (var nextv in G[cv])
            {
                if (seen[nextv]) { continue; }
                seen[nextv] = true;
                Dfs(G, seen, nextv);

                seen[nextv] = false;
            }

        }
    }

    

    public class Calculation
    {

    }

    public class Graph
    {
        
    }
}




Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
ll gcd(ll x, ll y) {
    if (x < y) swap(x, y);
    if (y == 0) return x;
    return gcd(x % y, y);
}
ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}
int main() {
    ll x;
    cin >> x;
    cout << lcm(360, x) / x << endl;
}

Measured memory_bytes: 3632
import collections as c
ip = lambda : map(int, input().split())
# ##############
mod = 1e9+7
N, X = ip()
L = list(map(int,input().split()))
d = 0
ans = 1
for i in range(N):
    d += L[i]
    if d <= X:
        ans+=1
    else:
        break
print(ans)

Measured memory_bytes: 3444
#include <stdio.h>
#include <math.h>
#define MIN(x,y) (x)<(y)?(x):(y)
#define MAX(x,y) (x)>(y)?(x):(y)

int main(void) {
	int min;
	long n,b;
	
	scanf("%lld",&n);
	
	min = log10(n)+1;
	for (long a = 1;a*a <= n;a++) {
		if (!(n % a)) {
			b = n/a;
			min = MIN(min,MAX((int) log10(a)+1,(int) log10(b)+1));
		}
	}
	printf("%d\n",min);
	
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	int n;
	n = 0;
	
	scanf("%d %d %d", &a, &b, &c);
	for(;a <= b;a++){
		if(c%a == 0){
			n++;
		}
	}
	printf("%d\n", n);
	
	return (0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(all(a));
  int ans=a[n-1]-a[0];
  cout<<ans<<endl;
  return 0;
}


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

int main(){
    int d, g; cin >> d >> g;
    vector <pair<int, int>> p_c(d);
    vector <int> turn(d);
    rep(i, d){
        int p, c; cin >> p >> c;
        p_c.at(i) = make_pair(p, c);
        turn.at(i) = i;
    }

    ll ans = 1000000000;
    do{
        ll cnt = 0;
        int _g = g;
        rep(i, d){
            int now = turn.at(i);
            int now_one_point = (now + 1) * 100;
            ll now_all_point = p_c.at(now).first * now_one_point;
            if(now_all_point > _g){
                cnt += (_g + now_one_point - 1) / now_one_point;
                _g = 0;
            }
            else{
                cnt += p_c.at(now).first;
                _g -= now_all_point + p_c.at(now).second;
            }
            if(_g <= 0) break;
        }
        ans = min(ans, cnt);
    }while(next_permutation(turn.begin(), turn.end()));

    cout << ans << endl;

}

Measured memory_bytes: 3636
n = int(input())
a = list(map(int, input().split()))
a.append(0)

ans = 0
c = a[0]
cnt = 1
for i in range(1, n + 1):
    if a[i] != c:
        ans += cnt // 2
        c = a[i]
        cnt = 1
    else:
        cnt += 1

print(ans)


Measured memory_bytes: 3060
'use strict'

function main(s) {

  s = s.split('\n').slice(0, -1);

  const a = s[0];
  const b = s[1];

  let ans = 'EQUAL';

  if (a.length > b.length) {
    ans = 'GREATER';
  } else if (a.length < b.length) {
    ans = 'LESS';
  } else {
    for (let i = 0; i < a.length; i++) {
      const na = Number(a.charAt(i));
      const nb = Number(b.charAt(i));
      if (na > nb) {
        ans = 'GREATER';
        break;
      } else if (na < nb) {
        ans = 'LESS'
        break;
      } else {
        continue;
      }
    }
  }

  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'



signed main() {
    fio();
    
    int n;
    cin >> n;
    vl a(n);
    rep (i, n) cin >> a[i];

    ll x = 0;
    for (int i = 2; i < n; i++) x ^= a[i];

    if (((a[0] % 2) ^ (a[1] % 2) ^ (x % 2)) == 1) {
        cout << -1 << endl;
        return 0;
    }

    ll now = 0;
    while (a[0] > 0) {
        if ((a[0] ^ a[1] ^ x) == 0) {
            cout << now << endl;
            return 0;
        }
        if (a[0] == 1) break;

        ll mask = 1LL << 50;
        while (true) {
            ll b0 = a[0] & mask, b1 = a[1] & mask, b2 = x & mask;
            if ((b0 ^ b1 ^ b2) == 0) mask >>= 1;
            else break;
        }

        ll mask2 = mask - 1;
        ll y1 = (a[0] & mask2) + 1;
        ll y2 = mask2 - (a[1] & mask2) + 1;
        ll y = min(y1, y2);
        now += y;
        a[0] -= y;
        a[1] += y;
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF (9e18)
#define EPS (1e-6)
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<endl;}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
void INIT(){
	ios::sync_with_stdio(false); cin.tie(0);
}

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int32_t main() {
	INIT();
	//code...
	string s; cin>>s;
	int n=sz(s);
	vector<int> v(n,0);
	int l=0,r=0,it=-1;
	bool sw=false;
	s=s+'R';
	For(i,0,n){
		if(i>0 && s[i]=='R' && s[i-1]=='L'){
			v[it]=r; v[it-1]=l;
			sw=false;
			l=r=0;
		}
		else if(i>0 && s[i]=='L' && s[i-1]=='R'){
			if(sw) swap(l,r);
			it=i;
		}
		if(s[i]=='L'){
			int t=i-it;
			if(t%2) l++;
			else r++;
		}
		else{
			swap(l,r); sw=!sw;
			r++;
		}
	}
	For(i,0,n-1) cout<<v[i]<<" \n"[i==n-1];
	return 0;
}






















Measured memory_bytes: 1004
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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() {
    int n;
    cin >> n;
    int hiku = n%1000;
    if(hiku==0) cout << 0 << endl;
    else cout << 1000 - hiku << endl;
}
    




Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    int c = 0;
    string s;
    string f = "CODEFESTIVAL2016";
    cin >> s;
    for (int i = 0; i < s.size(); i++){
        if (s[i] != f[i]){
            c = c + 1;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 768
#-swank
(unless (member :child-sbcl *features*)
  (quit
	:unix-status
	(process-exit-code
	  (run-program *runtime-pathname*
				   `("--control-stack-size" "128MB"
					 "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
					 "--eval" "(push :child-sbcl *features*)"
					 "--script" ,(namestring *load-pathname*))
				   :output t :error t :input t))))

(let ((a (read)) (b (read)))
  (if (< a b)
	(loop repeat b do (princ a))
	(loop repeat a do (princ b))))


Measured memory_bytes: 15924
#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
using ll=long long int; using dd=double;
using pii=pair<int,int>; using pll=pair<ll,ll>;
typedef vector<int> vi;
ll INFLL=(ll)2e18, MOD=1'000'000'007;
const int INF=0x3f3fffff ;
/////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is: "<<x<<'\n';
#define DD(x,y) cerr<<"("<<#x<<","<<#y<<") are: "<<x<<" "<<y<<'\n';
/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vi> adj; vi vis; vi level;
// int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
int dx8[]={-1,1,2,2,1,-1,-2,-2}, dy8[]={2,2,1,-1,-2,-2,-1,1};
inline ll mexp(ll x,ll n,ll m){ll res=1;while(n){if(n&1)res=(res*x)%m;n>>=1;x=((x%m)*(x%m))%m;}return res;}
inline bool ispow2(ll x){ return x && (!(x&(x-1)));}
inline ll gcd(ll x, ll y){ pll p{x,y}; while(p.ss) p={p.ss,p.ff%p.ss}; return p.ff;}


/////////////////// MAIN STARTS //////////////////////////////////
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
// random_device rd; mt19937 genr(rd());

#ifdef DEBUG
  auto tStart = chrono::system_clock::now(); //freopen("op.txt","w",stdout);
#endif

ll n,k,ans=0; cin>>n>>k;

for(ll a=1;a<=min(n,k);++a){
  if((2*a)%k!=0 || k-a>n) continue;
  ll t=(n-a)/k+1;
  ans+=t*t*t;
  // DD(t,tt);
}
cout<< ans <<'\n'; 

#ifdef DEBUG
  auto diff=chrono::system_clock::now()-tStart;
  cerr<<"\nExecution time: "<<chrono::duration<dd,milli>(diff).count()<<" ms.\n";
#endif
return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int DP[3100][3100] = {};
int path[3100][3100] = {};

int main(){
	
	string s, t;
	cin >> s >> t;
	
	int mul = 10000;
	
	for(int i = 1; i <= s.size(); i++){
		for(int j = 1; j <= t.size(); j++){
			int num = DP[i - 1][j];
			path[i][j] = 0;
			if(num < DP[i][j - 1]){
				num = DP[i][j - 1];
				path[i][j] = 1;
			}
			if(s[i - 1] == t[j - 1] && num < DP[i - 1][j - 1] + 1){
				num = DP[i - 1][j - 1] + 1;
				path[i][j] = 2;
			}
			DP[i][j] = num;
		}
	}
	
	int x = s.size();
	int y = t.size();
	string ans = "";
	
	while(x != 0 && y != 0){
		if(path[x][y] == 0){
			x -= 1;
		}else if(path[x][y] == 1){
			y -= 1;
		}else{
			x -= 1;
			y -= 1;
			string S = " ";
			S[0] = s[x];
			ans = S + ans;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 74112
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define mod ((ll)1e9+7)
#define inf 0x3f3f3f3f
#define infl 0x3f3f3f3f3f3f3f3f
#define Ninf -0x3e3e3e3f
#define Ninfl -0x3e3e3e3e3e3e3e3f
#define maxx ((ll)1e5+5)
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
ll add(ll x, ll y) { x += y; if (x >= mod) return x-mod; return x;}
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + mod; return x;}
ll mult(ll x, ll y) { return (x * y) % mod;}
ll rev(ll x) { return expm(x, mod - 2);}
/*
bool sv[maxx]={0};    // returns 0 if a num is prime
int sp[maxx]={0};     // gives smallest prime factor of the number
void Sieve() {for(int i= 2; i< maxx; i+= 2) sv[i]=1,sp[i] = 2;sv[2]=0;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll fact[maxx]={0}; // returns factorial of that number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<maxx;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncrm(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
ll inv[maxx];   // returns the modular inverse of number
void inversify( ll m){inv[1]=1;for(int i=2;i<maxx;i++){inv[i]= m- m/i*inv[m%i]%m;}}
ll ncr(ll n,ll r,ll m){int ans=1;for (int i = 0; i < r; i++){ans=ans*(n-i)%m*inv[i+1]%m;}return ans;}
*/
signed main(){
  fast;
  //test
  {
    int s,w;
    cin>>s>>w;
    if(w>=s)
      cout<<"unsafe";
    else
      cout<<"safe";
  }
  return 0;
}

Measured memory_bytes: 3608
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const ll INF = std::numeric_limits<long long>::max();
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define sz size
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }ll a[100000], b[100000];
int main() {
	string s;
	cin >> s;
	string v[4] = { "dream","dreamer","erase","eraser" };
	int mode = 0,ct=0,num/*vのどれか*/;
	bool bb=1;
	while (!(!bb || s.empty())) {
		//cout << s << endl;
		if (mode == 0) {//単語の末尾
			if (s.size() < 5) { bb = 0; break; }
			if (s[s.size() - 1] == 'r'&&s[s.size() - 2] == 'e'&&s[s.size() - 3] == 'm')num = 1;
			else if (s[s.size() - 1] == 'r'&&s[s.size() - 2] == 'e'&&s[s.size() - 3] == 's')num = 3;
			else if (s[s.size() - 1] == 'm')num = 0;
			else if (s[s.size() - 1] == 'e')num = 2;
			else bb = 0;
			ct = 1;
			s.pop_back();
			mode = 1;
			continue;
		}
		if (mode == 1) {
			if (ct == v[num].size()) { mode = 0; continue; }
			if (s[s.size() - 1] == v[num][v[num].size() - 1 - ct]) { ++ct; s.pop_back(); }
			else { bb = 0; break; }
		}
	}
	cout << YN(bb) << endl;
	return 0;
}

Measured memory_bytes: 512
S = input()

l = len(S)
x = [0]*(l+1)
y = [0]*(l+1)
for i in range(l):
    if S[i] == "<":
        x[i+1] = x[i]+1
for i in range(l):
    if S[l-i-1] == ">":
        y[l-i-1] = y[l-i]+1

res = 0
for a, b in zip(x, y):
    res += max(a, b)

print(res)

Measured memory_bytes: 28504
#include <bits/stdc++.h>
using std::cerr;
using std::endl;

const int N = 1e3 + 5, M = 2e5 + 5;

int n, m, ban;
struct Edge { int x, y; } E[M];
bool A[N][N], B[N][N];
std::vector<int> G[N];
int que[N], ql, qr;
int vis[N], tag[N], ver;

inline void bfs1(int st) {
  que[ql = qr = 0] = st;
  vis[st] = 1;
  while (ql <= qr) {
    int x = que[ql++];
    for (int y : G[x])
      if (!vis[y]) {
        vis[y] = 1;
        que[++qr] = y;
      }
  }
  for (int i = 1; i <= n; ++i)
    A[st][i] = vis[i], vis[i] = 0;
}

inline void bfs2(int st) {
  ++ver, tag[st] = ver;
  ++vis[st];
  que[ql = qr = 0] = st;
  while (ql <= qr) {
    int x = que[ql++];
    for (int y : G[x])
      if (vis[y] < 2 && tag[y] != ver) {
        ++vis[y];
        tag[y] = ver;
        que[++qr] = y;
      }
  }
}

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1, x, y; i <= m; ++i) {
    scanf("%d %d", &x, &y);
    E[i] = { x, y };
    G[x].push_back(y);
  }
  for (int i = 1; i <= n; ++i)
    bfs1(i);
  for (int i = 1; i <= n; ++i) {
    memset(vis, 0, sizeof(vis));
    vis[i] = 233;
    for (int j : G[i])
      if (vis[j] < 2)
        bfs2(j);
    for (int j = 1; j <= n; ++j)
      if (vis[j] >= 2)
        B[i][j] = 1;
  }
  for (int i = 1; i <= m; ++i) {
    int x = E[i].x, y = E[i].y,
        cnt = A[y][x] + B[x][y];
    puts(cnt == 1 ? "diff" : "same");
  }
  return 0;
}



Measured memory_bytes: 8704
#include <iostream>


using namespace std;


int main()
{
    long long A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    if (A + B <= C * 2) {
        cout << A * X + B * Y << endl;
        return 0;
    }

    long long ans = 0;
    if (X >= Y) {
        X -= Y;
        ans += Y * 2 * C;
        if (A > C * 2)
            ans += X * 2 * C;
        else
            ans += X * A;
    } else {
        Y -= X;
        ans += X * 2 * C;
        if (B > C * 2)
            ans += Y * 2 * C;
        else
            ans += Y * B;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
// AOJ 0612 Sandcastle
// 2018.2.26 bal4u

#include <stdio.h>
#include <ctype.h>

typedef struct { short r, c; } Q;
Q q[2][2000]; int top[2], tail[2];
char map[1002][1002];
char a[1002][1002];
int mv[8][2] = {{-1,0},{-1,1},{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1}};

int main()
{
	int h, w, r, c, i, k1, k2, nr, nc, ans, f;
	char buf[15], *p;

	fgets(buf, 15, stdin), sscanf(buf, "%d%d", &h, &w);

	for (r = 0; r < h; r++) {
		fgets(p=map[r], 1002, stdin);
		while (*p > ' ') {
			if (isdigit(*p)) *p &= 0xf;
			p++;
		}
	}

	for (r = 1; r < h-1; r++) for (c = 1; c < w-1; c++) {
		if (map[r][c] == '.') continue;
		for (i = 0; i < 8; i++) {
			nr = r + mv[i][0], nc = c + mv[i][1];
			if (map[nr][nc] == '.') a[r][c]++;
		}
		if (a[r][c] >= map[r][c]) {
			q[0][tail[0]].r = r, q[0][tail[0]++].c = c;
		}
	}

	ans = 0;
	for (k1 = 0, k2 = 1; ; k1 = k2, k2 = !k2) {
		 f = 0;
		 top[k2] = tail[k2] = 0;
		 while (top[k1] < tail[k1]) {
			r = q[k1][top[k1]].r, c = q[k1][top[k1]++].c;
			for (i = 0; i < 8; i++) {
				nr = r + mv[i][0], nc = c + mv[i][1];
				if (map[nr][nc] < 10 && ++a[nr][nc] == map[nr][nc]) {
					q[k2][tail[k2]].r = nr, q[k2][tail[k2]++].c = nc, f = 1;
				}
			}
		}
		ans++;
		if (!f) break;
	}
	printf("%d\n", ans);
	return 0;
}



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

int main()
{
    double a,b;
    cin>>a>>b;
    int c=a+1;
    int t=c/0.08;
    int s=b/0.1;
    int flag=1;
    for(int i=s;i<=t;i++)
    {
        int m,n;
        m=floor(i*0.08);
        n=floor(i*0.1);
        if(m==a&&n==b)
        {
            cout<<i;
            flag=0;
            break;
        }
    }
    if(flag)
        cout<<-1;
    return 0;
}


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

 int main(){
   int x;
   cin>>x;
   bool a=false;
   if(x%100==0){
     a=true;
   }

   int b=x/100;
   int c=x%100;

  if(c<=5*b  ){
    int d=c/5;
    int f=c%5;
    if(d==b){
      a=true;
    }else{
      int g1=f/4;
      int g2=f%4;
      int sum=b-d;
      if(f<=4*sum){
        if(g1==d){
          a=true;
        }else{
          int h1=g2/3;
          int h2=g2%3;
          sum=b-d-g1;
          if(g2<=3*sum){
            if(h1==g1){
              a=true;
            }else{
              int i1=h2/2;
              int i2=h2%2;
              sum=b-d-g1-h1;
              if(h2<=2*sum){
                if(i1==h1){
                  a=true;
                }else{
                  sum=b-d-g1-h1-i1;
                  if(i2<=sum){
                    a=true;
                  }
                }
              }
            }
          }
        }
      }
    }
  }
   if(a){
     cout<<1<<endl;
   }else{
     cout<<0<<endl;
   }
}



Measured memory_bytes: 256