akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
 
int main ()
{
    int n ;
    scanf("%d", &n);

    vector <int> v ;
    vector <int> v2 ;

    int aux1 , aux2 ;

    for (int i = 0 ; i < n ; i++)
    {
        scanf("%d%d", &aux1 , &aux2);
        v.pb(aux1);
        v2.pb(aux2);
    }

    double c = 0.0 ;
    double r , r2 , r3 ;

    for (int i = 0 ; i < n ; i++)
    {
        for (int j = 0 ; j < n ; j++)
        {
            r = pow((v[i] - v[j]) , 2);
            r2 = pow((v2[i] - v2[j]) , 2);
            r3 = sqrt(r + r2);
            c = c + r3;
        }
    }

    printf("%.10lf", c / n);

    return 0 ;
}

Measured memory_bytes: 256
import heapq

n,m=map(int,input().split())
a=[-int(x) for x in input().split()]
heapq.heapify(a)
for i in range(m):
  t=heapq.heappop(a)
  t=-t//2
  heapq.heappush(a,-t)
print(-sum(a))


Measured memory_bytes: 20364
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;

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


void solve(){
	int[string] x = ["SUN": 7, "MON": 6, 
	"TUE": 5, "WED": 4, "THU": 3, "FRI": 2, "SAT": 1];

	string a = rstring;
	x[a].writeln;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <cstdlib>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include <iomanip>

// #pragma comment(linker, "/STACK:1024000000,1024000000")
// #define pi acos(-1)
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x7f7f7f7f //2139062143
#define INF1 0x3f3f3f3f //1061109567
#define INF2 2147483647
#define llINF 9223372036854775807
#define pi 3.141592653589793//23846264338327950254
#define pb push_back
#define ll long long
#define debug cout << "debug\n";
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
// ios::sync_with_stdio(false);cin.tie(NULL);
#define scai(x) scanf("%d", &x)
#define sca2i(x, y) scanf("%d %d", &x, &y)
#define scaf(x) scanf("%lf", &x)
#define sca2f(x, y) scanf("%lf %lf", &x, &y)
#define For(m,n) for (int i = m;  i < n; i++)

#define local
#ifdef local
#endif

#define MAX 10233
#define LCH(i) ((i) << 1)
#define RCH(i) ((i) << 1 | 1)
const int N = 2e5 + 10;
int H[N];
bool cmp(int a, int b)
{
    return a > b;
}
int main()
{
    int n,K;
    scai(n);
    scai(K);

        for (int i = 0; i < n; i++)
        {
            scai(H[i]);
        }
    if (K >= n) {
            puts("0");

    }
    else {
        sort(H, H + n, cmp);
        ll sum = 0;
        for (int i = K; i < n; i++)
        {
            sum += (ll)(H[i]);
        }
        printf("%lld\n", sum);
    }
    return 0;
}


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

using namespace std;

typedef long long int 	ll;
typedef pair<int,int>   ii;
typedef vector< ii >   vii;
typedef vector<int>     vi;
typedef vector< vi >   vvi;

#define mm 100005
#define nn 1005
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())
#define all(a) a.begin(),a.end()
#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define cases int t;  cin>>t;   while(t--)
#define check(a,n) forn(iiii,int(n)) cout<<ll(a[iiii])<<" "; cout<<endl
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    fast_io;
    int n;
    string a,b;
    cin>>n>>a>>b;
    ll pro=1LL;
    int flag=1;
    forn(i,n)
    {
        if(a[i]==b[i]&&i==0)
        {
            pro*=3LL;
            pro%=mod;
        }
        else if(i==0)
        {
            pro*=6LL;
            pro%=mod;
            i++;
            flag=0;
        }
        else if(a[i]==b[i])
        {
            if(flag==1)
            {
                pro*=2LL;
                pro%=mod;
            }
            flag=1;
        }
        else
        {
            if(flag==0)
            {
                pro*=3LL;
                pro%=mod;
            }
            else
            {
                pro*=2LL;
                pro%=mod;
            }
            flag=0;
            i++;
        }
    }
    cout<<pro;
    return 0;
}


Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

MOD=10**9+7
N=gets.to_i
A=get_i
sum=array(N+1,0)
N.times do|i|
    sum[N-i-1]=sum[N-i]+A[N-1-i]
    sum[N-i-1]%=MOD
end
ans=0
N.times do|i|
  ans+=A[i]*sum[i+1] 
  ans%=MOD
end
puts ans

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

typedef map<string,bool> ID;

