akhauriyash/Code-Regression huggingface dataset:
r,g,b,n=map(int, input().split())
ans=0
for i in range(3001):
  for j in range(3001):
    v=i*r + j*g
    #print((n-v)/b)
    if n>=v:
      if (n-v)%b == 0:
        ans+=1
print(ans)

Measured memory_bytes: 67700
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1'000'000'007;
constexpr ll mod2 = 998244353;
const double PI = 3.14159265358;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> A(N);
  int mn=inf,mx=0;
  for(int i=0; i<N; i++){
    cin >> A[i];
    chmin(mn,A[i]);
    chmax(mx,A[i]);
  }
  if(mx-mn >= 2){
    cout << "No\n";
  }else if(mx-mn == 1){
    int one=0,many=0;
    for(int i=0; i<N; i++){
      if(A[i] == mx){
        many++;
      }else{
        one++;
      }
    }
    if(one < mx && 2*(mx-one) <= many){
      cout << "Yes\n";
    }else{
      cout << "No\n";
    }
  }else{
    if(mx == N-1 || mx*2 <= N){
      cout << "Yes\n";
    }else{
      cout << "No\n";
    }
  }
  return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n,a,s=0,b;
	cin>>n;
	b=n;
	
	while(n!=0)
	{
		a=n%10;
		n=n/10;
		s+=a;
	}
	
	if(b%s==0)
		cout<<"Yes";
	else
	    cout<<"No";
	
	return 0;
}
    

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

typedef vector<int> vint;

inline int mod(int x, int y){
	return x < y ? x : x - y;
}

vint input(int n){
	vint r(n);
	for(int i = 0; i < n; ++i){
		cin >> r[i];
	}
	return r;
}

vector<vint> xs;
vint ys;

bool match(const vint &x, const vector<vint> &t, int s, int e){
	int n = t.size();

	static vector<char> dp1, dp2;
	dp1.assign(e + 2, 0);
	dp2.assign(e + 2, 0);
	dp1[s] = 1;
	for(int i = 0; i < x.size(); ++i){
		for(int j = s; j <= e; ++j){
			if(dp1[j]){
				for(int k = j; k <= e; ++k){
					if(t[mod(j, n)][mod(k, n)] >> x[i] & 1){
						dp2[k + 1] = 1;
					}
				}
			}
		}
		dp1.swap(dp2);
		fill(dp2.begin(), dp2.end(), 0);
	}
	return dp1[e + 1];
}

vector<vint> CYK(const vint &a){
	int n = a.size();

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

	for(int k = 2; k <= n; ++k)
	for(int s = 0; s < n; ++s){
		int e = s + k - 1;
		for(int i = 0; i < xs.size(); ++i){
			if(match(xs[i], r, s, e)){
				r[s][mod(e, n)] |= 1 << ys[i];
			}
		}
	}

	return r;
}

int main(){
	int n, m, r, k;

	while(cin >> n >> m >> r, n){
		vint a = input(n);
		vint b = input(m);
		
		xs.resize(r);
		ys.resize(r);
		for(int i = 0; i < r; ++i){
			cin >> k;
			xs[i] = input(k);
			cin >> ys[i];
		}

		int ans = -1;
		vector<vint> p = CYK(a), q = CYK(b);

		vector<vint> dp;
		for(int i = 0; i < n; ++i)
		for(int j = 0; j < m; ++j){
			dp.assign(n + 1, vint(m + 1, -100));

			dp[0][0] = 0;
			for(int sa = 0; sa < n; ++sa)
			for(int ea = sa; ea < n; ++ea)
			for(int sb = 0; sb < m; ++sb)
			for(int eb = sb; eb < m; ++eb){
				if(p[mod(sa + i, n)][mod(ea + i, n)] & q[mod(sb + j, m)][mod(eb + j, m)]){
					dp[ea + 1][eb + 1] = max(dp[ea + 1][eb + 1], dp[sa][sb] + 1);
				}
			}
			ans = max(ans, dp[n][m]);
		}
		cout << ans << '\n';
	}
}

