akhauriyash/Code-Regression huggingface dataset:
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
using mint = modint998244353;
int op(int a, int b) {return max(a, b);}
int e() {return 0;}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  segtree<int, op, e> seg(300001);
  REP(i, N) {
    int v = seg.prod(max(0, A[i]-K), min(300001, A[i]+K+1)) + 1;
    if(seg.get(A[i]) < v) seg.set(A[i], v);
  }
  cout << seg.prod(0, 300001) << endl;
}

Measured memory_bytes: 9804
#include<stdio.h>

int main(){
    int M,D;
    int i,j;
    int cnt=0;

    scanf("%d %d",&M,&D);
    for(i=1 ; i <= M ;i++){
        for(j=1; j <= D; j++){
            int j_10,j_1;
            j_1 = j % 10;
            j_10 = (j - j_1) / 10;
            if(i == j_1*j_10 && j_1 >= 2 && j_10 >= 2){
                cnt++;
            } 
        } 
    }
    printf("%d",cnt);
    return 0;
}

Measured memory_bytes: 128
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

// 1. dp?????????
//???????????\??????????????\
//????????????????????????????????
//?????????????????????????????????
//????????????????????????????????
//???????????????????????????????

int dp[1001][1001];
// 2. n?????????
int N,M;
int C[1001],D[1001];
// 7. calc?????????
int calc(int k,int p){
	// 8. dp???????????°??????
	if(dp[k][p]>=0)return dp[k][p];
	// 9. dp????¨????
	if(k==p){
		dp[k][p]=calc(k-1,p-1)+C[p]*D[k];
	}else{
		dp[k][p]=min(calc(k,p-1),calc(k-1,p-1)+C[p]*D[k]);
	}

	return dp[k][p];
}
int main() {
	cin>>N>>M;

	//3.?????????
	for(int i=0;i<1001;i++){
		for(int j=0;j<1001;j++){
			dp[i][j]=-1;
		}
	}
	//4.??\???
	for(int i=1;i<N+1;i++){
		cin>>D[i];
	}
	for(int j=1;j<M+1;j++){
		cin>>C[j];
	}

	//5.???????????¨???

		for(int j=0;j<M+1;j++){
			dp[0][j]=0;
		}


	//6.??????


	cout<<calc(N,M)<<endl;



	return 0;
}

Measured memory_bytes: 7032
#include<bits/stdc++.h>
using namespace std;
#define task "atcoderd"
#define lwb lower_bound
#define upb upper_bound
#define ar array
#define fi first
#define se second
#define ALL(v) (v).begin(), (v).end()
typedef long double ld;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll,ll> pii;

