akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

def main():
  n, m = map(int, input().split())
  p = 2 ** n
  inf = 10 ** 9
  dp = [inf] * p
  dp[0] = 0

  for _ in range(m):
    a, _ = map(int, input().split())
    c = sum([2**(int(j)-1) for j in list(input().split())])
    for k in range(p):

        ## 同じ状態を再現するのにより多くのお金を使っていた場合
      if dp[k|c] > dp[k] + a:
        dp[k|c] = dp[k] + a

  if dp[-1] == inf:
    print(-1)
  else:
    print(dp[-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#why is this solotion valid?
"""
n=int(input())
xy=[]
for _ in range(n):
	x,y=map(int,input().split())
	xy.append([x,y])
ans=0
for i in range(n):
	for j in range(n):
		ans+=((xy[i][0]-xy[j][0])**2+(xy[i][1]-xy[j][1])**2)**0.5
print(ans/n)
"""



from itertools import permutations
from math import hypot, factorial

n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
d = lambda x1,y1,x2,y2: ((x1-x2)**2 + (y1-y2)**2)**0.5

x = 0
for i in permutations(a):
	for j in range(n-1):
		x += d(i[j][0],i[j][1], i[j+1][0],i[j+1][1])

#for i in range(n): f*=i+1
print(x / factorial(n))




Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
  int a[4], b[4];
  while (scanf("%d %d %d %d\n%d %d %d %d", &a[0], &a[1], &a[2], &a[3], &b[0], &b[1], &b[2], &b[3]) != EOF) {
    int i, j;

    int hit = 0;
    for (i=0; i<4; ++i) {
      if (a[i] == b[i]) {
        ++hit;
      }
    }

    int blow = 0;
    for (i=0; i<10; ++i) {
      int a_count = 0, b_count = 0;
      for (j=0; j<4; ++j) {
        if (a[j] == i) {
          ++a_count;
        }
        if (b[j] == i) {
          ++b_count;
        }
      }
      blow += (a_count < b_count ? a_count : b_count);
    }
    blow -= hit;

    printf("%d %d\n", hit, blow);
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
signed main(){
    int n,m,x[100000],ans=0,memo[100000];
    scanf("%d%d",&n,&m);
    rep(i,m){
        scanf("%d",x+i);
    }
    sort(x,x+m);
    if(m==1)cout<<0;
    else{
        rep(i,m-1){
            memo[i]=x[i+1]-x[i];
            ans+=x[i+1]-x[i];
        }
        sort(memo,memo+m-1);
        rep(i,n-1){
            ans-=memo[m-i-2];
        }
        cout<<ans;
    }
    return 0;
}


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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N; cin >> N;
    vector<int> prime(55555+1, 1); prime[0] = 0; prime[1] = 0;
    for(int i=2; i<sqrt(55555)+1; i++){
        if(prime[i] == 0) continue;
        for(int j=i+i; j<=55555; j+=i) prime[j] = 0;
    }

    VI ans;
    REP(i,55556){
        if(prime[i] == 0) continue;
        if(i%5 == 2) ans.push_back(i);
        if(ans.size() == N) break;
    }
    REP(i,N) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

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

int main(){
 while(true){
  int n;
  cin >> n;

  if(n==0) break;

  int len[n];
  for(int i=0; i<n; i++){
   string w;
   cin >> w;
   len[i] = w.size();
  }

  for(int i=0; i<n; i++){
   bool flag = false;
   int sta = 0; //区切り
   int sum = 0; //文字数の合計

   for(int j=i; j<n; j++){
    sum = sum + len[j];
    
    if(sum==5 || sum==12 || sum==17 || sum==24 || sum==31){
     sta++;
    }

    if(sta==5){
     flag = true;
     break;
    }else if(sum>=31){
     break;
    }
   }

   if(flag){
    cout << i+1 << endl;
    break;
   }
  }
 }

 return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    int d_min = INT32_MAX;
    rep(i,n) {
        int lower = i;
        int upper = lower+k-1;
        if(upper >= n || lower < 0) continue;
        chmin(d_min, abs(x[lower])+abs(x[upper]-x[lower]));
        chmin(d_min, abs(x[upper])+abs(x[upper]-x[lower]));
    }
    cout << d_min << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
int main(){int a,b,c,x,y,r;std::cin>>a>>b>>c>>x>>y;r=std::min(a*x+b*y,std::max(x,y)*c*2);r=std::min(r, (x<y?x*c*2+(y-x)*b:y*c*2+(x-y)*a));std::cout<<r<<"\n";}

Measured memory_bytes: 256
import math
n=int(input())
nn=n
a=[]
i=2
while i<=math.sqrt(n):
    if n%i==0:
        n//=i
        a.append(str(i))
    else:
        i+=1
if n!=1:
    a.append(str(n))
print(str(nn)+": "+" ".join(a))


Measured memory_bytes: 5664
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		int N = I[0];
		uint A = (uint)I[1], B = (uint)I[2];
		if (BitCount(A ^ B) % 2 == 0) { WriteLine("NO"); return; }
		WriteLine("YES");
		WriteLine(string.Join(" ", Generate(N, A, B)));
	}
	List<uint> Generate(int N, uint A, uint B)
	{
		if (N == 1) return new List<uint> { A, B };
		B ^= A;
		var cnt = BitCount(B);
		// B の bit を左に揃える
		int[] perm = new int[N], iperm = new int[N];
		int on = N - 1, off = 0;
		for (var i = 0; i < N; i++) { perm[i] = (B & (1u << i)) != 0 ? on-- : off++; iperm[perm[i]] = i; }
		B = ((1u << cnt) - 1) << (N - cnt);
		// 作る
		var ans = new List<uint>();
		var lim = 1u << (N - 1);
		for (var i = 0u; i < lim; i++) ans.Add(i ^ (i >> 1));   // 前半は gray code
		foreach (var i in Generate(N - 1, 1u << (N - 2), B ^ lim)) ans.Add(i ^ lim);    // 後半は再帰
																						// 戻す (perm と 最初の B^=A)
		for (var i = 0; i < ans.Count; i++)
		{
			var s = 0u;
			for (var j = 0; j < N; j++) if ((ans[i] & (1u << j)) != 0) s |= 1u << iperm[j];
			ans[i] = s ^ A;
		}
		return ans;
	}
	public static int BitCount(uint n)
	{
		n = (n & 0x55555555) + ((n >> 1) & 0x55555555);
		n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
		n = (n & 0x0f0f0f0f) + ((n >> 4) & 0x0f0f0f0f);
		n = (n & 0x00ff00ff) + ((n >> 8) & 0x00ff00ff);
		return (int)((n & 0x0000ffff) + ((n >> 16) & 0x0000ffff));
	}
}


Measured memory_bytes: 24924
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const ld PI = acos((ld)-1);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template <typename T> V<T> prefix_sum(const V<T>& v) {
  int n = v.size();
  V<T> ret(n + 1);
  rep(i, 0, n) ret[i + 1] = ret[i] + v[i];
  return ret;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(auto&& x: vec) is >> x;
  return is;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
  return os<<"{"<<p.fs<<","<<p.sc<<"}";
}

template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
  os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}

template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}