int main(){
  ID id;
  bool b = true;
  int n,m;
  
  cin >> n;
  for(int i = 0; i < n; i++){
    string str;
    cin >> str;
    id[str] = true;
  }
  
  cin >> m;
  for(int i = 0; i < m; i++){
    string str;
    cin >> str;
    if(id.count(str)){
      cout << (b ? "Opened by " : "Closed by ") ;
      b = !b;
    }else{
      cout << "Unknown ";
    }
    cout << str << endl;
  }
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
int x[110][2],w[110][2],n;bool cal[110];int COU(int a,int b){while(true){if(a<2||b<2)return 1;if(a<b){int t=a;a=b,b=t;}a%=b;if(!a)return b;}}long long DFS(int q){if(!q)return 1;q--;long long a=DFS(w[q][0]),b=DFS(w[q][1]);return (a*b*(x[q][0]+x[q][1]))/COU(a*x[q][0],b*x[q][1]);}int main(){while(true){cin>>n;if(!n)break;for(int i=0;i<n;i++)cal[i]=false;for(int i=0;i<n;i++){cin>>x[i][0]>>x[i][1]>>w[i][0]>>w[i][1];cal[w[i][0]-1]=true,cal[w[i][1]-1]=true;}for(int i=0;i<n;i++)if(!cal[i])cout<<DFS(i+1)<<endl;}return 0;}

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

int main() {
  int n, m, s = 0;
  cin >> n;
  vector<int> t(n);
  rep(i, n) cin >> t[i];
  cin >> m;
  vector<int> p(m), x(m);
  rep(i, m) cin >> p[i] >> x[i];
  rep(i, n) s += t[i];
  rep(i, m) cout << s - t[p[i]-1] + x[i] << endl; 
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+9;


vector<int> g[maxn];
set<pair<int,int>> se;
int vis[maxn],n,m,cnt;
bool dfs1(int u,int pre){
    vis[u]=++cnt;
    //cout<<"pre, u, vis = "<<pre<<" "<<u<<" "<<vis[u]<<endl;
    for(int i=0;i<g[u].size();i++){
        int v=g[u][i];
        if(v==pre)continue;
        if(se.count(make_pair(u,v)))continue;
        //cout<<u<<" "<<v<<" "<<vis[u]<<" "<<vis[v]<<endl;
        bool flag=0;
        if(!vis[v])flag=dfs1(v,u);
        if(vis[u]>=vis[v]){
            //cout<<u<<" "<<v<<endl;
            se.insert(make_pair(u,v));
            se.insert(make_pair(v,u));
            vis[u]=vis[v];
            return 1;
        }
        if(flag)return 1;
    }
    return 0;
}
bool de_dfs(){
    //cout<<"de_dfs\n";
    memset(vis,0,sizeof(vis));
    cnt=0;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            if(dfs1(i,-1))return 1;
        }
    }
    return 0;
}
int edges = 0, now = 0;
int dfs2(int u,int pre){
    for(int i=0;i<g[u].size();i++){
        int v=g[u][i];
        if(v==pre || se.count(make_pair(u,v)))continue;
        now++;
        se.insert(make_pair(u,v));
        se.insert(make_pair(v,u));
        return dfs2(v,u);
    }
    return u;
}
bool che(){
    memset(vis,0,sizeof(vis));
    cnt=0;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            now = 0;
            if(dfs2(i,-1)!=i)return 0;
            if(now>0){
                if(se.size()==m*2)return 1;
                else return 0;
            }
        }
    }
    //cout<<"se.size() = "<<se.size()<<"\n";
    return 0;
}
bool dfs3(int u,int pre,int x,int y){
    vis[u]=1;
    for(int i=0;i<g[u].size();i++){
        int v=g[u][i];
        if(v==pre || v==y)continue;
        if(v==x)return 1;
        if(!vis[v] && dfs3(v,u,x,y))return 1;
    }
    return 0;
}
bool chee(int x,int y){
    memset(vis, 0,sizeof(vis));
    return dfs3(x,-1,x,y);
}
int dd[maxn];
int main()
{
    scanf("%d%d",&n,&m);
    //cout<<"m,m = "<<m<<endl;
    memset(dd,0,sizeof(dd));
    for(int i=1;i<=m;i++){
        int a,b;scanf("%d%d",&a,&b);
        assert(a!=b);
        g[a].push_back(b);
        g[b].push_back(a);
        dd[a]++;
        dd[b]++;
    }
    int ins=0;
    bool ff=1;
    int a=0,b=0;
    int mark=0;
    for(int i=1;i<=n;i++){
        if(dd[i]&1){
            ff=0;
            mark=1;
        }
        if(dd[i]>=6)ins += maxn;
        else if(dd[i]==4){
            ins++;
            if(a==0)a=i;
            else if(b==0)b=i;
        }
    }
    if(ins<2){
        ff=0;
    }
    else if(ins==2 && ff){
        if(chee(a,b));
        else ff=0;
    }
    bool flag = de_dfs();/*
    for(auto it=se.begin();it!=se.end();it++){
        cout<<(it->first)<<" "<<(it->second)<<endl;
    }*/
    //cout<<"flag1 = "<<flag<<endl;
    if(ff && flag==0)while(1);
    if(flag)flag = de_dfs();
    if(ff && flag==0)assert(1==2);
    if(flag){
        flag = che();
    }
    //if(flag)printf("Yes\n");
    //else printf("No\n");
    if(ff!=flag){
        //if(ins==2)while(1);
        //if(ins>=maxn)assert(1==2);
    }
    printf("%s\n",ff?"Yes":"No");
    return 0;
}