int dd[1000005];
void solve()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    s=' '+s;
    int cnt=0;
    int ans=1e9;
    /// change to red
    for(int i=1;i<n;++i) if(s[i]=='W') ++cnt;
    ans=min(ans,cnt);
    /// change to white
    cnt=0;
    for(int i=2;i<=n;++i) if(s[i]=='R') ++cnt;
    ans=min(ans,cnt);
    /// move all white to right
    cnt=0;
    for(int i=1;i<=n;++i) if(s[i]=='W') ++cnt;
    int num=cnt;
    for(int i=n;i>=n-num+1;--i) if(s[i]=='W') --cnt;
    ans=min(ans,cnt);
    /// move all red to left
    cnt=0;
    for(int i=1;i<=n;++i) if(s[i]=='R') ++cnt;
    num=cnt;
    for(int i=1;i<=num;++i) if(s[i]=='R') --cnt; else break;
    ans=min(ans,cnt);
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(fopen(task".inp","r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    solve();
}







Measured memory_bytes: 3864
N = int(input())
now_t = 0
now_x = 0
now_y = 0
flag = 0
for i in range(N):
    t,x,y = map(int,input().split())
    if abs(x-now_x)+abs(y-now_y)<= abs(t-now_t) and (abs(x-now_x)+abs(y-now_y))%2 == abs(t-now_t)%2:
        now_t = t
        now_x = x
        now_y = y
    else:
        flag += 1
        break
if flag == 0:
    print("Yes")
else:
    print("No")

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

const int MAX_NUMBER = 55555;

vector<int> prime_numbers(int n){
  vector<bool> a(MAX_NUMBER+1, true);
  vector<int> ans;
  a[0] = a[1] = false;
  for(int i = 2; i <= MAX_NUMBER; ++i){
    if(a[i]){
      if(i % 5 == 1){
        ans.push_back(i);
        if(ans.size() >= n) break;
      }
      for(int j = i+i; j <= MAX_NUMBER; j += i){
        a[j] = false;
      }
    }
  }
  return ans;
}

int main(){
  int n;
  cin >> n;
  const auto& primes = prime_numbers(n);
  for(int i = 0; i < n; ++i){
    cout << primes[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10
    K = II()
    S = input()
    N = len(S)
    def gencmb(n,k):
        # N-1+K C K  ... N-1 C 0
        ans = [1]*(k+1)
        for i in range(1,k+1):
            ans[-i-1] = ans[-i] * (N+i-1) * pow(i,P-2,P) % P
        return ans
    ans = 0
    pow26 = [0] * (K+1)
    pow26[0] = 1
    for i in range(1,K+1):
        pow26[i] = pow26[i-1] * 26 % P
    pow25 = [0] * (K+1)
    pow25[0] = 1
    for i in range(1,K+1):
        pow25[i] = pow25[i-1] * 25 % P
    cmb = gencmb(N,K)
    for t in range(K+1):
        ans += pow26[t]*pow25[K-t]*cmb[t]%P
        ans %= P
    print(ans)

    
main()

Measured memory_bytes: 193760
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#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 XOX
    ~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__) << ", "

#define F first
#define S second
#define endl '\n'
#define pb emplace_back
#define mp make_pair
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define all(v) (v).begin(), (v).end()
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie();                    \
    cout.tie()
#define min3(x, y, z) (x < y ? (x < z ? x : z) : (y < z ? y : z))
#define max3(x, y, z) (x > y ? (x > z ? x : z) : (y > z ? y : z))
#define MAX_N int(1e6 + 7)
#define MAX_M int(1e6 + 7)
#define MAX_V int(1e6 + 7)
#define oo int(1e9 + 217)
#define MOD int(1e9 + 7)
using ll = long long;
using vi = vector< int >;
using vl = vector< ll >;
using vpii = vector< pair< int, int > >;
using pii = pair< int, int >;

typedef tree<
    int,
    null_type,
    less< int >,
    rb_tree_tag,
    tree_order_statistics_node_update >
    oset;

void solve()
{
}

int main()
{
    fast;
    int n;
    cin >> n;
    vector< int > dp(n + 1, 1);
    dp[ 1 ] = dp[ 2 ] = 0;
    for (int i = 4; i <= n; i++)
        for (int j = 3; j <= n; j++)
        {
            if (i - j >= 3)
                dp[ i ] = (dp[ i ] + dp[ i - j ]) % MOD;
        }
    cout << dp[ n ];
}

Measured memory_bytes: 3560
#include <stdio.h>

int main(void)
{
	int H[1024],W[1024],h,i,j,k,l;
	for(k=0;k<1024;k++){
		scanf("%d %d",&H[k],&W[k]);
		if(H[k]==0&&W[k]==0) break;
	}
	for(l=0;l<1024;l++){
		if(H[l]==0&&W[l]==0) break;
		for(i=0;i<H[l];i++){
			if(i==0||i==(H[l]-1)){
				for(j=0;j<W[l];j++){
					printf("#");
				}
			}else{
				printf("#");
				for(h=1;h<(W[l]-1);h++){
					printf(".");
				}
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 580
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define PB push_back
#define SZ size
#define MP make_pair

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const ll INF = (1LL << 58);
const bool DEBUG = 0;

std::vector<int> adj[100005];
ll val[100005];
bool vis[100005], hasAns = 1;

ll dfs(int node)
{
	vis[node] = 1;
	int i, limit = adj[node].SZ();
	ll X = val[node] * 2, thisSum = 0;
	if(limit == 1)
		X /= 2;
	fl(i,0,limit)
	{
		int v = adj[node][i];
		if(vis[v])	continue;
		ll currVal = dfs(v);
		if(currVal < 0 || currVal > val[node])
			hasAns = 0;
		thisSum += currVal;
	}
	ll ret = X - thisSum;
	if(ret > val[node])
		hasAns = 0;
	return ret;
}

int main()
{
	int i, j;

	int nodes;

	si(nodes);

	fl(i,0,nodes)
	{
		sll(val[i]);
	}

	fl(i,0,nodes - 1)
	{
		int x, y;
		si(x);	si(y);
		x--;	y--;
		adj[x].PB(y);	adj[y].PB(x);
	}

	ll ret = dfs(0);

	if(!hasAns || ret != 0)
		printf("NO\n");
	else
		printf("YES\n");


	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 11904
// In the name of Allah the Most Merciful.

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

typedef long long ll;

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

    ll n , d;
    cin >> n >> d;
    ll temp = 2*d+1;
    cout << (n+temp-1)/temp << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int a, b;
   cin >> a >> b;
   cout << (max(a, b) < 9 ? "Yay!" : ":(") << endl;
   return 0;
}


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
































string s;
int l;
int main()
{
    cin>>s;
    l=s.size();
    for(register int i=0;i<l;i++)
    {
        if(s[i]=='C')
        {
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            for(register int j=i+1;j<l;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

    long M = 1_000_000_007;
    int N = scanner.nextInt();

    int[] primes = findPrimes(1000);
    int[] primeFactorCounts = new int[primes.length];
    for (int i = 2; i <= N; i++) {
      int n = i;
      for (int j = 0; j < primes.length && n > 0; j++) {
        int p = primes[j];
        while (n % p == 0) {
          n /= p;
          primeFactorCounts[j]++;
        }
      }
    }

    long res = 1;
    for (int c : primeFactorCounts) {
      res *= c + 1;
      res %= M;
    }
    System.out.println(res);
  }

  private static int[] findPrimes(int n) {
    boolean[] prime = new boolean[n + 1];
    for (int i = 2; i <= n; i++) prime[i] = true;
    for (int i = 2; i * i <= n; i++)
      for (int j = i * 2; j <= n; j += i)
        prime[j] = false;
    List<Integer> primes = new ArrayList<>();
    for (int i = 0; i <= n; i++) if (prime[i]) primes.add(i);
    int[] res = new int[primes.size()];
    for (int i = 0; i < primes.size(); i++) res[i] = primes.get(i);
    return res;
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main() {
    int N, M; cin >> N >> M;
    vector<int> H(N + 5), ans(N + 5);
    rep(i, N) {
        cin >> H[i];
        ans[i] = 1;
    }

    int i, j;
    rep(_, M) {
        cin >> i >> j;
        i--;
        j--;

        if (H[i] > H[j]) ans[j] = 0;
        else if (H[i] < H[j]) ans[i] = 0;
        else {
            ans[i] = 0;
            ans[j] = 0;
        }
    }

    int sum = 0;
    rep(i, N) sum += ans[i];
    cout << sum << endl;
}

Measured memory_bytes: 4048
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
def dfs(curx,cury):
    global Map
    if Map[cury][curx] == 1:
        Map[cury][curx] = 0
        dfs(curx+1,cury)
        dfs(curx-1,cury)
        dfs(curx,cury+1)
        dfs(curx,cury-1)
        dfs(curx+1,cury-1)
        dfs(curx-1,cury-1)
        dfs(curx-1,cury+1)
        dfs(curx+1,cury+1)
    else:
        return
w = -1
h = -1
while(w != 0 and h != 0):
    w,h = map(int,input().split())
    if w == 0 and h == 0:
        break
    Map = [[0]*(w+2)]
    for _ in range(h):
        li = list(map(int,input().split()))
        a = [0]+li+[0]
        Map.append(a)
    Map.append([0]*(w+2))
    s = 0
    for i in range(w):
        for j in range(h):
            if Map[j+1][i+1] == 1:
                s += 1
                dfs(i+1,j+1)
    print(s)





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

int main() {
	int n, m;
	cin >> n >> m;
	vector<string> a(n), b(m);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < m; i++)
		cin >> b[i];
	for (int i = 0; i <= n - m; i++) {
		for (int j = 0; j <= n - m; j++) {
			bool ok = true;
			for (int k = 0; k < m; k++)
				for (int l = 0; l < m; l++)
					if (a[i + k][j + l] != b[k][l])
						ok = false;
			if (ok) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll mod_pow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1)res=res*x%MOD;
		x=x*x%MOD;
		n>>=1;
	}
	return res;
}

ll inverse_element(ll t){
	return mod_pow(t,MOD-2);
}


ll h,w,a,b;
ll ans=0;
ll fnc[200100];
void fnc1(){
	fnc[0]=1;
	ll anst=1;
	for(ll i=1;i<200100;i++){
		anst=anst*i%MOD;
		fnc[i]=anst;
		//cout<<anst<<endl;
	}
}
ll calc(ll t,ll s){
	ll tans=1;
	tans*=fnc[t+s];
	//cout<<"1:"<<tans<<endl;
	tans*=inverse_element((fnc[t]*fnc[s])%MOD);
	//cout<<"2:"<<tans<<endl;
	return tans%MOD;
}
int main(){
	fnc1();
	cin>>h>>w>>a>>b;
	for(ll i=0;i<h-a;i++){
		ans+=(calc(b-1,i)*calc(w-b-1,h-i-1))%MOD;
		//cout<<i<<" "<<ans<<endl;
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<functional>
#include<string>
#include<vector>
#include<cstring>
#include<utility>
#include<set>
#include<map>

#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 2e9
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()
const double PI = acos(-1);

using namespace std;

int main(void) {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//	freopen("input.txt", "r", stdin);
	
	int K; cin >> K;
	int val = 7;
	int cnt = 1;
	while (cnt < 1000000) {
		if (val%K == 0) {
			break;
		}
		else {
			val *= 10;
			val += 7;
			val %= K;
			cnt++;
		}
	}
	if (cnt == 1000000) cout << -1;
	else cout << cnt;

}


Measured memory_bytes: 3608
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int


int n, k;
vector<int> d;

int to_num(int num);

int main(){
    cin >> n >> k;
    d.resize(k);
    in_arr(int, d, k);
    for(int i = n; i < n * 100; i++){
        int num = i;
        bool flag = true;
        while(num > 0){
            if(find(d.begin(), d.end(), num % 10) != d.end()){
                flag = false;
                break;
            }
            num /= 10;
        }
        if(flag){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


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

typedef struct{
	int flg[4];
}Point;

int main(void){
	int di[] = {-1,0,1,0};
	int dj[] = {0,1,0,-1};
	char ch[] = "URDL";
	Point p[5][5];
	memset(p,0,sizeof(p));

	for(int i=0;i<9;i++){
		char wall[8];
		cin>>wall;
		if(i % 2){
			for(int j=0;j<5;j++){
				p[i/2][j].flg[2] = p[i/2+1][j].flg[0] = wall[j] - '0';
			}
		}
		else{
			for(int j=0;j<4;j++){
				p[i/2][j].flg[1] = p[i/2][j+1].flg[3] = wall[j] - '0';
			}
		}
	}

	int pi=0, pj=1, d=1;
	cout<<"R";
	while(pi != 0 || pj != 0){
		int front = p[pi][pj].flg[d];
		int left = p[pi][pj].flg[(d+3)%4];

		if(left == 1 || left == 0 && front == 1){
			if(left == 1) d = (d+3)%4;
			cout<<ch[d];
			pi += di[d];
			pj += dj[d];
		}
		else{
			d = (d+1)%4;
		}
	}
	cout<<endl;

	return 0;
}

Measured memory_bytes: 0
import math

a,b,h,m = map(int,input().split())



d = abs(30*h - 5.5*m)
if(d > 180):
    d = 360 - d

#print(d)
ans = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(d)))
print(ans)



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

vector<int> D;
vector<vector<int>> G;
vector<bool> fix;
int dfs(int x) {
	int mx = 0;
	if (fix[x]) return D[x];

	for (auto y : G[x]) {
		mx = max(mx, dfs(y));
	}

	D[x] = mx + 1;
	fix[x] = true;

	return mx + 1;
}

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

	G.resize(N + 1);

	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
	}

	D.resize(N + 1, 0);
	fix.resize(N + 1, 0);

	int ans = 0;

	for (int i = 1; i <= N; i++) {
		if (!fix[i]) ans = max(ans, dfs(i));
	}

	cout << ans - 1 << endl;

}


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

#define mod 1000000007

int main(){
    int n, k;
    cin >> n >> k;
    long long t = sqrt(n);
    #ifdef DEBUG
    cout << "t = " << t << "\n";
    #endif // DEBUG
    vector<vector<long long> > dp1(k + 1, vector<long long>(t + 1, 0)), dp2(k + 1, vector<long long>(t + 1, 0));
    vector<vector<long long> > s1(k + 1, vector<long long>(t + 1, 0)), s2(k + 1, vector<long long>(t + 1, 0));
    for(int i = 1; i <= k; i++){
        #ifdef DEBUG
        cout << "i = " << i << "\n";
        #endif // DEBUG
        for(int x = 1; x <= t; x++){
            if(i == 1){
                dp1[i][x] = dp2[i][x] = 1;
                s1[i][x] = (s1[i][x - 1] + dp1[i][x]) % mod;

            } else {
                dp1[i][x] = ((dp1[i][x] + s1[i - 1][t]) % mod + s2[i - 1][x]) % mod;
                dp2[i][x] = (dp2[i][x] + s1[i-1][x]) % mod;
                s1[i][x] = (s1[i][x - 1] + dp1[i][x]) % mod;
            }
        }
        for(int x = t; x >= 1; x--){
            if(x != t)
                s2[i][x] = (s2[i][x+1] + (1LL * (n / x - (n / (x+1) + 1) + 1) * dp2[i][x]) % mod) % mod;
            else
                s2[i][x] = ((1LL * (n / x - (t + 1) + 1) * dp2[i][x]) % mod) % mod;
        }
        #ifdef DEBUG
        for(int x = 1; x <= t; x++){
            cout << "x = " << x << ": dp1[" << i << "][" << x<< "]=" << dp1[i][x] << "  dp2[" << i << "][" << x<< "]=" << dp2[i][x] << "  s1[" << i << "][" << x<< "]=" << s1[i][x] << "  s2[" << i << "][" << x<< "]=" << s2[i][x] << "\n";
        }
        /*s2[i][x], x, i, x, dp1[i][x], i, x, dp2[i][x], i, x, s1[i][x], i, x, s2[i][x]);
        cout << dp1[i][x] << "\n";
        */
        #endif // DEBUG
    }
    long long ans = 0;
    for(int x = 1; x <= t; x++){
        ans = (ans + dp1[k][x]) % mod;
        if(x != t){
            ans = (ans + (1LL * ((n / x) - ((n / (x+1)) + 1) + 1) * dp2[k][x]) % mod) % mod;
        } else{
            ans = (ans + (1LL * ((n / x) - (t + 1) + 1) * dp2[k][x]) % mod) % mod;
        }
    }
    cout << ans;
}


Measured memory_bytes: 103276
package main

import (
	"fmt"
	"math"
)

func isPrime(x int) bool{
	// 合成数xは p<=√x を満たす素因数pを持つ
	if x == 2{
		return true
	}else if x%2 == 0 || x<2{
		return false
	}else{
		n := int(math.Sqrt(float64(x)))
		for i:=3; i<=n; i+=2{
			if x%i == 0{
				return false
			}
		}
	}
	return true
}
func main(){
	var n, cmt, num int
	fmt.Scan(&n)
	for i:=0; i<n; i++{
		fmt.Scan(&num)
		if isPrime(num){
			cmt++
		}
	}
	fmt.Println(cmt)
}


Measured memory_bytes: 1648
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

int main() {
	int A, B, Q;
	cin >> A >> B;
	int resultValue = 0;
	for (int i = 0; i < 2; ++i)
	{
		if (max(A, B) == A)
		{
			resultValue += A;
			--A;
		}
		else
		{
			resultValue += B;
			--B;
		}
	}
	cout << resultValue << endl;

	return 0;
}


Measured memory_bytes: 256
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 aa = a + a - 1;
		int ab = a + b;
		int bb = b + b - 1;

		int sum = Math.max(aa, ab);

		System.out.println(Math.max(sum, bb));

		sc.close();

	}
}

Measured memory_bytes: 35428
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
bool f[20000];
int n,m;
pair<int,pair<int,int> >t[20000];
int main(){
	while(cin>>n>>m&&n+m){
	for(int i=1;i<n;i++)f[i]=0;
	f[0]=1;
	for(int i=0;i<m;i++){
		cin>>t[i].X>>t[i].Y.X>>t[i].Y.Y;
		t[i].Y.X--,t[i].Y.Y--;
	}
	sort(t,t+m);
	for(int i=0;i<m;i++){
		if(f[t[i].Y.X])f[t[i].Y.Y]=1;
	}
	int ans=0;
	for(int i=0;i<n;i++)ans+=f[i];
	cout<<ans<<endl;
	}
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 3260
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int c=0;
    int f=1;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]!=t[i])
        {
            f=0;
            break;
        }
        else
        {
            c++;
        }
    }
    if(f==0)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 3628
from collections import deque

head = deque()
tail = deque()
count_rev = 0
switch = 0

S = input()
Q = int(input())

for i in range(Q):
    q = input()
    if(q == '1'):
        count_rev += 1
        if(switch == 1):
            switch = 0
        else:
            switch = 1

    else:
        tmp, f, c = q.split()
        if(f == '1'):
            # put head
            if(switch == 0):
                head.appendleft(c)
            else:
                tail.append(c)
        else:
            # put tail
            if(switch == 0):
                tail.append(c)
            else:
                head.appendleft(c)

reversed(head)
if(count_rev % 2 == 0):
    ans = list(head) + list(S) + list(tail)
else:
    s = list(S)
    s.reverse()
    ans = list(reversed(tail)) + s + list(reversed(head))

print(''.join(ans))

Measured memory_bytes: 10036
import java.util.*;

import static java.lang.System.*;

class Main {
	public static Scanner sc = new Scanner(in);
	public static Random rand=new Random();


	int[][] mov=new int[][]{{1,0},{0,1},{-1,0},{0,-1}};
	public void run() {
		while(true){
			int n=sc.nextInt();
			if(n==0)return;
			int size=sc.nextInt();
			int[] d=new int[size-1];
			int[] dir=new int[size-1];
			{
				int xprev=sc.nextInt(),yprev=sc.nextInt();
				for(int i=0;i<size-1;i++){
					int x=sc.nextInt(),y=sc.nextInt();
					if(x==xprev){
						if(y>yprev)dir[i]=1;
						else dir[i]=3;
						d[i]=Math.abs(y-yprev);
					}else{
						if(x>xprev)dir[i]=0;
						else dir[i]=2;
						d[i]=Math.abs(x-xprev);
					}
					xprev=x;yprev=y;
				}
			}
			check:for(int i=1;i<=n;i++){
				int s=sc.nextInt();
				int[] xs=new int[s];
				int[] ys=new int[s];
				for(int j=0;j<s;j++){
					xs[j]=sc.nextInt();
					ys[j]=sc.nextInt();
				}
				if(s!=size)continue;

				for(int D=0;D<4;D++){
					int x=xs[0],y=ys[0];
					boolean ok=true;
					for(int j=0;j<s-1;j++){
						x+=d[j]*mov[(dir[j]+D)%4][0];
						y+=d[j]*mov[(dir[j]+D)%4][1];
						if(x!=xs[j+1] || y!=ys[j+1])
							ok=false;
					}
					if(ok){
						ln(i);
						continue check;
					}
				}
				for(int D=0;D<4;D++){
					int x=xs[0],y=ys[0];
					boolean ok=true;
					for(int j=0;j<s-1;j++){
						x+=d[s-2-j]*mov[(dir[s-2-j]+D)%4][0];
						y+=d[s-2-j]*mov[(dir[s-2-j]+D)%4][1];
						if(x!=xs[j+1] || y!=ys[j+1])
							ok=false;
					}
					if(ok){
						ln(i);
						continue check;
					}
				}

			}
			ln("+++++");
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}

	public int[] nextIntArray(int n){
		int[] res=new int[n];
		for(int i=0;i<n;i++){
			res[i]=sc.nextInt();
		}
		return res;
	}
	public static void pr(Object o) {
		out.print(o);
	}
	public static void ln(Object o) {
		out.println(o);
	}
	public static void ln() {
		out.println();
	}
}

Measured memory_bytes: 29328
n = input()

ret = ''
if n[0]=='1':
    ret +='9'
else:
    ret += '1'

if n[1]=='1':
    ret+='9'
else:
    ret+='1'

if n[2]=='1':
    ret+='9'
else:
    ret+='1'

print(ret)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma GCC optimize("O999")
//#define long long ll
const int INF=0x3f3f3f3f;
const int maxn=50000005;
using namespace std;

int main(){
	//freopen(".in", "r",stdin );
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(0);
	int a, b;
	cin >> a >> b;
	b*=2;
	if(b<a)
		cout<<a-b<<endl;
	else
		cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAXN = 2e3+2+3;
string A;
string B;

int N;
int st[2*MAXN];
int lf[MAXN],rg[MAXN];

void build_st() {
        for (int i=0; i<2*N; i++)
                st[i] = 0;

        for (int i=0; i<N; i++)
                st[lf[i]+N] = max(st[lf[i]+N],rg[i]);

        for (int i=N-1; i>=0; --i)
                st[i] = max(st[2*i],st[2*i+1]);
}

int query(int a, int b) {
        int res=0;
        for (a+=N, b+=N; a<b; a>>=1, b>>=1) {
                if (a&1) res = max(res,st[a++]);
                if (b&1) res = max(res,st[--b]);
        }
        return res;
}

bool trivial() {
        for (int i=0; i<N; i++)
                if (B[i] == '1')
                        return false;

        if (A == B)
                cout << "0\n";
        else
                cout << "-1\n";
        return true;
}

int main() {
        cin >> A >> B;
        N = A.size();

        if (trivial())
                return 0;

        int mn=4*N;
        for (int offset=0; offset<N; ++offset) {
                for (int i=0; i<N; i++)
                        lf[i] = rg[i] = 0;
                int last1=0;
                for (int i=0; i<N; i++)
                        if (B[i] == '1')
                                last1 = i;
                for (int i=0; i<N; i++) {
                        if (B[i] == '1')
                                last1 = i;
                        if (A[i] != B[(i+offset)%N])
                                lf[i] = (i-last1+N)%N;
                }
                for (int i=N-1; i>=0; --i)
                        if (B[i] == '1')
                                last1=i;
                for (int i=N-1; i>=0; --i) {
                        if (B[i] == '1')
                                last1 = i;
                        if (A[i] != B[(i+offset)%N])
                                rg[i] = (last1-i+N)%N;
                }

                int mismatch=0;
                for (int i=0; i<N; i++)
                        if (A[i] != B[(i+offset)%N])
                                mismatch++;

                build_st();
                int mn_extra=N;
                for (int i=0; i<N; i++) {
                        int rd = query(i+1,N);
                        if (rd > offset)
                                mn_extra = min(mn_extra,i+rd-offset);
                        else
                                mn_extra = min(mn_extra,i);
                }
                mn = min(mn,offset+2*mn_extra+mismatch);

                mn_extra=N;
                for (int i=(N-offset)%N; i<N; i++) {
                        int rd = query(i+1,N);
                        mn_extra = min(mn_extra, i-(N-offset)%N+rd);
                }
                mn = min(mn,(N-offset)%N+2*mn_extra+mismatch);
        }

        cout << mn << "\n";
}

Measured memory_bytes: 256
#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        pp: [usize; n],
    }

    let mut tmin = pp[0];
    let mut cnt = 1;
    for i in 1..n {
        if pp[i] < tmin {
            cnt += 1;
            tmin = pp[i];
        }
    }


    println!("{}", cnt);
}


Measured memory_bytes: 6396
n,m,v,p = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
ok = p-1
ng = n
def solve(x):
    if a[x] + m < a[p-1]:
        return False
    now = 0
    for i in range(n):
        if i >= x:
            now += m
        elif i < p-1:
            now += m
        else:
            now += a[x] + m - a[i]
    if now >= m*v:
        return True
    else:
        return False

while ng - ok > 1:
    mid = (ng + ok)//2
    if solve(mid):
        ok = mid
    else:
        ng = mid

print(ok+1)

Measured memory_bytes: 14484
#include <iostream>

using namespace std;
int main(void){
    int max=-2147483648;
    int min=2147483647;
    long sum=0;
    
    int n,in;
    cin >> n;

    for (int i=0;i<n;i++){
        cin >> in;    
        if(min>in) min=in;
        
        if(max<in) max=in;

        sum = sum + in;
    }

    cout << min <<" "<< max <<" "<< sum << endl;            

    return 0;
}


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

int main(){
  string S;
  
  cin >> S;
  
  int sum = 0;
  
  if(S[0] == '1') sum += 1;
  if(S[1] == '1') sum += 1;
  if(S[2] == '1') sum += 1;
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#pragma region Template
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define EPS 1e-14
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define PI 2*acos(0.0)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(x) cout<<#x <<": "<< x << "\n"
#define DEBUG_ARR(a) REP(i, size(a)){ cout << #a << "[" << i << "]: " << a[i] << "\n"; }
const int VX[] = { 0, 1, 0, -1 };
const int VY[] = { 1, 0, -1, 0 };
const long MOD = 1000000007;

#pragma endregion

int main()
{
	//	--- I/O 高速化 ---
	cin.tie(0);
	ios::sync_with_stdio(false);
	// --- ここまで ---

	char c;
	char d[]= { 'a', 'e', 'i', 'o', 'u' };

	cin >> c;

	for (int i = 0; i < 5; i++)
	{
		if (c == d[i])
		{
			cout << "vowel\n";
			return 0;
		}
	}

	cout << "consonant\n";
	return 0;
}



Measured memory_bytes: 256
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes .by_ref() .map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input!(n: usize, a: usize, b: usize,);

    if n * a <= b {
        println!("{}", n * a);
    } else {
        println!("{}", b);
    }
}

Measured memory_bytes: 4352
N = int(input())

h = list(map(int, input().split()))

dp = [0] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, N):
  dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print(dp[N - 1])

Measured memory_bytes: 13928
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <queue>

using namespace std;

#define ll long long
constexpr ll inf = 1e9+7;

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

    ll N;
    cin>>N;
    vector<ll> P(N);
    for (ll n = 0; n < N; n++) cin>>P[n];

    ll ans = 0;
    for (ll n = 0; n < N - 1; n++) {
        if (P[n] == n+1) {
            P[n] = P[n+1];
            P[n+1] = n+1;
            ans++;
            continue;
        }
        if (n == N - 2 && P[N-1] == N) ans++;
    }
    cout<<ans<<endl;

    return 0;
}

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

int main() {
  int n, x; cin >> n >> x;
  vector<int> vec(n);
  for(int i=0; i<n; i++) cin >> vec[i];
  
  vector<int> vec2(n+1);
  vec2[0]= 0;
   for(int i=0; i<n; i++) vec2[i+1] += vec2[i] + vec[i];
  
  int ans=0;
  for(int i=0;i<=n;++i) if (vec2[i] <= x) ans++;
  
  cout << ans << endl;

  return 0;
}

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

#define endl '\n'
#define N 10000000

using namespace std;

typedef unsigned long long int ulli;

bool criba[N + 1];
ulli n, sumaHasta[N + 1], dp[N + 1];
vector<int> primos;

ulli f(ulli x)
{
    ulli copia = x, indice = 0, factor1 = 1, factor2 = 1;
    while (copia%primos[indice] != 0)
        ++indice;
    while (copia%primos[indice] == 0)
        copia /= primos[indice];
    factor1 = x / copia;
    factor2 = copia;
    return dp[factor1] * dp[factor2];
}

void precomputo()
{
    for (int i=2; i<=N; ++i)
        criba[i] = true;
    for (int i=2; i*i<=N; ++i)
        if (criba[i])
            for (int j=i*i; j<=N; j+=i)
                criba[j] = false;
    for (int i=0; i<=N; ++i)
        if (criba[i])
            primos.push_back(i);
    dp[1] = 1;
    sumaHasta[1] = 1 * dp[1];
    for (int i=0; i<primos.size(); ++i)
    {
        ulli indice = primos[i], exp = 1;
        while (indice <= N)
        {
            dp[indice] = (exp + 1);
            ++exp;
            indice *= primos[i];
        }
    }
    for (int i=2; i<=N; ++i)
    {
        if (!dp[i])
        {
            dp[i] = f(i);
        }
        sumaHasta[i] = sumaHasta[i - 1] + (i * dp[i]);
    }
}

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

    precomputo();

    ulli n;
    cin >> n;
    cout << sumaHasta[n] << endl;

    return 0;
}

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

template <typename Arg1>
void pn(Arg1&& arg1)
{ cout<<arg1<<"\n";}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<"\n"; pn(args...); }

template <typename Arg1>
void ps(Arg1&& arg1)
{ cout<<arg1<<" ";}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<" "; ps(args...); }

template <typename Arg1>
void pvs(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)ps(arg1[i]); }
template <typename Arg1>
void pvn(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)pn(arg1[i]); }

