akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

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

    int max_n = 0;
    repi(i, 1, N) {
        set<char> list;
        string sub_1 = S.substr(0, i);
        string sub_2 = S.substr(i, N - i + 1);
        for(char a : sub_1) {
            for(char b : sub_2) {
                if(a == b) list.insert(a);
            }
        }
        max_n = max(max_n, (int)list.size());
    }

    cout << max_n << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
  
int v;
int parent[100001];
int sibling[100001];
int degree[100001];
  
int Depth(int i);
int Height(int i);

int main(){
  int i,j;
  int id, l, r;

  scanf("%d", &v); 
 
  for(i = 0; i < v; ++i) {
    parent[i] = -1;
    sibling[i] = -1;
    degree[i] = 0;
  }
  for(i = 0; i < v; ++i) {
    scanf("%d %d %d", &id, &l, &r);
    if(l != -1){
      parent[l] = id;
      sibling[l] = r;
      ++degree[id];
    }
    if(r != -1){
      parent[r] = id;
      sibling[r] = l;
      ++degree[id];
    }
  }
  
  for(i = 0; i < v; ++i) {
    int depth = Depth(i);
 
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", i, parent[i], sibling[i], degree[i], depth, Height(i));
 
    if(depth == 0) {
      printf("root\n");
    } else if(degree[i] == 0) {
      printf("leaf\n");
    } else {
      printf("internal node\n");
    }
  }                                                                         
  return 0;
}

int Depth(int i){
  if(parent[i] == -1) return 0;
  return Depth(parent[i]) + 1;
}
  
int Height(int i){
  int j, h;
 
  h = 0;
  for(j = 0; j < v; ++j){
    if(parent[j] == i){
      int tmp = Height(j) + 1;
      if(tmp > h){
        h = tmp;
      }
    }
  }
  return h;
}

Measured memory_bytes: 620
# coding: utf-8
import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))


def BinarySearch(num, List):
    if len(List) == 0:
        print("Erorr : list has no element")
        return
    left,right = 0,len(List)
    while left < right:
        mid  = (left+right)//2
        if num < List[mid]:#
            right = mid
        else:
            left = mid + 1
    return right


def main():
    n,m,k = na()
    honA = [0] + na() + [float('inf')]
    honB = [0] + na() + [float('inf')]
    honAsum = [0]
    for i in range(n+1):
        honAsum += [honAsum[-1]+honA[i+1]]
    honBsum = [0]
    for i in range(m+1):
        honBsum += [honBsum[-1]+honB[i+1]]
    rightA = BinarySearch(k, honAsum)
    rightB = BinarySearch(k-honAsum[rightA-1],honBsum)
    ans = rightA + rightB - 2
    while rightA > 0:
        if rightB == m+1:
            break
        rightA -= 1
        rightB = BinarySearch(k-honAsum[rightA-1],honBsum)
        ans = max(ans, rightA+rightB-2)
    print(ans)
    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 127308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

  cout << max((n) * (n-1) / 2,0) + max(m * (m-1) / 2,0) << "\n";
}


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector v(N+1, 0LL);
  for (ll x = 1; x <= 100; x++) {
    for (ll y = 1; y <= 100; y++) {
      for (ll z = 1; z <= 100; z++) {
	ll k = x * x + y * y + z * z + x * y + y * z + z * x;
	if (k <= N) v.at(k)++;
      }
    }
  }
  for (ll i = 1; i <= N; i++) {
    cout << v.at(i) << "\n";
  }

  return 0;
}







Measured memory_bytes: 3632
def change(ball,x,y):
    tmp = ball[x]
    ball[x] = ball[y]
    ball[y] = tmp
    return ball

def jug(ball):
    ball2 = ["A","B","C"]

    for i in range(0,3):
        if ball[i] == 1:
            print ball2[i]
            break

if __name__ == "__main__":

    ball = [1,0,0]
    while True:
        try:
            x = 0
            y = 0
            z = 0

            a,b = map(str,raw_input().split(","))

            if a == "A":
                if b == "B":
                    x=0
                    y=1
		elif b == "C":
                    x=0
                    y=2
            elif a == "B":
		if b == "A":
                    x=1
                    y=0
		elif b == "C":
                    x=1
                    y=2
            elif a == "C":
		if b == "A":
                    x=2
                    y=0
		elif b == "B":
                    x=2
                    y=1

            ball = change(ball,x,y)
        except EOFError:
            break

    jug(ball)

Measured memory_bytes: 4264
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>

using namespace std;

int n;
int a, b;

int p[110];
int aSet, bSet, cSet;

int main()
{
	scanf("%d", &n);
	scanf("%d%d", &a, &b);
	
	for (int i = 0 ; i < n ; i++)
	{
		scanf("%d", &(p[i]));		
		if (p[i] <= a)
		{
			aSet++;
		}
		else if ((a < p[i]) && (p[i] <= b))
		{
			bSet++;
		}
		else if (p[i] > b)
		{
			cSet++;
		}
	}
	
	int minSet = aSet;
	if (minSet > bSet) minSet = bSet;
	if (minSet > cSet) minSet = cSet;
	
	printf("%d\n", minSet);
	
	return 0;
}

Measured memory_bytes: 128
from itertools import permutations

