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

void call(int n) {
  for (int i = 1; i <= n; i++) {
    int x = i;
    if (x % 3 == 0) {
      cout << " " << i;
      continue;
    }
    while (x) {
      if (x % 10 == 3) {
        cout << " " << i;
        break;
      }
      x /= 10;
    }
  }
  cout << endl;
}

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


Measured memory_bytes: 3084
import random
import time
import copy
import math
start=time.time()
d=int(input())
c=list(map(int,input().split()))
s=[]
cli=[]
for i in range(d+1):
  ch=[]
  for j in c:
    ch.append(i*j)
  cli.append(ch)
for i in range(d):
  s.append(list(map(int,input().split())))
last=[0]*26
score=0
solution=[]
for day in range(1,d+1):
  co=[]
  dla=[]
  down=0
  for (i,j) in zip(last,c):
    down+=(day-i)*j
  for (i,j) in zip(last,c):
    dla.append(down-(j*(day-i)))
  for con in range(26):
    co.append(s[day-1][con]-dla[con])
  choice=co.index(max(co))
  score+=co[choice]
  last[choice]=day
  #print(choice+1)
  #print(score)
  solution.append(choice)
#print(score)
stemp=5000
etemp=1
def tem():
  return stemp-((stemp-etemp)*(time.time()-start)/1.9)
while time.time()-start<1.9:
  
  sc=0
  sol=copy.deepcopy(solution)
  for x in [random.randrange(d) for i in range(1)]:
    sol[x]=random.randrange(26)
  last=[0]*26
  for (day,i) in zip(range(1,d+1),sol):
    sc+=s[day-1][i]
    last[i]=day
    for (i,j) in zip(last,range(26)):
      sc-=cli[day-i][j]
  try:
    prob = math.exp((sc-score)/tem())
  except:
    prob=0
  #print("{} {}".format(sc,prob))
  if prob>random.random():
    solution=copy.deepcopy(sol)
    score=sc
    #print(score)
for i in solution:
  print(i+1)
#print(sco)


Measured memory_bytes: 10528
#include<stdio.h>
#define MAX 120

main()
{
  int ver[MAX][MAX];
  int i,j,a,deg,num,n;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    {
      for(j=1;j<=n;j++)
	{
	  ver[i][j] = 0;
	}
    }

  for(i=1;i<=n;i++)
    {
      scanf("%d%d",&a,&deg);
      for(j=1;j<=deg;j++)
	{
	  scanf("%d",&num);
	  ver[i][num] = 1;
	}
    }

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

  return 0;
}

Measured memory_bytes: 652
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
string s;
int main() {
	cin >> s;
	int ret = 0;
	for (int i = 1; i < s.size(); i++) {
		if (s[i - 1] != s[i]) ret++;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1020
#include<stdio.h>
int main() {
	int x, y;
	while (true) {
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0)break;
		if (x > y) {
			printf("%d %d\n", y, x);
		}
		else {
			printf("%d %d\n", x, y);
		}
	}
	return 0;
}



Measured memory_bytes: 2564
N = int(input())
card_list = list(map(int,input().split()))
card_list.sort(reverse=True)
Alice_list = []
Bob_list = []

for i in range(N):
    if i%2 == 0:
        Alice_list.append(card_list[i])
    else:
        Bob_list.append(card_list[i])

print(sum(Alice_list)-sum(Bob_list))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

  static long[][] dp;
  static boolean[][] isPresent;

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int[] arr = new int[N];
    dp = new long[N + 1][N + 1];
    isPresent = new boolean[N + 1][N + 1];
    long[] prefixSum = new long[N];
    long sum = 0;
    for (int i = 0; i < N; i++) {
      arr[i] = scanner.nextInt();
      sum += arr[i];
      prefixSum[i] = sum;
    }
    System.out.println(solve(arr, prefixSum, 0, arr.length));
  }

  private static long solve(int[] arr, long[] prefixSum, int start, int end) {
    long solve = Long.MAX_VALUE;
//    System.out.println(start + ", " + end);
    if (start == end - 1) {
      solve = 0;
    } else {
      for (int i = start + 1; i < end; i++) {
        if (!isPresent[start][i]) {
          dp[start][i] = solve(arr, prefixSum, start, i);
          isPresent[start][i] = true;
        }
        if (!isPresent[i][end]) {
          dp[i][end] = solve(arr, prefixSum, i, end);
          isPresent[i][end] = true;
        }
        long solve1 = dp[start][i];
        long solve2 = dp[i][end];
        solve =
            Math.min(solve, solve1 + solve2 + prefixSum[end - 1] - prefixSum[start] + arr[start]);
      }
      dp[start][end] = solve;
      isPresent[start][end] = true;
    }
    return solve;
  }

}


Measured memory_bytes: 28080
#include <bits/stdc++.h>
using namespace std;
#define senor_SR ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef int32_t i32;

#define int long long
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define pf push_front

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>=b;i--)
#define FILL(a,b,c) for(ll i=0;i<c;i++) a[i]=b;

#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()

