akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	string s;
	cin >> s;
	int ans = 0;
	rep(i, s.size()/2) {
		if (s[i] != s[s.size()-1-i]) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        if (n == 1) {
            System.out.println(n);
        } else {
            System.out.println((int) Math.pow(n, 3));
        }
        sc.close();
    }
}


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

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

int dp[100];

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


int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int cnt = 0;
  for(int i = a; i <= b; i++){
    if(c % i == 0) cnt ++;
  }
  cout << cnt << endl;
}






Measured memory_bytes: 3116
#include <stdio.h>
int main(){
  int N,i,j,c=0,temp,a[100],min;
  
  scanf("%d",&N);
  
  for(i = 0;i < N; i++) scanf("%d",&a[i]);
  
  for(i = 0; i < N-1; i++){
    min = i;
    for(j = i + 1; j < N; j++){
      if(a[min] > a[j]) min = j;
    }

    if(a[i] > a[min]){
      temp = a[i];
      a[i] = a[min];
      a[min] = temp;
      c++;
    }

  }

  for(i = 0;i < N-1; i++) printf("%d ",a[i]);
  printf("%d",a[N-1]);

  printf("\n%d\n",c);

  return 0;
}

Measured memory_bytes: 600
fun main(args: Array<String>) {

    var (a,b,k) = readLine()!!.split(" ").map { it.toLong() }

    val a1 = a-k
    if(a+b < k) {
        println("0 0")
    }else if(a1 <= 0) {
        val b1 = b+a1
        println("0 $b1")
    }else {
        println("$a1 $b")
    }
}

Measured memory_bytes: 36192
#include<iostream>
#include<cstdio>
#include<string>
#include<ctime>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<stack>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<sstream>
using namespace std;
typedef long long ll;   
typedef unsigned long long ull;
const int MAXN=2000;
inline long long read()//inline 加速读入
{
	long long x=0;char c=getchar();//x代表返回值，c代表读取的字符
	while (c<'0'||c>'9') c=getchar();//读取所有非数部分
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();//如果读取的字符为数，加入返回值
	return x;
}
ll n,k,t,aa[MAXN+10][MAXN+10];
struct hh{
	ll x;
	int y;
}a[MAXN+10];
int cmp(hh a,hh y)
{
	return a.x>y.x;
}
ll run(int l,int r){
	if(l>r)return 0;
	if(aa[l][r])return aa[l][r];
	int i=n-(r-l);
	return aa[l][r]=max(run(l,r-1)+a[i].x*(r-a[i].y),run(l+1,r)+a[i].x*(a[i].y-l)) ; 
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		a[i].x=read();a[i].y=i;
	}
	sort(a+1,a+n+1,cmp);
	run(1,n);
	cout<<aa[1][n]<<endl;
} 


