akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String inputS = scanner.next();
		
		if(hasSameChar(inputS)) {
			System.out.println("no");
		}else {
			System.out.println("yes");
		}

		scanner.close();

	}
	

	static boolean hasSameChar(String inputS) {
		for (int i = 0; i < inputS.length() ; i++) {

			char buf = inputS.charAt(i);

			for (int j = 0; j < inputS.length() ; j++) {
				
				if(i==j) {continue;};

				if (buf == inputS.charAt(j)) {
					return true;
				}

			}

		}
		
		return false;

	}

}


Measured memory_bytes: 21844
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		ArrayList<Integer> x = new ArrayList<Integer>();
		int tmp;
		int cnt = 0;
		Scanner sc = new Scanner(System.in);
//		sc.useDelimiter("\\r\\n");

		tmp = sc.nextInt();
		x.add(tmp);
		cnt++;

		while(tmp!=0){
			sc.hasNext();
			tmp = sc.nextInt();
			x.add(tmp);
			cnt++;
		}

		for(int i=0;i<cnt-1;i++){
			System.out.println("Case "+ (i+1) +": "+ x.get(i));
		}
		sc.close();
	}

}

Measured memory_bytes: 45116
#include<stdio.h>
void matrixChainOrder(int);
int m[100][100],p[100];
int main(){
  int i,n,c;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&p[i],&c);
    p[i+1]=c;
  }
  
  matrixChainOrder(n);
  printf("%d\n",m[1][n]);
  return 0;
}

void matrixChainOrder(n){
  int i,j,l,k,q;
  
  for(i=1;i<=n;i++)
    m[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=100000000;     
      for(k=i;k<=j-1;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	if(q<m[i][j]) m[i][j]=q;
      }
    }
  }
}
	  

Measured memory_bytes: 636
void main()
{
    long n, m;
    rdVals(n, m);
    long[][] edge = new long[][](n);
    foreach (i; 0 .. m)
    {
        long x, y;
        rdVals(x, y);
        --x, --y;
        edge[x] ~= y;
    }

    long[] dp = new long[n];

    long dfs(long x)
    {
        if (dp[x]) return dp[x];
        long result;
        foreach (e; edge[x])
        {
            result = max(result, dfs(e)+1);
        }
        dp[x] = result;
        return result;
    }

    long result;
    foreach (i; 0 .. n)
    {
        if (!dp[i]) result = max(result, dfs(i));
    }

    result.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

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

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

int arr[110];
char dp[100010];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	while(t != 0) {
        int n, k;
        cin >> n >> k;
        for(int i = 0; i < n; i++) {
            cin >> arr[i];
        }
        memset(dp, false, sizeof dp);
        for(int i = 1; i <= k; i++) {
            for(int j = 0; j < n; j++) {
                if(i-arr[j] >= 0) {
                    dp[i] = (dp[i] | (~dp[i-arr[j]]));
                }
            }
        }
        if(dp[k]) {
            cout << "First";
        }
        else {
            cout << "Second";
        }
        cout << "\n";
	    t--;
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
  int sum = 0;
  int d[6];
  for (int i = 0; i < 5; i++) {
    cin >> d[i];
    sum += d[i] % 10 ? (d[i] / 10 + 1) * 10 : d[i];
  }

  int min_diff = 10;
  for (int i = 0; i < 5; i++) {
    if (d[i] % 10 != 0 && d[i] % 10 < min_diff)
      min_diff = d[i] % 10;
  }

  cout << sum - (10 - min_diff) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <ctime>
#include <cmath>
#include <vector>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <iostream>
#include <algorithm>
using namespace std;
template <typename Type>
inline int read(Type& x) {
    x = 0; char c = getchar(), f = 1;
    for(; c > '9' || c < '0'; c = getchar())
        if(c == '-') f = -f;
        else if(c == -1) return -1;
    for(; c <= '9' && c >= '0'; c = getchar())
        x = (x << 1) + (x << 3) + (c ^ 48);
    x *= f; return 1;
}
template <typename Type>
inline int write(Type x) {
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) return write(x / 10) && putchar(x % 10 | 48);
    return putchar(x | 48);
}
template <typename Type>
inline int write(Type x, char c) { return write(x) && putchar(c); }
#define Max(a, b) ( a > b ? a : b )
#define Min(a, b) ( a < b ? a : b )
inline bool OpenFile() { freopen("redistricting.in", "r", stdin); freopen("redistricting.out", "w", stdout); return 1; }
//bool _Opened = OpenFile();

int d, m;
int ans;
int main() {
    read(m), read(d);
    for(int i = 1; i <= m; i++) {
        for(int j = 22; j <= d; j++) {
            int a = j / 10, b = j % 10;
            if(a >= 2 && b >= 2 && a * b == i)
                ans++;
        }
    }
    write(ans, '\n');
}


Measured memory_bytes: 256
import math
import sys

m=10**9 + 7 
sys.setrecursionlimit(1000010)
N=int(input())
A  = list(map(int,input().split()))

# print(A)
dictA={}

for i in A:
    if i in dictA: 
        print("NO")
        exit(0)
    dictA[i]=1
print("YES")


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


int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

	map<string, int> ct;
	int n; cin >> n;
	for (int i = 0; i < n; ++i) {
		string s; cin >> s;
		++ct[s];
	}
	vector<string> v = {"AC", "WA", "TLE", "RE"};
	for (auto s : v)
		cout << s << " x " << ct[s] << '\n';
}