n=int(input())
lst_ini=[list(map(int,input().split())) for _ in range(n)]
row=list(range(8))
col=list(range(8))
for x in lst_ini:
    row.remove(x[0])
    col.remove(x[1])

for x in permutations(col):
    work=lst_ini[:]
    for i in range(8-n):
        work.append([row[i],x[i]])
    
    #対角方向チェック
    for y in work:
        for i in range(8):
            if y[0]==i: continue
            if [i,y[1]-(y[0]-i)] in work : break
            if [i,y[1]+(y[0]-i)] in work : break
        else : continue
        break
    else : break

for i in range(8):
    out=""
    for j in range(8):
        if [i,j] in work : out+="Q"
        else : out+="."
    print(out)



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

using namespace std;

typedef long long int ll;
#define inf 0x3f3f3f3f
#define endl '\n'
#define case(i) "Case #" << i << ": "

template <typename S, typename T>
ostream& operator<<(ostream& out, pair<S, T> const& p) {
    out << '(' << p.first << ", " << p.second << ')';
    return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> const& v) {
    ll l = v.size();
    for (ll i = 0; i < l - 1; i++) out << v[i] << ' ';
    if (l > 0) out << v[l - 1];
    return out;
}

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

    int n;
    cin >> n;
    ll k;
    cin >> k;

    vector<ll> a(n), f(n);
    vector<pair<ll, ll>> r(n);

    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for(int i = 0; i < n; ++i) {
        cin >> f[i];
    }
    sort(a.rbegin(), a.rend());
    sort(f.begin(), f.end());

    // cout << a << endl << f << endl;

    for(int i = 0; i < n; ++i) {
        r[i] = {a[i] * f[i], f[i]};
    }
    sort(r.begin(), r.end());
    // cout << r << endl;

    ll start = 0, end = r[n-1].first;

    ll ans = end;
    while(start <= end) {
        ll mid = (start + end) / 2;

        ll req = 0;
        for(int i = 0; i < n; ++i) {
            if(r[i].first > mid) {
                ll diff = r[i].first - mid;
                req += (diff / r[i].second);
                if(diff % r[i].second) req++;
            }
        }
        if(req <= k) {
            ans = mid;
            end = mid - 1;
        }
        else start = mid + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;
const string MINUSINF = "-";

void chmax(string &a, string b) {
  if (a == MINUSINF)
    a = b;
  else if (a.size() < b.size())
    a = b;
  else if (a.size() == b.size()) {
    if (a < b) a = b;
  }
}

long long match[10] = {2, 5, 5, 4, 5, 6, 3, 7, 6};

string dp[11000];

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (int i = 0; i < m; i++) cin >> a[i];

  for (int i = 0; i < 11000; i++) dp[i] = MINUSINF;

  dp[0] = "";
  for (int i = 0; i <= n; i++) {
    if (dp[i] == MINUSINF) continue;
    for (auto a_i : a) chmax(dp[i + match[a_i - 1]], dp[i] + (char)('0' + a_i));
  }

  cout << dp[n] << endl;
  return 0;
}


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

#define F first
#define S second

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

const int oo = 1e9 + 4;
const int SZ = 2e5 + 4;

int n;
vector <int> a;
ll ans;
map <ll, int> k;

void read() {
    cin >> n;
    a.resize(n);
    for (auto &t : a) {
        cin >> t;
        k[t]++;
    }
}

void solve() {
    for (auto t : k)
        ans += 1ll * t.S * (t.S - 1) / 2;
    for (int i = 0; i < n; i++) {
        ll t = k[a[i]];
        ll res = ans - t * (t - 1) / 2;
        res += (t - 1) * (t - 2) / 2;
        cout << res << endl;
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    read();
    solve();
}


Measured memory_bytes: 10368
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 2e5+5;

int A[N];
int main() {
	int n;
	while(~scanf("%d", &n)) {
		for(int i = 0; i < n; ++i) {
			scanf("%d", &A[i]);
			A[i] -= i;
		}
		sort(A, A+n);
		int mid = (A[n/2] + A[(n-1)/2]) / 2;
		ll ans = 0;
		for(int i = 0; i < n; ++i) {
			ans += abs(A[i] - mid);
		} 
		printf("%lld\n", ans);
	}
	return 0;
}


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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	int d[4];
	REP(i, 4) cin >> d[i];
	sort(d, d+4);
	if(d[0] == 1 && d[1] == 4 && d[2] == 7 && d[3] == 9) cout <<"YES" << endl;
	else cout << "NO" << endl;
} 

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

int main() {
  using namespace std;

  int N, K;
  std::cin >> N >> K;

  int h[100000];
  for (int i = 0; i < N; i++) {
    std::cin >> h[i];
  }

  int cost[100000] = {0};
  // 0 ~ K
  cost[0] = 0;
  for (int i = 1; i < min(K + 1, N); i++) {
    cost[i] = abs(h[i] - h[0]);
  }

  for (int i = K; i < N; i++) {
    int tmp = cost[i - 1] + abs(h[i] - h[i - 1]);
    for (int j = 2; j <= K; j++) {
      tmp = min(tmp, cost[i - j] + abs(h[i] - h[i - j]));
    }
    cost[i] = tmp;
  }

  cout << cost[N - 1] << std::endl;

  return 0;
}


