akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ri rd<int>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; --i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++i)
#define fore(e, u, v) for (int p = e.g[u], v = e[p].y; p; v = e[p = e[p].nxt].y)
typedef long long LL;
const int maxN = 1e5 + 7;

template<class T> T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; return f ? x : -x;
}

int n;
int deg[maxN];

struct Vec {
	int g[maxN], te;
	struct edge {int y, nxt;} e[maxN << 1];
	inline void push(int x, int y) { e[++te] = (edge){y, g[x]}; g[x] = te; }
	inline void link(int x, int y) { push(x, y), push(y, x); }
	inline edge& operator [] (int x) { return e[x]; }
}e;

int dfs(int x, int fa) {
	int res = 0;
	--deg[x];
	fore (e, x, y) if (y != fa) {
		int tp = dfs(y, x);
		deg[x] -= tp > 0;
		res += tp;
	}
	return res + max(0, deg[x] - 1);
}

int main() {

	n = ri();
	For (i, 1, n) {
		int x = ri() + 1, y = ri() + 1;
		e.link(x, y);
		++deg[x], ++deg[y];
	}

	rep (i, 1, n) if (deg[i] > 2) {
		++deg[i];
		printf("%d\n", dfs(i, 0));
		return 0;
	}
	puts("1");

	return 0;
}


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


typedef struct node{
    int key;
    struct node *next,*prev;
}*NodePointer;
 
NodePointer tamesi;
 
NodePointer listSearch(int key){
    NodePointer cur=tamesi->next;
    while(cur != tamesi ){
        //if ( cur == tamesi ) break;
        if(cur->key==key) return cur;
        cur=cur->next;
    }
    return tamesi;
}
 
void init(){
    tamesi=(NodePointer)malloc(sizeof(struct node));
    tamesi->next=tamesi;
    tamesi->prev=tamesi;
}
void printList(){
    NodePointer cur=tamesi->next;
    int isf=0;
    while(1){
        if(cur==tamesi) break;
        if(isf++>0) printf(" ");
        printf("%d",cur->key);
        cur=cur->next;
    }
    printf("\n");
}

void deleteNode(NodePointer t){
    if(t==tamesi) return;
    t->prev->next=t->next;
    t->next->prev=t->prev;
    free(t);
}

void deleteFirst(){
    deleteNode(tamesi->next);
}

void deleteLast(){
    deleteNode(tamesi->prev);
}

void deleteKey(int key){
    deleteNode(listSearch(key));
}

void insert(int key){
    NodePointer x=(NodePointer)malloc(sizeof(struct node));
    x->key=key;
    x->next=tamesi->next;
    tamesi->next->prev=x;
    tamesi->next=x;
    x->prev=tamesi;
}
int main(){
    int key,n,i;
    int size=0;
    char com[20];
    int np=0,nd=0;
    scanf("%d",&n);
    init();
    for(i=0;i<n;i++){
        scanf("%s%d",com,&key);
        if(com[0]=='i'){insert(key); np++; size++;}
        else if (com[0]=='d'){
            if(strlen(com)>6){
                if(com[6]=='F') deleteFirst();
                else if (com[6]=='L')deleteLast();
                }else{
                deleteKey(key); nd++;
            }
            size--;
        }
    }
    printList();
    return 0;
}
       
       