template <typename Arg1>
void bug(Arg1&& arg1)
{ cout<<"->"<<arg1<<endl; }

ll lcm(ll a,ll b) 
{ return (a*b)/__gcd(a,b); }

ll mulmod(ll a,ll b,ll mod) 
{ ll res=0; a=a%mod; 
    while(b>0)
    { if(b%2==1) res=(res+a)%mod; 
      a=(a*2)%mod; b/=2; }
    return res % mod; } 

ll powmod(ll x,ll y,ll p) 
{ ll res=1; x=x%p;
    while(y>0) 
    { if (y&1) res=(res*x)%p; 
      y=y>>1; x=(x*x)%p; } 
    return res; } 

ll modInverse(ll n, ll p) 
{ return powmod(n, p-2, p); } 

ll log(ll n, ll b)
{ ll c=0;
	while(n>(b-1))
	{ c++; n/=b; } return c; }

ll fib(ll n) 
{ double phi=(1+sqrt(5))/2; 
  return round(pow(phi,n)/sqrt(5)); } 

vector<bool> prime;
void sieve(int n)
{ prime.resize(n,true);
	for(int p=2;p*p<=n;p++)
		if(prime[p])
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false; }

void yes(){pn("Yes");}
void no(){pn("No");}
void bug(){cout<<"here"<<endl;}

