akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
int A;
int B;
cin>>A>>B;
int ans;
if((B-1)%(A-1)==0){
  ans=(B-1)/(A-1);
}
else{
  ans=(B-1)/(A-1)+1;
}
cout<<ans<<"\n";
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  vector<int> A1(N), A2(N);
  for (int i=0; i<N; i++) cin >> A1[i];
  for (int i=0; i<N; i++) cin >> A2[i];
  vector<int> ans(N); // ans[i]には，A1[i]でA2[i]に移った時の回収できる飴の個数を格納
  for (int i=0; i<N; i++) {
    ans[i] = accumulate(A1.begin(), A1.begin()+i+1, 0);
    ans[i] += accumulate(A2.begin()+i, A2.end(), 0);
  }
  sort(ans.begin(), ans.end());
  cout << ans[N-1] << endl;
}

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

int main() {
  
  int N;
  cin >> N;
  int p = 200;
  
  for (int i = 0; i < N; i++) { 
    
    int A;
    cin >> A;
    
    int y = 0;
    
    for (int j = 0; ; j++) {
      
      if (A % 2 == 0) {
        A /= 2;
        y += 1;
      }
      else {
        break;
      }
    }
    
    if (p > y) {
        p = y;
    }
  }
  cout << p << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {

    val (N, K) = readLine()!!.split(" ").map(String::toInt)
    val S = readLine()!!

    var C = S.toCharArray()
    var sum = 0
    for (i in S.indices) {
        val c = C[i]
        when (c) {
            'R' -> {
                if (i + 1 in S.indices && C[i + 1] == 'R') {
                    sum++
                }
            }
            'L' -> {
                if (i - 1 in S.indices && C[i - 1] == 'L') {
                    sum++
                }
            }
        }
    }
    val happy = sum + 2 * K
    if (happy >= N) {
        println(N - 1)
    } else {
        println(happy)
    }
}

Measured memory_bytes: 41636
N = int(input())
S = list(input())

alf = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")

slide = alf[N:] + alf[:N]

ans = []

for i in S:
    l = alf.index(i)
    t = slide[l]
    ans.append(t)

print("".join(ans))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  int count = 0;
  for (int i = 1; i<a; i++) {
    for (int j = 2; j<a; j++) {
      if (pow(i, j) <= a) {
        if (pow(i, j) >= count) {
          count = pow(i, j);
        }
      }
    }
  }
  if (a != 1) {
  cout << count << endl;
  }
  else {
    cout << 1 << endl;
  }
}

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

using namespace std;

