akhauriyash/Code-Regression huggingface dataset:
a[2][101],n,m,i,j,c,p;main(s){for(;scanf(m=c="%d",&n),n;printf(m>210?"NA\n":"%d\n",m)){for(a[0][n]=a[1][n]=i=2;i--;)for(j=0;j-n;scanf(c,a[i]+j++));for(i=2;i--;m>c?m=c:0)for(j=i,c=p=0;s=a[j][p],c<220&&s==2|n+~p;)s-2?s-1|a[j][p+1]-1?p+=2,j=1&~j,++c:++p:--p;}}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int enemyH = sc.nextInt();
        int t = sc.nextInt();
        int total = 0;
        for(int i = 0;i < t;i++){
            total += sc.nextInt();
        }
        if(enemyH <= total){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 48152
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define OJ \
        freopen("input.txt","r",stdin); \
        freopen("output.txt","w",stdout);

int main()
{ 
   
//  OJ;
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
  int n,k,ans=0;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
  }
  sort(a,a+n);
  for(int i=0;i<k;i++)
  {
ans+=a[i];
  }
  cout<<ans;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int main(){
	int n;
	cin >> n;
	char registeredID[256][11];
	for(int i=0;i<n;i++){
		cin >> registeredID[i];
	
	}
	int m;
	cin >> m;
	char cardID[256][11];
	for(int i=0;i<m;i++){
		cin >> cardID[i];
	}
	bool isOpen = false;
	for(int i=0;i<m;i++){
		bool contains = false;
		for(int j=0;j<n;j++){
			if(strcmp(cardID[i], registeredID[j])==0){
				//一致している
				contains = true;
				break;
			}
		}
		if(contains==true){
			if(isOpen==true){
				cout << "Closed by " << cardID[i] << endl;
				isOpen = false;
			}else{
				cout << "Opened by " << cardID[i] << endl;
				isOpen = true;
			}
		}else{
			cout << "Unknown " << cardID[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
class BIT():

    __slots__ = ["n", "data"]

    def __init__(self, length_or_list):
        if isinstance(length_or_list, int):
            self.n = length_or_list + 1
            self.data = [0] * self.n
        else:
            self.n = len(length_or_list) + 1
            self.data = [0] + length_or_list
            for i in range(1, self.n):
                if i + (i & -i) < self.n:
                    self.data[i + (i & -i)] += self.data[i]        

    def point_append(self, index, delta):
        index += 1
        while index < self.n:
            self.data[index] += delta
            index += index & -index
        
    def prefix_folded(self, end):
        res = 0
        while end > 0:
            res += self.data[end]
            end -= end & -end
        return res

    def folded(self, begin, end):
        ret = 0
        while begin < end:
            ret += self.data[end]
            end -= end & -end
        while end < begin:
            ret -= self.data[begin]
            begin -= begin & -begin
        return ret

def main():
    import sys
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read
    N, Q = map(int, input().split())
    seg = BIT(list(map(int, input().split())))
    for _ in range(Q):
        a, b, c = map(int, input().split())
        if a:
            print(seg.folded(b, c))
        else:
            seg.point_append(b, c)

if __name__ == "__main__":
    main()

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

using namespace std;

static void inputArray(int A[], int num) {
  for (int i = 0; i < num; i++) {
    cin >> A[i];
  }
}

static inline bool solve(int A[], int i, int n, int m) {
  if (m == 0) {
    return true;
  }
  
  if (i < n) {
    return solve(&A[0], i + 1, n, m) || solve(&A[0], i + 1, n, m - A[i]);
  } else {
    return false;
  }
}

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

  vector<int> A(n);
  inputArray(&A[0], n);

  int q;
  cin >> q;

  int m;
  bool ans;
  for (int i = 0; i < q; i++) {
    cin >> m;
    ans = solve(&A[0], 0, n, m);
    cout << (ans ? "yes" : "no") << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3112
#include <stdio.h>

#define N 3
#define N2 9
#define LEN 362880

typedef struct Puzzle
{
  int f[N2];
  int space;
  int path;
}P;

static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char dir[4] = {'u', 'l', 'd', 'r'};

int V[LEN];
P Q[LEN];
int head = 0;
int tail = 0;

void enqueue(P);
P dequeue(void);
int bfs(P);
int isTarget(P);
int henkan(P);

int main()
{
  P in;

  int i, ans;

  for(i = 0; i < N2; i++)
    {
      scanf("%d",&in.f[i]);

      if(in.f[i] == 0)
	{
	  in.f[i] = N2;
	  in.space = i;
	}
    }

  ans = bfs(in);

  printf("%d\n",ans);

  return 0;
}

void enqueue(P num)
{
  int next = (tail+1)%LEN;

  Q[tail] = num;
  tail = next;
}

P dequeue(void)
{
  P val;
  
  val = Q[head];
  head = (head+1)%LEN;
  
  return val;
}

int bfs(P s)
{
  P u, v;
  int sx, sy, tx, ty, r, temp;

  s.path = 0;
  enqueue(s);
  V[henkan(s)] = 1;

  while(head != tail)
    {
     
      u = dequeue();
      if(isTarget(u))return u.path;
      sx = u.space/N;
      sy = u.space%N;

      for(r = 0; r < 4; r++)
	{
	  tx = sx + dx[r];
	  ty = sy + dy[r];
	  if( tx < 0 || ty < 0 || tx >= N || ty >= N)continue;
	  v = u;
	  temp = v.f[u.space];
	  v.f[u.space] = v.f[tx * N + ty];
	  v.f[tx * N + ty] = temp;
	  v.space = tx * N + ty;
	  if(!V[henkan(v)])
	    {
	      V[henkan(v)] = 1;
	      v.path++;
	      enqueue(v);
	    }
	}
    }
  return -1;
}

int isTarget(P p)
{
  int i;
  
  for(i = 0; i < N2; i++)
    {
      if(p.f[i] != (i+1))return 0;
    }
  return 1;
}

int henkan(P v)
{
  int i, j, a, count, order = 0;

  for(i = 0, a = 1; i < N2; a*=++i)
    {
      for(j = 0, count = 0; j < i; j++)
	{
	  if(v.f[j] < v.f[i])count++;
	}
      order += count*a;
    }
  return order;
}



Measured memory_bytes: 10964
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 0, mod = (int) 0;

int main() {
	int mx = 0;
	int n, k;
	cin >> n >> k;
	int g = 0;
	while (n--) {
		int x;
		cin >> x;
		if (g == 0) {
			g = x;
		} else {
			g = __gcd(x, g);
		}
		mx = max(mx, x);
	}
	if (mx >= k && k % g == 0) {
		cout << "POSSIBLE\n";
	} else {
		cout << "IMPOSSIBLE\n";
	}
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int N,ans=0;cin>>N;
    vector<int> map(N,0);
    REP(i,N)cin>>map[i];
    sort(map.begin(),map.end());
    for(int i=1;i<N;i++)ans+=map[i]-map[i-1];
    cout<<ans<<endl;
}

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

int main() {
  ll D,N;
  cin>>D>>N;
  ll f=pow(100,D);
  ll g=f*101;
  if(N!=100) {
    cout<<f*N<<endl;
  }
  else {
    cout<<g<<endl;
  }
}

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++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int k; cin>>k;
    vector<string> suffix;
    rep(i,s.size()){
        suffix.pb(s.substr(i,s.size()-i));
    }
    sort(all(suffix));
    set<string> Set;
    rep(i,s.size()){
        rep(j,suffix[i].size()){
            Set.ins(suffix[i].substr(0,j+1));
            if (Set.size()==k) break;
        }
        if (Set.size()==k) break;
    }
    auto itr = Set.end(); itr--;
    cout<<(*itr)<<endl;
    return 0;
}


Measured memory_bytes: 16128
import Foundation

let main: () = {
    let N = getInt()
    var ans = 0
    for n in 1...N {
        if !n.isMultiple(of: 3) && !n.isMultiple(of: 5) { ans += n }
    }
    print(ans)
}()

func getString() -> String { readLine()! }
func getInt() -> Int { Int(getString())! }
func getDouble() -> Double { Double(getString())! }



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

int main(){
  int k;
  int a, b, c;
  int d, r, o, p;
  int sum = 0;
  
  cin >> k;

  for(a = 1; a <= k; a++)
  {
    for(b = 1; b <= k; b++)
    {
      for(c = 1; c <= k; c++)
      {
        if(a > b)
        {
          o = a;
          p = b;
        }
        else if(a < b || a == b)
        {
          o = b;
          p = a;
        }
        r = o % p;
        while(r != 0)
        {
          o = p;
          p = r;
          r = o % p;
        }
         
        d = p;
        
        if(c > d || c == d)
        {
          o = c;
          p = d;
        }
        else if(c < d)
        {
          o = d;
          p = c;
        }
        r = o % p;
        while(r != 0)
        {
          o = p;
          p = r;
          r = o % p;
        }
        sum += p;   
      }
    }
  }
 
   cout << sum << endl;
}

Measured memory_bytes: 3640
n = int(input())
a = list(map(int, input().split()))
x = a[0]
y = 0
for i in range(1, n):
    y += a[i]
ans = abs(x - y)
for i in range(1, n - 1):
    x += a[i]
    y -= a[i]
    ans = min(ans, abs(x - y))
print(ans)

Measured memory_bytes: 24832
///
// File:  c.go
// Author: ymiyamoto
//
// Created on Sat May 26 21:32:03 2018
//
package main

import (
	"fmt"
)

var N int
var S string

func main() {
	fmt.Scan(&N, &S)
	w := make([]int, N)
	e := make([]int, N)

	for i := range S {
		if S[i] == 'E' {
			w[i] += 1
		}
		if i != 0 {
			w[i] += w[i-1]
		}
	}

	for i := len(S) - 1; i >= 0; i-- {
		if S[i] == 'W' {
			e[i] += 1
		}
		if i != len(S)-1 {
			e[i] += e[i+1]
		}
	}

	min := 1 << 30
	for i := range w {
		var a, b int
		if 0 <= i-1 {
			a = w[i-1]
		}
		if i+1 < len(w) {
			b = e[i+1]
		}

		n := N - 1 - (a + b)
		if n < min {
			min = n
		}
	}

	fmt.Println(min)
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>


using namespace std;
//using namespace __gnu_pbds;


#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

int main() {

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

    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        int a[n+1],b[n],c[n+1],d[n];
        for(int i=0;i<n+1;i++)
            {   cin>>a[i];
                c[i]=a[i];
                }
        rep(i,n) {cin>>b[i];d[i]=b[i];}
        long long  ans=0,ans1=0;
        for(int i=0;i<n;i++)
            {
                int x=min(a[i],b[i]);
                a[i]-=x;
                b[i]-=x;
                ans+=x;
                x=min(a[i+1],b[i]);
                a[i+1]-=x;
                b[i]-=x;
                ans+=x;
            } 
          for(int i=0;i<n;i++)
            {   
                int x=min(c[i+1],d[i]);
                c[i+1]-=x;
                d[i]-=x;
                ans1+=x;
                x=min(c[i],d[i]);
                c[i]-=x;
                d[i]-=x;
                ans1+=x;
            } 

          cout<<max(ans,ans1)<<'\n';             
    }
    return 0;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
import math

in_a = list(map(int, input().split()))
A = in_a[0]
B = in_a[1]
N = in_a[2]

ans = 0

if ( B>N ):
  X = N
  ans = math.floor(A*X/B) - ( A * math.floor(X/B) )
  
else:
  X = B - 1
  ans = math.floor(A*X/B) - ( A * math.floor(X/B) )

print(ans)

Measured memory_bytes: 9080
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long[] ll = sc.LongArray();

        long answer = 0;

        for (int a = 0; a < n; a++)
        {
            for (int b = a + 1; b < n; b++)
            {
                for (int c = b + 1; c < n; c++)
                {
                    if (ll[a] == ll[b] || ll[a] == ll[c] || ll[b] == ll[c])
                    {
                        continue;
                    }
                    long sum = ll[a] + ll[b] + ll[c];
                    long max = Math.Max(ll[a], Math.Max(ll[b], ll[c]));
                    if (max * 2 < sum)
                    {
                        answer++;
                    }
                }
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 28204
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>

using namespace std;

#define mod 1000000007

long long int getlen(string s)
{
	long long int ans = 0;
	for(int i = 0; i < s.length(); i++){
		if(isdigit(s[i])){
			long long int num = s[i] - '0';
			i++;
			while(isdigit(s[i])){
				num = num * 10 + (s[i] - '0');
				i++;
			}
			if(s[i] != '('){
				ans += num;
				continue;
			}
			int kakko = 1;
			int tmp = i + 1;
			while(kakko > 0){
				if(s[tmp] == '(') kakko++;
				else if(s[tmp] == ')') kakko--;
				tmp++;
			}
			string tmps = s.substr(i + 1, tmp - 1 - (i + 1));
			ans += num * getlen(tmps);
			i = tmp - 1;
		} else {
			ans++;
		}
		if(ans > mod) ans = mod;
	}
	// cout << s << " " << ans << endl;
	return ans;
}

char solve(string s, int n)
{
	// cout << s << n << endl;
	long long int nowlen = 0;
	bool allchar = true;
	for(int i = 0; i < s.length(); i++){
		if(isdigit(s[i])){
			allchar = false;
			long long int num = s[i] - '0';
			i++;
			while(isdigit(s[i])){
				num = num * 10 + (s[i] - '0');
				i++;
			}
			if(s[i] != '('){
				// cout << s[i] << nowlen + num << endl;
				if(nowlen + num > n) return s[i];
				else {
					nowlen += num;
					continue;
				}
			}
			int kakko = 1;
			int tmp = i + 2;
			while(kakko > 0){
				if(s[tmp] == '(') kakko++;
				else if(s[tmp] == ')') kakko--;
				tmp++;
			}
			string tmps = s.substr(i + 1, tmp - 1 - (i + 1));
			long long int tmpl = getlen(tmps);
			// cout << tmps << " " << tmpl << " " << nowlen << " " << n << " " << num << endl;
			if(nowlen + num * tmpl > n) return solve(tmps, (n - nowlen) % tmpl);
			i = tmp - 1;
			nowlen += num * tmpl;
			// cout << nowlen << endl;
		} else {
			if(nowlen == n) return s[i];
			nowlen++;
		}
	}
	if(allchar && n < s.length()) return s[n];
	return '0';
}

int main()
{
	string s;
	int n;
	while(1){
		cin >> s >> n;
		if(s == "0") break;
		cout << solve(s, n) << endl;
	}
	return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}
int main() {
    const long long MOD = 1e9+7;
    int N; cin >> N;
    map<int, int> m;
    repp(i, 0, N) {
        int a; cin >> a;
        m[a] += 1;
    }
    bool can = true;
    for (int i = 1 - N%2; i < N; i += 2) {
        if (m.count(i) == 0) {
            can = false;
            break;
        }
        if (i == 0) {
            can &= m[i] == 1;
        } else {
            can &= m[i] == 2;
        }
    }
    if (can) {
        ll res = 1;
        repp(i,0,N/2) {
            res *= 2;
            res %= MOD;
        }
        cout << res << endl;
    } else {
        cout << 0 << endl;
    }
}


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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;

/////////////////////////////////

int const MAX = 1000 + 41;
int const INF = 1000 * 1000 * 1000 + 41;

int n, a[MAX];

void solvecase() {
	int cur = -INF;
	fi(1, n) {
		cur = max(cur, a[i]);
	}
	if (cur <= 0) {
		printf("%d\n", cur);
		printf("%d\n", n - 1);
		vi b;
		fi(1, n) { 
			b.pb(a[i]);
		}
		while (sz(b) > 1) {
			if (b[0] == cur) {
				printf("%d\n", sz(b));
				b.pop_back();
			} else if (b.back() == cur) {
				printf("1\n");
				b.erase(b.begin());
			} else {
				printf("%d\n", sz(b));
				b.pop_back();				
			}
		}
		exit(0);
	}
}

ll const LINF = (ll) INF * INF;
ll ans1, ans2;
vi vans1, vans2;

void calc(vi &vans, ll &ans, int p) {
	vector<ll> b;
	fi(1, n) {
		b.pb(a[i]);
	}
	while (p < n && b[p] <= 0) {
		p += 2;
	}	
	if (p >= n) {
		ans = LINF;
		return;
	}
	while (1) {
		if (p + 2 >= sz(b)) break;
		if (b[p + 2] > 0) {
			vans.pb(p + 1);
			ll s = b[p] + b[p + 2];
			fi(1, 3) {
				b.erase(b.begin() + p);
			}
			b.insert(b.begin() + p, s);
		} else {
			if (p + 3 >= sz(b)) break;
			vans.pb(p + 2);
			ll s = b[p + 1] + b[p + 3];
			fi(1, 3) {
				b.erase(b.begin() + p + 1);
			}
			b.insert(b.begin() + p + 1, s);
		}
	}
	while (sz(b) - 1 != p) {
		vans.pb(sz(b) - 1);
		b.pop_back();		
	}
	fi(1, p) {
		vans.pb(0);
		b.erase(b.begin());
	}
	ans = b[0];
}

void solve() {
	solvecase();
	calc(vans1, ans1, 0);
	calc(vans2, ans2, 1);
	if (ans1 > ans2) {
	  printf("%lld\n", ans1);
	  printf("%d\n", sz(vans1));
	  for (int z : vans1) {
	  	printf("%d\n", z + 1);
	  }
	} else {
		printf("%lld\n", ans2);
	  printf("%d\n", sz(vans2));
	  for (int z : vans2) {
	  	printf("%d\n", z + 1);
	  }
	}
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

  scanf("%d", &n);
  fi(1, n) {
  	scanf("%d", &a[i]);
  }
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	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 int MOD = 1000000007;
const ll INF = 1LL<<60;



int main(){
    vector<ll> A(5,0);
    ll ans = 100000;
    rep(i,5){
        cin >> A[i];
    }
    
    rep(i,5){
        ll tmp = 0;    
        rep(j,5){
            if (i == j){
                tmp += A[j];
            }
            else{
                tmp += (A[j]+10-1)/10*10;
            }
        }
        ans = min(ans, tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
w, h, n = map(int,input().split())
X = [list(map(int,input().split())) for i in range(n)]

A = [0, -w, 0, -h]

for i in range(n):
    j = X[i][2]-1
    A[j] = max(A[j], X[i][j//2] * (-1) ** j)

# print(A)
print(max(0, -A[1]-A[0]) * max(0, -A[3]-A[2]))

Measured memory_bytes: 38256
#include <stdio.h>

int main(void)
{
    int N, Q, i;
    scanf("%d%d", &N, &Q);

    char str[N + 1];
    int sum[N], l[Q], r[Q];
    scanf("%s", str);

    sum[0] = 0, sum[1] = 0;
    for (i = 1; i < N; i++)
    {
        sum[i + 1] = sum[i];
        if(str[i - 1] == 'A' && str[i] == 'C'){
            sum[i + 1]++;
            }
    }

    for (i = 0; i < Q; i++)
        scanf("%d %d", &l[i], &r[i]);

    for (i = 0; i < Q; i++)
        printf("%d\n", sum[r[i]] - sum[l[i]]);

    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) a.begin(),a.end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define INF 1e9
typedef long long ll;

int result[1<<16];
vector<string> exps[17];

bool eval(vector<bool> &table,string s,int &i){
    if(isdigit(s[i])){
        return s[i++] == '1';
    }
    if(s[i] == '-'){
        i++;
        return !eval(table,s,i);
    }
    if(isalpha(s[i])){
        return table[s[i++]-'a'];
    }
    assert(s[i] == '(');
    i++;
    bool e1 = eval(table,s,i);
    char op = s[i];
    i++;
    bool e2 = eval(table,s,i);
    i++;
    if(op == '^') return e1^e2;
    if(op == '*') return e1*e2;
    assert(false);
}

int get_feature(string &E){
    vector<bool> table(4);
    int k = 0;
    int res = 0;
    rep(a,2)rep(b,2)rep(c,2)rep(d,2){
        table[0] = a;
        table[1] = b;
        table[2] = c;
        table[3] = d;
        int i = 0;
        if(eval(table,E,i)){
            res |= 1<<k;
        }
        k++;
    }
    return res;
}

int main(void){
    rep(i,1<<16){
        result[i] = 20;
    }
    exps[1] = {"a","b","c","d"};
    for(int m = 2; m <= 16; m++){
        for(string E : exps[m-1]){
            if(E[0] == '-') continue;
            exps[m].push_back("-"+E);
        }
        rep1(x,m-2){
            int y = m-3-x;
            if(x>y) continue;
            assert(x>0 && y>0 && x<=y);
            for(string E1 : exps[x]){
                for(string E2 : exps[y]){
                    bool ng = false;
                    for(char ch : {'a','b','c','d'}){
                        string E = E1+E2;
                        if(count(all(E),ch)>1){
                            ng = false;
                        }
                    }
                    if(ng) continue;
                    exps[m].push_back("("+E1+"^"+E2+")");
                    exps[m].push_back("("+E1+"*"+E2+")");
                }
            }
        }
        
    }
    exps[1].push_back("0");
    exps[1].push_back("1");

    rep1(m,16){
        for(string E : exps[m]){
            int f = get_feature(E);
            result[f] = min(result[f], m);
        }
    }

    string E;
    while(cin>>E, E != "."){
        cout<<result[get_feature(E)]<<endl;
    }
    return 0;
}



Measured memory_bytes: 13392
#include<bits/stdc++.h>
#define LL long long
#define max 1e5

using namespace std;

int gcd(int a , int b)
{
        return a%b==0? b:gcd(b,a%b);
}
inline int quickread()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}
void slove()
{
    ;
}
int main()
{
    /*int t;
    cin>>t;
    while(t--)
    {
        slove();
    }*/
    int t;
    cin>>t;
    if(t>=30)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

    string S;
    cin >> S;
    if(S=="ABC"){
        cout<< "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }

}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define rrep(i,m,n) for(int i = m; i >= n; i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    rep(i,1,N+1){
        ll sum = i * (i+1) / 2;
        if(sum >= N){
            // print(i);
            // print(sum - N);
            rep(j,1,i+1){
                if(j != sum - N){
                    print(j);
                }
            }
            return 0;
        }
    }
}


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

int main() {

  string S, T;
  cin >> S >> T;
  
  int count = 0;
  int size = S.size();
  
  for(int i=0; i<size;i++) {
    if(S.at(i)!=T.at(i)) count++;
  }

  cout << count << endl;
  
}

Measured memory_bytes: 3896
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int R[100000];
vector<P> G[100000];
int A[100000], B[100000], C[100000];
int T[100000];

int dfs(int x, int p, int r) {
  R[x] = r;
  int s = 1;
  for (P pp : G[x]) {
    int t = pp._1;
    if (t == p) continue;
    s += dfs(t, x, r+1);
  }
  return T[x] = s;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N-1) {
    cin >> A[i] >> B[i] >> C[i];
    A[i]--, B[i]--;
    G[A[i]].pb(P(B[i], C[i]));
    G[B[i]].pb(P(A[i], C[i]));
  }
  dfs(0, -1, 0);
  int g = -1;
  long long s = 0;
  int mx = -1;
  bool f = false;
  rep(i, N-1) {
    int v = A[i], u = B[i];
    if (R[A[i]] < R[B[i]]) v = B[i], u = A[i];
    int a = T[v];
    int b = N-a;
    if (mx < min(a, b)) {
      mx = min(a, b);
      if (a > b) g = v;
      else g = u;
    }
    int t = 0;
    if (a == b) {
      f = true;
      t = 2*a-1;
    }
    else t = 2*min(a, b);
    //cout<<a+1<<"<->"<<b+1<<": t="<<t<<"\n";
    s += 1LL*t*C[i];
  }
  if (!f) {
    int m = INF;
    for (P p : G[g]) m = min(m, p._2);
    s -= m;
  }
  cout << s << "\n";
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

int n, m, d;

int main() {
	cin >> n >> m >> d;
	for (int i = 0; i < n; i ++) {
		for (int j = 0; j < m; j ++) {
			int x = (i+j)/d;
			int y = (i-j+n+m)/d;
			putchar("RYGB"[(x%2)*2+(y%2)]);
		}
		puts ("");
	}
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<cstring> 
#include<cstdlib>
#include<set>
#include<vector>
using namespace std;
#define ll long long
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
char a[4000];

 
int main()
{   int n;
	cin>>n;
	long long s1=0,s2=0,s3=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]=='R')
		s1++;
		if(a[i]=='G')
		s2++;
		if(a[i]=='B')
		s3++;	
	}
	long long m=s1*s2*s3;
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j+=2){
			if(a[i]!=a[j]&&a[i]!=a[(i+j)/2]&&a[j]!=a[(i+j)/2])
			m--;
		}
	}
	
	cout<<m<<endl;
	
	
     
	
	
	
	


}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;

// 二分探索（改）
// judge を満たすような下限を求める
// left:[X] 定義域の下限
// right:[X] 定義域の上限
// judge:[X -> bool] X を評価する関数
// lower:[bool] falseにすると代わりに上限を求める
// eps:[X] 終了距離
template <typename X>
X BinSearch(X left, X right, function<bool(X)> judge, bool lower = true, X eps = 1) {
    while (right - left > eps) {
        X mid = (right + left) / 2;
        if (judge(mid) == lower) {
            right = mid;
        } else {
            left = mid;
        }
    }
    return lower ? right : left;
}

int64_t divceil(int64_t a, int64_t b) {
    return a / b + (a > 0 && a % b ? 1 : 0);
}

// O(N log(max(h_i)))
int main() {
    i64 N, A, B;
    cin >> N >> A >> B;
    vector<i64> h(N);
    for(auto &x : h) cin >> x;
    cout << BinSearch<i64>(0, 1e9 + 1, [&](i64 y) -> bool {
        i64 z = 0;
        for(int i = 0; i < N; i++) {
            if(h[i] < B * y) continue;
            z += divceil(h[i] - B * y, A - B);
        }
        return z <= y;
    }, true) << endl;
    return 0;
}

Measured memory_bytes: 1024
void main()
{
    int[] tmp = readln.split.to!(int[]);
    int month = tmp[0], day = tmp[1];

    int cnt;
    foreach (m; 2 .. month+1)
    {
        foreach (d; 21 .. day+1)
        {
            int div = d / 10, rem = d % 10;
            if (rem >= 2 && m == div * rem)
            {
                ++cnt;
            }
        }
    }

    cnt.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
n,a,b = list(map(int, input().split()))
array = []
array2 = []

def degitSum(n):
  s = str(n)
  array = list(map(int,s))
  return sum(array)

for i in range(1,n+1):
  if degitSum(i) >= a and degitSum(i) <= b:
    array2.append(i)
    
print(sum(array2))

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

int main()
{
    int n;
    cin >> n;
    int h[100002];
    for(int i = 0; i < n; i++) cin >> h[i];
    h[0]--;
    for(int i = 1; i < n; i++){
        if(h[i - 1] < h[i]) h[i]--;
    }
    for(int i = 1; i < n; i++){
        if(h[i - 1] > h[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = 0;
  for (ll i = 1; i <= n; i++) {
    string s = to_string(i);
    ll sum = 0;
    for (ll j = 0; j < s.size(); j++) {
      sum += s[j] - '0';
    }
    if (a <= sum && sum <= b) ans += i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
h,w=map(int,input().split());A=[list(input())for _ in "_"*h]
def f(x,y):
  A[x][y]="."
  if x<h-1 and A[x+1][y]<".":return f(x+1,y)
  if y<w-1 and A[x][y+1]<".":return f(x,y+1)
f(0,0);print(['P','Imp']['#' in [x for a in A for x in a]]+'ossible')

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

using namespace std;
#define ll long long 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	int x=0;
	for (int i=0; i<s.size(); i++) {
		if (s[i]=='x') x++;
	}
	cout << 700+(3-x)*100;
	return 0;	
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int X;
  cin >> X;

  FOR(n,1,100000) {
    int x = X - 100*n;
    if(x < 0) break;

    if(x <= 5*n) {
      cout << 1 << endl;
      return 0;
    }
  }

  cout << 0 << endl;

  return 0;
}


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

int main() {
	int e, y; cin >> e >> y;
	if (e == 0) {
		if (1868 <= y && y <= 1911) cout << "M" << y - 1867 << endl;
		if (1912 <= y && y <= 1925) cout << "T" << y - 1911 << endl;
		if (1926 <= y && y <= 1988) cout << "S" << y - 1925 << endl;
		if (1989 <= y && y <= 2016) cout << "H" << y - 1988 << endl;
	}
	else if (e == 1) cout << y + 1867 << endl;
	else if (e == 2) cout << y + 1911 << endl;
	else if (e == 3) cout << y + 1925 << endl;
	else if (e == 4) cout << y + 1988 << endl;
	return 0;
}


Measured memory_bytes: 3096
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

int K;

int main()
{
  scanf( "%d", &K );

  int even = K/2;
  int odd = K-even;

  printf( "%d\n", even*odd );

  return 0;
}

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

using namespace std;

const int md = 1000000007;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) {
    a -= md;
  }
}

const int N = 1234567;

int need1[23], need2[23];
int go[N][23];
int put[N];
int f[N];

int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < m; i++) {
    need1[i] = 0;
    need2[i] = 0;
  }
  while (k--) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    a--; b--;
    need1[a] |= (1 << b);
    need2[a] |= (1 << b) * c;
  }
  n--;
  for (int t = 0; t < (1 << n); t++) {
    for (int i = 0; i < n; i++) {
      go[t][i] = -1;
    }
    int id = 0;
    for (int i = 0; i < n; i++) {
      if (t & (1 << i)) {
        if (i > 0 && !(t & (1 << (i - 1)))) {
          go[t][id] = t ^ (1 << i) ^ (1 << (i - 1));
        }
        id++;
      }
    }
  }
  for (int t = 0; t < (1 << n); t++) {
    put[t] = -1;
    for (int i = n - 1; i >= 0; i--) {
      if (t & (1 << i)) {
        continue;
      }
      put[t] = t ^ (1 << i);
      break;
    }
  }
  for (int t = 0; t < (1 << n); t++) {
    f[t] = 0;
  }
  f[0] = 1;
  for (int i = 0; i < m; i++) {
    for (int t = 0; t < (1 << n) - 1; t++) {
      add(f[put[t]], f[t]);
    }
    for (int id = 0; id < n; id++) {
      for (int t = (1 << n) - 1; t >= 0; t--) {
        if (go[t][id] != -1) {
          add(f[go[t][id]], f[t]);
        }
      }
    }
    for (int t = 0; t < (1 << n); t++) {
      if ((t & need1[i]) != need2[i]) {
        f[t] = 0;
      }
    }
  }
  int ans = 0;
  for (int t = 0; t < (1 << n); t++) {
    add(ans, f[t]);
  }
  printf("%d\n", ans);
  return 0;
}


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


int main() {
    int a,b,c,x,count=0;
    cin>>a>>b>>c>>x;
    x/=50;
    for(int i=0;i<a+1;i++){
        for (int j = 0; j < b+1; ++j) {
            for (int k = 0; k < c+1; ++k) {
                if(k+2*j+10*i==x){
                    count++;
                    //cout<<i<<j<<k<<endl;
                }
            }
        }
    }
    cout<<count<<endl;
    return 0;
}


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

long long n,dp[2020],a,ans,jum(1),sum;
string s;
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>s;
	dp[0]++;
	for(int i=s.length()-1;i>=0;i--)
	{
		a=s[i]-'0';
		sum=(sum+jum*a)%2019;
		jum=jum*10%2019;
		dp[sum]++;
	}
	for(int i=0;i<2019;i++)
	{
		ans+=dp[i]*(dp[i]-1)>>1;
	}
	cout<<ans<<'\n';
}

Measured memory_bytes: 3692
n = gets.to_i
s = gets

count = 0
i = 0
n -= 1
while i < n do
	i += 1 while s[i] == 'R'
    n -= 1 while s[n] == 'W'
      if i < n
      count += 1
      i += 1
      n -= 1
    end
end
puts count 

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

int main() {
  int r,g,b;
  cin>>r>>g>>b;
  if ((100*r+10*g+b)%4==0)cout << "YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


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

template <int mod>
struct RollingHash {
  vector<int> hashed;
  vector<int> power;
  RollingHash(const string &s, int base = 10007) {
    int n = (int) s.size();
    hashed.assign(n + 1, 0);
    power.assign(n + 1, 0);
    power[0] = 1;
    for (int i = 0; i < n; i++) {
      power[i + 1] = (long long) power[i] * base % mod;
      hashed[i + 1] = ((long long) hashed[i] * base + s[i]) % mod;
    }
  }
  int get(int l, int r) {
    int ret = hashed[r] + mod - ((long long) hashed[l] * power[r - l]) % mod;
    if (ret >= mod) ret -= mod;
    return ret;
  }
};

using RH = RollingHash<1000000007>;

struct UnionFind {
  vector<int> par;
  vector<int> siz;
  UnionFind(int n) {
    par = vector<int>(n);
    siz = vector<int>(n, 1);
    iota(par.begin(), par.end(), 0);
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    par[x] = y;
    siz[y] += siz[x];
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return siz[root(x)];
  }
};

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  string ss = s;
  while (ss.size() < t.size()) {
    ss += s;
  }
  ss += ss;
  RH sh(ss), th(t);
  auto uf = UnionFind(n);
  for (int i = 0; i < n; i++) {
    if (sh.get(i, i + t.size()) == th.get(0, t.size())) {
      int x = i % n;
      int y = (i + t.size()) % n;
      if (uf.same(x, y)) {
        cout << -1 << endl;
        return 0;
      }
      uf.unite(x, y);
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, uf.size(i) - 1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 31412
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<iostream>
using namespace std;
int dp[100000][3]={0};
int n,a[100000][3];
int ans(int i,int j)
{
	if(i==n)
		return 0;
 
	if(dp[i][j]!=0)
		return dp[i][j];
 
	int best=0;
	for(j;j<3;j++)
	{
		for(int k=0;k<3;k++) 
		{
			if(k==j)
				continue;
			best=max(best,a[i][j]+ans(i+1,k));
		}
		if(i!=0)
			break;
	}
	return dp[i][j]=best;
}
 
int main()
{
	ios_base::sync_with_stdio(0);           
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
			cin>>a[i][j];
	}
	cout<<ans(0,0);
    
    return 0;
}

Measured memory_bytes: 15264
#include<stdio.h>
int main(void)
{
	int a,b,d,r;
	double f;
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/b;
	printf("%d %d %f",d,r,f);

return 0;
}

Measured memory_bytes: 636
S = list(input())
stl = len(S) - 2
countOfC = 0


if S[0] != 'A':
  print('WA')
  exit(0)

for i in range(1, len(S)):
  if S[i].isupper():
    if i >= 2 and i <= stl and  S[i] == 'C':
      countOfC += 1
    else:
      print('WA')
      exit(0)

if countOfC == 1:
  print('AC')
else:
  print('WA')

Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1);
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
#define ll long long
#define inf int(1e9+7)
#define pb push_back
#define mp make_pair
vector<int>g[4005];
int n,k,q[4005],t,dist[4005],ans=2005;
void bfs()
{
	for(int k=0;k<t;k++)
	{
		int v=q[k];
		for(int l=0;l<g[v].size();l++)
		{
			int u=g[v][l];
			int w=dist[v]+2;
			if(dist[u]<=w)
				continue;
			dist[u]=w;
			q[t++]=u;
		}
	}
	return;
}
int sv(int v)
{
	for(int i=0;i<n;i++)
		dist[i]=inf;
	dist[v]=0;
	t=0;
	q[t++]=v;
	bfs();
	int res=0;
	for(int i=0;i<n;i++)
		if(dist[i]>k)
			res++;
	return res;
}
int se(int v,int u)
{
	for(int i=0;i<n;i++)
		dist[i]=inf;
	dist[v]=dist[u]=1;
	t=0;
	q[t++]=v;
	q[t++]=u;
	bfs();
	int res=0;
	for(int i=0;i<n;i++)
		if(dist[i]>k)
			res++;
	return res;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<n;i++)
	{
		int v,u;
		cin>>v>>u;
		v--;
		u--;
		g[v].pb(u);
		g[u].pb(v);
	}
	for(int v=0;v<n;v++)
		ans=min(sv(v),ans);
	for(int v=0;v<n;v++)
		for(int i=0;i<g[v].size();i++)
		{
			int u=g[v][i];
			if(u>v)
				ans=min(ans,se(v,u));
		}
	cout<<ans;
	return 0;
}

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

int main() {
	int sec,min,hour;
	std::cin >> sec;
	hour = sec / 3600; //hour
	int tmp = sec - hour * 3600;
	min = tmp / 60;
	sec = tmp - min * 60;
	std::cout << hour << ":" << min << ":" << sec << std::endl;
	return 0;
}

Measured memory_bytes: 1168
#include <stdio.h>
#include <string.h>
int main(){
  int c=0;
  char r;
  char s[101];
  scanf("%s",s);
  for(int i=0;i<strlen(s);i++){
    for(int j=0;j<strlen(s)-1;j++){
      if(s[j]>s[j+1]){
        r=s[j];
        s[j]=s[j+1];
        s[j+1]=r;
      }
    }
  }
  for(int i=0;i<strlen(s)-1;i++){
    if(s[i]==s[i+1])c++;
    else if(c%2==1)c=0;
    else {
      puts("No");
      return 0;
    }
  }
  if(strlen(s)==1)puts("No");
  else puts("Yes");
  return 0;
}

Measured memory_bytes: 128
# coding: utf-8
class Case03

  def initialize
  end

  def show
    p self.instance_variables
        .map{ |sym| [sym, self.instance_variable_get(sym)] }
        .to_h
  end
  
  # 実行する
  def execute
    read
    solve
    output
  end

  # 読込
  def read
    @n = gets.chomp.to_i
    @h = gets.chomp.split.map(&:to_i)
  end

  # 回答
  def solve
    e = @n
    s = @n
    @result = 0
    while e >= 1 do
      while s > 1 && @h[s-2] >= @h[s-1] do
        s -= 1
      end
      @result = (e - s) if (e - s) > @result
      break if s <= 1
      e = s - 1
      s = e
    end
  end
  
  # 出力
  def output
    puts @result
  end

end

Case03.new.execute if $0 == __FILE__



Measured memory_bytes: 11532
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define A 5e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	int N; cin >> N;
	vector<int> a(N);
	int B = 0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		B += a[i];
	}
	B /= N;
	int ans = 1e9;
	for (int i = -1; i <= 1; i++) {
		int cst = 0;
		for (int j = 0; j < N; j++) {
			cst += (a[j] - (B + i)) * (a[j] - (B + i));
		}
		ans = min(ans, cst);
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 3576
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative
import Control.Monad
import Control.Monad.State
import Control.DeepSeq
import Data.Array
import Data.Bits
import Data.Char
import Data.Functor.Identity
import Data.List
import Data.Maybe
import Data.Ord
import Data.Tree
import Data.Tuple
import qualified System.IO
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.Sequence as Q
import qualified Data.ByteString.Char8 as B

main = do
  (n,m) <-getIntPair
  xss <- group . sort <$> getInts
  let as = accumArray (+) 0 (0,m-1) [(head ys`mod`m, length ys`div`2) | ys <- xss]
  let bs = accumArray (+) 0 (0,m-1) [(head ys`mod`m, length ys`mod`2) | ys <- xss]
  -- print as
  -- print bs
  print $ sum [f (i==j) (as!i) (as!j) (bs!i) (bs!j) | i <- [0..m`div`2], let j = (-i)`mod`m]

f True a _ b _ = a + (b`div`2)
f False a0 a1 b0 b1
  | b0 >= b1  = a0+a1+b1+ min ((b0-b1)`div`2) a1
  | otherwise = a0+a1+b0+ min ((b1-b0)`div`2) a0


type Z = Int
type Q = Rational
type R = Double
type S = String

fint :: (Integral a, Num b) => a -> b
fint = fromIntegral

getInt = fst . fromJust . B.readInt <$> B.getLine
getIntPair = (\[a,b]->(a,b)) <$> getInts
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine
getStr = B.unpack <$> B.getLine

yesNo :: Bool -> String
yesNo True = "Yes"
yesNo False = "No"

printList :: (Show a) => [a] -> IO ()
printList = putStrLn . unwords . map show

readLnList :: (Read a) => IO [a]
readLnList = map read . words <$> getLine


-----  Union-find
type UnionFindT v m a = StateT (M.Map v (UnionFindVal v)) m a
newtype UnionFindVal v = UnionFindVal v

runUnionFindT :: (Monad m) => UnionFindT v m a -> m a
runUnionFindT = flip evalStateT $ M.empty

runUnionFind = runIdentity . runUnionFindT

ufFresh :: (Monad m, Ord v) => v -> UnionFindT v m ()
ufFresh v = modify $ M.insert v (UnionFindVal v)

ufClass :: (Monad m, Ord v) => v -> UnionFindT v m v
ufClass v = do
  (UnionFindVal pv) <- gets (M.! v)
  if v == pv
    then return v
    else do
      c <- ufClass pv
      modify $ M.insert v (UnionFindVal c)
      return c

ufUnify v w = do
  cv <- ufClass v
  cw <- ufClass w
  modify $ M.insert cw (UnionFindVal cv)
  return $ cv /= cw


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

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

	
	int ans = 0;
	for (int i = a; i <= b; i++) {
		int remaind;
		int reverse = 0;
		int tmp = i;
		while (tmp != 0) {
			remaind = tmp % 10;
			reverse = reverse * 10 + remaind;
			tmp /= 10;
		}

		if (reverse == i) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256