akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <utility>
#include <vector>

long long int gcd(long long int a, long long int b)
{
    long long B = std::min(a, b);
    if (B == 0) {
        return std::max(a, b);
    }
    return gcd(std::max(a, b) % B, B);
}

std::pair<long long int, long long int> norm(
    long long int a,
    long long int b)
{
    long long int g = gcd(std::abs(a), std::abs(b));
    return std::make_pair(((b < 0LL) ? -a : a) / g, std::abs(b) / g);
}

int main()
{
    int n;
    constexpr static long long int mod = 1000000007LL;
    long long int ans = 1LL, zero = 0LL;
    std::cin >> n;
    std::vector<long long int> p2(n + 1);
    p2[0] = 1;
    for (int i = 0; i < n; i++) {
        p2[i + 1] = (p2[i] * 2LL) % mod;
    }

    std::map<std::pair<long, long>, std::pair<long, long>> eq;
    for (int i = 0; i < n; i++) {
        long long int a, b;
        std::cin >> a >> b;

        if (a == 0LL && b == 0LL) {
            zero++;
        } else if (a == 0LL) {
            eq[std::make_pair(0LL, 0LL)].first++;
        } else if (b == 0LL) {
            eq[std::make_pair(0LL, 0LL)].second++;
        } else {
            auto n = norm(a, b);
            if (n.first < 0LL) {
                eq[std::make_pair(n.second, -n.first)].second++;
            } else {
                eq[n].first++;
            }
        }
    }

    for (auto&& e : eq) {
        long long r = (p2[e.second.first] + p2[e.second.second] - 1LL) % mod;
        ans = (ans * r) % mod;
    }
    ans = (ans + mod - 1LL + zero) % mod;

    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 19940
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    vint kb(32,0);
    int now=0;
    while(k>0){
        kb[now]=k%2;
        k>>=1;
        now++;
    }
    vvint ab(n,vint(32,0));
    vll b(n);
    ll ans = 0;
    REP(i,n){
        int a;
        cin >> a >> b[i];
        now=0;
        while(a>0){
            ab[i][now]=a%2;
            a>>=1;
            now++;
        }
    }
    for(int i=31;i>=-1;i--){
        if(i>=0&&kb[i]==0)continue;
        ll tmp=0;
        REP(x,n){
            bool f = true;
            for(int j=31;j>i;j--){
                if(ab[x][j]>kb[j]){
                    f=false;
                    break;
                }
            }
            if(i>=0&&f){
                if(ab[x][i]==1){
                    f=false;
                }
            }
            if(f)tmp+=b[x];
        }
        ans = max(ans,tmp);
    }

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

Measured memory_bytes: 17536
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

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

  ld L;
  std::cin >> L;

  ld ans = (L / 3.0) * (L / 3.0) * (L / 3.0);
  std::cout << std::setprecision(9);
  print(ans);

  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int q = sc.nextInt();
        long[] s = new long[a + 2];
        long[] t = new long[b + 2];
        for (int i = 0; i < a; i++) {
            s[i] = sc.nextLong();
        }
        s[a] = (long) Math.pow(10, 18) * -1;
        s[a + 1] = (long) Math.pow(10, 18);
        for (int i = 0; i < b; i++) {
            t[i] = sc.nextLong();
        }
        t[b] = (long) Math.pow(10, 18) * -1;
        t[b + 1] = (long) Math.pow(10, 18);
        Arrays.sort(s);
        Arrays.sort(t);
        for (int i = 0; i < q; i++) {
            long x = sc.nextLong();
            int smax = BS.solve(s, x);
            int tmax = BS.solve(t, x);
            int smin = smax - 1;
            int tmin = tmax - 1;
            long ans = solveMin(s[smin], s[smax], t[tmin], t[tmax], x);
            System.out.println(ans);
        }
        sc.close();
    }

    static long solveMin(long a, long b, long c, long d, long x) {
        long ans[] = new long[8];
        long bsa = b - x;
        long asa = x - a;
        long tmp = Math.abs(b - c);
        ans[0] = bsa + tmp; // b > c
        tmp = Math.abs(b - d);
        ans[1] = bsa + tmp; // b > d
        tmp = Math.abs(a - c);
        ans[2] = asa + tmp; // a > c
        tmp = Math.abs(a - d);
        ans[3] = asa + tmp; // a > d
        long csa = x - c;
        long dsa = d - x;
        tmp = Math.abs(c - a);
        ans[4] = csa + tmp; // c > a
        tmp = Math.abs(c - b);
        ans[5] = csa + tmp; // c > b
        tmp = Math.abs(d - a);
        ans[6] = dsa + tmp; // d > a
        tmp = Math.abs(d - b);
        ans[7] = dsa + tmp; // d > b
        Arrays.sort(ans);
        return ans[0];
    }
}

