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

#define pb push_back
#define all(a) (a).begin(), (a).end()

typedef long long ll;
typedef pair<int, int> pii;

struct union_find {
    vector<int> parent;
    vector<int> size;
    int components = 0;

    union_find(int n = 0) {
        if (n > 0)
            init(n);
    }

    void init(int n) {
        parent.resize(n + 1);
        size.assign(n + 1, 1);
        components = n;
        for (int i = 0; i <= n; ++i) 
            parent[i] = i;
    }

    int find(int v) {
        return v == parent[v] ? v : parent[v] = find(parent[v]);
    }

    bool unite(int u, int v) {
        u = find(u);
        v = find(v);
        if (u == v)
            return false;
        if (size[u] < size[v]) 
            swap(u, v);
        parent[v] = u;
        size[u] += size[v];
        --components;
        return true;
    }
};

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int n, m, k; cin >> n >> m >> k;
    vector<vector<int>> fr(n + 1);
    vector<vector<int>> bl(n + 1);
    vector<int> ans(n + 1, 0);

    union_find UF(n);
    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        fr[a].pb(b);
        fr[b].pb(a);
        UF.unite(a, b);
    }
    for (int i = 0; i < k; ++i) {
        int c, d; cin >> c >> d;
        bl[c].pb(d);
        bl[d].pb(c);
    }

    for (int i = 1; i <= n; ++i) {
        int par = UF.find(i);
        ans[i] = UF.size[par] - int(fr[i].size()) - 1;
        for (auto &u : bl[i]) {
            if (UF.find(i) == UF.find(u))
                --ans[i];
        }
        assert(ans[i] >= 0);
    }

    for (int i = 1; i <= n; ++i) {
        cout << ans[i] << ' ';
    }
    cout << '\n';

}

Measured memory_bytes: 13048
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	int ans=0;
	for(auto u:s)ans+=u=='R';
	if(s!="RSR")cout<<ans;else cout<<1;
	RE 0;
}


Measured memory_bytes: 3640
#時間Sを受け取る
time = gets.chomp.to_i
#SをHに変換する s/3600
h = time / 3600 
#↑変換したときの余り/60 で分単位を取り出す
m = time % 3600 / 60
#↑変換したときの余りをsとする
s = time % 3600 % 60
#表示
puts "#{h}:#{m}:#{s}"


Measured memory_bytes: 6872
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define REPR(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) \
  for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define FORR(i, a, b) \
  for (int i = static_cast<int>(b) - 1; i >= static_cast<int>(a); --i)
