akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll n, k;
  cin >> n >> k;
  ll ans = k;
  rep(i, n - 1) {
    ans *= (k - 1);
  }
  ANS;
  return 0;
}

Measured memory_bytes: 3644
import java.io.IOException;
import java.util.Scanner;
public class Main {
	static int mod=1000000007;
	static Scanner scan=new Scanner(System.in);
	static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
	static long lcm (long a, long b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
			}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	static long modpow(long a,long n) {
		if(n==0) return 1;
		else if(n==1)return a;
		long tmp=modpow(a,n/2);
		tmp%=mod;
		tmp*=tmp;
		tmp%=mod;
		if(n%2==0)return tmp;
		else return (tmp*a)%mod;
	}
	public static void main(String[] args) throws IOException {
		String a=scan.next();
		char ch1=a.charAt(0);
		char ch2=a.charAt(1);
		char ch3=a.charAt(2);
		char ch4=a.charAt(3);
		if(ch1==ch2||ch2==ch3||ch3==ch4) {
			System.out.println("Bad");
		}
		else {
			System.out.println("Good");
		}
	}
}


Measured memory_bytes: 21332
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

public class Hello
{
    public static void Main()
    {
        hoge();
    }

    public static void hoge()
    {
        var vars = System.Console.ReadLine();

        Match matche = Regex.Match(vars, "[A-Z]");

        Console.WriteLine(matche.Value.Length == 0 ? "a" : "A");
    }
}