#define endl "\n"
#define setpri(x) setprecision(x)
#define vp(x) cout<<#x<<" : "<< (x)<<" | "
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define farr(a,n) for(long long i=0;i<n;i++) cin>>a[i];
#define fvec(vec,n) for(long long i=0;i<n;i++) {ll tmp;cin>>tmp;vec.pb(tmp);}
#define parr(a,n) for(long long i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define prvec(v) for(long long i=v.size()-1;i>=0;i--) cout<<v[i]<<" "; cout<<endl;
#define pvecpair(v) for(long long i=0;i<v.size();i++) cout<<v[i].first<<" "<<v[i].second<<endl;

#define INF 1e17+4
#define MINF 
#define MAX_INT 100000
#define MOD 1000000007
ll mod(ll n) { n %= MOD; if (n < 0) return n + MOD; else return n;}
// vector<int> adj[1000002];
// int vis[1000002],dep[1000002],siz[1000002];

// void dfs(ll cur,ll par)
// {
//     vis[cur]=1;siz[cur]=1;
//     for(auto x:adj[cur])
//     {
//         if(vis[x]!=1)
//         {
//             dep[x]=dep[cur]+1;
//             dfs(x,cur);
//             siz[cur]+=siz[x];
//         }    
//     }
// }

// bool myfunc1(const pair<int,int> &a, const pair<int,int> &b) { return ;}

void solve()
{
    int n;cin>>n;
    map<string,int> m;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        m[s]++;
    }
    cout<<m.size();
}

signed main()
{
    senor_SR;
    
    // ll t;cin>>t;while(t--)
        solve();
 
    return 0;
}

Measured memory_bytes: 19144
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int x, t; cin >> x >> t;
	cout << max(x-t, 0)<< endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

using Graph = vector<vector<int>>;

typedef pair<int, int> P;
const int MOD = 1000000007;


int main(){
    string S; cin >> S;

    int n = S.size();

    int ans = 0;
    int red_count = 0;
    int blue_count = 0;
    rep(i,n){
        if (S[i] == '0') red_count++;
        else blue_count++;
        while (red_count >= 1 && blue_count >= 1){
            ans += 2;
            red_count--;
            blue_count--;
        } 
    }

    cout << ans << endl;
}



Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ull  unsigned long long
#define vll  vector <long long>
#define pll pair <long long,long long>
#define f first
#define s second
#define up upper_bound
#define lp lower_bound
#define pq priority_queue
#define inf 1e10
#define minf -1e10
#define pi 3.14159265
#define mod 300000000000000000
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);
int main()
{
  ll n,W;
  cin>>n>>W;
  vector <pll> vec;
  ll ara[n+1][W+1];
  for(ll i=0;i<n;i++)
  {
      ll num,num1;
      cin>>num>>num1;
      vec.pb(mp(num,num1));
  }
  for(ll i=0;i<=n;i++)
  {
      for(ll j=0;j<=W;j++)
      {
          if(i==0||j==0)
          {
              ara[i][j]=0;
          }
          else if(vec[i-1].f<=j)
          {
              ara[i][j]=max(vec[i-1].s+ara[i-1][j-vec[i-1].f],ara[i-1][j]);
          }
          else
            ara[i][j]=ara[i-1][j];
      }
  }
  cout<<ara[n][W]<<endl;

}


