akhauriyash/Code-Regression huggingface dataset:
// 2020-07-31 08:38:39
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int n;
  cin >> n;
  int x = 0;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    x ^= a[i];
  }
  rep(i, n) {
    if(i) cout << ' ';
    cout << (x ^ a[i]);
  }
  cout << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3968
# coding: utf-8
# Your code here!
N,M=map(int,input().split())

shop=[]

for _ in range(N):
    A,B=map(int,input().split())
    shop.append([A,B])

shop.sort(key=lambda x:x[0])

ans=0
for money, num in shop:
    if M<=num:
        ans+=money*M
        break
    else:
        ans+=money*num
        M-=num

print(ans)


Measured memory_bytes: 62720
# -*- coding:utf-8 -*-
"""考え方
・BBBBWWW
右にBを置けば良い

・WWBBWW
右にBを置く
右にWを置く

・WBWBWBWBBBBBBW
右にBWBWBWBWの順に置く
または、
左にBWBWBWBWの順に置く

どうやら、左と右でもかわらない様子
"""
def solve():
    S = input()

    ans = 0
    now = S[0]
    for i, moji in enumerate(list(S)):
        if now == moji:
            continue
        ans += 1
        now = moji
    print(ans)
    

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3956
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            if (str.Contains("a") && str.Contains("b") && str.Contains("c"))
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
            Console.ReadLine();
        }
        
    }

}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i, n) cin>>v[i];
    int q;
    cin>>q;
    vector<pair<int, int> > change(q);
    rep(i, q){
        int b, c;
        cin>>b>>c;
        change[i]  = make_pair(b, c);
    } 
    map<int, int> mp;
    rep(i, n){
        mp[v[i]]++;
    }
    ll ans = 0;
    for (auto p : mp){
        ans+=(ll)p.second*(ll)p.first;
    }
    rep(i, q){
        int b, c;
        b = change[i].first;
        c = change[i].second;
        int k = mp[b];
        mp[b] = 0;
        mp[c]+=k;
        ans -= (ll)b*(ll)k;
        ans += (ll)c*(ll)k;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 8640
#include <stdio.h> 
#include <stdlib.h>
#define swap(X, Y) {int Z; Z = Y; Y = X; X = Z;}


int main()
{
	int a, b, c; 
	scanf("%d %d %d", &a, &b, &c);
	
	if(a > b)
	{
		swap(a, b);
	}
	if(a > c)
	{
		swap(a, c);
	}
	if(b > c)
	{
		swap(b, c);
	}
	printf("%d %d %d\n", a, b, c);
	
	return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

static const int MAX = 100000;

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;

void dfs(int u)
{
  V[u] = true;
  for (int i = 0; i < G[u].size(); i++)
  {
    int v = G[u][i];
    if (!V[v])
    {
      dfs(v);
    }
  }
  out.push_front(u);
}

int main()
{
  int s, t, M;
  cin >> N >> M;
  for (int i = 0; i < N; i++)
  {
    V[i] = false;
  }

  for (int i = 0; i < M; i++)
  {
    cin >> s >> t;
    G[s].push_back(t);
  }

  for (int i = 0; i < N; i++)
  {
    if (!V[i])
    {
      dfs(i);
    }
  }

  for (list<int>::iterator it = out.begin(); it != out.end(); it++)
  {
    cout << *it << endl;
  }

  return 0;
}


Measured memory_bytes: 6172
n,m = [int(x) for x in input().split()]
a=[]
b=[]
for i in range(n): a.append([int(x) for x in input().split()])
for j in range(m): b.append(int(input()))
for a_row in a:
    print(sum([x*y for x,y in zip(a_row,b)]))


Measured memory_bytes: 6020
//Name: Magical Girl Sayaka-chan
//Level: 3
//Category: 動的計画法,DP
//Note:

/**
 */
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define TIMES(i_, n_) for(int i_ = 0; i_ < (n_); ++i_)
typedef long long LL;

int N, M, L;
vector<int> ks;
vector<int> ss;
vector<LL> acc;
LL memo[2001][2001];

LL cost(int a, int b) {
    int ka = ks[a];
    int kb = ks[b];
    if(ka > kb) swap(ka, kb);
    return (acc[kb] - acc[ka-1]) / L;
}

LL calc(int l, int r) {
    if(memo[l][r] != -1) return memo[l][r];
    const int next = max(l, r) + 1;
    if(next == N) {
        return cost(l, r);
    }
    memo[l][r] = min(calc(next, r) + cost(l, next), calc(l, next) + cost(r, next));
    return memo[l][r];
}

bool solve() {
    if(!(cin >> N >> M >> L)) return false;
    if(!N && !M && !L) return false;

    ks.resize(N);
    TIMES(i, N) {
        cin >> ks[i];
    }
    ss.resize(M);
    TIMES(i, M) {
        cin >> ss[i];
    }
    acc.resize(M+1);
    acc[0] = 0;
    for(int i = 1; i <= M; ++i) {
        acc[i] = acc[i-1] + ss[i-1];
    }

    sort(ks.begin(), ks.end());
    TIMES(i, N) {
        TIMES(j, N) {
            memo[i][j] = -1;
        }
    }
    cout << calc(0, 0) << endl;
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 33580
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<int> A(N),B(N);
  for(int i=0;i<N;i++)
    cin>>A[i]>>B[i];
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  if(N%2)cout<<(B[N/2]-A[N/2])+1<<endl;
  else cout<<((B[N/2]+B[N/2-1])-(A[N/2]+A[N/2-1]))+1<<endl;
}

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

int main(void) {
  int n, p_i, q_i;
  int p[8], q[8], s[8];
  
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for(int i = 0; i < n; i++) {
    cin >> q[i];
  }
    
  for(int i = 0; i < n; i++) {
    s[i] = i+1;
  }
  
  int count = 0;
  do {
    bool flag_p = true;
    bool flag_q = true;
    for(int i = 0; i < n; i++) {
      if(s[i] != p[i]) flag_p = false;
      if(s[i] != q[i]) flag_q = false;
    }
    if(flag_p) p_i = count;
    if(flag_q) q_i = count;
    count++;
  } while(next_permutation(s, s+n));
  
  cout << abs(p_i - q_i) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
ll dp[100005];
int main() {
    ios;
    ll h,n;cin>>h>>n;
    f(i,0,100005)dp[i]=INT_MAX;
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        ll a,b;cin>>a>>b;
        for(int i=a;i<100005;i++)
        {
              if(dp[i-a]+b<dp[i])
               dp[i]=dp[i-a]+b;
        }
    }
 ll ans=INT_MAX;
  for(int i=h;i<100005;i++)
    ans=min(ans,dp[i]);
    cout<<ans;
	
 
    
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
 
public class Main {
 
	void submit() {
	    long N = nextLong();
	    long K = nextLong();
	    
	    long amari = N%K;
	    long amari2 = Math.abs(N%K-K);
	    
	    if(amari < amari2){
            out.print(amari);
	    }else{
            out.print(amari2);	        
	    }

	}

	void preCalc() {
 
	}
 
	void stress() {
 
	}
 
	void test() {
 
	}
 
	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}
 
	static final Random rng = new Random();
 
	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}
 
	public static void main(String[] args) throws IOException {
		new Main();
	}
 
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
 
	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}
 
	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
 
	int nextInt() {
		return Integer.parseInt(nextToken());
	}
 
	long nextLong() {
		return Long.parseLong(nextToken());
	}
 
	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin >> t;
	while (t--)
	{
		string s, t;
		cin >> s >> t;
		int ans = 0;
		for (int i = 0; i < sz(s); i++) {
			ans += s[i] != t[i];
		}
		cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<int> C(N);
    vector<vector<int>> G(N);
    REP(i,N) cin >> C[i], C[i]--;
    REP(i,N-1){
        int u, v;
        cin >> u >> v;
        G[--u].push_back(--v);
        G[v].push_back(u);
    }
    vector<vector<int>> res(N);
    vector<int> cnt(N);
    vector<map<int, int>> dp(N);
    auto dfs = [&](auto && self, int v, int par) -> void{
        for(auto nv : G[v]){
            if(nv == par) continue;
            self(self, nv, v);
            cnt[v] += cnt[nv];

            int tmpCnt = cnt[nv];
            if(dp[nv].count(C[nv])) tmpCnt -= dp[nv][C[v]];
            res[C[v]].push_back(tmpCnt);

            //merge technique
            if(dp[v].size() < dp[nv].size()) swap(dp[v], dp[nv]);
            for(auto &x : dp[nv]) dp[v][x.first] += x.second;
        }
        cnt[v]++;
        dp[v][C[v]] = cnt[v];
    };

    dfs(dfs, 0, -1);
    REP(i,N) res[i].push_back(N - dp[0][i]);
    vector<ll> ans(N, N * (N + 1) / 2);
    REP(i,N) for(ll c : res[i]) ans[i] -= c * (c + 1) / 2;

    REP(i,N) cout << ans[i] << endl;
}


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

using namespace std;

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


Measured memory_bytes: 3096
#include <cstdio>
using namespace std;

#define REP(i, stop) for (int i = 0, i##_len = stop; i < i##_len; ++i)

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getc() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int read() {
	int r = 0;
	if (ci - cn + 16 > cm) while ((ct = getc()) & 16) r = r * 10 + ct - '0';
	else while ((ct = *ci++) & 16) r = r * 10 + ct - '0';
	return r;
}

int A[200000];
signed main() {
	int n = read();
	int m0 = 0;
	int m1 = 0;
	REP(i, n) {
		int a = read();
		if (a > m0) {
			m1 = m0;
			m0 = a;
		} else if (a > m1) {
			m1 = a;
		}
		A[i] = a;
	}
	REP(i, n) {
		int a = A[i];
		if (a == m0) {
			printf("%d\n", m1);
		} else {
			printf("%d\n", m0);
		}
	}
}


Measured memory_bytes: 2432
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
char maps[25][25];
int n,m;
struct A
{
    int x,y,dis;
};
int vis[25][25];
int  ans;
int dx[]= {0,0,1,-1};
int dy[]= {1,-1,0,0};
void dfs(int x,int y)
{
    if(maps[x][y]=='#')
    {
        return ;
    }
    memset(vis,0,sizeof(vis));
    queue <A>q;
    q.push((A)
    {
        x,y,0
    });
    vis[x][y]=1;
    while(!q.empty())
    {
        A now=q.front();
        q.pop();
        ans=max(ans,now.dis);
        for(int i=0; i<4; ++i)
        {
            int temp_x=now.x+dx[i],temp_y=now.y+dy[i];
            if(temp_x<=0||temp_x>n||temp_y<=0||temp_y>m||maps[temp_x][temp_y]=='#'||vis[temp_x][temp_y])
                continue;
            q.push((A)
            {
                temp_x,temp_y,now.dis+1
            });
            vis[temp_x][temp_y]=1;
        }
    }
}
int main()
{
    cin>>n>>m;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            cin>>maps[i][j];
        }
    }
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            dfs(i,j);
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3640
n, m, c = [int(x) for x in input().split()]
bm = [int(x) for x in input().split()]
count = 0
source = 0

