akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
	string s;
  	cin>>s;
  	for (int i=0; i<s.size(); i++)
      if ((i%2==0 && s[i]=='L') || (i%2 && s[i]=='R'))
      {
      cout<<"No";
        return 0;
      }
  	cout<<"Yes";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n=0;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++) n+=s[i]-'0';
  if(n%9==0) cout<<"Yes";
  else cout<<"No";
  return 0;
}

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

using namespace std;

typedef long long int64;

int main()
{
  int N, M, K, A[15], B[15], C[15];
  cin >> N >> M >> K;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for(int i = 0; i < N; i++) {
    cin >> B[i];
  }
  int ret = 0;
  for(int k = 0; k < (1 << N); k++) {
    if(__builtin_popcount(k) > K) continue;
    int cost = 0;
    for(int i = 0; i < N; i++) {
      C[i] = B[i];
    }
    int foo = M;
    while(foo > 0) {
      int curr = 0;
      for(int i = 0; i < N; i++) {
        if((k >> i) & 1 && C[i] > 0) {
          curr = max(curr, A[i]);
        }
      }
      if(curr == 0) break;
      cost += curr;
      for(int i = 0; i < N; i++) {
        if((k >> i) & 1 && C[i] > 0 && A[i] == curr) {
          --C[i];
          --foo;
          break;
        }
      }
    }
    ret = max(ret, cost + foo);
  }
  cout << ret << endl;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;



int main() {
  int ab, bc, cd;
  cin >> ab >> bc >> cd;
  cout << ab*bc/2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX=101;
int main()
{
  int n,k,i,j,d,t,res;
  bool h[N_MAX];
  cin >> n >> k;
  fill(h+1,h+n+1,0);
  res=n;
  for(i=0;i<k;i++){
    cin >> d;
    for(j=0;j<d;j++){
      cin >> t;
      h[t]=1;
    }
  }
  for(i=1;i<=n;i++)
    res-=h[i];
  cout << res << endl;
  return 0;
}

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

int main(){
  vector<vector<int>> a(3, vector<int>(3));
  rep(i,3)rep(j,3){{
    cin >> a.at(i).at(j);
    }}
  
  int n;
  cin >> n;
  
  rep(i,n){
    int b;
    cin >> b;
    rep(i,3)rep(j,3){{
    if(a.at(i).at(j) == b) a.at(i).at(j) = 0;
    }}
  }

  
  string ans = "No";
  rep(i,3){
  if(a.at(i).at(0) == 0 && a.at(i).at(1) == 0 && a.at(i).at(2) == 0) {ans = "Yes";}
  if(a.at(0).at(i) == 0 && a.at(1).at(i) == 0 && a.at(2).at(i) == 0) {ans = "Yes";}
  }
  if(a.at(0).at(0) == 0 && a.at(1).at(1) == 0 && a.at(2).at(2) == 0) ans = "Yes";
  if(a.at(0).at(2) == 0 && a.at(1).at(1) == 0 && a.at(2).at(0) == 0) ans = "Yes";
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, a[212345];
LL ans;

int main()
{
	in >> N;
	rep(i, N) { in >> a[i]; }

	rep(i, N) { a[i + 1] += a[i]; }
	for (LL i = 0; i < N - 1; ++i)
	{
		LL res;
		if ((a[i] - (a[N] - a[i])) < 0) { res = -(a[i] - (a[N] - a[i])); }
		else { res = a[i] - (a[N] - a[i]); }
		if (i == 0) { ans = res; }
		else ans = std::min(ans, res);
	}

	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 1792
from math import ceil

N, H = map(int, input().split())
dmg = []
for _ in range(N):
    a, b = map(int, input().split())
    dmg.append(a)
    dmg.append(b)
tl = [(i, d) for i, d in enumerate(dmg)]
tl.sort(key=lambda x: x[1], reverse=True)

ans = 0
rest = H
for i in range(2*N):
    idx, damage = tl[i]
    if idx % 2 == 0:
        if rest % damage == 0:
            ans += rest // damage
        else:
            ans += rest // damage + 1
        break
    else:
        ans += 1
        rest -= damage
        if rest <= 0:
            break
print(ans)

Measured memory_bytes: 105632
#include <stdio.h>

int main(){
  int W,H,x,y,r;
  scanf("%d",&W);
  scanf("%d",&H);
  scanf("%d",&x);
  scanf("%d",&y);
  scanf("%d",&r);

  if( x-r < 0 || x+r > W || y-r < 0 || y+r > H ) {
    printf("No\n");
  } else {
    printf("Yes\n");
  }

  return 0;
}


Measured memory_bytes: 2624
import java.util.Scanner;
public class Main{
    public static void main(String argv[])
    {
	Scanner scan = new Scanner(System.in);

	int num = scan.nextInt();
	int h=0,m=0,s=0;

	while(true)
	    {
		if( num - 3600 >= 0 )
		    {
			num = num-3600;
		    h++;
		    }
		else if( num - 60 >= 0 )
		    {
			num = num-60;
			m++;
		    }
		else {
		        if( num == 0) break;
			s++;
			num--;
		}
	    }
	System.out.println(h+":"+m+":"+s);

    }
}

Measured memory_bytes: 26248
n = int(input())
*A, = map(int, input().split())

ans = 0
for i in range(n):
    for j in range(n-1):
        if A[j+1] < A[j]:
            A[j], A[j+1] = A[j+1], A[j]
            ans += 1
print(*A)
print(ans)

Measured memory_bytes: 7664
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
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; }

//---------------------------------------------------------------
// ------ graph ------ //
using Weight = int;
using Flow = int;
struct Edge {
    int src, dst;
    Weight weight;
    Flow cap;
    Edge() : src(0), dst(0), weight(0) { }
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // pqが降順のため
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
using Edges = vector<Edge>;
struct Graph {
    vector<Edges> adj;
    Graph(int n) : adj(n) { }
    int size() { return adj.size(); }
    Edges operator [] (int v) { return adj[v]; }
    void add_edge(int a, int b, Weight w = 1) { // graph
        adj[a].emplace_back(a, b, w);
        adj[b].emplace_back(b, a, w);
    }
    void add_arc(int a, int b, Weight w = 1) {  // digraph
        adj[a].emplace_back(a, b, w);
    }
};
using Array = vector<Weight>;
using Matrix = vector<Array>;

// ------ Topological Sort (Kahn) ------ //
vector<int> tsort(Graph &g) {
    int n = g.size(), k = 0;
    vector<int> ord(n), in(n);
    for (int i = 0; i < n; i++) for (Edge &e : g[i]) in[e.dst]++;
    queue<int> q;
    for (int i = 0; i < n; i++) if (in[i] == 0) q.push(i);
    while (!q.empty()) {
        int v = q.front(); q.pop();
        ord[k++] = v;
        for (Edge &e : g[v]) if (--in[e.dst] == 0) q.push(e.dst);
    }
    return *max_element(in.begin(), in.end()) == 0 ? ord : vector<int>();
}
//---------------------------------------------------------------

int main() {
    int V, E; cin >> V >> E;
    Graph g(V);
    for (int i = 0; i < E; i++) {
        int s, t; cin >> s >> t;
        g.add_arc(s - 1, t - 1);
    }
    vector<int> ord = tsort(g);
    vector<int> dp(V, 0);
    for (int cu : ord) for (Edge e : g[cu]) chmax(dp[e.dst], dp[cu] + 1);
    int ans = 0;
    for (int i = 0; i < V; i++) chmax(ans, dp[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6912
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdio>
using namespace std;
long long dp[100][100][5000]; long long n, k, x[100];
int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> x[i]; dp[0][0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < 5000; k++) {
				if (dp[i][j][k] == 0)continue;
				dp[i + 1][j+1][k + x[i]] += dp[i][j][k];
				dp[i + 1][j][k] += dp[i][j][k];
			}
		}
	}
	long long sum = 0;
	for (int i = 1; i <= n; i++)sum += dp[n][i][k*i];
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 12976
#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;
#define FL(i,a,b) for(int i = a;i<b;i++)
typedef vector<int> vi;
typedef long long int lli;
const int inf = numeric_limits<int>::max();




int main(){
    long int n,m;
    cin>>n>>m;
    vector<lli> h(n);
    for(long int i = 0;i<n;i++){
        cin>>h[i];
    }
    vector<vector<long int>> arr(n);
    for(long int i = 0;i<m;i++){
        long int a,b;
        cin>>a>>b;
        a--;b--;
        arr[a].push_back(b);
        arr[b].push_back(a);
    }
    lli count = 0;
    for(long int i = 0;i<n;i++){
        bool ans = true;
        for(long int j = 0;j<arr[i].size();j++){
            if(h[arr[i][j]]>=h[i]){
                ans = false;
                break;
            }
        }
        if(ans){
            count++;
            //cout<<i<<" ";
        }
    }
    cout<<count;
}




Measured memory_bytes: 9800
A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
B=[int(input()) for i in range(N)]
if A[0][0] in B:
    if A[0][1] in B:
        if A[0][2] in B:
            print("Yes")
            exit()
    if A[1][0] in B:
        if A[2][0] in B:
            print("Yes")
            exit()
    if A[1][1] in B:
        if A[2][2] in B:
            print("Yes")
            exit()
if A[0][1] in B:
    if A[1][1] in B:
        if A[2][1] in B:
            print("Yes")
            exit()
if A[0][2] in B:
    if A[1][2] in B:
        if A[2][2] in B:
            print("Yes")
            exit()
    if A[1][1] in B:
        if A[2][0] in B:
            print("Yes")
            exit()
if A[1][0] in B:
    if A[1][1] in B:
        if A[1][2] in B:
            print("Yes") 
            exit()
if A[2][0] in B:
    if A[2][1] in B:
        if A[2][2] in B:
            print("Yes")
            exit()
print("No")


Measured memory_bytes: 3064
#![allow(unused)]
use std::io::{self, Read};

fn get_stdin() -> String {
    let mut buf = String::new();
    let mut stdin = io::stdin();
    stdin.read_to_string(&mut buf);
    return buf
}

fn to_nums(ss: &str) -> Vec<i32> {
    ss.split_whitespace()
        .map(|x| x.parse::<i32>().unwrap())
        .collect()
}

fn main() {
    let input = get_stdin();
    let mut v = to_nums(&input);
    v.sort();
    println!("{} {} {}", v[0], v[1], v[2]);
}



Measured memory_bytes: 5032
# dpに文字列を格納 (TLE)
def resolve():
    s = input()
    t = input()

    dp = [[""] * (len(t)+1) for _ in range(len(s)+1)]
    
    for i in range(len(s)):
        for j in range(len(t)):
            if s[i] == t[j]:
                dp[i+1][j+1] = dp[i][j] + s[i]
            else:
                if len(dp[i][j+1]) >= len(dp[i+1][j]):
                    dp[i+1][j+1] = dp[i][j+1]
                else:
                    dp[i+1][j+1] = dp[i+1][j]

    print(dp[len(s)][len(t)])

def resolve():
    s = input()
    t = input()

    dp = [[0] * (len(t)+1) for _ in range(len(s)+1)]
    
    for i in range(len(s)):
        for j in range(len(t)):
            if s[i] == t[j]:
                dp[i+1][j+1] = dp[i][j] + 1
            else:
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])

    # 後ろから探索
    # s[i-1]が、LCSに含まれるかどうか判定
    # dp[i][j]とdp[i-1][j]またはdp[i][j-1]が一致(変化なし)の場合、s[i-1]はLCSに含まれない
    res = ""
    i = len(dp) - 1
    j = len(dp[0]) - 1
    while i != 0 and j != 0:
        if dp[i][j] == dp[i - 1][j]: 
            i -= 1 
        elif dp[i][j] == dp[i][j - 1]:
            j -= 1
        else:
            res = s[i-1] + res
            i -= 1
            j -= 1

    print(res)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 111452
/*  ***  In The Name of God ... ***  */ 
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;


#define int long long
#define all(v) v.begin() , v.end()
#define pb push_back
#define endl '\n' 
template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = 50 + 10 , maxn = 50 * 50 + 10 ; 

int n , a [ N ] , A , dp [ N ] [ maxn ] [ N ] ;  

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> A ;
	for ( int i = 1 ; i <= n ; i++ )
		cin >> a [ i ] ;
	dp [ 0 ] [ 0 ] [ 0 ]++ ; 
	dp [ 1 ] [ 0 ] [ 0 ]++ ; 
	dp [ 1 ] [ a [ 1 ] ] [ 1 ]++ ; 
	for ( int i = 2 ; i <= n ; i++ ) {
		for ( int j = maxn - 1 ; j >= 0 ; j-- ) {
			for ( int t = 0 ; t <= i ; t++ ) {
				dp [ i ] [ j ] [ t ] = dp [ i - 1 ] [ j ] [ t ] ;
				if ( j - a [ i ] >= 0 && t )
					dp [ i ] [ j ] [ t ] += dp [ i - 1 ] [ j - a [ i ] ] [ t - 1 ] ;
			}
		}
	}
	int ans = 0 ;
	for ( int i = 0 ; i < maxn ; i++ ) {
		for ( int j = 1 ; j <= n ; j++ ) {
			if ( j * A == i ) { 
				ans += dp [ n ] [ i ] [ j ] ;
			}
		}
	}
	cout << ans << '\n' ; 
}


Measured memory_bytes: 59648
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
b = na()

b = [10**6] + b + [10**6]
ans = 0
for i in range(1,n+1):
    ans += min(b[i-1],b[i])

print(ans)

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

int main() {
	int N;
	cin >> N;
	vector<long long>A(N);
	long long x = 0;
	long long y = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		y += A[i];
	}
	long long ans = 1e18;
	for (int i = 0; i < N - 1; ++i) {
		x += A[i];
		y -= A[i];
		ans = min(ans, abs(x - y));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4788
#include<cstdio>
const int mod=1e9+7;
int n,k,x,y,Ans;
int f[105][260];
int main(){
    scanf("%d%d",&n,&k);
    f[0][0]=y=1;//初始化
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        for(int j=i;j>=1;j--)
        for(int k=0;k<=255;k++)
        f[j][k]=(f[j][k]+f[j-1][k^x])%mod;//转移
    }
    for(int i=1;i<=n;i++){
        y=1ll*y*i%mod;
        Ans=(Ans+1ll*f[i][k]*y%mod)%mod;
    }
    printf("%d\n",Ans);
}

Measured memory_bytes: 384
#include <cstddef>
#include <cstdint>
#include <utility>
#include <vector>

template <class T, class Op> class doubling {
  using usize = std::size_t;
  using u64 = std::uint64_t;

  Op op;
  std::vector<T> pow;

  const T &get(const usize i) {
    while (i >= pow.size()) {
      pow.push_back(op(pow.back(), pow.back()));
    }
    return pow[i];
  }

public:
  doubling(Op op, T x) : op(op), pow({std::move(x)}) {}

  template <class U, class Ap> U apply(Ap ap, U init, u64 k) {
    usize i = 0;
    while (k != 0) {
      if (k % 2 != 0) {
        init = ap(std::move(init), get(i));
      }
      k /= 2;
      i += 1;
    }
    return std::move(init);
  }

  template <class U, class Ap, class Pred> u64 find(Ap ap, U init, Pred pred) {
    if (!pred(init)) {
      return 0;
    }
    U temp = ap(init, get(0));
    usize i = 0;
    while (pred(temp)) {
      init = std::move(temp);
      temp = ap(init, get(i));
      i += 1;
    }
    u64 ret = static_cast<u64>(1) << i;
    while (i != 0) {
      i -= 1;
      temp = ap(init, get(i));
      if (pred(temp)) {
        init = std::move(temp);
      } else {
        ret -= static_cast<u64>(1) << i;
      }
    }
    return ret;
  }
};

#include <iostream>
#include <vector>

int main() {
  int n;
  long long k;
  std::cin >> n >> k;

  std::vector<int> a(n);
  for (int &e : a) {
    std::cin >> e;
    e -= 1;
  }

  const auto op = [](std::vector<int> l, const std::vector<int> &r) {
    for (int &e : l) {
      e = r[e];
    }
    return std::move(l);
  };

  doubling<std::vector<int>, decltype(op)> db(op, a);

  const auto ap = [](const int l, const std::vector<int> &r) { return r[l]; };

  std::cout << db.apply(ap, 0, k) + 1 << "\n";

  return 0;
}


Measured memory_bytes: 50904
#include <iostream>
#include "bits/stdc++.h"

using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i, a, b) for(ll i=a;i<b;i++)
#define REP(i, a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i, a) for(ll i=a;i>0;i--)
#define rrep(i, a, b) for(ll i=a-1;i>=b;i--)
#define printall(n, array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
typedef vector<vector<ll>> VVE;
const ll mod = 1e9 + 7; //10^9+7

int main () {
    ll a, b, c;
    cin >> a >> b >> c;
    if(a == b && b == c){print("Yes");}
    else {print("No");}
}

Measured memory_bytes: 256
/********************/
                    /*user -> tushar284*/
                    /******************/
#include<bits/stdc++.h>
                                                    /*********/            
using namespace std;                             /*   __   __   */
#define  f              first                    /*   @ ) ( @   */
#define  s              second                   /*     / \     */            
#define  mp             make_pair                /*  __  -  __  */
#define  loop(i,s,e)    for(int i=s;i<e;i++)     /*    ..^..    */
#define  rev(i,s,e)     for(int i=s;i>=e;i--)     /*     |     */
#define  mod            1000000007                  /*   |   */
#define  pb             push_back                      /***/
#define  start	        int main()                     
#define  fast           ios_base::sync_with_stdio(false);cin.tie(0);
#define  test           int t; cin>>t;while(t--)
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;


start
{   
    int n,k;
    cin>>n>>k;
    bool have[n+1]={false};
    loop(i,1,k+1){
        int d,x;
        cin>>d;
        loop(i,0,d){
            cin>>x;
            have[x] = true;
        }
    }
    int cnt=0;
    loop(i,1,n+1)if(!have[i])cnt++;
    cout<<cnt;
    
	return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int a, b;
    cin >> a >> b;
    int ans = ((b - 1) + (a - 2)) / (a - 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*

Author : AllKilled
Date   : 202001197 19:50:00 UTC+8

Website: https://atcoder.jp/contests/abc152
Contest: AtCoder Beginner Contest 152
Problem: Task C.
Result :

*/
#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<LL, LL> PLL;

const int inf = 0x3f3f3f3f;
const int N = 18;
const LL MAXN = 2e5 + 3;

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

int n, ma = inf, ans;

int main()
{
    cin >> n;
    for (int m, i = 0; i < n; ++i) {
        cin >> m;
        if (m < ma) {
            ma = m;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;
ll n;
ll a[16][16];
ll dp[(1<<18)];
ll mx;
int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);

    cin >> n;
    for(ll i = 0; i < n; ++i)
        for(ll j = 0; j < n; ++j)
            cin >> a[i][j];
    mx = (1<<n);
    vector<ll> tmp;
    for(ll bit = 0; bit < mx; ++bit){
        tmp.clear();
        for(ll i = 0; i < n; ++i)
            if((bit&(1<<i)) != 0)
                tmp.pb(i);
        for(ll i = 0; i < tmp.size(); ++i)
            for(ll j = i+1; j < tmp.size(); ++j)
                dp[bit] += a[tmp[i]][tmp[j]];
    }
    for(ll bit = 0; bit < mx; ++bit)
        for(ll sub = (bit-1)&bit; sub > 0; sub = ((sub-1)&bit)){
            dp[bit] = max(dp[bit], dp[bit-sub] + dp[sub]);
        }
    cout << dp[(1<<n)-1] << "\n";
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n,m;cin >> n>>m;
    vector<lint> v(m,1);
    REP(i, n) {
        int k;
        cin >> k;
        vector<lint> v2(m);
        REP(j,k){
            int a;
            cin >> a;
            v2[a-1] = 1;
        }
        REP(j,m){
            v[j] *= v2[j];
        }
    }
    lint ans=0;
    REP(i,m){
        ans += v[i];
    }

    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    string s[n];
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }
    sort(s,s+n);
    for(int i=0;i<n;i++)
    {
        cout<<s[i];
    }
    cout<<endl;

}


Measured memory_bytes: 256
package main

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

func main() {

	stdin := bufio.NewScanner(os.Stdin)
	stdin.Split(bufio.ScanLines)

	stdin.Scan()

	switch stdin.Text() {
	case "25":
		fmt.Println("Christmas")
	case "24":
		fmt.Println("Christmas Eve")
	case "23":
		fmt.Println("Christmas Eve Eve")
	case "22":
		fmt.Println("Christmas Eve Eve Eve")
	}
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    int x = a[a.size()-1];
    a.pop_back();

    int mx = -1, y = 0;
    rep(i,n){
        int ai = a[i];
        if(a[i] > x/2) ai = x - a[i];
        if(mx < ai){
            mx = ai;
            y = a[i];
        }
    }
    cout << x << " " << y << endl;
    return 0;
}

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

#define MAX 16777216

using namespace std;

bool dic[16777216];

int getStrNum(string str){
	int sum = 0, p=1;
	for(int i=0;i<str.size();++i){
		if(str[i] == 'A')sum += 1*p;
		else if(str[i] == 'C')sum += 2*p;
		else if(str[i] == 'G')sum += 3*p;
		else if(str[i] == 'T')sum += 4*p;
		p*=4;
	}
	return sum;
}

int main(){
	int n, i;
	cin >> n;
	
	string siji, _str;
	for(i=0;i<n;++i){
		cin >> siji >> _str;
		if(siji[0] == 'i'){
			dic[getStrNum(_str)]=true;
		}else{
			if(dic[getStrNum(_str)])cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4520
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 998244353
typedef long long ll;
using namespace std;
vector<ll> fac(300001);
vector<ll> ifac(300001);
ll mpow(ll x, ll n){ 
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}
ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}


int main(){
    ll n,m,k;
    cin>>n>>m>>k;
    ll ans=0;
    ll numlist[200005];

    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % MOD;
        ifac[i+1] = ifac[i]*mpow(i+1, MOD-2) % MOD;
    }
    ll t=m;
    for(ll j=0;j<n;j++){
        t*=(m-1);
        t%=MOD;
        numlist[j]=t;
    }
    
    for(ll i=0;i<=k;i++){//i:隣り合うブロックが同じ色なのがi組
        if(n-2-i>=0){
            ll t=numlist[n-2-i];
            t*=comb(n-1,i);
            t%=MOD;
            ans+=t;
            ans%=MOD;
        }
        else{
            ans+=m;
            ans%=MOD;
        }
    }

    cout<<ans;
    return 0;
}


Measured memory_bytes: 9496
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007;
const int INF = 1 << 29;
const double EPS = 1e-9;

lint fac_mod(lint n, lint mod) {

	lint res = 1;
	for (int i = 1; i <= n; i++) res = (res * i) % mod;

	return res;
}

int main() {

	cin.tie(0);

	lint N;
	cin >> N;

	cout << fac_mod(N, MOD);

	return 0;
}

Measured memory_bytes: 256
class UnionFind:

    def __init__(self, size):
        # 負の値はルート (集合の代表) で集合の個数
        # 正の値は次の要素を表す
        self.size = size
        self.table = [-1 for _ in range(size)]

    def find(self, x):
        # 集合の代表を求める
        while self.table[x] >= 0:
            if self.table[self.table[x]] >= 0:
                self.table[x] = self.table[self.table[x]]
            x = self.table[x]

        return x

    def union(self, x, y):
        # 併合
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] >= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
        return self.table[s1]


n,m = map(int, input().split())
p = list(map(int, input().split()))
uf = UnionFind(2*n)
for i in range(n):
    uf.union(n+i, p[i]-1)
for i in range(m):
    x,y = map(int, input().split())
    uf.union(n+x-1, n+y-1)

cnt = 0
for i in range(n):
    if uf.find(i) == uf.find(n+i):
        cnt += 1
print(cnt)

    

Measured memory_bytes: 14640
///#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

/*
    zet:
        find_by_order(k): k-stat [k > 0]
        order_of_key(k) : {el < k}

    gp_hash_table<key, val, custom_hash>

    rope<T>:
        iterators: mutable_begin, ..
        methods  : erase, insert, substr, ..
*/

#define all(x) (x).begin(), (x).end()
#define size(x) (int)((x).size())
#define em_back emplace_back

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<typename T>
using zet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

mt19937 eng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e3 + 4;

struct rad {
    int x, y, r;
    void read(int r_) {
        if (r_ == 0) {
            cin >> x >> y;
        } else {
            cin >> x >> y >> r;
        }
    }
};

int s, t, n;
ld d[N][N];
rad p[N];

void read() {
    p[0].read(0);
    p[1].read(0);
    cin >> n;
    swap(p[n + 1], p[1]);
    for (int i = 1; i <= n; ++i) {
        p[i].read(1);
    }
    s = 0;
    t = n + 1;
}

ld sqr(ld x) {
    return x * x;
}

ld dist(int a, int b) {
    return sqrt(sqr(p[a].x - p[b].x) + sqr(p[a].y - p[b].y));
}

void prepare() {
    for (int i = s; i <= t; ++i) {
        for (int j = s; j <= t; ++j) {
            d[i][j] = max(ld(0), dist(i, j) - p[i].r - p[j].r);
        }
    }
}

ld dijk() {
    vector<ld> c(t + 1, 1e18);
    vector<bool> used(t + 1);
    c[s] = 0;

    for (int i = s; i <= t; ++i) {
        int u = -1;
        for (int v = s; v <= t; ++v) {
            if (!used[v] && (u == -1 || c[u] > c[v])) {
                u = v;
            }
        }
        if (u == t) {
            return c[t];
        }
        used[u] = 1;
        for (int v = s; v <= t; ++v) {
            c[v] = min(c[v], c[u] + d[u][v]);
        }
    }
}

void solve() {
    read();
    prepare();
    cout << setprecision(9) << fixed << dijk() << "\n";
}

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

    int z = 1;
    /// cin >> z;

    while (z--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 19544
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9+7;
const int MAX_N = 100010;

int main(void){
  int x,y;
  cin >> x >> y;
  cout << x + y/2 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        String[] array = N.split("");
        boolean ans = false;
        
        for(int i = 0 ; i < 3;i++) {
        	if(array[i].equals(array[i+1])) {
        		ans = true;
        		break;
        	}
        }
       System.out.println(ans?"Bad":"Good");
    }
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M;
	int s[5+2] = {0};
	char c[5+2] = {0};

	cin >> N >> M;
	int min = 0, max = 0;
	if(N==1){
		min = 0;
	}
	else{
		min = (int)pow(10, N-1);
	}
	max = (int)pow(10, N) - 1;

	for(int i = 1; i <= M; i++){
		int a;
		char b;
		cin >> a >> b;
		s[i] = a;
		c[i] = b;
	}

	int ans = 0;
	int match = 0;
	for(ans = min; ans <= max; ans++){
		match = 1;
		char num[4] = {0};
		sprintf(num, "%d", ans);
		for(int i=1; i<=M; i++){
			if(num[s[i]-1] != c[i]){
				match = 0;
				break;
			}
		}
		if(match == 1) break;
	}
	if(match == 1){
		printf("%d\n", ans);
	}
	else{
		printf("-1\n");
	}
	return 0;
}

Measured memory_bytes: 640
//#include <bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)//初期値a,i<bの範囲でループ
#define REP(i,n) FOR(i,0,n)//初期値0,i<nの範囲でループ
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;

int a,b,c,d,e,f;

int main(){
    cin>>a>>b>>c>>d>>e>>f;
    //water 100a 100b
    //suger c d
    // e/100 suger/water
    //e*suger=100*water
    int w,s;
    int max;
    int i,j,k,l;
    int sum;
    
    ll noudo,maxnoudo=0;
    int maxws=0,maxs;


    
    REP(i,31){
        REP(j,31){
            w=i*100*a+j*100*b;
            if(w>f)break;
            for(k=0;;k++){
                if(w+k*c>f)break;
                if(!w)break;
                for(l=0;;l++){
                    s=k*c+l*d;
                    if(w+s>f)break;//あふれる
                    if(s>e*(w/100))break;//とけのこる
                    //if(w+s==2634 && s==934)cout<<"hui";
                    noudo=(s*1000000000000)/(w+s);
                    if(noudo>=maxnoudo){
                        //if(maxws==2634 && maxs==934)cout<<"omg";
                        maxnoudo=noudo;
                        //cout<<noudo<<endl;
                        //if(noudo==50)cout<<w+s<<s;
                        maxws=w+s;
                        maxs=s;
                    }


                }
            }
        }
    }
    
    cout<<maxws<<" "<<maxs;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,mint=1000000000,i,x,t;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&x);
        t=0;
        while(x % 2 ==0)
        {
            x=x/2;
            t++;
        }
        if(t<mint)mint=t;
    }
    printf("%d\n",mint);
    return 0;
}

Measured memory_bytes: 128
#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 getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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 ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int num[26];

int main(void){
	int h,w;
	cin >> h >> w;
	rep(i,h)rep(j,w){
		char in;
		cin >> in;
		num[in-'a']++;
	}

	int one = 0, two = 0,four = 0;
	rep(i,h)rep(j,w){
		const int ri = h - 1 - i;
		const int rj = w - 1 - j;
		if(ri < i or rj < j) continue; 
		

		if(i==ri and j==rj)
			one++;
		else if(i!=ri and j!=rj)
			four++;
		else
			two++;
	}

	while(one>0){
		int tar = 0;
		rep(i,26) if(num[i]>0) tar = i;
		rep(i,26) if(num[i]>=1 and num[i]%2==1) tar = i;
		num[tar]--;
		one--;
	}

	while(two>0){
		int tar = 0;
		rep(i,26) if(num[i]>0) tar = i;
		rep(i,26) if(num[i]>=2 and num[i]%4==2) tar = i;
		num[tar]-=2;
		two--;
	}

	while(four>0){
		int tar = 0;
		rep(i,26) if(num[i]>0) tar = i;
		rep(i,26) if(num[i]>=4) tar = i;
		num[tar]-=4;
		four--;
	}

	bool ok = true;
	rep(i,26) if(num[i]!=0) ok=false;

	if(ok)
		puts("Yes");
	else
		puts("No");

	return 0;
}

Measured memory_bytes: 256
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));
  $m=1000000007;
  $sum=array_sum($a);
  $sum=$sum%$m;

  $minus=0;
  for($i=0;$i<$n;$i++){
    $x=$a[$i]*$a[$i]%$m;
    $minus=$minus+$x;
    $minus=$minus%$m;
  }

  $ans=$sum*$sum;
  $ans=$ans-$minus;
  $ans=($ans+$m)%$m;
  $y=repeatSqrt(2, $m-2, $m);
  echo ($ans*$y)%$m;