Measured memory_bytes: 79104
#include <iostream>
#include <stdio.h>
#include <map>
using namespace std;
int main(){
    int n;
    cin>>n;
    map<string,bool>ans;
    char com[6],ch[12];
    for(int i=0;i<n;i++){
        scanf("%s%s",com,ch);
        if(com[0]=='i'){
            ans[string(ch)]=true;
        }else if(com[0]=='f'){
            if(ans[string(ch)]){
                cout<<"yes"<<endl;
            }else{
                cout<<"no"<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 47512
// 2013 7/4
import java.lang.*;
import java.util.*;
//1153
public class Main
{
    static Scanner sc = new Scanner(System.in);
        
    public static void main(String args[])
    {
        int[] p = new int[300000];
        int c=0;
        Arrays.fill(p,1);
        for(int i=2; i<300000; i++){
            if(p[i] == 1){
                if(i%7 == 1 || i%7 == 6){
                    for(int j=i*2; j<300000; j+=i){
                        p[j] = 0;
                    }
                    c++;
                   
                }else p[i] = 0;
            }
        }
        
        while( true ){
            int n = sc.nextInt();
            if(n==1) break;
             System.out.print(n+":");    

            for(int i=2; i<300000; i++){
                if(p[i] == 1 && n%i==0)System.out.print(" " + i);
                
            }
             System.out.println();    
             
        }
    }   
}


	    

Measured memory_bytes: 26204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  ll n, d, ans = 0;
  cin >> n >> d;
  vector<ll> x(n), y(n);
  REP(i, n) { cin >> x[i] >> y[i]; }
  REP(i, n) {
    if (x[i] * x[i] + y[i] * y[i] <= d * d) ans++;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 6424
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;
////////////////いろいろあるよ//////////////////////////////////
 
int main(){
  int data[3][3];
  REP(i,3)REP(j,3)cin >> data[i][j];
  int N;
  cin >> N;
  REP(i,N){
    int b;
    cin >> b;
    REP(i,3){
      REP(j,3){
        if(b == data[i][j])data[i][j]=-1;
      }
    }
  }
  REP(i,3){
      if(data[i][0]+data[i][1]+data[i][2]==-3){
        cout << "Yes" << endl;
      	return 0;
      }else if(data[0][i]+data[1][i]+data[2][i]==-3){
        cout << "Yes" << endl;
        return 0;
      }
    }
  
 if(data[0][0]+data[1][1]+data[2][2]==-3){
   cout << "Yes" << endl;
   return 0;
 }else if(data[0][2]+data[1][1]+data[2][0]==-3){
   cout << "Yes" << endl;
   return 0;
 }
  cout << "No" << endl;
  return 0;
  
}

Measured memory_bytes: 256
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

n = iinput()
a = iarr()

ans = 1
for num in a:
    ans *= num
    if ans > 10**18: ans = -1; break
if 0 in a: ans = 0
print(ans)



Measured memory_bytes: 51260
def check(x, y)
  2.times do |z|
    4.times do
      return true if x == y
      a, b, c, d, e, f  = x
      x = z.zero? ? [e, a, c, d, f, b] : [d, b, a, f, e, c]
      c = x
      4.times do
        i, j, k, l, m, n = c
        c = [i, k, m, j, l, n]
        return true if c == y
      end
    end
  end
  false
end

ar = $<.map(&:chomp).map(&:split).drop(1)
ar.size.times do |x|
  (x+1).upto(ar.size) do |y|
    (puts 'No')^exit if check(ar[x], ar[y])
  end
end
puts 'Yes'

Measured memory_bytes: 9872
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MOD 998244353
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
typedef unsigned short int usi;

// 昇順
int cmp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

int main()
{
    int n, m, max=0;
    int k[30], a[30][30];
    int i, j;
    scanf("%d %d",&n, &m);
    int *count = (int*)calloc(m, sizeof(int));
    int ans=0;
    for(i=0; i<n; i++) {
        scanf("%d",&k[i]);
        for(j=0; j<k[i]; j++) {
            scanf("%d",&a[i][j]);
            count[a[i][j]-1]++;
        }
    }
    for(i=0; i<m; i++) {
        if(count[i]==n)ans++;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

//最長回文の長さを求める。
//O(N)

int Manarcher(const string &_s) {
  int n = _s.size();
  string s(2 * n + 1, '#');
  for (int i = 0; i < n; i++) s[2 * i + 1] = _s[i];
  n = 2 * n + 1;

  vector<int> rad(n);
  for (int i = 0, j = 0; i < n;) {
    while (i - j >= 0 && i + j < n && s[i - j] == s[i + j]) j++;
    rad[i] = j;

    int k;
    for (k = 1; i - k >= 0 && rad[i] - k > rad[i - k]; k++) rad[i + k] = rad[i - k];

    i += k;
    j = max(j - k, 0LL);
  }
  return *max_element(rad.begin(), rad.end()) - 1;
}

signed main() {
  string s;
  int ans = 0;
  while (cin >> s) {
    if (s.size() == Manarcher(s)) ans++;
  }

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



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

#define INF 2e+9
#define MAX_N 100000

int dp[MAX_N];
int n;
vector<int> a;

void solve() {
    int *point;
    fill(dp, dp+n, INF);
    for (int i=0; i<n; ++i) {
        point = lower_bound(dp, dp+n, a[i]);
        while(*point == a[i]){
            ++point;
        }
        *point = a[i];
    }
    cout << lower_bound(dp, dp+n, INF) - dp << endl;
}

int main() {
    cin >> n;
    a.resize(n);
    for(int i=n-1; i>=0; --i) cin >> a[i];
    solve();
    system("pause");
    return 0;
}

Measured memory_bytes: 1272
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		player player1[] = new player[8];
		player player2[] = new player[8];
		player player3[] = new player[8];
        for(int i=0; i<8; i++)player1[i] = new player(sc.nextInt() , sc.nextDouble());
        for(int i=0; i<8; i++)player2[i] = new player(sc.nextInt() , sc.nextDouble());
        for(int i=0; i<8; i++)player3[i] = new player(sc.nextInt() , sc.nextDouble());
        
        Arrays.sort(player1);
        System.out.println(player1[0] + "\n" + player1[1]);
        player1[0].record = 50;
        player1[1].record = 50;
         
        Arrays.sort(player2);
        System.out.println(player2[0] + "\n" + player2[1]);
        player2[0].record = 50;
        player2[1].record = 50;
         
        Arrays.sort(player3);
        System.out.println(player3[0] + "\n" + player3[1]);
        player3[0].record = 50;
        player3[1].record = 50;
        
        Arrays.sort(player1);
        Arrays.sort(player2);
        Arrays.sort(player3);
        player player4[]= new player[6];
        player4[0] = new player(player1[0].playerNumber,player1[0].record);
        player4[1] = new player(player1[1].playerNumber,player1[1].record);
        player4[2] = new player(player2[0].playerNumber,player2[0].record);
        player4[3] = new player(player2[1].playerNumber,player2[1].record);
        player4[4] = new player(player3[0].playerNumber,player3[0].record);
        player4[5] = new player(player3[1].playerNumber,player3[1].record);
        Arrays.sort(player4);
        System.out.println(player4[0] + "\n" + player4[1]);
    }
}
	class player implements Comparable<player>{
		int playerNumber;
	    double record;
	    player(int playerNumber, double record){
	        this.playerNumber = playerNumber;
	        this.record = record;
	    }
	    @Override
	    public String toString(){
	        return  playerNumber + " " + record;
	    }
	    @Override
	    public int compareTo(player o) {
	    	return new Double(record).compareTo(o.record);
	    }
}

Measured memory_bytes: 28108
/* abc_171_b */

#include<stdio.h>

int main()
{
  int N,K;
  int i,j,t,s;
  int p[1000];
  for(i=0;i<1000;i++){
    p[i]=0;
  }
  s=0;
  scanf("%d",&N);
  scanf("%d",&K);
  for (i=0;i<N;i++){
    scanf("%d",&p[i]);
  }
  for (i=0;i<N;i++){
    for (j=i+1;j<N;j++){
      if(p[i]>p[j]){
        t=p[i];
        p[i]=p[j];
        p[j]=t;
      }
    }
  }
  for(i=0;i<K;i++){
    s+=p[i];
  }
  printf("%d\n",s);
  return 0;
}


Measured memory_bytes: 1740
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <locale>
using namespace std;

int main(){
    char a,b;
    cin >> a >> b;
    if(a == 'H' && b == 'H'){cout << 'H' << endl;}
    else if(a == 'H' && b == 'D'){cout << 'D' << endl;}
    else if(a == 'D' && b == 'H'){cout << 'D' << endl;}
    else if(a == 'D' && b == 'D'){cout << "H" << endl;}

    return 0;
}

Measured memory_bytes: 768
// -*- mode: cpp; coding=utf-8-unix; -*-
// vim: filetype=cpp fileencoding=utf-8 fileformat=unix
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define INTMAX  99999999

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

#define MAX_M (1000*100)
#define MAX_N (1000*100)

int N,M;
int L[MAX_M];
int R[MAX_M];

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

	cin >> N >> M;

	int maxL = 0;
	int minR = MAX_N;
	for(int i=0; i<M; i++) {
		cin >> L[i] >> R[i];
		maxL = max(maxL, L[i]);
		minR = min(minR, R[i]);
	}

	int ans = 0;
	ans = max(minR-maxL+1, 0);
	cout << ans << endl;

	return 0;
}



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

int a[3][3];

int main(){
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> a[i][j];
        }
    }
    int n; cin >> n;
    bool ok=false;
    for(int i=0;i<n;i++){
        int b; cin >> b;
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(a[j][k]==b) a[j][k]=0;
            }
        }
        bool f,g;
        for(int j=0;j<3;j++){
            f=true;g=true;
            for(int k=0;k<3;k++){
                if(a[j][k]!=0) f=false;
                if(a[k][j]!=0) g=false;
            }
            if(f || g) break;
        }
        bool h=false;
        if(a[0][0]==0 && a[1][1]==0 && a[2][2]==0) h=true;
        if(a[2][0]==0 && a[1][1]==0 && a[0][2]==0) h=true;
        if(f || g || h){ok=true;}
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main(){
	var a, b, c, s, l, h, theta float64
	fmt.Scan(&a, &b, &c)
	theta = math.Pi / 180.0 * c
	s = a * b * math.Sin(theta) / 2.0
	l = a + b + math.Sqrt(a*a+b*b-2.0*a*b*math.Cos(theta))
	h = b * math.Sin(theta)
	fmt.Println(s)
	fmt.Println(l)
	fmt.Println(h)
}


Measured memory_bytes: 1152
n=int(input())
s=input()
ans=0
for i in range(1,n):
    x,y=set(s[:i]),set(s[i:])
    #print(x,y)
    tmp=0
    for j in x:
        if j in y:
            #print(j,y)
            tmp+=1
            #print("tmp",tmp)
    if ans<tmp:
        ans=tmp
print(ans)
    

Measured memory_bytes: 2940
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}
template<typename T> inline void in(T &e){cin>>e;}
template<typename T> inline void out(T e){cout<<e<<endl;}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int n;

signed main(){
    io();
    in(n);
    int ans=0;
    for(int i=1;i<=n;i+=2){
        int res=0;
        REP(j,1,i+1){
            if(i%j==0) res++;
        }
        if(res==8) ans++; 
    }

    out(ans);

    return 0;
}


Measured memory_bytes: 888
for t in xrange(input()):
    x0, y0, x1, y1, x2, y2, x3, y3 = map(int, raw_input().split())
    dx0 = x1 - x0
    dy0 = y1 - y0
    dx1 = x3 - x2
    dy1 = y3 - y2

    s = (y0-y2)*dx1 - (x0-x2)*dy1
    sm = dx0*dy1 - dy0*dx1
    if s < 0:
        s = -s
        sm = -sm
    t = (y2-y0)*dx0 - (x2-x0)*dy0
    tm = dx1*dy0 - dy1*dx0
    if t < 0:
        t = -t
        tm = -tm
    if 0 <= s <= max(sm, 0) and 0 <= t <= max(tm, 0):
        ov = dx0*dy1 - dy0*dx1
        if ov == 0:
            r0 = dx0**2 + dy0**2
            r1 = (x2-x0)*dx0 + (y2-y0)*dy0
            r2 = (x3-x0)*dx0 + (y3-y0)*dy0
            if r1 > r2: r1, r2 = r2, r1
            if r2 < 0 or r0 < r1:
                print 0
            else:
                print 1
        else:
            print 1
    else:
        print 0

Measured memory_bytes: 6476
require "set"

S = gets.chomp

acgt = Set["A", "C", "G", "T"]
ans = 0

0.upto(S.length - 1).each do |i|
  cnt = 0
  i.upto(S.length - 1).each do |j|
    break unless acgt.include?(S[j])
    cnt += 1
  end
  ans = [ans, cnt].max
end
puts ans


Measured memory_bytes: 2172
#010101…と101010…の2通り
#2通りともコストを計算して小さい方を採用するだけ。
#文字列処理のほうが楽。if文注意
s = input()
even = True
ans1=0#010101…
ans2=0#101010…
for c in s:
  if even:
    even = False
    if c == '0':
      ans2 += 1
    else:
      ans1 += 1
  else:
    even = True
    if c == '0':
      ans1 += 1
    else:
      ans2 += 1
print(min([ans1,ans2]))

Measured memory_bytes: 3188
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
ll n;
int main()
{
	cin >> n;
	if(n==0)
	{
		cout << 0 << endl;
		return 0;
	}
	ll r = 1ll;
	int c = 0;
	while(r<=n)
	{
		r*=2ll;
		c++;
	}
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 1160
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
void solve() {
	string s;
	while (true) {
		cin >> s;
		if (s == "#") return;
		ll bunsi = 0;
		vector<int> gogo;
		REP(i, s.length()) {
			if (s[i] == 'w') {
				i += 3;
				gogo.push_back(90);
			}
			else {
				i += 4;
				gogo.push_back(0);
			}
		}
		int bunbo = 1;
		bunsi = gogo.back();
		for (int i = (int)gogo.size() - 2; i >= 0; --i) {
			bunsi *= 2LL;
			bunbo *= 2LL;
			if (gogo[i] == 90) {
				bunsi += 90;
			}
			else {
				bunsi -= 90;
			}
		}
		while (bunsi % 2 == 0 && bunbo % 2 == 0) {
			bunsi /= 2;
			bunbo /= 2;
		}
		cout << bunsi;
		if (bunbo != 1) {
			cout << "/" << bunbo;
		}
		cout << endl;
	}
}
#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3044
N, P = map(int, input().split())
A = list(map(int, input().split()))
mod0, mod1 = 0, 0
for a in A:
  if a % 2 == 0: mod0 += 1
  else: mod1 += 1
#print(mod0, mod1)

from math import factorial
comb0 = 2 ** mod0
comb1 = 0
if mod1 > 0:
  for i in range(P, mod1+1, 2):
    comb1 += factorial(mod1) // (factorial(mod1 - i) * factorial(i))
else:
  if P == 0:
    comb1 = 1
ans = comb0 * comb1
#print(comb0, comb1)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstdio>
using namespace std;

class Dice{
public:
  //Dice();
  void input();
  void routen(char ch);
  int upnum(){
    return d[0];
  }
  int find(int, int);
private:
  int tmp[6], d[6];
};

void Dice::input(){
  for(int i=0;i<6;i++){
    cin >> d[i];
  }
}

int Dice::find(int up, int forward){
  char v[5] = "SSSW";
  for(int k=0;k<7;k++){
    for(int i=0;i<4;i++){
      if(d[0] == up && d[1] == forward){
        return d[2];
      }else if(d[1] == up && d[0] == forward){
        return d[3];
      }
      routen(v[i]);
    }
  }
  return 0;
}

void Dice::routen(char ch){
  for(int i=0;i<6;i++){
    tmp[i] = d[i];
  }
  switch(ch){
    case 'E':
      d[0] = tmp[3];
      d[2] = tmp[0];
      d[3] = tmp[5];
      d[5] = tmp[2];
    break;
    case 'W':
      d[0] = tmp[2];
      d[2] = tmp[5];
      d[3] = tmp[0];
      d[5] = tmp[3];
    break;
    case 'S':
      d[0] = tmp[4];
      d[1] = tmp[0];
      d[5] = tmp[1];
      d[4] = tmp[5];
    break;
    case 'N':
      d[0] = tmp[1];
      d[1] = tmp[5];
      d[5] = tmp[4];
      d[4] = tmp[0];
    break;
  };
}

int main(){
  Dice dice;
  int N, forward, up;
  vector<int> v;

  dice.input();
  cin >> N;

  for(int i=0;i<N;i++){
    cin >> up >> forward;
    v.push_back(dice.find(up, forward));
  }

  for(int i=0;i<N;i++){
    cout << v[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 1220
N, Y = map(int, input().split())

ans = [-1, -1, -1]
for i in range(N+1):
    for j in range(N-i+1):
        k = N - (i + j)
        if 10000*i + 5000*j + 1000*k == Y:
            ans = [i, j, k]
            break
    else:
        continue
    break

print(ans[0], ans[1], ans[2])

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

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

  vector<vector<double>> x(N, vector<double>(D));

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> x[i][j];
    }
  }
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int y = i + 1; y < N; y++) {
      double sum = 0.0;
      for (int z = 0; z < D; z++) {
        sum += pow(abs(x[i][z] - x[y][z]), 2.0);
      }
      double a = sqrt(sum);
      if (ceil(a) == floor(a)) { cnt++; }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
N = int(input())
*A, = map(int, input().split())
a = b = 0
for i in range(1, N):
    if i > 1:
        a, b = b, min(a + abs(A[i] - A[i-2]), b + abs(A[i] - A[i-1]))
    else:
        a, b = b, a + abs(A[i] - A[i-1])
print(b)

Measured memory_bytes: 13928
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N;
  cin>>N;
  VI L(N);
  rep(i,N) cin>>L[i];
  sort(all(L));
  ll ans=0;
  rep(i,N) rep(j,N){
    if(i<j){
      int U=lower_bound(all(L),L[i]+L[j])-L.begin();
      int D=upper_bound(all(L),abs(L[i]-L[j]))-L.begin();
      int Z=U-D;
      if(abs(L[i]-L[j])<L[i]) Z--;
      if(abs(L[i]-L[j])<L[j]) Z--;
      ans+=Z;
    }
  }
  cout<<ans/3<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 2e18;
const ll fact_table = 1200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
    #undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
// const ll mod = 998244353ll;
const ll mod = 2000000011;
  
ll mypow(ll number1,ll number2, ll mod){
    if(number2 == 0){
        return 1ll;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/

bool multicase = false;

ll n,m,num,a,b,c,d,e,h,q;
ll w, k, l, r;
ll x[500005], y[500005], z[500005];
string s;

void solve(){
    cin >> s;
    bool find = false;
    for(ll i=0;i<s.size();i++){
        if(s[i] == '7')find = true;
    }
    Yes(find);
    return;
}


int main(){
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;

    if(multicase){
        cin >> q;
    }else{
        q = 1;
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    
    // solve();
    return 0;

}
















Measured memory_bytes: 3632
#include<stdio.h>
int main(void)
{
    int n,a,b,c;
    int cal[10000]={0};
    int i,j;
    int x,z;
    int xx=0,yy = 0;//”a&#352;r—p

    scanf("%d%d%d%d",&n,&a,&b,&c);
    for(i = 0;i < n; i++) scanf("%d",&cal[i]);

    for(i = 0;i < n; i++){
        for(j = 0;j < n; j++){
            if(cal[i] > cal[j]){
                x = cal[i];
                cal[i] = cal[j];
                cal[j] = x;
            }
        }
    }
    z = c;
    xx = c/a;
    for(i = 1;i <= n; i++){
        z += cal[i-1];
        yy = z / ((b*i)+a);
        if(xx <=yy)xx = yy;
        else break;
    }
    printf("%d\n",xx);
    return 0;
}

Measured memory_bytes: 640
n, m = map(int,input().split())
lst = list(map(int,input().split()))
lst2 = []
for i in range(n):
    lst3 = [lst[i]]
    lst2.append(lst3)

for i in range(m):
    a, b = map(int,input().split())
    a = a - 1
    b = b - 1
    lst2[a].append(lst2[b][0])
    lst2[b].append(lst2[a][0])

ans = 0
for i in range(n):
    x = lst2[i][0]
    lst2[i].sort()
    lst2[i].reverse()
    if (len(lst2[i]) == 1):
        ans = ans + 1
    elif (x == lst2[i][0]):
        lst2[i].pop(0)
        y = lst2[i][0]
        if (x != y):
            ans = ans + 1

print(ans)


Measured memory_bytes: 26936
#include <bits/stdc++.h>
#define NAME "taskA"
#define scan 1
bool isFile;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

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

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;

#define mp make_pair
#define pb push_back
#define fr first
#define sc second

#define ins insert
#define all(v) v.begin(), v.end()
#define rep(i,a,n) for (int i=a;i<n;i++)
#define onbit(x, i) (x | (1ll << (i - 1)))
#define offbit(x, i) (x & ~(1ll << (i - 1)))
#define bpc(x) __builtin_popcountll(x)
#define rev(a) reverse(all(a))
#define skip continue
#define read(a) for(auto &i : a) cin >> i
#define print(a) for(auto i : a) cout << i << ' '
#define unique(a) sort(all(a));    a.resize(unique(all(a)) - a.begin())

//                D  R  U   L
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

void _();

void faster() {
    _();
    if (isFile) {
        freopen(NAME".in", "r", stdin);
        freopen(NAME".out", "w", stdout);
    }
    if (scan) {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    }
}

const ll  INF = 1e18;
const int inf = 2e9;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ld  PI = acos(-1);
const ld  EPS = 3E-16;
const int ALPHA = 27;
const int N = (int)1e5 + 5;
const int M = 1234;

namespace MATH_CAL {
    const int mod = MOD;
    inline ll add(ll a, ll b) { return a + b >= mod ? a + b - mod : a + b; }
    inline ll sub(ll a, ll b) { return a - b < 0 ? a - b + mod : a - b; }
    inline ll mul(ll a, ll b) { return (ll) a * b % mod; }
    inline void Add(ll &a, ll b) { (a += b) >= mod ? a -= mod : 0; }
    inline void Sub(ll &a, ll b) { (a -= b) < 0 ? a += mod : 0; }
    inline ll qpow(ll x, ll n) { ll r = 1; for ( ; n; n /= 2, x = mul(x, x)) if (n & 1) r = mul(r, x); return r; }
    inline ll mod_inv(ll x) { return qpow(x, mod - 2); }
    inline ll gcd(ll a, ll b) {while(b) {a %= b; swap(a, b);} return a;}
    inline ll lcm(ll a, ll b) {return a * b / gcd(a, b);}
} using namespace MATH_CAL;

void solve() {
    ll x;
    cin >> x;
    double yen = 100;
    ll year = 0;
    while((ll) yen < x) {
        year++;
        yen *= 1.01;
        yen = (ll) yen;
    }
    cout << year << endl;
}

void _() {
//    isFile = 1;
}

int main() {
    faster();
    int t = 1;
//    cin >> t;
    while(t--) {
         solve();
    }
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define loop for(;;)
typedef std::vector<long> LI;
template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   long memo[314][314];
   LI xs;
   long dfs(long left, long right) {
      if( memo[left][right] != -1 ) return memo[left][right];
      if( right - left <= 1 ) return 0;
      long res = 0;
      if( std::abs(xs[right-1] - xs[left]) <= 1 ) {
         long x = dfs(left + 1, right - 1);
         if( x == (right - 1) - (left + 1) ) {
            res = std::max(res, x + 2);
         }
      }
      for(long i = left + 1; i <= right - 1; ++i) {
         res = std::max(res, dfs(left, i) + dfs(i, right));
      }
      return memo[left][right] = res;
   }
   void solve() {
      long n; scan(n);
      if( n == 0 ) exit(0);
      xs.resize(n); for(long &x : xs) scan(x);
      init();
      printf("%ld\n", dfs(0, n));
   }
   void init() {
      for(long i = 0; i < 314; ++i) {
         for(long k = 0; k < 314; ++k) {
            memo[i][k] = -1;
         }
      }
   }
};

int main() {
   loop std::shared_ptr<Solver>(new Solver())->solve();
}

Measured memory_bytes: 4064
#include <iostream>
using namespace std;
#define MAX (500000)
int H,A[MAX+1];

void MaxHeap(int i){
    int l,r,max;
    l=2*i;
    r=2*i+1;
    if(l<=H&&A[l]>A[i])max=l;
    else max=i;
    if(r<=H&&A[r]>A[max])max=r;
    
    if(max!=i){
        swap(A[i],A[max]);
        MaxHeap(max);
    }
}

int main(void){
    cin>>H;
    for(int i=1;i<=H;i++){
        cin>>A[i];
    }
    for(int i=H/2;i>=1;i--){
        MaxHeap(i);
    }
    for(int i=1;i<=H;i++){
        cout<<" "<<A[i];
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 4996
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String args[])throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
        String str = br.readLine();
        int money = Integer.parseInt(str);
        int result = 0;
        int concern = 0;

        result = (int)Math.floor(money / 1.08);
        concern = (int)Math.floor(result * 1.08);

        if(concern == money){
          System.out.println(result);
        }else{
          concern = (int)Math.floor((result + 1) * 1.08);
          if(concern == money){
            System.out.println(result + 1);
          }else{
            System.out.println(":(");
          }
        }
      }
    }
}

Measured memory_bytes: 22996
S = gets.chomp.split(//)
acgt = %w(A C G T)
max = 0
cnt = 0
for n in (0..S.length-1)
  for m in (n..S.length-1)
    if acgt.include?(S[m])
      cnt += 1
    else
      break
    end
  end
  max = cnt if cnt > max
  cnt = 0
end
puts max

Measured memory_bytes: 3836
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

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

signed main(){
    int n, c;
    cin >> n >> c;

    vector<int> x(n+1), v(n+1), rx(n+1), rv(n+1);
    for(int i = 1; i <= n; i++){
        cin >> x[i] >> v[i];
        rx[n+1-i] = c - x[i];
        rv[n+1-i] = v[i];
    }

    vector<int> s(n+1), rs(n+1);
    for(int i = 1; i <= n; i++){
        s[i] = s[i-1] + v[i];
        rs[i] = rs[i-1] + rv[i];
    }

    vector<int> maxV(n+1), maxRV(n+1);
    for(int i = 1; i <= n; i++){
        maxV[i] = max(maxV[i-1], s[i] - x[i]);
        maxRV[i] = max(maxRV[i-1], rs[i] - rx[i]);
    }

    int ans = 0;
    for(int i = 0; i <= n; i++){
        int tmp = maxV[i];
        tmp += max((int)0, maxRV[n-i] - x[i]);
        if(ans < tmp){
            ans = tmp;
        }
    }

    for(int i = 0; i <= n; i++){
        int tmp = maxRV[i];
        tmp += max((int)0, maxV[n-i] - rx[i]);
        if(ans < tmp){
            ans = tmp;
        }
    }

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


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
long long a,b,t,c,ans;
int main (){
    cin>>t;
    for(int i=1;i<=t;i++)
	{
        ans=0;
		cin>>a>>b;
        if(a==b) ans=2*a-2;
        else
		{
            c=sqrt(a*b);
            if(c*c==a*b) c--;
            if(c*(c+1)>=a*b) ans=2*c-2;
            else ans=2*c-1;
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

int A, B;

int main() {
  cin >> A >> B;
  int num[3] = {1, 2, 3};
  for(int i = 0; i < 3; i++) {
    if(num[i] == A || num[i] == B) continue;
    else cout << num[i] << endl;      
  }        
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long 
#define double long double 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(a) (a).begin(),(a).end()

using namespace std;


signed main(){
	IOS;
	double l ;
	cin>>l;
	cout << fixed << setprecision(20) << (l*l*l)/(27) << endl ;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

int L;

// dijkstra O(ElogV)
// verify : https://onlinejudge.u-aizu.ac.jp/problems/GRL_1_A
template<typename T>
struct Dijkstra {
private:
    int V;
    struct edge { int to; T cost; };
    vector<vector<edge>> G;
public:
    const T inf = numeric_limits<T>::max();

    // s から i の最小コスト
    // 経路がない場合は inf
    vector<pair<int, T>> d;

    Dijkstra(int V) : V(V) {
        G.resize(V);
    }

    // 辺の追加
    // 有向の場合　directed = true
    void add_edge(int from, int to, T weight, bool directed = false) {
        G[from].push_back({to,weight});
        if (!directed) G[to].push_back({from,weight});
    }

    void build(int s) {
        d.assign(V, {INF,inf});
        typedef pair<pair<int, T>, int> P; //(回数,-燃料,v)
        priority_queue<P, vector<P>, greater<P>> pq;
        d[s] = {0,-L};
        pq.push(P(d[s], s));
        while (!pq.empty()) {
            P p = pq.top(); pq.pop();
            int v = p.second;
            if (d[v] < p.first) continue;
            for (const edge &e : G[v])
            {
                // 最小値が更新されるとき push
                if (d[v].second + e.cost <= 0 && d[e.to] > make_pair(d[v].first, d[v].second + e.cost)) {
                    d[e.to] = make_pair(d[v].first, d[v].second + e.cost);
                    pq.push({d[e.to], e.to});
                }
                if (-L + e.cost <= 0 && d[e.to] > make_pair(d[v].first + 1, -L + e.cost)) {
                    d[e.to] = make_pair(d[v].first + 1, -L + e.cost);
                    pq.push({d[e.to],e.to});
                }
            }
        }
    }
};

int main() {
    int n, m; cin >> n >> m >> L;
    vector<vector<ll>> ans(n,vector<ll>(n));
    Dijkstra<ll> G(n);
    REP(i, m) {
        int a, b; ll c; scanf("%d %d %lld", &a, &b, &c);
        a--; b--;
        G.add_edge(a, b, c);
    }
    REP(i, n) {
        G.build(i);
        REP(j, n) {
            ans[i][j] = (G.d[j].first == INF ? -1 : G.d[j].first);
        }
    }
    int q; cin >> q;
    REP(i, q) {
        int s, t; scanf("%d %d", &s, &t);
        s--; t--;
        printf("%lld\n", ans[s][t]);
    }
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  if (S == "SUN") {
    cout << "7" << endl;
  }
  if (S == "MON") {
    cout << "6" << endl;
  }
  if (S == "TUE") {
    cout << "5" << endl;
  }
  if (S == "WED") {
    cout << "4" << endl;
  }
  if (S == "THU") {
    cout << "3" << endl;
    }
  if (S == "FRI") {
    cout << "2" << endl;
    }
  if (S == "SAT") {
    cout << "1" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){ 
   ll n;
   cin>>n;
   ll ans=1;
   for(int i=1;i<=n;i++){
      ans *= i;
      ans %= 1000000007;
   }
   cout<<ans;






return 0;
}

Measured memory_bytes: 256