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

//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define dbg(x) cerr<<#x<<" : "<<x<<endl

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;
clock_t time_p=clock();
void timer(){time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}

template <typename Arg1> ostream& operator << (ostream& out, const vector<Arg1> &a) {out<<"[ ";for(const auto &x:a)out<<x<<" ";return out<<"]";}

vector<vi> adj;

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

    ll n,m;
    cin>>n>>m;
    adj.assign(n,{});
    rep(i,m){
        ll u,v;
        cin>>u>>v;
        u--;v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    ll ans = 0;
    vi c; //connected components;
    vi color(n,-1);
    ll p=0,r=0,j=0;
    rep(i,n){
        if(color[i] == -1){
            ll sz = 0;
            bool bpt = true;
            queue<int>q;
            q.push(i);
            color[i] = 0;
            while(!q.empty()){
                sz++;
                ll top = q.front();
                q.pop();
                for(auto x: adj[top]){
                    if(color[x] == -1){
                        color[x] = color[top]^1;
                        q.push(x);
                    } else {
                        if(color[x] == color[top]){
                            bpt=false;
                        }
                    }
                }
            }
            if(bpt&&sz>1) r++;
            if(!bpt&&sz>1) p++;
            if(sz==1)j++;
            assert(sz>=1);
        }
    }
    ans = 2*n*j-j*j+(p+r)*(p+r) + r*r;

    cout<<ans<<endl;



    timer();
    return 0;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int>L(M);
  vector<int>R(M);
  int ans=0;
  int count=0;
  for(int i=0;i<M;i++){
    cin >> L[i] >> R[i];
    if(i==0){
      ans=L[0];
      count=R[0];
    }
    else{
      ans=max(ans,L[i]);
      count=min(count,R[i]);
    }
  }
  if(ans>count){
    cout << 0 << endl;
  }
  else{
    cout << count-ans+1 << endl;
  }
}

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

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, cnt = 0, cntA = 0, cntB = 0, cntAB = 0;
    cin >> n;
    REP(i, n) {
        string s;
        cin >> s;
        if (s.front() == 'B') {
            cntB++;
        }
        if (s.back() == 'A') {
            cntA++;
            if (s.front() == 'B') {
                cntAB++;
            }
        }
        size_t t = 0;
        while (true) {
            t = s.find("AB", t);
            if (t == string::npos) {
                break;
            } else {
                cnt++;
            }
            t += 2;
        }
    }
    int ans = cnt + min(cntA, cntB);
    if (cntA > 0 && cntA == cntB && cntA == cntAB) {
        ans--;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int x, y;
    cin >> x >> y;
    int v, u, r;
    v = max(x, y);
    u = min(x, y);
    r = v % u;
    while (r != 0){
        v = u;
        u = r;
        r = v%u;
    }
    cout << u << endl;
    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a,b;
	cin>>a>>b;
	if(a=='H' || a=='D')
	{
		if(b=='H' || b=='D')
		{
			
			if(a==b)
			{
				cout<<"H";
			}
			else 
			{
				cout<<"D";
		
			}
		}
	}
	else
	{
		cout<<"Error";
	}
}

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

