akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <iostream>
#include <limits.h>

using namespace std;

int main(void) {
  int N, M, a[51], b[51], c[51], d[51], e[51], f[51], ca;
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i];
    e[i] = INT_MAX / 2;
  }
  for (int i = 0; i < M; i++) {
    cin >> c[i] >> d[i];
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      ca = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (e[i] > ca) {
        e[i] = ca;
        f[i] = j + 1;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    cout << f[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
	unsigned int n;
	while (true) {
		double ave = 0.0;
		double a = 0.0;
		vector<double> s;

		cin >> n;
		if (n == 0) break;

		s.resize(n);
		for (unsigned int i = 0; i < n; ++i) {
			cin >> s[i];
			ave += s[i];
		}
		ave /= n;
		for (unsigned int i = 0; i < n; ++i) {
			a += pow(fabs(s[i]-ave), 2);
		}

		cout << setprecision(10) << sqrt(a/n) << endl;
	}
	return 0;
}



Measured memory_bytes: 3296
#include <iostream>
using namespace std;
int main()
{
	int x;
	string s;
	cin>>s;
	for(x=0;x<=4;x++)
	{
		cout<<s[x];
	}
	cout<<" ";
	for(x=6;x<=12;x++)
	{
		cout<<s[x];
	}
	cout<<" ";
	for(x=14;x<=18;x++)
	{
		cout<<s[x];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
import collections


def main():


    N = int(input())
    sList = [input() for _ in range(N)]
    M = int(input())
    tLIst = [ input() for _ in range(M)]
    sDict = collections.Counter(sList)
    tDict = collections.Counter(tLIst)
    sDict.subtract(tDict)
    ansList = []
    for i in sDict:
        ansList.append(sDict[i])
    print(max(ansList)if max(ansList) > 0 else 0)






if __name__ == "__main__":
    main()



Measured memory_bytes: 38256
main = do
    n <- readLn :: IO Int
    let (x,y,z) = head [(h,w,(h*w*n) `div` (4*h*w-w*n-h*n))|h <- [1..3500], w <- [h..3500], (4*h*w-w*n-h*n) > 0, (h*w*n) `mod` (4*h*w-w*n-h*n) == 0]
    putStrLn $ show x ++ " " ++ show y ++ " " ++ show z

Measured memory_bytes: 508
from itertools import permutations
from math import sqrt
n = int(input())
xy = [list(map(int, input().split())) for i in range(n)]
l = []
for i in permutations(xy):
    m = 0
    for j in range(n - 1):
        m += sqrt((i[j + 1][0] - i[j][0]) ** 2 + (i[j + 1][1] - i[j][1]) ** 2)
    l.append(m)
print(sum(l) / len(l))

Measured memory_bytes: 4400
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

template<typename T>
vector<T> Divisor(T n) {
    vector<T> ret;
    for(T i=1; i*i<=n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n / i);
        }
    }
    return ret;
}

int main(void) {
    long long B;
    vector<pair<int, int>> out;
    while (1) {
        cin >> B;
        if (!B) break;
        long long b = B * 2;
        long long ans[2] = {0};
        // (a + a + n - 1) * n = b;
        vector<long long> ns = Divisor(b);
        for (long long n : ns) {
            if ((b-n*n+n) % (2*n) == 0) {
                long long tmp = (b-n*n+n) / (2*n);
                if (tmp > 0) {
                    ans[0] = tmp;
                    ans[1] = n;
                }
            }
        }
        out.push_back({ans[0], ans[1]});
    }
    for (auto &p : out) {
        cout << p.first << " " << p.second << endl;
    }
}   


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    int n,a;
    cin >> n >> a;
    cout << n * n - a << endl;
    return 0;
}

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

int main() {
  long long N;
  cin >> N;
  map <int, int> p;
  for(int i=1; i<=N; i++)
    p[i] = 0;
  
  for(int i=0; i<N-1; i++){
    int tmp;
    cin >> tmp;
    if(p.count(tmp)) p.at(tmp)++;
  }
  
  for(auto x : p){
    cout << x.second << endl;
  }
}

Measured memory_bytes: 13012
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;

int main() {
  int N;
  long long Ans=0;
  
  cin>>N;
  vector<long long> A(N),Sum(N);
  
  rep(i,N){cin >> A.at(i);
           Sum.at(i)=A.at(i);
          }
  rep(i,N-1){Sum.at(N-i-2)=(Sum.at(N-i-2)+Sum.at(N-i-1))%MOD;}

  rep(i,N-1){Ans=(Ans+A.at(i)*Sum.at(i+1))%MOD;}

  cout<<Ans<<endl;

}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, a, b;
  string s;
  cin >> n >> a >> b >> s;
  int na, su;
  na = su = 0;
  rep(i, n){
    if(s[i] == 'a'){
      if(na + su < a + b){
	cout << "Yes\n";
	na ++;
      } else {
	cout << "No\n";
      }
    } else if(s[i] == 'b'){
      if(na + su < a + b && su < b){
	cout << "Yes\n";
	su ++;
      } else {
	cout << "No\n";
      }
    } else {
      cout << "No\n";
    }
  }
  return 0;
}