class BS {
    static int solve(long[] ar, long key) {
        // keyより大きいあたいのindexを返す
        int left = 0;
        int right = ar.length - 1;
        int mid;
        while (true) {
            mid = (left + right) / 2;
            // 一致することはない
            if (ar[mid] < key) {
                left = mid;
            } else if (ar[mid] > key) {
                right = mid;
            }
            if (left + 1 == right) {
                return right;
            }
        }
    }
}


Measured memory_bytes: 96352
#include<stdio.h>
int main(void){
	int N,K;
	int ans;
	int i;
	
	scanf("%d %d",&N,&K);
	
	ans = K;
	K--;
	for (i=0;i<N-1;i++)ans *=K;
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
int n;
int x[202];
int y[202];
int l[222];

ll mod = 998244353;

ll pow2(ll x){
    ll r = 1;
    ll a = 2;
    while(x){
        if (x & 1){
            r = r*a%mod;
        }
        a = a*a%mod;
        x>>=1;
    }
    return r;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&x[i],&y[i]);
    }

    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            int cnt = 0;
            int b = x[i] - x[j];
            int a = y[j] - y[i];
            int c = a*x[i] + b*y[i];
            for(int k=1;k<=n;k++){
                if (k == i || k == j || c == a*x[k] + b*y[k])cnt++;
            }
            l[cnt]++;
        }
    }
    ll ans = (pow2(n) - n - 1 + mod)%mod;
    for(int i=2;i<=n;i++){
        l[i] /= i*(i-1)/2;
        ans = (ans - (pow2(i) - i - 1)*l[i]%mod + mod) % mod;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 128
#pragma GCC optimize ("Ofast")
#include"bits/stdc++.h"
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << "  ";
    __f(comma + 1, args...);
}

#define ll long long
#define pii pair<int,int>
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ff first
#define ss second
#define endll '\n'
#define rep(i,n) for(int i=0;i++<n;)
#define scl(i) scanf("%lld",&i)
#define int long long int
#define all(n) n.begin(),n.end()
#define mem(n,i) memset(n,i,sizeof n)
#define em(a) emplace_back(a)
#define pb(a) push_back(a)
#define srep(it,vv) for(auto &it : vv)
#define prep(it,vv) for(auto it : vv)
//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));

typedef vector<int> vii;
typedef vector<string> vss;
/*

*/
signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, cap; cin >> n >> cap;

    vector<int>wei(n + 5);
    vector<int>profit(n + 5);

    rep(i, n) cin >> wei[i] >> profit[i];

    vector<vector<int>>dp(n + 5, vector<int>(cap + 5, INT_MIN));

    dp[n + 1][0] = 0;

    for (int i = n; i >= 1; i--)
    {
        for (int j = 0; j <= cap; j++)
        {
            if (j - wei[i] >= 0) dp[i][j] = max(dp[i + 1][j], profit[i] + dp[i + 1][j - wei[i]]);
            else dp[i][j] = dp[i + 1][j];
        }
    }
    int ans = INT_MIN;
    for (int i = 0; i <= cap; i++)
    {
        ans = max(ans, dp[1][i]);
    }

    cout << ans << endll;
}

Measured memory_bytes: 86308
import java.util.Scanner;
import java.util.Map;
import java.util.HashMap;

public class Main {
    public static void main(String[] args) throws Exception {
        // Here your code !
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        
        String result = "NO";
        if(A==5&&B==5&&C==7){
            result = "YES";
        }else if(A==5&&B==7&&C==5){
            result = "YES";
        }else if(A==7&&B==5&&C==5){
            result = "YES";
        }
        System.out.println(result);
        
    }
}


Measured memory_bytes: 9680
//In the Name of God
    //Let Our Voices Echo
    #pragma GCC optimize("O3")
    #include<bits/stdc++.h>
    using namespace std;
    #define X real()
    #define Y imag()
    typedef long long ll;
    typedef double ld; 
    typedef complex<ld> point;
    const ld eps=1e-9;
    const int MAX=1e5+9,MOD=1e9+7;
    long long n,a[MAX],ans;
    int main()
    {
    	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    	cin>>n;
    	for (int i=0;i<n;i++)
    		cin>>a[i];
    	for (int i=0;i<n-1;i++) 
    	{
                ans+=a[i]/2;
                a[i]%=2;
    		long long x=min(a[i],a[i+1]);
    		a[i]-=x;
    		a[i+1]-=x;
    		ans+=x;
    	}
    	for (int i=0;i<n;i++) ans+=a[i]/2;
    	cout<<ans;
    	return 0;
    }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    int r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

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

    ll ans = 0;
    REP(i, 1, K + 1) {
        REP(j, 1, K + 1) {
            REP(k, 1, K + 1) {
                ans = ans + gcd(gcd(i, j), k);
            }
        }
    }
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 3636
li=list(input())
li.sort()
if len(li)%2:
    print("No")
    exit()
