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

int main()
{
    int N, M;
    cin >> N >> M;
    long long H[N];
    bool good[N];
    vector<vector<int>> v(N, vector<int>(0));
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
        good[i] = true;
    }
    int A[M], B[M];
    for (int i = 0; i < M; i++)
    {
        cin >> A[i] >> B[i];
        v[A[i] - 1].push_back(B[i] - 1);
        v[B[i] - 1].push_back(A[i] - 1);
    }
    for (int i = 0; i < N; i++)
    {
        bool is_good = true;
        for (int j : v[i])
        {
            if (H[i] <= H[j])
            {
                is_good = false;
                break;
            }
        }
        if (is_good == false)
        {
            good[i] = false;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if (good[i])
        {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 10132
def resolve():
    n = int(input())
    ans = 0
    for i in range(2, n + 1, 2):
        c = 0
        while i % 2 == 0:
            i //= 2
            c += 1
        if c > ans:
            ans = c
    print(2 ** ans)


if __name__ == "__main__":
    resolve()


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

namespace AtCoder
{
    static class Solver
    {
        static IO io = new IO();

        public static void Solve()
        {

            io.ReadSplit();
            int N = io.Int();
            long K = io.Long();

            P[] plist = new P[N];

            for (int i = 0; i < N; ++i)
            {
                io.ReadSplit();
                plist[i].a = io.Int();
                plist[i].b = io.Int();
            }

            plist = plist.OrderBy(p => p.a).ToArray();
            for (int i = 0; i < N; ++i)
            {
                if (K - plist[i].b <= 0)
                {
                    io.WriteLine(plist[i].a.ToString());
                    break;
                }
                else
                {
                    K -= plist[i].b;
                }
            }
        }
    }
    public struct P
    {
        public int a;
        public int b;
    }
}
namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            Solver.Solve();
        }
    }
    class IO
    {
        private string[] _Inputs;
        private int _Index;
        public void Read()
        {
            _Inputs = new string[1];
            _Inputs[0] = Console.ReadLine();
            _Index = 0;
        }
        public void ReadSplit()
        {
            _Inputs = Console.ReadLine().Split(' ');
            _Index = 0;
        }
        public string String()
        {
            return _Inputs[_Index++];
        }
        public string[] String(int xCount)
        {
            string[] rv = new string[xCount];
            Array.Copy(_Inputs, _Index, rv, 0, xCount);
            _Index += xCount;
            return rv;
        }
        public int Int()
        {
            return int.Parse(_Inputs[_Index++]);
        }
        public int[] Int(int xCount)
        {
            int[] rv = new int[xCount];
            for (int i = 0; i < xCount; ++i)
            {
                rv[i] = int.Parse(_Inputs[_Index++]);
            }
            return rv;
        }
        public long Long()
        {
            return long.Parse(_Inputs[_Index++]);
        }
        public long[] Long(int xCount)
        {
            long[] rv = new long[xCount];
            for (int i = 0; i < xCount; ++i)
            {
                rv[i] = long.Parse(_Inputs[_Index++]);
            }
            return rv;
        }
        public void Write(string xStr)
        {
            Console.Write(xStr);
        }
        public void WriteLine(string xStr)
        {
            Console.WriteLine(xStr);
        }
    }
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}


void smain() {

    int n,k;
    cin>>n>>k;
    int u=n/2+n%2;

    if(u>=k)
        cout<<"YES\n";
    else
        cout<<"NO\n";



}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int n;
    cin >> n;
    set<string> se;
    rep(i, n){
        string s;
        cin >> s;
        se.insert(s);
    }
    cout << se.size() << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 19120
#include <iostream>

using namespace std;