Measured memory_bytes: 3944
#include <algorithm>
#include <cctype>
#include <cstring>
#include <cstdio>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{   
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 2e5+5;
int n, m;
int a[N], b[N], cnt, ans;
int main()
{
    n = read(), m = read();
    for(int i = 1; i <= m; ++i) a[i] = read(), cnt += (a[i]&1);
    if(cnt > 2) return puts("Impossible"), 0;
    for(int i = 1; i <= m; ++i) if(a[i]&1) swap(a[i], a[1]), i = m;
    for(int i = 2; i <= m; ++i) if(a[i]&1) swap(a[i], a[m]);
    if(a[1] != 1) b[++ans] = a[1]-1;
    for(int i = 2; i < m; ++i) b[++ans] = a[i]; b[++ans] = n;
    for(int i = 1; i < ans; ++i) b[ans] -= b[i];
    for(int i = 1; i <= m; ++i) printf("%d ", a[i]); puts("");
    printf("%d\n", ans);
    for(int i = 1; i <= ans; ++i) printf("%d ", b[i]); puts("");
    return 0;
}

Measured memory_bytes: 128
import sys

lines = 1
inp = list()

for _ in range(lines):
    inp.append(sys.stdin.readline().strip())


line = inp[0].split()

a = int(line[0])
b = int(line[1])
c = int(line[2])
d = int(line[3])

t_life = a
a_life = c

while True:
    a_life -= b
    t_life -= d
    if a_life <= 0:
        print("Yes")
        break
    if t_life <= 0:
        print("No")
        break


Measured memory_bytes: 9132
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2") 
#pragma GCC optimization ("unroll-loops")

using namespace std;
using ll = long long;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define Ceil(x, y) ((x+y-1)/y)
#define PI acos(-1)
const int mod = (int) 1000000007;



void solve()
{
    ll n, x, t;
    cin>>n>>x>>t;
    cout<<t*Ceil(n, x);
}
 

int main(int argc, char *argv[])
{
    clock_t clk_start = clock();
    fast;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
 
    int cases = 1;
    // cin>>cases;
    while(cases--)
    {
        solve();
    }
    cerr<<"Execution Time: "<<fixed<<double(clock() - clk_start)/double(CLOCKS_PER_SEC)<<setprecision(6)<<" sec\n"; 
}


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

int main(){
    int n;
    cin >> n;
    int A[2][n];
    int S[2][n];
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){
            cin >> A[i][j];
            S[i][j]=A[i][j];
        }
    }
    for(int j=1;j<n;j++){
        S[0][j]+=S[0][j-1];
    }
    int res;
    int ans=0;
    for(int i=0;i<n;i++){
        res=S[0][i];
        for(int j=i;j<n;j++){
            res+=A[1][j];
        }
        ans=max(res,ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//agc017_a.cpp
//Sat Nov  3 11:39:12 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

vector<vector<ll>> comb(int n, int r) {
  vector<vector<ll>> v(n + 1,vector<ll>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int main(){
	ll n,p;
	cin >> n >> p;

	ll even = 0;
	ll odd = 0;
	for (int i=0;i<n;i++){
		int temp;
		cin >> temp;
		if (temp%2 == 0){
			even++;
		}else {
			odd++;
		}
	}

	ll evenans = 0;
	for (int i=0;i<=even;i++){
		vector<vector<ll>> temp = comb(even,i);
		evenans += temp[even][i];
	}
	ll oddans = 0;
	if (p==0){
		for (int i=0;i<=odd;i=i+2){
			vector<vector<ll>> temp = comb(odd,i);	
			oddans += temp[odd][i];
		}
	}else {
		for (int i=1;i<=odd;i=i+2){
			vector<vector<ll>> temp = comb(odd,i);	
			oddans += temp[odd][i];
		}
	}

	cout << evenans*oddans << endl;
}

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

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



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, M;
	cin >> N >> M;
	int S[2000], T[2000];
	rep(i, N) cin >> S[i];
	rep(i, M) cin >> T[i];

	ll mod = 1e9 + 7;
	ll dp[2001][2001] = {};
	ll dps[2001][2001] = {};

	dp[0][0] = 1;
	rep(i, M + 1) dps[0][i] = 1;
	rep1(i, N) {
		dps[i][0] = 1;
		rep1(j, M) {
			if (S[i - 1] == T[j - 1]) {
				dp[i][j] = dps[i - 1][j - 1];
			}
			dps[i][j] = dps[i - 1][j] + dps[i][j - 1] - dps[i - 1][j - 1] + dp[i][j] + mod;
			dps[i][j] %= mod;
		}
	}

	ll kotae = 0;
	rep1(i, N) rep1(j, M) {
		kotae += dp[i][j];
		kotae %= mod;
	}
	co((kotae + 1) % mod);

	Would you please return 0;
}

Measured memory_bytes: 62848
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        s: String,
    };
    let mut c_vec: Vec<char> = s.chars().collect();
    if *c_vec.last().unwrap() != 's' {
        c_vec.push('s');
    } else {
        c_vec.append(&mut vec!['e', 's']);
    }
    println!("{}", c_vec.iter().collect::<String>());
}


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

#define ll long long int
#define maximum 0x7f

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

double dp[3000][3000];

int main()
{
    int n;
    cin>>n;
    double p[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>p[i];
        dp[i][0]=1;
    }
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(!j)
                dp[i][j]=(1-p[i])*dp[i-1][j];
            else
                dp[i][j]=(1-p[i])*dp[i-1][j]+dp[i-1][j-1]*p[i];
        }
    }
    double ans=0.0;
    for(int i=n/2+1;i<=n;i++)
        ans+=dp[n][i];
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 68864
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int N=cin.nextInt();
        long[] a=cin.ArrayLong(N,0);
        bool down =false;
        int maxdown=0;
        int downcount=0;
        for(int i=0;i<N-1;i++)
        {
            if(down==false&&a[i]>=a[i+1]){down =true;downcount++;}
            else if(down==true&&a[i]>=a[i+1])downcount++;
            else if(down==true&&a[i]<a[i+1]){maxdown=Math.Max(downcount,maxdown);downcount=0;down=false;}
        }
        if(down==true)maxdown=Math.Max(downcount,maxdown);
        Console.WriteLine(maxdown);
        
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
    public void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}

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