for i in range(n):
    tup_data = [int(x) for x in input().split()]
    #print(tup_data,end=":")
    
    for j in range(m):
        source += bm[j]*tup_data[j]
    #print(source + c)
    if source+c > 0:
        count += 1
    
    tup_data = []
    source = 0

print(count)

Measured memory_bytes: 9096
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }


int main()
{
    using namespace std;

    ull n, k;
    cin >> n >> k;

    constexpr ll bits = 60;

    vec<ull> v(bits);
    for (int i = 0; i < n; ++i)
    {
        ull in;
        cin >> in;
        for (int i = 0; i < bits; ++i)
        {
            if (((in >> i) & 1) != 0)
                ++v[i];
        }
    }

    ull xo{};

    for (int i = bits - 1; i >= 0; --i)
    {
        //cout << i << ":" << endl;
        if ((xo ^ (1ull << i)) <= k && v[i] <= n / 2)
        {
            //cout << i << " " << v[i] << " " << n / 2 << endl;
            xo ^= (1ull << i);
        }
    }

    ll ans {};
    for (ll i = 0, x = 1; i < bits; ++i)
    {
        if ((xo >> i) & 1 != 0)
        {
            v[i] = n - v[i];
        }
        ans += v[i] * x;
        x *= 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <valarray>
#include <utility>
#include <numeric>
#include <memory>
#include <functional>
#include <stdexcept>
#include <typeinfo>
#include <limits>
#include <complex>
#include <locale>
using namespace std;
#define Debug(x) cerr << #x << " = " << x << endl
#define Debug22(x,y) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<endl;
#define Debug2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define Debug3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<")\n";
#define Debug_arr(v,n) for(int i=0;i<n;++i) cerr<<#v<<"["<<i<<"]"<<" = "<<v[i]<<endl;
#define SET(p,v) fill((__typeof(**p)*)p,(__typeof(**p)*)p+sizeof(p),v);
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define prl cerr << "called: " << __LINE__ << endl
//#define FILE_JUDGE
//#define TIMES
//#define LINES
//#define home
const int mod=1000000007;
string s[2];
int n;
int main()
{
	#ifdef FILE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	cin>>n>>s[0]>>s[1];
	int cur=0;
	long long ans=1;
	int last=-1;
	while (cur<n)
	{
		if (s[0][cur]==s[1][cur])
		{
			if (last==-1)
			{
				ans*=3;
			}
			else if (last==0)
			{
				ans*=2;
			}
			else
			{
				ans*=1;
			}
			cur+=1;
			last=0;
		}
		else
		{
			if (last==-1)
			{
				ans*=6;
			}
			else if (last==0)
			{
				ans*=2;
			}
			else
			{
				ans*=3;
			}
			cur+=2;
			last=1;
		}
		ans%=mod;
	}
	cout<<ans<<endl;
	#ifdef TIMES
	eprintf("Times = %d ms.\n",clock());
	#endif
	#ifdef LINES
	eprintf("lines : %d line.\n",__LINE__+3);
	#endif
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    string str = "WS";
    rep(i, 0, 2){
        rep(j, 0, 2){
            string t = "";
            t += str[i];            
            t += str[j];
            rep(k, 1, n + 1){
                int m = k % n;
                int l = (k - 1 + n) % n;
                int r = (k + 1) % n;
                int tmp = 0;
                if(s[m] == 'x') tmp++;
                if(t[m] == 'W') tmp++;
                if(tmp % 2 == 0){
                    t += t[l];
                }else{
                    t += (t[l] == 'W' ? 'S' : 'W');
                }
            }
            // cout << i << " " << j << "" << t << endl;
            if(t[0] == t[n] && t[1] == t[n + 1]){
                cout << t.substr(0, n) << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 812
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef long long ll;
typedef long double ld;
int  main()
{
	int n, m; cin >> n >> m;
	vector<string> a(n);
	vector<string> b(m);
	rep(i, n)
	{
		cin >> a[i];
	}
	rep(i, m)
	{
		cin >> b[i];
	}
	int cnt = 0;
	rep(i, (n - m) + 1)
	{
		rep(j, (n - m + 1))
		{
			int k = 0;
			if (a[i].substr(j, m) == b[k])
			{
				cnt = 1;
				for(k = 1; k < m; k++)
				{
					if (a[i + k].substr(j, m) == b[k])
						cnt++;
				}
				if (cnt == m)
				{
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;
	// cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int i,j,k;
	int n;
	int y,m,d;
	int ans;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		ans=0;
		
		scanf("%d%d%d",&y,&m,&d);
		
		for(j=y;j<1000;j++){
			if(j%3==0){
				ans+=20*10;
			}else{
				ans+=20*5+19*5;
			}
			if(j==y){
				for(k=1;k<m;k++){
					if(k%2!=0 || j%3==0) ans-=20;
					else ans -=19;
				}
				ans-=d;
			}
		}
		ans++;
		printf("%d\n",ans);
				
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

bool solve(ll a, ll b, ll c, ll d) {
  if (a < b || d < b) return false;
  ll g = __gcd(d, b);
  ll x = a % g;
  return c >= b - g + x;
}

int main() {
#ifdef LOCAL
  freopen("b.in", "r", stdin);
  freopen("b.out", "w", stdout);
#endif

  int t;
  while (scanf("%d", &t) == 1) {
    while (t-->0) {
      ll a, b, c, d;
      assert(scanf("%lld%lld%lld%lld", &a, &b, &c, &d) == 4);
      printf("%s\n", solve(a, b, c, d) ? "Yes" : "No");
    }
  }

  return 0;
}


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

int a_to_int(char a)
{
  return a - '0';
}

int main()
{
  string S;
  cin >> S;
  int ans = 1000;

  rep(i, S.size() - 2)
  {
    int num = a_to_int(S[i]) * 100;
    num += a_to_int(S[i + 1]) * 10;
    num += a_to_int(S[i + 2]) * 1;
    num = abs(num - 753);
    ans = min(ans, num);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define LIMIT 400001

int iQueue[LIMIT * 2];

int main() {
    int iNumOfQuery;    // 命令数
    int iQuery;         // 命令番号
    int iOption;        // 命令のオプション
    int iArg;           // 命令に応じた引数
    int iCount;         // counter
    int iHead = LIMIT;  // 配列の先頭  
    int iTail = LIMIT;  // 配列の末尾

    // In: 命令数
    scanf("%d", &iNumOfQuery);
    for (iCount = 0; iCount < iNumOfQuery; iCount++) {
        scanf("%d", &iQuery);
        switch (iQuery) {
        case 0:
            scanf("%d %d", &iOption, &iArg);
            if (iOption == 0) {
                iHead--;
                iQueue[iHead] = iArg;
            }
            else {
                iQueue[iTail] = iArg;
                iTail++;
            }
            break;
        case 1:
            scanf("%d", &iArg);
            printf("%d\n", iQueue[iHead + iArg]);
            break;
        case 2:
            scanf("%d", &iOption);
            if (iOption == 0) iHead++;
            else iTail--;
            break;
        default:
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3268
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000001;
const long long LINF = 1e18;
const int MAX = 510000;

int main() {
	int d, n;
	int m;
	int ans;
	cin >> d >> n;
	if (d == 0)m = 1;
	else if (d == 1)m = 100;
	else if (d == 2)m = 10000;
	if (n != 100) {
		ans = n * m;
	}
	else {
		ans = (n + 1) * m;
	}
	cout << ans << endl;
		return 0;
	}


Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys

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


def solve(A: int, B: int, C: int, D: int):
    while(True):
        C -= B
        if C <= 0:
            print('Yes')
            break

        A -= D
        if A <= 0:
            print('No')
            break

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(A, B, C, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K;
  cin >> K;
  string S;
  cin >> S;
  if (S.size() <= K) {
    cout << S << endl;
  }
  else {
    for (int i = 0; i < K; i++) {
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3584
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<utility>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<cctype>
#include<cmath>
using namespace std;
int main()
{
	int sum=700;
	string s;
	cin >> s;
	for(int i=0;i<3;i++)
	{
		if(s[i]=='o')
		{
			sum+=100;
		}
	}
	cout << sum;
	return 0;
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const double PI = acos(-1);
const double EPS = 1e-10;
int sgn(double d) { return d > EPS ? 1 : d < -EPS ? -1 : 0; }

struct Point {
  double x, y, z;
  Point() {}
  Point(const double x, const double y, const double z) : x(x), y(y), z(z) {}
  Point& operator += (const Point other) { x += other.x; y += other.y; z += other.z; return *this; }
  Point& operator -= (const Point other) { x -= other.x; y -= other.y; z -= other.z; return *this; }
  Point& operator *= (const double factor) { x *= factor; y *= factor; z *= factor; return *this; }
  Point& operator /= (const double factor) { x /= factor; y /= factor; z /= factor; return *this; }
  bool operator == (const Point other) { return x == other.x && y == other.x && z == other.z; }
  bool operator != (const Point other) { return !(*this == other); }
};
using Vector = Point;
Point operator + (const Point lhs, const Point rhs) { return Point(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z); }
Point operator - (const Point lhs, const Point rhs) { return Point(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z); }
Point operator * (const Point lhs, const double factor) { return Point(lhs.x * factor, lhs.y * factor, lhs.z * factor); }
Point operator * (const double factor, const Point rhs) { return Point(factor * rhs.x, factor * rhs.y, factor * rhs.z); }
Point operator / (const Point lhs, const double factor) { return Point(lhs.x / factor, lhs.y / factor, lhs.z / factor); }
double operator * (const Point lhs, const Point rhs) { return lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z; }
Point operator ^ (const Point lhs, const Point rhs) { return Point(lhs.y * rhs.z - lhs.z * rhs.y, lhs.z * rhs.x - lhs.x * rhs.z, lhs.x * rhs.y - lhs.y * rhs.x); }
double norm(const Point point) { return point * point; }
double abs(const Point point) { return sqrt(norm(point)); }
Point polar(const double r, const double a, const double b) { return Point(r * sin(a) * cos(b), r * sin(a) * sin(b), r * cos(a)); }

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  const double R = 6378.1;
  double a, b, c, d;
  while (cin >> a >> b >> c >> d) {
    if (a == -1 && b == -1 && c == -1 && d == -1) break;
    a /= 180, b /= 180, c /= 180, d /= 180;
    a *= PI, b *= PI, c *= PI, d *= PI;
    Point p = polar(1, PI / 2 - a, b), q = polar(1, PI / 2 - c, d);
    double t = acos(p * q);
    cout << int(round(R * t)) << endl;
  }  

  return 0;
}


Measured memory_bytes: 3440
import heapq, sys
input = sys.stdin.readline
n, q = map(int, input().split())
event = []
for _ in range(n):
    s, t, x = map(int, input().split())
    event.append((s-x, 1, x))
    event.append((t-x, -1, x))

for _ in range(q):
    d = int(input())
    event.append((d, 2, 0))

event.sort(key=lambda x: (x[0], x[1]))
now = []
memo = set()

tmp = 0

for i, (t, flg, x) in enumerate(event):
    if flg == -1:
        memo.remove(x)
    elif flg == 1:
        heapq.heappush(now, x)
        memo.add(x)
    else:
        while len(now) > 0 and now[0] not in memo:
            heapq.heappop(now)
        if len(now) > 0:
            print(now[0])
        else:
            print(-1)

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

struct Unifind{
	vector<int> par;

	Unifind(){}
	Unifind(int n) :
		par(n+1, -1)
	{}
	int root(int x){
		if(par[x] < 0) return x;
		return par[x] = root(par[x]);
	}
	int size(int x){
		return -par[root(x)];
	}
	bool same(int a, int b){
		return root(a) == root(b);
	}
	bool marge(int a, int b){
		a = root(a), b = root(b);
		if(a == b) return false;
		if(par[a] > par[b]) swap(a, b);
		par[a] += par[b];
		par[b] = a;
		return true;
	}
};

int main(){
	llong N, K, L;
	cin >> N >> K >> L;

	Unifind road(N), train(N);
	int p,q;
	for(int i = 0; i < K; i++){
		cin >> p >> q;
		road.marge(p,q);
	}
	int r,s;
	for(int i = 0; i < L; i++){
		cin >> r >> s;
		train.marge(r,s);
	}

	map<P,int> m;
	for(int i = 1; i <= N; i++)
		m[P(road.root(i), train.root(i))]++;

	for(int i = 1; i <= N; i++)
		cout << m[P(road.root(i), train.root(i))] << " ";
	cout << endl;

	return 0;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

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

    int x;
    for(int i = 1; i <= n; i++)
        cin >> x;

    int cnt = 0;
    for(int i = 1; i < n; i += k - 1)
        cnt++;

    cout << cnt << '\n';
    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int sum = 0;
  int L = 1;
  for (int i = 0; i < 1000000000; i++) {
    if (N < L) {
      break;
    }
    else {
      L *= K;
      sum += 1;
    }
  }
  cout << sum << endl;
}

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

using namespace std;



typedef long long ll;

int n;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    if(n % 10 == 7 || n % 100 / 10 == 7 || n / 100 == 7)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 3640
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, A, B = map(int, input().split())
X = list(map(int, input().split()))

ans = 0
for i in range(1, N):
    ans += min((X[i] - X[i - 1]) * A, B)

print(ans)

Measured memory_bytes: 63596
#include <stdio.h>
#include <stdlib.h>

int n = 0;
int tree[2000001];

void insert(int);
void heapincreasekey(int);
void swap(int,int);
void extract(void);
void maxheapfy(int);

int main(){
  int key;
  char function[10];

  while( 1 ){
    scanf("%s",function);
    
    if(function[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }

    if(function[0] == 'e' && function[1] == 'x')  extract();

    if(function[0] == 'e' && function[1] == 'n')  break;
  }

  return 0;
}


void insert(int key){

  n++;
  tree[n] = key;
  heapincreasekey(n);
}

void heapincreasekey(int i){
  
  int p;

  p = i/2;
  if(p >= 1 && tree[i] > tree[p]){
    swap(i,p);
    heapincreasekey(p);
  }
  else return;
}

void swap(int i,int p){
  int box;
  box = tree[i];
  tree[i]=tree[p];
  tree[p]=box;
}

void extract(void){
  printf("%d\n",tree[1]);
  tree[1] = tree[n];
  n--;

  maxheapfy(1);
}


void maxheapfy(int i){
  int l,r,larger;
  l = 2 * i;
  r = l + 1;

  if( l <= n && tree[l] > tree[i]) larger = l;
  else larger = i;
  if( r <= n && tree[r] > tree[larger]) larger = r;

  if(larger != i){
    swap(larger,i);
    maxheapfy(larger);
  }
  else return;
}

Measured memory_bytes: 4696
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        int n = sc.nextInt();
        LinkedList<Integer> b = new LinkedList<>();

        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            if (i % 2 == 0) {
                b.addLast(a);
            } else {
                b.addFirst(a);
            }
        }

        boolean f = true;

        for (int i = 0; i < n; i++) {
            int x = n % 2 == 0 ? b.removeFirst() : b.removeLast();
            if (f) {
                f = false;
                out.print(x);
            } else {
                out.print(" " + x);
            }
        }

        out.println();

        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 98576
#include <iostream>
#include <istream>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

int main() {
  int a[3];
  
  cin >> a[0] >> a[1] >> a[2];
  
  int sum;
  sum = a[0] + a[1] + a[2];
  
  if (sum >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mood;
		}
		x = x * x % mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, a[200000];
int ta[200010];
int ans = INF;

P ni(int x, int y) {
	P res;
	int ma, mi, md;
	int l, r;
	ma = y;
	mi = x;
	l = x - 1;
	r = y;
	while (r - l > 1) {
		md = (ma + mi) / 2;
		if (ta[y] - ta[md] > ta[md] - ta[x - 1]) {
			l = md;
			mi = md;
		}
		else {
			r = md;
			ma = md;
		}
	}
	if ((ta[y] - ta[l]) - (ta[l] - ta[x - 1]) < (ta[r] - ta[x - 1]) - (ta[y] - ta[r])) {
		res = { ta[y] - ta[l] ,ta[l] - ta[x - 1] };
	}
	else res = { ta[r] - ta[x - 1] ,ta[y] - ta[r] };
	return res;
}

signed main() {
	cin >> n;
	ta[0] = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ta[i + 1] = ta[i] + a[i];
	}
	for (int i = 2; i < n - 1; i++) {
		P x = ni(1, i);
		P y = ni(i + 1, n);
		int cnt = max({ x.first,x.second,y.first,y.second }) - min({ x.first,x.second,y.first,y.second });
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}

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

using namespace std;

string s;

vector<int> v;

int n, k, cnt, chk = 1;

int main()
{
	ios::sync_with_stdio(false);
	cin >> s, n = s.size();
	if (s[0] != '1' || s[n - 1] != '0')
		chk = 0;
	for (int i = 0; i < n - 1; i++)
		if (s[i] != s[n - i - 2])
			chk = 0;
	if (!chk)
	{
		cout << -1 << endl;
		exit(0);	
	}
	v.push_back(0);
	for (int i = 0; i < n; i++)
		if (s[i] == '1')
			v.push_back(i + 1);
	v.push_back(n);
	k = v.size() - 1;
	cnt = k;
	for (int i = 1; i <= k; i++)
	{
		if (i != 1)
			cout << i << " " << i - 1 << endl;
		int x = v[i] - v[i - 1] - 1;
		for (int j = 1; j <= x; j++)
			cout << i << " " << ++cnt << endl;
	}
	return 0;	
}


Measured memory_bytes: 1992
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String str=br.readLine();
		for(int i=0;i<str.length();i++){
			String ans=str.substring(i, i+1);
			if(ans.equals(ans.toLowerCase())) ans=ans.toUpperCase();
			else if(ans.equals(ans.toUpperCase())) ans=ans.toLowerCase();
			System.out.print(ans);
		}
		System.out.println("");
	}
}

Measured memory_bytes: 17028
import sys
readline = sys.stdin.readline
from heapq import heapify, heappush, heappop
INF = float("inf")
def MAIN():
    n = int(input())
    adj = [[]] * n
    for _ in range(0, n):
        U = list(map(int, input().split()))
        adj[U[0]] = zip(U[2::2], U[3::2])
    def dijkstra():
        d = [0] + [INF] * (n - 1)
        hq = [(0, 0)]
        while hq:
            u = heappop(hq)[1]
            for v, c in adj[u]:
                alt = d[u] + c
                if d[v] > alt:
                    d[v] = alt
                    heappush(hq, (alt, v))
        print("\n".join(f"{i} {c}" for i, c in enumerate(d)))
    dijkstra()
MAIN()



Measured memory_bytes: 40036
using System;
using System.Linq;

namespace ABC142B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] nk = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int[] h = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Console.WriteLine(h.Where(e => e >= nk[1]).Count());
        }
    }
}


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

int main(){
    int n,m;
    int min_n,max_n;
    int l,r;
    int ans;
    min_n = (1 << 25);
    max_n = -1;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> l >> r;
        max_n = max(max_n,l);
        min_n = min(min_n,r);
    }
    ans = min_n-max_n;
    if(ans < 0)
        cout << 0;
    else 
        cout << ans+1;
    cout << endl;
}


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

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}
			Arrays.sort(a);
			long result = 0;
			for (int i = n - 1; i >= n / 2; i--) {
				result += a[i] * 2;
			}
			if (n % 2 == 1) {
				result -= a[n / 2];
			}
			result -= a[n - 1];
			System.out.println(result);
		}
	}
}


Measured memory_bytes: 60008
n = int(input())
a = len(str(n))
b = 0
c = a//2

if a%2 == 0:
    for j in range(c):
        b += 9*100**j
    print(b)
else:
    for j in range(c):
        b += 9*100**j
    print(n-10**(a-1)+1+b)

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n;
  cin >> n;
  vi a(n);
  vector<vector<P>> test(n);
  rep(i,n) {
    cin >> a[i];
    rep(j,a[i]) {
      int x,y;
      cin >> x >> y;
      x--;
      test[i].emplace_back(x,y);
    }
  }
  int ans = 0;
  for(int i = 0; i < (1<<n); i++) {
    bitset<15> b(i);
    bool ok = true;
    rep(j,n) {
      if(b[j]) {
        for(P p : test[j]) {
          if(b[p.first] != p.second) ok = false;
        }
      }
    }
    if(ok) {
      ans = max(ans, (int)b.count());
    }
  }
  cout << ans << endl;
}

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

int MOD=1000000007LL;
bool used[55][55][55][55];
int dp[55][55][55][55];

struct st{
  int n[4];
  st(){}
  st(int *a){
    for(int i=0;i<4;i++) n[i]=a[i];
  }
  st(int a0,int a1,int a2,int a3){
    n[0]=a0;n[1]=a1;n[2]=a2;n[3]=a3;
  }
};

signed main(){
  int n[4],m;
  for(int i=0;i<4;i++) cin>>n[i];
  cin>>m;
  cin.ignore();
  string s[m];
  for(int i=0;i<m;i++) getline(cin,s[i]);
  string key[m];
  vector<string> v[m];
  for(int i=0,j=0;i<m;i++,j=0){
    while(isalpha(s[i][j])) key[i]+=s[i][j++];
    j++;
    while(j<(int)s[i].size()){
      while(j<(int)s[i].size()&&s[i][j]==' ') j++;
      if(s[i][j]=='['){
	string t;
	j++;
	while(s[i][j]!=']') t+=s[i][j++];
	j++;
	v[i].push_back(t);
      }else{
	string t;
	while(j<(int)s[i].size()&&isalpha(s[i][j])) t+=s[i][j++];
	v[i].push_back(t);
      }
    }
  }
  map<string,int> ms;
  for(int i=0;i<m;i++) ms[key[i]]=i;
  
  int sum=0;
  for(int i=0;i<4;i++) sum+=n[i];
  //cout<<sum<<endl;
  
  int sz[m];
  
  for(int i=m-1;i>=0;i--){
    sz[i]=v[i].size();
    for(int j=0;j<(int)v[i].size();j++){
      if(islower(v[i][j][0])){
	int t=ms[v[i][j]];
	sz[i]+=sz[t]-1;
	if(sz[t]<=sum){
	  v[i].erase(v[i].begin()+j);
	  for(int k=0;k<sz[t];k++){
	    //cout<<v[t][k]<<endl;
	    v[i].insert(v[i].begin()+j+k,v[t][k]);
	  }
	}
      }
    }
    sz[i]=v[i].size();
  }

  /*//
  for(int i=0;i<m;i++){
    cout<<key[i]<<":";
    for(int j=0;j<sz[i];j++) cout<<" "<<v[i][j];
    cout<<endl;
  }
  //*/

  int ans=0;
  map<char,int> mc;
  mc['A']=0;
  mc['T']=1;
  mc['G']=2;
  mc['C']=3;
  
  for(int i=0;i<m;i++){
    //cout<<i<<"+"<<sz[i]<<endl;
    if(sz[i]!=sum) continue;
    memset(used,0,sizeof(used));
    memset(dp,0,sizeof(dp));
    queue<st> q;
    q.push(st(0,0,0,0));
    dp[0][0][0][0]=1;
    while(!q.empty()){
      st p=q.front();q.pop();
      int a[4],x=0;
      for(int j=0;j<4;j++) a[j]=p.n[j],x+=p.n[j];
      if(x==sum) break;
      //cout<<i<<"-"<<x<<":";
      //for(int j=0;j<4;j++) cout<<" "<<a[j];cout<<endl;
      for(int j=0;j<(int)v[i][x].size();j++){
	//cout<<j<<endl;
	int b[4];
	for(int k=0;k<4;k++) b[k]=a[k];
	if(b[mc[v[i][x][j]]]==n[mc[v[i][x][j]]]) continue;
	b[mc[v[i][x][j]]]++;
	(dp[b[0]][b[1]][b[2]][b[3]]+=dp[a[0]][a[1]][a[2]][a[3]])%=MOD;
	if(used[b[0]][b[1]][b[2]][b[3]]) continue;
	q.push(st(b));
	used[b[0]][b[1]][b[2]][b[3]]=1;
      }
    }
    (ans+=dp[n[0]][n[1]][n[2]][n[3]])%=MOD;
  }
  
  cout<<ans<<endl;
  return 0;
}

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

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

    int count = 0;

    while (N != 0)
    {
        if (to_string(N).length() % 2 != 0)
        {
            ++count;
        }
        N -= 1;
    }

    std::cout << count << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
  int main(){
    int N,sum;
    sum = 0;
    cin >> N;
    vector<int>W(N);
    for(int i=0;i<N;i++){
        cin >> W.at(i);
        sum += W.at(i);
    }
    int ans = 100000;
    for(int i=1;i<N+1;i++){ 
         int front = 0;
       for(int j=0;j<i;j++){
         front += W.at(j);
       }
      int a = 2*front - sum;
      int b = sum - 2*front;
      if(a<0 && b<ans){
        ans = b;
      }else if(0<=a && a<ans){
        ans = a;
      }
    }
    
    cout << ans << endl;
  }


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

int main(){

    int n, k; cin >> n >> k;
    vector<long long> x(n);
    for(int i = 0; i < n; i++) cin >> x[i];

    long long ans = 100100100100;
    for(int l = 0; l < n; l++){
        int r = l + k - 1;
        if(r >= n) break;

        ans = min(ans, x[r] - x[l] + min((long long)abs(x[r]), (long long)abs(x[l])));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024