akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
  int i,n;
  double say;
  char di[9],fr[5];
  di[8]=fr[4]='\0';
  do{
    scanf("%lf",&say);
    if(say<0) break;
    for(i=0;i<8;i++) di[i]='0';
    for(i=0;i<4;i++) fr[i]='0';
    n=say; say-=(double)((int)say);
    for(i=0;i<8&&n!=0;i++,n>>=1) di[7-i]=n%2+'0';
    if(n){
      printf("NA\n");
      continue;
    }
    for(i=0;i<4&&say!=0.0;i++,say=(say*2)-(double)((int)(say*2)))
      fr[i]=say*2+'0';
    if(say){
      printf("NA\n");
      continue;
    }
    printf("%s.%s\n",di,fr);
  }while(1);
  return 0;
}

Measured memory_bytes: 0
/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define endl "\n"
#define inf 1e18

void solve(){
	ll n; cin>>n;
	ll ans = 0;
	ll x = n/500;
	ans += (1000*x);
	n %= 500;
	x = n/5;
	ans += (5*x);
	cout<<ans<<endl;
}

int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        double N = sc.nextInt();
        double a = 0;
if(N%2 == 0) a = (double)(1.0/2.0);
else a = ((int)((N/2)+1))/N;
        
System.out.println(a);
    }
}


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

vector<pair<string, pair<string,string>>> books;

void search_books(string qname, string qauthor, string qfrom, string qto){
    for(int i=0;i<books.size();++i){
        if(books[i].first.find(qname)==string::npos&&qname.at(0)!='*') continue;
        if(books[i].second.first.find(qauthor)==string::npos&&qauthor.at(0)!='*') continue;
        if(books[i].second.second<qfrom&&qfrom.at(0)!='*') continue;
        if(books[i].second.second>qto&&qto.at(0)!='*') continue;
        cout << books[i].first << endl;
    }

    return;
}

