akhauriyash/Code-Regression huggingface dataset:
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 100;
int top;
int S[100];

void initialize() {
	top = 0;
}
int isEmpty() {
	return top == 0;

}
int isFull() {
	return top > MAX;
}
void push(int x) {
	if (isFull()){
		printf("満杯です");
	return;
	}
	top++;
	S[top] = x;
}
int pop() {
	if (isEmpty()) {
		printf("これ以上取り除けません");
		return NULL;
	}
	top--;
	return	S[top + 1];
}

int main() {
	int i = 0;
	char str[1300],*cn;
	initialize();
	fgets(str, sizeof(str), stdin);	//get関数は最後に\n　\0を作る。
	cn = strtok(str," ");
	
	while (cn != NULL) {
	
		if (strcmp(cn,"+") == 0 || strcmp(cn,"+\n") == 0) {
			
			int x = pop();
			int y = pop();
			push(x + y);
		}
		else if (strcmp(cn,"-") == 0 || strcmp(cn,"-\n") == 0) {
			int x = pop();
			int y = pop();
			push(y - x);

		}
		else if (strcmp(cn,"*") == 0 || strcmp(cn,"*\n") == 0) {
			int x = pop();
			int y = pop();
			push(x * y);
		}
		else {
			push(atoi(cn));
		}
		cn = strtok(NULL," ");
	}

	printf("%d\n",S[1]);
	
	return 0;
}
//1 2 + 3 4 - *


Measured memory_bytes: 2108
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
  ll n;cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  ll sunuke=a[0];
  ll arai=0;
  rep(i,n)arai+=a[i];
  arai-=a[0];
  ll MIN=abs(arai-sunuke);
  for(ll i=1;i<n-1;i++){
    arai-=a[i];
    sunuke+=a[i];
    MIN=min(abs(sunuke-arai),MIN);
  }
   cout<<MIN<<endl;
}

Measured memory_bytes: 1792
import Data.List
import Data.Maybe

data Result = O | X | Draw
instance Show Result where
    show O = "o"
    show X = "x"
    show Draw = "d"


ttt :: [Char] -> Result
ttt xs = let
    linesToCheck =
        cutEvery 3 xs ++ (transpose . cutEvery 3) xs ++
        map (map (xs !!)) [[0,4,8], [2,4,6]]
    lns = map checkLine linesToCheck
    in
        case (listToMaybe . catMaybes) lns of
            Nothing -> Draw
            (Just r) -> r

checkLine :: [Char] -> Maybe Result
checkLine xs
    | all (== 'o') xs = Just O
    | all (== 'x') xs = Just X
    | otherwise       = Nothing

-- try weird things
cutEvery :: Int -> [a] -> [[a]]
cutEvery n = takeWhile (not . null) . unfoldr (Just . splitAt n)

main = getContents >>= mapM_ (print . ttt) . lines

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
const int dx[]={0,1,0,-1,1,-1,-1,1};
const int dy[]={-1,0,1,0,1,1,-1,-1};
const int INF = 1<<30;
const double EPS = 1e-15;
#define PB push_back
#define mk make_pair
#define fi first
#define se second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
typedef pair<int,int> Pii;
typedef pair<Pii,Pii> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
class data{
    public:
    int type;
    int cnt;
    data(){}
    data(int _type,int _cnt){
        type = _type;
        cnt = _cnt;
    }
};
vector < data >  G[10001];
int pay[10001];
int main(){
    int N,M;
    scanf("%d%d",&N,&M);
    int s,t,e;
    while(true){
        scanf("%d%d%d",&s,&t,&e);
        if(s+t+e == 0)break;
        s--;t--;
        G[s].PB(data(t,e));
    }
    int L;
    scanf("%d",&L);
    rep(i,L){
        rep(j,M){
            scanf("%d",pay+j);
        }
        rep(j,N){
            int ret = 0;
            rep(k,G[j].size()){
                ret += pay[G[j][k].type]*G[j][k].cnt;
            }
            printf("%d%c",ret,j==N-1?'\n':' ');
        }
    }
    return 0;
}

Measured memory_bytes: 2200
/*input
6 15
6 5
5 6
6 4
6 6
3 5
7 2
*/

#include <functional>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <utility> 
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>

using namespace std;

using ll = long long;
using ld = long double;

const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define all(c)      (c).begin(),(c).end()
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

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

template <typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(auto x: v) {
    os << x << " ";
  }
  return os;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &x : v) is >> x;
  return is;
}

/******************************** START *********************************/
const int N = 100005;
vector < vector < ll > > v;
ll dp[101][N];

ll func(int n, int w) 
{
  if(n == 0) {
    return 0;
  }
  if(dp[n][w] > -1) {
    return dp[n][w];
  }

  ll res = func(n - 1, w);
  if(w - v[n - 1][0] >= 0) {
    res = max(res, v[n - 1][1] + func(n - 1, w - v[n - 1][0]));
  }
  return dp[n][w] = res;
}