#define ALL(f, x, ...) \
  ([&](auto& y) { return (f)(begin(y), end(y), ##__VA_ARGS__); })(x)
auto INDEX = [](auto& x, auto& xs) { return &x - &xs[0]; };
void async_io() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
const auto inf = INT_MAX / 3;
const auto pi = 2 * std::acos(0.0);
const auto eps = 1e-14;
using ll = signed long long;
using ull = unsigned long long;

signed main() {
  async_io();
  int n;
  while (true) {
    cin >> n;
    if (n == 0) return 0;
    auto sum = 0;
    for (int i = 2;; i++) {
      auto base = i * (i + 1) / 2;
      if (base > n) break;
      if ((base - n) % i == 0) sum++;
    }
    cout << sum << "\n";
  }
}

Measured memory_bytes: 3124
#include "bits/stdc++.h"
using namespace std;
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
typedef long long ll;

const int INF = 1e9 + 7;
const long long LLINF = 1e18;

int main() {
    string w;
    cin>>w;

    int cnt[26]={};
    REP(i, 0, w.size()){
        cnt[w[i]-'a']++;
    }
    REP(i, 0, 26){
        if(cnt[i]%2!=0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 384
(function (input) {
    var inputs = input.replace(/\r/g, '').split("\n"),
        n;

    n = parseInt(inputs.shift());

    for ( var i = 0; i < n; i++ ) {
        var funds = parseInt(inputs.shift()),
            years = parseInt(inputs.shift()),
            dataNum = parseInt(inputs.shift()),
            methods = [];

        /*
        利子：毎年発生、運用資金残高に年利率をかけ、1円未満を切り捨て

        複利：利子は翌年以降の運用資金の残高に加算
        単利：利子は別の場所へ蓄積

        手数料：上記の処理を行ったあとに、運用資金の残高から手数料が引かれる
        */
        for ( var j = 0; j < dataNum; j++ ) {
            var line = inputs.shift().split(' ');
            methods.push({
                isSimpleInterest: line[0] === '0' ? true : false,    // 単利 true
                annualInterestRate: parseFloat(line[1]),             // 年利率
                charge: parseInt(line[2])                            // 手数料
            });
        }

        var max = 0;
        methods.forEach(function(m) {
            var tmp = funds,
                box = 0;
            for ( var i = 0; i < years; i++ ) {
                if ( m.isSimpleInterest ) {
                    box += ~~(tmp * m.annualInterestRate);
                } else {
                    tmp += ~~(tmp * m.annualInterestRate);
                }
                tmp -= m.charge;
            }
            tmp += box;
            if ( tmp > max ) {
                max = tmp;
            }
        });
        console.log(max);
    }

})(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11116
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


int main() {
    int n;cin >> n;
    vector<int> ans(26,0);
    string s1;cin >> s1;
    rep(i,s1.size())ans[s1[i]-'a']++;
    rep(i,n-1){
        vector<int> sans(26,0);
        string s;
        cin >> s;
        rep(k,s.size())sans[s[k]-'a']++;
        rep(i,26)ans[i]=min(ans[i],sans[i]);
    }
    string can;
    rep(i,26){
        rep(j,ans[i])can+='a'+i;
    }
    printf("%s\n",can.c_str());
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#include <set>
#include <iterator>
using namespace std;
using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF INT_MAX
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 22
#define maxmask (1ll<<maxbits)
typedef tree<pll, null_type, less<pll>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
const int  N=100000 +10, M=(ll)1e9+1 ;
 const int mod =(ll)1e9+7,sz=5 ;

 ll n;
map<ll,ll> m;
void comp(ll x){
    cout << 3 << " " << n+1 << "\n";
    for(ll i=3;i<=x;i+=2){
        m[i+n]++;
        m[i-1]++;
        cout << 1 << " " << i+n << "\n";
        cout << 1 << " " << i-1 << "\n";
        cout << i << " " << i-1 << "\n";
        cout << i+n << " " << i-1+n << "\n";
    }
}

void work(){
    cin >> n;
    if((n&(n-1))==0){
        cout << "No\n";
        return;
    }
    cout << "Yes\n";
    if(n&1)
        comp(n);
    else{
        comp(n-1);
        ll x=n^1;
        ll a,b,k=log2(x);
        a=(1ll<<k);
        b=x^a;
        if(m[a]!=0)
            cout << a << " " << n << "\n";
        else
            cout << a+n << " " << n << "\n";
        if(m[b]!=0)
            cout << b << " " << 2*n << "\n";
        else
            cout << b+n << " " << 2*n << "\n";
    }
}
int main(){
 ios_base::sync_with_stdio(0);
// cin.tie(0);
    ll t;
//    cin >> t;
    t=1;
    while(t--){
            work();
    }
   return 0;

}


Measured memory_bytes: 8576
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

int main() {
    int N;
    ll r_count=0;
    ll g_count=0;
    ll b_count=0;
    ll ans;
    string S;
    cin >> N;
    cin >> S;

    for (int i = 0; i < N; i++) {
        if (S[i] == 'R') {
            r_count++;
        } else if (S[i] == 'G') {
            g_count++;
        } else {
            b_count++;
        }
    }

    ans += r_count*g_count*b_count;
    for (int i = 0; i < N; i++) {
        for (int j = i; j < N && 2*j - i < N; j++) {
            if (S[i] != S[j] && S[j] != S[2*j-i] && S[2*j-i] != S[i]) {
                ans--;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3532
import sys
input = sys.stdin.buffer.readline
MOD = 10**9 + 7

N = int(input())
A = [0] + list(map(int, input().split()))

C = [0]
for i in range(1, len(A)):
    C.append(C[-1] + A[i])

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

ans %= MOD
print(ans)


Measured memory_bytes: 29268
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
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); }


//CODE
void solve(void)
{
  string S,T;
  cin>>S;
  cin>>T;
  int SIZE = S.size();
  S += S;
  bool ANS = false;
  for (int i = 0; i < SIZE; i++)
  {
    bool check = true;
    for (int j = 0; j < SIZE; j++)
    {
      if(T[SIZE-1-j] != S[SIZE*2-1-i-j])
      {
        check = false;
      }
    }
    if(check == true) ANS = true;
    
    
  }
  cout<<(ANS?"Yes":"No")<<endl;
  
  

  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
while True:
    a,op,b = map(str,input().split())
    a = int(a)
    b = int(b)
    if op == "?":
        break
    elif op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    else:
        print(a//b)


Measured memory_bytes: 5596
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)a
    B.append(b)'''

#def sol(n,):    
    
def main():
    import sys
    input = sys.stdin.readline
    
    A = []
    for i in range(3): 
        a = list(map(int, input().split()))
        A.append(a)

    
    n = int(input())
    B = []
    for i in range(n):
        B.append(int(input()))
    for i in range(n):
        for j in range(3):
            for k in range(3):
                if B[i]==A[j][k]:
                    A[j][k]=101
    flg = False
    for i in range(3):
        if A[i][0] == A[i][1]== A[i][2]==101:
            flg = True
            break
    for j in range(3):
        if A[1][j] == A[2][j] == A[0][j]==101:
            flg = True
            break
    if A[0][0] == A[1][1] == A[2][2] == 101 or A[0][2] == A[1][1] == A[2][0] == 101:
        flg = True
    if flg:
        print("Yes")
    else:
        print("No")



    



if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AHarmony solver = new AHarmony();
        solver.solve(1, in, out);
        out.close();
    }

    static class AHarmony {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int a = s.nextInt(), b = s.nextInt();
            if ((a + b) % 2 == 0) w.println(a + b >> 1);
            else w.println("IMPOSSIBLE");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 23380
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A = LI()

    cnt = 0
    flag = True
    while flag:
        flag = False
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                cnt += 1
                flag = True
    print(*A)
    print(cnt)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 5624
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

ll dp[110][110000];

void solve() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep (i, N) cin >> A[i];

  rep (i, 110) rep (j, 110000) dp[i][j] = 0;
  dp[0][K] = 1;

  rep (i, N) rep (j, K+1) {
    ll down = j - 1;
    ll top = j + A[i];
    if (top > K)  top = K;
    ll current = dp[i][top];
    if (down >= 0) current -= dp[i][down];
    if (j > 0) current += dp[i+1][j-1];
    current += MOD;
    current %= MOD;
    dp[i+1][j]= current;
  }

  cout << dp[N][0] << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 94848
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String st = sc.next();

		if (st.contains("a") && st.contains("b") && st.contains("c")) {
			System.out.println("Yes");
		} else {
			System.out.println("No");

		}
	}
}


Measured memory_bytes: 22740
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(){
  int n,x;
  cin>>n>>x;
  int sz=2*n-1;
  if(x==1||x==sz)cout<<"No\n";
  else {
    cout<<"Yes\n";
    rep(i,sz)cout<<1+(n+x+i-1)%sz<<"\n";
    }
  return 0;
}


Measured memory_bytes: 1536
package main

import "fmt"

func calc(N int, am map[int]struct{}) int64 {
	dp := make([]int64, N+1)
	dp[0] = 1
	if _, ok := am[1]; !ok {
		dp[1] = 1
	}

	for i := 2; i <= N; i++ {
		if dp[i-1] == 0 && dp[i-2] == 0 {
			break
		}

		if _, ok := am[i]; ok {
			dp[i] = 0
		} else {
			dp[i] = (dp[i-1] + dp[i-2]) % 1000000007
		}
	}

	return dp[N]
}

func main() {
	var N, M int
	fmt.Scanf("%d %d", &N, &M)
	am := map[int]struct{}{}
	for i := 1; i <= M; i++ {
		var a int
		fmt.Scan(&a)
		am[a] = struct{}{}
	}

	ans := calc(N, am)
	fmt.Println(ans % 1000000007)
}


Measured memory_bytes: 5504
#include <iostream>
#define MAX_N 100000
using namespace std;

int a[MAX_N];
int p[MAX_N]; // 持ち点
int n, k, q;

void solve()
{
    // 最初に全員Qマイナスする
    for (int i = 0; i < n; i++)
    {
        p[i] = k - q;
    }
    // 正解者に１点加算
    for (int i = 0; i < q; i++)
    {
        p[a[i] - 1]++;
    }

    // 出力
    for (int i = 0; i < n; i++)
    {
        if (p[i] > 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}

int main()
{
    cin >> n >> k >> q;
    for (int i = 0; i < q; i++)
    {
        cin >> a[i];
    }

    solve();
}


Measured memory_bytes: 1408
#coding: utf-8

N, K = (int(i) for i in input().split()) 
S = input()

while "LL" in S:
    S = S.replace("LL", "L")

while "RR" in S:
    S = S.replace("RR", "R")

sad = N - len(S)
sad += K * 2

sad = min(N-1, sad)
print(sad)



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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  int N,M;
  cin >> N >> M;
  vector<bool> red_box(N,false);
  red_box[0] = true;
  VI box(N,1);

  int to, from;
  rep(i,M){
    cin >> from >> to;
    from--, to--;
    // red = true and ball num is 1
    if(red_box[from] && box[from] == 1){
      //processing from
      red_box[from] = false;
      box[from] = 0;
      //processing to
      red_box[to] = true;
      box[to]++;
    }
    else {
      //processing from
      box[from] --;
      //processing to
      red_box[to] = red_box[from] || red_box[to];
      box[to]++;
    }
  }
  int ans = 0;
  rep(i,N) if(red_box[i]) ans++;

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
N=int(input())
AB=[list(map(int,input().split())) for i in range(N)]

AB.sort(key=lambda x:x[1])
total=0
for i in range(N):
    total+=AB[i][0]
    if total<=AB[i][1]:
        continue
    else:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 47036
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef set<ii> sii;
typedef set<int> si;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef multiset<ll> ssll;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll MOD = 1000000007;

int main() {FIN
	
	ll n, t, i, a;
	ssll ns;
	pll df(0, 0);
	cin >> n >> t;
	vll as(n);
	for (i = 0; i < n; i++) {
		cin >> as[i];
		ns.insert(as[i]);
	}
	for (i = 0; i < n; i++) {
		auto it = ns.find(as[i]);
		ns.erase(it);
		if (!ns.empty()) {
			a = (*ns.rbegin());
			if (a > as[i]) {
				if (df.first == a-as[i])
					df.second++;
				else if (a-as[i] > df.first)
					df = pll(a-as[i], 1);
			}
		}
	}
	
	cout << df.second << "\n";
	
	return 0;
}


Measured memory_bytes: 8680
# Problem https://atcoder.jp/contests/abc068/tasks/abc068_b
# Ruby 2nd Try
Nmax = 100
Ni = Array.new(Nmax+1,0)
1.upto(Nmax) do |j|
    number = j
    counter = 0
    oddFlag = false
    while true
        if number % 2 == 1
        oddFlag = true
        end
        if oddFlag
            break
        end
        number = number / 2
        counter = counter+1
    end
    Ni[j]=counter
end
# p Ni
N = gets.chomp.to_i
answer = 0
countents = 0
1.upto(N) do |j|
    if(countents <= Ni[j])
        answer = j
        countents = Ni[j]
    end
end
puts(answer)


Measured memory_bytes: 1788
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;

int **read(int &n) {
    cin >> n;
    int ** v = new int*[n + 1];
    for (int i = 0; i <= n; ++i) {
        v[i] = new int[4];
        for (int j = 0; j <= 3; ++j)
            v[i][j] = 0;
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= 3; ++j) {
            cin >> v[i][j];
        }
    }

    return v;
}
int main() {
    int n;
    int **a = read(n);

    int **d = new int*[n + 1];
    for (int i = 0; i <= n; ++i)
        d[i] = new int[n + 1];

    for (int i = 1; i <= 3; ++i) {
        d[n][i] = a[n][i];
    }

    for (int i = n - 1; i >= 1; --i) {
        d[i][1] = a[i][1];
        d[i][1] += max(d[i + 1][2], d[i + 1][3]);
        d[i][2] = a[i][2];
        d[i][2] += max(d[i + 1][1], d[i + 1][3]);
        d[i][3] = a[i][3];
        d[i][3] += max(d[i + 1][1], d[i + 1][2]);
    }

    int MAX = 0;
    for (int i = 1; i <= 3; ++i) {
        MAX = max(MAX, d[1][i]);
    }

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

Measured memory_bytes: 405760
#include <bits/stdc++.h>
using namespace std;
 
int x, c, o;
int main()
{
    cin >> c >> o >> x;
    if (x > c + o)
    {
        cout << "NO" << endl;
    }
    else
    {
        if (x < c)
        {
            cout << "NO" << endl;
        }
        else
        {
            cout << "YES" << endl;
        }
        
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ll n;
    cin>>n;

   vector<ll>v;
  ll temp =n-1;
   if(n&1)
   {
       temp*=.5;
   }
   else
   {
       n*=.5;
   }
   while(n)
   {
       v.push_back(n%10);
       n/=10;
   }

   ll carry=0;
   for(int i=0;i<v.size();i++)
   {
       ll mul = v[i]*temp + carry ;
       v[i] = mul%10;
       carry=mul/10;
   }
   while(carry)
   {
       v.push_back(carry%10);
       carry/=10;
   }
   ll ans=0;
   for(int i=v.size()-1;i>=0;i--)
   {
           cout<<v[i];
   }
   cout<<endl;


}


Measured memory_bytes: 256
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long x, long long n, std::vector<long long> p){
    pair<i64,i64> ans(MOD, MOD);
    set<int> s;
    for(auto y : p)
        s.emplace(y);
    for(int i = -5000; i < 5000; ++i){
        if(s.find(i) != s.end())
            continue;
        chmin(ans, make_pair(abs(x - i), 1LL*i));
    }
    cout << ans.second << endl;
}


signed main(){
    long long X;
    scanf("%lld",&X);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(X, N, std::move(p));
    return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	map<int,int> m;
	int n,k; cin>>n;
	Foz(i,n)
	{	
		cin>>k;
		m[k]++;
		if(m[k]>1)
		{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
}



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

public class Main {
	static final int mod = (int) 1e9 + 7;
	static final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int[] DX8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, DY8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static final String nextLine = "\n";

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int k = fs.nextInt(), n = fs.nextInt();
		int a[] = fs.nextIntArray(n);
		int b[] = new int[n+1];
		for(int i=0;i<n;i++) {
			b[i] = a[i];
		}
		b[n] = k + a[0];
		
		long dif[] = new long[n];
		for(int i=0;i<n;i++) {
			dif[i] = b[i+1]-b[i];
		}
		long ans = LINF;
		for(int i=0;i<n;i++) {
			ans = Math.min(ans, k - dif[i]);
		}
		
		System.out.println(ans);
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 46804
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# --------------------------------------------

dp = None

def main():
    a, b = [int(_) for _ in input().split()]

    if a >= 9 or b >= 9:
        print(":(")
    else:
        print("Yay!")

main()


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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);


  int n;cin>>n;
  while(n--){
    int t;cin>>t;
    if(t%2==0){
      if(t%3!=0&&t%5!=0){
        puts("DENIED");return 0;
      }
    }
  }
        puts("APPROVED");return 0;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const int INF = 1 << 25;
const LL MOD = 1000000007LL;
using namespace std;
int G[100][100];
int dp[100][100];
int main() {
	int N, M;
	cin >> N >> M;
	fill((int*)dp, (int*)(dp + 100), INF);
	rep(i, N) dp[i][i] = 0;
	rep(i, M) {
		int a, b, c;
		cin >> a >> b >> c; a--; b--;
		G[a][b] = G[b][a] = c;
		dp[a][b] = dp[b][a] = c;
	}
	rep(k, N) {
		rep(i, N) {
			rep(j, N) {
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
			}
		}
	}
	int ans = 0;
	rep(i, N) {
		rep(j, N) {
			if (G[i][j] == 0) continue;
			bool OK = 0;
			rep(s, N) {
				if (dp[s][i] + G[i][j] == dp[s][j]) {
					OK = 1;
					break;
				}
			}
			if (!OK) ans++;
		}
	}
	cout << ans / 2 << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) { cin >> a.at(i); }

  ll ans = 0;
  int border = 0;
  for (int i = 0; i < n; i++) {
    border = max(border, a.at(i));
    ans += border - a.at(i);
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3988
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#define MAXA 100000
#define MAX 20000000000
#define s(i) scanf("%d", &(i))
#define p(i) printf("%d", (i))
#define ps() printf(" ") 
#define rer(i,j,k) for((i)=(j);(i)<(k);++(i))
#define ret(i,j,k) for((i)=(j);(i)>(k);--(i))
using namespace std;
int a1[MAXA] = {0}, a2[MAXA] = {0};
int main(){
	int a, b, c, i, j;
	int Count = 0;
	cin >> a >> b;
	for(i = a; i <= b; i++){
		int t = 0, is = 0, q;
		q = i;
		while(q){
			a1[t++] = q%10;
			q/=10;
		}
		for(j = 0; j < (t+1)/2; j++){
			if(a1[j]!=a1[t-1-j]){
				is = 1;
				break;
			}
		}
		if(!is){
			Count++;
		}
		memset(a1,0,sizeof(a1));
	}
	cout << Count << endl;
	return 0;
}

Measured memory_bytes: 768
#include <stdio.h>

typedef struct
{
    int a,b;
}datatype;

void quicksort(datatype number[],int first,int last){
   int i, j, pivot;
   datatype temp;

   if(first<last){
      pivot=first;
      i=first;
      j=last;

      while(i<j){
         while(number[i].b<=number[pivot].b&&i<last)
            i++;
         while(number[j].b>number[pivot].b)
            j--;
         if(i<j){
            temp=number[i];
            number[i]=number[j];
            number[j]=temp;
         }
      }

      temp=number[pivot];
      number[pivot]=number[j];
      number[j]=temp;
      quicksort(number,first,j-1);
      quicksort(number,j+1,last);
   }
}

int main()
{
    int n,time = 0,i;
    datatype times[200000];

    scanf("%d",&n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d %d",&times[i].a,&times[i].b);
    }
    quicksort(times,0,n - 1);
    for (i = 0; i < n; i++)
    {
        //printf("%d %d\n",times[i].a,times[i].b);
        time += times[i].a;
        if(time > times[i].b)
        {
            break;
        }
    }
    if (i == n)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }

}


Measured memory_bytes: 1792
import Data.Maybe
import Data.List
import Text.Printf
import qualified Data.ByteString.Char8 as C

getInts :: IO [Int]
getInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  _ <- getInts
  as <- getInts
  let f [] = 0
      f [_] = 0
      f (x : xs) = g x xs + f xs
      g _ [] = 0
      g x (y : ys) = g x ys + if x == y then 0 else length $ filter (\z -> z /= y && z > x - y) ys
  printf "%d\n" (f $ reverse $ sort as)


Measured memory_bytes: 4020
pub fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let h: usize = iter.next().unwrap().parse().unwrap();
    let w: usize = iter.next().unwrap().parse().unwrap();
    let mut a: Vec<Vec<usize>> = vec![vec![0;w];h];
    for i in 0..h {
        for j in 0..w {
            a[i][j] = iter.next().unwrap().parse().unwrap();
        }
    }

    let mut way: Vec<(usize, usize)> = Vec::new();
    let mut y: usize = 0;
    loop {
        if y+1<h {
            for x in 0..w {
                way.push((y,x));
            }
            y+=1;
            for x in 0..w {
                way.push((y,w-1-x));
            }
            y+=1;
        } else if y<h {
            for x in 0..w {
                way.push((y,x));
            }
            break;
        } else {
            break;
        }
    }

    let mut ret: Vec<(usize, usize, usize, usize)> = Vec::new();
    
    for i in 0..way.len()-1 {
        let cur = way[i];
        let next = way[i+1];
        if a[cur.0][cur.1] % 2 != 0 {
            a[cur.0][cur.1] -= 1;
            a[next.0][next.1] += 1;
            ret.push((cur.0,cur.1,next.0,next.1));
        }
    }

    println!("{}", ret.len());
    for tpl in ret {
        println!("{} {} {} {}", tpl.0+1, tpl.1+1, tpl.2+1, tpl.3+1);
    }
}


Measured memory_bytes: 17396
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

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

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

ll Count(string s,ll n){
    ll re = 0;
    ll cnt = 0;
    rep0(i, s.size()){
        if (s[i] == 'A') {
            ++cnt;
            re += cnt;
        }else{
            cnt = 0;
        }
    }
    return re * n;
}

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


Measured memory_bytes: 256
from collections import defaultdict
import sys
import copy

def main():
    flag = False
    while True:
        t = int(input())
        if not t:
            return
        if flag:
            print()
        flag = True
        cclist = (10,50,100,500)
        cc = list(map(int,input().split())) # 10 50 100 500
        csum = sum([c*n for c,n in zip(cclist,cc)])
        ots = otsuri(csum-t)
        for c,n1,n2 in zip(cclist, cc, ots):
            n = n1-n2
            if n <= 0:
                continue
            print(c,n)



def otsuri(n: int):
    res = [0]*4
    l = len(res)-1
    for i,c in enumerate([500,100,50,10]):
        res[l-i] = n // c
        n %= c
    return res


if __name__ == '__main__':
    main()


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

using ll = long long;
using namespace std;
constexpr ll inf = 1e15;
constexpr ll mod = 1e9+7;

ll dp[1001][1001] = {0};

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

    int Q;
    cin>>Q;
    for (int q = 0; q < Q; q++) {
        string X, Y;
        cin>>X>>Y;

        for (int i = 1; i <= X.length(); i++) {
            for (int j = 1; j <= Y.length(); j++) {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
                if (X[i-1] == Y[j-1]) dp[i][j] = max(dp[i][j], dp[i-1][j-1]+1);
            }
        }
        cout<<dp[X.length()][Y.length()]<<endl;
    }
    return 0;
}


Measured memory_bytes: 11060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mx=1e5+1;
int n,dp[mx],v[101],w[101],wi;


int main()
{
int i,j;
ll sum=0;

for(i=0;i<mx;i++)
    dp[i]=1e9+7;
    dp[0]=0;
cin>>n>>wi;
 for(i=0;i<n;i++)
    {cin>>w[i]>>v[i];
    sum+=v[i];
    }

for(i=0;i<n;i++)
{
    for(j=sum;j-v[i]>=0;j--)
        dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
}

//cout<<x<<endl;
for(i=sum;i>=0;i--)
{
    if(dp[i]<=wi)
    {cout<<i<<endl;break;}
}

return 0;}


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

int main()
{
	int n;
	cin >> n;
	vector<int64_t> hs(n);
	for (auto &h : hs)
	{
		cin >> h;
	}
	vector<int64_t> dp(n, 1LL << 60);
	dp[0] = 0;
	for (int i = 1; i < n; i++)
	{
		dp[i] = min(dp[i], dp[i - 1] + abs(hs[i] - hs[i - 1]));
		if (0 <= i - 2)
		{
			dp[i] = min(dp[i], dp[i - 2] + abs(hs[i] - hs[i - 2]));
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	long x = sc.nextLong();
	long k = sc.nextLong();
	long d = sc.nextLong();
	if (x < 0) x = -x;
	if (x/d >= k) {
	    System.out.print(x - k*d);
	} else {
	    k = k - x/d;
	    x = x - x/d * d;
	    if (k%2 == 1) System.out.print(Math.abs(x - d));
	    else { System.out.print(x); }
	}
    }
}


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

int main()
{
    long long n,a,i,j,c=0;
    cin>>n;
    long long A[n];
    for(i=0;i<n;i++)
    cin>>A[i];
    for(i=0;i<n-1;i++)
    if(A[i]<=A[i+1])c++;
    else
        A[i+1]=A[i];

    cout<<c+1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<fstream>
#include<sstream>
using namespace std;
vector<long>trn;
int main()
{
    long test,i,a,b,c;

      cin>>test;
     for(i=0;i<test;i++)
     {
         cin>>a>>b>>c;
         trn.push_back(a);
         trn.push_back(b);
         trn.push_back(c);
         sort(trn.begin(),trn.end());

          if(trn[0]*trn[0]+trn[1]*trn[1]==trn[2]*trn[2])
            cout<<"YES"<<endl;
          else
            cout<<"NO"<<endl;

          trn.clear();
     }



    return 0;
}

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

public class Main {
    public static String baseM2(int N){
        if(N==0) return "";
        if(N%2==0) return baseM2(-N/2)+"0";
        else return baseM2(-(N-1)/2)+"1";
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if(N==0) System.out.println("0");
        else System.out.println(baseM2(N));
    }
}

Measured memory_bytes: 21844
import java.util.Scanner;

 public class Main {

  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
       String C=sc.nextLine();
       String alp="abcdefghijklmnopqrstuvwxyz";
       int X=alp.indexOf(C);

      System.out.println(alp.charAt(X+1));

    }
  }

Measured memory_bytes: 21844
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;


typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

ll n, m, q;
vector<ll> a(60), b(60), c(60), d(60);
vector<ll> s(20);
ll ans = 0;

void dfs(ll x, ll y){
    if(y == n){
        ll sum = 0;
        for(ll i=0;i<q;++i){
            if(s[b[i]-1] - s[a[i]-1] == c[i]){
                sum += d[i];
            }
        }
        ans = max(ans, sum);
    }else{
        for(ll i=x;i<=m;++i){
            s[y] = i;
            dfs(i, y+1);
        }
    }
}

int main(){
    cin>>n>>m>>q;
    for(ll i=0;i<q;++i){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    dfs(1, 0);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)

using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    cout<<n*n<<"\n";
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <ctime>
#include <cmath>
#include <queue>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define PII pair<int,int>
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,b,a) for (int i=(b);i>=(a);--i)
typedef long long LL;
inline int read(){
	int x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}

const int MAXN=300005,Mo=1000000007;
int n,m,a[MAXN],b[MAXN];
int main(){
	n=read();
	int x=0,y=0,z=0;
	FOR(i,1,n) {
		a[i]=read();
		if (a[i]%4==0) z++;
		else if (a[i]%2==0) y++;
		else x++;
	}
	if ((x==0)||(y==0&&x<=z+1)||x<=z) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

/*
*/


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include  <list>
#include  <utility>
#include  <memory>
#include  <cstring>
#include  <fstream>
#include  <numeric>
using namespace std;
int main(){
  long long n,mi=10000000;
  cin>>n;
  for (long long i=1;i<=(n+1)/2;i++){
    long long cnt1=i,cnt2=n-i;
    long long lo1=cnt1/100000;
    long long lo2=cnt1%100000/10000;
    long long lo3=cnt1%10000/1000;
    long long lo4=cnt1%1000/100;
    long long lo5=cnt1%100/10;
    long long lo6=cnt1%10;
    long long mo1=cnt2/100000;
    long long mo2=cnt2%100000/10000;
    long long mo3=cnt2%10000/1000;
    long long mo4=cnt2%1000/100;
    long long mo5=cnt2%100/10;
    long long mo6=cnt2%10;
    mi=min(mi,lo1+lo2+lo3+lo4+lo5+lo6+mo1+mo2+mo3+mo4+mo5+mo6);
  }
  cout<<mi;
  return 0;
}

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

using lint = long long;

bool is_palin(string s) {
	for (int i = 0, j = s.size()-1; i < j; ++i, --j)
		if (s[i] != s[j]) return false;
	return true;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s;
    cin >> s;
    const int n = s.size()-1;
    if (is_palin(s) && is_palin(s.substr(0, n>>1)) && is_palin(s.substr((n+3)>>1, n+1)))
    	cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256