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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)
    x=x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right!=NIL)
    x=x->right;
  return x;
}

Node treeSearch(Node u, int k){
while(u!=NIL && k!=u->key){
    if(k<u->key) u=u->left;
    else u=u->right;         }
  return u;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL)
    return treeMinimum(x->right);

  y=x->parent;
  while(y!=NIL && x==y->right)
    {x=y;
      y=y->parent;}
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left == NIL || z->right == NIL)y=z;
  else y=treeSuccessor(z);
  }
  
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL)
    {y=x;
      if(z->key < x->key) x=x->left;
      else x=x->right;  }
  z->parent = y;
  if(y==NIL) root=z;
  else
    { if(z->key < y->key)y->left=z;
      else y->right=z;
    }
}

void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25212
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX



 
void solve()
{
   int a,b;
   cin >> a >> b;
   cout << max({a*b, a-b, a+b}) << endl;
}


signed main()
{
    
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

// 入力

int main(){
  string S,T; cin >> S >> T;
  int s = S.size(), t = T.size();

  vector<string> v;
  for (int i = 0; i+t <= s; i++) {
    string tmp = S.substr(i,t);
    bool ok = true;
    rep(j, t) if(tmp[j] != T[j] && tmp[j] != '?') ok = false;
    if(ok){
      string ans = S.substr(0,i) + T + S.substr(i+t);
      rep(k, s) if(ans[k] == '?') ans[k] = 'a';
      v.pb(ans);
    }
  }
  //for(auto aa : v) std::cout << aa << '\n';

  if(v.empty()){
    std::cout << "UNRESTORABLE" << '\n';
    return 0;
  }

  sort(all(v));
  std::cout << v[0] << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define nl cout<<"\n"
#define pb push_back
#define se second
#define fi first
#define int long long 
#define pi pair<int,int>
#define vpi vector<pi>
#define vvi vector<vpi>
#define For(i,n) for(int i=0;i<n;i++)
#define Forn(i,a,n) for(int i=a;i<n;i++)
#define pie =3.14159265358979323846264338327950;
const int mod= 1e9+7;


int32_t main(){
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
	int n,m;
	cin>>n>>m;
	char ar[n][m];
	For(i,n)For(j,m) cin>>ar[i][j];
	int dp[n][m];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<n;i++){
		if(ar[i][0]=='.'){
			dp[i][0]=1;
		}
		else break;
	}
	for(int i=0;i<m;i++){
		if(ar[0][i]=='.'){
			dp[0][i]=1;
		}
		else break;
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<m;j++){
			if(ar[i][j]=='.'){
				dp[i][j]= dp[i-1][j]+dp[i][j-1];
				dp[i][j]%=mod;
			}
			else{
				dp[i][j]=0;
			}
		}
	}
	//for(int i=0;i<n;i++){
		//for(int j=0;j<m;j++){
			//cout<<dp[i][j]<<" ";
		//}
		//cout<<endl;
	//}
	cout<<dp[n-1][m-1]<<endl;
	return 0;
}


Measured memory_bytes: 12452
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)
 
 
 
int main(){
    
    string s;
    int l;
    ll tmp,sum=0;
    
    cin>>s;
    l=s.size();
    rep(i,0,l){
        rep(j,0,l-i){
            if(i==l-1){
                tmp=0;
                rep(k,0,l){
                    tmp*=10;
                    tmp+=s[j+k]-'0';
                }
                sum+=tmp;
            }
            else{
                tmp=0;
                rep(k,0,i+1){
                    tmp*=10;
                    tmp+=s[j+k]-'0';
                }
                if(j==0||j==l-i-1){
                    sum+=tmp*pow(2,l-i-2);
                }
                else{
                    sum+=tmp*pow(2,l-i-3);
                }
            }
        }
    }
    cout<<sum<<endl;
    
    return 0;
}

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

vector<string> clearRows(vector<string> v) {
	vector<string> ans;

	for (int i = 0; i < v.size(); i++) {
		bool to_delete = true;
		auto it = find(v[i].begin(), v[i].end(), '#');
		if (it != v[i].end()) to_delete = false;
		if (!to_delete) ans.push_back(v[i]);
	}

	return ans;
} 

