akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
//template< typename T >
//T mod_pow(T x, T n, const T &p) {
//  T ret = 1;
//  while(n > 0) {
//    if(n & 1) (ret *= x) %= p;
//    (x *= x) %= p;
//    n >>= 1;
//  }
//  return ret;
//}
/////////////////// 
//

#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
#define mp make_pair
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
//
//
//

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  string s;
  string ss = "CODEFESTIVAL2016";
  cin >> s;
  ll ans=0;
  rep(i,s.length()){
    if(s[i]!=ss[i]){
      ans++;
    }
  }
  pri(ans);
  return 0;
}







Measured memory_bytes: 256
import Data.List
main=do
 getLine
 ab<-sort.map((\[a,b]->(b,a)).map read.words).lines<$>getContents
 putStrLn$if f 0 ab then"Yes"else"No"
f now[]=True
f now((b,a):ab)
 |now+a<=b=f(now+a)ab
 |otherwise=False

Measured memory_bytes: 212448
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    int N,A;
    ll sum[2] = {},cnt[2] = {};
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> A;
        sum[0] += A;
        sum[1] += A;
        bool bit = i&1;
        if(sum[!bit] <= 0){
            cnt[!bit] += llabs(sum[!bit]-1);
            sum[!bit] = 1;
        }
        if(sum[bit] >= 0){
            cnt[bit] += llabs(sum[bit]+1);
            sum[bit] = -1;
        }
    }
    cout << min(cnt[0],cnt[1]) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

const int MAX_N = 100+1;

int main() {
	int N, M, X;
	int i;
	int val[MAX_N] = {0};
	scanf("%d %d %d", &N, &M, &X);
	for (i = 0; i < M; i++) {
		int t;
		scanf("%d", &t);
		val[t] = 1;
	}
	int min = 0;
	for (i = X-1; i >= 0; i--) {
		min += val[i];
	}
	int m = 0;
	for (i = X+1; i <= N; i++) {
		m += val[i];
	}
	min = std::min(min, m);
	printf("%d\n", min);
}


Measured memory_bytes: 128
/*
			███╗   ███╗ █████╗ ███████╗███╗   ███╗ ██████╗ ██╗   ██╗██████╗ ███████╗ █████╗ ███╗   ███╗██████╗ ██╗   ██╗
			████╗ ████║██╔══██╗╚════██║████╗ ████║██╔═══██╗██║   ██║██╔══██╗╚════██║██╔══██╗████╗ ████║██╔══██╗╚██╗ ██╔╝
			██╔████╔██║███████║    ██╔╝██╔████╔██║██║   ██║██║   ██║██║  ██║    ██╔╝███████║██╔████╔██║██║  ██║ ╚████╔╝
			██║╚██╔╝██║██╔══██║   ██╔╝ ██║╚██╔╝██║██║   ██║██║   ██║██║  ██║   ██╔╝ ██╔══██║██║╚██╔╝██║██║  ██║  ╚██╔╝
			██║ ╚═╝ ██║██║  ██║   ██║  ██║ ╚═╝ ██║╚██████╔╝╚██████╔╝██████╔╝██╗██║  ██║  ██║██║ ╚═╝ ██║██████╔╝   ██║
			╚═╝     ╚═╝╚═╝  ╚═╝   ╚═╝  ╚═╝     ╚═╝ ╚═════╝  ╚═════╝ ╚═════╝ ╚═╝╚═╝  ╚═╝  ╚═╝╚═╝     ╚═╝╚═════╝    ╚═╝

			“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent
*/
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define pb push_back
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define sz(v) ((int)((v).size()))
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define Accepted 0
#define watch(x) cout << #x << " = " << x << endl;
#define un_map unordered_map
#define RT(x) return cout << (x), 0;
#define sc(a) scanf("%d", &a)
#define scll(x) scanf("%I64d", &x)
#define scan(s) scanf("%[^\n]%*c", &s)
#define pr(s) printf("%s", s.c_str()); // print string
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double EPS = -1e-2;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const ll mod = 1000000007;
const int Mx = INT_MAX;
const int Mn = INT_MIN;
const ll MX = LLONG_MAX;
const ll MN = LLONG_MIN;
const int N = 1e5 + 1;
void Open()
{
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
int n, k;
int mem[N];
vector<int>v;
int solve(int i) {
	int& ret = mem[i];
	if (~ret)return ret;
	ret = Mx;
	for (int j = 1; j <= k && i + j < n; j++)
		ret = min(ret, solve(i + j) + abs(v[i] - v[i + j]));

	ret = ret == Mx ? 0 : ret;
	return ret;
}
int main()
{
	Ma7moud_7amdy;
	//Open_Sesame;
	clr(mem, -1);
	cin >> n >> k;
	v = vector<int>(n);
	for (int i = 0; i < n; i++)cin >> v[i];
	cout << solve(0);
	return Accepted;
}

Measured memory_bytes: 5760
#!/usr/bin/python
from fractions import Fraction
import sys
if sys.version_info[0]>=3: raw_input=input

def gauss(a):
	if not a or len(a)==0: return None
	n=len(a)
	for i in range(n):
		if a[i][i]==0:
			for j in range(i+1,n):
				if a[j][i]!=0:
					for k in range(i,n+1): a[i][k]+=a[j][k]
					break
			else:
				return None
		for j in range(n):
			if i!=j:
				r = Fraction(a[j][i],a[i][i])
				for k in range(i,n+1): a[j][k] = a[j][k] - a[i][k]*r
	for i in range(n):
		x=Fraction(a[i][i],1)
		for j in range(len(a[i])):
			a[i][j] /= x
	return a

uaz=list(map(int,raw_input().split()))
enemy=[0]+[-x+y for x,y in zip(map(int,raw_input().split()),uaz)]
b0=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]
b1=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]
b2=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]
sol=gauss(list(map(list,zip(b0,b1,b2,enemy,[1,0,0,0]))))
print('MISS' if sol and all(0<=e[-1]<=1 for e in sol) else 'HIT')

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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(0)





