akhauriyash/Code-Regression huggingface dataset:
import bisect
m = int(input())
a = []
for _ in range(m):
  a.append(int(input()))

a = list(map(lambda x: -x, a))
m = len(a)

lis = [float('inf')]*m

for x in a:
  lis[bisect.bisect_right(lis, x)] = x

print(len([x for x in lis if not (x == float('inf'))]))

Measured memory_bytes: 11060
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) printf("Case #%d: ",i);
using namespace std;
typedef long long int ll;
typedef complex<double> com;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main(){
	int n; cin >> n;
	vector<int> a(n);
	rep(i, 0, n) cin >> a[i];
	int ans = 0;
	rep(i, 0, n) {
		if (a[i] == i + 1) {
			if (i != n - 1)swap(a[i], a[i + 1]);
			else swap(a[i - 1], a[i]);
			ans++;
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define rep0(i,n) for(int i=0;i<n;i++)
#define per0(i,n) for(int i=n;i>0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
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; }
 

void solve() {
    int n, K; cin >> n >> K;
    vector<int> h_list;
    h_list.push_back(0);
    rep(i,0,n){
        int temp; cin >> temp;
        h_list.push_back(temp);
    }

    vector<int> dp(n+10);
    dp[0] = 10000000;
    dp[1] = 0;
    rep(i,2,n+1){
        dp[i] = 1000000000;
        rep(k,1, min(i, K+1)){
            chmin(dp[i], dp[i-k] + abs(h_list[i]-h_list[i-k]));
        }
    } 
    int ans = dp[n];
    //rep(i,0,n+1){
        //cout << dp[i];
    //}
    cout << ans;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

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

ll solve() {
    ll N, M;
    cin >> N >> M;
    map<ll, ll> p;
    for ( ll k = 2; k * k <= M; k++ ) {
        while ( M % k == 0 ) {
            p[k]++;
            M /= k;
        }
    }
    if ( M != 1 ) p[M]++;

    const ll MOD = 1e9 + 7;
    auto Add = [&](ll& x, ll y) { x = ( x % MOD + y % MOD ) % MOD; };
    auto Mul = [&](ll& x, ll y) { x = ( x % MOD * y % MOD ) % MOD; };
    auto Pow = [&](ll x, ll n) -> ll {
        ll t = x % MOD, r = 1;
        while ( n > 0 ) {
            if ( n & 1 ) Mul(r, t);
            Mul(t, t);
            n >>= 1;
        }
        return r;
    };
    auto Inv = [&](ll a) -> ll {
        return Pow(a, MOD - 2);
    };
    auto bin = [&](ll n, ll k) {
        ll x = 1;
        for ( ll i = 1; i <= k; i++ ) {
            Mul(x, n+1-i);
            Mul(x, Inv(i));
        }
        return x;
    };
    ll ans = 1;
    for ( auto u : p ) {
        ll k = u.second;
        ll b = bin(N+k-1, k);
        Mul(ans, b);
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>

#define fir first
#define sec second
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define All(s) (c).begin(), (c).end()
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define repk(i, j, k) for(int (i)=(j);(i)<(k);(i)++)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long int ll;
const ll INF = 10241024;
int N;
int ans = 0;

int main(){
    cin >> N;
    vector<int> numbers(N-1);
    rep(i, N-1){
        cin >> numbers[i];
    }

    ans += numbers[0] + numbers[N-2];
    for (int i=0;i<N-2;i++){
        ans += min(numbers[i], numbers[i+1]);
    }

    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{   
    map<ll,ll> t;
    t[1]=0;
    t[2]=0;
    t[3]=0;
    t[4]=0;
    ll ai, bi;
    for(int i=0;i<3;i++){
        cin >> ai >> bi;
        t[ai]++; t[bi]++;
    }
    if(t[1]>=3 || t[2]>=3 || t[3]>=3 || t[4]>=3){
        cout<<"NO"<<endl;
    }else{
        cout<<"YES"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
# n = gets.to_i
s = gets.chomp
# n,m = gets.split.map(&:to_i)

def y(f)
    puts f ? "Yes" : "No"
end

# y(true)

 class String
   # 文字列が回文であればtrueを返す
   def palindrome?
     self == self.reverse
   end
 end
 
n = s.size
y(s.palindrome? && s[0,(n-1)/2].palindrome? && s[(n+3)/2-1,(n-1)/2].palindrome? )

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

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

        cout<<A*B<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  while(1){
    string s;
    cin>>s;
    if(s=="-"){
      break;
    }
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
      int h;
      cin>>h;
      s=s.substr(h)+s.substr(0,h);
    }
    cout<<s<<endl;
  }
  return 0;
}


Measured memory_bytes: 3160
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
int main(){
    string str;
    cin >> str;
    ll cnt=0,cnt2=0;
    for(ll i=0;i<str.size();i++){
        if(i%2==0&&str[i]=='0') cnt++;
        else if(i%2==1&&str[i]=='1') cnt++;
    }
    for(ll i=0;i<str.size();i++){
        if(i%2==0&&str[i]=='1') cnt2++;
        else if(i%2==1&&str[i]=='0') cnt2++;
    }
    cout << min(cnt,cnt2);
    return 0;
}

Measured memory_bytes: 512
using System;
using System.Linq;

namespace _0336
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (x.Sum() == 0) Console.WriteLine(0);
            else Console.WriteLine(x.Sum() > 0 ? 1 : -1);
        }
    }
}

Measured memory_bytes: 9588
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int N, W, w[110], v[110];

    cin >> N >> W;
    REP(i, N)
    cin >> w[i] >> v[i];

    ll dp[110][100010];

    memset(dp, 0, sizeof(dp));

    //dp[1][w[0]] = v[0];

    for (int i = 1; i <= N; i++)
    {
        for (int j = 1; j <= W; j++)
        {
            if (j - w[i - 1] >= 0)
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
            else
                dp[i][j] = dp[i - 1][j];
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}

Measured memory_bytes: 86272
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#include <typeinfo>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){
    string S;
    cin >> S;
    int y,m,d;
    y = stoi(S.substr(0,4));
    m = stoi(S.substr(5,2));
    d = stoi(S.substr(8,2));
    if(y >= 2019 && m >= 5 && d >= 1){
        cout << "TBD" << endl;
    }
    else{
        cout << "Heisei" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
A, B, K = map(int, input().split())

a = []
b = []

if A >= 2:
    for i in range(1, A//2):
        if A % i == 0:
            a.append(i)
            a.append(A//i)
else:
    a.append(1)
if B >= 2:
    for i in range(1, B//2):
        if B % i == 0:
            b.append(i)
            b.append(B//i)
else:
    b.append(1)

anslist = list(set(a) & set(b))
anslist.sort(reverse=True)
print(anslist[K-1])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    // f.clear();
    int n,m;
    cin>> n>> m;
    int a=max(n,m);
    // func(a);
    // cout<<a<<endl;
    long long num1=0;
    long long num2=0;

    if(n>=2)
    {
        num1=n*(n-1)/2;

    }
    if(m>=2)
    {
        num2=m*(m-1)/2;
    }
    
    cout<<num1+num2<<endl;
    return 0;
    
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		long a = GetLong();
		long b = GetLong();
		long c = GetLong();

		long tmp = c - (a + b);
		if(tmp <= 0)
		{
			WriteLine("No");
			return;
		}
		WriteLine(4 * a * b < tmp * tmp ? "Yes" : "No");
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include <stack>
#include <sstream>
#include <vector>
#include <queue>

#define f first
#define s second

#define ll long long

using namespace std;

ll pow_(ll a,ll b)
{
    if(b==0)
        return 1;
    if(b%2!=0)
        return a*pow_(a,b-1);
    ll x=pow_(a,b/2);
    return x*x;
}

int main()
{
    ios_base::sync_with_stdio(false);
    srand(time(NULL));
//    ifstream cin("input.txt");
//    ofstream cout("output.txt");
    string str;
    cin>>str;
    if(str[0]=='Y' && str[1]=='A' && str[2]=='K' && str[3]=='I')
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

int main(){
    char N[5];
    int i;
    scanf("%s",N);
    int len = strlen(N);
    for(i=0;i<len;i++){
        if(N[i]==N[len-i-1])
            continue;
        else
            break;
    }
    if(i==len)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;
int main()
{
    string s;
    cin >> s;

    if (s.length() == 2) // 判断长度是否为 2
    {
        // 照原样打印
        cout << s << endl;
    } else { // 长度为 3
        reverse(s.begin(), s.end()); // 翻转字符串
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}

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

  sieve(55555);
  vector<int> ans;
  rep1(i,55555){
    if(IsPrime[i]){
      if(i%5==1){
	ans.pb(i);
	cout << i << " ";
      }
    }
    if(ans.size()==n) break;
  }
  cout << "" << endl;

  
  return 0;
    

}


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

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        List<Integer> A = new ArrayList<>();
        List<Boolean> R = new ArrayList<>();
        for (int i = 0; i < 9; i++) {
            int a = Integer.parseInt(s.next());
            A.add(a);
            R.add(false);
        }
        int N = Integer.parseInt(s.next());
        for (int i = 0; i < N; i++) {
            int b = Integer.parseInt(s.next());
            for (int j = 0; j < A.size(); j++) {
                if (A.get(j) == b) {
                    R.set(j, true);
                }
                if (bingo(R)) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }

    static boolean bingo(List<Boolean> list) {
        return (list.get(0) && list.get(1) && list.get(2)) || (list.get(3) && list.get(4) && list.get(5))
                || (list.get(6) && list.get(7) && list.get(8)) || (list.get(0) && list.get(3) && list.get(6))
                || (list.get(1) && list.get(4) && list.get(7)) || (list.get(2) && list.get(5) && list.get(8))
                || (list.get(0) && list.get(4) && list.get(8)) || (list.get(2) && list.get(4) && list.get(6));
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
int main(void){
    string s,t;
    cin>>s>>t;
    string ans="A";
    bool che=false;
    for(int i=0;i<s.size();i++){
        int c=0;
        for(int j=0;j<t.size();j++){
            if(s[i+j]==t[j]||s[i+j]=='?')c++;
        }
        if(c==t.size()){
            string u=s;
            for(int j=0;j<t.size();j++){
                u[i+j]=t[j];
            }
            for(int j=0;j<s.size();j++){
                if(u[j]=='?')u[j]='a';
            }
            che=true;
            if(ans=="A")ans=u;
            if(ans>u)ans=u;
        }
    }
    if(che){
        cout<<ans<<endl;
    }
    else{
        cout<<"UNRESTORABLE"<<endl;
    }
    return 0;
}


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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int a; cin >> a;
    cout << a + a*a + a*a*a << endl;

    return 0;
}


Measured memory_bytes: 3560
s=input()
a=["dreamer", "dream", "eraser", "erase"]
while s:
  for i in a:
    k=len(i)
    if s[-k:]==i:
      s=s[:-k]
      break
  else:
  	break

if s=="":
  print("YES")
else:
  print("NO")

Measured memory_bytes: 9168
console.log(
  require('fs')
    .readFileSync('/dev/stdin', 'utf8')
    .split('\n')
    .slice(1, 3)
    .map(l => l.split(' ').map(s => parseInt(s)))
    .reduce((v, c) => v.map((e, i) => Math.max(e - c[i], 0)))
    .reduce((s, c) => s + c)
);


Measured memory_bytes: 21064
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
now = a[0]
for i in range(1,n):
    now ^= a[i]
for i in range(n):
    print(now ^ a[i])

Measured memory_bytes: 32716
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    int n,w;
    cin >> n >> w;
    ll g[n],v[n];
    rep(i,0,n)cin >> g[i] >> v[i];

    ll dp[n+1][w+1] = {};

    rep(i,0,n){
	rep(j,0,w+1){
	    if(j-g[i] >= 0){
		dp[i+1][j] = max(dp[i][j], dp[i][j-g[i]] + v[i]);
	    }else{
		dp[i+1][j] = dp[i][j];
	    }
	}
    }

    P(dp[n][w]);
    return  0;
}


Measured memory_bytes: 79104
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int a, b;
	cin >> a >> b;

	cout << max(0, a - 2 * b) << "\n";

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = array = list(map(int, input().split()))

res = True
for a in A:
    if a % 2 == 0:
        if (a % 3 == 0) or (a % 5 == 0):
            continue
        else:
            res = False

if res:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL read(){
	LL x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)&&ch!='-')
		ch=getchar();
	if (ch=='-')
		f=-1,ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x*f;
}
const int N=1000005;
struct Gragh{
	static const int M=N*2;
	int cnt,y[M],nxt[M],fst[N];
	void clear(){
		cnt=1;
		memset(fst,0,sizeof fst);
	}
	void add(int a,int b){
		y[++cnt]=b,nxt[cnt]=fst[a],fst[a]=cnt;
	}
}g;
int n;
int f[N],dp[N][2];
void dfs(int x,int pre){
	int cnt=0,y=0;
	for (int i=g.fst[x];i;i=g.nxt[i])
		if (g.y[i]!=pre){
			y=g.y[i],cnt++;
			dfs(y,x);
		}
	if (cnt==0){
		f[x]=1;
		dp[x][0]=dp[x][1]=1;
		return;
	}
	if (cnt==1){
		f[x]=f[y];
		dp[x][0]=dp[y][0];
		dp[x][1]=dp[y][1];
		return;
	}
	f[x]=0;
	dp[x][1]=0;
	for (int i=g.fst[x];i;i=g.nxt[i])
		if (g.y[i]!=x){
			y=g.y[i];
			dp[x][1]+=min(dp[y][0],dp[y][1]);
		}
	dp[x][0]=dp[x][1];
/*	if (cnt==2){
		int tot=0;
		for (int i=g.fst[x];i;i=g.nxt[i])
			if (g.y[i]!=x){
				y=g.y[i];
				tot+=dp[y][1];
			}
		for (int i=g.fst[x];i;i=g.nxt[i])
			if (g.y[i]!=x){
				y=g.y[i];
				if (f[y])
					dp[x][0]=min(dp[x][0],tot-dp[y][1]);
			}
		return;
	}*/
	for (int i=g.fst[x];i;i=g.nxt[i])
		if (g.y[i]!=x){
			y=g.y[i];
			if (f[y])
				dp[x][0]=min(dp[x][0],dp[x][1]-min(dp[y][0],dp[y][1]));
		}
}
int in[N];
int main(){
	n=read();
	g.clear();
	for (int i=1;i<n;i++){
		int a=read()+1,b=read()+1;
		g.add(a,b);
		g.add(b,a);
		in[a]++,in[b]++;
	}
	if (n==1)
		return puts("0"),0;
	if (n==2)
		return puts("1"),0;
	int rt=0;
	for (int i=1;!rt&&i<=n;i++)
		if (in[i]==1)
			rt=i;
	dfs(rt,0);
//	printf("%d\n",rt);
//	for (int i=1;i<=n;i++)
//		printf("%d %d %d\n",dp[i][0],dp[i][1],f[i]);
	printf("%d",dp[rt][1]);
	return 0;
}

Measured memory_bytes: 23680
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int H, W;
int K;
int v[3000][3000] ={};

ll dp[3000][3000][4];
ll solve(int y, int x, int n){
    if(y >= H || x >= W) return -1e18L;
    if(y == H-1 && x == W-1){
        if(n < 3) return v[y][x];
        return 0;
    }
    if(dp[y][x][n] != -1) return dp[y][x][n];
    ll ret = 0;
    ret = max(ret, solve(y+1, x, 0));
    ret = max(ret, solve(y, x+1, n));
    if(n < 3){
        ret = max(ret, solve(y+1, x, 0) + v[y][x]);
        ret = max(ret, solve(y, x+1, n+1) + v[y][x]);
    }
    return dp[y][x][n] = ret;
}

signed main(){
    cin >> H >> W >> K;
    rep(i, K){
        int y, x, _v;
        cin >> y >> x >> _v;
        v[y-1][x-1] = _v;
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0, 0) << endl;
}

Measured memory_bytes: 320688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll m = 1000000007;

ll fn(ll n, ll a, ll mod = m) {
    ll res = 1, x = a%mod;
    ll ans = 0;
    while(n) {
        if(n&1) ans = (x*ans + res)%mod;
        res = ((res*x)%mod + res%mod)%mod;
        x = (x*x)%mod;
        n = n/2;
    }
    return ans;
}

ll mul(ll a, ll b, ll mod = m) {
    ll r = 0;
    a %= mod;
    while (b) {
        if (b & 1) r = (r+a)%mod;
        a = (a+a)%mod;
        b = b/2;
    }
    return r;
}

ll power(ll x, ll n, ll mod = m) {
    ll res = 1;
    x %= mod;
    while (n)  
    {  
        if (n & 1)  res = (res*x)%mod;  
        n = n/2; 
        x = (x*x)%mod;  
    }  
    return res;
}

ll power2(ll x, ll n) {
    ll res = 1;
    while (n)  
    {  
        if (n & 1)  res = (res*x);  
        n = n/2; 
        x = (x*x);  
    }  
    return res;
}

bool is_prime(long long x) {
    if(x == 1 || x == 0) return false;
    for(int i=2; i*i <= x; i++) {
        if(x%i == 0) return false;
    }
    return true;
}

ll compgcd(ll n, vector<ll> primes) 
{ 
    ll res = n; 
    for (ll i=0; primes[i]*primes[i] <= n; i++) {
        if (n % primes[i]== 0) { 
            res -= (res / primes[i]); 
            while (n%primes[i]== 0) {
               n/=primes[i]; 
            }
        } 
    } 
    if (n > 1) {
       res -= (res / n); 
    }
    return res; 
} 

vector<bool> sieve(vector<bool> &prime, vector<ll> &primes, ll lim) {
    for(int i = 2; i*i <= lim; i++) {
        if(prime[i]) {
            for(int j = 2; j*i <= lim; j++) {
                prime[j*i] = false;
            }
        }
    }
    for(int i = 2; i <= lim; i++) {
        if(prime[i]) {
            primes.push_back(i);
        }
    }
    return prime;
}

void sieveGCD(ll lim, vector<ll> &tab, vector<ll> primes) {
    for(int  i = 1; i <= lim; i++) {
        tab[i] = i;
    }
    for(int i = 0; i<primes.size() && primes[i] <= lim; i++) {
        tab[primes[i]] = primes[i]-1;
        for(int j = 2; primes[i]*j <= lim; j++) {
            tab[primes[i]*j] = (tab[primes[i]*j]/primes[i])*(primes[i]-1);
        }
    }
}

int main() 
{ 
    ios_base::sync_with_stdio(false);
    ll N;
    cin >> N;
    bool seven = false;
    while(N > 0) {
        if(N%10 == 7) {
            seven = true;
            break;
        }
        N /= 10;
    }
    if(seven) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
} 

Measured memory_bytes: 3640
n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))

def make_list(A):
    n = len(A)
    result = []
    for i in range(2**n):
        tmp = 0
        if i == 0:
            idx = ['0' for _ in range(n)]
        else:
            idx = list(bin(i).lstrip('0b').zfill(n))
        for num, j in enumerate(idx):
            if j == '1':
                tmp += A[num]
        result.append(tmp)
    return result


res = make_list(A)
for i in m:
    if i in res:
        print('yes')
    else:
        print('no')


Measured memory_bytes: 43092
#include<stdio.h>
int main()
{
    int m;
    while(scanf("%d",&m)!=EOF)
    {
        int key,i,j,x,A[150];
        for(i=0;i<m;i++)scanf("%d",&A[i]);
        for(i=0;i<m;i++)
        {
            key=A[i];
            j=i-1;
                while(j>=0&&A[j]>key)
            {
                A[j+1]=A[j];
                j--;
                A[j+1]=key;

            }
            for(x=0; x<m-1; x++)printf("%d ",A[x]);printf("%d\n",A[x]);
        }
    }return 0;
}



Measured memory_bytes: 2036
#include <iostream>
#include <cassert>
#include <cmath>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;

// ÀW(xNg)
typedef complex<double> P;
// ½p`(¶ñ]ðOñÆ·é)
typedef vector<P> G;
// ¼ü
struct L : public vector<P>
{
	L(P a, P b) { push_back(a); push_back(b); }
};


// î{Ö(è)
#define EPS			(1e-10)
#define PI			(3.14159265358979323846)

#define X(a)		( (a).real() )
#define Y(a)		( (a).imag() )
#define EQ(a,b)		( -EPS<(a)-(b) && (a)-(b)<EPS )
#define EQV(a,b)	( EQ(X(a),X(b)) && EQ(Y(a),Y(b)) )

#define unit(a)		( (a)/abs(a) )
#define normal(a)	( (a)*P(0,1) )
#define dot(a,b)	( X((a)*conj(b)) )
#define cross(a,b)	( Y(conj(a)*(b)) )

vector<L> common_lineCC(P a, double ra, P b, double rb)
{
	double k,kc; P s,t;
	kc = atan2(Y(b-a),X(b-a));

	vector<L> ret;

	for(int i=-1; i<=1; i+=2)
	for(int j=-1; j<=1; j+=2)
	{
		k = kc + j*asin( (rb+i*ra)/abs(b-a) );
		s = a  + polar( ra, k-i*j*PI/2);
		t = s  + polar(100.0, k);

		ret.push_back( L(s,t) );
	}

	return ret;
}

double s_distLP(P a, P b, P p)
{
	return abs(cross(b-a, p-a))/abs(b-a);
}


P p[64];
double r[64],m[64];
vector<L> line;

int main()
{
	int N;
	while(cin >> N, N)
	{
		for(int i=0; i<N; i++)
		{
			cin >> X(p[i]) >> Y(p[i]) >> r[i] >> m[i];
		}

		if(N==1)
		{
			cout << 1 << endl;
			continue;
		}

		int mx=0,tm;
		for(int i=0; i<N-1; i++)
		for(int j=i+1; j<N; j++)
		{
			double ra[] = {r[i], r[i]+m[i]};
			double rb[] = {r[j], r[j]+m[j]};

			for(int ii=0; ii<2; ii++)
			for(int jj=0; jj<2; jj++)
			{
				line = common_lineCC(p[i],ra[ii],p[j],rb[jj]);

				for(int k=0; k<4; k++)
				{
					tm=0; double dis;
					for(int n=0; n<N; n++)
					{
						dis = s_distLP(line[k][0],line[k][1],p[n]);
						if( r[n]-EPS <= dis && dis<=r[n]+m[n]+EPS )
						{
							tm++;
						}
					}
					mx = max(tm,mx);
				}
			}
		}
		cout << mx << endl;
	}
}

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

int main()
{
    int n; cin >> n;
    set<string> ans;
    string s;
    while (n--) {
        cin >> s;
        ans.insert(s);
    }
    cout << ans.size();
    return 0;
}


Measured memory_bytes: 19064
import scala.io.StdIn

object Main {

  def main(args: Array[String]): Unit = {

    val Array(w, h, n) = StdIn.readLine().trim.split(' ').map(_.toInt)

    val (xs, ys, as) = (1 to n).map { _ =>
      val Array(x, y, a) = StdIn.readLine().trim.split(' ').map(_.toInt)
      (x, y, a)
    }.unzip3

    var (left, right, top, bottom) = (0, w, h, 0)

    (0 until n).foreach { i =>

      as(i) match {
        case 1 =>
          if (left < xs(i)) { left = xs(i) }
        case 2 =>
          if (xs(i) < right) { right = xs(i) }
        case 3 =>
          if (bottom < ys(i)) { bottom = ys(i) }
        case 4 =>
          if (ys(i) < top) { top = ys(i) }
      }
    }

    if (left < right && bottom < top) {
      println((right - left) * (top - bottom))
    } else {
      println(0)
    }
  }
}


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

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

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

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

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

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

int main()
{
    IN(ll, N);
    AIN(string, s, N);
    map<string, ll> S;
    FOR(x, s)
    {
        SORT(x);
        ++S[x];
    }
    ll ans = 0;
    for (auto [_, c] : S)
    {
        ans += c * (c - 1) / 2;
    }
    OUT(ans);
}

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

#define int long long 
#define all(a) (a).begin(), (a).end()

int32_t main(){ 
    ios::sync_with_stdio(false) ; 
    cin.tie(0) ;
	freopen("debug.txt" , "w" , stderr) ; 
	int a , b , c , d ;
	cin >> a >> b >> c >> d ;
	int ans = max(a * c , max(a * d , max(b * c , b * d))) ; 
	cout << ans ;

	return 0 ;
}

Measured memory_bytes: 3680
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>
#include <algorithm>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	std::cin >> n;
	std::vector<int> lis;
	while(n--) {
		int x;
		std::cin >> x;
		x = -x;
		int id = std::upper_bound(lis.begin(), lis.end(), x) - lis.begin();
		if((int) lis.size() == id) lis.push_back(0);
		lis[id] = x;
	}
	std::cout << lis.size() << '\n';
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,ans;
string s;
int main(void){
    cin>>s;
    n=s.size();
    ll a=0;
    for(int i=0;i+1<n;i++){
		if(s[i]=='A'){
			a++;
		}else if(s[i]=='B'&&s[i+1]=='C')ans+=a,i++;
		else a=0;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
using namespace std;
int n,ans;
pair<ll,int> a[200001];
int main()
{
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i].first;
	sort(a,a+n);
	for (int i=n;i--;)
    {
		if (a[i].second) continue;
		ll t=2LL<<__lg(a[i].first);
		int k=upper_bound(a,a+i,mp(t-a[i].first,0))-a;
		if (0<k && k<=i && a[i].first+a[k-1].first==t) ans++,a[k-1].second=1;
    }
	cout<<ans;
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int A,B,C;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>B>>C;
	
	if(C==0) return _P("YES\n");
	for(i=1;i<=100;i++) {
		if((A*i%B)>0 && C % (A*i%B)==0) return _P("YES\n");
	}
	_P("NO\n");
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#include <iostream>                                                                                                               
using namespace std;                                                                                                              
                                                                                                                                  
int main(void) {                                                                                                                  
  int a, b, c;                                                                                                                    
  cin >> a >> b >> c;                                                                                                             
  int ans=0;                                                                                                                      
  for (int i=a; i<=b; i++) {                                                                                                      
    if (c%i==0) {                                                                                                                 
      ans++;                                                                                                                      
    }                                                                                                                             
  }                                                                                                                               
  cout << ans << endl;                                                                                                            
  return 0;                                                                                                                       
}                                                                                                                                 
                                                                                                                                  
                                                                                                                                  
                                    

Measured memory_bytes: 3096
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();
        System.out.println(Math.min(a+b, Math.min(b+c, c+a)));
    }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define ri register int
typedef long long ll;
const int N=55,mod=1e9+7;
int c[N][N],f[N][N];
int main(){
	ri n,i,j,k,x,y;
	scanf("%d",&n);
	for(i=0;i<=n;++i){
		c[i][0]=1;
		for(j=1;j<=i;++j)
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod; 
	}
	f[1][0]=f[1][1]=n;
	for(i=1;i<n;++i)
		for(j=0;j<=i;++j)
			if(f[i][j])
				for(k=max(1,j);k<=n-i;++k)
					if(~(k-j)&1){
						y=(k-j)/2;
						for(x=0;x<=k;++x)
							f[i+k][abs(x-y)]=(f[i+k][abs(x-y)]+(ll)f[i][j]*c[n-i][k]%mod*c[k][x])%mod;
					}
	printf("%d\n",f[n][0]);
	return 0;
}

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

int main() {
  int N, K, S;
   cin >> N >> K;
  
  S = 1;
  for (int i = 0; i < N; i++) {
    if (S < K) {
      S *= 2;
    }
    else {
      S += K;
    }
  }
    cout << S << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int x1,x2;
	scanf("%d %d",&x1,&x2);
	if(x2>x1){
		printf("%d\n",x2-x1);
	}
	else if(x1>x2){
		printf("%d\n",x1-x2);
	}
	else{
		printf("%d\n",x1-x2);
	}
	return 0;
}


Measured memory_bytes: 2712
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, aa, bb, ans;
	cin >> a >> b >> aa >> bb;
	ans = (a - aa) * (b - bb);
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
data = []
X = []
for i in range(N):
    T, A = map(int, readline().split())
    data.append((T,A))

T_pre,A_pre = data[0] 
for i in range(1,N):
    T,A = data[i]
    n = max(-(-T_pre//T),-(-A_pre//A))
    T_pre = n*T
    A_pre = n*A
print(T_pre+A_pre)    

Measured memory_bytes: 9256
#include <iostream>
#include <vector>

void solve() {
    int n, m;
    std::cin >> n >> m;

    std::vector<int> ts(m);
    for (auto& t : ts) {
        std::cin >> t;
        --t;
    }

    std::vector<int> ans(n, 0);
    for (auto t : ts) {
        for (int i = 0; i < n; ++i) {
            int x;
            std::cin >> x;
            --x;

            ++ans[(x == t ? i : t)];
        }
    }

    for (auto a : ans) std::cout << a << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}



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

void call(int n){
  int i = 1;
	CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
	INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
	END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;
}

int main() {
	int n;
	cin >> n;
	// call(n);
	for(int i = 1; i <= n; i++) {
		int x = i;
		if(x % 3 == 0) {
			cout << " " << i;
		}
		else{
			while(x) {
				if(x % 10 == 3) {
					cout << " " << i;
					break;
				}
				else {
					x /= 10;
				}
			}
		}
	}
	cout << endl;
}





Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include<cmath>
#include<limits>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    unsigned long long int n,t=0;
	cin>>n;
	for(unsigned long long int i=0;i<=n;i++){
		if(0==i%15){
			continue;
		}
		else if(0==i%3){
			continue;
		}
		else if(0==i%5){
			continue;
		}
		else{
			t+=i;
		}
	}
	cout<<t<<endl;
}

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = 2147483647;
constexpr ll L_INF = 9223372036854775807LL;

//===

template <typename _Ty>
struct Edge
{
	int src, to;
	_Ty cost;

	constexpr Edge(int _to, _Ty _cost) noexcept : src(-1), to(_to), cost(_cost) {}
	constexpr Edge(int _src, int _to, _Ty _cost) noexcept : src(_src), to(_to), cost(_cost) {}
};

template <typename _Ty>
using WeightedGraph = std::vector<std::vector<Edge<_Ty>>>;

template <typename _Ty>
void bellman_ford(std::vector<_Ty>& dist, std::vector<bool>& closed, std::vector<int>& prev, const WeightedGraph<_Ty>& g, int s)
{
	constexpr _Ty inf = std::numeric_limits<_Ty>::max();
	int n = static_cast<int>(g.size());
	dist.resize(n, inf);
	closed.resize(n, false);
	prev.resize(n, -1);
	dist[s] = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			for (const auto& edge : g[j]) {
				if (dist[j] != inf && dist[edge.to] > dist[j] + edge.cost) {
					dist[edge.to] = dist[j] + edge.cost;
					prev[edge.to] = j;
					if (i == n - 1) {
						closed[edge.to] = true;
					}
				}
			}
		}
	}
}



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

	WeightedGraph<ll> g(N);

	for (int i = 0; i < M; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		--a; --b;
		g[a].emplace_back(b, -c);
	}

	Vl dist;
	Vi prev;
	vector<bool> closed;
	bellman_ford(dist, closed, prev, g, 0);

	if (closed[N - 1]) {
		cout << "inf" << endl;
	}
	else {
		cout << -dist[N - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		scan.close();

		if(b < 10){
			a *= 10;
		}else if(b < 100) {
			a *= 100;
		}else
			a *= 1000;

		int c = a + b;

		if(((int) Math.sqrt(c)) * ((int) Math.sqrt(c)) == c)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 21716