Measured memory_bytes: 32932
#include<bits/stdc++.h>
using namespace std;
typedef tuple<int,int,int>T;
typedef vector<T>VT;
int main(void){
	int n;
	int stone[100001];
	int i,j,k;
	int f,b,c;
	VT v;
	int sum;
	while(1){
		cin>>n;
		v.clear();
		if(n==0)	break;
		for(i=1;i<=n;i++)	cin>>stone[i];
		f=1;	b=1;	c=stone[i];
		v.push_back(make_tuple(f,b,c));
		for(i=2;i<=n;i++){
			if(i%2!=0){
				if(stone[i]!=stone[i-1]){
					f=i;	b=i;	c=stone[i];
					v.push_back(make_tuple(f,b,c));
				}
				else{
					get<1>(v[v.size()-1])++;
				}
			}
			else{//i%2==0
				if(stone[i]==stone[i-1]){
					get<1>(v[v.size()-1])++;
				}
				else{//stone[i]!=stone[i-1]
					v.push_back(make_tuple(i,i,stone[i]));
					/* for(j=0;j<v.size();j++)		cout<<get<0>(v[j])<<" "<<get<1>(v[j])<<" "<<get<2>(v[j])<<endl;
					cout<<endl; */
					j=v.size()-1;
					//cout<<j<<endl;
					while(j>-1){
						j--;
						if(stone[i]==get<2>(v[j]))	break;
					}
					//cout<<j<<endl;
					if(j==-1){
						v.clear();
						f=1;	b=i;	c=stone[i];
						v.push_back(make_tuple(f,b,c));
					}
					else{
						get<0>(v[v.size()-1])=get<0>(v[j]);
						for(k=v.size()-2;k>=j;k--){
							v.erase(v.begin()+k);
						}
					}
					/* for(j=0;j<v.size();j++)		cout<<get<0>(v[j])<<" "<<get<1>(v[j])<<" "<<get<2>(v[j])<<endl;
					cout<<endl; */
				}
			}
			/* for(j=0;j<v.size();j++)		cout<<get<0>(v[j])<<" "<<get<1>(v[j])<<" "<<get<2>(v[j])<<endl;
			cout<<endl; */
		}
		sum=0;
		for(i=0;i<v.size();i++){
			if(get<2>(v[i])==0){
				//cout<<get<1>(v[i])-(get<0>(v[i])-1)<<endl;
				sum+=get<1>(v[i])-(get<0>(v[i])-1);
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}
				
				
			
		
	


Measured memory_bytes: 3408
N,M = map(int, input().split())
H = [int(h) for h in input().split()]
E = [[] for _ in range(N)]
for _ in range(M):
    a,b = map(int, input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)

ans = 0
for i in range(N):
    flag = True
    for e in E[i]:
        if H[i] <= H[e]:
            flag = False
            break
    if flag:
        ans += 1

print(ans)

Measured memory_bytes: 92836
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll K , X;
    cin >> K >> X;
    
    for(int i = max((X-K+1),-1000000LL); i <= min(1000000LL, K + X -1); i++ ){
        cout << i << " ";
    }
    cout << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

int main(){
    
    int n; cin>>n;
    set<string> key;
    REP(i,n){
        string t; cin>>t;
        key.insert(t);
    }
    
    cin>>n;
    bool state = false;
    REP(i,n){
        string t; cin>>t;
        if(key.find(t)==key.end()){
            cout<<"Unknown "<<t<<endl;
        }else{
            if(state){
                cout<<"Closed by "<<t<<endl;
            }else{
                cout<<"Opened by "<<t<<endl;
            }
            state=!state;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3256
#
# abc072 a
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """100 17"""
        output = """83"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """48 58"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1000000000 1000000000"""
        output = """0"""
        self.assertIO(input, output)


def resolve():
    X, t = map(int, input().split())
    print(max(X-t, 0))


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16120
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const double PI = acos(-1);

vector<vector<int>> Edge;
vector<vector<int>> Dist;

void dfs(int cur, int from, int depth, int id) {
	//深さを入れる
	Dist[cur][id] = depth;
	//行ける辺があれば行く
	for (auto to : Edge[cur]) {
		//来た辺には戻らない
		if (to != from) {
			//toを今、curを前にして深さ+1
			dfs(to, cur, depth + 1, id);
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n, u, v;
	cin >> n >> u >> v;
	u--; v--;

	Edge.resize(n);
	Dist.resize(n, vector<int>(2));

	rep(i, n - 1LL) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		Edge[a].push_back(b);
		Edge[b].push_back(a);
	}

	dfs(u, u, 0, 0);
	dfs(v, v, 0, 1);

	int ma = 0;
	rep (i, n) {
		if (Dist[i][0] < Dist[i][1]) {
			chmax(ma, Dist[i][1] - 1);
		}
	}

	out(ma);

	return 0;
}

Measured memory_bytes: 16384
#include<iostream>

int main()
{
    int N = 0;
    int X = 0;
    int T = 0;
    int i = 1;
    int t_num =0;

    std::cin >> N;
    std::cin >> X;
    std::cin >> T;
 
    t_num = i * X;

    for(i=1; t_num < N;) 
    {
	    i++;
        t_num = i * X;
    }

    std::cout << T*i;

    return 0;
}

Measured memory_bytes: 3600
N = int(input())
v = []
for i in range(N):
	v.append(list(map(int,input().split())))
v.sort()
ans = 0
for i in range(N-1):
	ans += min(v[i+1][0]-v[i][0],v[i][1]-v[i+1][1])-1
print(ans+v[0][0]-1+v[-1][1]+N)

Measured memory_bytes: 29540
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>

using namespace std;
#define REP(i,m,n) for(int i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

int main() {
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
char t[999];i=12,c;f(x,z){if(t[x]-->48)for(;z;)f(x+"HJ<V"[--z]-73,4);}main(j){for(;~scanf("%s",t+i--*13);c=0)for(j=170;i?0:--j||!printf("%d\n",c,i=12);f(j,4))c+=t[j]>48;}

Measured memory_bytes: 0
n,k = [int(s) for s in input().split()]
arr = [int(s) for s in input().split()]
arr.sort()
maxi = 0
for i in range(1,len(arr)):
    maxi = max(maxi,arr[i]-arr[i-1])
maxi = max(maxi,n-arr[k-1]+arr[0])
print(n-maxi)

Measured memory_bytes: 77388
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

int main() {
    int N, T;
    cin >> N >> T;
    vector<pair<int, int>> D(N);
    for (int i = 0; i < N; i++) {
        cin >> D[i].first >> D[i].second;
    }
    sort(D.begin(), D.end());

    vector<vector<int>> dp(N, vector<int>(T, 0));
    if (D[0].first < T) {
        dp[0][D[0].first] = D[0].second;
    }
    for (int i = 1; i < N; i++) {
        for (int t = 0; t < T; t++) {
            dp[i][t] = dp[i - 1][t];
            if (D[i].first <= t) {
                dp[i][t] = max(dp[i][t], dp[i - 1][t - D[i].first] + D[i].second);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int temp = 0;
        for (int t = 0; t < T; t++) {
            temp = max(temp, dp[i][t]);
        }
        if (i != N - 1) {
            temp += D[i + 1].second;
        }
        ans = max(ans, temp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 35584
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<utility>
#include<iostream>
using namespace std;
int main()
{
	string s;cin>>s;
	int w;cin>>w;
	int len = s.length();
	for(int i=0;i<len;i+=w)
	printf("%c",s[i]);
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  //上皿天秤が左に傾くなら Left を、釣り合うなら Balanced を、右に傾くなら Right を出力せよ
  if(a+b == c+d) cout<<"Balanced"<<endl;
  else if(a+b > c+d) cout<<"Left"<<endl;
  else cout<<"Right"<<endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<long long> > vvll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define INF 1000000000
#define MOD 1000000007
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define p_q priority_queue
 
#define FOR(i, a, b) for (int i=(a); i<=(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)
 
#define MN 200005
int n;
string s;

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

    cin >> n >> s;
    int r = 0, b = 0;

    F0R(i, n){
        if(s[i] == 'R') r++;
        else b++;
    }

    if(r > b) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
from sys import stdin

class Node(object):
    def __init__(self, parent=None, left=None, right=None,
                 name=None, sibling=None, degree=None):
        self.parent = parent
        self.left = left
        self.right = right
        self.name = name
        self.sibling = sibling
        self.degree = degree

def print_nodes(nodes, n):
    def get_depth(nodes, u):
        p = nodes[u].parent
        nonlocal d
        if p != None and p != -1:
            get_depth(nodes, p)
            d += 1
        return d

    def get_height(nodes, u):
        h1 = 0
        h2 = 0
        r = nodes[u].right
        l = nodes[u].left
        if r != -1:
            h1 = get_height(nodes, r) + 1
        if l != -1:
            h2 = get_height(nodes, l) + 1
        return max(h1, h2)

    for i in range(n):
        d = 0
        if nodes[i].parent == None:
            nodes[i].parent = -1
            nodes[i].sibling = -1
            nodes[i].name = "root"
        print("node {0}: parent = {1}, sibling = {2}, degree = {3}, depth = {4}, height = {5}, {6}".format(
               i, nodes[i].parent, nodes[i].sibling, nodes[i].degree, get_depth(nodes, i),
               get_height(nodes, i), nodes[i].name))

def read_binary_tree(nodes, n):
    for _ in range(n):
        i = [int(i) for i in stdin.readline().strip().split()]
        nodes[i[0]].left = i[1]
        nodes[i[0]].right = i[2]
        nodes[i[0]].degree = 0
        if i[1] != -1:
            nodes[i[0]].name = "internal node"
            nodes[i[1]].parent = i[0]
            nodes[i[1]].sibling = i[2]
            nodes[i[0]].degree += 1
        if i[2] != -1:
            nodes[i[0]].name = "internal node"
            nodes[i[2]].parent = i[0]
            nodes[i[2]].sibling = i[1]
            nodes[i[0]].degree += 1
        if i[1] == -1 and i[2] == -1:
            nodes[i[0]].name = "leaf"

n = int(input())
nodes = [Node() for _ in range(n)]
read_binary_tree(nodes, n)
print_nodes(nodes, n)


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll dp[MAXn],w[MAXn],v[MAXn];
int main(){
  IOS();
  ll n,W;
  cin >> n >> W;
  REP (i,n) cin >> w[i] >> v[i];

  REP (i,n) {
    for (ll j=W;j>=w[i];j--) {
      dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
    }
  }

  ll ans = 0;
  REP (i,W+1) ans = max(ans,dp[i]);
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 998244353
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll n, k, ptr, ans=0;

	cin>>n>>k;

	vll a(n);

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

	ptr=0;
	while(ptr<n-1){
		ans++;
		ptr+=k-1;
	}
	cout<<ans<<endl;
}


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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

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

template <class T>
void dump_vec(const vector<T> &v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

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

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

signed main() {
    int N;
    cin >> N;
    vector<int> S(N);
    rep(i, 0, N) cin >> S[i];
    int Q;
    cin >> Q;
    vector<int> T(Q);
    rep(i, 0, Q) cin >> T[i];

    int ans = 0;
    rep(i, 0, Q) {
        bool ok = false;
        rep(j, 0, N) {
            if (T[i] == S[j]) ok = true;
        }
        if (ok) ans++;
    }
    cout << ans << "\n";
}



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

using namespace std;

const int W = 1'000;
const int MOD = 1'000'000'007;

int dp[W];

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

    dp[0] = 1;

    int h, w;
    cin >> h >> w;

    for (int i = 0; i < h; ++i) {
        string row;
        cin >> row;

        if (row[0] == '#') dp[0] = 0;
        for (int j = 1; j < w; ++j) {
            if (row[j] == '#')
                dp[j] = 0;
            else
                dp[j] = (dp[j - 1] + dp[j]) % MOD;
        }
    }

    cout << dp[w - 1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  int64_t N, X;
  cin >> N >> X;
  vector<int64_t> A(N);
  rep(i, N) cin >> A[i];

  int64_t answer = 0;
  for(int i = 1; i < N; ++i) {
    if(X < (A[i-1] + A[i])) {
      int64_t diff = (A[i] + A[i-1]) - X;
      A[i] -= min(A[i], diff);
      answer += diff;
    }
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
int main(){
	long long int n;
	int ss[10000]={};
	int l;
	scanf("%lld",&n);
	for(int i=0;true;i++){
		if(n%2!=0){
			ss[i]=1;
			n=n-1;
		}
		if(n==0){
			l=i;
			break;
		}
		n=-n/2;
	}
	char s[l+2]={};
	for(int i=0;i<=l;i++){
		s[i]=ss[l-i]+'0';
	}
	printf("%s\n",s);
	return 0;
}
		

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
int main(){
FASTIO	
int n,m;
cin>>n>>m;
vector<int> v(n+1,0);
vector<int> wa(n+1,0);
int l=0;
for(int i=0;i<m;i++){
	int a;
	cin>>a;
	string s;
	cin>>s;
	if(v[a]==1)
	  continue;
	if(s[0]=='A'){
		v[a]=1;
		l+=wa[a];
	}
	else{
		  wa[a]++;
	}
}
int l1=0;
for(int i=1;i<=n;i++){
	if(v[i]==1)
	  l1++;
}
cout<<l1<<" "<<l;
return 0;
}


Measured memory_bytes: 1024
N =int(input())
nums = [int(input()) for _ in range(N)]

v = nums 
v_sort = sorted(v, reverse=True)
v_max=v_sort[0]
v_max2=v_sort[1]

for i in range(N):
    if(v[i]!=v_max):
        print(v_max)
    else:
        print(v_max2)

Measured memory_bytes: 14112
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
#n = int(input())
x, n = map(int, sys.stdin.readline().split())
#s = input()
p = list(map(int, sys.stdin.readline().split()))

r = []
for i in range(1000):
    r.append(-500+i)

for i in range(n):
    r.remove(p[i])
    
ans = []
q = 10 ** 8
for i in range(len(r)):
    if abs(r[i] - x) < q:
        q = abs(r[i] - x)

for i in range(len(r)):
    if q == abs(r[i] - x):
        ans.append(r[i])


    
print(min(ans))




















Measured memory_bytes: 10032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N,K;string s;cin>>N>>K>>s;
	int a=0;
	rep(i,N-1) if(s[i] != s[i+1]) a++;
	a = max(a-K*2,0);
	cout << N-1-a << endl;
}


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

int len_pre_atgc(string s) {
  int res = 0;
  for (auto c : s) {
    if (c == 'A' || c == 'T' || c == 'G' || c == 'C') {
      res++;
      continue;
    }
    break;
  }
  return res;
}

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.length(); i++) {
    ans = max(ans, len_pre_atgc(s.substr(i)));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string>
#include <string.h>
#include <float.h>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main()
{
	char szS[100];

	cin >> szS;
	int nLen = strlen(szS);
	int nLpMax = 0;
	if(0 == nLen%2)
		nLpMax = nLen / 2;
	else
		nLpMax = nLen / 2;
	int nHag = 0;
	for (int i = 0; i < nLpMax; i++)
	{
		int nRvsIdx = nLen - 1 - i;
		if (szS[i] != szS[nRvsIdx])
			nHag++;
	}
	cout << nHag;
	return 0;
}

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

using namespace std;

const int INF = 0x7fffffff;
const int N = 2005;
int n, a[N<<1], t, dp[N][N], g[N<<1][N<<1];
char c;

int cal(int x, int b, int w){
	return g[x][b] - g[x-1][b] + g[x][w] - g[x][n] - g[x-1][w] + g[x-1][n];
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n << 1; i++){
		scanf("%s%d", &c, &a[i]);
		if(c == 'W')	a[i] += n;
		for(int j = 1; j < i; j++)
			g[a[j]][a[i]] = 1;
	}
	for(int i = 1; i <= n << 1; i++)
		for(int j = 1; j <= n << 1; j++)
			g[i][j] += g[i-1][j] + g[i][j-1] - g[i-1][j-1];
	memset(dp, 0x7f, sizeof dp);
	dp[0][0] = 0;
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= n; j++){
			if(!i && !j)	continue;
			dp[i][j] = min(i ? dp[i-1][j] + cal(i, i, j+n) : INF, j ? dp[i][j-1] + cal(j+n, i, j+n) : INF);
		}
	}
	printf("%d\n", dp[n][n]);
	return 0;
}


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

#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
#define loo 10000000000000007

#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

char mat[51][51];
int ans[51][51];
map<ii, ii> ant;
map<ii, int> visi;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int h, w; cin >> h >> w;
    for (int i = 0; i < h; ++i){
        for (int j = 0; j < w; ++j){
            cin >> mat[i][j];
        }
    }

    queue<ii> q;
    q.push({0, 0});
    ii ult = {0, 0};
    int f = 0;
    while(!q.empty()){
        ii at = q.front();
        if(at == mp(h-1, w-1)) {
            f = 1;
            break;
        }
        ult = at;
        if(at.ff && !visi[{at.ff-1, at.ss}] && mat[at.ff-1][at.ss] == '.') {
            q.push({at.ff-1, at.ss});
            ant[{at.ff-1, at.ss}] = at;
            visi[{at.ff-1, at.ss}] = 1;
        }
        if(at.ss && !visi[{at.ff, at.ss-1}] && mat[at.ff][at.ss-1] == '.') {
            q.push({at.ff, at.ss-1});
            ant[{at.ff, at.ss-1}] = at;
            visi[{at.ff, at.ss-1}] = 1;
        }
        if(at.ff < h-1 && !visi[{at.ff+1, at.ss}] && mat[at.ff+1][at.ss] == '.') {
            q.push({at.ff+1, at.ss});
            ant[{at.ff+1, at.ss}] = at;
            visi[{at.ff+1, at.ss}] = 1;
        }
        if(at.ss < w-1 && !visi[{at.ff, at.ss+1}] && mat[at.ff][at.ss+1] == '.') {
            q.push({at.ff, at.ss+1});
            ant[{at.ff, at.ss+1}] = at;
            visi[{at.ff, at.ss+1}] = 1;
        }
        q.pop();
    }
    if(!f){
        cout << "-1\n";
        return 0;
    }
    ii at = {h-1, w-1};
    while(at != mp(0, 0)){
        ans[at.ff][at.ss] = 1;
        at = ant[at];
    }
    ans[0][0] = 1;
    int res = 0;
    for (int i = 0; i < h; ++i){
        for (int j = 0; j < w; ++j){
            if(mat[i][j] == '.' && ans[i][j] == 0){
                res++;
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 640
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


//main function
fn main() {
    let a:i64 = read();
    let b:i64 = read();
    let k:i64 = read();
    let max = a+k-1;
    let min = b-k+1;
    if max >= min {
	for i in a..b+1{
	    println!("{}",i);
	}
    }else {
	for i in 0..k{
	    println!("{}",a+i);
	}
	for i in 0..k{
	    println!("{}",b-k+i+1);
	}
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int n = sc.nextInt();
        int[] time = new int[100100];
        int[] x    = new int[100100];
        int[] y    = new int[100100];
        for(int i = 0; i < n; i++) {
            time[i + 1] = sc.nextInt();
            x[i + 1]    = sc.nextInt();
            y[i + 1]    = sc.nextInt();
        }
        boolean can = true;
        for( int i = 0; i < n; i++) {
            int dt = time[i+1] - time[i];
            int dist = Math.abs(x[i+1] -x[i]) + Math.abs(y[i+1] -y[i]);
            if(dt < dist) {
                can = false;
                break;
            }
            if(dist % 2 != dt %2) {
                can = false;
                break;
            }
        }
        String ans = "No";
        if(can) ans = "Yes";
        System.out.println(ans);
    }
}


Measured memory_bytes: 94780
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <cmath>
#include <cstdarg>
#include <cstdlib>
#include <string>

#include <vector>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

int main(int argc, char const *argv[]) {
    int N;
    long long D;
    cin >> N >> D;
    long long x, y;
    int count = 0;
    for (int i = 0; i < N; i ++) {
        cin >> x >> y;
        if (x * x + y * y <= D * D) {
            count ++;
        }
    }
    cout << count << endl;
    return 0;
}

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

void trace(vector<int> V){
  int N = V.size();
  for ( int i = 0 ; i < N ; i++ ){
  	cout << V.at(i) ;
    if( i == N-1 ) 
      cout << endl;
    else
      cout << " ";
  }
  return;
}

int main() {
  int N;
  cin >> N ;
  
  vector<int> V(N);
  for ( int i = 0 ; i < N ; i++ ){
    cin >> V.at(i);
  }
  
  int count = 0;
  for ( int i = 0 ; i < N-1 ; i++ ){
    for ( int j = N-1 ; j > i ; j-- ){
      if (V.at(j) < V.at(j-1)){
        swap( V.at(j) , V.at(j-1) );
        count++;
      }
    }
  }  
  trace(V);
  cout << count << endl;  
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r,g,b;
  cin >> r >>g >>b;
  int s;
  s = r*100+g*10+b;
  if(s%4 == 0)
  { cout << "YES" <<endl;}
  else{
    cout << "NO" <<endl;}
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  vector<int> a(13);
  a[4] = a[6] = a[9] = a[11] = 1;
  a[2] = 3;
  int x, y;
  cin >> x >> y;
  if (a[x] == a[y]) cout << "Yes" << '\n';
  else cout << "No" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)
#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(V.begin(),V.end(),c))

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N;
    cin >>N;

    cout << N*N <<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++)

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    h.push_back(1000000001);
    int ans = 0;
    int cnt = 0;
    rep(i,n){
        if(h[i]>=h[i+1]) cnt++;
        else{
            ans = max(ans,cnt);
            cnt = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4040
import math
a,b=map(int,input().split())
c = math.ceil(a*100/8)
d = math.ceil((a+1)*100/8)
e = math.ceil(b*100/10)
f = (b+1)*100//10
for i in range(d-c):
  if c+i>=e and c+i<f:
    print(c+i)
    break
else:
  print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    long double d=2*sqrt((long double)a*b);
    if(a+b+d<c)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}




int main(){
	int N;
	cin >> N;
	vector<string> s(N);
	vector<int> G[N];
	for(auto &&x:s){
		cin >> x;
	}

	int d[N][N] = {};
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(s[i][j]=='1')d[i][j] = 1;
			if(s[i][j]=='1')G[i].push_back(j);
			if(s[i][j]!='1')d[i][j] = 999;
			if(i==j)d[i][j] = 0;
		}
	}

	for(int k=0;k<N;k++){
		for(int i=0;i<N;i++){
			for(int j=0;j<N;j++){
				d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}

	bool is_bipartite_graph = true;
	for(int i=0;i<N;i++){
		for(auto x:G[i]){
			if(d[i][0]%2 == d[x][0]%2)is_bipartite_graph = false;
		}
	}

	if(not is_bipartite_graph){
		cout << -1 << endl;
		return 0;
	}

	int ans = 0;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			ans = max(ans,d[i][j]+1);
		}
	}
	cout << ans << endl;
}


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

using namespace std;

using ll = long long;

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

    string s;

    cin >> s;
    cout << 700 + 100 * count(s.begin(), s.end(), 'o') << endl;

    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    int total = 0;
    rep(i, n)rep(j, n){
        if(i != j){
            int rec = d[i] * d[j];            
            total += rec;
        }
    }
    cout << total / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};


const int MAX = 510000;

// 二項係数計算
long long com(ll n){
    ll k = 2;
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return n*(n-1)/2;
}

int main()
{

    ll N;
    cin >> N;
    vector<ll> A;
    ll same[200005] = {};
    ll done[200005] = {};

    for(ll i=0; i<N; ++i)
    {
        ll tmp;
        cin >> tmp;			// ボールの値
        A.push_back(tmp);	// ボール配列を作成
        ++same[tmp];		// 同じ値のボール個数
    }

    ll all = 0;
    for(ll i=0; i<N; ++i)
    {
        if(done[A[i]]==1) continue;
        else
        {
            done[A[i]] = 1;				// ボールの値毎の済フラグ
            all += com(same[A[i]]);		// そのボールの値を２つ取り出すパターン数を合計
        }
    }

    for(ll i=0; i<N; ++i)
    {
        cout << all - com(same[A[i]]) + com(same[A[i]]-1) << endl;
			// all: 同じ値のボールを取り出す組み合わせ数
			// same[A[i]]:k番目のボールの値を２つ取り出す組み合わせ数
			// same[A[i]]-1:k番目のボールを除外した時に、その値のボールを２つ取り出す組み合わせ数


    }

    return 0;
}


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

int main(){
    long double A,B,H,M; cin >> A >> B >> H >> M;
    const double pi = 3.141592653589793;
    long double rad = pi * 2 * (H/12 + ((M/60)/12) - (M/60));
    double ans = A*A + B*B - 2*A*B*cosl(rad);
    ans = sqrtl(ans);
    cout << fixed;
    cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 4040
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        { 
            int ans;
            int N =int .Parse( Console.ReadLine());//整数
            ans = N*N*N;
            Console.WriteLine(ans);
        }
    }

}

Measured memory_bytes: 11092
S = list(input())

count = 0
ans = 0
flg = False

for word in S:
    if word=="A" or word=="C" or word=="G" or word=="T":
        flg = True
    else:
        flg=False
        count = 0
    
    if flg:
        count += 1
    ans = max(ans,count)

print(ans)

Measured memory_bytes: 61856
//AGC 007-A
#define _USE_MATH_DEFINES

#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <numeric>
#include <string>
#include <map>
#include <sstream>
using namespace std;

int main() {
	long A[100000], B[100000], N, ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++){
		cin >> A[i] >> B[i];
	}
	for (int i = N-1; i >= 0; i--){
		if(A[i] % B[i] != 0){
			ans += B[i] - A[i] % B[i];
		}
		if(i > 0) A[i-1] += ans;
	}
	cout << ans << endl;
}


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

long dp[2][100100];
long inf = 1000000007;

long nCr(long n,long r){
  for(int i = 0;i <= n-r;i++){
    dp[0][i] = 1;
  }
  for(int i = 1;i <= r;i++){
    for(int j = 1;j <= n-r;j++){
      if(i % 2 == 0){
        if(j == 1){
          dp[0][j] = (dp[1][j] + 1) % inf;
        }
        else{
          dp[0][j] = (dp[1][j] + dp[0][j-1]) % inf;
        }
      }
      else{
        if(j == 1){
          dp[1][j] = (dp[0][j] + 1) % inf;
        }
        else{
          dp[1][j] = (dp[0][j] + dp[1][j-1]) % inf;
        }
      }
    }
  }
  if(r % 2 == 0){
    return dp[0][n-r];
  }
  else{
    return dp[1][n-r];
  }
}

int main(){
  long n;
  long m;
  vector<long> r;
  cin >> n >> m;
  for(long i = 2;i*i <= m;i++){
    long c = 0;
    bool yakusu = false;
    while(m % i == 0){
      m /= i;
      c++;
      yakusu = true;
    }
    if(yakusu == true){
      r.push_back(c);
    }
  }
  if(m != 1){
    r.push_back(1);
  }
  long result = 1;
  for(int i = 0;i < r.size();i++){
    result = (result * nCr(n-1+r.at(i),n-1)) % inf;
  }
  cout << result << endl;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int64_t n; cin>>n;
	cout<<n*(n+1)/2-(n/3)*(n/3+1)/2*3-(n/5)*(n/5+1)/2*5+(n/15)*(n/15+1)/2*15<<"\n"s;
}

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>

int main() {
    int n;

    while (std::cin >> n, n) {

        std::vector< double > ss(n);
        for (auto &s: ss) std::cin >> s;

        double m = std::accumulate(ss.begin(), ss.end(), double(0)) / n;
        double alpha = 0;
        for (auto s: ss) {
            alpha += std::pow(s - m, 2);
        }

        alpha = std::sqrt(alpha / n);

        std::cout << std::fixed << std::setprecision(20);
        std::cout << alpha << std::endl;
    }
}



Measured memory_bytes: 3236
INF = 1<<60
n = gets.to_s.to_i
a = gets.to_s.split.map { |v| v.to_i }

dp = Array.new(n) { |i| Array.new(n) { |j| i == j ? 0 : INF } }
cs = a.each_with_object([0]) { |v, b| b << b[-1] + v }

1.upto(n-1) do |j|
  0.upto(n-1-j) do |i|
    lo = i
    hi = i + j
    # pp [lo,hi]
    lo.upto(hi-1) do |mid|
      dp[lo][hi] = [
        dp[lo][hi],
        dp[lo][mid] + dp[mid+1][hi] + cs[hi+1] - cs[lo]
      ].min
    end
  end
end

pp dp[0][-1]


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

long long n,s,cnt=0;

int main()
{
    cin>>n;
    for(int i=int(sqrt(n)) ;i>=1; i--)
    {
        if(n%i==0)
        {
            s=n/i;
            for(; s>0; s/=10)
            	cnt++;
            cout<<cnt<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import numpy as np
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
right = 0
left = 0
ans = 0
for i in range(N):
  right += ((A[i+1:] < A[i]).sum())
  left += ((A[:i] < A[i]).sum())
ans += K*(K+1)//2 % (10**9+7) * right
ans += (K-1)*K//2 % (10**9+7) * left
ans = ans % (10**9+7) 
print(ans)

Measured memory_bytes: 27896