Measured memory_bytes: 3656
import fractions

def calc(v):
    ta = v // C
    tb = v // D
    tc = v // ((C * D) // fractions.gcd(C, D))
    return v-(ta+tb-tc)


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

count = 0
i = A
a = calc(A-1)
b = calc(B)
print(abs(a-b))


Measured memory_bytes: 5348
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define mt make_tuple
#define ldb double
#define pii pair<int,int>
#define pll pair<ll,ll>
template<typename T>void ckmn(T &a,T b){a=min(a,b);}
template<typename T>void ckmx(T &a,T b){a=max(a,b);}
int ri(){int x;scanf("%i",&x);return x;}
void rd(){}
template<typename...T>void rd(int &x,T&...args){scanf("%i",&x);rd(args...);}
template<typename...T>void rd(ll &x,T&...args){scanf("%lld",&x);rd(args...);}
template<typename...T>void rd(ldb &x,T&...args){scanf("%lf",&x);rd(args...);}
template<typename...T>void rd(pii &x,T&...args){scanf("%i %i",&x.first,&x.second);rd(args...);}
template<typename T>void rd(vector<T>&v){for(T&i:v)rd(i);}

int main(){
	int x=ri();
	int ans=0,now=0;
	do{
		now+=x;
		now%=360;
		ans++;
	}while(now!=0);
	printf("%i\n",ans);
	return 0;
}

Measured memory_bytes: 3788
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    IN(ll, K);
    AIN(ll, p, N);
    SORT(p);
    ll ans = 0;
    REP(i, K)
    {
        ans += p[i];
    }
    OUT(ans);
}

Measured memory_bytes: 3628
/*
My heart’s beating faster
I know what I’m after
 
I’ve been standing here my whole life
Everything I’ve seen twice
Now it’s time I realized
It’s spinning back around now
On this road I’m crawlin’
Save me 'cause I’m fallin’
Now I can’t seem to breathe right
'Cause I keep runnin' runnin' runnin' runnin'
Runnin' runnin' runnin' runnin'
Runnin' from my heart
*/
 
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define nt _int128
#define fir first
#define sec second
#define slow_as_snail ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define debug(x) cout<<x<<"\n";
#define debugged cout<<"debugged\n";
#define inf 0x3f3f3f3f
#define rall(v) v.rbegin(),v.rend()
#define all(v) v.begin(),v.end() 
 
const ll mod = 1000000007;
#define mx 10000005
const ll mxi = 100005;

