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

using namespace std;
typedef long long ll;

class UnionFind{
public:
    UnionFind(int n){
        size = n;
        parent = vector<int>(size,-1);
    }
    int getSize(){return size;}
    int getParentElement(int index){return parent[index];}
    int find(int x){
        int a = x;
        vector<int> children;
        while(parent[a]>=0){
            children.push_back(a);
            a = parent[a];
        }
        for(auto child: children){parent[child] = a;}
        return a;
    }
    int Union(int x,int y){
        int root_x = find(x);
        int root_y = find(y);
        if(root_x != root_y){
            if(parent[root_x]>=parent[root_y]){
                parent[root_x] += parent[root_y];
                parent[root_y] = root_x;
            }else{
                parent[root_y] += parent[root_x];
                parent[root_x] = root_y;
            }
        }
        return parent[root_x];
    }
private:
    int size;
    vector<int> parent;
};

int main(){
    int n,k,l;
    cin >> n >> k >> l;
    UnionFind load(n);
    UnionFind train(n);
    int p,q,r,s;
    for(int i=0;i<k;i++){
        cin >> p >> q;
        p--;q--;
        load.Union(p,q);
    }
    for(int i=0;i<l;i++){
        cin >> r >> s;
        r--;s--;
        train.Union(r,s);
    }

    map<pair<int,int>,int> mp;
    for(int i = 0; i < n; i++){
        mp[{load.find(i),train.find(i)}]++;
    }
    for(int i = 0; i < n-1; i++){
        cout << mp[{load.find(i),train.find(i)}] << " ";
    }
    cout << mp[{load.find(n-1),train.find(n-1)}] << endl;
    return 0;

}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<int> data(N);
    
  for (int i = 0; i < N; i++) 
    cin >> data.at(i);  
  
  int num = 0;
  while (1){
    for (int i = 0; i < N; i++){
   	  if (data.at(i) % 2 != 0){
        cout << num << endl;
        return 0;
      }
      else data.at(i) /= 2;
    }
    num++;
  }
  
  cout << num << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(e) e.begin(), e.end()
#define RALL(e) e.rbegin(), e.rend()
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define dbg(x) (cerr << #x << ":" << x << endl)
#define mid (l + r) / 2
#define pii pair <int, int>
#define fi first
#define sc second
#define N 1000000009

using namespace std;

#define int long long

signed main(){
	ios::sync_with_stdio(0);
	int n,k;
	cin >> n >> k;
	vector <int> ar(n);
	int sm = 0;
	for(int &x: ar){
		cin >> x;
		sm += x;
	}


	sort(ALL(ar), greater<int>());

	for(int i=0; i<n; i++){
		if(k > 0){
			sm -= ar[i];
			k--;
		}else break;
	}

	cout << sm;


	return 0;
}

Measured memory_bytes: 1792
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
			
	   Scanner sc = new Scanner(System.in);
	   int a = sc.nextInt();
	   int b = sc.nextInt();
	   
	 System.out.println((a*b)+" "+(a+b)*2);
		
	}

}

Measured memory_bytes: 17160
#include<bits/stdc++.h>
#include<chrono>
using namespace std;
using namespace chrono;
#define all(a) a.begin(), a.end()
#define sz(x) (int(x.size()))
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef vector<string> vs;
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vl a(n), b(n), c(n);
	for(int i = 0; i < n; i ++){
		cin >> a[i] >> b[i] >> c[i];
	}
	vl da(n), db(n), dc(n);
	da[0] = a[0], db[0] = b[0], dc[0] = c[0];
	for(int i = 1; i < n; i ++){
		da[i] = a[i] + max(db[i - 1], dc[i - 1]);
		db[i] = b[i] + max(dc[i - 1], da[i - 1]);
		dc[i] = c[i] + max(da[i - 1], db[i - 1]);
	}
	cout << max({da.back(), db.back(), dc.back()});
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
vector<int>arr(0);
int main(void)
{
	int a, b, c = 0; cin >> a >> b;
	for (int i = 0; i < b - a; i++)
	{
		c += i;
	}
	cout << c - a << "\n";
}



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

class Main {
    public static void main(String[] args) {
        Scanner sc = null;
        try {
            sc = new Scanner(System.in);
            Stack<Integer> carNumbers = new Stack<Integer>();
            while (sc.hasNextInt()) {
                int carNumber =sc.nextInt();
                if(carNumber!=0){
                    carNumbers.push(carNumber);
                }else{
                    System.out.println(carNumbers.pop());
                }
            }
        } finally {
            sc.close();
        }
    }
}