ll dp[200010]={};

void solve(){
  ll n;cin>>n;
  ll k;cin>>k;
  dp[0]=1;

  V<PL> v(k);
  V<ll> sum(n+5,0);
  sum[1]=1;

  rep(i,0,k)cin>>v[i].fs>>v[i].sc;

  rep(i,1,n+1){
    rep(j,0,k){
      ll l=max(-1ll,i-v[j].sc-1);
      ll r=max(-1ll,i-v[j].fs);//[l,r]

      dp[i]+=(sum[r+1]-sum[l+1]+mod)%mod;
      dp[i]%=mod;
    }

    sum[i+1]=sum[i]+dp[i];
    sum[i+1]%=mod;
  }

  cout<<dp[n-1]%mod<<ENDL;
  return;
}

signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  solve();
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 6440
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e10;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double



////////////////////////////////////////////////////////////////////

template<typename T>
struct edge {
  int to, from;T cost;
  edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};
template<typename T>
using edges = vector<edge<T>>;
template<typename T>
using graph = vector<edges<T>>;
template<typename T>
using matrix = vector<vector<T>>;

template<typename T>
bool compByCost(const edge<T>& left, const edge<T>& right){
  return left.cost < right.cost; 
}

int n;matrix<int> g;edges<int> es;vector<vector<int>> dist;
bool erased[300][300];int ans;
template<typename T>
vector<vector<T>> warshall(matrix<T> &g){
  vector<vector<T>> dist(g.size());
  rep(i,g.size()){
    dist[i].resize(g.size());
    rep(j,g.size())dist[i][j] = (i == j ? 0 : g[i][j]);
  }
  rep(k,g.size()){
    rep(i,g.size()){
      rep(j,g.size()){
        if(dist[i][k] == INF || dist[k][j] == INF)continue;
        if(dist[i][j] >= dist[i][k] + dist[k][j]){
          dist[i][j] = dist[i][k] + dist[k][j];
          if(!erased[i][j] && k != i && k != j){
            erased[i][j] = true;ans -= g[i][j];
          }
        };
      }
    }
  }
  return dist;
}

#define warshall warshall<int>// matの初期化でINFを詰めておく


////////////////////////////////////////////////////////////////////i

