akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
            int w = sc.nextInt();
            int n = sc.nextInt();
            int[] values = new int[w];
            for(int i=0; i<values.length;i++){
                values[i]=i+1;
            }
            for(int i=0;i<n;i++){
                String str = sc.next();
                String[] ab = str.split(",");
                int a = Integer.parseInt(ab[0])-1;
                int b = Integer.parseInt(ab[1])-1;
                int k=0;
                k=values[a];
                values[a]=values[b];
                values[b]=k;
            }
            for(int i=0;i<values.length;i++){
                System.out.println(values[i]);
            }
        }
    }
}


Measured memory_bytes: 26120
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

template<typename T> struct Combination
{
    vector<T> fact, rfact, inv;
    Combination(int n) : fact(n + 1), rfact(n + 1), inv(n + 1)
    {
        fact[0] = fact[1] = 1;
        rfact[0] = rfact[1] = 1;
        inv[1] = 1;
        for(int i = 2; i < n + 1; i++)
        {
            fact[i] = fact[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            rfact[i] = rfact[i - 1] * inv[i] % MOD;
        }
    }
    T C(int n, int k)
    {
        if(n < k) return 0;
        if(n < 0 or k < 0) return 0;
        return fact[n] * (rfact[k] * rfact[n - k] % MOD) % MOD;
    }
};

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    Combination<ll> comb(5000);
    cout << comb.C(n - 1, k - 1) << endl;
    return 0;
}




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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;

int N,M;
vpint G[111111];

int X[111111];

bool dfs(int v){
    for(auto &e:G[v]){
        if(X[e.fi]!=INF){
            if(X[v]+e.se!=X[e.fi])return false;
            continue;
        }

        X[e.fi]=X[v]+e.se;
        if(!dfs(e.fi))return false;
    }
    return true;
}

