akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
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;}

ll pow_mod(ll n,ll p,ll m){
    ll res = 1;
    while(p>0){
        if(p%2==1) res = (res * n) % m;
        n = (n * n) % m;
        p /= 2;
    }
    return res;
}

int main(){
    string s;cin >> s;
    int n = s.size();
    vector<vl> dp(n+10,vl(13,0));
    dp[0][0] = 1;
    reverse(s.begin(),s.end());
    for(int i=0;i<n;++i){
        if(s[i]!='?'){
            int num = ((s[i]-'0')*pow_mod(10,i,13))%13;
            for(int j=0;j<13;++j){
                dp[i+1][(num+j)%13] = dp[i][j];
            }
        }
        else{
            for(int j=0;j<10;++j){
                int num = (j * pow_mod(10,i,13)) % 13;
                for(int k=0;k<13;++k){
                    dp[i+1][(num+k)%13] = (dp[i+1][(num+k)%13] + dp[i][k]) % MOD;
                }
            }
        }
    }
    /*rep(i,n+1){
        rep(j,13) cout << dp[i][j] << " ";
        cout << endl;
    }*/
    cout << dp[n][5] << endl;
}

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

#define INF 2e9

#define REP(i,n) for(int i = 0; i < n;++i)
#define REPA(i,a,n) for(int i = a; i < n; ++i)
#define REPR(i,a) for(int i = a; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

int gcd(int a, int b){ return b ? gcd(b, a % b) : a; }
template<typename A> void psn(A a){ cout << a << endl; }
template<typename A, typename... B> void psn(A a, B... b){ cout << a << ' '; psn(b...); }

int main(void) {
    
    ll sum = 0;
    string S;
    
    cin >> S;
    
    int N = S.size();
    
    vi nums(N + 1, 0);
    
    REP(i, N){
        if(S[i] == '<'){ // 右に向かって調べる
            nums[i] = 0;
            REPA(j, i + 1, N){
                i++;
                nums[j] = nums[j - 1] + 1;
                if(S[j] == '>') break;
            }
        }
    }
    
    // 一番右端N+1を処理
    if(S[N - 1] == '<') nums[N] = nums[N - 1] + 1;
    else nums[N + 1] = 0;
    
    REPR(i, N - 1){
        if(S[i] == '>'){ // 左に向かって調べる
            nums[i + 1] = 0;
            REPR(j, i - 1){
                i--;
                // さっき調べた時より高くなければいけないなら上書き
                if(nums[j + 2] + 1 > nums[j + 1]) nums[j + 1] = nums[j + 2] + 1;
                if(S[j] == '<') break;
            }
        }
    }
    
    // 一番左端N+1を処理
    if(S[0] == '>') {
        if(nums[1] + 1 > nums[0]) nums[0] = nums[1] + 1;
    }
    else nums[0] = 0;
    
    REP(i, N + 1) sum += nums[i];

    psn(sum);
    
    return 0;
}

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

int m[201][201];
bool flag[201][201];
int a[3];

int gcd(int a, int b) {
	if (flag[a][b])
		return m[a][b];
	if (!(a % b))
		return b;
	int g = gcd(b, a % b);
	m[a][b] = g, m[b][a] = g, flag[a][b] = 1, flag[b][a] = 1;
	return g;
}
long long ans = 0;

int main() {
	int k;
	cin >> k;
	for (int i = 1; i < k + 1; i++) {
		for (int j = 1; j < k + 1; j++) {
			for (int l = 1; l < k + 1; l++) {
				ans += gcd(gcd(i, j), l);
			}
		}
	}
	cout << ans << endl;

}