signed main(){
  cin>>n;
  g.resize(n, vector<int>(n, INF));
  rep(i,n){
    rep(j,n){
      cin>>g[i][j];ans += g[i][j];
      es.push_back(edge<int>(i, j, g[i][j]));
    }
  }
  dist = warshall(g);
  int b = true;
  rep(i,n)rep(j,n)b = b && g[i][j] == dist[i][j];
  if(!b){
    cout << -1 << endl;return 0;
  }
  ans /= 2;
  cout << ans << endl;
}





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

int main(){

  int N, K;
  string S;
  cin >> N;
  cin >> S;
  cin >> K;

  for(int i=0; i<N; i++){
    if(S[i]!=S[K-1]) S[i]='*';
  }

  cout << S << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<ll,ll> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]


int main(){
    ll n,a,b; cin >> n >> a >> b;
    a-=b;
    ll h[n];
    rep(i,n) cin >> h[i];
    ll l=0,r=1001001001;
    while(r-l>1){
        ll mid=(r+l)/2;
        ll x=0;
        rep(i,n){
            if(h[i]-mid*b>0){
                x+=(h[i]-mid*b+a-1)/a;
            }
        }
        if(x<=mid) r=mid;
        else l=mid;
    }
    cout << r << endl;
}


Measured memory_bytes: 1024
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

score = 0
#dp[i][j]をi回目のジャンケンで、j(0-> R, 1 -> S, 2 -> P)の手を出したときまでのスコアの和とする
for i in range(n):
    if i - k < 0:
        if t[i] == 'r':
            score += p
        elif t[i] == 's':
            score += r
        else:
            score += s
        continue
    
    else:
        if t[i-k] == t[i]:
            t = t[:i] + 'n' + t[i+1:]
            # print(t)
        else:
            if t[i] == 'r':
                score += p
            elif t[i] == 's':
                score += r 
            else:
                score += s
        
print(score)

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

typedef long long ll;

using namespace std;

int main() {
    ll n, p = 1, q = 1, t, a, m;
    cin >> n;
    for (ll i = 0; i < n; ++i) {
        cin >> t >> a;
        m = max((p - 1) / t + 1, (q - 1) / a + 1);
        p = t * m, q = a * m;
    }
    cout << p + q << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <sstream>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;

int N, K;

int c[10];

int main() {
    cin >> N >> K;
    for (int i = 1; i <= N; ++i) c[i] = -1;
    int s, t;
    for (int i = 0; i < K; ++i) {
        cin >> s >> t;
        if (c[s] != -1 && t != c[s]) {
            cout << -1 << endl;
            return 0;
        }
        c[s] = t;
    }


    for (int i = 1; i <= N; ++i) {
        if (i == 1 && c[i] == -1 && N != 1) c[i] = 1;
        if (c[i] == -1) c[i] = 0;
    }

    if (c[1] == 0) {
        if (N == 1) {
            cout << 0 << endl;
            return 0;
        } else {
            cout << -1 << endl;
            return 0;
        }
    }

    int ans = 0;
    int l = 1;
    for (int i = N; i >= 1; --i) {
        ans += l * c[i];
        l *= 10;
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
    const int INF = 1000000000;
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    vector<int> b(n);
    rep(i, n){
        cin >> a[i] >> b[i];
    }
    vector<vector<int>> dp(n+1, vector<int>(h+1, INF));
    dp[0][0] = 0;
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= h; j++){
            if(j > a[i]){
                dp[i+1][j] = min(dp[i][j], dp[i+1][j-a[i]] + b[i]);
            }else{
                dp[i+1][j] = min(dp[i][j], b[i]);
            }
        }
    }
    cout << dp[n][h] << endl;
}

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


Measured memory_bytes: 2048
from bisect import bisect_right
n = int(input())
d = {}
amax = 0
for a in map(int, input().split()):
  if a in d:
    d[a] += 1
  else:
    d[a] = 1
  amax = max(amax, a)
t = 1
valids = []
while t < 2 * amax:
  t *= 2
  valids.append(t)
result = 0
while True:
  prev = result
  keys = list(d.keys())
  keys.sort(reverse = True)
  for x in keys:
    if x not in d:
      continue
    t = valids[bisect_right(valids, x)] - x
    while True:
      if t not in d:
        break
      if x == t and d[x] == 1:
        break
      result += 1
      if d[x] == 1:
        del d[x]
      else:
        d[x] -= 1
      if d[t] == 1:
        del d[t]
      else:
        d[t] -= 1
      if x not in d:
        break
  if prev == result:
    break
print(result)

