akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  string s, t;
  cin >> s >> t;
  int sn = s.size(), tn = t.size();
  vector<vector<int>> v(26);
  rep(i, 0, sn) v[s[i] - 'a'].push_back(i + 1);
  rep(i, 0, 26) sort(v[i].begin(), v[i].end());

  ll ans = 0;
  int last_index = 0;
  rep(i, 0, tn) {
    int ti = t[i] - 'a';
    if (v[ti].size() == 0) {
      cout << -1 << endl;
      return 0;
    }

    auto x = upper_bound(v[ti].begin(), v[ti].end(), last_index);
    if (x == v[ti].end()) {
      ans += (sn-last_index) + v[ti][0];
      last_index = v[ti][0];
    } else {
      ans += *x - last_index;
      last_index = *x;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1228
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int INF=1e9;
const int maxn=3e3+10;
const double eps=1e-9;
int dp1[maxn],dp2[maxn];
inline int read(){
	int x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
int main(){
	int i,j,k,m,n;
	int a,b,c,d,e,f;
	a=read();b=read();c=read();d=read();e=read();f=read();
	a*=100,b*=100;
	dp1[0]=dp2[0]=1;
	for(i=0;i<=f;i++)
		if(dp1[i]){
			if(i+a<=f)dp1[i+a]=1;
			if(i+b<=f)dp1[i+b]=1;
		}
	for(i=0;i<=f;i++)
		if(dp2[i]){
			if(i+c<=f)dp2[i+c]=1;
			if(i+d<=f)dp2[i+d]=1;
		}
	double t=-1;
	int ans1,ans2;
	for(i=0;i<=f;i++)
		for(j=0;i+j<=f;j++)
			if(dp1[i] && dp2[j] && j*1.0>t*(i+j) && i!=0 && j*100.0<=e*i){
				ans1=i+j;
				ans2=j;
				t=j*1.0/(i+j);
			}
	printf("%d %d\n",ans1,ans2);
	return 0;
}


Measured memory_bytes: 256
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second


void solve()
{
	ll n;
	cin >> n;
	ll gcd = __gcd(n, 360ll);
	cout << (ll)(360 / gcd) << "\n";

}

int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ll t;
	// cin>>t;
	// while(t--)
	// {
	solve();
	// }

	return 0;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main() {
	unsigned long long x;
	cin >> x;
	int n = 0;
	unsigned long long yen = 100;
	while (yen < x) {
		n++;
		yen = yen * 1.01;
	}
	cout << n;
	return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;

#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k%2==1){
        cout << b-a << endl;
    }else{
        cout << a-b << endl;
    }
}

Measured memory_bytes: 888
N,A,B = map(int, input().split())
S = []
for i in range(1,N+1):
  if i < 10 and A <= i <= B:
    S.append(i)
  elif i >= 10:
    a = list(str(i))
    count = 0
    for j in range(len(a)):
      count += int(a[j])
    if A <= count <= B:
      S.append(i)
print(sum(S))

Measured memory_bytes: 3420
#include <iostream>

using namespace std;

int main()
{
	int x, y;
	cin >> x >> y;
	if (y % 2 != 0) {
		cout << "No" << endl;
		return 0;
	}

	int b = y / 2 - x;
	int a = x - b;

	if (a >= 0 && b >= 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n, k) for (ll i = n; i >= k; i--)
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;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

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

    ll M, K;
    cin >> M >> K;

    if(M == 0) {
        if(K == 0) cout << "0 0" << endl;
        else cout << -1 << endl;
        return 0;
    }
    if(M == 1) {
        if(K == 0) cout << "0 0 1 1" << endl;
        else cout << -1 << endl;
        return 0;
    }
    if(M >= 2) {
        if(K <= pow(2, M) - 1) {
            ll mod = K % 4;
            vll list;
            rep(i, 4) {
                if(i == mod) continue;
                list.push_back(4*(K/4)+i);
            }

            rep(i, pow(2, M)) {
                if(4*(K/4) <= i && i <= 4*(K/4) + 3) continue;
                cout << i << " ";
            }
            cout << K << " ";
            rrep(i, pow(2, M)-1, 0) {
                if(4*(K/4) <= i && i <= 4*(K/4) + 3) continue;
                cout << i << " ";
            }
            rep(i, 3) cout << list[i] << " ";
            cout << K << " ";
            rrep(i, 2, 0) cout << list[i] << " ";
            cout << endl;
        }
        else cout << -1 << endl;
    }
}


Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
int main(){
 	int n;
  	scanf("%d",&n);
  	vector<int> h(n);
  	for(int &i:h){
     	scanf("%d",&i); 
    }
  	vector<int> dp(n);
  	dp[0]=0;
  	dp[1]=abs(h[0]-h[1]);
  	for(int i=2;i<n;i++){
     	dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2])); 
    }
  printf("%d",dp[n-1]);
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

