akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		int[] h=new int[n];
		for(int i=0;i<n;i++){
			h[i]=scanner.nextInt();
		}
		int ans=0;
		boolean w=false;
		boolean b=false;
		while(true){
			for(int i=0;i<n;i++){
				if(h[i]!=0&&!w){
					h[i]--;
					w=true;
					if(i==n-1){
						w=false;
						ans++;
					}
				}
				else if(w&&h[i]!=0){
					h[i]--;
					if(i==n-1){
						ans++;
						w=false;
					}
				}
				else if(w&&h[i]==0){
					ans++;
					w=false;
				}
			}
			for(int i=0;i<n;i++){
				if(h[i]!=0){
					b=false;
					break;
				}else{
					b=true;
				}
			}
			if(b){
				break;
			}
		}
		System.out.println(ans);
	}
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 21204
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include <initializer_list>
#include<unordered_set>
#include<map>
#include<cmath>
#include <iterator>
#include<stack>
#include<queue>
#include <iomanip>
#include<math.h>
#include <limits.h>
#include <numeric>
#include <functional>
#include<fstream>
using namespace std;

#define mod  
#define ll  long long
#define endl "\n"
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll x;
	cin >> x;
	cout << 3 * (x * x) << endl;
	return 0;
}

Measured memory_bytes: 256
void main()
{
    string s = readln.chomp;
    long k = readln.chomp.to!long;

    long n = s.countUntil!(x => x != '1');
    if (n == -1 || n >= k)
    {
        s[0].writeln;
    }
    else
    {
        s[n].writeln;
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
h,w = map(int,input().split())

if h==1 or w==1:
    print(1)
    exit()

if h%2==0:
    a = h//2
    ans = a*w
else:
    a1 = (h+1)//2
    a2 = a1 - 1
    if w%2==0:
        ans = ( a1+a2 )*( w//2 )
    else:
        ans = ( a1+a2 )*( w//2 ) + a1

print(ans)

Measured memory_bytes: 38256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int p = 0;
    for(int i = 0; i < s.length(); i++) {
      if(String.valueOf(s.charAt(i)).equals("+")) p++;
    }
    System.out.println(2 * p - 4);
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
#include <cassert>
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int n, m;
mint dp[2100][2100];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> m;
  vector<int> s(n + 1);
  vector<int> t(m + 1);

  REP(i, n) cin >> s[i];
  REP(i, m) cin >> t[i];

  dp[0][0] = 1;
  REP(i, n + 1) REP(j, m + 1) {
    if(i > 0 && j > 0 && s[i - 1] == t[j - 1]) dp[i][j] += dp[i - 1][j - 1];
    if(i > 0) dp[i][j] += dp[i - 1][j];
    if(j > 0) dp[i][j] += dp[i][j - 1];
    if(i > 0 && j > 0) dp[i][j] -= dp[i - 1][j - 1];
  }

  cout << dp[n][m] << endl;
}


Measured memory_bytes: 38124
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    cout<<n*(n+1)/2<<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;

#define ll long long
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}


ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(){
  string A, B, C;
  cin >> A >> B >> C;
  cout << A[0] << B[0] << C[0] << endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<cstring>
#include<functional>

using namespace std;

int main()
{
	int n, x, y;
	int dist[2001][2001];

	memset(dist, -1, sizeof(dist));

	scanf("%d %d %d", &n, &x, &y);

	int cnt[2001] = { 0, };

	for (int i = 1; i <= n; i++)
	{
		for (int j = i + 1; j <= n; j++)
		{
			dist[i][j] = dist[j][i] = j - i;

			int ix, iy, jx, jy;

			ix = abs(i - x);
			iy = abs(i - y);
			jx = abs(j - x);
			jy = abs(j - y);

			int id, jd;

			id = ix < iy ? ix : iy;
			jd = jx < jy ? jx : jy;

			if (id + jd + 1 < dist[i][j])
			{
				dist[i][j] = id + jd + 1;
			}

			cnt[dist[i][j]]++;
		}
	}

	for (int i = 1; i < n; i++)
	{
		printf("%d\n", cnt[i]);
	}

	return 0;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;
#define INF 1e9
int N;
int gcd(int a, int b){
  if(b == 0){
    return a;
  }
  return gcd(b, a%b);
}
int main(){
  string s;
  cin >> s;
  char c = s[0];
  int ans = 0;
  REP(i, s.length()){
    if(c != s[i]){
      c = s[i];
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

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

int ar[4];

int main(){
    ios_base::sync_with_stdio(false);

    cin>>ar[0]>>ar[1]>>ar[2];
    sort(ar,ar+3);

    cout<<ar[2]*10+ar[1]+ar[0]<<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mpr make_pair
#define mt make_tuple
 
using namespace std;
 
const ll N = 100010;
const ll mod = 1e9 + 7;
ll power(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 dp[N][3];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    ll arr[N][3];
    cin>>n;
    for(int i=0;i<n;i++)   cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    dp[0][0] = arr[0][0];   dp[0][1] = arr[0][1];   dp[0][2] = arr[0][2];
    for(int i=1;i<n;i++){
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + arr[i][0];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + arr[i][1];
        dp[i][2] = max(dp[i-1][1], dp[i-1][0]) + arr[i][2];
    }
    cout<<max({dp[n-1][0], dp[n-1][1], dp[n-1][2]})<<endl;
    return 0;
}

Measured memory_bytes: 4992
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	vector<vector<ll>> left(n), right(n);
	rep(i,n){
		cin >> a[i];
		if(i - a[i] >= 0) right[i-a[i]].push_back(i);
		if(i + a[i] < n) left[i+a[i]].push_back(i);
	}
	ll ans = 0;
	rep(i,n){
		ans += left[i].size() * right[i].size();
	}
	cout << ans << endl;
	return 0;
}

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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    int64_t X, K, D;
    cin >> X >> K >> D;
    X = max(X, -X);
    if (K < X / D)
        cout << X - D * K;
    else
    {
        if (X % D == 0)
        {
            if ((K - X / D) % 2 == 0)
                cout << 0;
            else
                cout << D;
        }
        else
        {
            if ((K - X / D) % 2 == 0)
                cout << X % D;
            else
                cout << D - X % D;
        }
    }
}

Measured memory_bytes: 3580
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:16777216")
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <stack>
#include <iomanip>
#include <set>
#include <queue>
#include <unordered_map>

using namespace std;

#define ff first
#define ss second

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int maxn = 2e5 + 7;
const int inf = 2e9 + 7;
const ll infl = 1e18 + 7;
const long double eps = 1e-9;
const ll mod = 998244353;

int main() {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif // _DEBUG

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector<int> dp(n);
	for (int i = 1; i < n; i++) {
		dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
		if (i != 1) {
			dp[i] = min(dp[i], dp[i - 2] + abs(a[i] - a[i - 2]));
		}
	}
	cout << dp[n - 1];
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
As = list(map(int, input().split()))

pos = [(-1)**i for i in range(N)]
neg = [-(-1)**i for i in range(N)]
sp = 0
sn = 0
cp = 0
cn = 0
for i in range(N):
    A = As[i]
    sp += A
    if pos[i] * sp <= 0:
        cp += abs(sp) + 1
        sp = pos[i]
    sn += A
    if neg[i] * sn <= 0:
        cn += abs(sn) + 1
        sn = neg[i]

print(min(cp, cn))

Measured memory_bytes: 66516
using System;
using System.Collections;
using System.Collections.Generic;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    void calc()
    {
        while (true)
        {
            try
            {
                string input = Console.ReadLine();
                if (input == null) break;
                string[] st = input.Split(' ');
                int a = int.Parse(st[0]);
                int b = int.Parse(st[1]);
                int g = gcd(a, b);
                Console.WriteLine(g + " " + ((long)a * b / g));
            }
            catch
            {
                break;
            }
        }

    }

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

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

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

    int a, b, c; cin >> a >> b >> c;
    if ((a == b && b != c) || (b == c && c != a) || (c == a && a != b)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>) {
    var (A,B,C) = readLine()!!.split(" ").map(String::toInt).sorted()
    val offset = if(A % 2 != B % 2) {
        val tmp = (B-A) / 2 + 1
        C+=1
        A=B
        tmp
    } else {
        (B-A)/2
    }
    println(C-B + offset)
}

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

int cnt[10010];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        ++cnt[a];
    }
    int fir = 1;
    for (int i = 0; i < 10010; ++i) {
        for (int j = 0; j < cnt[i]; ++j) {
            if (!fir)
                cout << " ";

            cout << i;
            fir = 0;
        }
    }
    cout << "\n";

    return 0;
}

Measured memory_bytes: 3100
s = gets.chomp.split("")
ln = s.length
cnts = Array.new(ln, 0)

cnt = 0
for i in 0..(ln-2)
  if s[i] == "R"
    cnt += 1
  end
  if [s[i],s[i+1]].join == "RL"
    cnts[i] += cnt/2
    cnts[i+1] += cnt/2
    if cnt % 2 == 1
      cnts[i] += 1
    end   
    cnt = 0
  end
end

i = ln-1
while 1 <= i
  if s[i] == "L"
    cnt += 1
  end
  if [s[i-1],s[i]].join == "RL"
    cnts[i-1] += cnt/2
    cnts[i] += cnt/2
    if cnt % 2 == 1
      cnts[i] += 1
    end
    cnt = 0
  end
  i -= 1
end
puts cnts.join(" ")

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

struct	ITEM {
	int	wei;
	int	val;
};

bool	COMP(ITEM X, ITEM Y) {
	return(X.wei<Y.wei);
}

int	knap(vector<ITEM> &p, int ix, int K, vector<vector<int>> &V) {
	if (ix < 0)
	       return 0;	// No more item
	if (V.at(ix).at(K) >= 0) return V.at(ix).at(K); // Check memo if done for this
	//cout << K << ":" << ix << endl;
	int R=0;
	if (K == 0) R=0;	// No more spaece in knapsack
		// If space avalable, try both and pick up better one
	else if (K >= p.at(ix).wei)
		R=max( p.at(ix).val + knap(p, ix-1, K-p.at(ix).wei, V), knap(p, ix-1, K, V) );
		// No space to put this, but may be more
	else R=knap(p, ix-1, K, V);
	V.at(ix).at(K)=R;	// Let's take note for this
	return R;
};

int	main() {
	int N, T;
	cin >>N >>T;
	vector<ITEM> p(N);
	for (int i=0; i<N; i++)
		cin >>p.at(i).wei >>p.at(i).val;
	sort(p.begin(), p.end(), COMP);
	// Items = { Weight, Value }
	//vector<ITEM>	p = { {2, 3}, {1, 2}, {3, 6}, {2, 1}, {1, 3}, {5, 85} };
	// Memo table
	vector<vector<int>> V(N, vector<int> (T, -1));
	// initial value: only first one
	int S=0;
	for (int i=1; i<N; i++) {
		// Here we go
		S=max(S, knap(p, i-1, T-1, V)+p.at(i).val);
	}
	cout <<S <<endl;
	return 0;
}


Measured memory_bytes: 35840
import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;
  
public class Main{
    public static void main(final String[] args){
 
        final Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        int ans=0;
        long q =2;
 
        //1だった時はさっさと終わらす
        if(N==1){
            System.out.println(0);
            return;
        }
 
        //本編
        while(q*q<=N){
            //qを決定する
            if(N%q ==0){
                //qの累積を全部発見する
                for(int i = 1; N>=Math.pow(q,i);i++){
                    if(N%Math.pow(q, i)==0){
                        //発見するたびにカウントアップ
                        ans++;
                        //発見するたびに除算
                        N = (long) (N / Math.pow(q, i));
                    }
                }
                //qの累積は見つけ尽くしたので、Nからqを完全に取り除く
                while(N%q ==0){
                    N = N/q;
                }
            }   
            q++;
        }

        //1以外の数が搾りカスとして出たら足してあげる
        if(N != 1){ans++;}
            System.out.println(ans);
    }
}

Measured memory_bytes: 35640
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int a,b;
  char op;
  cin >> a >> op >> b;
  while(op!='?'){
    int c;
    if(op=='+') c=a+b;
    if(op=='-') c=a-b;
    if(op=='*') c=a*b;
    if(op=='/') c=a/b;
    cout << c << endl;
     cin >> a >> op >> b;
  }
  return 0;
}
 


Measured memory_bytes: 3104
def calc(a):
  if a %2 == 0:
    return a/2
  else:
    return 3*a+1

a = int(input())
A = [a]
while True:
  b = calc(a)
  A.append(b)
  c = A.count(a)
  a = b
  if c == 2:
    break
print(len(A)-1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);

using namespace std;

int n, m;

signed main()
{

 	FLASH

	cin>>n;
	int ans = n - 1;
	if(n == 2) return cout<<0, 0;
	
	for(int i = 2; i*i <= n; i++){
		if(n%i != 0) continue;
		int x = n%(i - 1);

		if(n == i*x) ans += i - 1;
		if(i*i == n) continue;

		x = n%(n/i - 1);
		if(n == (n/i)*x) ans += n/i - 1;
	} 	

	cout<<ans;
}

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

using namespace std;
using ll = long long;
const int limit = 100010;
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
    depth[v] = d;
    for (auto &e : tree[v])
    {
        if (e.to == p)
        {
            continue;
        }
        dfs(e.to, v, d + e.cost);
    }
}

void solve() {
    int N;
    cin >> N;
    for (int i = 0; i < N-1; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        tree[a].push_back({b, c});
        tree[b].push_back({a, c});
    }
    int Q, K;
    cin >> Q >> K;
    K--;
    
    dfs(K, -1, 0);
    for (int i = 0; i < Q; i++)
    {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        cout << depth[x] + depth[y] << endl;
    }
    
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 16104
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

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

int main() {
    int A, B;
    cin >> A >> B;
    if (A > B) cout << A + A - 1 << endl;
    else if (A < B) cout << B + B - 1 << endl;
    else cout << A + B << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
//01.標準入力(n) n:i64
//let n = read_i();
fn read_i() -> i64 {
    let stdin = stdin();
    let mut stdin = stdin.lock();
    let token = stdin
        .by_ref().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .fold(0, |a, x| (x as u8 - b'0') as i64 + a * 10);
    token
}
//02.標準入力(s) s:Vec<char>
//let s = read_s();
fn read_s() -> Vec<char> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token = stdin
        .bytes().map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !(*c=='\r'||*c=='\n')).collect();
    token
}
//03.標準入力(n) n:FromStr
//let n:u32=read();
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !(*c=='\r'||*c=='\n'))
        .collect();
    token.parse().ok().expect("failed to parse token")
}
//04.標準入力[a(1)...a(n)]
//let a:Vec<i64>=read_a();
fn read_a<T: FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
//05.標準入力(a,b)*n
//let mut a=Vec::new();
//let mut b=Vec::new();
//for _ in 0..n{
//    let tl:Vec<i64>=read_a();
//    a.push(tl[0]);
//    b.push(tl[1]);
//}

fn main() {
    let ab=read_a();
    let a:i64=ab[0];
    let b:i64=ab[1];
    let mut j=false;
    for c in 1..4{
        if a*b*(c as i64)%2==1{j=true;}
    }
    if j{println!("Yes")} else {println!("No")};
}


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

int main(){
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  cout << w * h / 2 << " " ;
  if(x == w / 2 && y == h / 2){
    cout << 1 << endl;
  }
  else{
    cout << 0 << endl;
  }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N, M; cin >> N >> M;
  vector<int> k(M); vector<vector<int>> s(M);
  vector<int> p(M);
  REP(i, M) {
    cin >> k[i];
    REP(m, k[i]) {
      int S; cin >> S;
      s[i].push_back(S);
    }
  }
  REP(i, M) cin >> p[i];
  int ans = 0;
  for(int bit = 0; bit < (1 << N); ++bit) {
    int res = 0;
    REP(m, M) {
      int tmp = 0;
      for(int i = 0; i < k[m]; ++i) {
        if(bit & (1 << (s[m][i]) - 1)) {
          tmp++;
        }
      }
      if(tmp % 2 == p[m]) res++;
    }
    if(res == M) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#define ll long long
#define write(a) printf("%d",a)
#define writeln printf("\n")
#define FOR(a,b,c) for (int a=b;a<=c;a++)
#define FORD(a,b,c) for (int a=b;a>=c;a--)
using namespace std;
inline ll read(){
    ll x=0,f=1;
    char c=getchar();
    while (c<'0'||c>'9'){
        if (c=='-')f=-1;
        c=getchar();
    }
    while (c>='0'&&c<='9'){
        x=x*10+c-'0';
        c=getchar();
    }
    return x*f;
}
int a[120];
int main(){
	a[1]=read();a[2]=read();a[3]=read();sort(a+1,a+4);
	write(abs(a[2]-a[1])+abs(a[3]-a[2]));writeln;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int):
    ret = N * N * N
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

signed main(void)
{
	string s;
	cin >> s;
	rep(i, s.size() - 1)
	{
		if ("AC" == s.substr(i, 2))
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>
#include <numeric>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

static const ll MAX = 200000;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

void printVector(const vector<ll>& vec) {
    for (ll value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int main()
{
    IO;

    ll n; cin >> n;
    vl a(n);

    rep(i, n) cin >> a[i];

    rep(i, n) {
        ll key = a[i];
        ll j = i - 1;
        while (j >= 0 && a[j] > key) {
            a[j + 1] = a[j];
            --j;
        }
        a[j + 1] = key;
        rep(i, n - 1) cout << a[i] << " ";
        cout << a[n - 1] << endl;
    }

}


Measured memory_bytes: 3208
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    ll n;cin>>n;
    vector<ll> a(n);
    vec<ll> cnt(1e5+3);
    rep(i, n) {
        cin>>a[i];
        cnt[a[i]]++;
        cnt[a[i]+1]++;
        cnt[a[i]+2]++;
    }
    dump(a);
    cout << *max_element(all(cnt)) << endl;
    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 4788
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  string s,t;
  cin>>s>>t;
  rep(i,sz(s)){
    if(s[i]!=t[i]){
      COUT("No");
      return 0;
    }
  }
  COUT("Yes");
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main() {
    int n, m, x;
    int a;

    cin >> n >> m >> x;
    
    int r = 0;
    int l = 0;

    for (int i = 0; i < m; i++) {
        cin >> a;
        if (a < x) {
            l++;
        } else {
            r++;
        }
    }

    if (r > l) {
        cout << l << endl;
    } else {
        cout << r << endl;
    }

    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
n, m = map(int, input().split())
data = [input().split() for i in range(m)]
check = [False] * (n + 1)
tmp_wa = [0] * (n + 1)
ac = 0
wa = 0

for i in range(m):
    if data[i][1] == 'WA':
        if check[int(data[i][0])]:
            continue
        else:
            tmp_wa[int(data[i][0])] += 1
    else:
        if check[int(data[i][0])]:
            continue
        else:
            check[int(data[i][0])] = True
            wa += tmp_wa[int(data[i][0])]
            ac += 1

print('{} {}'.format(ac, wa))


Measured memory_bytes: 33900
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,a[10][10];
    cin>>n;
    memset(a,0,sizeof(a));
    for(int i=1;i<=n;i++){
        a[to_string(i)[0]-'0'][i%10]++;
    }
    int ans=0;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            ans+=a[i][j]*a[j][i];
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, int>;
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i < (int)n; i++)
const ll mod = 1e9 + 7;
const ll inf = 1e12;
const double pi = 3.141592;
const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};

template <class T>
bool contain(const string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    int ans1 = a[n - 1];
    auto iter1 = lower_bound(a.begin(), a.end(), ans1 / 2);
    auto iter2 = iter1 - 1;
    int dis1 = abs(*iter1 - (ans1 / 2 ));
    int dis2 = abs(*iter2 - (ans1 / 2 ));
    int ans2 = 0;
    if (dis1 <= dis2){
        ans2 = *iter1;
        if (ans1 == ans2)
            ans2 = *iter2;
    }
    else if(dis1>dis2)
        ans2 = *iter2;
    cout << ans1 << " " << ans2 << "\n";
    return 0;
}

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

 // an operand should be pushed into the stack
 // an operator -> the program should pop two elements from the stack
 // perform the corresponding operations, then push the result in to the stack
 
int top;
int S[1010];

// input x
// increment top
void push(int x){
    S[top] = x;
    top++;
}

// decrement top
// remove the top element
int pop(){
    top--;
    return S[top];
}

int main(){
    
    int a, b;
    top = 0;
    char s[1010];
    // EOF: End Of File
    // 紐付けられているストリームがファイル終端に達していれば true を返す
    while(scanf("%s", s) != EOF){
        
        if (s[0]== '+'){
            a = pop();
            b = pop();
            push(a+b);
        }
        else if (s[0] == '-'){
            
            // -の場合, 取り出す順番に注意せよ！
            // [130, 20, -]ならば, push(130-20)!!
            b = pop();
            a = pop();
            push(a-b);
        }
        else if (s[0] == '*'){
            
            a = pop();
            b = pop();
            push(a*b);
        }
        else{
            push(atoi(s));
        }
    }
    
    printf("%d\n", pop());
}


Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, t, h = 1;
	string s, c, a = "";
	cin >> s >> num;
	rep(i, num) {
		cin >> t;
		if (t & 1)
			h = !h;
		else {
			cin >> t >> c;
			if (h ^ (t & 1))
				s += c;
			else
				a += c;
		}
	}
	if (h) {
		for (i = a.size() - 1; i >= 0; i--)
			cout << a[i];
		cout << s;
	}
	else {
		for (i = s.size() - 1; i >= 0; i--)
			cout << s[i];
		cout << a;
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 964
#include<stdio.h>
int cnt,m,G[101];

int insertionSort(int *A, int n, int g){
  int i;
  for (i = g ;i< n;i++){
          int v = A[i];
          int j = i - g;
          while( j >= 0 && A[j] > v){
              A[j+g] = A[j];
              j = j - g;
              cnt++;
            }
          A[j+g] = v;
        }
}



void shellSort(int *A, int n){
     cnt = 0;
     int x=0;
     while(1){
       x=x*3+1;
       if(x>n)break;
       G[m++]=x;
     }
     int i;
     for (i = 0 ;i< m;i++)insertionSort(A, n, G[m-i-1]);
}




int main(){
  int n;
  scanf("%d",&n);
  int A[n],i;
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  shellSort(A,n);
  printf("%d\n",m );
  for(i=m-1;i>=0;i--){
    if(i!=0)printf("%d ",G[i]);
    else printf("%d\n%d\n",G[i],cnt );
  }
  for(i=0;i<n;i++)printf("%d\n",A[i] );
  return 0;
}



Measured memory_bytes: 6596
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using ll = long long;

int constexpr N = 1009;
int n, m, dist[N][N];
char g[N][N];
array<int, 3> d {1, -1, 0};

bool in(int i, int j) {
    return i >= 1 && i <= n && j >= 1 && j <= m;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    fill((int*) dist, (int*) dist + N * N, 1e9);
    cin >> n >> m;
    queue<pair<int, int>> q;
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= m; ++j) {
            cin >> g[i][j];
            if(g[i][j] == '#') {
                q.push({i, j});
                dist[i][j] = 0;
            }
        }
    }
    while(q.empty() == false) {
        pair<int, int> f = q.front();
        q.pop();
        int i = f.fi, j = f.se;
        for(auto dx : d) {
            for(auto dy : d) {
                if(dx != 0 && dy != 0) continue;
                if(in(i + dx, j + dy) && dist[i][j] + 1 < dist[i + dx][j + dy]) {
                    dist[i + dx][j + dy] = dist[i][j] + 1;
                    q.push({i + dx, j + dy});
                }
            }
        }
    }

    int mx = 0;
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= m; ++j) mx = max(mx, dist[i][j]);
    }
    cout << mx << '\n';
}


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

int main() {
	int m, d, a = 0;
	cin >> m >> d;
	for (int i = 1; i <= m; i++)
		for (int j = 21; j <= d; j++)
			if (j % 10 > 1 && i == j / 10 * (j % 10))
				a++;
	cout << a << endl;
	return 0;
}


Measured memory_bytes: 256
# dpB - Frog 2
# 貰うDP
def main():
    n, k = tuple(map(int, input().rstrip().split()))
    A = tuple(map(int, input().rstrip().split()))
    dp = [float("inf")] * n
    dp[0] = 0
    for i in range(1, n):
        for j in range(1, k + 1):
            if i - j >= 0:
                dp[i] = min(dp[i], dp[i - j] + abs(A[i] - A[i - j]))
    print(dp[-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 58336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int INF = 1e9;
template<class T> inline void chmax(T &a,T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a,T b){if(a>b)a=b;}

int dp[100010];
vector<vector<int> > G;

int dfs(int v){
    if(dp[v]!=-1) return dp[v];
    int ret = 0;
    for(int nv : G[v]){
        chmax(ret,dfs(nv)+1);
    }
    return dp[v] = ret;
}

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,M,x,y;
    cin >> N >> M;
    G.resize(N);
    
    for(int i = 0; i < M; ++i){
        cin >> x >> y;
        --x; --y;
        G[x].push_back(y);
    }
    for(int i = 0; i < N; ++i) dp[i] = -1;
    int ans = 0;
    for(int i = 0; i < N; ++i) chmax(ans,dfs(i));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8192
import math
a,b,cdeg= map(float, input().strip().split())
crad = cdeg*math.pi/180
print(a*b/2*math.sin(crad))
print(a+b+math.sqrt(a**2 + b**2 -2*a*b*math.cos(crad)))
print(b*math.sin(crad))

Measured memory_bytes: 7852
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll D;
ll N;
ll M;
ll K;

int main(){

    
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;
    cin >> K;

    ll str = A * 60 + B;
    ll end = C * 60 + D;
    ll bet = end - str;

    cout << bet - K << endl;
    

}

Measured memory_bytes: 3620
#include<iostream>

using namespace std;

int main(){
	int H, W, i, j, ah = 0, aw = 0;
	char pic[1000][1000], ans[1000][1000];
	cin >> H >> W;
	for(i = 0; i < H; i++){
		aw = 0;
		for(j = 0; j < W; j++){
			cin >> pic[i][j];
			if(pic[i][j] == '*'){
				ans[ah][aw] = '*';
				ans[ah+1][aw] = '*';
				aw++;
			}
			else{
				ans[ah][aw] = '.';
				ans[ah+1][aw] = '.';
				aw++;
			}
			
		}
		ah += 2;
	}
	for(i = 0; i < H * 2; i++){
		for(j = 0; j < W; j++){
			cout << ans[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)

ll getOpt(char c, ll k){
    if(c-'a'==0)
        return 0;
    ll res = 'a'+26 - c;
    if(k>= res)
        return res;
    else
        return 0;
}

char change(char c, ll k){
    return (char)(((ll)(c-'a') + k) % 26 + 'a');
}

void solve(std::string s, long long K){
    ll N = s.length();
    rep(i, N){
        if(K>0){
            ll num = getOpt(s.at(i), K);
            s.at(i) = change(s.at(i), num);
            K -= num;
        }
    }

    if(K > 0)
        s.at(N-1) = change(s.at(N-1), K);
    
    cout << s << endl;
}

int main(){
    std::string s;
    std::cin >> s;
    long long K;
    scanf("%lld",&K);
    solve(s, K);
    return 0;
}


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,b;
		String op;
		String jj="+";
		a=sc.nextInt();
		op=sc.next();
		b=sc.nextInt();
		
		if(op.equals(jj)) {
			System.out.println(a+b);
		}else {
			System.out.println(a-b);
			}
	}
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;

void solve() {
  int N, ans = 0;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    if (to_string(i).size() % 2 != 0) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

  solve();

  return 0;
}


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

#define FOR(a,b,c) for (int a=(b);a<(c);++a)
#define REP(i,n) FOR(i,0,n)
#define ll long long
#define pii pair<int,int>
#define x first
#define y second
#define pb push_back
#define lf double

using namespace std;

const int MAX = (int)1e6 + 5;
const int MOD = (int)1e9 + 7;

inline int ADD(ll a,ll b){ return (a+b)%MOD;}
inline int MUL(int a,int b){ return (ll)a*b%MOD;}

int pot(int a,int n){
	int ret=1;
	while(n){
		if (n&1) ret=MUL(ret,a);
		a=MUL(a,a);
		n/=2;
	}
	return ret;
}

int calc_inv(int a){
	return pot(a,MOD-2);
}

int fact[MAX];
int inv[MAX];

int nck(int a,int b){
	return MUL(fact[a],MUL(inv[b],inv[a-b]));
}

int main(){
	int n,k,res=0;
	scanf ("%d%d",&n,&k);
	ll minn=0;
	ll maxx=0;
	REP(i,k){
		minn+=i;
		maxx+=n-i;
	}
	FOR(i,k,n+2){
		res=ADD(res,maxx-minn+1);
		minn+=i;
		maxx+=n-i;
	}
	
	printf ("%d\n",res);
	return 0;
}


Measured memory_bytes: 3828