Measured memory_bytes: 44560
#include <stdio.h>
int i,j,k,v,N,A[100];
int main(void){
    for(scanf("%d",&N);i<N;scanf("%d",&A[i++]));
    for(k=0;k<N;printf("%d%s",A[k],k==N-1?"\n":" "),k++);
    for(i=1;i<N;i++){
        v=A[i];
        for(j=i-1;A[j]>v;j--){
            A[j+1]=A[j];
        }
        A[j+1]=v;
        for(k=0;k<N;printf("%d%s",A[k],k==N-1?"\n":" "),k++);
    }

}

Measured memory_bytes: 1844
#include <bits/stdc++.h>
#include<iostream>
#include<string>
#include<queue>
#include<vector>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)//初期値a,i<bの範囲でループ
#define REP(i,n) FOR(i,0,n)//初期値0,i<nの範囲でループ
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;

int n;
ll a[100010];
int c[5];

int main(){
    cin>>n;
    REP(i,n){
        cin>>a[i];
        if(a[i]%4==0){
            a[i]=4;
        }else if(a[i]%2==0){
            a[i]=2;
        }else{
            a[i]=1;
        }
        c[a[i]]++;
    }
    
    int f2=0;
    if(c[2])f2=1;
    if(c[4]==0){
        if(c[2]==n)cout<<"Yes";
        else cout<<"No";
    }else{
        if(c[4]+1>=c[1]+f2)cout<<"Yes";
        else cout<<"No";
    }

    return 0;
}

Measured memory_bytes: 1152
#include<iostream>

using namespace std;