Measured memory_bytes: 22144
#include <bits/stdc++.h>
        using namespace std;
        #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
        #define M_PI 3.14159265358979323846
        #define data data_
        #define ff first
        #define ss second
        #define pb push_back
        #define ll long long
        #define ld long double

        int main()
        {
            tani_nachi_ke  

           int n,m;
           cin >> n >> m;
           int a = 0,b = 0;
           set<int> st;
           map<int,int> mp;
           for(int i = 0; i < m; i++)
           {
                int x;
                string s;
                cin >> x >> s;
                if(s=="AC")
                {
                    st.insert(x);
                }
                else
                {
                    if(st.find(x) == st.end())
                    {
                        mp[x]++;
                    }
                    
                }
           }
           for(auto &it:st)
            b+=mp[it];
           cout << st.size() << " " << b << endl;






           return 0;
        }

Measured memory_bytes: 9600
# https://atcoder.jp/contests/abc126/tasks/abc126_e
class UnionFindWithType
  attr_reader :types
  def initialize(size)
    @rank = Array.new(size) { 0 }
    @parent = Array.new(size) { |id| id }
    @types = size
  end

  def unite(id_x, id_y)
    x_parent = get_parent(id_x)
    y_parent = get_parent(id_y)
    return if x_parent == y_parent
    @types -= 1
    if @rank[x_parent] > @rank[y_parent]
      @parent[y_parent] = x_parent
    else
      @parent[x_parent] = y_parent
      @rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
    end
  end

  def get_parent(id_x)
    @parent[id_x] == id_x ? id_x : (@parent[id_x] = get_parent(@parent[id_x]))
  end
end


N, M = gets.split.map(&:to_i)
uf = UnionFindWithType.new(N)
M.times do
  uf.unite(*gets.split.take(2).map { |s| s.to_i - 1 })
end
p uf.types

Measured memory_bytes: 3324
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	ll N;
	cin >> N;

	int sq = sqrt(N);


	ll kotae = 0;
	rep1(i, sq) {
		if (N % i == 0) {
			if (i < N / i - 1) kotae += N / i - 1;
		}
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
n = gets.to_s.to_i

s = Array.new(n){ Array.new(n){ nil } }

n.times do |i|
  
  a = gets.to_s.to_i
  a.times do
    x, y = gets.to_s.split.map{|t|t.to_i}
    x -= 1
    s[i][x] = y
  end
end

ans = 0
(2**n).times do |bit|
  
  cnt = 0
  flag = true
  n.times do |i|
    
    next if bit[i] == 0
    cnt += 1
    s[i].each_with_index do |y, j|
      
      next unless y
      if y != bit[j]
        flag = false
        break
      end
    end
  end
  
  ans = [ans, cnt].max if flag
end

puts ans

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

typedef long long ll;
#define fore(i,ii,iii) for(ll i=ii;i<iii;i++)
#define mset(a,b) memset(a,b,sizeof(a))
#define pb push_back

const ll N=21,MOD=1e9+7;
ll n,x,dp[N][1<<N];
vector<ll>g[N];
ll solve(ll k,ll mask) {
  if(k==n)return 1;
  if(dp[k][mask]!=-1)return dp[k][mask];
  ll res=0;
  for(ll i:g[k]) {
    if(mask&(1ll<<i)) {
      res=(res+solve(k+1,mask^(1ll<<i)))%MOD;
    }
  }
  return dp[k][mask]=res;
}

int main() {
  ios::sync_with_stdio(false);
  mset(dp,-1);
  cin>>n;
  fore(i,0,n)fore(j,0,n){
    cin>>x;
    if(x)g[i].pb(j);
  }
  cout<<solve(0,(1ll<<n)-1)<<endl;
}

Measured memory_bytes: 344320
h, w = map(int, input().split())
table = []
for i in range(h):
    line = input()
    table.append(line)

for i in range(h):
    line = ""
    for j in range(w):
        hs = max(0, i - 1)
        he = min(h - 1, i + 1)
        ws = max(0, j - 1)
        we = min(w - 1, j + 1)
        counter = 0
        for hi in range(hs, he + 1):
            for wi in range(ws, we + 1):
                if table[hi][wi] == "#":
                    counter += 1
        if table[i][j] == "#":
            line += "#"
        else:
            line += str(counter)
    print(line)


Measured memory_bytes: 9196
use itertools::Itertools;
use proconio::{input, marker::Bytes};
use std::cmp::Reverse;
use std::collections::{BinaryHeap, HashMap};

fn main() {
    input!(mut s: [(Bytes, u64)]);
    s.sort_by(|a, b| b.1.cmp(&a.1));
    let s = s;

    #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    enum Fix {
        Pre(Vec<u8>),
        Suf(Vec<u8>),
    };
    use Fix::*;

    let mut depth = HashMap::new();
    let mut que = BinaryHeap::new();

    for (s, c) in &s {
        let c = *c;
        depth.insert(Pre(s.clone()), c);
        depth.insert(Suf(s.clone()), c);
        que.push((Reverse(c), Pre(s.clone())));
        que.push((Reverse(c), Suf(s.clone())));
    }

    while let Some((Reverse(dv), v)) = que.pop() {
        let adj = s.iter().flat_map(|(s, c)| match v.clone() {
            Pre(v) => {
                let w = &v.iter().copied().rev().collect_vec();
                if s.ends_with(w) {
                    Some((Suf(s[..s.len() - v.len()].into()), c))
                } else if w.ends_with(s) {
                    Some((Pre(v[s.len()..].into()), c))
                } else {
                    None
                }
            }
            Suf(v) => {
                let w = &v.iter().copied().rev().collect_vec();
                if s.starts_with(w) {
                    Some((Pre(s[v.len()..].into()), c))
                } else if w.starts_with(s) {
                    Some((Suf(v[..v.len() - s.len()].into()), c))
                } else {
                    None
                }
            }
        });

        for (w, &c) in adj {
            let alt = dv + c;
            if let Some(dw) = depth.get_mut(&w) {
                if *dw > alt {
                    *dw = alt;
                    que.push((Reverse(alt), w.clone()));
                }
            } else {
                depth.insert(w.clone(), alt);
                que.push((Reverse(alt), w.clone()));
            }
        }
    }

    let ans = depth
        .iter()
        .filter(|&(s, _)| {
            let s = match s {
                Pre(s) => s,
                Suf(s) => s,
            };
            s.iter().eq(s.iter().rev())
        })
        .map(|(_, d)| d)
        .min();
    if let Some(ans) = ans {
        println!("{}", ans)
    } else {
        println!("-1")
    }
}