Measured memory_bytes: 848
import java.io.BufferedInputStream;
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
    public static long combination(int n,int k){
        if(k==0)
            return 1;
        else
            return combination(n,k-1)*(n-k+1)/k;

    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(new BufferedInputStream(System.in));
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=0;
        c+=Main.combination(a,2);
        c+=Main.combination(b,2);
        System.out.println(c);

    }
}

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

typedef long long ll;
int main(){
    int N;
    cin >> N;
    map<string,int> A;
    for(int i=0;i<N;i++){
        string num;
        cin >> num;
        if(A.count(num)){
            cout << "NO" << endl;
            return 0;
        }
        A[num]++;
    }
    cout << "YES" << endl;

}

Measured memory_bytes: 24832
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	
	public static int BubbleSort(final int N, int[] A){
		
		int count = 0;
		for(int i = 0; i < N; i++){
			int min = A[i];
			int min_pos = i;
			
			for(int j = i + 1; j < N; j++){
				if(A[j] < min){
					min = A[j];
					min_pos = j;
				}
				
			}
			
			if(min_pos != i){
				int tmp = A[i];
				A[i] = min;
				A[min_pos] = tmp;
				count++;
			}
		}
		
		return count;
	}
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++){
			A[i] = sc.nextInt();
		}
		
		final int times = BubbleSort(N, A);
		
		for(int i = 0; i < N; i++){
			if(i != 0){
				System.out.print(" ");
			}
			System.out.print(A[i]);
		}
		System.out.println();
		
		System.out.println(times);
	}
}

Measured memory_bytes: 19648
// Author := Abhishek Giri

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define V(type) vector<(type)>
#define all(c) ((c).begin(),(c).end())
#define in(var) cin>>(var)
#define out(var) cout<<(var)
#define on(var) cout<<var<<"\n"
#define f(i,n) for(ll i = 0 ; i < n ;i++)
#define mfor(i,init,n,b) for(ll i = (init) ; i < (n) ; i+= (b))
#define cfor(i,c) for(auto i = (c).begin() ; i!= (c).end(); i++)
#define el "\n"
#define ret return
#define F first
#define S second
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"

/*##################################################################################*/


/*bool prime[100000] ;
vector < int > pr;
void calculateprime()
{
    prime[0] = prime[1] = true;
    for(int i = 2 ; i <= 100000 ; i++)
    {
        if(prime[i] == false)
        {
            pr.pb(i);
            for(ll j = i*i ; j <= 100000 ; j += i )
            {
                prime[j] = true;
            }
        }
    }
}
*/