int main()
{
    slow_as_snail;
    string str;
    cin>>str;
    ll flag = 1;
    for(int i=0;i<str.length()-1;i++)
    {
        if(str[i]==str[i+1])
        {
            flag = 0;
            break;
        }
    }
    if(!flag)
    cout<<"Bad";
    else
    cout<<"Good";
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
	int men[31] = {}, a[31] = { 0 };
	for (int i = 0; i < 28; i++){
		cin >> a[i];
		men[a[i]] = 1;
	}
	for (int i = 1; i <= 30; i++){
		if (men[i] != 1){
			cout << i << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int n,m,x,y,z,s;
bool a[100005];
int main()
{
    cin>>n>>m>>x;
    for (int i=0;i<m;i++)
    {
        cin>>y;
        a[y]=true;
    }
    y=0;
    for (int i=x;i>=0;i--)
    {
        if (a[i])
            y++;
    }
    for (int i=x;i<=n;i++)
    {
        if (a[i])
            z++;
    }
    cout<<min (z,y);
    return 0;
}


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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(K: int, X: int):
    if 500 * K >= X:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(K, X)

if __name__ == '__main__':
    main()


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

int main() {

    string S;
    int N, K;
    cin >> S >> K;
    N = S.size();

    ll dp[101][4][2] = {0};
    dp[0][0][0] = 1;

    rep(i, N) rep(j, 4) rep(k, 2) {
        int now = S[i] - '0';
        rep(d, 10) {
            int ni = i + 1, nj = j, nk = k;
            if (d != 0)
                nj++;
            if (nj > K)
                continue;
            if (k == 0) {
                if (d > now)
                    continue;
                if (d < now)
                    nk = 1;
            }
            dp[ni][nj][nk] += dp[i][j][k];
        }
    }

    cout << dp[N][K][0] + dp[N][K][1] << endl;

    return 0;
}

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

main(){
  int N;
  cin >> N;
  char A[N],B[N],C[N];
  cin >> A >> B >> C;
  int ans=0;
  for(int ii=0;ii<N;ii++){
    if(A[ii]==B[ii] && B[ii]==C[ii])ans+=0;
    else if(A[ii]==B[ii] || B[ii]==C[ii] || A[ii]==C[ii])ans++;
    else ans+=2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 998244353;


int main() {
    int n; 
    cin >> n;
    vector<int> as(n+1);
    rep(i, n) cin >> as[i+1];
    vector<vector<ll>> dp(n+1, vector<ll>(2, 0));
    dp[2][0] = as[1] + as[2];
    dp[2][1] = - dp[2][0];
    rng(i, 3, n+1) {
        dp[i][0] = max(dp[i-1][0], dp[i-1][1]) + as[i];
        dp[i][1] = max(dp[i-1][0] -2*as[i-1], dp[i-1][1] + 2*as[i-1]) - as[i] ;
    }
    cout << max(dp[n][0], dp[n][1]) << endl;
    return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
#define MOD 1000000007
using namespace std;
using ll=int64_t;
using pii=pair<int,int>;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
//最大公約数
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
//最小公倍数
int lcm(int a,int b){
   return a*b/gcd(a,b);
}
bool prime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0)
        return false;
    }
    return true;
}
int main(){
    int a,b;
    cin>>a>>b;
    if(a==b)
    cout<<2*a<<endl;
    else
    {
        cout<<2*max(a,b)-1<<endl;
    }
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,j;
    char s[20],a[20],b[20];
    cin>>s;
    cin>>a;
    cin>>n>>m;
    cin>>b;
    i = strcmp(s,b);
    j = strcmp(a,b);
    if(i==0)
    {
        cout<<n-1<<" "<<m;
    }
    else if(j==0)
    {
        cout<<n<<" "<<m-1;
    }
}


Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

ll MOD = (ll)pow(10, 9) + 7;

ll factorial(ll n) {
    if (n == 0) return 1;
    return (n * factorial(n-1)) % MOD;
}

ll power(ll base, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) return power((base * base) % MOD, n / 2) % MOD;
    return (base * power((base * base) % MOD, (n - 1) / 2)) % MOD;
}

int main(int argc, const char * argv[]) {
    ll n, a, b; cin >> n >> a >> b;

    ll ans = power(2, n) % MOD;

    ll pn = 1;
    ll na = 0, nb = 0;
    for (ll i = n; i > n - b; i--) {
        if (i == n - a) na = pn;
        pn = (pn * i) % MOD;
    }
    nb = pn;
    ll fa = factorial(a) % MOD;
    ll fb = factorial(b) % MOD;

    ll nCa = (na * power(fa, MOD-2)) % MOD;
    ll nCb = (nb * power(fb, MOD-2)) % MOD;

    ans = (ans - nCa) % MOD;
    ans = (ans - nCb) % MOD;
    ans = (ans - 1) % MOD;

    cout << (ans < 0 ? ans + MOD : ans) << endl;

    return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int N, X; cin >> N >> X;
	vector<int> m(N);
	int sum = 0;
	REP(i,N){ 
		cin >> m[i];
		sum += m[i];
	}

	SORT(m);
	int x = X - sum;
	int ans = N + x/m.front();

	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N, M;
    cin >> N >> M;

    vector<ll> A(M);
    FOR(i, 0, M){
        cin >> A.at(i);
    }
    sort(ALL(A));

    if(N>=M){
        p(0);
        return 0;
    }

    vector<ll> D;
    FOR(i, 1, M){
        D.push_back(A[i] - A[i-1]);
    }
    sort(ALL(D));

    ll sum = 0;
    FOR(i, 0, D.size()-(N-1)){
        sum += D[i];
    }

    p(sum);
    
    return 0;
}

Measured memory_bytes: 2168
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		for(int i=1;i<=n;i++){
			int x = i;
			
			if(x%3==0){
			    System.out.print(" "+i);
			    x = 0;
			}
			
			while(x!=0){
				if(x%10==3){
				    System.out.print(" "+i);
				    break;
				}
				x /= 10;
			}
			
		}
		
		System.out.println("");
		
	}

}



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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

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

  double result=0.0;
  if(d==0) result = (double)1/n;
  else result = (double)2*(n-d)/n/n;
  result *= (m-1);

  cout<<fixed<<setprecision(12)<<result;

  return 0;
}