Measured memory_bytes: 2256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll n,m;
vector<ll> a;

int main(){
    //累積和したってO(sigmaN)=O(N^2)でしょうもない
    //どうやって計算量を落とす？
    cin>>n>>m;
    a.resize(n);
    rep(i,n){
        cin>>a[i];
        a[i]%=m;
    }
    vector<ll> sum(n+1,0);
    rep(i,n){
        sum[i+1]=(sum[i]+a[i])%m;
    }
    map<ll,ll> m;
    rep(i,n+1){
        m[sum[i]]++;
    }
    ll ans=0;
    for(auto x:m){
        if(x.second>=2){
            ans+=x.second*(x.second-1)/2;
        }        
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5760
#include<stdio.h>
#include<string.h>
char SS[101];
void Henkan(char);
int main()
{
  int i,j,n;
  char S[101];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",S);
    scanf("%s",SS);
    for(j=strlen(S)-1;j>=0;j--){
      Henkan(S[j]);
    }
    printf("%s\n",SS);
  }
  return 0;
}

void Henkan(char SSS){
  int i;
  char tmp,t1[101],t2[101];
  switch(SSS){
  case 'C':
    tmp=SS[0];
    for(i=0;i<strlen(SS)-1;i++)SS[i]=SS[i+1];
    SS[strlen(SS)-1]=tmp;
    break;
  case 'J':
    tmp=SS[strlen(SS)-1];
    for(i=strlen(SS)-1;i>=1;i--)SS[i]=SS[i-1];
    SS[0]=tmp;
    break;
  case 'E':
    for(i=0;i<strlen(SS)/2;i++)t1[i]=SS[i];
    t1[i]='\0';
    for(i=0;i<strlen(t1);i++)t2[strlen(t1)-1-i]=SS[strlen(SS)-1-i];
    for(i=0;i<strlen(t1);i++)SS[strlen(SS)-1-i]=t1[strlen(t1)-1-i];
    for(i=0;i<strlen(t1);i++)SS[i]=t2[i];
    break;
  case 'A':
    for(i=0;i<strlen(SS)/2;i++){
      tmp=SS[strlen(SS)-1-i];
      SS[strlen(SS)-1-i]=SS[i];
      SS[i]=tmp;
    }
    break;
  case 'M':
    for(i=0;i<strlen(SS);i++){
      if(SS[i]>='0' &&SS[i]<'9')SS[i]++;
      else if(SS[i]=='9')SS[i]='0';
    }
    break;
  case 'P':
    for(i=0;i<strlen(SS);i++){
      if(SS[i]>'0' &&SS[i]<='9')SS[i]--;
      else if(SS[i]=='0')SS[i]='9';
    }
    break;
  }
}

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

namespace program {
  class Program {
    static void Main()
    {
      var s = Input.ScanStr();
      var t = Input.ScanStr();
      int c = 0;
      if(s[0]==t[0]) c++;
      if(s[1]==t[1]) c++;
      if(s[2]==t[2]) c++;
      Out(c);
    }
    static public void Out(object s) { Console.Write($"{s} "); }
  }
  
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


Measured memory_bytes: 13140
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,i;
	scan(N);scan(i);
	prin(N+1-i);

	return 0;
}


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

using namespace std;

#define cin_desync()                                                           \
    do {                                                                       \
        ios_base::sync_with_stdio(false);                                      \
        cin.tie(0);                                                            \
    } while (0)

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

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

int main() {
    cin_desync();
    string S;
    cin >> S;

    int N = S.length();
    int num_after = 0, num_black = 0;
    ll ans = 0;
    for (int i = N - 1; i >= 0; --i) {
        if (S[i] == 'B') {
            ans += num_after - num_black;
            ++num_black;
        }
        ++num_after;
    }

    cout << ans << endl;
}


Measured memory_bytes: 720
# 解説

import queue

k = int(input())

q = queue.Queue()

for i in range(1,10):
    q.put(i)

for i in range(k):
    a = q.get()
    if i==k-1:
        print(a)
        exit()
    c = int(str(a)[-1])
    if c==0:
        q.put(a * 10 + c)
        q.put(a * 10 + c + 1)
    elif c==9:
        q.put(a * 10 + c - 1)
        q.put(a * 10 + c)
    else:
        q.put(a*10+c-1)
        q.put(a*10+c)
        q.put(a*10+c+1)



Measured memory_bytes: 58196
n,m=map(int,input().split())
s=[]
c=[]
flag=True
for i in range(m):
    s_tmp,c_tmp=map(int,input().split())
    if s_tmp in s:
        if c_tmp in c:
            pass
        else:
            flag=False
    else:
        if s_tmp==1 and c_tmp==0 and n!=1:
            flag=False
        else:
            s.append(s_tmp)
            c.append(c_tmp)
if flag:
    tmp_number=0
    for i in range(len(s)):
        tmp_number+=(10**(n-s[i]))*c[i]
    if tmp_number<10**(n-1) and n>1:
        tmp_number+=10**(n-1)
    print(tmp_number)
else:
    print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define s second
#define f first
long long const mod = 1000000007; 
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

ll power(ll x,ll y,ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
}

ll modInv(ll x)
{
    return power(x,mod-2,mod)%mod;
}

struct st
{
    ll s,e,ind;
};
bool compare(st s1,st s2)
{
    if(s1.s==s2.s)
        return s1.e<s2.e;
    return s1.s<s2.s;
}

bool operator<(const st& t1, const st& t2) 
{ 
    return (t1.ind < t2.ind); 
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ld n,k;
    cin>>n>>k;
    ll p=max(0LL,ll(ceil(n/k)-1));
    n=n-p*k;
    //cout<<p<<endl<<n<<endl;
    cout<<fixed<<ll(min(n,k-n))<<endl;

    return 0;
}

Measured memory_bytes: 256
main = do
  s <- getLine
  putStrLn $ f s 

f :: String -> String
f xs
  | inc (take 2 xs) && inc (drop 2 xs) = "AMBIGUOUS"
  | inc (take 2 xs) = "MMYY"
  | inc (drop 2 xs) = "YYMM"
  | otherwise = "NA"
  where
    inc x = x `elem` ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]