Measured memory_bytes: 3816
#include<stdio.h>
int main() {

	char str1[7];
	fgets(str1, 7, stdin);
	if (str1[0] == 'S') {
		puts("Cloudy");
	}
	if (str1[0] == 'C' ) {
		puts("Rainy");
	}
	if (str1[0] == 'R') {
		puts("Sunny");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

int main() {
  int k;
  string s;
  cin >> k >> s;
  if (s.size() <= k) {
    cout << s << endl;
  } else {
    cout << s.substr(0, k) + "..." << endl;
  }
}

Measured memory_bytes: 3624
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    int n;
    cin >> n;
    ll sum=0;
    for(int i=0;i<n;i++){
        ll a;
        cin >> a;
        sum += a-1;
    }

    cout << sum << endl;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI acos(-1)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    while(cin>>n)
    {
        map<string,ll> mp;
        ll ans=0;
        for(int i=1;i<=n;i++)
        {
            string ch;
            cin>>ch;
            sort(ch.begin(),ch.end());
            mp[ch]++;
        }
        map<string,ll> ::iterator it;
        //ll ans=0;
        for(it=mp.begin();it!=mp.end();it++)
        {
            ll x=(*it).second;
            ans += (x*(x-1))/2;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 11264
#include<cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#include <map>
using namespace std;
int main(){
  int n;
  long long a[100001];
  long long sumo[100001];
  long long sume[100001];
    cin>>n;
  for (int i=0;i<n;i++){
  cin>>a[i+1];
  }
  long long anso=0;
  long long anse=0;
  sumo[0]=0;
  sume[0]=0;
  for (int i=1; i<=n;i++){
        if (i%2==0){
            if (sume[i-1]+a[i]>0) sume[i]=sume[i-1]+a[i];
            if (sume[i-1]+a[i]<=0){
                sume[i]=1;
                anse+=(1-(sume[i-1]+a[i]));
            }
            if (sumo[i-1]+a[i]<0) sumo[i]=sumo[i-1]+a[i];
            if (sumo[i-1]+a[i]>=0){
                sumo[i]=-1;
                anso+=sumo[i-1]+a[i]+1;
            }
        }
      else if (i%2==1){
          if (sumo[i-1]+a[i]>0) sumo[i]=sumo[i-1]+a[i];
          if (sumo[i-1]+a[i]<=0){
              sumo[i]=1;
              anso+=(1-(sumo[i-1]+a[i]));
                }
          if (sume[i-1]+a[i]<0) sume[i]=sume[i-1]+a[i];
          if (sume[i-1]+a[i]>=0){
              sume[i]=-1;
              anse+=(sume[i-1]+a[i]+1);
             
          }
      }
  }
    long long ans;
    ans=min(anso,anse);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
struct State{
  vector<int> v;
  State(vector<int> v) : v(v.begin(), v.end()) {}
  int head() const {
    return v.back();
  }
  bool operator < (const State& s) const {
    if(v.size() != s.v.size()) return v.size() > s.v.size();
    return head() > s.head();
  }
};

int main(){
  vector<int> s;
  s.push_back(1);
  priority_queue<State> que;
  que.push(State(s));
  int ans[1025];
  int cnt[1025] = {};
  REP(i, 1025) ans[i] = INF;
  const int B = 30;
  while(!que.empty()){
    State s = que.top(); que.pop();
    if(cnt[s.head()] >= B) continue;
    cnt[s.head()]++;
    ans[s.head()] = min(ans[s.head()], (int)s.v.size());
    for(int i = 0; i < s.v.size(); i++){
      int x = s.head() + s.v[i];
      if(1 < x && x <= 1024 && cnt[x] < B) {
        State next = s;
        next.v.push_back(x);
        que.push(next);
      }
      x = s.head() - s.v[i];
      if(1 < x && x <= 1024 && cnt[x] < B) {
        State next = s;
        next.v.push_back(x);
        que.push(next);
      }
    }
  }
  int N;
  while(cin >> N && N) cout << ans[N] - 1 << endl;
  return 0;
}

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

#define INF (1<<30)
#define MAX_N 100000

int n;
int a[MAX_N];

int dp[MAX_N];

int main()
{
	cin >> n;
	for( int i = 0; i < n; i++ ) {
		cin >> a[i];
	}

	for( int i = 0; i < n; i++ ) {
		dp[i] = INF;
	}
	for( int i = 0; i < n; i++ ) {
		*lower_bound( dp, dp + n, a[i] ) = a[i];
	}
	int ans = lower_bound( dp, dp + n, INF ) - dp;

	cout << ans << endl;

	return 0;
}



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

int main(){
	int n;
	int data[101];
	while(cin >> n , n){
		for(int i=0;i<n;i++){
			cin >> data[i];
		}
		sort(data,data+n);
		int sum = 0;
		for(int i=1;i<n-1;i++){
			sum += data[i];
		}
		int avg = sum / (n-2);
		cout << avg << endl;
	}
}

Measured memory_bytes: 1176
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

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

    vector <long long> A(N);
    long long xorSum = 0;

    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        xorSum ^= A[i];
    }

    xorSum ^= A[0]^A[1];
    // (A[0]-K) ^ (A[1]+K) ^ xorSum == 0 => Target
    // a+b = A[0]+A[1]
    // a+b = (a^b) + 2*(a&b)
    // (a^b) = xorSum
    long long R = A[0]+A[1] - xorSum;

    if (R%2 != 0 || R < 0) {
        cout << -1 << endl;
    } else {
        long long AND = R/2;

        // a+b = xorSum + 2*AND
        // a = (AND^Y)
        // b = (AND^Z)
        // Z^Y = xorSum
        if (AND & xorSum) {
            cout << -1 << endl;
        } else {
            // argMax(a) <= A[0] => argMin |A[0]-a|
            // 10^12 => (2^10)^4
            long long ans = AND;
            // cout << "BASE " << ans << endl;

            for (long long bit = 42; bit >= 0; --bit) {
                long long flag = (1LL << bit);
                if ((flag & xorSum) && ans + flag <= A[0]) { // dispatch
                    ans += flag;
                }
            }

            cout << (ans == 0 || ans > A[0] ? -1 : A[0]-ans) << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
using namespace std;
 
int n;
 
int main() {
   cin >> n;
  	if(n%10 == 2 || n%10 ==4 || n%10 == 5 || n%10 ==7|| n % 10 == 9){
    	cout <<"hon";
    }else if(n%10 == 3){
    	cout << "bon";
    }else{
    	cout << "pon";
    }
    return 0;
}

Measured memory_bytes: 3084
/* include */
#include"bits/stdc++.h"
/* namespace */
using namespace std;
/* typedef */
/* long系 */
typedef long long ll;	// long long
typedef long double ld;	// long double
/* vector系 */
typedef vector<int> vint;	// intのvector
typedef vector<double> vdouble;	// doubleのvector
typedef vector<ll> vll;	// llのvector
typedef vector<ld> vld;	// ldのvector
typedef vector<pair<int, int>> vi_i;	// i_iのvector
typedef vector<pair<double, double>> vd_d;	// d_dのvector
typedef vector<pair<ll, ll>> vl_l;	// l_lのvector
typedef vector<pair<ld, ld>> vld_ld;	// ld_ldのvector
typedef vector<string> vstring;	// stringのvector
/* pair系 */
typedef pair<int, int> i_i;	// int同士のpair
typedef pair<double, double> d_d;	// double同士のpair
typedef pair<ll, ll> l_l;	// ll同士のpair
typedef pair<ld, ld> ld_ld;	// ld同士のpair
/* define */
#define pb push_back	// push_back
#define all(v) v.begin(),v.end()	// コンテナ全体
#define PI (acos(-1))  // 円周率pi
/* 変数入出力 read, write */
template <typename T>	// 1変数
void read(T& x) {
    cin >> x;
}
template <typename T, typename T0>	// 2変数
void read(T& x, T0& y) {
    cin >> x >> y;
}
template <typename T, typename T0, typename T1>	// 3変数
void read(T& x, T0& y, T1& z) {
    cin >> x >> y >> z;
}
template <typename T, typename T0, typename T1, typename T2>	// 4変数
void read(T& x, T0& y, T1& z, T2& w) {
    cin >> x >> y >> z >> w;
}
template <typename T>	// 1変数
void write(T& x) {
    cout << x << endl;
}
template <typename T, typename T0>	// 2変数
void write(T& x, T0& y) {
    cout << x << " " << y << endl;
}
template <typename T, typename T0, typename T1>	// 3変数
void write(T& x, T0& y, T1& z) {
    cout << x << " " << y << " " << z << endl;
}
template <typename T, typename T0, typename T1, typename T2>	// 4変数
void write(T& x, T0& y, T1& z, T2& w) {
    cout << x << " " << y << " " << z << " " << w << endl;
}
// vectorの出力
template <typename T>
void printvec(const vector<T> &data) {
for (const auto elm : data) {
    cout << elm << " ";
}
cout << endl;
}


int main(int argc, char const *argv[])
{
    string s; s.resize(6);
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int n, k;
    string s;
    cin>>n>>s>>k;

    char ch = s[k-1];
    for(int i=0; i<n; i++){
        if(s[i] != ch) s[i] = '*';
    }

    cout << s << endl;
}

Measured memory_bytes: 768
#Bitter Alchemy
N,X=map(int, input().split())
m=[]
for i in range(N):
    m.append(int(input()))
x=X
count=0
for make in m:
    x-=make
    count+=1
make=min(m)
while x>=make:
    x-=make
    count+=1
print(count)

Measured memory_bytes: 3060
/**
 * Copyright (c) 2017, xehoth
 * All rights reserved.
 * 「ARC 085C」HSI 06-12-2017
 *
 * @author xehoth
 */
#include <bits/stdc++.h>

int main() {
    register int n, m;
    std::cin >> n >> m;
    std::cout << (1900 * m + 100 * (n - m)) * (1 << m);
    return 0;
}

Measured memory_bytes: 256
(let* ((n (read))
       (lst (loop :repeat n :collect (read)))
       (k 0))
  (setf k (count t (mapcar #'= lst (sort (copy-list lst) #'<)) :test #'equal))
  (if (or (= k n) (= k (- n 2)))
      (princ "YES")
      (princ "NO")))

Measured memory_bytes: 4328
package main

import (
  "fmt"
)

func absInt(x int) int {if x < 0 {x *= -1}; return x}
func maxInt(a ...int) int {m := a[0]; for _, x := range a {if x > m {m = x}}; return m}
func minInt(a ...int) int {m := a[0]; for _, x := range a {if x < m {m = x}}; return m}

func main() {
  var n int 
  fmt.Scan(&n)
  w := make([]int, n)
  s1, s2 := 0, 0
  for i := 0; i < n; i++ {
    fmt.Scan(&w[i])
    s2 += w[i]
  }
  res := s2
  for i := 0; i < n; i++ {
    s1 += w[i]
    s2 -= w[i]
    res = minInt(res, absInt(s1 - s2))

  }
  fmt.Println(res)


}

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

long long x;

int main() {
  cin >> x;
  if (x % 11 == 0) cout << 2 * (x / 11) << endl;
  else cout << 2 * (x / 11) + ((x % 11 > 6) ? 2 : 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define inp(k)           ll k;cin>>k;
    #define in2(n,k)       ll n, k; cin>>n;cin>>k;
    #define in3(n,k,r)       ll n, k,r; cin>>n;cin>>k;cin>>r;
    #define ll long long
    #define dl double
    #define ch char
    #define f(i,a,b) for(ll i=a;i<b;i++)
    #define rf(i,a,b) for(ll i=a-1;i>=b;i--)
    #define Godspeed                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define vpl vector< pair<ll,ll> >
    #define vpi vector< pair<int,int> >
    #define vi vector<int>
    #define vl vector<ll>
    #define vdl vector<dl>
    #define vch vector<char>
    #define pll pair<ll,ll>
    #define pb push_back
    #define mp make_pair
    #define fr first
    #define se second
    #define PI 3.14159265
    /*vl v[10005];
    ll cnt=0;
    ll a[51][51]={0};
    bool visited[10005]={0};
    void dfs(ll u)
    {
        visited[u]=1;
        f(i,0,v[u].size())
        {
            ll f=v[u][i];
            if(!visited[f])
            {
                dfs(f);
            }
        }
    }*/
    const int INF=1e9+5;
    void solve()
    {
        inp(n);
        ll a[n][3];
        f(i,0,n)
        {
            f(j,0,3)cin>>a[i][j];
        }
        ll dp[n][3];f(i,0,n){dp[i][0]=0,dp[i][1]=0,dp[i][2]=0;}
        dp[0][0]=a[0][0];dp[0][1]=a[0][1];dp[0][2]=a[0][2];
        f(i,1,n)
        {
            dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
            dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
            dp[i][2]=max(dp[i-1][0],dp[i-1][1])+a[i][2];
        }
        cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    }

    int32_t main(void)
    {
        Godspeed;
        int q;
        q=1;
        //cin>>q;
        while (q--)
        {
            solve();cout<<endl;
        }
        return 0;
    }


Measured memory_bytes: 8260
#include <stdio.h>
#include <stdlib.h>
  
#define MIN_N 1
#define MAX_N 200000
#define MIN_A 0
#define MAX_A 1000000000
  
int array[MAX_N];
long invcnt = 0;
  
void merge(int *array, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    int i, j, k, *left_array, *right_array;
  
    left_array = malloc(sizeof(int) * n1 + 100);
    right_array = malloc(sizeof(int) * n2 + 100);
  
    for(i = 0; i < n1; i++) 
        left_array[i] = array[left + i];
    for(i = 0; i < n2; i++)
        right_array[i] = array[mid + i];
    left_array[n1] = MAX_A + 1;
    right_array[n2] = MAX_A + 1;
    i = 0;
    j = 0;
    for(k = left; k < right; k++) {
        if(left_array[i] <= right_array[j]) 
            array[k] = left_array[i++];
        else {
            invcnt += n1 - i;
            array[k] = right_array[j++];
        }
          
    }
    free(left_array);
    free(right_array);
}
  
void merge_sort(int *array, int left, int right)
{
    if(left + 1 < right) {
        int mid;
  
        mid = (left + right) / 2;
        merge_sort(array, left, mid);
        merge_sort(array, mid, right);
        merge(array, left, mid, right);
    }
  
}
  
int main(void)
{
    int i, n;
  
    scanf("%d", &n);
    for(i = 0; i < n; i++)
    {
        int a;
        scanf("%d", &a);
        array[i] = a;
    }
    merge_sort(array, 0, n);
    printf("%ld\n", invcnt);
  
    return 0;
}

Measured memory_bytes: 3036
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <iostream>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long llu;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;

int vec[2][100];
int dp[2][100];
int n = 2, m;

int go(int x, int y) {
	if (x == n || y == m) return 0;
	if (x == n - 1 && y == m - 1) return vec[x][y];
	if (dp[x][y] != -1) return dp[x][y];

	int mav = 0;
	mav = max(mav, go(x + 1, y));
	mav = max(mav, go(x, y + 1));

	return dp[x][y] = mav + vec[x][y];
}

int main() {
	memset(dp, -1, sizeof(dp));
	scanf("%d", &m);

	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			scanf("%d", &vec[i][j]);

	printf("%d", go(0, 0));
}

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

using namespace std;

const int MAXN = 1e6 + 10;

int numb[MAXN];

void preclac() {
	numb[0] = 0;
	for (int i = 1; i < MAXN; i++) {
		numb[i] = numb[i - 1];
		int x = i;
		while (x % 2 == 0) {
			numb[i]++;
			x /= 2;
		}
	}
}

bool Cnk(int n, int k) {
	int a = numb[n];
	int b = numb[k] + numb[n - k];
	if (a == b)
		return 1;
	return 0;
}

int main() {
	preclac();
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		a[i] = s[i] - '0';
		a[i]--;
	}
	int ans = 0;
	bool flag = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] % 2 == 0)
			continue;
		flag = 1;
		if (Cnk(n - 1, i))
			ans ^= 1;
	}
	if (ans == 1) {
		cout << 1 << endl;
		return 0;
	}
	if (flag) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 0; i < n; i++)
		a[i] /= 2;
	ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] % 2 == 0)
			continue;
		if (Cnk(n - 1, i))
			ans ^= 1;
	}
	if (ans == 1) {
		cout << 2 << endl;
	}
	else
		cout << 0 << endl;
}

Measured memory_bytes: 9220
#B - Judge Status Summary

n = int(input())
l = []

for i in range(n):
  l.append(input())

print('AC x ' + str(l.count('AC')))
print('WA x ' + str(l.count('WA')))
print('TLE x ' + str(l.count('TLE')))
print('RE x ' + str(l.count('RE')))


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

int main(){
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int answer = 0;
  int sum;
  
  for(int i = 0; i<=a; i++){
    for(int j = 0; j<=b; j++){
      for(int k = 0; k<=c; k++){
        sum = 500*i + 100*j +50*k;
        if(sum == x)
          answer++;
      }
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n;
    cin >> n;
    vi x(n);
    vector<pii> xs;
    xs.reserve(n * n);
    for (ll i = 0; i < n; ++i) {
        cin >> x[i];
        x[i]--;
        xs.emplace_back(x[i], i + 1);
    }
    sort(xs.begin(), xs.end());
    vi ret(n * n, -1);
    ll idx = 0;
    for (ll i = 0; i < n; ++i) {
        ret[xs[i].first] = xs[i].second;
        for (ll j = 0; j < xs[i].second - 1; ++j) {
            while (ret[idx] != -1)
                idx++;
            ret[idx] = xs[i].second;
        }
    }
    idx = n * n - 1;
    for (ll i = n - 1; i >= 0; --i) {
        for (ll j = 0; j < n - xs[i].second; ++j) {
            while (ret[idx] != -1)
                idx--;
            ret[idx] = xs[i].second;
        }
    }

    vi cnt(n + 1, 0);
    for (ll i = 0; i < n * n; ++i) {
        cnt[ret[i]]++;
        if (ret[i] == cnt[ret[i]]) {
            if (x[ret[i] - 1] != i) {
                cout << "No"
                     << "\n";
                return 0;
            }
        }
    }
    cout << "Yes"
         << "\n";
    print(ret);
    return 0;
}

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

int main()
{
    int m,n,k,j,i,sum=0;
    cin>>j;
       for(i=0;i<j;i++)
    {
    cin>>m>>n>>k;
    if(sqrt(m*m+n*n)==k)
    {
        cout<<"YES"<<endl;
    }
    else if(sqrt(m*m+k*k)==n)
        {
            cout<<"YES"<<endl;
        }
    else if(sqrt(k*k+n*n)==m)
    {
       cout<<"YES"<<endl;
    }
    else
cout<<"NO"<<endl;
    }

return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	int a,b;
cin>>a>>b;
if(a>b){
	for(int i=0;i<a;i++){
		cout<<b;
	}
}
else if(a<b){	
	for(int j=0;j<b;j++){
		cout<<a;}
	
}
else{
	for(int m=0;m<a;m++ ){
		cout<<a;
	}
}
	return 0;
}
	
	
	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll n, m, t, a[100005];
vector< ll > adj[100005];
#define ari for( int i = 0 ; i < n ; i++ ) cin >> a[i];
#define ginp for( int i = 0 ; i < m ; i++ ){ int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u);}
#define pb push_back
#define ss second
#define ff first
#define fs first.second
#define fff first.first
#define sss second.second
#define sf second.first
#define mp make_pair

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k;
    cin >> k;
    if( k % 2 == 0 or k % 5 == 0 ){
    	cout << "-1" << endl;
    	return(0);
    }
    ll po = (7 % k), prev = 0, ans = 0;
    for(int i = 1 ; ; i++){
    	if( (po + prev) % k == 0 ){
    		ans = i;
    		break;
    	}
    	prev = (po + prev) % k;
    	po = (po * 10) % k;
    }
    cout << ans << endl;
	return(0);
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

template<typename T>
T gcd(T x, T y){
    if (x == 0 || y == 0) {
        return 0;
    }

    while (x != y){
        if (x > y) {
            x -= y;
        }else{
            y -= x;
        }
    }
    return x;
}

// }}}
/* vim:set foldmethod=marker: */

void solve(){
    int r;
    cin >> r;

    if (r<1200) {
        cout << "ABC" << endl;
    }else if (1200 <= r && r < 2800) {
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


// map の key, value を全て抜き出す。
// for (auto itr = mp.begin(); itr != mp.end(); itr++) {
//     cout << "key" << itr->first << " value" << itr->second << endl;
// }

// 文字列の検索
// string s="abc";
// if (s.find('d') == string::npos){
//     cout << "find" << endl;
// }else{
//     cout << "not find" << endl;
// }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define qwq(x) cerr<<" #"<<#x<<" = "<<x<<endl;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=200005,T=30000;
int a[N],b[N],p[N],n;

int main(){
	read(n);
	rep(i,1,n){
		read(p[i]);
		a[i]=i*T;
		b[i]=(n+1-i)*T;
	}
	rep(i,1,n)a[p[i]]-=n-i;
	rep(i,1,n)printf("%d ",a[i]);puts("");
	rep(i,1,n)printf("%d ",b[i]);puts("");
	return 0;
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

template<class T> inline T gcd(T a, T b) {
    T r;
    if ( a < b ) swap(a, b);

    while( b > 0 ) {
        r = a % b;
        a = b;
        b = r;
    }

    return a;
}

template<class T> inline map<T, int> prime_factor(T n) {
    map<T, int> ret;
    for(T i = 2; i * i <= n; ++i) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }

    if (n != 1) ret[n] = 1;
    return ret;
}

int main(void) {
    ll A, B;
    cin >> A >> B;

    ll GCD = gcd(A, B);
    ll c = 1;
    c += prime_factor(GCD).size();

    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))
d = {}
for a in A:
  d[a] = d.get(a, 0) + 1
for i in range(M):
  b, c = map(int, input().split())
  d[c] = d.get(c, 0) + b
ans = 0
n = 0
for a, b in sorted(d.items(), reverse=True):
  if n >= N: break
  elif n + b > N:
    ans += a * (N - n)
  else:
    ans += a * b
  n += b
print(ans)

Measured memory_bytes: 40736
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC132
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var p = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int result = 0;

            for(int i = 1; i < n - 1; i++)
            {
                if(p[i-1]<p[i] && p[i] <p[i+1] 
                    || p[i-1]>p[i] && p[i] > p[i + 1])
                {
                    result++;
                }
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int i;
	int a[26]={0};
	string n;
	while(getline(cin,n)){
		for(i=0;i<n.size();i++){
			if('A'<=n[i]&&n[i]<='Z'){
				n[i]=n[i]+('a'-'A');
			}
		}
		for(i=0;i<n.size();i++){
			if('a'<=n[i]&&n[i]<='z'){
				a[n[i]-'a']++;
			}
		}
	}
	for(i=0;i<26;i++){
		printf("%c : %d\n",i+'a',a[i]);
	}
	return 0;
}


Measured memory_bytes: 3292
main :: IO ()                                                                                                                                         
main = do                                                                                                                                             
  _ <- getLine                                                                                                                                        
  vs <- map read . words <$> getLine :: IO [Int]                                                                                                      
  cs <- map read . words <$> getLine :: IO [Int]                                                                                                      
  print $ sum $ zipWith (\x y -> if x > y then x - y else 0) vs cs

Measured memory_bytes: 636
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <tuple>
#include <algorithm>
#include <cmath>
using namespace std;


int main(){
    long A;
    string B;
    cin >> A >> B;


    //cout << B[0] << endl;
    int B2 = (B[0]-48)*100 + (B[2]-48)*10 + (B[3]-48);

    cout << (A * B2)/100 <<endl;

    
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))
 
 // ^^^ Template ^^^ //

int main() {
	in(ll, N);
	in_v(ll, A, N); sort_v(A);
	in_v(ll, B, N); sort_v(B);
	in_v(ll, C, N); sort_v(C);
	vector<ll> Bc(N, 0), Bs(N);
	loop(i, N)
		Bc[i] = C.end() - upper_bound(C.begin(), C.end(), B[i]);
	ll ans = 0, Bst = 0;
	loop(i, N){
		Bst += Bc[N-1-i];
		Bs[N-1-i] = Bst;
	}
	//loop(i, N) cerr << "Bs[" << i << "] = " << Bs[i] << endl;
	loop(i, N){
		ll p = upper_bound(B.begin(), B.end(), A[i]) - B.begin();
		//cerr << " p -> " << p << endl;
		ans += Bs[p];
	}
	cout << ans << endl;
}



Measured memory_bytes: 4224
import math


a,b,x=map(int,input().split())

if 2*x<=a*a*b:
    sit=math.atan((a*b*b)/(2*x))
    print(math.degrees(sit))
elif 2*x>a*a*b:
    p1=2*(a*a*b-x)
    p2=a*a*a
    sit=math.atan(p1/p2)
    print(math.degrees(sit))


Measured memory_bytes: 3060
import java.util.*;
public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int arr[] = new int[N];
    for(int i = 0; i<N; i++){
      arr[i] = sc.nextInt(); 
    }
    Arrays.sort(arr);
    int ans = 1000000000;
    for(int i = K-1; i<N; i++){
      ans = Math.min(ans, arr[i] - arr[i-K+1]); 
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 58552
import java.util.*;


public class Main{
  public static void main(String[] arg){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    String ans ;
    if(A == B){
      ans = "Draw";
    }else if(A < B && A != 1){
      ans = "Bob";
    }else if(B == 1){
      ans = "Bob";
    }else{
      ans = "Alice";
    }
    System.out.println(ans);
  }
}


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

using namespace std;

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

  vector<int> a(Q), b(Q), c(Q), d(Q);
  for (int i = 0; i < Q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--, b[i]--;
  }

  int ans = 0;
  vector<int> A(N, 1);

  while (true) {
    int score = 0;
    for (int i = 0; i < Q; i++) {
      if (A[b[i]] - A[a[i]] == c[i]) {
        score += d[i];
      }
    }
    ans = max(ans, score);

    if (A[0] == M) {
      break;
    }
    int idx = N - 1;
    while (A[idx] == M) {
      idx--;
    }
    A[idx]++;
    for (int i = idx + 1; i < N; i++) {
      A[i] = A[i - 1];
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3608
# -*- coding: utf-8 -*-
k, a, b = list(map(int,input().split()))

d = a-b
if(a>=k):
    print(1)
elif(d<=0):
    print(-1)
else:
    if((k-a)%d == 0):
        print((2*(k-a)//d)+1)
    else:
        print((2*((k-a)//d+1))+1)

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

#define Wingardium_Leviosa ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define ll long long int

#define pii pair <int, int>
#define pll pair <ll, ll>

#define vi vector <int>
#define vll vector <ll>
#define vpii vector <pii>
#define vpll vector <pll>

#define mapinrev for(auto i = m.rbegin(); i != m.rend(); i++)

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define line cout << "\n"

const ll mod = 1e9 + 7;

const ll N = 1e6 + 100;
ll pr[N] = {0};

ll SEr()
{   for(ll i = 2; i < N; i++){
        if(pr[i] == 0){
            for(ll j = 2*i; j < N; j += i) pr[j]++;
        }
    } return 0;
}

bool isPrime(ll n)
{
    if(pr[n] == 0) return true;
    else return false;
}

ll power(ll a, ll b){
	a %= mod; ll res = 1;
	while(b > 0)
	{
		if(b % 2) {res *= a; res %= mod;}
		a *= a; a %= mod; b /= 2;
	}
	return res;
}

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

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

/*
 ____________________________________________________________
|                                                            |
|       I solemnly swear that I am up to no good.            |
|____________________________________________________________|

*/


int main(){

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    Wingardium_Leviosa;

    ll T = 1;
    //cin >> T;
    while(T--)
    {
        ll n, i;
        cin >> n;
        if(n >= 30)
            cout << "Yes";
        else
            cout << "No";
    }
    return 0;
}

/*
 ____________________________________________________________
|                                                            |
|                   Mischief managed!                        |
|____________________________________________________________|

*/


Measured memory_bytes: 3648
n=int(input())
a=list(map(int,input().split()))
print(2*n-1)
if min(a)+max(a)>0:
    s=a.index(max(a))
    for i in range(n):
        print(s+1,i+1)
    for i in range(1,n):
        print(i,i+1)
else:
    s=a.index(min(a))
    for i in range(n):
        print(s+1,i+1)
    for i in range(n,1,-1):
        print(i,i-1)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int K;
vector<int> A;
int main() {
	cin >> K;
	A.resize(K);
	for (auto& x : A) cin >> x;
	ll x = 2, y = 2;
	bool ok = true;
	for (int p = K-1; p >= 0; -- p) {
		ll xx = (x + A[p] - 1) / A[p];
		ll yy = y / A[p];
		if (xx > yy) { ok = false; break; }
		x = xx * A[p];
		y = (yy+1) * A[p] - 1;
	}
	if (!ok) {
		cout << -1 << endl;
	} else {
		cout << x << " " << y << endl;
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
const ll mod = 1000000007;


std::vector<long long> fac(100100), inv(100100), finv(100100); //階乗 / 逆元 / inv * fac
void comb_init()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2;i < 100100; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}

long long comb(int n,int r){
    if(n < r) return 0;
    if(n < 0 || r < 0)return 0;
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
}


int main()
{
    comb_init();
    int n,k;
    std::cin >> n >> k;
    std::vector<ll> a(n);
    for(int i = 0; i < n; i++)std::cin >> a[i];
    std::sort(a.begin(),a.end());
    ll max = 0, min = 0;
    for(int i = k - 1; i < n; i++){
        max += a[i] * comb(i,i + 1 - k) % mod;
        min += a[n - i - 1] * comb(i,i + 1 - k) % mod;
    }
    ll ans = (max - min) % mod;
    if(ans < 0)ans += mod;
    std::cout << ans % mod<< std::endl;

}

Measured memory_bytes: 3328
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
char c;
int main(){
  rd(c);
  c++;
  wt_L(c);
  wt_L('\n');
  return 0;
}

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

int N, M;
int S[100000];
bool X[100000];

int main() {
  cin >> N >> M;
  X[0] = true;
  for (int i=0; i<N; i++) S[i] = 1;
  for (int i=0; i<M; i++) {
    int x, y; cin >> x >> y;
    x--, y--;
    X[y] |= X[x];
    S[y]++, S[x]--;
    if (X[x] && S[x] == 0) X[x] = false;
  }
  int c = 0;
  for (int i=0; i<N; i++) {
    if (X[i]) c++;
  }
  cout << c << "\n";
  return 0;
}


Measured memory_bytes: 768
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define INF 9223372036854775807 / 2
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair


using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

struct uf_tree {
	std::vector<int> parent;
	int __size;
	uf_tree(int size_) : parent(size_, -1), __size(size_) {}
	void unite(int x, int y) {
		if ((x = find(x)) != (y = find(y))) {
			if (parent[y] < parent[x]) std::swap(x, y);
			parent[x] += parent[y];
			parent[y] = x;
			__size--;
		}
	}
	bool is_same(int x, int y) { return find(x) == find(y); }
	int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); }
	int size(int x) { return -parent[find(x)]; }
	int size() { return __size; }
};



//!!!問題をちゃんと読む!!!
//!!!問題をちゃんと読め!!!
//!!!問題は読みましたか？!!!

int ans[1000000];
bool visited[1000000];
Graph G(100001);

void dfs(int node, int weight, int color) {
	if (visited[node]) return;
	if (ans[node] != -1) return;

	visited[node] = true;
	if (weight % 2 == 0) {
		ans[node] = 1;
	}
	else {
		ans[node] = 0;
	}

	for (Edge e : G[node]) {
		if (visited[e.dst]) {
			continue;
		}

		dfs(e.dst, weight + e.weight, color);
	}
}

signed main() {
	//木:生き方は必ず1通り
	//DFSをして偶奇が同じ限りおなじいろで塗る
	
	int N;
	cin >> N;

	rep(i, N-1) {
		int u, v, w;
		cin >> u>>v>> w;
		u--;
		v--;
		add_edge(G, u, v, w);
	}


	rep(i, N) ans[i] = -1;
	dfs(0,0, 0);

	rep(i, N) {
		cout << ans[i] << "\n";
	}
	


	return 0;
}

Measured memory_bytes: 13184
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, i, j;

    for(;;){
      n = sc.nextInt();
      if(n == 0)break;
      for(i = n;;i--)if(isprime(i))break;
      for(j = n;;j++)if(isprime(j))break;
      out.println(j - i);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static boolean isprime(int p){
    int i;
    if(p == 1)return false;
    for(i = 2;i * i <= p;i++)if(p % i == 0)return false;
    return true;
  }
}

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

using namespace std;

int main(){
    string s;
    cin >> s;
    vector<char> v;
    for(int i = 0; i<4; i++){
        v.push_back(s[i]);
    }
    sort(v.begin(), v.end());
    if(v[0] == v[1] && v[2] == v[3] && v[1] != v[2]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
M = lines[0][1]

access = []
for i in 1..N do
  access[i-1] = []
end

for i in 1..M do
  from = lines[i][0]
  to = lines[i][1]
  access[from-1].push(to)
  access[to-1].push(from)
end

visited = []
cluster = []
for i in 1..N do
  visited[i-1] = false
  cluster[i-1] = 0
end

num_cluster = 0
for k in 1..N do
  if visited[k-1] == false then
    visited[k-1] = true
    num_cluster += 1
    cluster[k-1] = num_cluster
    target = [k]
    while target != [] do
      i = target.pop
      access[i-1].each do |j|
        if visited[j-1] == false then
          cluster[j-1] = num_cluster
          target.push(j)
          visited[j-1] = true
        end
      end
    end
  end
end
    
puts num_cluster

Measured memory_bytes: 33084
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int dp[2][90005];
const int mod=998244353;
int mm[305];
int pwr1[305],pwr2[305];
int x[2][90004];

signed main()
{

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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    pwr1[0]=1;
    pwr2[0]=1;
    for(int i=1;i<=300;i++) 
        pwr1[i]=(pwr1[i-1]*3)%mod;

    for(int i=1;i<=300;i++) 
        pwr2[i]=(pwr2[i-1]*2)%mod;

    int n;
    cin>>n;    
    int a[n+1];
    int tot=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];        
        tot+=a[i];
        mm[a[i]]++;
    }
    dp[0][0]=1;
    x[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=90000;j++)
        {
            dp[i&1][j]=0;
            x[i&1][j]=0;
            if(j>=a[i])
            {
                dp[i&1][j]+=dp[(i+1)&1][j-a[i]];
                x[i&1][j]+=x[(i+1)&1][j-a[i]];
            }
            dp[i&1][j]+=dp[(i+1)&1][j]*2;
            dp[i&1][j]%=mod;
            x[i&1][j]+=x[(i+1)&1][j];
            x[i&1][j]%=mod;
        }
    }
    int ans=0;
    for(int i=(tot+1)/2;i<=90000;i++)
    {
            ans+=dp[n&1][i];
            ans%=mod;
            ans%=mod;
    }

    ans*=3;
    ans%=mod;
    int z=pwr1[n];
    z%=mod;
    if(tot%2==0)
        z+=(x[n&1][tot/2]*3)%mod%mod;
    z%=mod;
    cout<<(z-ans+mod)%mod;
} 



Measured memory_bytes: 3072