Measured memory_bytes: 17212
#include<iostream>

using namespace std;

int main()
{

    int a,b;

    while(cin>>a>>b&&!(a==0&&b==0))
    {
        for(int i=0;i<a;i++)
        {
            for(int j=0;j<b;j++)
            {
                cout<<'#';
            }
            cout<<endl;
        }
        cout<<endl;
    }

    return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    string s; cin >> s;
    map<char, int> c;
    rep(i,s.length()) {
        c[s[i]]++;
    }

    if (abs(c['a']-c['b']) <= 1 && abs(c['a']-c['c']) <= 1 && abs(c['b']-c['c']) <= 1)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 512
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Aman
 */


#include<bits/stdc++.h>

using namespace std;

#include <iostream>

void __print(int x) { cout << x; }

void __print(long x) { cout << x; }

void __print(long long x) { cout << x; }

template<typename T, typename V>
void __print(const pair<T, V> &x) {
    cout << '{';
    __print(x.first);
    cout << ',';
    __print(x.second);
    cout << '}';
}

template<typename T>
void __print(const T &x) {
    int f = 0;
    cout << '{';
    for (auto &i: x) cout << (f++ ? "," : ""), __print(i);
    cout << "}";
}

void _print() { cout << "]\n"; }

template<typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cout << ", ";
    _print(v...);
}


#define ll   long long
#ifdef LOCAL
#else
#define dbg(x...)
#endif


class

BProductMax {
public:


    void solve(std::istream &cin, std::ostream &cout) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        ll ans = max({a * c, a * d, b * c, b * d});
        cout << ans;
    }

};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    BProductMax solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

class Pair {
  public int first;
  public int second;
}

public class Main {
  static public void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int n, m;
    while ((n = s.nextInt()) != 0 && (m = s.nextInt()) != 0) {
      Pair[] pairs = new Pair[m];
      for (int j = 0; j < m; j++) {
        pairs[j] = new Pair();
        pairs[j].first = j + 1;
      }
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          pairs[j].second += s.nextInt();
        }
      }
      Arrays.sort(pairs, new Comparator<Pair>() {
        public int compare(Pair p1, Pair p2) {
          return p2.second - p1.second;
        }
      });
      for (int i = 0; i < m - 1; i++) {
        System.out.printf("%d ", pairs[i].first);
      }
      System.out.printf("%d\n", pairs[m - 1].first);
    }
  }
}

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

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

Measured memory_bytes: 3540
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;

const int N = 1e5 + 7;

int n, m, cnt[N];

struct note { int y, p, id; } a[N];
int cmp(note u, note v) { return u.y < v.y; }

int ans[N][2];

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) scanf("%d%d", &a[i].p, &a[i].y), a[i].id = i;
	sort(a + 1, a + m + 1, cmp);
	for (int i = 1; i <= m; i++) ans[a[i].id][0] = a[i].p, ans[a[i].id][1] = ++cnt[a[i].p];
	for (int i = 1; i <= m; i++) printf("%06d%06d\n", ans[i][0], ans[i][1]);
	return 0;
}

Measured memory_bytes: 3712
# ALDS1_6_B
def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            w = A[i]
            A[i] = A[j]
            A[j] = w
    v = A[i+1]
    A[i+1] = A[r]
    A[r] = v
    return i + 1

n = int(input())
A = list(map(int, input().split()))
#n = 12
#A = [13,19,9,5,12,8,7,4,21,2,6,11]
#standard = A[-1]
p = partition(A, 0, n-1)
# for idx, item in enumerate(A):
#     if item == standard:
#         A[idx] = "["+str(standard)+"]"
for i in range(n):
    if i:
        print(" ", end = "")
    if i == p:
        print("[", end="")
    print(A[i], end="")
    if i == p:
        print("]", end="")
print()


Measured memory_bytes: 16388
/*...Bismillahir Rahmanir Rahim...*/
#include <iostream>
using namespace std;

inline void solve(){
    int a,b,c;
    cin>>a>>b>>c;
    int mp[10]={};
    mp[a]++;
    mp[c]++;
    mp[b]++;
    if (mp[5]==2 and mp[7]==1) cout << "YES";
    else cout<<"NO";
}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n ;
  for(int i = 0; i< n ; i++){
    string s ;
    cin >> s;
    if( s == "Y"){
      cout << "Four" << endl;
      break;
    }
    if( i == n - 1 ){
      cout << "Three" << endl;
    }
  }
}

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