Measured memory_bytes: 380
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		int a;
		int b;
		int c;
		Scanner scan=new Scanner(System.in);
		a=scan.nextInt();
		b=scan.nextInt();
		c=scan.nextInt();

		int x;


		if(a>b){
		x =a;
		a=b;
		b=c;
		
		c=x;
		}
		if(b>c){
			x=b;
			b=c;
			c=x;


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


Measured memory_bytes: 26204
#include <iostream>
#include <stdio.h>
void cs(int k);

int A[2000001];
int B[2000001];
int n;

// length is n
main(){

  int i,k=0;
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
    if(A[i]>k) k=A[i];
  }
  // setting is finished

  cs(k);

  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i!=n) printf(" ");
  }
  printf("\n");

  return 0;
}

void cs(int k){
  int C[k+1];
  int i,j,len;
  for(i=0; i<=k; i++)
    C[i] = 0;

  for(j=1; j<=n;j++)
    C[A[j]]++;

  for(i=1; i<=k; i++)
    C[i] = C[i] + C[i-1];

  for(j=n; j>=1; j--){

    B[C[A[j]]] = A[j];
    C[A[j]] = C[A[j]]-1;

  }

}

Measured memory_bytes: 16852
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		int t = scan.nextInt();

		int A = X-t;

		if(A < 0){
			System.out.println(0);
		}else{
			System.out.println(A);
		}

		scan.close();
	}
}


