akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
#include <algorithm>
#include <cmath>

using namespace std;

void _097b()
{
    int X;
    set<long> pow_list;
    
    cin >> X;
    
    if (X == 1) {
        cout << "1" << endl;
        return;
    }

    for (int i = 1; i < X; i++) {
        for (int j = 2; j < X; j++) {
            int n = pow(i, j);
            pow_list.insert(n);
            if (n > X) {
                pow_list.erase(n);
                break;
            }
        }
    }
    set<long>::iterator p = pow_list.end();
    --p;
    cout << *p << endl;
}

int main()
{
    _097b();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

//  const int MOD = 1e9 + 7;

//unsigned seed1= chrono::system_clock::now().time_since_epoch().count();
//mt19937 rng (seed1);

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


  int N;
  cin >> N;
  for(double X = 1.; X <= N; ++X){
    if( (int)(1.08 * X) == N ){
      cout << (int)X << endl;
      exit(0);
    }
  }
  
  cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;

typedef long long ll;


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

  int res = 0;
  for (int i = 1; i <= 3; ++i) {
    res = A * B * i;
    if (res % 2 != 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, k;
  int t;
  cin>>t;
  for(int j=0;j<t;++j){
    int x[100000]={};
    int diff[100000]={};
    cin>>n >>k;
    cin>>x[0];
    for(int i=1;i<n;++i){
      cin>>x[i];
      diff[i] = x[i]-x[i-1];
    }
    sort(diff, diff+n);
    reverse(diff, diff+n);
    int ans = x[n-1] - x[0];
    for(int i=0;i<k-1;++i){
      ans-=diff[i];
      }
    if(ans<0) cout<<0<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3920
n = int(input())
s = str(input())
x_sum=[]
y_sum=[]
for i in range(n):
    x = s[0:i]
    y = s[i:n]
    x_sum.append(x)
    y_sum.append(y)
m = []
for i in range(1,n):
    x_list = list(x_sum[i])
    x_unique = list(set(x_list))
    l = 0
    for j in x_unique:
        if y_sum[i].find(j) > -1:
            l += 1
    m.append(l)
print(max(m))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		while (scanner.hasNext()) {

			int n = input();
			int count = 0;

			for (int i = 0; i <= 9; i++) {

				for (int j = 0; j <= 9; j++) {

					for (int k = 0; k <= 9; k++) {

						for (int l = 0; l <= 9; l++) {

							if (n == i + j + k + l) {

								count++;

							}
						}
					}
				}
			}

			System.out.println(count);

		}

		close();

	}

	public static int input() {

		return scanner.nextInt();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 26712
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#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 fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)

void solve(){
    ll n;
    cin>>n;
    ll a[n];
    ll fo[n+1]={0}, fn[n+1]={0};
    loop(i,0,n){
        cin>>a[i];
        fo[a[i]]++, fn[a[i]]++;
    }
    ll ans = 0;
    loop(i,1,n+1){
        ans += (fo[i]*(fo[i]-1))/2;
    }
    // trace(ans);
    loop(i,0,n){
        ll x = ans;
        x -= (fo[a[i]]*(fo[a[i]]-1))/2;
        x += ((fo[a[i]]-1)*(fo[a[i]]-2))/2;
        print(x);
    }

}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
   
}


Measured memory_bytes: 7296
#include<stdio.h>
#include<string.h>

int main(){
    char s[200001];
    char t[200001];
    scanf("%s",s);
    scanf("%s",t);
    int ans = 0;
    for(int i=0;i<strlen(s);i++){
        if(s[i]!=t[i]){
            ans ++;
        }
    }
    printf("%d\n",ans);
}

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

int main()
{
    int n;
    cin >> n;
    int cnt=0;
    for(int i=1;i<=n;++i){
        int a=i,j=1;
        while(a>=10){
            a/=10;
            ++j;
        }
        if(j%2==1) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


YES = "Yes"  # type: str
NO = "No"  # type: str

def solve():
    return


def main():
    N = int(input())
    for i in range(1, 10):
        for j in range(1, 10):
            if i * j == N:
                print(YES)
                return
    print(NO)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3944
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

sum = 0
for i in range(n):
    sum += B[i]
    if i == n-1:
        continue
    else:
        if A[i]+1 == A[i+1]:
            sum += C[A[i]-1]
print(sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
int x,y,z,w;
  cin>>x>>y>>z>>w;
   while(x>0&&z>0){
  z-=y;
  if (z<=0){
  break;}
  else{
   x-=w;}
  if(x<=0){
  break;}
  else{
    continue;}
  }
  if (z<=0){
  cout<<"Yes"<<endl;}
  else{
     cout<<"No"<<endl;} 
}

Measured memory_bytes: 3632
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>
#include<tuple>
using namespace std;

int abc108_b(){
    // 入力
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3,y3,x4,y4;

    
    //処理
    int xdist = x1 - x2;
    int ydist = y1 - y2;
    x3 = x2 + ydist;
    y3 = y2 - xdist;
    x4 = x1 + ydist;
    y4 = y1 - xdist;
    
    //出力
    cout << x3 << " "<< y3 << " " << x4 << " " << y4 << endl;
    return 0;
}

int main() {
    abc108_b();
    return 0;
}


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


int comb(int n, int r) {
    int ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

int main(void) {
    int n;
    cin >> n;
    int a[n], sorted[n];
    int ai = 0, aj = 0, max = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] > ai) ai = a[i];
    }

    int q_aj = 0;
    for (int j = 0; j < n; j++) {
        int p_aj = 0;
        if (a[j] <= ai / 2) p_aj = a[j];
        else p_aj = ai - a[j];
        if (ai - p_aj >= p_aj && q_aj <= p_aj) {
            aj = a[j];
            q_aj = p_aj;
        }
    }

    cout << ai << ' ' << aj << endl;

    return 0;
}


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

string int2str(int n){
	stringstream ss;
	ss<<n;
	string text;
	ss>>text;
	return text;
}

int main(void){

	while (true){
		int a,b;
		cin>>a;
		if (cin.eof()) break;
		cin>>b;
		cout<<int2str(a+b).size()<<endl;
	}
	
	return 0;
} 

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  while(cin>>N>>M,N){
    int r,t,n,m,s;
    vector<int> d[10001];
    cin>>r;
    for(int i=0;i<r;i++){
      cin>>t>>n>>m>>s;
      if(!s)s=-1;
      d[m].push_back(s*t);
    }
    int q,ts,te,a;
    cin>>q;
    for(int i=0;i<q;i++){
      int ans=0,k=0;
      cin>>ts>>te>>a;
      for(int j=0;j<d[a].size();j++){
	if(!k&&ts<d[a][j])ts=d[a][j];
	if(d[a][j]>0)k++;
	else k--;
	if(!k)ans+=max(0,min(te,-d[a][j])-ts);
      }
      cout<<ans<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3372
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main(){
	ll n;
	cin>>n;
	ll a[n];
	ll dp[n];
	for(int i=0;i<n;++i){
		if(i!=0){
			cin>>a[i];
			dp[i]=a[i]+dp[i-1];
		}else{
			cin>>a[i];
			dp[0]=a[0];
		}
	}
	ll mod = 1e9+7;
	ll ans=0;
	for(int i=0;i<n;++i){
		ans=(ans+(((dp[n-1]-dp[i])%mod)*(a[i]%mod))%mod)%mod;
		//cout<<a[n-1]-a[i]<<"\n";
	}
	cout<<ans;
}


Measured memory_bytes: 6744
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

vector<int> MakePrimeList(int N) {
	vector<bool> IsPrime(N+1, true);
	for (int i = 2; i <= (int)sqrt(N)+1; i++) {
		if (IsPrime[i]) {
			int buf = i*2;
			while (buf < N) {
				IsPrime[buf] = false;
				buf += i;
			}
		}
	}
	vector<int> PrimeList;
	for (int i = 2; i <= N; i++) if (IsPrime[i]) PrimeList.push_back(i);
	return PrimeList;
}

bool IsPrime(int X, vector<int> PrimeList) {
	int limit = (int)sqrt(X) + 1;
	for (int p : PrimeList) {
		if (X == p) return true;
		if (X % p == 0) return false;
		if (p >= limit) break;
	}
	return true;
}

int main() {
	int X;
	cin >> X;
	if (X!= 2 && X % 2 == 0) X++;
	vector<int> PrimeList = MakePrimeList(X);
	while (!IsPrime(X, PrimeList)) X += 2;
	cout << X << endl;
}



Measured memory_bytes: 384
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		BigInteger b1= new BigInteger(scan.nextLine());
		BigInteger b2= new BigInteger("9");
		BigInteger c= new BigInteger("0");
		if((b1.mod(b2)).equals(c)) System.out.println("Yes");
		else System.out.println("No");

	}

}


Measured memory_bytes: 34024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
} edge;
typedef struct {
	bool a;
	bool b;
} P;
int main( void ){
	int H, W; cin >> H >> W;
	vector <vector <P> > vec( H, vector <P>( W, P{0, true} ));
	rep( i, 0, H ){
		rep( j, 0, W ){
			char c; cin >> c;
			vec[ i ][ j ].a = ( c == '.' );
		}
	}
	queue <int> que;
	rep( i, 0, H ){
		bool can = true;
		rep( j, 0, W ){
			if (!vec[ i ][ j ].a){
				can = false;
				break;
			}
		}
		if (can){
			rep( j, 0, W )
			vec[ i ][ j ].b = false;
			que.push( i );
		}
	}
	rep( i, 0, W ){
		bool can = true;
		rep( j, 0, H ){
			if (!vec[ j ][ i ].a){
				can = false;
				break;
			}
		}
		if (can)
			rep( j, 0, H )
			vec[ j ][ i ].b = false;
	}
	rep( i, 0, H ){
		if (!que.empty() && que.front() == i){
			que.pop();
			continue;
		}
		rep( j, 0, W ){
			if (vec[ i ][ j ].b)
				cout << ( vec[ i ][ j ].a ? '.' : '#' );
		}
		cout << endl;
	}
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
const f: array[1..12] of array[1..2] of longint =
    ((0,0),(0,2),(0,3),(1,0),(1,1),(1,2),(2,0),(2,1),(2,2),(3,0),(3,2),(3,3));
    XXX = 1000000007;

var n, ans: int64;
    i, j: longint;
    cnt: array[0..1,0..60,0..3] of int64;

begin
    read(n);
    fillchar(cnt, sizeof(cnt), 0);
    cnt[0,0,0] := 1;
    cnt[0,0,3] := 1;
    cnt[1,0,0] := 1;
    cnt[1,0,3] := ord(odd(n));
    for i := 1 to 60 do
        for j := 1 to 12 do begin
            cnt[0,i,f[j,1]] := (cnt[0,i,f[j,1]] + cnt[0,i-1,f[j,2]]) mod XXX;
            if (f[j,1] div 2) < ((n shr i) and 1) then
                cnt[1,i,f[j,1]] := (cnt[1,i,f[j,1]] + cnt[0,i-1,f[j,2]]) mod XXX
            else if (f[j,1] div 2) = ((n shr i) and 1) then
                cnt[1,i,f[j,1]] := (cnt[1,i,f[j,1]] + cnt[1,i-1,f[j,2]]) mod XXX;
        end;
    ans := cnt[1,60,0];
    write(ans);
end.

Measured memory_bytes: 128
function Main(input) {
	var inputArr = input.split(" ");
	var a = parseInt(inputArr[0], 10);
    var b = parseInt(inputArr[1], 10);
    var t = parseInt(inputArr[2], 10);
    console.log(Math.floor((t+0.5) / a) * b) ;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int n;
	cin >> n;
	vector<ll> h(n);
	cin >> h[0];
	bool ans = true;
	for (int i = 1; i < n; i++)
	{
		cin >> h[i];
	}


	for (int i = n - 1; i >= 1; i--)
	{
		if (h[i] >= h[i - 1])
		{
			continue;
		}
		else
		{
			h[i-1]--;
		}
	}
	rep(i, n - 1)
	{
		if (h[i] <= h[i + 1])
		{
			continue;
		}
		else
		{
			ans = false;
		}
	}
	if (ans)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}


}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int maxn = 1e5 + 10;
int root[maxn];
int getroot(int x){
	return root[x] = root[x] == x ? x : getroot(root[x]);
}
int n , m;
int v[maxn] , who[maxn] , b[maxn];
bool use[maxn];
long long ans = 0;
int main(){
	ios::sync_with_stdio(0);
	cin >> n >> m;
	for(int i = 1 ; i <= n ; ++ i)
		cin >> v[i];
	for(int i = 1 ; i <= n ; ++ i)
		root[i] = i;
	for(int i = 1 ; i <= n ; ++ i)
		who[i] = i;
	for(int i = 1 ; i <= m ; ++ i){
		int s , t;
		cin >> s >> t;
		s ++; t ++;
		int s1 = getroot(s) , t1 = getroot(t);
		if(s1 == t1) continue;
		if(v[who[s1]] < v[who[t1]])
			who[t1] = who[s1];
		root[s1] = t1;
	}
	int cnt = 0;
	for(int i = 1 ; i <= n ; ++ i){
		int s = getroot(i);
		if(s == i){
			cnt ++; 
			ans += v[who[i]];
			use[who[i]] = 1;
		}
	}
	if((cnt - 1) * 2 > n)
		cout << "Impossible" << endl;
	else{
		if(cnt == 1){
			cout << 0 << endl;
			return 0;
		}
		int sum = 0;
		for(int i = 1 ; i <= n ; ++ i)
			if(!use[i]) b[++ sum] = v[i];
		sort(b + 1 , b + sum + 1);
		for(int i = 1 ; i < cnt - 1 ; ++ i)
			ans += b[i];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1920
for _ in [0]*int(input()):
    s=input()
    char=0
    for _ in [0]*int(input()):
        c=input()
        if c[0]=='i':
            c=c.split('"')[1]
            s=s[:char]+c+s[char:]
            char += len(c)
            
        elif c[8]=='w':
            while char <len(s) and s[char]==' ':
                char += 1
            while char < len(s) and s[char]!=' ':
                char += 1
                
        elif c[7]=='c':
            s=s[:char]+s[char+1:]
            
        elif c[9]=='w':
            while char > 0 and s[char-1]==' ':
                char-=1
            while char > 0 and s[char-1]!=' ':
                char-=1
                
        elif c[8]=='c':
            char=min(len(s),char+1)
            
        elif c[7]=='w':
            if s[char:].count(' ') == len(s[char:]): 
                continue
            while char<len(s) and s[char]==' ':
                s=s[:char]+s[char+1:]
                
            while char<len(s) and s[char]!=' ':
                s=s[:char]+s[char+1:]
                
        else:
            char=max(0,char-1)
            
    print(s[:char]+'^'+s[char:])



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

using namespace std;

#define ll long long

int main()
{
    vector <int> a(4);
    char x;
    for (int i=0; i<4; ++i) {
        cin >> x;
        a[i] = (x - '0');
    }

    if (a[0] == a[1] || a[1] == a[2] || a[2] == a[3])
        cout << "Bad";
    else
        cout << "Good";
    return 0;
}


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

int main(){
	int A,B,C;
	cin >> A >> B >> C;
	int answer = 0;
	if(A >= B && A >= C){
		answer = A * 10 + B + C;
	}else if(B >= A && B >= C){
		answer = B * 10 + A + C;
	}else{
		answer = C * 10 + A + B;
	}
	cout << answer << endl;
}


Measured memory_bytes: 256
#ifdef ConanYu
#include "E:\yuzining\code\local.hpp"
#else
#pragma GCC optimize("-O3")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(...) do { } while(false)
void Main();
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie();
  Main();
  return 0;
}
#endif

vector<ll> v;
ll cur;
void dfs(int id, int lst) {
  if(id == 0) {
    v.push_back(cur);
    return;
  }
  for(int i = max(lst - 1, 0); i <= min(lst + 1, 9); i++) {
    cur = cur * 10 + i;
    dfs(id - 1, i);
    cur /= 10;
  }
}

void Main() {
  for(int i = 0; i < 10; i++) {
    for(int j = 1; j <= 9; j++) {
      if(i == 9 && j >= 4) continue;
      cur = j;
      dfs(i, j);
    }
  }
  sort(v.begin(), v.end());
  debug(v.size(), v.back());
  int k; cin >> k;
  cout << v[k - 1] << "\n";
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int cnt = 0;

    for (int i = a; i <= b; i++) {
      String s = Integer.toString(i);
      StringBuilder bld = new StringBuilder(s.substring(3));
      String rev = bld.reverse().toString();
      if (s.substring(0, 2).equals(rev)) {
        cnt++;
      }
    }

    System.out.println(cnt);

  }
}

Measured memory_bytes: 53140
#include <stdio.h>

int main(){
    int a, b, c, min;
    scanf("%d%d%d", &a, &b, &c);
    min = a + b;
    if(min > (b + c)){
        min = b + c;
    }
    if(min > (c + a)){
        min = c + a;
    }
    printf("%d\n", min);

    return 0;
}

Measured memory_bytes: 128
def s(a):
	b = c = 0
	for i in a:
		if i > b:
			b = i
		elif i > c:
			c = i
		else:
			return False
	return True
	
for n in range(int(raw_input())):
	print "YES" if s(map(int,raw_input().split())) else "NO"

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

int main(){
  ll n;
  cin >> n;
  ll ans = 10000000000000;
  for(ll i=1; i*i<=n; i++){
    if(n%i != 0) continue;
    ll j = n/i;
    ans = min(ans, i+j-2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    vector<int> tako(n);
    for(int i=0; i<n; i++){
        cin >> tako.at(i);
    }
    int sum = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(i != j)sum += tako.at(i)*tako.at(j);
        }
    }
    cout << sum/2 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

typedef int S4;

#define START_NUM	(1)
#define END_NUM		(9)

S4 main(){
	S4 s4_t_i;
	S4 s4_t_j;
	S4 s4_t_result;
	for(s4_t_i = (S4)START_NUM; s4_t_i <= (S4)END_NUM; s4_t_i++)
	{
		for(s4_t_j = (S4)START_NUM; s4_t_j <= (S4)END_NUM; s4_t_j++)
		{
			s4_t_result = s4_t_i * s4_t_j;
			printf("%dx%d=%d\n", s4_t_i, s4_t_j, s4_t_result);
		}
	}
	return 0;
}

Measured memory_bytes: 1684
using System;

namespace ITP1_7_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int n = int.Parse(str.Split(' ')[0]);
            int m = int.Parse(str.Split(' ')[1]);
            int l = int.Parse(str.Split(' ')[2]);
            int[,] A = new int[n, m];
            int[,] B = new int[m, l];
            long[,] C = new long[n, l];

            for (int i = 0; i < n; i++)
            {
                string number = Console.ReadLine();
                for (int j = 0; j < m; j++)
                {
                    A[i, j] = int.Parse(number.Split(' ')[j]);
                }
            }

            for (int i = 0; i < m; i++)
            {
                string number = Console.ReadLine();
                for (int j = 0; j < l; j++)
                {
                    B[i, j] = int.Parse(number.Split(' ')[j]);
                }
            }

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < l; j++)
                {
                    for (int k = 0; k < m; k++)
                    {
                        C[i, j] += A[i, k] * B[k, j];
                    }
                }
            }

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < l; j++)
                {
                    Console.Write("{0}", C[i, j]);
                    if (j != l - 1)
                        Console.Write(" ");
                }
                Console.Write("\n");
            }
        }
    }
}


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