signed main(){
    cin>>N>>M;
    fill_n(X,N,INF);

    rep(i,M){
        int l,r,d;
        cin>>l>>r>>d;
        l--;r--;
        G[l].pb({r,d});
        G[r].pb({l,-d});
    }

    rep(i,N){
        if(X[i]!=INF)continue;
        X[i]=0;
        if(!dfs(i)){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 16768
#include <bits/stdc++.h> 
#define ll long long
#define MAX 100001
using namespace std; 
void printString(ll n) 
{ 
    char str[MAX];
    int i = 0; 
  
    while (n > 0)
	 { 
       ll rem = n % 26;  
        if (rem == 0) { 
            str[i++] = 'z'; 
            n = (n / 26) - 1; 
        } 
        else
        { 
            str[i++] = (rem - 1) + 'a'; 
            n = n / 26; 
        } 
    } 
    str[i] = '\0'; 
reverse(str, str + strlen(str));
	cout<<str<<endl; 
    return; 
} 
int main() 
{ 
  ll n;
  cin>>n;
  printString(n);
  return 0;
} 

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <fstream>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
#include <cassert>
#pragma warning (disable: 4996)
using namespace std;

using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

struct UnionFind {
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    if (n < 0)return 0;
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

ll merge_cnt(vector<ll>& a) {
    int n = a.size();
    if (n <= 1) { return 0; }

    ll cnt = 0;
    vector<ll> b(a.begin(), a.begin() + n / 2);
    vector<ll> c(a.begin() + n / 2, a.end());

    cnt += merge_cnt(b);
    cnt += merge_cnt(c);

    int ai = 0, bi = 0, ci = 0;
    while (ai < n) {
        if (bi < b.size() && (ci == c.size() || b[bi] <= c[ci])) {
            a[ai++] = b[bi++];
        }
        else {
            cnt += n / 2 - bi;
            a[ai++] = c[ci++];
        }
    }
    return cnt;
}

int main() {
    ll n;
    cin >> n;
    if (n == 1)cout << 0 << endl;
    else cout << 1 << endl;
}

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

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

    string str;
    int sabs = 0, sa = 0,bs = 0, bsa = 0;
    for (int  i = 0; i < N; i++){
        cin >> str;
        //cout << str << endl;
        for (int j = 0; j < str.length() - 1; j++){
            if(str[j] == 'A' && str[j+1] == 'B')
                sabs++;
        }
        
        if(str.back() == 'A' && str.front() == 'B')
            bsa++;
        else if(str.back() == 'A')
            sa++;
        else if(str.front() == 'B')
            bs++;
        //cout << sabs << " BsA= " << bsa <<" A= " << sa << " B= " << bs << endl;
    }
    //cout << sabs + (bsa > 0 ? bsa - 1 + (sa > bs ? min(sa, bs + 1) : min(sa + 1, bs)) : min(sa,bs) ) << endl;
    int count = sabs;
    if(bsa > 0){
        if(sa > 0 && bs > 0) count += bsa + 1 + min(sa - 1,bs - 1);
        else if(sa > 0 || bs > 0) count += bsa;
        else count += bsa - 1; 
    }
    else count += min(sa ,bs);


    cout << count << endl;

    return 0;

}

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


int main(){
    bool w = false;
    bool s = false;
    bool n =false;
    bool e =false;
    string N;
    cin>>N;

    for(int i =0;i<N.length();++i){
        char x = N[i];
        if(x=='N'){
            n=true;
        }
        if(x=='W'){
            w=true;
        }
        if(x=='S'){
            s=true;
        }
        if(x=='E'){
            e=true;
        }

    }
    if(n==s&&e==w){
        cout <<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

const int MAX_N = 200100;
int H[MAX_N];
int N, K;

int main()
{
    scanf("%d %d", &N, &K);
    for(int i = 0; i < N; ++i) scanf("%d", &H[i]);
    sort(H, H + N, greater<int>());
    ll res = 0LL;
    for(int i = K; i < N; ++i) res += (ll)H[i];
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 1024
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
#define MAX(a, b) ((ll)(a) > (ll)(b)) ? (ll)(a) : (ll)(b)
#define MIN(a, b) ((ll)(a) > (ll)(b)) ? (ll)(b) : (ll)(a)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = 1000000007;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1}};

ll min(ll a, ll b){
	if (a < b)
		return a;


		return b;
}


ll N, K;
vector<ll> A, B;




vector<ll> a;
ll b[30];
int main() {
	
	cin >> N >> K;

	ll u, v;

	rep(i, N) {
		cin >> v >> u;

		A.push_back(v);
		B.push_back(u);

	}

	rep(i, 30) {
		if ((K & (ll)pow(2.0, i)) != 0) {
			a.push_back(i);
			b[i] = 1;
		}
		

	}
	ll ans = 0;
	
	reverse(a.begin(), a.end());

	

	ll finalans = 0;
	rep(i, a.size()+1) {
		rep(j, N) {

			bool flag = true;
			

			if (i == a.size()) {
				for (int k = 0; k < 30; k++) {
					if (b[k] == 0) {
						if (A[j] > K || ((A[j] & (ll)pow(2.0, k)) != 0)) {
							flag = false;
							break;
						}
					}
					else if (A[j] > K) {
						flag = false;
						break;
					}

				  }

				 if (flag == true) {
					ans += B[j];
				  }


			}


			else if (i > 0) {
				for (int k = a[i]; k <= a[0]; k++) {

					if (b[k] == 0 || k == a[i]) {
						if (A[j] > K || ((A[j] & (ll)pow(2.0, k)) != 0)) {
							flag = false;
							break;
						}
					}
					else if (A[j] > K) {
						flag = false;
						break;
					}

				}

				if (flag == true) {
					ans += B[j];
				}

			}

			

			else if(i == 0 && a.size() != 0){
				if (A[j] <= K && ((A[j] & (ll)pow(2.0, a[i])) == 0))
					ans += B[j];

			}





		}

		finalans = MAX(finalans, ans);
		ans = 0;
	}
	
	cout << finalans << endl;


	return 0;
}

Measured memory_bytes: 2036
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll n;cin>>n;
    ll a[n];
    vector<pair<ll,ll>> p;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        p.push_back(make_pair(a[i],i));
    }
    sort(p.begin(),p.end());
    cout<<p[0].second+1;
    for(ll i=1;i<n;i++){
        cout<<' '<<p[i].second+1;
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 3312
from itertools import permutations

n = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
S = sorted(P)
for i, C in enumerate(permutations(S)):
    if C == P:
        a = i
    if C == Q:
        b = i
print(abs(a - b))


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

void Solve(){
    int n, x;
    cin>>x>>n;
    vector<bool> vst(102);
    for(int i = 0; i < n; i++){
        int a;
        cin>>a;
        vst[a] = true;
    }
    if(!vst[x]){
        cout<<x<<endl;
        return;
    }
    int res = x;
    while(vst[res]){
        res++;
    }
    int k = x;
    while(vst[k]){
        k--;
    }
    if(res - x < x - k) cout<<res<<endl;
    else cout<<k<<endl;
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    //cin>>T;
    while(T--){
        Solve();
    }
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 1e9 + 5; 
int main(){
	int n,k;
	cin>>n>>k;
	vector<int>a(n);
	for(int &x:a){
		scanf("%d",&x);
	}
	vector<int>dp(n,INF);
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<=i+k;j++){
			if(j<n){
			
			dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
		}
	}
	}
	cout<<dp[n-1];
	
	
	
	
}

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

int main(){
  int N;
  cin >> N;
  vector<int> x(N),y(N);
  for(int i=0;i<N;i++)  cin >> x.at(i) >> y.at(i);

  if(N==1){
    cout << 1 << endl;
    return 0;
  }

  int ans=1e9;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(i==j)  continue;
      int count=0;
      int p=x.at(i)-x.at(j);
      int q=y.at(i)-y.at(j);
      for(int k=0;k<N;k++){
        for(int l=0;l<N;l++){
          if(k==l)  continue;
          int pt=x.at(k)-x.at(l);
          int qt=y.at(k)-y.at(l);
          if(pt==p && qt==q)  count++;
        }
      }
      ans=min(ans,N-count);
    }
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n-1);
  for (int i=0; i<n; i++) {
    cin >> a[i];
  }
  for (int i=0; i<n; i++) {
    cin >> b[i];
  }
  for (int i=0; i<(n-1); i++) {
    cin >> c[i];
  }
  
  int m=0;
  for (int i=0; i<n; i++) {
    m += b[a[i]-1];
    if (i > 0) {
      if ((a[i-1]+1) == a[i]) {
        m += c[a[i-1]-1];
      }
    }
  }
  
  cout << m << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int>v, sum, last;
void update(int node, int left, int right, int indx, int val){
    if(left == right){
        v[indx] = v[indx] + val;
        sum[node] = sum[node] + val;
    }
    else{
        int mid = (left + right)/2;
        if(indx <= mid){
            update(2 * node, left, mid, indx, val);
        }
        else{
            update(2 * node + 1, mid + 1, right, indx, val);
        }
        sum[node] = sum[2 * node] + sum[2 * node + 1];
    }
}
int query(int node, int left, int right, int l, int r){
    if(r < left || l > right){
        return 0;
    }
    else if(l <= left && r >= right){
        return sum[node];
    }
    int mid = (left + right)/2;
    int p1 = query(2 * node, left, mid, l, r);
    int p2 = query(2 * node + 1, mid + 1, right, l, r);
    int result = p1 + p2;
    return result;
}
int main(){
    int q;
    cin >> n >> q;
    vector<int>c(n + 3);
    last = vector<int>(n + 3, -1);
    sum = vector<int>(4 * n + 3, 0);
    v = vector<int>(n + 3, 0);
    for(int i = 1; i <= n; i++){
        cin >> c[i];
    }
    vector<pair<int, pair<int, int> > >queries;
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        queries.push_back(make_pair(r, make_pair(l, i)));
    }
    sort(queries.begin(), queries.end());
    vector<int>ans(q + 3);
    int cur = 0;
    for(int i = 1; i <= n; i++){
        if(last[c[i]] == -1){
            last[c[i]] = i;
            update(1, 1, n, i, 1);
        }
        else{
            update(1, 1, n, last[c[i]], -1);
            last[c[i]] = i;
            update(1, 1, n, i, 1);
        }
        while(queries[cur].first == i){
            int l = queries[cur].second.first, r = queries[cur].first, idx = queries[cur].second.second;
            ans[idx] = query(1, 1, n, l, r);
            cur++;
        }
    }
    for(int i = 0; i < q; i++){
        cout << ans[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 25276
import * as fs from "fs";

let input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const n = +input[0];

type Obj = { side: number, pos: number };
const a: Obj[] = [];
for (let i = 0; i < n; i++) {
	a.push({side: 0, pos: +input[i + 1]});
}

for (let i = 0; i < n; i++) {
	a.push({side: 1, pos: +input[i + n + 1]});
}

a.sort((a: Obj, b: Obj) => {
	return a.pos - b.pos;
});

const MOD = 1e9 + 7;
let stack = 0;
let side = -1;
let result = 1;
for (const obj of a) {
	if (stack === 0) {
		stack++;
		side = obj.side;
	}
	else if (obj.side === side) {
		stack++;
	}
	else {
		result *= stack;
		result %= MOD;
		stack -= 1;
	}
}

console.log(result);


Measured memory_bytes: 59212
def write(H, W):
    for i in range(H):
        if i==0 or i==H-1:
            print('#'*W)
        else:
            print('#'+'.'*(W-2)+'#')
            

while True:
    H, W = map(int, input().split())
    if H==0 and W==0:
        break
    write(H, W)
    print('')


Measured memory_bytes: 5612
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  int A,B;
  cin >> A >> B;
  if(A%3==0||B%3==0||(A+B)%3==0) printf("Possible\n");
  else printf("Impossible\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}

const int maxn = 1e5 + 69, mod = 1e9 + 7;

signed main()
{
//	freopen("TEXT.inp", "r", stdin); freopen("TEXT.out", "w", stdout);
	fastio();

	ll n; cin >> n;
	ll dis = LLONG_MAX;
	for (ll i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {
            dis = min(dis, abs(1ll - i) + abs(1ll - n / i));
        }
	}
	cout << dis;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;

int main() {
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	double distance = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
	printf("%.6lf\n",distance);
}


Measured memory_bytes: 3296
#include<stdio.h>
int main (){
  int n,i,res,ans = 0;
  scanf("%d",&n);
  for (i = 0; i < 1000000000;i++){
    res = i * i;
    if (res > n ) {
      break ;
    } else {
      ans = res;
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
n, m = map(int, input().split())
cake = [list(map(int, input().split())) for i in range(n)]


def solve(a, b, c):
    cake.sort(key=lambda lst: a*lst[0]+b*lst[1]+c*lst[2], reverse=True)
    p = [0, 0, 0]
    for i in range(m):
        p[0] += cake[i][0]
        p[1] += cake[i][1]
        p[2] += cake[i][2]

    return abs(p[0]) + abs(p[1]) + abs(p[2])


def main():
    max_p = 0
    for i in range(-1, 2, 2):
        for j in range(-1, 2, 2):
            for k in range(-1, 2, 2):
                max_p = max(solve(i, j, k), max_p)

    print(max_p)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e18;
using namespace std;
typedef long long ll;
int main() {
  ll N;
  cin >> N;
  ll A[N];
  ll ans[N];

  REP(i, N) {
    cin >> A[i];
    ans[i] = A[i];
  }
  sort(ans, ans + N);

  REP(i, N) {
    if (A[i] == ans[N - 1]) {
      cout << ans[N - 2] << endl;
    } else {
      cout << ans[N - 1] << endl;
    }
  }

  return 0;
}

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

int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  int x=tx-sx,y=ty-sy;
  for(int i=0;i<x;i++)
    cout<<'R';
  for(int i=0;i<y;i++)
    cout<<'U';
  for(int i=0;i<x;i++)
    cout<<'L';
  for(int i=0;i<y;i++)
    cout<<'D';
  cout<<'D';
  for(int i=0;i<=x;i++)
    cout<<'R';
  for(int i=0;i<=y;i++)
    cout<<'U';
  cout<<"LU";
  for(int i=0;i<=x;i++)
    cout<<'L';
  for(int i=0;i<=y;i++)
    cout<<'D';
  cout<<'R';
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int i, n, z=0, o=0;
    char s[100000];

    scanf("%s", s);

    n = strlen(s);

    /*while(s[n]){
        n++;
    }*/

    for(i=0; i<n; i++){
        if(s[i] == '0'){
            z++;
        }else{
            o++;
        }

    }


    if(o<z){
        printf("%d\n", o*2);
    }else{
        printf("%d\n", z*2);
    }

    return 0;
}


Measured memory_bytes: 256
# n,kに代入
n,k = map(int, input().split())
n_list = []
tmp = []

for i in range(n):
    n_list.append(i + 1)

for i in range(k):
#     d:お菓子の個数
    d = int(input())
#     tmp:お菓子が配られる人
    a = input().split()
    for j in range(len(a)):
        if int(a[j]) in n_list:
            n_list.remove(int(a[j]))

print(len(n_list))

Measured memory_bytes: 9036
import java.util.Scanner;
public class Main {
	static int dfs(int total, int addv, int target, int n){ return n == 0 ? total == target ? 1 : 0 : addv > 9 ? 0 : dfs(total + addv, addv + 1, target, n - 1) + dfs(total, addv + 1, target, n); }
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(true){ int n = sc.nextInt(), s = sc.nextInt(); if(n == 0 && s == 0) break; System.out.println(dfs(0, 0, s, n)); }
		}
	}
}

Measured memory_bytes: 26340
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int inf = 1000000000;


int main(void) {
  int t;
  cin >> t;
  int h = t / 30;
  t %= 30;
  cout << h << " " << t * 2 << endl;

  return 0;
}

// EOF

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
int A[20];
ll dp1[17][1<<16];
ll dp3[17][1<<16];
ll mo=1000000007;
const int NUM_=1<<17;
ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	inv[1]=fact[0]=factr[0]=1;
	for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
	for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	
	cin>>N>>M;
	
	
	A[0]=1;
	dp1[0][0]=1;
	int mask,U;
	for(i=1;i<=M;i++) {
		cin>>A[i];
		FOR(j,N) FOR(mask,1<<N) if((mask&(1<<j))) (dp1[i-1][mask]+=dp1[i-1][mask^(1<<j)])%=mo;
		FOR(U,1<<N) {
			int t=U-(A[i-1]-1);
			int d=A[i]-A[i-1]-1;
			if(t>=d) dp3[i][U]=fact[t]*factr[t-d]%mo*dp1[i-1][U]%mo;
		}
		
		FOR(j,N) FOR(mask,1<<N) if((mask&(1<<j))) (dp3[i][mask]+=mo-dp3[i][mask^(1<<j)])%=mo;
		FOR(U,1<<N) if(U>=(A[i]-2)) dp1[i][U]=(U-(A[i]-2))*dp3[i][U]%mo;
		
	}
	
	ll ret=0;
	FOR(mask,1<<N) ret+=dp1[M][mask];
	ret=ret%mo*fact[(1<<N)-A[M]]%mo*(1LL<<N)%mo;
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 20736
n = int(input())

ans = [0] * (10**5)

for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            ans[x**2 + y**2 + z**2 + x*y + y*z + z*x] += 1

for i in range(1,n+1):
    print(ans[i])


Measured memory_bytes: 9960
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

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


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1 << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	int D, G;
	cin >> D >> G;
	vector< int > p(D), c(D);
	rep(i, D) cin >> p[i] >> c[i];
	int ans = LINF;
	for (int b = 0; b < (1 << D); b++) {
		bitset< 10 > bit(b);
		int tmp = 0, tmp2 = 0;
		rep(i, D) {
			if (bit[i]) {
				tmp += (i + 1) * 100 * p[i] + c[i];
				tmp2 += p[i];
			}
		}
		for (int i = D - 1; i >= 0; i--) {
			if (bit[i])
				continue;
			int tmp3 = max(0LL, (G - tmp + (i + 1) * 100 - 1) / ((i + 1) * 100));
			chmin(tmp3, p[i]);
			tmp += (i + 1) * 100 * tmp3;
			tmp2 += tmp3;
		}
		chmin(ans, tmp2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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



Measured memory_bytes: 26116
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define int long long
using namespace std;
int n,A[li],dp[li],k;
int dfs(int node){
	int cev=inf;
	if(node==n) return 0;
	if(~dp[node]) return dp[node]; 
	for(int i=1;i<=k;i++){
		if(node<=n-i) cev=min(cev,dfs(node+i)+abs(A[node]-A[node+i]));
	}
	return dp[node]=cev;
}
main(){
	memset(dp,-1,sizeof(dp));
	scanf("%lld %lld",&n,&k);
	for(int i=1;i<=n;i++) scanf("%lld",&A[i]);
	int ty=dfs(1);
	printf("%lld\n",ty);
	return 0;
}



Measured memory_bytes: 6528
#include <iostream>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

template<class T> inline bool chmin(T &a, T b) {
    if (a > b) a = b; return true;
    return false;
}

void solve(long long N, long long L){
    int sum = 0;
    REP(i, N)
        sum += L + i;

    long long mini = 100100100;
    REP(i, N) {
        chmin(mini, abs(L));
        L++;
    }

    if (L <= 0) cout << sum + mini << '\n';
    else cout << sum - mini << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long L;
    scanf("%lld",&L);
    solve(N, L);
    return 0;
}


Measured memory_bytes: 256
fn main() {
    let (a, b, h, m) = {
        let v = read_vec::<f64>();
        (v[0], v[1], v[2], v[3])
    };
    let rad = 2.0 * std::f64::consts::PI * (h / 12.0 + (m / 60.0) / 12.0 - m / 60.0);
    let ret = a * a + b * b - 2.0 * a * b * rad.cos();
    println!("{}", ret.sqrt());
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 3036
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int L = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int ans = L-max(div(A,C),div(B,D));
		System.out.println(ans);
	}
	static private int div(int a,int b) {
		return a/b+(a%b!=0 ? 1 : 0);
	}
	static private int max(int a, int b) {
		return a > b ? a : b;
	}
}

Measured memory_bytes: 17160
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <fstream>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;


string s;
int dfs(char c,int p){
	if( p == s.size() ){
		return c == 'B';
	}
	if( c == 'A' ){
		if(s[p]=='0'){
			if( dfs('X',p+1) ) return 1;
		}else if( dfs('Y',p+1) ) return 1;
	}
	if( c == 'B' ){
		if(s[p]=='0'){ if( dfs('Y',p+1) ) return 1;}
		else if( dfs('X',p+1) ) return 1;
	}
	if( c == 'X' ){
		if(s[p]=='1'){ if( dfs('Z',p+1) ) return 1;}
	}
	if( c == 'Y' ){
		if(s[p]=='0'){ if( dfs('X',p+1) ) return 1;}
	}
	if( c == 'W' ){
		if(s[p]=='0'){ if( dfs('B',p+1) ) return 1;}
		else if( dfs('Y',p+1) ) return 1;
	}
	if( c == 'Z' ){
		if(s[p]=='0'){ if( dfs('W',p+1) ) return 1;}
		else if( dfs('B',p+1) ) return 1;
	}
	return 0;
}
int main(){
	while(cin >> s && s != "#" ){
		cout << (dfs('A',0)?"Yes":"No") << endl;
	}
}

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

int f(int n) {
    if (n % 2 == 0) {
        return n / 2;
    } else {
        return 3 * n + 1;
    }
}

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

    int s;
    cin >> s;

    int ans = 1;
    while (s != 4 && s != 2 && s != 1) {
        s = f(s);
        ans++;
    }
    cout << ans + 3 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll n, a, b;
    cin >> n >> a >> b;
    cout << max(0LL, (b * (n - 1) + a) - (a * (n - 1) + b) + 1) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a % 2 == 1 && b % 2 == 1)
		cout << "Odd" << endl;
	else
		cout << "Even" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()

const ll mod=1000000007;

int countBits(int in){
  int res=0;
  for(int i=0;i<10;i++){
    int msk=1<<i;
    if((in&msk)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  vector<int> a(n+1);
  for(int i=1;i<n+1;i++){
    cin>>a[i];
  }
  vector<bool> ans(n+1,false);
  for(int i=n;i>0;--i){
    int val=0;
    for(int j=i;j<=n;j+=i){
       if(ans[j]){
         val++;
       }
    }
    if(a[i]!=val%2){
      ans[i]=true;
    }    
  }
  vector<int> answ;
  for(int i=1;i<n+1;i++){
    if(!ans[i]){
      continue;
    }
    answ.push_back(i);
  }
  cout<<answ.size()<<endl;
  for(int i=0;i<answ.size();i++){
    cout<<answ[i]<<" ";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 2428
n,q=map(int,input().split())
a=[0]*(n-1)
c=[0 for i in range(n)]
for i in range(n-1):
  a[i]=list(map(int,input().split()))

a.sort()

for i in range(q):
  x,y=map(int,input().split())
  c[x-1]+=y

for i in range(n-1):
  c[a[i][1]-1]+=c[a[i][0]-1]

print(*c)

Measured memory_bytes: 66664
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
//#include <intrin.h>
//#include <chrono>
//#include <random>
//#include <unordered_map>

using namespace std;

typedef long long ll;

const int sz = 2e5 + 1;

ll sum = 0;
ll mem[sz];

void solve() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		ll a;
		cin >> a;
		mem[a]++;
		sum += a;
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		ll a, b;
		cin >> a >> b;
		sum -= mem[a] * a;
		sum -= mem[b] * b;
		mem[b] += mem[a];
		mem[a] = 0;
		sum += mem[b] * b;
		cout << sum << '\n';
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << '\n';
	}
}

Measured memory_bytes: 4360
#include <bits/stdc++.h>
typedef long long ll;
#define forn(i, start, end) for (ll i = start; i < ll(end); i++)
#define input(arr, n) forn(i, 0, n) cin >> arr[i];
#define MOD 1000000007
#define vll vector<ll>
#define vpll vector<pair<ll, ll>>
#define vvll vector<vector<ll>>
#define mll map<ll, ll>
#define mcl map<char, ll>
#define sc set<char>
#define sll set<ll>
#define ssll stack<ll>
#define CHK(param) cout << #param << " is : " << param << "\n";
#define pb push_back
#define ppb pop_back
#define mk make_pair
#define f first
#define s second
#define all(x) (x).begin(), (x).end()
#define LAUV                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define TC       \
    ll TTTT;     \
    cin >> TTTT; \
    while (TTTT--)
using namespace std;

int32_t main()
{
    LAUV;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // TC
    {
        string s;
        cin>>s;
        ll cnt=0,maxx=INT_MIN;
        forn(i,0,s.length()){
            if(s[i]=='R'){
                cnt++;
            }
            else{
                maxx=max(cnt,maxx);
                cnt=0;
            }
        }
        cout<<max(maxx,cnt)<<"\n";
    }
    return 0;
}

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

int main()
{
	double n=3.14159265358979323846264338327950288;
	int c;
	cin>>c;
	int d=c*2;
	cout<<setiosflags(ios::fixed)<<setprecision(20)<<d*n<<endl;
	return 0;
}

Measured memory_bytes: 3784
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        s: chars,
    );

    let mut s = s as Vec<char>;

    s.sort();

    if s[0] == s[1] && s[1] != s[2] && s[2] == s[3] {
        println!("Yes");
    }
    else {
        println!("No");
    }
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define log2(x) log(x)/log(2)
#define ln '\n'
#define bln(i,n) (i==n-1?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a[114514], b[114514], sum;

signed main() {
	cin >> n;
	repst(i,1,n) cin >> a[i];
	rept(i,n) b[i] = abs(a[i+1] - a[i]);
	sum = accumulate(b, b+n+1, 0);
	repst(i,1,n) cout << sum - (b[i-1] + b[i]) + abs(a[i-1] - a[i+1]) << ln;
}

Measured memory_bytes: 2048
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int n;
int a[100000];

int main() {
	ios_base::sync_with_stdio(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	sort(a, a + n);
	if (a[n - 1] - a[0] > 1) {
		cout << "No";
		return 0;
	}
	
	int cnt1 = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == a[0]) cnt1++;
	}
	
	if (cnt1 == n) {
		if (a[0] * 2 <= n || a[0] == n - 1) {
			cout << "Yes";
		} else {
			cout << "No";
		}
	} else {
		int cnt2 = n - cnt1;
		int among2 = a[n - 1] - cnt1;
		if (among2 >= 1 && among2 * 2 <= cnt2) {
			cout << "Yes";
		} else {
			cout << "No";
		}
	}
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    map<char, int> m;
	while (getline(cin, s)) {
	    for (auto c : s) {
	        m[c]++;
	    }
	}
	for (char c = 'a'; c <= 'z'; c++) {
	    cout << c << " : " << m[c] + m[c + 'A' - 'a'] << endl;
	}
}


Measured memory_bytes: 3212
package main

import (
  "fmt"
  "bufio"
  "os"
  "strconv"
  "sort"
)

var sc = bufio.NewScanner(os.Stdin)

func sum(A ...int) (ret int) {
  ret = 0
  for _, a := range A {
    ret += a
  }
  return
}

func min(A ...int) (ret int) {
  ret = A[0]
  for _, a := range A {
    if a < ret {
      ret = a
    }
  }
  return
}

func main() {
  var N, M int
  fmt.Scan(&N, &M)
  sc.Split(bufio.ScanWords)
  X := make([]int, M)
  for i, _ := range X {
    sc.Scan()
    x, _ := strconv.Atoi(sc.Text())
    X[i] = x
  }
  sort.Sort(sort.IntSlice(X))
  D := make([]int, M)
  for i := 1; i < M; i++ {
    D[i - 1] = X[i] - X[i - 1]
  }
  sort.Sort(sort.Reverse(sort.IntSlice(D)))
  fmt.Println(X[M - 1] - X[0] - sum(D[:min(N - 1, M)]...))
}

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

int main() {
	
	while (1) {
		int H, W;
		cin >> H >> W;

		if (H == 0 && W == 0) break;

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	
	return 0;

}


Measured memory_bytes: 3088
#include <iostream>

using namespace std;

int main()
{
   int N,M;
   cin >> N >> M;
   int i,A[N],count=0,count_1=0;
   for(i=0;i<N;i++){
       cin >> A[i];
       count+= A[i];
   }
   double B[N],h;
   h = 1.0/(4*M);
   for(i=0;i<N;i++){
       B[i] = A[i]/(1.0*count);
       if(B[i]>=h) count_1+=1;
   }
   
   if(count_1>=M) cout << "Yes";
   else cout << "No";
   
   return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int a=in.nextInt();
		int b=in.nextInt();
		int c=in.nextInt();
		int sum=0;
		for(int i=a;i<=b;i++)
			if(c%i==0)
				sum++;
		System.out.println(sum);
	}
}

Measured memory_bytes: 26220
#include<iostream>
using namespace std;
using ll = long long;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a>b){
        if(a>c) cout << a*10+b+c << endl;
        else cout << c*10+a+b << endl;
    }
    else{
        if(b>c) cout << b*10+a+c << endl;
        else    cout << c*10+a+b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod = M) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P, ll Mod = M) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod = M) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod = M) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination

int main(void) {
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  bool flag = true;
  rep(i,n){
    if (a[i]%2==0){
      if (a[i]%3!=0 && a[i]%5!=0) flag = false;
    }
  }
  if (flag) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
  return 0;
}

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

int main(){
  int n; cin>>n;
  map<int,int> m;
  for(int i=1;i<=n;i++){
    int a; cin>>a;
    m[a]=i;
  }
  long long longest=1,count=1;
  for(int i=1;i<n;i++){
    if(m[i]<m[i+1]){
      count++;
    }else{
      longest=max(longest,count);
      count=1;
    }
  }longest=max(longest,count);
  cout<<n-longest<<endl;
}

Measured memory_bytes: 9728