Measured memory_bytes: 22612
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
string solve(ll n) {
    string ans;
    n-=1;
    ans+=char(97+(n%26));
    n/=26;
    while(n>0){
        ans=ans+char(97+(n-1)%26);
        n=(n-1)/26;
    }
    reverse(ans.begin(),ans.end());
    return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    cout<<solve(n)<<endl;
    return 0;
}


Measured memory_bytes: 3648
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextLong() int64 {
	i, err := strconv.ParseInt(io.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextDouble() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func main() {
	io := NewIo()
	defer io.Flush()
	N := io.NextInt()
	M := io.NextInt()
	A := make([]string, N)
	for i := 0; i < N; i++ {
		A[i] = io.Next()
	}
	B := make([]string, M)
	for i := 0; i < M; i++ {
		B[i] = io.Next()
	}
	ans := false
	for i := 0; i + M <= N; i++ {
		for j := 0; j + M <= N; j++ {
			ok := true
			for y := 0; y < M; y++ {
				for x := 0; x < M; x++ {
					if B[y][x] != A[y+i][x+j] {
						ok = false
					}
				}
			}
			if ok {
				ans = true
			}
		}
	}
	if ans {
		io.PrintLn("Yes")
	} else {
		io.PrintLn("No")
	}
}

Measured memory_bytes: 640
// Problem : E - Red Scarf
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		int arr[n+1];
		for(int i=0;i<n;++i)
		cin>>arr[i];
		if(n==2)
		{
			cout<<arr[1]<<" "<<arr[0];
			return 0;
		}
		int pre[n+1] = {},suf[n+1] = {};
		pre[0] = arr[0];
		suf[n-1] = arr[n-1];  
		for(int i=1;i<n;++i)
		{
			pre[i] = pre[i-1]^arr[i];
		}
		for(int i=n-2;i>=0;--i)
		{
			suf[i] = suf[i+1]^arr[i];
		}
		for(int i=0;i<n;++i)
		{
			if(i!=0)
			cout<<(pre[i-1]^suf[i+1])<<" ";
			else
			cout<<suf[i+1]<<" ";
		}
			
    }
    return 0;
}


Measured memory_bytes: 8312
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
#define INT_MAX 1<<30
const ll mod = 1e9+7;

int main(){
	ll n,m; cin >> n >> m;
	vl a(n); rep(i,n) cin >> a[i];
	sort(all(a));
	vl b = a;
	sort(rall(b));
	vl sum(n+1,0);
	rep(i,n) sum[i+1] = sum[i] + b[i];
	ll ok = 0, ng = 1e6;
	ll s = 0;
	ll times = 0;
	while(ng-ok>1){
		ll mid = (ok+ng)/2;
		ll cnt = 0;
		s = 0;
		rep(i,n){
			ll d = a.end() - lower_bound(all(a),mid-a[i]);
			cnt += d;
		}
		if(cnt >= m) times = cnt;
		if(cnt >= m) ok = mid;
		else ng = mid;
	}
	rep(i,n){
		ll d = a.end() - lower_bound(all(a),ok-a[i]);
		s += a[i]*d + sum[d];
	}
	s -= ok * (times - m);
	cout << s << endl;
}

Measured memory_bytes: 2560
n,k = list(map(int,input().split()))
arr = []
for i in range(k):
    l = list(map(int,input().split()))
    arr.append(l)
mex = 2*pow(10,5) + 5
mod = 998244353
dp = [0 for i in range(mex)]
suf = [0 for i in range(mex)]
dp[n] = 1
suf[n] = 1
for i in range(n-1,0,-1):
    for j in range(k):
        l = i+arr[j][0]
        r = i+arr[j][1]
        r = min(r,n)
        if l<=r:
            dp[i] = (dp[i]+suf[l]-suf[r+1])%mod
    suf[i] = (dp[i]+suf[i+1])%mod
print(dp[1])

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

using namespace std;

typedef long long ll;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define INF 1000000000

