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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m,d;
char field[105][105];

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

int check(int a, int b){
	int ret = 0;
	for (int i = 0;i < 4;i++){
		int ni = a, nj = b;
		for (int j = 0;j < d-1;j++){
			ni += dx[i]; nj += dy[i];
			if(ni < 0 || nj < 0 || ni >= n || nj >= m || field[ni][nj] == '#') break;
			if(j == d-2) ret++;
		}
	}

	return ret;
}

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

	cin >> n >> m >> d;

	for (int i = 0;i < n;i++){
		for (int j = 0;j < m;j++){
			cin >> field[i][j];
		}
	}

	int ans = 0;

	for (int i = 0;i < n;i++){
		for (int j = 0;j < m;j++){
			if(field[i][j] != '#') ans += check(i,j);
		}
	}

	cout << ans/2 << endl;

	return 0;

}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
const int INF = 1e9;
const int MAX_V = 100000;

struct edge{
   int to, cost;
};

vector<edge> G[MAX_V];
bool used[MAX_V];
int n, m;

int prim(){
    int res = 0;
    priority_queue<P, vector<P>, greater<P> > q;
    memset(used, false, sizeof(used));
    q.push(P(0, 0));
    while(!q.empty()){
        P p = q.top(); q.pop();
        int v = p.second;
        int d = p.first;
        if(used[v]) continue;
        used[v] = true;
        res += d;
        for(int i = 0; i < G[v].size(); i++){
            q.push(P(G[v][i].cost, G[v][i].to));
        }
    }
    return res;
}

int main(){
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int s, t, w;
        cin >> s >> t >> w;
        //s--; t--;
        G[s].push_back({t, w});
        G[t].push_back({s, w});
    }
    cout << prim() << endl;
}

/* verified
https://onlinejudge.u-aizu.ac.jp/#/courses/library/5/GRL/2/GRL_2_A
*/


Measured memory_bytes: 9996
local n,k=io.read("n","n")
local a={}
for i=1,n do
    a[i]=io.read("n")
end

local mod=1000000007
local A=0
local B=0
local counter=0
for i=1,n do
    for j=1,n do
        if a[i]>a[j] and i<j then
            A=A+1
        end
        if a[i]>a[j] then
            B=B+1
        end
    end