Measured memory_bytes: 1252
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
const int mod = 10000;
string a, b; int m, power[509], modm[6009], dp[509][11][2][509];
int solve(string s, int z) {
	// [1, s]
	int n = s.size();
	int ret1 = 0;
	for (int i = z; i < n - 1; i++) {
		for (int j = 1; j <= 9; j++) ret1 += dp[i][j][z][0];
		while (ret1 >= mod) ret1 -= mod;
	}
	int mod1 = 0;
	for (int i = n - 1; i >= 0; i--) {
		int r = s[i] - 48, tl = (i == n - 1 ? 1 : 0), tr = (i == 0 ? r : r - 1);
		if (i != n - 1) {
			if ((i + z) & 1) tl = max(tl, s[i + 1] - 48 + 1);
			else tr = min(tr, s[i + 1] - 48 - 1);
		}
		for (int j = tl; j <= tr; j++) ret1 += dp[i][j][z][mod1];
		while (ret1 >= mod) ret1 -= mod;
		mod1 = (mod1 - r * power[i] + r * m) % m;
		if (i != n - 1) {
			if (((i + z) & 1) && s[i + 1] >= s[i]) break;
			if (!((i + z) & 1) && s[i + 1] <= s[i]) break;
		}
	}
	return ret1;
}
int main() {
	cin >> a >> b >> m;
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	a[0]--;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] < 48) {
			a[i] += 10;
			a[i + 1]--;
		}
	}
	if (a.back() == 48) a.pop_back();
	if (a == "") a = "0";
	for (int i = 0; i <= 6000; i++) modm[i] = i % m;
	power[0] = modm[1];
	for (int i = 1; i <= 500; i++) power[i] = power[i - 1] * 10 % m;
	for (int i = 0; i <= 9; i++) dp[0][i][0][i % m] = dp[0][i][1][i % m] = 1;
	for (int i = 1; i <= 500; i++) {
		for (int j = 0; j <= 9; j++) {
			for (int k = 0; k < m; k++) {
				int z = modm[k - j * power[i] + j * m];
				if (i & 1) {
					for (int l = 0; l < j; l++) dp[i][j][0][k] += dp[i - 1][l][0][z];
					for (int l = 9; l > j; l--) dp[i][j][1][k] += dp[i - 1][l][1][z];
				}
				else {
					for (int l = 9; l > j; l--) dp[i][j][0][k] += dp[i - 1][l][0][z];
					for (int l = 0; l < j; l++) dp[i][j][1][k] += dp[i - 1][l][1][z];
				}
				while (dp[i][j][0][k] >= mod) dp[i][j][0][k] -= mod;
				while (dp[i][j][1][k] >= mod) dp[i][j][1][k] -= mod;
			}
		}
	}
	int ret1 = (solve(a, 0) + solve(a, 1)) % mod;
	int ret2 = (solve(b, 0) + solve(b, 1)) % mod;
	cout << (ret2 - ret1 + mod) % mod << endl;
	return 0;
}

Measured memory_bytes: 24004
#include <bits/stdc++.h>
#include<assert.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

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

signed main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, 0, n) cin >> a[i];
    bool p = 1, s = 1;

    set<int> st;
    rep(i, 0, n) {
        int q = a[i];
        for (int j = 2; j * j <= q; j++) {
            if (q % j == 0) {
                assert(j>=1);
                //if (*st.find(j) == j) {
                if(st.count(j)>0){
                    p = 0;
                    break;
                }
                st.insert(j);
                while (q % j == 0) {
                    q /= j;
                }
            }
        }
        assert(q>=1);
        if (q != 1) {
            //if (*st.find(q) == q) p = 0;
            if(st.count(q)>0)p=0;
        }
        st.insert(q);
        if (!p) break;
    }

    // for (auto p : st) cout << p << " ";

    int now = a[0];
    rep(i, 0, n) { now = gcd(now, a[i]); }
    if (now != 1) s = 0;

    if (p) {
        cout << "pairwise coprime\n";
    } else if (s) {
        cout << "setwise coprime\n";
    } else {
        cout << "not coprime\n";
    }
}


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

using namespace std;

//#define FILE_IO

const int mod = 924844033;

int N, K;
int cupl[2005][2005][3];
int cpl[2005];
int lst[2005];
int fct[2005];