#define ll long long
#define F first
#define S second
#define ii pair < int , int >
#define ever (;;)

const int N = 110;

int n,k,a[N],dp[100100];

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

    for(int i=1;i<=k;i++)
        for(int j=1;j<=n;j++)
            if( i-a[j] >= 0 )
                dp[i] |= !dp[i-a[j]];

    printf( ( dp[k] ) ? "First\n" : "Second\n" );
}


Measured memory_bytes: 4068
#include<iostream>
using namespace std;
#define int long long
int n,a,b;
signed main(){
	cin>>n>>a>>b;
	if(a>b||(n==1&&a!=b))cout<<"0"<<endl;
	else cout<<(b*(n-1)+a)-(a*(n-1)+b)+1<<endl;
	return 0;
}

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

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int ans = (h2 - h1) * 60 + m2 - m1 - k;

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


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> x(M);
    for(int i = 0; i < M; i++) cin >> x.at(i);
  	sort(x.begin(), x.end());
    
    vector<long long> y(M-1);
    for(int i = 0; i < M-1; i++) y.at(i) = abs(x.at(i+1) - x.at(i));
    sort(y.begin(), y.end());
    int ans = 0;
    for(int i = 0; i < max(M - N, 0); i++) ans += y.at(i);
    cout << ans << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  string x;
  cin>>x;
  int diff = 0;
  int s = 0, t = 0;
  rep(i,x.size()) {
    if(x[i] == 'S') {
      s++;
    } else {
      t++;
    }
    diff = max(diff, t - s);
  }
  cout << diff * 2 << endl;

  return 0;

}


Measured memory_bytes: 720
n = int(input())
a_array = [int(x) for x in input().split()]
b_array = [int(x) for x in input().split()]

res = 0
amari = 0
amari0 = 0
amari1 = 0
for i in range(n):
    if i % 2 == 0:
        monster = max(0, a_array[i]-amari1)
        res += min(amari1, a_array[i])
        res += monster if b_array[i] >= monster else b_array[i]
        # amari = max(0, (b_array[i]+amari)-a_array[i])
        amari0 = 0 if b_array[i] <= monster else b_array[i]-monster
    else:
        monster = max(0, a_array[i]-amari0)
        res += min(amari0, a_array[i])
        res += monster if b_array[i] >= monster else b_array[i]
        # amari = max(0, (b_array[i]+amari)-a_array[i])
        amari1 = 0 if b_array[i] <= monster else b_array[i]-monster

if n % 2 == 0:
    monster = max(0, a_array[-1]-amari1)
    res += min(amari1, a_array[-1])
else:
    monster = max(0, a_array[-1]-amari0)
    res += min(amari0, a_array[-1])
print(res)


Measured memory_bytes: 18624
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''
n=list(map(int, input().split()))
if sum(n)%9==0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9368
#include <bits/stdc++.h>
using namespace std;
 
const int MAXN = 50005;
const int MAXM = 50005;
const string str[12] = {"C","C#","D","D#","E","F","F#","G","G#","A","A#","B"};
 
map<string, int> id;
int n, m;
int T[MAXN], S[MAXM];
 
bool rec(int k, int p) {
  if((m - p) * 2 < (n - 1) - k) return false;
  if(p == m) return (n + 1) - k <= 2;
  if(k-1 > 0 && (T[k-1]+11)%12 == S[p] && rec(k-1, p+1)) return true;
  if(k+1 < n+1 && (T[k+1]+0)%12 == S[p] && rec(k+1, p+1)) return true;
  if(k+2 < n+1 && (T[k+2]+1)%12 == S[p] && rec(k+2, p+1)) return true;
  return false;
}
 
int main() {
  for(int i = 0; i < 12; ++i) id[str[i]] = i;
 
  int Tc; cin >> Tc;
  while(Tc--) {
    cin >> n >> m;
    for(int i = 0; i < n; ++i) {
      string s; cin >> s;
      T[i+1] = id[s];
    }
    for(int i = 0; i < m; ++i) {
      string s; cin >> s;
      S[i] = id[s];
    }
    cout << (rec(0, 0) ? "Yes" : "No") << endl;
  }
  return 0;
}