const int  maxnum = 7368792;

bool is_prime[maxnum];

int main() {

    while(1) {

        int m,n;

        cin >> m >> n;

        if(m==0 && n==0) break;

        for (int i = 0; i < maxnum; i++) {
            is_prime[i] = true;
        }

        is_prime[0] = is_prime[1] = false;

        vector<int> vec;


        for (int i = m; i <= maxnum; i++) {
            if (is_prime[i]) {
                vec.push_back(i);
                for (int j = 2 * i; j <= maxnum; j += i) {
                    is_prime[j] = false;
                }
                n--;
                if(n==0) break;
            }
        }

        for(int i=vec[vec.size()-1] + 1; ; i++){
            if(is_prime[i]){
                cout << i << endl;
                break;
            }
        }

    }


    return 0;
}


Measured memory_bytes: 13964
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#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;
int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;

  rep(i,s.size()){
    int c=(s[i]-'A'+n)%26;
    s[i] = (char)(c+'A');
  }
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	String w;
	int[] a;
	public void solve() {
		w = next();
		a = new int[26];
		for(int i = 0;i < w.length();i++){
			a[w.charAt(i) - 'a']++;
		}

		for(int i = 0;i < 26;i++){
			if(a[i] % 2 == 1){
				out.println("No");
				return;
			}
		}
		out.println("Yes");
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 8020
use std::io::Read;

macro_rules! debug {
($($a:expr),*) => {
eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
fn main() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut splits = s.trim().split_whitespace();
    let n : usize = splits.next().unwrap().parse::<usize>().unwrap();

    let mut v: Vec<usize> = vec![];

    for _ in 0..n {
        v.push(splits.next().unwrap().parse::<usize>().unwrap());
    }

    //debug!(n, v);

    v.sort();

    let mut ans: f64 = v[0] as f64;
    for i in 1..n {
        ans += v[i] as f64;
        ans = ans / 2.0;
    }

    println!("{}", ans);
        
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long
#define ends ' '
#define endl '\n'
#define pb push_back
#define x first
#define y second

int32_t main()
{
	#ifndef ONLINE_JUDGE
		//freopen("output.txt", "w", stdout);
	#endif
	IOS;

	int n;
	cin >> n;
	std::vector<int> v(n);

	for(int i = 0; i < n; ++i)
		cin >> v[i];
	sort(v.begin(), v.end());
	int t = 0;
	for(int x : v)
	{
		t += x;
	}

	if(2*v[n-1] < t)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <functional>
#include <iostream>
#include <memory>
#include <set>
#include <string>

using namespace std;

int main() {
	int n;
	cin >> n;
	unique_ptr<int[]> a(new int[n]);
	for (int i = 0; i < n; i++) {
		cin >> a.get()[i];
	}
	std::set<int> s(a.get(), a.get() + n);
	cout << s.size() << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>


     
#define INF 1e9
#define LINF 1e19
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define pb push_back
#define sz size()
     
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

     
const ll MOD = 1e9 + 7;
const ll ZER = 0;


int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    map<ll, ll> mp;
    rep(i, n){
        cin >> h[i];
        mp[h[i]]++;
    }
    for(auto m : mp){
        if(m.second >= k){
            cout << 0 << endl;
            return 0;
        }
    }
    sort(ALL(h));
    ll res = INF * 2;
    rep(i, n - k){
        chmin(res, h[i + k - 1] - h[i]);
    }
    cout << res << endl;
}





Measured memory_bytes: 10300
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
       Scanner in = new Scanner(System.in);
       String s = in.nextLine();
       
       for(int i = s.length() - 1; i > 0; i--){
           String t = s.substring(0, i);
           if(t.length() % 2 == 0){
               String s1 = t.substring(0, t.length() / 2);
               String s2 = t.substring(t.length() / 2, t.length());
               if(s1.equals(s2)){
                   System.out.println(i);
                   return;
               }
               
           }
       }
    }
}


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

#define ll long long int

using namespace std;

map<ll,int> num;

int main(){
    ll n;
    cin >> n;
    ll ans = 0;

    ll nn = n; bool isPrime=true;
    for(ll i=2;i<=sqrt(n)+1;i++){
        while(nn%i==0){
            if(num[i])num[i]++;
            else num[i]=1;
            nn/=i;
            isPrime=false;
        }
    }
    if(nn!=1)num[nn]=1;

    for(auto x : num) {
        ll ee=(int)1;
        while(ee<=x.second){
            x.second-=ee;
            ee++;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;


}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

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

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

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

    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    vector<ll> cnt(n);

    ll zerocnt = 0;
    ll ans = 1;
    for(int i = 0; i < n; i++){
        cnt[a[i]]++;
        if(a[i] == 0){
            zerocnt++;
        }else{
            ans *= cnt[a[i]-1];
            ans %= MOD;
            cnt[a[i]-1]--;
        }
    }

    if(zerocnt > 3){
        cout << 0 << endl;
    }else if(zerocnt == 3 || zerocnt == 2){
        cout << (ans*(ll)6)%MOD << endl;
    }else{
        cout << (ans*(ll)3)%MOD << endl;
    }

    return 0;
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int a[3];
  for (int i = 0; i < 3; i++) cin >> a[i];

  sort(a, a + 3);

  // 解答
  cout << (a[1] - a[0]) + (a[2] - a[1]) << endl;

  return 0;
}


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

int main(int argc, char *argv[]){
	int n , l;
	cin >> n >> l;
	vector<int> v(n+1);
	v[0]=0;
	int pie=0;
	for(int i=1;i<=n;++i) pie+=l+i-1;
	for(int i=1;i<=n;++i){
		v[i]=pie-(l+i-1);
	}
	int j;int min=1000000; int hit;
	for(j=1;j<=n;++j){
		if( min > abs(pie-v[j])) { min = abs(pie-v[j]); hit=j;}
	} 
	cout << v[hit] << endl;
}	

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

typedef long long ll;

int mod = 1e9 + 7;
ll p = 5e5 + 100;

int main() {	
	vector<ll> com(p + 1);
	vector<ll> inv(p + 1);
	vector<ll> mul(p + 1);
	com[0] = 1;
	for (ll i = 1; i <= p; ++i) {
		com[i] = (com[i - 1] * i) % mod;
	} 
    inv[0] = 1;
    inv[1] = 1;
	for (ll i = 2; i <= p; ++i) {
		inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod; 
	}
	mul[0] = 1;
	for (int i = 1; i <= p; ++i) {
		mul[i] = (mul[i - 1] * inv[i]) % mod;
	}
	
	int n;
	cin >> n;
	vector<ll> v(n);
	map<ll,ll> m;
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		m[v[i]]++;
	}
	for (auto &x : m) {
		ans += (x.second * ( x.second - 1)) / 2;
	}
	for (int i = 0; i < n; ++i) {
		if (m[v[i]] > 1) { 
			ll py = ((m[v[i]] - 1) *(m[v[i]] - 2)) / 2;
			ll px = ((m[v[i]]) *(m[v[i]] - 1)) / 2;
			cout << ans - (px - py) << endl; 
		}else {
			cout << ans << endl;
		}
	}
}










Measured memory_bytes: 24316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
  int N, M;  cin >> N >> M;
  vector<ll> A(N);
  vector<int> B(N);
  rep(i, N)  cin >> A[i] >> B[i];

  vector<pair<ll, int>> p;
  rep(i, N) {
    p.push_back(make_pair(A[i], B[i]));
  }
  sort(p.begin(), p.end());

  ll ans = 0;
  int cnt = 0;
  while(M > 0) {
    int d = p[cnt].second;
    ans += min(M, d) * p[cnt].first;
    M -= min(M, d);
    cnt++;
  }
  print(ans);
}


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

using namespace std;
#define ll long long
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1e9 + 7;
typedef pair<int,int>           PI;
typedef pair<ll,ll>             PL;
typedef vector<PI>               vip; 
typedef vector<int>             vi;
typedef vector<vi>              vvi;
typedef vector<ll>              vl;
typedef vector<vl>              vvl;








int main (){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll power = 1;
    REPS(i,n){
        power *= i;
        power %= mod;
    }
    cout << power << endl;


    return 0;
}

Measured memory_bytes: 896
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;



std::pair<int,int> range[300000];
std::pair<int32_t, bool> pos[200000];
int32_t N, M;
std::vector<std::pair<int, int>> graph[200000];
bool state[200000];
bool used[200000];
std::vector<int> result;
bool func(int v)
{
    used[v] = true;
    bool swaped = false;
    for (auto& next : graph[v])
    {
        if (!used[next.first]) {
            if (func(next.first)) {
                swaped = !swaped;
                result.push_back(next.second);
            }
        }
    }
    bool res = state[v] ^ swaped;
    state[v] = false;
    return res;
}

int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> N >> M;
    for (size_t i = 0; i < N; i++)
    {
        int s;
        in >> pos[i].first >> s; pos[i].second = s != 0;
    }
    std::sort(pos, pos + N);
    for (int32_t i = 0; i < M; i++)
    {
        int l, r;
        in >> l >> r;
        range[i].first  = std::lower_bound(pos, pos + N, std::pair<int32_t, bool>{l, false}) - pos;
        range[i].second = std::upper_bound(pos, pos + N, std::pair<int32_t, bool>{r, true}) - pos;
        graph[range[i].first].emplace_back(range[i].second, i);
        graph[range[i].second].emplace_back(range[i].first, i);
    }


    state[0] = pos[0].second;
    state[N] = pos[N-1].second;
    for (int i = 1; i < N; i++)
    {
        state[i] = pos[i - 1].second ^ pos[i].second;
    }
    for (int i = 0; i <= N; i++)
    {
        if (state[i]) {
            if (func(i)) {
                out << -1 << endl; return 0;
            }
        }
    }
    std::sort(all_range(result));
    out << result.size() << endl;
    for (auto& r : result) {
        out << 1+r << ' ';
    }
    out << endl;

    return 0;
}
#endif