int main() {
    for(int N;cin>>N;){
        for(int i=0;i<N;++i){
            string name,author,date;
            cin>>name>>author>>date;
            books.push_back(make_pair(name,make_pair(author,date)));
        }
        int Q;
        cin>>Q;
        for(int i=0;i<Q;++i){
            string qname,qauthor,qfrom,qto;
            cin>>qname>>qauthor>>qfrom>>qto;
            search_books(qname,qauthor,qfrom,qto);
            if(i!=Q-1) cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n,m;cin >> n >> m;
    vector<int> a(m);
    rep(i,m) cin >> a[i];
    ll ans = SUM(a,0);
    if(n-ans>=0) cout << n-ans << endl;
    else cout << -1 << endl;
}
// ll n;cin >> n;
// vector<int> a(n);
// rep(i,n) cin >> a[i];

// cout << (res?"Yes":"No") << endl;
// cout << ans << endl;

Measured memory_bytes: 3668
////////////////////////////////////////////////////////////////
//
//    (☝ ՞ਊ ՞)☝ << Be accept!!
//
//    C++ format for competitive professional v1.0
//
//    GCC is recommendation.
//
////////////////////////////////////////////////////////////////
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<time.h>
#include<random>
#include<map>
#include<thread>
#include<tuple>
#include<boost/multiprecision/cpp_int.hpp>
#define rep(i,n) for(int i = 0;i < n;i++)
using ll = long long;
using namespace std;
using namespace boost::multiprecision;//cpp_int
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
int inline setup(void) {//set
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	return 0;
}
int lenght(char* str){//getcharlengh
	int i = 0;
	while (str[i]) {
		i++;
	}
	return i;
}
int gcd(long long a, long long b) {
	if (a < b)return gcd(b, a);
	long long r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
#define DEBUG
int main(int argc, const char* argv[]) {
	setup();

	int h, w, n;
	cin >> h >> w >> n;
	int bigger;
	bigger = max(h, w);
	int ans;
	ans = n / bigger;
	if (bigger * ans - n != 0) {
		ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include<time.h>
#include<cmath>
#include<vector>
using namespace std;

int main(void)
{
	long long a, b,x,ans;
	cin >> a >> b >> x;

	long long A, B;

	B = b / x + 1;
	if (a == 0) {
		A = 0;
	}
	else {
		A = (a - 1) / x + 1;
	}

	ans = B - A;
	cout << ans;
	cout << endl;


}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;
int main()
{
    ll a, b;
    cin >> a >> b;

    if (a * b <= 0)
        puts("Zero");
    else if (a > 0 || (a < 0 && (a - b + 1) % 2 == 0))
        puts("Positive");
    else
        puts("Negative");
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int n, q;
  string s;
  cin >> n >> q;
  cin >> s;
  vector<int> l(q), r(q);

  for (int i = 0; i < q; i++){
    cin >> l[i] >> r[i];
    
  }
  vector<int> acl(n + 5, 0), acr(n + 5, 0);
  for (int i = 0; i < n - 1; i++){
    if(s[i] == 'A' && s[i+1] == 'C'){
      acl[i]++;
      acr[i + 1]++;
    }
    acl[i + 1] = acl[i];
    acr[i + 2] = acr[i + 1];
  }
  
  /*
  for (int i = 0; i < n; i++){
    cout << acl[i] << " " << acr[i] << "\n";
  }
  */

  for (int i = 0; i < q; i++)
  {
    cout << acr[r[i] - 1] - acl[l[i] - 2] << "\n";
    }
  

  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    string a,b;
    cin>>a>>b;
    ll cnt = 0;
    for(ll i=0;i<a.size();i++)
    {
        if(a[i] == b[i])
            cnt++;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	min, sum := 10, 0
	time := make([]int, 5)
	for i := 0; i < 5; i++ {
		fmt.Scan(&time[i])
		t := (time[i] % 10)
		if t != 0 && t < min {
			min = t
		}
		if t == 0 {
			sum += time[i]
		} else {
			sum += time[i] + 10 - t
		}
	}

	fmt.Println(sum - (10 - min))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second


void solve()
{
    int n;cin>>n;
    vector<int>l(n);
    REP(i,n)cin>>l[i];
    sort(ALL(l));
    int ans=0;
    REP(i,n)rep(j,i+1,n)rep(k,j+1,n)
        if(l[k]<l[i]+l[j])ans++;
    cout<<ans<<endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;

const ll MAX=1000000000000000000;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];        
    }
    auto z=find(a.begin(),a.end(),0);
    if(z!=a.end()){
        cout<<0<<endl;
    }else{
        ll ans=1;
        for(ll i=0;i<n;i++){                        
            if(MAX/ans<a[i]){
                ans=-1;
                break;
            }
            ans*=a[i];
        }
        cout<<ans<<endl;        
    }
    
    return 0;
}

Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
const int MOD=1e9+7;
#define pb push_back
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
#define ci cout<<"impossible\n"
typedef unsigned long long int ull;
typedef long long int ll;
const int MAX=500005;
ll ar[MAX],br[MAX];
const int M=1e4;
ll cnt[M];
int main()
{
    string s,t;
    ll n;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=0;
    ll val=0;
    val=a*c;
    val=max(val,a*d);
    val=max(val,b*c);
    val=max(val,b*d);
    cout<<val<<endl;
}




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

template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

int mul(const int r1, const int c1, const int r2, const int c2) {
	assert(c1 == r2);
	return r1 * c2 * r2;
}

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

	vector<int> R(n), C(n);
	for(int i = 0; i < n; ++i) {
		cin >> R[i] >> C[i];
	}

	constexpr int INF = (1 << 29);
	vector<vector<int>> dp(n, vector<int>(n + 1, INF));
	for(int i = 0; i < n; ++i) {
		dp[i][i + 1] = 0;
	}

	for(int len = 0; len <= n; ++len) {
		for(int l = 0; l + len <= n; ++l) {
			const int r = l + len;
			for(int i = l + 1; i < r; ++i) {
				chmin(dp[l][r], dp[l][i] + dp[i][r] + mul(R[l], C[i - 1], R[i], C[r - 1]));
			}
		}
	}

	cout << dp[0][n] << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1256
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

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

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	return a.second < b.second;
}

bool check[100000];
long tall[100000];

int main()
{
	long x;
	cin >> x;
	for (int i = 0; i < 20000; i++)
	{
		for (int j = 0; j < 20000; j++)
		{
			if (((long long)i * i * i * i * i) - ((long long)j * j * j * j * j) == x)
			{
				cout << i << " " << j;
				return 0;
			}

			if (((long long)i * i * i * i * i) + ((long long)j * j * j * j * j) == x)
			{
				cout << i << " " << -j;
				return 0;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 34220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

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

    vector<ll> a(n),d(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    ll k;
    if(sum % ((ll)n*(n+1)/2)==0){
        k = sum / ((ll)n*(n+1)/2);
    }else{
        cout << "NO" << endl;
        return 0;
    }


    for(int i = 0; i < n; i++){
        d[i] = max(a[i] - a[(i+1)%n] + k,0LL);
    }
    ll q = 0;
    for(int i = 0; i < n; i++){
        if(d[i]%(ll)n != 0){
            cout << "NO" << endl;
            return 0;
        }else{
            q += d[i]/(ll)n;
        }
    }
    if(k==q){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]
res = 0
for i in range(N - 1, - 1, -1):
    res += (X[i][1] - (X[i][0] + res) % X[i][1]) % X[i][1]
print(res)


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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin>>n;
    vll c(n);
    rep(i, n) cin>>c[i];

    const int mod = 1e9 + 7;

    vll left(200200, -1), dp(200200, 0);
    dp[0] = 1;
    for(int i = 0; i < n; i++) {
        dp[i + 1] = dp[i]; 
        if (left[c[i]] >= 0 and left[c[i]] < i - 1) {
            dp[i + 1] += dp[left[c[i]] + 1];
            dp[i + 1] %= mod;
        }
        left[c[i]] = i;
    }

    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws Exception {
		OriginScanner os = new OriginScanner();
		PrintWriter pw = new PrintWriter(System.out);
		
		int h = os.nextInt();
		int a = os.nextInt();
		
		int c = 0;
		do {
			h -= a;
			c++;
		}
		while (h > 0);
		pw.println(c);
		pw.close();
	}
	
	static class OriginScanner {
		private BufferedReader br;
		private StringTokenizer st;
		
		public OriginScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String nextLine() {
			String str = null;
			try {
				str = br.readLine();
			}
			catch (IOException e) {
				System.out.println(e);
			}
			return str;
		}
		String next() {
			if (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(nextLine());
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
	for (auto i : a) cerr << i << ' ';\
	cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

map<int, map<int, vector<int>>> e;
map<int, vector<int>> cols;
map<int, vector<int>> elist;

int comp_num = 0;
map<int, int> comp;

vector<int> p, q, c, ix;
void go(int v, int color) {
    if (comp.find(v) != comp.end()) return;
    comp[v] = comp_num;
    for (int i : e[color][v]) {
        if (p[i] == v) go(q[i], color);
        else go(p[i], color);
    }
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int n, m;
    cin >> n >> m;
    p.resize(m), q.resize(m), c.resize(m), ix.resize(m);
    forn(i, 0, m) {
        cin >> p[i] >> q[i] >> c[i];
        --p[i], --q[i];
    }
    forn(i, 0, m) elist[c[i]].eb(i);
    forn(i, 0, m) {
        cols[c[i]].eb(p[i]);
        cols[c[i]].eb(q[i]);
    }
    forn(i, 0, m) {
        e[c[i]][p[i]].eb(i);
        e[c[i]][q[i]].eb(i);
    }
    for (auto &x : cols) {
        comp.clear();
        for (int v : x.sn) {
            ++comp_num;
            go(v, x.fs);
        }
        for (int i : elist[x.fs])
            ix[i] = comp[p[i]];
    }
    vector<vector<int>> ixs(n);
    forn(i, 0, m) {
        ixs[p[i]].eb(ix[i]);
        ixs[q[i]].eb(ix[i]);
    }
    vector<int> dist(n, INF);
    set<int> used_comp;
    vector<int> qu;
    int cur_dist = 1;
    qu.eb(0);
    dist[0] = 0;
    map<int, vector<int>> ixlist;
    forn(i, 0, m) {
        ixlist[ix[i]].eb(i);
    }
    while (!qu.empty()) {
        vector<int> nq;
        for (int i : qu) for (int x : ixs[i]) if (used_comp.find(x) == used_comp.end()) {
            used_comp.insert(x);
            for (int j : ixlist[x]) {

                if (dist[p[j]] == INF) nq.eb(p[j]);
                if (dist[p[j]] == INF) dist[p[j]] = cur_dist;
                if (dist[q[j]] == INF) nq.eb(q[j]);
                if (dist[q[j]] == INF) dist[q[j]] = cur_dist;
            }
        }
        qu = nq;
        ++cur_dist;
    }
    //forn(i, 0, n) cout << dist[i] << ' ';
    //cout << '\n';
    int ans = dist[n - 1];
    if (ans == INF) ans = -1;
    cout << ans << '\n';
}



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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    ll n, k;
    cin >> n >> k;
    
    cout << (ll)( (ll)k * pow(k-1, n-1) ) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <math.h>

int main()
{
  int n, m;
  scanf("%d %d",&n, &m);
  int i = 0;
  int head = 1;
  int tail = n;
  // odd
  for (i = 0; i < m; i+=2) {
    printf("%d %d\n", head++, tail--);
  }
  // even
  head = n/2;
  tail = head+2;
  for (i = 0; i < m/2; i++) {
    printf("%d %d\n", head--, tail++);
  }

  return 0;
}



Measured memory_bytes: 1700
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

//union-find
#define UFLIMIT (1<<17)
int unicnt[UFLIMIT+10];//正ならcnt、非正なら根のindex
void ufinit(int n){rep(i,0,n)unicnt[i]=1;}
int root(int x){return unicnt[x]<=0?-(unicnt[x]=-root(-unicnt[x])):x;}
int same(int x,int y){return root(x)==root(y);}
void uni(int x,int y){if((x=root(x))==(y=root(y)))return;if(unicnt[x]<unicnt[y]){int t=x;x=y;y=t;}unicnt[x]+=unicnt[y];unicnt[y]=-x;}
#undef UFLIMIT

int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	ufinit(n);
	while(m--){
		int a,b;
		scanf("%d%d",&a,&b);
		uni(a,b);
	}
	scanf("%d",&m);
	while(m--){
		int a,b;
		scanf("%d%d",&a,&b);
		puts(same(a,b)?"yes":"no");
	}
}


Measured memory_bytes: 2060
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=200200;
char s[N];
int n;
int main(){
	scanf("%s",s);
	n=strlen(s);
	int ans=0;
	for(int i=0;i<n;i++){
		if(i==0||s[i]!=s[i-1]){
			ans++;
		}
		else if(i+1<n){
			ans++;
			i++;
			if(i+1<n){
				ans++;
				i++;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    int A, B;
    cin >> A >> B;
    for (int i = 0; i < 1010; i++) {
        if (floor(i * 0.08) == A && floor(i * 0.10) == B) {
            cout << i << endl;
            return 0;
        }
    }
    puts("-1");
}

Measured memory_bytes: 256
S = str(input())
o = ["L","U","D"]
e = ["R","U","D"]

ans = 1
for i, s in enumerate(S):
  if (i+1) % 2 == 0:
    if s not in o:
      ans = 0
      break
  else:
    if s not in e:
      ans = 0
      break
if ans:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
// AOJ 0279
#include<cstdio>
#include<algorithm>
#define rep(i,a) for( int i = 0; i != (a); ++i )

int N;

int main()
{
	while( scanf( "%d", &N ), N )
	{
		bool fl = false;
		int cnt = 0;
		rep( i, N )
		{
			int k;
			scanf( "%d", &k );
			if( k >= 2 )
				fl = true;
			if( !k )
				++cnt;
		}

		if( !fl )
		{
			puts("NA");
			continue;
		}

		printf( "%d\n", N+1-cnt );
	}

	return 0;
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const ll INF = 1e18;

int main(){
  ll n, k;
  cin >> n >> k;
  ll p[n];
  rep(i,n) {
    cin >> p[i];
    p[i]--;
  }
  ll c[n];
  rep(i,n) cin >> c[i];
  ll ans = -INF;
  rep(id,n) {
    vector<ll> sum;
    vector<ll> u(n);
    sum.push_back(0);
    u[id] = 0;
    int pos = id;
    while(!u[p[pos]]) {
      pos = p[pos];
      u[pos] = sum.size();
      sum.push_back(sum.back()+c[pos]);
    }
    ll stop = sum.size();
    pos = p[pos];
    ll start = u[pos];
    sum.push_back(sum.back()+c[pos]);
    ll d = stop - start;
    ll sd = sum[stop] - sum[start];
    if(k <= start) {
      for(int i = 1; i <= k; i++) ans = max(ans,sum[i]);
    } else {
      for(int i = 1; i <= min(k,stop); i++) ans = max(ans,sum[i]);
      if(sd > 0) {
        ll res = sum[start];
        ll step = k - start;
        res += sd*(step/d);
        ans = max(ans,res);
        for(int i = 1; i <= min(d,step%d); i++) ans = max(ans,res+sum[start+i]-sum[start]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3804
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>

#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 pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) rep(i, begin, end) PRINT_ARRAY(name, i)


using namespace std;

typedef long long ll;

int N;
ll ans;
ll minA = 1000000005;

int main(void) {
    scanf("%d", &N);
    
    int c = 0;
    rep(i, 0, N) {
      ll A;
      scanf("%lld", &A);
      if ( A< 0 ) {
        c++;
        A *= -1;
      } 
      ans += A;
      minA = min(A, minA);
    }
    
    if (c%2==0) printf("%lld\n", ans);
    else printf("%lld\n", ans - minA*2);

	return 0;
}


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

const int MOD = (int)1e9+7;

void dfs(vector<vector<bool>> &graph,vector<bool> &visited,int v,int N,int &ans){
  bool check=true;
  for(int i=0;i<N;i++)  if(!visited.at(i)) check=false;
  if(check){
    ans++;
    return;
  }

  for(int i=0;i<N;i++){
    if(graph.at(v).at(i)==true && visited.at(i)==false){
      visited.at(i)=true;
      dfs(graph,visited,i,N,ans);
      visited.at(i)=false;
    }
  }

  return;
}

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> a(M);
  vector<int> b(M);
  for(int i=0;i<M;i++){
    cin >> a.at(i) >> b.at(i);
    a.at(i)--;
    b.at(i)--;
  }

  vector<vector<bool>>  graph(N,vector<bool>(N,false));
  for(int i=0;i<M;i++){
    graph.at(a.at(i)).at(b.at(i))=true;
    graph.at(b.at(i)).at(a.at(i))=true;
  }

  vector<bool> visited(N,false);
  visited.at(0)=true;
  int ans=0;
  dfs(graph,visited,0,N,ans);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  string s; cin >> s;
  for (char c : s) cout << 'x';
  cout << '\n';
  return 0;
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

string s;
int res;

int main()
{
  while(cin >> s){
    rep(i, s.size()){
      int tmp = 0;
      while(s[i] >= '0' && s[i] <= '9'){
        tmp *= 10;
        tmp += s[i] - '0';
        i++;
      }
      res += tmp;
    }
  }

  printf("%d\n", res);

  return 0;
}

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

using namespace std;

int main() {
	int a, b; scanf("%d%d", &a, &b);
	if(a <= 0 && b >= 0) { puts("Zero"); return 0; }
	if(a > 0 || ((b - a) & 1)) { puts("Positive"); return 0; }
	puts("Negative");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = 1e9+7;
const int SIZE = 1e6+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;

char s[200009];

int main(){
	scanf("%s",s);
	int n=LEN(s);
	stack<char> t;
	REP(i,n){
		if(SZ(t)==0){t.push(s[i]);}
		else{
			if(s[i]=='T'&&t.top()=='S'){
				t.pop();
			}
			else{
				t.push(s[i]);
			}
		}
	}
	printf("%d",SZ(t));
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll A, B, C;
    cin >> A >> B >> C;

    if(A % 2 or B % 2 or C % 2) drop(0);
    if(A == B and B == C) drop(-1);

    ll ct = 0;
    while(A % 2 == 0 and B % 2 == 0 and C % 2 == 0){
        ll a, b, c;
        a = (B + C) / 2;
        b = (C + A) / 2;
        c = (A + B) / 2;
        A = a, B = b, C = c;
        ++ct;
    }

    print(ct);

    return 0;
}

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

int main() {
    int N; cin >> N;
    vector<ll> a(N);
    for(int i = 0; i < N; ++i) cin >> a[i];
    ll ans = 0;
    for(int i = 1; i < N; ++i) {
        int l = 0,r = N-1;
        ll suml = 0, sumr = 0;
        map<int,int> mp;
        mp[0] = mp[N-1] = 1;
        while(l < N-1 - i && i < r && mp[l]==1 && mp[r]==1) {
            suml += a[l];
            sumr += a[r];
            ans = max(ans,suml+sumr);
            l += i;
            r -= i;
            mp[l]++;
            mp[r]++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

#include <climits>

using namespace std;


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

	vector<int> a(m);
	vector<int> b(m);
	vector<int> c(n+1);

	for (int i = 0; i < m; i ++) cin >> a[i] >> b[i];
	
	for (int i = 0; i < m; i++) {
		c[a[i]]++;
		c[b[i]]++;
	}

	for (int i = 1; i <= n; i++)cout << c[i] << endl;

	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  li a,b; cin >>a >>b;
  printf("%d",(a+b-1)/b);
  
}

/// confirm df==0 ///


Measured memory_bytes: 256
N = int(input())
ans = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for i in range(N):
    s = input()
    if(s == 'AC'):
        ans['AC'] = ans['AC'] + 1
    elif(s == 'WA'):
        ans['WA'] = ans['WA'] + 1
    elif(s == 'TLE'):
        ans['TLE'] = ans['TLE'] + 1
    elif(s == 'RE'):
        ans['RE'] = ans['RE'] + 1
print('AC x {}' .format(ans['AC']))
print('WA x {}'.format(ans['WA']))
print('TLE x {}'.format(ans['TLE']))
print('RE x {}'.format(ans['RE']))


Measured memory_bytes: 9220
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N = sc.nextInt();
        int M = sc.nextInt();
        ArrayList<Integer> a = new ArrayList<Integer>();
        ArrayList<Integer> b = new ArrayList<Integer>();
        ArrayList<Integer> c = new ArrayList<Integer>();
        ArrayList<Integer> d = new ArrayList<Integer>();
        for(int i =0;i<N;i++){
            a.add(sc.nextInt());
            b.add(sc.nextInt());
        }
        for(int i =0;i<M;i++){
            c.add(sc.nextInt());
            d.add(sc.nextInt());
        }
        for(int i = 0;i<N;i++){
            int kyori = -1;
            int x = a.get(i);
            int y = b.get(i);
            int out = 1;
            for(int j =0;j<M;j++){
                int xc = c.get(j);
                int yd = d.get(j);
                if(kyori==-1){
                    kyori = Math.abs(x-xc)+Math.abs(y-yd);
                }
                if(kyori>(Math.abs(x-xc)+Math.abs(y-yd))){
                    kyori = Math.abs(x-xc)+Math.abs(y-yd);
                    out = j+1;
                }


            }
            System.out.println(out);

        }


    }
}

Measured memory_bytes: 20564
def solve():
    X = abs(x)
    a = X//D
    if a <= K:
        if (K-a)%2 == 0:
            ans = X%D
        else:
            ans = min(abs((X%D)+D), abs((X%D)-D))
    else:
        ans = min(abs(X-K*D), abs(X+K*D))
    print(ans)

if __name__ == "__main__":
    x,K,D = list(map(int, input().split()))
    solve()  


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

using namespace std;

int main(){
  int N, K;
  int res = 0;
  cin >> N >> K;
  int curr;
  for(int i=0; i<N; i++){
    cin>>curr;
    if(curr>=K){
      res++;
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
  int a[100],n,i,j,t,c;
  for(;;){
    cin >> n;
    if(n==0)break;
    for(i=0;i<n;i++){
      cin >> a[i];
    }
    c = 0;
    for(i=n-1;i>0;i--){
      for(j=0;j<i;j++){
	if(a[j] > a[j+1]){
	  t = a[j];
	  a[j] = a[j+1];
	  a[j+1] = t;
	  c++;
	}
      }
    }
    cout << c << endl;
  }
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    ll sum = 0;
    rep(i,n) {
        cin >> a[i];
        sum += (ll)a[i];
    }
    sum /= 2;
    ll sum_after_0 = 0;
    for(int i=1; i<=n-2; i+=2) sum_after_0 += a[i];
    b[0] = sum - sum_after_0;
    for(int i=1; i<n; i++) b[i] = a[i-1] - b[i-1];
    rep(i, n) cout << b[i]*2 << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 4032
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void shortestPath(const Graph &g, int s, vector<Weight> &dist) {
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (dist[e.dst] < e.weight) continue;
    FOR(f,g[e.dst]) {
      if (dist[f->dst] > e.weight+f->weight) {
        dist[f->dst] = e.weight+f->weight;
        Q.push(Edge(f->src, f->dst, e.weight+f->weight));
      }
    }
  }
}

int main() {
  int n;
  cin >> n;
  Graph g(n);
  while(n--) {
    int a;
    cin >> a;
    int s;
    cin >> s;
    while(s--) {
      int d;
      cin >> d;
      g[a-1].push_back(Edge(a-1,d-1,1));
    }
  }
  int m;
  cin >> m;
  while(m--) {
    int s,d,t;
    cin >>s>>d>>t;
    vector<int> v;
    shortestPath(g,s-1,v);
    if (v[d-1]<t)
      cout << v[d-1]+1 << endl;
    else
      cout << "NA"<< endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <utility>
#include <algorithm>

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

int N;
P A[100005];
int x[100005];

int main(void)
{
	cin >> N;
	int a;
	for(int i = 1; i <= N; i++){
		cin >> a;
		A[i] = make_pair(a, i);
	}
	sort(A+1, A+N+1);
	
	for(int i = 1; i <= N; i++){
		x[A[i].second] = i;
	}
	
	int ans = 0;
	for(int i = 1; i <= N; i+=2){
		if(x[i] % 2 == 0) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
def rvrs(base, start, end):
    r = base[int(start):int(end) + 1][::-1]
    return base[:int(start)] + r + base[int(end) + 1:]
def rplc(base, start, end, string):
    return base[:int(start)] + string + base[int(end) + 1:]

ans = input()
q = int(input())
for _ in range(q):
    ORD = list(input().split())
    if ORD[0] == 'print':
        print(ans[int(ORD[1]):int(ORD[2])+1])
    elif ORD[0] == 'reverse':
        ans = rvrs(ans, int(ORD[1]), int(ORD[2]))
    elif ORD[0] == 'replace':
        ans = rplc(ans, int(ORD[1]), int(ORD[2]), ORD[3])


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	vector<int> v{a, b, c};
	sort(begin(v), end(v));
	for (auto iter=begin(v);iter != --end(v); ++iter){
		cout << *iter << " ";
	}
	cout << *--end(v) << endl;
}

Measured memory_bytes: 1204
import java.io.*;
import java.util.*;
//import java.util.Map.Entry;
//import java.util.stream.*;
//import java.math.*;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        long MOD = (long) (Math.pow(10, 9) + 7);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int array[] = new int[n + 1];
        for (int i = 0; i < m; i++) {
            int ai = sc.nextInt();
            int bi = sc.nextInt();
            if (ai == 1) {
                array[bi]++;
            }
            if (bi == n) {
                array[ai]++;
            }
        }
        for (int num : array) {
            if (num == 2) {
                System.out.println("POSSIBLE");
                return;
            }
        }
        System.out.println("IMPOSSIBLE");
        bw.flush();
    }
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//
//==============================================//

    static class Pair implements Comparable<Pair> {

        int a, b;

        public Pair(int x, int y) {
            a = x;
            b = y;
        }

        @Override
        public int compareTo(Pair p) {
            return a - p.a;
        }
    }

    static void forl_0(int n, int[] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void forl_1(int n, int[] array, Scanner sc) {
        for (int i = 1; i <= n; i++) {
            array[i] = sc.nextInt();
        }
    }

    static void two_d(int n, int m, int[][] array, Scanner sc) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                array[i][j] = sc.nextInt();
            }
        }
    }

    static boolean isPrime(long n) {
        if (n < 2) {
            return false;
        } else if (n == 2 || n == 3) {
            return true;
        } else if (n % 2 == 0 || n % 3 == 0) {
            return false;
        }
        long sqrtN = (long) Math.sqrt(n) + 1;
        for (long i = 6L; i <= sqrtN; i += 6) {
            if (n % (i - 1) == 0 || n % (i + 1) == 0) {
                return false;
            }
        }
        return true;
    }

    public static long gcd(long a, long b) {
        return (b == 0) ? a : gcd(b, a % b);
    }

    public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
    }
}


Measured memory_bytes: 50588
import sys
x = int(input())
divisors = []
for i in range(1, int(x**0.5)+1):
    if x % i == 0:
        divisors.append(i)
        if i != x // i:
            divisors.append(x//i)
for j in divisors:
  for a in range(10000):
    b = a - j
    if a * a * a * a * a - b * b * b * b * b == x:
      print(a, b)
      sys.exit(0)


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

int main(){
    string s; cin >> s;
    int n = s.size();
    int chunk = 0;
    
    int tmp = s.at(0);
    for(int i = 1; i < n; i++){
        if(tmp != s.at(i)){
            tmp = s.at(i);
            chunk++;
        }
    }
    cout << chunk << endl;
            
            
    
}




Measured memory_bytes: 512
/* 競プロ用のテンプレ
 * SKMT
 * 作成日   2020年09月06日  15:46
 * ファイル名    ABC121_b.cpp
 */
#include<bits/stdc++.h>
using namespace std;

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

int main(int argc, char const* argv[]){
	int N,M,C;
	cin >> N>>M>>C;
	vector<int> b(M);
	vector<vector<int>> a(N,vector<int>(M));
	rep(i,M) cin >> b.at(i);
	rep(i,N){
		rep(j,M){
			int temp;
		cin >> temp;
		a.at(i).at(j)=temp;
		}
	}
	int cnt=0;
	long sum=C;
	rep(i,N){
		rep(j,M){
			sum+=a.at(i).at(j) * b.at(j);
		}
		if(sum > 0) cnt++;
		sum=C;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long Int;
#define MOD 998244353LL;

Int cmemo[4000][4000];

Int C(Int x, Int y){
	if(x < y)return 0;
	Int &res = cmemo[x][y];
	if(res != -1)return res;
	if(y == 0 || x == y)return res = 1;
	return res = (C(x-1, y) + C(x-1, y-1)) % MOD;
}

Int cnt(Int n, Int k){
	if(n < 0)return 0;
	return C(n+k-1, n);
}

Int solve(Int n, Int ban, Int k){
	Int res = 0;
	Int p = 1;
	for(Int i = 1;i <= ban;i++){
		res += p * C(ban, i) * cnt(n-2*i,k) % MOD;res %= MOD;
		p *= -1;
	}
	if(res < 0)res += MOD;
	return cnt(n, k) - res;
}

int cnthoge(int x, int k){
	int res = 0;
	for(int i = 1;i <= k;i++){
		int kk = x - i;
		if(0 < kk && kk <= k && kk != i)res++;
	}
	return res / 2;
}

int main(){
	Int k, n;
	for(int i = 0;i < 4000;i++)
		for(int j = 0;j < 4000;j++)
			cmemo[i][j] = -1;
	cin >> k >> n;
	for(int i = 2;i <= 2*k;i++){
		Int res = 0;
		if(i % 2 == 0){
			res += solve(n,cnthoge(i, k), k-1);
			res += solve(n-1,cnthoge(i, k), k-1);
			res %= MOD;
		}
		else{
			res += solve(n, cnthoge(i, k), k);
		}
		res %= MOD;
		if(res < 0)res += MOD;
		cout << res << endl;
	}
	return 0;
}

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

	

int main() {
	
	int N;
	cin >>N;
	
	vector<pair<int,int>> A(N);
	for(int i=0; i<N; i++){
		
		cin >>A.at(i).first;
		A.at(i).second=i;
		
	}
	
	sort(A.begin(),A.end());
	
	for(int i=0; i<N-1; i++){
		
		cout <<A.at(i).second+1<<" ";
		
	}
	
	cout <<A.at(N-1).second+1<<endl;
	
	
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) begin(x)+(a), begin(x)+(n)
#define ADD(a, b) ((((a)%MOD+MOD)%MOD+((b)%MOD+MOD)%MOD)%MOD)
#define SUB(a, b) ((((a)%MOD+MOD)%MOD-((b)%MOD+MOD)%MOD+MOD)%MOD)
#define MUL(a, b) (((((a)%MOD+MOD)%MOD)*(((b)%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N, X, Y;
int ans[2010];


signed main(){
    cin >> N >> X >> Y;
    X--, Y--;

    rep(i, 0, N) rep(j, i+1, N){
        if(j <= X or Y <= i) ans[j-i]++;
        else if(i <= X and Y <= j) ans[X-i+1+j-Y]++;
        else if(X <= i and j <= Y) ans[min(j-i, i-X+1+Y-j)]++;
        else if(i <= X and j <= Y) ans[min(j-i, X-i+1+Y-j)]++;
        else ans[min(j-i, i-X+1+j-Y)]++;
    }

    rep(i, 1, N) cout << ans[i] << endl;

    return 0;
}

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


int main() {
  int N;
  cin >> N;
  map<string,int> mp;
  for (int i = 0;i<N;i++) {
    string s;
    cin >> s;
    mp[s]++;
  }
  int ans = 0;
  for (pair<string,int> p : mp) {
    ans = max(ans,p.second);
  }
  vector<string> vec;
  for (pair<string,int> p : mp) {
    if (p.second == ans) {
      vec.push_back(p.first);
    }
  }
  sort(vec.begin(),vec.end());
  for (int i =0;i<vec.size();i++) {
    cout << vec.at(i) << endl;
  }
}


Measured memory_bytes: 26868
#include <iostream>
 using namespace std;
 int main(){
 string s;
 cin >> s;
 int ans;
 if(s == "SUN")ans = 7;
 if(s == "MON")ans = 6;
 if(s == "TUE")ans = 5;
 if(s == "WED")ans = 4;
 if(s == "THU")ans = 3;
 if(s == "FRI")ans = 2;
 if(s == "SAT")ans = 1;
 cout << ans << endl;
 }


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int i, ii,n, r, w, tmp, tmp2, f, ans = 0;;
    char s[200006];
    scanf("%d%s", &n, s);
    tmp = n - 1;
    for (i = 0; i < n; i++)
    {
        if (s[i] == 'W')
        {
            f = 1;
            for (ii = tmp; ii > i; ii--)
            {
                if (s[ii] == 'R')
                {
                    s[i] = 'R';
                    s[ii] = 'W';
                    f = 0;
                    ans++;
                    tmp = ii - 1;
                    break;
                    //printf("%d %d,", i, ii);
                }
            }
            if (f)
            {
                printf("%d", ans);
                return (0);
            }
        }
    }
    printf("%d", ans);
    return (0);
    
}



Measured memory_bytes: 1928