while True:   
    if len(li)==0:
        print("Yes")
        break
    elif li[0]==li[1]:
        li.pop(0)
        li.pop(0)
    else:
        print("No")
        break

Measured memory_bytes: 38364
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define FOR(i,n) for (int i = 0; i < n; i++)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

int n;
ll c, x[100005], v[100005];
ll mx[100005], mx2[100005], acu = 0, res = 0;

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);
    
    cin >> n >> c;
    for (int i = 0; i < n; i++)
    	cin >> x[i] >> v[i];

    for (int i = n - 1; i >= 0; i--) {
    	acu += v[i];
    	mx[i] = max(mx[i+1], acu - (c - x[i]));
    	mx2[i] = max(mx2[i+1], acu - 2 * (c - x[i]));
    }

    res = max(res, mx[0]);

    acu = 0;
    for (int i = 0; i < n; i++) {
    	acu += v[i];
    	res = max(res, acu - x[i]);
    	res = max(res, acu - x[i] + mx[i+1] - x[i]);
    	res = max(res, acu - x[i] + mx2[i+1]);
    }

    cout << res << endl;

    return 0;
}

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

int main(void){
    int x;
    
    cin >> x;
    
    if(x < 600) cout << 8;
    else if(x < 800) cout << 7;
    else if(x < 1000) cout << 6;
    else if(x < 1200) cout << 5;
    else if(x < 1400) cout << 4;
    else if(x < 1600) cout << 3;
    else if(x < 1800) cout << 2;
    else if(x < 2000) cout << 1;
    cout << endl;
}

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

int main() {
  long long int a,b,c;
  cin >> a >> b >> c;
  if(c-a-b < 0){
  	cout << "No" << endl;
  }
  else if((c-a-b)*(c-a-b)-4*a*b > 0){
  	cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import std.regex;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long N;
  scanln(N);
  auto xs = N.rep!(() => readln.chomp).sort!"a<b".group.array.sort!"a[1]>b[1]".array;
  xs = xs.filter!(x => x[1] == xs[0][1]).array;
  xs.sort!"a[0]<b[0]".map!"a[0]".each!writeln;
}

// ----------------------------------------------


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep);

  string line = readln.chomp;
  static if (__VERSION__ >= 2074) {
    line.formattedRead!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "line.formattedRead(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 28156
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const ll Mod = 998244353;
const ll Inf = 1e15;
const ll Log = 20;
const int Maxn = 1e5 + 10;
const int sig = 27;

const int Base = 101;


ll seg[4 * Maxn];
void add(int id, int l, int r, ll v, int L, int R){
	if( (r <= L) || (R <= l) ) return ;
	if( (l <= L) && (R <= r) ){
		seg[id] = v;
		return ;
	}
	int mid = (L + R) >> 1;
	//shift(id);
	add(id << 1, l, r, v, L, mid);
	add(id << 1 | 1, l, r, v, mid, R);
	seg[id] = min(seg[id << 1], seg[id << 1 | 1]);
}
ll get(int id, int l, int r, int L, int R){
	if( (r <= L) || (R <= l) ) return Inf;
	if( (l <= L) && (R <= r) ) return seg[id];	
	int mid = (L + R) >> 1;
	//shift(id);
	return min(
		get(id << 1, l, r, L, mid),
		get(id << 1 | 1, l, r, mid, R)
		);
}

ll dp[Maxn];
vector<pll> en[Maxn];


int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	memset(seg, 31, sizeof seg);
	ll n, m;
	cin >> n >> m;
	ll l, r, c;
	for(int i = 0; i < m; i++){
		cin >> l >> r >> c;
		en[r].pb({l, c});
	}
	memset(dp, 31, sizeof dp);
	
	dp[1] = 0;
	add(1, 1, 2, 0, 0, Maxn);
	for(int i = 2; i <= n; i++){
		for(auto x : en[i]){
			dp[i] = min(dp[i], x.S + get(1, x.F, i, 0, Maxn) );
		}
		add(1, i, i + 1, dp[i], 0, Maxn);
	}
	if(dp[n] >= Inf) cout << -1;
	else cout << dp[n];
	return 0;
}
/*
abacabacca

*/