Measured memory_bytes: 26892
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define mp make_pair
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
    IOS;
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    map<int,int> m;
    for(int i=0;i<n;i++){
        m[i-a[i]]++;
    }
    int ans=0;
    for(int i=0;i<n;i++){
        m[i-a[i]]--;
        int x=i+a[i];
        ans+=m[x];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 27924
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	vector<int> a(3);
	for (int i = 0; i < 3; i++)
		cin >> a[i];
	sort(a.begin(), a.end());
	int result = 1000000000;
	do
	{
		int res = 0;
		for (int i = 1; i < 3; i++)
			res += abs(a[i - 1] - a[i]);
		result = min(result, res);
	}	
	while (next_permutation(a.begin(), a.end()));
	cout << result << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
int a, b;
int main() {
	cin >> a >> b;
	cout << (a + b) % 24 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <cstdio>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

////Nayeem Shahriar Joy,Applied Physics &Electronic Engineering,University of Rajshahi.

int main()

{
   string s;
   cin>>s;
   reverse(s.begin(),s.end());
   cout<<s<<endl;
   return 0;
}

Measured memory_bytes: 3132
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_WORDS 100

int main(int argc, char *argv[])
{
  int n = 0;
  char *words[MAX_WORDS];
  if (scanf("%d", &n) != 1) {
    return 0;
  }

  for (int i = 0; i < n; i++) {
    words[i] = (char *) malloc(10);
    if (scanf("%s", words[i]) != 1) {
      return 0;
    }
  }

  // Condition 1
  for (int i = 1; i < n; i++) {
    if (words[i][0] != words[i-1][strlen(words[i-1])-1]) {
      printf("No\n");
      for (int j = 0; j < n; j++) {
        free(words[j]);
      }
      return 0;
    }
  }

  // COndition 2
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (strcmp(words[i], words[j]) == 0) {
        printf("No\n");
        for (int j = 0; j < n; j++) {
          free(words[j]);
        }
        return 0;
      }
    }
  }

  printf("Yes\n");
  for (int j = 0; j < n; j++) {
    free(words[j]);
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>      
#define pb push_back 
#define fr first 
#define sc second
#define MOD 1000000007
#define len(s) s.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define f(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef map<int,int> mii; 

int main() {

    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif */
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;

    //int t; cin>>t; while(t--) { 
    int n; cin>>n;
    vi h(n);
    for(int& x:h) cin>>x;
    vi dp(n,MOD);
    dp[0]=0;
    
    f(i,0,n) {
        for(int j: {i+1,i+2}) {
            if(j<n) dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
        }
    }
    cout<<dp[n-1];
    

    return 0 ;
}

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

int main(){
	ll N,M;
	string S;
	cin >> N >> M >> S;

	vector<ll> ind;
	for(int i=0;i<N+1;i++){
		if(S[i]=='0'){
			ind.push_back(i);
		}
	}

	vector<ll> ans;
	ll now = N;
	while(now){
		ll to = ind[upper_bound(ind.begin(),ind.end(),now-M-1)-ind.begin()];
		if(to == now){
			cout << -1 << endl;
			return 0;
		}
		ans.push_back(now - to);
		now = to;
	}
	reverse(ans.begin(), ans.end());
	cout << ans[0];
	for(int i=1;i<ans.size();i++){
		cout << " " << ans[i];
	}
	cout << endl;
}

Measured memory_bytes: 2676
n = input().zfill(16)
def main(n):
    len_n = len(n)
    INF = 10**18
    memo_ls = [[0 for i in range(2)] for j in range(len_n+1)]
    memo_ls[0][0] = 0
    memo_ls[0][1] = -INF
    for i in range(1, len_n+1):
        s = int(n[i-1])
        memo_ls[i][0] = memo_ls[i-1][0] + s
        memo_ls[i][1] = memo_ls[i-1][1] + 9
        if s > 0:
            memo_ls[i][1] = max(memo_ls[i][1], memo_ls[i-1][0] + s - 1)
    print(max(memo_ls[-1]))
    return 0

main(n)

Measured memory_bytes: 3064
N=int(input())
s=input()
R=[0]
G=[0]
B=[0]
ans=0
#RGBの累積和を作る
for i in range(N):
  if s[i]=="R":
    R[i]+=1
  elif s[i]=="G":
    G[i]+=1
  else:
    B[i]+=1
  R.append(R[i])
  G.append(G[i])
  B.append(B[i])
del R[-1]
del G[-1]
del B[-1]
#作った

#全探索する
for i in range(N-2):
  a=s[i]
  for j in range(i+1,N-1):
    if a==s[j]:
      continue
    b=s[j]
    k=2*j-i
    if "R" not in a+b:
      ans+=R[-1]-R[j]
      try:
        if s[k]=="R":
          ans-=1
      except:
        pass
    
    if "G" not in a+b:
      ans+=G[-1]-G[j]
      try:
        if s[k]=="G":
          ans-=1
      except:
        pass
        
    if "B" not in a+b:
      ans+=B[-1]-B[j]
      try:
        if s[k]=="B":
          ans-=1
      except:
        pass
print(ans)

Measured memory_bytes: 74676
#include <iostream>
#include <algorithm>
#include <array>
#include <deque>
#include <vector>
#include <utility>
#include <string>
#include <cmath>

using uint128_t = unsigned long long int;

int main()
{
    uint128_t POW_TEN_BY_EIGHTEEN = 1;
    for (int i = 0; i < 18; ++i)
    {
        POW_TEN_BY_EIGHTEEN *= 10;
    }

    int n = 0;
    std::cin >> n;

    std::vector<uint128_t> a;
    a.resize(n);

    uint128_t ans = 1;
    uint128_t ans_before = 0;
    uint128_t val = 0;
    bool outputted = false;
    bool overflowed = false;
    for (auto& i : a)
    {
        ans_before = ans;
        std::cin >> val;
        ans *= val;
        if (val == 0)
        {
            outputted = true;
            std::cout << 0;
            break;
        }
        if (ans_before != (ans / val) || ans > POW_TEN_BY_EIGHTEEN)
        {
            overflowed = true;
        }
    }
    if (!outputted)
    {
        if (overflowed)
        {
            std::cout << -1;
        }
        else
        {
            std::cout << ans;
        }
    }
    return 0;
}

Measured memory_bytes: 4052
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

int main(){
    long double n,k;
    cin>>n>>k;

    long double sum=0;
    for(int i=1;i<=n;++i){
        if(i >= k){
            sum += 1 / n;
            continue;
        }
        long double x = 0;
        long double work = i;
        while(true){
            if(work >= k)break;
            else{
                work *= 2;
                ++x;
            }
        }
        sum +=  1 / (n * pow(2.0,x));
    }
    cout<<fixed<<setprecision(12)<<sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<lint, int>;
const int MAXN = 200005;

string s;
int dp[MAXN];

int main(){
	cin >> s;
	lint ret = 0;
	for(int i=s.size()-1;i>=0; i--){
		if(s[i] == 'A') dp[i] = dp[i + 1];
		if(i + 1 < s.size() && s[i] == 'B' && s[i + 1] == 'C'){
			dp[i] = dp[i + 2] + 1;
		}
		if(s[i] == 'A') ret += dp[i + 1];
	}
	cout << ret << endl;
}


Measured memory_bytes: 1412
#include <stdio.h>

int main()
{
	int a, b;
	int diff, space;

	scanf("%d%d", &a, &b);
	if (a >= b) {
		diff = a - b;
		space = 16 - b * 2;
	} else {
		diff = b - a;
		space = 16 - a * 2;
	}

	if ((space - 1) / 2 + 1 >= diff) {
		printf("Yay!\n");
	} else {
		printf(":(\n");
	}


	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

int main(){
  ll s=100;
  ll x;cin>>x;
  if(s>=x){cout<<0<<endl;return 0;}
  for(int i=1;i<10000000;i++){

    s=s*1.01;
    s=ll(s);
    if(s>=x){cout<<i<<endl;return 0;}
  }
}


Measured memory_bytes: 3624
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){function t(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=[],n=!0,o=!1,u=void 0;try{for(var i,l=e[Symbol.iterator]();!(n=(i=l.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(e){o=!0,u=e}finally{try{n||null==l.return||l.return()}finally{if(o)throw u}}return t}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}e.exports=function(e){for(var r=e.split("\n"),n=t(r[0].split(" ").map(function(e){return Number(e)}),2),o=n[0],u=n[1],i=r[1].split(" ").map(function(e){return Number(e)}),l=0,f=0;f<=o;f++)if((l+=i[f])>u)return void console.log(f+1);console.log(o+1)}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 7620
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main () {
  unsigned long int h, w;
  cin >> h >> w;
  unsigned long int ans = 0;
  if (h == 1 || w ==1){
    ans = 1;
  } else {
    if (h%2 == 0){
      ans = h * w / 2;
    }else{
      if (w % 2 == 1){
        ans = h * w / 2 + 1;
      } else {
        ans = h * w / 2;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define met(a) memset(a,0,sizeof(a))
#define inf 0x3f3f3f3f
#define ll long long
using namespace std;
const  int N=1e5+10;
const int mod=1e9+7;
ll a[N],val[N],f[N];
ll pow(ll a,ll b,ll mod)
{
    ll ret=1;
    while(b)
    {
        if(b&1)
            ret=(ret*a)%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ret%mod;
}
ll C(ll a,ll b)
{
    if(b>a)
        return 0;
    return (val[a]*pow(val[b]*val[a-b]%mod,mod-2,mod))%mod;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll i,j,k,u,v,w,m,n;
    cin>>n;
    n+=1;
    val[0]=1;
    for(i=1; i<=n; i++)
        val[i]= (val[i-1]*i)%mod;
    for(i=1; i<=n; i++)
    {
        cin>>a[i];
        if(f[a[i]]==0)
            f[a[i]]=i;
        else
            u=f[a[i]],v=i;
    }
    w=v-u-1;
    m=n-w-2;
    for(i=1; i<=n; i++)
        cout<<(C(n,i)-C(m,i-1)+mod)%mod<<endl;
    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int dp[1000000];
	int N, h[10000000];  cin >> N;
	for(int i = 1 ; i <= N ; i++)  cin >> h[i];

	dp[0] = INF,  dp[1] = 0;
	for(int i = 2 ; i <= N ; i++)
	 dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));

	cout << dp[N] << endl;

	return 0;
}

Measured memory_bytes: 4608
#include<iostream>
using namespace std;
int main()
{
    string x,y;
    cin>>x>>y;
    if(x[0]==y[2]&&x[1]==y[1]&&x[2]==y[0])
      {
        cout<<"YES"<<endl;
      }
    
    else
    {
      cout<<"NO"<<endl;
    }
  
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
ll n, m, x, t;
vector<vector<ll>> tble;
vector<ll> cost;
ll finalCost = INT_MAX;
void recurs(ll index, vector<ll> &ind)
{
    if (index<n)
    {
        vector<ll> t;
        for (auto i:ind)
        {
            t.push_back(i);
        }
        recurs(index + 1, t);
        t.push_back(index);
        recurs(index + 1, t);
    }
    else
    {
        // for (auto i:ind)
        // {
        //     cout << i << " ";
        // }
        // cout << '\n';
        if (ind.size()!=0)
        {
            bool f = 0;
            ll temp_cost = 0;
            for (auto i: ind)
            {
                temp_cost += cost[i];
            }
            for (int j = 0; j < m; j++)
            {
                ll t=0;
                for (auto i : ind)
                {
                    t += tble[i][j];
                }
                //cout << t << '\n';
                if (t<x)
                {
                    //cout << t << '\n';
                    f=1;
                    break;
                }
            }
            if (!f)
            {
                finalCost = min(finalCost, temp_cost);
                return;
            }
        }
        return;
    }
        
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m >> x;
    vector<ll> ind;
    for (int i = 0; i < n; i++)
    {
        vector<ll> k;
        for (int j = 0; j < m+1; j++)
        {
            cin >> t;
            if (j!=0)
            {
                k.push_back(t);
            }
            else
            {
                cost.push_back(t);
            }
            
        }
        tble.push_back(k);
    }
    // for (auto i:cost)
    // {
    //     cout << i << " ";
    // }
    recurs(0, ind);
    if (finalCost==INT_MAX)
    {
        cout << -1 << '\n';
    }
    else
    {
        cout << finalCost << '\n';
    }
    

}

Measured memory_bytes: 3664
def gcm(m, n)
  if m % n == 0
    n
  else
    gcm(n, m % n)
  end
end

def lcm(m, n)
  m * n / gcm(m, n)
end

n = gets.chomp.to_i

ans = 1
n.times do
  ans = lcm(ans, gets.chomp.to_i)
end
puts ans


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	long long int r, D, x; cin >> r >> D >> x;
	int N = 10;

	REP(i,N){
		long long int v = r*x - D;
		cout << v << endl;
		x = v;
	}

	


	return 0;

}


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

class D
{
	struct P
	{
		public int i, j;
		public P(int _i, int _j) { i = _i; j = _j; }
		public bool IsInRange => 0 <= i && i < h && 0 <= j && j < w;
		public P[] Nexts() => new[] { new P(i, j - 1), new P(i, j + 1), new P(i - 1, j), new P(i + 1, j) };
	}

	static int h, w;

	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var z = Read();
		h = z[0]; w = z[1];
		var s = Read();
		var g = Read();
		var c = new int[h].Select(_ => Console.ReadLine()).ToArray();

		var sp = new P(s[0] - 1, s[1] - 1);
		var gp = new P(g[0] - 1, g[1] - 1);

		var u = new int[h, w];
		for (int i = 0; i < h; i++)
			for (int j = 0; j < w; j++)
				u[i, j] = c[i][j] == '.' ? -1 : 1 << 30;
		var q = new Queue<P>();
		var l = new List<P>();

		u[sp.i, sp.j] = 0;
		q.Enqueue(sp);
		l.Add(sp);

		while (q.Any())
		{
			while (q.TryDequeue(out var p))
				foreach (var x in p.Nexts())
				{
					if (!x.IsInRange || u[x.i, x.j] >= 0) continue;
					u[x.i, x.j] = u[p.i, p.j];
					q.Enqueue(x);
					l.Add(x);
				}

			var lt = l.ToArray();
			l.Clear();

			foreach (var p in lt)
				for (int i = -2; i <= 2; i++)
					for (int j = -2; j <= 2; j++)
					{
						var x = new P(p.i + i, p.j + j);
						if (!x.IsInRange || u[x.i, x.j] >= 0) continue;
						u[x.i, x.j] = u[p.i, p.j] + 1;
						q.Enqueue(x);
						l.Add(x);
					}
		}
		Console.WriteLine(u[gp.i, gp.j]);
	}
}


Measured memory_bytes: 50592
from collections import deque
s = input()
n = int(input())
q = deque()

for i in range(len(s)):
    q.append(s[i])

flag = True
for i in range(n):
    query = input()
    if query[0]=="1":
        flag = not flag
    else:
        if query [2]=="1":
            if flag:
                q.appendleft(query[4])
            else:
                q.append(query[4])
        else:
            if flag:
                q.append(query[4])
            else:
                q.appendleft(query[4])
if flag:
    print(''.join(q))
else:
    q.reverse()
    print("".join(q))




Measured memory_bytes: 74968
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
#define ff first
#define ss second

signed main() {

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

    int can = a - b;
    int ans = max(c - can, 0LL);

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int hight = sc.nextInt();
        int width = sc.nextInt();

        String[] pic = new String[hight];

        for (int i = 0; i < hight; i++) {
            // System.out.println("DEBUG i:" + i);
            pic[i] = sc.next();
        }

        // System.out.println("DEBUG:" + pic);

        for (int i = 0; i < width + 2; i++) {
            System.out.print("#");
        }

        System.out.println();

        for (int i = 0; i < hight; i++) {
            System.out.print("#");

            System.out.print(pic[i]);

            System.out.println("#");
        }

        for (int i = 0; i < width + 2; i++) {
            System.out.print("#");
        }

        System.out.println();

    }

}

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

int main()
{
    int a,b,c;
    cin >> a >> b >> c ;
    
    if(a > b)
    {
        int d,e;
        
        d = a;
        a = b;
        b = d;
        
        if(b > c)
        {
            int f;
            f = b;
            b = c;
            c = f;
            
            if(b < a)
            {
                int g;
                g = a;
                a = b;
                b = g;
                cout << a << " " << b << " " << c << endl;
            }
            else
            {
                cout << a << " " << b << " " << c << endl;
            }
        }
        else
        {
            cout << a << " " << b << " " << c << endl;

        }
    }
    else
    {
        if(b > c)
        {
            int h;
            h = b;
            b = c;
            c = h;
            
            cout << a << " " << b << " " << c << endl;
        }
        else
        {
            cout << a << " " << b << " " << c << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3056
N = int(input())
p1 = (0, 0)
p2 = (0, 0)
p3 = (0, 0)
p4 = (0, 0)

for i in range(N):
    x, y = map(int, input().split())
    if i == 0:
        p1 = (x, y)
        p2 = (x, y)
        p3 = (x, y)
        p4 = (x, y)
    else:
        if p1[0] + p1[1] < x + y:
            p1 = (x, y)
        if -p2[0] + p2[1] < -x + y:
            p2 = (x, y)
        if -p3[0] - p3[1] < - x - y:
            p3 = (x, y)
        if p4[0] - p4[1] < x - y:
            p4 = (x, y)

ans1 = abs(p1[0] - p3[0]) + abs(p1[1] - p3[1])
ans2 = abs(p2[0] - p4[0]) + abs(p2[1] - p4[1])

print(max(ans1, ans2))



Measured memory_bytes: 69844
#coding:utf-8

while True:
    try:
        count = 0
        n = input()

        for a in xrange(0, 10):
            for b in xrange(0, 10):
                for c in xrange(0, 10):
                    for d in xrange(0, 10):
                        if a + b + c + d == n:
                            count += 1
        print(count)
    except:
        break

Measured memory_bytes: 6284
package main

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

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(stringLineScan())
	a, _ := strconv.Atoi(stringLineScan())
	b, _ := strconv.Atoi(stringLineScan())
	x := n / (a + b)
	fmt.Println(x*a + smaller(n-x*(a+b), a))
}
func smaller(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}


Measured memory_bytes: 640
#include <iostream>//头文件
using namespace std;//命名空间

int n;//输入的数

int main() {
    cin >> n;//输入n
    if(n >= 1200) cout << "ARC";//如果n >= 1200，则输出"ARC"
    else cout << "ABC";//否则输出"ABC"
    return 0;
}

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

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

	cout << ((a+b) % 2 == 0 ? "Alice" : "Borys") << endl;
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	os << "{";
	rep(i, (int)v.size()) {
		if (i)
			os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
	for (auto val : array)
		std::cout << val << ", ";
	std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

	double a, b, x; std::cin >> a >> b >> x;
	double s = x / a;
	double rad;
	if (s >= a * b / 2) {
		double h = 2 * (a * b - s) / a;
		rad = atan2(h, a);
	} else {
		double w = 2.0 * s / b;
		rad = atan2(b, w);
	}
	double deg = rad * 180 / acos(-1);
	std::cout << fixed;
	std::cout << setprecision(7) << deg << "\n";
}


Measured memory_bytes: 256
///----> bismillahir rahmanir rahim <---- -- { ^ _ ^ }
///     { ^_^ }   { ^ _ ^ }
#include<bits/stdc++.h>
#include<bits/stdc++.h>
using namespace std;

//<--------------------------------------------typo section--------------------------------------------->
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;
typedef priority_queue<int>piwi;
typedef queue<int>kiwi;
typedef map<int,int>mi;
typedef map<string,int>mis;
typedef multimap<int,int>muli;
typedef multimap<string,int>muls;
typedef multiset<int>si;

//<----------------------------------------------------Narcos----------------------------------------------->
#define endl "\n"
#define Y cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define sp " "
#define PB push_back
#define F first
#define S second
#define as(a) (a).begin(),(a).end()
#define ras(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()
#define ki 1LL
#define MOD 1000000007
#define over return 0;
#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))
#define test int t;cin>>t;while(t--)


//<-----------------------------------------------------Const--------------------------------------------------->
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;


//<--------------------------------------------------------------------------------------------------->
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

const long long MAX_SIZE = 1000001; vector<long long >isprime(MAX_SIZE , true); vector<long long >prime; vector<long long >SPF(MAX_SIZE); void manipulated_seive(int N) { isprime[0] = isprime[1] = false ; for (long long int i=2; i<N ; i++) { if (isprime[i]) { prime.push_back(i); SPF[i] = i; } for(int j=0;j < (int)prime.size() && i*prime[j] < N && prime[j] <= SPF[i]; j++) { isprime[i*prime[j]]=false; SPF[i*prime[j]] = prime[j] ; } } }
int man_seive(int n){ manipulated_seive(n); for(int i=0;i<prime.size() && prime[i]<=n;i++)
cout<<prime[i]<<endl;
}
ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }

//continue;

//-----------------------------> YOUR JOURNEY STARTS HERE ------------------------------------>>

int main(){
    optimize();
 ll n,m;
 cin>>n>>m;
 if(gcd(n,m)==1) cout<<n*m<<endl;
 else cout<<max(n,m)*(min(n,m)/gcd(n,m))<<endl;
over
}


Measured memory_bytes: 18644
import math

S = input()

r = [0] * len(S)
S += 'R'
last = 0
count = 0
for i in range(0, len(S)-1):
    count += 1
    if S[i] != S[i+1]:
        # reset
        if S[i] == 'R':
            r[i] += math.ceil(count/2)
            r[i+1] += math.floor(count/2)
            last = i
        else:
            r[last] += math.floor(count/2)
            r[last+1] += math.ceil(count/2)
            pass
        count = 0
print(' '.join(map(str, r)))


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

const int INF = 0x3f3f3f3f;

int n;
ll x;
ll num[55],len[55];

ll dfs(int lev,ll pos){
	if(lev == 1){
		if(pos >= 1)
		    if(pos <= 4)
		        return pos - 1;
		    else
		        return 3;
		else
		    return 0ll;
	}
	if(pos <= 1)
	    return 0ll;
	if(pos == 2 + len[lev - 1])
	    return num[lev - 1] + 1;
	if(pos < 2 + len[lev - 1])
	    return dfs(lev - 1,pos - 1);
	if(pos == len[lev - 1] * 2 + 3)
	    return num[lev - 1] * 2 + 1;
	return 1 + num[lev - 1] + dfs(lev - 1,pos - len[lev - 1] - 2);
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	num[0] = 1;
	len[0] = 1;
	for(int i = 1;i <= 50;i++){
	    num[i] = num[i - 1] * 2 + 1;
	    len[i] = len[i - 1] * 2 + 3;
	}
	scanf("%d%lld",&n,&x);
	printf("%lld",dfs(n,x));
	return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putLn :: Show a => a -> IO ()
putLn = print

putList :: Show a => [a] -> IO ()
putList [n] = put n
putList (n:ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n] = putStr n
putStrList (n:ns) = do
  putStr n
  putStr " "
  putStrList ns

main = do
  [a, b, c] <- readInt
  if a == b
    then put c
    else if a == c
           then put b
           else put a


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

typedef pair<int,int> PI;


main(){
  int n;
  while(cin >> n && n){
    priority_queue<PI , vector<PI> , greater<PI> > Q;
    int m;
    
    for(int i=0;i<n;i++){
      int h,r;
      cin >> h >> r;
      Q.push( make_pair(h,r));
    }
    cin >> m;
    for(int i=0;i<m;i++){
      int h,r;
      cin >> h >>r;
      Q.push( make_pair(h,r));
    }
    int a[m+n][2];//a[i][0] Height a[i][1] radius
    for(int i=0;i<m+n;i++){
      a[i][0]=Q.top().first;
      a[i][1]=Q.top().second;
      Q.pop();
    }

    int res[m+n][m+n];
    for(int i=0;i<m+n;i++){
      for(int j=0;j<m+n;j++){
        res[i][j]=0;
      }
      res[i][i]=1;
    }
    
    
    
    for(int i=0;i<m+n;i++){
      int ma =1;
      for(int j=0;j <= i;j++){
        if ( a[i][0] > a[j][0] && a[i][1] > a[j][1]){
          res[i][j]=res[j][j]+1;
          ma = max(res[i][j],ma);
        }else {
          /*
            if ( j>0 && i > 0)res[i][j]=max(res[i][j-1],res[i-1][j]);
            else if (i == 0 && j > 0)res[i][j]=res[i][j-1];
            else if (j == 0 && i>0)res[i][j]=res[i-1][j];
          */
          if ( j>0)res[i][j]=max(res[i][j-1],ma);
          
        }
      }
    }

    /*
    for(int i=0;i<m+n;i++){
      for(int j=0;j<m+n;j++)cout << res[i][j]<<"  ";
      cout << endl;
    }
    */
    
    int max=0;
    for(int i=0;i<m+n;i++){
      if (res[i][i] > max)max = res[i][i];
    }

    cout << max << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int a[500000];

int main()
{
  _int64 ans;
  int i,j,n;
  scanf("%d",&n);
  for (i=0;i<n+n+n;i++)
    scanf("%d",&a[i]);
  sort(a,a+n+n+n);
  ans=0;
  for (i=n;i<n+n+n;i+=2)
    ans+=a[i];
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll ans;
    cin >> ans;
    for(int i = 2; i <= n; i++) {
        ll cur;
        cin >> cur;
        ans = ans / __gcd(ans, cur) * cur;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-5;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int n,m;cin>>n>>m;
    vector<int> x(m);
    for(int i=0;i<m;i++)cin>>x[i];
    sort(all(x));
    int ans=x[m-1]-x[0];
    vector<int> v;
    for(int i=1;i<m;i++){
        v.push_back(x[i]-x[i-1]);
    }
    sort(all(v));
    reverse(all(v));
    for(int i=0;i<min(n-1,m-1);i++){
        ans-=v[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int a[100005];
int dp[100005];
int main()
{
	int n,k;
	cin>>n>>k;
	int i;
	for(i=0;i<n;i++)
	cin>>a[i];
	dp[0]=0;
	for(i=1;i<=k;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i-a[j]>=0)
			{
				if(dp[i-a[j]]==0)
				{
					dp[i]=1;
					break;
				}
			}
		}
	}
	dp[k]==1 ? cout<<"First": cout<<"Second";
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const int pmax=100010;

int dp[pmax];
int p[15][15];

int main(void){
	int n,d,x;
	cin >> n >> d >> x;
	rep(i,d)rep(j,n) cin >> p[i][j];

	rep(i,d-1){
		rep(j,x+1) dp[j]=j;
		rep(j,n)rep(k,x+1) if(k-p[i][j]>=0) dp[k]=max(dp[k],dp[k-p[i][j]]+p[i+1][j]);
		int y=0;
		rep(j,x+1) y=max(y,dp[j]);
		x=y;
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 1272
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
s = ""
for i in range(n):
    s = input()
    if s == "AC":
        ac += 1
    elif s == "WA":
        wa += 1
    elif s == "TLE":
        tle += 1
    else:
        re += 1
print(f"AC x {ac}\nWA x {wa}\nTLE x {tle}\nRE x {re}")


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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define MOD 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;
typedef pair<ll,ll> Pl;
typedef vector<ll> vl;
typedef vector<Pl> vpl;


/*nCk (mod MOD)の計算 BEGIN*/
//faccal -> n!, k!^(MOD-2)の計算(初期化)
//comb -> nCk (mod MOD)の計算
ll mlpow(ll x, ll p) { //x^p(long long)%MOD
    ll tmp = 1;
    if(p == 0) return 1;
    while(p != 0) {
        if(p & 1) tmp = tmp*x % MOD;
        x = x*x % MOD;
        p = p >> 1;
    }
    return tmp;
}

int facnum = 2000005;
vl fac(facnum);   //n!
vl facM2(facnum);  //k!^(MOD-2)

void faccal(ll up) {
    fac[0] = 1;
    facM2[0] = 1;
    for(ll i = 0; i < up+1; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        facM2[i+1] = facM2[i]*mlpow(i+1, MOD-2) % MOD; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
}

ll comb(ll n, ll k) {
    if(n == 0 && k == 0) return 1;
    if(n < k || n < 0) return 0;
    ll tmp = facM2[n-k]*facM2[k] % MOD;
    return tmp*fac[n] % MOD;  //nCk = n!*(k!)^(M-2)*((n-k)!)^(M-2)
}
/*nCk (mod MOD)の計算 END*/

int main() {
    int X, Y;
    cin >> X >> Y;

    ll ans = 0;
    int m = (2*X - Y)/3, n = (2*Y - X)/3;
    int mr = (2*X - Y)%3, nr = (2*Y - X)%3;
    if(mr == 0 && nr == 0 && m >= 0 && n >= 0) {
        faccal(m+n);
        ans = comb(m+n, m);
    }

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


Measured memory_bytes: 31488
#include <iostream>

using namespace std;

int main(){
    int N, A, B;
    int keta, sum = 0;

    cin >> N >> A >> B;

    for(int i=1; i<=N; i++){
        int n = i;
        keta = 0;

        while(n != 0){
            keta += (n%10);
            n /= 10;
        }
        if(keta >= A && keta <= B){
            sum += i;
        }
    }

    cout << sum;
}

Measured memory_bytes: 256
import java.util.*;
    import java.util.Scanner;
    import java.io.*;
    import java.io.BufferedReader; 
    import java.io.IOException; 
    import java.io.InputStreamReader; 
    import java.util.Scanner; 
    import java.util.StringTokenizer; 
    
    public class Main
    {
        static class FastReader 
        { 
            BufferedReader br; 
            StringTokenizer st; 
    
            public FastReader() 
            { 
                br = new BufferedReader(new
                        InputStreamReader(System.in)); 
            } 
    
            String next() 
            { 
                while (st == null || !st.hasMoreElements()) 
                { 
                    try
                    { 
                        st = new StringTokenizer(br.readLine()); 
                    } 
                    catch (IOException  e) 
                    { 
                        e.printStackTrace(); 
                    } 
                } 
                return st.nextToken(); 
            } 
    
            int nextInt() 
            { 
                return Integer.parseInt(next()); 
            } 
    
            long nextLong() 
            { 
                return Long.parseLong(next()); 
            } 
    
            double nextDouble() 
            { 
                return Double.parseDouble(next()); 
            } 
    
            String nextLine() 
            { 
                String str = ""; 
                try
                { 
                    str = br.readLine(); 
                } 
                catch (IOException e) 
                { 
                    e.printStackTrace(); 
                } 
                return str; 
            } 
        } 
        
        

        public static void main(String args[]) 
        {  
            FastReader in=new FastReader();
            int n=in.nextInt();
            int rem=n%1000;
            if(rem==0)
                System.out.println(rem);
            else
                System.out.println(1000-rem);
    
            
                
            
        }
    }

Measured memory_bytes: 25360
fn read<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect()
}

fn main() {
    let v: Vec<usize> = read();
    let (n, t) = (v[0], v[1]);
    let ts: Vec<usize> = read();
    let mut ans = t;
    for i in 1..n {
        ans += std::cmp::min(t, ts[i] - ts[i - 1]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 10492
import java.util.*;
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		int N = sc.nextInt(), D = sc.nextInt(), c = 0;
 
		for(int i = 0; i < N; i++) {
			long X = sc.nextInt(), Y = sc.nextInt();
			if(Math.sqrt(X * X + Y * Y) <= D) {
				c++;
			}
		}
		System.out.println(c);
	}
}

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

using namespace std;

vector<vector<int>> G; int N,M;
vector<int> dp;

int rec(int v){
  if(dp[v] != -1){ return dp[v];}
  
  int res = 0;
  for(auto nv: G[v]){
    res = max(res, rec(nv) + 1);}
  
  return dp[v] = res;} //書き込みながら再帰

int main(){
   cin >> N >> M;
  
  G = vector<vector<int>> (N); dp = vector<int> (N,-1);
  
  for(int i = 0; i < M; i++){
    int x,y; cin >> x >> y; x--; y--;
    G[x].push_back(y);}
  
  int res = 0;
  
  for(int i = 0; i < N; i++){
    res = max(res, rec(i) );}
cout <<res << endl; return 0;}


Measured memory_bytes: 8192
def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    
    ans = 0
    rem = 0

    if a[0] < b[0]:
        ans += a[0]
        rem = b[0]- a[0]
    else:
        ans += b[0]
        
    for i in range(1,n):
        if a[i] < rem:
            ans += a[i]
            rem = b[i]
        else:
            ans += rem
            mons = a[i] - rem
            if mons < b[i]:
                ans += mons
                rem = b[i]- mons
            else:
                ans += b[i]
                rem = 0
    
    ans += min(a[n],rem)

    print(ans)

        
    





main()

Measured memory_bytes: 19004
#include <bits/stdc++.h>
using namespace std;
#define sz(a) (a.size())
#define int long long
#define SYNC ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(c) c.begin(), c.end()
#define pb push_back
#define F first
#define S second
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define debug(x) cout << #x << " = " << x << endl;
#define debug2(x, y) cout << #x << " = " << x << " , " << #y << " = " << y << endl;
#define debug3(x, y, z) cout << #x << " = " << x << " , " << #y << " = " << y << " , " << #z << " = " << z << endl;
const int M = 1000000007;
const int N = 1e9 + 1;

signed main()
{
    int h;
    cin>>h;
    int ans = ceil(log2(h+1));
    cout<<fixed<<(int)pow(2 , ans) - 1<<endl;

}


Measured memory_bytes: 256