akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int C = 1000 * 100 + 87;
const ll inf = 9e18;
ll min_weight[C];
int main()
{
    fill_n(min_weight, C, inf);
    min_weight[0] = 0;
    int N, W;
    cin >> N >> W;
    int sv = 0;
    for (int i = 0; i < N; ++i) {
        int w, v;
        cin >> w >> v;
        sv += v;
        for (int j = sv; j >= v; --j)
            min_weight[j] = min(min_weight[j], min_weight[j - v] + w);
    }
    for (int j = C - 1; j >= 0; --j)
        if (min_weight[j] <= W) {
            cout << j << endl;
            return 0;
        }
}



Measured memory_bytes: 1024
import java.util.Scanner

object Main {

  def check2(num: Int, input: => Array[Array[Boolean]]): Int = {
    var ans = 0
    for (j <- 0 until input(0).length) {
      ans += {
        var N = 0
        for (i <- 0 until input.length) {
          N += (if (if ((num >> i) % 2 == 1) input(i)(j) else !(input(i)(j))) 0 else 1)
        }
        math.max(N, input.length - N)
      }
    }
    ans
  }

  def make(R: Int, C: Int, sc: => Scanner): Int = {
    val input: Array[Array[Boolean]] = Array.fill(R)(Array.fill(C)(sc.nextInt == 1))
    (0 until 1 << (R - 1)).foldLeft(0)((acc, i) => math.max(acc, check2(i, input)))
  }