Measured memory_bytes: 256
using System;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {   
            int ans;
            int n = int.Parse(Console.ReadLine());
            if (n % 1000 == 0)
            {
                ans = 0;
            }else
            {
                ans = (n/1000 + 1) * 1000 - n;
            }
            Console.WriteLine(ans);
        }
    }
}

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

int main(){
	int a, b, c, d;

	cin >> a;
	if (a == 3) {
		cout<<"YES"<<endl;
	}
	else if (a==5) {
		cout << "YES" << endl;
	}
	else if (a==7) {
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
int main(){
  random_device rnd;
  mt19937 mt(rnd());
  int D;
  cin >> D;
  vector<int> c(26);
  for (int i = 0; i < 26; i++){
    cin >> c[i];
  }
  vector<vector<int>> s(D, vector<int>(26));
  for (int i = 0; i < D; i++){
    for (int j = 0; j < 26; j++){
      cin >> s[i][j];
    }
  }
  vector<int> last(26, -1);
  for (int i = 0; i < D; i++){
    int t = min(9, D - i);
    vector<vector<int>> L(26, vector<int>(t, 0));
    for (int j = 0; j < 26; j++){
      for (int k = 0; k < t; k++){
        L[j][k] = c[j] * (i + k - last[j]);
      }
    }
    int mx = 0;
    int a = 0;
    vector<int> best(t);
    vector<vector<int>> L2 = L;
    for (int j = 0; j < 26000; j++){
      vector<int> next(t, 0);
      if (j < 14000){
        for (int k = 0; k < t; k++){
          next[k] = mt() % 26;
        }
      } else if (j < 24000){
        next = best;
        for (int k = 0; k < 3; k++){
          int pos = mt() % t;
          int upd = mt() % 26;
          next[pos] = upd;
        }
      } else {
        next = best;
        for (int k = 0; k < 2; k++){
          int pos = mt() % t;
          int upd = mt() % 26;
          next[pos] = upd;
        }
      }
      int diff = 0;
      for (int k = 0; k < t; k++){
        diff += s[i + k][next[k]];
        for (int l = k; l < t; l++){
          diff += L2[next[k]][l] - (l - k) * c[next[k]];
          L2[next[k]][l] = (l - k) * c[next[k]];
        }
      }
      if (diff > mx){
        mx = diff;
        best = next;
      }
      for (int k = 0; k < t; k++){
        L2[next[k]] = L[next[k]];
      }
    }
    cout << best[0] + 1 << endl;
    last[best[0]] = i;
  }
}

Measured memory_bytes: 3712
function main()
	mod=10^9+7
	N=parse(Int,readline())
	A=map(x->parse(Int,x),split(readline()))
	ans=0
	for a=A
		ans+=invmod(a,mod)
		ans%=mod
	end
	for i=2:10^3
		c=0
		for j=1:N
			n=0
			while A[j]%i==0
				A[j]=div(A[j],i)
				n+=1
			end
			if c<n
				c=n
			end
		end
		ans=i^c%mod*ans%mod
	end
	for a=unique(A)
		ans=ans*a%mod
	end
	println(ans)
end
main()


Measured memory_bytes: 169500
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

int main(void) {
    const string base = "keyence";
    string str;
    cin >> str;

    int flag = 0;
    for(int i = 0; i < str.length(); i++) {
        for(int j = i; j < str.length(); j++) {
            // [i, j)
            string nstr = str.substr(0, i) + str.substr(j);
            if(nstr == base) {
                flag = 1;
                break;
            }
        }
    }
    cout << (flag ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//https://www.creativ.xyz/dump-cpp-652/
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
 
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

#ifdef DEBUG_
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif

signed main(void) { cin.tie(0); ios::sync_with_stdio(false);
    int a,b,k; cin>>a>>b>>k;
    if(a>k){
        cout<<a-k<<' '<<b<<endl;
    }else{
        cout<<0<<' '<<max(b - (k-a), 0LL)<<endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	
	public void solve(){
		Scanner sc = new Scanner(System.in);
		
		
		int k =sc.nextInt();
		int l =sc.nextInt();
		int a,b;
		if(k < l){
			System.out.println("a < b");
		}else if(k > l){
			System.out.println("a > b");
		}else if(k == l){
			System.out.println("a == b");
		}
	}
	public static void main(String[] args){
		Main obj = new Main();
		obj.solve();
	}
}

Measured memory_bytes: 17324
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
struct node{
  int key;
  struct node *parent, *left, *right;
};
typedef struct node * Node;
Node root;

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u=u->left;
    else u=u->right;
  }
  return u;
}

void insert(int k){
  Node y = NIL; // x の親
  Node x = root;
  Node z;
  z=malloc(sizeof(struct node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while (x != NIL){
    y = x; // 親を設定
    if( z->key < x->key) x = x->left; // 左の子へ移動
    else x = x->right; // 右の子へ移動
  }
  z->parent = y;
  if (y == NIL) // T が空の場合
    root = z;
  else if (z->key < y->key)
    y->left = z; // z を y の左の子にする
  else 
    y->right = z; // z を y の右の子にする
}
void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 20496
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;

const int mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  map<int, int> fact;
  for(int i = 2; i <= N; i++) {
    int tmp = i;
    for(int j = 2; j <= N; j++) {
      while(!(tmp%j)) {
        fact[j]++;
        tmp /= j;
      }
    }
  }
  ll ans = 1;
  for(auto e : fact)
    ans = ans*(e.second+1)%mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int n = s.length;
		int res = 0;
		for(int i = 0; i < n/2; i++) {
			if(s[i] != s[n-1-i]) res++;
		}
		System.out.println(res);
	}

}


Measured memory_bytes: 21844
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int N=8e5+2;
const int mod=924844033;

int n,tot,siz[N],cnt[N],head[N];
int g1[N],g2[N],g3[N],res[N],ans[N],fac[N],inv[N];
struct Edge {int nxt,to;} G[N<<1];

inline int mul(int x,int y) {return 1ll*x*y%mod;}
inline int dec(int x,int y) {x-=y;if(x<0) x+=mod;return x;}
inline int add(int x,int y) {x+=y;if(x>=mod) x-=mod;return x;}
inline int modpow(int x,int y,int res=1) {
    for(;y;y>>=1,x=mul(x,x)) if(y&1) res=mul(res,x);
    return res;
}
template <typename _Tp> inline void IN(_Tp&x) {
    char ch;bool flag=0;x=0;
    while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
    while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    if(flag) x=-x;
}
inline void addedge(int u=0,int v=0) {
    IN(u),IN(v);
    G[++tot]=(Edge){head[u],v},head[u]=tot,
    G[++tot]=(Edge){head[v],u},head[v]=tot;
}

void dfs(int u,int fa) {
    siz[u]=1;
    for(int i=head[u],v;i;i=G[i].nxt)
        if((v=G[i].to)^fa) dfs(v,u),siz[u]+=siz[v],cnt[siz[v]]++;
    cnt[n-siz[u]]++;
}

namespace Poly {
    int filp[N];
    inline void NTT(int*f,int limit,short inv) {
        for(int i=0;i<limit;++i) if(i<filp[i]) swap(f[i],f[filp[i]]);
        for(int p=2;p<=limit;p<<=1) {
            int len=p>>1,tmp=modpow(5,(mod-1)/p);
            for(int k=0;k<limit;k+=p) {
                int buf=1;
                for(int l=k;l<k+len;++l,buf=mul(buf,tmp)) {
                    int t=mul(f[l+len],buf);
                    f[l+len]=dec(f[l],t),f[l]=add(f[l],t);
                }
            }
        }
        if(inv==1) return void();
        int sl=modpow(limit,mod-2);reverse(f+1,f+limit);
        for(int i=0;i<limit;++i) f[i]=mul(f[i],sl);
    } 
}using namespace Poly;

inline int C(int n,int m) {return mul(fac[n],mul(inv[n-m],inv[m]));}
int main() {
    IN(n);
    for(int i=2;i<=n;++i) addedge();
    dfs(1,0),fac[0]=inv[0]=1;
    for(int i=1;i<=n;++i) fac[i]=mul(fac[i-1],i);
    for(int i=1;i<=n;++i) inv[i]=modpow(fac[i],mod-2);
    for(int i=0;i<=n;++i) g1[i]=mul(cnt[i],fac[i]),g2[i]=inv[n-i];
    int cnt=0,limit=1;
    while(limit<=(n<<1)) limit<<=1,++cnt;
    for(int i=0;i<limit;++i) filp[i]=(filp[i>>1]>>1)|((i&1)<<(cnt-1));
    NTT(g1,limit,1),NTT(g2,limit,1);
    for(int i=0;i<limit;++i) g3[i]=mul(g1[i],g2[i]);
    NTT(g3,limit,-1);
    for(int i=1;i<=n;++i) res[i]=g3[n+i];
    for(int i=1;i<=n;++i) ans[i]=dec(mul(n,C(n,i)),mul(inv[i],res[i]));
    for(int i=1;i<=n;++i) printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 49024
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int i,j,n,m;
    int a[100][100];
    int b[100];
    int c[100];

    cin >> n >> m;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            if(j==0){
                scanf("%d",&a[i][j]);
            }else{
                scanf(" %d",&a[i][j]);
            }
        }
    }
    for(j=0;j<m;j++) cin >> b[j];

    for(i=0;i<n;i++){
        for(j=0;j<m;j++) c[i] += a[i][j] * b[j];
    }

    for(i=0;i<n;i++) cout << c[i] << endl;;

    return 0;
}


Measured memory_bytes: 3208
n, d = map( int, input().split() )
x = []
y = []
for _ in range( n ):
    x_i, y_i = map( int, input().split() )
    x.append( x_i )
    y.append( y_i )

ans = 0
for i in range( n ):
    if x[ i ] ** 2 + y[ i ] ** 2 <= d ** 2:
        ans += 1

print( ans )

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  string S;
  cin >> S;
  int n = 0, b = 0;
  for (int i=0; i < S.size(); i++) {
    if (S[i] == 'a') {
      if (n < A+B) {
	cout << "Yes" << endl;
	n++;
      } else {
	cout << "No" << endl;
      }
    } else if (S[i] == 'b') {
      if (n < A+B && b < B) {
	cout << "Yes" << endl;
	n++;
	b++;
      } else {
	cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  }
}



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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        a[i] -= 1;
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        if(a[a[i]] == i){
            ans += 1;
        }
    }
    cout << ans/2;
}

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
std::vector<std::vector<std::pair<int, int> > > qs;
std::vector<int64_t> res;