Measured memory_bytes: 3948
import java.util.*;

class Main {
	static Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		while(in.hasNext()) {
			String[] A = in.nextLine().split(" ");
			String[] B = in.nextLine().split(" ");
			int hit = 0 , blow = 0;
			for (int i = 0; i < A.length; i++) {
			for (int j = 0; j < B.length; j++) {
				if (A[i].equals(B[j])) {
					if (i==j) hit++;
					else blow++;
				}
			}}
			System.out.printf("%d %d\n",hit, blow);
		}
	}
}

Measured memory_bytes: 15364
def prepare(n, MOD):
 
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return factorials, invs

MOD = 10**9+7
fact, fact_inv = prepare(3*10**5, MOD)

n, k = map(int,input().split())

k = min(n-1, k)

ans = 1
for i in range(1,k+1):
    z = fact[n] * fact_inv[i] % MOD * fact_inv[n-i] % MOD
    p = fact[n-1] * fact_inv[n-i-1] % MOD * fact_inv[i] % MOD
    ans += z * p % MOD
    ans %= MOD
print(ans)

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

int main() {

    int a;
    cin >> a;

    std::string s;
    std::cin >> s;

    if ( a >= 3200 ) {
        std::cout << s << std::endl;
    }
    else {
        cout << "red" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX_N = 1e4+5;

int N;
ll a[MAX_N], b[MAX_N];

void input() {
	cin >> N;
	for(int i=0;i<N;i++) cin >> a[i];
	for(int i=0;i<N;i++) cin >> b[i];
}
void solve() {
	//sort(a, a+N);
	//sort(b, b+N);
	ll add = 0;
	for(int i=0;i<N;i++) {
		if(a[i] > b[i]) {
			// この回数ここにa-bを足す必要がある
			add -= (a[i]-b[i]);
		} else if(a[i] < b[i]) {
			// この差/2だけ足す余裕がある
			add += (b[i]-a[i])/2;
		}
	}
	cout << ((add>=0)?"Yes":"No") << endl;
}

int main(){
	input();
	solve();
}

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

using namespace std;



template<typename T>
class UF{
public:
	UF(){
		size = 0;
	}

	//値を挿入する
	void push(T a){
		M[a] = size;
		V.push_back(size);
		rank.push_back(0);
		C.push_back(1);
		size++;
	}

	//同じグループにする
	void unite(T a, T b){
		long long int x = find(M[a]);
		long long int y = find(M[b]);
		if( x == y )return;
		if( rank[x] < rank[y] ){
			V[x] = y;
			C[y] += C[x];
		} else{
			V[y] = x;
			C[x] += C[y];
			if( rank[x] == rank[y] )rank[x]++;
		}
	}

	void merge(T a, T b){
		unite(a, b);
	}

	//同じグループにいるかどうか判定する
	bool same(T a, T b){
		return find(M[a]) == find(M[b]);
	}

	//今何グループあるか数を返す
	long long int group(){
		set<long long int>S;
		for( long long int i = 0; i < V.size(); i++ ){
			S.insert(find(V[i]));
		}
		return S.size();
	}

	//グループに属している数を返す
	long long int count(T a){
		return C[find(M[a])];
	}

	//今属しているグループのIDを返す
	long long int groupID(T a){
		return find(M[a]);
	}

	//同じグループのメンバーを返す
	vector<T>friendList(T a){
		long long int inputID = find(M[a]);
		vector<T>ret;
		for( auto now : M ){
			if( find(now.second) == inputID ){
				ret.emplace_back(now.first);
			}
		}
		return ret;
	}

private:
	vector<long long int>C, V, rank;
	map < T, long long int>M;
	long long int size;

	//祖先までたどる
	long long int find(long long int x){
		if( V[x] == x )return x;
		else return V[x] = find(V[x]);
	}
};



int main(){
	long long int N, M;
	cin >> N >> M;
	vector<long long int>P(N);
	UF<long long int>uf;
	for( size_t i = 0; i < N; i++ ){
		cin >> P[i];
		P[i]--;
		uf.push(i);
	}


	for( size_t i = 0; i < M; i++ ){
		long long int x, y;
		cin >> x >> y;
		uf.merge(x - 1, y - 1);
	}

	long long int count = 0;
	for( size_t i = 0; i < N; i++ ){
		count += uf.same(i, P[i]);
	}
	cout << count << endl;
}

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

using ll = long long;
static const ll INF = 1e18;

struct edge {
  int to;
  ll cap, cost;
  int rev;
};

vector<ll> h, d; // ポテンシャル, 最短距離
vector<int> prevv, preve; // 直前の頂点と辺

void add_edge(vector<vector<edge>> &G, int from, int to, ll cap, ll cost) {
  G[from].emplace_back((edge) {to, cap, cost, (int) G[to].size()});
  G[to].emplace_back((edge) {from, 0, -cost, (int) G[from].size() - 1});
}

// sからtへの流量fの最小費用流(流せない場合は-1)
ll min_cost_flow(vector<vector<edge>> &G, int s, int t, ll f) {
  ll res = 0;
  h.assign(G.size(), 0);
  prevv.assign(G.size(), 0);
  preve.assign(G.size(), 0);
  while (f > 0) {
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
    d.assign(G.size(), INF);
    d[s] = 0;
    pq.push(make_pair(0, s));
    while (!pq.empty()) {
      pair<ll, int> p = pq.top();
      pq.pop();
      int v = p.second;
      if (d[v] < p.first) continue;
      for (int i = 0; i < G[v].size(); i++) {
        edge &e = G[v][i];
        if (e.cap > 0 && d[e.to] > d[v] + e.cost + h[v] - h[e.to]) {
          d[e.to] = d[v] + e.cost + h[v] - h[e.to];
          prevv[e.to] = v;
          preve[e.to] = i;
          pq.push(make_pair(d[e.to], e.to));
        }
      }
    }
    if (d[t] == INF) return -1;
    for (int i = 0; i < G.size(); i++) h[i] += d[i];
    
    // s-t間最短路に流す
    int nowf = f;
    for (int i = t; i != s; i = prevv[i]) {
      nowf = min<ll>(nowf, G[prevv[i]][preve[i]].cap);
    }
    f -= nowf;
    res += nowf * h[t];
    for (int i = t; i != s; i = prevv[i]) {
      edge &e = G[prevv[i]][preve[i]];
      e.cap -= nowf;
      G[i][e.rev].cap += nowf;
    }
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while (true) {
    int n;
    cin >> n;
    if (n == 0) return 0;
    
    ll sum = 0;
    vector<vector<ll>> v(n, vector<ll>(3));
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 3; j++) {
        cin >> v[i][j];
      }
      sort(v[i].begin(), v[i].end());
      sum += v[i][0] * v[i][1] * v[i][2];
    }
    
    int vs = 2 * n, vt = 2 * n + 1; // フローの始点と終点
    vector<vector<edge>> G(2 * n + 2);
    for (int i = 0; i < n; i++) {
      add_edge(G, vs, i, 1, 0);
      add_edge(G, i + n, vt, 1, 0);
      for (int j = 0; j < n; j++) {
        if (v[i][0] > v[j][0] && v[i][1] > v[j][1] && v[i][2] > v[j][2]) {
          add_edge(G, i, j + n, 1, -v[j][0] * v[j][1] * v[j][2]);
        }
      }
    }
    add_edge(G, vs, vt, n, 0);
    ll fl = min_cost_flow(G, vs, vt, n);
    cout << sum + fl << '\n';
  }
}


Measured memory_bytes: 3280
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;

int main(){
    int k,n,ans=0;
    cin>>n>>k;
    vector<int>a(10000);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end(),greater<>());
    for(int i=n-1;i>n-k-1;i--){
        ans+=a[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3644
n = int(input())
a = list(map(int,input().split()))

a.sort()
ans = [0,0]
temp_1 = 0
sign = 0

for i in range(1,n+1):
  temp = a[-i]

  if temp == temp_1:
    temp_1 = 0
    ans[sign] = temp
    if sign == 1:
      break
    sign = 1
  else:
    temp_1 = temp

print(ans[0]*ans[1])

Measured memory_bytes: 14252
#include <iostream>

using namespace std;

int main() {

  int a,b;
  int sum;
  int count;

  while(cin >> a >> b) {

    count=0;

    sum=a+b;

    while(sum>0) {

      sum/=10;

      count++;

    }

    cout << count << endl;

  }

}

Measured memory_bytes: 0
N = int(input())
mod = 10**9 + 7

dp = [[[[0 for i in range(4)] for j in range(4)] for k in range(4)] for l in range(N+1)]
dp[0][3][3][3] = 1
let = {i:l for i,l in enumerate('AGCT')}

def judge(lets):
    for i in range(4):
        t = lets.copy()
        if i >= 1:
            t[i-1],t[i] = t[i],t[i-1]
        if 'AGC' in ''.join(t):
            return False
    return True

for i in range(1,N+1):
    for l3 in range(4):
        for l2 in range(4):
            for l1 in range(4):
                for nextl in range(4):
                    lets = list(let[l3]+let[l2]+let[l1]+let[nextl])
                    if judge(lets):
                        dp[i][l2][l1][nextl] += dp[i-1][l3][l2][l1]
                        dp[i][l2][l1][nextl] %= mod
ans = 0
for l3 in range(4):
    for l2 in range(4):
        for l1 in range(4):
            ans = (ans + dp[N][l3][l2][l1])%mod
print(ans)


Measured memory_bytes: 3440
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)

ll A[100100];
ll ASUM[100100];
ll X[100100];
int main(){
    int N;
    cin >> N;
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a;
    }
    sort(A,A+N);
    ASUM[0] = A[0];
    FOR(i,1,N){
        ASUM[i] = ASUM[i-1] + A[i];
    }

    ll thres = ceil((double)A[N-1]/2);
    ll* p = A+N-1;
    while(1){
        //cout << thres << endl;
        ll* pp = lower_bound(A, A+N, thres);
        if(p == pp) break;
        p = pp;
        //cout << *pp << endl;
        thres = ceil((double)*pp/2);
    }
    //cout << thres << endl;

    REP(i,N){
        int num = upper_bound(A,A+N,A[i]*2) - A;
        X[i] = ASUM[num-1];
    }

    //REP(i,N){
    //    cout << X[i] << endl;
    //}

    int ans = 0;
    REP(i,N){
        ll x = X[i];
        if(x >= thres) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
n=int(input())
A = [0]*(n)
for i in range(n):
    s=int(input())
    A[i]=[s,i]    
lista=sorted(A,key=lambda x:x[0])
cnt=0
for i in range(n):
    lista[i].append(i)
for i in range(n):
    if (lista[i][1]-lista[i][2])%2!=0:
        cnt+=1
print(cnt//2)   

Measured memory_bytes: 27084
import math
h, n = map(int, input().split())
a, b = [], []
for i in range(n):
  x, y = map(int, input().split())
  a.append(x)
  b.append(y)

c = [min(b)] + [h*max(b)]*(h-1)

for i in range(1,h):
  for j in range(n):
    if a[j] >= i+1:
      c[i] = min(c[i], b[j])
    else:
      c[i] = min(c[i], c[i-a[j]]+b[j])
print(c[h-1])

Measured memory_bytes: 42348
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int cnt[100009];

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

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

	for (int i = 0; i < Q; i++) {
		int a; cin >> a;
		cnt[a]++;
	}

	for (int i = 1; i <= N; i++) {
		if (cnt[i] > Q - K) cout << "Yes" << endl;
		else cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define pb push_back
int n;
int A[210000];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&A[i]); A[i]-=i;
	}
	sort(A+1,A+n+1);
	long long ans=0;
	for (int i=1;i<=n;i++) ans+=abs(A[i]-A[(n+1)/2]);
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s;
  cin >> s;
  int s1 = s/100;
  int s2 = (s- s1 *100)/10;
  int s3 = (s- s1 *100 - s2*10);
  cout << s1+s2+s3 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int n;
string s;
pair<ll, ll> hsh[5005], c_hs[5005][5005];
ll inv1[5005];
ll inv2[5005];
ll p = 31, p1 = 179;
ll m = 1e9 + 9, m1 = 1e9 + 7;

void computeHashes(){
	ll hash_value = 0, hash_value1 = 0;
	ll p_pow = 1, p_pow1 = 1;
	int cnt = 0;
	for(char c : s){
		hash_value = (hash_value + (c - 'a' + 1) * p_pow) % m;
		p_pow = (p_pow * p) % m;
		hash_value1 = (hash_value1 + (c - 'a' + 1) * p_pow1) % m1;
		p_pow1 = (p_pow1 * p1) % m1;
		hsh[cnt] = mp(hash_value, hash_value1);
		cnt++;
	}
}

ll mypow(ll a, ll p, ll MOD){
	if(p == 0) return 1;
	if(p == 1) return (a % MOD);
	if(p & 1) return ((a % MOD) * (mypow(a, p - 1, MOD) % MOD)) % MOD;
	ll x = mypow(a, p / 2, MOD) % MOD;
	return (x * x) % MOD;
}

void computeInvs(){
	ll mult1 = 1LL, mult2 = 1LL;
	rep(i, 5005){
		inv1[i] = mypow(mult1, m - 2, m);
		(mult1 *= p) %= m;
	}
	rep(i, 5005){
		inv2[i] = mypow(mult2, m1 - 2, m1);
		(mult2 *= p1) %= m1;
	}
}

void comp_hs(int i, int j){
	ll hs1 = ((hsh[j].fi - (i ? hsh[i - 1].fi : 0)) + m) % m;
	ll hs2 = ((hsh[j].se - (i ? hsh[i - 1].se : 0)) + m1) % m1;
	(hs1 *= inv1[i]) %= m;
	(hs2 *= inv2[i]) %= m1;
	c_hs[i][j] = mp(hs1, hs2);
}

bool eq(pair<ll, ll> a, pair<ll, ll> b){
	return (a.fi == b.fi && a.se == b.se);
}

bool check(int len){
	rep(i, n - (2 * len) + 1) repn(j, i + len, n - len + 1){
		if(eq(c_hs[i][i + len - 1], c_hs[j][j + len - 1])) return 1;
	}
	return 0;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	cin >> n;
	cin >> s;
	vi cnt(30, 0);
	int f = 1;
	rep(i, n){
		if(cnt[s[i] - 'a']){
			f = 0;
			break;
		}
		cnt[s[i] - 'a']++;
	}
	if(f){
		cout << 0 << endl;
		return 0;
	}
	computeHashes();
	computeInvs();
	rep(i, n) repn(j, i, n) comp_hs(i, j);
	int l = 1, r = n / 2;
	while(l < r){
		int mid = (l + r + 1) / 2;
		if(check(mid)) l = mid;
		else r = mid - 1;
	}
	cout << l << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 391552
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
inline void print() { cout << endl; }
template <class Head, class... Tail> inline void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...);}
template <class T> inline void print(vector<T>& vec) { for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " "; } cout << endl;}
template <class T> inline void print(vector<vector<T>>& df) { for (auto& vec : df) { print(vec); }}
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;


int main() { 
    int N; cin >> N;
    vector<string> W;
    string s; cin >> s;
    W.push_back(s);
    REP(i, N-1) {
        string next_s; cin >> next_s;
        if(find(W.begin(), W.end(), next_s) != W.end()) {
            print("No");
            return 0;
        }
        if(next_s[0] != s[s.size()-1]) {
            print("No");
            return 0;
        }
        W.push_back(next_s);
        s = next_s;
    }
        
    print("Yes");
    
    return 0;
}

Measured memory_bytes: 256
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>


#define DEBUG if(false)

using namespace std;

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

  if(S.length() > K){
    for(int i = 0; i < K; i++){
      cout << S[i];
    }
    cout << "..." << endl;
  }else{
    cout << S << endl;
  }

  return 0;
}