using namespace std;

int main(){
    int k;
    cin >> k;
    int a;
    int b;
    cin >> a >> b;
    for(int i = a; i <= b; i++){
        if(i % k == 0){
            cout << "OK" << endl;
            return 0;
        }
        else if(i == b){
            cout << "NG" << endl;
            return 0;
        }
    }
}

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

int main() {
    long a, b, c, k;
    cin>>a >>b >>c >>k;
    if(a>=k){
        cout<<k<<endl;
    }else if((a+b)>=k){
        cout<<a<<endl;
    }else{
        cout<<2*a-k+b<<endl;
    }
}

Measured memory_bytes: 3632
N = int(input())
"""
どの部分集合の共通する要素も一つだけで、各数字（１～N）は２回ずつしか出現しないことから、部分集合の数をｋとすると、
(1)と(2)の共通が１、(1)と(3)の共通が２、～、(k-1)と(k)の共通がN、のように表現でき、この中で１～Nが２回ずつ出現している。
ある部分集合がほかのk-1この部分集合と共通の値を一個ずつもつので、部分集合の要素数はk-1となる。
１～Nまで２回ずつ出てくる＆ｋ個の部分集合の要素がそれぞれ（ｋ－１）であることから、２N＝k(k-1)となる。
ｋが決まれば、上記の(1)と(2)の共通が１で～みたいな置き方をしていくだけでそれぞれの集合が決まる。
Nは10^5までなので、ｋが１０００程度の範囲までで、２N＝k(k-1)を満たすｋがあるか調べていけばよい。

公式開設動画が非常にわかりやすかった：https://www.youtube.com/watch?v=wwCqOcWkVh4
"""
k = 0
while N != k*(k-1)//2:
    k += 1
    if k == 1000:
        break