int add(int x, int y)   {int ans = x + y; if(ans >= mod) ans -= mod; return ans;}
int mul(int x, int y)   {return (1LL * x * y) % mod;}
int sub(int x, int y)   {int ans = x - y; if(ans < 0)   ans += mod; return ans;}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d", &N, &K);

    vector <int> prm;
    for(int i = 1; i <= N; i++)
        prm.push_back(i);

    /*do
    {
        int ok = 1;
        for(int i = 0; i < N; i++)
        {
            int x = abs(prm[i] - (i + 1));
            if(x == K)  ok = 0;
        }

        if(ok)
        {
            for(auto x: prm)
                printf("%d ", x);
            printf("\n");
        }
    }while(next_permutation(prm.begin(), prm.end()));
    return 0;*/

    cupl[0][0][0] = 0;
    cupl[0][0][1] = cupl[0][0][2] = 1;
    cupl[1][0][0] = cupl[1][0][1] = cupl[1][0][2] = 1;
    cupl[1][1][0] = 0;
    cupl[1][1][1] = 1;
    cupl[1][1][2] = 2;

    for(int i = 2; i <= N; i++)
    {
        cupl[i][0][0] = cupl[i][0][1] = cupl[i][0][2] = 1;
        cupl[i][1][0] = ( 2 * (i - 1) ) % mod;
        cupl[i][1][1] = ( 2 * (i - 1) + 1 ) % mod;
        cupl[i][1][2] = ( 2 * (i - 1) + 2 ) % mod;

        for(int j = 2; j <= i; j++)
        {
            //cupl[i][j][0] = cupl[i - 1][j][1] + cupl[i - 1][j - 1][0];
            cupl[i][j][0] = add( cupl[i - 1][j][1], cupl[i - 1][j - 1][0] );
            //cupl[i][j][1] = cupl[i - 1][j][2] + cupl[i - 1][j - 1][1];
            cupl[i][j][1] = add( cupl[i - 1][j][2], cupl[i - 1][j - 1][1] );
            //cupl[i][j][2] = cupl[i - 1][j][2] + cupl[i - 1][j - 1][2] + cupl[i - 1][j - 1][1];
            cupl[i][j][2] = add( cupl[i - 1][j][2], add(cupl[i - 1][j - 1][2], cupl[i - 1][j - 1][1]) );
        }
    }

    cpl[0] = 1;
    for(int i = 1; i <= 2 * K && i <= N; i++)
    {
        for(int j = 0; j <= N; j++)
            lst[j] = cpl[j];

        int x = (N - i) / (2 * K) + 1;
        int y = 0;
        if(i > K)   y = floor( (double)(N - (i - K)) / (double)(2 * K) ) + 1;
        else y = floor( (double)(N - (i + K)) / (double)(2 * K) ) + 1;

        if(x - 1 == y)  y = 0;
        else if(x == y) y = 1;
        else if(x + 1 == y) y = 2;

        for(int j = 0; j <= N; j++)
        {
            cpl[j] = 0;
            for(int k = 0; k <= x && k <= j; k++)
                cpl[j] = add(cpl[j], mul(lst[j - k], cupl[x][k][y]));
        }
    }

    fct[0] = 1;
    for(int i = 1; i <= N; i++)
        fct[i] = mul(fct[i - 1], i);

    int ans = 0;
    for(int i = 0; i <= N; i++)
    {
        if(i % 2 == 0)  ans = add(ans, mul(cpl[i], fct[N - i]));
        else    ans = sub(ans, mul(cpl[i], fct[N - i]));
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 45696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e18;
template<class T> void print(const T& t){ cout << t << endl; }
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin >> n;
  vector<vector<double>> dp(n + 1, vector<double>(n + 1));
  rep(i, n+1){
    rep(j,n+1){
      dp[i][j] = 0;
    }
  }
  vector<double> p(n);
  rep(i,n){
    cin >> p[i];
  }
  dp[0][0] = 1;
  for (ll i = 1; i <= n; i++){
    dp[i][0] = dp[i - 1][0] * ((double)1-p[i-1]);
    for (ll j = 1; j <= i; j++){
      dp[i][j] += dp[i - 1][j] * ((double)1-p[i-1]) + dp[i - 1][j - 1] * p[i-1];
    }
  }
  ld ans = 0;
  for (ll i = (n + 1) / 2; i <= n; i++){
    ans += dp[n][i];
  }
  cout << fixed << setprecision(10)<<ans << endl;
}

Measured memory_bytes: 71680
#include<iostream>
#include<algorithm>
#include<vector>
#define PP std::pair<int,int>
int N;
int L[51];
std::vector<PP> D[51][51];
int res[51][51];
int ans=1<<30;
int main(){
    std::cin>>N;
    for(int i=1;i<=N;i++){
        std::cin>>L[i];
        L[i]+=L[i-1];
    }
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            res[i][j]=1<<30;
        }
    }
    for(int i=0;i<=N;i++){
        D[i][1].push_back(PP{L[i],L[i]});
        ans=std::min(ans,std::abs(L[N]-L[i]-L[i]));
    }
    for(int i=1;i<N;i++){
        for(int j=2;j<=i;j++){
            for(int k=j-1;k<i;k++){
                for(auto u:D[k][j-1]){
                    int m=std::min({u.first,L[N]-L[i],L[i]-L[k]});
                    int M=std::max({u.second,L[N]-L[i],L[i]-L[k]});
                    if(res[i][j]>=M-m){
                        if(res[i][j]>M-m){
                            D[i][j].clear();
                        }
                        res[i][j]=M-m;
                        ans=std::min(res[i][j],ans);
                        int m=std::min(u.first,L[i]-L[k]);
                        int M=std::max(u.second,L[i]-L[k]);
                        if(M-m>ans)continue;
                        D[i][j].push_back(PP{m,M});
                    }
                }
            }
        }
    }
    std::cout<<ans<<std::endl;
    return 0;
}



Measured memory_bytes: 7724
# -*- coding: utf-8 -*-
n = int(input())
s = []
for i in range(n):
    s.append(input())
m = int(input())
t = []
for i in range(m):
    t.append(input())

ans = 0
for i in range(n):
    tmp = s.count(s[i]) - t.count(s[i])
    if tmp > ans:
        ans = tmp
print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define FF first
#define SS second

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

const int N = 800;

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

string s[N];
int n,m,k;
int ans;
int dist[N][N];
queue<pii > q;