Measured memory_bytes: 18812
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int a;
    cin >> a;
    if(a/100==a%10){
      cout <<"Yes";
    }else{
      cout << "No";
    }
    return 0;
}


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

int main(){
  long long n;
  cin >> n;
  int ans=100;
  for(int i=1;i<100001;i++){
    long long a;
    int am,bm;
    int d;
    if(n%i == 0){a=n/i;
                 am=log10(a)+1;
                 bm=log10(i)+1;
                 d=max(am,bm);
                 ans=min(ans,d);
                }
    if(n<i){break;}
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int m,d;
   cin>>m>>d;
   int c=0;
   for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=d;j++)
        {   int p=j;
          vector<int> l;
           while(p!=0)
           {    
               l.push_back(p%10);
               p=p/10;
           }
           if(l.size()==2)
           {
               if(l[0]>=2 && l[1]>=2 && l[0]*l[1]==i)
                 c++;
           }
           l.clear();
        }

    }   
    cout<<c;
  
  

}  

Measured memory_bytes: 256
import sys
def main():
    n, m = map(int, input().split())
    A = [list(input()) for _ in range(n)]
    B = [list(input()) for _ in range(m)]

    for i in range(n - m + 1):
        for j in range(n - m + 1):
            f = 1
            for k in range(m):
                for l in range(m):
                    if A[i + k][j + l] != B[k][l]:
                        f = 0
                        break
                if f == 0:
                    break
            if f:
                print("Yes")
                sys.exit()
    print("No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    int A, B, C;
    cin >> A >> B >> C;

    int c = 0;
    int m = B;

    while(1)
    {
        m = m - A;

        if(c == C)
            break;

        if(m < 0)
            break;

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

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

N = int(input())
A = np.array([int(x) for x in input().split()],dtype=np.int64)

"""
F_2 上の線形代数。基本変形で簡単な基底を得る。
"""

xor = np.bitwise_xor.reduce(A)

A = np.concatenate([np.array([1<<i for i in range(60) if xor&(1<<i)],np.int64),A])

for k in range(60,-1,-1):
    bit = 1<<k
    one = (A&bit != 0)
    i = np.where(one & (A < (1<<(k+1))))[0]
    if len(i) == 0:
        continue
    i = i[0]
    x = A[i]
    A[one] ^= x
    A[i] = x

A = A[A != 0]
A.sort()
A = A[::-1]

if len(A) > 0:
	red = np.bitwise_xor.reduce(A)
else:
    red = 0
blue = red^xor
answer = red + blue
print(answer)


Measured memory_bytes: 24200
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	string s;
	cin >> s;
	rep(i, 0, s.size()){
		if(s[i] == '?') s[i] = 'D';
	}
	cout << s;
	return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n;
vector<pair<LL, LL>> p;

int main() {
	cin >> n;
	inc(i, n) {
		LL x, y;
		cin >> x >> y;
		
		p.EB(min(x, y), max(x, y));
	}
	
	sort(ALL(p));
	LL xmin = p[0].FI, xmax = p[n - 1].FI;
	
	inc(i, n) { swap(p[i].FI, p[i].SE); }
	sort(ALL(p));
	LL ymin = p[0].FI, ymax = p[n - 1].FI;
	
	PQ<pair<LL, LL>> q;
	inc(i, n) { q.push(p[i]); }
	
	LL ans = (xmax - xmin) * (ymax - ymin);
	while(! q.empty()) {
		auto e = q.top(); q.pop();
		if(e.FI <= e.SE) { break; }
		q.emplace(e.SE, e.FI);
		
		setmin(ymin, e.SE);
		setmax(xmax, e.FI);
		ymax = q.top().FI;
		
		setmin(ans, (xmax - xmin) * (ymax - ymin));
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 12396
K, A, B = map(int, input().split())
rem = K-(A-1)

if rem>0:
    if rem%2==0:
        print(max(K+1, A+(B-A)*(rem//2)))
    else:
        print(max(K+1, A+(B-A)*(rem//2)+1))
else:
    print(K+1)

Measured memory_bytes: 38256
from numpy import*
from scipy.sparse import*
_,*s=open(0)
s=array([list(map(int,t[:-1]))for t in s])
m=csgraph.floyd_warshall(csr_matrix(s))
i=m[0]%2<1
j=i^True
print(all(s[i][:,i]<1)*all(s[j][:,j]<1)*int(m.max()+1)or-1)

Measured memory_bytes: 15468
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;


int main(){
    int h,w,n;
    cin>>h>>w>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    vector<vector<int>> ans(h,vector<int>(w));
    int col=1;
    int cnt=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            ans[i][j]=col;
            cnt++;
            if(a[col-1]==cnt){
                col++;
                cnt=0;
            }
        }
    }
    for(int i=0;i<h;i++){
        if(i%2!=0)reverse(ans[i].begin(),ans[i].end());
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }
    
    

}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
using ll = long long;
using namespace std;

string S;

int main() {
	cin >> S;
	size_t n = S.size();
	int ans;
	if (n % 2 == 0) {
		ans = n / 2;
	}
	else {
		ans = (n + 1) / 2;
	}
	const int c = S[ans - 1];
	for (size_t i = 0; i < n / 2; i++)
	{
		if (S[n - ans - 1] == c && S[ans] == c) {
			ans++;
		}
		else {
			break;
		}
	}
	cout << ans << endl;;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
namespace P_TEMPLATE{
	#define endl '\n'
	#define rgi register int
	typedef long long ll;
	class fastin{private:int _ch,_f;
	public:inline fastin&operator>>(char&c){c=getchar();return*this;}
	template<typename _Tp>inline fastin&operator>>(_Tp&_x){
	_x=0;while(!isdigit(_ch))_f|=(_ch==45),_ch=getchar();
	while(isdigit(_ch))_x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
	_f&&(_x=-_x,_f=0);return*this;}fastin(){_ch=_f=0;}
	}fin;class fastout{private:int _num[32],_head;
	public:inline fastout&operator<<(char c){putchar(c);return*this;}
	template<typename _Tp> inline fastout&operator<<(_Tp _x){
	_Tp _k;if(_x==0){putchar('0');return *this;}if(_x<0)putchar('-'),_x=-_x;
	while(_x>0)_k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
	while(_head>0)putchar(_num[_head]),--_head;return*this;}fastout(){_head=0;}
	}fout;inline void P_INIT(){
	#ifdef D_STDOUT_UNBUFFERED
	setbuf(stdout,NULL),setbuf(stdin,NULL);
	#endif
}}using namespace P_TEMPLATE;
// ----------------------------
// #define int ll
using namespace std;
const int maxn=200004;
const int mod=1000000007,inf=1201201201;

signed main()
{P_INIT();
	string s;
	cin>>s;
	if(s[s.length()-1]=='s') s+="es";
	else s+="s";
	cout<<s;
	return 0;
}
// ----------------------------
// by imzzy

Measured memory_bytes: 3624
if __name__ == "__main__":
    S = input()
    S = list(S)

    count = 0
    maxc = 0
    for i in S:
        if i == 'R':
            count += 1
            if maxc < count:
                maxc = count
        else:
            if maxc < count:
                maxc = count
            count = 0

    print(maxc)

Measured memory_bytes: 9040
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
f=0
for i in range(N):
    if A[i]<=f+B[i]:
        ans+=A[i]
        if f>=A[i]:
            f=B[i]
        else:
            f=f+B[i]-A[i]
    else:
        ans+=f+B[i]
        f=0
ans+=min(A[N],f)
print(ans)


Measured memory_bytes: 82020
#include<stdio.h>
int main(){
int S[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
int H[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
int C[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
int D[13]={1,2,3,4,5,6,7,8,9,10,11,12,13};
int num,n,i;
char mark; 

scanf("%d", &n);
for(i=0; i<n*2; i++){
scanf("%c %d", &mark, &num);
	if(mark=='S'){
		S[num-1]=0;
	}else if(mark=='H'){
		H[num-1]=0;
	}else if(mark=='C'){
		C[num-1]=0;
	}else if(mark=='D'){
		D[num-1]=0;
	}
}

for(i=0; i<13; i++){
	if(S[i]==0){
		printf("");
	}else{
		printf("S %d\n", S[i]);
	}
}

for(i=0; i<13; i++){
	if(H[i]==0){
		printf("");
	}else{
		printf("H %d\n", H[i]);
	}
}

for(i=0; i<13; i++){
	if(C[i]==0){
		printf("");
	}else{
		printf("C %d\n", C[i]);
	}
}

for(i=0; i<13; i++){
	if(D[i]==0){
		printf("");
	}else{
		printf("D %d\n", D[i]);
	}
}

return 0;

}

Measured memory_bytes: 596
package main

import "fmt"

func main() {
	var N, T, A float64
	fmt.Scan(&N, &T, &A)
	idx, cur := -1, float64(1e10)
	for i := 0; i < int(N); i++ {
		var H float64
		fmt.Scan(&H)
		mean := T - H*0.006
		if abs(cur-A) >= abs(mean-A) {
			idx = i + 1
			cur = mean
		}
	}
	fmt.Println(idx)
}

func abs(x float64) float64 {
	if x < 0 {
		x *= -1
	}
	return x
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

int main()
{
	FAST;
	ll n, l;
	cin >> n >> l;
	if(l >= 0)
	{
		ll ans = 0, i;
		fr(i,1,n)
		{
			ans += l+i;	
		}	
		cout << ans;
	}	
	else
	{
		ll ans = 0, i;
		if(l + n - 1 >= 0)
		{
			fr(i,0,n)
				ans += l+i;
		}
		else
		{
			fr(i,0,n-1)
				ans += l+i;
		}
		cout << ans;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

signed main(){

    string s;
    cin >> s;
    ll n = s.size();
    ll ans[n] = {};

    ll dp[21][n]; 
    rep(i,0,n) dp[0][i] = (s[i] == 'L' ? i-1 : i+1 );

    rep(i,1,21){
        rep(j,0,n){
            dp[i][j] = dp[i-1][dp[i-1][j]];
        }
    }

    rep(i,0,n) ans[dp[20][i]]++;

    rep(i,0,n) cout << ans[i] << (i-n+1?" ":"");
    cout << endl;
    return 0;
}

Measured memory_bytes: 17920
from collections import Counter as C

N = int(input())
A = [int(a) for a in input().split()]

B = C(A)
ma = max(B)
mi = min(B)

if (ma==mi*2 and B[ma]>=2 and B[mi]==1) or (ma==mi*2-1 and B[ma]>=2 and B[mi]==2):
    for i in range(mi+1,ma):
        if B[i] < 2:
            print("Impossible")
            break
    else:
        print("Possible")
else:
    print("Impossible")

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

class SegTree {
private:
    lint l, r, v, lazy;
    SegTree *sl, *sr;

public:
    SegTree(lint* arr, int l, int r) 
        : l(l), r(r), lazy(0), sl(NULL), sr(NULL) {
        if (l == r) {
            v = arr != NULL ? arr[l] : 0;
            return;
        }

        int m = l + r >> 1;
        sl = new SegTree(arr, l, m);
        sr = new SegTree(arr, m + 1, r);
        
        // Recalculate node
        v = sl->get() + sr->get();
    }

    // Get size of segment tree
    int size() { return r - l + 1; }

    // a[ql..qr] += qv
    void update(int ql, int qr, int qv) {
        if (ql == l && qr == r) {
            lazy += qv;
            return;
        }
        // Push down
        sl->lazy += lazy;
        sr->lazy += lazy;
        lazy = 0;
        // Update
        int m = l + r >> 1;
        if (qr <= m) {
            sl->update(ql, qr, qv);
        } else if (ql > m) {
            sr->update(ql, qr, qv);
        } else {
            sl->update(ql, m, qv);
            sr->update(m + 1, qr, qv);
        }
        // Recalculate
        v = sl->get() + sr->get() + lazy * size();
    }

    // a[l] + a[l+1] + ... + a[r]
    lint get() {
        return v + lazy * size();
    }

    // a[ql] + a[ql+1] + ... + a[qr]
    lint query(int ql, int qr) {
        if (ql == l && qr == r) return get();

        int m = l + r >> 1;
        lint ans = lazy * (qr - ql + 1);
        if (qr <= m) {
            ans += sl->query(ql, qr);
        } else if (ql > m) {
            ans += sr->query(ql, qr);
        } else {
            ans += sl->query(ql, m) + sr->query(m + 1, qr);
        }
        return ans;
    }
};

// SegTree tree(NULL, 1, 100000);

int main() {
    int n, q;
    cin >> n >> q;
    SegTree* tree = new SegTree(NULL, 1, n);
    for (int i = 0; i < q; i++) {
        int t; cin >> t;
        if (t == 0) {
            int s, t, x; cin >> s >> t >> x;
            tree->update(s, t, x);
        } else {
            int s, t; cin >> s >> t;
            cout << tree->query(s, t) << endl;
        }
    }
}


Measured memory_bytes: 15592
N = int(input())
if N == 0:
  print(0)
  quit()

S = ''
while N != 0:
  if N % 2 == 0:
    S += '0'
    N //= -2
  else:
    S += '1'
    N -= 1
    N //= -2

print(S[::-1])

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

int main(){
  int n;
  cin >> n;
  map<int,int> a;
  rep(i,n){
      int tmp;
      cin >> tmp;
      a[tmp]++; 
  }
  bool diff = true;
  for(auto m : a){
      if(m.second > 1) diff = false;
  }
  if(diff) cout << "YES" << endl;
  else cout << "NO" << endl;

}

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

int main(){
	int a,b;
	cin>>a>>b;
	if(a<b)cout<<"a < b"<<endl;
	else if(a>b)cout<<"a > b"<<endl;
	else if(a==b)cout<<"a == b"<<endl;
	
	return 0;
}



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

using namespace std;

const int MAX_N = 2e5;

int n;
long long a[MAX_N];
long long b[MAX_N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    long long d = 0;
    for (int i = n - 1; i >= 0; i--) {
        a[i] += d;
        long long nx = (a[i] + b[i] - 1) / b[i] * b[i];
        d += nx - a[i];
    }
    cout << d << "\n";
}


Measured memory_bytes: 1792
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    map < int, int > mp;
    int n;
    cin >> n;
    while (n--) {
        int x;
        cin >> x;
        mp[x]++;
        mp[x + 1]++;
        mp[x - 1]++;
    }
    int ans = 0;
    for (auto it : mp) ans = max(ans, it.second);
    cout << ans;
    return 0;
}

Measured memory_bytes: 4736
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(),
			x = 0, m = 0, i;
		String s = sc.next();
		for(i = 0; i < n; i++){
			if(s.charAt(i) == 'I')x+=1;
			if(s.charAt(i) == 'D')x-=1;
			if(m < x)m = x;
		}
		System.out.println(m);
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    string st;
    cin>>st;
    int ans=st.size();
    REP(i,st.size()-1){
        if(st[i]!=st[i+1]){
            ans=min(ans,max(i+1,(int)st.size()-i-1));
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    string S;
    cin >> S;
    S += "!!";
    int N = S.size();
    int64_t ans = 0, a = 0, bc = 0;
    int pt = 0;
    while(pt < N){
        if(S[pt] == 'A'){
            a++;
            pt++;
        }else if(S.substr(pt, 2) == "BC"){
            ans += a;
            pt += 2;
        }else{
            a = bc = 0;
            pt++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 644
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static boolean solve() {
		int n = in.nextInt();
		if (n == 0) return false;

		int[] k = new int[n];
		for (int i=0; i<n; i++) {
			k[i] = in.nextInt();
		}
		String s = in.next();
		int pos = 0;
		for (int i=0; i<s.length(); i++, pos = (pos+1)%n) {
			int c = 'a' <= s.charAt(i) && s.charAt(i) <= 'z' ? s.charAt(i) - 'a' : (s.charAt(i) - 'A' + 26);
			c = (c + 52 - k[pos])%52;
			out.print(c < 26 ? (char)(c + 'a') : (char)(c + 'A' - 26));
		}
		out.println();


		return true;
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		while(solve());
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 34208