int main() {

	ll n, m[5] = { 0 }, ans = 0;
	cin >> n;
	FOR(i, n) {
		string s;
		cin >> s;
		if (s[0] == 'M')m[0]++;
		else if (s[0] == 'A')m[1]++;
		else if (s[0] == 'R')m[2]++;
		else if (s[0] == 'C')m[3]++;
		else if (s[0] == 'H')m[4]++;
	}
	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			for (int k = j + 1; k < 5; k++) {
				ans += m[i] * m[j] * m[k];
			}
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

class Data{
public:
	double x;
	double y;
	double r;
	Data(double _x,double _y,double _r){
		x = _x;
		y = _y;
		r = _r;
	}
};

bitset<10000> found; 
bool filled[400][400];
int main(){
	int n;
	int idx = 1;
	while(~scanf("%d",&n)){
		if(n==0) break;

		vector<Data> Points;
		memset(filled,0,sizeof(filled));

		for(int i=0;i<n;i++){
			double x,y,r;
			scanf("%lf %lf %lf",&x,&y,&r);
			Points.push_back(Data(x,y,r));

			//x=200; cx=20000;
			//x=0 cx=0;
			//r=200 ra=20000;
			//-20000<square<20000

			int cx = x*100.0;
			int cy = y*100.0;
			int ra = r*100.0; 
			
			for(int y=0;y<40000;y+=100){
				for(int x=0;x<40000;x+=100){
					if(cx - ra + 20000 <= x && x+100 < cx+ra + 20000
					&& cy - ra + 20000 <= y && y+100 < cy+ra + 20000){
						filled[y/100][x/100] = true;
						continue;
					}
				}
			}
		}


		int res=0;


		for(int y=0;y<40000;y+=100){
			for(int x=0;x<40000;x+=100){
				if(filled[y/100][x/100]){
					res+= 10000;
					continue;
				}
				else{

					found.reset();
					for(int i=0;i<Points.size();i++){
						int cx = Points[i].x*100.0 + 20000;
						int cy = Points[i].y*100.0 + 20000;
						int ra = Points[i].r*100.0;


						if(cx+ra < x || x+100 <= cx - ra) continue;
						if(cy+ra < y || y+100 <= cy - ra) continue;
						for(int dy= max(cy-ra,y);dy<min(cy+ra,y+100);dy++){
							for(int dx = max(cx-ra,x);dx < min(cx+ra,x+100); dx++){
								found[(dy-y)*100+(dx-x)] = true;
							}
						}

					}

					res += found.count();

				}

			}
		}

		printf("%d %.2lf\n",idx++,res/(double)10000);		
	}
}

Measured memory_bytes: 1420
#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



signed main(){

    int K, A, B; cin >> K >> A >> B;
    bool f = false;
    FOR(i, A, B + 1) if(i % K == 0) f = true;
    Ans(f, "OK", "NG");

    return 0;
}


Measured memory_bytes: 3688
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int K,X;
	cin>>K>>X;
	int i;
	bool bFirst=true;
	for (i=X-K+1;i<=X+K-1;i++){
		if (bFirst){
			bFirst=false;
		}else{
			cout<<" ";
		}
		cout<<i;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
 
struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}


signed main(){
    int n,x,t;cin>>n>>x>>t;
    cout<<(t*((n+x-1)/x))<<endl;
    return 0;
}


Measured memory_bytes: 3648
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
s = list(input())
res = 0
for i in range(1,n):
    x = s[:i]
    y = s[i:]
    sx = set(x)
    sy = set(y)
    cnt = 0
    for i in list(sx):
        if i in sy:
            cnt += 1
    res = max(res, cnt)
print(res)

Measured memory_bytes: 64748
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)
#define fcout cout << fixed << setprecision(10)

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    vector<int> x(3);
    REP(i, 3) cin >> x[i];
    sort(x.begin(), x.end());
    if (x[1] == 5 && x[0] == 5 && x[2] == 7) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		final int N = scan.nextInt();

		H[] hs = new H[N];
		for(int i = 0; i < N; i++) {
			hs[i] = new H(i + 1, scan.nextInt());
		}

		Arrays.sort(hs, new Comparator<H>(){
			public int compare(H h1, H h2) {
				return h1.getOrder() - h2.getOrder();
			}
		});

		System.out.print(hs[0].getNum());
		for(int i = 1; i < N; i++) {
			System.out.print(" " + hs[i].getNum());
		}
		scan.close();
	}
}

class H{
	private int num;
	private int order;

	public H (int num, int order) {
		this.num = num;
		this.order = order;
	}

	public int getNum() {
		return this.num;
	}

	public int getOrder() {
		return this.order;
	}
}


