akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(int a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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

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

ll INF = 10000000;
ll mod = 1000000007;//10^9+7


//番号ズレ注意！！
int main() {
    string S;
    cin >> S;
    int N = S.size();
    int ans1 = 0, ans2 = 0;
    if (N % 2 == 0) {
        for (int i = 0; i < N; i += 2) {
            if (S[i] == '1')ans1++;
            if (S[i + 1] == '0')ans1++;
        }
        for (int i = 0; i < N; i += 2) {
            if (S[i] == '0')ans2++;
            if (S[i + 1] == '1')ans2++;
        }
    } else {
        for (int i = 0; i < N - 1; i += 2) {
            if (S[i] == '1')ans1++;
            if (S[i + 1] == '0')ans1++;
        }
        if (S[N - 1] == '1')ans1++;
        for (int i = 0; i < N - 1; i += 2) {
            if (S[i] == '0')ans2++;
            if (S[i + 1] == '1')ans2++;
        }
        if (S[N - 1] == '0')ans2++;
    }
    int ans = min(ans1, ans2);
    printAns(ans);
}

Measured memory_bytes: 512
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
l,r=0,max(a)
while 1<r-l:
 m=(l+r)//2;c=0
 for i in a:c+=math.ceil(i/m)-1
 if c>k:l=m
 else:r=m
print(r)

Measured memory_bytes: 31044
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<long> a(N+1);
  a[0]=2;
  a[1]=1;
  for(int i=2;i<N+1;i++) a[i]=a[i-1]+a[i-2];
  cout<<a[N]<<endl;
}
                 

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


int main(){

	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;


	vector<int>r(a), g(b), h(c);

	priority_queue<int>pqr, pqg;


	for(int i=0; i<a; i++) cin >> r[i];

	for(int i=0; i<b; i++) cin >> g[i];

	for(int i=0; i<c; i++) cin >> h[i];
	

	sort(r.rbegin(), r.rend());	
	sort(g.rbegin(), g.rend());	
	sort(h.rbegin(), h.rend());
	

	for(int i=0; i<x; i++)pqr.push(-r[i]);
	
	for(int i=0; i<y; i++)pqg.push(-g[i]);

	
	for(int i=0; i<c; i++){
		int t = -pqr.top();
		int u = -pqg.top();
		
		if(h[i] >= t or h[i] >= u){
			if(t <= u){
				pqr.pop();
				pqr.push(-h[i]);
			}
			else{
				pqg.pop();
				pqg.push(-h[i]);
			}	
		}
		else break;
	}	


	long long ans = 0;

	while(!pqr.empty()){
		ans += -pqr.top();
		pqr.pop();
	}

	while(!pqg.empty()){
		ans += -pqg.top();
		pqg.pop();
	}


	cout << ans << endl;


	return 0;
} 

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

struct Query {
    ll a, b, c, d;
};

std::istream &operator>>(std::istream &in, Query &o) {
    cin >> o.a >> o.b >> o.c >> o.d;
    o.a--;
    o.b--;
    return in;
}

int main() {
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];

    map<int, int> m;
    rep(i, n) m[i - v[i]]++;

    ll ans = 0;
    rep(i, n) {
        ll now = m[v[i] + i];
        ans += now;
    }
    cout << ans << endl;

}


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