using ll = long long int;
using vi = vector<int>;
using vll = vector<long long int>;
using vii = vector<vi>;
using pii = pair<int, int>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  int n, m;
  queue<int> que;
  scanf("%d%d", &n, &m);
  vii data(n);
  REP(i , n){
    data[i].resize(n, 100000001);
    data[i][i] = 0;
  }
  int tmp1, tmp2, tmp3;
  REP(i, m){
    cin >> tmp1 >> tmp2 >> tmp3;
    tmp1--;
    tmp2--;

    data[tmp1][tmp2] = tmp3;

    data[tmp2][tmp1] = tmp3;

    if(tmp1 > tmp2){
      que.push(tmp2);
      que.push(tmp1);
    }
    else{
      que.push(tmp1);
      que.push(tmp2);
    }
    que.push(tmp3);
  }

  REP(i, n){
    REP(j, n){
      REP(k, n){
        data[j][k] = MIN(data[j][k], data[j][i] + data[i][k]);
      }
    }
  }
  int a, b, c, ans = 0;
  bool flag;
  while(!que.empty()){
    a = que.front();que.pop();
    b = que.front();que.pop();
    c = que.front();que.pop();
    flag = true;
    REP(i, n){
      if(data[i][a] + c == data[i][b]){
        flag = false;
        break;
      }
    }
    if(flag){
      ans++;
    }
  }

  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long n,a,b,ac,bc;
  scanf("%lld%lld%lld",&n,&a,&b);
  if((b-a)%2==0)
  {
    printf("%lld\n",(b-a)/2);
  }
  else
  {
    bc = b-a;
    bc = a  + (bc-1)/2;
    ac = a + n-b+1;
    ac = n-b+1 + (n-ac)/2;
    printf("%lld\n",min(ac,bc));
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int64_t INF=1e18+1;
const int mod = 1000000007;

int main(){
  int K;
  cin>>K;
  for(int i=0;i<K;i++){
    cout<<"ACL";
  }cout<<endl;
  return 0;                       
}

Measured memory_bytes: 3640
#include <stdio.h>

long wari(long a,long b){
    if(a % 2==0){
        b++;
        return wari(a/2,b);
    }else{
        return b;
    }
}

int main (void){
    int i;
    long s[250] = {0};
    int n;
    long ans=0;
    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%ld",&s[i]);
    }
    for(i=0;i<n;i++){
        if(i==0){
            ans = wari(s[i],0);
        }else{
            if(wari(s[i],0) < ans){
                ans = wari(s[i],0);
            }
        }
    }
    printf("%ld\n",ans);
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

template<typename T> bool is_prime(T n)
{
	if (n == 2)
	{
		return true;
	}
	else if ((n == 1) || (n % 2 == 0))
	{
		return false;
	}

	T p = (T)sqrt(n);
	for (T i = 3; i <= p; i += 2)
	{
		if (n % i == 0)
		{
			return false;
		}
	}

	return true;
}

int main()
{
	vector<int> p(100010);
	int c = 0;
	for (int i = 1; i <= 100000; i++)
	{
		int x = (i + 1) / 2;
		if (is_prime(i) && is_prime(x))
		{
			c++;
		}
		p.at(i + 1) = c;
	}

	int n;
	for (cin >> n; n--; )
	{
		int l, r;
		cin >> l >> r;

		cout << p.at(r + 1) - p.at(l) << endl;
	}
}


Measured memory_bytes: 1024
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	m1, d1 = readline() |> split |> parseMap
	m2, d2 = readline() |> split |> parseMap
	println(m1!=m2?1:0)
end

main()

Measured memory_bytes: 112400
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;
int main(void) {
	int b[30];
	int x,y, ans, n, m, k;
	ans = 0;
	scanf("%d %d %d", &n, &m,&k);
	for (int i = 0; i < m; i++) {
		scanf("%d", &b[i]);
	}
	for (int i = 0; i < n; i++) {
		x = k;
		for (int j = 0; j < m; j++) {
			scanf("%d", &y);
			x += (b[j] * y);
		}
		if (x > 0)ans++;
	}
	printf("%d\n", ans);


	return 0;
}

Measured memory_bytes: 128
# from fractions import gcd
# mod = 10 ** 9 + 7
# N = int(input())
# a = list(map(int,input().split()))
# a,b,c = map(int,input().split())
# ans = [0] * N
# math.ceilで切り上げ
# dp = [[0] * 4 for i in range(3)] #2次元配列初期化
# dp = [[[0] * 2 for i in range(3)] for j in range(5)]
# (ord('A'))でASCII出力 Aは65
import math
import numpy as np
import statistics
import string
import sys
from array import array
from collections import deque

def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):#最大公約数 math.gcdが使えない時の手段として入れとく。pythonが更新されたらいらなくなるはず
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

N = intinput()
ans = 0
tmp = []
sum = 0
for i in range(N):
    a = np.array(listintinput())
    for j in tmp:
       sum += np.linalg.norm(a-j)
    tmp.append(a)

print(sum*(N-1)/(N*(N-1)/2))

Measured memory_bytes: 13544
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
string s;
int d = 0;
int i;
cin >> s;
for(int i= 0;i<3;i++){
if(s[i]=='o'){
   d+=100;
}
}
cout << d+700 << endl;
 return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    N,M=list(map(int,sys.stdin.readline().split()))
    H=list(map(int,sys.stdin.readline().split()))
    lsts=[[] for _ in range(N)]
    st=set()
    for i in range(M):
        A,B=list(map(int,sys.stdin.readline().split()))
        if (A,B) not in st:
            lsts[A-1].append(H[B-1])
            lsts[B-1].append(H[A-1])
            st.add((A,B))
            
    output=0
    for i,lst in enumerate(lsts):
        if len(lst)==0:
            output+=1
        elif max(lst)<H[i]:
            output+=1
    print(output)


    

main()

Measured memory_bytes: 40436
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
struct Card {
	int R, C, A;
	bool operator<(const Card &right) const {
		return A < right.A;
	}
};
struct UnionFind {
	vector<int> data;
	vector<int> es;
	UnionFind(int size) : data(size, -1), es(size, 0) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
			es[x] += es[y];
		}
		es[x]++;
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
	bool full(int x) {
		int r = root(x);
		return (-data[r] == es[r]);
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, H, W;
	cin >> N >> H >> W;
	vector<Card> c(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> c[i].R >> c[i].C >> c[i].A;
		c[i].R--;
		c[i].C--;
	}
	sort(c.rbegin(), c.rend());
	UnionFind uf(H + W);
	for (int i = 0; i < N; i++) {
		int a = c[i].R;
		int b = H + c[i].C;

		if (uf.full(a) && uf.full(b)) {
			
		}
		else {
			uf.unionSet(a, b);
			res += c[i].A;
		}

		//res = max(res, cur + sum[min(rem, (int)sum.size() - 1)] );
	}

	cout << res << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector<double> p(n);

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

    vector<vector<double>> dp(n + 1, vector<double>(n + 1));

    dp[0][0] = 1.0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            dp[i + 1][j + 1] += dp[i][j] * p[i];
            dp[i + 1][j] += dp[i][j] * (1 - p[i]);
        }
    }

    double ans = 0;

    for (int i = (n + 1) / 2; i <= n; i++) {
        ans += dp[n][i];
    }

    cout << fixed << setprecision(12) << ans << endl;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define mp make_pair
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;
const int N=1e5+5;
bool dp[N];
int a[105];
bool vis[N];