/**
 * mod Pの世界での繰り返し二乗法
 * @param $b 基数
 * @param $p 指数
 * @param $m 素数
 */
function repeatSqrt($b, $p, $m){
  if($p==1)
  {
    return $b;
  }
  else if($p%2 == 0)
  {
    $t = repeatSqrt($b, floor($p/2), $m);
    return ($t * $t) % $m;
  }
  else
  {
    return ($b * repeatSqrt($b, $p-1, $m)) % $m;
  }
}

Measured memory_bytes: 38120
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  vector<ll> p(n+1);
  p[0]=2;p[1]=1;
  for(int i=2;i<n+1;i++){
    p[i]=p[i-1]+p[i-2];
  }

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


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

int main() {
  long long N, D;
  cin >> N >> D;
  vector<long long> X(N);
  vector<long long> Y(N);
  for(int i = 0; i < N; i++) {
    cin >> X.at(i) >> Y.at(i);
  }
  long long cnt = 0;
  for(int i = 0; i < N; i++) {
    if(X.at(i)*X.at(i)+Y.at(i)*Y.at(i) <= D*D) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


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

using namespace std;

int main()
{
	int n;

	while (scanf("%d", &n), n) {
		int s[5001] = {};

		for (int i = 1; i <= n; ++i) {
			int a; scanf("%d", &a);
			s[i] = a + s[i - 1];
		}

        int ma = -100000;

		for (int i = 1; i <= n; ++i) for (int j = 1; j <= i; ++j) {
			ma = max(ma, s[i] - s[j - 1]);
		}

		printf("%d\n", ma);
	}
}

Measured memory_bytes: 1216
import itertools

N, K = map(int ,input().split())

d = []
A = []

for i in range(K):
    d.append(int(input()))
    a = list(map(int, input().split()))
    A.append(a)

ans = 0
A = itertools.chain.from_iterable(A)
A = set(A)
for i in range(1,N+1):
    if i not in A:
        ans += 1

print(ans)

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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;


void solve(){
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif
	int a, b, h;
	cin >> a >> b >> h;

	cout << (a + b) * h / 2 << endl;
}


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


	solve();
	system("PAUSE");
	return 0;
}

Measured memory_bytes: 884
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        String S = sc.next();
        String T = sc.next();
        StringBuilder sb = new StringBuilder();
        for (int i=0;i<N;i++) {
            sb.append(S.charAt(i));
            sb.append(T.charAt(i));
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 21588
#include <stdio.h>
#include <stdlib.h>

typedef long long int ll;

struct creature {
  int index;
  int size;
};

struct creature A[100000];
ll  S[100000];

int cmpfunc (const void * a, const void * b){
  return ((struct creature *)a)->size - ((struct creature *)b)->size;
}


int main(){
  int i, n;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    A[i].size = a;
    A[i].index = i;
  }

  qsort(A, n, sizeof(struct creature), cmpfunc);

  S[0] = A[0].size;
  for(i=1;i<n;i++){
    S[i] = S[i-1] + A[i].size;
  }

  for(i=n-2;i>=0;i--){
    if(2*S[i] < A[i+1].size) break;
  }

  printf("%d\n", n-1-i);
  return 0;
}


Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(void){
    int a,b;
    char op;
    while(true){
        cin>>a>>op>>b;
    
    if(op=='?'){
    break;
    }
    
    if(op=='+'){
    cout<<a+b<<endl;
    }
    
    if(op=='-'){
    cout<<a-b<<endl;
    }
    
    if(op=='*'){
    cout<<a*b<<endl;
    }
    
    if(op=='/'){
    cout<<a/b<<endl;
    }
    }
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  int a, b;
  cin >> a >> b;
  if (a >= 13) {
    cout << b << endl;
  }
  else if (a >= 6) {
    cout << b / 2 << endl;
  }
  else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;

  if(a + b == 15) {
    cout << "+" << endl;
  }
  else if(a * b == 15) {
    cout << "*" << endl;
  }
  else {
    cout << "x" << endl;
  }

  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    if(s[s.size()-1]=='s') s+="es";
    else s+='s';
    cout<<s<<"\n";
	return 0;
}

Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		long N = long.Parse(str);
		int[]A = new int[N];
		for(var i=0;i<N;i++){
			A[i] = int.Parse(Console.ReadLine());
		}
		Array.Sort(A);
		string ans = "second";
		for(var i=0;i<N;i++){
			if(A[i]%2==1){
				ans = "first";
				break;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 15328
#include <iostream>
using namespace std;
int kosu(int roku,int nine){
  int ret = 0;
  int rokumx = 1;
  while(rokumx <= roku){
    rokumx*=6;
  }
  while(rokumx != 0){
    ret += roku /rokumx;
    roku %= rokumx;
    rokumx/=6;
  }
  int ninemx = 1;
  while(ninemx <= nine){
    ninemx*=9;
  }
  while(ninemx != 0){
    ret += nine/ninemx;
    nine %= ninemx;
    ninemx/= 9;
  }
  return ret;
}
int main(){
  int n;cin>>n;
  if(n < 6){
    cout << n << endl;
    return 0;
  }
  int ret = n % 3;
  int thre = n/3*3;
  int nine;
  int roku;
  if(thre % 6 == 0){
    roku = thre/6;
    nine = 0;
  }else{
    roku = thre/6 - 1;
    nine = 1;
  }
  int mn = 1000000000;
  while(0 <= roku){
    mn = min(mn,kosu(roku,nine));
    roku -= 3;
    nine += 2;
  }
  cout << mn+ret << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from math import gcd

N, *AB = map(int, sys.stdin.read().split())

dict_F = {}
count_0 = 0

def insert(A,B,s): # A>=0, B>0, s=0or1
  if (A,B) not in dict_F.keys():
    dict_F[(A,B)] = [0,0]
  dict_F[(A,B)][s] += 1

def make_power2(N):
  result = 1
  list_result = [1]
  for _ in range(N):
    result = (2*result)%mod
    list_result.append(result)
  return list_result

for i in range(N):
  A,B = AB[2*i], AB[2*i+1]
  if A==0 and B==0:
    count_0 += 1
    continue
  g = gcd(A,B)
  A //= g
  B //= g
  if A>=0 and B>0:
    insert(A,B,0)
  elif A>0 and B<=0:
    insert(-B,A,1)
  elif A<=0 and B<0:
    insert(-A,-B,0)
  elif A<0 and B>=0:
    insert(B,-A,1)

mod = 1000000007
power2 = make_power2(N)
answer = 1

for A,B in dict_F.values():
  answer = (answer*(power2[A]+power2[B]-1))%mod
answer = (answer+count_0-1)%mod

print(answer)


Measured memory_bytes: 93236
N, M = map(int, input().split())
A = list(map(int, input().split()))
match = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}

# キーはマッチの本数、値は桁数を入れる辞書。マッチ本数が0本の場合も考慮したいので、range(N+1)としている
dp = [-1 for i in range(N + 1)]

cost = []
for i in range(M):
    cost.append([A[i], match[A[i]]])

dp[0] = 0


for i in range(N): # マッチの本数分ループする
    for k in range(M): # 今回使える整数分だけループ
        if i + 1 - cost[k][1] >= 0: # 整数kが使えるだけのマッチの本数がある場合
            dp[i + 1] = max(dp[i + 1], dp[i + 1 - cost[k][1]] + 1) # (指定したマッチの本数 - 新しい整数を入れるのに要した本数) + 1が桁数となる。


tmp = 0 #使ったマッチの数
res = ''
cost.sort(key=lambda x: x[0], reverse=True) # 今回使える整数を、大きい順にソート

for i in range(dp[N]):
    for j in range(M):
        if N - cost[j][1] - tmp >= 0: # 全マッチ本数 - 整数のコスト - 今まで使ったマッチ本数>= 0
            if dp[N - cost[j][1] - tmp] == dp[N - tmp] - 1:
                '''
                左辺:まだ残っているマッチ本数から対象の整数を利用した場合の桁数
                右辺:まだ残っているマッチで実現できる桁数-1
                '''
                res = res + str(cost[j][0])
                tmp += cost[j][1]
                break # 対象桁ごとに、何らかの整数が入ったらそこでおしまいにする
            
print(res)

Measured memory_bytes: 3404