int main()
{
  ifalse;
  int n, w;
  cin >> n >> w;
  v.assign(n, vector < ll > (2, 0));
  cin >> v;

  memset(dp, -1, sizeof(dp));
  cout << func(n, w);
  return 0;
}

Measured memory_bytes: 79232
#pragma GCC optimize("O3")
#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>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    priority_queue<double, vector<double>, greater<double>> que;
    for(int i=0; i<n; i++){
        double a; cin>>a;
        que.emplace(a);
    }

    while(que.size() != 1){
        double v1 = que.top(); que.pop();
        double v2 = que.top(); que.pop();

        que.emplace(1. * (v1 + v2) / 2);
    }

    printf("%.10f\n", que.top());
}

Measured memory_bytes: 256
type bs_tree = Nil | Node of node and
     node = {
         key:int;
         mutable left:bs_tree;
         mutable right:bs_tree
       };;

let new_node key = {key=key;left=Nil;right=Nil};;

let insert t z =
  let rec loop y = function
      Nil -> y
    | Node x ->
       if z.key < x.key then
         loop (Node x) (x.left)
       else
         loop (Node x) (x.right)
  in
  let y = loop t t in
  match y with
    Nil -> (Node z)
  | Node y ->
     if z.key < y.key then
       y.left <- (Node z)
     else
       y.right <- (Node z)
    ;t
;;

let rec print_in = function
    Nil -> ()
  | Node x ->
     print_in (x.left);
     Printf.printf " %d" x.key;
     print_in (x.right)
;;

let rec print_pre = function
    Nil -> ()
  | Node x ->
     Printf.printf " %d" x.key;
     print_pre (x.left);print_pre (x.right)
;;

let () =
  let n = read_int () in
  let rec read t = function
      0 -> ()
    | i ->
       let com = Scanf.scanf "%s" (fun x -> x) in
       if com = "insert" then begin
           let arg = Scanf.scanf " %d\n" (fun x -> x) in
           let z = new_node arg in
           read (insert t z) (i-1)
         end
       else if com = "print" then begin
           let _ = Scanf.scanf "%s\n" (fun x -> x) in
           print_in t;print_newline ();
           print_pre t;print_newline ();
           read t (i-1)
         end
       else ()
  in read Nil n
;;

Measured memory_bytes: 28304
import numpy as np
 
s = input()
p = np.array([0]*13)
p[0] = 1
 
amari = [[0]*13 for _ in range(13)]
for j in range(10):
  for i in range(13):
    amari[i][(i*10+j)%13] += 1
M = np.array(amari)
 
for si in range(len(s)):
  a = np.array([0]*13)
  if s[si] == '?':
    a = np.dot(p,M)
  else:
    c = int(s[si])
    for i in range(13):
      a[(i*10+c)%13] += p[i]
  p = np.mod(a,1000000007)
print(p[5])

Measured memory_bytes: 12712
n, m = map(int, input().split())
a = list(map(int, input().split()))

d = [2,5,5,4,5,6,3,7,6]
a.sort()
dic = {}
for ai in a:
    dic[d[ai-1]] = ai

dp = [""] + ["0"] * n
for i in range(n + 1):
    for j, k in dic.items():
        if i - j >= 0 and dp[i - j] != '0':
            temp = str(k) + dp[i - j]
            if len(temp) >= len(dp[i]) and temp > dp[i]:
                dp[i] = temp
                
print(dp[-1])

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