void customrun(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

bool isprime(ll n)
{
    if(n == 1) return false;

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

ll fib(int n)
{
    ll a = 0, b = 1, c, i;
    if( n == 0)
        return a;
    for (i = 2; i <= n; i++)
    {
        c = (a + b);
        a = b;
        b = c;
    }
    return b;
}


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

ll extendedgcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = extendedgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

ll findgrouplcm(vector<int> &arr, int n)
{
    ll ans = arr[0];

    for (ll i = 1; i < n; i++)
        ans = (arr[i] * (ans/(gcd(arr[i], ans))));

    return ans;
}


ll powerwithmod(ll x, unsigned ll y, ll p)
{
    ll res = 1;

    x = x % p;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;

        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}


bool comp(const pair < long,long > &a, const pair < long ,long > &b){
    if(a.first == b.first) return a.second < b.second;
    return a.first < b.first;
}

void solve();

int main() {
    clock_t begin = clock();

    fast();
    customrun();
    ll t = 1;
    //cin>>t;
    //calculateprime();
    mfor(i,1,t+1,1)
    {
        //cout<<"Case #"<<i<<": \n";
        solve();
    }
    clock_t end = clock();
    double time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
    //cout<<"\ntime spent is "<<time_spent;
    return 0;
}


void solve(){
    ll n;
    in(n);
    ll arr[n];
    f(i,n) in(arr[i]);

    ll sum = arr[0] , res = 0;

    mfor(i,1,n,1){
        res = (res % mod + (sum % mod * arr[i] % mod )) % mod;
        sum += arr[i];
    }

    out(res);
}

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

typedef long long lli;

int main()
{
    int n;
    cin>>n;

    int arr[n];
    int cnt = 0;
    for(int i = 1; i <= n; i++ )
    {
        cin>>arr[i];
        if( arr[i] != i )cnt++;
    }

    if(cnt == 0)cout<<"YES"<<endl;
    else
    {
        int a = cnt/2;
        int b = cnt%2;
        if( a == 1 && b == 0 )cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }

}

Measured memory_bytes: 256
while True:
    a,b,c=map(str,input().split())
    a=int(a)
    c=int(c)
    if b=='?':
        break
    else:
        if b=='+':
            print(a+c)
        elif b=='-':
            print(a-c)
        else:
            if b=='*':
                print(a*c)
            else:
                print(a//c)
          


Measured memory_bytes: 5596
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a,b = na()
p = na()
c = [0,0,0]

for i in p:
    if i <= a:
        c[0] += 1
    elif a+1 <= i <= b:
        c[1] += 1
    else:
        c[2] += 1

print(min(c))

Measured memory_bytes: 3064
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int a, p; cin >> a >> p;
	cout << (3 * a + p) / 2;

	return 0;
}

Measured memory_bytes: 3156
n, k = map(int, input().split())
X, Y = [], []
for x in map(int, input().split()):
    if x < 0:
        X.append(-x)
    else:
        Y.append(x)
X.reverse()
INF = 10**9
ans = INF
if len(X) == 0:
    ans = Y[k-1]
elif len(Y) == 0:
    ans = X[k-1]
else:
    for i in range(1, k):
        L, R = k-i-1, i-1
        if not(L < len(X) and R < len(Y)):
            continue
        a, b = X[L], Y[R]
        ans = min(ans, min(a, b)+a+b)
print(ans)


Measured memory_bytes: 14128
X,K,D = map(int,input().split())
X = max(X,X*(-1))
plusmin = X%D
minusmin = -plusmin+D
totalmin = min(plusmin,minusmin)
if totalmin == plusmin:
    num = X//D
else:
    num = X//D+1
    
if K<num:
    answer = X-D*K
elif K==num+1:
    answer = max(plusmin,minusmin)
elif K%2==num%2:
    answer = totalmin
else :
    answer = max(plusmin,minusmin)
    
print(answer)

Measured memory_bytes: 61632
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()

	ans := 0
	for a := 1; a < n; a++ {
		for b := 1; n-a*b > 0; b++ {
			ans++
		}
	}

	fmt.Println(ans)
}

// from [my library](https://github.com/ikngtty/go-contestlib)
// -   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *Scanner) ReadFloat() float64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseFloat(text, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  char a,b;
  cin>>a>>b;
  if(a=='H') cout<<b<<'\n';
  else{
    if(b=='H') cout<<'D'<<'\n';
    else cout<<'H'<<'\n';
  }
  return 0;
}


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

signed main(){
  
  int X, N;
  cin>>X>>N;

  set<int> S;

  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    S.insert(a);
  }
  
  int minx = 200, idx;

  for(int i=200;i>=0;i--){
    if( S.count( i ) ) continue;
    int x = abs( i - X );
    if( minx >= x ){
      minx = x;
      idx = i;
    }
  }
  
  cout<<idx<<endl;
  
  return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		if(N%1000!=0) {
			System.out.println(1000-N%1000);
		}else {
			System.out.println(0);
		}
	}

}

Measured memory_bytes: 35824
#include <iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int prim(int n, int m[MAX][MAX]) {
    int u, minv;
    int d[MAX], p[MAX], color[MAX];

    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }

    d[0] = 0;

    while (true) {
        minv = INFTY;
        u = -1;
        for (int i = 0; i < n; i++) {
            if (minv > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1) break;
        color[u] = BLACK;
        for (int v = 0; v < n; v++) {
            if (color[v] != BLACK && m[u][v] != INFTY) {
                if (d[v] > m[u][v]) {
                    d[v] = m[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] != -1) sum += m[i][p[i]];
    }

    return sum;
}

int main() {
    int n, m[MAX][MAX];
    cin >> n;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int e;
            cin >> e;
            m[i][j] = (e == -1) ? INFTY : e;
        }
    }

    cout << prim(n, m) << endl;
}



Measured memory_bytes: 3120
import java.util.Scanner;

public class Main {

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

		int num = scan.nextInt();
		int amountOfMoney = scan.nextInt();

		scan.close();

		for(int i = 0; i <= num; i++) {
			for(int j = 0; j <= num - i; j++) {
				for(int k = 0 ; k <= num - i - j; k++) {
					if(10000 * i + 5000 * j + 1000 * k == amountOfMoney
						&& i + k + j == num) {
						System.out.println(i + " " + j + " " + k);
						return;
					}
				}
			}
		}
		System.out.println(-1 + " " + -1 + " " + -1);

	}

}

Measured memory_bytes: 22732
k,t = map(int,input().split())
a = list(map(int,input().split()))