lint gcd(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

lint lcm(lint a, lint b) {
	//aとbの最小公倍数を返す
	return a / gcd(a, b) * b;
}

/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	string S;
	cin >> S;
	int Z = S.size();
	rep(i, Z-8) {
		cout << S[i];
	}
	cout  << endl;
}


Measured memory_bytes: 256
import math
while True:
  num = int(input())
  if num == 0:
    break
  li = list(map(int,input().split()))
  ave = sum(li) / len(li)
  result = 0
  for i in li:
    result += (i - ave) ** 2
  result= math.sqrt(result / num)
  print(result)



Measured memory_bytes: 5692
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

int N,M;

int main()
{
  cin >> N >> M;
  
  if(N==M) cout <<"Yes";
  else cout << "No";
  
}

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

int main(){
    int n, k;
    cin >> n >>k;
    string s;
    cin>>s;
    int ans=0;
    rep(i,n-1){
        if(s[i]==s[i+1]) ans++;
    }
    
    cout<< min(ans+2*k,n-1)<<endl;
    return 0;
}


Measured memory_bytes: 512
from math import gcd
n = int(input())

if n == 1:
    print(1)
    exit(0)

N = 2 * n


def list_divs(x):
    divs = []
    for y in range(2, int(x ** 0.5) + 1):
        if x % y == 0:
            divs.append(y)
            if y != x // y:
                divs.append(x // y)
    divs.sort()
    return divs


def chineserem(r1, m1, r2, m2):
    c0, c1 = m1, m2
    a0, a1 = 1, 0
    b0, b1 = 0, 1
    while c1:
        a0, a1 = a1, a0 - c0 // c1 * a1
        b0, b1 = b1, b0 - c0 // c1 * b1
        c0, c1 = c1, c0 % c1
    return (r1 * m2 * b0 + r2 * m1 * a0) % (m1 * m2)


divs = list_divs(N)

ans = float("inf")
for a in divs:
    b = N // a
    if gcd(a, b) == 1:
        tmp = chineserem(0, a, -1, b)
        ans = min(ans, tmp)
print(ans)


Measured memory_bytes: 69524
#include <iostream>
int main(int argc, char* argv[]){
  int k, x;
  std::cin >> k >> x;
  int min = -1000000;
  if (min < x - k + 1) {
    min = x - k + 1; 
  }

  int max = 1000000;
  if (max > x + k - 1) {
    max = x + k - 1; 
  } 
  for (int i = min;i <= max; i++){
   	std::cout << i << " "; 
  }
    
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int h1, m1, h2, m2, k;
	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
	printf("%d\n", 60 * h2 + m2 - 60 * h1 - m1 - k);
	return 0;
}

Measured memory_bytes: 1736
#include<stdio.h>

int main()
{
 int a,b,c,max;

 scanf("%d %d %d",&a,&b,&c);

 max=a;
 if(b>max)max=b;
 if(c>max)max=c;

 printf("%d\n",a+b+c-max);

 return 0;
}


Measured memory_bytes: 1720
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
int main(){
  string s; cin>>s;
  if(s=="SUN") cout<<7;
  if(s=="MON") cout<<6;
  if(s=="TUE") cout<<5;
  if(s=="WED") cout<<4;
  if(s=="THU") cout<<3;
  if(s=="FRI") cout<<2;
  if(s=="SAT") cout<<1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define $$ long long int
#define pb push_back
#define db pop_back
#define q2(n) (n%2)==0
#define loop(i,m,p) for ($$ i = m; i < p; ++i)

using namespace std;


int main()
{

 string s;
 cin>>s;
 $$ n=s.size();
 $$ ar[n];
 for (int i = 0; i < s.size(); ++i)
 {
   $$ k=s[i];
   ar[i]=k-48;
 }
 $$ mn =10001;
loop(i,0,n-2)
{
  $$ l=(ar[i]*100)+(ar[i+1]*10)+(ar[i+2]);
  $$ d=abs(l-753);
  mn=min(mn,d);

}
cout<<mn<<"\n";



    return 0;

}


Measured memory_bytes: 256
# include<iostream>
# include<cstring>
# include<cstdio>
# include<algorithm>
# define LL long long
using namespace std;
const int MAX=1e6+5;
int n,k,tot;
LL a[MAX];
LL qwq[2][MAX];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)
	  scanf("%lld",&a[i]);
	for(int i=1;i<=n;++i)
	  {
	  	LL sum=0;
	  	for(int j=i;j<=n;++j)
	      qwq[0][++tot]=sum+=a[j];
	  }
	LL tt=tot,fl=1,cnt=0,ans=0;
	for(LL i=63;i>=0;--i)
	  {
	  	fl^=1,cnt=0;
	  	for(int j=1;j<=tt;++j)
	  	  if(qwq[fl][j]&(1ll<<i)) qwq[fl^1][++cnt]=qwq[fl][j];
	  	if(cnt>=k) ans+=(1ll<<i),tt=cnt;
	  	else for(int j=1;j<=tt;++j)
	  	  qwq[fl^1][j]=qwq[fl][j];
	  }
	return printf("%lld",ans),0;
}