  def solve(sc: => Scanner): Unit = {
    val R: Int = sc.nextInt
    val C: Int = sc.nextInt
    if (R != 0 && C != 0) {
      println(make(R, C, sc))
      solve(sc)
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}

Measured memory_bytes: 283096
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	int r, g, b, a;
	scanf("%d %d %d", &r, &g, &b);
	
	a = (g * 10 + b)%4;
	if (a == 0) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 2040
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 2050;

int n, k;
int sum[2][MAXN][MAXN];
int totalBlack = 0;

int getSum(int color, int i, int j, int ii, int jj) {
  if (i > ii) {
    return getSum(color, 0, j, ii, jj) + getSum(color, i, j, 2 * k - 1, jj);
  }
  if (j > jj) {
    return getSum(color, i, 0, ii, jj) + getSum(color, i, j, ii, 2 * k - 1);
  }
  int result = sum[color][ii][jj];
  if (i > 0) {
    result -= sum[color][i - 1][jj];
  }
  if (j > 0) {
    result -= sum[color][ii][j - 1];
  }
  if (i > 0 && j > 0) {
    result += sum[color][i - 1][j - 1];
  }
  return result;
}

int main() { 

  scanf("%d %d\n", &n, &k);
  for (int i = 0; i < n; i++) {
    int x, y;
    char c;
    scanf("%d %d %c\n", &x, &y, &c);
    x %= (2 * k);
    y %= (2 * k);
    if (c == 'W') {
      sum[0][x][y]++;
    } else {
      sum[1][x][y]++;
      totalBlack++;
    }
  }

  for (int color = 0; color < 2; color++) {
    for (int i = 0; i < 2 * k; i++) {
      for (int j = 0; j < 2 * k; j++) {
        if (i > 0) {
          sum[color][i][j] += sum[color][i - 1][j];
        } 
        if (j > 0) {
          sum[color][i][j] += sum[color][i][j - 1];
        }
        if (i > 0 && j > 0) {
          sum[color][i][j] -= sum[color][i - 1][j - 1];
        }
      }
    }  
  }

  int x1 = 0, x2 = k - 1;
  int y1 = 0, y2 = k - 1;
  int x3 = k, x4 = 2 * k - 1;
  int y3 = k, y4 = 2 * k - 1;

  int ans = 0;

  for (int i = 0; i < 2 * k; i++) {
    for (int j = 0; j < 2 * k; j++) {
      int cur = getSum(0, x1, y1, x2, y2) + getSum(0, x3, y3, x4, y4);
      cur += totalBlack - (getSum(1, x1, y1, x2, y2) + getSum(1, x3, y3, x4, y4));
      ans = max(ans, cur);
      y1 = (y1 + 1) % (2 * k); 
      y2 = (y2 + 1) % (2 * k); 
      y3 = (y3 + 1) % (2 * k); 
      y4 = (y4 + 1) % (2 * k);
    }
    x1 = (x1 + 1) % (2 * k); 
    x2 = (x2 + 1) % (2 * k); 
    x3 = (x3 + 1) % (2 * k); 
    x4 = (x4 + 1) % (2 * k);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 33024
#include<iostream>
using namespace std;
int main()
{ 
  int count5 = 2;
  int count7 = 1;
  
  for(int i=0; i<3; i++){
  	int N;
    cin >> N;
  	if(N == 5){
      count5--;
    }else if(N == 7){
      count7--;
    }
  }
  
  if(count5 == 0 && count7 == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
    ll n;
    cin>>n;
    vec(a,n);
    a=getv<ll>(n);
    int cnt=0;
    int Cnt=0;
    vec(C,9);
    rep(i,n){
        rep(j,9){
            if(j==8){
                Cnt++;
                break;
            }
            if(a[i]<400*(j+1)){
                if(!C[j]){
                    C[j]++;
                    cnt++;
                }
                break;
            }
        }
    }
    cout<<(cnt?cnt:1)<<" "<<cnt+Cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
a = input("")

b= list(a)
m = " ";
b.append(m)
c = [];
k = "";
h = "";
for j in range(len(b)):
     if b[j] != " ":
         h = h + b[j]
     else:
         c.append(h)
         h = ""

d = 0;
if int(c[2])-1>int(c[0])+int(c[1]):
    d = int(c[0])+int(c[1])+int(c[1])+1
else:
    d = int(c[1])+int(c[2])
print(d)
    

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;
int main(){
    string s,s1;
    int size;
    bool flag = 1;
    //s = "erasedremereraseraser";
    cin >> s;
    while(s.size()>0 && flag){
        size = s.size();
        if(0 < size && size < 7){
            if(s == "dream"|| s == "erase" || s == "eraser")break;
            flag = 0;
            break;
        }

        s1 = s.substr(size-7,7);
        if(s1 == "dreamer" )s.erase(size-7,7);
        else if(s1.substr(1,6) == "eraser")s.erase(size-6,6);
        else if(s1.substr(2,5) == "dream" || s1.substr(2,5) == "erase")s.erase(size-5,5);
        else flag = 0;
    }
    if(flag)cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <map>
using namespace std;

int main()
{
 int a,b;

 cin >> a >> b;

int ans;
 if( a * b == 2) ans = 3;
 if( a * b == 3) ans = 2;
 if(a * b == 6) ans = 1;


 printf("%d",ans);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  mint ans = 0;
  combination comb(200100);
  rep(i, k + 1) {
    mint nv = m - 1;
    nv = nv.pow(n - i - 1);
    nv *= m;
    ans += nv * comb(n - 1, i);
  }
  cout << ans << endl;
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)

vector<LL>v;
LL n;
LL bs(LL x)
{
    LL l=0,h=n;
    LL mid,ans=-1;
    while(l<=h)
    {
//        cout<<l<<" "<<h<<"....\n";
        mid=(l+h)/2;
        if(v[mid]>=x)
        {
            ans=mid;
            h=mid-1;
        }
        else
            l=mid+1;
    }
    return ans+1;
}



int main()
{
    cin>>n;
    LL a;
    for(LL i=0; i<n; i++)
    {
        cin>>a;
        v.pb(a);

    }
    sort(all(v));
    LL cnt=0;
//    for(LL i=0; i<n; i++)
//        cout<<v[i]<<" ";
//    cout<<endl;
    for(LL i=0; i<n; i++)
    {
        for(LL j=i-1; j>=0; j--)
        {
//            cout<<v[i]<<" "<<v[j]<<" "<<endl;
            LL p=bs(v[i]-v[j]+1);
//            cout<<p<<" ....P\n";
//            cout<<j-p<<endl;

            cnt+=max(0LL,j-p+1);
        }
    }
    cout<<cnt;

}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  VI xs(N);
  map<int,int> ms;
  REP(i,N){
	string s; cin >> s;
	s.erase(begin(s)+1);
	xs[i] = stoi(s);
	ms[xs[i]]++;
  }

  int acc = 0;
  map<int,int> ans;
  for(auto&& m: ms){
	ans[m.FF] = m.SS-1 + acc * 3;
	acc += m.SS;
  }
  
  for(int i=0;i<N;++i)
	cout << ans[xs[i]] << endl;

  return 0;
}

Measured memory_bytes: 3712
#!usr/bin/env python3

def string_two_numbers_spliter():
    a, b = [int(i) for i in input().split()]
    return a, b


def main():
    a, b = string_two_numbers_spliter()

    if a < b:
        print('a < b')
    elif a > b:
        print('a > b')
    else:
        print('a == b')


if __name__ == '__main__':
    main()

Measured memory_bytes: 7656
import math
N = int(input())
flag = 0
while flag == 0:
  lst = []
  for i in range(1, math.ceil(N**0.5)):
    if N%i == 0:
      if i**2 == N:
        lst.append(i)
      else:
        lst.append(i)
        lst.append(N//i)
  if len(lst) == 2:
    flag = 1
  else:
    N += 1
print(N)



Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var N = int.Parse(inputs[0]);
        var M = int.Parse(inputs[1]);
        var X = int.Parse(inputs[2]);
        var Y = int.Parse(inputs[3]);
        var xmax = -999999;
        inputs = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++)
        {
            var x = int.Parse(inputs[i]);
            xmax = Math.Max(x, xmax);
        }

        inputs = Console.ReadLine().Split(' ');
        var ymin = int.MaxValue;
        for (int i = 0; i < M; i++)
        {
            var y = int.Parse(inputs[i]);
            ymin = Math.Min(y, ymin);
        }

        string ans;
        if (xmax < ymin && X < ymin && ymin <= Y)
        {
            ans = "No War";
        }
        else
        {
            ans = "War";
        }

        Console.WriteLine(ans);
    }

}



Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
bool prime[100005];
void sieve()
{
    prime[1]=true;

    int s=sqrt(100004);

    for(int i=2;i<=s;i++)
    {
        if(!prime[i])
        {
            for(int j=i*i;j<100002;j+=i)
            {
                prime[j]=true;
            }
        }
    }
}


int arr[100005],seg_tree[400005];

void build_segment_tree(int pos,int low,int high)
{
    seg_tree[pos]=0;
    if(low==high)
    {
        seg_tree[pos]=(arr[low]%2 && !prime[arr[low]] && !prime[(arr[low]+1)/2])?1:0;
        return;
    }

    int mid=(low+high)/2;
    build_segment_tree(2*pos+1,low,mid);
    build_segment_tree(2*pos+2,mid+1,high);

    seg_tree[pos]=seg_tree[2*pos+1]+seg_tree[2*pos+2];
}


int query(int pos,int qlow,int qhigh,int low,int high)
{
    if(qlow<=low && qhigh>=high)
        return seg_tree[pos];
    else if(qlow>high || qhigh<low)
        return 0;
    int mid=(high+low)/2;
    return query(2*pos+1,qlow,qhigh,low,mid)+query(2*pos+2,qlow,qhigh,mid+1,high);
}
int main()
{
    sieve();
    for(int i=1;i<=100003;i++)
    {
        arr[i]=i;
    }
    int n,l,r;
    cin>>n;
    build_segment_tree(0,0,100002);
    for(int i=1;i<=n;i++)
    {
        cin>>l>>r;
        printf("%d\n",query(0,l,r,0,100002));
    }

}


Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;

int main(){
    int a,b;cin>>a>>b;
    long long m=max(a,b);
    while(1){
        if(m%a==0&&m%b==0){
            cout<<m<<endl;
            break;
        }
        m+=max(a,b);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())

class DisjointSet {
    public:
        vector<int> rank, p;
        
        DisjointSet() {}
        DisjointSet(int size) {
            rank.resize(size, 0);
            p.resize(size, 0);
            for (int i = 0; i < size; i++) makeSet(i);
        }

        void makeSet(int x) {
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x, int y) {
            return findSet(x) == findSet(y);
        }

        void unite(int x, int y) {
            link(findSet(x), findSet(y));
        }

        void link(int x, int y) {
            if (rank[x] > rank[y]) {
                p[y] = x;
            }
            else {
                p[x] = y;
                if (rank[x] == rank[y]) {
                    rank[y]++;
                }
            }
        }

        int findSet(int x) {
            if (x != p[x]) {
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};

int main() {
    int n, a, b, q;
    int t;

    cin >> n >> q;
    DisjointSet ds = DisjointSet(n);

    for (int i = 0; i < q; i++) {
        cin >> t >> a >> b;
        if (t == 0) ds.unite(a, b);
        else if (t == 1) {
            if (ds.same(a, b)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3172
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        b: chars,
    }

    match b[0] {
        'A' => println!("T"),
        'T' => println!("A"),
        'C' => println!("G"),
        'G' => println!("C"),
        _ => return,
    }

}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+5;
typedef long long ll;
int n,rt=1,tot=1,ch[N][2];
bool lev[N];
ll l,sg;
char s[N];
void Insert()
{
    int now=rt;
    for(int i=1;s[i];i++)
    {
        int p=s[i]-'0';
        if(!ch[now][p]) ch[now][p]=++tot;
        now=ch[now][p];
    }
    lev[now]=true;
}
ll getsg(ll x)
{
    if(x==0) return 0;
    ll ans=1;
    while(x%4==0)
    {
        x/=4;ans*=4;
    }
    if(x%4==1||x%4==3) return ans;
    return ans*2;
}
void dfs(int u,int dep)
{
    if(lev[u]) return;
    if(!ch[u][0]||!ch[u][1])
    {
        sg^=getsg(l-dep);
    }
    if(ch[u][0]) dfs(ch[u][0],dep+1);
    if(ch[u][1]) dfs(ch[u][1],dep+1);
}
int main()
{
    scanf("%d%lld",&n,&l);
    while(n--)
    {
        scanf("%s",s+1);
        Insert();
    }
    dfs(rt,0);
    if(sg) printf("Alice\n");
    else printf("Bob\n");
}


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

void solve() 
{
    int x;cin>>x;
    cout<<(x==1?0:1)<<endl;
}

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

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
// #define INF __INT32_MAX__
#define INF 1e9
#define LINF __LONG_LONG_MAX__

int main() {
    int N, K; cin >> N >> K;
    vector<ld> P(N);
    rep(i, N) { cin >> P[i]; }

    vector<ld> sum(N + 1);
    for (int i = 1; i <= N; i++) {
        sum[i] = (1 + P[i - 1]) * P[i - 1] / (2 * P[i - 1]);
    }
    for (int i = 1; i <= N; i++) {
        sum[i + 1] += sum[i];
    }

    ld res = -1;
    for (int i = K; i <= N; i++) {
        res = max(res, sum[i] - sum[i - K]);
    }

    cout << fixed << setprecision(10) << res << endl;
}


Measured memory_bytes: 9668
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string s;cin>>s;
    map<char, bool>m;
    string d = "abcdefghijklmnopqrstuvwxyz";
    for(char c: d)
    {
        m[c]=false;
    }
    
    for(char c: s)
    {
        m[c]=true;
    }
    vector <char > no;
    
    for(auto x: m)
    {
        if(!x.second){no.push_back(x.first);}
    }
    if(no.size()==0){cout << "None";return 0;}
    char min='z';
    for(char c: no)
    {
        min = min > c ? c : min;
    }
    cout << min ; 
    return 0;
}


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

#define int long long

//signed main(signed argc, char* argv[])
signed main()
{
    // N,M
    int N, M;
    cin >> N >> M;
    // k,s
    int k[M];
    int s[M];
    for (int i = 0; i < M; i++) {
        cin >> k[i];
        s[i] = 0;
        for (int j = 0; j < k[i]; j++) {
            int sij;
            cin >> sij;
            s[i] |= (1 << (sij - 1));
        }
    }
    // p
    int p[M];
    for (int i = 0; i < M; i++) {
        cin >> p[i];
    }

    int ans = 0;
    for (int bits = 0; bits < (1 << N); bits++) {
        bool ok = true;
        for (int i = 0; i < M; i++) {
            ok &= (__builtin_popcount(bits & s[i]) % 2 == p[i]);
        }
        ans += ok;
    }
    cout << ans << endl;
}

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

const ll MOD=1000000007;

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear1(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p){
  ll n=solveLinear1(a,p,1);
  n=n%p;
  if(n<0)return n+p;
  return n;
}

ll L[51];
ll a[51];

ll patty(ll x,int n){
  if(x<=0)return 0;
  if(n==0)return 1;
  if(x>=L[n])return a[n];
  ll cnt=patty(x-1,n-1)+patty(x-2-L[n-1],n-1);
  if(x>L[n-1]+1)cnt++;
  return cnt;
}

int main(){
  int i,j,k,cnt=0;
  int n;ll x;
  cin>>n>>x;
  L[0]=1;
  a[0]=1;
  for(i=1;i<=50;i++){
    L[i]=2*L[i-1]+3;
    a[i]=2*a[i-1]+1;
  }
  cout<<patty(x,n)<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		String[] a = new String[n];
		for(int i = 0; i < n; i++)
			a[i] = sc.next();
		String[] b = new String[m];
		for(int i = 0; i < m; i++)
			b[i] = sc.next();
		boolean found = false;
		for(int i = 0; i < n - m + 1 && !found; i++) {
			for(int j = 0; j < n - m + 1 && !found; j++) {
				boolean match = true;
				for(int k = 0; k < m && match; k++) {
					for(int l = 0; l < m && match; l++) {
						if(a[i + k].charAt(j + l) != b[k].charAt(l))
							match = false;
					}
				}
				if(match)
					found = true;
			}
		}
		System.out.println(found ? "Yes" : "No");
	}
}

Measured memory_bytes: 9936
M, D = map(int, input().split())
count = 0
for month in range(1,M+1):
    for day in range(10,D+1):
        d_10, d_1 = map(int, list(str(day)))
        if d_10*d_1 == month and d_1 > 1 and d_10 > 1:
            count += 1

print(count)

Measured memory_bytes: 40560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  double l;
  cin >> l;
  cout << pow(l/3,3) << endl; 
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}
	public static void Ans() {

			var inputArray = retreiveLongArray();
			var inputCount = 3;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			long X = inputArray[1];
			long T = inputArray[2];

			var kaisu = N / X;
			if (N%X !=0) {
				kaisu++;
			}

			//答えの出力
			var ans = kaisu*T;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


Measured memory_bytes: 28236
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stdio.h>
#include <stack>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define TR(i,x) for(__typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))
#define PB push_back
#define MP make_pair

using namespace std;

const double eps = 1e-8;

typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int,int> PII;
typedef long long int64;
typedef long long LL;
typedef unsigned int UI;
typedef long double LD;

int main() {
    int a, b;
    cin >> a >> b;
    if (a == b) {
        cout << a << endl;
        return 0;
    }
    int d = abs(b - a);
    if (d % 2 != 0) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    cout << min(a, b) + d / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
mod = 10**9+7
def main():
    n = int(input())
    a = list(map(int,input().split()))
    ret = [0]*n
    for i in a: ret[i] += 1
    #0,2,2,4,4
    if n%2==1:
        if ret[0] != 1:
            print(0)
            return 0
        for i in range(1,n):
            if i%2==0 and ret[i] != 2 or i%2==1 and ret[i] != 0:
                print(0)
                break
        else:
            print(pow(2,n//2,mod))
    else:
        for i in range(n):
            if i%2==0 and ret[i] != 0 or i%2==1 and ret[i] != 2:
                print(0)
                break
        else:
            print(pow(2,n//2,mod))

main()


Measured memory_bytes: 14008
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include <set>
typedef long long ll;
using namespace std;
ll min(ll a,int b)
{
	if(a>b)
	return b;
	else
	return a;
 } 
int a[1000005],maxx=-1,minn=1e9,mid;
ll sum,sum1,ans=1e12;
int main() {
    int n,k,r;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i+k-1<=n;i++)
	{
    r=i+k-1;
    ans=min(ans,a[r]-a[i]+min(abs(a[i]),abs(a[r])));
	}
	cout<<ans;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = "";

        while (!(line = br.readLine()).equals("0")) {
            int n = Integer.parseInt(line);
            int min = 1001, max = -1, sum = 0;
            for (int i = 0; i < n; i++) {
                int s = Integer.parseInt(br.readLine());
                sum += s;
                if (s < min) {
                    min = s;
                }
                if (s > max) {
                    max = s;
                }
            }
            System.out.println((sum - min - max) / (n - 2));
        }
    }
}

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

typedef long long ll;

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

ll lcm(ll a, ll b) {
    return a * (b / gcd(a, b));
}

int main() {
    int N;
    cin >> N;
    vector<ll> T(N);
    for (int i = 0; i < N; i++) {
        cin >> T[i];
    }
    ll x = T[0];
    for (int i = 1; i < N; i++) {
        x = lcm(T[i], x);
    }
    cout << x << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            if (n == 1)
            {
                Console.WriteLine("Hello World");
                return;
            }
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            Console.WriteLine(a + b);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  int aa = abs(x - a);
  int bb = abs(x - b);
  if(aa < bb) cout << "A" << endl;
  else cout << "B" << endl;
  return 0;
}

Measured memory_bytes: 3644
n, a, b = map(int, input().split())

# print(n, a, b)

ans = 0
for i in range(1, n+1):
  s = str(i)
  t = 0
  for k in range(len(s)):
    t += int(s[k])
  #print(t, i)
  if a <= t and t <= b:
    ans += i
print(ans)

Measured memory_bytes: 40176
program kadai
implicit none
integer  ::  N
real(8)  ::  ans


read(*,*) N

if (mod(N,2)==0) then
    ans=0.5
else
    ans=(real(N,8)+1.0_8)/(2.0_8*real(N,8))
end if

write(*,*) ans
stop
contains
end program kadai


Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
	int n;
	
	while(1){
		
		scanf("%d", &n);
		
		if(n==0)
		break;
		
		int sum=0, k, i;
		
		for(i=0;i<n/4;i++){
			scanf("%d", &k);
			sum+=k;
		}
		
		printf("%d\n", sum);
	}
	return 0;
}

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

int main(){
    string s,t;
    cin>>s>>t;
    vector<int> c1(26,0),c2(26,0);
    rep(i,s.size()){
        c1[s[i]-'a']++;
        c2[t[i]-'a']++;
    }
    sort(c1.begin(),c1.end());
    sort(c2.begin(),c2.end());
    
    if(c1==c2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 776
N=int(input())
A=list(map(int,input().split()))

if N==1:
    print("YES")
    exit()

odd=0
even=0
for item in A:
    if item%2==1:
        odd+=1
    else:
        even+=1

if odd%2==1:
    print("NO")
    exit()
else:
    even+=odd//2
        
print("YES")


Measured memory_bytes: 14108
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

const int MAX_LOOP = 86;
const int MAX_N = 100;
int n;
double x[MAX_N], y[MAX_N], v[MAX_N];

double dist(double x, double y, double x_, double y_){
	return sqrt((x - x_) * (x - x_) + (y - y_) * (y - y_));
}

double h(double px, double py){
	double res = 0;
	for(int i=0 ; i < n ; i++ ){
		double d = dist(px, py, x[i], y[i]);
		double t = d / v[i];
		res = max(res, t);
	}
	return res;
}

double g(double left, double right, double py){
	for(int i=0 ; i < MAX_LOOP ; i++ ){
		double mid1 = (left * 2 + right) / 3;
		double mid2 = (left + right * 2) / 3;
		if( h(mid1, py) < h(mid2, py) ){
			right = mid2;
		}else{
			left = mid1;
		}
	}
	return h((left + right) / 2, py);
}

double f(double left, double right){
	for(int i=0 ; i < MAX_LOOP ; i++ ){
		double mid1 = (left * 2 + right) / 3;
		double mid2 = (left + right * 2) / 3;
		if( g(0, 100, mid1) < g(0, 100, mid2) ){
			right = mid2;
		}else{
			left = mid1;
		}
	}
	return g(0, 100, (left + right) / 2);
}

int main(){
	while( scanf("%d", &n), n ){
		for(int i=0 ; i < n ; i++ ){
			scanf("%lf %lf %lf", &x[i], &y[i], &v[i]);
		}
		double ans = f(0,100);
		printf("%.8f\n", ans);
	}
}

Measured memory_bytes: 1088
N = int(input())
A = []
for _ in range(N):
  A.append(int(input()))
  
cnt = A[0] - 1
cant_use = 1
for a in A[1:]:
  wk = a
  if wk == cant_use+1:
    #cnt += 1
    cant_use += 1
    continue
    
  if wk % (cant_use+1) == 0:
    wk -= cant_use + 2
    cnt += 1
  cnt += wk // (cant_use+1)
print(cnt)

Measured memory_bytes: 13836
n, *x = map(int, input().split())
k = 'ABC'
ans = []
s = [input() for _ in range(n)]
for p in range(n):
    sp = s[p]
    if sp == 'AB':
        i = 0
        j = 1
    elif sp == 'BC':
        i = 1
        j = 2
    else:
        i = 0
        j = 2
    if x[i] == x[j] == 0:
        print('No')
        break
    if x[i] == x[j] and p < n - 1:
        sp1 = s[p + 1]
        if k[i] in sp1:
            x[i] += 1
            x[j] -= 1
            ans.append(k[i])
        else:
            x[i] -= 1
            x[j] += 1
            ans.append(k[j])
    elif x[i] < x[j]:
        x[i] += 1
        x[j] -= 1
        ans.append(k[i])
    else:
        x[i] -= 1
        x[j] += 1
        ans.append(k[j])
else:
    print('Yes')
    print(*ans, sep='\n')


Measured memory_bytes: 18480
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) erase(x.begin(), x.begin+n)
// #define int long long
#define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;

signed main(void) {
  	int N;
  	cin >> N;
  	vector<int> A;
  	vector<int> B(N);
  	vector<int> decided(N);
  	rep(i, N) {
  		int tmp;
  		cin >> tmp;
  		A.pb(tmp);
  	}
  	
  	int sum = 0;
  	for(int i=N; i > 0; i--) {
  		sum = 0;
  		for (int j=1; j<=N/i; j++) {
  			sum+=B[j*i-1];
  		}
  		if (sum%2 != A[i-1]) {
  			B[i-1] = 1;
  			sum++;
  		}
  	}

  	cout << sum << endl;
  	rep(i, N) {
  		if (B[i] == 1) {
  			cout << i+1 << " ";
  		}
  	}

  	cout << endl;
 	
	return 0;
}


Measured memory_bytes: 3316
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

void main(){
  auto nk = readNums!ulong;
  auto a = readNums!ulong;
  a ~= a;

  ulong inv;
  foreach(i; 0 .. nk[0]){
    foreach(j; i+1 .. i+nk[0]){
      if(a[i] > a[j]){
        if(j < nk[0]){
          inv += nk[1] * (nk[1]+1) / 2;
          inv %= 10^^9 + 7;
        } else {
          inv += nk[1] * (nk[1]-1) / 2;
          inv %= 10^^9 + 7;
        }
      }
    }
  }

  writeln(inv);
}


Measured memory_bytes: 380
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define SREP(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;
int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	int a, b, k;
	scanf("%d %d %d", &a, &b, &k);
	SREP(i, a, a+k) {
		if (i > b)break;
		PRINTD(i);
	}
	SREP(i, b-k+1, b+1) {
		if (i <= a + k - 1)continue;
		PRINTD(i);
	}
}

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

int main () {
  int N;
  cin >> N;
  vector <int> h(N);
  for (int i = 0; i < N; i++) cin >> h.at(i);
  int count = 0;
  int ans = 0;
  for (int i = 0; i < N-1; i++) {
    if (h.at(i) >= h.at(i+1)) count ++;
    else count = 0;
    if (ans < count) ans = count;
  }  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int n,y;
    cin >> n >> y;
    y/=1000;
    REP(i, n+1){
        REP(j, n+1){
            REP(k, n+1){
                if(i+j+k>n)break;
                if(i+j+k==n && 10*i+5*j+k == y) {
                    pr(i,j,k);
                    return 0;
                }
            }
            if(i+j>n)break;
        }
    }
    pr(-1,-1,-1);
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}
unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    auto s = readln.chomp();
    size_t i = 0;
    size_t j = s.length - 1;
    long ans;
    while(i < j) {
        if(s[i] == s[j]) {
            ++i;
            --j;
            continue;
        }
        if(s[i] != 'x' && s[j] != 'x') {
            writeln(-1);
            return;
        }
        ++ans;
        if(s[i] == 'x') {
            ++i;
        } else {
            --j;
        }
    }
    writeln(ans);
}



Measured memory_bytes: 2428
#include <stdio.h>
long powmod(long a,long b,long m){
    if(b==0){return 1;}
    long c;
    c = powmod((a*a)%m,b/2,m);
    if(b%2){
        c=(c*a)%m;
    }
    return c;
}
int main(void){
  long n,m,k;
  long i;
  scanf("%ld %ld %ld", &n, &m, &k);
  long mod = 998244353;
  long sum = (m*powmod(m-1,n-1,mod))%mod;
  long c=1;
  for(i=1;i<=k;i++){
    c = (c *(((n-i)*powmod(i,mod-2,mod))%mod))%mod;
    sum = (sum + ((m*c)%mod)*powmod(m-1,n-1-i,mod))%mod;
  }
  printf("%ld",sum);
}


Measured memory_bytes: 1736
#include<iostream>
#include<algorithm>
#include<assert.h>
using namespace std;

long long t[100000000];
int ti=0;

int main(){
	long long x,y,z,k;
	cin>>x>>y>>z>>k;
	long long a[x],b[y],c[z];
	for(long long i=0;i<x;++i)
		cin>>a[i];
	for(long long i=0;i<y;++i)
		cin>>b[i];
	for(long long i=0;i<z;++i)
		cin>>c[i];
	sort(a,a+x,greater<long long>());
	sort(b,b+y,greater<long long>());
	sort(c,c+z,greater<long long>());

	for(long long i=0;i<x;++i)
		for(long long j=0;j<y;++j)
			for(long long l=0;l<z;++l){
				if((i+1)*(j+1)*(l+1)<=k){
					t[ti]=a[i]+b[j]+c[l];
					++ti;
					continue;
				}
				else
				break;
			}
	sort(t,t+ti,greater<long long>());
	for(long long i=0;i<k;++i)
		cout<<t[i]<<endl;
	return 0;
}

Measured memory_bytes: 1152
import random
import time

def search(day, schedule, c, s, satisfy):
    score = 0
    date = [0] * 26
    for d in range(day):
        tmp = 0
        contest = 0
        nmax = -float('inf')
        for i in range(26):
            tmp += c[i] * (d + 1 - date[i])
        for i in range(26):
            tmp2 = s[d][i] - tmp + c[i] * (d + 1 - date[i])
            if nmax < tmp2:
                nmax = tmp2
                contest = i
        
        date[contest] = d + 1
        satisfy.append(tmp - c[contest] * (d + 1 - date[contest]))
        schedule.append(contest)
        score += s[d][contest] - satisfy[d]

    return score
    
# def decrease(day, schedule, c, s, satisfy):
#     ret = 0
#     date = [0] * 26

#     for d in range(day):
#         now = schedule[d] + 1
#         date[now - 1] = d + 1
#         tmp = 0
#         for i in range(26):
#             tmp += c[i] * (d+1 - date[i])
#         ret += tmp
#         satisfy.append(tmp)

#     return ret

def change(_from, _to, schedule, c, s, satisfy):
    ret = 0
    date = [0] * 26

    for d in range(_to):
        if d < _from-1:
            ret += satisfy[d]
            continue

        now = schedule[d] + 1
        date[now - 1] = d + 1
        tmp = 0
        for i in range(26):
            tmp += c[i] * (d+1 - date[i])
        ret += tmp
        satisfy[d] = tmp

    return ret

def Main():
    D = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(D)]
    
    dissatisfy=[]
    schedule = []
    score = 0
    start = time.time()

    #最大値を足すだけ
    # for i in range(D):
    #     schedule.append(np.argmax(s[i]))
    #     score += np.max(s[i])
    ans = search(D, schedule, c, s, dissatisfy)
    for i in range(D):
        score+=s[i][schedule[i]]
    
    while time.time() - start < 1.8:
        contest = random.randint(0, 25)
        day = random.randint(0, D - 1)
        if schedule[day] == contest:
            continue

        save = dissatisfy.copy()
        dec2 = change(day + 1, D, schedule, c, s, dissatisfy)
        score2 = score - s[day][schedule[day]] + s[day][contest]

        if ans < score2 - dec2:
            ans = score2 - dec2
            score = score2
            schedule[day] = contest
        else:
            dissatisfy = save

    for i in range(D):
        print(schedule[i] + 1)

if __name__ == "__main__":
    Main()


Measured memory_bytes: 89752
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main {
static  Scanner sc = new Scanner(System.in);


public static void main(String[] args) {

int min=754;
String[] tr=sc.nextLine().split("");
for(int i=0;i<tr.length-2;i++){
String s=tr[i]+tr[i+1]+tr[i+2];
int te=Integer.parseInt(s);
min=Math.min(min,Math.abs(753-te));
}
System.out.println(min);

}

}




Measured memory_bytes: 21844