using Table = std::vector<std::pair<int, int64_t> >;
Table merge(Table a, int cost, int profit) {
	int m = a.size();
	a.push_back({1000000000, 1000000000000000000});
	int left = 0, right = 0;
	Table res;
	while (left < m || right < m) {
		assert(left <= m && right <= m);
		bool consume_left = a[left].first < a[right].first + cost;
		auto tmp = consume_left ? a[left++] : a[right++];
		if (!consume_left) tmp.first += cost, tmp.second += profit;
		if (tmp.first > 100000) continue;
		while (res.size() && res.back().first == tmp.first && res.back().second < tmp.second) res.pop_back();
		if (res.size() && res.back().second >= tmp.second) continue;
		res.push_back(tmp);
	}
	return res;
}

std::vector<std::pair<int, int> > info;
Table top{{0, 0}}, bottom{{0, 0}};
int threshold = 11;
int n;
void dfs(int i, int depth) {
	Table bak;
	if (depth < threshold) bak = top, top = merge(top, info[i].first, info[i].second);
	else bak = bottom, bottom = merge(bottom, info[i].first, info[i].second);
	for (auto j : qs[i]) {
		int head = 0;
		for (int k = bottom.size(); k--; ) {
			while (head < (int) top.size() && top[head].first + bottom[k].first <= j.first) head++;
			if (head) res[j.second] = std::max(res[j.second], top[head - 1].second + bottom[k].second);
		}
	}
	if (i < (n - 1) / 2) for (int j = 1; j <= 2; j++) dfs((i << 1) + j, depth + 1);
	
	if (depth < threshold) top = bak;
	else bottom = bak;
}