int main() {
  scanf("%d%d%d",&n,&m,&k);
  rep(i,0,n) cin >> s[i];
  int x,y;
  rep(i,0,n) rep(j,0,m) if(s[i][j] == 'S') {
    x = i; y = j;
  }

  q.push(mp(x,y));
  memset(dist, -1, sizeof(dist));
  dist[x][y] = 0;
  while(q.size()) {
    pii p = q.front();
    q.pop();
    rep(i,0,4) {
      int a = p.FF + dx[i];
      int b = p.SS + dy[i];
      if(a < 0 || a >= n || b < 0 || b >= m) continue;
      if(s[a][b] == '#' || dist[a][b] != -1) continue;
      dist[a][b] = dist[p.FF][p.SS] + 1;
      q.push(mp(a,b));
    }
  }

  int ans = n * m;
  rep(i,0,n) rep(j,0,m) if(dist[i][j] != -1 && dist[i][j] <= k) {
    int cur = min(i, j);
    cur = min(cur, n - 1 - i);
    cur = min(cur, m - 1 - j);

    ans = min(ans, (cur + k - 1) / k + 1);
  }
  P(ans);

  return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    cout << ((s[2] == s[3] && s[4] == s[5]) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

constexpr ll mod = 1e9 + 7;
const double PI = acos(-1.0);

vector<int> par;
vector<int> rak; // number of edges
vector<ll> sum; // sum of the weight of vertices
vector<int> ans; // number of edges satisfied

void init(int n) {
  par.resize(n+1);
  rak.resize(n+1);
  sum.resize(n+1);
  ans.resize(n+1);
  for(int i=1; i<=n; i++) {
    par.at(i) = i;
    rak.at(i) = 0;
    cin >> sum[i];
  }
}

int find(int x) {
  if (par.at(x) == x) {
    return x;
  } else {
    return par.at(x) = find(par.at(x));
  }
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x==y) return;
  if (rak.at(x) < rak.at(y)) {
    rak[y] += rak[x];
    sum[y] += sum[x];
    ans[y] += ans[x];
    par.at(x) = y;
  } else {
    rak[x] += rak[y];
    sum[x] += sum[y];
    ans[x] += ans[y];
    par.at(y) = x;
  }
}

void calc(int x, ll len) {
  x = find(x);
  rak[x]++;
  if (len <= sum[x]) {
    ans[x] = rak[x];
  }
}

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

  int n, m; cin >> n >> m;
  init(n);
  vector<pair<int, P>> vec(m);
  rep(i, m) {
    int a, b, y; cin >> a >> b >> y;
    vec[i] = make_pair(y, P(a,b));
  }

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

  for(auto e: vec) {
    auto a = e.second.first;
    auto b = e.second.second;
    auto len = e.first;
    unite(a,b);
    a = find(a);
    calc(a,len);
    //debug(x); debug(rak[x]); debugln(ans[x]);
  }
  cout << m - ans[find(1)] << endl;
}

Measured memory_bytes: 3456
# import sys
# sys.stdin = open('input.txt', 'r')

class Card:
    def __init__(self):
        self.suit = ''
        self.num = 0
    def __str__(self):
        return self.suit + ' ' + str(self.num)

def merge(A, left, mid, right):
    """
    right: 最後の添字 + 1
    """
    SENTINEL = Card()
    SENTINEL.num = 2 * 10**9

    n1 = mid - left;
    n2 = right - mid;
    L = A[left:left+n1]
    R = A[mid:mid+n2]

    L.append(SENTINEL)
    R.append(SENTINEL)
    i = 0
    j = 0

    for k in range(left, right):
        if L[i].num <= R[j].num:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2;
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

def partition(A, p, r):
    """
    r: 最後の添字
    """
    x = A[r].num # last item
    i = p - 1
    for j in range(p, r):
        if A[j].num <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i + 1 # index of the initial A[r]

def quickSort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quickSort(A, p, q-1)
        quickSort(A, q+1, r)

n = int(input())
A = []
for i in range(n):
    x = Card()
    x.suit, x.num = input().split()
    x.num = int(x.num)
    A.append(x)

A_mergeSort = A[:]
mergeSort(A_mergeSort, 0, n)
quickSort(A, 0, n-1)
isStable = True

for i in range(n):
    if A[i].suit == A_mergeSort[i].suit and A[i].num == A_mergeSort[i].num:
        pass
    else:
        isStable = False

print('Stable') if isStable else print('Not stable')

for i in A:
    print(i)


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

int main(){
    int n; cin >> n;
    string s; cin >> s;
    for(int i = 0; i < s.size(); i++)
        s[i] = ((s[i]-'A'+n)%26) + 'A';
    cout << s << endl;
	return 0;
}


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

typedef long long ll;