Measured memory_bytes: 9600
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            WillReturn.Add("3");
            WillReturn.Add("1");
            WillReturn.Add("2");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4");
            WillReturn.Add("3");
            WillReturn.Add("4");
            WillReturn.Add("1");
            WillReturn.Add("2");
            //-1
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("5");
            WillReturn.Add("3");
            WillReturn.Add("3");
            WillReturn.Add("4");
            WillReturn.Add("2");
            WillReturn.Add("4");
            //3
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int[] AArr = InputList.Skip(1).Select(X => int.Parse(X)).ToArray();

        var VisitedSet = new HashSet<int>();
        VisitedSet.Add(0);

        int Answer = 0;
        int CurrInd = 0;
        while (true) {
            int NextInd = AArr[CurrInd] - 1;
            if (VisitedSet.Add(NextInd) == false) {
                Console.WriteLine(-1);
                break;
            }

            Answer++;
            if (NextInd == 1) {
                Console.WriteLine(Answer);
                break;
            }
            CurrInd = NextInd;
        }
    }
}


Measured memory_bytes: 20960
import sys
from heapq import heappop, heappush

input = sys.stdin.readline


def main():
    MAX_A = 10 ** 5
    N, M = map(int, input().split())
    AB = [[] for _ in range(MAX_A + 1)]
    for i in range(N):
        A, B = map(int, input().split())
        AB[A].append(-B)

    p_queue = []
    ans = 0
    for m in range(1, M + 1):
        for b in AB[m]:
            heappush(p_queue, b)
        if p_queue:
            x = heappop(p_queue)
            x *= -1
            ans += x

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 22212
import numpy as np
N,W = map(int,input().split())
#N,W = [3,8]
wvlist = [list(map(int,input().split())) for _ in range(N)]
INF = 10**15
ans = INF

#初期条件
#dp = [[INF for _ in range(N*1000+1)] for i in range(N+1)]
dp = np.full((N+1,N*1000+1),INF)
dp[0][0] = 0

for i in range(N):
    dp[i+1][:wvlist[i][1]] = dp[i][:wvlist[i][1]]
    dp[i+1][wvlist[i][1]:] = np.minimum(dp[i][wvlist[i][1]:],dp[i][:-wvlist[i][1]]+wvlist[i][0])
        
for i in range(N*1000+1):
    if W >= dp[N][i]:
        ans = i
        
print(ans)
    

Measured memory_bytes: 93028
BIG_NUM = 2000000000
 
while True:
 
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if i == 0 or i == H-1 or k == 0 or k == W-1:
                print("#",end = "")
            else:
                print(".",end = "")
        print()
 
    print() #データセットの区切り


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

 int main(){
 	long long a , b;
 	scanf( "%lld%lld" , &a , &b );

 	if( ((a*b)&1) == 1 ) puts( "Odd" );
 	else puts( "Even" );

 	return 0;
 }

Measured memory_bytes: 768
n = gets.to_i
a = gets.split.map(&:to_i).sort.reverse
side = []
tmp = 0
a.each do |i|
  break if side.size == 2
  if tmp == i
    side << i
    tmp = 0
  else
    tmp = i
  end
end

puts side.size == 2 ? side[0] * side[1] : 0


Measured memory_bytes: 10112
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
  int a, b, c, d; cin >> a >> b >> c >> d;
  int x = a+b;
  int y = c+d;
  if( x > y ) cout << "Left";
  else if( x < y ) cout << "Right";
  else cout << "Balanced";
  cout << endl;
}


Measured memory_bytes: 256
//
// Created by yuu on 2019-04-13.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>

using namespace std;


int main(void){
    int N;
    cin>>N;
    int H[1000];
    for (int i = 0; i < N; ++i) {
        cin>>H[i];
    }
    int ans = 0;

    for (int j = 0; j <N; ++j) {
        bool flag = true;
        int A = H[j];
        for (int i=j-1; i>=0; i--){
            if(H[i]>A){
                flag = false;
            }
        }
        if(flag){
            ans++;
        }
    }
    
    cout<<ans<<endl;


    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  ll A, B, x, y;
  scanf("%lld %lld.%lld", &A, &x, &y);
  B = x * 100 + y;
  cout << A * B / 100 << endl;
  return 0;
}


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

using namespace std;