Measured memory_bytes: 65564
#include <bits/stdc++.h>
#define mp make_pair
#define pbk push_back
#define ph push
#define ptc putchar
#define enter putchar('\n')
#define mod 998244353
using namespace std;
typedef pair<int,int> pii;
typedef double db;
typedef long double ldb;
typedef long long ll;
typedef long long lnt;
inline int read(){
	int x = 0;char c = getchar();
	while (!isdigit(c)) c = getchar();
	while (isdigit(c)) x = (x << 1) + (x << 3) + c - '0' , c = getchar();
	return x;
}
inline void write(int x){
	if (!x){
       ptc('0');
       return;
	}
	int dg[20] , len = 0;
	while (x) dg[len++] = x % 10 , x /= 10;
	while (len--) ptc(dg[len]+'0');
}
inline void writeln(int x){
	write(x);
	ptc('\n');
}
inline int add(int x,int y){
	x += y;if (x >= mod) x -= mod;
	return x;
}
inline int sub(int x,int y){
	x -= y;if (x < 0) x += mod;
	return x;
}
inline int qpow(int x,int y){
	int res = 1;
	while (y){
		if (y & 1) res = 1ll * res * x % mod;
		x = 1ll * x * x % mod;y >>= 1;
	}
	return res;
}

const int N = 6e3 + 10;
int n , pa[N] , pb[N] , ca , cb , pos[N];
char s[N];
int sg;
bool visit[N];
string SegMax[N] , f[N];
 
int main(){
	scanf("%d",&n);	
	scanf("%s",s + 1);
	n <<= 1;
	for (int i = 1;i <= n;i++){
		if (s[i] == 'a'){
			pa[++ca] = i;
			pos[i] = ca;
		}else{
			pb[++cb] = i;
			pos[i] = cb;
		}
	}
	
	for (int i = 1;i <= n;i++){
		
		int j = i , sum = s[i] == 'a' ? 1 : -1;
		while (sum != 0){
			j++;
			sum += s[j] == 'a' ? 1 : -1;
		}
//		printf("(%d %d)\n",i,j);
		
		if (s[i] == 'a'){
			++sg;
			for (int k = i;k <= j;k++){
				if (s[k] == 'b') continue;
				visit[k] = visit[pb[pos[k]]] = 1;
				k = pb[pos[k]];
			}
			for (int k = i;k <= j;k++){
				if (visit[k]) SegMax[sg].pbk(s[k]);
			}
		}else{
			++sg;
			string tmp;
			int L = pos[i] , R = pos[j];
			
//			printf("(%d %d)\n",L,R);
			for (int k = R;k >= L;k--){//k , L
				tmp.clear();
				for (int _k = i;_k <= j;_k++) if (pos[_k] >= k) tmp.pbk(s[_k]);
//				cout<<tmp<<endl;
				SegMax[sg] = max(SegMax[sg] , tmp);
			}
		}
//		printf("[%d %d]\n",i,j);
//		cout<<SegMax[sg]<<endl;
		i = j;
	}
	
	for (int i = sg;i >= 1;i--){
		f[i] = max(f[i + 1] , SegMax[i] + f[i + 1]);
	}
	
	cout<<f[1]<<endl;
	return 0;
}



Measured memory_bytes: 10752
import scala.io.Source

object Main {
  val list = Seq("Sunny", "Cloudy", "Rainy")

  def succ(x: String): String = {
    (list zip (list.tail :+ list.head)).toMap.get(x).get
  }

  def main(args: Array[String]) {
    val s = Source.stdin.getLines.toSeq.head
    println(succ(s))
  }
}


Measured memory_bytes: 25540
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        boolean[][] canvas = new boolean[H+2][W+2]; //black <> true, white <>false
        for(int h=0;h<=H+1;h++){
        	canvas[h][0] = false;
        	canvas[h][W+1] = false;
        }
        for(int w=0;w<=W+1;w++){
        	canvas[0][w] = false;
        	canvas[H+1][w] = false;
        }
        
        for(int h=1;h<=H;h++){
        	String line = sc.next();
        	for(int w=1;w<=W;w++) canvas[h][w] = (line.charAt(w-1)=='#');
        }
        
        boolean ans = true;
        for(int h=1;h<=H;h++) for(int w=1;w<=W;w++){
        	if(  canvas[h][w]
        	 && !canvas[h+1][w]
        	 && !canvas[h-1][w]
        	 && !canvas[h][w+1]
        	 && !canvas[h][w-1]) ans = false;
        }
        System.out.println(ans ? "Yes" : "No");
    }
}

Measured memory_bytes: 23636
import java.io.*
import java.util.*

fun solve(X: Long){
    var x = X
    while(!isPrime(x)){
        x++
    }
    println(x)
    return
}

fun isPrime(num: Long): Boolean {
    if (num == 1L) return false
    if (num in listOf(2L, 3L)) return true
    if (num % 6 in listOf(0L, 2L, 3L, 4L)) return false
    val sqrt = Math.sqrt(num.toDouble()).toLong()
    for (n in 5..sqrt step 6) {
        if (num % n == 0L) return false
    }
    for (n in 7..sqrt step 6) {
        if (num % n == 0L) return false
    }
    return true
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val X = sc.next().toLong()
    solve(X)
}



Measured memory_bytes: 33964