int main() {
	n = ri();
	info.resize(n);
	for (int i = 0; i < n; i++) info[i].second = ri(), info[i].first = ri();
	
	if (n < 1000) {
		int q = ri();
		for (int i = 0; i < q; i++) {
			int x = ri() - 1;
			int l = ri();
			std::vector<std::pair<int64_t, int64_t> > all{{0, 0}};
			for (int j = x; ; j = (j - 1) / 2) {
				auto next = all;
				for (auto k : all) next.push_back({k.first + info[j].first, k.second + info[j].second});
				all = next;
				if (!j) break;
			}
			int64_t res = 0;
			for (auto i : all) if (i.first <= l) res = std::max(res, i.second);
			printf("%" PRId64 "\n", res);
		}
		return 0;
	}
	
	int q = ri();
	qs.resize(n);
	res.resize(q);
	for (int i = 0; i < q; i++) {
		int x = ri() - 1;
		int l = ri();
		qs[x].push_back({l, i});
	}
	
	dfs(0, 0);
	
	for (auto i : res) printf("%" PRId64 "\n", i);
	
	return 0;
}


Measured memory_bytes: 15644
c = 0
while True:
    c +=1
    L = []
    num = int(input())
    if num == 0:
        break
    
    for i in range(num):
        name, w, l, d = input().split()
        w = int(w)
        d = int(d)
        L.append((i,name,w*3+d))
    
    L.sort(key=lambda x: (-x[2],x[0]))
    
    if c > 1:
        print()
        
    for l in L:
        print("{},{}".format(l[1], l[2]))