int main () {
  string S;
  cin >> S;
  
  ll result = 0;
  for (ll bit = 0; bit < (1 << S.size() - 1); bit++) {
    int pos = 0;
    for (int i = 0; i < S.size() - 1; i++) {
      if (bit & (1 << i)) { // i番目が1である
        string sub = S.substr(pos, i-pos+1);
        result += stoll(sub);
        pos = i+1;
      }
    }
    string sub = S.substr(pos, S.size());
    result += stoll(sub);
  }
  cout << result;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    li n;
    cin >> n;
    vector<li> as(n), bs(n);

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

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

    vector<pair<li, li>> bas;
    for (int i = 0; i < n; ++i) {
        bas.emplace_back(bs[i], as[i]);
    }
    sort(bas.begin(), bas.end());
    for (int i = 0; i < n; ++i) {
        as[i] = bas[i].second;
        bs[i] = bas[i].first;
    }

    vector<li> cs = as, ds = bs;
    sort(cs.begin(), cs.end());
    sort(ds.begin(), ds.end());

    for (int i = 0; i < n; ++i) {
        if (ds[i] < cs[i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    for (int i = 1; i < n; ++i) {
        if (cs[i] <= ds[i - 1]) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    vector<pair<li, li>> ais;
    for (int i = 0; i < n; ++i) {
        ais.emplace_back(as[i], i);
    }
    sort(ais.begin(), ais.end());
    li pos = ais[0].second, size = 1;
    while (pos != 0) {
        size += 1;
        pos = ais[pos].second;
    }

    cout << ((size < n) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 8048
n = int(input())
chars="-abcdefghijklmnopqrstuvwxyz"

n_rem = n
res = ""

while True:
    x = n_rem % 26
    if x == 0:
        x = 26
    res += chars[x]
    n_rem -= x
    if n_rem == 0:
        break
    n_rem //=26

print(res[::-1])

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}

int H,W,K;
char c[810][810];
int dis[810][810];
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
signed main() {
	cin>>H>>W>>K;
	queue<P>que;
	rep(i,H)rep(j,W){
		cin>>c[i][j];
		dis[i][j]=inf;
		if(c[i][j]=='S'){
			que.push({0,i*W+j});
			dis[i][j]=0;
		}
	}
	while(!que.empty()){
		P p=que.front();que.pop();
		if(dis[p.second/W][p.second%W]<p.first)continue;
		rep(i,4){
			int nx=p.second/W+dx[i],ny=p.second%W+dy[i];
			if(nx<0||ny<0||nx>=H||ny>=W||c[nx][ny]=='#')continue;
			if(dis[nx][ny]==inf){
				dis[nx][ny]=dis[p.second/W][p.second%W]+1;
				if(dis[nx][ny]!=K){
					que.push({dis[nx][ny],nx*W+ny});
				}
			}
		}
	}
	int ans=inf;
	rep(i,H)rep(j,W){
		if(dis[i][j]==inf)continue;
		chmin(ans,1+(i+K-1)/K);
		chmin(ans,1+(H-i-1+K-1)/K);
		chmin(ans,1+(j+K-1)/K);
		chmin(ans,1+(W-j-1+K-1)/K);
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
#define in(s) ll s; cin>>s
#define pr(r) cout<<r<<endl
#define prr(m,n) cout<<m<<" "<<n<<endl
#define prarr(a,i,n) fab(j,i,n) cout<<a[j]<<" "
#define wh(t) ll t; cin>>t; while(t--)
#define sz(u) u.size()
#define all(v) v.begin(),v.end()
#define arr(a,n) ll a[n]; fab(i,0,n) cin>>a[i]
#define showdp(d,n,m) fab(i,0,n){ fab(j,0,m) cout<<d[i][j]<<" "; cout<<endl; }
#define prs(u) cout<<u<<" ";
#define fab(i,a,b) for(ll i=a;i<b;i++)
#define fba(i,b,a) for(ll i=b;i>=a;i--)
#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MX 1000000007
#define MAX 10000007
#define endl "\n"
#define ll long long int
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define pl pair<ll,ll>
#define mxe(x,n) *max_element(x,x+n)
#define mne(x,n) *min_element(x,x+n)
#define mp make_pair
#define pb push_back
#define fs first
#define sd second
#define fr front()
#define bk back()
#define rr return
#define N 3005

bool rsort1(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.first > b.first);}
bool rsort2(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.second>b.second);}
bool sort2(const pair<ll,ll> &a,const pair<ll,ll> &b){ return (a.second < b.second);}

ll dp[N][N],vis[N],h,w;
string s[1005];

int main()
{
	sup; 
	cin>>h>>w;
	fab(i,0,h)
	cin>>s[i];
	fab(i,0,h)
	    fab(j,0,w)
	    {
	        if(i==0 && j==0)
	        dp[i+1][j+1]=1;
	        else if(s[i][j]=='#')
	        continue;
	        else
	        dp[i+1][j+1]=((dp[i][j+1]%MX)+(dp[i+1][j]%MX))%MX;
	    }
	pr(dp[h][w]%MX);
    return 0;
}


Measured memory_bytes: 24832
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main{
	static Scanner s=new Scanner(System.in);

	void solve(){
		int a=gInt(),b=gInt();
		long n=b-a;
		System.out.println(n*(n-1)/2-a);
	}

	public static void main(String[] A){
		new Main().solve();
	}

	static int gInt(){
		return Integer.parseInt(s.next());
	}
	static long gLong(){
		return Long.parseLong(s.next());
	}
	static double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,Main::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,Main::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,Main::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(Main::gInt).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}
class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}
class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}

	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}

}

Measured memory_bytes: 21844
n, t = map(int,raw_input().split())

arr = [0 for i in range(t+1)]

for i in range(n):
	start, end = map(int,raw_input().split())
	arr[start] += 1
	arr[end] -= 1

cs = [arr[0] for i in range(t+1)]

for i in range(1,t+1):
	cs[i] = cs[i-1] + arr[i]

print max(cs)


Measured memory_bytes: 11600
#include<iostream>

using namespace std;

int main(){

int n;
int a[10000];
long long int ans;

while(true){

cin >> n;

if(n == 0) break;

for(int i = 0; i < n; i++){

cin >> a[i];

}

ans = -1000000000;
long long int sum;

for(int i = 0; i < n; i++){
sum = 0;
for(int j = i; j < n; j++){
sum += a[j];
if(sum > ans){
ans = sum;
}
}
}

cout << ans << endl;

}

return 0;

}

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

int main()
{
    ll n;
    cin>>n;
    ll a[n][2],p=0,f=0,i;
    for(i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1];
        if(a[i][0]==a[i][1])
        p++;
        else
        p=0;
        if(p==3)
        {
            f=1;
        }
    }
    if(f==1)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
    
}

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