int main()
{
    int cnt=0;
    ll x,y;
    cin>>x>>y;
    while(x<=y)
    {
        x=(ll)x*(ll)2;
        cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}


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

const int MAXN = 4e5 + 10; //dummy
const ll MOD = 1e9 + 7;

template<typename T>
T fast_powerModulo( T a, T b, T M){T res = (T)1;a %= M;while( b ){if( b & 1 ) res = (res * a) % M;b >>= 1;a *= a;a %= M; }return res;}

void solve(){
	ll H; cin >> H;
	ll pow2 = 0;
	ll temp = 0;
	ll ans = 1;
	while( H ){
		H /= 2LL;
		temp++;
	}
	for(int i = 0; i < temp; ++i){
		ans *= 2LL;
	}
	cout << ans - 1<< '\n';
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
	//int t; cin >> t;
	//while( t-- )
		solve();
	return 0;
}

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

int solve(int n) {
	int i, j;
	int answer = 0;
	for (i = 1; i <= n; i += 2) {
		int temp = 0;
		for (j = 1; j <= n; j++)
			if (i % j == 0) temp++;
		if (temp == 8) 
			answer++;
	}
	return answer;
}

int main() {
	int n;
	cin >> n;
	cout << solve(n) << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define Reverse(x) reverse(all(x));
#define Sort(x) sort(all(x));
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli n;
    cin >> n;
    for (lli i = 1; i < 10;i++)
    {
        if(111*i>=n)
        {
            out(111 * i);
            return 0;
        }
    }
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;

    class Program
    {
        static void Main(string[] args)
        {
            string line1 = Console.ReadLine();
            string line2 = Console.ReadLine();

            int N = int.Parse(line1);
            List<int> B = new List<int>(line2.Split(' ').Select((arg) => int.Parse(arg)));
            int[] A = new int[N];

            int point = 0;

            A[0] = B[0];

            for(int i = 0; i < N; i++)
            {
                if (i+1 < A.Length)
                {
                    A[i + 1] = B[i];
                    if (A[i + 1] < A[i])
                    {
                        A[i] = A[i + 1];
                    }
                }
            }

            // List<int> Nums = new List<int>(line1.Split(' ').Select((arg) => int.Parse(arg)));

            for(int i = 0; i < A.Length; i++)
            {
                point += A[i];
                
            }
Console.Write(point);

        }
    }

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char const *argv[])
{
	int x, y, z, K;
	cin >> x >> y >> z >> K;
	vector<ll> a(x), b(y), c(z);
	rep(i, a.size()) cin >> a[i];
	rep(i, b.size()) cin >> b[i];
	rep(i, c.size()) cin >> c[i];

	sort(all(a), greater<ll>());
	sort(all(b), greater<ll>());
	sort(all(c), greater<ll>());

	vector<ll> ab, abc;
	rep(i, min((int)a.size(), K)) rep(j, min((int)b.size(), K)) ab.push_back(a[i] + b[j]);
	sort(all(ab), greater<ll>());
	rep(i, min((int)ab.size(), K)) rep(j, min((int)c.size(), K)) abc.push_back(ab[i] + c[j]);
	sort(all(abc), greater<ll>());
	rep(i, K) cout << abc[i] << endl;

	return 0;
}

Measured memory_bytes: 43240
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int n;
    cin>>n;
    vector<int> v(n,0);
    vector<int> v2(n,0);

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


    for(int i=n/2+1;i<n;i++){
      if(v[i]){
          ans.push_back(i+1);
          v2[i]=1;
      }else{
          v2[i]=0;
      }
    }

    int k;
    for(int i=(n)/2;i>=0;i--){
        k=i+1;
        int sum=0;

        for(int j=2;j*k<=n;j++){
            sum+=v2[j*k-1];
        }

        if(sum%2==1&&v[i]==0){
            ans.push_back(i+1);
            v2[i]=1;
        }else if(sum%2==0&&v[i]==1){
            ans.push_back(i+1);
            v2[i]=1;
        }


    }


cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++){
        cout<<ans[i]<<" ";
    }


    return 0;
}


Measured memory_bytes: 3064
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N, Q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N-1)]
px = [list(map(int, input().split())) for _ in range(Q)]
cnter = [0]*N
edge = [[] for _ in range(N)]
seen = [0]*N

for pxi in px:
    p, x = pxi
    cnter[p-1] += x

for abi in ab:
    a, b = abi
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

stack = deque()
stack.append([0])
while stack[0]:
    nstack = []
    cstack = stack.pop()
    #print('cstack:', cstack)
    for index in cstack:
        seen[index] = 1
        for edgei in edge[index]:
            if seen[edgei] == 0:
                nstack.append(edgei)
                cnter[edgei] += cnter[index]
    stack.append(nstack)

print(*cnter)



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


int dp[100];