Measured memory_bytes: 5604
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        int[] hw = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var h = hw[0];
        var w = hw[1];

        string[] tmp = new string[h];
        for (int i = 0; i < h; i++)
        {
            tmp[i] = Console.ReadLine();
        }

        char[][] jagArray1 = new char[h][];
        for (int i = 0; i < jagArray1.Length; i++)
        {
            string t = tmp[i];
            jagArray1[i] = t.ToCharArray();
        }

        string ans = "Yes";
        for (int i = 0; i < h; i++)
        {
            for (int k = 0; k < w; k++)
            {
                // # の場合上下左右に#があることを確認する
                if (jagArray1[i][k] == '#')
                {
                    bool flag = false;
                    //上確認
                    if (i != 0 && jagArray1[i - 1][k] == '#')
                    {
                        flag = true;
                    }
                    //下確認
                    if (i != h - 1 && jagArray1[i + 1][k] == '#')
                    {
                        flag = true;
                    }
                    //左確認
                    if (k != 0 && jagArray1[i][k - 1] == '#')
                    {
                        flag = true;
                    }
                    //右確認
                    if (k != w - 1 && jagArray1[i][k + 1] == '#')
                    {
                        flag = true;
                    }

                    if (!flag)
                    {
                        ans = "No";
                        break;
                    }

                }
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#include <complex>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef complex<double> P;


// 点 a を中心に arg だけ回転する単位ベクトルを加算
P rot (P a, double arg )
{
	P r = P (cos(arg), sin(arg ));
	P res = a*r;
	res /= abs(res);

	return res + a;
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.TH2", "r", stdin );
	while (1 ){
		P p = P(1.,0.);
		int n;
		scanf ("%d", &n );
		if (n == -1 ) break;
		while (--n ) p = rot (p, M_PI/2. );
		printf ("%.2lf %.2lf\n", p.real(), p.imag() );
	} // end loop
	
	return 0;
}

Measured memory_bytes: 1244
import sys

l = []
for i in sys.stdin:
    l.append(i.split())

for i in range(0,len(l)):
    print(int(int(l[i][0]) / int(l[i][1])),int(int(l[i][0]) % int(l[i][1])),'%.5f' % float(int(l[i][0]) / int(l[i][1])))


Measured memory_bytes: 5620
n = gets.to_i
h = gets.chomp.split
n.times do |i|
    h[i] = h[i].to_i
end

count = 1
prev = h[0]
max = h[0]
(1..(n-1)).each do |i|
    count += 1 if max <= h[i] && prev <= h[i]
    max = h[i] if max < h[i]
    prev = h[i]
end

puts count

Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

void max_self(ll& a, ll b) {
    a = max(a, b);
}

int main() {
    int n, W;
    scanf("%d%d", &n, &W);
    vector<ll> dp(W + 1); // 0 ... W
    // dp[i] - the maximum total value of items with total weight exactly
    for(int item = 0; item < n; ++item) {
        int weight, value;
        scanf("%d%d", &weight, &value);
        // dp[0] -> dp[3] -> dp[6]
        for(int weight_already = W - weight; weight_already >= 0; --weight_already) {
        //~ for(int weight_already = 0; weight_already <= W - weight; ++weight_already) {
            max_self(dp[weight_already+weight], dp[weight_already] + value);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= W; ++i) {
        max_self(answer, dp[i]);
    }
    printf("%lld\n", answer);
}


Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() 
{
	long long i,n,w,j;
	cin>>n>>w;
	long long weight[w+1];
	long long value[n+1];
	for(i=0;i<n;i++)
	cin>>weight[i]>>value[i];
	long long dp[n+1][w+1];
	for(i=0;i<=n;i++)
	{
	    for(j=0;j<=w;j++)
	    {
	        if(i==0 || j==0)
	        dp[i][j]=0;
	        else if(weight[i-1]>j)
	        dp[i][j] = dp[i-1][j];
	        else
	        dp[i][j] = max(dp[i-1][j- weight[i-1]]+value[i-1],dp[i-1][j]);
	    }
	}
	cout<<dp[n][w];
	return 0;
}


Measured memory_bytes: 82472
#include <iostream>

int main()
{
  int n, m, x;
  int a[120];
  int t[120] = {0};

  std::cin >> n >> m >> x;

  for (int i = 0; i < m; ++i) {
    std::cin >> a[i];
    t[a[i]]++;
  }
  int left = 0;
  int right = 0;

  for (int i = x; i < n+1; ++i) {
    if (t[i] == 1) {
      left++;
    }
  }
  for (int i = x; i > 0; --i) {
    if (t[i] == 1) {
      right++;
    }
  }
  int min = left;
  if (min > right) {
    min = right;
  }
  
  std::cout << min << std::endl;

  return 0;
}


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

int main() {
	int a, b, m;
	int apls, bpls,amin= 1000000,bmin = 1000000;
	int mini = 1000000;
	
	cin >> a >> b >> m;
	vector<int>ap(a), bp(b);
	vector<vector<int>>mc(m,vector<int>(3));
	for (int i = 0; i < a; i++) {
		cin >> ap.at(i);
		amin = min(amin, ap.at(i));
	}
	for (int i = 0; i < b; i++) {
		cin >> bp.at(i);
		bmin = min(bmin, bp.at(i));
	}
	for (int i = 0; i < m; i++) {
		cin >> mc.at(i).at(0) >> mc.at(i).at(1) >> mc.at(i).at(2);
	}

	for (int i = 0; i < m; i++) {
		apls = ap.at(mc.at(i).at(0) - 1);
		bpls = bp.at(mc.at(i).at(1) - 1);
		mini = min(mini, apls + bpls - mc.at(i).at(2));
	}

	cout << min(mini,amin + bmin) << endl;

}


Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define INF 10000000000

ll a, b, c, n, m, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s;

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

    ll d;
    cin >> a >> b >> c >> d >> n;
    c = min(c, 2 * min(b, 2 * a));
    cout << n / 2 * min(d, 2 * c) + (n % 2) * c << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int sm(long long a)
{
    int ret=0;
    while (a)
    {
        ret+=a%10;
        a/=10;
    }
    return ret;
}
int main()
{
    long long cur=1;
    int k;
    scanf("%d",&k);
    while (k--)
    {
        printf("%lld\n",cur);
        long long best=-1;
        for (long long add=1;add<=1000000000000000;add*=10)
            if (best==-1||best*sm(cur+add)>(cur+add)*sm(best))
                best=cur+add;
        cur=best;
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    lint a[m];
    rep(i, m) scanf("%lld", &a[i]);
    lint sum = accumulate(a, a+m, 0LL);
    printf("%lld\n", sum <= n ? n-sum : -1);
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}
template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}
template<class Type> Type igcd(Type x,Type y){if(x==0||y==0)return (x>y)?x:y;return (y%x)?igcd(y%x,x):x;}
template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	vvi d(n,vi(n));
	REP(i,n)REP(j,n) cin>>d[i][j];
	
	llong sum=0;
	REP(i,n)REP(j,i+1) sum+=d[i][j];
	
	bool jud[n][n]={};
	REP(k,n)REP(i,n)REP(j,i+1){
		if(k==i or k==j) continue;
		if(d[i][j]>d[i][k]+d[k][j]){
			cout<<-1<<endl;
			return 0;
		}else if(d[i][j]==d[i][k]+d[k][j]){
			if(!jud[i][j]){
				sum-=d[i][j];
				jud[i][j]=true;
			}
		}
	}
	
	cout<<sum<<endl;
}

Measured memory_bytes: 640