bool find(int k,int n){
    if(k<0) return(1);
    if(vis[k]==1) return(dp[k]);
    bool ans=0;
    for(int i=0;i<n;i++){
        ans=((!find(k-a[i],n))||ans);
    }
    vis[k]=true;
    return(dp[k]=ans);
}

int32_t main(){
    IOS;
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>a[i];
    memset(vis,false,sizeof(vis));
    if(find(k,n)){
        cout<<"First"<<endl;
    }
    else{
        cout<<"Second"<<endl;
    }
}

Measured memory_bytes: 5120
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {

  int N;
  cin >> N;
  vector<ll> A(N);
  ll count = 0;
  for(int i = 0; i < N; i++) cin >> A[i];

  int tmp = 0;
  ll lltmp, lltmp1;
  lltmp = 0;
  for(int i = 0; i < N; i++){
    // tmp = i;
    // lltmp = A[i];
    while(true){
      // tmp++;
      if (tmp == N) {
        // if (tmp - i > 1) {
        //   count += (tmp - i) * (tmp - i - 1) / 2;
        //   i = tmp;
        // }else{
        //   i = tmp;
        // }
        // break;
        count += tmp - i;
        lltmp -= A[i];
        break;
      }
      lltmp1 = lltmp ^ A[tmp];
      if (lltmp1 == lltmp + A[tmp]){
        lltmp = lltmp1;
        tmp++;
      }else{
        count += tmp - i;
        if (i == tmp) {
          tmp++;
        }else{
          lltmp -= A[i];
        }
        break;
      }
    }
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

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

  int ans = 0;
  for(int i = n-1; i >= 0; i--){
    int res = min(b[i],a[i+1]);
    b[i] -= res;
    ans += res;

    res = min(a[i],b[i]);
    a[i] -= res;
    ans += res;
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
	int n, sum = 0; cin >> n;
	vector<int>a(n); 
	for (auto&& x : a) {
		cin >> x;
		sum += x;
	}
	cout << (sum % 2 == 0 ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
#define LL long long
using namespace std;

const int maxn = 200;
int n;
bool vis[maxn];

pair<int, int> r[maxn], b[maxn];

int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; i ++)
        scanf("%d%d", &r[i].first, &r[i].second);
    for(int i = 0; i < n; i ++)
        scanf("%d%d", &b[i].first, &b[i].second);
    int ans = 0 ;
    sort(b, b + n);
    for(int i = 0; i < n; i ++) {
        int now = -1;
        for(int j = 0; j < n; j ++) {
            if(vis[j])
                continue;
            if(r[j].first < b[i].first && r[j].second < b[i].second && (now == -1 || r[j].second > r[now].second)) {
                now = j;
            }
        }
        if(now != -1) {
            vis[now] = true;
            ans ++;
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	sort(a.begin(), a.end());
	const int minval = a.front(), maxval = a.back();
	if(minval == maxval){
		cout << ((minval <= n / 2 || minval == n - 1) ? "Yes" : "No") << endl;
	}else if(minval + 1 == maxval){
		const int max_count = count(a.begin(), a.end(), maxval);
		const int min_count = n - max_count;
		const int c = minval - min_count + 1;
		cout << ((c >= 1 && c <= max_count / 2) ? "Yes" : "No") << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            HashSet<long> mochi = new HashSet<long>();
            for(int i = 0; i < N; i++)
            {
                mochi.Add(long.Parse(Console.ReadLine()));
            }
            Console.WriteLine(mochi.Count());
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


//Console.WriteLine(ans);


Measured memory_bytes: 28176
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <iostream>

/*int main(){
//	int n=100000;
	char s[200000];
	for(int i=0;i<200000;i++){
		s[i]='2';
	}
	scanf("%s", s);
	int size=-1;
	for(int i=0;i<100000;i++){
		if(s[i]!='2'){
//					printf("%d %c\n",i,s[i]);

			size++;
		}

	}



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


*/


int main(){
//	int n=100000;
	char s[100010];
	for(int i=0;i<100010;i++){
		s[i]='2';
	}
	scanf("%s", s);
	int size=0;
	for(int i=0;i<100010;i++){
		if(s[i]!='2'){
//					printf("%d %c\n",i,s[i]);

			size++;
		}
	}
	size--;
	//				printf("%d\n",size);

	int half=size/2;
	int ans=half;
	//					printf("%d\n",half);

	if(size%2){
		for(int i=0;i<=half;i++){
			if(s[half-i]==s[half+i]&&s[half+i]==s[half]){
				ans++;
	//				printf("%d\n",ans);

			}else{
				break;
			}
		}
	}else{
		for(int i=0;i<half;i++){
			if(s[half-1-i]==s[half+i]&&s[half+i]==s[half]){
				ans++;
			}else{
				break;
			}
		}
	}
	printf("%d\n",ans);
}

















/*int main(){
	long long x=0;
	long long y=0;
	scanf("%lld %lld", &x, &y);
	int ans=1;
	while(2*x<=y){
		ans++;
		x=x*2; 
	}
	printf("%d\n", ans);
}*/

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

LL n, m, l, q, d[300][300], INF = 1e12;

int main() {
	cin >> n >> m >> l;
	inc(i, n) {
	inc(j, n) {
		d[i][j] = INF;
	}
	}
	inc(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		d[a][b] = d[b][a] = c;
	}
	
	auto WF = [&]() {
		inc(k, n) {
		inc(i, n) {
		inc(j, n) {
			setmin(d[i][j], d[i][k] + d[k][j]);
		}
		}
		}
	};
	
	WF();
	
	inc(i, n) {
	inc(j, n) {
		d[i][j] = (d[i][j] <= l ? 1 : INF);
	}
	}
	
	WF();
	
	inc(i, n) {
	inc(j, n) {
		if(d[i][j] >= INF) { d[i][j] = -1; } else { d[i][j]--; }
	}
	}
	
	cin >> q;
	inc(i, q) {
		int s, t;
		cin >> s >> t;
		s--; t--;
		cout << d[s][t] << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

const int Dist(const vector<int> &values, const int num)
{
    if (values.empty() || num == 0)
    {
        return 0;
    }
    else
    {
        return values[num - 1];
    }
}

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> lefts, rights;
    for (int i = 0; i < N; ++i)
    {
        int candle;
        cin >> candle;
        if (candle == 0)
        {
            --K;
        }
        else if (candle < 0)
        {
            lefts.push_back(-candle);
        }
        else
        {
            rights.push_back(candle);
        }
    }
    sort(lefts.begin(), lefts.end());
    int minSum = MOD;
    for (int leftNum = 0; leftNum <= static_cast<int>(lefts.size()); ++leftNum)
    {
        int rightNum = K - leftNum;
        if (rightNum < 0 || static_cast<int>(rights.size()) < rightNum)
        {
            continue;
        }
        int sum = Dist(lefts, leftNum) + Dist(rights, rightNum);
        if (leftNum != 0 && rightNum != 0)
        {
            sum += min(lefts[leftNum - 1], rights[rightNum - 1]);
        }
        if (sum < minSum)
        {
            minSum = sum;
        }
    }
    cout << minSum << endl;
}


Measured memory_bytes: 1020
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def main():
    S = input()
    i = 0
    max_length = 0
    for c in S:
        if c in ['A', 'T', 'G', 'C']:
            i += 1
        else:
            if max_length < i:
                max_length = i
            i = 0
    if max_length < i:
        max_length = i
    print(max_length)



if __name__ == "__main__":
    main()

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const int MAX_N = 200;
int n,l;

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n >> l;

  vi taste;
  forn1(i,n)
    taste.push_back(l+i-1);

  int min_abs = INT_MAX;
  for (int v : taste) {
    if (abs(v) < abs(min_abs))
      min_abs = v;
  }


  cout << accumulate(taste.begin(),taste.end(),0) - min_abs << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define ll long long
#define pii pair<int,int> 
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
int inf=1000001000;
ll INF=100000000000000000;
ll MOD=1000000007;
//g++ code.cpp   ./a.out 
 
int main() {
    int n;
    cin >> n;
    vector<int> p(n); 
    int ans=0,m=inf;
    rep(i,n){
        cin >> p[i];
        m=min(m,p[i]);
        if(p[i]==m) ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 1024
//ABC089C
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	cin >> n;
	map<char, int> m;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (s[0] == 'M' ||
				s[0] == 'A' ||
				s[0] == 'R' ||
				s[0] == 'C' ||
				s[0] == 'H') {
			m[s[0]]++;
		}
	}
	string s = "MARCH";
	vector<vector<int>> v = {
		{0, 1, 2},
		{0, 1, 3},
		{0, 1, 4},
		{0, 2, 3},
		{0, 2, 4},
		{0, 3, 4},
		{1, 2, 3},
		{1, 2, 4},
		{1, 3, 4},
		{2, 3, 4},
	};

	long long ans = 0;
	for (auto e : v) {
		ans += (long long)m[s[e[0]]] * m[s[e[1]]] * m[s[e[2]]];
	}
	cout << ans << endl;
}

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

int main(){
    int n; cin >> n;
    vector<int> a(n);
    int tmp = 1;
    for (int i=0; i<n; i++){
        cin >> a[i];
    }
    for (int i=0; i<n; i++){
        if (a[i] == tmp){
            tmp += 1;
        }
    }
    if (tmp == 1){
        cout << -1 << endl;
        return 0;
    }
    else{
        cout << n - tmp + 1 << endl;
        return 0;
    }
}

Measured memory_bytes: 1152
n = gets.to_i
a = gets.split.map(&:to_i)
a.sort!
max = a.max
mid = max / 2.0
min = max / 1.0
ans = 0
n.times do |i|
  if min > (mid - a[i]).abs
    min = (mid - a[i]).abs
    ans = i
  end
  break if mid - a[i] < 0
end
puts "#{max} #{a[ans]}"

Measured memory_bytes: 9328
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}

int main(){
    vector<string>ans;
    int n;
    cin >> n;
    vector<string>z(n);
    for(int i=0;i<n;i++){
        cin >> z.at(i);
    }
    reverse(z.begin(),z.end());
    vector<bool>che(n,false);
    for(int i=0;i<n;i+=2){
        if(i>=n)continue;
        ans.push_back(z.at(i));
        che.at(i)=true;
    }
    reverse(z.begin(),z.end());
    reverse(che.begin(),che.end());
    for(int i=0;i<n;i++){
        if(!che.at(i)){
            ans.push_back(z.at(i));
        }
    }
    for(int i=0;i<n;i++){
        if(i==n-1){
            cout << ans.at(i)<<endl;
            return 0;
        }
        cout << ans.at(i)<<" ";
    }
}



Measured memory_bytes: 17648
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
long n,arr1[10000000],arr2[10000000];
int main(){
	scanf("%ld",&n);
	for(int i=0;i<n+1;i++){
		scanf("%ld",&arr1[i]);
	} 
	for(int i=0;i<n;i++){
		scanf("%ld",&arr2[i]);
	}
	long sum=0;
	
	for(int i=0;i<n;i++){
		if(arr1[i]<arr2[i]){
			arr2[i]=arr2[i]-arr1[i];
			sum+=arr1[i];
			arr1[i]=0;
			if(arr1[i+1]<arr2[i]){
				sum+=arr1[i+1];
				arr2[i]=arr2[i]-arr1[i+1];
				arr1[i+1]=0;
			}else{
				sum+=arr2[i];
				arr1[i+1]=arr1[i+1]-arr2[i];
				arr2[i]=0;
			}
		}else{
			sum+=arr2[i];
			arr1[i]=arr1[i]-arr2[i];
			arr2[i]=0;
		}
	} 
	printf("%ld",sum);
	return 0;
}

Measured memory_bytes: 3072
N = int(input())
# = str(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

change = N%1000

if change == 0:
    print(0)
    exit()

print(1000-change)


Measured memory_bytes: 9144
#include <iostream>
using namespace std;
int main() {
	int x,y,z;
	cin >> x >> y >> z;
	if (x == y) {
		cout << z << endl;
	}
	else if (y == z) {
		cout << x << endl;
	}
	else {
		cout << y << endl;
	}
}

Measured memory_bytes: 3588
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	for(int i=1;i<=9;i++)
	{
		for(int j=1;j<=9;j++)
		{
			cout<<i<<"x"<<j<<"="<<i*j<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2976
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main() {

    int N; cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; i++) scanf("%d", &v[i]);
    sort(v.begin(), v.end());
    int max_v = v[N-1];
    int r = 0;
    for (int i = 0; i < N-1; i++) {
        if (r <  min(v[i], max_v - v[i])) 
            r = v[i];
    }
    cout << max_v << ' ' << r << '\n';

}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  vector<ll> T(N);
  vector<ll> A(N);
  REP(i, N) cin >> T[i] >> A[i];

  ll t = T[0];
  ll a = A[0];
  for(ll i = 1; i < N; i++) {
    ll tk, jk;
    if(t % T[i] != 0) {
      tk = t / T[i];
      tk++;
    } else {
      tk = t / T[i];
    }
    if(a % A[i] != 0) {
      jk = a / A[i];
      jk++;
    } else {
      jk = a / A[i];
    }
    ll k = max(tk, jk);
    t = T[i] * k;
    a = A[i] * k;
    // cout << t << ' ' << a << endl;
  }
  cout << t + a << endl;
  return 0;
}

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

int main() {
    string S;
    cin >> S;
    int ans = 0;
    for (int i = 0; i < (int)S.length()/2; i++) {
        if (S[i] != S[(int)S.length()-1-i]) ans++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);


        String s = sc.next();

        for(int i = 0; i < s.length() - 1; i++){
            if(s.charAt(i) == s.charAt(i + 1)){
                System.out.println("Bad");
                return;
            }
        }

        System.out.println("Good");

    }
}


Measured memory_bytes: 21716
//WrittenBiDP
//flowers

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

#define INF 100000000500000000LL

typedef long long ll;
typedef vector <ll> vi;

vi height, beauty, ans;
vi tree;

void add(int apex, int l, int r, int num, ll value) {
	if (r < num || num < l) return;
	if (l == r) {
		tree[apex] = value;
		return;
	}
	int m = (l + r) / 2;
	add(apex * 2, l, m, num, value);
	add(apex * 2 + 1, m + 1, r, num, value);

	tree[apex] = max(tree[apex * 2], tree[apex * 2 + 1]);
}

ll get(int apex, int l, int r, int L, int R) {
	if (R < l || r < L) return 0;
	if (L <= l && r <= R) return tree[apex];
	int m = (l + r) / 2;
	return max(get(apex * 2, l, m, L, R),
		get(apex * 2 + 1, m + 1, r, L, R));
}

int main() {
	//ifstream In("input.txt");
	//ofstream Out("output.txt");

	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		height.push_back(t);
	}

	tree.resize(4 * n);

	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		beauty.push_back(t);
		
	}

	ans.resize(n);

	for (int i = 0; i < n; i++) {
		ans[i] = get(1, 1, n, 1, height[i] - 1) + beauty[i];
		add(1, 1, n, height[i], ans[i]);
	}

	ll answer = -INF;

	for (int i = 0; i < n; i++) {
		answer = max(answer, ans[i]);
	}

	cout << answer;

	return 0;
}

Measured memory_bytes: 11376
#include<iostream>
using namespace std;
int main(){
  int w,ans;
  while(cin>>w){
    if(w==-1) break;
    ans = 1150;
    if(w>10&&w<=20) ans += (w-10) * 125;
    else if(w>=20) ans += 10 * 125;
    if(w>20&&w<=30) ans += (w-20) * 140;
    else if(w>30) ans += 10 * 140;
    if(w>30) ans += (w-30) * 160;
    cout << 4280-ans << endl;
  }
  return 0;
}

 

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

using namespace std;

string s;

int main()
{
  cin >> s;
  int prefix = s.length();
  int lim = s.length();
  for (int i = 0; i < lim; i++)
  {
    if ((s[i] == '0' && s[i + 1] == '1') || (s[i] == '1' && s[i + 1] == '0'))
    {
      s.erase(s.begin() + i, s.begin() + i + 2);
      i -= 2;
      lim -= 2;
    }
  }

  cout << prefix - s.length();
}


Measured memory_bytes: 512
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
-- import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: String -> Int
solve s = acc
  where
    (stack, acc) = foldl' op ([], 0) s
    op ([], !acc) c = ([c], acc)
    op (stack@(c1:p), !acc) c2 | c1 == c2 = (c2:stack, acc)
                               | c1 /= c2 = (p, acc+2)

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_s]:remLines1 = remLines0
      s = B.unpack bs_s
  in solve s

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents


-------------------------------------------------------------------------------

inp1 = "0011\n"
inp2 = "11011010001011\n"
inp3 = "0\n"
tv1 = tmain $ B.pack inp1
tv2 = tmain $ B.pack inp2
tv3 = tmain $ B.pack inp3
test1 = tv1 == 4
test2 = tv2 == 12
test3 = tv3 == 0
alltest = test1 && test2 && test3



Measured memory_bytes: 5500
#include <bits/stdc++.h>
#define fast_read ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
using namespace std;
int main()
{
    fast_read
    char a,b;
    cin>>a>>b;
    if (a == b)cout<<'='<<endl;
    else if (a > b)cout<<'>'<<endl;
    else cout<<'<'<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define t_case ll test;cin>>test;while(test--)
#define left(nod) 2*nod
#define right(nod) 2*nod+1
#define ss second
#define ff first
#define pb push_back
#define pll pair<ll,ll>
#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define deb(a) cout<<#a<<": "<<a;cout<<endl;
#define deba(a) cout<<#a<<": ";for(auto it:a)cout<<it<<" ";cout<<endl;


int main()
{
	FAST;
	
	ll n;cin>>n;char c[200009];ll cnt[200009];cnt[0]=0;
	for(ll i=1;i<=n;i++){cin>>c[i];cnt[i]=(c[i]=='R') + cnt[i-1];}
	ll ans=1e17;
	for(ll i=0;i<=n;i++)
	{
		ll ca=0;
		
		ll r1=cnt[i], w1=i-cnt[i];
		ll r2=cnt[n]-r1, w2=n-i-r2;
		
		ll s=min(w1,r2);
		ll req=min(w1,r2);
		s=min(s,req);
		ca+=s;r1+=s;w2+=s;
		ca+=i-r1 + n-i-w2;
		ans=min(ca,ans);
	}
	cout<<ans;
	
	
	
}


Measured memory_bytes: 5412
#include <bits/stdc++.h>
using namespace std;
int INF = 0x3f3f3f3f;;
vector<int> h(1e5 + 10);
vector<int> dp(1e5 + 10, INF);

int dfs(int j, int k) {
    if (j <= 0) return 0;
    if (j <= k) {
        return abs(h[j] - h[0]);
    }
    if (dp[j] != INF) return dp[j];
    
    for (int i = 1; i <= k; i++) {
        dp[j] = min(dp[j], abs(h[j] - h[j-i]) + dfs(j - i, k));
    }
    return dp[j];
}
int main() {
    int n, k;
    cin >> n >> k;
    
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    
    
    cout << dfs(n-1, k) << '\n';
}

Measured memory_bytes: 8832
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N, l[1123], r[1123];
int ans;

int main()
{
	in >> N;
	rep(i, N) { in >> l[i] >> r[i]; }

	rep(i, N)
	{
		ans += r[i] - l[i] + 1;
	}

	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
  var N,sum int
  fmt.Scan(&N)
  d := make([]int, N)
  for i := range d {
    fmt.Scan(&d[i])
  }
  for a := 0; a < N; a++{
    for b := a+1; b < N; b++{
      sum += d[a]*d[b]
    }
  }
  fmt.Println(sum)
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] line1 = line.split(" ");
        Long a = Long.parseLong(line1[0]);
        Long b = Long.parseLong(line1[1]);
        Long c = Long.parseLong(line1[2]);
        Long d = Long.parseLong(line1[3]);
        Long count1 = b - a + 1;
        //System.out.println(count1);
        Long e;
        if(a % c == 0)
        e = a / c;
        else
        e = a / c + 1;
        Long f = b / c;
        Long count2 = f - e + 1;
        //System.out.println(count2);
        if(a % d == 0)
        e = a / d;
        else
        e = a / d + 1;
        f = b / d;
        Long count3 = f - e + 1;
        //System.out.println(count3);
        Long g = lcm(c, d);
        if(a % g == 0)
        e = a / g;
        else
        e = a / g + 1;
        f = b / g;
        Long count4 = f - e + 1;
        //System.out.println(count4);
        System.out.println(count1 - (count2 + count3 - count4));
    }
    static long lcm (long a, long b) {
	    long temp;
	    long c = a;
	    c *= b;
	    while((temp = a % b)!=0) {
	    	a = b;
	    	b = temp;
	    }
	return (long)(c/b);
    }
}

Measured memory_bytes: 23252
k = int(input())

def gcd1(a, b):
    while b:
        a, b = b, a % b
    return a

ans = 0

for a in range(1,k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            g1=gcd1(a,b)
            ans += gcd1(g1,c)
            
print(ans)



Measured memory_bytes: 73792
// Copyright 2017 wu_qing
#include <cstdio>
#include <algorithm>
int n, a, cnt, tot;
bool b[10];
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a);
        if (a < 3200)
            b[a / 400] = true;
        else
            cnt++;
    }
    for (int i = 0; i <= 7; i++)
        if (b[i])
            tot++;
    printf("%d ", std::max(1, tot));
    printf("%d\n", cnt + tot);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define maxn 205