int main() {
    static int NUMS[] = { 0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

    int index;
    cin >> index;
    cout << NUMS[index] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <cstring>
struct DSU {
  DSU(int n) : parent_(n) {
    for (int i = 0; i < n; i++) {
      parent_[i] = i;
    }
  }

  std::vector<int> parent_;
  int get(int x) {
    return parent_[x] = (x == parent_[x] ? x : get(parent_[x]));
  }
  int merge(int x, int y) {
    x = get(x);
    y = get(y);
    if (x == y) {
      return x;
    }
    if (rand() % 2 == 0) {
      parent_[x] = y;
      return y;
    }
    parent_[y] = x;
    return x;
  }
};
using int64 = long long;
struct Node {
  int64 sum_x{0};
  int bad_edges{0};
  void add_edge(int64 e) {
    if (e > sum_x) {
      bad_edges++;
    } else {
      bad_edges = 0;
    }
  }
  void merge(Node other) {
    sum_x += other.sum_x;
    bad_edges += other.bad_edges;
  }
};
int main(void) {
  int n, m;
  while (scanf("%d%d", &n, &m) == 2) {
    DSU dsu(n);
    std::vector<Node> weight(n);
    for (auto &w : weight) {
      scanf("%lld", &w.sum_x);
    }
    struct Edge {
      int a, b, c;
    };
    std::vector<Edge> edges(m);
    for (auto &e : edges) {
      scanf("%d%d%d", &e.a, &e.b, &e.c);
      e.a--;
      e.b--;
    }
    std::sort(edges.begin(), edges.end(), [](const auto &a, const auto &b) { return a.c < b.c; });
    for (auto e : edges) {
      int a = e.a;
      int b = e.b;
      int c = e.c;
      a = dsu.get(a);
      b = dsu.get(b);
      int t = dsu.merge(a, b);
      if (a != b) {
        weight[t].merge(weight[a + b - t]);
      }
      weight[t].add_edge(c);
    }
    int x = dsu.get(0);
    printf("%d\n", weight[x].bad_edges);
  }
}


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

#define ll long long
#define ld long double
#define fi first
#define endl "\n"
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define initialize(array,size,value) for(ll i=0;i<size;i++) array[i]=value
#define couta(array,size) for(ll i=0;i<size;i++) cout<<array[i]<<" "
#define inf (long long int) 1e18
#define eps 0.000001
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
#define mod 1000000007
#define MAXN 100001
ll spf[MAXN]; 
ll gcd(ll a,ll b);
ll palindrome(string s);
ll modexp(ll a,ll b,ll m);
void sieve();
ll ceil(ll a, ll b);
vl getFactorization(ll x);
void getZarr(string str, ll Z[]);
vector<ll> prefix_function(string s);

ll n;
string a[5205];
bool f(ll x){
    //cout<<"llo"<<endl;
    for(ll i=0; i<n; i+=x){
        //cout<<"lolppl"<<endl;
        for(ll j=0; j<n; j+=x){
            bool done=true;
            char ch=a[i][j];
            for(ll k=i; k<i+x; k++){
                for(ll o=j; o<j+x; o++){
                    if(a[k][o]!=ch){
                        return 0;
                    }
                }
            }
        }
    }
    return 1;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/

   ll n;
   cin>>n;
   string a, b, c;
   cin>>a>>b>>c;
   ll ans=0;
   loop(i,0,n){
    char ch[3];
    ch[0]=a[i], ch[1]=b[i], ch[2]=c[i];

    sort(ch, ch+3);

    //loop(j,0,3) cout<<ch[j];
    //cout<<endl;
    if(ch[0]==ch[2]) continue;
    else if((ch[0]==ch[1] && ch[1]!=ch[2]) || (ch[0]!=ch[1] && ch[1]==ch[2])) ans++;
    else {
        //cout<<"lol"<<" "<<i<<endl;
        ans=ans+2;
    }
   }
   cout<<ans<<endl;



}

ll gcd(ll a, ll b){
    if (a == 0)   return b;
    if(b==0)      return a;
    if (a == b)   return a;
    if (a > b)    return gcd(a%b, b);
    return gcd(a, b%a);
}

ll palindrome(string s){
    ll l = 0;
    ll h = s.length() - 1;
    while (h > l){
        if (s[l++] != s[h--]){
            return 0;
        }
    }
    return 1;
}

ll modexp(ll a, ll b, ll m){
    if (b==0)
        return 1;
    ll temp = modexp(a,b/2,m);
    temp = (temp*temp)%m;
    if (b&1)
        return (temp*(a%m))%m; // if b is odd a^b = a^(b/2)*a^(b/2)*a
    return temp;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
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; }
const int INF = 1<<30;
const int mod = 1000000007;

int main(){
    int n, m;
    cin >> n >> m;
    vector<pii> B;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        B.pb({b, a});
    }
    sort(all(B));
    int l = 0, cnt = 0;
    for(int i = 0; i < m; i++){
        if(l > B[i].se) continue;
        l = B[i].fi;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1400
package main
import("fmt")

func main(){
    var s string
    fmt.Scan(&s)
    pt := len(s)
    words := []string{"dream", "dreamer", "erase", "eraser"}
    for pt > 3 {
        _pt := pt
        for _, v := range words {
            if s[pt - 3: pt] == v[len(v) - 3: len(v)] && s[pt - len(v): pt] == v  {
                pt -= len(v)
                break
            }
        }
        if _pt == pt {
            pt = -1
        }
    }

    if pt == 0 {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}

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

int n,r,g,b;
int ans;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>r>>g>>b>>n;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            int l=n-i*r-j*g;
            if(l<0)continue;
            if(l%b==0)ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

char A[4], B[4];

void solve()
{
	int f;
	for (int i = 0; i < 3 && (f = A[i] - B[2 - i]) == 0; i++);
	if (f == 0) cout << "YES\n";
	else cout << "NO\n";

}

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

	solve();
	return 0;
}

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

template<size_t N>
bitset<N> prime_list(){
  bitset<N> ret, notPrime;
  notPrime[0] = notPrime[1] = true;
  int sqrt = 0;
  while(sqrt * sqrt <= N) ++ sqrt;
  for(int i = 2;i < sqrt;++ i){
    if(notPrime[i]) continue;
    ret[i] = true;
    for(int j = i * i;j <= N && j >= 0;j += i) notPrime[j] = true;
  }
  for(int i = sqrt;i <= N;++ i) if(!notPrime[i])  ret[i] = true;
  return ret;
}
int main() {
  const int LEN = 10000000;
  bitset<LEN> prime = prime_list<LEN>();
  int cumsum[LEN + 1];
  for (int i = 0;i < LEN + 1;++ i) cumsum[i] = 0;
  for (int i = 3;i < prime.size();i += 2) if (prime[i] && prime[i + 1 >> 1]) ++ cumsum[i];
  for (int i = 1;i < LEN + 1;++ i) cumsum[i + 1] += cumsum[i];
  int Q;
  cin >> Q;
  while(Q--) {
    int l, r;
    cin >> l >> r;
    cout << cumsum[r] - cumsum[l - 1] << endl;
  }
}


Measured memory_bytes: 42112
n = int(input())
v_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

answer = 0
for i in range(n):
    if v_list[i] - c_list[i] > 0:
        answer += v_list[i] - c_list[i]
print(answer)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
	char* left="qwertasdfgzxcvb";
	int isleft[128]={};
	for(int i=0;left[i];i++)
		isleft[left[i]]=1;
	
	for(string s;cin>>s,s!="#";){
		int res=0;
		for(int i=1;i<s.size();i++)
			if(isleft[s[i-1]]!=isleft[s[i]])
				res++;
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<int> v(N);
  rep(i,N)cin >> v[i];
  int sum = 0;
  rep(i,N) repp(j,i+1,N){
    sum += v[i]*v[j];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    cnt = {}
    for a in A:
        if a not in cnt:
            cnt[a] = 0
        cnt[a] += 1
    tmp = 0
    for k in cnt:
        tmp += cnt[k] - 1
    print(N - (tmp+1)//2 * 2)


if __name__ == "__main__":
    main()


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    vector<ll> vec;
    ll temp;
    bool muri;muri=false;
    int cnt;cnt=0;
    ll before;before=0;
    vec.pb(0);
    REP(i,N){
        cin>>temp;
        vec.pb(temp);
    }
    bool cantchange[N+1]={};
    ll kijyun;kijyun=0;
    REP1(i,N-1){
        if(vec[i]==kijyun)cantchange[i]=true;
        if(vec[i+1]<vec[i]){
            if(vec[i]-vec[i+1]>1){
                cout<<"No"<<endl;
                return 0;
            }
            if(cantchange[i]){
                cout<<"No"<<endl;
                return 0;
            }else{
                vec[i]--;
                cantchange[i]=true;
                kijyun=vec[i];
            }
        }
    }
        print("Yes");
    
    //cout<<fixed;
    return 0;
}


Measured memory_bytes: 1400
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc083/tasks/abc083_b

"""
import sys
from sys import stdin
input = stdin.readline


def digits_sum(N):
    ans = 0
    while N:
        ans += (N % 10)
        N //= 10
    return ans


def solve(N, A, B):
    ans = []
    for i in range(1, N+1):
        d_sum = digits_sum(i)
        if A <= d_sum <= B:
            ans.append(i)
    return sum(ans)


def main(args):
    N, A, B = map(int, input().split())
    ans = solve(N, A, B)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
const int maxn=10;
char ch[maxn];
int main(){
	scanf("%s",ch);
	if(ch[0]=='S')puts("Cloudy");
	if(ch[0]=='C')puts("Rainy");
	if(ch[0]=='R')puts("Sunny");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include <numeric>
#include<cmath>
#include<string>
using namespace std;
#define ll long long

int main(void){
    int n,q;
    cin >> n>> q;
    string s;
    cin >> s;
    vector<int>r(n+1,0);
    r[q]=0;

    for(int i=s.length()-2;i>=0;i--){
        if(s.substr(i,2)=="AC"){
            r[i] = r[i+1]+1;
        }else{
            r[i] = r[i+1];
        }
    }

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

    for(int i=0;i<q;i++){
        int a,b;
        cin >> a>>b;
        // for(int j=a-1;j<b;j++){
        //     cout << s[j];
        // }
        // cout << endl;
        ll ans = r[a-1]-r[b];
        if(b!=n and s.substr(b-1,2)=="AC"){
            ans -= 1;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1408
#include <string>
#include <algorithm>
#include <iostream>
#include <math.h>

using namespace std;

void a_aircon(void) {
    int x;
    cin >> x;

    if (x >= 30) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

int main()
{
    a_aircon();

    return 0;
}

Measured memory_bytes: 3620
import sys

input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def main():
    N = int(input())
    P = read_list()
    pre = P[0]
    res = 0
    for p in P:
        if pre >= p:
            res += 1
            pre = p
    print(res)


if __name__ == "__main__":
    main()


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

using namespace std;

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define MP make_pair
#define PB push_back
#define X first
#define Y second

typedef long long int lld;
typedef pair<int, int> pii;
typedef pair<lld, lld> pll;

const int maxn = (int) 1e3 + 5;
const int inf = (int) 1e9 + 5;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int h, w;
    cin >> h >> w;

    int ch, cw, dh, dw;
    cin >> ch >> cw >> dh >> dw;
    ch--, cw--, dh--, dw--;

    vector<vector<int>> board(h, vector<int>(w)), dis(h, vector<int>(w, inf));

    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < w; j++) {
            board[i][j] = s[j] == '.' ? 0 : 1;
        }
    }

    priority_queue<pair<int, pii>, vector<pair<int, pii>>, greater<pair<int, pii>>> pq;
    pq.emplace(0, pii(ch, cw));
    dis[ch][cw] = 0;

    auto ok = [&](int x, int y) {
        return x >= 0 && x < h && y >= 0 && y < w && board[x][y] != 1;
    };

    while (!pq.empty()) {
        auto front = pq.top();
        pq.pop();

        int &x = front.second.first;
        int &y = front.second.second;
        int &d = front.first;

        // cout << x << ' ' << y << ' ' << d << '\n';
        
        if (x == dh && y == dw) {
            cout << front.first << '\n';
            return 0;
        }

        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                int xx = x + i;
                int yy = y + j;

                if (!ok(xx, yy)) {
                    continue;
                }

                if (abs(i) + abs(j) <= 1) {
                    if (dis[xx][yy] > d) {
                        dis[xx][yy] = d;
                        pq.emplace(d, pii(xx, yy));
                    }
                } else {
                    if (dis[xx][yy] > d + 1) {
                        dis[xx][yy] = d + 1;
                        pq.emplace(d + 1, pii(xx, yy));
                    }
                }
            }
        }
        
    }

    cout << -1 << '\n';

    return 0;
}

// g++ sol.cpp -o sol.out -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17

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

  int main() {
  int N;
   cin >> N;
   vector<int> count(N-1);
  int counttwo=0;
  int sum=0; //Σｄを保存
  vector<int> d(N);

  for(int i=0; i<N; i++)
    cin >> d.at(i); //dの入力

  for(int t=1; t<N; t++){  //N-1回ループ
    
    
    for(int j=0; j<N-t; j++){//N-1回ループ
      sum+=d.at(j+t);
      
    }
      sum*=d.at(t-1);
      count.at(t-1)=sum;
      sum=0;
    }
  
   
  for(int i=0; i<N-1; i++){
    counttwo+=count.at(i);
  }

  cout << counttwo << endl;
}


Measured memory_bytes: 256
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

#input = sys.stdin.readline

########################################


s = input()
t = input()
n = len(s)
m = len(t)
ans = -float("inf")
for i in range(n-m+1):
	temp = 0
	for j in range(i,i+m):
	#	print("!!",i,s[j],t[j-i])
		if t[j-i]==s[j]:
			temp+=1
	#print(i,temp)
	ans = max(temp , ans)
print(m - ans)







Measured memory_bytes: 73844
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

N, M = map(int, raw_input().split())
X = map(int, raw_input().split())

cnt = [0]*100005
for x in X:
    cnt[x] += 1

pair = [0]*M
for i in xrange(100005):
    pair[i%M] += cnt[i]/2
    cnt[i] %= 2

mod = [0]*M
for i in xrange(100005):
    mod[i%M] += cnt[i]

ans = sum(pair)
for i in xrange(M):
    if i == 0 or i == M - i:
        ans += mod[i]/2 
        mod[i] %= 2
    else:
        m = min(mod[i], mod[M - i])
        ans += m
        mod[i] -= m
        mod[M - i] -= m

for i in xrange(1, M):
    while pair[i] >= 1 and mod[M - i] >= 2:
        ans += 1
        pair[i] -= 1
        mod[M - i] -= 2


print ans


Measured memory_bytes: 12640
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto abc = RDR.ARR;
	abc.sort();
	
	writeln(abc[0] + abc[1] == abc[2] ? "Yes" : "No");
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 380
import sys
from pprint import pprint

def solve(n, k, s):
    a = [0] * n
    for i in range(n):
        if i < k:
            a[i] = s
        else:
            if s == 10**9:
                a[i] = s-1
            else:
                a[i] = s+1
    print(" ".join(map(str,a)))


if __name__ == '__main__':
    n, k, s = map(int, sys.stdin.readline().strip().split(" "))
    solve(n, k, s)

Measured memory_bytes: 66156
#include <stdio.h>
#include <utility>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, h, w, n, now = 0;
  scanf("%lld%lld%lld", &h, &w, &n);
  pair<ll, ll> a[n];
  for(i = 0; i < n; ++i) scanf("%lld%lld", &a[i].first, &a[i].second);
  sort(a, a + n);
  for(i = 0; i < n; ++i) {
    if(a[i].first - now == a[i].second) now++;
    else if(a[i].first - now > a[i].second) {
      printf("%lld", a[i].first - 1);
      return 0;
    }
  }
  printf("%lld", h);
  return 0;
}

Measured memory_bytes: 3328
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(998244353)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int gcd(int A,int B) {if(!B)return A;return gcd(B,A%B);}
int main()
{
 int x;
 cin>>x;
  cout<<360/gcd(360-x,360);
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fo(i,n) for(i=0;i<n;i++)
#define fok(i,k,n) for(i=k;i<n;i++)
#define ci(x) cin>>x;
#define ci2(x,y) cin>>x>>y;
#define co(x) cout<<x<<"\n";
#define co2(x,y) cout<<x<<" "<<y<<"\n";
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;

int main() {
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	string S,T;
	ci2(S,T);	
	bool ans = false ;
	for( int i = 0; i < (int)S.size (); ++ i ) {
		if ( S == T ){
			ans = true ;
			break ;
		}
		S = S.back() + S.substr(0,S.size()-1);
	}
	if ( ans ) {
	cout << " Yes " << endl ;
	}
	else {
	cout << "No" << endl ;
	}

	return 0;
}


Measured memory_bytes: 256
n = gets.chop.to_i


table = Hash.new(0)
ans = 0

n.times do
  s = gets.chop.chars.sort.join

  if table.has_key?(s) then
    ans += table[s]
  end

  table[s] += 1
end

## charsで分解し、joinでくっつける

print ans

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

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


Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF=1e9+7;

int main() {
	int H,W,K,a=INF;
	cin >> H >> W >> K;
	vector<string> f(H);
	vector<vector<int>> w(H, vector<int>(W,0)), c(H, vector<int>(W,0));

	rep(i,H) {
		cin >> f.at(i);
		rep(j,W)
			if(f.at(i).at(j) == '1')
				w.at(i).at(j) = 1;
	}

	rep(i,H)
		rep(j,W)
			if(j == 0)
				c.at(i).at(j) = w.at(i).at(j);
			else
				c.at(i).at(j) = c.at(i).at(j-1)+w.at(i).at(j);

	rep(i,H-1)
		rep(j,W)
			c.at(i+1).at(j) += c.at(i).at(j);

	// rep(i,H) {
	// 	rep(j,W)
	// 		cout << c.at(i).at(j) << " ";
	// 	cout << endl;
	// }
	// cout << endl;

	
	rep(i,1<<H-1) {
		vector<vector<int>> r;
		int x=0, p=-1;
		rep(j,H-1) {
			if(i & 1<<j) {
				r.push_back(vector<int>(W,0));
				rep(k,W) {
					if(p == -1)
						r.at(r.size()-1).at(k) = c.at(j).at(k);
					else
						r.at(r.size()-1).at(k) = c.at(j).at(k)-c.at(p).at(k);
				}
				p = j;
			}
		}
		r.push_back(vector<int>(W,0));
		rep(k,W)
			if(p == -1)
				r.at(r.size()-1).at(k) = c.at(H-1).at(k);
			else
				r.at(r.size()-1).at(k) = c.at(H-1).at(k)-c.at(p).at(k);

		// rep(i,r.size()) {
		// 	rep(j,W)
		// 		cout << r.at(i).at(j) << " ";
		// 	cout << endl;
		// }
		// cout << endl;

		p = -1;
		bool ok=1;
		rep(j,W) {
			int m=0;
			rep(k,r.size())
				m = max(m, ((p==-1) ? r.at(k).at(j) : r.at(k).at(j)-r.at(k).at(p)));
			// cout << m << " " << p << endl;
			if(m <= K)
				continue;
			p = j-1;
			if(p < 0) {
				ok = 0;
				break;
			}
			++x;
		}
		// cout << x+r.size()-1 << endl;
		if(ok)
			a = min(a, (int)(x+r.size()-1));
	}

	cout << a << endl;
}

Measured memory_bytes: 384
H,W,h,w = map(int,input().split())

lis = [[600] * W for i in range(H)]

for i in range(H):

    for j in range(W):

        if i % h == h-1 and j % w == w-1:
            lis[i][j] = -600 * (h * w - 1) - 1

s = 0

for i in range(H):
    s += sum(lis[i])

if s <= 0:
    print ("No")

else:
    print ("Yes")
    for i in lis:
        
        print (" ".join(map(str,i)))


Measured memory_bytes: 44484
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 1000005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

int n, m;
vector<pi> adj[MAX];
bool valid(int i, int j) {
	return i>=0 && j>=0 && i<n && j<m;
}

/* Dijkstra Algo */
int dijkstra(int s, int d) {
	int mincost[MAX], i;
	rep(i, 0, MAX) mincost[i] = INT_MAX;
	
	priority_queue<pi, vector<pi>, greater<pi> > pq;
	pq.push(MP(0, s));
	mincost[s] = 0;
	
	while(!pq.empty()) {
		pi _top = pq.top();
		pq.pop();
		int node = _top.Y;
		
		for(i=0;i<adj[node].size();i++) {
			int ch = adj[node][i].X;
			int wt = adj[node][i].Y;
			if(mincost[node] + wt < mincost[ch]) {
				mincost[ch] = mincost[node] + wt;
				pq.push(MP(mincost[ch], ch));
			} 
		}
	}
	
	return mincost[d];
}

int get_node(int i, int j) {
	return i*m + j;
}

void solve() {
	in2(n, m);
	int si, sj, di, dj;
	in2(si, sj);
	in2(di, dj);
	si--;sj--;di--;dj--;
	
	string s[n];
	for(int i=0;i<n;i++) cin>>s[i];
	
	for(int i=0;i<n;i++) {
		for(int j=0;j<m;j++) {
			if(s[i][j] == '#') continue;
			int u = get_node(i, j);
			
			for(int xi=i-2;xi<=i+2;xi++) {
				for(int xj=j-2;xj<=j+2;xj++) {
					if(valid(xi, xj) && s[xi][xj] == '.') {
						int wt = (abs(xi-i) + abs(xj-j)) == 1 ? 0 : 1;
						int v = get_node(xi, xj);
						adj[u].PB(MP(v, wt));
					}
				}
			}
		}
	}
	
	int st = get_node(si, sj);
	int dest = get_node(di, dj);
	int ans = dijkstra(st, dest);
	if(ans == INT_MAX) ans = -1;
	cout<<ans<<en;
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 106768