int main() {
  char c;
  cin >> c;
  if (c=='a' || c=='i' || c=='u' || c=='e' || c=='o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 384
X = int(input())

i = X

while 1:
    if i == 2:
        print(2)
        exit()
    if i % 2 == 0:
        pass
    else:
        for j in range(2, i):
            if i % j == 0:
                break

            if j == i-1:
                print(i)
                exit()
    i += 1

Measured memory_bytes: 2940
S = input()
l = set(list(S))
l = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'} - l
l = list(l)
l.sort()
print(l[0] if(len(l)) else "None" )


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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i++)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

//library----------------------------------------------


signed main(){
    CIN(N);
    vi v(N);
    rep(i,N)cin>>v[i];
    sort(all(v),greater<int>());
    int big = INF,count=0;
    rep(i,N){
        if(big>v[i]){
            big=v[i];
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}

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

#define int long long
#define pb push_back
#define ff first
#define ss second

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n;
    cin>>n;
    
    string ans;
    while(n)
    {
        ans.pb((n-1)%26+'a');
        n=(n-1)/26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ls (o << 1)
#define rs (o << 1 | 1)
#define mid ((L + R) >> 1)
using namespace std;
typedef long long LL;
const int N = 200500;
const int mod = 998244353;
int main() {
#ifdef TEST
	freopen("input.txt", "r", stdin);
#endif
	int n, pre, t;
	scanf("%d%d%d", &n, &t, &pre);
	LL ans = t;
	for (int i = 1, u; i < n; ++i) {
		scanf("%d", &u);
		ans += min(pre + t, u) - pre;
		pre = u;
	}
	cout << ans << endl;
	return 0;
}

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

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

    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    
    sort(h.begin(), h.end());
    int ans = 1000000000;
    for (int i = 0; i < N - K + 1; i++) {
        ans = min(ans, h[i + K - 1] - h[i]);
    }
    cout << ans << endl;
}

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

double dp[310][310][310];

signed main() {
	int n;
	cin >> n;
	int a=0;
	int b=0;
	int c=0;
	int arr[n];
	for(int i=0;i<n;i++){
		cin >> arr[i];
		if(arr[i]==1){
			a++;
		}
		else if(arr[i]==2){
			b++;
		}
		else if(arr[i]==3){
			c++;
		}
	}
	dp[0][0][0]=0.0L;
	for(int k=0;k<=n;k++){
		for(int j=0;j<=n;j++){
			for(int i=0;i<=n;i++){
				if(i+j+k==0){
					continue;
				}
				if(i>0){
					dp[i][j][k]+=(double)i*(dp[i-1][j][k])/(double)(i+j+k);
				}
				if(j>0){
					dp[i][j][k]+=((double)j*dp[i+1][j-1][k] )/(double)(i+j+k);
				}
				if(k>0){
					dp[i][j][k]+=( (double)k*dp[i][j+1][k-1])/(double)(i+j+k);
				}
				if(i+j+k!=0){
					dp[i][j][k]+=(double)n/(double)(i+j+k);
				}
			}
		}
	}
	cout.precision(17);
	cout << fixed << dp[a][b][c];
	// your code goes here
	return 0;
}

Measured memory_bytes: 452864
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, m; cin >> n >> m;
    vll h(n); rep(i, n) cin >> h[i];
    vll highest(n, 0);
    rep(i, m) {
        ll a, b; cin >> a >> b; a--, b--;
        highest[a] = max(highest[a], h[b]);
        highest[b] = max(highest[b], h[a]);
    }

    ll c = 0;
    rep(i, n) {
        if (h[i] > highest[i]) c++;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 4832
#include <stdio.h>

int main(){
	int a,b,c,h;
	scanf("%d %d %d",&a,&b,&c);
	if(a > b){   //一番目と二番目を比較
		h = a;
		a = b;
		b = h;
	}
	if(b > c){   //二番目と三番目を比較
		h = b;
		b = c;
		c = h;
	}
	if(a > b){   //二番目と三番目の大きかった方と一番目の数字を比較
		h = a;
		a = b;
		b = h;
	}
	printf("%d %d %d\n",a,b,c);
	
	return 0;
}	


Measured memory_bytes: 2104
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import static java.util.stream.Collectors.toList;

public class Main{
    private static final BigDecimal CONVERSION = new BigDecimal("0.006");

    public static int process(TestCase testCase) {
        int N = testCase.N;
        int T = testCase.T;
        int A = testCase.A;
        List<Integer> H = testCase.H;

        final List<BigDecimal> diffs = H.stream().map(x -> asTemperature(x, T)).map(t -> asDiff(t, A)).collect(toList());

        int minIndex = 0;
        for (int i = 1, length = H.size(); i < length; ++i) {
            final BigDecimal minDiff = diffs.get(minIndex);
            final BigDecimal diff = diffs.get(i);
            final boolean isCloser = diff.compareTo(minDiff) < 0;
            if (isCloser) {
                minIndex = i;
            }
        }

        return minIndex + 1;
    }

    private static BigDecimal asTemperature(int x, int t) {
        return BigDecimal.valueOf(t).subtract(CONVERSION.multiply(BigDecimal.valueOf(x)));
    }

    private static BigDecimal asDiff(BigDecimal t, int a) {
        return t.subtract(BigDecimal.valueOf(a)).abs();
    }

    private static boolean is753(int x) {
        return x == 7 || x == 5 || x == 3;
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final int result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int T = sc.nextInt();
        int A = sc.nextInt();

        List<Integer> H = new ArrayList<>();
        for (int i = 0; i < N; ++i) {
            H.add(sc.nextInt());
        }

        sc.close();
        return new TestCase(N, T, A, H);
    }

    private static void output(int result) {
        System.out.println(result);
    }

    public static class TestCase {
        final int N;
        final int T;
        final int A;
        final List<Integer> H;

        public TestCase(int N, int T, int A, List<Integer> H) {
            this.N = N;
            this.T = T;
            this.A = A;
            this.H = H;
        }
    }
}


Measured memory_bytes: 28492
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
using namespace std;
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);

  int ans = 0;
  for(int i=0;i<n;i++) {
    ll tmp;
    cin >> tmp;
    while(tmp % 2 == 0) {
      ans++;
      tmp /= 2;
    }
  }

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


Measured memory_bytes: 384
#include <bits/stdc++.h>  // ver2.2.2
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){Vout(a[lY]);}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
void uniq(Vi &v){sort(ALL(v)); v.erase(unique(ALL(v)),v.end());}  //  uniqのやつ

int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}

string sreplace(string s,string t,string u){
  string::size_type Pos(s.find(t));
  while(Pos!=string::npos){
    s.replace(Pos,t.length(),u);
    Pos = s.find(t,Pos+u.length());
  }
  return s;
}

signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  string s;
  cin >> s;
  s = sreplace(s,"BC","X");
  
  int l = s.size(),ans=0,now=0;
  
  rep(i,0,l){
    if(s[i]=='A') now++;
    else if(s[i]=='X') ans+=now;
    else now = 0;
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;

int main(void) {
  int n;
  cin >> n;
  int a, b, c, d;
  d = n % 10;
  n /= 10;
  c = n % 10;
  n /= 10;
  b = n % 10;
  n /= 10;
  a = n % 10;
  if (a+b+c+d==7) printf("%d+%d+%d+%d=7", a, b, c, d);
  else if (a-b+c+d==7) printf("%d-%d+%d+%d=7", a, b, c, d);
  else if (a+b-c+d==7) printf("%d+%d-%d+%d=7", a, b, c, d);
  else if (a-b-c+d==7) printf("%d-%d-%d+%d=7", a, b, c, d);
  else if (a+b+c-d==7) printf("%d+%d+%d-%d=7", a, b, c, d);
  else if (a-b+c-d==7) printf("%d-%d+%d-%d=7", a, b, c, d);
  else if (a+b-c-d==7) printf("%d+%d-%d-%d=7", a, b, c, d);
  else if (a-b-c-d==7) printf("%d-%d-%d-%d=7", a, b, c, d);
  printf("\n");
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
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;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vi a(n); for(auto& e : a) cin >> e, e--;

    int res = 0;
    int i = 0;
    while(i != 1 and a[i] >= 0){
        int ni = a[i];
        a[i] = -1;
        i = ni;
        res++;
    }

    if(i != 1) res = -1;
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 640
#Trained?
N = int(input())
a = [int(input()) for _ in range(N)]

now = 1
L = [0]*N
for i in range(N):
    L[i] = now
    now = a[now-1]

judge = 1
for i in range(N):
    if L[i] == 2:
        print(i)
        judge = 0
        break
    else:
        pass

if judge == 1:
    print(-1)

Measured memory_bytes: 7852
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());

        int result = b / a;
        if (result > c) {
            result = c;
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans = max(max(10 * a + b + c, 10 * b + a + c), 10 * c + a + b);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, raw_input().split())
V = map(int, raw_input().split())
achievable = 0
for i in range(1, k+1):
    #print "i=" + str(i)
    for l in range(-1, i):
        if l > n :
            break
        #print "l=" + str(l)
        candid = 0
        fail = False
        kr = k - i
        subV = V[0:l+1]
        negatives = [x for x in subV if x < 0]
        #print "kr=" + str(kr)
        if l == -1:
            pass
        else:
            candid += sum(subV)
            #print subV
        for r in range(n-1, n-i+l, -1):
            if l >= r:
                fail = True
                break
            candid += V[r]
            #print V[r]
            if V[r] < 0:
                negatives.append(V[r])
        if fail:
            continue
        negatives.sort(reverse=True)
        while len(negatives) > 0 and kr > 0:
            candid -= negatives.pop()
            kr -= 1
        achievable = max(achievable, candid)
print achievable

Measured memory_bytes: 2820
# Contest No.: M-SOLUTIONS Programming Contest 2020
# Problem No.: A
# Solver:      JEMINI
# Date:        20200725

import sys
import heapq

def main():
    n = int(input())
    if 400 <= n < 600:
        print(8)
    elif 600 <= n < 800:
        print(7)
    elif 800 <= n < 1000:
        print(6)
    elif 1000 <= n < 1200:
        print(5)
    elif 1200 <= n < 1400:
        print(4)
    elif 1400 <= n < 1600:
        print(3)
    elif 1600 <= n < 1800:
        print(2)
    elif 1800 <= n < 2000:
        print(1)
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 62260
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

void Main() {
    // input
    u_int64_t N;
    cin >> N;
    // R…RW…W となるように
    vector<char> stones(N);
    for (u_int64_t i = 0; i < N; i++) {
        cin >> stones[i];
    }

    // process
    u_int64_t red_count = 0;
    for (u_int64_t i = 0; i < N; i++) {
        if (stones[i] == 'R') {
            red_count++;
        }
    }

    u_int64_t count = 0;
    for (u_int64_t i = 0; i < red_count; i++) {
        if (stones[i] == 'R') {
            count++;
        }
    }

    // output
    cout << red_count - count << endl;


}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const lli inf = 1e18;

int main(){
    int w,h;
    cin >> w >> h;
    int n;
    cin >> n;
    vector<lli> x(n),y(n);
    for(int i=0; i<n; i++){
        cin >> x[i] >> y[i];
    }
    vector<lli> sx=x, sy=y; // sorted
    sort(sx.begin(), sx.end());
    sort(sy.begin(), sy.end());
    lli ans_cost=inf, ans_x, ans_y;
    for(int i=(n-1)/2; i<=n/2; i++){
        for(int j=(n-1)/2; j<=n/2; j++){
            lli xx=sx[i], yy=sy[j];
            lli sub = 0;
            lli maxd = 0;
            for(int k=0; k<n; k++){
                lli d = abs(xx -x[k]) +abs(yy -y[k]);
                maxd = max(maxd, d);
                sub += 2*d;
            }
            sub -= maxd;
            if(sub < ans_cost){
                ans_cost = sub;
                ans_x = xx;
                ans_y = yy;
            }
        }
    }
    cout << ans_cost << endl;
    cout << ans_x << " " << ans_y << endl;
    return 0;
}



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

int main() {
  int n;
  cin >> n;
  int ans = 1;
  
  while (true) {
    if (ans * 2 <= n) {
      ans *= 2;
    } else {
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
template <class T>inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<long long, long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

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

int main() {
    int N;
    cin >> N;
    vecl A(N),B(N);
    REP(i,N) cin >> A[i];
    B = A;
    reverse(B.begin(),B.end());
    vecl R(N+1),L(N+1);
    REP(i,N) {
        R[i+1] = gcd(R[i],A[i]);
        L[i+1] = gcd(L[i],B[i]);
    }
    ll ans = 0;
    REP(i,N) {
        chmax(ans,gcd(L[i],R[N-1-i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 6432
def f(x):
    div = 1
    while div * div <= x:
        if x % div == 0:
            for a in range(0, int((x // div) ** 0.25) + 2):
                b = a - div
                if a ** 5 - b ** 5 == x:
                    return a, b

            opp_div = x // div
            for a in range(0, int((x // opp_div) ** 0.25) + 2):
                b = a - opp_div
                if a ** 5 - b ** 5 == x:
                    return a, b
        div += 1


def main():
    x = int(input())
    a, b = f(x)
    print(a, b)


main()


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

public class Hello{
    public static void Main(){
        var input = Console.ReadLine().Split().Select(x => Int32.Parse(x)).ToList();
        var n = input[0];
        var m = input[1];
        
        var graf = new List<List<int>> ();
        var sign = new List<int>();
        
        for(var i = 0; i < n; ++i){
            graf.Add(new List<int>());
            sign.Add(-1);
        }
        
        for(var i = 0; i < m; ++i){
            input = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToList();
            graf[input[0] - 1].Add(input[1] - 1);
            graf[input[1] - 1].Add(input[0] - 1);
        }

        var que = new Queue<int>();
        sign[0] = 0;
        
        que.Enqueue(0);

        while(0 < que.Count){
            var room = que.Dequeue();
            foreach(var next in graf[room]){
                if(sign[next] < 0){
                    sign[next] = room;
                    que.Enqueue(next);
                }
            }
        }

        if (sign.All(x => 0 <= x)){
            Console.WriteLine("Yes");
            var j = 0;
            foreach(var i in sign){
                if(j++ != 0) Console.WriteLine(i + 1);
                
            }
        } else {
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 52632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int[] heights = new int[N + 1];
        for (int i = 0; i < N; i++) heights[i] = in.nextInt();
        heights[N] = Integer.MAX_VALUE;

        int res = 0, i = 0, j = 1;
        while(j < N + 1) {
            if (heights[j] <= heights[j - 1]) {
                j++;
            } else {
                res = Math.max(res, j - i - 1);
                i = j;
                j++;
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 49944
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
void solve()
{
   ll h,n;
   cin>>h>>n;
   vector<ll> a(n);
   ll i,j,k,sum=0;
   for(i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
   }
   if(sum>=h)
        cout<<"Yes";
    else 
        cout<<"No";
}
int main() {
	ll t;
// 	cin>>t;
// 	while(t--)
	    solve();
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void) {
	int a, b, t=0,i=0;
	do {
		scanf("%d%d", &a, &b);
	} while ((a < 3 || 20 < a) || (b < 3 || 20 < b));

	while (i < 2) {
		if (a <= b) {
			t = t + b;
			b--;
		}
		else {
			t = t + a;
			a--;
		}
		i++;
	}
		printf("%d", t);
		return 0;
}

Measured memory_bytes: 128
N, M, K = list(map(int, input().split()))

k = 0
flag = False
for i in range(N+1):
  for j in range(M+1):
    k = (N-i) * j + (M-j) * i
    if k == K:
      flag = True
      break
  if flag:
    break

if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 40428
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

ll pow_mod(ll x, ll n) {
	ll ans = 1;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x % MOD;
		}
		x = x * x % MOD;
		n = (n >> 1);
	}
	return ans;
}

vector<ll> factrial;
vector<ll> inverse;
ll comb_fermat(int n, int k) {
	// 階乗とその逆元を計算
	factrial[0] = 1;
	inverse[0] = 1;
	for (int i = 1; i <= n; i++) {
		factrial[i] = factrial[i - 1] * i % MOD;
		inverse[i] = inverse[i - 1] * pow_mod(i, MOD - 2) % MOD;
	}
	return factrial[n] % MOD * inverse[k] % MOD * inverse[n - k] % MOD;
}

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int N, K;
	cin >> N >> K;

	vector<int> A(N);
	for (auto &&i : A) {
		cin >> i;
	}

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

	factrial.resize(N + 1);
	inverse.resize(N + 1);
	comb_fermat(N, K);

	ll sum_max = 0;
	for (int i = K - 1; i < N; i++) {
		sum_max += (ll)A[i] % MOD * factrial[i] % MOD * inverse[K - 1] % MOD * inverse[i - K + 1] % MOD;
		sum_max %= MOD;
	}
	// cout << sum_max << endl;
	ll sum_min = 0;
	for (int i = 0; i < N - K + 1; i++) {
		sum_min += (ll)A[i] % MOD * factrial[N - 1 - i] % MOD * inverse[K - 1] % MOD * inverse[N - K - i] % MOD;
		sum_min %= MOD;
	}
	// cout << sum_min << endl;
	ll ans = sum_max - sum_min;
	if(ans < 0) {
		ans += MOD;
	}
	cout << ans % MOD << endl;

	return 0;
}


Measured memory_bytes: 2176
import java.io.*;
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main
{	
	public static void main(String []args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		
		String []s=br.readLine().split(" ");
		
		int X=Integer.parseInt(s[0]);
		int Y=Integer.parseInt(s[1]);
		
		String ans="Yes";
		
		if(Y<2*X || Y>4*X || (Y&1)==1)
			ans="No";
		
		out.println(ans);
		
	}
	
	
}




Measured memory_bytes: 32548
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
puts A[gets.to_i - 1]


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
int main(){
    string s;cin >> s;
    int n=s.size();
    string ans="";
    for(int i=0; i<n; i++) ans=ans+'x';
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

using ll = long long;

ll mod_pow(ll x, ll p, ll MOD) {
    ll a = 1;
    while (p) {
        if (p % 2) a = a * x % MOD;
        x = x * x % MOD;
        p /= 2;
    }
    return a;
}

// mod_inverse
ll mod_inverse(ll a, ll m) {
    return mod_pow(a, m - 2, m);
}

const int MOD = 1e9 + 7;

const int MAX = 333333;
ll fact[MAX], rfact[MAX];

ll nCr(int n, int r) {
    return fact[n] * rfact[r] % MOD * rfact[n - r] % MOD;
}

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    fact[0] = rfact[0] = 1;
    for (int i = 1; i < MAX; i++) {
        fact[i] = (fact[i - 1] * i) % MOD;
        rfact[i] = mod_inverse(fact[i], MOD);
    }
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    ll ans = 0;
    for (int i = B + 1; i <= W; i++) {
        int h = H - A - 1, w = i - 1;
        ll tmp = nCr(h + w, h);
        h = A - 1, w = W - i;
        tmp *= nCr(h + w, w);
        ans += tmp % MOD;
    }
    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 5504
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#include <bitset>
#include <complex>
#include <cassert>
#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)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define GLL(i) (scanf("%lld",&i))
#define GD(i)  (scanf("%lf",&i))
#define PB          push_back
#define MP          make_pair
#define MT          make_tuple
#define GET0(x)     (get<0>(x))
#define GET1(x)     (get<1>(x))
#define GET2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       (1LL<<60)
#define LLMIN       -(1LL<<60)
#define IMAX        (1<<30)
#define IMIN        -(1<<30)
typedef long long LL;
using namespace std;

int N,C;
int cost_sum[3][30],D[30][30],c[500][500];

int main(void){
    GI(N);GI(C);
    REP(i,C)REP(j,C)GI(D[i][j]);
    REP(i,N)REP(j,N){GI(c[i][j]);c[i][j]--;}
    REP(i,3)REP(j,C)REP(k,N)REP(l,N){
        if(i == (k+l)%3)
            cost_sum[i][j] += D[c[k][l]][j];
    }
    int ans = IMAX;
    REP(i,C)REP(j,C)REP(k,C){
        if(i!=j && j!=k && k!=i)
            ans = min(ans, cost_sum[0][i] + cost_sum[1][j] + cost_sum[2][k]);
    }
    printf("%d\n",ans);
    return 0;
}


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


vector<int> A;
vector<int> B;
vector<int> C;
vector<int> D;
ll MAX = 0;
int M, S, Q;
vector<int> P;
void solve(int i){
    if(i == S){
        ll m = 0;
        for(int j=0;j<Q;j++){
            if(P[B[j]-1] - P[A[j]-1] == C[j]){
                m += D[j];
            }
        }
        if (m>MAX){
            MAX = m;
        }
        return;
    }
    // decide the [i]
    int mini = 1;
    if (i!=0){
        mini = P[i-1];
    }
    for(int j=mini;j<=M;j++){
        P[i] = j;
        solve(i+1);
    }
}

int main() {
    int N;
    cin >> N >> M >> Q;
    vector<int> a(Q);
    vector<int> b(Q);
    vector<int> c(Q);
    vector<int> d(Q);
    for(int i=0;i<Q;i++){
        cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    }
    A = a;
    B = b;
    C = c;
    D = d;
    vector<int> p(N);
    P = p;
    S = p.size();
    solve(0);
    cout << MAX << endl;
    return 0;
}

Measured memory_bytes: 3636
s=list(input())
a=len(s)
l=[0]*a
t=0
for i in range(a):
  if s[i]=="A" or s[i]=="T" or s[i]=="G" or s[i]=="C":
    t+=1
    l[i]=t
  else:
    t=0
print(max(l))

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

using namespace std;

const double pi=3.1415926; 

const int N=2e5+10;

int a[N];

int main()
{
	int n;
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int k;
		cin>>k;
		a[k]++;
	}
	for(int i=1;i<=n;i++) cout<<a[i]<<'\n';
 	return 0;
} 

Measured memory_bytes: 4348
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if(s*t >= d) cout << "Yes" << endl;
  else cout << "No" << endl;
return 0;
}

Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int main()
{ 
  int h,a,n,s=0;
  cin>>h>>n;
  while(n--)
  {
    cin>>a;
    s+=a;
  }
  if(s>=h)
    cout<<"Yes";
  else cout<<"No";
  return 0;
}
  


Measured memory_bytes: 256
S = input()
ans = 'AC'

# 1文字目が'A'
if S[0] != 'A':
	ans = 'WA'

# 3文字目-末尾2文字目にCが1つ含まれる
s1 = S[2:-1]
if s1.count('C') != 1:
	ans = 'WA'

# 1文字目の'A'、3-末尾2文字目の'C'以外は小文字
s2 = S[1:].replace('C', '')
s2_lower = s2.lower()
if (s2 != s2_lower) or S.count('C') != 1:
	ans = 'WA'

print(ans)

Measured memory_bytes: 3064
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

immutable long mod = 10^^9 + 7;
alias Pair = Tuple!(int, "l", int, "x");

void main(){
    int N, M;
    int li, ri, xi;
    readVars(N, M);

    auto cond = new Pair[][](N + 1);

    foreach(i ; 0 .. M){
        readVars(li, ri, xi);
        cond[ri] ~= Pair(li, xi);
    }

    //writeln(cond);

    auto dp = new int[][][](N + 1, N + 1, N + 1);
    dp[0][0][0] = 1;

    int k, v, ans;

    foreach(r ; 0 .. N + 1){
        foreach(g ; 0 .. N + 1){
            foreach(b ; 0 .. N + 1){
                if (!dp[r][g][b]) {
                    continue;
                }

                k = max(r, g, b);
                bool flag;

                foreach(c ; cond[k]){
                    v = (c.l <= r) + (c.l <= g) + (c.l <= b);

                    if (v != c.x) {
                        flag = true;
                        break;
                    }
                }

                if (flag) {
                    dp[r][g][b] = 0;
                    continue;
                }

                if (k == N) {
                    (ans += dp[r][g][b]) %= mod;
                    continue;
                }

                dp[k + 1][g][b] = (dp[k + 1][g][b] + dp[r][g][b]) % mod;
                dp[r][k + 1][b] = (dp[r][k + 1][b] + dp[r][g][b]) % mod;
                dp[r][g][k + 1] = (dp[r][g][k + 1] + dp[r][g][b]) % mod;
            }
        }
    }

    writeln(ans);

}

void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}

Measured memory_bytes: 193404
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  int l[N];
  for(int i = 0; i < N; i++){
    cin >> l[i] ;
  }
  sort(l,l+N,greater<int>());
  int ans = 0;
  for(int i = 0; i < K; i++) ans += l[i];
  cout << ans << endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{a:[i64;4], n:i64};
    let mut a = a;
    a[0] *= 4;
    a[1] *= 2;
    //debug!(a);
    let b:i64 = a[3];
    let a:i64 = min(a[0],min(a[1],a[2]));
    //debug!(a,b);
    if n%2==0 {
        println!("{}", min(a*n, b*n/2));
    } else {
        println!("{}", min(a*n, b*(n/2)+a));
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int which_group(int n) {
	if (n == 2) {
		return 2;
	}
	else if (n == 4 || n == 6 || n == 9 || n == 11) {
		return 1;
	}
	return 0;
}

int main(void)
{

	int x, y;
	cin >> x >> y;

    if (which_group(x) == which_group(y)) {
    	printf("Yes\n");
    }
    else {
    	printf("No\n");
    }

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
typedef long long LL;
const LL N = 2005;
const LL M = 400005;

vector <LL> G[N];
LL vis[2][N][N],p[2][N];
LL eu[M],ev[M],n,m;

void dfs_vis(LL u,LL rt){
	vis[0][rt][u] = 1;
	for(LL i = 0;i < G[u].size();i ++){
		LL v = G[u][i];
		if(vis[0][rt][v]) continue;
		dfs_vis(v,rt);
	}
}

void get_vis(){
	for(LL i = 1;i <= n;i ++){
		dfs_vis(i,i);
	}
}

void dfs_sol(LL u,LL col,LL pid,LL rt){
	p[pid][u] = col;
	for(LL i = 0;i < G[u].size();i ++){
		LL v = G[u][i];
		if(p[pid][v]) continue;
		dfs_sol(v,col,pid,rt);
	}
}

void solve(LL u){
	memset(p,0,sizeof(p)); p[0][u] = 1; p[1][u] = 1;
	for(LL i = 0;i < G[u].size();i ++) if(!p[0][G[u][i]]) dfs_sol(G[u][i],i + 1,0,u);
	for(LL i = (LL)(G[u].size()) - 1;i >= 0;i --) if(!p[1][G[u][i]]) dfs_sol(G[u][i],i + 1,1,u);
	for(LL i = 1;i <= n;i ++) if(p[0][i] != p[1][i]) vis[1][u][i] = 1;
}

int main(){
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for(LL i = 1;i <= m;i ++){
		cin >> eu[i] >> ev[i];
		G[eu[i]].push_back(ev[i]);
	}
	get_vis();
	for(LL i = 1;i <= n;i ++) solve(i);
	for(LL i = 1;i <= m;i ++) cout << ((vis[0][ev[i]][eu[i]] ^ vis[1][eu[i]][ev[i]]) ? "diff" : "same") << '\n';
	return 0;
}

Measured memory_bytes: 44800
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,a,m,i,h;
    cin>>n>>k;
	cin>>a;
    h=a;
    for(i=2;i<=n;i++){
    cin>>m;
    a=__gcd(a,m);
    h=max(m,h);
    }
    if(k%a==0 && k<=h){
    cout<<"POSSIBLE"<<endl;
    }
    else{
    cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}

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

int main(){
	ll mod=1000000007;
	ll n, i, ans=1;
	cin>>n;
	for(i=1; i<=n; i++){
		ans=ans*i%mod;
	}
	cout<<ans<<endl;
	return 0;
}


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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define YN(y, n, b) (b? y : n)
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 N;
    f64 D;
    cin >> N >> D;
    i32 sum = 0;
    for (i32 i = 0; i < N; i++) {
        i64 X, Y;
        cin >> X >> Y;
        if (sqrt(X * X + Y * Y) <= D) sum++;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3764
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = 0
for i in range(n):
    mi = a[i] - b[i]
    ans += min(b[i], a[i]+a[i+1])
    if mi < 0:
        a[i+1] += mi
        if a[i+1] < 0:
            a[i+1] = 0
print(ans)

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

int main() 
{
    int n;
    cin >> n;
    int dp[n+1][3];
    dp[0][0]=0;
    dp[0][1]=0;
    dp[0][2]=0;
    for(int i=1;i<=n;i++)
    {
        int a,b,c;
        cin >> a >> b >> c;
        dp[i][0]=max(dp[i-1][1] + a , dp[i-1][2] + a);
        dp[i][1] = max(dp[i-1][0] + b,dp[i-1][2] + b);
        dp[i][2]=max(dp[i-1][0] + c,dp[i-1][1] + c);
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
	return 0;
}


Measured memory_bytes: 1408