long long dp[101][100001];
int main()
{
    long long n,k;
    cin>>n>>k;
    long long children[n];
    for(int i=0;i<n;i++)
    {
        cin>>children[i];
    }
    dp[0][0]=1;
    for(int i=0;i<n;i++)
    {
        long long prefix[k+2];
        prefix[0]=0;
        for(long long j=1;j<=k+1;j++)
        {
            prefix[j]=(prefix[j-1]+dp[i][j-1])%1000000007;
        }
        for(long long j=0;j<=k;j++)
        {
            long long bla=(prefix[j+1]-prefix[max((long long)(0),j-children[i])])%1000000007;
            if(bla<0)
            {
                bla+=1000000007;
            }
            dp[i+1][j]=bla;
        }
    }
    cout<<dp[n][k]<<endl;
}


Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
string str;
bool flag;
int main()
{
	cin>>str;
	for(int i=0;i<str.length();i++)
	{
		if(str[i]=='C')flag=1;
		if(str[i]=='F'&&flag)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

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

vector<int> h;
int dp[(int)1e5 + 5];
int n, k;

int solve(int i) {
    if (i == n - 1) {
        return 0;
    } else if (i >= n)
        return 1e9;

    if (dp[i] == -1) {
        int mini = 1e9;
        for (int j = i + 1; j <= min(i + k, n - 1); j++) {
            mini = min(mini, solve(j) + abs(h[j] - h[i]));
        }
        dp[i] = mini;
    }
    return dp[i];
}

int main(void) {
    memset(dp, -1, sizeof(dp));
    cin >> n >> k;
    h.resize(n);
    for (auto &i : h)
        cin >> i;
    h.push_back(0);
    cout << solve(0) << "\n";
}

Measured memory_bytes: 7288
#include<iostream>
#include<string.h>
#include<string>
using namespace std;
int main()
{
	int n;
	int num[3005];
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>num[i];
	}
	int sum = 0;
	for(int i=0;i<n;i++)
	{
		sum+=num[i]-1;
	}
	cout<<sum<<endl;
	return 0;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    if(n % 2 == 1) {
        if(k <= n / 2 + 1)cout << "YES" << endl;
        else cout << "NO" << endl; 
    } else {
        if(k <= n / 2)cout << "YES" << endl;
        else cout << "NO" << endl; 
    }
    return 0;
}

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

using namespace std;

int main()
{
	int a,b;
	cin>>a>>b;
	int maxx=0;
	for(int i=1;i<=b;i++){int x;cin>>x;maxx=max(maxx,x);}
	cout<<max(maxx*2-a-1,0)<<endl;
}

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

int main(){
  int n; cin >> n;
  vector<string> data(n);
  for(int i=0; i<n; i++) cin >> data[i];
  sort(data.begin(),data.end());
  vector<string> ans1(1,data[0]);
  vector<int> ans2(1,1);
  for(int i=1; i<n; i++){
    if(data[i-1]==data[i]){
      ans2[ans2.size()-1]++;
    }
    else{
      ans1.push_back(data[i]);
      ans2.push_back(1);
    }
  }
  int makkusu=0;
  for(int i=0; i<ans2.size(); i++) makkusu =max(makkusu,ans2[i]);
  for(int i=0; i<ans2.size(); i++)
    if(ans2[i]==makkusu)
      cout << ans1[i] << endl;
}
    

Measured memory_bytes: 17652
N = int(input())
A = list(map(int,input().split()))
ans = 1


if 0 in A:
    ans = 0
else:
    for i in range(N):
        ans = ans * A[i]
        if ans > 10**18:
            ans = -1
            break

    
print(ans)
    
    
    
    

Measured memory_bytes: 21772
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int group(int a){
  if(a==2) return 2;
  if(a==4 || a==6 || a==11 || a==9) return 4;
  return 1;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int x,y;
  cin >> x >> y ;
  bool flag= group(x)==group(y);
  cout << (flag?"Yes":"No") << endl;
  return 0;
  
  /*int a[] ={0,1,2,1,4,1,4,1,1,4,1,4,1};
  int x,y;
  cin >> x >> y;
  cout << (a[x]==a[y]?"Yes":"No") << endl;
  return 0;*/
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp std::make_pair
#define pb push_back
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::set<int> si;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N;
ll A[100010];
int main(){
  cin>>N;
  rep(i,N) cin>>A[i];
  std::sort(A,A+N);
  ll sum[100010];
  sum[0]=0;
  rep1(i,N){
    sum[i]=sum[i-1]+A[i-1];
  }
  int cnt=1;
  for(int i=N-1;i>=0;i--){
    if(2*sum[i]>=A[i]) cnt++;
    else break;
  }
  prin(cnt);
  return 0;
}


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

int func(int i) {
  if (i < 10)
    return i;
  return func(i / 10) + (i % 10);
}

int main() {
  int N;
  cin >> N;
  if (N % func(N) == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  int antena=e-a;
  if(antena>k){
    cout<<":("<<endl;
  }else{
    cout<<"Yay!"<<endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
	private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public static void main(String[] args) throws Exception {
		int n = Integer.parseInt(br.readLine());
		
		int count = 0;
		for(int i = 0; i < n; i++){
			int num = Integer.parseInt(br.readLine());
			if(num == searchMinDivisor(num)){
				count++;
			}
		}
		
		System.out.println(count);
	}
	
	public static long searchMinDivisor(long n){
		long p;
		boolean isSucceed = false;
		for(p = 2; p * p <= n; p++){
			if(n % p == 0){
				isSucceed = true;
				break;
			}
		}
		if(!isSucceed){
			p = n;
		}
		return p;
	}
}



Measured memory_bytes: 27540
#include<iostream>

#define MAX 50
using namespace std;
void check(char a[MAX][MAX+1],char b[MAX][MAX+1],int n, int m);
bool check2(char a[MAX][MAX+1],char b[MAX][MAX+1],int n, int m, int k, int l);
int main(){
	int n,m;
	int i,j;
	char a[MAX][MAX+1],b[MAX][MAX+1];
	
	cin >> n >> m;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	
	for(i=0;i<m;i++){
		cin >>b[i];
	}
	check(a,b,n,m);
	return 0;
}
void check(char a[MAX][MAX+1],char b[MAX][MAX+1],int n, int m){
	int i,j,k,l;
	bool flag;
	for(i=0; i<=n-m;i++){
		for(j=0;j<=n-m;j++){
			if(check2(a,b,n,m,i,j)){
				cout << "Yes" <<endl;
				return;
			}
		}
	}
	cout << "No" << endl;
}
bool check2(char a[MAX][MAX+1],char b[MAX][MAX+1],int n, int m, int k, int l){
	int i,j;
	
	for(i=0; i<m;i++){
		for(j=0; j<m;j++){
			if( a[i+k][j+l] != b[i][j])
				return false;
		}
	}
	return true;
}

Measured memory_bytes: 256
class in{struct myIterator{int it;const bool rev;explicit constexpr myIterator(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(myIterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const myIterator i,n;public:explicit constexpr in(int n):i(0),n(n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const myIterator& begin(){return i;}const myIterator& end(){return n;}};

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

using i64 = long long;
const int INF = 1e9;
int dp[301][301];
int cost[301][301];

int calc(const vector<string>& fld, int pos) {
    memset(dp, 0, sizeof(dp));
    memset(cost, 0, sizeof(cost));
    int h = fld.size();
    for(int i : in(1, h + 1)) for(int j : in(1, h + 1)) {
        cost[i][j] = cost[i - 1][j - 1];
        if(fld[i - 1][pos] == fld[j - 1][pos + 1])
          ++cost[i][j];
    }
    for(int i : in(h + 1)) for(int j : in(h + 1)) {
        if(i == 0 || j == 0) {
            dp[i][j] = 0;
            continue;
        }
        int& res = dp[i][j];
        dp[i][j] = INF;
        res = min(res, dp[i - 1][j] + cost[i][j]);
        res = min(res, dp[i][j - 1] + cost[i][j]);
    }
    return dp[h][h];
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> fld(h);
    for(auto& x : fld) cin >> x;
    int sum = 0;
    for(int i : in(w - 1))
      sum += calc(fld, i);
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1152
// Problem : C - Skill Up
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int c[12], a[12][12];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    int n, m, x;
    cin >> n >> m >> x;
    for (int i=0; i<n; i++) {
        cin >> c[i];
        for (int j=0; j<m; j++)
            cin >> a[i][j];
    }
    
    int ret = INT_MAX;
    for (int mask=0; mask<1<<n; mask++) {
        int cost = 0;
        vector<int> level(m);
        for (int i=0; i<n; i++)
            if (mask & (1 << i)) {
                cost += c[i];
                for (int j=0; j<m; j++)
                    level[j] += a[i][j];
            }
        
        bool ok = true;
        for (int j=0; j<m; j++)
            ok &= (level[j] >= x);
        
        if (ok)
            ret = min(ret, cost);
    }
    
    cout << (ret == INT_MAX ? -1 : ret) << "\n";

    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
int n, *A;

int partition(int p, int r)
{
	int x = A[r];
	int i = p-1;
	int swap = 0;
	for(int j = p; j <= r-1; j++)
	{
		if(A[j] <= x)
		{
			i +=1;
			swap = A[i];
			A[i] = A[j];
			A[j] = swap;
		}
	}
	swap = A[i+1];
	A[i+1] = A[r];
	A[r] = swap;
	return i+1;
}

int main()
{
	//input
	scanf("%d", &n);
	A = (int  *)malloc(n * sizeof(int));
	for(int i = 0; i<n ; i++) scanf("%d", &A[i]);
	int ass = partition(0, n-1);
	
	for(int i = 0; i<n ; i++) 
	{
		if(i!=ass) printf("%d", A[i]);
		else printf("[%d]", A[i]);
		if(i!=n-1) printf(" ");
	}
	printf("\n");
	free(A);//smart boi
	return 0;
}


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

vector<int> color;
vector< vector< pair<int,int> > > adj;

void dfs(int u, int p, int s) {
    if (s % 2 == 0) color[u] = 1;
    for (auto& r : adj[u]) {
        int v = r.first;
        int w = r.second;
        if (v != p)
            dfs(v, u, s + w);        
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    int N;
    cin >> N;
    color.resize(N, 0);
    adj.resize(N);
    for (int i = 0; i < N-1; ++i) {
        int u, v, w;
        cin >> u >> v >> w;
        --u; --v;
        adj[u].push_back({v, w});
        adj[v].push_back({u, w});
    }

    dfs(0, -1, 0);

    for (int i = 0; i < N; ++i) {
        cout << color[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 8192
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	int n;
	cin >> n;
	cout << (n + 1) / 2 << endl;

	return 0;
}


Measured memory_bytes: 3092
#include <iostream>

using namespace std;

int main(){
    int n,m,s[1000],t[1000];
    while(cin>>n>>m,n){
        for(int i=0;i<n;++i) cin>>s[i];
        for(int i=0;i<m;++i) cin>>t[i];
        int sum=0,c=0;
        while(sum<(n-1)){
            sum += t[c]+s[sum+t[c]];
            ++c;
        }
        cout<<c<<endl;
    }
    return 0;
}

Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.nextLine().toCharArray();
		//
		long sum = 0;
		int l = S.length-2;
		for (int i=0; i<S.length; i++) {
			for (int j=l; j>=i; j--) sum += (S[i]-'0') * Math.pow(10, l-j) * (1<<j);
			sum += (S[i]-'0') * Math.pow(10, l-i+1) * (1<<i);
		}
		System.out.println(sum);
		sc.close();
	}

}


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

int main(){
  string S; cin >> S;
  int n = S.size();
  int ans = 1e9;
  for(int i = 0; i < n-2; i++){
    int a = (S[i] - '0')*100 + (S[i+1] - '0')*10 + (S[i+2]-'0');
    int b = abs(a-753);
    ans = min(ans,b);
  }
  cout << ans << endl;
}


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

int main(void)
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int num=1;
    for(int i=0;i<k;i++){
        num*=2;
    }
    int x=a*num+b+c;
    int y=a+b*num+c;
    int z=a+b+c*num;

    if(x>=y&&x>=z){
        cout<<x<<endl;
     }
    else if(y>=x&&y>=z){
        cout<<y<<endl;
    }else {
        cout<<z<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int R;
  cin >> R;
  cout << fixed << setprecision(12) << acos(-1) * 2 * R << endl;
  return 0;
}


Measured memory_bytes: 3744
// AtCoderTemplate.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<cstdio>
#include<iomanip>
#include<cmath>

using namespace std;

typedef long long ll;

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

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

	int count = 0;
	rep(i, n)
	{
		int h;
		cin >> h;

		if (h >= k) count++;
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
x=input()
l=len(x)
ans=0
q=[]
for i in range(l):
    if x[i]=='S':
        q.append(x[i])
    else:
        if not q or q[-1]=='T':
            q.append(x[i])
        else:
            q.pop()
            ans+=1
print(l-ans*2)


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

int main()
{
int inp;
cin>>inp;
string s="";
if(inp==0)
{
cout<<"0";
return 0;
}

while(inp!=0)
{
int k=abs(inp)%2;
if(k==0)
 s="0"+s;
else { 
  s="1"+s;
  inp--;
  }
inp=inp/-2;

}
cout<<s;
return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

int main(){

	int A,N;
	scanf("%d",&A);

	for(N = 1; ; N++){
		if(((N-1)*N)/2 < A && (N*(N+1))/2 >= A)break;
	}

	int count = 0;

	for(int i = 0; i < N-((N*(N+1))/2-A);i++){
		printf(")");
		count++;
	}
	printf("(");

	for(; count < N; count++)printf(")");
	for(int i = 1; i <= N-1; i++)printf("(");
	printf("\n");

	return 0;
}

Measured memory_bytes: 2664
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(true){
			int k = in.nextInt();
			if(k==0)break;
			int n = k*(k-1)/2;
			//System.out.println(n);
			int sum=0;
			//int data[] = new int[101];
			for(int i=0;i<n;i++){
				sum+=in.nextInt();
			}
			int ans=sum/(k-1);
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 60308
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _stridx{
	char word[1000];
	struct _stridx *right;
	struct _stridx *left;
	int cnt;
} STRIDX;

STRIDX *createNODE(char *str);
void ADDNODE(STRIDX *P,char *str);
void searchFREQ(STRIDX *node,char *str,int *f);
void searchLONGEST(STRIDX *node,char *str,int *f);

int main(){

	char str[1002];
	char *p,*q;
	char token[1000];
	char longest[1000];
	char freq[1000];
	STRIDX *TOP;

	scanf("%[^\n]\n",str);
	p=str;
	q=p;

	if( (TOP = (STRIDX *)malloc(sizeof(STRIDX)))==NULL){
		printf("malloc error\n");
		exit(1);
	}
	TOP->word[0]='\0';
	TOP->right=NULL;
	TOP->left=NULL;
	TOP->cnt=-1;
	
//	TOP=createNODE(NULL);
	while(*p!='\0'){
		p++;
		if(*p==' '||*p=='\0'){
			*p='\0';
			strcpy(token,q);
			q=p+1;
			p=q;
			ADDNODE(TOP,token);
		}
	}
	
	int f;
	f=0;
	searchFREQ(TOP,freq,&f);
	f=0;
	searchLONGEST(TOP,longest,&f);
	
	printf("%s ",freq);
	printf("%s\n",longest);
	
	
	return 0;
}

STRIDX *createNODE(char *str){
	STRIDX *node;
	if( (node = (STRIDX *)malloc(sizeof(STRIDX)))==NULL){
		printf("malloc error\n");
		exit(1);
	}
	strcpy(node->word,str);
	node->cnt=1;
	node->right=NULL;
	node->left=NULL;
	return node;
}

void ADDNODE(STRIDX *P,char *str){
	
	STRIDX *node;
	int c,i;
	
	c=strcmp(P->word,str);
	if(c==0){
		P->cnt+=1;
		return;
	}
	if(c<0){
		if(P->left==NULL){
			node=createNODE(str);
			P->left=node;
		} else {
			ADDNODE(P->left,str);
		}
	}
	if(c>0){
		if(P->right==NULL){
			node=createNODE(str);
			P->right=node;
		} else {
			ADDNODE(P->right,str);
		}
	}
	return;
}
	
	
void searchFREQ(STRIDX *node,char *str,int *f){

	if(node==NULL)return;
	
	if(node->cnt>=*f){
		*f=node->cnt;
		strcpy(str,node->word);
	}
	searchFREQ(node->left,str,f);
	searchFREQ(node->right,str,f);
	
	return;
}
void searchLONGEST(STRIDX *node,char *str,int *f){
	if(node==NULL)return;
	
	if(strlen(node->word)>=*f){
		*f=strlen(node->word);
		strcpy(str,node->word);
	}
	searchLONGEST(node->left,str,f);
	searchLONGEST(node->right,str,f);
	
	return;
}
	
	

Measured memory_bytes: 628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(stdin.readLine());
        int[] a = Pattern.compile(" ").splitAsStream(stdin.readLine()).mapToInt(Integer::parseInt).toArray();

        int[] b = new int[n + 1];
        TreeSet<Integer> set = new TreeSet<>();
        for (int i = 0; i < n; i++) b[a[i]] = i + 1;
        set.add(0);
        set.add(n + 1);

        long ans = 0L;
        for (int i = 1; i <= n; i++) {
            long lo = set.lower(b[i]);
            long hi = set.higher(b[i]);
            ans += (b[i] - lo) * (hi - b[i]) * i;
            set.add(b[i]);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 55472
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, char>
#define fi first
#define se second

vector<ii> points;

ii get(char s)
{
    ii ans = {0, '.'};
    for(ii &w : points)
        if(w.se == 'r' and s == 's')
            ans = w;
        else if(w.se == 's' and s == 'p')
            ans = w;
        else if(w.se == 'p' and s == 'r')
            ans = w;
    return ans;
}

int32_t main()
{
    string str;
    int n, m, k;
    cin >> n >> k;
    points.resize(3);
    for(ii &w : points) cin >> w.fi;
    points[0].se = 'r';
    points[1].se = 's';
    points[2].se = 'p';
    sort(points.rbegin(), points.rend());
    cin >> str;
    
    int ans = 0;
    vector<char> last(n);
    for(int i = 0; i < n; i++)
    {
        ii j = get(str[i]);
        if(i >= k and (last[i - k] != j.se or last[i - k] == '.'))
            ans += j.fi, last[i] = j.se;
        else if(i < k)
            ans += j.fi, last[i] = j.se;
        else
            last[i] = '.';
    }
    cout << ans << '\n';


	return 0;
}

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

int main(){
    int A, B;
    int d,e,f;

    cin >> A >> B;
    
    d = A+B;
    e = A-B;
    f = A*B;

    if(d>=e && d>=f){
        cout << d << endl;
    }else if(e>=d && e>=f){
        cout << e << endl;
    }else{
        cout << f << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    static tree[] wd;
	public static void main(String[] args) {
	    int x,i,j,n,root = 0,hz;
	// TODO Auto-generated method stub
     Scanner sca = new Scanner(System.in);
     n=sca.nextInt();
     wd=new tree[n];
     int[]checkmap=new int[n+1];
    for(j=0;j<n;j++){
    	x=sca.nextInt();
	if(j==0)root=x;
	wd[x]=new tree(x);
	for(i=0;i<2;i++){
	    hz=sca.nextInt();
	    if(i==0){
            wd[x].setleft(hz);
	    }else{
	    wd[x].setright(hz);
	    }
	    if(hz==-1)hz=n;
	checkmap[hz]=1;
	}
    }
    for(j=0;j<n;j++){
	if(checkmap[j]!=1)root=j;
    }
    chain(root,-1);
    System.out.println("Preorder");
    preorder(root);
    System.out.println("\nInorder");
    inorder(root);
    System.out.println("\nPostorder");
    postorder(root);
    System.out.println("");
   }
    public static void preorder(int nd){
	System.out.print(" "+wd[nd].getnode());
	if(wd[nd].getleft()!=-1)preorder(wd[nd].getleft());
	if(wd[nd].getright()!=-1)preorder(wd[nd].getright());
    }
    public static void inorder(int nd){
	if(wd[nd].getleft()!=-1)inorder(wd[nd].getleft());
	System.out.print(" "+wd[nd].getnode());
	if(wd[nd].getright()!=-1)inorder(wd[nd].getright());
    }
    public static void postorder(int nd){
	if(wd[nd].getleft()!=-1)postorder(wd[nd].getleft());
	if(wd[nd].getright()!=-1)postorder(wd[nd].getright());
	System.out.print(" "+wd[nd].getnode());
    }
    public static void chain(int chi,int p){
	int i;
	wd[chi].setpar(p);
	if(wd[chi].getdeg()==0)return;
	if(wd[chi].getleft()!=-1) chain(wd[chi].getleft(),chi);
	if(wd[chi].getright()!=-1)chain(wd[chi].getright(),chi);
	}
}
class tree{
    int node,par,n,i,degree=0;
    int left,right;
    tree(int node){
	this.node=node;
    }
    public int getnode(){
	return node;
    }
    public void setleft(int c){
	left=c;
	if(left!=-1) degree++;
    }
    public int getleft(){
	return left;
    }
    public void setright(int c){
	right=c;
	if(right!=-1) degree++;
    }
    public int getright(){
	return right;
    }
    public void setpar(int p){
	par=p;
    }
    public int getpar(){
	return par;
    }
    public int getdeg(){
	return degree;
    }
    
}



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

signed main() {
  lint N; cin >> N;
  vector<lint> a(N);
  lint ans = 0, sum = 0;
  for(int i = 0; i < N; i++){
    cin >> a[i];
    if(a[i] == 0){
      ans += sum/2;
      sum = 0;
    }
    sum += a[i];
  }
  ans += sum/2;
  cout << ans << endl;
}

Measured memory_bytes: 1024
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
N = inp.shift() * 1
_dividers = function(n) {
  var arr = []
  for (var i = 1; i*i <= n; i++) {
     if (n % i === 0) {
       arr.push(i)
       if ( i != n / i) {
         arr.push(n / i)
       }
     }
  }
  return arr.sort((a, b) => a - b)
}
d = _dividers(N)
min = N.toString().length
for (i=0; i<d.length; i++) {
  b = d[i]
  a = N / b
  m = a > b ? a.toString().length : b.toString().length
  if (min > m) {
      min = m
  }
}
console.log(min)

Measured memory_bytes: 21064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    vector<ll> sum(n+1);
    rep(i, n) {
        sum[i+1] = sum[i] + a[i];
    }

    ll ans = sum[n];
    for(int i = 2; i < n-1; i++) {
        ll val[4];
        auto itr = lower_bound(all(sum), sum[i]>>1);
        if(itr-sum.begin() != i) {
            val[0] = *itr;
            val[1] = sum[i] - val[0];
            itr--;
            if(itr != sum.begin() and val[0]-val[1] > sum[i]-2*(*itr)) {
                val[0] = *itr;
                val[1] = sum[i] - val[0];
            }
        } else {
            itr--;
            val[0] = *itr;
            val[1] = sum[i] - val[0];
        }
        itr = lower_bound(all(sum), (sum[n]+sum[i])>>1);
        if(itr != sum.end()) {
            val[2] = *itr - sum[i];
            val[3] = sum[n] - *itr;
            itr--;
            if(itr != sum.begin()+i and val[2]-val[3] > sum[n]+sum[i]-2*(*itr)) {
                val[2] = *itr - sum[i];
                val[3] = sum[n] - *itr;
            }
        } else {
            itr--;
            val[2] = *itr - sum[i];
            val[3] = sum[n] - *itr;
        }
        chmin(ans, *max_element(val, val+4) - *min_element(val, val+4));
    }

    cout << ans << endl;
}

Measured memory_bytes: 5580
s = input()
n = int(s)

answer = False
x = n

h = []
while (x > 0):
    h.append(x % 10)
    x = int(x / 10)



f = 0

for i in range(len(h)):
    f += h[i]

if n % f == 0:
    answer = True

if answer:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
using namespace std;
int main(){
int n;
cin>>n;
ll dp[n+1][3]={};
rep(i,n){
    int a,b,c;
    cin>>a>>b>>c;
    dp[i+1][0]=max(dp[i][1]+a,dp[i][2]+a );
    dp[i+1][1]=max(dp[i][0]+b,dp[i][2]+b );
    dp[i+1][2]=max(dp[i][0]+c,dp[i][1]+c );



   }
cout<<max({dp[n][0],dp[n][1],dp[n][2]})<<endl;
return 0;

}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

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

int H, W;
int sx, sy, gx, gy;
vector<string> fi;
using pint = pair<int,int>;

long long solve() {
    deque<pint> que;
    vector<vector<int>> dist(H, vector<int>(W, -1));
    dist[sx][sy] = 0;
    que.push_front(pint(sx, sy));
    while (!que.empty()) {
        auto cur = que.front();;
        que.pop_front();
        int x = cur.first, y = cur.second;
        //cout << x << ", " << y << ": " << dist[x][y] << endl;
        for (int dir = 0; dir < 4; ++dir) {
            int nx = x + dx[dir], ny = y + dy[dir];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (fi[nx][ny] == '#') continue;
            if (dist[nx][ny] == -1) {
                dist[nx][ny] = dist[x][y];
                que.push_front(pint(nx, ny));
            }
            else if (chmin(dist[nx][ny], dist[x][y])) {
                que.push_front(pint(nx, ny));
            }
        }
        for (int nx = x - 2; nx <= x + 2; ++nx) {
            for (int ny = y - 2; ny <= y + 2; ++ny) {
                if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
                if (fi[nx][ny] == '#') continue;
                if (dist[nx][ny] == -1) {
                    dist[nx][ny] = dist[x][y] + 1;
                    que.push_back(pint(nx, ny));
                }  
                else if (chmin(dist[nx][ny], dist[x][y] + 1)) {
                    que.push_front(pint(nx, ny));
                } 
            }
        }
    }
    return dist[gx][gy];
}

int main() {
    while (cin >> H >> W >> sx >> sy >> gx >> gy) {
        --sx, --sy, --gx, --gy;
        fi.resize(H);
        for (int i = 0; i < H; ++i) cin >> fi[i];
        cout << solve() << endl;
    }
}

Measured memory_bytes: 9504
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int a = 0, b = 0, x = 0;
  cin >> a >> b;
  x = (a+b)/2;
  if((a+b)%2 == 0){
    x = (a+b)/2;}
  else{
    x = (a+b)/2+1;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        var L = int.Parse(input[0]);
        var R = int.Parse(input[1]);

        int ans = 2019;
        for (var v = L; v < R; v++)
        {
            for (var w = v+1; w <= R; w++)
            {
                ans = Math.Min(ans, ((v % 2019) * (w % 2019)) % 2019);
                if (ans == 0) break;
            }
            if (ans == 0) break;
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 2e18;

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

  ll a, b, k;
  cin >> a >> b >> k;

  if (k <= a)
  {
    a -= k;
  }
  else
  {
    k -= a;
    a = 0;
    b -= k;
  }
  b = max <ll> (b, 0);
  cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int main(void){
  int cnt[3] = {};
  string S; cin >> S;
  for (auto c : S)
    ++cnt[c - 'a'];
  int mn = min({cnt[0], cnt[1], cnt[2]});
  int mx = max({cnt[0], cnt[1], cnt[2]});
  if (mx - mn <= 1) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	int n;cin>>n;
	map<string,int>mp;
	rep(i,n){
		string s;cin>>s;
		sort(s.begin(),s.end());
		mp[s]++;
	}
	ll ans=0;
	for(auto p:mp){
		ans+=p.second*(ll)(p.second-1)/2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin>>N;
  int sum=0;
  int T[N];
  for(int i=0;i<N;i++){
    cin>>T[i];
    sum+=T[i];
  }
  int M;
  cin>>M;
  int P[M],X[M];
  for(int i=0;i<M;i++){
    cin>>P[i]>>X[i];
  }
  
  for(int i=0;i<M;i++){
    cout<<(sum-T[P[i]-1]+X[i])<<endl;
  }
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int loop = Math.max(a, b);
		int print = Math.min(a, b);
		for (int i=0;i<loop;i++) {
			System.out.print(print);
		}

	}
}

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

const int N=205,MX=10000010;
int n,m,mx,ma,mb,a[N],b[N],e[N][N],vis[N],lmat[N],rmat[N],B[MX],p[MX/10],ans;

void add(int x){if (x&1)  a[++ma]=x;  else  b[++mb]=x;}

bool dfs(int x)
{
	for (int y=1; y<=mb; y++)
		if ((e[x][y])&&(vis[y]!=vis[0]))
			{
				vis[y]=vis[0];
				if ((!rmat[y])||(dfs(rmat[y])))  return lmat[x]=y,rmat[y]=x,1;
			}
	return 0;
}

void work()
{
	scanf("%d",&n);
	for (int i=1,x,y=-1; i<=n+1; i++)
		{
			if (i<=n)  scanf("%d",&x),mx=max(mx,x+1);
			if ((i!=1)&&(y+1!=x))  add(y+1);
			if ((i<=n)&&(y+1!=x))  add(x);
			y=x;
		}
	B[1]=1;
	for (int i=1; i<=mx; i++)
		{
			if (!B[i])  p[++m]=i;
			for (int j=1; j<=m&&i*p[j]<=mx; j++)
				{
					B[i*p[j]]=1;
					if (i%p[j]==0)  break;
				}
		}
	for (int i=1; i<=ma; i++)
		for (int j=1; j<=mb; j++)
			e[i][j]=!B[abs(a[i]-b[j])];
	for (int i=1; i<=ma; i++)  if (vis[0]++,dfs(i))  ans++;
	ans+=(ma-ans)/2*2+(mb-ans)/2*2+((ma-ans)&1)*3;
	printf("%d",ans);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 43264
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    string s;
    cin >> n >> s >> k;
    char c = s[k-1];
    for (int i = 0; i < n; i++)
    {
        if (s[i] != c)
        {
            s[i] = '*';
        }
    }
    cout << s << endl;
}

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

int abs(int n)
{
    if (n >= 0)
        return n;
    else
        return -n;
}

int main()
{
    int N;
    cin >> N;
    int h[N + 1];
    FOR1(i, N)
    {
        cin >> h[i];
    }
    int dp[N + 1];
    FOR1(i, N)
    {
        dp[i] = 0;
    }

    FOR(i, 2, N)
    {
        if (i == 2)
        {
            dp[i] = dp[i - 1] + abs(h[i - 1] - h[i]);
        }
        else
        {
            dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 1024
#整数の入力
N = int(input())
#スペース区切りの整数の入力リスト
A_list = list(map(int, input().split()))

ans = 0
  
  
ans_list = [0]*N
  
for i in range(len(A_list)):
  #ans = A_list.count(i+1)
  ans_list[A_list[i]-1]+=1


for i in range(len(ans_list)):
  print(ans_list[i])

Measured memory_bytes: 32368
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use std::mem::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::usize;

#[allow(unused_macros)]
macro_rules! read_cols {
    ($($t:ty),+) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();

        let mut it = line.trim()
            .split_whitespace();

        ($(
            it.next().unwrap().parse::<$t>().ok().unwrap()
        ),+)
    }}
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    line.trim().to_string().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

    line.trim()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let s = read::<String>();
    
    let remains = s.chars().fold((0, 0), |(r, b), c| {
        if c == '0' /* red */ {
            if b > 0 {
                (0, b - 1)
            } else {
                (r + 1, 0)
            }
        } else /* blue */ {
            if r > 0 {
                (r - 1, 0)
            } else {
                (0, b + 1)
            }
        }
    });
    
    println!("{}", s.len() - remains.0 - remains.1);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll a,b,x;
	cin >> a >> b >> x;
	ll ans=0;
	ll c=b/x;
	if(a%x)
	{
		cout << c-(a/x);
	}
	else
	{
		cout << c-(a/x)+1;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int a,b,c,d; cin >>a>>b>>c>>d;
    if (a+b > c+d)
    {
        cout << "Left\n";
    } else if ( a+b == c+d) {
        cout << "Balanced\n";
    } else {
        cout << "Right\n";
    }
    return 0;
}

Measured memory_bytes: 256
fun main() {
    val s = readLine()?.toList() ?: listOf()
    val t = readLine()?.toList()?:  listOf()

    var index  = 0
    s.forEachIndexed { idx, value ->
        if (value === t[idx]) {
            index++
        }
    }

    println(s.size - index)
}

Measured memory_bytes: 43684
#include<stdio.h>
#define M 251

int main(){
  int i,h,heap[M];
  scanf("%d",&h);
  for(i=1;i<=h;i++)
    scanf("%d",&heap[i]);
  for(i=1;i<=h;i++){
    printf("node %d: key = %d, ",i,heap[i]);
    if(i/2) printf("parent key = %d, ",heap[i/2]);
    if(2*i<=h) printf("left key = %d, ",heap[2*i]);
    if(2*i+1<=h) printf("right key = %d, ",heap[2*i+1]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
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;
}

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define F first
#define S second

typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1000000;
const int minf = -1000000;
const ll lnf = 1e12;
const ll mlnf = -1e12;

void debug_vector(vector<int>& v)
{
    int n = v.size();
    for (int i = 0; i < n; i++) {
        cout << v[i] << " ";
    }
    cout << endl;
}

void solve();

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

void solve()
{
    int N;
    std::cin >> N;
    std::vector<int> S(N);
    rep(i, N) cin >> S[i];
    int q;
    cin >> q;
    std::vector<int> T(q);
    rep(i, q) cin >> T[i];
    sort(all(S));
    int ans = 0;
    for (auto t : T) {
        if (binary_search(all(S), t))
            ans++;
    }
    cout << ans << endl;
}



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

int main()
{
	int n;
	cin>>n;
	
	if(n<1 || n>100)
		return 0;
	
	vector<int> v;
	int a;
	
	for(int i=0;i<n;)
	{
		cin>>a;
		if(a>=1 && a<=100)
		{
			v.push_back(a);
			i++;
		}
			
	}
	
	sort(v.begin(),v.end());
	
	int suma=0;
	
	bool im=true;
	
	for(int i=n-1;i>=0;i--)
	{
			if(im==true)
			{	suma+=v[i];			
				im=false;
			}
			else
			{
				suma-=v[i];
				im=true;
			}	
	}
	
	if(suma<0)
		suma*=(-1);	
	
	cout<<suma;
	
	return 0;
}

Measured memory_bytes: 256
import sys


def solve(inp):
    A = list(map(int, inp.readline().strip().split(' ')))

    if A[0] <= A[2] <= A[1]:
        return "Yes"
    else:
        return "No"


def main():
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940