akhauriyash/Code-Regression huggingface dataset:
def f(flg, an):
    accum = 0
    ret = 0
    for i, ai in enumerate(an):
        accum += ai
        if flg:
            flg = False
            if accum <= 0:
                ret += -accum + 1
                accum = 1
        else:
            flg = True
            if 0 <= accum:
                ret += accum + 1
                accum = -1
    return ret


def main():
    n, *an = map(int, open(0).read().split())
    print(min(f(False, an), f(True, an)))
    return


main()


Measured memory_bytes: 14084
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        long l = 0;
        long m = 0;
        for (int i = n - 1; i > 0; i--) {
            if (a[i] == a[i - 1] && l == 0) {
                l = a[i];
                i--;
            } else if (a[i] == a[i - 1]) {
                m = a[i];
                break;
            }
        }
        System.out.println(l * m);
    }
}


Measured memory_bytes: 49196
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int n;cin>>n;
	string s;cin>>s;
	int z = (int)'Z';
	string ans = s;
	rep(i,s.size()){
		ans[i] = (char)((int)s[i] + n);
		if(ans[i] > z){
			ans[i] -= 26;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc153/tasks/abc153_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, ans = 0;
    cin >> N;
    priority_queue<pair<int, int>> q;
    q.push({N, 1});
    while (!q.empty()) {
        auto t = q.top();
        q.pop();
        ans += t.second;
        int a = t.first / 2;
        if (a >= 1) {
            q.push({a, t.second * 2});
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

#include <utility>
#include <vector>

class EdgeListGraph {
    // 頂点数
    const int n;
    // from, to, cost
    std::vector<std::tuple<int, int, long long>> edges;

public:
    void add_edge(int from, int to, long long cost = 1) {
        edges.emplace_back(from, to, cost);
    }

    // sからの各頂点への最短距離を格納したvectorと、負閉路があればそれを検知した辺を格納したvectorを返す
    std::pair<std::vector<long long>, std::vector<std::pair<int, int>>> bellman_ford(int s);

    EdgeListGraph(int n, int m) : n(n) {
        edges.reserve(m);
    }
};

std::pair<std::vector<long long>, std::vector<std::pair<int, int>>> EdgeListGraph::bellman_ford(int s) {
    auto ret = std::make_pair(std::vector<long long>(n, 1000000000000000007LL), std::vector<std::pair<int, int>>());
    auto& dist = ret.first;

    dist[s] = 0;
    for (int i = 0; i < n; ++i) {
        for (const auto& e : edges) {
            int from, to; long long cost;
            std::tie(from, to, cost) = e;

            if (dist[from] + cost < dist[to]) {
                dist[to] = dist[from] + cost;
                if (i == n - 1) ret.second.emplace_back(from, to);
            }
        }
    }
    return std::move(ret);
}

int main() {
    int n, m, p; cin >> n >> m >> p;
    EdgeListGraph egraph(n, m);
    vector<vector<int>> graph(n);
    vector<vector<int>> reversed_graph(n);
    for (int i = 0; i < m; ++i) {
        int a, b, c; cin >> a >> b >> c;
        --a; --b;
        egraph.add_edge(a, b, p - c);
        graph[a].push_back(b);
        reversed_graph[b].push_back(a);
    }

    auto ret = egraph.bellman_ford(0);

    set<int> visited_from_1;
    {
        visited_from_1.insert(0);
        queue<int> que; que.push(0);
        while (!que.empty()) {
            int from = que.front(); que.pop();
            for (int to : graph[from]) {
                if (!visited_from_1.count(to)) {
                    que.push(to);
                    visited_from_1.insert(to);
                }
            }
        }
    }

    set<int> visited_from_n;
    {
        visited_from_n.insert(n - 1);
        queue<int> que; que.push(n - 1);
        while (!que.empty()) {
            int from = que.front(); que.pop();
            for (int to : reversed_graph[from]) {
                if (!visited_from_n.count(to)) {
                    que.push(to);
                    visited_from_n.insert(to);
                }
            }
        }
    }

    bool no_maxscore = false;
    for (const auto& e : ret.second) {
        if (visited_from_1.count(e.first) && visited_from_n.count(e.second)) no_maxscore = true;
    }

    if (no_maxscore) cout << -1 << endl;
    else cout << max(-ret.first.back(), 0LL) << endl;
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll a, b, c;
  cin >> a >> b >> c;
  if (b - a == c - b) {
    COUT("YES");
  } else {
    COUT("NO");
  }
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<long long int> l(2);
  l={2,1};
  for(int i=2;i<n+1;i++){l.push_back(l.at(i-2)+l.at(i-1));}
  cout << l.at(n) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N;
int H[100001];

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

  cin >> N;
  rep(i, N) cin >> H[i];

  int ans = 0;
  int tmp = 0;
  int now = H[0];
  rep(i, N-1){
    if (H[i+1]<=now){
      now = H[i+1];
      tmp++;
    } else{
      now = H[i+1];
      ans = max(ans, tmp);
      tmp = 0;
    }
  }
  ans = max(ans, tmp);
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 640
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
//#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
//#include <array>
#include <valarray>
#include <stdio.h>
//#include <random>
//#include <windows.h>
//#pragma comment(lib, "winmm.lib")
#include <algorithm>

using namespace std;
typedef long long ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

long long  int nCm(long long int n, long long int m) {
	if (m == 1) {
		return n;
	}
	else {
		return n*nCm(n - 1, m - 1) / m;
	}
}

long long int npm(long long int n,long long int m) {
	if (m == 1) {
		return n;
	}
	else 
		if (m == 0) {
			return 1;
		}else {
		return n*npm(n, m - 1);
	}
}

 int main() {
	//long long int gomi, tuyoi;

	long long int N, A;
	cin >> N >> A;
	vector<long long int> gary(70,0);
	vector<long long int> tary(70,0);
	long long int zero = 0;
	for (long long int i = 0; i < N; ++i) {
		long long int X;
		cin >> X;
		X -= A;
		if (X == 0) {
			zero++;
		}
		else
			if (X > 0) {
				gary[X]++;
			}
			else {
				tary[-X]++;
			}

	}
	long long int num=1;

	vector<long long int>gsize(2501, 0);
	gsize[0] = 1;
	long long int gmax = 0;
	for (long long int i = 1; i <= 50; ++i) {
		vector<long long int> gcopy(gmax + 2, 0);
		for (long long int j = 0; j < gmax + 1; ++j) {
			gcopy[j] += gsize[j];
		}
		for (long long int j = 0; j < gary[i]; ++j) {
			for (long long int k = 0; k < gmax + 1; ++k) {
				gsize[i*(j + 1) + k] += gcopy[k] * nCm(gary[i],j+1);
				
			}
		}
		if (gary[i]!=0) {
			gmax = i*gary[i] + gmax;
		}
	}

	vector<long long int>tsize(2501, 0);
	tsize[0] = 1;
	long long int tmax = 0;
	for (long long int i = 1; i <= 50; ++i) {
		vector<long long int> tcopy(tmax + 2, 0);
		for (long long int j = 0; j < tmax + 1; ++j) {
			tcopy[j] += tsize[j];
		}
		for (long long int j = 0; j < tary[i]; ++j) {
			for (long long int k = 0; k < tmax + 1; ++k) {
				tsize[i*(j + 1) + k] += tcopy[k] * nCm(tary[i], j + 1);
			}
		}
		if (tary[i] != 0) {
			tmax = i*tary[i] + tmax;
		}
	}
	long long int mins = min(gmax, tmax);
	for (long long int i = 1; i <= mins; ++i) {
		num += gsize[i] * tsize[i];
	}
	cout << num*npm(2, zero) - 1 << endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#include <chrono> 
using namespace std::chrono;
#define fl(i,z,n) for(int i=z;i<=(n);i++)
#define flr(i,z,n) for(int i=z;i>=(n);i--)
using namespace std;
#define ll long long 
#define pa(a,s) fl(i,0,s-1) cout<<*(a+i)<<" "; cout<<nl;
#define pv(v) fl(i,0,v.size()-1) cout<<v[i]<<" "; cout<<nl;
#define read(v) fl(i,0,v.size()-1) cin>>v[i];
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define vll vector<ll>
#define sll set<ll>
#define spll set<pll>
#define debnl(x) cout<<#x<<"="<<x<<nl;
#define deb(x) cout<<#x<<"="<<x<<" ";
#define mkp(x,y) make_pair(x,y)
#define ump unordered_map
#define ff first
#define ss second
#define in insert
#define sz size
#define len length
#define nl '\n'
#define pb push_back
#define in insert
#define ub upper_bound
#define lb lower_bound
#define ld long double
const int MXN=1e5;
ll mod=1e9+7;
void solve(){
    string t,s;
    cin>>s>>t;
    int n=s.length(), m=t.length();
    ll ans=1e12;
    fl(i,0,n-1){
        ll c=0;
        fl(j,0,m-1){
            if(i+j >=n){
                c=1e13; break;
            }
            if(s[i+j]!=t[j]) c++;
        }
        ans=min(ans,1LL*c);
    }
    cout<<ans<<nl;
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); ll t=1;
    //cin>>t; //comment for single test
    while(t--) solve();
}

Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1


a = int(input())
s = input().rstrip()
print(s if a >= 3200 else 'red')





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

using ll = long long;

int main() {
    int T; cin >> T;
    while(T--) {
        ll a, b, c, d; cin >> a >> b >> c >> d;
        //cout << "a, b, c, d: " << a << " " << b << " " << c << " " << d << endl;
        if(a < b || d < b) {
            cout << "No" << endl;
        } else if(c >= b) {
            cout << "Yes" << endl;
        } else {
            if(a >= c + 1) {
                const ll t = a - (a - c - 1) / b * b;
                if(c < t && t < b) {
                    cout << "No" << endl;
                    continue;
                }
            }
            const ll g = __gcd(b, d);
            ll t = (a < c ? a - b : a - (a - c + b - 1) / b * b);
            t += (c + 1 - t + g - 1) / g * g;
            //cout << "t: "<< t << endl;
            if(c < t && t < b) {
                cout << "No" << endl;
            } else {
                cout << "Yes" << endl;
            }
        }
    }
}

Measured memory_bytes: 256
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

#define M 1000000007LL

ll dp[100004];

ll pw(ll a, ll b) {
    if (b == 0LL)
        return 1LL;
    ll x = pw(a, b/2LL);
    x = (x*x) % M;
    if (b%2LL)
        return (x*a)%M;
    return x;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n = gi();
    int k = gi();
    ll res = 0;
    for (int g = k; g >= 1; g--) {
        int h = k/g;
        ll v = pw(h, n);
        for (int gg = 2*g; gg <= k; gg+=g)
            v = (v+M-dp[gg])%M;
        dp[g] = v;
        res = (res + v*g) % M;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 4428
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace AtCoder_1
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = CinLAr();
            long L = a[0];
            long R = a[1];
            long nowr = 2100;
            for(long i = L;i < R; i++)
            {
                for(long j = i + 1; j <= R; j++)
                {
                    long t = (i * j) % 2019;
                    if(t == 0)
                    {
                        nowr = 0;
                        i = R;
                        break;
                    }
                    else
                    {
                        nowr = Math.Min(nowr, t);
                    }
                }
            }
            Cout(nowr);
        
 
        }


        static string Cin() { return Console.ReadLine(); }
        static string[] CinAr() { return Console.ReadLine().Split(' '); }
        static int CinT() { return S2i(Cin()); }
        static int[] CinTAr() { return CinAr().Select((x, i) => { return S2i(x); }).ToArray(); }
        static long CinL() { return S2L(Cin()); }
        static long[] CinLAr() { return CinAr().Select((x, i) => { return S2L(x); }).ToArray(); }
        static double CinD() { return S2D(Cin()); }
        static double[] CinDAr() { return CinAr().Select((x, i) => { return S2D(x); }).ToArray(); }
        static int S2i(string s) { return int.Parse(s); }
        static long S2L(string s) { return long.Parse(s); }
        static double S2D(string s) { return double.Parse(s); }
        static void Cout(object s) { Console.WriteLine(s); }
        static void DbShowE<Type>(IEnumerable<Type> types)
        {
            foreach(var i in types)
            {
                Console.Write(i + " ");
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 13396
#include <stdio.h>
int main(){
  int n,i,A[200000],j,max=-9999999999,min;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);

  min=A[0];

  for(j=1;j<n;j++){
      if(max<A[j]-min)
          max=A[j]-min;
      if(min>A[j])
          min=A[j];
  }
  
  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 2496
#include<bits/stdc++.h>
#define ll long long int
const ll mod=1e9+7;
#define loop(i,a,n) for(i=a;i<n;i++)
#define pool(i,n,a) for(i=n;i>=a;i--)
#define fastinout     ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

void myfun()
{
	ll n,i,j,k,ans=0;
	cin>>n;
	ll arr[n];
	for(i=0;i<n;i++)
	cin>>arr[i];
	sort(arr,arr+n);
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			for(k=j+1;k<n;k++)
			{
			  if((arr[i]+arr[j])>arr[k] && arr[i]!=arr[j] && arr[i]!=arr[k] && arr[j]!=arr[k])
			  {
			  //cout<<arr[i]<<" "<<arr[j]<<" "<<arr[k]<<"\n";
			  ans++;
			  }	
			}
		}
	}
	cout<<ans;
}


int main()
{
	 fastinout;
	ll t=1;
	//cin>>t;
	while(t--)
	myfun();
	return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>    
using namespace std;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define int long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define fone for(i=0;i<n;i++)
#define endl "\n"
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N          = 5000*100+1;
const ll N2      = 1000*1000+5;
const ld PI  = 3.14159265;
const ll R   = 250;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
    }


signed main ()
{
  fastio();
  int n,k;
  cin>>n>>k;
  //cout<<2<<endl;
  int a[N2];
  //cout<<1<<endl;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }

  int i;
  int ans=0;
  int flag=0;
  int dp[N2];
  fill(dp,0);
  dp[0]=0;
 for( i=1;i<k;i++)
  {
    dp[i]=abs(a[i]-a[0]);
  }
  for(int i = k ; i<n;i++)
  {
    int m=INF;
    for(int j=i-1;j>=max(i-k,0ll);j--)
    {
       m=min(m,abs(a[j]-a[i])+dp[j]);
    }
    dp[i]=m;
  }
  cout<<dp[n-1]<<endl;

return 0;
  
}


Measured memory_bytes: 11776
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;
 int n;
 bool f;        
 int a;
 vector<ll>p;
void T(int sum,int tag){
    if (tag == n) {
        if (sum == a)f = 1;
        return;
    }

    T(sum + p[tag], tag+1);
    T(sum, tag+1);
}


int main()
{
   
    cin >> n;
    
    p.resize(n + 1);

    for (int i = 0; i < n; i++)cin >> p[i];

    int q;
    cin >> q;
    while (q--) {


        cin >> a;
        f = 0;
        T(0, 0);
        if (f)cout << "yes" << endl;
        else cout << "no" << endl;

    }
    


    return 0;

}


Measured memory_bytes: 3088
import math

def resolve():
    X = int(input())
    answer = prime_number_from_X(X)

    print("{}".format(answer))

# Trial-division
def prime_number_from_X(X):
    i = X
    while True:
        i_sqrt = int(math.sqrt(i))
        is_prime_number = False
        if X == 2:
            return 2
        for j in range(2, i_sqrt):
            if i % j == 0:
                is_prime_number = False
                break
            else:
                is_prime_number = True
        if is_prime_number:
            return i
        i += 1

if __name__ == "__main__":
    resolve()

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

int K, A, B;

int main(){
    cin >> K >> A >> B;

    int a = A / K;
    int c = A % K;
    int b;
    if(c == 0){
         b = K * a;
    }
    else{
         b = K * (a + 1);
    }

    if( b <= B ){
        cout << "OK" << endl;
    }else
    {
        cout << "NG" << endl;
    }
    

}

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

class unionfind{
    int64_t *uf;
    size_t root(size_t i){
        if(uf[i] < 0) return i;
        return uf[i] = root(uf[i]);
    }
public:
    unionfind(size_t n){
        uf = new int64_t[n];
        for(size_t i=0;i<n;++i) uf[i] = -1;
    }
    bool is_same(size_t i, size_t j){
        return root(i) == root(j);
    }
    size_t count(size_t i){
        return -uf[root(i)];
    }
    bool merge(size_t i, size_t j){
        if(is_same(i, j)) return false;
        if(count(i) < count(j)) swap(i, j);
        uf[root(i)] -= count(j);
        uf[root(j)] = root(i);
        return true;
    }    
};

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    unionfind uf(n + 1);
    static int count[100001];
    for(int i=1;i<=n;++i) count[i] = 1;
    for(int i=0;i<m;++i){
        int a, b;
        cin >> a >> b;
        uf.merge(a, b);
        ++count[a];
        ++count[b];
    }
    for(int i=0;i<k;++i){
        int c, d;
        cin >> c >> d;
        if(uf.is_same(c, d)){
            ++count[c];
            ++count[d];
        }
    }
    for(int i=1;i<=n;++i) cout << uf.count(i) - count[i] << " \n"[i==n];

    return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <queue>
#define ll long long int
#define inf 3e18+1
#define all(v) (v).begin(),(v).end() 
#define N 200005
#define F first
#define S second
using namespace std;
ll mod=1e9+7;
ll parent[200005],sz[200005];
ll find(ll x){
    if(x==parent[x]) return x;
    return parent[x]=find(parent[x]);
}
void join(ll x,ll y) {
    ll a=find(x);
    ll b=find(y);
    if(a!=b) {
        if(sz[a]<=sz[b]) {
            swap(a,b);
        }
        parent[b]=parent[a];
        sz[a]+=sz[b];
    }
}
int main()
{
    // added the two lines below 
    ios_base::sync_with_stdio (false); 
    cin.tie(NULL);
    cout.tie(0);    
    ll test=1;//cin>>test;
    while(test--){
        ll n,m;
        cin>>n>>m;
        for(int i=1;i<=n;i++){
            parent[i]=i;
            sz[i]=1;
        }
        while(m--){
            ll u,v;
            cin>>u>>v;
            join(u,v);
        }
        ll ans=0;
        for(int i=1;i<=n;i++){
            ans=max(ans,sz[find(i)]);
        }
        cout<<ans<<endl;
    }
    return 0;
}




Measured memory_bytes: 6704
import sys
INF = 10**10
MOD = 10**9 + 7
sys.setrecursionlimit(100000000)
from functools import lru_cache
from itertools import permutations

def main():
    n,m = map(int,input().split())
    dist = [[INF] * n for _ in range(n)]
    for i in range(n):
        dist[i][i] = 0

    edge = []
    for _ in range(m):
        a,b,c = map(int,input().split())
        a -= 1
        b -= 1
        dist[a][b] = c
        dist[b][a] = c
        edge.append((a,b,c))
    
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j])
    
    cnt = 0
    for e in edge:
        a,b,c = e
        flag = True
        for i in range(n):
            for j in range(n):
                if dist[i][a] + c + dist[b][j] == dist[i][j]:
                    flag = False
                    break
            if flag == False:
                break
        
        if flag:
            cnt += 1
    
    print(cnt)

if __name__=='__main__':
    main() 

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

int main ()
{
    int c;
    int x,t;
    cin >> x;
    cin >> t;
    if (x>t)
    {
        c = x-t;
        cout << c << endl;
    }
    else
        cout << 0 << endl;
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;
const int max_n = 1e6 + 5;

int gcd(int a, int b) {
    return a == 0 ? b : gcd(b%a, a);
}
char s[1234567];
char t[] = "keyence";
int m = 7;

int main() {
	scanf("%s", s);
	int n = strlen(s);
	int pre = 0;
	FOR(i,0,m) {
		if (s[i] != t[i]) {
			break;
		}
		pre++;
	}
	int suf = 0;
	FOR(i,0,m) {
		if (s[n-1-i] != t[m-1-i]) {
			break;
		}
		suf++;
	}
	if (suf + pre >= 7) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}

}



Measured memory_bytes: 256
from scipy.sparse.csgraph import minimum_spanning_tree
from scipy.sparse import csr_matrix
from operator import itemgetter

n = int(input()) 
ixy = [[i] + [int(x) for x in input().split()] for i in range(n)]

edge = set()

for key in [itemgetter(1),itemgetter(2)]:
    ixy.sort(key = key)
    for i in range(n-1):
        i1, i2 = ixy[i][0], ixy[i+1][0]
        x1, x2 = ixy[i][1], ixy[i+1][1]
        y1, y2 = ixy[i][2], ixy[i+1][2]
        d = min(abs(x2-x1), abs(y2-y1))
        edge.add((i1,i2,d))
    
row,col,value = zip(*edge)
csr_ = csr_matrix((value, (row,col)), shape=(n, n))
mst = minimum_spanning_tree(csr_, overwrite=True).astype(int)
print(mst.sum())

Measured memory_bytes: 81228
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

H, W = map(int, input().split())

cells = []
for h in range(H):
    s = input()
    if s != '.' * W:
        cells.append(s)

new_cells = [''] * len(cells)
for w in range(W):
    delete = True
    for c in cells:
        if c[w] == '#':
            delete = False
    if not delete:
        for h, c in enumerate(cells):
            new_cells[h] += cells[h][w]

for c in new_cells:
    print(c)


Measured memory_bytes: 7120
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
ll n,m;
vector<ll> a;
vector<ll> suma;
ll search_min(ll x){//握手の価値がx以上のものを返す
	ll res = 0;
	for(int i = 0; i < n; i++) {
		ll key = x - a[i];
		res += (a.end() - lower_bound(ALL(a),key));
 	}
	return res;
}

ll search_sum(ll x){
	ll res = 0;
	ll cnt = 0;
	for(int i = 0; i < n; i++) {
		ll key = x - a[i];
		int index = upper_bound(ALL(a),key) - a.begin() - 1;
		res += ((n - (index + 1))* a[i] + suma[n] - suma[index + 1]);
		cnt += (n - (index + 1));
		// cout << res <<" " << i << endl;
	}
	res += x * (m - cnt);
	return res;
}



int main(){
	cin>>n>>m;
	for(int i = 0; i < n; i++) {
		ll x;cin>>x;
		a.pb(x);
	}
	sort(ALL(a));
	suma.pb(0);
	for(int i = 0; i < n; i++) {
		suma.pb(suma[i] + a[i]);
	}
	ll ok = LINF;
	ll ng = 0;
	while(ok - ng > 1){
		ll mid = (ok + ng) / 2;
		if (search_min(mid) <= m){
			ok = mid;
		}
		else{
			ng = mid;
		}
	}
	// cout << "ok" << ng << endl;
	// cout << search_min(113) <<" " << search_min(114) << endl;
	cout << search_sum(ng) << endl;




	return 0;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=200005;
//i_am_noob
int a,b;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cout << fixed << setprecision(12);
	cin >> a >> b;
	print1(max(max(a+b,a-b),a*b));
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[,]A = new int[N-1,3];
		int[]ans = new int[N];
		int[]c = new int[N];
		for(var i=0;i<N-1;i++){
			string[] str = Console.ReadLine().Split();
			A[i,0] = int.Parse(str[0]);
			A[i,1] = int.Parse(str[1]);
			A[i,2] = int.Parse(str[2]);
		}
		var list = new List<int[]>[N];
		for(var i=0;i<N;i++){
			list[i] = new List<int[]>();
		}
		for(var i=0;i<N-1;i++){
			list[A[i,0]-1].Add(new int[2]{A[i,1]-1,A[i,2]});
			list[A[i,1]-1].Add(new int[2]{A[i,0]-1,A[i,2]});
		}
		int w = -1;
		for(var i=0;i<N;i++){
			if(list[i].Count==1){
				w = i;
			}
		}
		var list2 = new List<int>();
		list2.Add(w);
		c[w] = 1;
		while(list2.Count>0){
			var list3 = new List<int>(list2);
			list2.Clear();
			foreach(var i1 in list3){
				for(var i=0;i<list[i1].Count;i++){
					int i2 = list[i1][i][0];
					if(c[i2]==0){
					int w2 = list[i1][i][1];
					int a2 = ans[i1];
					if((a2+w2)%2==1){
						ans[i2] = 1;
					}
					list2.Add(i2);
					c[i2]=1;
					}
				}
			}
		}
		for(var i=0;i<N;i++){
			Console.WriteLine(ans[i]);
		}
	}
}

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

int main() {
	int a, b, ans = 0, tmp;
	int n[5];
	cin >> a >> b;
	for (int i = a; i <= b; i++) {
		tmp = i;
		for (int j = 0; j < 5; j++) {
			n[j] = tmp % 10;
			tmp /= 10;
		}
		if (n[4] == n[0] && n[3] == n[1]) {
			ans += 1;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, M, K, A;
    map<int, int> mii;
    cin >> N >> M;
    REP(i, N) {
        cin >> K;
        REP(j, K) {
            cin >> A;
            mii[A]++;
        }
    }

    int ans = 0;
    for (auto p : mii) {
        if (p.second == N) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	"strings"
)

// define
var (
	sc = bufio.NewScanner(os.Stdin)
)

func scanIntLine(len int) []int{
	arr := make([]int, len)
	for i:=0; i<len; i++{
		sc.Scan()
		tmp, err := strconv.Atoi(sc.Text())
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func scanStringLine(len int) []string{
	arr := make([]string, len)
	for i:=0; i<len; i++{
		sc.Scan()
		arr[i] = sc.Text()
	}
	return arr
}

func scanIntSplit(len int) []int{
	arr := make([]int, len)
	sc.Scan()
	for i, v := range strings.Split(sc.Text(), " "){
		tmp, err := strconv.Atoi(v)
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

var (
	n int
	cmap [][]int
)

func step(x, y int) int{
	sum := cmap[y][x]
	if !(x < n && y < 2) {
		return sum
	}
	x_step, y_step := step(x+1, y), step(x, y+1)
	if x_step > y_step {
		sum += x_step
	} else {
		sum += y_step
	}
	return sum
}

func main(){
	cmap = make([][]int, 3)
	fmt.Scan(&n)
	for i:=0; i<2; i++ {
		cmap[i] = scanIntSplit(n)
		cmap[i] = append(cmap[i], 0)
	}
	cmap[2] = make([]int, n+1)
	fmt.Println(step(0,0))
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a;
cin>>a;
    cout<<a*a*a+a*a+a;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll N;
    cin >> N;
/*
    repd(i, 2, N + 1) {
        ll t = N;
        while (t % i == 0) {
            t /= i;
        }
        if (t % i == 1) cout << i << endl;
    }
    */

    ll ans = 0;
    set<ll> st;
    for (ll i = 2; i * i <= N; i++) {
        ll t = N;
        while (t % i == 0) {
            t /= i;
        }
        if (t % i == 1) {
            if (st.count(i) == 0) {
                ans++;
                st.insert(i);
            }
            ll t2 = N / i;
            if (N % t2 == 1 && st.count(t2) == 0) {
                ans++;
                st.insert(t2);
            }
        }
    }

    if (st.count(N) == 0) ans++;
    if (st.count(N - 1) == 0 && N - 1 > 1) ans++;
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;

const int N = 1e5+1;

const ll MAX = 1e10+1;

ll f(ll u, ll x) {
	return abs(x-u);
}

int main () {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int A, B, Q; cin >> A >> B >> Q;
	vector<ll> a(A+1), b(B+1);
	for (int i = 0; i < A; i++)
		cin >> a[i];
	for (int i = 0; i < B; i++)
		cin >> b[i];
	a[A] = b[B] = MAX;
	while (Q--) {
		ll ans = 69*MAX;
		ll x; cin >> x;

		auto xa = lower_bound(a.begin(), a.end(), x);
		auto xb = lower_bound(b.begin(), b.end(), x);

		auto xal = (xa == a.begin() ? xa : xa-1);
		auto xar = (*xa == MAX ? xa-1 : xa);
		auto xbl = (xb == b.begin() ? xb : xb-1);
		auto xbr = (*xb == MAX ? xb-1 : xb);

		auto xalb = lower_bound(b.begin(), b.end(), *xal);
		auto xarb = lower_bound(b.begin(), b.end(), *xar);
		auto xbla = lower_bound(a.begin(), a.end(), *xbl);
		auto xbra = lower_bound(a.begin(), a.end(), *xbr);

		auto xalbl = (xalb == b.begin() ? xalb : xalb-1);
		auto xalbr = (*xalb == MAX ? xalb-1 : xalb);
		ans = min(ans, f(*xal, x)+min(f(*xalbl, *xal),f(*xalbr,*xal)));

		auto xarbl = (xarb == b.begin() ? xarb : xarb-1);
		auto xarbr = (*xarb == MAX ? xarb-1 : xarb);
		ans = min(ans, f(*xar, x)+min(f(*xarbl, *xar),f(*xarbr,*xar)));

		auto xblal = (xbla == a.begin() ? xbla : xbla-1);
		auto xblar = (*xbla == MAX ? xbla-1 : xbla);
		ans = min(ans, f(*xbl, x)+min(f(*xblal, *xbl),f(*xblar,*xbl)));

		auto xbral = (xbra == a.begin() ? xbra : xbra-1);
		auto xbrar = (*xbra == MAX ? xbra-1 : xbra);
		ans = min(ans, f(*xbr, x)+min(f(*xbral, *xbr),f(*xbrar,*xbr)));

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

Measured memory_bytes: 2944
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>

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

using namespace std;
typedef long long int ll;
const int INF = 100000000;

int main()
{
    int l;
    cin >> l;
    double a = static_cast<double>(l) / 3.0;
    double ans = a * a * a;
    cout << fixed << setprecision(10);
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

n=int(input())
Arr=get_array()
total=0
for i in Arr:
  total+=(1/i)
ans=1/total
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, m, k;
char input[6][500];
char str[10000100];
set<string> opened;

string Open(int &pos) {
  string ret;
  while (input[5][pos] != '\0' && input[5][pos] != ')') {
    if (isdigit(input[5][pos])) {
      int num = atoi(input[5] + pos);
      while (isdigit(input[5][pos])) { pos++; }
      assert(input[5][pos] == '(');
      pos++;
      string nret = Open(pos);
      assert(input[5][pos] == ')');
      pos++;
      num = min(num, max(2, (m + (int)nret.size() - 1) / (int)nret.size()));
      if (nret.size() >= 400) {
        if (opened.count(nret)) { num = 1; }
        opened.insert(nret);
      }
      string add;
      REP(i, num) { add += nret; }
      if (add.size() >= 400) { opened.insert(add); }
      ret += add;
    } else {
      ret += input[5][pos++];
    }
  }
  assert((int)ret.size() <= 10000000);
  return ret;
}

int main() {
  while (scanf("%d %d %d", &n, &m, &k) > 0) {
    opened.clear();
    scanf("%s", input[5]);
    REP(i, k) {
      scanf("%s", input[i]);
    }
    {
      int pos = 0;
      string s = Open(pos);
      sprintf(str, "%s", s.c_str());
    }
    int ans = -1;
    int maxValue = -1;
    REP(iter, k) {
      int lv = 0;
      REP(r, m) {
        REP(l, r + 1) {
          char c = input[iter][r + 1];
          input[iter][r + 1] = 0;
          lv += strstr(str, input[iter] + l) != NULL;
          input[iter][r + 1] = c;
        }
      }
      if (lv > maxValue) {
        ans = iter + 1;
        maxValue = lv;
      }
    }
    printf("%d %d\n", ans, maxValue);
  }
}

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

int main(void){
    int n;
    cin >> n;
    map<int,int> mp;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        if((itr->second)%2 == 1){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int n, k;
long long int f[1005];
long long int ans;
int main() {
	cin >> n >> k;
	f[1] = 1;
	f[k] = 1;
	ans = 1;
	if (k == 2) ans ++;
	for (int i = 3; i <= n; i++) {
		if (i >= 3) f[i] += f[i-2];
		if (i >= k+2) f[i] += f[i-k-1];
		ans += f[i];
	}
	cout << ans << endl;
}





Measured memory_bytes: 3100
package main

import (
	"fmt"
	"strconv"
	"strings"
)


func validate(s string) bool{
	i := strings.IndexAny(s,"7")
	j := strings.IndexAny(s,"5")
	k := strings.IndexAny(s,"'3")
	return i>=0 && j >=0 && k>= 0

}
func get(a string) (ans []string){
	if(len(a)>9){
		return []string{}
	}

	return append(append(append(get(a+"7"),get(a+"5")...), get(a+"3")...),a)
}
func main() {
	var N int;
	fmt.Scan(&N)
	ans := 0
	for _, value := range get("") {
		if !validate(value){
			continue
		}
		if v,_ := strconv.Atoi(value); v<= N{
			//fmt.Println(v)
			ans++
		}
	}
	fmt.Println(ans)


}


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

int main() {
  long long A,B;
  cin >> A >> B;
  long long mul = 1;
  
  for (int i = 2; i <= 100000; i++) {
    if (A % i == 0 && B % i == 0){
      A = A/i;
      B = B/i;
      mul *= i;
      i = 1;
    }
  }
  long long MM = A*B*mul;
  cout << MM << endl;
}

Measured memory_bytes: 3584
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;

int main()
{
	int a,b;
	cin>>a>>b;
	long long ans=0;
	for(int i=0; i<a; i++)
	{
		int c;
		cin>>c;
		if(c>=b)
		{
			ans++;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <queue>
#define maxn 805
#define INF 23333333
#define hh(x) (((x)>0)?((x)-1)/K+1:0)
using namespace std;

int ans=INF,sum,H,W,K,x1,y1,f[maxn][maxn][4];
int vis[maxn][maxn],fx[4][2]={{-1,0},{0,-1},{1,0},{0,1}};
int tmp,xxx,yyy,x,y,dep;
char map[maxn][maxn];

struct xx
{
	int x,y,dep;
};
queue <xx > q;
inline int check(int x,int y)
{
	return 1<=x&&x<=H&&
	       1<=y&&y<=W&&
		   map[x][y]!='#';
}

inline void bfs()
{
	q.push((xx){x1,y1,0});
	while (!q.empty())
	{
		xx now=q.front();q.pop();
		 x=now.x,y=now.y,dep=now.dep;
		if (dep>K||vis[x][y]) continue;
		vis[x][y]=1;
		tmp=min(min(H-x,W-y),min(x-1,y-1));
		tmp=(tmp+K-1)/K;
		if (tmp+1>ans) continue;
		ans=min(ans,tmp+1);
	//printf("-- x:%d y:%d dep:%d tmp+1:%d\n--",x,y,dep,tmp+1);
		for (int i=0;i<4;++i)
		{
			xxx=x+fx[i][0];
			yyy=y+fx[i][1];
			if (check(xxx,yyy)//&&!vis[xxx][yyy])
			)
				  q.push((xx){xxx,yyy,dep+1});
		}
	}
	return ;
}

int main()
{
	
	scanf("%d%d%d",&H,&W,&K);
	for (int i=1;i<=H;++i) scanf("%s",map[i]+1);
	for (int i=1;i<=H;++i)
	  for (int j=1;j<=W;++j)
	  	  if ('S'==map[i][j]) x1=i,y1=j;
	if (x1==1||x1==H||y1==1||y1==W) ans=0;
	else bfs();
	printf("%d",ans);
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	int a = 0, b = 0;
	for (int i = 0; i < n; i++) {
		string s, t;
		cin >> s >> t;
		if (s > t)
			a += 3;
		else if (s < t)
			b += 3;
		else {
			a++;
			b++;
		}
	}
	cout << a << ' ' << b << endl;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int W, H, N; scanf("%d %d %d", &W, &H, &N);
  vector<int> X(N), Y(N), A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d %d %d", &X[i], &Y[i], &A[i]);
  }
  int left = 0, right = W, bottom = 0, top = H;
  for (int i = 0; i < N; ++i) {
    if (A[i] == 1) { left = max(left, X[i]); }
    else if (A[i] == 2) { right = min(right, X[i]); }
    else if (A[i] == 3) { bottom = max(bottom, Y[i]); }
    else if (A[i] == 4) { top = min(top, Y[i]); }
  }
  int ans = 0;
  if (left < right and bottom < top) {
    ans = (right - left) * (top - bottom);
  }
  printf("%d\n", ans);
  return 0;
}


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

int main() {
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
}


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

bool notprime(int n) {
  int i;
  int ns;

  for (i=3; i*i<=n; i+=2) {
    if (n%i==0) return true;
  }
  return false;
}
int main()
{
  int X;
  cin >> X;
  if (X==2 || X==3 || X==5 || X==7) {
    printf("%d\n", X);
    return 0;
  }
  if (X%2 == 0) X++;
  while (notprime(X)) X+=2;
  printf("%d\n", X);
  return 0;
}


Measured memory_bytes: 256