dp = [[False] * (k//2+1) for _ in range(t+1)]

dp[0][0] = True

for i in range(t):
    for j in range(k//2+1):
        if dp[i][j]:
            dp[i+1][j] = True
            if j + a[i] < k//2+1:
                dp[i+1][j + a[i]] = True

cnt = 0
for i,e in enumerate(dp[-1]):
    if e:
        cnt = i

ans = k - (2 * cnt + 1)

print(max(ans, 0))


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

#define pb push_back
#define ff first
#define ss second
#define N 200005
#define mod 1000000007
#define fo(n) for(int i=1;i<=n;i++)
typedef pair<int,int> pii;
typedef long long int ll;
typedef long int li;
int mod1 = 998244353;

ll a[N]; int k;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    cin>>k;
    for(int i=1;i<=9;i++) a[i] = i;
    int j=1;
    for(int i=10;i<=k;) {
        int x = a[j]%10;
        if(x-1 >=0) {a[i] = a[j]*10 + (x-1); i++;}
        a[i] = a[j]*10 + x; i++;
        if(x+1 < 10) {a[i] = a[j]*10 + (x+1); i++;}
        j++;
    }
    //fo(k) cout<<a[i]<<" ";
    cout<<a[k]<<"\n";
    return 0;
}

Measured memory_bytes: 1024
use std::io::Read;
use std::cmp::max;

fn calc(p: &[(usize, usize)], dp: &mut Vec<usize>) -> usize {
    if p.len() == 0 {
        return 0;
    }
    if p.len() == 1 {
        return *dp.last().unwrap() + p[0].1;
    }
    let n = p.len();
    let m = n / 2;
    let save = dp.clone();
    for &(a, b) in &p[..m] {
        for i in (a..dp.len()).rev() {
            dp[i] = max(dp[i], dp[i - a] + b);
        }
    }
    let x = calc(&p[m..], dp);
    let mut dp = save;
    for &(a, b) in &p[m..] {
        for i in (a..dp.len()).rev() {
            dp[i] = max(dp[i], dp[i - a] + b);
        }
    }
    let y = calc(&p[..m], &mut dp);
    max(x, y)
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let w: usize = it.next().unwrap().parse().unwrap();
    let mut p = vec![];
    let mut q = 0;
    for _ in 0..n {
        let a: usize = it.next().unwrap().parse().unwrap();
        let b: usize = it.next().unwrap().parse().unwrap();
        if a < w {
            p.push((a, b));
        } else {
            q = std::cmp::max(q, b);
        }
    }
    let mut dp = vec![0; w];
    for &(a, b) in p.iter() {
        for i in (a..w).rev() {
            dp[i] = max(dp[i], dp[i - a] + b);
        }
    }
    let ans = max(dp[w - 1] + q, calc(&p, &mut vec![0; w]));
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()

int main(){
  ll n, r;
  cin >> n >> r;
  if(n>0&&n<10){
    cout << r + 100 * (10 - n) << endl;
    ;
  }
  else{
    cout << r << endl;
  }
}

Measured memory_bytes: 256
(let* ((h (read))
    (w (read))
    (s (make-array (list (+ h 2) (+ w 2)) :initial-element "0")))

    (loop for i below h do
        (let ((a (read-line)))
            (loop for j below w do
                (setf (aref s (+ i 1) (+ j 1)) (char a j))
            )
        )
    )
    (loop for i from 1 to h do
        (loop for j from 1 to w do
            (let ((ans 0))
                (if (string= (aref s i j) ".")
                    (progn
                        (loop for k from (- i 1) to (+ i 1) do
                            (loop for l from (- j 1) to (+ j 1) do
                                (if (string= (aref s k l) "#")
                                    (incf ans)
                                )
                            )
                        )
                        (format t "~D" ans)
                    )
                    (format t "#")
                )
            )
        )
        (format t "~%")
    )
)

Measured memory_bytes: 25072
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long ll;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define MAX_V 100001
#define MOD 1000000007
typedef vector<vector<int> > Graph;

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


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

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

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    vector<int> c(11);
    for(int i=0;i<3;i++){
        int x;
        cin>>x;
        c[x]++;
    }
    if((c[5]==2)&&(c[7]==1)) cout<<"YES";
    else cout<<"NO";
}


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

int main(){
    int N, M;
    cin >> N >> M;
    vector<ll> H(N);
    for (int i = 0; i < N; i++) cin >> H.at(i);
    vector<int> A(M), B(M);
    vector<vector<int>> C(N);
    for (int i = 0; i < M; i++) {
        cin >> A.at(i) >> B.at(i);
        A.at(i)--;
        B.at(i)--;
        C.at(A.at(i)).push_back(B.at(i));
        C.at(B.at(i)).push_back(A.at(i));
    }
    int ans = 0;
    bool flag = false;
    for (int i = 0; i < N; i++) {
        flag = false;
        for (int j = 0; j < C.at(i).size(); j++) {
            if (H.at(i) <= H.at(C.at(i).at(j))) {
                flag = true;
                break;
            }
        }
        if (flag) continue;
        ans++;
    }
    
    cout << ans << endl;
    return 0;
}


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

using namespace std;


bool checkPalindrome(string s){
	for(int i = 0; i < s.size()/2; i++){
		if(s[i]!=s[s.size()-i-1])
			return false;
	}
	return true;
}

int main(){

	string s;
	int cnt=0;
	while(cin>>s){
		if(checkPalindrome(s))
			cnt++;
	}
	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 0
#pragma region
#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define rep(i, a, n) for (long long i = a; i <= n; ++i)
#define per(i, a, n) for (long long i = n; i >= a; --i)
#define IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
template <typename T>
void read(T &x) {
    x = 0;
    char ch = getchar();
    ll f = 1;
    while (!isdigit(ch)) {
        if (ch == '-') f *= -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - 48;
        ch = getchar();
    }
    x *= f;
}
using namespace std;
/*
 *                                                     __----~~~~~~~~~~~------___
 *                                    .  .   ~~//====......          __--~ ~~
 *                    -.            \_|//     |||\\  ~~~~~~::::... /~
 *                 ___-==_       _-~o~  \/    |||  \\            _/~~-
 *         __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *     _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *   .~       .~       |   \\ -_    /  /-   /   ||      \   /
 *  /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 *  |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 *           '         ~-|      /|    |-~\~~       __--~~
 *                       |-~~-_/ |    |   ~\_   _-~            /\
 *                            /  \     \__   \/~                \__
 *                        _--~ _/ | .-~~____--~-/                  ~~==.
 *                       ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                  -_     ~\      ~~---l__i__i__i--~~_/
 *                                  _-~-__   ~)  \--______________--~~
 *                                //.-~~~-~_--~- |-------~~~~~~~~
 *                                       //.-~~~--\
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */

#pragma endregion
const int maxn = 1e5 + 5;
int a[maxn], b[maxn], c[maxn], dp[maxn][3];
int main() {
    IO;
    int n;
    cin >> n;
    rep(i, 1, n) cin >> a[i] >> b[i] >> c[i];
    rep(i, 1, n) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll A,B,C,ans=0;
  cin >> A >> B >> C;

  if(C>A+B){
    ans = A+B+B+1; 
  } else {
    ans = B+C;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <bitset>
using namespace std;
#define int long long
int MOD = 1000000007;
bitset<300005> B;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, R;
	cin >> N >> R;
	vector<int> A(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		//A[i] = i + 1;
		A[i]--;
	}
	vector<int> V(N, 0);
	map<int, int> mp;
	for (int i = 0; i < N; i++) {
		if (V[i] == 0) {
			int t = i;
			int cnt = 1;
			V[i] = 1;
			while (true) {
				t = A[t];
				if (t == i)break;
				V[t] = 1;
				cnt++;
			}
			//cerr << cnt << endl;
			mp[cnt]++;
		}
	}
	B.set(0);
	for (auto m : mp) {
		int sz = m.first;
		for (int i = 0; i <= 20; i++) {
			if ((1 << (i + 1)) - 1 < m.second) {
				B = (B | (B << (sz << i)));
			}
			else {
				int x = m.second - ((1 << i) - 1);
				//cerr << sz << " " << x << endl;
				B = (B | (B << (sz * x)));
				break;
			}
		}
	}
	/*for (int i = 0; i <= N; i++) {
		cerr << (B[i] ? 1 : 0) << endl;


	}*/

	if (B[R]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}


Measured memory_bytes: 7876
#include <algorithm>
#include <iostream>
#include <limits>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  int mn  = numeric_limits<int>::max();
  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    int P;
    cin >> P;
    if (P <= mn) {
      cnt++;
    }
    mn = min(P, mn);
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;


int main(){
  string s; cin>>s;
  int a=(s[0]-'0')*10+(s[1]-'0');
  int b=(s[2]-'0')*10+(s[3]-'0');
  if(a>12||a==0){
    if(b>12||b==0)
    cout<<"NA"<<endl;
    else
    cout<<"YYMM"<<endl;
  }else{
    if(b>12||b==0)
    cout<<"MMYY"<<endl;
    else
    cout<<"AMBIGUOUS"<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
const int M=1e5,mod=1e9+7;
int n,m,f[M],g[M],A[M],bit[M],Ans,S;
void add(int &x,int y) {x+=y;if(x>=mod) x-=mod;}
void Get(int *f,int x)
{
	for(int zt=0;zt<=S;zt++)
	{
		if(!(zt&bit[x])) continue;
		f[zt]=bit[A[zt]+1];
		for(int s=(zt-1)&zt;s;s=(s-1)&zt)
			if(s&bit[x])
				add(f[zt],mod-1ll*f[s]*bit[A[zt-s]+1]%mod);
	}
}
int main()
{
	cin>>n>>m;bit[1]=1;
	for(int i=2;i<=150;i++) bit[i]=bit[i-1]*2ll%mod;
	Ans=bit[m+1];S=bit[n+1]-1;
	for(int i=1,x,y;i<=m;i++)
		cin>>x>>y,A[bit[x]|bit[y]]++;
	for(int j=1;j<=n;j++)
		for(int i=0;i<=S;i++)
			if(i&bit[j]) A[i]+=A[i^bit[j]];
	Get(f,1);Get(g,2);
	for(int zt=0;zt<=S;zt++)
		if((zt&bit[1])&&!(zt&bit[2]))
			for(int s=S-zt;s;s=(s-1)&(S-zt))
				if((s&bit[2])&&(A[s]+A[zt]==A[s|zt]))
					add(Ans,mod-1ll*f[zt]*g[s]%mod*bit[A[S-s-zt]+1]%mod);
	cout<<Ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
inline int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int k=1,kk=0;if (c=='-')c=getchar(),k=-1;
	while (c>='0'&&c<='9')kk=kk*10+c-'0',c=getchar();return kk*k;
}using namespace std;
void write(int x){if (x<0)putchar('-'),x=-x;if (x/10)write(x/10);putchar(x%10+'0');}
void writeln(int x){write(x);puts("");}
int n,a[1000010],ans;
signed main(){
	n=read();for (int i=1;i<=n;i++)a[i]=read()-i;
	sort(a+1,a+1+n);
	for (int i=1;i<=n;i++)ans+=abs(a[i]-a[(n+1)/2]);
	writeln(ans);
}




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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

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

int a[5][5];
int col[5][5], row[5][5];
int ld = 1, rd = 1;

signed main() {
#ifdef _DEBUG
  freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  for (int i = 1; i <= 3; i++)
  for (int j = 1; j <= 3; j++) {
    cin >> a[i][j];
  }
  int n;
  cin >> n;
  set<int> s;
  for (int i = 0; i < n; i++) {
    int t; cin >> t;
    s.insert(t);
  }
  int cnt = 0;
  for (int i = 1; i <= 3; i++) {
    col[0][i] = row[i][0] = 1;
  }
  for (int i = 1; i <= 3; i++)
  for (int j = 1; j <= 3; j++) {
    int t = 0;
    if (s.count(a[i][j])) {
      t = col[i][j] = row[i][j] = 1;
    }
    col[i][j] *= col[i - 1][j];
    row[i][j] *= row[i][j - 1];
    if (i - j == 0) ld *= t;
    if (i + j == 4) rd *= t;
    if (j == 3 && row[i][j] == 1) cnt++;
    if (i == 3 && col[i][j] == 1) cnt++;
  }
  if (ld) cnt++;
  if (rd) cnt++;
  if (cnt) cout << "Yes" << '\n';
  else cout << "No" << '\n';
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int in[1010];
vector< vector < int > > g ;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int n , k ;
	cin >> n >> k ;

	if(k == 1)
        return cout << 0 << '\n' , 0 ;
   cout << n - k<< '\n';

	return 0 ;
}


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

int main()
{
	int N = 0;
	int i = 0;
	vector <int> P;
	vector <string> S;
	vector<pair<pair<string, int>,int>> v;
	pair<pair<string, int>, int> p;
	cin >> N;
	for (i = 0; i < N; i++) {
		cin >> p.first.first >> p.first.second;
		p.second = i + 1;
		v.push_back(p);
	}

	for (i = 0; i < N; i++) {
		v[i].first.second *= -1;
	}
	sort(v.begin(),v.end());

	for (i = 0; i < N; i++) {
		cout << v[i].second<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    final long MOD = 1000000007;
    void solve(){
        Scanner scan = new Scanner(System.in);
        long n = scan.nextInt();
        System.out.println((pow(10, n) - (2 * pow(9, n)) % MOD + pow(8, n)) % MOD);
    }

    long pow(long x, long n){
        if(n == 0) return 1;
        long ret = pow(x * x % MOD, n / 2);
        if((n & 1) == 1) ret = ret * x % MOD + MOD;
        return ret;
    }

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


Measured memory_bytes: 35612
#include<iostream>
    int main()
        {
            int m, f, r;
            char g;
                while (true) {
                    std::cin >> m >> f >> r;
                        if (m == -1 && f == -1 && r == -1) {
                            break;
                        } else if (m == -1 || f == -1) {
                            g = 'F';
                        } else if (m + f >= 80) {
                            g = 'A';
                        } else if (m + f >= 65) {
                            g = 'B';
                        } else if (m + f >= 50) {
                            g = 'C';
                        } else if ( m + f >= 30) {
                            if (r >= 50) {
                                g = 'C';
                            } else {
                                g = 'D';
                            }
                        }
                        else {
                            g = 'F';
                        }
                    std::cout << g << std::endl;
                }
        return 0;
        }

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

void chmax(ll& a, ll b) { if (a < b) a = b; }

int main() {
  //ios::sync_with_stdio(false);
  //cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int>> p(n);
  rep(i, n) {
    int a;
    cin >> a;
    p[i] = make_pair(a, i);
  }
  sort(p.rbegin(), p.rend());
  
  vector<vector<ll>> dp(2005, vector<ll>(2005, 0ll));
  rep(i, n) {
    for (int j = 0; j+i < n; ++j) {
      int k = i+j;
      chmax(dp[i+1][j], dp[i][j] + 1ll*p[k].first*abs(p[k].second-i));
      chmax(dp[i][j+1], dp[i][j] + 1ll*p[k].first*abs(n-1-j-p[k].second));
    }
  }
  ll ans = 0;
  rep(i, n) chmax(ans, dp[i][n-i]);
  cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const int INF = 1e9;

ld dp[303][303][303];
ll n, ans = 0;
int a;

ld f(int i, int j, int k) {
  if (dp[i][j][k] >= 0) return dp[i][j][k];
  if (i == 0 && j == 0 && k == 0) return 0;

  ld res = 0.0;
  if (i > 0) res += f(i - 1, j, k) * i;
  if (j > 0) res += f(i + 1, j - 1, k) * j;
  if (k > 0) res += f(i, j + 1, k - 1) * k;
  res += n;
  res *= 1.0 / (i + j + k);

  return dp[i][j][k] = res;
}

int main() {
  cin >> n;
  ll one = 0, two = 0, three = 0;
  rep(i, n) {
    cin >> a;
    if (a == 1)
      one++;
    else if (a == 2)
      two++;
    else
      three++;
  }

  memset(dp, -1, sizeof(dp));
  cout << setprecision(10) << f(one, two, three) << endl;
  return 0;
}

Measured memory_bytes: 434944
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		int m = 100000;
		for(int i = 0; i < n; i++) {
			m = m * 105 / 100;
			int res = m - (m / 1000) * 1000;
			if(res != 0) {
				m = (m / 1000) * 1000 + 1000;
			}
		}
		System.out.println(m);
	}
}


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

int main(){
	ll n,y;
	cin >> n >> y;
	for(int i = 0; 10000 * i <= y; i++){
		for(int j = 0; 10000 * i + 5000 * j <= y; j++){
			if(10000 * i + 5000 * j + 1000 * (n - i - j) == y){
				cout << i << " " << j << " " << n - i - j << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
$|=1;
$line = <STDIN>;chomp $line;
($N, $Y)=split " ",$line;

if ($Y%1000 !=0) { print "-1 -1 -1\n"; exit; }
$P=$Y/1000-$N;
$x4=$P%4;

for($x=$x4;$x<=$N && $x*9<=$P;$x+=4) {
 $y=($P-9*$x)/4;
 $z=$N-$x-$y;
 next if ($z<0);
 print "$x $y $z\n";
 exit;
}
print "-1 -1 -1\n";


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int answer = 0;
		if (a < b) {
			answer += a;
		} else {
			answer += b;
		}
		if (c < d) {
			answer += c;
		} else {
			answer += d;
		}

		System.out.println(answer);
	}

}

Measured memory_bytes: 21972
import sys

# input処理を高速化する
input = sys.stdin.readline

def main():
    # input
    H, W = map(int, input().split())
    A = [input() for _ in range(H)]

    MOD = 10**9 + 7

    # 0-indexed DPは0で初期化
    dp = [[0] * W for _ in range(H)]
    # DP初期条件
    dp[0][0] = 1

    # 全マス目を探索
    for i in range(H):
        for j in range(W):
            if i+1 < H and A[i+1][j] == '.':
                dp[i+1][j] += dp[i][j]
                # 計算の途中で余りをとる
                if dp[i+1][j] >= MOD:
                    dp[i+1][j] -= MOD
            if j+1 < W and A[i][j+1] == '.':
                dp[i][j+1] += dp[i][j]
                if dp[i][j+1] >= MOD:
                    dp[i][j+1] -= MOD
    
    print(dp[H-1][W-1])

main()


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

using namespace std;

typedef long long ll;

int main()
{
    ll n;
    cin >> n;
    ll ans = 1e15;
    for(ll i = 1; i*i <= n; i++){
        if(n%i == 0)
            ans = min(ans,i+(n/i)-2);
    }
    cout << ans << endl;

}


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

using namespace std;

typedef long long ll;

string s;
int ps[500000];
int n, m;

signed main()
{
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); i++)
    {
        int len = 0;
        for (int j = i; j < s.size(); j++)
        {
            if (s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T')
            {
                len++;
            }
            else
            {
                break;
            }
        }
        ans = max(ans, len);
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#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)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int n,a,b,c;
int main(int argc, char const *argv[])
{
	string o,e;
	cin >> o >> e;
	REP(i,SZ(o)){
		cout << o[i];
		if(i < SZ(e))
			cout << e[i];
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}



const int modn=1000000007;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> broken(n+1);
    rep(i,m){
        int a;
        cin>>a;
        broken[a]=1;
    }
    vector<ll> dp(n+1);
    for(int i=0;i<=n;++i){
        if(!broken[i]){
            if(i==0)dp[i]=1;
            else if(i==1)dp[i]=1;
            else dp[i]=(dp[i-1]+dp[i-2])%modn;
        }else{
            dp[i]=0;
        }
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 4588
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<int> H(N);
  for (auto& hi: H) scanf("%d", &hi);

  std::vector<int> res(N);
  for (size_t i = 1; i < N; ++i) {
    if (H[i-1] >= H[i]) {
      res[i] = res[i-1] + 1;
    }
  }
  printf("%d\n", *std::max_element(res.begin(), res.end()));
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

ll f(ll x){
    if(x%100!=0) return 0;
    else return f(x/100)+1;
}

int main(void)
{
    ll d,n; cin>>d>>n;
    ll cnt=0,i=1;
    while(true){
        if(f(i)==d){
            cnt++;
        }
        if(cnt==n){
            cout<<i<<endl;
            return 0;
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;
 
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int[] num = new int[5];
		for(int i=0; i<5; i++) {
			num[i]=sc.nextInt();
		}
		int k=sc.nextInt();
		if(num[4]-num[0]>k) System.out.println(":(");
		else System.out.println("Yay!");
	}
}

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

int main() {
  int W,H,N;
  cin >> W >> H >> N;
  vector<vector<int>>data(H,vector<int>(W,0));
  for (int i = 0; i < N; i++) {
    int x,y,a;
    cin >> x >> y >> a;
    switch(a){
        case 1:
      	  for(int j=0; j<x; j++){
        	  for(int k=0; k<H; k++){
        	    data.at(k).at(j)=1;
      	    }
          }
          break;
        case 2:
      	  for(int j=x; j<W; j++){
      	    for(int k=0; k<H; k++){
      	      data.at(k).at(j)=1;
       	 	}
     	  }
          break;
        case 3:
     	   for(int j=0; j<y; j++){
      	    for(int k=0; k<W; k++){
      	      data.at(j).at(k)=1;
      	    }
           }
           break;
        case 4:
     	   for(int j=y; j<H; j++){
      	    for(int k=0; k<W; k++){
      	       data.at(j).at(k)=1;
      	    }
           }
           break;
        default:
           break;
    }
  }

  int area=0;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(data.at(i).at(j)==0)area++;
    }
  }
  
  cout << area << endl;
}

Measured memory_bytes: 256
l,r = map(int,input().split())
diff = r - l

if(diff >= 2019):
  print(0)
else:
  lmod = l % 2019
  rmod = r % 2019
  if(rmod  < lmod):
    print(0)
  else:
    ans =2020
    for i in range(l,r+1):
      for j in range(i+1,r+1):
        if((i*j) % 2019 < ans):
          ans = (i*j) % 2019
    print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

typedef long long ll;

int n,l;
ll a[100001];
ll dp[100001];

ll memo(int v){
	if(dp[v]>=0)return dp[v];
	if(a[v]==0)return dp[v]=0;
	ll c=l-a[v];
	ll c2=0;
	if(a[v-1]>a[v])c2=memo(v-1);
	if(a[v+1]>a[v])c2=max(c2,memo(v+1));
	return dp[v]=c+c2;
}

int main(void){
	scanf("%d%d",&n,&l);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	ll res=0;
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=n;i++)if(dp[i]==-1)memo(i);
	for(int i=1;i<=n;i++){
		res=max(res,dp[i]);
		//printf("%lld%c",dp[i],i==n?'\n':' ');
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 4712
N = input()

def f(s):
    if int(s) > int(N):
        return 0

    if "3" in s and "5" in s and "7" in s:
        cnt = 1
    else:
        cnt = 0

    for t in "3","5","7":
        cnt += f(s + t)

    return cnt

ans = f("0")
print(ans)

Measured memory_bytes: 3060