#define MOD 1000000007 //10^9+7
#define pi 3.14159265358979323846
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<=n;i++)
#define fd(i,n) for(i=n-1;i>=0;i--)
#define fn(i,s,d) for(i=s;i<d;i++)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define pl pair<ll,ll>
#define pd pair<double,double>
#define vl vector<ll>
#define vb vector<bool>
#define vd vector<double>
#define vpl vector<pl>
#define vpd vector<pd>
#define vs vector<string>
#define vvl vector<vl>
#define vvs vector<vs>
#define vvpl vector<vpl>
#define ff first
#define ss second
#define um unordered_map
#define dsort(v) sort(v); reverse(v);
#define maxpq(v) priority_queue<v>
#define minpq(v) priority_queue<v,vector<v>,greater<v>>

void solve()
{
	ll i,j;
	ll n;
	cin>>n;
	if(n>=30)
		yes();
	else
		no();
}

int main()
{
	#ifdef Deeksha
		// freopen("../Downloads/validation_input.txt", "r", stdin);
		freopen("../Downloads/_input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif
	std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	solve();/* 
	ll t;
	cin>>t;
	for(ll tt=1;tt<=t;tt++)
	{
		// cout<<"Case #"<<tt<<": ";
		solve();
	}
	//*/
}



Measured memory_bytes: 3696
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if(A + B > C + D) cout << "Left" << endl;
  else if(A + B < C + D) cout << "Right" << endl;
  else cout << "Balanced" << endl;
  return 0;
}


Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 105005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,W;
    cin >> N >> W;
    ll w[100],v[100];
    REP(i,N){
        cin >> w[i] >> v[i];
    }
    vector< vector<ll> > knapsack(N,vector<ll>(W+1));
    REP(i,N){
        //cout << i << ":";
        if(i==0){
            REP(j,W+1)if(j>=w[0]){
                knapsack[0][j] = v[0];
            }else{
                knapsack[0][j] = 0;
            }
        }else{
            REP(j,W+1)if(j<w[i]){
                knapsack[i][j] = knapsack[i-1][j];
            }else{
                knapsack[i][j] = max(knapsack[i-1][j],knapsack[i-1][j-w[i]]+v[i]);
            }
        }
        //REP(j,W+1)cout << knapsack[i][j] << " ";
        //cout << endl;
    }
    cout << knapsack[N-1][W] << endl;
    return 0;
}