Measured memory_bytes: 12544
use std::io::BufRead;

fn main() {
    let stdin = std::io::stdin();
    let s = stdin.lock().gets().into_bytes();
    let w = stdin.lock().gets().parse::<usize>().unwrap();
    println!("{}", s.chunks(w).map(|x| x[0] as char).collect::<String>());
}

trait Gets { fn gets(&mut self) -> String; }
impl<T: std::io::BufRead> Gets for T {
    fn gets(&mut self) -> String { self.lines().next().unwrap().unwrap() } }


Measured memory_bytes: 4352
def fcd(a , b):
    
    if a>= b:
        while b != 0:
            a,b = b,a%b
        return a
    
    else:
        while a != 0:
            b,a = a,b%a
        return b
    
    
def lcm(a,b):
    return a*b//fcd(a , b)


n = int(input())
t_list = []
ans_list = []
for i in range(n):
    t_list.append(int(input()))
    
    
for i in range(len(t_list)):
    if i == 0:
        ans_list.append(t_list[0])
        continue
    if i == 1:
        ans_list.append(lcm(t_list[0] , t_list[1]))
    
    if i >=2:
        ans_list.append(lcm(ans_list[-1],t_list[i]))
print(ans_list[-1])

Measured memory_bytes: 3064
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <string.h>
#include <vector>

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("file.1", "r", stdin);

  vector<int> a(5);
  int i;
  int ans = 0;
  for (i = 0; i < 5; i++) {
    cin >> a[i];
  }
  int mod_min = a[0] % 10;
  for (i = 1; i < 5; i++) {
    if (0 < (a[i] % 10) && (a[i] % 10) < mod_min) {
      mod_min = a[i] % 10;
    }
  }
  for (i = 0; i < 5; i++) {
    a[i] = (a[i] + 9) / 10 * 10;
    ans += a[i];
    // cout << a[i] << endl;
  }
  // cout << mod_min << endl;
  if (0 < mod_min)
    ans += (-10 + mod_min);

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


Measured memory_bytes: 256
using namespace std;
#include<string>
#include<cmath>
#include <map>
#include <list>
#include <unordered_map>
#define ppl pair<ll,ll>
#define ll long long
#define ld long double
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

#define fr(i,a,b) for(ll i=a;i<b;i++)
#define ffr(i,a,b) for(ll i=a;i>=b;i--)
#include<bits/stdc++.h>
#include<vector>
#define vl vector<ll>
#define PI 3.141592654
const ll N = 1e5 + 1;
const ll P = 1e9 + 7;
#include<iterator>




void solve() {
	ll x, k, d, mi = N, y, p; cin >> x >> k >> d;
	ll e = abs(x);
	ll f = e / d;
	if (k > f) {
		ll h = f * d;
		if (x < 0) {
			p = x + h;
			ll t = k - f;
			if (t % 2 == 0) {cout << abs(p); return;}
			cout << abs(p + d);
		}
		else {
			p = x - h;
			ll t = k - f;
			if (t % 2 == 0) {cout << abs(p); return;}
			cout << abs(p - d);
		}
	}
	else {
		ll g = k * d;
		cout << abs(e - g);
	}
}



int main() {
	fio;
#ifndef ONLINE_JUDGE
	// for getting input
	freopen("input.txt", "r", stdin);
	//for writing output
	freopen("jout.txt", "w", stdout);
#endif
	ll t;
	if (1)
		t = 1;
	else
		cin >> t;
	while (t--) {
		//cout << "Case #" << h << ":\n";
		solve();
		//h++;
		//cout << '\n';
	}
	return 0;
}


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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