int main(){
	map<int64_t, int> m;
	int n;
	cin >> n;
	while(n--){
		int64_t a;
		cin >> a;
		m[a]++;
	}
	vector<int64_t> v;
	for(auto p:m) for(int i = 0; i < p.second / 2; i++) v.emplace_back(p.first);
	sort(v.rbegin(), v.rend());
	if(v.size() < 2){
		cout << 0 << endl;
		return 0;
	}
	cout << v[0] * v[1] << endl;
}

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

#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

//?´?????????????????§????
//Union-Find??¨
struct UnionFind {
	vector<int> p; //parent
	int sz; //size ???????????°
	vector<int> mi;
	UnionFind(int n) :p(n, -1), sz(n), mi(n) {}
	bool unite(int x, int y) {
		int c = min(mi[x], mi[y]);
		x = root(x); y = root(y);
		if (x == y) return false;
		if (size(x) < size(y)) swap(x, y);
		p[x] += p[y]; p[y] = x; sz--;
		mi[x] = min({ mi[x],mi[y], c });
		dump(x); dump(c);
		return true;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); }
	//?????????????´???°
	int size(int x) { return -p[root(x)]; }
	int solve() {
		int ret = 0;
		rep(i, 0, mi.size())
			ret += mi[root(i)];
		return ret;
	}
};

signed main() {
	int N; cin >> N;
	UnionFind UF(N);
	map<string, int> mp;
	rep(i, 0, N) {
		string a; int x; cin >> a >> x;
		mp[a] = i;
		UF.mi[i] = x;
	}
	int M; cin >> M;
	rep(i, 0, M) {
		string s, t; cin >> s >> t;
		UF.unite(mp[s], mp[t]);
	}
	cout << UF.solve() << endl;
	dumpc(UF.p);
	dumpc(UF.mi);
	return 0;
}

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

N = len(S)
M = len(T)
dp = [[0 for _ in range(N+1)] for _ in range(M+1)]

for i in range(1, M+1):
    for j in range(1, N+1):
        if S[j-1]==T[i-1]:
            dp[i][j] += dp[i-1][j-1]+1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

i, j = M, N
lcs = ""
while i>0 and j>0:
    if T[i-1]==S[j-1]:
        lcs += T[i-1]
        i -= 1
        j -= 1
    else:
        if dp[i-1][j]>dp[i][j-1]:
            i -= 1
        else:
            j -= 1
print(lcs[::-1])

Measured memory_bytes: 120540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    ll a,b; cin >> a >> b;
    if(a%b == 0) cout << -1 << endl;
    else cout << a << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<map>
#include<stack>
using namespace std;
int dx[] = { -1,0,0,1,-1,-1,1,1,0 };
int dy[] = { 0,1,-1,0,1,-1,1,-1,0 };
/*
int main()
{
	int r, c;
	cin >> r >> c;
	int sy, sx, gy, gx;
	vector<vector<char>>field(r,vector<char>(c));
	sy--, sx--, gy--, gx--;
	for (int i = 0; i < r; i++)
	{
		for (int j = 0; j < c; j++)
		{
			cin >> field[i][j];
		}
	}
	queue<pair<int,int>>q;
	q.push({ sx,sy });
	vector<vector<int>>d(c, vector<int> (r, -1));
	d[sx][sy] = 0;

	while (!q.empty())
	{
		pair<int, int>p = q.front;
		q.pop();
		for (int i = 0; i < 4; i++)
		{
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (nx < 0 || ny < 0 || nx >= c || ny >= r || d[nx][ny] != -1 || field[nx][ny] == '#')continue;
			q.push({ nx,ny });
			d[nx][ny] = d[p.first][p.second] + 1;
		}
	}

	cout << d[gx][gy] << endl;
}*/