#define inf ((int)1e9+10)
#define int long long
using namespace std;
int n,m,r,graph[maxn][maxn],ans=inf;
vector<int> v;
main()
{
	cin>>n>>m>>r;
	for(int i=0;i<r;i++)
	{
		int x;
		cin>>x;
		--x;
		v.push_back(x);
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
		{
			if(i==j)
				graph[i][i]=0;
			else
				graph[i][j]=inf;
		}
	for(int i=0;i<m;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		--a,--b;
		graph[a][b]=graph[b][a]=c;
	}
	for(int k=0;k<n;k++)
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				graph[i][j]=min(graph[i][j],graph[i][k]+graph[k][j]);
	vector<int> sp=v;
	do
	{
		int sum=0;
		for(int i=1;i<v.size();i++)
			sum+=graph[v[i]][v[i-1]];
		ans=min(ans,sum);
		next_permutation(v.begin(),v.end());
	}while(sp!=v);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
import Data.Bits
import Data.Foldable (foldlM,foldrM)
import Data.Maybe (fromMaybe)
import Data.List
import qualified Data.Vector.Unboxed.Mutable as V
import Control.Monad
import qualified Data.ByteString.Lazy.Char8 as B
--import Debug.Trace

findrem :: Eq a => a -> [a] -> Maybe [a]
findrem x [] = Nothing
findrem x (a:as) = if x == a then Just as
  else case (findrem x as) of
    Nothing -> Nothing
    Just as' -> Just $ a:as'

remove1 :: Int -> (Int,Int) -> (Int,Int) -> [(Int,Int)] -> [(Int,Int)]
remove1 _ _ _ [] = []
remove1 n (p,q) (x,y) ps = case findrem (x+p,y+q) ps of
  Nothing -> ps
  Just ps'-> remove1 n (p,q) (x+p,y+q) ps'

solve' :: Int -> (Int,Int) -> [(Int,Int)] -> Int
solve' _ _ [] = 0
solve' n (p,q) ps = 1 + (solve' n (p,q) $ remove1 n (p,q) (head ps) (tail ps))

solve :: Int -> [(Int,Int)] -> Int
solve n ps' = let ps = sortOn (\(x,y) -> x+y) ps'
  in if length ps <= 1 then 1
    else minimum [solve' n (p,q) ps | (p,q) <- [(x'-x,y'-y)| (x,y) <- ps, (x',y') <- ps, x < x' || y < y']]

main :: IO ()
main = do
  n <- readLn
  ps <- replicateM n $ do
    [x,y] <- map read.words <$> getLine :: IO [Int]
    return (x,y)
  print $ solve n ps


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1e9+1;

/*

*/

void solve(){
    int x,y;
    cin >> x >> y;
    cout << x + (y/2) << endl;
}

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


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(A: int, B: int):
    if A * B % 2 == 0:
        ret = NO
    else:
        ret = YES
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int H, N;
	cin >> H >> N;
	vector<int> data(H + 1, INF32);

	data[0] = 0;
	for (int i = 0; i < N; i++)
	{
		int damage, cost;
		cin >> damage >> cost;
		for (int i = 0; i < H; i++)
		{
			data[min(H, i + damage)] = min(data[min(H, i + damage)], data[i] + cost);
		}
	}
	cout << data[H] << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	string b;
	cin>>a>>b;
	if (b.size()<=a)
		cout<<b;
	else
	{
		for (int i=0;i<a;i++)
			cout<<b[i];
		cout<<"...";
	}
	return 0;
}


Measured memory_bytes: 3624
A, B = [int(i) for i in input().split()]
# rest = B % (A - 1)
# if rest <= 1:
#     print(int(B / (A - 1)))
# else:
#     print(int(B / (A - 1) + 1))

taps = 1
num = 0
while True:
    if taps >= B:
        break
    taps -= 1
    taps += A
    num += 1
print(num)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

int main() {
  int X,A,B; cin >>X >>A >>B;
  int nanko=(X-A)/B;
  int ans=X-A-B*nanko;
  cout <<ans <<endl;
  return 0;
}


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

using namespace std;

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

int N,T,S;
int A[3001], B[3001];
int dp[3001][3001];

int dfs(int n, int t){
  if(n>=N) return 0;
  if(t>T) return 0;

  int &res = dp[n][t];
  if(res >= 0) return res;
  res = 0;
  if(t+B[n] <= T && (S <= t || t+B[n] <= S)) res = max(res, dfs(n+1, t+B[n])+A[n]);
  else if(t+B[n] <= T && (t < S && S < t+B[n]) && S+B[n] <= T) res = max(res, dfs(n+1, S+B[n])+A[n]);
  res = max(res, dfs(n+1, t));
	    
  return res;
}

int main(){
  scanf("%d%d%d", &N,&T, &S);
  rep(i,N) scanf("%d%d",&A[i],&B[i]);
  memset(dp,-1,sizeof(dp));
  printf("%d\n", dfs(0, 0));
}

Measured memory_bytes: 36536
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
  string s; cin >> s;
  int len = s.size();
  ll ans=0;
  for (int tmp = 0; tmp < (1 << len-1); ++tmp) {
    ll ver = s[0] - '0';
    for(int i=0; i<len-1; ++i){
      if(tmp & (1 << i)){
        ans += ver;
        ver=0;
      }
      ver = ver * 10 + s[i + 1] - '0';
    }
    ans += ver;
  }  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<set>
#define MAX 100000
using namespace std;
int N = 0;
vector<int> G[MAX];
int p[MAX] = {},visited[MAX] = {},ord[MAX] = {},low[MAX] = {};
int timer=0;
void dfs(int current,int prev){
    ord[current] = low[current] = ++timer;
    visited[current] = true;
    for(auto &itr:G[current]){
        if(!visited[itr]){
            p[itr] = current;
            dfs(itr,current);
            low[current] = min(low[current],low[itr]);
        }else if(itr != prev){
            low[current] = min(low[current],ord[itr]);
        }
    }
}

int main(void){
    int e,s,t;
    scanf("%d %d",&N,&e);
    for(int i = 0;i < e;++i){
        scanf("%d %d",&s,&t);
        G[s].push_back(t);
        G[t].push_back(s);
    }
    p[0] = -1;
    dfs(0,-1);
    for(int i = 0;i < N;++i){
      //printf("%d:%d ",low[i],ord[i]);
    }
    int cp=0;
    int pnum;
    set<int> ap;
    for(int i = 1;i < N;++i){
        pnum = p[i];
        if(pnum == 0){
            cp++;
        }else if(ord[pnum] <= low[i]){
            ap.insert(pnum);    
        }
    }
    if(cp >= 2) printf("%d\n",0);
    for(auto &itr:ap) printf("%d\n",itr);
    
    
    
}


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

int main() {
    int n, t[100], s = 0;
    double v[100], w[50000], ans = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> t[i];
    }
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    w[0] = 0;
    for(int i=0;i<n;i++){
        w[s] = min(w[s], v[i]);
        for(int j=0;j<t[i]*2;j++){
            w[++s] = v[i];
        }
    }
    for(int i=1;i<s;i++){
        w[i] = min(w[i], w[i-1]+0.50);
    }
    w[s] = 0;
    for(int i=s-1;i>0;i--){
        w[i] = min(w[i], w[i+1]+0.50);
    }
    for(int i=0;i<s;i++){
        ans += (w[i] + w[i+1]) / 4.00;
    }
    cout << fixed << setprecision(16) << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main() {
	int a,b,ans;
	scanf("%d%d", &a,&b);
	if(a>=13){
		ans=b;
	}else if(a<=5){
		ans=0;
	}else{
		ans=b/2;
	}
	printf("%d\n", ans);
	return 0;
}


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

int main() {
  vector<int> num(3);
  cin >> num.at(0) >> num.at(1) >> num.at(2);
  sort(num.begin(), num.end());
  if (num.at(0) == num.at(1) && num.at(0) != num.at(2)) {
    cout << "Yes" << endl;
  }
  else if (num.at(0) != num.at(1) && num.at(1) == num.at(2)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256