///priority_queue< int, vector< int >, greater< int > > minHeap;

void mor(){cout<<"NO"; exit(0);}

int cnt[200005][22];

int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;

    int n;
    scn(n);
    int a[n+1];
    Fill(cnt,0);
    for(int i=1; i<=n; i++)scn(a[i]);

    for(int i=n; i ; i--){

        int num = a[i];

        for(int pos = 0 ; pos<22 ; num /= 2 , pos++){
            int d = num%2;
            cnt[i][pos] = d + cnt[i+1][pos];
        }
    }

    lli ans = 0;
    //cout<<cnt[1][2]<<" "<<cnt[1][1]<<" "<<cnt[1][0]<<endl;

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

        int lo = 1 , hi = i , mid , mn = i;

        vector<int>bin(23,0);

        for(int pos = 0 , num = a[i]; num ; num /= 2 , pos++) bin[pos] = num%2;

        while(lo<=hi){
            mid = (lo+hi)/2;

            bool ok = true;

            for(int pos=0; pos<22 && ok; pos++){

                int v = cnt[mid][pos]-cnt[i][pos];

                ok = (bin[pos]? (v == 0) : (v<=1));
            }

            if(ok){
                mn = min(mn,mid);
                hi = mid-1;
            }
            else lo = mid+1;

            if(lo == hi && mid == lo)break;
        }

        ans += i-mn+1;
    }

    cout<<ans;
    return 0;
    ///return main();
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)


Measured memory_bytes: 18176
#include<stdio.h>
#define M 100

int main(){
  int i, n, m, p, a, x, sum, ans;

  while(1){
    scanf("%d %d %d", &n, &m, &p);
    if(n == 0 && m == 0 && p == 0) break;

    for(i=0, sum=0; i<n; i++){
      scanf("%d", &a);
      sum += a;
      if(i == m-1) x = a;
    }

    if(x == 0){
      printf("0\n");
    }else{
      ans = sum * (M-p) /x;
      printf("%d\n", ans);
    }
  }
  return 0;
}

Measured memory_bytes: 0
// abc157_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    vector<vector<int>> A(3, vector<int>(3));
    REP(i, 3)REP(j, 3) cin >> A[i][j];

    vector<vector<bool>> B(3, vector<bool>(3));

    int N;
    cin >> N;
    REP(q, N){
        int b;
        cin >> b;
        REP(i, 3)REP(j, 3) {
            if (A[i][j] == b){
                B[i][j] = true;
            }
        }
    }

    bool bingo = false;

    REP(i, 3){
        bool tmp = true;
        REP(j, 3) tmp &= B[i][j];
        bingo |= tmp;
    }
    REP(j, 3){
        bool tmp = true;
        REP(i, 3) tmp &= B[i][j];
        bingo |= tmp;
    }
    {
        bool tmp = true;
        REP(i, 3) tmp &= B[i][i];
        bingo |= tmp;
    }
    {
        bool tmp = true;
        REP(i, 3) tmp &= B[i][2-i];
        bingo |= tmp;
    }

    if (bingo){
        print("Yes");
    } else {
        print("No");
    }



    return 0;
}


Measured memory_bytes: 256
from math import cos,radians

a,b,h,m = [int(x) for x in input().split()]

#minute hand 6 deg/min hour hand 0.5 deg/min

dmin = 6*m
dhour = 0.5*(h*60 + m)

diff = abs(dmin - dhour)

ang = min(diff, 360- diff)

ans = pow((a**2) + (b**2) - 2*a*b*cos(radians(ang)),0.5)

# print(ang)
print(ans)

Measured memory_bytes: 9512
#include <algorithm>

#include <bitset>

#include <tuple>

#include <cstdint>

#include <cstdio>

#include <cctype>

#include <assert.h>

#include <stdlib.h>

#include <stdio.h>

#include <cassert>

#include <cfloat>

#include <climits>

#include <cmath>

#include <complex>

#include <ctime>

#include <deque>

#include <fstream>

#include <functional>

#include <iomanip>

#include <iostream>

#include <iterator>

#include <list>

#include <limits>

#include <map>

#include <memory>

#include <queue>

#include <random>

#include <set>

#include <stack>

#include <string>

#include <unordered_map>

#include <unordered_set>

#include <utility>

#include <vector>