vector<string> leftMove(vector<string> v) {
	int len = v.empty() ? 0 : v[0].size();
	vector<string> ans(len);

	for (int i = 0; i < v.size(); i++) {
		for (int j = v[i].length() - 1; j >= 0; j--) {
			ans[len - j - 1].push_back(v[i][j]);
		}
	}

	return ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	for (auto& e : s)
		cin >> e;

	s = clearRows(s);
	s = leftMove(s);
	s = clearRows(s);
	s = leftMove(s);
	s = leftMove(s);
	s = leftMove(s);

	for (auto e : s) {
		for (auto c : e) {
			cout << c;
		}
		cout << "\n";
	}

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n, m; cin >> n >> m;
    vector<vector<bool>> g(n, vector<bool> (m,false));

    rep(i,m){
        int k; cin >> k;
        rep(_,k){
            int s; cin >> s; s--;
            g[s][i] = true;
        }
    }

    vector<int> p(m); rep(i,m) cin >> p[i];
    ll ans = 0;

    for(int bit = 0; bit < (1 << n); bit++){
        vector<int> tmp(m,0);

        rep(i,n){
            if(bit & (1 << i)){
                rep(j,m) if(g[i][j]) tmp[j] ^=1; 
            }
        }
        
        bool jud = true;
        rep(i,m){
            if(p[i] != tmp[i]) jud = false;
        }

        if(jud) ans++;

    }

    cout << ans << endl;
}



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

using namespace std;

#define MOD 1000000007
#define N 403
#define M 30
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

ll pre[N], dp[N][N];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, i, j, l, r, sz, ai;
    cin>>n;
    for(i=1; i<=n; i++){
        cin>>ai;
        pre[i] = pre[i-1] + ai;
    }
    for(l=1; l<=n; l++){
        for(r=1; r<=n; r++){
            if(l == r) dp[l][r] = 0;
            else dp[l][r] = LLONG_MAX;
        }
    }
    for(sz=2; sz<=n; sz++){
        for(i=1; i<=n; i++){
            l = i; r = min(n, (i + sz - 1));
            for(j=l; j<r; j++){
                dp[l][r] = min(dp[l][r], dp[l][j] + dp[j+1][r] + pre[r] - pre[l-1]);
            }
        }
    }
    cout<<dp[1][n];
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> using hset = unordered_set<T>;
template<class Key, class T> using hmap = unordered_map<Key, T>;

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

int main() {
    int n, cnt;
    string s0, s1;
    while (cin >> n) {
        if (n == 0) continue;

        cnt = 0;
        cin >> s1;
        for (int i=1; i<n; i++) {
            cin >> s0;
            if ((s0[1] == s1[1]) && (s0[0] != s1[0])) cnt++;
            s1 = s0;
        }

        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int a, b;
    string op;
    while (cin >> a >> op >> b) {
        if (op == "?") break;
        if (op == "+") cout << a + b;
        else if (op == "-") cout << a - b;
        else if (op == "*") cout << a * b;
        else cout << a / b;
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3112
#include <stdio.h>
#include <stdlib.h>
#define M 2000001
#define X 10001

int main(){
  unsigned short *A, *B;

  int C[X];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short) * n + 1);
  B = malloc(sizeof(short) * n + 1);

  for ( i = 0; i <= X; i++ ) C[i] = 0;

  for ( i = 0; i < n; i++ ){
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]+=1;
  }

  for ( i = 1; i <= X; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]-=1;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}

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

int main() {
    int A,B,C;
    int K;
    cin >> A >> B >> C >> K;
    int cnt = 1;
    for(int i = 0; i < K; i++) {
        cnt *= 2;
    }
    cout << A+B+C+max(max(A,B),C)*cnt-max(max(A,B),C) << endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


template<class Type>
Type solve(Type res = Type()){
    int N,i; cin >> N >> i;
    res = N- i + 1;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    //test();
    //solve<ll>();
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

using namespace std;

using Pair = pair<int, int>;
using lint = long long;

// const int mod = 1e9 + 7;
// const int mod = 998244353;

template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <class T, class L>
T binarySearch(T ok, T no, L isok, T limit = 1) {
  while (std::abs(ok - no) > limit) {
    T mid = (ok + no) / 2;
    if (isok(mid))
      ok = mid;
    else
      no = mid;
  }
  return ok;
}
int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0;i< n;i++)
    cin >> a[i];
  cout << binarySearch(1000000000, 0, [=](int s) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      cnt += (a[i]+s-1) / s - 1;
    }
    return cnt <= k ? true : false;
  }) << endl;
}


Measured memory_bytes: 4792
import java.util.*;

public class Main{
    private static final Scanner sc = new Scanner(System.in);

    public static void main(String[] args){
        double r =sc.nextDouble();
        double one = r*r*Math.PI;
        double two = 2*r*Math.PI;
        System.out.printf("%f %f\n", one, two);
    }
}


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

char s[105];
ll ans;