int main() 
{
	int n;
	cin >> n;
	int ans = 0;
	int x;
	for (int i = 1; i < n; i++)
	{


		for (int j = 1; j < n; j++)
		{
			if (i*j>n)
			{
				break;
			}


			
			if (n - (i*j) > 0)
			{
				ans += 1;
			}
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 3600
while True:
    n, x = map(int, input().split())
    
    if n==x==0:
        break
    
    l = [i for i in range(1, n+1)]
    count = 0
    
    for i in range(n-2):
        for j in range(i+1, n-1):
            for k in range(j+1, n):
                if l[i]+l[j]+l[k]==x:
                    count+=1
                
    print(count)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
 
const ll N = 100005;
const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);
 
ll n, a;
ll freq[N];
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
#ifndef ONLINE_JUDGE
    // freopen("in.txt", "r", stdin);
#endif
    cin >> n;
    ll ans = 0;
    vector<ll> odd;
    for(int i = 0; i < n; i++)
    {
        cin >> a;
        freq[i] = a;
        ans += a / 2;
        if(a & 1)
            odd.push_back(i);
    }
    int m = odd.size();
    for(int i = 0; i < m - 1; i++)
    {
        bool ok = true;
        for(int j = odd[i] + 1; j < odd[i + 1]; j++)
            if(freq[j] < 2)
                ok = false;
        if(ok)
            ans++, i++;
    }
    cout << ans << endl;
}


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

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,d,ans=0;
    cin>>n>>d;
    vector<vector<int>> v(n);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < d; j++)
        {
            int x;
            cin>>x;
            v[i].push_back(x);
        }
    }
    
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < i; j++)
        {
            double dist = 0;
            for (int k = 0; k < d; k++)
            {
                dist += pow(v[i][k] - v[j][k], 2); 
            }
            dist = sqrt(dist);
            if(dist == (int)(dist))
            {
                ans++;
            }
        }
        
    }
    

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        String S = sc.next();
        String T = sc.next();
        System.out.println(solve(S, T));
    }

    private static String solve(String S, String T) {
        for (int i = S.length()-1; i >= 0; i--) {
            if( isOk(S, T, i) ) {
                return calc(S, T, i);
            }
        }
        return "UNRESTORABLE";
    }

    private static boolean isOk(String S, String T, int i) {
        String sub = S.substring(i, Math.min(S.length(), i + T.length()));
        if( sub.length() != T.length() ) return false;
        for (int j = 0; j < sub.length(); j++) {
            if (sub.charAt(j) != '?' && T.charAt(j) != sub.charAt(j)) {
                return false;
            }
        }
        return true;
    }

    private static String calc(String S, String T, int i) {
        String prev = S.substring(0, i);
        String post = S.substring(i + T.length());

        return prev.replace('?', 'a') + T + post.replace('?', 'a');
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;cin>>S;
  int n=S.size(),countlow=0,countC=0;
  if(S[0]!='A')cout<<"WA"<<endl;
  else{
    for(int i=1;i<n;i++){
      if('a'<=S[i] && S[i]<='z')countlow++;
      if(2<=i && i<=n-2 && S[i]=='C')countC++;
    }
    if(countlow==n-2 and countC==1)cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;
constexpr ll MOD = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<int> p(n);
	
	for(int i = 0; i < n; ++i) {
		cin >> p[i];
	}
	
	int x = INT_MAX;
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		if( x >= p[i] ) ans++;
		
		x = min(x, p[i]);
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int main(){
  int n, l;
  cin >> n >> l;
  vector<string> v(n);
  rep(i,n) cin >> v[i];

  sort(v.begin(), v.end());
  string ans;
  rep(i, n){
    ans += v[i];
  }

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

Measured memory_bytes: 3588
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x&&x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS*max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x*x + y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;


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

	bool ok = false;
	for (int i=0;i<SZ(s)-1;i++)
	{
		if (s.substr(i, 2) == "AC")
		{
			ok = true;

		}

	}

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



Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(void)
{
    int N, X;
    cin >> N >> X;

    int donuts = 0;
    int mi_min = 1000;
    for(int i = 0; i < N; ++i)
    {
        int mi;
        cin >> mi;
        X -= mi;
        donuts++;
        if(mi < mi_min)
            mi_min = mi;
    }

    cout << (donuts + X / mi_min) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long
#define yokuwaruprime (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int n,m,ans;
  cin>>n>>m;
  ans=pow(2,m)*100*(n+18*m);
  cout<<ans<<endl;
}

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

#define   offcin        ios::sync_with_stdio(false)
using namespace std;

const int maxn = 1e4 + 5;

string s[maxn], a[maxn], b[maxn];

int main(int argc, const char * argv[]) {
    offcin;
    int N;
    cin>>N;
    for (int i = 1; i <= N; i ++) {
        cin>>s[i];
        long len = s[i].length();
        for (int j = 0; j < len; j ++) {
            if (s[i][j] == '?') a[i] += 'a', b[i] += 'z';
            else a[i] += s[i][j], b[i] += s[i][j];
        }
    }
    string t; cin>>t;
//    a[N + 1] = b[N + 1] = t;
    sort(a + 1, a + N + 1);
    sort(b + 1, b + N + 1);
    
    int l1 = 1, l2 = 1;
    while (l1 <= N && a[l1] < t) l1 ++;
    while (l2 <= N && b[l2] <= t) l2 ++;
    
    if (l1 > l2) swap(l1, l2);
    
    for (long i = l1; i < l2; i ++) cout<<i<<" ";
    cout<<l2<<endl;
    return 0;
}


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

using namespace std;

int main(){
	string s;
	int ans=0;
	cin>>s;

	for(int i=1;i<s.size()-1;i++){
		ans++;
	}
	cout<<s[0]<<ans<<s[s.size()-1]<<endl;
	return (0);
}


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

int main() {
  int X, Y; cin >> X >> Y;
  if (Y % 2 == 0 && (X*2 <= Y && Y <= X*4)) {
    coe("Yes")
  } else coe("No")
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> A(N);

    REP(i, N){
        cin >> A[i];
    }

    sort(A.begin(), A.end());

    ll big = A[N-1];

    ll middle = INF;
    ll b = 0;
    double harf = double(big/2.0);

    REP(i, N){
        if(abs(A[i] - harf) < middle){
            middle = abs(A[i] - harf);
            b = A[i];
        }
    }
    cout << big << " " << b << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#define ll long long
using namespace std;

int n,m;
int cnt;

int pre[100005];
int a[100005];

inline int read(){
	int s=0,w=1;
	char ch = getchar();
	while(ch < '0' || ch > '9'){
		if(ch == '-')w = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9'){
		s = s*10+ch-'0';
		ch = getchar();
	}
	return w*s;
}

int main(){
	scanf("%d%d",&n,&m);
	int l,r;
	for(int i = 1;i <= m;++i){
		l = read();
		r = read();
		pre[l]++;
		pre[r+1]--;
	}
	for(int i = 1;i <= n;++i){
		a[i] = a[i-1]+pre[i];
		if(a[i] == m)cnt++;
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 1024
#include"bits/stdc++.h"
using namespace std;
typedef long long LL;
const int N=1e6;
int mp[2000][50];
int main()
{
	int n=38;
	int cnt=0;
	printf("%d %d\n",n*n-n+1,n);
	mp[0][0]=++cnt;
	for(int i=0;i<n;i++)
		for(int j=1;j<n;j++){
			mp[i][j]=++cnt;
		}

	for(int i=0;i<n;i++)mp[i][0]=1;
	
	for(int j=2;j<=n;j++){
		int d=j-2;
		for(int i=1;i<n;i++){
			int y=i,x=(j-1)*(n-1)+i;
			mp[x][0]=j;
			
			for(int k=1;k<n;k++){
				int z=y%(n-1);
				if(z==0)z=n-1;
				mp[x][k]=mp[k][z];
				y+=d;
			}	
		}
	}
	
	for(int i=0;i<n*n-n+1;i++){
		for(int j=0;j<n-1;j++){
			printf("%d ",mp[i][j]);
		}
		printf("%d\n",mp[i][n-1]);
	}
		
	
}

Measured memory_bytes: 768
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <cstring>
using namespace std;

using int64 = long long;

#define repeat(i, n) for (auto i = decltype(n)(); (i) < (n); (i)++)

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

  int ab, bc, ca;
  cin >> ab >> bc >> ca;

  cout << ab * bc / 2 << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" : "<<x<<'\n';
#define int long long
#define PI 3.141592653589793238

void solve()
{
	int a; cin>>a;
	string s; cin>>s;
	string before,after;
	bool flag = 0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='.'){
			flag=1;
			continue;
		}
		if(flag){
			after+=s[i];
		}
		else{
			before+=s[i];
		}
	}
	int b = stoi(before);
	int c = stoi(after);
	cout<<(a*(b*100+c))/100<<'\n';
}

main()
{
	int t=1;
	while(t--)
		solve();
}

Measured memory_bytes: 3572
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;

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

int main() {

    ll X,A;
    cin >> X >> A;
    if(X<A) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}


Measured memory_bytes: 256
use std::f64::consts;
use std::io::{self, Write};

fn main() {
    let mut stdout = io::stdout();
    let stdin = io::stdin();
    let radius = {
        let mut input = String::new();
        stdin.read_line(&mut input).expect("failed to read line");
        match input.trim().parse::<f64>() {
            Ok(r) => r,
            Err(e) => {
                eprintln!("error: {:?}", e);
                std::process::exit(1);
            }
        }
    };
    println!("{}", 2.0 * consts::PI * radius);
    stdout.flush().unwrap();
}

Measured memory_bytes: 2232
T = list(map(int, input().split()))
X = T[0]
Y = T[1]

cnt = 0

for i in range(X+1):
  TT = 2*i+4*(X-i)
  if TT == Y:
    cnt += 1
  else:
    pass

if cnt >0:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 9084
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

using VI = vector <int>;
using VVI = vector < VI >;


class UnionAndFind {
    public:
    VI groupSize;
    VI groupParent;

    UnionAndFind (int gSize) {
        groupSize = vector<int> (gSize, 1);
        groupParent = vector<int> (gSize, -1);
    }

    int findGroup(int n) {
        if (groupParent[n] == -1) {
            return n;
        }
        return groupParent[n] = findGroup(groupParent[n]);
    }

    void unionGroup(int x, int y) {
        y = findGroup(y);
        x = findGroup(x);

        if (x == y) {
            return ;
        }

        if (groupSize[x] > groupSize[y]) {
            swap(x, y);
        }

        groupSize[y] += groupSize[x];
        groupParent[x] = y;
    }
};

int main() {
    int N;
    int M;
    cin >> N >> M;

    UnionAndFind group(N);

    for (int i = 0; i < M; ++i) {
        int f;
        int t;
        cin >> f >> t;

        --f;
        --t;
        group.unionGroup(f, t);
    }

    int ans = 0;

    for (int i = 0; i < N; ++i) {
        ans = max(ans, group.groupSize[i]);
    }

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

Measured memory_bytes: 4844
N = int(input())
H = list(map(int, input().split()))

ans = True

for i in range(1, N) :
    if H[i - 1] <= H[i] :
        continue
    if H[i - 1] <= H[i] + 1 :
        H[i] += 1
        continue
    ans = False

if ans :
    print('Yes')
else :
    print('No')


Measured memory_bytes: 15020
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	string a,b,c;
	cin >> a >> b >> c;
	if(a.at(a.size()-1)==b.at(0) && b.at(b.size()-1)==c.at(0)){
		cout << "YES" << endl;
    }else{
		cout << "NO" << endl;
    }
  
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
using namespace std;

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

int f(int k){
	if(k==0) return 5;
	else if(k==1) return 0;
	else return 2;
}

ll x[200001];
ll x2[200001];

int main(){
	int n,X; cin>>n>>X;
	FOR(i,0,n) cin>>x[i];
	x2[0]=x[0];
	FOR(i,1,n) x2[i]=x2[i-1]+x[i];

	ll m=1e18;
	FOR(k,1,n+1){
		int t=0;
		ll ans=0;
		while(n-1-t*k>=0){
			ans+=f(t)*x2[n-1-t*k];
			if(ans>m) break;
			t++;
		}
		if(ans>m) continue;
		ans+=(ll)X*(n+k);
		m=min(ans,m);
	}
	co(m);
}


Measured memory_bytes: 3328
class Dice():
    
    def __init__(self,d1,d2,d3,d4,d5,d6):
        self.d1=d1
        self.d2=d2
        self.d3=d3
        self.d4=d4
        self.d5=d5
        self.d6=d6
    
    def roll(self,c):
        if c=='N':
            self.d1,self.d5,self.d6,self.d2=self.d2,self.d1,self.d5,self.d6
        elif c=='S':
            self.d1,self.d5,self.d6,self.d2=self.d5,self.d6,self.d2,self.d1
        elif c=='E':
            self.d1,self.d3,self.d6,self.d4=self.d4,self.d1,self.d3,self.d6
        else:
            self.d1,self.d3,self.d6,self.d4=self.d3,self.d6,self.d4,self.d1
    
a,b,c,d,e,f=map(int,input().split())
D=Dice(a,b,c,d,e,f)
n=int(input())
for i in range(n):
    up,forward=map(int,input().split())
    if up==D.d3:
        D.roll('W')
    elif up==D.d6:
        D.roll('E')
        D.roll('E')
    elif up==D.d4:
        D.roll('E')
    elif up==D.d2:
        D.roll('N')
    elif up==D.d5:
        D.roll('S')
    if forward==D.d2:
        print(D.d3)
    elif forward==D.d3:
        print(D.d5)
    elif forward==D.d5:
        print(D.d4)
    else:
        print(D.d2)


Measured memory_bytes: 5608
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> A;
    for (int64_t i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A.push_back(t);
    }

    int64_t count = 0;
    for (int64_t i = 0; i < N - 1; ++i) {
        // 自分と右隣りでペア作る
        count += A[i] / 2;

        bool remain = A[i] & 1;

        if (remain && A[i+1] > 0) {
            count++;
            A[i+1]--;
        }
    }

    count += A[N-1] / 2;

    std::cout << count << std::endl;

    /*
      当初考えたやり方だと、
      1 6 1
      というようなパターンに対応できない。
    */

    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL; 

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N;
    cin >> N;
    int max_digit = to_string(N).size(); //桁数
    int arr[3] = {3,5,7};
    LL seed = LL(pow(3,max_digit));
    int ans = 0;

    FOR(digit,1,max_digit+1)
    {
        FOR(i,0,LL(pow(3,digit)))
        {
            int num = i;
            int sum = 0;
            bitset<3> check;
            REP(j,digit)
            {
                sum = sum * 10 + arr[num % 3];
                check[num % 3] = true;
                num /= 3;
            }
            if(check.all() && sum <= N) {
                dump(sum)
                ans++;
            }
        }
    }
    cout << ans << endl;

}


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

using ll = long long;

int div_up(int a, int b)
{
    return (a + b - 1) / b;
}

int f(int A, int B)
{
    int kagen1 = div_up(25 * A, 2);
    int jogen1 = (25 * A + 24) / 2;
    int kagen2 = 10 * B;
    int jogen2 = 10 * B + 9;

    if (jogen1 < kagen2 || jogen2 < kagen1)
    {
        return -1;
    }
    else
    {
        return std::max(kagen1, kagen2);
    }
}

int main()
{
    int A, B;
    std::cin >> A >> B;
    int ans = f(A, B);
    std::cout << ans;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll from;
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RES(a, n) (a).resize(n)
#define VLCIN(a, n) REP(i,n){cin >> a[i];}
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = (ll)pow(10,7);
/****** define constant end ********/
/****** define variable start ******/
ll n, m;
vl u, v;
ll s, t;
vll Gans;
/******* define variable end *******/
int solve() {
	cin >> n >> m;
	RES(Gans, 3 * n);
	RES(u, m);
	RES(v, m);
	REP(i, m){
		cin >> u[i] >> v[i];
		Gans[u[i]-1].push_back(n + v[i]-1);
		Gans[n + u[i]-1].push_back(n+n+v[i]-1);
		Gans[n+n+u[i]-1].push_back(v[i]-1);
	}
	cin >> s >> t;
	  // BFS のためのデータ構造
    vector<ll> dist(3 * n, -1); // 全頂点を「未訪問」に初期化
    queue<ll> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[s-1] = 0;
    que.push(s-1); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        ll v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (ll nv : Gans[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
	if(dist[t-1] == -1){
		cout << -1 << endl;
		return 0;
	}
	cout << dist[t-1]/3 << endl;
	return 0;
}
int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 23536
#include <cstdio>
#include <cstring>

using namespace std;

const int N = 100'009;

char s[N];
int st[N];

int main() {
  scanf("%s", s);
  int sz = 0;
  for (int i = 0; s[i]; ++i) {
    int t = (int)(s[i] - '0');
    if (sz > 0 && st[sz - 1] != t) {
      --sz;
    } else {
      st[sz++] = t;
    }
  }
  printf("%d\n", (int)strlen(s) - sz);
}


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

int main() {
	string s;cin>>s;
	if(s[0]=='S'){
		cout<<"Cloudy"<<endl;
	}else if(s[0]=='C'){
		cout<<"Rainy"<<endl;
	}else{
		cout<<"Sunny"<<endl;
	}
	return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N;

int solve(int a , int k){
	if(a<k) return 0;
	if(a%k==0) return a/k;
	int d = a/k + 1;
	d = (a%k+d-1)/d*d;
	return solve(a-d,k);
}

int main(){
	cin >> N;
	int g = 0;
	repp(i,0,N){
		int A,K;
		cin >> A >> K;
		g ^= solve(A,K);
	}
	cout << (g==0?"Aoki":"Takahashi") << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = str(input())
l = []
for i in range(n):
    if s[i] == "I":
        l.append(1)
    elif s[i] == "D":
        l.append(-1)
for i in range(1,n):
    l[i] = l[i-1] + l[i]
print(max(max(l),0))

Measured memory_bytes: 3060
def B():
    S = input()
    minA = 1000000000000000
    for i in range(3, len(S) + 1):
        if abs(int(S[i - 3:i]) - 753) < minA:
            minA = abs(int(S[i - 3:i]) - 753)
    print(minA)
B()


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		int Q = sc.nextInt();
		int[] A = new int[Q];
		int[] Point = new int[N];
		
		for(int i=0;i<Q;i++) {
			A[i] = sc.nextInt();
		}
		
		for(int i=0;i<N;i++) {
			Point[i] += K -Q;
		}
		
		for(int i =0;i<Q;i++) {
			int correct = A[i] - 1;
			Point[correct] += 1;
		}
		
		for(int i:Point) {
			if(i>0) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}
		
		sc.close();	
	}
}

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

int main(){
    int a, b;
    cin >> a >> b;

    //小数の消費税は切り捨て
    for(int i = 0; i <= 1500; i++){
        int tmpa, tmpb;
        tmpa = i * 0.08;
        tmpb = i * 0.1;
        if(tmpa == a and tmpb == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int const MAX_N = 210;
int const MAX_R = 1010;
int const INF = 1<<29;
ll dpl[MAX_N][MAX_N];
ll dps[MAX_N][MAX_N];
ll dp[MAX_R][MAX_N];
ll N, M, R;
int z[MAX_R];

int main() {
     
  while(cin >> N >> M && (N|M)) {
    for(int i=0; i<N; i++) {
      for(int j=i+1; j<N; j++) {
        dpl[i][j] = dpl[j][i] = INF;
        dps[i][j] = dps[j][i] = INF;
      }
      dpl[i][i] = 0;
      dps[i][i] = 0;
    }
     
    for(int i=0; i<M; i++) {
      int x, y, c; char ls;
      cin >> x >> y >> c >> ls; x--, y--;
      if(ls == 'L') {
        dpl[x][y] = dpl[y][x] = c;
      }
      else {
        dps[x][y] = dps[y][x] = c;
      }
    }
     
    cin >> R;
    for(int i=0; i<R; i++) {
      cin >> z[i]; z[i] --;
    }
     
    for(int k=0; k<N; k++) {
      for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++) {
          dpl[i][j] = min(dpl[i][j], dpl[i][k]+dpl[k][j]);
          dps[i][j] = min(dps[i][j], dps[i][k]+dps[k][j]);
        }
      }
    }
 
    fill(dp[0], dp[0]+MAX_R*MAX_N, INF);
    dp[0][z[0]] = 0;
    for(int i=1; i<R; i++) {
      for(int s=0; s<N; s++)
        for(int t=0; t<N; t++) {
          dp[i][t] = min(dp[i][t], dp[i-1][s] + dpl[z[i-1]][s] + dps[s][t] + dpl[t][z[i]]);
          dp[i][t] = min(dp[i][t], dp[i-1][t] + dpl[z[i-1]][z[i]]);
        }
    }
          
    cout << *min_element(dp[R-1], dp[R]) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3484
using System;
using System.Collections.Generic;

namespace program{

	class workspace{

		static void Main(){
			string Num1 = Console.ReadLine();
			string Num2 = Console.ReadLine();

			if(Num1.Length > Num2.Length){
				Console.WriteLine("GREATER");
				return;
			}else if(Num2.Length > Num1.Length){
				Console.WriteLine("LESS");
				return;
			}

			for(int i = 0; i < Num1.Length; i++){
				if(Num1[i] > Num2[i]){
					Console.WriteLine("GREATER");
					return;
				}else if(Num2[i] > Num1[i]){
					Console.WriteLine("LESS");
					return;
				}
			}

			Console.WriteLine("EQUAL");

		}

	}

}

Measured memory_bytes: 11092
#include <stdio.h>

#define inf 1000000000

struct company_info{
	int rail[100][100];
	int p;
	int dst[51];
	int cost[20001];
};

int n, m, c, s, g;
struct company_info company[20];
int i, j, k, l;
int x, y, d, ci;
int r;
int dp[100][100];

int main(){
	while(1){
		scanf("%d %d %d %d %d", &n, &m, &c, &s, &g);
		if(n==0) break;

		s--; g--;

		for(k=0; k<c; k++){
			for(i=0; i<n; i++){
				for(j=0; j<n; j++){
					if(i==j){
						company[k].rail[i][j] = 0;
						dp[i][j] = 0;
					}else{
						company[k].rail[i][j] = inf;
						dp[i][j] = inf;
					}
				}
			}
		}

		for(i=0; i<m; i++){
			scanf("%d %d %d %d", &x, &y, &d, &ci);
			x--; y--; ci--;
			if(company[ci].rail[x][y]>d){
				company[ci].rail[x][y] = company[ci].rail[y][x] = d;
			}
		}

		for(i=0; i<c; i++){
			scanf("%d", &(company[i].p));
		}

		for(i=0; i<c; i++){
			for(j=1; j<company[i].p; j++){
				scanf("%d", &(company[i].dst[j]));
			}
			company[i].dst[j] = 20000;
			k = 1;
			company[i].cost[0] = 0;
			for(j=1; j<=company[i].p; j++){
				scanf("%d", &r);
				for(k; k<=company[i].dst[j]; k++){
					company[i].cost[k] = company[i].cost[k-1] + r;
				}
			}
		}

		for(l=0; l<c; l++){
			for(k=0; k<n; k++){
				for(i=0; i<n; i++){
					for(j=0; j<n; j++){
						if(company[l].rail[i][j]>company[l].rail[i][k] + company[l].rail[k][j]){
							company[l].rail[i][j] = company[l].rail[i][k] + company[l].rail[k][j];
						}
					}
				}
			}
			for(i=0; i<n; i++){
				for(j=0; j<n; j++){
					if(company[l].rail[i][j]!=inf){
						company[l].rail[i][j] = company[l].cost[company[l].rail[i][j]];
						if(dp[i][j]>company[l].rail[i][j]){
							dp[i][j] = company[l].rail[i][j];
						}
					}
				}
			}
		}

		for(k=0; k<n; k++){
			for(i=0; i<n; i++){
				for(j=0; j<n; j++){
					if(dp[i][j]>dp[i][k] + dp[k][j]){
						dp[i][j] = dp[i][k] + dp[k][j];
					}
				}
			}
		}
		if(dp[s][g]!=inf){
			printf("%d\n", dp[s][g]);
		}else{
			printf("-1\n");
		}
	}

	return 0;
}

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

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

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

  int n, m;
  cin >> n >> m;
  cout << (n - 1) * (m - 1) << endl;
  return 0;
}


Measured memory_bytes: 256