if k == 1000:
    print("No")
else:
    ans = [[] for _ in range(k)]
    cnt = 0
    for i in range(k):
        for j in range(i+1,k):
            ans[i].append(cnt+1)
            ans[j].append(cnt+1)
            cnt += 1

    print("Yes")
    print(k)
    for a in ans:
        print(k-1, *a)

Measured memory_bytes: 12608
using System;

namespace Project
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			string[] str = Console.ReadLine().Split(' ');
			double a = double.Parse(str[0]);
			double b = double.Parse(str[1]);
			double C = int.Parse(str[2]);
			C = Math.PI * C / 180;
			double c = Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(C));
			double S = a * b * Math.Sin(C) / 2;
			double L = a + b + c;
			double h = b * Math.Sin(C);
			Console.Write("{0}\n{1}\n{2}\n", S, L, h);
		}
	}
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1777777777ll
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;
li x[111];

int main() {
    cin >> n;
    rin{
        cin >> x[i];
    }
    li res = INF;
    repp(i, 1, 101) {
        li tres = 0;
        rep(j, n) {
            li diff = abs(x[j] - i);
            tres += diff * diff;
        }
        res = min(tres, res);
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
n=int(input())
s_list=list(input())

alpha2num = lambda c: ord(c) - ord('A') + 1

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)    
    else:
        return num2alpha(num%26)

ans = []
for i in range(len(s_list)):
    num_ = alpha2num(s_list[i])
    if (num_ + n) %26 != 0:
        ans.append(num2alpha(num_ + n))
    else:
        ans.append('Z')

ans_str = ''

if n == 0:
    for i in range(len(s_list)):
        ans_str += s_list[i]
    print(ans_str)
else:
    for i in range(len(ans)):
        ans_str += ans[i]
    print(ans_str)

Measured memory_bytes: 3188
s = list(input())
k = int(input())

if len(set(s)) == 1:
    print((len(s)*k)//2)
    exit()

def n_change(sss):
    s = sss.copy()
    x = 0
    for i in range(1, len(s)):
        if s[i] == s[i-1]:
            s[i] = "X"
            x += 1
    return x

print(n_change(s) + (k-1) * (n_change(2*s) - n_change(s)))

Measured memory_bytes: 3064
S = input()
ans = 0
for left in range(len(S)):
    for right in range(left, len(S) + 1):
        tmp = S[left:right]
        for ch in tmp:
            if ch not in ('A', 'T', 'C', 'G'):
                break
        else:
            ans = max(ans, len(tmp))
print(ans)

Measured memory_bytes: 3060
n,k = (int(x) for x in input().split())
town = [int(i) for i in input().split()]
warp  = [1]
checklist = [0]+[-1]*n
i = 0
j = 1
s = 0
while j<=n:
    warp.append(town[i])
    if checklist[town[i]-1]!=-1:
        s = checklist[town[i]-1]
        loop = warp[s:j]
        break
    checklist[town[i]-1] = j
    i = town[i]-1
    j += 1
if k>=s:
    m = len(loop)
    print(loop[(k-s)%m])
else:
    print(warp[k])

Measured memory_bytes: 32272
#include<cstdio>

int main(){
    int n,m,l;
    scanf("%d %d %d",&n,&m,&l);
    int a[n][m];
    int b[m][l];
    long c[n][l];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(int i = 0; i < m; i++){
        for(int j = 0; j < l; j++){
            scanf("%d",&b[i][j]);
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++) {
            c[i][j] = 0;
            for(int k = 0; k < m; k ++){
                c[i][j] += a[i][k] * b[k][j];
            }
            if(j != l - 1){
                printf("%ld ",c[i][j]);
            }
            else{
                printf("%ld",c[i][j]);
            }
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2868
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;


// RMQ segment tree O(n) for init
// 1. init(n)
// 2. query(l, r, 0, 0, n) or update

const int MAX_N = 1 << 17;

ll n, dat[2 * MAX_N - 1];

void init(int n_) {
  n = 1;
  while(n < n_) n *= 2;

  for(int i = 0; i < 2 * n - 1; i++) dat[i] = INFi;
}

void update(int k, ll a) {
  k += n - 1;
  dat[k] = a;
  while(k > 0) {
    k = (k - 1) / 2;
    dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
  }
}

ll query(int a, int b, int k, int l, int r) {
  if(r <= a || b <= l) return INFi;
  if(a <= l && r <= b) return dat[k];
  else {
    ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return min(vl, vr);
  }
}

int N;
ll x;
ll a[MAX_N];

int main(){
  cin >> N >> x;
  REP(i, N) cin >> a[i];

  init(2 * N);
  REP(i, N) {
    update(i, a[i]);
    update(i + N, a[i]);
  }

  ll ans = INFll;
  REP(i, N) {
    ll s = i * x;
    REP(j, N) {
      s += query(N + j - i, N + j + 1, 0, 0, n);
    }
    ans = min(ans, s);
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    long long N;
    long long A[100000];
    cin >> N;
    for (int i=0; i<N; i++) cin >> A[i];
    
    vector<int> color(N);
    for (int i=0; i<N; i++) {
        color[i] = 1;
    }
    int head = 1;
    for (int i=0; i<N; i++) {
        long long item = -A[i];
        int idx = upper_bound(color.begin(), color.begin()+head, item) - color.begin();
        color[idx] = item;
        if (idx == head-1) {
            head++;
        }
    }
    int s = 0;
    for (int i=0; i<N; i++) {
        if (color[i] == 1) break;
        s++;
    }
    cout <<  s << endl;
    return 0;
}



Measured memory_bytes: 1408
#include<cstdio>
//#include<vector>
#include<algorithm>
#define N (int)1e6
using namespace std;

int main(){
  int n,tmp,dp[N],dp_odd[N];
  int plc[1000],num;

  for(int i=0;i<N;i++)dp[i] = dp_odd[i] = N+1;
  dp[0] = dp_odd[0] = 0;

  tmp = 1;
  for(num=1;;num++){
    plc[num] = tmp;
    tmp *= num+3; tmp /= num;
    if(tmp>=N)break;
  }
  
  for(int i=0;i<N;i++){
    for(int j=1;j<num;j++){
      if(i<plc[j])break;
      dp[i] = min(dp[i],dp[i-plc[j]]+1);
      if(plc[j]&1)dp_odd[i] = min(dp_odd[i],dp_odd[i-plc[j]]+1);
    }
  }

  while(scanf("%d",&n) && n)printf("%d %d\n",dp[n],dp_odd[n]);
}

Measured memory_bytes: 8448
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    int n, d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    for(int i = 0; i<n; i++){
        for(int j =0; j<d; j++){
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i< n; i++){
        for(int j = 0; j<i; j++){
            int naka = 0;
            for(int k = 0; k < d; k++){
                int s = x[i][k]-x[j][k];
                naka += s * s;
            }
            int s = sqrt(naka)+0.1;
            if(s * s == naka) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n = int(input())
mtx = []

for i in range(n):
    a = int(input())
    l = []
    for j in range(a):
        x,y = map(int, input().split())
        l.append([x, y])
    mtx.append(l)

def counter(sample):
    if sample == 0:
        return 0
    else:
        return counter(sample >> 1) + (sample & 1) #末尾が１なら１をたす

count = 0
for sample in range(2**n):
    judge = True
    for i in range(n):
        if not sample & (1 << i):
            continue
        else:
            for j in mtx[i]:
                if ((sample >> (j[0] - 1)) & 1) ^ j[1]:
                    judge = False
                    break
            if not judge:
                break
    if judge:
        count = max(count, counter(sample))
    
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define rep(i,a,b) for(int i = a ; i < b ; ++i)

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

template<class T> bool umin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool umax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int MOD = 1e9+9 ;
const ll inf = 1e18 ;  
const ll mod = 1e9+7 ;  

ll nCr(ll n,ll r){ll t=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){t*=(n-i);t/=(i+1);}return t;}
ll power(ll a, ll n) { ll r=1;while(n){if(n&1)r=(r*a)%MOD;n>>=1;a=(a*a)%MOD;}return r%MOD;}



vt<pii> dir =  {{-1,0} , {1, 0} , {0,-1} , {0,1}} ; 

// ==========Start Here==============

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
	int n ; 
	cin >> n ; 
 	int N = 1e6 ; 
 	vt<bool> primes(N) ; 
 	vt<bool> vis(N);
 	primes[1] = 0 ; 
 	rep(i,2,N) {
 		if(!vis[i]) {
 			primes[i] = 1 ; 
 			if(i >= n) {
 				cout << i ; 
 				return 0 ; 
 			}
 			for(int j = i ; j < N ; j+= i) {
 				vis[j] = 1 ; 
 			}
 		}
 	}

	return 0 ; 
}

Measured memory_bytes: 3768
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,p[4],a,b,c,ans=0,k=0,j=0;
priority_queue<pair<int,int>,vector<pair<int,int> >, greater<pair<int,int> > >q;
signed main()
{
    cin>>n>>m;
    for(int i=1;i<n;++i)q.push(make_pair(i,3));
    cin>>p[1];
    for(int i=2;i<=m;++i)
    {
        cin>>p[i%2];
        int x=min(p[i%2],p[(i+1)%2]);
        int y=max(p[i%2],p[(i+1)%2]);
        q.push(make_pair(x,1));
        q.push(make_pair(y,2));
    }
    while(!q.empty())
    {
        pair<int,int>pr=q.top();
        q.pop();
        if(pr.second==3)
        {
            cin>>a>>b>>c;
            ans+=min(a*k,b*k+c);
            j++;
        }
        if(pr.second==1)k++;
        if(pr.second==2)k--;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11120
def meg_bisect(ng, ok, func):
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if func(mid):
            ok = mid
        else:
            ng = mid
    return ok

n, k, *a = map(int, open(0).read().split())
print(meg_bisect(0, max(a), lambda x: sum(0--b // x - 1 for b in a) <= k))

Measured memory_bytes: 31540
while 1:
  n = int(input())
  if n == 0:
    break
    
  for _ in range(n):
    m, e, j = map(int, input().split())
    total = m + e + j
    if 100 in [m, e, j]:
      print('A')
    elif m + e >= 180:
      print('A')
    elif total >= 240:
      print('A')
    elif total >= 210:
      print('B')
    elif total >= 150 and (m >= 80 or e >= 80):
      print('B')
    else:
      print('C')



Measured memory_bytes: 5612
import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7

N, K = MAP()
A = LIST()

cur = A[:]
for k in range(K):
    imos = [0] * (N+1)
    for i in range(N):
        imos[max(i-cur[i], 0)] += 1
        imos[min(i+cur[i]+1, N)] -= 1
    imos = list(accumulate(imos))
    cur = imos[:-1]
    if min(cur) == N:
        break
print(*cur)


Measured memory_bytes: 181380
def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

P = 998244353

N, A, B, K = reads()

def inv(n):
  return pow(n, P-2, P)

fact = [1] * (N+1)
for i in range(1, N+1):
  fact[i] = fact[i-1] * i % P

invfact = [inv(fact[N])] * (N+1)
for i in range(N, 0, -1):
  invfact[i-1] = invfact[i] * i % P

def comb(n, k):
  # assert 0 <= k <= n
  return fact[n] * invfact[k] * invfact[n-k] % P

result = 0
for x in range(N+1):
  y, r = divmod(K - A * x, B)
  if r == 0 and 0 <= y <= N:
    result = result + comb(N, x) * comb(N, y) % P

print(result % P)

Measured memory_bytes: 26740
#!/usr/bin/env python

if __name__ == '__main__':
    while True:
        m, f, r = map(int, raw_input().split())

        if [m, f, r] == [-1, -1, -1]:
            break

        if m == -1 or f == -1:
            print 'F'
        elif m+f >= 80:
            print 'A'
        elif m+f >= 65:
            print 'B'
        elif m+f >= 50 or r >= 50:
            print 'C'
        elif m+f >= 30:
            print 'D'
        else:
            print 'F'



Measured memory_bytes: 4648
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int INF=0x3f3f3f3f;
const int N=12,M=1e3;
int f[M+4][(1<<N)+4];
int v[M+4],st[M+4];
int n,m;
inline void smin(int &x,int y) {
	x=min(x,y);
}
int main() {
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;++i) {
		int num;
		scanf("%d%d",&v[i],&num);
		while (num--) {
			int x;
			scanf("%d",&x);
			st[i]|=(1<<(x-1));
		}
	}
	memset(f,INF,sizeof(f));
	f[0][0]=0;
	for (int i=1;i<=m;++i)
		for (int j=0;j<(1<<n);++j) {
			smin(f[i][j|st[i]],f[i-1][j]+v[i]);
			smin(f[i][j],f[i-1][j]);
		}
	if (f[m][(1<<n)-1]^INF) printf("%d\n",f[m][(1<<n)-1]);
	else puts("-1");
	return 0;
}

Measured memory_bytes: 16384
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

int main()
{
  int N, K;
  cin >> N >> K;
  int cnt = 0;
  while (N != 0)
  {
    N /= K;
    cnt += 1;
  }
  cout << cnt << endl;
}


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

int main(){
 int W,H,x,y,r;
 cin >> W >> H >> x >> y >> r;
 if(((x+r) <= W) && ((y+r) <= H) && ((x-r) >= 0) && ((y-r) >= 0)){
   cout << "Yes" <<endl;
 }
 else{
   cout << "No" << endl;
 }
  return 0;
}



Measured memory_bytes: 3116
n,m = list(map(int,input().split()))
A = [[0 for i in range(m)] for j in range(n)]
for j in range(n):
    A[j] = list(map(int,input().split()))
b = [0 for i in range(m)]
for i in range(m):
    b[i] = int(input())
c = [0 for j in range(n)]
for j in range(n):
    for i in range(m):
        c[j] += A[j][i]*b[i]
    print(c[j])


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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int d , t , s ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>d>>t>>s ;
	if(t*s >= d)
		cout<<"Yes\n" ;
	else
		cout<<"No\n" ;
	return 0 ;
}		

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse4")
#pragma GCC optimize("unroll-loops")
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
using namespace std;
ll fact[200005],A[100005],res[100005];
ll power(ll a,ll b){
	ll x=1,y=a;
	while(b){
		if(b&1)
			x=(x*y)%hell;
		y=(y*y)%hell;
		b>>=1;
	}
	return x;
}
ll C(int n,int r){
	return (fact[n]*power((fact[r]*fact[n-r])%hell,hell-2))%hell;
}
int main()
{
    // std::ios::sync_with_stdio(false);
    // cin.tie(0);
    // cout.tie(0);
	int h,w,a,b,i;
	ll ans=0;
	for(i=fact[0]=1;i<=200000;i++)
		fact[i]=(i*fact[i-1])%hell;
	cin>>h>>w>>a>>b;
	for(i=1;i<=h;i++)
		if(i<=h-a)
			A[i]=C(b+i-1,b);
		else
			A[i]=A[i-1];
	res[h]=A[h];
	if(b+1<w)
		for(i=h-1;i>=1;i--)
			res[i]=(A[i]*C(w-b-2+h-i,h-i))%hell;
	for(i=1;i<=h;i++)
		ans=(ans+res[i])%hell;
	cout<<ans;
    return 0;
}

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

int main() {
 	long long int A, B, N;
  	cin >> A >> B >> N;
  
  	long long int res = (N / B) * B - 1;
  
  	if((A * res) / B - (res / B) * A >= (A * N) / B - (N / B) * A) cout << (A * res) / B - (res / B) * A << endl;
  	else cout << (A * N) / B - (N / B) * A << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h> 
#define rr(i,n)  for(int i=0; i<n; i++)
#define ol(a) cout << a << endl;
using namespace std;

int main(){
  int64_t n;  cin >> n;
  //string s; cin >> s;
  int a = n%10;
  if(a==0|a==1|a==6|a==8){
    ol("pon");
  }
  else if(a==3){
    ol("bon");
  }
  else{
    ol("hon");
  }
    
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define REPR(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) \
  for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define FORR(i, a, b) \
  for (int i = static_cast<int>(b) - 1; i >= static_cast<int>(a); --i)
#define ALL(f, x, ...) \
  ([&](auto& y) { return (f)(begin(y), end(y), ##__VA_ARGS__); })(x)
auto INDEX = [](auto& x, auto& xs) { return &x - &xs[0]; };
void async_io() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
const auto inf = INT_MAX / 3;
const auto pi = 2 * std::acos(0.0);
const auto eps = 1e-14;
using ll = signed long long;
using ull = unsigned long long;

signed main() {
  async_io();
  int n;
  while (true) {
    cin >> n;
    if (n == 0) return 0;
    auto sum = 0;
    for (int i = 2;; i++) {
      auto base = i * (i + 1) / 2;
      if (base > n) break;
      if ((base - n) % i == 0) sum++;
    }
    cout << sum << "\n";
  }
}

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

#define LLINF (1LL<<60)
typedef long long ll;

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

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

//C++14 (GCC 5.4.1)
int main() {
    ll N,M;
    cin >>N>>M;

    //-----------------------------------
    ll ans;
    if(N==1 && M==1){
        ans=1;
    }else if(N==1){
        if(M<=2) ans=0;
        else ans=M-2;
    }else if(M==1){
        if(N<=2) ans=0;
        else ans=N-2;

    }else if((N==2 && M==2)||(N==3 && M==2)|| (N==2 && M==3) ){
        ans=0;
    }else{
        ans=(N-2)*(M-2);
    }

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

Measured memory_bytes: 256