int main()
{
	cin>>s;
	for(int i=0;i<strlen(s)/2;i++)
	{
		if(s[i]!=s[strlen(s)-1-i]) ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
package main

import (
	"fmt"

	//	"math"

	"sort"
	"strconv"
)

func stringToint(s string) int {
	i, _ := strconv.ParseInt(s, 10, 64)
	return int(i)
}

func noResult() {
	fmt.Println(0)
}

func main() {
	//	scanner := bufio.NewScanner(os.Stdin)
	//	line := make([]string, 0, 0)
	var n int
	var tmp string
	fmt.Scan(&n)

	data := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&tmp)
		data[i] = stringToint(tmp)
	}

	// for scanner.Scan() && scanner.Text() != "" {
	// 	if scanner.Err() != nil && scanner.Err() == io.EOF {
	// 		break
	// 	}
	// 	line = append(line, scanner.Text())
	// }
	// if len(line) < 2 {
	// 	noResult()
	// 	return
	// }

	// input := strings.Split(line[1], " ")

	// for _, s := range input {
	// 	data = append(data, stringToint(s))
	// }

	// if len(data) != stringToint(line[0]) {
	// 	noResult()
	// 	return
	// }

	sort.Ints(data)
	totalNum := 0

	if len(data)%2 != 0 {
		if data[0] != 0 {
			noResult()
			return
		} else {
			for i := 0; i < (len(data)-1)/2; i++ {
				if !(data[i*2+1] == int((i+1)*2) && data[i*2+2] == int((i+1)*2)) {
					noResult()
					return
				}
			}
			totalNum = (len(data) - 1) / 2
		}
	} else {
		for i := 0; i < len(data)/2; i++ {
			if !(data[i*2] == int((i+1)*2)-1 && data[i*2+1] == int((i+1)*2)-1) {
				noResult()
				return
			}
		}
		totalNum = len(data) / 2
	}

	var remain int
	remain = 1
	for i := 0; i < totalNum; i++ {
		remain = (remain * 2) % 1000000007
	}
	fmt.Println(remain)
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)

int main() {
    ll ans, n;
    ans = 1;
    cin >> n;
    ll a;
    ll MAX = 1e18;
    bool over = false;
    rep(i, n) {
        cin >> a;

        if (a == 0){
            ans = 0;
            break;
        }
        if (over) continue;
        if (a <= MAX/ans) {
            ans *= a;
        }else {
            ans = -1;
            over = true;
        }
    }
    cout << ans << endl;
    return 0;
}



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

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