end
local counterA=A*k%mod
local counterB=(k*(k-1)//2%mod)*B%mod
print((counterA+counterB)%mod)

Measured memory_bytes: 760
const processData = (lines) => {
  const s = lines[0]
  const t = lines[1]

  if (t.length = s.length + 1 && t.slice(0, -1) === s) {
    console.log('Yes')
  } else {
    console.log('No')
  }
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> ans(N, 0);
    REP(i, N - 1)
    {
        ll a;
        cin >> a;
        a--;
        ans[a]++;
    }
    REP(i, N) cout << ans[i] << endl;
}


Measured memory_bytes: 4756
#include <cstdio>

int main()
{
    int count = 0;
    for (int i = 0; i < 3; ++i)
    {
        char t;
        scanf("%c", &t);
        if (t == 'o')
        {
            count++;
        }
    }
    printf("%d\n", (7 + count) * 100);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
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 (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;
using pi=pair<int,int>;
void solve()
{
	int n;
	cin>>n;
	vector<pair<int,int>>ab(n);
	vector<int>b(n),a(n);
	rep(i,n){
		cin>>ab[i].x>>ab[i].y;
		a[i]=ab[i].x;
		b[i]=ab[i].y;
	}
	sort(all(ab));
	sort(all(b));
	sort(all(a));
	if(n%2==0){
		int max_b[2]={b[n/2-1],b[n/2]};
		int min_a[2]={a[n/2-1],a[n/2]};
		int mi=min_a[1]+min_a[0];
		int ma=max_b[1]+max_b[0];
		//cout<<mi<<" "<<ma<<endl;
		int dis=ma-mi+1;
		cout<<dis<<endl;

	}else{
		int max_b=b[n/2];
		
		int min_a=a[n/2];
		int ans=max_b-min_a+1;
		//cout<<ans<<endl;
	/*	FOR(i,n/2,n){
			if(a[i]<=max_b){
				int ite=upper_bound(all(b),a[i])-b.begin();
				if(ite>0&&ite<n){
					int bf=*(upper_bound(all(b),a[i])-1);
					//cout<<bf<<" "<<a[i]<<endl;	
					int dis=a[i]-bf;
					if(dis>1){
						ans-=(dis-1);
					}
				}
			}
		}*/
		cout<<ans<<endl;

	}
	
}

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


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

bool isPrime(int n){
    if (n == 1) {
        return false;
    }
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

int main() 
{
    int X;
    cin >> X;
    while (X) {
        if(isPrime(X)){
            break;
        }
        X++;
    }
    cout << X << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

ll solve(ll h){
    if(h==1) return 1;
    return 2*solve(h/2)+1;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    ll h;
    in>>h;
    cout<<solve(h)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    string s;
    cin >> s;
    rep(i, s.size() - 1){
        if(s[i] == s[i + 1]){
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }
    
    rep(i, s.size() - 2){
        if(s[i] == s[i + 2]){
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
    
    return 0;
}

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

using namespace std;

#define ll long long int

ll matrix[100005];

ll h[100005];

ll func(ll i)

{

    if(i==0) return 0;

    else if (i==1) return abs(h[1]-h[0]) ;

    else

    {

        if(matrix[i-2]==-1)

        matrix[i-2]=func(i-2);

        if(matrix[i-1]==-1)

        matrix[i-1]=func(i-1);

        matrix[i]=min(matrix[i-2]+abs(h[i]-h[i-2]),matrix[i-1]+abs(h[i]-h[i-1])) ;       

        return matrix[i];

     }

}

int main()

{

    //cout << "Hello,World!\n";

    memset(matrix,-1,sizeof(matrix));

    ll n;

    cin>>n;

    for(ll i=0;i<n;i++)

    cin>>h[i];

    cout<<func(n-1);

    return 0;

}

Measured memory_bytes: 7464
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
const int mod = 1000000007;
void add(int &a,int b){
    a = (a+b)%mod;
}
signed main(){
    int h,w;cin >> h >> w;
    vector<string> f(h);
    rep(i,h)cin >> f[i];
    vector<vector<int>> dp(h,vector<int>(w,0));
    dp[0][0] = 1;
    rep(i,h)rep(j,w){
        if(i+1 < h && f[i+1][j] != '#')add(dp[i+1][j],dp[i][j]);
        if(j+1 < w && f[i][j+1] != '#')add(dp[i][j+1],dp[i][j]);
    }
    cout << dp[h-1][w-1] << endl;
    return 0;
}

Measured memory_bytes: 13008
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        string S, T;
        cin >> S >> T;

        ll N = len(S);
        rep(i, 0, N) {
                string l = T.substr(0, i);
                string r = T.substr(i, N-i);
                if (S == r+l) {
                        cout << "Yes" << endl;
                        return 0;
                }
        }
        cout << "No" << endl;
}

Measured memory_bytes: 3628
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(18);
}
signed main(){
  init_io();
  ll INF = 10000000000;
  ll n,T,ans=INF;
  cin >> n >> T;
  vector<ll> c(n),t(n);
  for(int i=0;i<n;i++){
    cin >> c[i] >> t[i];
    if(t[i]<=T){
      ans = min(c[i],ans);
    }
  }
  if(ans==INF) cout <<"TLE\n";
  else cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 文字列の入力
        List<String> list = new ArrayList<>();
		list.addAll(Arrays.asList(sc.next().split("")));
        int aIndex = list.indexOf("A");
        int zIndex = 0;
        for(int i = aIndex + 1; i < list.size(); i++) {
          if (list.get(i).equals("Z")) {
            zIndex = i;
          }
        }
    
		// 出力
		System.out.println(zIndex - aIndex + 1);
	}
}

Measured memory_bytes: 53068
using System;
class Program
{
  static void Main(string[] args)
  {
    var n=Read(3);
    Write(n[0]+n[1]+n[2]+max(n)*9);
  }

  static void Write(string s) { Console.WriteLine(s); return; }
  static void Write(long n) { Console.WriteLine(n.ToString()); return; }
  static string ReadStr() { return Console.ReadLine(); }
  static string[] ReadStrs() { return Console.ReadLine().Split(' '); }
  static long Read() { return long.Parse(Console.ReadLine()); }
  static long[] Read(long n) {
    long[] p = new long[n];
    string[] t = Console.ReadLine().Split(' ');
    for(long i = 0; i < n; i++) { p[i] = long.Parse(t[i]); }
    return p;
  }
  static long abs(long n) { return (n > 0) ? n : -n; }
  static long gcd(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = gcd(p, n[i]); } return p; }
  static long gcd(long a, long b) { return (a==0)?b:gcd(b % a, a); }
  static long lcm(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = lcm(p, n[i]); } return p; }
  static long lcm(long a, long b) { return a * b / gcd(a, b); }
  static long max(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = (p>n[i])?p:n[i]; } return p; }
  static long min(params long[] n) { long p = n[0]; for (long i = 1; i < n.Length; i++) { p = (p<n[i])?p:n[i]; } return p; }
  static void YN(bool t) { Console.WriteLine(t ? "YES" : "NO"); }
  static void Yn(bool t) { Console.WriteLine(t ? "Yes" : "No"); }
  static void yn(bool t) { Console.WriteLine(t ? "yes" : "no"); }
  static string clip(string s, int start, int count) {
    if (start + count < s.Length) { s = s.Remove(start + count); }
    if (start > 0) { s = s.Remove(0, start); }
    return s;
  }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,b) for(ll i=0;i<b;i++)
ll mod=1000000007;
#define vl vector<ll>
#define pl pair<ll,ll>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=b-1;i>=a;i--)
#define rsort(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(),(v).end()

ll n,a,p=0,ans=1,m;
int main() {
    cin>>n>>a;
    rep(i,n){
        cin>>m;
        p+=m;
        if(p<=a)ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
n,l=map(int,input().split())
li1=[0]*n
li2=[0]*n
cnt=0
for i in range(n):
    li1[i]=l+i
    li2[i]=abs(li1[i])
    cnt+=li1[i]

li1.sort()
li2.sort()

c=0
for i in range(n):
    if li1[i]==li2[0]:
        c+=1

if c>=1:
    print(cnt-li2[0])
else:
    print(cnt+li2[0])

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

bool solveLot( int* sl, int row, int col, int start, int goal ){
	int cur = start;
	for ( int i = 0; i < row; ++i ){
		if ( sl[ i * ( col + 1 ) + ( cur - 1 ) ] ){
			--cur;
		}else if( sl[ i * ( col + 1 ) + cur ] ){
			++cur;
		}
	}
	return ( cur == goal );
}

int main(){
	int col, row, start, goal;
	string s;

	while ( cin >> col  && col ){
		cin >> start;
		cin >> goal;
		cin >> row;
		int* swapLine = new int[ row * ( col + 1 ) ];

		for ( int i = 0; i < row; ++i ){
			cin >> s;
			for ( int j = 0; j < col+1; ++j ){
				if ( j == 0 || j == col ){
					swapLine[ i * ( col + 1 ) + j ] = 0;
				}else{
					swapLine[ i * ( col + 1 ) + j ] = static_cast< int >( s[ j - 1 ] - '0' );
				}
			}
		}

		if ( solveLot( swapLine, row, col, start, goal ) ){
			cout << "0" << endl;
		}else{
			int* plusLine = new int[ row * ( col + 1 ) ];
			for ( int i = 0; i < row; ++i ){
				for ( int j = 0; j < col+1; ++j ){
					plusLine[ i * ( col + 1 ) + j ] = 0;
					if ( !( j == 0 || j == col )
						&& !swapLine[ i * ( col + 1 ) + ( j - 1 ) ]
						&& !swapLine[ i * ( col + 1 ) + j ]
						&& !swapLine[ i * ( col + 1 ) + ( j + 1 ) ] ){
							plusLine[ i * ( col + 1 ) + j ] = 1;
					}
				}
			}

			bool solved = false;
			for ( int i = 0; i < row; ++i ){
				for ( int j = 0; j < col+1; ++j ){
					if ( plusLine[ i * ( col + 1 ) + j ] ){
						swapLine[ i * ( col + 1 ) + j ] = 1;
						if ( solveLot( swapLine, row, col, start, goal ) ){
							cout << i+1 << " " << j << endl;
							solved = true;
							break;
						} else {
							swapLine[ i * ( col + 1 ) + j ] = 0;
						}
					}
				}
				if ( solved ) break;
			}

			if ( !solved ){
				cout << "1" << endl;
			}

			delete[] plusLine;
		}

		delete[] swapLine;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>



typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) FOR(i,0,n)



ll fast_pow(ll x,ll n,ll mod){
    if (n==0) return 1;
    ll res=fast_pow(x*x %mod,n/2,mod);
    if (n&1) res=res*x%mod;
    return res;
}

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;




int main(){
    int N,T;
    cin>>N>>T;
    int a[1000000];
    rep(i,N){
        cin>>a[i];
    }
    ll cnt=0;
    ll to=a[0];
    FOR(i,1,N){
        if (a[i]<=to+T){
            cnt+=a[i]-to;
        }else {
            cnt+=T;
        }
        to=a[i];
    }
    
    cout<<cnt+T<<endl;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		memo = new int[2][];
		for(int i=0;i<2;i++){
			memo[i] = new int[K + 1];
		}
		
		memo[0][0] = 1;
		memo[1][0] = 1;
		
		for(int i=0;i<K;i++){
			for(int j=0;j<2;j++){
				if((memo[j][i] >> 1) % 2 == 0){
					for(int k=0;k<N;k++){
						if(i + A[k] > K) continue;
						memo[j ^ 1][i + A[k]] |= 1 << 1;
					}
				} else {
					for(int k=0;k<N;k++){
						if(i + A[k] > K) continue;
						memo[j ^ 1][i + A[k]] |= 1 << 0;
					}
				}
			}
		}
		
		Console.WriteLine(memo[0][K] != 1 ? "First" : "Second");
		
	}
	
	int dfs(int me, int k){
Console.WriteLine("{0} {1}",me,k);
		if(memo[me][k] != -1) return memo[me][k];
		
		int[] wl = new int[2];
		for(int i=0;i<N;i++){
			if(k - A[i] < 0) continue;
			int ret = dfs(me ^ 1, k - A[i]);
			wl[ret]++;
		}
		
		if(wl[0] > 0){
			return memo[me][k] = 1;
		} else {
			return memo[me][k] = 0;
		}
		
	}
	
	int[][] memo;
	int[] A;
	int N,K;
	public Sol(){
		var d = ria();
		N = d[0]; K = d[1];
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;

int main() {
source:
    ll x;
    cin >> x;
    repd(a, -200, 201) {
        repd(b, -200, 201) {
            ll a_temp = 1, b_temp = 1;
            rep(i, 5) {
                a_temp *= a;
                b_temp *= b;
            }
            if (a_temp - b_temp == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3584
# E - Sum of gcd of Tuples (Hard)

n, k = map(int, input().split())
X = [0]*(k+1)
mod = 10**9+7

for x in range(k, 0, -1):
    #X[x] = ((k//x)**n)%mod
    X[x] = pow(k//x, n, mod)
    for x_multi in range(x*2, k+1, x):
        X[x] -= X[x_multi]

print(sum((i*x)for i, x in enumerate(X))%mod)

Measured memory_bytes: 11184
#include <stdio.h>
#include <stdlib.h>
#define INF 10000000

void insert(int);
void maxHeapify(int);
void increaseKey(int,int);
void swap(int,int);
int extractMax(void);
int parent(int);
int left(int);
int right(int);

int heap[2000000],h=1;

int main(){
 int n=0, i, x,ans[2000000];
  char com[20];

  while(1){
    scanf("%s", com);
    if(com[0]=='e'&& com[1]=='n') break;
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'e'&& com[1]== 'x' ){
      ans[n] = extractMax();
      n++;
    } 
  }

  for(i=0;i<n;i++)printf("%d\n",ans[i]);
  return 0;
}

void insert(int i){
 h = h + 1;
 heap[h] = -INF;
 increaseKey(h,i);
}

int extractMax(void){
  int max;
if(h<1)return -INF;
max = heap[1];
heap[1] = heap[h];
h = h - 1;
maxHeapify(1);
return max;
}

void increaseKey(int i,int key){
 if(key < heap[i]) return;
 heap[i] = key;
 while(i>1&&heap[parent(i)]<heap[i]){
  swap(i,parent(i));
  i = parent(i);
 }
}

void maxHeapify(int i){
  int l,r,largest;

  l = left(i);
  r = right(i);

  if(l <= h && heap[l] > heap[i]) largest = l;
  else largest = i;

  if(r <= h && heap[r] > heap[largest]) largest = r;

  if(largest != i){
    swap(i,largest);
    maxHeapify(largest);
  }
}

int parent(int i){
  return i/2;
}

int left(int i){
  return 2 * i;
}

int right(int i){
  return 2 * i + 1;
}

void swap(int a,int b){
int temp;

temp = heap[a];
heap[a] = heap[b];
heap[b] = temp;

}

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

s = input()
n = len(s)
aa = []
for i,t in enumerate(s):
    if i == 0:
        tmp = t
        cnt = 1
        continue
    if tmp != t:
        aa.append(cnt)
        cnt = 1
        tmp = t
    else:
        cnt += 1
aa.append(cnt)
# print(aa)
res = [0] * n
cnt = 0
for i in range(len(aa))[::2]:
    l = aa[i]; r = aa[i+1]
    av = (l+r)//2
    if (l%2 and r%2) or (l%2==0 and r%2==0):
        res[cnt+l-1] = av
        res[cnt+l] = av
    else:
        if l%2:
            res[cnt+l-1] = av+1
            res[cnt+l] = av
        else:
            res[cnt+l-1] = av
            res[cnt+l] = av+1
    cnt += l+r
print(*res)

Measured memory_bytes: 9432
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int ans=0;
    vector<int>a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(),a.end());
    if((3*a[2])%2==(a[0]+a[1]+a[2])%2){
        cout << ((a[2]-a[0])+(a[2]-a[1]))/2;
    }else{
        cout << 1+((a[2]-a[0])+(a[2]+1-a[1]))/2;
    }
}

Measured memory_bytes: 256
# ediitorialを参考にした
# M個の目的地があると、そこには(M-1)個の区間がある。N個のコマを使うことで(N-1)個の区間を訪れなくてもよくなる。
# つまり、長い区間を(N-1)個除いて、それ以外の区間の和が移動回数の最小値
N, M = map(int, input().split())
X = [int(x) for x in input().split()]
X = sorted(X)
sa = [0] * (M - 1)
for i in range(M - 1):
    sa[i] = X[i + 1] - X[i]
sa = sorted(sa)
numofmove = 0
if N >= M:
    numofmove = 0
else:
    for j in range(M - N):
        numofmove += sa[j]

print(numofmove)


Measured memory_bytes: 13832
#include<stdio.h>
int main()
{
	int A,B,C,d,sum;
	d=17;
	scanf("%d %d %d",&A,&B,&C);
	sum=(A==5||A==7)+(B==5||B==7)+(C==5||C==7);
	if(sum==3)
	{
		if((A==7&&B==7)||(A==7&&C==7)||(B==7&&C==7))
		{
			printf("NO");
		}
		else
		printf("YES");
	}
	else
	{
		printf("NO");
	}
	return 0;
 } 

Measured memory_bytes: 128
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
if a>b:
    if b-w*t>=a-v*t:
        print("YES")
    else:
        print("NO")
else:
    if b+w*t<=a+v*t:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 9188
n=int(input())
lst=[]
for i in range(n):
    a,b=map(int,input().split())
    lst.append([a,b])
lst=sorted(lst,key=lambda x:x[1])
time=0
for i in range(n):
    a,b=lst[i]
    time+=a
    if time>b:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 114936
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>

using namespace std;

int main() {
  string S;
  int i;
  int ns[2];
  int ew[2]; 
  
  cin >> S;

  ns[0]=ns[1]=0;
  ew[0]=ew[1]=0; 
  
  for(i=0;i<(int)S.length();i++){
    if(S[i]=='N') ns[0]=1;
    else if(S[i]=='S') ns[1]=1;
    else if(S[i]=='E') ew[0]=1;
    else if(S[i]=='W') ew[1]=1;    
  }

  if(ns[0]==ns[1] && ew[0]==ew[1]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;    
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




vector<vector<int>> g;
vector<int> range, ans;

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    vector<vector<int>> g(n);
    vector<int> range(n, -1), ans(n);
    REP(i, m){
        int a, b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int q;
    cin >> q;
    vector<int> v(q), d(q), c(q);
    REP(i, q){
        scanf("%d %d %d", &v[i], &d[i], &c[i]);
        v[i]--;
    }
    for(int i = q - 1; i >= 0; i--){
        queue<pair<int, int>> q;
        vector<bool> used(n, false);
        if(range[v[i]] < d[i]){
            q.push({v[i], d[i]});
        }
        while(!q.empty()){
            auto t = q.front(); q.pop();
            if(used[t.first]) continue;
            if(!ans[t.first]) ans[t.first] = c[i];
            used[v[i]] = true;
            range[t.first] = t.second;
            if(t.second){
                for(auto &x : g[t.first]){
                    if(!used[x] && range[x] + 1 < t.second){
                        q.push({x, t.second - 1});
                    }
                }
            }
        }
    }
    REP(i, n){
        printf("%d\n", ans[i]);
    }
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<string> S(3);
  string ans;
  REP(i, 3){
    cin >> S[i];
    ans += S[i][0]-'a'+'A';
  }
  cout << ans << endl;
}

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

using namespace std;

int i;
char s[100005];

int main(){
	scanf("%s", s);
	int l = strlen(s);
	
	int res = 0;
	
	for(i = 1; i < l; i++)
	res += (s[i] != s[i - 1]);
	
	printf("%d\n", res);
}


Measured memory_bytes: 384
from math import gcd
k = int(input())
r = 0
for i in range(1, k + 1):
    if i > 1:
        for j in range(1, k + 1):
            if j > 1:
                for l in range(1, k + 1):
                    r += gcd(i, gcd(j, l))
            else:
                r += k
    else:
        r += k * k
print(r)

Measured memory_bytes: 67684
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var a = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var boxes = new int[N];
        for (int i = N - 1; i >= 0; i--)
        {
            var _a = 0;
            for (int j = i; j < N; j += i + 1)
                _a = (_a + boxes[j]) % 2;

            if(a[i] != _a)
                boxes[i]++;
        }

        var b = boxes.Select((e, i) => (e, i)).Where(x => x.e == 1).Select(x => x.i + 1).ToArray();
        var M = b.Length;

        WriteLine(M);
        WriteLine(string.Join(' ', b));
    }
}


Measured memory_bytes: 47832
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define pi 3.1415926
using namespace std;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<long long,int> pli;
typedef pair<int,long long> pil;
const ll INF=100000000000000007;
const int MOD=1000000007;
const int nmax=201234;

int n,m,l[nmax],r[nmax];
ll lt[nmax*4],lt2[nmax*4],a[nmax],dp[nmax],res;
vector<pii> v2,v3;

void pushdown(int i){
    lt2[i<<1]+=lt2[i];
    lt2[i<<1|1]+=lt2[i];
    lt2[i]=0;
}

void update(int i,int l,int r,int L,int R,ll val)
{
    if(l>R || r<L)
        return;
    else if(l>=L && r<=R)
        lt2[i]+=val;
    else
    {
        int mid=(l+r)>>1;
        pushdown(i);
        update(i<<1,l,mid,L,R,val);
        update(i<<1|1,mid+1,r,L,R,val);
        lt[i]=max(lt[i<<1]+lt2[i<<1],lt[i<<1|1]+lt2[i<<1|1]);
    }
}

ll query(int i,int l,int r,int pos)
{
    if(l>pos)
        return -INF;
    else if(r<=pos)
        return lt[i]+lt2[i];
    else{
        int mid=(l+r)>>1;
        pushdown(i);
        return max(query(i<<1,l,mid,pos),query(i<<1|1,mid+1,r,pos));
    }
}

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0; i<m; ++i)
    {
        scanf("%d%d%lld",&l[i],&r[i],&a[i]);
        v2.pb({l[i],i});
        v3.pb({r[i],i});
    }
    sort(v2.begin(),v2.end());
    sort(v3.begin(),v3.end());
    ll tmp=0;
    for(int i=1,j=0,k=0; i<=n; ++i)
    {
        while(j<m && v2[j].first<=i)
            tmp+=a[v2[j++].second];
        while(k<m && v3[k].first<i)
            tmp-=a[v3[k++].second];
        dp[i]=tmp;
    }
    tmp=0;
    for(int i=0; i<m; ++i)
        update(1,1,n,l[i],r[i],-a[i]);
    for(int i=1,k=0; i<=n; ++i)
    {
        dp[i]=dp[i]+max((ll)0,query(1,1,n,i-1));
        if(res<dp[i])
            res=dp[i];
        update(1,1,n,i,i,dp[i]);
        while(k<m && v3[k].first<=i){
            update(1,1,n,l[v3[k].second],v3[k].first,a[v3[k].second]);
            k++;
        }
    }        
    printf("%lld\n",res);
    return 0;
}
//    ios::sync_with_stdio(false);
//    cin.tie(0);
//    cout.tie(0);


Measured memory_bytes: 18788
import sys
n=int(input())
w=[]
w1=[]
w2=[]
for i in range(n):
    a=input()
    w1.append(a)
    w.append(list(a))
if len(set(w1))!=n:
    print("No")
    sys.exit()
for i in range(n):
    if i==0:
        w2.append(w[i][-1])
    elif i==(n-1):
        w2.append(w[i][0])
    else:
        w2.append(w[i][0])
        w2.append(w[i][-1])
for i in range(0,((n-1)*2),2):
    x=w2[i:2+i]
    if len(set(x))!=1:
        print("No")
        sys.exit()
print("Yes")


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

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

int main() {
	ll A, B, C, N; cin >> A >> B >> C >> N;
	ll nums = 2*A*B + 2*B*C + 2*C*A;	
	map<tuple<ll, ll, ll>, bitset<6>> flag;
	set<tuple<ll, ll, ll>> used;	

	auto isin = [&](ll x, ll y, ll z) {
		return (0 <= x && x < A && 0 <= y && y < B && 0 <= z && z < C);
	};
	auto create = [&](bitset<6>& f, ll x, ll y, ll z) {
		if (z == C-1) f[0] = true;
		if (z == 0) f[3] = true;
		if (x == A-1) f[1] = true;
		if (x == 0) f[4] = true;
		if (y == B-1) f[2] = true;
		if (y == 0) f[5] = true;
	};

	while (N--) {
		ll x, y, z; cin >> x >> y >> z;

		if (flag.find(tie(x, y, z)) == flag.end()) {
			create(flag[tie(x, y, z)], x, y, z);
		}
		auto &now = flag[tie(x, y, z)];

		for (int i = 0; i < 6; i++) {
			if (now[i]) { nums--; now[i] = false; continue; }
			ll nz = z + dz[i], nx = x + dx[i], ny = y + dy[i];
			if (!isin(nx, ny, nz) || used.find(tie(nx, ny, nz)) != used.end()) continue;
			if (flag.find(tie(nx, ny, nz)) == flag.end()) {
				create(flag[tie(nx, ny, nz)], nx, ny, nz);
			}
			auto &nei = flag[tie(nx, ny, nz)];
			if (!nei[(i+3)%6]) {
				nei[(i+3)%6] = true; nums++;
			}
		}
		used.insert(tie(x, y, z));
	}
	cout << nums << endl;
	return (0);
}



Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7;

int main() {
    int N, Y, k;
    cin >> N >> Y;

    for(int i=0; i<=N; i++) {
        for(int j=0; i+j<=N; j++) {
            k = N - i - j;
            if(10000 * i + 5000 * j + 1000 * k == Y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 3556
#include "bits/stdc++.h"
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)

#define debug(x) cerr << #x << " " << x << endl
#define print(x) cout << x;
#define println(x) cout << x << endl;
#define spc << " " <<

#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define eb emplace_back
#define np next_permutation

using ll = long long;
using Pii = pair<int, int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;
template<class T>using VV = vector<vector<T>>;
using Vi = vector<int>;
using VVi = vector<vector<int>>;

int main() {
   int N; cin >> N;
   Vi A = Vi(N); rep(i, N) cin >> A[i];

   bool ok = false;
   int ans = 0;
   while (!ok) {
      ok = true;
      rep(i, N-1) {
         if (A[i] > A[i+1]) {
            swap(A[i], A[i+1]);
            ok = false;
            ans++;
         }
      }
   }
   cout << A[0]; REP(i, 1, N) cout << " " << A[i]; cout << endl;
   cout << ans << endl;
   return 0;
}



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

int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(a+b < k){
        cout << a-((k-a)-b) << endl;
        return 0;
    }
    if(a>k){
        cout << k << endl;
        return 0;
    }
    if(k>=a){
        cout << a << endl;
        return 0;
    }
}

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

int main() {
  int N, ans = 0;
  bool flag = true;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  while(flag) {
    for(int i = 0; i < N; i++){
      if(a.at(i) % 2 == 0){
        a.at(i) /= 2;
      }else{
        flag = false;
        break;
      }
    }
    if(flag){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
typedef struct {
  int c;
  int t;
} smart;

int comp( const void *c1, const void *c2 )
{
  smart test1 = *(smart *)c1;
  smart test2 = *(smart *)c2;

  int tmp1 = test1.c;   /* b を基準とする */
  int tmp2 = test2.c;

  return tmp1 - tmp2;
}

int main(){
  int i,j,k;
  int N,T;
  scanf("%d %d",&N,&T);
  smart base[N];
  
  for(i = 0; i < N;i++){
    scanf("%d %d",&base[i].c,&base[i].t);
  }
  qsort( base, N, sizeof(smart), comp );
  
  for(i=0;i<N;i++){
    if(base[i].t <= T){
      printf("%d\n",base[i].c);
      return 0;
    }
  }
  puts("TLE");
  return 0;
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

#ifdef DEBUG
#define debug(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
#else
#define debug(fmt, ...)
#endif

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<llll> vllll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll solve(ll a,ll b,ll c) {
    if (a+b+1 < c) {
        c = a+b+1;
    }
    return b+c;
}


int main() {
    ll a,b,c; cin >> a >> b >> c;
    cout << solve(a,b,c) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    int s[] = {63,6,91,79,102,109,125,39,127,111};
    while(true){
	int n;
	cin >> n;
	if(n==-1) break;
	int now = 0;
	REP(i,n){
	    int a;
	    cin >> a;
	    now ^= s[a];
	    string ans = "";
	    int temp = now;
	    now = s[a];
	    while(temp>0){
		ans += (char)(temp%2+'0');
		temp/=2;
	    }
	    REP(i,7-ans.size()) cout << "0";
	    RREP(i,ans.size()) cout << ans[i];
	    cout << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>
#define Max 100000


int A[Max];

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


int main() {
    int n;
    
    int i;
    scanf("%d",&n);
    for(i=0; i<n; i++) scanf("%d",&A[i]);
    
    int q = partition(0, n-1);
    
    for(i=0; i<n; i++) {
        if(i){
            printf(" ");
        }
        
        if(i==q) printf("[");
        printf("%d",A[i]);
        if(i==q) printf("]");
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 992
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

int main(){
  int w,h,n,a,x,y;
  int k=0,ax=0,ay=0,bx,by;
  cin >> w >> h >> n;
  bx = w;by = h;
  for(int i=0;i<n;i++){
    cin >> x >> y >> a;
    switch (a) {
      case 1:
      ax = max(ax,x);
      break;
      case 2:
      bx = min(bx,x);
      break;
      case 3:
      ay = max(ay,y);
      break;
      case 4:
      by = min(by,y);
      break;
      default:
      break;
    }
  }
  if(ax<bx&&ay<by) k=(bx-ax)*(by-ay);
  cout << k << endl;
}


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

int main(){
	long long n,a,b;
	cin>>n>>a>>b;
	long long mn=(n-1)*a+b;
	long long mx=(n-1)*b+a;
	cout<<max(mx-mn+1,0ll);

}
//solved  problems for today:2


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

int main() {
  string S;
  cin >> S;
  int length1 = S.size();
  vector<char> kaibun;
  vector<int> position;
  int tmp = 0;
  for (int i = 0; i < length1; i++) {
    if (S[i] != 'x') {
      kaibun.push_back(S[i]);
      position.push_back(tmp);
      tmp = 0;
    }
    else tmp++;
  }
  position.push_back(tmp);
  int length2 = kaibun.size();
  bool can = true;
  for (int i = 0; i < length2/2; i++) {
    if (kaibun[i] != kaibun[length2-1-i]) {
      can = false;
      break;
    }
  }
  int res = -1;
  int length3 = position.size();
  if (can) {
    res++;
    for (int i = 0; i < length3/2; i++) {
      res += abs(position[i] - position[length3-1-i]);
    }
  }
  cout << res << endl;
}


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

int main(){
  int N;
  cin>>N;
  vector <pair<int,int>> p(N);
  int V[N];
  int C[N];
  int temp;
  for (int i=0;i<N;i++){
    cin>>temp;
    V[i]=temp;
  }
  for (int i=0;i<N;i++){
    cin>>temp;
    C[i]=temp;
  }
  for (int i=0;i<N;i++){
    p[i]=make_pair(V[i],C[i]);
  }
  int sum=0;
  for(int i=0;i<N;i++){
    if(V[i]>C[i]){
      sum=sum+V[i]-C[i];
    }
  }
  cout<<sum<<endl;
      
  
  
  return 0;
}

  
  
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>

using namespace std;

struct point
{
	int x, y, step, vital;
};
const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

int H, W, N;

point search(const vector< vector<char> >& field, point start)
{
	vector< vector<bool> > isVisited(H, vector<bool>(W));
	queue<point> Que;
	Que.push(start);
	isVisited[start.y][start.x] = true;
	while (!Que.empty())
	{
		point p = Que.front();
		Que.pop();
		if (field[p.y][p.x] - '0' == p.vital)
		{
			++p.vital;
			return(p);
		}
		for (int i = 0; i < 4; ++i)
		{
			int nx = p.x + dx[i];
			int ny = p.y + dy[i];
			if (0 <= nx && nx < W && 0 <= ny && ny < H && isVisited[ny][nx] == false && field[ny][nx] != 'X')
			{
				point np;
				np.x = nx;
				np.y = ny;
				np.step = p.step + 1;
				np.vital = p.vital;
				Que.push(np);
				isVisited[ny][nx] = true;
			}
		}
	}
}

void solve()
{
	cin >> H >> W >> N;
	vector< vector<char> > field(H, vector<char>(W));
	point start;
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			cin >> field[i][j];
			if (field[i][j] == 'S')
			{
				start.x = j;
				start.y = i;
				start.step = 0;
				start.vital = 1;
			}
		}
	}
	int sum = 0;
	while (start.vital < N + 1)
	{
		start = search(field, start);
		sum += start.step;
		start.step = 0;
	}
	cout << sum << endl;
}

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

Measured memory_bytes: 2352
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main()
{
	int num;
	cin >> num;
	vector<int> a(num + 1);
	for (int idx = 1; idx < num + 1; ++idx)
	{
		cin >> a[idx];
	}

	vector<int> b(num + 1, 0);
	vector<int> c;

	for (int idx = num; idx >= 1; --idx)
	{
		// 倍数の個数を取得
		int tmp = 0;
		for (int idx2 = 1; idx2 <= num && idx * idx2 <= num; ++idx2)
		{
			tmp += b[idx * idx2];
		}

		// 違っていれば入れる
		if (tmp % 2 != a[idx])
		{
			c.push_back(idx);
			b[idx] = 1;
		}
	}

	// 結果
	cout << c.size() << endl;
	if (c.size())
	{
		REP(i, c.size())
		{
			cout << c[i] << " ";
			cout << endl;
		}

	}

	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int n;
    cin >> n;
    vector<double> v(n);
    rep(i,n) cin >> v[i];
    //小さい順に並び替えて順番に処理する
    sort(all(v));
    double ans=0;
    for(int i=0; i<n-1; i++){
        ans = (v[i]+v[i+1])/2;
        v[i+1] = ans;
    }
    cout   << ans << endl;


}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if ((a < c && c < b) || (a > c && c > b))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
<?php
while (true) {
    list($a, $operator, $b) = getInputExplodeBySpaces();
    if($operator == '?'){
        break;
    }
    $results[] = calc($a, $operator, $b);
}
echo implode(PHP_EOL, $results), PHP_EOL;
 
function getInputExplodeBySpaces()
{
    return explode(' ', trim(fgets(STDIN)));
}
 
function calc($a, $operator, $b)
{
    switch ($operator) {
        case '+':
            return addTwoNum($a, $b);
        case '-':
            return subTractTwoNum($a, $b);
        case '*':
            return multiplyTwoNum($a, $b);
        case '/':
            return divideTwoNumByFloorPoint($a, $b);
    }
}
 
function addTwoNum($a, $b)
{
    return $a + $b;
}
 
function subTractTwoNum($a, $b)
{
    return $a - $b;
}
   
function multiplyTwoNum($a, $b)
{
    return $a * $b;
}
 
function divideTwoNumByFloorPoint($a, $b)
{
    return floor($a / $b);
}

Measured memory_bytes: 15436
n = gets.strip.to_i
a = gets.strip.split(' ').map(&:to_i)

sticks = {}
a.map do |stick|
  if sticks[stick]
    sticks[stick] += 1
  else
    sticks[stick] = 1
  end
end

# puts sticks
# puts a.uniq.sort.reverse

found = 0
a.uniq.sort.reverse.each do |current|
  count = sticks[current]
  if count >= 4
    # puts "current has more 4"
    if found > 0
      puts current * found
    else
      puts current * current
    end
    exit 0
  elsif count == 2 or count == 3
    # puts "current has 2"
    if found > 0
      # puts "found * current: #{found} * #{current}"
      puts found * current
      exit 0
    else
      # puts "found will be #{current}"
      found = current
    end
  end
end

puts 0


Measured memory_bytes: 24076
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        int n = reader.nextInt();
        int res = 0;
        int a;
        for (int i =0; i<n; ++i){
            a = reader.nextInt();
            while(a%2==0){
                res++;
                a/=2;
            }
        }
        System.out.println(res);
        reader.close();
    }
}

Measured memory_bytes: 35048