int main() {
    long N, middle, answer;
    cin >> N;

    vector<long> A(N);

    for (long i = 0; i < N; ++i) {
        cin >> A[i];
        A[i] -= (i + 1);
    }

    sort(A.begin(), A.end());

    if (N % 2 == 0) {
        middle = A[N / 2 - 1];
    }
    else {
        middle = A[N / 2];
    }
    answer = 0;

    for (long i = 0; i < N; ++i) {
        answer += abs(A[i] - middle);
    }

    cout << answer << endl;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
	int x, y;
	
	cin >> x;
	cin >> y;
	
	if(x < y){
		int temp = x;
		x = y;
		y = temp;
	}
	
	while(y > 0){
		int r = x % y;
		x = y;
		y = r;
	}
	cout << x << endl;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), a = sc.nextInt();	
		sc.close();
		int tmpn = n / 500;
		tmpn = n - tmpn * 500;
		String ans[] = {"Yes", "No"};
		int an = 0;
		if(tmpn > a)an = 1;
		System.out.println(ans[an]);
	}

}


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

using namespace std;

char alphas[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};


int main(){
    long long int N;
    string ans="";
    cin >> N;

    while(0<N){
        ans += alphas[(N-1)%26];
        N--;
        N /= 26;
    }

    reverse(ans.begin(),ans.end());

    cout << ans << endl;
}

Measured memory_bytes: 3592
import sys
import fractions
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n = INT()
h = LIST()

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

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

print(dp[n-1])


Measured memory_bytes: 77932
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main()
{
    int N,M,X;
    cin >> N >> M>>X;
    vector<int> C(N);
    vector<vector<int>> A(N,vector<int>(M));    
    rep(i,N){
        cin >> C[i];
        rep(j,M){
            cin >> A[i][j];
        }
    }
    int ans = 10000000;
    bool ok;
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bitset<13> s(tmp);  // 最大10個なので20ビットのビット列として扱う
    int money = 0;
    vector<int> R(M);
    ok = true;
      rep(j,N){
        if((s.test(j))){
            money += C[j];
            rep(i,M){
                R[i] += A[j][i];
            }
        }
      }
      rep(k,M){
        if(R[k] < X) ok = false;
      }
      if(ok && money != 0) ans = min(ans,money);      
  }


    if(ans == 10000000) ans = -1;

    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 3596
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <iostream>
#include <fstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <iterator>
#include <iomanip>
#include <unordered_map>

using namespace std;

#define ll long long int


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

    int x,y,a,b,cl;
    cin>>x>>y>>a>>b>>cl;
    int red[a], green[b], color_less[cl];
    for (int i = 0; i < a; i++)
    {
        cin>>red[i];
    }
    for (int i = 0; i < b; i++)
    {
        cin>>green[i];
    }
    for (int i = 0; i < cl; i++)
    {
        cin>>color_less[i];
    }
    sort(red, red+a, greater<int>());
    sort(green, green+b, greater<int>());
    sort(color_less, color_less+cl, greater<int>());

    vector<int> v;
    ll ans=0;
    for(int i=0;i<x;i++)
    {
        v.push_back(red[i]);
    }
    for(int i=0;i<y;i++)
    {
        v.push_back(green[i]);
    }
    for(int i=0;i<cl;i++)
    {
        v.push_back(color_less[i]);
    }
    sort(v.begin(), v.end(), greater<int>());
    for(int i=0;i<x+y;i++)
        ans+=v[i];
    cout<<ans;

}



Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)
#include <iostream>
#include <vector>
#include <cstdlib>
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; }

const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

int main() {
    // 頂点数と辺数
    int N; cin >> N;
    int x,y;cin>>x>>y;
    vl k(N);

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < N-1; ++i) {
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }

    G[x-1].push_back(y-1);
    G[y-1].push_back(x-1);






    // 初期条件 (頂点 0 を初期ノードとする)
    for(int i=0;i<N;i++){

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    dist[i] = 0;
    que.push(i); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
            k[dist[nv]]++;
        }
    }

}

for(int i=1;i<N;i++)cout<<k[i]/2<<endl;


}

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

using namespace std;