int main(void)
{
    int n;

    cin >> n;

    int m = n,i;
    for (i = 0; i < 10; i++)
    {
        m /= 10;
        if (m == 0)
        {
            break;
        }
    }
    int ans = 0;
    switch (i)
    {
        case 0:
            ans = n;
            break;
        case 1:
            ans = 9;
            break;
        case 2:
            ans = 9 + n - 99;
            break;
        case 3:
            ans = 9 + 900;
            break;
        case 4:
            ans = 9 + 900 + n - 9999;
            break;
        case 5:
            ans = 9 + 900 + 90000;
            break;
    }

    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;


int f(int n) {
	int ans = 0;
	for (int x = n; x >= 1; x--) {
		if (x*x > n) continue;
		for (int y = x; y >= 1; y--) {
			if (y*y + x*x + x*y > n) continue;
			for (int z = y; z >= 1; z--) {
				int sum = x*x + y*y + z*z + x*y + y*z + z*x;	
				if(n != sum) continue;
				set<int> set;
				set.insert(x);
				set.insert(y);
				set.insert(z);
				if(set.size() == 1) {
					ans++;	
				}else if(set.size() == 2) {
					ans += 3;
				}else if(set.size() == 3) {
					ans += 6;
				}
			}
		}
	}
	return ans;
}
int main(int argc, char *argv[]) {
	
	int N; cin >> N;

	vector<int> ans(N);
	for (int i = N; i >= 1; i--) {
		ans[i-1] = f(i);
	}
	for (int i = 0; i < N; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}


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

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]) {

    bool all_visited = true;

    for (int i = 0; i < N; i++) {
        if (visited[i] == false) all_visited = false;
    }

    if (all_visited) return 1;

    int ret = 0;

    for (int i = 0; i < N; i++) {
        if (graph[v][i] == false) continue;
        if (visited[i]) continue;

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}

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

    int N, M; cin >> N >> M;

    for (int i = 0; i < M; i++) {
        int A, B; cin >> A >> B;
        graph[A-1][B-1] = graph[B-1][A-1] = true;
    }

    bool visited[nmax];
    visited[0] = true;
    cout << dfs(0, N, visited) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
string S,T;
//=============================
void input()
{
    cin>>N;
    cin>>M;
    cin>>K;

}
//=============================
void func(){}
//=============================
void solve()
{
    int X=N;
    int A=M;
    int B=K;
    cout<<(X-A-((X-A)/B)*B)<<endl;

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
/// 5:28 PM 17/05/20
/// Author: t_bone_289 (An Immature Programmer.... I'm still developing !!)
#include<bits/stdc++.h>

using namespace std;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define VARIABLE_ERROR(x) cout << #x << " = " << x << endl;
#define CONTAINER_ERROR(v) cout << "{";for (auto &x:v) { cout << x << ','; }cout << "}" << endl;
#define PI 3.14159265358979323846
#define M 1000000007
#define INF 1e15
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll k;
    string s;
    cin >> k >> s;
    ll n = s.size();
    if(n <= k) {
        cout << s << endl;
    } else {
        for(ll i=0;i<k;i++) {
            cout<<s[i];
        }
        cout<<"...";
    }
    return 0;
}

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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

void solve()
{	
	ll n; cin >> n;
	string s, p; cin >> s >> p;
	ll res = 0;
	for (int i = 1; i <= n; ++i)
	{
		string t = s.substr(0, i);
		string o = p.substr(p.length() - i, i);
		if (t == o)
		{
			res = max(res, (ll)len(o));
		}
		//cout << "t = " << t << " o = " << o << endl;
	}
	reverse(all(p));
	reverse(all(s));
	for (int i = 1; i <= n; ++i)
	{
		string t = s.substr(0, i);
		string o = p.substr(p.length() - i, i);
		if (t == o)
		{
			res = max(res, (ll)len(o));
		}
		//cout << "t = " << t << " o = " << o << endl;
	}
	cout << 2 * len(s) - res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>

using namespace std;

int main()
{
	bool flag = true;
	int N, half;
	string S;
	cin >> N >> S;
	if (N % 2 == 0)
	{
		half = N / 2;
		for (int count = 0; count < half; count++)
		{
			if (S.at(count) != S.at(count + half))
			{
				flag = false;
				break;
			}
		}
		if (flag)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int i,n,A[200000],min,max=-1000000000,a;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  min=A[0];
  for(i=1;i<n;i++){
    a=A[i]-min;
    if(a>max)max=a;
    if(A[i]<min)min=A[i];
  }
  printf("%d\n",max);
  return 0;
}



Measured memory_bytes: 2604
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    int N;
    cin >> N;
    int bit = 0;
    rep(i, N) {
        int a; cin >> a;
        bit ^= a;
    }
    
    string ans = "No";
    if(bit == 0) ans = "Yes";
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
void solve(){
	ll n;
	cin>>n;
	map<string,ll> m;
	for(ll i=0;i<n;i++){
		string s;
		cin>>s;
		m[s]++;
	}
	cout<<"AC x "<<m["AC"]<<"\n";
	cout<<"WA x "<<m["WA"]<<"\n";
	cout<<"TLE x "<<m["TLE"]<<"\n";
	cout<<"RE x "<<m["RE"];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++)
	solve();
}


Measured memory_bytes: 3660
let rev s =
  let len = String.length s in
  let rec aux i acc =
    if i = len then acc else aux (i + 1) (Char.escaped s.[i] ^ acc)
  in
  aux 0 ""


let has_any_prefix s =
  try
    List.find
      (fun word ->
         let len = String.length word in
         try String.sub s 0 len = word with _ -> false)
      ["maerd"; "remaerd"; "esare"; "resare"]
  with Not_found -> ""


let trim_prefix s prefix =
  let len_pre = String.length prefix in
  let len_s = String.length s in
  String.sub s len_pre (len_s - len_pre)


let rec solve str =
  if String.length str = 0 then "YES"
  else
    match has_any_prefix str with
    | "" -> "NO"
    | a -> trim_prefix str a |> solve


let () = read_line () |> rev |> solve |> print_endline

Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
const int INF = 10000000;
typedef pair<int,int> P;
int da[] = {1,0,-1,0};
int db[] = {0,1,0,-1};
int h,w,n,ans=0;
char m[1002][1002];
int d[1002][1002];
int main(){
	scanf("%d%d%d",&h,&w,&n);
	for(int i = 0;i < h;i++){
		scanf("%s",m[i]);
	}
	int a,b;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			if(m[i][j] == 'S'){
				a = i,b = j;
				break;
			}
		}
	}
	for(int c = 1;c <= n;c++){
		for(int i = 0;i <= h;i++){
			for(int j = 0;j <= w;j++){
				d[i][j] = INF;
			}
		}
		d[a][b] = 0;
		queue<P> que;
		que.push(P(a,b));
		while(que.size()){
			P p = que.front(); que.pop();
			int aa = p.first,bb = p.second;
			if(m[aa][bb] - '0' == c){
				ans += d[aa][bb];
				a = aa,b = bb;
				break;
			}
			for(int i = 0;i < 4;i++){
				int na = aa + da[i];
				int nb = bb + db[i];
				if(na >= 0 && na < h && nb >= 0 && nb < w && m[na][nb] != 'X' && d[na][nb] == INF){
					d[na][nb] = d[aa][bb] + 1;
					que.push(P(na,nb));
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 6112
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    ll n,k;
    ll v[110];
    std::cin >> n>>k;
    for (int i = 0; i < n; i++) {
        std::cin >> v[i];
    }
    
    ll answer = 0;
    
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= k && j <= k-i ; j++) {
            vector<ll> all;
            ll res = 0;
            for (int asdf = 0; asdf < n; asdf++) {
                if(asdf <= i-1 || n-j <= asdf){
                    all.push_back(v[asdf]);
                    res += v[asdf];
                }
            }
            sort(all.begin(),all.end());
            for (int d = 0; d < k-i-j && d<all.size(); d++) {
                if(all[d] < 0){
                    res -= all[d];
                }else{
                    break;
                }
            }
            answer = max(answer,res);
        }
    }
    
    std::cout << answer << std::endl;
}


Measured memory_bytes: 256
N, K= map(int, input().split())

p_list = list(map(int, input().split()))

# 累積和初期化
s_list = [0] * (N + 1)

for i in range(N):
	s_list[i + 1] = s_list[i] + p_list[i]

# 隣り合うK個の要素の和が最大になるような範囲の開始位置を求める
max_s_sum = 0
max_sum_index = 0

for n in range(N - K + 1):
    s_sum = s_list[n + K] - s_list[n]
    if max_s_sum < s_sum:
        max_s_sum = s_sum
        max_sum_index = n

# 求めた開始位置から隣接するK個の要素の期待値を求める
ans = 0
for k in range(K):
    x = p_list[max_sum_index]
    ans += (x + 1) / 2
    max_sum_index += 1
  
print(ans)

Measured memory_bytes: 25060
package main

import (
	"fmt"
	"math"
)

func primeFactorization(n int) []int {
	if n < 2 {
		return []int{}
	}
	var ret []int
	k := int(math.Sqrt(float64(n)))
	noPrime := make([]bool, k+1)
	for n%2 == 0 {
		n /= 2
		ret = append(ret, 2)
	}
	for i := 3; i <= k; i += 2 {
		if noPrime[i] {
			continue
		}
		for n%i == 0 {
			n /= i
			ret = append(ret, i)
		}
		for j := 3 * i; j <= k; j += 2 * i {
			noPrime[j] = true
		}
	}
	if n > 1 {
		ret = append(ret, n)
	}
	return ret
}

func main() {
	var n int
	fmt.Scanln(&n)
	pf := primeFactorization(n)
	fmt.Printf("%d:", n)
	for _, v := range pf {
		fmt.Printf(" %d", v)
	}
	fmt.Println("")
}


Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

vector<vector<int>> to(100005);
vector<int> checked(100005);

void dfs(int v){
    if(checked[v])return;
    checked[v]=1;
    for(int u:to[v]){
        dfs(u);
    }
    return;
}

int main() {
    int N,M;
    cin>>N>>M;
    rep(i,M){
        int x,y,z;
        cin>>x>>y>>z;
        x--;y--;
        to[x].pb(y);
        to[y].pb(x);
    }
    int count=0;
    rep(i,N){
        if(!checked[i]){
            count++;
            dfs(i);
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 9216
#include <iostream>
using namespace std;
typedef long long ll;
ll k, ans;
double sunu;

ll pow(ll x, ll y){
    if (y == 0) return 1;
    return x * pow(x, y - 1);
}

ll sum(ll x){
    ll res = 0;
    while (x > 0) {
        res += x % 10;
        x /= 10;
    }
    return res;
}

double f(ll x){
    return (double)x / sum(x);
}

void func(ll x, ll y, ll z){
    if (pow(10, y - 1) > x) return;
    double a = f(x);
    if (a < sunu) {
        sunu = a;
        ans = x;
    }
    if (z == 9) {
        func(x, y + 1, x / pow(10, y) % 10);
    } else {
        func(x + pow(10, y - 1), y, z + 1);
    }
    return;
}

void g(ll x, ll y) {
    if (y == k) return;
    sunu = f(x) + 1;
    func(x, 1, x % 10);
    cout << ans << endl;
    g(ans + 1, y + 1);
    return;
}

int main(void){
    // Your code here!
    cin >> k;
    g(1, 0);
}


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



int main(void){
int a,b,c;
cin >> a >> b >> c;
if(b-a == c - b) cout << "YES" <<endl;
else cout << "NO" << endl;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const int TLE = 1000000;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    ll a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    ll sum = 0;
    for(int i=0;i<n;i++) sum += a[i];
    if(sum % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main()
{
  ll n,d,a,b,c=0;
  cin>>n>>d;
  while(n--)
  {
    cin>>a>>b;
    if((a*a+b*b)<=d*d)
      c++;
  }
  cout<<c<<"\n";
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>
#include <complex>
#include <stack>
#include <set>
#include <map>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i,n) for (int i = (n)-1; i >= 0; i--)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define allof(c) c.begin(), c.end()
#define partof(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define EPS 1e-9
#define INF 1000000000
using namespace std;

typedef complex<int> POINT;
template <class T>
class vevector : public vector<vector<T>>
{
public:
	using vector<vector<T>>::operator []; 
	T& operator [](const POINT &index) { return (*this)[index.real()][index.imag()]; }
};

template <class T> T read() { T t; cin >> t; return t; }
template <> POINT read<POINT>() { int x, y; cin >> x >> y; return POINT(x, y); }
template <class T> vector<T> read(int n) { vector<T> v; REP(i,n) { v.push_back(read<T>()); } return v; }
template <class T> vevector<T> read(int n, int m) { vevector<T> v; REP(i,n) v.push_back(read<T>(m)); return v; }
template <class T> void write(const T &t) { cout << t << endl; }
template <class T> void write(const T &t, const T &t2) { cout << t << ' ' << t2 << endl; }

template <class T> void write(const vector<T> &v)
{
	ostringstream ss; 
	for (auto x : v) ss << x << ' ';
	auto s = ss.str();
	cout << s.substr(0, s.length() - 1) << endl;
}

template <class T> string toString(const T &t) { stringstream ss; ss << t; return ss.str(); }

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__
#define countof(a) (sizeof(a)/sizeof(a[0]))
#define COMPARISON(t,a,b) [](const t & a, const t & b) -> bool

// primes //
vector<unsigned char> isPrime;
vector<int> primes;
void initPrimes(int n)
{
	isPrime = vector<unsigned char>(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	FOR(i, 2, n)
	{
		if (!isPrime[i]) continue;
		primes.push_back(i);
		for (int j = i * 2; j <= n; j += i)
			isPrime[j] = false;
	}
}

// iota iterator //
struct iotait
{
	int n;
	iotait(int n = 0) : n(n) { }
	iotait &operator ++() { ++n; return *this; }
	int operator *() { return n; }
};

// start up //
void solve();
int main() { solve(); return 0; }


/// template end ///

void solve()
{
	REP (testcase, INF)
	{
		READ(int, T, P, R);
		if (!(T|P|R)) { break; }
		
		struct team { int t, c, p; };
		vector<team> teams(T);
		REP(i,T) { teams[i].t = i + 1; }
		vector<vector<int>> wrongCount(T, vector<int>(P));

		REP(i,R)
		{
			READ(int, t,p,time);
			READ(string, message);
			if (message == "CORRECT")
			{
				teams[t - 1].p += time + wrongCount[t - 1][p - 1] * 1200;
				teams[t - 1].c++;
			}
			else
			{
				wrongCount[t - 1][p - 1]++;
			}
		}

		sort(allof(teams), COMPARISON(team,a,b)
		{
			return a.c != b.c ? a.c > b.c
				:  a.p != b.p ? a.p < b.p
				:  a.t < b.t;
		});

		for (auto t : teams) { cout << t.t << ' ' << t.c << ' ' << t.p << endl; }
	}
}

Measured memory_bytes: 1248
#include <iostream>
#include <vector>

#define M 100000

long long StrToID(std::string str){
	long long id = 0;
	for (int i = 0; i < str.length(); ++i){
		switch(str[i]){
			case 'A': id = 1 + id*10; break; 
			case 'C': id = 2 + id*10; break;
			case 'G': id = 3 + id*10; break;
			case 'T': id = 4 + id*10; break;
			default : break;
		}
	}
	return id;
}

bool includeNum(long long fig, std::vector<long long> S){
	for (int i = 0; i < S.size(); ++i){
		if(S[i]==fig) return true;
	}
	return false;
}

int main(int argc, char const *argv[]){
	std::vector< std::vector<long long> > Dictionary(M);
	int N,key;
	long long id;
	std::string cmd,str;
	std::cin >> N;

	for (int i = 0; i < N; ++i){
		std::cin >> cmd >> str;
		id = StrToID(str);
		key = id % M;
		if(cmd=="insert"){
			if(!includeNum(id,Dictionary[key])) Dictionary[key].push_back(id);
		}else if(cmd=="find"){
			if(includeNum(id,Dictionary[key])){
				std::cout << "yes" << std::endl;
			}else{
				std::cout << "no" << std::endl;
			}
		}else{
			//exception
		}
	}
	return 0;
}


Measured memory_bytes: 9556
import itertools
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m, x = map(int, readline().split())
c = [list(map(int, readline().split())) for _ in range(n)]

ans = 10 ** 9 + 7
for l in list(itertools.product([0, 1], repeat=n)):
    cart = [0] * (m + 1)
    for i in [i for i, a in enumerate(l) if a == 1]:
        array = c[i]
        cart = list(map(lambda x,y: x+y, cart, array))
    if min(cart[1::]) >= x:
        ans = min(ans, cart[0])
        
print(ans if ans != 10 ** 9 + 7 else '-1')

Measured memory_bytes: 9540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n;
ll a[10005];
set<ll>vec;
vector<ll>vecc;
ll x = 0;
bool h[20505];
bool testt(ll p){
	if(abs(a[n])%p != 0) return 0;
	srand((unsigned)time(NULL));
	rep(w,100){
		ll aa = rand()%(p-1);
		aa++;
		ll s = 0;
		ll v = 1;
		for(int i=n;i>=0;i--){
			s += a[i]*v%p;
			v = v*1LL*aa%p;
		}
		s = (s%p+p)%p;
		if(s != 0) return 0;
	}
	return 1;
}
int main(){
	cin>>n;
	for(int i=0;i<=n;i++){
		cin>>a[i];
		x = __gcd(x,abs(a[i]));
	}
	for(ll i=2;i*i<=x;i++){
		if(x%i == 0){
			vec.insert(i);
			while(x%i == 0){ x /= i; }
		}
	}
	if(x > 1){
		vec.insert(x);
	}
	for(int i=2;i<=2*n+100;i++){
		if(h[i]) continue;
		vecc.pb(i);
		for(int j=2;i*j<=2*n+100;j++){
			h[i*j] = 1;
		}
	}
	for(int i=0;i<vecc.size();i++){
		if(testt(vecc[i])){
			vec.insert(vecc[i]);
		}
	}
	for(auto it:vec) cout<<it<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const ll MOD = 998244353;
const int INF = 1001001001;
// const ll INF = 1000000000000000000LL;
  
int main() {
    ll n,k;
    cin >> n >> k;
    vector<pair<ll,ll>> pr(k);
    rep(i,k){
        ll a,b;
        cin >> a >> b;
        pr[i].first = a;
        pr[i].second = b;
    }
    sort(pr.begin(),pr.end());

    vector<ll> dp(n);
    vector<ll> dp_sum(n+1);
    dp[0] = 1;
    dp_sum[0] = 0;
    dp_sum[1] = 1;
    for(int i=1;i<n;i++){
        rep(j,k){
            ll cur_l = pr[j].first;
            ll cur_r = pr[j].second;
            if(i-cur_l<0) break;
            if(i-cur_r<0)
                cur_r = i;
            // if(i-cur_r>=0){
                //あとで
                dp[i] += dp_sum[i-cur_l+1]-dp_sum[i-cur_r];
                dp[i]%=MOD;
            // }
            // else{
            //     for(int k=cur_l;k<=cur_r;k++){
            //         if(i-k>=0){
            //             dp[i] += dp[i-k];
            //             dp[i]%=MOD;
            //         }
            //         else
            //             break;
            //     }
            // }
        }
        dp_sum[i+1] = dp[i]+dp_sum[i];
        dp_sum[i+1] %=MOD;
    }
    if(dp[n-1]<0)
        dp[n-1]+=MOD;
    cout << dp[n-1] << endl;
    return 0;
}

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

using namespace std;

int n;
int A, B, C;
int D[100];
int main() {
    cin >> n;
    cin >> A >> B;
    cin >> C;
    for (int i = 0; i < n; i++) {
        cin >> D[i];
    }

    
    sort(D, D + n);
    reverse(D, D + n);
    
    int max,cal=C,wa;
    wa=C/A;
    max=wa;
    for (int i = 0; i < n; i++) {
    	cal+=D[i];
    	A+=B;
    	wa=cal/A;
    	if(wa>max) max=wa;
    }
    cout << max << endl;

    return 0;
}

Measured memory_bytes: 3132
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <bitset>
using namespace std;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int N, ans = 0; char str[2005];
bitset<2005> A[2005], L[2005], R[2005];

int main(){
	getint(N);
	for(register int i = 2; i <= N; i++){
		scanf("%s", str + 1);
		for(register int j = 1; j < i; j++)
			A[i][j] = str[j] &= 1, A[j][i] = str[j] ^ 1;
	}
	for(register int i = 1; i <= N; i++) L[i][i] = R[i][i] = 1;
	for(register int gap = 1; gap < N; gap++)
		for(register int i = 1, j; (j = i + gap) <= N; i++){
			L[j][i] = (R[i + 1] & L[j] & A[i]).count() > 0;
			R[i][j] = (L[j - 1] & R[i] & A[j]).count() > 0;
		}
	return printf("%d\n", (int)(R[1] & L[N]).count()), 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(){

int p;
char S[10];
for(p = 0;S[p] != '\0';p++){
scanf("%s",&S[p]);
}

int i = 0,n = 0; //n:小文字が出てくる回数
while(S[i] != '\0'){
if(S[i] >= 'a'&&S[i] <= 'z'){
n++;
}
i++;
}

int c,j; //c:'C'が出てくる回数
for(j = 2; j <= i - 2; j++){
if(S[j] == 'C') c++;
}

if(S[0] == 'A'&&c == 1&&n == i - 2){
printf("AC");
}else{
printf("WA");
}

return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3

# from numba import njit

# from collections import Counter
# from itertools import accumulate
# import numpy as np
# from heapq import heappop,heappush
# from bisect import bisect_left

# @njit
def solve(n,a):
  tripCourse = [0] + a + [0]
  wholeSum = sum(abs(tripCourse[i+1] - tripCourse[i]) for i in range(n+1))
  res = [wholeSum]*n
  for i in range(n):
    res[i] -= abs(tripCourse[i+1] - tripCourse[i+2]) + abs(tripCourse[i] - tripCourse[i+1]) - abs(tripCourse[i+2]-tripCourse[i])
  return res



def main():
  N = int(input())
  # N,M = map(int,input().split())
  a = list(map(int,input().split()))
  ans = solve(N,a)
  for i in range(N):
    print(ans[i])
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 20612
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> v(n), p(n), q(n);
	rep(i,n) cin >> p[i];
	rep(i,n) cin >> q[i];
	rep(i,n) v[i] = i+1;
	int pid = 0, qid = 0;
	int cnt = 1;
	do{
		bool P = true;
		bool Q = true;
		rep(i,n){
			if(v[i] != p[i]) P = false;
			if(v[i] != q[i]) Q = false;
		}
		if(P) pid = cnt;
		if(Q) qid = cnt;
		++cnt;
	} while(next_permutation(v.begin(), v.end()));
	int ans = abs(pid - qid);
	cout << ans << endl;
	return 0;
}

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string S; cin >> S;
    if ((int)S.size() % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    REP(i, (int)S.size()/2) {
        if (S[2*i] == 'h' && S[2*i + 1] == 'i') continue;
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define MX 10000000000
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return sol;
}

ll gcd( ll a, ll b )
{
   if( b == 0 )
      return a;
   else
   {
      return gcd( b, a % b );
   }
}
void solve()
{
	int k;
	cin >> k;
	ll sol = 0;
	for (int i = 1; i <= k; i++)
	{
		for (int j = 1; j <= k; j++)
		{
			for (int m = 1; m <= k; m++)
			{
				sol += gcd(gcd((ll)i, (ll)j),(ll)m);
			}
		}
	}
	cout << sol;
}
int main()
{
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
}


Measured memory_bytes: 3636
#include <iostream>
#include <cmath>

using namespace std;

typedef long long ll;

ll INF = 1e10;

ll N,M;
ll key_yen[1000];
ll keystate[1000];
ll dp[1000][1<<12];

int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++){
        cin >> key_yen[i];
        int n,m;
        cin >> m;
        keystate[i] = 0;
        for(int j=0;j<m;j++){
            cin >> n;
            keystate[i] |= 1 << (n-1);
        }
    }
    for(int i=0;i<M;i++){
        for(int j=0;j<(1<<N);j++){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    dp[0][keystate[0]] = key_yen[0];
    for(int i=1;i<M;i++){
        for(int j=0;j<(1<<N);j++) dp[i][j] = dp[i-1][j];
        for(int j=0;j<(1<<N);j++){
            dp[i][j|keystate[i]] = min(dp[i-1][j]+key_yen[i], dp[i][j|keystate[i]]);
        }
    }
    if(dp[M-1][(1<<N)-1] == INF) dp[M-1][(1<<N)-1] = -1;
    cout << dp[M-1][(1<<N)-1] << endl;
    return 0;
}

Measured memory_bytes: 32256
#include <cstdio>
#include <cstring>
#define maxn 100010
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
char str[maxn];
int main() {
	scanf("%s", str);
	int len = strlen(str);
	int ans = len;
	for(int i = 1; i < len; i++) {
		if(str[i-1] != str[i]) {
			ans = min(ans, max(i, len - i));
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int x = sc.nextInt();
    
    if (x == 7 || x == 5 || x == 3)
      System.out.println("YES");
    else
      System.out.println("NO");
  }  
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>

using namespace std;

int main(){

    int K,T;cin>>K>>T;
    int ans=0;
    REP(i,T){
        int a;cin>>a;
        ans = max(ans,K-(K-a)*2-1);
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
//I am so vegetable
#include <bits/stdc++.h>
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _defor(i,a,b) for((i) = (a);(i)<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto p:st)
//#define _LOCAL_
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll maxn = 1e2 + 5;
const int MOD = 1e9 + 7;
const double exps = 1e-6;
#ifdef _LOCAL_
void deprint() {
	ofstream cout("E:\\acm dream\\debug.txt");
	return;
}
#endif
int main() {
#ifdef _LOCAL_
	ifstream cin("E:\\acm dream\\in.txt");
	ofstream cout("E:\\acm dream\\out.txt");
#endif
	//srand((unsigned)time(nullptr));
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n; cin >> n;
	cout << (int)ceil(n / 2.0) << endl;
	return 0;
}

Measured memory_bytes: 256
s=input()
ans=0
for i in range(2**(len(s)-1)):
  i=bin(i)[2:].zfill(len(s)-1)
  a=s[0]
  for j in range(len(s)-1):
    if i[j]=='1':
      a+='+'
    a+=s[j+1]
  ans+=eval(a)
print(ans)

Measured memory_bytes: 8952
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()

def bisection(l,r,f,left=True,discrete=True):
    eps=1 if(discrete) else 10**-8
    if((not left)^f(r)): return r if(left) else r+1
    elif(left^f(l)): return l-1 if(left) else l
    while(r-l>eps):
        h=(l+r)//2 if(discrete) else (l+r)/2
        if((not left)^f(h)): l=h
        else: r=h
    return (l+r)/2 if(not discrete) else l if(left) else r

def resolve():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    A=[min(a,k+1) for a in A]
    A.sort()
    mask=(1<<k)-1

    def check(i): # i のカードを除いて、k-a[i]<=s<k が作れるか
        if(k-A[i]<0): return True
        dp=1
        for j in range(n):
            if(i==j): continue
            dp|=(dp<<A[j])
            dp&=mask

        dp>>=(k-A[i])
        return dp>0

    print(bisection(0,n-1,check,left=False))
resolve()

Measured memory_bytes: 41196
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 4444444
int n,k,f[2015][2015];
const int MOD=1e9+7;
ll fac[SZ],rfac[SZ];
ll qp(ll a,ll b)
{
	ll x=1; a%=MOD;
	while(b)
	{
		if(b&1) x=x*a%MOD;
		a=a*a%MOD; b>>=1;
	}
	return x;
}
ll C(ll a,ll b)
{
	if(b>a||b<0) return 0;
	return fac[a]*rfac[a-b]%MOD*rfac[b]%MOD;
}
int main()
{
	fac[0]=1;
	for(int i=1;i<SZ;++i)
		fac[i]=fac[i-1]*i%MOD;
	rfac[SZ-1]=qp(fac[SZ-1],MOD-2);
	for(int i=SZ-1;i>=1;--i)
		rfac[i-1]=rfac[i]*i%MOD;
	scanf("%d%d",&n,&k);
	if(k==1)
	{
		puts("1");
		return 0;
	}
	--k; f[0][0]=1;
	for(int j=1;j<=n;++j)
		f[0][j]=C(j*k-1,k-1)*f[0][j-1]%MOD;
	for(int i=1;i<=n;++i)
	{
		f[i][i]=f[i-1][i];
		for(int j=i+1;j<=n;++j)
		{
			f[i][j]=(f[i-1][j]+C(
			i+j*k-1,k-1)*f[i][j-1])%MOD;
		}
	}
	ll ans=f[n][n];
	for(int i=1;i<=n;++i) ans=ans*i%MOD;
	ans=(ans%MOD+MOD)%MOD;
	printf("%d\n",int(ans));
}


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

int main(void){
    long long int n, l, r, i, j, min, sum=0, btm, top;
    scanf("%lld %lld", &n, &l);
    btm = l;
    top = l+n-1;
    sum = (btm+top)*n/2;
    if(btm>=0) printf("%lld", sum-btm);
    else if(top<=0) printf("%lld", sum-top);
    else printf("%lld", sum);
    
    
}

Measured memory_bytes: 128
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
	SpeedForce;

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

	while(1) {
		++cur;
		u[0] -= a[1];
		if (u[0] <= 0) break;

		for (int i = 0; i < 2; ++i) swap(a[i], u[i]);
	}
	cout << (cur%2==0 ? "No" : "Yes");
	
	return Accepted;
}

// B...a

Measured memory_bytes: 17756
from operator import add
from functools import reduce

r,c = map(int,input().split())

x = [list(map(int, input().split())) for i in range(r)]


#import numpy as np


#x=[[3,4,5],[1,2,3]]
#a=np.array(x)
#print(a)
#b=reduce(add, a)
#print(b)
#b=list(b)

#x=list(x[1])
#x.append(b)

#print(x)


b = []

for j in range(c):
    a = [x[i][j] for i in range(len(x))]
    b.append(reduce(add,a))

#print(b)

x.append(b)

for i in range(len(x)):
    y = reduce(add,x[i])
    x[i].append(y)
    
    
z = [list(map(str,x[i])) for i in range(len(x))]

#print(z)
#print(z)

w = [' '.join(z[i]) for i in range(len(x))]

[print(w[i]) for i in range(len(w))]



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


int main() {
	
	int N;
	cin >> N;
	bool flag = 1;
	vector<string> w(N);
	set<string> z;
	for(auto &i:w) cin >> i;
	for(int i=1; i<N; i++){
		if(w.at(i-1).back()!=w.at(i).front()) flag = 0;
		z.insert(w.at(i));
	}
	z.insert(w.at(0));
	if(z.size()!=N) flag = 0;
	if(flag) cout << "Yes" <<endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
def lower(word):
    Word = ''
    str = list(word)
    for i in range(len(str)):
        if str[i].isupper(): Word += str[i].lower()
        else: Word += str[i]
    return Word
a = []
for line in sys.stdin:
    a.extend(list(line))


count = [0] * 26
for i in range(len(a)):
    a[i] = lower(a[i])
    if 97 <= ord(a[i]) and ord(a[i]) < 123:
        count[ord(a[i]) - 97] += 1
for i in range(26):
    print(chr(i + 97) + ' : ' + str(count[i]))



Measured memory_bytes: 5584
using System;
using System.Text;

namespace _066_TicTacToe
{
	class Program
	{
		static void Main ( string[] args )
		{
			string inputStr;
			StringBuilder output = new StringBuilder (100);

			while ((inputStr = Console.ReadLine ()) != null)
			{
				char result = IsLine (inputStr);
				output.AppendLine (result.ToString ());
			}
			Console.Write (output);
		}

		static char IsLine ( string result )
		{
			//?¨?
			if (result[0] != 's' && result[0] == result[1] && result[1] == result[2])
			{
				return result[0];
			}
			else if (result[3] != 's' && result[3] == result[4] && result[4] == result[5])
			{
				return result[3];
			}
			else if (result[6] != 's' && result[6] == result[7] && result[7] == result[8])
			{
				return result[6];
			}

			//???
			else if (result[0] != 's' && result[0] == result[3] && result[3] == result[6])
			{
				return result[0];
			}
			else if (result[1] != 's' && result[1] == result[4] && result[4] == result[7])
			{
				return result[1];
			}
			else if (result[2] != 's' && result[2] == result[5] && result[5] == result[8])
			{
				return result[2];
			}

			//??????
			else if (result[0] != 's' && result[0] == result[4] && result[4] == result[8])
			{
				return result[0];
			}
			else if (result[2] != 's' && result[2] == result[4] && result[4] == result[6])
			{
				return result[2];
			}

			return 'd';
		}
	}
}

Measured memory_bytes: 8668
#include <iostream>
using namespace std;
int main(){
    int n; cin >> n;
    cout << n << ":";
    for(int i = 2; i*i <= n; i++){
        while(!(n%i)){
            cout << " " << i;
            n /= i;
        }
    }
    if(n>1) cout << " " << n;
    cout << endl;
}



Measured memory_bytes: 3104
<?php
$d = array_map('trim', file('php://stdin'));
$dummy = array_shift($d);
$sum = array_count_values($d);
$e = ['AC', 'WA', 'TLE', 'RE'];
foreach ($e as $f) {
    printf("%s x %d\n", $f, $sum[$f] ?? 0);
}


Measured memory_bytes: 28252
data class JudgeStatus(
    var ac: Int,
    var wa: Int,
    var tle: Int,
    var re: Int
)

fun main() {
    val judgeStatus = judge(readLine()!!.toInt())

    println("AC x ${judgeStatus.ac}")
    println("WA x ${judgeStatus.wa}")
    println("TLE x ${judgeStatus.tle}")
    println("RE x ${judgeStatus.re}")
}

fun judge(answerCount: Int): JudgeStatus {
    val judgeStatus = JudgeStatus(0,0,0,0)
    repeat(answerCount) {
        when(readLine()!!.toString()) {
            "AC" -> judgeStatus.ac++
            "WA" -> judgeStatus.wa++
            "TLE" -> judgeStatus.tle++
            "RE" -> judgeStatus.re++
        }
    }
    return judgeStatus
}

Measured memory_bytes: 57388
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean ok = true;
        for(int i = 0;i < n;i++){
            int num = sc.nextInt();
            if(num%2 != 0||(num%3==0||num%5==0)){
                ok = true;
            }else{
                ok = false;
                break;
            }
        }
        System.out.println(ok?"APPROVED":"DENIED");
    }
}


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

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define EPS (1e-7)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;


int main(){
	int n;
	cin>>n;
	string s=to_string(n);
	int sum=0;
	for(int i=0;i<s.size();i++){
		sum+=s[i]-'0';
	}
	if(n>=sum && n%sum==0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a,b,c=map(int,input().split())
if a+b>=c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
long long l[100];
int main(){
  int n; cin >> n;
  l[0]=2; l[1]=1;
  for(int i=2;i<=n;i++) l[i]=l[i-1]+l[i-2];
  cout << l[n];
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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; }

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cerr << (*begin) << " ";
    *begin++;
  }
  cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cerr << " " << Array[i][j];
    }
    cerr << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

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

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

  int n = s.size();
  int ans = 0;
  rep (i, n) {
    int cnt = 0;
    repp (j, i, n) {
      if (s[j] == 'A' or s[j] == 'G' or s[j] == 'C' or s[j] == 'T') {
        cnt++;
      } else {
        break;
      }
    }
    chmax(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9
 
const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };
 
 
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	cout << s[0] << s.size()-2 << s[s.size() - 1] << endl;
}

Measured memory_bytes: 256