//最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


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

  int all = 0;
  rep(i, n) all += w[i];

  int left = 0;
  int ans = 1e9;
  rep(i, n){
    left += w[i];
    int right = all - left;
    ans = min(ans, abs(left - right));
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
fn main() {
    let scan = std::io::stdin();
    let mut line = String::new();
    let _ = scan.read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();
    let mut n: i32 = vec[0].parse().unwrap();

    let mut ans: i32 = 0;
    loop{
        if n % 2 == 1 {
            ans = ans + 1
        }else{

        }
        if n / 10 == 0{
            break;
        }else{
            n = n / 10;
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 4352
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def hitofude(H, W):
    for row in range(H):
        for col in range(W):
            if row % 2 == 1:
                new_col = W - 1 - col
            else:
                new_col = col
            yield (row, new_col)


def main():
    H, W = LI()
    A = []
    for _ in range(H):
        a = LI()
        A.append(a)
    cur = list(hitofude(H, W))[:-1]
    nex = list(hitofude(H, W))[1:]
    ans = []
    for (cur_r, cur_c), (nex_r, nex_c) in zip(cur, nex):
        if A[cur_r][cur_c] % 2 == 0:
            pass
        else:
            A[cur_r][cur_c] -= 1
            A[nex_r][nex_c] += 1
            ans.append((cur_r + 1, cur_c + 1, nex_r + 1, nex_c + 1))
    print(len(ans))
    for a in ans:
        print(*a)

main()



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

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

  bool is_even = false;
  for (auto c : s) {
    if ((c == 'L' && !is_even) ||
        (c == 'R' && is_even)) {
      std::cout << "No";
      return 0;
    }
    is_even = !is_even;
  }

  std::cout << "Yes";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, ans;
int a[200021];
int main () {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = n; i >= 1; i--) {
		for (int j = 2 * i; j <= n; j += i) {
			a[i] ^= a[j];
		}
		if (a[i]) {
			ans++;
		}
	}
	printf("%d\n", ans);
	for (int i = 1; i <= n; i++) {
		if (a[i]) {
			printf("%d\n", i);
		}
	}
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define Rep(i, N) for(int i = 0; i < N; i++)

signed main()
{
  int N;

  while(cin >> N, N) {

    int A[1005];
    
    Rep(i, N) cin >> A[i];

    sort(A, A + N);
    
    int minv = 1LL << 60;

    Rep(i, N - 1) {
      minv = min(minv, A[i + 1] - A[i]);
    }

    cout << minv << endl;

  }

  return 0;
}

Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<bitset>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define LONG_INF 9223372036854775807
#define INF 1000000000LL
#define EPS 1e-10
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define dump(a) rep(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define all(v) v.begin(),v.end()
#define pb push_back


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

    int N, M;
    cin >> N >> M;
    if(N==M) cout <<"Yes"<<endl;
    else cout << "No" << endl;

    return 0;
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;
ll m;
template <typename T>
T zero_sum_ranges(vector<T> A) {
    T n = A.size();
    T sum[n + 1] = {};
    sum[1] = A[0];
    map<T, T> mp;
    for(size_t i = 0; i < n; i++) {
        sum[i + 1] = (sum[i] + A[i]) % m;
    }
    T ret = 0;
    for(size_t i = 0; i <= n; i++) {
        if(mp.count(sum[i])) ret += mp[sum[i]];
        mp[sum[i]]++;
    }
    cout << ret << endl;
}

int main() {
    ll n, i, j, k;
    cin >> n >> m;
    vector<ll> v(n);
    for(auto &x:v)cin >> x;
    zero_sum_ranges(v);
    return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>
int main(void){
   int m,f,r;
   

   while(1){
       scanf("%d %d %d",&m,&f,&r);
       if(m==-1&&f==-1&&r==-1)break;
       
       if(m==-1||f==-1) printf("F\n");
       else if(80<=m+f) printf("A\n");
       else if(65<=m+f&&m+f<80) printf("B\n");
       else if(50<=m+f&&m+f<65) printf("C\n");
       else if(30<=m+f&&m+f<50){
           if(r>=50) printf("C\n");
           else printf("D\n");
       }
       else printf("F\n");
   }
   return 0;
}


Measured memory_bytes: 2080
import math
N = int(input())
number = [2]*N
ans = 1
if(N>=2):
  for i in range(2,N+1):
    ans += number[i-1]*i
    #if(i<=math.sqrt(N)):
    if(i <= int(N/2)):
      for j in range(2,N//i+1):
        number[i*j-1] += 1
print(ans)  

Measured memory_bytes: 146020
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,m;
	cin>>m>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	int ma=0;
	in.pb(in[0]+m);
	rep(i,n)cmax(ma,in[i+1]-in[i]);
	cout<<m-ma<<endl;
	
}






Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int N, A, B, C;
vector<int> L(8);
int ans = 1000000000;

int calc(vector<int> v){
    int num[4] = {}, sum[4] = {};
    for(int i=0;i<N;i++){
        num[v[i]]++;
        sum[v[i]] += L[i];
    }
    if( num[0]==0 or num[1]==0 or num[2]==0 ) return false;

    int ret = ( (num[0]-1) + (num[1]-1) + (num[2]-1) ) * 10;
    ret += abs(A-sum[0]) + abs(B-sum[1]) + abs(C-sum[2]);
    return ans = min(ans, ret);
}

int dfs(int depth, vector<int> v){
    if( depth == N ) return calc(v);

    for(int i=0;i<4;i++){
        v[depth] = i;
        dfs(depth+1, v);
    }
}

int main() {
    cin >> N >> A >> B >> C;

    for(int i=0;i<N;i++)    cin >> L[i];

    vector<int> v(N);
    dfs(0, v);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100
int main()
{
    int m[N][N];
    int n, u, k, v;
    scanf("%d",&n);
    for(int i=0; i < n; i++ ) 
    {
        for(int j = 0; j < n; j++ )
        {
            m[i][j] = 0;
        }
    }
    for( int i = 0; i < n; i++) 
    {
        scanf(" %d %d ",&u,&k);
        u--;
        for(int j = 0; j < k; j++ ) 
        {
            scanf("%d",&v);
            v--;
            m[u][v] = 1;
        }
    }
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++ )
        {
            if( j ) 
            {
                printf(" ");
            }
            printf("%d",m[i][j]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2132
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>>a(1000,vector<char>(1000));
    vector<int>x(100);
    vector<int>y(100);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
        }
    }
      for(int i=0;i<100;i++){
          x[i]=0;
          y[i]=0;
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]=='#'){
                x[i]=1;
                y[j]=1;
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(x[i]==0||y[j]==0){

            }
            else{
                cout<<a[i][j]<<flush;
            }
        }if(x[i]==1){
            cout<<endl;
        }
    }
    

    return 0;
}

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

int main()
{
    int N, K, Q;
    cin >> N >> K >> Q;

    vector<int> A(N, K - Q);
    rep(i,Q) {
        int a;
        cin >> a;
        A[a - 1]++;
    }

    rep(i,N) cout << ((A[i] > 0) ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 1024
n = int(input())
nums = list(map(str, input().split()))
ans = ['-1' for i in range(n)]
for i in range(n)[::-1]:
    k = (n-1-i)
    if k % 2 == 0:
        ans[k//2] = nums[i]
    else:
        ans[n-1-(k//2)] = nums[i]
print(' '.join(ans))


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M;
    cin >> N >> M;
    map<ll, ll> cnt;
    rep(i, M) {
        ll a, b;
        cin >> a >> b;
        cnt[a]++;
        cnt[b]++;
    }
    bool ok = true;
    for (P p : cnt) {
        if (p.second % 2) {
            ok = false;
        }
    }
    cout << (ok ? "YES" : "NO") << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int n;
  cin >> n;
  cout << "ABC" << n << endl;
}



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

using namespace std;

const int inf = 1e9;

vector<vector<int>> warshall_floyd(vector<vector<int>> costs) {
	int n = costs.size();
	for (int i = 0; i < n; i++) {
		costs[i][i] = 0;
	}

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

	return costs;
}

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

	vector<int> r(R);
	for (int i = 0; i < R; i++) {
		cin >> r[i];
		r[i]--;
	}

	vector<vector<int>> costs(N, vector<int>(N, inf));
	int a, b, c;
	for (int i = 0; i < M; i++) {
		cin >> a >> b >> c;
		a--;
		b--;
		costs[a][b] = c;
		costs[b][a] = c;
	}

	costs = warshall_floyd(costs);
	sort(r.begin(), r.end());

	long long ans = inf;
	do {
		long long dist = 0;
		for (int i = 1; i < R; i++) {
			dist += costs[r[i-1]][r[i]];
		}
		ans = min(ans, dist);
	} while (next_permutation(r.begin(), r.end()));

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


Measured memory_bytes: 512
import math
MOD=10**9+7
N=int(input())
x=list(map(int, input().split()))
y=[x[i+1]-x[i] for i in range(N-1)]
N_1=N-1
upp=math.factorial(N_1)%MOD
  
b=[0]*(N_1)
b[0]=upp
tmp=upp
out=b[0]*y[0]%MOD
for i in range(1, N_1):
  a=tmp*pow(i+1, MOD-2, MOD)%MOD
  b[i]=(b[i-1]+a)%MOD
  out+=b[i]*y[i]%MOD
  out%=MOD
print(out)

Measured memory_bytes: 71192
a,b,c = map(int, input().split())
if a < b :
    if b < c:
        print(a,b,c)
    else:
        print(a,c,b)
elif b < c:
    if c < a:
        print(b,c,a)
    else:
        print(b,a,c)
elif c < a:
    if a < b:
        print(c,a,b)
    else:
        print(c,b,a)


Measured memory_bytes: 5592
n=int(input())
A=[]
for i in range(n):
    a=int(input())
    A.append(a-1)
t = 0
r = 0
while True:
    t = A[t]
    r += 1
    if t == 1:
        print(r)
        break
    if r == n:
        print(-1)
        break


Measured memory_bytes: 7084
n = int(input())
C = []
S = []
F = []
for i in range(n-1):
  c,s,f = map(int, input().split())
  C.append(c)
  S.append(s)
  F.append(f)  
  
for i in range(n):
  t = 0
  for j in range(i,n-1):
    if t < S[j]:
      t = S[j]
    elif t % F[j] == 0:
      pass#到着タイミングと発車タイミングが同じなので待ち時間0
    else:
      t = t + F[j] - (t % F[j])  
    t += C[j]
  print(t)

Measured memory_bytes: 3188
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;


int main(){
    int x[5];
    int cnt =0;
    for(int i=0;i<5;i++){
        cin >> x[i];
    }
    for(int i=0;i<5;i++){
        if(x[i]==0){
            cnt = i;
        }
    }
    cout << cnt+1 << endl;
    return 0;
}


Measured memory_bytes: 3632
fun main() {
    abc134d()
}

fun abc134d() {
    val n = readLine()!!.toInt()
    // 各桁について、1ならiの倍数が奇数個になるようにするという意味
    val a = BooleanArray(n + 1) { false }
    for ((i, s) in readLine()!!.split(" ").withIndex()) {
        a[i + 1] = s == "1"
    }
    val ans = mutableSetOf<Int>()
    var i = n
    while (i * 2 > n) {
        if (a[i]) ans.add(i)
        i--
    }
    while (i > 1) {
        var k = 2
        var count = 0
        while (i * k <= n) {
            if (i * k in ans) count++
            k++
        }
        val isOdd = count % 2 == 1
        if (isOdd xor a[i]) ans.add(i)
        i--
    }
    if (a[1]) {
        if (ans.size % 2 == 0) ans.add(1)
    } else {
        if (ans.size % 2 == 1) ans.add(1)
    }
    println(ans.size)
    println(ans.joinToString(" "))
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int n, m;
  cin >> n >> m;

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

  for (int i = 0; i < n; ++i) {
    cout << r[i] << '\n';
  }

  return 0;
}


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

using namespace std;

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

    string numbers = to_string(N);

    string answer = "No";
    for (char number : numbers) {
        if (number == '7') {
            answer = "Yes";
            break;
        }
    }

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 3692
#include <stdio.h>

int main(void) {
  int i, j, h, w, k;
  while( 1 ) {
    scanf("%d%d", &h, &w);
    if(!h && !w) break;
    for(j = 0; j < h; ++j) {
      for(k = 0; k < w; ++k) {
        if(!((k + j) % 2)) printf("#");
        else printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2600
N,M=map(int,input().split())
G1 = [set() for _ in range(N)]
G2 = [set() for _ in range(N)]

for i in range(N-1+M):
  a,b=map(int,input().split())
  G1[a-1].add(b-1)
  G2[b-1].add(a-1)
  
# https://ikatakos.com/pot/programming_algorithm/graph_theory/topological_sort
inc = [len(G2[i]) for i in range(N)]
S = {i for i, c in enumerate(inc) if c == 0}
L = []

while S:
    n = S.pop()
    L.append(n)
    for m in G1[n]:
        inc[m] -= 1
        if inc[m] == 0:
            S.add(m)

d = [-1]*N
d[L[0]]=0

ans=[0]*N
for v in L[1:]:
  MAX=0
  argmax=-1
  for p in G2[v]:
    if d[p] != -1 and MAX<d[p]+1:
      MAX=d[p]+1
      argmax=p+1
  d[v] = MAX
  ans[v]=argmax

print(*ans)

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

int main() {
  string S;
  cin >> S;
  int count = 1;
  vector<int> num(1000);
  for(int i = 0; i < S.size(); i++){
    int snum = S.at(i) - 'a';
    num.at(snum)++;
  }
  
  for(int i = 0; i < 26; i++){
    if(num.at(i) == 0){
      char ans = i + 'a';
      cout << ans << endl;
      count =0;
      break;
    }
  }
  
  if(count){
    cout << "None" << endl;
  }
}

Measured memory_bytes: 512
import sys
n = int(sys.stdin.readline().rstrip("\n"))
ans = 0
zorome = 0
for _ in range(n):
    d1,d2 = map(int, sys.stdin.readline().rstrip("\n").split())
    if d1 == d2:
        zorome += 1
    else:
        zorome = 0
    ans = max(ans,zorome)
if ans >= 3:
    print('Yes')
else:
    print('No')

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

int main(){
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  int x[N], y[M];
  int max = -120;
  int min = 120;
  
  for(int i = 0; i < N; i++){
    cin >> x[i];
    if(max < x[i]) max = x[i];
  }
  //cout << max << endl;
  for(int i = 0; i < M; i++){
    cin >> y[i];
    if(min > y[i]) min = y[i];
  }
  //cout << min << endl;
  int cnt = 0;
  for(int z = X + 1; z <= Y; z++){
    if(z > max && z <= min) cnt++;
  }
  if(cnt != 0) cout << "No War" << endl;
  else cout << "War" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#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
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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(int argc, char const *argv[]) {
  string s;
  cin >> s ;

  if(sz(s)==1){
    cout << "0" << endl;
    return 0;
  }

  int n=sz(s),ans=0;
  char c=s[0],one='1',zero='0';
for(int i=0; i<n-1; i++){
  if(s[i]==s[i+1]){
    ans++;
    if(s[i]==one) s[i+1]=zero;
    else s[i+1]=one;
  }

}
cout << ans << endl;

  return 0;
}


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


string Tolower(string s){
    string t = s;
    for(int i = 0; i < s.size(); i++){
        t[i] = toupper(s[i]);
    }

    return t;
}

int main(){
    string word , bun;
    cin >> word ;

    word = Tolower(word);

    int cnt = 0;

    while(1){
        cin >> bun;
        if(bun == "END_OF_TEXT"){
            break;
        }
        bun = Tolower(bun);
        if(word == bun) cnt++;
    }    
    cout << cnt << endl;

    return 0;

}





Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int a, b, c, k;

int main() {
#ifdef _0219nice
	freopen("1.in", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	while (cin >> a >> b >> c >> k) {
		int ans = 0;
		vector<pair<int, int>> nums = {{a, 1}, {b, 0}, {c, -1}};
		for (int i = 0; i < 3; i++) {
			ans += min(k, nums[i].first) * nums[i].second;
			k -= nums[i].first;
			if (k <= 0) break;
		}
		cout << ans << "\n";
	}
	return 0;
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	int a, b;

	cin >> a >> b;

	if (a < b) {
		for (int i = 0; i < b; i++) {
			printf("%d", a);
		}
		puts("");
	} else {
		for (int i = 0; i < a; i++) {
			printf("%d", b);
		}
		puts("");
	}

	return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()
l=[0]
for i in range(n):
    l.append(l[i]+(s[i]=="R"))
ans=n
#print(l)
for i in range(n+1):
    ans=min(ans,abs(l[i]-i)+abs(l[-1]-l[i]))
    #print(ans,i)
    if i==l[-1]:
        ans=min(ans,abs(l[i]-i))
        #print(ans)
print(ans)


Measured memory_bytes: 17080