int main() {
    string s;
    int ans = 0;
    cin >> s;
    for (int i = 0; i < 4; i++) {
        if (s[i] == '+') {
            ans++;
        } else {
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;
#define N 4
#define N2 16
#define LIMIT 45
const int dx[4] { -1, 0, 1, 0 };
const int dy[4] { 0, -1, 0, 1 };
const char dir[4] { 'u', 'l', 'd', 'r' };
struct Puzzle {
	int f[N2], space, MD;
};
int MDT[N2][N2];
int getAllMd(Puzzle p) {
	int sum = 0;
	for (int i = 0; i < N2; ++i) {
		if (p.f[i] == N2)
			continue;
		sum += MDT[i][p.f[i] - 1];
	}
	return sum;
}

int limit;
int path[LIMIT];
Puzzle state;
bool dfs(int depth, int prev) {

	if (state.MD == 0)
		return true;
	if (depth + state.MD > limit)
		return false;

	int sx = state.space / N;
	int sy = state.space % N;
	Puzzle tmp;
	for (int r = 0; r < 4; ++r) {
		int tx = sx + dx[r];
		int ty = sy + dy[r];
		if (tx < 0 || ty < 0 || tx >= N || ty >= N)
			continue;
		if (max(prev, r) - min(prev, r) == 2)
			continue;
		tmp = state;

		state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
		state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];

		swap(state.f[sx * N + sy], state.f[tx * N + ty]);
		state.space = tx * N + ty;

		if (dfs(depth + 1, r)) {
			path[depth] = r;
			return true;
		}
		state = tmp;
	}
	return false;
}
string deepening(Puzzle p) {
	int md = getAllMd(p);
	p.MD = md;
	state = p;
	for (limit = md; limit <= LIMIT; ++limit) {
		string ans = "";
		if (dfs(0, -100)) {
			for (int i = 0; i < limit; ++i) {
				ans += dir[path[i]];
			}
			return ans;
		}
	}
	return "";
}

int main() {
	for (int i = 0; i < N2; ++i) {
		for (int j = 0; j < N2; ++j) {
			MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
		}
	}
	Puzzle p;
	for (int i = 0; i < N2; ++i) {
		scanf("%d", &p.f[i]);
		if (p.f[i] == 0) {
			p.f[i] = N2;
			p.space = i;
		}
	}

	string ans = deepening(p);
	cout << ans.size() << endl;

	return 0;
}

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

#define int long long
#define endl "\n"

using namespace std;

vector <int> v[100010];
bool vis[100010];
int h[100010];
int l[100010];
int par[100010];
int a,b;

void dfs(int n, int m, int pat)
{
    vis[n] = true;
        
    l[n] = m;
    h[n] = 1;
    par[n] = pat;
    
    for(int i:v[n])
    {
        if(!vis[i])
        {
            dfs(i,m+1,n);
            h[n] = max(h[n],h[i]+1);
        }
    }
}

int32_t main()
{
    int n;
    cin >> n >> a >> b;
    
    for(int i=1;i<n;i++)
    {
        int x,y;
        cin >> x >> y;
        
        v[x].push_back(y);
        v[y].push_back(x);
    }
    
    dfs(b,1,-1);
    
    // for(int i=1;i<=9;i++)
    //     cout << l[i] << " ";
    // cout << endl;
    
    // for(int i=1;i<=9;i++)
    //     cout << h[i] << " ";
    // cout << endl;
    
    if(l[a] == l[b])
        cout << 0 << endl;
    else
    {
        int c1 = l[a];
        int c2 = l[b];
        
        int ans = (c1-c2+1)%2;
        int cnt = (c1-c2-1)/2;
        
        while(cnt--)
            a = par[a], ans++;
            
        // cout << a << " " << ans << endl;
            
        ans += (h[a] - 1);
        
        cout << ans << endl;
    }
}

Measured memory_bytes: 12160
N = int(input())
nums = [[i, True] for i in range(55555+1)]

for i in range(2, 55555+1):
    if nums[i][1]:
        if nums[i][0] % 5 == 1:
            print(nums[i][0])
            N -= 1
        for j in range(i, 55555+1, nums[i][0]):
            nums[j][1] = False

    if not N:
        break

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

using ll = long long;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

int n, m, l;

ll a[100][100], b[100][100], c[100][100];

int main(){
	cin.tie(0);
	
	cin>>n>>m>>l;
	
	rep(i, n)rep(j, m)cin>>a[i][j];
	rep(j, m)rep(k, l)cin>>b[j][k];
	
	rep(i, n) rep(j, l) {
	    rep(k, m)c[i][j] += a[i][k]*b[k][j];
	}

	rep(i, n) {
	    rep(j, l) {
	        cout<<c[i][j];
	        if(j<l-1)cout<<' ';
	    }
	    cout<<endl;
	}

	return 0;
}



Measured memory_bytes: 3300
n = gets.to_i
require 'prime'
d = Prime.prime_division(n)
rslt = 0
d.each do |dd|
  r = 0
  a = dd[1]
  while a >= r * (r + 1) / 2 do
    r = r + 1
  end
  rslt = rslt + r - 1
end

puts rslt

Measured memory_bytes: 14496
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
//#include <intrin.h>
#include <ctime>
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
using namespace::std;

void solve(){
	int H,W;
	cin >> H >> W;
	vector< string > F(H);
	for(int i=0;i<H;++i){
		cin >> F[i];
	}
	int SUM = 0;//しろ,ぽいーん
	for(int r=0;r<H;++r){
		for(int c=0;c<W;++c){
			if( F[r][c] == '.' ){
				SUM++;
			}
		}
	}
	queue< vector<int> > Q;
	vector<int> pos(3,0);
	Q.push( pos );
	int dr[] = {0,1,0,-1};
	int dc[] = {1,0,-1,0};
	vector< vector<bool> > visit(H,vector<bool>(W,false));
	while( Q.size() ){
		pos = Q.front();
		Q.pop();

		if( pos[0]== H-1 && pos[1] == W-1 ){
			cout << SUM-pos[2]-1 << endl;//スタート地点
			return;
		}
		for(int k=0;k<4;++k){
			int rr = pos[0] + dr[k];
			int cc = pos[1] + dc[k];
			if( rr<0||H<=rr ||cc<0||W<=cc ){
				continue;
			}
			if( visit[rr][cc] ){
				continue;
			}
			if( F[rr][cc] == '#' ){
				continue;
			}
			visit[rr][cc] = true;
			vector<int> temp(3);
			temp[0] = rr;
			temp[1] = cc;
			temp[2] = pos[2] + 1;
			Q.push( temp );
		}
	}
	cout << -1 << endl;
}	
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

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


int main() {
    int n; cin >> n;
    vector<int> as(n+2, 0);
    rep(i, n) cin >> as[i+1]; 
    vector<int> ds(n+1, 0);
    int tot = 0; 
    rep(i, n+1) {
        ds[i] = abs(as[i+1]-as[i]);
        tot += ds[i];
    }
    rep(i, n) {
        int d2 = abs(as[i+2]-as[i]);
        int ret = tot - ds[i] - ds[i+1] + d2; 
        cout << ret  << endl;
    } 

    return 0;
}

Measured memory_bytes: 2048
<?php
  $n = trim(fgets(STDIN));
  $w = explode(" ",trim(fgets(STDIN)));
  $min = 100000000000;
  $s1 = 0;
  for($t=0; $t<$n; $t++){
    $s1 += $w[$t];
    $s2 = 0;
    for($i=$t+1; $i<$n; $i++){
      $s2 += $w[$i];
    }
    $min = min($min,abs($s1-$s2));
  }
  echo $min."\n";

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

inline void solve(){

    int n, h[100005]={},dp[100005]={};
    cin >> n;
    for(int i = 1; i<= n; i++) {
        cin >> h[i];
    }
    dp[1] = 0;
    for(int i = 2; i <= n; i++) {
        if( i != 2)
            dp[i] = min(abs(h[i]-h[i-2])+dp[i-2],
                        abs(h[i]-h[i-1])+dp[i-1]);
        else
            dp[i] = abs(h[i]-h[i-1])+dp[i-1];
    
    }

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

struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}



Measured memory_bytes: 1024
n,l = map(int, input().split())

aji = [l+i-1 for i in range(1, n+1)]
#print(aji)

kei = sum(aji)/n
#print(kei)

sa = [abs(l+i-1) for i in range(1, n+1)]
#print(sa)

i = sa.index(min(sa))

#print(i)

print(sum(aji)-aji[i])

Measured memory_bytes: 3060
"use strict";

// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0]に入る
    input = input.split("\n");
    let tmp = input[0].split(" ");
    //文字列から10進数に変換するときはparseIntを使います
    let a = parseInt(tmp[0], 10);
    let b = parseInt(tmp[1], 10);
    let c = parseInt(tmp[2], 10);
    let d = parseInt(tmp[3], 10);
    let e = parseInt(tmp[4], 10);
    //出力
    if (a == 0) {
        console.log("1");
    } else if (b == 0) {
        console.log("2");
    } else if (c == 0) {
        console.log("3");
    } else if (d == 0) {
        console.log("4");
    } else if (e == 0) {
        console.log("5");
    }
}
//*この行以降は編集しない（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29612
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}