Measured memory_bytes: 26392
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <queue>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,n,s) for(int i=(int)(s);i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int dir[] = {1, 0, -1, 0, 1};
int main() {
    int h,w;cin>>h>>w;
    int white = 0;
    string s[h];
    REP(i,h) {
        cin>>s[i];
        white += (int)count(ALL(s[i]), '.');
    }

    int num[h][w];
    fill(num[0], num[h], -1);
    bool f = false;

    queue< pair<int, int> > q;
    q.push(make_pair(0, 0));
    num[0][0] = 0;
    while(!q.empty()) {
        int y = q.front().first, x = q.front().second;
        q.pop();

        REP(j,4) {
            int Y = y + dir[j], X = x + dir[j+1];
            if(Y<0||Y>=h||X<0||X>=w) continue;
            if(num[Y][X] >= 0) continue;
            if(s[Y][X] == '#') continue;

            q.push(make_pair(Y,X));
            num[Y][X] = num[y][x] + 1;
            if(Y == h-1 && X == w-1) {
                f = true;
                break;
            }
        }
        if(f) break;
    }
    if(f) cout << white-num[h-1][w-1]-1 << endl;
    else cout << -1 << endl;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int tv[30][100100] = {0};

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

  int N, C;
  cin >> N >> C;

  int s, t, c;
  for(int i = 0; i < N; i++){
    cin >> s >> t >> c;
    c--;
    for(int j = s; j <= t; j++){
      tv[c][j] = 1;
    }
  }


  vector<int> ans_vec(1e5+10); 
  for(int i = 0; i < 100100; i++){
    for(int j = 0; j < 30; j++){
      ans_vec[i] += tv[j][i];
    }
  }

  int ans = 0;
  for(int i = 0; i < ans_vec.size(); i++){
    chmax(ans, ans_vec[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 12416
#include <iostream>
#include <iomanip>
#include <vector>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    vector<vector<int>> a(2, vector<int>(n, 0));
    repi(i, 2, 0)
    {
        repi(j, n, 0)
        {
            cin >> a[i][j];
        }
    }
    int ans = 0;
    repi(i,n,0){
        int s = 0;
        repi(j,i + 1,0){
            s += a[0][j];
        }
        repi(j,n,i){
            s += a[1][j];
        }
        ans = max(ans,s);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int H, W, i, j;
	
	while(1)
	{
		scanf("%d %d", &H, &W);
		if(H == 0 && W == 0) break;
		for(i = 1; i <= H; i++)
		{
			for(j = 1; j <= W; j++)
			{
				if(i == 1 || i == H)
					putchar('#');
				else if(j == 1 || j == W)
				    putchar('#');
				else 
				    putchar('.');
			}
			putchar('\n');
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 576
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	
	if (a * b % 2 == 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

void solve()
{
    LL N, H;
    cin >> N >> H;
    vector<LL> a(N);
    vector<LL> b(N);
    LL max_a = 0;
    REP0 (i, N)
    {
        cin >> a[i];
        max_a = max(max_a, a[i]);
        cin >> b[i];
    }

    sort(b.begin(), b.end(), [](LL a, LL b) { return a > b; });

    LL ans = 0;
    for (auto b_i : b)
    {
        if (max_a <= b_i and 0 < H)
        {
            H -= b_i;
            ans++;
        }
        else
        {
            break;
        }
    }

    cout << ans + max(0LL, (H + max_a - 1) / max_a) << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


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

int main(void) {
	char a, b;
	cin >> a >> b;

	string str_a = string((int)(b - '0'), a);
	string str_b = string((int)(a - '0'), b);

	string ans = (str_a < str_b) ? str_a : str_b;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define INF (1e9)

int D = 365;
vi c, ans;
vvi s;

void input() {
  cin >> D;
  c = vi(26);
  s = vvi(D, vi(26));
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
}

void simulate(vi a) {
  int sum = 0;
  vi last(26, 0);
  for (int i = 0; i < D; i++) {
    sum += s[i][a[i]];
    last[a[i]] = i + 1;
    for (int j = 0; j < 26; j++) {
      sum -= c[j] * (i - last[j] + 1);
    }
    cout << sum << endl;
  }
  // return (int)1e6 + sum;
  // return max((int)1e6 + sum, 0);
}

int main() {
  input();

  vi t(D);
  for (ll i = 0; i < D; i++) {
    cin >> t[i];
    t[i]--;
  }

  simulate(t);
}


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

using namespace std;
#define PI 3.141592653589793238462643383279502884197169399
int main(){
	double a,b,x;
	cin>>a>>b>>x;
	double V=a*a*b;
	if(x>V*1.0/2){
		double Y=2*x*1.0/(a*a)-b;
		double ans=atan(a*1.0/(b-Y))/PI*180.0;
		printf("%.10f\n",90.0-ans);		
	}else{
		//cout<<"2"<<endl;
		double Z=2.0*x/(a*b);
		double ans=atan(Z*1.0/(b))/PI*180.0;
		printf("%.10f\n",90.0-ans);		
	}
	return 0;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

int main() {
    ll n;
    cin >> n;

    vector<ll> divisor;

    repll2(i, (ll) sqrt(n)) {
        if (n % i == 0) {
            divisor.push_back(i);
        }
    }

    int Min = INF;

    for (auto d : divisor) {
        string a = to_string(d);
        string b = to_string(n / d);

        int m = max(a.length(), b.length());
        Min = min(Min, m);
    }

    cout << Min << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    static  Scanner sc=new Scanner(System.in);
    public static void main(String[] args) {
        int n=sc.nextInt(),ans=0;
        for(int i=1;i<=n;i++){
            String s=String.valueOf(i);
            if(s.length()%2==1) ans++;
        }
        System.out.println(ans);
    }

}


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

using namespace std;

class Prime {
private:
  vector<long long> divisor;
  
public:
  Prime(long long n) {
    for (long long i = 0; i < n; ++i) divisor.emplace_back(i);
    for (long long i = 2; i <= n / i; ++i) if (divisor[i] == i) {
      for (long long j = i * i; j < n; j += i) divisor[j] = i;
    }
  }
  
  bool isPrime(long long n) {
    if (n <= 1) return false;
    if (n < (long long)divisor.size()) return divisor[n] == n;
    for (long long i = 2; i <= n / i; ++i) if (n % i == 0) return false;
    return true;
  }
  
  vector<long long> factor(long long n) {
    vector<long long> res;
    for (long long i = 2; i <= n / i && n >= (long long) divisor.size(); ++i) {
      while (n % i == 0) {
        res.emplace_back(i);
        n /= i;
      }
    }
    if (n >= (long long)divisor.size()) {
      res.emplace_back(n);
    } else {
      while (n > 1) {
        res.emplace_back(divisor[n]);
        n /= divisor[n];
      }
    }
    sort(res.begin(), res.end());
    return res;
  }
  
  vector<long long> divisors(long long n) {
    vector<long long> res;
    for (long long i = 2; i <= n / i && n >= (long long) divisor.size(); ++i) {
      if (n % i) continue;
      res.emplace_back(i);
      while (n % i == 0) n /= i;
    }
    if (n >= (long long)divisor.size()) {
      res.emplace_back(n);
    } else {
      while (n > 1) {
        long long d = divisor[n];
        res.emplace_back(d);
        while (n % d == 0) n /= d;
      }
    }
    sort(res.begin(), res.end());
    return res;
  }
};

int main() {
  Prime prime(1000000);
  array<int, 1000000> sum;
  sum[0] = 0;
  for (int i = 1; i < 1000000; ++i) sum[i] = sum[i - 1] + prime.isPrime(i);
  int n;
  while (cin >> n) cout << sum[n] << endl;
}

Measured memory_bytes: 13184
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,X,Y,xm,ym,x;cin>>N>>M>>X>>Y;
  xm=X,ym=Y;
  for(int i=0;i<N;i++){
    cin>>x;xm=max(x,xm);
  }
  for(int i=0;i<M;i++){
    cin>>x;ym=min(x,ym);
  }
  if(xm<ym)cout<<"No ";
  cout<<"War"<<endl;
}

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

const int mxN = 100;
int main()
{
	int n, sum = 0, a[mxN];
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	int ans = 0;
	int k = round((float)sum / n);
	for (int i = 0; i < n; i++)
	{
		ans += pow(a[i] - k, 2); 
	}
	
	cout << ans;
	return 0;
}


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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

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

    int n, m, x;
    cin >> n >> m >> x;
    vll c(n);
    vector<vll> a(n, vll(m, 0));
    rep(i, n) {
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }

    ll ans = mod;
    for (int bit = 0; bit < (1 << n); bit++) {
        vi select;
        rep(i, n) {
            if (bit & (1 << i)) {
                select.emplace_back(i);
            }
        }

        ll t = 0LL;
        vll cnt(m, 0);
        rep(i, select.size()) {
            rep(j, m) {
                cnt[j] += a[select[i]][j];
            }
            t += c[select[i]];
        }

        bool b = true;
        rep(j, m){
            if(cnt[j]<x){
                b = false;
                break;
            }
        }

        if(b){
            ans = min(t, ans);
        }
    }

    if(ans==mod){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
using namespace std;
int main(){
 int b[5][4];
 int sx,sy;
 int x,y;
 string line;
 while(true){
 for(int i=0;i<20;i++)b[i%5][i/5] = 0;
 sx=sy=-1;
 for(y=0;y<8;y++){
 if (!(cin>>line))break;
 for(x=0;x<8;x++){
 if (line[x]=='1'){
 if (sy==-1){sx=x-1;sy=y;}
 b[x-sx][y-sy] = 1;
 }
 }
 }
 if (y<8)break;
 if(b[2][0]&&b[1][1]&&b[2][1])cout<<"A"<<endl;
 if(b[1][3])cout<<"B"<<endl;
 if(b[4][0])cout<<"C"<<endl;
 if(b[0][2])cout<<"D"<<endl;
 if(b[3][1])cout<<"E"<<endl;
 if(b[2][2])cout<<"F"<<endl;
 if(b[0][1]&&b[2][0])cout<<"G"<<endl;
 }}

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

int main(){
    long long a,b,x;

    scanf("%lld",&x);
    for(a=1;;a++){
        bool flag=false;
        long long temp=a*a*a*a*a-x;
        for(b=0;;b++){
            if(b*b*b*b*b==temp){
                printf("%lld %lld",a,b);
                flag=true;
                break;
            }else if(-b*b*b*b*b==temp){
                printf("%lld %lld",a,-b);
                flag=true;
                break;
            }
            if(temp<0&&-b*b*b*b*b<temp){
                break;
            }
            if(temp>0&&b*b*b*b*b>temp){
                break;
            }
        }
        if(flag){
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3816
/* C++14(GCC5.4.1) */
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int main(void){
    // 入力
    int n; 
    cin >> n;
    ll A[n];
    for(int i=0; i<n; i++){
        cin >> A[i];
    }

    // 各山に降った雨量(の半分)を格納
    ll rain_a_mount[n]={0};

    // 山0に降った雨の量(の半分)が求まる
    for(int i=0; i<n; i++){
        if(i%2 == 0) rain_a_mount[0]+=A[i];
        else rain_a_mount[0]-=A[i];
    }
    rain_a_mount[0] /= 2;

    // 全ての山の雨量(の半分)を求める
    // 前の計算結果使ってるので一種のdpみたいな感じ
    for(int i=1; i<n; i++){
        rain_a_mount[i] = A[i-1] - rain_a_mount[i-1];
    }

    // 出力
    for(int i=0; i<n; i++){
        cout << 2*rain_a_mount[i] << " ";
    }

    return 0;
}

Measured memory_bytes: 2816
#include<stdio.h>
int main()
{
    int a[3],i,j;
    for(i=0;i<3;i++) scanf("%d",&a[i]);
    for(i=0;i<3;i++)
        for(j=i;j<3;j++)
    {
        if(a[i]<a[j])
        {
            int temp=a[i];
            a[i]=a[j];
            a[j]=temp;
        }
    }
    // printf("%d %d %d",a[0],a[1],a[2]);
    int res=(a[0]-a[2]);
    printf("%d\n",res);
}


Measured memory_bytes: 128
// Try AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(), &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let mut lists = vec![];
    for _ in 0 .. n {
        let mut list = vec![];
        for _ in 0 .. n-1 {
            list.push(get!(usize) - 1);
        }
        list.reverse();
        lists.push(list);
    }
    let mut ds = vec![0; n];
    let mut ps = vec![0; n];
    let mut d = 1;
    let mut tmp = vec![];
    for i in 0 .. n {
        tmp.push(i);
    }
    while tmp.len() > 0 {
        let mut played = false;
        let mut tmp2 = vec![];
        for &i in tmp.iter() {
            if ds[i] == d || ps[i] == n - 1 {
                continue;
            }
            let x = lists[i][ps[i]];
            if ds[x] >= d {
                continue;
            }
            if lists[x][ps[x]] == i {
                played = true;
                ps[i] += 1;
                ps[x] += 1;
                ds[i] = d;
                ds[x] = d;
                if ps[i] < n - 1 {
                    tmp2.push(i);
                }
                if ps[x] < n - 1 {
                    tmp2.push(x);
                }
            }
        }
        d += 1;
        tmp = tmp2;
        if !played {
            break;
        }
    }
    let mut ans = 0;
    for i in 0 .. n {
        if ps[i] != n - 1 {
            ans = -1;
            break;
        }
        ans = std::cmp::max(ans, ds[i]);
    }
    println!("{}", ans);
}

Measured memory_bytes: 16504
#include <iostream>

using namespace std;

int main()
{
    int N,num,cntP=0,cntW=0,cntG=0,cntY=0;
    cin >> num;
    char color[num];

    for(int i=0;i<num;i++){
        cin >> color[i];
        /*
        if(color[i]=='P'){
            cntP++;
        }else if(color[i] =='W'){
            cntW++;
        }else if(color[i]== 'G'){
            cntG++;
        }else if(color[i]== 'Y'){
            cntY++;
        }
        */
        if(color[i]=='Y')cntY++;
    }
    if(cntY==0){
        cout << "Three\n";
    } else {
        cout << "Four\n";
    }
    
}

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

main(){
	int x=0;
	int a=0;
	int n;
	string s;
	cin >> n;
	cin >> s;
	for(int i=0;i<n;i++){
		if(s[i]=='I'){
			a++;
			if(a>x){
				x=a;
			}
		}else{
			a--;
		}
	}
	cout << x <<endl;


}



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

int main() {
	int n; cin >> n;
	vector<int>a(n); for (auto&& x : a)cin >> x;

	int ans = 0, now = 0;
	while (true) {
		if (ans >= n) {
			cout << -1 << endl;
			return 0;
		}
		if (now == 1) {
			cout << ans << endl;
			return 0;
		}
		now = a[now]-1;
		ans++;
	}

	return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	int n, k;
	cin >> n >> k;
	const int ans = n - k + 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    sys.setrecursionlimit(10 ** 6)
    input = sys.stdin.readline
    K = int(input())
    A, B = [int(x) for x in input().strip().split()]
    for i in range(A, B+1):
        if i % K == 0:
            print('OK')
            exit()
    print('NG')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9188
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

N,X=map(int,input().split())
x=list(map(int,input().split()))
D=abs(x[0]-X)
for i in range(N):
  D=gcd(D,abs(X-x[i]))
print(D)

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

int main() {
  int year, month, day;
  char c1, c2;
  cin >> year >> c1 >> month >> c2 >> day;
  
  if (month <= 4) cout << "Heisei" << endl;
  else cout << "TBD" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

int main() {
  ll x;
  while (cin >> x) {
    if (x % 11 == 0) cout << 2 * (x / 11) << endl;
    else if (x % 11 <= 6) cout << 2 * (x / 11) + 1 << endl;
    else cout << 2 * (x / 11) + 2 << endl;
  }
}


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

using namespace std;

typedef long long ll;
const int MAXN = 1e5 * 2 + 1;
int n;
ll arr[MAXN],tmp[MAXN];

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

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		tmp[i] = arr[i] - (i + 1);
	}

	sort(tmp, tmp + n);

	int div = n / 2;

	ll sum = 0;

	for (int i = 0; i < n; i++) {
		sum += abs(arr[i] - (tmp[div] + (i + 1)));
	}

	cout << sum << "\n";

	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
    int N;
    int number = 0;
    ll x;

    cin >> N >> x;
    vector<ll> a(N);

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

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

    for (int i = 0; i < N; i++) {
        x -= a[i];
        if (x < 0) break;
        number++;
    }

    if (x > 0) number--;

    cout << number << endl;

    return 0;
}

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

int main() {
    int n;
    cin>>n;
    vector<double>p(n);
    for(int i=0;i<n;i++ )cin>>p[i];
    std::vector<vector<double> >v(n,vector<double>(2*n+1,0)) ;
    v[0][n-1]=1-p[0];
    v[0][n+1]=p[0];
    for(int i=1;i<n;i++){
        for(int j=0;j<2*n+1;j++){
            if(j<2*n)v[i][j+1]=v[i][j+1]+v[i-1][j]*p[i];
            if(j>0)v[i][j-1]=v[i][j-1]+v[i-1][j]*(1-p[i]);
        }
    }
    double sum=0.;
    for(int i=n+1;i<=2*n;i++)sum+=v[n-1][i];
    cout<<setprecision(9)<<sum;
}

Measured memory_bytes: 140928
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, m;
    cin >> n >> m;    
    
    vvl G(n);
    vl indeg(n);  // indeg[v] : 頂点vの入次数
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
        indeg[b]++;
    }
    
    // 入次数0の頂点をqueueに入れる
    queue<ll> Q;
    rep(v, n) {
        if(indeg[v] == 0) {
            Q.push(v);
        }
    }
    
    vl dp(n);
    while(!Q.empty()) {
        ll v = Q.front();
        Q.pop();
        for(auto u : G[v]) {
            indeg[u]--;
            if(indeg[u] == 0) {
                chmax(dp[u], dp[v] + 1);
                Q.push(u);
            }
        }
    }
    
    ll longestPathLen = 0;
    rep(v, n) {
        chmax(longestPathLen, dp[v]);
    }

    out(longestPathLen);
    re0;
}

Measured memory_bytes: 7296
#include<stdio.h>
#include<math.h>
#include<stdlib.h>


int main(){
    int k, a, b, cont=0;
    scanf("%d", &k);
    scanf("%d %d", &a, &b);
    for(int i=a; i<b+1; ++i){
        if(i%k==0)
            cont=1;
    }
    if(cont ==1)
        printf("OK\n");
    else
        printf("NG\n");
    return 0;
}


Measured memory_bytes: 1616
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b ,c int
	fmt.Scanf("%d %d %d", &a, &b, &c)
	d := float64(a + b)
	e := float64(a + c)
	f := float64(c + b)
	fmt.Println(math.Min(d, math.Min(e, f)))
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		int a, b, c;
		
		Scanner scan = new Scanner(System.in);
		
		a = scan.nextInt();
		b = scan.nextInt();
		c = scan.nextInt();
		
		if (a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 26352
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <functional>
#include <tuple>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(std::min<int>(l_, r_)), r(r_) {}
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): r(std::max<int>(l_, r_) - 1), l(l_ - 1) {}
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
inline T scan() {
  T res;
  std::cin >> res;
  return res;
}

using lint = long long;
constexpr lint inf = (1ll << 60);

int main() {
  lint N, K;
  std::cin >> N >> K;
  lint zero = 0;
  std::vector<lint> pos, neg;
  std::vector<lint> A(N); 
  for (lint &x: A) {
    std::cin >> x;
    if (x == 0) {
      ++zero;
    }
    else if (x > 0) {
      pos.push_back(x);
    }
    else {
      neg.push_back(-x);
    }
  }
  std::sort(pos.begin(), pos.end());
  std::sort(neg.begin(), neg.end());
  lint ok = inf, ng = -inf;
  while (ok - ng > 1) {
    lint md = (ok + ng) / 2;
    ([&] {
      // md 以下はいくつ ?
      lint cnt = 0;
      if (md < 0) {
        for (lint x: pos) {
          cnt += neg.end() - std::lower_bound(neg.begin(), neg.end(), (-md + x - 1) / x);
        }
      }
      else {
        for (lint x: pos) {
          cnt += std::upper_bound(pos.begin(), pos.end(), md / x) - pos.begin();
          if (x * x <= md) {
            --cnt;
          }
        }
        for (lint x: neg) {
          cnt += std::upper_bound(neg.begin(), neg.end(), md / x) - neg.begin();
          if (x * x <= md) {
            --cnt;
          }
        }
        cnt /= 2;
        cnt += pos.size() * neg.size();
      }
      if (md >= 0) {
        cnt += zero * (zero - 1) / 2;
        cnt += zero * (N - zero);
      }
      // std::cout << md << ' ' << cnt << '\n';
      return cnt >= K;
    }() ? ok : ng) = md;
  }
  std::cout << ok << '\n';
  return 0;
}


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

using namespace std;

typedef long long ll;
 
int main() {
    ll N,Q; cin>>N>>Q;

    map<ll,ll> tree;

    for (ll i=0;i<N-1;i++) {
        ll a,b; cin>>a>>b;
        // a:parent, b:child
        tree.insert(make_pair(b,a));
    }

    vector<ll> X(N+1,0);
    for (ll i=0;i<Q;i++) {
        ll p,x; cin>>p>>x;
        X[p] += x;
    }

    vector<ll> node(N+1,0);
    node[1] = X[1];
    cout << node[1] << " ";
    for (ll i=2;i<=N;i++) {
        node[i] = node[tree[i]] + X[i];
        cout << node[i] << " ";
     }
    cout << endl;
   
    return 0;
}


Measured memory_bytes: 18048
#include <iostream>
#include <map> 
#include <cmath> 
using namespace std;
// typedef pair<int, int> P;
typedef long long ll;

long long *L = new long long[200001];
long long *R = new long long[200001];

int main() {
    int N;
    cin >> N;
    map<long long, long long> mp; 
    for(int i=1;i<N + 1;i++){
        long long a;
        cin >> a;
        L[i] = i + a;
        R[i] = i - a;
    }
    ll cnt = 0;
    for(int i=1;i<N+1;i++){
        auto itr = mp.find(L[i]);
        if( itr != mp.end() ) {
            mp[L[i]] = itr->second + 1;
        }else{
            mp[L[i]] = 1;
        }
        // mp[L[i]]++;
        itr = mp.find(R[i]);
        if( itr != mp.end() ) {
            cnt += itr->second;
        }
        // cnt += mp[R[i]];
    }
    // for(int i=1;i<N+1;i++){
    //     auto itr = mp.find(R[i]);
    //     if( itr != mp.end() ) {
    //         cnt += itr->second;
    //     }
    // }
    
    cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 19208
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	double calc(int deg){
		double rad = Math.toRadians(deg);
		return Math.sin(rad);
	}
	
	void run(){
		for(;;){
			int n  = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			int deg[] = new int[n+1];
			deg[0] = 0;
			deg[n] = 360;
			for(int i = 1; i < n ; i++){
				deg[i] = sc.nextInt();
			}
			double area = 0;
			int degsum = 360;
			for(int i = 0; i < n ;i++){
				area += calc(deg[i]);
				degsum -= deg[i];
			}
			area += calc(degsum);
			
			n = sc.nextInt();
			
			deg = new int[n+1];
			deg[0] = 0;
			deg[n] = 360;
			for(int i = 1; i < n ; i++){
				deg[i] = sc.nextInt();
			}
			double area2 = 0;
			degsum = 360;
			for(int i = 0; i < n ;i++){
				area2 += calc(deg[i]);
				degsum -= deg[i];
			}
			area2 += calc(degsum);
//			System.out.println(area+" "+area2);
			if(Math.abs(area - area2) < 1e-8){
				System.out.println(0);
			}else
			if(area>area2){
				System.out.println(1);
			}else{
				System.out.println(2);
			}
		}
		
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 12000
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE ViewPatterns          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import           Unsafe.Coerce

main :: IO ()
main = do
    !n <- readLn :: IO Int
    print $ 180 * (n - 2)


-------------------------------------------------------------------------------
type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
    (,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt4 :: Parser (Int, Int, Int, Int)
parseInt4 = runStateT $
    (,,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a<(b+c)){
    cout<<min(b,c)<<' '<<(b+c)-a<<endl;
  }
  else{
    cout<<min(b,c)<<' '<<0<<endl;
  }
}

Measured memory_bytes: 256
a,b = map(int,input().split())
list = []
#print(a)
#list = [x if a/0.08 <= x and (a+1)/0.08 >x]
for x in range(1500):
  if a/0.08 <= x < (a+1)/0.08 and b/0.1<= x < (b+1)/0.1:
    list.append(x)
    
if len(list) == 0 :
  print(-1)
  
else:
  print(min(list))

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

const int Nmax=200010;
//#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//#definr REP(i,n) FOR(i,0,n)
//#define dump(x) cout << #x << "=" << (x) << endl;
//#define debug(x) cout << #x << "=" << (x) << "(L" << _LINE_ << ")" << "" << _FILE_ << endl;
//ll a[Nmax];
//int* P = new int[N];

int main() {
	int A,B,X;
	cin >> A >> B >> X;
	if(X-A <= B && A <= X) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}

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

typedef long long ll;
#define rep(i,n) for( ll (i)=0; (i)<(n); ++(i) )
#define rpi(i,n) for( int (i)=0; (i)<(n); ++(i) )
#define rpv(d) for(auto& v:d)
#if __cplusplus < 201703L
  std::ostream& co_(){ return std::cout << std::endl; }
  std::istream& cn_(){ return std::cin; }
  template<class Head, class... Args>
  std::ostream& co_( Head&& head, Args&&... args ){ std::cout << head; return co_(std::forward<Args>(args)...); }
  template<class Head, class... Args>
  std::istream& cn_( Head&& head, Args&&... args ){ std::cin >> head; return cn_(std::forward<Args>(args)...); }
#else
  template<class... Args>
  std::ostream& co_( Args... args ){ return std::cout << ... << args << std::endl; }
  template<class... Args>
  std::istream& cn_( Args... args ){ return std::cin >> ... >> args; }
#endif
#define co(...) co_(__VA_ARGS__);
#define cn(...) cn_(__VA_ARGS__);
#define all(x) (x).begin(), (x).end()
#define rgt(x,i) (x).begin(), (x).begin()+(i)

int main(){
  int a,b,c;cn(a,b,c)
  if (a+b+c<22){
    puts("win");
  }else{
    puts("bust");
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		
		if (a > b) {
			int t = a;
			a = b;
			b = t;
		}
		
		if (b > c) {
			int t = b;
			b = c;
			c = t;
		}

		if (a > b) {
			int t = a;
			a = b;
			b = t;
		}
		
		System.out.println(a + " " + b + " " + c);
	}

}



Measured memory_bytes: 26164
use proconio::{input, fastout};
use std::cmp::min;

#[fastout]
fn main() {
    input! {
        n: usize,
        h: [i32; n],
    }

    let mut dp = vec![-1; n];
    dp[0] = 0;
    dp[1] = (h[1]-h[0]).abs();
    for i in 2..n {
        dp[i] = min(dp[i-1] + (h[i-1] - h[i]).abs(),
                    dp[i-2] + (h[i-2] - h[i]).abs());
    }

    println!("{}", dp[n-1]);
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

using namespace std;
using namespace __gnu_pbds;
#define  st first
#define  nd second



void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

#define maxn  1000001
#define M   1000000007
#define int long long
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef cc_hash_table<int, int, hash<int > > ht;
int cei(int x,int y){
if(x%y==0)
    return x/y;
else
    return (x/y)+1;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    cout<<cei(n,2*k+1);

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    for(int i=0; i*2<s.size(); i++){
        if(s[i] != s[s.size()-1-i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int N = Integer.parseInt(br.readLine());
        int x = 0;
        if (N <= 111) {
            x = 111;
        } else if (N <= 222) {
            x = 222;
        } else if (N <= 333) {
            x = 333;
        } else if (N <= 444) {
            x = 444;
        } else if (N <= 555) {
            x = 555;
        } else if (N <= 666) {
            x = 666;
        } else if (N <= 777) {
            x = 777;
        } else if (N <= 888) {
            x = 888;
        } else {
            x = 999;
        }
        out.println(x);
        out.close();
    }
}

Measured memory_bytes: 22612
import sys
input = sys.stdin.readline

import collections
import random

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

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

def dist(x1,y1,x2,y2):
	return abs(x1-x2)+abs(y1-y2)

def main():
	N = int(input())
	#vS = [input().rstrip() for _ in [0,]*N]
	oA = ord("a")
	vD = [chr(i+oA) for i in range(26)]
	#vD += [".","#"]

	res = ""
	while N:
		#print(N, N%26, (N-1)%26)###
		res += vD[(N-1)%26]
		N -= 1
		N //= 26
	
	print(res[::-1])
	#sT = "No Yes".split()
	#print(sT[res])
	

if __name__ == "__main__":
	main()


Measured memory_bytes: 9820
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int chiten=sc.nextInt();
		int[] zahyo=new int[chiten+2];
		zahyo[0]=0;
		zahyo[chiten+1]=0;
		long souwa=0l;
		for(int i=1; i<=chiten; i++) {
			zahyo[i]=sc.nextInt();
			souwa+=Math.abs(zahyo[i-1]-zahyo[i]);
		}
		souwa+=Math.abs(zahyo[chiten]-zahyo[chiten+1]);
		int diff=0;

		for(int i=1; i<=chiten; i++) {
			diff=Math.abs(zahyo[i-1]-zahyo[i+1])-(Math.abs(zahyo[i-1]-zahyo[i])+Math.abs(zahyo[i]-zahyo[i+1]));//本来の道
			System.out.println(souwa+diff);
		}
	}
}

Measured memory_bytes: 70328
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

#include <bits/stdc++.h>
using namespace std;

signed main(){
    int N,K; cin>>N>>K;
    vec h(N); REP(i,N) cin>>h[i];
    vec DP(110000,INF);
    DP[0]=0;

    FOR(i,0,N){
            FOR(j,1,K+1){
                DP[i+j]=min(DP[i+j],DP[i]+abs(h[i]-h[i+j]));
            }
        }
    Out(DP[N-1]);
}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {
public static void main(String [] args){
		
		Scanner scan = new Scanner(System.in);
		
		int cards[][];
		cards = new int[4][13];
		int i, j, num;
		
		for(i=0; i<4; i++){
			num = 1;
			for(j=0; j<13; j++){
				cards[i][j] = num;
				num++;
			}
		}
		
		int a = scan.nextInt();
		for(i=0; i<a; i++){
			char op = scan.next().charAt(0);
			int c = scan.nextInt();
			
			if(op == 'S'){
				cards[0][c-1] = 0; 
			}
			if(op == 'H'){
				cards[1][c-1] = 0; 
			}
			if(op == 'C'){
				cards[2][c-1] = 0; 
			}
			if(op == 'D'){
				cards[3][c-1] = 0; 
			}
		}
		
		for(i=0; i<4; i++){
			for(j=0; j<13; j++){
				if(cards[i][j] != 0){
					if(i==0){
						System.out.println("S "+cards[i][j]);
					}
					if(i==1){
						System.out.println("H "+cards[i][j]);
					}
					if(i==2){
						System.out.println("C "+cards[i][j]);
					}
					if(i==3){
						System.out.println("D "+cards[i][j]);
					}
					
				}
			}
		}
		
	}
}

Measured memory_bytes: 18060