void solve() {

	
	int n;
	string s;
	cin >> n;
	cin >> s;
	for(int i = 0; i < s.length(); i++) {
		char ch = s[i] + n;
		if(ch > 'Z') {
			ch = ch - 'Z' + 'A' - 1;
		}
		cout << ch;
	}




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	fix;
	solve();

	return 0;
}

Measured memory_bytes: 3632
module IMap=Map.Make(struct type t=int let compare=compare end);;
Scanf.(Array.(scanf" %d"@@ fun n->
	let m = init n(fun _->scanf" %d"@@fun v->v)
	|> fold_left(fun m v->IMap.add v (1+try IMap.find v m with Not_found -> 0) m) IMap.empty
	in IMap.fold(fun v c r->
		let p,q=(try IMap.find (v-1) m with Not_found->0),(try IMap.find (v+1) m with Not_found->0)
		in max r (p+q+c)) m 0 |> print_int))

Measured memory_bytes: 10496
#include<iostream>
using namespace std;
int main(void){
  int n;
  char t1[50],t2;
  cin>>n;
  if(n%2!=0){
    cout<<"No";
    return 0;
  }
  for(int i=0;i<n/2;++i){
    cin>>t1[i];
  }
  for(int i=0;i<n/2;++i){
    cin>>t2;
    if(t1[i]!=t2){
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define si set <int>

using namespace std;

int main(){speed;
	int n;
	cin >> n;
	vector < pair <int, int> > v;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		v.pb(mp(x , i));
	}
	sort(v.begin(), v.end());
	for(int i = 0; i < n; i++){
		cout << v[i].S + 1  << " ";
	}
	
}

Measured memory_bytes: 1780
#=============================================================================
# パナソニックコンテスト A
#=============================================================================

num=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(num[K-1])


Measured memory_bytes: 2940
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned int  ull;
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define int ll
#define pll pair<ll, ll> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;

ll power(ll x, ll y){  
	if(x == 1 || y == 0)
		return 1;
    ll res = 1;   
    x = x % mod; 
    if (x == 0) 
		return 0;  
    while (y > 0){  
        if (y & 1)  
	        res = (res * x) % mod;  
        y = y >> 1; 
        x = (x * x) % mod;  
    }  
    return res;  
} 
vi pr;
void sieve(int n){ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++){ 
        if (prime[p] == true){ 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 

    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          pr.pb(p); 
} 
signed main(){
	FASTIO
	int n;
	cin >> n;
	if(n == 1){
		cout << 0;
		return 0;
	}
	int ans = power(10LL, n);
	ans = (ans - (2LL * power(9LL, n)) % mod + mod) % mod;
	ans = (ans + power(8LL, n)) % mod;
	cout << ans;
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int main(){

  int w,ryoukin;

  while(1){
    
    cin >>w;

    if(w == -1)break;
    
    ryoukin=1150;
    
    if(w > 30){
      ryoukin+=(w-30)*160;
      w=w-(w-30);
    }
    if(w > 20){
      ryoukin+=(w-20)*140;
      w=w-(w-20);
    }
    if(w > 10){
      ryoukin+=(w-10)*125;
    }
    
    cout <<4280-ryoukin<<endl;

  }
  return 0;
}

Measured memory_bytes: 1164
import sys
import math
x = int(sys.stdin.readline())
divs = 2
answer = 0
if x == 2:
  answer=2

while True:
  if divs >= int(math.sqrt(x)):
    answer = x
    break
  if x % divs == 0:
    x += 1
    divs = 2
  else:
    divs += 1
  
print(answer)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int MOD = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int n;
    cin >> n;
    vector<int> A(n + 2);
    A[0] = A[n + 1] = 0;
    for (int i = 1; i <= n; i++) cin >> A[i];

    int sum = 0;
    for (int i = 0; i < n + 1; i++) {
        sum += abs(A[i] - A[i + 1]);
    }
    for (int i = 1; i <= n; i++) {
        int d1 = abs(A[i - 1] - A[i]);
        int d2 = abs(A[i] - A[i + 1]);
        int d_new = abs(A[i - 1] - A[i + 1]);
        cout << sum - (d1 + d2) + d_new << '\n';
    }
}


Measured memory_bytes: 3720
#include <stdio.h>
int yoko,tate;
int x,y;

main(){
while(1){
	
  scanf("%d%d",&tate,&yoko);
  for(x=1;tate>=x;x++){
   for(y=1;yoko>=y;y++){
    if(x%2==1&&y%2==1){
    printf("#");
    }
    else if(x%2==1&&y%2==0){
     printf(".");
    }
    if(x%2==0&&y%2==1){
     printf(".");
    }
    else if(x%2==0&&y%2==0){
    	printf("#");
    }	
    if(yoko==y){printf("\n");}
   if(yoko==y&&tate==x){printf("\n");}
   }
  }
  if(yoko==0&&tate==0){
  return 0;}
}  
}  
  

Measured memory_bytes: 572
Dice = Struct.new(:top, :south, :east, :west, :north, :bottom) do
  def self.init(labels)
    labels = labels.dup.freeze
    raise ArgumentError, "length of labels should be 6" unless labels.count == 6

    new(*labels)
  end

  def rotate(direction)
    case direction
    when ?N then rotate_northward
    when ?S then rotate_southward
    when ?E then rotate_eastward
    when ?W then rotate_westward
    when ?R then rotate_right
    when ?L then rotate_left
    else raise ArgumentError, "direction should be N, S, E, W, L or R, but #{direction} was given."
    end
  end

  def labels
    [top, south, east, west, north, bottom]
  end

  def rotate_westward
    a,b,c,d,e,f = labels
    self.class.init([c,b,f,a,e,d])
  end

  def rotate_eastward
    c,b,f,a,e,d = labels
    self.class.init([a,b,c,d,e,f])
  end

  def rotate_southward
    a,b,c,d,e,f = labels
    self.class.init([e,a,c,d,f,b])
  end

  def rotate_northward
    e,a,c,d,f,b = labels
    self.class.init([a,b,c,d,e,f])
  end

  def rotate_left
    a,b,c,d,e,f = labels
    self.class.init([a,d,b,e,c,f])
  end

  def rotate_right
    a,d,b,e,c,f = labels
    self.class.init([a,b,c,d,e,f])
  end

  def [](index)
    raise ArgumentError, "index should be in 1 to 6" unless (1..6).include?(index)

    labels[index-1]
  end

  def all_state
    ('WNWNWN'.chars.flat_map{|c|[c,*[?R]*4]}).reduce([self]){|dices, inst|
      dices + [dices[-1].rotate(inst)]
    }
  end
end

labels = gets.split.map(&:to_i)
dice1 = Dice.init(labels)

labels = gets.split.map(&:to_i)
dice2 = Dice.init(labels)

puts dice1.all_state.find{|d|
  d == dice2
} ? 'Yes' : 'No'



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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)((n)-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int n,m;
vvi g;
vi tsort_Kahn(){
    vi indeg(n, 0);
    vi dist(n, -1);
    stack<int> S;
    rep(i,n) for(auto v : g[i]) indeg[v]++;
    rep(i,n) if(indeg[i] == 0) S.push(i), dist[i] = 0;

    vi res;
    while(S.size()>0){
        int v = S.top(); S.pop();
        res.emplace_back(v); for(auto u : g[v]){
            indeg[u]--;
            if(indeg[u] == 0) S.push(u), dist[u] = max(dist[u], dist[v] + 1);
        }
    }
    return dist;
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    cin >> n >> m;
    g = vvi(n+1);
    vi cnt(n+1);
    rep(i,n-1+m){
        int a,b;
        cin >> a >> b;
        g[a].push_back(b);
        cnt[b]++;
    }
    n++;
    REP(i,1,n) if(cnt[i] == 0) g[0].push_back(i);
    auto dist = tsort_Kahn();

    vi par(n, 0);
    REP(v,1,n){
        for(auto u : g[v]){
            if(dist[u] == dist[v] + 1) par[u] = v;
        }
    }
    REP(v,1,n){
        cout << par[v] << endl;
    }
    return 0;
}

Measured memory_bytes: 10416
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		int ans = Integer.MAX_VALUE;
		for (int i = 0; i <= n - m; i++) {
			int r = i + m - 1;
			if (Integer.signum(a[i]) * Integer.signum(a[r]) < 0)
				ans = Math.min(ans, Math.min(-2 * a[i] + a[r], -a[i] + 2 * a[r]));
			else
				ans = Math.min(ans, Math.max(Math.abs(a[i]), Math.abs(a[r])));
		}

		out.println(ans);
	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 998244353
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool prime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

struct CustomCompare
{
    bool operator()(const int& lhs, const int& rhs)
    {
        return lhs < rhs;
    }
};

bool comp(pair<ll, pi>a,pair<ll,pi>b)
{
    if(a.se.fi==b.se.fi)return a.se.se>b.se.se;
    return a.se.fi>b.se.fi;
}

ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}


int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll n,k; cin>>n>>k;
vi arr(n+1);
rep(i,1,n+1)cin>>arr[i];
//vi diff(n+2);
while(k--)
{
    //rep(i,1,n+1)diff[i] = arr[i] - arr[i-1];
    vi diff(n+2);
    rep(i,1,n+1)
    {
        diff[max(1LL,i - arr[i])]++;
        diff[min(n+1,i+arr[i]+1)]--;
    }
    vi temp(n+1);
    rep(i,1,n+1)temp[i] = diff[i]+temp[i-1];
    rep(i,1,n+1)arr[i] = temp[i];
    bool flag = true;
    //rep(i,1,n+1)cout<<arr[i]<<" ";
    rep(i,1,n+1)flag&=(arr[i]==n);
    //cout<<endl;
    if(flag)break;
}
rep(i,1,n+1)cout<<arr[i]<<" ";
return 0;
}
/*
50 25
39 99 70 24 49 13 86 43 88 74 45 92 72 71 90 32 19 76 84 46 63 15 87 1 39 58 17 65 99 43 83 29 64 67 100 14 17 100 81 26 45 40 95 94 86 2 89 57 52 91 45
1221 360 459 651 958 584 345 181 536 116 1310 403 669 1044 1281 711 222 280 1255 257 811 409 698 74 838
*/


Measured memory_bytes: 7952
// ~maqsat~
/*    
**    “Anyone who has never made a mistake has never tried anything new.”
**    © Albert Einstein
*/

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 1e5 + 345;
const ll MOD = 1e9 + 7;
const ll INF = 1e10 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int main() {
    fre("");
    ACCELERATE;
	
	int n;
	cin >> n;
	string s;
	cin >> s;

	for(int i = 0; i < sz(s); i++) {
		if(int(s[i]) + n > 90) cout << char((s[i] + n) - 26);
		else cout << char(s[i] + n);
	}

    return 0;
}
/*
 
*/


Measured memory_bytes: 256
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(long long int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
//#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); vect(A);for(long long i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

//ll z[100004]={0};

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
int main()
{
    /*
   #ifndef ONLINE_JUDGE
       freopen ("input.txt" , "r" , stdin);
		// freopen ("OUTPUT.txt" , "w" , stdout);
	#endif 
    */
    fio;
    ll n,k;
    cin>>n>>k;
    ll r,s,p;
    cin>>r>>s>>p;
    string t;
    cin>>t;
    ll ans=0;
    vector<char> c;
    forin(i,0,n-1)
    {
        if(i>=k)
        {
            if(t[i]=='r')
            {
                if(c[i-k]!='p')
                {
                    ans+=p;
                    c.pb('p');
                }
                else
                {
                    c.pb('0');
                }
                
            }
            if(t[i]=='s')
            {
                if(c[i-k]!='r')
                {
                ans+=r;
                c.pb('r');
                }
                else
                {
                    c.pb('0');
                }
            }
            if(t[i]=='p')
            {
                if(c[i-k]!='s')
                {
                ans+=s;
                c.pb('s');
                }
                else
                {
                    c.pb('0');
                }
            }
        }
        else
        {
            if(t[i]=='r')
            {
                ans+=p;
                c.pb('p');
            }
            if(t[i]=='s')
            {
                ans+=r;
                c.pb('r');
            }
            if(t[i]=='p')
            {
                ans+=s;
                c.pb('s');
            }
        }
        
    }
    cout<<ans<<endl;
}

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

int main(){
  int n,zero=0,one=0;
  cin >> n;

  vector<int> a;
  for(int i=0;i<n;i++){
    int t; cin >> t;
    if(t==0)zero++;
    else if(t==1)one++;
    else a.push_back(t);
  }

  sort(a.begin(),a.end());
  int m = a.size();

  if((zero&1)==0){
    if(m>1 && a[m-2]==2 && a[m-1]==3)swap(a[m-1],a[m-2]);
    for(int i=0;i<m;i++)cout << a[i] << endl;
    while(zero--)cout << 0 << endl;
    while(one--)cout << 1 << endl;
  }else if(one){
    if(m>1 && a[m-2]==2 && a[m-1]==3)swap(a[m-1],a[m-2]);
    for(int i=0;i<m;i++)cout << a[i] << endl;
    for(int i=1;i<zero;i++)cout << 0 << endl;
    cout << 1 << endl; one--;
    cout << 0 << endl;
    while(one--)cout << 1 << endl;    
  }else{
    if(m>2 && a[m-2]==2 && a[m-1]==3)swap(a[m-1],a[m-2]);
    for(int i=1;i<m;i++)cout << a[i] << endl;
    for(int i=1;i<zero;i++)cout << 0 << endl;
    if(m)cout << a[0] << endl;
    cout << 0 << endl;
  }
}

Measured memory_bytes: 1220
#include "bits/stdc++.h"

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;
const long double PI = (acos(-1));
const ull MOD = 1000000007;


struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main(){
    ll N;
    cin >> N;
    ll min_f = 10;
    for(ll A = 1; A <= pow(N, 0.5); A++){
        if(N % A == 0) min_f = min(min_f, (ll)max(to_string(A).size(), to_string(N / A).size()));
    }
    cout << min_f << endl;
}

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

using namespace std;

int main(void)
{   
    int dx[4] = {-1, 0, 1, 0};
    int dy[4] = {0, -1, 0, 1};
    int n;
    while(cin >> n){
        if(!n) break;

        vector<int> x(n, 0);
        vector<int> y(n, 0);
        int xmin = 0;
        int xmax = 0;
        int ymin = 0;
        int ymax = 0;

        for(int i = 1; i < n; i++){
            int ni, di; cin >> ni >> di;
            x[i] = x[ni] + dx[di];
            y[i] = y[ni] + dy[di];

            xmin = min(xmin, x[i]);
            xmax = max(xmax, x[i]);
            ymin = min(ymin, y[i]);
            ymax = max(ymax, y[i]);
        }

        cout << xmax - xmin + 1 << " " << ymax - ymin + 1 << endl;
    }
    return 0;

}    

Measured memory_bytes: 2988
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  string s;
  cin >> s;
  int n = s.size();
  ll ans = 1;
  ans += (ll)n *(n-1) /2;
  map<char,int> mp;
  for(int i=0; i<n; ++i){
    ans -= mp[s[i]];
    ++mp[s[i]];
  }
  cout << ans << endl;
}

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

int main(){
	int n, k = 100000;
	cin >> n;
	for(int i = 0;i<n;i++){
		k *= 1.05;
		if(k%1000>0){
			k = k - (k % 1000) + 1000;
		}
	}
	cout << k << endl;
	return 0;
}

Measured memory_bytes: 2996
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

const int maxn=600+10;
const int maxN=360000+100;
struct node {
	int x,y;
};
int n;
int d[2];
int col[maxN],vis[maxN];
int id[maxn][maxn];
vector<node>s[4];
vector<int>g[maxN];

inline void file() {
	freopen("AGC025D.in","r",stdin);
	freopen("AGC025D.out","w",stdout);
}

inline bool check(int x,int y) {
	if (x<1 || x>n) return 0;
	if (y<1 || y>n) return 0;
	return 1;
}

inline void init(int p) {
	For (i,1,n*n) g[i].clear();
	for (int i=0;i*i<=d[p];++i) {
		int j=sqrt(d[p]-i*i);
		if (i*i+j*j==d[p]) {
			For (x,1,n)
				For (y,1,n) {
					int xx,yy;
					xx=x+i; yy=y+j;
					if (check(xx,yy)) g[id[x][y]].push_back(id[xx][yy]);
					xx=x+i; yy=y-j;
					if (check(xx,yy)) g[id[x][y]].push_back(id[xx][yy]);
					xx=x-i; yy=y+j;
					if (check(xx,yy)) g[id[x][y]].push_back(id[xx][yy]);
					xx=x-i; yy=y-j;
					if (check(xx,yy)) g[id[x][y]].push_back(id[xx][yy]);
				}
		}
	}
}

void dfs(int u,int c,int p) {
	vis[u]=1; col[u]|=c<<p;
	For (i,0,g[u].size()-1) {
		int v=g[u][i];
		if (vis[v]) continue;
		dfs(v,c^1,p);
	}
}

inline void solve(int p) {
	Set(vis,0);
	For (i,1,n)
		For (j,1,n)
			if (!vis[id[i][j]]) dfs(id[i][j],0,p);
}

int main() {
//	file();
	scanf("%d%d%d",&n,&d[0],&d[1]); n*=2;
	int cnt=0;
	For (i,1,n)
		For (j,1,n) id[i][j]=++cnt;
	For (i,0,1) init(i),solve(i);
	For (i,1,n)
		For (j,1,n)
			s[col[id[i][j]]].push_back((node){i,j});
	For (i,0,3)
		if ((int)s[i].size()>=n*n/4) {
			For (j,0,n*n/4-1)
				printf("%d %d\n",s[i][j].x-1,s[i][j].y-1);
			break;
		}
	return 0;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<string> words(N);

	for (int i = 0; i < N; ++i) {
		cin >> words[i];
	}

	map<string,long> counter;
	string tmp_str;
	long long cnt = 0;
	for (int i = 0; i < N; ++i) {
		tmp_str = words[i];
		sort(tmp_str.begin(), tmp_str.end());
		//cnt += counter[tmp_str];
		++counter[tmp_str];
		//cout << tmp_str << ':' << counter[tmp_str] << endl;
	}

	for (auto word : counter) {
		cnt += word.second * (word.second-1) / 2;
		//cout << word.first << ':' << word.second << endl;
	}

	cout << cnt << endl;
	return 0;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N, M;
int A[100100];
pii CB[100100];

signed main() {
    cin >> N >> M;
    rep(i, N)cin >> A[i];
    rep(i, M) {
        int b, c;
        cin >> b >> c;
        CB[i] = pii(c, b);
    }
    sort(A, A + N);
    sort(CB, CB + M, greater<pii>());
    int k = 0;
    rep(i, M) {
        int cnt = 0;
        while (k < N && cnt < CB[i].second && CB[i].first > A[k]) {
            A[k] = CB[i].first;
            ++k;
            cnt++;
        }
    }
    int ans = 0;
    rep(i, N) {
        ans += A[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
# -*- coding: utf-8 -*-


n = int(input())

l = []

w = [input() for i in range(n)]
if len(w) != len(set(w)):
    print('No')
    exit()
else:
    for i in range(len(w) - 1):
        if w[i][-1] != w[i + 1][0]:
            print('No')
            exit()

print('Yes')

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

int main() {
  int A, B, C, x;
  cin >> A >> B >> C >> x;
  
  int ans = 0;
  
  for(int a = 0; a <= A; a++) {
    
    for(int b = 0; b <= B; b++) {
      
      for(int c = 0; c <= C; c++) {

        if(x == 500 * a + 100 * b + 50 * c) ans++;
      }
    }
  }
  cout << ans << endl;
}  

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv){vprint(v)};

class SSTree{
    public:
        ll size;
        vll v;
        vll lv;

        SSTree(ll n){
            this->size = n;
            ll m = 1;
            while(n>m) m *= 2;
            this->v = vll(2*m-1, 0);
            this->lv = vll(2*m-1, 0);
        }

        ll get(ll left, ll right, ll level=0, ll idx=0){
            if(left>right) return 0;
            ll step = (this->v.size()+1) >> (level+1);
            ll lb = (idx-(1<<level)+1) * step;
            ll ub = lb + step - 1;
            if(lb==left && ub==right){
                vll s;
                ll tmp = idx;
                do{ s.push_back(tmp=(tmp-1)/2); } while(tmp>0);
                for(auto it=s.rbegin(); it!=s.rend(); ++it){
                    for(int i=1; i<=2; ++i) v[*it*2+i] = max(v[*it*2+i], lv[*it]);
                    for(int i=1; i<=2; ++i) lv[*it*2+i] = max(lv[*it*2+i], lv[*it]);
                    lv[*it] = 0;
                }
                return v[idx];
            }
            else return max(get(left, min((lb+ub)/2, right), level+1, idx*2+1), get(max((lb+ub)/2+1, left), right, level+1, idx*2+2));
        }

        void update(ll left, ll right, ll e, ll level=0, ll idx=0){
            if(left>right) return;
            ll step = (this->v.size()+1) >> (level+1);
            ll lb = (idx-(1<<level)+1) * step;
            ll ub = lb + step - 1;
            if(lb==left && ub==right){
                this->v[idx] = max(this->v[idx], e);
                this->lv[idx] = max(this->lv[idx], e);
            }
            else{
                this->v[idx] = max(this->v[idx], e);
                ll mid = (lb+ub) / 2;
                update(left, min(mid, right), e, level+1, idx*2+1);
                update(max(mid+1, left), right, e, level+1, idx*2+2);
            }
        }
};

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

    ll N, K;
    cin >> N >> K;
    vll A(N);
    rep(i, N) cin >> A[i];

    SSTree t(300001);
    rep(i, N){
        ll l = max(0ll, A[i]-K);
        ll r = min(300000ll, A[i]+K);
        ll v = t.get(A[i], A[i]);
        t.update(l, r, v+1);
    }
    cout << t.get(0, 300000) << endl;
}


Measured memory_bytes: 21956
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	string S;
	cin>>S;
	
	for(int i=0;i<S.size()-1;i++){
		if(S.substr(i,2)=="AC"){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	
	cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[1]:


n,m = map(int,input().split())
data = [list(map(int, input().split())) for i in range(m)]

def dfs(pos):
  if visit[pos] == 1:
    return
  visit[pos] = 1
  
  for i in range(n):
    if graph[pos][i] == 1:
      dfs(i)

count = 0
for hen in range(m):
  graph = [[0]*n for i in range(n)]
  visit = [0]*n

  for i in range(m):
    pos1 = data[i][0] - 1
    pos2 = data[i][1] - 1
    if i != hen:
      graph[pos1][pos2] = 1
      graph[pos2][pos1] = 1
  dfs(0)
  connected = True
  for i in range(n):
    if visit[i] == 0:
      connected = False
  if not connected:
    count += 1
print(count)


# In[ ]:






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

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

    int cnt = 0;
    for (int i = 1; i <= k; i++) {
        bool f = i % 2;
        for (int j = i + 1; j <= k; j++) {
            if (j % 2 == f) continue;
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
Q = [list(map(int, input().split())) for i in range(M)]


for n in range(1000):
    X = list(map(int, list(str(n))))
    if len(X) != N:
        continue
    for s, c in Q:
        s -= 1

        if X[s] != c:
            break
    else:
        print(n)
        exit()

print(-1)


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

typedef long long int ll;
ll arr[101][100001];
ll dp[101][100001];

ll func(ll i,ll j)
{
	if(i==0)
	{
		if(j>=arr[i][0])
			dp[i][j]=arr[i][1];
		else
			dp[i][j]=0;
		return dp[i][j];
	}
	if(dp[i][j]!=-1)
		return dp[i][j];
	if(j>=arr[i][0])
		dp[i][j] = max(func(i-1,j),arr[i][1]+func(i-1,j-arr[i][0]));
	else
		dp[i][j]=func(i-1,j);
	return dp[i][j];
}

int main()
{
	ios::sync_with_stdio(0);
	ll n,w,i,j;
	cin >> n >> w;
	for(i=0;i<n;i++)
	{
		for(j=0;j<=w;j++)
			dp[i][j]=-1;
	}
	for(i=0;i<n;i++)
		cin >> arr[i][0] >> arr[i][1];
	ll ans = func(n-1,w);
	cout << ans << "\n";
	return 0;
}	

Measured memory_bytes: 157952
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> a(n);
  vector<ll> score(n, 1);
  rep(i, n) cin >> a[i];

  for (int i = k; i < n; i++) {
    cout << (a[i] > a[i - k] ? "Yes" : "No") << endl;
  }
  return 0;
}


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

int n;
int minusc = 0; 
ll ans = 0;

int main(){
  cin >> n;
  vector<ll> a(n);
  rep(i, n){
    cin >> a.at(i);
    if(a.at(i) < 0){
      minusc++;
      a.at(i) *= (-1);
    }
  }
  sort(a.begin(), a.end());
  rep(i, n) ans += a.at(i);
  if(minusc%2 == 1) ans -= 2*a.at(0);
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <map>
using namespace std;
const int MAX = 2e5 + 20;
typedef long long  ll;
int pic[MAX],n,k;
bool check(int goal)
{
    int tem = k,i;
    for (i  = 1; i <= n;i++)
    {   
        if (pic[i] <= goal)
            continue;
        else
        {
            int ans = 0,logg = pic[i];
            ans = logg / goal;
            if (logg % goal == 0)
                ans--;
            tem -= ans;
            if (tem < 0)
                return false;
        }
    }
    return true;
}
int main()
{
    cin >> n >> k;
    int l = 1, r = 0;
    for (int i = 1; i <= n;i++)
    {
        scanf("%d", &pic[i]);
        r = max(pic[i], r);
    }
    while (l + 2 < r)
    {
        int mid = (l + r) >> 1;
        if (check(mid))
            r = mid;
        else
            l = mid + 1;
    }
    for (int i = l; i <= r;i++)
        if (check(i))
        {
            cout << i << endl;
            break;
        }
    return 0;
}

Measured memory_bytes: 4504
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans1 = a + b;
		int ans2 = a - b;
		int ans3 = a * b;
		int ans = Math.max(ans1, Math.max(ans2,ans3));
		System.out.println(ans);
	}
	
	
	}

Measured memory_bytes: 21716
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// chrono::steady_clock sc;
 //  	auto start = sc.now();
 //  	ifstream cin;
 //  	cin.open("INPUT.txt");

	int N,M,C;
	cin>>N>>M>>C;
	int B[M];
	for (int i = 0; i < M; ++i)
	{
		cin>>B[i];
	}
	int ans=0;
	for (int i = 0; i < N; ++i)
	{
		int x=C;
		for (int i = 0; i < M; ++i)
		{
			int y;
			cin>>y;
			x+=y*B[i];
		}
		if(x>0)
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	
	// cin.close();
	// auto end = sc.now();
 //   	auto time_span = static_cast<chrono::duration<double>>(end - start);
 //   	cout<<"Operation took: "<<time_span.count()<<" seconds";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  map<int,int>data;
  for(int i=0;i<N;i++){
    int tmp;
    cin>>tmp;
    data[tmp]+=1;
  }
  cout<<data.size()<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define MOD 1000000007
#define deb(n) cout<<"[ "#n<<" = "<<n<<" ]"<<endl;
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const long long  MAX = 1 << 18;
int case_no = 1;
#define w(x) int x; cin>>x; while(x--)

int main() {
    FIO
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long ans;
    ans = max(max(a * c, a * d), max(b * c, b * d));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

signed main() {
	int i, o, t, j, l, s, z;
	cin >> i >> o >> t >> j >> l >> s >> z;

	int ret = 0;
	ret += o;

	int oddNum = 0;
	oddNum += i % 2;
	oddNum += j % 2;
	oddNum += l % 2;
	if (oddNum >= 2 && i > 0 && j > 0 && l > 0) {
		i--;
		j--;
		l--;
		ret += 3;
	}

	ret += (i / 2) * 2;
	ret += (j / 2) * 2;
	ret += (l / 2) * 2;

	cout << ret << endl;

    return 0;
}


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

std::string judg(std::vector<int> A){
    for(auto i = 0; i < A.size(); i++){
        if(A.at(i) % 2 == 0){
            if(A.at(i) % 3 != 0 && A.at(i) % 5 != 0){
                return "DENIED";
            }
        }
    }

    return "APPROVED";
}

int main(){
    int N;
    std::cin >> N;
    std::vector<int> A(N);

    for(auto i = 0; i < N; i++){
        std::cin >> A.at(i);
    }

   std::cout << judg(A) << std::endl;

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
//-------------------------------------------------------------------------
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define prv(v) for (auto i : v) { cout << i << " ";}
#define prmat(v) for (auto i : v) { prv(i); cout << "\n";}
#define cout(x) cout << fixed << setprecision(x)
#define read(v) for (int i_ = 0; i_ < v.size(); i_++) { cin >> v[i_];}
#define fast_io ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define all(v) (v.begin()), (v.end())
#define rall(v) (v.rbegin()), (v.rend())
#define pii pair<ll, ll>
//------------------------------------------------------------------------
ll gcd(ll a, ll b){
    while(b){
        a %= b;
        swap(a, b);
    }
    return a;
}
int main(){
    fast_io;
#ifdef LOCALKA
   freopen("in.txt", "r", stdin);
   freopen("out.txt", "w", stdout);
#endif
    ll n, m;
    string s, t;
    cin >> n >> m >> s >> t;
    ll len = (n * m) / gcd(n, m);
    if(len == max(n, m)){
        cout << -1;
        return 0;
    }
    for(int i = 0; i < n; i++){
        ll cur_pos = i * (len / n) + 1;
        ll j = -1;
        if((cur_pos - 1) % (len / m) == 0){
            j = (cur_pos - 1) / (len / m);
        }
        if(j != -1 && s[i] != t[j]){
            cout << -1;
            return 0;
        }
    }
    cout << len;
}


Measured memory_bytes: 640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    boolean isC = false;
    if(!S.substring(0,1).equals("A")){
      System.out.println("WA");
      return;
    }
      char d = S.charAt(1);
    if(Character.isUpperCase(d)){
          System.out.println("WA");
          return;
    }
    for(int i=2;i<S.length()-1;i++){
      char c = S.charAt(i);
      if(Character.isUpperCase(c)){
        if(S.substring(i,i+1).equals("C")&&!isC){
          isC=true;
        }else{
          System.out.println("WA");
          return;
        }
      }
    }
    if(!isC){
      System.out.println("WA");
      return;
    }
    char last = S.charAt(S.length()-1);
    if(Character.isUpperCase(last)){
      System.out.println("WA");
      return;
    }
    System.out.println("AC");
    
          
    
  }
  

  
}

Measured memory_bytes: 22868
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <queue>
#include <stack>
#include <string>
#include <cmath>
#include <bitset>

#define rep(i,a) for(int i = 0;i < (a); i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)
#define repd(i,a,b) for(int i = (a); i >= (b); i--)
#define repit(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())
#define pb push_back
#define mp make_pair
#define INF 1e10
#define EPS 1e-10
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef complex<double> P;
typedef vector<P> G;

double cross(const P& a, const P& b){
  return imag(conj(a)*b);
}

double dot(const P& a, const P& b){
  return real(conj(a)*b);
}

struct L : public vector<P>{
  L(const P &a, const P &b){
    pb(a); pb(b);
  }
};

int ccw(P a, P b, P c){
  b -= a; c -= a;
  if(cross(b, c) > 0) return +1;
  if(cross(b, c) < 0) return -1;
  if(dot(b, c) < 0) return +2;
  if(norm(b) < norm(c)) return +-2;
  return 0;
  
}

bool intersectSS(const L &s, const L &t){
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 && ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}

P crosspointLL(const L &l, const L &m){
  double A = cross(l[1] -l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if(abs(A) < EPS && abs(B) < EPS) return m[0];
  if(abs(A) < EPS) return P(INF,INF);
  return m[0] + B / A * (m[1] - m[0]);
}

int main(){
  int z;
  cin >> z;
  while(z--){
    P a, b;
    cin >> a.real() >> a.imag() >> b.real() >> b.imag();
    L ab(a,b);
    int n;
    cin >> n;
    vector<pair<double,int> > cr;
    while(n--){
      P s, t;
      int o, l;
      cin >> s.real() >> s.imag() >> t.real() >> t.imag();
      cin >> o >> l;
      L st(s,t);
      if(intersectSS(ab,st)){
	P p = crosspointLL(ab,st);
	double d = sqrt((a.real()-p.real())*(a.real()-p.real()) + (a.imag()-p.imag())*(a.imag()-p.imag()));
	if(!o) l = (l)? 0: 1;
	cr.pb(mp(d,l));
      }
    }
    if(cr.size()>0){
      sort(all(cr));
      int l = cr[0].second;
      int ans = 0;
      repi(i,1,cr.size()){
	if(l != cr[i].second){
	  ans++;
	  l = cr[i].second;
	}
      }
      cout << ans << endl;
    }else cout << 0 << endl;
  }
}

Measured memory_bytes: 1260