#include <math.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	if (N % 1000 != 0) {
		cout << (N / 1000 + 1) * 1000 - N << endl;
	}
	else {
		cout << "0" << endl;
	}
}

Measured memory_bytes: 3600
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rf = lambda: map(float, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
s = rr()
k = ri()
a = s[k-1]
ans = ''
for i in s:
    if i == a:
        ans += a
    else:
        ans += '*'
print(ans)

Measured memory_bytes: 27184
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)

int main() {
	ll x; cin >> x;
	ll ans = 0;
	rep(i, 0, 100000) {
		if (x <= i * (i + 1) / 2) {
			ans = i;
			break;
		}
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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 long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    string s; cin >> s;
    int cnt = 0, ans = -1;
    rep(i, s.size())
    {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') cnt++;
        else ans = max(ans, cnt), cnt = 0;
    }
    ans = max(cnt, ans);
    cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
info = [list(map(int, input().split())) for i in range(m)]

graph = [[] for i in range(n)]
for a, b in info:
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)
    
ans = 0
for i in range(n):
    flag = True
    for v in graph[i]:
        if h[i] <= h[v]:
            flag = False
    if flag:
        ans += 1
print(ans)

Measured memory_bytes: 106344
N = int(input())
T, A = input().split(' ')
T = int(T)
A = int(A)
line = input().split(' ')

minScore = abs(A-(T-int(line[0]) * 0.006))
minIndex = 1
for i in range(N):
    h = int(line[i])
    temp = abs(A-(T - h * 0.006))
    if temp < minScore:
        minScore = temp
        minIndex = i + 1

print (minIndex)


Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

//Ruins
public class Main{

	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		List<Integer>[] l = new List[10001];
		for(int i=1;i<=10000;i++)l[i] = new ArrayList<Integer>();
		for(int i=1;i<=10000;i++)for(int j=1;j*j<=i;j++){
			if(i%j==0)l[i].add(j);
		}
		for(;;){
			int a = sc.nextInt(), b = sc.nextInt();
			if((a|b)==0)break;
			int min = 1<<29;
			int[] t = new int[4];
			for(int p:l[a])for(int q:l[b]){
				t[0]=p; t[1]=a/p; t[2]=q; t[3]=b/q;
				Arrays.sort(t);
				min = Math.min(min, (t[1]-t[0])*(t[1]-t[0])+(t[2]-t[1])*(t[2]-t[1])+(t[3]-t[2])*(t[3]-t[2]));
			}
			System.out.println(min);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
(defun main(x n)
    (let ((a (make-array n :initial-element 0))
        (b 0)
        (ans T))

        (if (= n 0)
            (setq b x))
    
        (dotimes (i n)
            (setf (aref a i) (read))
        )

        (dotimes (i n)
            (if (= x (aref a i))
                (setf ans Nil))
        )
        (if (not (eq ans Nil))
            (setq b x)
            (setf ans T)
        )

        (if (= b 0)
            (loop named main-loop for i from 1 to 100
                do (progn    
                (if (and (<= 0 (- x i)) (eq ans T))
                    (progn
                    (setq b (- x i))
                    (dotimes (j n)
                        (if (= (- x i) (aref a j))
                            (setf ans Nil)))
                    (if (equal ans T)
                        (return-from main-loop)
                        (setf ans T))
                    )
                )
                )
                (if (and (>= 101 (+ x i)) (eq ans T))
                    (progn
                    (setq b (+ x i))
                    (dotimes (j n)
                        (if (= (+ x i) (aref a j))
                            (setf ans Nil)))
                    (if (equal ans T)
                        (return-from main-loop)
                    (setf ans T))
                    )
                )

            )
        )
    b)

)
(format t "~D~%" (main (read) (read)))

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


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

R, G, B, N = MAP()
ans = 0

for r in range(N//R + 1):
	for g in range((N-r*R)//G + 1):
		b = (N - R*r - G*g)/B
		if b == b//1 :
			ans += 1

print(ans)

Measured memory_bytes: 64236
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  int a;cin>>a;
  string s;
  if(a<1200)s="ABC";
  else if(a<2800)s="ARC";
  else s="AGC";
  cout<<s<<endl;
  return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	vi v1,v2;

	cin>>n>>m>>k;

	if(n==m) cout<<k<<endl;
	else if(n==k) cout<<m<<endl;
	else if (m==k) cout<<n<<endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000007
//0=48,A=65,a=97

int main() {
    int n,m;cin >> n >> m;
    vector<int> a(n);
    vector<int> b(n);for(int i=0;i<n;i++) cin >> a[i] >> b[i];  
    vector<int> c(m);
    vector<int> d(m);for(int i=0;i<m;i++) cin >> c[i] >> d[i];  
    
    for(int i = 0; i < n; i++) {
        int mi=INF,x=-1;
        for(int j = 0; j < m; j++) {
            if(abs(a[i]-c[j])+abs(b[i]-d[j])<mi){
                mi=abs(a[i]-c[j])+abs(b[i]-d[j]);
                x=j+1;
            }
        }
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstring>

using namespace std;

int main(void)
{
    int n,i;
    string s;
    cin>>n>>s;
    if(n&1)
        cout<<"No";
    else
    {
        n>>=1;
        for(i=0;i<n;i++)
            if(s[i]!=s[n+i])
                break;
        if(i==n)
            cout<<"Yes";
        else
            cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char S[3];
	int i,c=0,d=0;
	scanf("%s",S);
	i=0;
for(i=0;i<3;i++)
{
	if(S[i]=='A')
	c++;
	else if (S[i]=='B')
	d++;
}
if(c==2||d==2)
printf("Yes");
else
printf("No");
}

Measured memory_bytes: 128
//#include <bits\stdc++.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
using namespace std;

int n, i, x, y, t;

vector<pair<pair<int, int>, int> > vpp;

pair<int, int> pre;

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

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> t >> x >> y;
		vpp.push_back(make_pair(make_pair(x, y), t));
	}

	for (int i = 0; i < n; i++)
	{
		int dist = abs(pre.first - vpp[i].first.first) + abs(pre.second - vpp[i].first.second);
		if (dist > vpp[i].second) return cout << "No", 0;
		if (dist <= vpp[i].second && ((dist % 2) != (abs(vpp[i].second - 2)) % 2))return cout << "No", 0;
	}
	cout << "Yes";
	return 0;
}

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

signed main(){
	int A,B,C,D; cin>>A>>B>>C>>D;
	int ans=0;
	while(A>0 || C>0){
		C-=B;
		ans++;
		if(C<=0)break;
		A-=D;
		ans++;
		if(A<=0)break;
	}
	cout<<(ans%2==1 ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define debug(s, param) std::cerr << s << param << std::endl;

using namespace std;using ll = long long;

// https://atcoder.jp/contests/abc077/tasks/arc084_a

ll biggerSearch(const vector<int>& vec, int target) {
  ll ok = (ll)vec.size();
  ll ng = -1;
  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if (vec[mid] <= target) ng = mid;
    else ok = mid;
  }
  return ok;
}

ll lowerSearch(const vector<int>& vec, int target) {
  ll ok = -1;
  ll ng = (ll)vec.size();
  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if (vec[mid] >= target) ng = mid;
    else ok = mid;
  }
  return ok;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n, 0), b(n, 0), c(n, 0);
  rep (i, n) cin >> a[i];
  rep (i, n) cin >> b[i];
  rep (i, n) cin >> c[i];
  sort(a.begin(), a.end());
  sort(c.begin(), c.end());

  ll ans = 0;
  rep (i, n) {
    ll ai = lowerSearch(a, b[i]);
    ll ci = biggerSearch(c, b[i]);
    ans += ((ai + 1) * (n - ci));
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {
  string a,b;
  int cont;
  cin >> a >> b;
  int temp = a.length()-1;
  while(temp >= 0){
    string s2 = "";
    cont = temp;
    while(s2.length()<b.length()){   
      s2 += a[cont];
      cont++;
      if(cont == a.length()){
        cont=0;
      }
    }
    if(s2==b){
        cout << "Yes" << endl;
        return 0;
    }
    temp--;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3196
def main():
    N, X, Y = map(int, input().split())
    X = X - 1
    Y = Y - 1
    d = {}
    for i in range(X):
        for j in range(i+1, X+1):
            if (j - i) in d:
                d[j - i] += 1
            else:
                d[j - i] = 1
        for j in range(X+1, Y+1):
            t = min(j - i, Y - j + 1 + X - i)
            if t in d:
                d[t] += 1
            else:
                d[t] = 1
        for j in range(Y+1, N):
            t = (j - Y + 1 + X - i)
            if t in d:
                d[t] += 1
            else:
                d[t] = 1
    for i in range(X, Y):
        for j in range(i+1, Y+1):
            t = min(j - i, i - X + 1 + Y - j)
            if t in d:
                d[t] += 1
            else:
                d[t] = 1
        for j in range(Y+1, N):
            t = min(j - i, i - X + 1 + j - Y)
            if t in d:
                d[t] += 1
            else:
                d[t] = 1
    for i in range(Y, N):
        for j in range(i+1, N):
            if (j - i) in d:
                d[j - i] += 1
            else:
                d[j - i] = 1
    for i in range(1, N):
        if i not in d:
            print(0)
        else:
            print(d[i])
main()


Measured memory_bytes: 50396
N = int(input())
A = [int(x) for x in input().split()]

B = [0 for x in range(N)]

for i in range(N):
    if i % 2 == 0:
        B[0] += A[i]
    else:
        B[0] -= A[i]

for i in range(N - 1):
    B[i + 1] = A[i] * 2 - B[i]

for i in range(N):
    if i < N - 1:
        print(B[i], end=' ')
    else:
        print(B[i])

Measured memory_bytes: 14028
import numpy as np
from itertools import product


def main():
    N, M, X = map(int, input().split())

    books = np.array([list(map(int, input().split())) for _ in range(N)])

    min_total_cost = 10**9

    for read_flags in product((True, False), repeat=N):
        to_read_books = books[read_flags, :]
        total_cost = to_read_books[:, 0].sum()
        increased_levels = to_read_books[:, 1:].sum(axis=0)

        if min(increased_levels) >= X:
            min_total_cost = min(min_total_cost, total_cost)

    if min_total_cost == 10**9:
        print('-1')
    else:
        print(min_total_cost)


if __name__ == "__main__":
    main()


Measured memory_bytes: 27308
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const long double PI = acosl(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 1000005;
const int MAXV = 60;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;

struct FenwickTree {
    FenwickTree() {}
    inline void increase(int r, int c, int x) {
        for (int i = r; i <= n; i += lowbit(i))
            for (int j = c; j <= m; j += lowbit(j)) {
                a[i][j] += x;
                b[i][j] += r * x;
                d[i][j] += c * x;
                e[i][j] += r * c * x;
            }
    }
    inline int getSum(int r, int c) {
        int ans = 0;
        for (int i = r; i; i -= lowbit(i))
            for (int j = c; j; j -= lowbit(j)) {
                ans += a[i][j] * (r + 1) * (c + 1);
                ans -= b[i][j] * (c + 1);
                ans -= d[i][j] * (r + 1);
                ans += e[i][j];
            }
        return ans;
    }
    int a[MAXN][MAXN], b[MAXN][MAXN], d[MAXN][MAXN], e[MAXN][MAXN];
    inline int lowbit(int x) { return x & (-x); }
};

int a[MAXN];
bool solve(int mid) {
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ans += max(((a[i] + mid - 1) / mid) - 1, 0);
    }
    return ans <= k;
}
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d%d", &n, &k);
    int maxx = 0;
    for (int i = 0; i < n; i++) {
        a[i] = read<int>();
        maxx = max(maxx, a[i]);
    }
    int l = 1, r = maxx;
    int ans = r;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (solve(mid)) {
            ans = mid;
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
	ll k;
	cin>>k;
	ll n=50;
	Array ans(n,0);
	REP(i,n) ans[i]=i+k/n;
	if(k%n){
		ll d=k%n;
		REP(i,d) ans[i]+=n-(d-1);
		rep(i,d,n) ans[i]-=d;
	}

	cout<<n<<en;
	REP(i,n) cout<<ans[i]<<" ";
	cout<<en;
}

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

    solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}

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

typedef long long ll;

using namespace std;

const int maxn = 1e4 + 100, maxl = 110, dig = 10, mod = 1e9 + 7;
ll dp[maxn][maxl], ps[maxn][maxl];

int main()
{
    int d;
    string k;
    cin >> k >> d;

    for (int i = 0; i < maxn - dig; i++)
        for (int j = 0; j < d; j++)
            for (int x = 0; x < dig; x++)
                if (!i)
                    dp[i + 1][j] += (((x % d) == j) && x);
                else
                    dp[i + 1][(j + x) % d] = (dp[i + 1][(j + x) % d] + dp[i][j]) % mod;

    for (int j = 0; j < d; j++)
        for (int i = 1; i < maxn - dig; i++)
            ps[i][j] = (ps[i - 1][j] + dp[i][j]) % mod;

    ll ans = 0;
    for (int i = 0, s = 0, x; i < k.size(); s += x, ans %= mod, i++)
    {
        x = k[i] - '0';

        if (i == k.size() - 1)
            for (int j = 0; j <= x; j++)
                if (j || i)
                    ans += !((s + j) % d);
                else
                    continue;
        else
            for (int j = 0; j < x; ans += ((!((s + j) % d)) && (j || i)) ,j++)
                for (int u = 0; u < d; u++)
                    if (!((u + s + j) % d))
                        ans = (ans + ps[k.size() - i - 1][u]) % mod;
    }

    cout << ans;

    return 0;
}

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



int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> field(h);
    rep(i,h) cin >> field[i];
    int ans = 0;
    for(int bith = 0; bith < (1<<h); bith++){
        vector<int> row(h,1);
        for(int i = 0; i < h; i++){
                if(bith & (1<<i)) row[i] = 0;
        }
        for(int bitw = 0; bitw < (1<<w); bitw++){
            vector<int> column(w,1);
            for(int j = 0; j < w; j++){
                if(bitw & (1<<j)) column[j] = 0;
            }
            int cnt = 0;
            for(int i = 0; i < h; i++){
                if(row[i] == 0) continue;
                for(int j = 0; j < w; j++){
                    if(column[j] == 0) continue;
                    if(field[i][j] == '#') cnt++;
                }
            }
            if(cnt == k) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
N,K = map(int, input().split())
v_list = list(map(int,input().split()))


def func(n):
    lri = []
    for l in range(n+1):
        for r in range(n-l+1):
            for i in range(n-l-r+1):
                if i>l+r:
                    continue
                if l+r >N:
                    continue
                lri.append([l,r,i])
    return lri

lri_list = func(K)

result = 0
for l,r,i in lri_list:
#     print(l,r,i)
    if r>0:
        tmp_v = v_list[:l] + v_list[-r:]
    else:
        tmp_v = v_list[:l]
#     print(tmp_v)
    tmp_v = sorted(tmp_v)
#     print(tmp_v)
    
    tmp_sum = sum(tmp_v)
    
    for v in tmp_v:
        if i<=0:
            break
        if v<0:
            tmp_sum += -v
            i -= 1
    if result < tmp_sum:
        result = tmp_sum
#     print(tmp_sum)
print(result)

Measured memory_bytes: 51676
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int a , b , c;
    cin >> a >> b >> c;
    if(a == b && b == c){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3616
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;

// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}


void solve(istream& in, ostream& out) {
  auto n = next<int>(in);
  auto m = next<int>(in);
  out << (1 << m) * (100 * (n - m) + 1900 * m) << "\n";
}


//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll,pair<ll, ll>> lpll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;

#define deg_to_rad(deg) (((deg)/360)*2*PI)

const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;

const ld PI = (acos(-1));
const ld EPS = 0.0000000001;
// cout << fixed << setprecision(10) << middle << endl;

int main() {
    // input, ready
    int N,Q;
    cin >> N;
    vector<int> AList(100001,0);
    ll ans = 0;
    for (int i=0; i<N; i++) {
        int a;
        cin >> a;
        AList[a]++;
        ans += a;
    }
    cin >> Q;

    // resolve
    for (int i=0; i<Q; i++) {
        int b,c;
        cin >> b >> c;
        ll change_num = AList[b];
        AList[c] += change_num;
        AList[b] = 0;
        ans -= b*change_num;
        ans += c*change_num;
        cout << ans << endl;
    }


    // output

    return 0;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
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;}

int main() {
    ll n;
    cin >> n;
    ll dp[110][5][5][5];
    memset(dp, 0, sizeof(dp));
    dp[0][0][0][0] = 1;

    rep(i, 0, n) rep(a, 0, 5) rep(b, 0, 5) rep(c, 0, 5) rep(d, 1, 5) {
        // dp[i][a][b][c], dp[i+1][b][c][d]
        // skip AGC, ACG, GAC, A*GC, AG*C
        if(b==1 && c==3 && d==2) continue;
        if(a==1 && c==3 && d==2) continue;
        if(b==3 && c==1 && d==2) continue;
        if(b==1 && c==2 && d==3) continue;
        if(a==1 && b==3 && d==2) continue;

        dp[i+1][b][c][d] += (dp[i][a][b][c] % MOD);
    }
    ll ans = 0;
    rep(a, 0, 5) rep(b, 0, 5) rep(c, 0, 5) {
        ans += (dp[n][a][b][c] % MOD);
    }
    cout << ans % MOD << endl;

}

Measured memory_bytes: 384