Measured memory_bytes: 3632
#include<iostream>

using namespace std;

int main(){
  int h[201]={0},t[3]={0},ban,a,b;
  while(1){
    cin>>a;
    if(a==0)break;
    for(int i=0;i<202;i++)h[i]=0;
    h[a*2+1]=2;
    t[1]=a;
    t[0]=a;

    for(int i=0;i<a;i++){
      cin>>b;
      h[b]=1;
    }

    ban=1;
    while(1){
      for(int i=1;i<a*2+1;i++){
	if(ban==h[i]){
	  h[i]=-1;
	  if(t[ban]==1){
	    t[ban]--;
	    break;
	  }
	  t[ban]--;
	  if(ban==1)ban=0;
	  else if(ban==0)ban=1;
	}
      }
      if(t[1]==0||t[0]==0)break;
      else if(ban==1)ban=0;
      else if(ban==0)ban=1;
    }
    cout<<t[0]<<endl<<t[1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3044
from fractions import gcd
N = int(input())
a = list(map(int, input().split()))

def lcm(A):
  x = A[0]
  for i in range(1, len(a)):
    x = (x * A[i]) // gcd(x, A[i])
  return x
 
n = lcm(a) - 1
ans = 0
for v in a:
  ans += n % v
print(ans)

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

int main() {
  string s;
  cin >> s;
  int y = 700;
  if (s[0] == 'o') y += 100;
  if (s[1] == 'o') y += 100;
  if (s[2] == 'o') y += 100;
  cout << y;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    int num = 0;
    int max = num;
    for (int i = 0; i < N; i++) {
      if (S.charAt(i) == 'I') {
        num++;
      } else {
        num--;
      }
      if (max < num) {
        max = num;
      }
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 23124
#include <stdio.h>
int main(){
    int n,i,f[10000],now=2;
    bool flag;
    f[0]=2;
    f[1]=3;
    for(i=5;i<60000;i+=2){
        flag=true;
        for(int j=1;f[j]*f[j]<=i&&flag;j++){
            if(i%f[j]==0)flag=false;
        }
        if(flag){
            f[now]=i;
            now++;
        }
    }
    while(scanf("%d",&n)!=EOF){
        for(i=0;f[i]<n;i++);
        if(f[i]==n)printf("%d %d\n",f[i-1],f[i+1]);
        else printf("%d %d\n",f[i-1],f[i]);
    }
}

Measured memory_bytes: 2704
#include<bits/stdc++.h>
#define maxn 320
using namespace std;
typedef long double LD;
LD f[maxn][maxn][maxn];
int c[3];
int main(){
	int N;
	cin >> N;
	for(int i = 0; i < N; i += 1){
		int a;
		cin >> a;
		c[a - 1] += 1;
	}
	for(int k = 0; k <= N; k += 1)
		for(int j = 0; j + k <= N; j += 1)
			for(int i = 0; i + j + k <= N; i += 1) if(i + j + k){
				f[i][j][k] = 1;
				if(i) f[i][j][k] += f[i - 1][j][k] * i / N;
				if(j) f[i][j][k] += f[i + 1][j - 1][k] * j / N;
				if(k) f[i][j][k] += f[i][j + 1][k - 1] * k / N;
				f[i][j][k] = f[i][j][k] / (i + j + k) * N;
			}
	cout << setprecision(15) << f[c[0]][c[1]][c[2]];
} 

Measured memory_bytes: 481408
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
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; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll N, X; cin >> N >> X;
    vector<ll> x(N);
    REP(i, N) cin >> x[i];

    REP(i, N) {
        x[i] = abs(x[i] - X);
    }

    ll ans = x.front();
    REP(i, N) {
        ans = gcd(ans, x[i]);
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();
        int ans = 1;
        while(true) {
          int value = ans * ans;
          if (value > n) {
            ans--;
            break;
          }
          ans++;
        }
    
		// 出力
		System.out.println(ans * ans);
	}
}

Measured memory_bytes: 22740
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        int X = sc.nextInt();
 
        String s = Integer.toString(X);
 
        if (String.valueOf(s).contains("7")) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
 
 
 
 
 
    }
}

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

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

	int b[10000];

	for (int i = 0; i < n-1; ++i) cin >> b[i];

	
	int sum = 0;

	sum += b[0]; //#1
	sum += b[n-2]; //#n-1

	for (int i = 0; i < n-2; ++i) {
		sum += min(b[i], b[i + 1]);
	}
	cout << sum << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 100007
using namespace std;
int n,a[M];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	printf("%d\n",a[n/2+1]-a[n/2]);
	return 0;
}

Measured memory_bytes: 640