int main(){
    int x,y,n,r,g,b,m,p,h,k,max=-10000000,min=1000000000,ans=0,sum=0;
    string s,t;
    bool f=true;
    cin >> r >> g >> b >> n;
    for(int i=0; i<=3000; i++){
        for(int j=0; j<=3000;j++){
            k = i*r+j*g; 
            if(n>=k && (n-k)%b==0){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    ll x,tem=100,ans=0;
    cin >> x;
    
    while(tem<x){
        tem+=tem/100;
        ans++;
    }

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 3616
#include "bits/stdc++.h"

using namespace std;

void solve()
{
    int n;
    cin >> n;
    vector<pair<int, int>> g[n];
    for (int i = 0; i < n - 1; i++)
    {
        int s, t, w;
        cin >> s >> t >> w;
        g[s].push_back(make_pair(t, w));
        g[t].push_back(make_pair(s, w));
    }
    vector<int> dis(n, 1e9);
    priority_queue<pair<int, int>> pq;
    pq.push(make_pair(0, 0));
    dis[0] = 0;
    while (!pq.empty())
    {
        int v = pq.top().second, d = -pq.top().first;
        pq.pop();
        for (auto p : g[v])
        {
            if (dis[p.first] > d + p.second)
            {
                dis[p.first] = d + p.second;
                pq.push(make_pair(-dis[p.first], p.first));
            }
        }
    }
    int maxi = -1, s = -1;
    for (int i = 0; i < n; i++)
    {
        if (maxi < dis[i])
        {
            maxi = dis[i];
            s = i;
        }
    }
    //cout << s << ' ' << dis[s] << endl;
    pq.push(make_pair(0, s));
    dis.assign(n, 1e9);
    dis[s] = 0;
    while (!pq.empty())
    {
        int v = pq.top().second, d = -pq.top().first;
        pq.pop();
        for (auto p : g[v])
        {
            if (dis[p.first] > d + p.second)
            {
                dis[p.first] = d + p.second;
                pq.push(make_pair(-dis[p.first], p.first));
            }
        }
    }
    cout << *max_element(dis.begin(), dis.end()) << endl;
}

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



Measured memory_bytes: 9760
require 'pp'

def gets; ARGF.gets; end

class Solver

  def main
    h = gets.chomp.to_i

    x = 1
    loop do
      if h < x
        puts x - 1
        return
      end

      x *= 2
    end
  end
end

if __FILE__ == $0
  Solver.new.main
end


Measured memory_bytes: 2556
#include<iostream>
#include<sstream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<numeric>
#include<bitset>
//#include<chrono>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;
typedef map<string,int> dict;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
double eps = 1e-10 ;

template <typename T>
void out(vector < T > v)
{
  for(size_t i = 0; i < v.size(); i++)
  {
    debug(v[i]);
  }
}

template<typename T>
string ntos( T i ) {
  ostringstream s ;
  s << i ;
  return s.str() ;
}

template<typename T>
T ston(string str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s ;
  int d;
  vi v = {1,0,0} ;
  while(cin >> s ){
    if(s[0] == 'A'){
      d = v[0] ;
      if(s[2] == 'B'){
        v[0] = v[1] ;
        v[1] = d ;
      }
      if(s[2] == 'C'){
        v[0] = v[2] ;
        v[2] = d ;
      }
    }
    else if(s[0] == 'B'){
      d = v[1] ;
      if(s[2] == 'C'){
        v[1] = v[2] ;
        v[2] = d ;
      }
      if(s[2] == 'A'){
        v[1] = v[0] ;
        v[0] = d ;
      }
    }
    else{
      d = v[2] ;
      if(s[2] == 'A'){
        v[2] = v[0] ;
        v[0] = d ;
      }
      if(s[2] == 'B'){
        v[2] = v[1] ;
        v[1] = d ;
      }
    }
  }
  if(v[0] == 1){
    cout << 'A' << endl ;
  }
  if(v[1] == 1){
    cout << 'B' << endl ;
  }
  if(v[2] == 1){
    cout << 'C' << endl ;
  }
  return 0;
}

Measured memory_bytes: 1176
#include<stdio.h>
#include<algorithm>

int dp[50001];
const int INF = 114514;

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    int c[m];
    for(int j=0; j<m; j++){
        scanf("%d\n", &c[j]);
    }

    // initialize dp table
    dp[0] = 0;
    for(int i=1; i<=n; i++){
        dp[i] = INF;
    }
    for(int l=0; l<m; l++){
        for(int k=c[l]; k<=n; k++){
            dp[k] = std::min(dp[k], dp[k - c[l]] + 1);
        }
    }
    printf("%d\n",dp[n]);

    return 0;
}

Measured memory_bytes: 2860