using namespace std;

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

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

  int res = 1;
  int maxCount = 0;
  for (int i = 1; i <= n; i++) {
    int j = i;
    int count = 0;
    while (j > 0 && j % 2 == 0) {
      j /= 2;
      count++;
    }
    if (count >= maxCount) {
      res = i;
      maxCount = count;
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
const int N=2e5+5;
int n,k,x,i;
char s[N],c;
int main(){
	scanf("%s",s);n=strlen(s);x=1;
	for (i=0;i<n;i++){
		if (s[i]!=x) x=x?s[i]:1,k++;
		else x=0;
	}
	printf("%d",k);
}

Measured memory_bytes: 384
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H1, M1, H2, M2, K = map(int, input().split())

S = H1 * 60 + M1
E = H2 * 60 + M2

print(E - K - S)


Measured memory_bytes: 9168
#include<stdio.h>
#define MAX 10000
#define NIL -1
 
struct Node{int p, l, r;};
struct Node T[MAX];
int n;
 
void preParse(int u){
    if(u == NIL) return;
    printf(" %d",u);
    preParse(T[u].l);
    preParse(T[u].r);
}
 
void inParse(int u){
    if(u == NIL) return;
    inParse(T[u].l);
    printf(" %d",u);
    inParse(T[u].r);
}
 
void postParse(int u){
    if(u == NIL) return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d",u);
}
 
int main(){
    int i,v,l,r,root;
     
    scanf("%d",&n);
    for(i = 0;i < n;i++){
        T[i].p = NIL;
    }
     
    for(i = 0;i < n;i++){
        scanf("%d %d %d",&v,&l,&r);
        T[v].l = l;
        T[v].r = r;
        if(l != NIL) T[l].p = v;
        if(r != NIL) T[r].p = v;
    }
    for(i = 0;i < n;i++) if(T[i].p == NIL) root = i;
     
    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");
     
    return 0;
}


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

int main() {
  long long A, B, K;
  cin >> A >> B >> K;
  
  if (K - A < 0) {
    cout << A - K << " " << B << endl;
    return 0;
  } else {
    if (B - (K - A) < 0) {
      cout << 0 << " " << 0 << endl;
      return 0;
    } else {
      cout << 0 << " " << B - (K - A) << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

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

	vector<ll> v(N);
	rep(i, N) cin >> v[i];

	ll ans = 0;
	for(int l = 0; l <= K;l++){
		for(int r = 0; r <= K; r++){
			int s = K - l - r;
			if(s < 0) continue;
			if(l + r > N) continue;

			ll t = 0;
			vector<int> w;
			for(int i = 0; i < l; i++){
				w.push_back(v[i]);
				t += v[i];
			}

			for(int i = N - 1; i > N - 1 - r; i--){
				w.push_back(v[i]);
				t += v[i];
			}

			sort(w.begin(), w.end());
			for(int i = 0; i < s; i++){
				if(i < w.size() && w[i] < 0){
					t -= w[i];
				}
			}

			ans = max(ans, t);
		}
	}

	cout << ans << endl;
}


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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

// bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
//     return arg1.first > arg2.first;
// }

int main(void) {
    string s;
    cin >> s;

    int ans=0, cnt=0;
    
    for(int is=0;is<s.size();is++) {
        if(s.at(is)=='A'||s.at(is)=='T'||s.at(is)=='G'||s.at(is)=='C') cnt++;
        else { 
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);

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


Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let c: i32 = read();
    println!("{}", if a + b >= c { "Yes" } else { "No" });
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long N,K;
    long r;
    cin >> N >> K;
    r = N % K;
    if(r < K - r){
        cout << r << endl;
    }else{
        cout << K-r << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    int n;
    scan(n);
    writeln(24 + 24 - n);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
n,k = map(int,input().split())
h = list(map(int,input().split()))

dp = [float("inf")]*n
dp[0]=0
for i in range(n-1):
    for j in range(1,k+1):
        if i+j<n:
            dp[i+j] = min(dp[i+j],dp[i]+abs(h[i+j]-h[i]))
print(dp[n-1])


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

int main() {
  while (1) {
    int n;
    cin >> n;

    if (n == 0) break;

    double sum = 0;
    int scores[n];

    for (int i = 0; i < n; i++) {
      int score;
      cin >> score;
      scores[i] = score;
      sum += score;
    }

    double avg = sum / n;
    double acc_diffs = 0;

    for (int i = 0; i < n; i++) {
      double diff = scores[i] - avg;
      acc_diffs += pow(diff, 2);
    }

    double var = acc_diffs / n;
    double std_dev = sqrt(var);

    printf("%.8f\n", std_dev);
  }

  return 0;
}



Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define lint long long int
using namespace std;
int main() 
{
	lint n=0;
	cin>>n;
	vector<lint> a(n);
	map<lint,lint> m;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n;i++)
	{
		a[i]--;
	}
	for(int i=0;i<n;i++)
	{
		m[a[i]]++;
	}
	for(int i=0;i<n;i++)
	{
		cout<<m[i]<<endl;
	}
	return 0;
}


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

using namespace std;

int n;
vector<int> nums;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	int cur;
	for (int i = 0; i < 2*n; i++) {
		cin >> cur;
		nums.push_back(cur);
	}
	sort(nums.begin(), nums.end());
	int ans = 0;
	for (int i = 0; i < nums.size(); i += 2) {
		ans += nums[i];
	}
	cout << ans << endl;

}


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

using namespace std;


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

	long long n, t, i, j, k, ans, nn;
	cin >> n >> t;
	vector<pair<long long, long long>> a(n);
	vector<long long> maxx(n);
	for (i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
	}

	sort(a.begin(), a.end());
	maxx[n - 1] = a[n - 1].second;
	for (i = n - 2; i >= 0; i--) maxx[i] = max(maxx[i + 1], a[i].second);

	vector<long long> dp(t + 1, -1000000000);
	ans = 0;
	dp[0] = 0;
	for (j = 0; j < n; j++) {
		for (i = t - 1; i >= 0; i--) {
			if (i + a[j].first <= t) {
				dp[i + a[j].first] = max(dp[i + a[j].first], dp[i] + a[j].second);
			}
		}
		ans = max(ans, dp[t]);
		if (j < n - 1) for (i = t - 1; i >= 0; i--) ans = max(ans, dp[i] + maxx[j + 1]);
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 888
import java.util.*;

import static java.lang.System.*;

class Main {
	public static Scanner sc = new Scanner(in);
	public static Random rand=new Random();

	public List<Integer> getPrimeList(int max){
		LinkedList<Integer> primes=new LinkedList<Integer>();

		PLoop:for(int i=2;i<max;i++){
			for(int prime:primes){
				if(i%prime==0){
					continue PLoop;
				}
				if( prime*prime>i){
					break;
				}
			}
			primes.add(i);
		}
		return primes;
	}
	public void run() {
		List<Integer> plist=new ArrayList<Integer>(getPrimeList(200000));

		TCase:while(true){
			int n=sc.nextInt(),p=sc.nextInt();
			if(n==-1)return;

			int ind=Collections.binarySearch(plist,n+1);
			if(ind<0)ind=~ind;

			List<Integer> sumset=new LinkedList<Integer>();
			for(int i=ind;i<=ind+p;i++)for(int j=i;j<=ind+p;j++){
				sumset.add(plist.get(i)+plist.get(j));
			}
			Collections.sort(sumset);

			ln(sumset.get(p-1));
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}

	public int[] nextIntArray(int n){
		int[] res=new int[n];
		for(int i=0;i<n;i++){
			res[i]=sc.nextInt();
		}
		return res;
	}
	public static void pr(Object o) {
		out.print(o);
	}
	public static void ln(Object o) {
		out.println(o);
	}
	public static void ln() {
		out.println();
	}
}

Measured memory_bytes: 69056
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

ll MOD = 1000000007;
// ll lcm(ll a, ll b) { return (a / __gcd(a, b) * b); }

int main() {
  //
  int n, a;
  cin >> n >> a;
  vi x(n);
  rep(i, n) cin >> x[i];
  // total, toindex, cnt
  vector<vector<vector<ll>>> data(2501, vvl(n, vl(n + 1, 0)));
  data[x[0]][0][1] = 1;
  data[0][0][0] = 1;
  REP(i, 1, n) {
    REP(cnt, 0, i + 2) {
      rep(sub, 2501 - x[i]) {
        // use i
        if (cnt >= 1) data[sub + x[i]][i][cnt] += data[sub][i - 1][cnt - 1];
        // dont use i
        data[sub][i][cnt] += data[sub][i - 1][cnt];
      }
    }
  }
  ll ans = 0;
  REP(cnt, 1, n + 1) {
    int total = a * cnt;
    // cout << total << endl;
    // cout << cnt << ":" << data[total][n - 1][cnt] << endl;
    if (total <= 2500) {
      ans += data[total][n - 1][cnt];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 54144
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1LL<<60;

int main()
{
  int N, A[101010];
  cin>>N;
  for(int i = 1; i < N+1; i++){
    cin>>A[i];
  }

  
  int cur=1;
  for (int i =0; i < 101010; i ++) {
    cur = A[cur];
    if (cur == 2) {
      printf("%d\n", i + 1);
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}

Measured memory_bytes: 4100
#include <stdio.h>

static int c = 0;

void s(int *a,int *b){
  int i=*a;*a=*b;*b=i;
}

void bS(int *A, int a){
  int i,j;
  for(i=0;i<a;i++)
    for(j=a-1;j>i;j--)
      if(A[j]<A[j-1]) {
        s(&A[j],&A[j-1]); c++;}
}

int main(void){
  int N,n;
  int A[101];
  scanf("%d\n",&N);
  for(n=0;n<N;n++){
    int i;
    scanf("%d", &i); A[n] = i;
  }
  bS(A,N);
  for(n=0;n<N-1;n++)
    printf("%d ",A[n]);
  printf("%d\n",A[N-1]);
  printf("%d\n",c);
  return 0;
}

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

using namespace std;

using ll = long long;

constexpr ll MOD = 1e9 + 7;
constexpr int MAX_N = 100;
int n;
int dp[MAX_N + 2][5][5][5];

// _ = 0, A = 1, C = 2, G = 3, T = 4
vector<int> Next(const int b1, const int b2, const int b3) {
    vector<int> res;
    if (b2 == 0 || b3 == 0) res = {1, 2, 3, 4};
    else if (b1 == 1 && b2 == 3) res = {1, 3, 4};
    else if ((b2 == 1 && b3 == 3) || (b2 == 3 && b3 == 1)) res = {1, 3, 4};
    else if (b2 == 1 && b3 == 2) res = {1, 2, 4};
    else if (b1 == 1 && b3 == 3) res = {1, 3, 4};
    else res = {1, 2, 3, 4};

    return res;
}

int Rec(int idx, int b1, int b2, int b3) {
    if (idx == n) return 1;
    if (dp[idx][b1][b2][b3] != -1) return dp[idx][b1][b2][b3];

    int &cnt = dp[idx][b1][b2][b3] = 0;
    vector<int> nxt = Next(b1, b2, b3);
    for (int d : nxt) (cnt += Rec(idx + 1, b2, b3, d)) %= MOD;

    return cnt % MOD;
}

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

    cin >> n;
    for (int i = 0; i <= n; ++i)
        for (int j = 0; j < 5; ++j)
            for (int k = 0; k < 5; ++k)
                for (int l = 0; l < 5; ++l)
                dp[i][j][k][l] = -1;

    cout << Rec(0, 0, 0, 0) << endl;

    return 0;
}


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

int main() {
  int n, k;
  vector<int> a;
  
  cin >> n >> k;
  a.resize(n);
  for (int &elem : a) {
    cin >> elem;
  }
  
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < k; ++i) {
    ans += a[i];
  }
  
  cout << ans << '\n';
}


Measured memory_bytes: 3540
table = list("abcdefghijklmnopqrstuvwxyz")
N = int(input())

ans = []
while True:
    ans.append(N%26)
    if N%26 == 0:
        N -= 1
    if  N//26 == 0:
        break
    N//=26
for x in reversed(ans):
    print(table[x-1],end='')

print()


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

int main(){
    int a, b;
    cin >> a >> b;
    int c = 0;
    vector<int> data = {1, 2, 3};
    for(int i=0; i<data.size(); i++){
        if(a != data.at(i) && b != data.at(i)){
            c = i+1;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h> 
using namespace std;
int main(){
  int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++){
    cin>>arr[i];
  }
  int dp[n];
  dp[0]=0;
  int i=1;
  dp[1]=arr[i]>arr[i-1]?arr[i]-arr[i-1]:arr[i-1]-arr[i];
  for(i=2;i<n;i++)
  {
   	int a= arr[i]>arr[i-1]?arr[i]-arr[i-1]:arr[i-1]-arr[i];
    int b= arr[i]>arr[i-2]?arr[i]-arr[i-2]:arr[i-2]-arr[i];
    a+=dp[i-1];
    b+=dp[i-2];
    dp[i]=min(a,b);
  }
  cout<<dp[n-1];
  return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n
a1
..
an

n 10^5
ai 10^9
 */
int n;
ll a[100001];

int main(){
  cin>>n;
  REP(i,n){
    cin>>a[i];
  }

  ll ans = 0;
  REP(i,n){
    ans += (a[i]+a[i+1])/2;
    a[i+1] = a[i+1]==0 ? 0 : (a[i]+a[i+1])%2;
  }

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


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

int main() {
    int n, a;
    cin >> n >> a;
    cout << n * n - a << endl;

    return 0;
}



Measured memory_bytes: 256
w = gets.to_i
line = Array.new(w){|i| i+1 }
arr = Array.new
gets.to_i.times do
  arr << gets.split(',').map {|x| x.to_i - 1 }
end

arr.each do |a|
  line[a[0]], line[a[1]] = line[a[1]], line[a[0]]
end

line.each do |n|
  puts n
end

Measured memory_bytes: 6104
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    vector<vector<ll> > A(N, vector<ll>(3));

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

    if(M == 0) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;

    for(int i = 0; i < 8; i++) {

        vector<vector<ll> > dp(N, vector<ll>(M));
        vector<ll> s(N);

        for(int j = 0; j < 3; j++) {
            if(i & (1 << j)) {
                dp[0][0] -= A[0][j];
                s[0] -= A[0][j];
            } else {
                dp[0][0] += A[0][j];
                s[0] += A[0][j];
            }
        }

        for(int j = 1; j < N; j++) {

            ll c = 0;
            for(int k = 0; k < 3; k++) {
                if(i & (1 << k))
                    c -= A[j][k];
                else
                    c += A[j][k];
            }

            s[j] = c;

            if(c > dp[j - 1][0])
                dp[j][0] = c;
            else
                dp[j][0] = dp[j - 1][0];

            for(int k = 1; k < min(j + 1, M); k++) {
                c = dp[j - 1][k - 1] + s[j];
                if(c > dp[j - 1][k] || j == k)
                    dp[j][k] = c;
                else
                    dp[j][k] = dp[j - 1][k];
            }
        }

        ans = max(ans, dp[N - 1][M - 1]);
/*
        for(int j = 0; j < N; j++) {
            for(int k = 0; k < M; k++) {
                cerr << dp[j][k] << " ";
            }
            cerr << endl;
        }
        cerr << endl;*/
    }

    cout << ans << endl;
}

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

const int inf = 1e9;

int main(){
  int N, Ma, Mb;
  cin >> N >> Ma >> Mb;
  vector<vector<int>> abc(N, vector<int>(3));
  for (int i=0; i<N; i++){
    cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
  }
  vector<vector<vector<int>>> dp(N+1, vector<vector<int>>(401, vector<int>(401, inf)));
  dp[0][0][0] = 0;
  for (int n=1; n<=N; n++){
    for (int i=0; i<401; i++){
      for (int j=0; j<401; j++){
        if (i==0&&j==0) dp[n][i][j] = 0;
        else {
          if (i-abc[n-1][0]<0||j-abc[n-1][1]<0) dp[n][i][j] = dp[n-1][i][j];
          else dp[n][i][j] = min(dp[n-1][i][j],dp[n-1][i-abc[n-1][0]][j-abc[n-1][1]]+abc[n-1][2]);
        }
      }
    }
  }
  int ans = inf;
  for (int i=1; i<400; i++){
    if (Ma*i>400||Mb*i>400) break;
    if (dp[N][Ma*i][Mb*i]<inf){
      ans = min(ans, dp[N][Ma*i][Mb*i]);
    }
  }
  if (ans < inf) cout << ans << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 27264
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
void trace(int n, int arr[]){for(int i = 0; i < n; i++){cout << i << " " << arr[i] << endl;} cout << endl << endl;}
int main()
{
    Hello
    int n, k;
    cin >> n >> k;
    int arr[n + 5];
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr, arr + n);
    ll ans = 0;
    for(int i = 0; i < k; i++)
        ans += arr[i];
    cout << ans;
    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int cnt5=0, cnt7=0;
		for(int i=0; i<3; ++i)
		{
			int x=sc.nextInt();
			if(x==5) ++cnt5;
			else if(x==7) ++cnt7;
		}
		System.out.println((cnt5==2 && cnt7==1)?"YES":"NO");
		sc.close(); 
	}

}

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

int main(int argc, char const *argv[])
{
    int A, B;
    cin >> A >> B;

    int plus, minus, times;
    plus = A + B;
    minus = A - B;
    times = A * B;

    int max_1 = max(plus, minus);
    int max_2 = max(max_1, times);
    cout << max_2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,j,k,l=0,arr[20009]={},a,b,c;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&arr[i]);
    sort(arr,arr+n);
   for(i=0;i<n-2;i++){
    for(j=i+1;j<n-1;j++){
        m=arr[i]+arr[j]-1;
        a=upper_bound(arr,arr+n,m) - arr;
       // printf("%d ",a);
       if(a>=n)
        a=n-1;
        while(a>j && arr[a]>m)
            a--;
           // printf("%d ",a);
        l+=a-j;
       // printf("%d ",l);
    }
   }
    printf("%d\n",l);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

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

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

vector<string> hold;
ll n;
void gen(char curr,string &s)
{
    if(s.length() == n)
    {
        hold.pb(s);
        return;
    }
    
    for(char c='a';c<curr;c++)
    {
        string s1 = s+c;
        gen(curr,s1);
    }
    
    s+=curr;
    curr++;
    gen(curr,s);
}

int main()
{
   FAST/**/
   
  
   cin>>n;
   string s;
   gen('a',s); 
   
   rep(hold.size())
        cout<<hold[i]<<"\n";
   
   return 0;        
}  
   

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

#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for ( int i = 0 ; i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

signed main() {
  int N;  
  while ( cin >> N, N ) {
    int M, K;
    int l[101];
    bool used[101][101] = {{0}};

    Rep(i, N) {
      cin >> M;
      Rep(j, M) {
	int p;
	cin >> p;
	p--;
	used[i][p] = true;
      }
    }

    cin >> K;
    Rep(i, K) {
      cin >> l[i];
      l[i]--;
    }

    int ans = -2;
    bool flag = false;
    Rep(i, N) {
      int cnt = 0;
      Rep(j, K) {
	if ( used[i][l[j]] ) cnt++;
      }
      if ( cnt == K ) {
	if ( flag ) {
	  ans = -2;
	} else {
	  ans = i;
	  flag = true;
	}
      }
    }

    cout << ans+1 << endl;
  }
}

Measured memory_bytes: 3116
a, b, k = input().split(' ')
a = int(a)
b = int(b)
k = int(k)

if a == 0 and b == 0:
    print(str(a) + ' ' + str(b))
elif a >= k:
    out = str(a - k) + ' ' + str(b)
    print(out)
else:
    a2 = k - a
    if b - a2 > 0:        
        out = '0 ' + str(b - a2)
        print(out)
    else:
        print('0 0')

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


//a b c  a b c a-b b-c c-a a-b-c
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    //---------------------Code-------------------------------------
    char a;
    cin>>a;
    if(isupper(a))
    {
        cout<<"A"<<endl;
    }
    else
    {
        cout<<"a"<<endl;
    }

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

}

Measured memory_bytes: 3648
typedef long unsigned int size_t;
extern int printf (const char *__restrict __format, ...);
extern int scanf (const char *__restrict __format, ...) ;
extern int getchar (void);
extern int putchar (int __c);
int nextInt(){int f=0;char s=0;char c=getchar();while((c<48)||(57<c)){if(c==45){s=1;c=getchar();break;}c=getchar();}while((48<=c)&&(c<=57)){f=f*10+(c-48);c=getchar();}return s?-f:f;}
char nextChar(){char f=0;char s=0;char c=getchar();while((c<48)||(57<c)){if(c==45){s=1;c=getchar();break;}c=getchar();}while((48<=c)&&(c<=57)){f=f*10+(c-48);c=getchar();}return s?-f:f;}
short int nextShort(){short f=0;char s=0;char c=getchar();while((c<48)||(57<c)){if(c==45){s=1;c=getchar();break;}c=getchar();}while((48<=c)&&(c<=57)){f=f*10+(c-48);c=getchar();}return s?-f:f;}
long long int nextLong(){long long int f=0;char s=0;char c=getchar();while((c<48)||(57<c)){if(c==45){s=1;c=getchar();break;}c=getchar();}while((48<=c)&&(c<=57)){f=f*10+(c-48);c=getchar();}return s?-f:f;}
void println(){putchar(10);}
void print(char *f){while(*f){putchar(*f);f++;}}
void printInt(int f){char c[10];if(!f){putchar(48);return;}if(f<0){f=-f;putchar(45);}char i=0;while(f){c[++i]=(f%10)+48;f/=10;}while(i){putchar(c[i--]);}}
void printLong(long long int f){char c[19];if(!f){putchar(48);return;}if(f<0){f=-f;putchar(45);}char i=0;while(f){c[++i]=(f%10)+48;f/=10;}while(i){putchar(c[i--]);}}
int n, b;
char d;
char s[33];
int main(void){
 n=nextInt();
 b=1; d=0;
 while(n){
  if((n&b)!=0){
   s[d]=1;
   if(d&1){
    n+=b;
   }else{
    n-=b;
   }
  }
  b<<=1; d++;
 }
 d--;
 if(d<0){d=0;}
 for(; d>=0; d--){
  putchar(s[d]+'0');
 }
 println();
}


Measured memory_bytes: 128
//
// Created by nori on 19/09/11.
//

#include <bits/stdc++.h>

using namespace std;

int main() {
    int N;
    cin >> N ;
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h.at(i);
    }
    int res = 0;
    for(int i = 0; i < N; i++){
        while(i+1 < N && h.at(i) == h.at(i+1)){
            i++;
        }
        if(i+1 < N && h.at(i) < h.at(i+1)){
            while(i+1 <N && h.at(i) <= h.at(i+1)){
                i++;
            }
        }
       else if( i+1 < N && h.at(i) > h.at(i+1)){
            while(i+1 <N && h.at(i) >= h.at(i+1)){
                i++;
            }
        }
        res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
    cout << fixed << setprecision(10);
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    int cnt = 0;
    for(int i = 0;i <= (n+r-1)/r; i++){
        for(int j = 0; j <= (n - i*r + g - 1)/g; j++){
            //cout << i << " " << j << endl;
            if( (n - i*r - j*g)%b == 0 && (n - i*r - j*g) >= 0) cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
  int n, s[2], m = 100000;
  cin >> n;
  vector<int> w(n);
  for(int i = 0; i < n; i++) {
    cin >> w.at(i);
  }
  for(int i = 0; i < n; i++) {
    s[0] = accumulate(w.begin(), w.begin()+i+1, 0);
    s[1] = accumulate(w.begin()+i+1, w.end(), 0);
    m = min(m, abs(s[0]-s[1]));
  }
  cout << m;
}

Measured memory_bytes: 256
# 400 points
import math


# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
k, a, b = map(int, input().split())

n = 0
left = k


if b - a > 2:
    # 最初に叩く
    if a - 1 > k:
        print(1 + k)

    else:
        left = k - (a-1)    # 残りの回数

        n = math.floor(left/2.0)
        print(a + (b - a) * n + (left - 2 * n))

else:
    print(1 + k)




Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        var inp = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var list = new List<Tuple<int, int>>();
        for (int i = 0; i < inp[1]; i++)
        {
            var line = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            list.Add(new Tuple<int, int>(line[0], line[1]));
        }
        int min = int.MaxValue;
        int max = 0;
        for (int i = 0; i < inp[1]; i++)
        {
            if (max < list[i].Item1) max = list[i].Item1;
            if (min > list[i].Item2) min = list[i].Item2;
        }
        Console.WriteLine(Math.Max(0, min - max + 1));
    }
}

Measured memory_bytes: 19140