akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n,m;
    cin>>n;
    vector<string> s(n);
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    cin>>m;
    vector<string> t(m);
    for(int i=0;i<m;i++){
        cin>>t[i];
    }
    int max=0;
    for(int i=0;i<n;i++){
        int score=0;
        for(int j=0;j<n;j++){
            if(s[i]==s[j]){
                score++;
            }
        }
        
        for(int j=0;j<m;j++){
            if(s[i]==t[j]){
                score--;
            }
        }
        if(max<score){
            max=score;
        }
    }
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 998244353
#define pb push_back
#define ll long long int
#define con 1000000007
using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll i,j,m,n,k;
    ll t;
    cin>>n>>k;
    ll a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    ll sum=0;
    for(i=0;i<k;i++)
        sum+=a[i];
    cout<<sum;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
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;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int n;
    scanf("%d", &n);
    printf("%d\n", n*(n+1)/2);
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
typedef pair<double, int> P;
typedef pair<int, int> PI;
typedef pair<double, PI> S;

double calc(P p, P q){
  double x = p.first - q.first;
  double y = p.second - q.second;
  return sqrt(x * x + y * y);
}
int main(){
  int N;
  while(cin >> N && N){
    int x[100], y[100];
    REP(i, N) cin >> x[i] >> y[i];
    vector<int> hv;
    REP(i, N) hv.push_back(y[i]);
    sort(hv.begin(), hv.end());
    hv.erase(unique(hv.begin(), hv.end()), hv.end());
    vector<P> ps;
    REP(i, N) ps.push_back(P(x[i], y[i]));
    REP(i, N - 1){
      if(y[i] == y[i + 1]) continue;
      int l = min(y[i], y[i + 1]);
      int r = max(y[i], y[i + 1]);
      REP(j, hv.size()){
        int h = hv[j];
        if(l < h && h < r){
          double px = x[i] + double(h - y[i])/(y[i + 1] - y[i]) * (x[i + 1] - x[i]);
          ps.push_back(P(px, h));
        }
      }
    }
    sort(ps.begin(), ps.end());
    ///REP(i, ps.size()) printf("ps[%d] = (%f, %f)\n", i, (double)ps[i].first, (double)ps[i].second);
    priority_queue<S, vector<S>, greater<S> > que;
    map<PI, double> dist;
    dist[PI(0, ps.size() - 1)] = 0;
    que.push(S(0, PI(0, ps.size() - 1)));
    while(!que.empty()){
      S s = que.top(); que.pop();
      int a = s.second.first, b = s.second.second;
      double c = s.first;
      if(dist[PI(a, b)] < c) continue;
      if(a == b){
        printf("%.12f\n", c);
        break;
      }
      for(int da = -1; da <= 1; da++){
        for(int db = -1; db <= 1; db++){
          int na = a + da;
          int nb = b + db;
          if(!valid(na, nb, ps.size(), ps.size())) continue;
          if(ps[na].second != ps[nb].second) continue;
          double nc = c;
          nc += calc(ps[a], ps[na]);
          nc += calc(ps[b], ps[nb]);
          //printf("na = %d nb = %d nc = %f\n", na, nb, nc);
          if(!dist.count(PI(na, nb)) || dist[PI(na, nb)] > nc) {
            dist[PI(na, nb)] = nc;
            que.push(S(nc, PI(na, nb)));
          }
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3212
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
	static void Main()
	{
		try {
			new Program().Solve();
		} catch {
			Console.WriteLine("INF");
		}
	}

	void Solve()
	{
		var nm = ReadLongArray();
		var n = nm[0];
		var m = nm[1];

		var x = new List<long>();
		var y = new List<long>();

		var a = new long[n]; // x
		var b = new long[n]; // x
		var c = new long[n]; // y
		for (var k = 0; k < n; k++) {
			var abc = ReadLongArray();
			x.Add(a[k] = abc[0]);
			x.Add(b[k] = abc[1]);
			y.Add(c[k] = abc[2]);
		}
		var d = new long[m]; // x
		var e = new long[m]; // y
		var f = new long[m]; // y

		for (var k = 0; k < m; k++) {
			var def = ReadLongArray();
			x.Add(d[k] = def[0]);
			y.Add(e[k] = def[1]);
			y.Add(f[k] = def[2]);
		}

		x.Sort();
		x = x.Distinct().ToList();

		y.Sort();
		y = y.Distinct().ToList();

		var idxX = new Dictionary<long, long>();
		for (var i = 0; i < x.Count; i++) {
			idxX[x[i]] = i;
		}

		var idxY = new Dictionary<long, long>();
		for (var i = 0; i < y.Count; i++) {
			idxY[y[i]] = i;
		}

		var tate = new bool[x.Count - 1, y.Count];
		for (var k = 0; k < n; k++) {
			for (var ix = idxX[a[k]]; ix < idxX[b[k]]; ix++) {
				tate[ix, idxY[c[k]]] = true;
			}
		}

		var yoko = new bool[x.Count, y.Count - 1];
		for (var k = 0; k < m; k++) {
			for (var i = idxY[e[k]]; i < idxY[f[k]]; i++) {
				yoko[idxX[d[k]], i] = true;
			}
		}

		var st = new Point(0, 0);
		for (; x[st.X + 1] <= 0; st.X++) ;
		for (; y[st.Y + 1] <= 0; st.Y++) ;

		var que = new Queue<Point>();
		que.Enqueue(st);

		var gone = new bool[x.Count + 2, y.Count + 2];
		var size = 0L;

		while (que.Count != 0) {
			var p = que.Dequeue();
			if (gone[p.X, p.Y]) continue;
			gone[p.X, p.Y] = true;
			if (!yoko[p.X + 1, p.Y]) que.Enqueue(new Point(p.X + 1, p.Y));
			if (!yoko[p.X + 0, p.Y]) que.Enqueue(new Point(p.X - 1, p.Y));
			if (!tate[p.X, p.Y + 1]) que.Enqueue(new Point(p.X, p.Y + 1));
			if (!tate[p.X, p.Y + 0]) que.Enqueue(new Point(p.X, p.Y - 1));
			size += (x[p.X + 1] - x[p.X]) * (y[p.Y + 1] - y[p.Y]);
		}

		Console.WriteLine(size);
	}

	#region Console.Read 関係
	long[] ReadLongArray() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	long ReadLong() => long.Parse(Console.ReadLine());
	#endregion
}

class Point
{
	public int X;
	public int Y;
	public Point(int x, int y)
	{
		X = x; Y = y;
	}
}


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

int main()
{
    char s[15],t[15],u[15];
    int a,b;
    scanf("%s %s",s,t);
    scanf("%d %d",&a,&b);
    scanf("%s",u);
    if(strcmp(s,u)==0)
        a--;
    else b--;
    printf("%d %d\n",a,b);


    return 0;
}


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	string n,m;
	cin >> n;
	m=n;
	REV(n);
	if(n==m) cout << "Yes" << endl;
	else cout << "No" << endl;

	
//////////////////////////////////////////////
}


Measured memory_bytes: 256
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
typedef long long int ll;
using namespace std;
int main(){
	int x1,y1,x2,y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int a=y2-y1;
	int b=x2-x1;
	int x3,y3,x4,y4;
	if(a>=0 && b>=0){
		cout << x2-abs(a) <<" "<< y2+abs(b) << " "<< x1-abs(a) <<" "<< y1+abs(b)<< endl;
	}else if (a>=0 && b<0){
		cout << x2-abs(a) <<" "<<y2-abs(b) << " " << x1-abs(a) <<" " << y1-abs(b) << endl;
	}else if (a<0 && b<0){
		cout << x2+abs(a) << " " << y2-abs(b)<< " " << x1+abs(a) <<" " << y1-abs(b) << endl;
	}else{
		cout << x2+abs(a) <<" " << y2+abs(b) << " " << x1+abs(a) << " " << y1+abs(b) << endl;
	}
}

Measured memory_bytes: 256
a,b,c= input().split()
x,y,z=(int(a),int(b),int(c))
B_list  = input().split()
count = 0
for j in range(x):
    A_list = input().split()
    sum_ans = 0
    for i in range(y):
        
        sum_ans +=  int(A_list[i]) * int(B_list[i])
    if sum_ans > -1 * z:
        count += 1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const int N=2e5+5;
const int MOD=1e9+7;
double a[N];

int b[N];

char s[N];
char t[N];
ll f[N];
int used[15];


multiset<int> ss;
map<int,int>mp;
typedef pair<double,int> P;//first是值，second是index
struct cmp
{
    bool operator()(const P p1, const P p2)
    {
        if(p1.first < p2.first)
            return 1;
        if(p1.first==p2.first){
            return p1.second>p2.second;
        }
        return 0;
    }
};

int main()
{
    int n;
    cin>>n;
    int cur=0;
    int ans=-1;
    for(int i=1; ; i++){
        cur=(cur*10+7)%n;
        if(mp[cur]==1) break;
        mp [cur]=1;
        if (cur==0){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 50448
S = input()
T = input()

dcts = {}
dctt = {}
jdg = True

for i, s in enumerate(S):
    if s in dcts.keys():
        if dcts[s]!=T[i]:
            jdg = False
            break
    else: dcts[s] = T[i]
    if T[i] in dctt.keys():
        if dctt[T[i]]!=s:
            jdg = False
            break
    else: dctt[T[i]] = s
print('Yes' if jdg else 'No')

Measured memory_bytes: 3632
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        d: usize,
        x: [f32; n * d],
    }
    let mut count = 0;
    for i in 0..n {
        for j in 0..i {
            let mut s = 0.0;
            for k in 0..d {
                let dk = (x[d * i + k] - x[d * j + k]) as f32;
                s += dk * dk;
            }
            let s = s.sqrt();
            if s == s.floor() {
                count += 1;
            }
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a,b; 
    cin >> a >>b;
    if(a==1){
        if(b==1){ cout << "Draw" << endl;}
        else{ cout << "Alice" << endl; }
        return 0;
    }
    if(b==1){
        cout << "Bob" << endl; 
        return 0;
    }

    if(a>b){ cout << "Alice" << endl; }
    if(a<b) { cout << "Bob" << endl; }
    if(a==b) { cout << "Draw" << endl; }

    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll A,B,C;
ll i,j,ans;
int main(){
    scanf("%lld%lld%lld", &A, &B, &C);
    ans = B + C - A;
    printf("%lld", ans < 0 ? 0 : ans);
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

def main():
    N, X = list(map(int, input().split()))
    L = list(map(int, input().split()))

    d = 0
    for i in range(N):
        d += L[i]
        if d > X:
            return i+1
            break
    return i+2

if __name__ == '__main__':
    print(main())

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

const int MOD = 1000000007;
const int MAX =200000;

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++){
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import collections
sys.setrecursionlimit(10**6)

M = 10**6+5


def main(input, print):
    n = int(input())
    a = list(map(int, input().split()))
    cnt = [0] * M
    for i in range(n):
        if cnt[a[i]] != 0:
            cnt[a[i]] += 1
            continue

        for j in range(a[i], M, a[i]):
            cnt[j] += 1
    ans = 0
    for i in range(n):
        if cnt[a[i]] == 1:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Measured memory_bytes: 97672
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main(void)
{
   int n,ans=0,k,x;
      cin>>k;
      for(int i=1;i<=k;i++)
      {
         for(int j=1;j<=k;j++)
         {
            for(int p=1;p<=k;p++)
            {
               x=__gcd(i, j);
               x=__gcd(x, p);
               ans=ans+x;
            }
         }
      }
      cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 1000000000000000
#define MOD 1000000007

int main(){
  ll N,T;
  cin>>N>>T;
  vector<ll> A(N);
  for(ll i=0;i<N;i++){
    cin>>A.at(i);
  }

  pair<ll,ll> minimum=make_pair(A.at(0),1);
  pair<ll,ll> profit=make_pair(0,1);
  ll ans=1;
  for(ll i=1;i<N;i++){
    if(A.at(i)<minimum.first){
      minimum=make_pair(A.at(i),1);
    }else if(A.at(i)==minimum.first){
      minimum.second++;
    }else if(A.at(i)-minimum.first>profit.first){
      profit=make_pair(A.at(i)-minimum.first,1);
      ans=profit.second;
    }else if(A.at(i)-minimum.first==profit.first){
      ans+=profit.second;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    ll n; cin >> n;
    ll mn = 1e16;
    rep(i,5) {
        ll a; cin >> a;
        chmin(mn, a);
    }

    cout << (n+mn-1)/mn+4 << endl;
    return 0;
}

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

using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")

#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"

#define sz(a) ((int)(a).size())
#define all(v) (v).begin(), (v).end()
#define tr(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); it++)
#define pres(c, val) ((c).find(val) != (c).end())      //
#define cpres(c, val) (find(all(c), val) != (c).end()) //

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define forf(i, a, b) for (int i = (a); i < (b); i++)
#define forb(i, a, b) for (int i = (b); i >= (a); i--)
#define fo(i, n) forf(i, 0, n)
#define fob(i, n) forb(i, 0, n - 1)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;

const int INF = 9e18;
// const int N = 1e9 + 7;
const int N = 998244353;

const auto start_time = std::chrono::high_resolution_clock::now();

void zark() {
  #ifdef ZARK
  auto end_time = std::chrono::high_resolution_clock::now();
  std::chrono::duration<double> diff = end_time - start_time;
  cerr << "Time Taken : " << diff.count() << "s\n";
  #endif
}

#ifdef ZARK
#include "/home/aranjan/Desktop/CP/header.h"
#else
#define dbg(args...)
#endif

/* ------------------ Actual Coding Starts ------------------ */

void solve() {
  int n,k;
  cin >> n >> k;
  vector<vi> sn(n+1);
  fo(i, k) {
    int d;
    cin >> d;
    fo(j, d) {
      int x;
      cin >> x;
      sn[x].pb(i);
    }
  }
  int ans = 0;
  forf(i, 1, n+1) if(sn[i].empty()) ans++;
  cout << ans << endl;
}

int32_t main() {
  fastio;
  #ifdef ZARK
  freopen("input.in", "r", stdin);
  #endif

  // freopen("txt.in", "r", stdin);
  // freopen("txt.out", "w", stdout);
  // cout << fixed << setprecision(35);

  solve();
  zark();
  return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL =LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    string s;
    cin>>s;
    
    int y,m,d;
    y = (s[0]-'0')*1000 + (s[1]-'0')*100+(s[2]-'0')*10+s[3]-'0';
    m = (s[5]-'0')*10 + (s[6]-'0');
    d =(s[8]-'0')*10 + (s[9]-'0');
    
    if (y<2019) {cout<<"Heisei"<<endl;return 0;}
    if (y==2019 && m < 4){cout<<"Heisei"<<endl;return 0;}
    if (y==2019 && m == 4 && d<=30){cout<<"Heisei"<<endl;return 0;}
    cout<<"TBD"<<endl;
    
    
    
    return 0;
}








Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
typedef long long int ll;
using namespace std;

int n;
string s;

int main(){
  cin >> n;
  cin >> s;
  int ans = 1;
  for(int i=0;i+1<n;i++){
     if (s[i] != s[i+1]) ans++;
  }
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        String[] s = new String[n];
        for(int i = 0; i < n; i++){
            s[i] = scan.next();
        }
        Arrays.sort(s);
        int out = 1;
        for(int i = 0; i < n - 1; i++){
            if(!s[i].equals(s[i + 1])){
                out++;
            }
        }
        System.out.println(out);
    }
}

Measured memory_bytes: 62368
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;


int main(void) {
	int n,a,b,ans=0,res;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		int c = 0, t = i;
		for (int j = 0; j < 5; j++) {
			c += t % 10;
			t /= 10;
		}
		if (a <= c && c <= b) {
			ans += i;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	int n, l, i, w=0;
	char a[200001];
	gets(a);
	l = strlen(a);
	for(i=0; i<l; i++)
    {
        if(a[i]=='A')
        {
            n=i;
            break;
        }
    }
    for(i=l; i>n; i--)
    {
        if(a[i]=='Z')
        {
            w=i;
            break;
        }
    }

	printf("%d\n", (w-n+1));


	return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

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


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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }

    int ans = 0;
    rep(i, n){
        if(i == a[a[i]-1]-1){
            ans++;
        }
    }

    cout << ans / 2 << endl;

    return 0;
}

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

using namespace std;

int main(){
  
  string s1;
  cin>>s1;
  
  for(int i=0;i<s1.size();i++){
  	s1[i]='x';
  
  }
    
 cout<<s1;
  
  return 0;
  
  
  
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N;
  int H[100000];
  int max=1000000000;
  int flag = 0;
  
  scanf("%d",&N);

  for(int i=0;i<N;i++)
    scanf("%d", &H[i]);

  for(int i=N-1;i>=0;i--)
    if(max>=H[i])
      max = H[i];
    else if(max+1<H[i])
      flag ++;

  if(flag)
    printf("No\n");
  else
    printf("Yes\n");
  
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

#define ll long long
#define pii pair<int, int>

const int N = 2e5 + 5, bzmax = 20;

int n;
int X[N];
ll dep[N];
vector<pii> G[N];

boolean ban[N];
ll dis[bzmax][N];
int fG[N], sz[N], Gd[N];
priority_queue<ll, vector<ll>, greater<ll>> H[N];

int get_sz(int p, int fa) {
	sz[p] = 1;
	for (auto _ : G[p]) {
		int e = _.first;
		if (!ban[e] && (e ^ fa))
			sz[p] += get_sz(e, p);
	}
	return sz[p];
}
int get_grav(int p, int fa, int lim) {
	for (auto _ : G[p]) {
		int e = _.first;
		if (!ban[e] && (e ^ fa) && sz[e] > lim) {
			return get_grav(e, p, lim);
		}
	}
	return p;
}

void dfs(int p, int fa, int dep, ll dist) {
	dis[dep][p] = dist + X[p];
	for (auto _ : G[p]) {
		int e = _.first;
		int w = _.second;
		if ((e ^ fa) && !ban[e]) {
			dfs(e, p, dep, dist + w);
		}
	}
}

void dividing(int layer, int p, int fg) {
	get_sz(p, 0);
	int g = get_grav(p, 0, sz[p] >> 1);
	ban[g] = true;
	Gd[g] = layer, fG[g] = fg;
	dis[layer][g] = X[g];
	for (auto _ : G[g]) {
		int e = _.first;
		int w = _.second;
		if (!ban[e]) {
			dfs(e, g, layer, w);
		}
	}
	for (auto _ : G[g]) {
		int e = _.first;
		if (!ban[e]) {
			dividing(layer + 1, e, g);
		}
	}
}

void enable(int p) {
	for (int q = p; q; q = fG[q]) {
		H[q].push(dis[Gd[q]][p]);
	} 
}
ll query(int p) {
	ll ret = 1e18;
	for (int q = p; q; q = fG[q]) {
		if (!H[q].empty()) {
			ret = min(ret, H[q].top() + dis[Gd[q]][p]);
		}
	}
	return ret;
}

void dfs(int p, int fa) {
	for (auto _ : G[p]) {
		int e = _.first;
		int w = _.second;
		if (e ^ fa) {
			dep[e] = dep[p] + w;
			dfs(e, p);
		}
	}
	if (fa)
		dep[p] += X[p];
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", X + i);
	}
	for (int i = 1, u, v, w; i < n; i++) {
		scanf("%d%d%d", &u, &v, &w);
		G[u].emplace_back(v, w);
		G[v].emplace_back(u, w);
	}
	dfs(1, 0);
	vector<int> ord (n - 1);
	for (int i = 0; i < n - 1; i++)
		ord[i] = i + 2;
	sort(ord.begin(), ord.end(), [&] (int x, int y) {	return dep[x] < dep[y];	});
	dividing(0, 1, 0);
	enable(1);
	ll ans = 0;
	for (auto p : ord) {
		ans += query(p);
		enable(p);
	}
	printf("%lld\n", ans);
	return 0;
}


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

typedef long long ll;


void solve(std::string S, std::string T){
  ll rv = 0;
  for (size_t i = 0; i < min(S.size(), T.size()); ++i) {
    rv += (S[i] != T[i]);
  }
  cout << rv << endl;;
}

int main() {
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;
  solve(S, T);
  return 0;
}


Measured memory_bytes: 4096
#include<stdio.h>

int main (){
    int P,Q,R,AB,BC,CA;
    scanf("%d%d%d",&P,&Q,&R);
 
    AB=P+Q;
    BC=Q+R;
    CA=R+P;
 
    if (AB<=BC && AB<=CA){
        printf("%d",AB);
    }else if (BC<=AB && BC<= CA){
        printf("%d",BC);
    }else if (CA<=BC && CA<= AB){
        printf("%d",CA);
    }
}

Measured memory_bytes: 128
from collections import defaultdict
from math import factorial
import itertools



def main():
    num = int(input())
    data = defaultdict(int)
    for i in range(num):
        a = input()[0]
        if a in ['M', 'A', 'R', 'C', 'H']:
            data[a] += 1

    ans = 0
    if len(data) >= 3:
        for now_data in list(itertools.combinations(data.values(),3)):
            ans += now_data[0] * now_data[1] * now_data[2]
    print(ans)




if __name__ == '__main__':
    main()


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

int main() {
    int H,W;
    cin>>H>>W;
    string S;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>S;
            if(S=="snuke"){
                //cout<<i<<j<<endl;
                cout<<char(j+1+64)<<i+1<<endl;
            }
        }
    }
return 0;}
/*
g++ code.cpp
./a.out
*/

Measured memory_bytes: 256
/*  union_find_tree_rank.cpp
    素集合系を union-find tree で管理するライブラリ
    併合時の工夫：union by rank

    verified: AOJ DSL_1_A
        http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A
*/

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

/* UnionFind：素集合系管理の構造体(union by rank)
    isSame(x, y): x と y が同じ集合にいるか。 計算量はならし O(α(n))
    unite(x, y): x と y を同じ集合にする。計算量はならし O(α(n))
*/
struct UnionFind {  // The range of node number is from 0 to n-1
    //'rank[x]' is a rank of the union find tree the root of which is x.
    //'parents[x]' is the parent of x
    vector<int> rank, parents;
    // constructor
    UnionFind() {}
    UnionFind(int n) {  // make n trees.
        rank.resize(n, 0);
        parents.resize(n, 0);
        for (int i = 0; i < n; i++) {
            makeTree(i);
        }
    }
    // make a union find tree
    void makeTree(int x) {
        parents[x] = x;  // the parent of x is x
        rank[x] = 0;
    }

    // check whether the root of x is the same as that of y
    bool isSame(int x, int y) { return findRoot(x) == findRoot(y); }

    // unite two tree
    void unite(int x, int y) {
        x = findRoot(x);
        y = findRoot(y);
        if (rank[x] > rank[y]) {
            parents[y] = x;
        } else {
            parents[x] = y;
            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
    }

    // travel the parents of tree recursivily to find root
    int findRoot(int x) {
        if (x != parents[x]) {
            parents[x] = findRoot(parents[x]);  // change the x's parent to the root of tree.
        }
        return parents[x];
    }
};

using P = pair<int, int>;

int main() {
    int N, M;
    cin >> N >> M;
    vector<P> edges(M);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edges[i] = make_pair(a, b);
    }

    int ans = 0;
    for (int i = 0; i < M; i++) {
        UnionFind uft(N);  // make trees
        for (int j = 0; j < M; j++) {
            if (i != j) {
                uft.unite(edges[j].first, edges[j].second);
            }
        }
        if (!uft.isSame(edges[i].first, edges[i].second)) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# atcoder 
# Türkçe konuşyorum
# Türkler var mı?

s = input()
t = input()
tlen = len(t)
slen = len(s)

if slen > 10 or tlen != slen + 1 or slen < 1:
    print("No")
elif t[:-1] != s:
    print("No")
elif False ==  t.isalpha() or False == s.isalpha():
    print("No")
else: 
    print("Yes")



Measured memory_bytes: 9112
/*

    author : s@if

*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			1e9
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> new_data_set;

//*find_by_order(k)  gives the kth element;
//order_of_key(item)   gives the index(number of element strictly less than item) of item;


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)2e5+9;


int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    ll i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>n; if(n==1) cout<<1<<endl;
    else
    {
        p = 1; v = 0;

        while(p*2<=n)
        {
            p*=2; v++;
        }

       // cout<<p<<" "<<v<<endl;

        cout<<(1LL<<(v+1))-1<<endl;
    }

   // main();

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


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

int main() {
    int w, h ,n;
    cin >> w >> h >> n;
    int xl,xr,yl,yr;
    double dx, dy;
    xl = 0;
    xr = w;
    yl = 0;
    yr = h;
    for (int i = 0; i < n; i++) {
        int x,y,a;
        cin >> x >> y >> a;

        switch (a) {
            case 1 : xl = max(xl,x);break;
            case 2 : xr = min(xr,x);break;
            case 3 : yl = max(yl,y);break;
            case 4 : yr = min(yr,y);break;
        }
    }

    dx = xr - xl;
    dy = yr - yl;
    if (dx > 0 && dy > 0) {
        cout << dx*dy << endl;
    } else {
        cout << 0 << endl;
    }

}


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

int main ()
{
    int n,m;
    cin>>n;
    vector<string> blue(n);
    for(int i=0;i<n;i++)
    {
        cin>>blue.at(i);
    }

    cin>>m;
    vector<string> red(m);
    for (int i=0;i<m;i++)
    {
        cin>>red.at(i);
    }

    int ans=0,count=0;
    vector<string> checked(1," ");
    for(int i=0;i<n;i++)
    {
        for(int k=0; k<checked.size();k++)
        {
            if(blue.at(i)==checked.at(k))
            continue;
        }
        for(int k=0;k<n;k++)
        {
            if(blue.at(i)==blue.at(k))
            count+=1;
        }
        for(int k=0;k<m;k++)
        {
            if(blue.at(i)==red.at(k))
            count-=1;
        }
        ans = max(ans,count);
        count =0;
        checked.push_back(blue.at(i));
    }

    cout<<ans<<endl;
}

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

int main(void) {
  int a, b;
  cin >> a >> b;
  if (a%2 == 1 and b%2 == 1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
} 

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class ICoins {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        vector<double> p(n);
        rep(i,n){
            in >> p[i];
        }
        out << setprecision(12);
        vector<vector<double>> dp(n+1,vector<double>(n+1,0));
        dp[0][0]=1;
        for(int i=1;i<=n;i++){
            dp[i][0]=dp[i-1][0]*(1-p[i-1]);
        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<=i;j++){
                dp[i][j]=dp[i-1][j-1]*p[i-1]+dp[i-1][j]*(1-p[i-1]);
            }
        }
        double ans=0.;
        for(int i=n/2+1;i<=n;i++){
            ans+=dp[n][i];
        }
        out << ans << endl;
	}
};


int main() {
	ICoins solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }



signed main(){

    int N; cin >> N;
    vec A(N), B(N);
    REP(i, N) cin >> A[i] >> B[i];

    int a = -1, b = -1;
    REP(i, N) if(A[i] > a){
        a = A[i];
        b = B[i];
    }
    cout << a + b;
    
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int euclidean(int,int);

int main(){
	int n,m,div,mul;
	while(scanf("%d %d",&n,&m)!=-1){
		if(m>n)div=euclidean(m,n);
		else div=euclidean(n,m);
		n/=div;
		m/=div;
		mul=div*n*m;
		printf("%d %d\n",div,mul);
	}
	return 0;
}

int euclidean(int n,int m){
	int a;
	while(m%n!=0){
	a=m%n;
	m=n;
	n=a;
	}
	return n;
}

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

using namespace std;

const int N = 200005, L = 60;

int n;
int dp[N][L];
int a[N];

int main() {
	long long k;
	scanf("%d %lld", &n, &k);

	for(int i = 1; i <= n; i++) scanf("%d", a + i);

	for(int i = 1; i <= n; i++) dp[i][0] = a[i];

	for(int lvl = 0; lvl + 1 < L; lvl++) {
		for(int i = 1; i <= n; i++) {
			dp[i][lvl + 1] = dp[ dp[i][lvl] ][lvl];
		}
	}

	int u = 1;

	for(int i = L - 1; i >= 0; i--) if(k >> i & 1) {
		u = dp[u][i];
	}

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

}


Measured memory_bytes: 51452
#include <iostream>
int main(){
    int n,m;
    for (int i = 0;; i++){
        std::cin>>n>>m;
        if(n+m==0){
            return 0;
        }
        std::cout<<std::min(n,m)<<" "<<std::max(n,m)<<std::endl;
    }
        return 0;
}



Measured memory_bytes: 3108
import java.util.*;
public class Main{
  public static void main(String args[])
  {
    Scanner in = new Scanner(System.in); 
    int n = Integer.parseInt(in.nextLine());
    String s = in.nextLine();
    if(s.length() <= n)
    {
      System.out.println(s);
    }
    else
    {
      System.out.println(s.substring(0, n) + "...");
    }
  }
}

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

long long mod = 1e9 + 7;

int main()
{
	int H, W;
	cin >> H >> W;
	vector<vector<bool>> empty(H, vector<bool>(W));
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			char a;
			cin >> a;
			empty[i][j] = (a == '.');
		}
	}


	vector<vector<long long>> paths(H, vector<long long>(W, 0));
	paths[0][0] = 1;
	
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			if (!empty[i][j])
				continue;
			
			if (i > 0)
				paths[i][j] = (paths[i][j] + paths[i-1][j]) % mod;
			
			if (j > 0)
				paths[i][j] = (paths[i][j] + paths[i][j-1]) % mod;
		}
	}
	
	cout << paths[H-1][W-1] << '\n';
}


Measured memory_bytes: 8320
#include <stdio.h>
#include <math.h>

int main(){
	int sum, a, b, d;

	while( scanf("%d %d", &a, &b) != EOF ){
		sum = a + b;
		for( d=1; ; d++ ){
			if( sum < pow(10,d) )
				break;
		}
		printf("%d\n", d);
	}

	return 0;
}

Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
#define maxn 200020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 1e18
typedef long long ll;
typedef pair<int,int> pr;

int a[maxn],n;
ll sum[maxn],ans;

inline ll cal(ll a,ll b,ll c,ll d){
	return max(max(a,b),max(c,d)) - min(min(a,b),min(c,d));
}
int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i]), sum[i] = sum[i - 1] + a[i];
	int l = 1 , r = 2;
	ans = inf;
	rep(i,2,n - 1){
		while ( l < i && sum[l] < sum[i] - sum[l] ) l++;
		while ( r < n && sum[r] - sum[i] < sum[n] - sum[r] ) r++;
		ans = min(ans,cal(sum[l],sum[i] - sum[l],sum[r] - sum[i],sum[n] - sum[r]));
		if ( l > 1 ) ans = min(ans,cal(sum[l - 1],sum[i] - sum[l - 1],sum[r] - sum[i],sum[n] - sum[r]));
		if ( r > i + 1 ) ans = min(ans,cal(sum[l],sum[i] - sum[l],sum[r - 1] - sum[i],sum[n] - sum[r - 1]));
		if ( l > 1 && r > i + 1 ) ans =  min(ans,cal(sum[l - 1],sum[i] - sum[l - 1],sum[r - 1] - sum[i],sum[n] - sum[r - 1]));
	}
	cout<<ans<<endl;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


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

    int n = s.size();
    if(s[0] == s[n-1]){
        if(n%2 == 0) cout << "First" << endl;
        else cout << "Second" << endl;
    }else{
        if(n%2 == 1) cout << "First" << endl;
        else cout << "Second" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum,ans, dp[10000][2], a[110000],b[110000];
string str, ss,dd;
bool f,ff;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<Edge>vec[10000];
vector<string>v;
map<string, LL>ma;
set<string>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> str;
	cin >> n;
	rep(i, str.size()) {
		string sn;
		for (int j = i; j < str.size(); j++) {
			if (i + n + 1 == j)break;
			sn.push_back(str[j]);
			v.push_back(sn);
		}
	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	cout <<v[n-1]<< endl;
	return 0;
}


Measured memory_bytes: 2172
#include <bits/stdc++.h>
 
using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;
 
#define int ll
#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;
 
template<typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48; 
    return x *= f;
}

const int N = 100000;

int getlen(int a, int b) {
    int t;
    if(a >= b) {
        t = (a + b) / (b + 1);
    } else {
        t = (a + b) / (a + 1);
    }
    return t;
}

int T;
int a, b, c, d, t;

bool chk(int x, int y) {
    if(x < 0 || y < 0) return false;
    if(x == 0) return y + 1 <= t;
    return x <= t && y <= t;
}

signed main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("D.out", "w", stdout);
#endif 
    
    read(T);
    while(T--) {
        static int ta, tb, lb, la;
        read(a), read(b), read(c), read(d);
        t = getlen(a, b);

        int l = 0, r = a;
        while(l < r) {
            int mid = (l + r + 1) >> 1;

            ta = a - mid*t;

            if(ta >= 0) 
                tb = (b - mid + 1 + ta) / (ta + 1);
            else 
                tb = oo;

            if(tb <= t) {
                l = mid;
            } else {
                r = mid - 1;
            }
        }

        ta = l;
        tb = (b - l) / t;
        lb = (b - l - t*tb);
        if(!lb && tb) { -- tb; lb = t; }

        la = (a - t*l - tb);
        //debug("%d %d %d %d %d\n", t, ta, tb, la, lb);

        for(int i = c; i <= d; ++i) {
            if(i <= ta * (t + 1)) {
                putchar(i % (t + 1) == 0 ? 'B' : 'A');
            } else if(i <= ta * (t + 1) + la + lb) {
                putchar(i - ta * (t + 1) <= la ? 'A' : 'B');
            } else {
                putchar((i - ta * (t + 1) - la - lb) % (t + 1) == 1 ? 'A' : 'B');
            }
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
const int MAXN=1e6+5;
int cnt,n;
int G[100];
int A[MAXN];
int num;
void insertionSort(int*A,int n,int g){
	for(int i=g;i<n;i++){
		int key=A[i];
		int j=i-g;
		while(j>=0&&A[j]>key){
			A[j+g]=A[j];
			j-=g;
			cnt++;
		}
		A[j+g]=key;
	}
}

int Generate(){
	num=0;
	G[num]=1;
	num++;
	while(3*G[num-1]+1<=n){
		G[num]=3*G[num-1]+1;
		num++;
	}
}

void sellSort(int* A,int n){
	for(int i=num-1;i>=0;i--){
		insertionSort(A,n,G[i]);
	}
}

int main(){
	cin>>n;
	cnt=0;
	Generate();
	for(int i=0;i<n;i++)cin>>A[i];
	sellSort(A,n);
	cout<<num<<endl;
	for(int i=num-1;i>=0;i--){
		cout<<G[i];
		if(i!=0)cout<<" ";
	}
	cout<<endl<<cnt<<endl;
	for(int i=0;i<n;i++)cout<<A[i]<<endl;
	return 0;
	
}


Measured memory_bytes: 6908
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[][] k = new int[n][3];
		int[] point = new int[n];
		for(int i = 0; i < n; i++) {
			k[i][0] = stdIn.nextInt();
			k[i][1] = stdIn.nextInt();
			k[i][2] = stdIn.nextInt();
		}
		for(int i = 0; i < 3; i++) {
			int[] cc = new int[101];
			for(int j = 0; j < n; j++) {
				cc[k[j][i]]++;
			}
			for(int j = 0; j < n; j++) {
				if(cc[k[j][i]] == 1) {
					point[j] += k[j][i];
				}
			}
		}
		
		for(int i = 0; i < n; i++) {
			System.out.println(point[i]);
		}
		
		
	}

}

Measured memory_bytes: 20776
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char> >s(h+2,vector<char>(w+2,'#'));
  int i,j;
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      cin >> s[i][j];
    }
  }
  int maxDistance = 0;
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      if(s[i][j]=='#')continue;
      vector<vector<int> >dist(h+2,vector<int>(w+2,-1));
      queue<pair<int,int> >que;
      que.push(make_pair(i,j));
      dist[i][j] = 0;
      int tmp = 0;
      while(!que.empty()){
        int x = que.front().first,y = que.front().second;
        tmp = max(tmp,dist[x][y]);
        que.pop();
        int xx = x+1;
        int yy = y;
        if(s[xx][yy]=='.'&&dist[xx][yy]==-1){
          dist[xx][yy] = dist[x][y]+1;
          que.push(make_pair(xx,yy));
        }
        xx = x-1;
        if(s[xx][yy]=='.'&&dist[xx][yy]==-1){
          dist[xx][yy] = dist[x][y]+1;
          que.push(make_pair(xx,yy));
        }
        xx = x;
        yy = y+1;
        if(s[xx][yy]=='.'&&dist[xx][yy]==-1){
          dist[xx][yy] = dist[x][y]+1;
          que.push(make_pair(xx,yy));
        }
        yy = y-1;
        if(s[xx][yy]=='.'&&dist[xx][yy]==-1){
          dist[xx][yy] = dist[x][y]+1;
          que.push(make_pair(xx,yy));
        }

      }
      if(tmp > maxDistance)maxDistance = tmp;

    }
  }
  cout << maxDistance << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,p1;
deque<int> dq;
int main() {
    cin>>n;
    for (int i=0; i<n; i++) {
        cin>>p1;
        if ((i%2)==0) dq.push_back(p1);
        else dq.push_front(p1);
    }
    vector<int> v;
    while (!dq.empty()) {
        v.push_back(dq.front());
        dq.pop_front();
    }
    if (n%2==1) reverse(v.begin(),v.end());
    for (int i=0; i<v.size(); i++) cout<<v[i]<<' ';
    cout<<'\n';
}

Measured memory_bytes: 5144
let N=Int(readLine()!)!
var C=[Int](),S=[Int](),F=[Int]()
for i in 1..<N{let i=readLine()!.characters.split(" ").map{Int(String($0))!};C+=[i[0]];S+=[i[1]];F+=[i[2]]}
for i in 0..<N{print((i..<N-1).reduce(0){max(S[$1],$0+(F[$1]-$0%F[$1])%F[$1])+C[$1]})}

Measured memory_bytes: 4208