akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
    int t;
    cin >> t;
    vector<ll> numbers(t);
    vector<ll> cumul(t);
    vector<ll> diff(t);
    for (int i = 0;i < t;i++) {
        cin >> numbers[i];
    }
    ll oper,sum1 = 0,sum2 = 0;
    for (int i = 0;i < t;i++) {
        sum1 += numbers[i];
        cumul[i] = sum1;
    }
    for (int i = 0;i < t;i++) {
        ll p = sum1 - cumul[i];
        ll q = sum1 - p;
        diff[i] = abs(p - q);
    }
    ll min1 = diff[0];
    for (int i = 1;i < t;i++) {
        min1 = min(diff[i],min1);
    }
    cout << min1 << "\n";
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#define llint long long
#define inf 1e18
#define mod 998244353
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)

using namespace std;
typedef pair<llint, llint> P;

string s, t;
string a[105];
llint beki[1005];
string ans;

string x, y;
vector<llint> vec, vec2;

llint gethash(string &s)
{
	llint hash = 0;
	for(int j = 0; j < 1000; j++){
		if(s[j] == '1') hash ^= beki[j];
	}
	return hash;
}

void get(string &s, vector<llint> &vec)
{
	for(int i = 0; i < 100; i++){
		llint h = 0;
		for(int j = 0; j < 30; j++){
			llint c = s[i*30+j]-'0';
			h |= c<<j;
		}
		vec.push_back(h);
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	beki[0] = 1;
	for(int i = 1; i < 1005; i++) beki[i] = beki[i-1] * 2 % mod;
	
	cin >> s;
	if(s == "Alice" || s == "Bob"){
		for(int i = 1; i <= 100; i++) cin >> a[i];
		
		for(int i = 1; i <= 100; i++){
			llint hash = gethash(a[i]);
			for(int j = 0; j < 30; j++){
				ans += (char)(((hash >> j)&1) + '0');
			}
		}
		cout << ans << endl;
		return 0;
	}
	else{
		cin >> x >> y;
		get(x, vec), get(y, vec2);
		
		for(int i = 1; i <= 100; i++){
		cin >> t;
			
			llint hash = gethash(t);
			for(int j = 0; j < vec.size(); j++){
				for(int k = 0; k < vec2.size(); k++){
					if((vec[j]^vec2[k]^hash) == 0){
						cout << j+1 << " " << k+1 << endl;
						goto end;
					}
				}
			}
			end:;
		}
	}
	
	return 0;
}


Measured memory_bytes: 3728
import numpy as np# your code goes here
def eucrid(a, b):
	if (a > b):
		buf = a
		a = b
		b = buf
	if (b % a == 0):
		return a
	else:
		return eucrid(b%a, a)
		
def main():
	buf = input().split()
	s = input()
	t = input()
	n = len(s)
	m = len(t)
	
	big = n*m//eucrid(n, m)
	flag = big
	"""
	for i in range(big):
		if (i%(big//n) == 0 and i%(big//m) == 0):
			#print(i, n, m)
			#print((i+1)//(big//n), (i+1)//(big//m))
			if(s[(i+1)//(big//n)] != t[(i+1)//(big//m)]):
				flag = -1
	"""			
	for i in range(n):
		if((i*(big//n))%(big//m) == 0):
			if(s[i] != t[(i*(big//n))//(big//m)]):
				flag = -1

	print(flag)
	#print(s, t, n, m)
	
	
main()

Measured memory_bytes: 12712
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,m;
  cin>>n>>m;
  set<int>  G[n+1];
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    G[a].insert(b);
    G[b].insert(a);
  }
  for(int i=2;i<n;i++){
    if(G[1].count(i)&&G[n].count(i)){
      cout<<"POSSIBLE"<<endl;
      return 0;
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

void solve(){
    ll a,b,c;
    cin >> a >> b >> c;

    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
        cout << 0 << endl;
        return;
    }

    cout << min(min(a*b, b*c),c*a) << endl;
    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
import sys
import bisect


def main():
    n, K, L, R = map(int, sys.stdin.readline().split())
    a = tuple(map(int, sys.stdin.readline().split()))
    m = n//2
    ls = [[] for _ in range(m+1)]
    for i in range(1 << m):
        ls[bin(i).count("1")].append(sum([a[j] for j in range(m) if i >> j & 1]))
    for i in range(m+1):
        ls[i].sort()
    ans = 0
    for i in range(1 << n-m):
        cnt = bin(i).count("1")
        val = sum([a[m+j] for j in range(n-m) if i >> j & 1])
        if K-m <= cnt <= K:
            ans += bisect.bisect_right(ls[K-cnt], R-val) - bisect.bisect_right(ls[K-cnt], L-val-1)
    print(ans)


if __name__ == '__main__':
    main()



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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define mp(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    int p[n + 1];
    ll c[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> c[i];
    }
    ll ans = LLONG_MIN;
    for (int i = 1; i <= n; i++) {
        int cur = i;
        vll scr;
        ll sum = 0;
        int nn = 0;
        do {
            nn++;
            cur = p[cur];
            sum += c[cur];
            scr.pb(sum);
        } while (cur != i);

        if (sum >= 0) {
            for (int j = 0; j < min(nn, k); j++) {
                ll tm = scr[j] + (sum * ((k - j - 1) / nn));
                ans = max(ans, tm);
            }
        } else {
            ll tm = LLONG_MIN;
            for (int j = 0; j < min(nn, k); j++) {
                tm = max(tm, scr[j]);
            }
            ans = max(ans, tm);
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3800
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val counter = IntArray(4)

    repeat(N) {
        val input = readLine()!!

        when(input) {
            "AC" -> counter[0]++
            "WA" -> counter[1]++
            "TLE" -> counter[2]++
            "RE" -> counter[3]++
        }
    }

    println("AC x ${counter[0]}")
    println("WA x ${counter[1]}")
    println("TLE x ${counter[2]}")
    println("RE x ${counter[3]}")
}


Measured memory_bytes: 56592
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int N,M,X[114514];
    cin >> N >> M;
    REP(i,M){
        cin >> X[i];
    }
    sort(X,X+M);
    int Y[114514]={};
    int Ans=0;
    REP(i,M-1){
        Y[i]=X[i+1]-X[i];
        Ans+=Y[i];
    }
    sort(Y,Y+M-1,greater<>());
    REP(i,N-1){
        Ans-=Y[i];
    }
    cout << Ans << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n; cin>>n;
    ll a, mn=1e9;
    ll sum=0;
    int c=0;
    for(int i=0; i<n-1; i++){
        cin>>a;
        sum+=abs(a);
        mn=min(mn, abs(a));
        if(a<0) c++;
    }
    cin>>a;
    if(c&1) cout<<max(sum-a, sum+a-2*mn)<<endl;
    else cout<<max(sum+a, sum-a-2*mn)<<endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	static Scanner scan = new Scanner(System.in);

	public static void main(String[] args) {

		int n = scan.nextInt();
		int k = scan.nextInt() - 1;

		int ans = 0;
		int oneIndex = 0;
		for(int i = 0; i < n; i++) {
			if(scan.nextInt() == 1) oneIndex = i;
		}

		ans = solve(n, k, oneIndex);
		for(int i = 1; i < k; i++) {
			ans = Math.min(ans, solve(n, k, oneIndex - i));
			ans = Math.min(ans, solve(n, k, oneIndex + i));
		}


		System.out.println(ans);
	}

	static int solve(int n, int k, int oneIndex) {
		if(oneIndex < 0 || oneIndex >= n) return n;
		int ans = 0;
		ans += oneIndex / k;
		if(oneIndex % k != 0) ans++;
		ans += (n - 1 - oneIndex) / k;
		if((n - 1 - oneIndex) % k != 0) ans++;
		return ans;
	}

}


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

int main() {
vector<int> x(5);
rep(i,5) cin >> x.at(i);
int k;
cin >> k;
bool ans = false;
rep(i,5)rep(j,i)if(abs(x.at(i)-x.at(j)) > k) ans = true;

puts(!ans?"Yay!":":(");
}
  


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, M, ma = -1;
	cin >> N >> M;
	VI A(N);
	REP(i, N) {
		cin >> A[i];
		chmax(ma, A[i]);
	}
	rSORT(A);
	VI a = A;
	SORT(a);


	int L = 0, R = ma * 2, X;
	int res = 0;
	while (L <= R) {
		X = (L + R) / 2;
		//cout << X << endl;
		int cnt = 0;
		REP(i, N) {
			int s;
			if (X - A[i] <= 0)s = N;
			else s = a.end() - LB(a, X - A[i]);
			cnt += s;
			//if (X == 9887)cout << i << " " << s << endl;
		}
		if (cnt < M) {
			//cout <<cnt<<"  K"<< endl;
			//chmin(res, X);
			R = X - 1;
		}
		else {
			chmax(res, X);
			L = X + 1;
		}
	}
	//cout << res << endl;
	//選ぶ握手の中で最低の幸福度
	//あとはO(NlogN)でXを下回らないように握手を選んでく


	int ans = 0;
	VI sum1(N + 1, 0);
	eFOR(i, 1, N)sum1[i] = sum1[i - 1] + A[i - 1];

	int co = 0;
	REP(i, N) {
		//cout << ans << endl;
		int s;
		if (res - A[i] <= 0)s = N;
		else s = a.end() - LB(a, res - A[i]);
		co += s;
		//cout << s << " " << sum1[s] << endl;
		ans += sum1[s];
		ans += A[i] * s;
	}
	ans -= (co - M)*res;
	//選び過ぎたやつを引く
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926

typedef long long int ll;

ll num[ten5];
//ll num[10][10];
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<string,ll>::iterator iter;

int main(void)
{
    long long int sum=0,range=0,ceiling;
    double ans=0.0,d;
    long long int m,n,o,i,j,k=0,money;
    long long int a,a1=0,a2=0,a3=0,ar,as,at1;
    string s;
    char c;
    a=a1=a2=a3=0;
    //vector <int> v;
    //float f,g,h;
    //int c,d,big=0;
    cin>>n;m=0;
    for(i=0;i<n;i++)
    {
        cin>>a;
        num[i]=a;
        m+=a;
    }
    m/=n;
    k=m+1;
    for(i=0;i<n;i++)
    {
        o=abs(num[i]-m);
        ar=abs(num[i]-k);
        a1+=o*o;
        a2+=ar*ar;
    }
    cout<<min(a1,a2);
    return 0;
}





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


def solve(N: int, L: int):
    apple_taste_list = [L+i for i in range(N)]

    min_abs = 100000
    for i in apple_taste_list:
        if abs(i) < abs(min_abs):
            min_abs = i

    sum_of_taste = sum(apple_taste_list)
    
    print(sum_of_taste - min_abs)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = int(next(tokens))  # type: int
    solve(N, L)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n = list(input())


if n[-1]=='2' or n[-1]=='4' or n[-1]=='5' or n[-1]=='7' or n[-1]=='9':
    print('hon')
elif n[-1]=='0' or n[-1]=='1' or n[-1]=='6' or n[-1]=='8':
    print('pon')
elif n[-1]=='3':
    print('bon')
    

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

int main(){
	int n,t;
	cin >> n >> t;
	int ans = 10000;
	rep(i,n){
		int a,b;
		cin >> a >> b;
		if(b <= t){
			ans = min(ans, a);
		}
	}
	if(ans == 10000){
		cout << "TLE" << endl;
	}else{
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
state = 0
cnt = 0
for i in range(n-1):
    if a[i] > a[i+1]:
        if state == 0:
            state = 1
        elif state == -1:
            cnt += 1
            state = 0
    elif a[i] < a[i+1]:
        if state == 0:
            state = -1
        elif state == 1:
            cnt += 1
            state = 0
print(cnt+1)

Measured memory_bytes: 14252
#include <stdio.h>

int min(int x, int y) {
	return x < y ? x : y;
}



int main() {
	int N;
	int B[100000];
	int A[100000];
	int i;
	int total = 0;

	scanf("%d", &N);

	for (i = 0; i < N - 1; i++) {
		scanf("%d", &B[i]);
	}

	A[0] = B[0];
	A[N - 1] = B[N - 2];

	for (i = 0; i < N - 2; i++) {
		A[i + 1] = min(B[i], B[i + 1]);
	}

	for (i = 0; i < N; i++) {
		total += A[i];
	}

	printf("%d\n", total);
	return 0;
}


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

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	vector<int> L( N );
	for( auto& v: L ) { cin >> v; }
	sort( L.begin(), L.end() );

	int s = 0;
	for( int i = 0; i < N-1; ++i ) {
		s += L[i];
	}

	cout << (L.back() < s ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << (n + 999) / 1000 * 1000 - n << endl;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18;

struct edge {
  ll to, cost;

  edge(ll t, ll c) {
    to = t;
    cost = c;
  }
};

struct graph {
  ll V;
  vector<vector<edge>> G;
  vector<vector<ll>> d;

  graph(ll n) { init(n); }

  void init(ll n) {
    V = n;
    G.resize(V);
    d.resize(V, vector<ll>(V, INF));
    for (int i = 0; i < V; i++) {
      d[i][i] = 0;
    }
  }

  void add_edge(ll s, ll t, ll cost) { G[s].push_back(edge(t, cost)); }

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

ll N, M, R;
vector<ll> r;
graph G = graph(N);

void solve() {
  G.Warshall_Floyd();
  vector<int> v(R);

  for (int i = 0; i < R; i++) {
    v[i] = i;
  }

  ll res = INF;

  while (next_permutation(v.begin(), v.end())) {
    ll tmp = 0;
    for (int i = 0; i < R - 1; i++) {
      tmp += G.d[r[v[i]] - 1][r[v[i + 1]] - 1];
    }
    res = min(res, tmp);
  }

  cout << res << "\n";
}

int main() {
  cin >> N >> M >> R;
  r.resize(R);
  for (int i = 0; i < R; i++) {
    cin >> r[i];
  }
  G.init(N);
  for (int i = 0; i < M; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    G.d[a - 1][b - 1] = c;
    G.d[b - 1][a - 1] = c;
  }
  solve();
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    set<string> s;
    rep(i,n) {
        string ss;
        cin>>ss;
        s.emplace(ss);
    }
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 19240
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	string s; cin >> s;
	if(s=="ABC")
		cout << "ARC" << endl;
	else
		cout << "ABC" << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // Tenka1 Programmer Contest C - 4/N
  // w = N*h*n / (4*h*n - N*h - N*n)
  ll N; cin >> N;
  
  ll ansh, ansn, answ;
  for(ll h = 1; h <= 3500; h++){
    for(ll n = 1; n <=3500; n++){
      if(4*h*n > N*h + N*n){
        if((N*h*n)%(4*h*n-N*h-N*n) == 0){
          ansh = h;
          ansn = n;
          ll answ = N*h*n / (4*h*n - N*h - N*n);
          cout << ansh << " " << ansn << " " << answ << endl;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int erasu(int);

int main(void) {
    int n;
    while(scanf("%d",&n)!=EOF)
        printf("%d\n",erasu(n));
    return 0;
}

int flag[1000000]={0};

int erasu(int n){
    int i,j;
    int sum=0;
    for(i=2;i<n+1;i++){
        flag[i]=1;
    }
    for(i=2;i<n+1;i++){
        if(flag[i]==0)
            continue;
        for(j=i+i;j<n+1;j+=i){
            if(j%i==0)
                flag[j]=0;
            }
    }
    for(i=0;i<n+1;i++){
        sum+=flag[i];
    }
    return sum;
}

Measured memory_bytes: 4500
#include<bits/stdc++.h>
using namespace std;
const int N=15;
int n,m,k[N],s[N][N],p[N],t[N],ans;
void dfs(int cur)
{
    if(cur==n+1){
        for(int i=1;i<=m;i++){
            int tot=0;
            for(int j=1;j<=k[i];j++)tot+=t[s[i][j]];
            if(tot%2!=p[i])return ;
        }
        ans++;
        return ;
    }
    t[cur]=0;
    dfs(cur+1);
    t[cur]=1;
    dfs(cur+1);
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>k[i];
        for(int j=1;j<=k[i];j++)cin>>s[i][j];
    }
    for(int i=1;i<=m;i++)cin>>p[i];
    dfs(1);
    return cout<<ans,0;
}

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

struct zahyou{
  int x;
  int y;
};

struct zahyou a[10];
int n;
double sum = 0;
double dist[9][9];
int sp = 0;
double s[100000];

int main(){
  int i,j,k;
  int r;
  double t;

  scanf("%d", &n);

  for(i = 0;i <= n;i++){
    for(j = 0;j <= n;j++) dist[i][j] = 0.0;
  }

  for(i = 1;i <= n;i++) scanf("%d %d", &a[i].x, &a[i].y);

  for(k = 1;k <= n;k++){
    for(j = 1;j <= n;j++){
      t = pow(a[j].x - a[k].x,2) + pow(a[j].y - a[k].y,2);
      dist[k][j] = sqrt(t);
      sum += dist[k][j];
    }
  }

  printf("%.9f\n", sum/n);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0;char ch=getchar();
	while (!isdigit(ch)) ch=getchar();
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x;
}
int a;
int main(){
	read();a=read()*10+read();
	if (a%4) puts("NO");
	else puts("YES");
	return 0;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var n=arr.shift()-0;
var v=arr.shift().split(" ").map(Number);
var sum=0;
for(var i=0;i<n;i++){
   sum+=v[i]-(i+1);
}
console.log(sum);


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
	int n;
	string s;
	cin>>n>>s;
	int x=0,y=0;
	for(auto c:s){
		if('A'<=c&&c<='M')y++;
		else if('N'<=c&&c<='Z')y--;
		else if('a'<=c&&c<='m')x++;
		else x--;
	}

	string ans;
	if(y>0)ans+=string(y,'A');
	else ans+=string(-y,'Z');
	if(x>0)ans+=string(x,'a');
	else ans+=string(-x,'z');

	cout<<ans.size()<<endl;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3308
N, M = map(int, input().split())

INF = 10**7
dp = [INF]*2**N
dp[0] = 0

for i in range(M):
    a, b = map(int, input().split())
    c_ls = map(int, input().split())
    #d = sum((1<< (i - 1)) for i in  map(int, input().split()))  
    d = 0
    for c in c_ls:
        d += 2**(c - 1)
    for j in range(2**N):
        jord = j | d
        dp[jord] = min(dp[j] + a, dp[jord])
        
if dp[- 1] == INF:
    print(- 1)
else:
    print(dp[- 1])

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

using namespace std;

int n;
long long co = 0;
string V[100005];
map<string, long long> m;


void input() {

    cin >> n;
    string t;


    for(int i=0;i<n;i++) {
        cin >> V[i];
        sort(V[i].begin(), V[i].end());

        m[V[i]]++;
    }

    for(auto res: m) {

        if(res.second >= 2) {
            co += (res.second * (res.second - 1) / 2);
        }
    }

    cout << co;

}
int main() {

    input();


    return 0;
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1000000000000000000;
int main(){
    int n;
    scanf("%d",&n);
    ll cur = 1;
    bool zero = 0;
    bool out = 0;
    for (int i =0 ; i < n; i++){
        ll x;
        scanf("%lld",&x);
        if (x == 0){
            zero = 1;
        }
        else if (cur > INF/x){
            out = 1;
        }
        else cur *= x;
    }
    if (zero) printf("0");
    else if (out) printf("-1");
    else printf("%lld",cur);
}


Measured memory_bytes: 3828
#include <iostream>
#include <string> 
#include <map>
using namespace std;
map<string,int> s; 
int main(){
	int n;
	cin>>n;
	while(n--){
		string a;
		cin>>a;
		s[a]++;
	}
	auto it=s.begin();
	int max0=0;
	while(it!=s.end()){
		if(it->second>max0) max0=it->second;
		it++;
	}
	it=s.begin();
	while(it!=s.end()){
		if(it->second==max0) cout<<it->first<<endl; 
		it++; 
	}
	return 0;
} 

Measured memory_bytes: 25216
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#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 mp make_pair
#define pb push_back

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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



int main() {
  string s;
  cin >> s;
  cout << s[0] << s.length()-2 << s[s.length()-1] << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;

#define pb push_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)
#define lb(a,b) lower_bound(all(a),b)
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define in1(a,n) F(i,1,n)cin>>a[i]
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define ff first
#define ss second
#define F(i,a,b) for (ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define rep(i,n) F(i,0,n-1)
#define clr(a) (a).clear()
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin() ,(a).rend()
#define endl '\n'

#define mod 1000000007

ll add(ll a, ll b){return (a%mod + b%mod)%mod;}
ll sub(ll a , ll b){return (a%mod - b%mod + mod)%mod;}
ll mul(ll a, ll b){return (a%mod * b%mod)%mod;}
ull poww(ull a,ull b){ull res=1;while(b){if(b&1){res*=a;}a=a*a;b>>=1;}return res;}
ll poww(ll a,ll b,ll MOD){ll res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define dbg(x) cout<<#x<<" :: "<<x<<endl;
#define dbg2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define dbg4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;

//end of template

int main(int argc, char const *argv[])
{
	crap;
	ll r, g, b, n;
	cin >> r >> g >> b >> n;
	vll p;
 	F(i, 0, 3000){
		F(j, 0, 3000){
			ll val = i*r + j*g;
			p.pb(val);
		}
	}
	sort(all(p));
	ll ans = 0;
	rep(i, sz(p)){
		if (p[i] > n ) break;
		if ((n-p[i]) % b == 0)
			ans += 1;
	}

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

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

using namespace std;

int main() {
    //マスターパターンの頭尾 m_head m_tail  head[i] tail[i]
    int card,gate;
    cin >> card >> gate;
    int head[gate],tail[gate];
    int m_head = 1 ,m_tail = card;
    bool flg = true;
    
    for(int i=0 ; i < gate ; i++){
        cin >> head[i] >> tail[i];
    }
    //gateごとに判定
    for(int i=0 ; i < gate ; i++){
        if(!flg) break;
        if(m_head > tail[i]){ flg = false;}//論外
        else if( m_tail < head[i]){ flg = false;}//論外
        else if(m_head > head[i]  ){ 
            if(m_tail > tail[i]){ m_tail = tail[i];}
         }else{
             m_head = head[i];
             if(m_tail > tail[i]){m_tail = tail[i];}
         }
    }

    if(!flg) cout << 0 << endl;
    if(flg) cout << m_tail - m_head + 1 << endl;   

    return 0;
}

Measured memory_bytes: 1024
s = str(input())
s_l = []
for i in range(len(s)):
    s_l.append(s[i])

n = len(s) - 1

m = n // 2 - 1

Tsuyoi = True
i = 0

while i <= m // 2:
    if s_l[i] != s_l[m - i]:
        Tsuyoi = False
        break
    if s_l[m + i + 2] != s_l[n - i]:
        Tsuyoi = False
        break
    if s_l[i] != s_l[n-i]:
        Tsuyoi = False
        break
    i += 1

if Tsuyoi:
    print("Yes")
else:
    print("No")

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



int main() {
    int n; cin >> n;
    ll m1,m2;
    vector<ll> x(n),y(n);

    rep(i,n){
        cin >> x[i];
        y[i] = x[i];
    }
    sort(x.begin(),x.end());

    m1 = x[(n-1)/2];
    m2 = x[n/2];

    rep(i,n){
        if(y[i] <= m1) cout << m2 << endl;
        else cout << m1 << endl;
    }
    return 0;
}











Measured memory_bytes: 6412
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main() {
    unsigned short *A, *B;
    
    int C[VMAX + 1];
    int n, i, j;
    scanf("%d", &n);
    
    A = malloc(sizeof(short) * n + 1);
    B = malloc(sizeof(short) * n + 1);
    
    for (i = 0; i <= VMAX; i++) C[i] = 0;
    
    for (i = 0; i < n; i++) {
        scanf("%hu", &A[i + 1]);
        C[A[i + 1]]++;
    }
    
    for (i = 1; i <= VMAX; i++) C[i] = C[i] + C[i - 1];
    
    for (j = 1; j <=n; j++) {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
    
    for (i = 1; i <= n; i++) {
        if (i > 1) printf(" ");
        printf("%d", B[i]);
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 9656
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Set<String> hash_set = new HashSet<String>();
    for (int i = 0; i < n; i++) {
      hash_set.add(sc.next());
    }
    System.out.println(hash_set.size());
    sc.close();
  }
}

Measured memory_bytes: 66320
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		
		System.out.println(var(A));
		
		sc.close();
	}
	
	public static int var(int A){
		if (A==2)
			return 1;
		
		else {
			return var(A-1)+A/2;
		}
			
	}

}
	


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

const int MOD = 1000000007;

// 3
// 10 2 5
// 6 3 4

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

  int v[100];
  int w[100];

  for (int i = 0; i < n; i++) {
    int tmp;
    scanf("%d", &tmp);
    v[i] = tmp;
  }

  for (int i = 0; i < n; i++) {
    int tmp;
    scanf("%d", &tmp);
    w[i] = tmp;
  }

  int sum = 0;
  for (int i = 0; i < n; i++) {
    int o = v[i] - w[i];
    if (o > 0) {
      sum += o;
    }
  }
  cout << sum << endl;
}


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

using ll = long long;
static const ll MOD = 1e9 + 7;

// 組合せを素数で割った値を求める
const int MAX = 1000005;
long long inv[MAX];

// テーブルを作る前処理
void COMinit() {
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  map<ll, ll> mp;
  for (int i = 0; i < n; i++) {
    ll now = a.at(i);
    for (int j = 2; j * j <= a.at(i); j++) {
      ll count = 0;
      while (now % j == 0) {
        now /= j;
        count++;
      }
      mp[j] = max(mp[j], count);
    }
    if (now > 1) mp[now] = max<ll>(mp[now], 1);
  }
  
  ll lcm = 1;
  for (auto i : mp) {
    lcm *= pow(i.first, i.second);
    lcm %= MOD;
  }
  
  COMinit();
  
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += lcm * inv[a.at(i)];
    ans %= MOD;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 8832
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005
unordered_map<ll,ll>m;
set<string>s;
int main()
{
	ios
	string a,b;
	ll k,i,j,n,cnt=0;
	cin>>a>>k;n=a.size();
	for(i=0;i<n;i++){
		string aa;
		ll num=0;
		for(j=i;j<min(n,i+10);j++){
			aa+=a[j];
			num=(num*37+a[j]-'a'+1)%hell;
			if(m[num]==0&&aa.size()<10){
				s.insert(aa);
				if(s.size()>5){
					auto ii=s.rbegin();
					s.erase(*ii);
				}
				m[num]=1;
			}
		}
	}
	for(auto i:s){
		cnt++;
		if(cnt==k){cout<<i;return 0;}
	}
	return 0;
}

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

#define IOS                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
#define int long long
#define ppi pair<int, int>
#define endl "\n"
#define nl cout << "\n"
#define deb(x) cout << #x << " " << x << endl;

const int N = 1010;
const int mod = 1e9 + 7;
int H, W;
char grid[N][N];
int dp[N][N];

// dp[i][j] = #Ways to reach from (i, j) to (H, W)
int Top_Down(int x = 1, int y = 1) {
    // Base Case
    if (x == H && y == W) return (dp[x][y] = 1);
    // Choice
    if (dp[x][y] != -1) return dp[x][y];
    int ways = 0;
    if (x <= H && grid[x + 1][y] == '.') ways += Top_Down(x + 1, y) % (mod);
    if (y <= W && grid[x][y + 1] == '.') ways += Top_Down(x, y + 1) % (mod);
    return (dp[x][y] = ways % (mod));
}

int countPathsWithObstacles() {
    int dp[H][W];  //dp[i][j] = number of paths from (0, 0) to (i, j)

    //Base Case
    dp[0][0] = 1;
    for (int i = 1; i < H; ++i) {
        if (grid[i][0] == '#') {
            //obstacle
            dp[i][0] = 0;
        } else {
            dp[i][0] = dp[i - 1][0];
        }
    }
    for (int j = 1; j < W; ++j) {
        if (grid[0][j] == '#') {
            dp[0][j] = 0;
        } else {
            dp[0][j] = dp[0][j - 1];
        }
    }

    //Recurrence
    for (int i = 1; i < H; ++i) {
        for (int j = 1; j < W; ++j) {
            if (grid[i][j] == '#') {
                dp[i][j] = 0;
            } else {
                dp[i][j] = (dp[i - 1][j] % mod + dp[i][j - 1] % mod) % mod;
            }
        }
    }
    return dp[H - 1][W - 1] % mod;
}

int32_t main() {
    IOS;
    memset(dp, -1, sizeof(dp));
    cin >> H >> W;
    for (int i = 0; i < H; ++i)
        for (int j = 0; j < W; ++j) {
            cin >> grid[i][j];
        }
    //
    cout << countPathsWithObstacles() % (mod) << endl;
}

Measured memory_bytes: 20440
buildings = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]

n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    buildings[b-1][f-1][r-1] += v

for b in range(4):
    for f in range(3):
        for r in range(10):
            print(f" {buildings[b][f][r]}", end="")
        print()
    if b <= 2:
        print("####################")




Measured memory_bytes: 5636
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
struct pnt{
    double x,y;
    pnt operator+(pnt key){
	pnt res; res.x=x+key.x,res.y=y+key.y;
	return res;
    }
    pnt operator-(pnt key){
	pnt res; res.x=x-key.x,res.y=y-key.y;
	return res;
    }
    pnt operator*(double key){
	pnt res; res.x=x*key,res.y=y*key;
	return res;
    }
    pnt operator/(double key){
	pnt res; res.x=x/key,res.y=y/key;
	return res;
    }
    double abs(){
	return sqrt(x*x+y*y);
    }
};
double dot(pnt a,pnt b){
    return a.x*b.x+a.y*b.y;
}
struct line{
    pnt a,b;
};
pnt projection(line p,pnt q){
    pnt base=p.b-p.a;
    pnt hypo=q-p.a;
    pnt res=p.a+base*dot(hypo,base)/base.abs()/base.abs();
    return res;
}
pnt reflection(line p,pnt q){
    pnt x=projection(p,q);
    return x*2-q;
}
int main(){
    line p;
    cin>>p.a.x>>p.a.y>>p.b.x>>p.b.y;
    ll n;cin>>n;
    while(n--){
	pnt q;
	cin>>q.x>>q.y;
	pnt res=reflection(p,q);
	cout<<fixed<<setprecision(9)<<res.x<<" ";
	cout<<fixed<<setprecision(9)<<res.y<<endl;
    }
    return 0;
}



Measured memory_bytes: 3268
#include<stdio.h>
#define N 1000

int main(void){
  int i,num,j,k;
  char m[9][9],hoge,ans[N];
  int c,sf=1;

  for(i=0;;i++){
    ans[i]=0;
    for(j=0;j<8;j++){
      for(k=0;k<8;k++)
        c=scanf("%c",&m[j][k]);
      if(c!=1){
        sf=0;
        break;
      }
      scanf("%c",&hoge);
    }
    if(sf==0)
      break;
    else
      scanf("%c",&hoge);

    for(j=0;j<8;j++){
      for(k=0;k<8;k++){
        if(m[j][k]=='1'){
          if(j<=6 && k<=6 &&
              m[j][k+1]=='1' &&
              m[j+1][k]=='1' &&
              m[j+1][k+1]=='1')
            ans[i]='A';
          else if(j<=4 &&
              m[j+1][k]=='1' &&
              m[j+2][k]=='1' &&
              m[j+3][k]=='1')
            ans[i]='B';
          else if(k<=4 &&
              m[j][k+1]=='1' &&
              m[j][k+2]=='1' &&
              m[j][k+3]=='1')
            ans[i]='C';
          else if(j<=5 && k>=1 &&
              m[j+1][k]=='1' &&
              m[j+1][k-1]=='1' &&
              m[j+2][k-1]=='1')
            ans[i]='D';
          else if(j<=6 && k<=5 &&
              m[j][k+1]=='1' &&
              m[j+1][k+1]=='1' &&
              m[j+1][k+2]=='1')
            ans[i]='E';
          else if(j<=5 && k<=6 &&
              m[j+1][k]=='1' &&
              m[j+1][k+1]=='1' &&
              m[j+2][k+1]=='1')
            ans[i]='F';
          else if(1<=k && k<=6 && j<=6 &&
              m[j][k+1]=='1' &&
              m[j+1][k]=='1' &&
              m[j+1][k-1]=='1')
            ans[i]='G';
        }
      }
    }
  }
  num=i;
  for(i=0;i<num;i++){
    printf("%c\n",ans[i]);
  }
  return 0;
}

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

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

  int ans = 0;

  vector<int> A(N);

  for (int i = 0; i < N; i++)
    cin >> A.at(i);

  int B;

  for (int i = 0; i < N; i++)
  {
    cin >> B;
    ans += B;
  }

  vector<int> C(N - 1);

  for (int i = 0; i < N - 1; i++)
    cin >> C.at(i);

  for (int i = 0; i < N - 1; i++)
  {
    if ((A.at(i) + 1) == A.at(i + 1))
      ans += C.at(A.at(i) - 1);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int i;
    double a,sum;
    while (scanf("%lf",&a)!=EOF) {
        sum=a;
        for (i=1; i<10; i++) {
            if (i%2==1) {
                a*=2.0;
            } else {
                a/=3.0;
            }
            sum+=a;
        }
        printf("%.8lf\n",sum);
    }
    return 0;
}

Measured memory_bytes: 652
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

ll powMod(ll n, ll k, ll m) {
	if (k == 0) {
		return 1;
	} else if (k % 2 == 1) {
		return powMod(n, k - 1, m) * n % m;
	} else {
		ll t = powMod(n, k / 2, m);
		return t * t % m;
	}
}

int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;

	ll ans=0;

	if (a >= k) {
		ans=k;
	} else {
		ans=a;
		k-=a;
		k-=b;
		if (k > 0) {
			ans-=k;
		}
	}

	cout << ans << endl;
}


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

int N,A,B,C;
int l[10];

int main(){
    cin >> N >> A >> B >> C;
    for(int i=0;i<N;i++){
        cin >> l[i];
    }
    int ans=1e8;
    for(int mask1=1;mask1<(1<<N);mask1++){
        for(int mask2=1;mask2<(1<<N);mask2++){
            if(mask1&mask2) continue;
            for(int mask3=1;mask3<(1<<N);mask3++){
                if(mask1&mask3) continue;
                if(mask2&mask3) continue;
                int len1,len2,len3;
                len1=len2=len3=0;
                int res=0;
                for(int i=0;i<N;i++){
                    if(mask1&(1<<i)){
                        len1+=l[i];
                    }else if(mask2&(1<<i)){
                        len2+=l[i];
                    }else if(mask3&(1<<i)){
                        len3+=l[i];
                    }
                }
                res+=abs(A-len1)+abs(B-len2)+abs(C-len3);
                res+=(__builtin_popcount(mask1)-1)*10;
                res+=(__builtin_popcount(mask2)-1)*10;
                res+=(__builtin_popcount(mask3)-1)*10;
                ans=min(ans,res);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
    long int h;
    cin>>h;
    if(h==1)
    cout<<1;
    else
    {
        long int sum=1,i=1;
        //long int count=0;
        //long int temp=h;
        while(h>1)
        {
            h=floor(h/2);
            sum=sum+pow(2,i);
            i++;
            
        }
        cout<<sum;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
<?php

$input = file_get_contents('php://stdin');
$counts = count_chars($input, 1);

$isBeautiful = true;
foreach($counts as $ord => $count) {
    $char = chr($ord);
    if ($char < "a" || $char > "z") {
        continue;
    }
    
    if ($count % 2 != 0) {
        $isBeautiful = false;
        break;
    }
}

echo $isBeautiful ? "Yes" : "No";

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

using namespace std;

typedef long long ll;

const int MAXN = 5005;
const int MOD = 1e9 + 7;

vector<int> G[MAXN];

int f[MAXN][MAXN][2], h[MAXN][2], g[MAXN], sz[MAXN];

int n, u, v;

inline void add(int &a, int b)
{
	a = (a + b) % MOD;
	if (a < 0) a += MOD;
}

void solve(int u, int p = 0)
{
	sz[u] = 1;
	f[u][1][0] = 1;
	for (auto v : G[u])
	{
		if (v == p) continue;
		solve(v, u);
		for (int i = 1; i <= sz[u] + sz[v]; i++)
			h[i][0] = h[i][1] = 0;
		for (int i = 1; i <= sz[u]; i++)
		{
			for (int j = 1; j <= sz[v]; j++)
			{
				for (int k = 0; k < 2; k++)
				{
					for (int l = 0; l < 2; l++)
					{
						add(h[i + j][k ^ l ^ 1], (ll)f[u][i][k] * f[v][j][l] % MOD);
						add(h[i][k ^ l], -1 * (ll)f[u][i][k] * f[v][j][l] % MOD * g[j] % MOD);
					}
				}
			}
		}
		for (int i = 1; i <= sz[u] + sz[v]; i++)
			for (int j = 0; j < 2; j++)
				f[u][i][j] = h[i][j];
		sz[u] += sz[v];
	}
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i < n; i++)
	{
		cin >> u >> v;
		G[u].emplace_back(v);
		G[v].emplace_back(u);
	}
	g[2] = 1;
	for (int i = 3; i <= n; i++)
		g[i] = (ll)g[i - 2] * (i - 1) % MOD;
	solve(1);
	int res = 0;
	for (int i = 1; i <= n; i++)
	{
		add(res, (ll)f[1][i][0] * g[i] % MOD);
		add(res, (ll)f[1][i][1] * g[i] % MOD);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 195456
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int ans = 0;
        for (int i = 0; i < 10; i++) {
            int idx1 = s.indexOf(String.valueOf(i));
            if(idx1 < 0)continue;
            for (int j = 0; j < 10; j++) {
                int idx2 = s.indexOf(String.valueOf(j), idx1+1);
                if(idx2 < 0)continue;
                for (int k = 0; k < 10; k++) {
                    int idx3 = s.indexOf(String.valueOf(k), idx2+1);
                    if(idx3 < 0)continue;
                    ans++;
                }
            }
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 24404
#include<bits/stdc++.h>
using namespace std;
int main()
{
	//code
	string s,t;
	cin>>s;
	cin>>t;
	
	t.pop_back();
	if(s==t)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
 	return 0;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep2(i,x,y) for (int i = x; i < (y); ++i)
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  int a, b;
  string op;
  while(op != "?"){
    cin >> a >> op >> b;
    if(op == "+"){
      cout << a + b << endl;
    }
    if(op == "-"){
      cout << a - b << endl;
    }
    if(op == "*"){
      cout << a * b << endl;
    }
    if(op == "/"){
      cout << a / b << endl;
    }
    if(op == "?"){
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3220
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <queue>
#include <stack>
#include <list>
#include <bitset>
#include <deque>
#include <cmath>
#include <iomanip>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define MCLR(a) memset((a), -1 ,sizeof(a))
#define SZ(a) (sizeof(a))
#define FILL(a,v) fill((int*)a,(int*)(a+(SZ(a)/SZ(*(a)))),v)
#define SORT(c) sort((c).begin(),(c).end())

bool cheak(int x, int y, int xMax, int yMax)
{
	return x >= 0 && y >= 0 && xMax > x && yMax > y;
}
const int dx[4] = { -1, 0, 1, 0 }, dy[4] = { 0, 1, 0, -1 };
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;
const int INF    = 2147483647;
const ll  LLINF  = 9223372036854775807;
const ull ULLINF = 18446744073709551615;



int main()
{
	REP(i, 9)REP(j, 9)
	{
		cout << i + 1 << "x" << j + 1 << "=" << (i + 1)*(j + 1) << endl;
	}

	return 0;
}

Measured memory_bytes: 1116
N = int(input())
T,A = map(int,input().split(' '))
H = [int(h) for h in input().split(' ')]
#　平均気温がAに最も近い場所の温度
best_place = -float('inf')
#A点に最も近い場所の地点
point = 0
for i,x in enumerate(H):
  TEM = T-x*0.006
  if abs(A-best_place)> abs(A-TEM):
    point = i
    best_place = TEM
print(point+1)
  
  

Measured memory_bytes: 3060
from collections import defaultdict
def main():
    n, x, y = map(int, input().split())
    ans = defaultdict(int)
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            l = min(abs(i - j), abs(i - x) + abs(y - j) + 1, abs(i - y) + abs(x - j) + 1)
            ans[l] += 1
    [print(ans[i]) for i in range(1, n)]

if __name__ == '__main__':
    main()


Measured memory_bytes: 9652