Measured memory_bytes: 79488
#include <iostream>
#include <utility>

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
#define mp make_pair
#define x first
#define y second

int main () {
	int a,b;
	cin>>a>>b;
	if(a<=b) cout<<"unsafe";
	else cout<<"safe";



return 0;
}

Measured memory_bytes: 3628
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int L[n], R[n]; for (int i = 0; i < n; i++) cin >> L[i] >> R[i];
    int r = max_element(L, L+n)-L, l = min_element(R, R+n)-R;
    if (l == r) {
        int ans = 0;
        for (int i = 0; i < n; i++)
            if (i != l) ans = max(ans, R[i] - L[i] + 1);
        cout << ans + R[r] - L[r] + 1 << endl;
    } else {
        vector<pair<int, int> > v;
        int ans = 0;
        for (int i = 0; i < n; i++)
            if (i != l && i != r) {
                v.push_back({L[i], R[i]});
                ans = max(ans, R[i] - L[i] + 1);
            }
        ans += max(0, R[l] - L[r] + 1);
        sort(v.begin(), v.end());
        int acc = R[r];
        for (int i = n-3; i >= 0; i--) {
            ans = max(ans, max(0, R[l] - max(v[i].first, L[l]) + 1) + max(0, acc - L[r] + 1));
            acc = min(acc, v[i].second);
        }
        ans = max(ans, max(0, R[l] - L[l] + 1) + max(0, acc - L[r] + 1));
        cout << ans << endl;
    }
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define lol        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define SIZE        1000005
#define debug(x)        cerr << #x << " = " << x << endl;

using namespace std;

void MOD(ll &x)
{
	if (x >= lol) x -= lol;
	if (x < 0) x += lol;
}


void solve()
{
	int n, k;
	cin>>n>>k;
	ll ans = 0;
	rep(i,1,n+1)
	{
	    int num = n/i;
	    int r = n%i;
	    ans += (ll)num*max(0,(i-k));
	    ans += (ll)max(0,(r-k+1));
	}
	if(!k)ans -= n;
	cout<<ans<<endl;
	
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	long long int n, count = 1;
	cin>>n;
	for(int i=2;i<=n;i++){
		if(i%3 != 0 && i%5 != 0)count = count + i;
	}
	cout<<count;
}


Measured memory_bytes: 3664
import scala.io.Source.stdin

object Main extends App {
  stdin.getLines.foreach { s=>
    var j=0;var i=0

    for(k <- 0 until s.length-2) {
      if(s(k) == 'J' && s(k+1) == 'O' && s(k+2) == 'I') j += 1
      if(s(k) == 'I' && s(k+1) == 'O' && s(k+2) == 'I') i += 1
    }
    println(j)
    println(i)
  }
}

Measured memory_bytes: 43848