akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

vector<pair<ll,ll>> V;
bool bl[1007][1007][1007];

int main(){
  ll X,Y,Z,K,a,b,c;
  vector<ll> A,B,C;
  cin >> X >> Y >> Z >> K;
  rep(i,X){
    cin >> a;
    A.push_back(a);
  }
  rep(i,Y){
    cin >> b;
    B.push_back(b);
  }
  rep(i,Z){
    cin >> c;
    C.push_back(c);
  }
  sort(ALL(A));reverse(ALL(A));
  sort(ALL(B));reverse(ALL(B));
  sort(ALL(C));reverse(ALL(C));
  ll x=0,y=0,z=0;
  rep(i,K){
    if(i==0){
      V.push_back(make_pair(A[0]+B[0]+C[0],x*1000000+y*1000+z));
    }
    else{
      if(x<X-1 && bl[x+1][y][z]==0){
        bl[x+1][y][z]=1;
        V.push_back(make_pair(A[x+1]+B[y]+C[z],(x+1)*1000000+y*1000+z));
      }
      if(y<Y-1 && bl[x][y+1][z]==0){
        bl[x][y+1][z]=1;
        V.push_back(make_pair(A[x]+B[y+1]+C[z],x*1000000+(y+1)*1000+z));
      }
      if(z<Z-1 && bl[x][y][z+1]==0){
        bl[x][y][z+1]=1;
        V.push_back(make_pair(A[x]+B[y]+C[z+1],x*1000000+y*1000+(z+1)));
      }
    }
    sort(ALL(V));reverse(ALL(V));
    cout << V[0].first << endl;
    x=V[0].second/1000000;
    y=V[0].second%1000000/1000;
    z=V[0].second%1000;
    V.erase(V.begin());
  }
}

Measured memory_bytes: 677888
while True:
    try:
        n=input()
        if n==0:break
        m=0
        dic={}
        for i in range(n):
            p,d1,d2=map(int,raw_input().split())
            t=d1+d2
            m=max(m,t)
            dic[t]=p
        print dic[m],m
    except SyntaxError:
        pass

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

ll s1, s2, c1, c2;
int main() {
    ll n;
    cin>>n;
    rep(i,n){
        int a;
        cin>>a;
        s1 += a;
        s2 += a;
        if (i % 2) {
            if (s1 <= 0) c1 += 1 - s1,s1 = 1;
            if (s2 >= 0) c2 += 1 + s2,s2 = -1;
        }
        else {
            if (s1 >= 0) c1 += 1 + s1,s1 = -1;
            if (s2 <= 0) c2 += 1 - s2,s2 = 1;
        }
    }
    cout << min(c1, c2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int A,B;
    cin >> A >> B;
    cout << A * B << endl;
    
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

int main() {
	cin.sync_with_stdio(false);
	int c[3][3];
	rep(i, 3) {
		rep(j, 3)cin >> c[i][j];
	}
	bool flag = true;
	rep(i, 2) {
		rep(j, 2) {
			if (c[i + 1][j + 1] - c[i][j + 1] != c[i + 1][j] - c[i][j])flag = false;
			if (c[j + 1][i + 1] - c[j][i + 1] != c[j + 1][i] - c[j][i])flag = false;
		}
	}
	if (flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define plint pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    int n;
    cin >> n;
    cout << n/2+(n%2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int x=0;
  int ans=0;
  for(int i=0; i<n; i++){
    if(s[i]=='I'){
      x++;
    }else if(s[i]=='D'){
      x--;
    }
    ans=max(ans,x);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
const int N=10000;
vector<int>G[N];
queue<int>Q;
list<int>L;
list<int>::iterator it;
int n,m,deg[N]={0},vis[N]={0};
void top(int i){
	Q.push(i);
	while(!Q.empty()){
		int v=Q.front();Q.pop();
		vis[v]=1;
		L.push_back(v);
		for(int i=0;i<G[v].size();i++){
			int u=G[v][i];
			deg[u]--;
			if(deg[u]==0&&!vis[u]) Q.push(u);
		}
	}
}
int main(){
	int u,v;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
	}
	for(int i=0;i<n;i++) for(int j=0;j<G[i].size();j++) deg[G[i][j]]++;
	for(int i=0;i<n;i++) if(deg[i]==0&&!vis[i]) top(i);
	for(it=L.begin();it!=L.end();it++) printf("%d\n",*it);
	return 0;	
}



Measured memory_bytes: 4244
import itertools
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
num = 0
for i in itertools.permutations(range(1,n+1),n):
    if i == p:
        a = num
    if i == q:
        b = num
    num += 1
print(abs(a-b))

Measured memory_bytes: 9188
#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(M, 0);
    int vac = 0;
    for(int i=0; i<M; i++){
        cin >> A[i];
        vac = vac + A[i];
    }

    if((N-vac) >= 0){
        cout << (N-vac) << endl;
    }
    else{
        cout << -1 << endl;
    }

    return 0;

}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {
	char S[15];
	scanf("%s", S);


	S[3] = '8';
	printf("%s", S);



}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
//debug() << imie(x) imie(y);
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
char s[20];cin>>s;
for(int i=0;i<19;i++)
{

	if(s[i]==',') 
	s[i]=' ';
}
cout<<s;
return 0;
}


Measured memory_bytes: 256
a,b,c = map(int,input().split())
kaisuu = int((a-(b-1))/2)
amari = (a-(b-1))%2
if b >= (c-2):
        print(a+1)
else:
        if amari == 1:
                print(kaisuu*(c-b)+1+b)
        else:
                print(kaisuu*(c-b)+b)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int have[26];
int main(){
    memset(have,0,sizeof(have));
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(have[s[i]-'a']){
            cout<<"no\n";
            return 0;
        }
        have[s[i]-'a']++;
    }
    cout<<"yes\n";
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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; }


int main() {    
    int h, w, n; cin >> h >> w >> n;
    double mx = max(h, w);
    int res = ceil(n / mx);
    cout << res << ln;
}

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

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

	int n;
	long long int t;
	vector <long long int> a;
	long long int g = 1;

	cin >> n;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		a.push_back(t);
	}

	long long int res = 0;

	for(int i=0;i<n;i++)
	{
		res += (a[i]-1);
	}

	cout << res << '\n';

	return 0;	
}

Measured memory_bytes: 384
# For taking integer inputs.
import math
from decimal import Decimal
from itertools import permutations


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


a = inlist()
a = sorted(a, reverse=True)

big = a[0]

if big % 2 == 0:
    print(0)
else:
    d1 = a[1] * a[2] * (big // 2)
    d2 = a[1] * a[2] * ((big // 2) + 1)
    print(d2 - d1)


Measured memory_bytes: 5076
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    
    int n,k,l,r,ans=800000000;
    int x[111111];
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    
    for(int i=k-1;i<n;i++){
        l=abs(x[i]-x[i-k+1])+abs(x[i-k+1]);
        r=l-abs(x[i-k+1])+abs(x[i]);
        ans=min(ans,min(l,r));
    }
    
    cout<<ans<<endl;
    
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
    int n,k=0;
    cin>>n;
    if(n>100||n<1){
        return 0;
    }

    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==n){
                k=1;
                cout<<"Yes"<<endl;
                break;
            }
        }
        if(k==1){
                break;
            }
    }

        if(k==0){
            cout<<"No"<<endl;
        }
    return 0;
}

Measured memory_bytes: 256
using System;

class myclass
{
    public static void Main()
    {
        int S = Int32.Parse(Console.ReadLine());
        int s = S % 60;
        int m = ((S - s) % 3600) / 60;
            ;
        int h = (S - s - m) / 3600;
        Console.WriteLine(h + ":" + m + ":" + s);
    }
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int h, n;
    cin >> h >> n;
    vector<int> A(n, 0);
    int cnt = 0;
    rep(i, n) {
        cin >> A[i];
        cnt += A[i];
    }
    if(h<=cnt){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  endl           "\n"
#define  pb             push_back
#define  sym(s)         s="#"+s+"#";
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());

typedef  long long             ll;
typedef  unsigned long long    ull;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   N  =  3e+5+7;

vll adj[N];ll vis[N]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n;
string s;
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>s;n = s.size();
		if(s[n-1]=='s')s+="es";
		else s+='s';
		cout<<s<<endl;
}

int main(){
    fastio;randomINIT;

    //cin>>t;
    while(t--){
        MAIN();
    }

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}

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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

const ll mod = 998244353;

int n;
string s;
int dp[1 << 3];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n >> s;
  ll r = 1;
  int m = (1 << 3) - 1;
  dp[0] = n;
  for (int i = 0; i < 3 * n; i++) {
    // r = (r * (i + 1)) % mod;
    int h = 1 << (s[i] == 'R' ? 0 : (s[i] == 'G' ? 1 : 2));
    if (dp[m ^ h]) {
      r = (r * dp[m ^ h]) % mod;
      dp[m ^ h]--;
      dp[m]++;
    } else if (h != 1 && dp[1]) {
      r = (r * dp[1]) % mod;
      dp[1]--;
      dp[1 | h]++;
    } else if (h != 2 && dp[2]) {
      r = (r * dp[2]) % mod;
      dp[2]--;
      dp[2 | h]++;
    } else if (h != 4 && dp[4]) {
      r = (r * dp[4]) % mod;
      dp[4]--;
      dp[4 | h]++;
    } else {
      r = (r * dp[0]) % mod;
      dp[0]--;
      dp[h]++;
    }
  }
  cout << r << "\n";
}


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

int main(){
	string id[256];
	bool kagisys = true;	//true:lock false:open
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> id[i];
	}	//input

	int m;
	int unknown = 0;
	cin >> m;
	for(int i = 0; i < m; i++){
		string name;
		cin >> name;
		for(int j = 0; j < n; j++){
			if(id[j] == name){
				switch(kagisys){
				case true:
					cout << "Opened by " << name << endl;
					kagisys = false;
					unknown ++;
					break;
				case false:
					cout << "Closed by " << name << endl;
					kagisys = true;
					unknown ++;
					break;
				}
			}
		}
		if (unknown == 0){
			cout << "Unknown " << name << endl;
		}
		unknown = 0;
	}

	return 0;
}

Measured memory_bytes: 1216
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>

using namespace std;
typedef long long ll;
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main()
{
    char str[1500]={};
    int n;
    char *begin[105]={};
    begin[0]=&str[0];
    int poi=0;
    scanf("%d\n",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%s\n",begin[i]);
        while(str[poi]!='\0')poi++;
        begin[i+1]=&str[poi+1];
        poi++;
        if(i>0)
        {
            if(*begin[i]!=*(begin[i]-2))
            {
                printf("No\n");
                return 0;
            }
        }
        REP(k,i-1)
        {
            if(strcmp(begin[i],begin[k])==0)
            {
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}

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

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

    int d[n];

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

    sort(d, d+n);

    int tmp = d[n/2];

    for(int i=0; i<tmp; i++){
      if(i>=d[n/2-1] && i<=d[n/2])
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder bd = new StringBuilder();
        //ArrayList<Integer> A = new ArrayList<Integer>();

        String str = sc.nextLine();
        char[] c = str.toCharArray();

        for (int i=0; i<c.length; i++) {
            if ((int)c[i] >= 65 && (int)c[i] <= 90) {
                bd.append(String.valueOf(c[i]).toLowerCase());
            }
            else if ((int)c[i] >= 97 && (int)c[i] <= 122) {
                bd.append(String.valueOf(c[i]).toUpperCase());
            }
            else {
                bd.append(c[i]);
            }
        }
        System.out.println(bd);
    }
}


Measured memory_bytes: 26352
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int N,M;
    cin >> N >> M;
    int X[M];
    for(int i=0; i<M; i++){
        cin >> X[i];
    }
    sort(X,X+M);
    int interval[M-1];
    for(int i=0; i<M-1; i++){
        interval[i] = X[i+1] - X[i];
    }
    sort(interval,interval+M-1);
    int ans = 0;
    for(int i=0; i<(M-N); i++){
        ans += interval[i];
    }
    cout << ans << endl;
    return 0;
}


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

set<int> solve(string exp) {
    vector<int> idx;
    map<int, int> rev;
    for (int i = 0, c = 0; i < exp.size(); i++) {
        if (exp[i] == '(')
            c++;
        if (exp[i] == ')')
            c--;
        if (c == 0 && (exp[i]=='*' || exp[i]=='/' || exp[i]=='+' || exp[i]=='-')) {
            rev[i] = idx.size();
            idx.push_back(i);
        }
    }

    if(idx.size() == 0) {
        if (exp[0] == '(') return solve(string(exp.begin()+1, exp.end()-1));
        stringstream ss;
        ss << exp;
        int num;
        ss >> num;
        set<int> ans;
        ans.insert(num);
        return ans;
    }

    vector<set<int> > res(idx.size() + 1);
    for (int i = 0; i < idx.size() + 1; i++) {
        int l = i == 0 ? 0 : idx[i - 1] + 1;
        int r = i == idx.size() ? exp.size() : idx[i];
        res[i] = solve(string(exp.begin() + l, exp.begin() + r));
    }


    set<int> ans;
    do {
        vector<set<int> > ret = res;
        vector<int> ridx(idx.size());
        for (int i = 0; i < idx.size(); i++) {
            ridx[rev[idx[i]]] = i;
        }
        for (int i = 0; i < idx.size(); i++) {
            int l = -1;
            int r = rev[idx[i]] + 1;
            set<int> num;
            for (int j = rev[idx[i]]-1, ml = -1; j >= 0 && i > ridx[j]; j--)
                if (ml < ridx[j]) {ml = ridx[j], l = j;}
            if (l == -1) l = rev[idx[i]];
            for (int j = r, mr = -1; j < idx.size() && i > ridx[j]; j++)
                if (mr < ridx[j]) {mr = ridx[j], r = j;}
             for (auto lhs : ret[l]) {
                for (auto rhs : ret[r]) {
                    if (exp[idx[i]] == '+')
                        num.insert(lhs + rhs);
                    if (exp[idx[i]] == '-')
                        num.insert(lhs - rhs);
                    if (exp[idx[i]] == '*')
                        num.insert(lhs * rhs);
                    if (exp[idx[i]] == '/') {
                        if (rhs == 0)
                            continue;
                        num.insert(lhs / rhs);
                    }
                }
            }

            ret[rev[idx[i]]] = num;
        }

        for (auto i : ret[rev[idx[idx.size()-1]]]) ans.insert(i);
    } while (next_permutation(idx.begin(), idx.end()));

    return ans;
}

int main() {
    string str;
    while (cin >> str, str != "#")
        cout << solve(str).size() << endl;

    return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

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

    int n,k;
    cin >> n >> k;
    vector<int> vec(n+1,0);
    rep(i,n){
        int a;
        cin >> a;
        vec[a] += 1;
    }
    sort(all(vec));
    int ans=0;
    for(int i=0;i<=n-k;i++){
        ans += vec[i];
    }
    cout << ans << endl;
    
    
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;
 
#define CASES int t;cin>>t;while(t--)
#define REP(i, val, b) for (int i = val; i < b; ++i)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
 
int main() {
	fastio
	int t, n;
	cin >> t >> n;
	if (n == 100) ++n;
	cout << n;
	REP(i,0,t) cout << "00";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int n,q;
string s;
vector<pair<char,bool>> v;
int f(int k){
    int tmp_x=k;
    char tmp_c=s[k];
    REP(x,v){
        if(x.first==tmp_c){
            if(x.second)tmp_x++;
            else tmp_x--;
            if(tmp_x==-1)return -1;
            else if(tmp_x==n)return 1;
            else tmp_c=s[tmp_x];
        }
    }
    return 0;
}
int main(){
    n=in();
    v.resize(q=in());
    s=stin();
    rep(i,q){
        char c;
        cin>>c;
        bool bl=stin()=="R"?1:0;
        v[i]=mp(c,bl);
    }
    int l1=0,r1=n+1,x=0,y=0;
    while(l1+1<r1){
        x=(l1+r1)/2;
        if(f(x)==-1)l1=x;
        else r1=x;
    }
    int l2=0,r2=n;
    while(l2+1<r2){
        y=(l2+r2)/2;
        if(f(y)==1)r2=y;
        else l2=y;
    }
    cout<<l2-l1<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int main(void)
{
    char str[1000];
    char a[5] = {"apple"};
    char p[5] = {"peach"};
    int i,j;
    int flag;

    flag = 0;
    fgets(str, 1000, stdin);
    for (i = 0; i < strlen(str); i++){
        if (str[i] == 'a'){
            for (j = 0 ; j < 5; j++){
                if (str[i + j] != a[j]){
                    flag = 1;
                    break;
                }
            }
            if (flag == 0){
                for (j = 0; j < 5; j++){
                    str[i + j] = p[j];
                }
            }
        }else if (str[i] == 'p'){
            for (j = 0 ; j < 5; j++){
                if (str[i + j] != p[j]){
                    flag = 1;
                    break;
                }
            }
            if (flag == 0){
                for (j = 0; j < 5; j++){
                    str[i + j] = a[j];
                }
            }

        }
        flag = 0;
        
    }
    printf("%s", str);

    return (0);
}


Measured memory_bytes: 1980
from collections import deque

n,q=map(int,input().split())

g=[[] for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)



c=[0]*n

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

used=[0]*n
used[0]=1
next=deque([0])

while next:
    v=next.popleft()
    cost=c[v]
    for nv in g[v]:
        if used[nv]:
            continue
        used[nv]=1
        next.append(nv)
        c[nv]+=cost

print(*c)
    

Measured memory_bytes: 56084
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 200005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

vvi to, co;
vl d;

void dfs(int v, int p=-1) {
  rep(i,sz(to[v])) {
    int u = to[v][i];
    if (u == p) continue;
    d[u] = d[v]+co[v][i];
    dfs(u,v);
  }
}

int main() {
  int n;
  scanf("%d",&n);
  to = co = vvi(n);
  rep(i,n-1) {
    int a,b;
    scanf("%d%d",&a,&b);
    --a; --b;
    int c;
    scanf("%d",&c);
    to[a].pb(b); co[a].pb(c);
    to[b].pb(a); co[b].pb(c);
  }
  int q,r;
  scanf("%d%d",&q,&r);
  --r;
  d = vl(n);
  dfs(r);
  rep(qi,q) {
    int a,b;
    scanf("%d%d",&a,&b);
    --a; --b;
    ll ans = d[a]+d[b];
    cout<<ans<<endl;
  }
  return 0;
}






















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

int n,q,t;
int main(){
    cin>>n;
    vector<int> s(n);
    rep(i,n) cin>>s[i];
    cin>>q;
    int ans=0;
    rep(i,q){
        cin>>t;
        int l=0,r=n-1;
        while(true){
            int mid=(l+r)/2;
            if(s[mid]==t){
                ans++;
                break;
            }
            else if(l==r) break;
            else if(s[mid]>t) r=mid;
            else l=mid+1;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};


vector<int>p(10000010,-1);

void f(int n=10000005)
{
  p[2]=2;
  for(int i=4;i<n;i+=2)
  {
    p[i]=2;
  }

  for(int i=3;i<n;i+=2)
  {
    if(p[i]==-1)
    {
      p[i]=i;
      for(int j=i*i;j<n;j+=i)
      {
        if(p[j]==-1)p[j]=i;
      }
    }
  }

}


void find(int x,map<int,int>&v)
{
  while(x!=1)
  {
    v[p[x]]++;
    x/=p[x];
  }
}

int32_t main()
{

ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

#ifndef ONLINE_JUDGE
freopen("input.txt","rt",stdin);
freopen("output.txt","wt",stdout);
#endif 

f();
int ans=0;
int n;
cin>>n;

for(int i=1;i<=n;i++)
{
  map<int,int>mp;
  find(i,mp);
  int val=1;
  for(auto j: mp)
  {
      val*=(j.second+1);
  }
  ans+=val*i;
}
 
 cout<<ans<<"\n";


}






Measured memory_bytes: 81208
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#define P 1000000007

#define M 400010
#define in(A, B, C) ((A) >= (B) && (A) <= (C))

using namespace std;

typedef long long ll;

int n, m, S, T, Head[M], Next[M], Go[M], Val[M], Can[M], Cnt = 1;

bool vis[M], used[M];

ll Dis[M], F[M], G[M], totdis;

struct node {
    ll dis, w;
    node(){}
    node(ll _1, ll _2) {
        dis = _1;
        w = _2;
    }
    bool operator < (const node& X) const {
        return dis > X.dis;
    }
};

priority_queue <node> Q;

void addedge(int x, int y, int z) {
    Go[++Cnt] = y;
    Next[Cnt] = Head[x];
    Val[Cnt] = z;
    Head[x] = Cnt;
}

void DIJ() {
    Q.push(node(0, S));
    for(int i = 1; i <= n; i++) Dis[i] = 1e18;
    Dis[S] = 0;
    for(; ;) {
        while(!Q.empty() && vis[Q.top().w]) Q.pop();
        if(Q.empty()) break;
        int W = Q.top().w;
        Q.pop();
        vis[W] = 1; //!!!
        for(int T = Head[W]; T; T = Next[T])
            if(Dis[Go[T]] > Dis[W] + Val[T]) {
                Dis[Go[T]] = Dis[W] + Val[T];
                Q.push(node(Dis[Go[T]], Go[T]));
            }
    }
    totdis = Dis[T];
    for(int i = 1; i <= n; i++)
        for(int T = Head[i]; T; T = Next[T])
            if(Dis[Go[T]] == Dis[i] + Val[T]) {
                Can[T] = 1;
                if(in(totdis - Dis[i], Dis[i] + 1, Dis[Go[T]]) || in(totdis - Dis[Go[T]], Dis[i], Dis[Go[T]] - 1))
                    Can[T] = 2;
            }
}

void add(ll &x, ll y) {
    x = (x + y) % P;
}

void calcS(int x) {
    if(used[x]) return;
    used[x] = 1;
    for(int T = Head[x]; T; T = Next[T]) if(Can[T]) calcS(Go[T]);
    for(int T = Head[x]; T; T = Next[T]) if(Can[T])
        add(F[x], F[Go[T]]);
        
}

void calcT(int x) {
    if(used[x]) return;
    used[x] = 1;
    for(int T = Head[x]; T; T = Next[T]) if(Can[T ^ 1]) calcT(Go[T]);
    for(int T = Head[x]; T; T = Next[T]) if(Can[T ^ 1])
        add(G[x], G[Go[T]]);
}

int main() {
    scanf("%d%d%d%d", &n, &m, &S, &T);
    for(int i = 1; i <= m; i++) {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        addedge(x, y, z);
        addedge(y, x, z);
    }
    DIJ();
    F[T] = 1;
    used[T] = 1;
    calcS(S);
    memset(used, 0, sizeof used);
    used[S] = 1;
    G[S] = 1;
    calcT(T);
    ll ans = F[S] * F[S] % P;
    for(int i = 1; i <= n; i++)
        for(int T = Head[i]; T; T = Next[T])
            if(Can[T] == 2)
                add(ans, -G[i] * F[Go[T]] % P * G[i] % P * F[Go[T]] % P);
    for(int i = 1; i <= n; i++) if(Dis[i] == totdis / 2)
        add(ans, -F[i] * G[i] % P * F[i] % P * G[i] % P);
    printf("%lld\n", (ans % P + P) % P);
    return 0;
}

Measured memory_bytes: 17148
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+100;

ll func(ll n){
    ll m=(n+1)/2;
    if(n%2==0){
        return m%2+n;
    }
    else{
        return m%2;
    }
}

int main()
{
    ll a,b;
    cin >> a >> b;
    a--;
    ll c=func(a);
    ll d=func(b);
    ll ans=c^d;
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256
N=int(input())
A=list(map(int, input().split()))
b=[]
sum=0
for a in A:
    sum+=a
    b.append(sum)

ans=float("inf")
for i in range(0,N-1):
    if ans>abs(b[-1]-b[i]*2):
        ans=abs(b[-1]-b[i]*2)
print(ans)


Measured memory_bytes: 24832
#include <iostream>
using namespace std;
int main() {
  int n; cin >> n;
  int a[101] = {}, t[101] = {}; 
  for(int i = 1; i <= n; i++){
	  cin >> a[i]; t[i] = a[i] + t[i - 1];
  }
  int mi = INT32_MAX;
  for(int i = 1; i <= n; i++){
	  int left = t[i], right = t[n] - t[i];
	//   cout << left << ' '  << right << endl;
	  mi = min(mi, abs(left - right));
  }
  cout << mi;
}

Measured memory_bytes: 256
#<>;$P=6.2831853;for$s(@a=<>){($x,$y,$~)=glob$s;printf"%f\n",sort{$b<=>$a}0,map+(($_-$~)/$P-.5,$~=$_)[0],(@b=sort{$a<=>$b}map{/ /;atan2$'-$y,$`-$x}grep$_ ne$s,@a),"@b"+$P;}
<>;$P=8*atan2 1,1;map{($x,$y,$~)=glob$s=$_;printf"%f\n",sort{$b<=>$a}0,map+(-$~+($~=$_))/$P-.5,(@b=sort{$a<=>$b}map{/ /*atan2$'-$y,$`-$x}grep!/^$s$/,@a),"@b"+$P}@a=<>

Measured memory_bytes: 5248
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt"); return;
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }
    
    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var w     = long.Parse(spl[0]);
        var h     = long.Parse(spl[1]);
        var x     = long.Parse(spl[2]);
        var y     = long.Parse(spl[3]);

        string ret = "";
        ret += (w * h)/2.0;

        if (w % 2 == 0 && x == w / 2 && h % 2 == 0 && y == h / 2) {
            ret += " 1";
        } else {
            ret += " 0";
        }
        return ret;
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

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

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int z;
  cin>>z;
  int ans = -1;
  string outp = "";
  REP(i,8){
    int temp = 0;
    int t = z;
    outp = "";
    REP(j,3){
      if(i>>j & 1){
        temp += t%10;
        outp = to_string(t%10) + outp;
        outp = '+' + outp;
      }else{
        temp -= t%10;
        outp = to_string(t%10) + outp;
        outp = '-' + outp;
      }
      t /= 10;
    }
    temp += t%10;
    outp = to_string(t%10) + outp;
    if(temp==7){
      ans = i;
      break;
    }
  }
  
  outp += "=7";
  cout<<outp<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long

int main()
{
    Hello
    int k;
    cin >> k;
    if (k % 7 == 0) k /= 7;
    if (__gcd(10, k) != 1)
        return cout << -1, 0;
    ll ans = 1 % k, len = 1;
    while (ans != 0) {
        ans = (10 * ans + 1) % k;
        len++;
    }
    cout << len;
    return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
#define mp make_pair
const int maxn=100;
char s[maxn+5][maxn+5];
int dp[maxn+5][maxn+5];
int n,m;
int main()
{

    // ios::sync_with_stdio(false);cin.tie(0);
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i)
        scanf("%s",s[i]+1);
    for(int i=0;i<=n+1;++i)
    for(int j=0;j<=m+1;++j)
    dp[i][j]=n*m;
    dp[0][1]=0;
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j)
            if(s[i][j]=='.') dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
            else
            {
                dp[i][j]=n*m;
                dp[i][j]=dp[i-1][j]+(s[i-1][j]!='#');
                dp[i][j]=min(dp[i][j],dp[i][j-1]+(s[i][j-1]!='#'));
            }
    // for(int i=1;i<=n;++i)
    //     for(int j=1;j<=m;++j)
    //         cout<<i<<" "<<j<<" : "<<dp[i][j]<<endl;
    cout<<dp[n][m]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int N[30],n;
    int ans = 0;
    scanf("%d", &n);
    for (int a = 0; a < n;a++){
        scanf("%d", &N[a]);
    }
  
    for (int b = 0; b < n-2  ;b++){
        if(N[b]<=N[b+1] && N[b+1]<=N[b+2]){
            ans++;
        }
      if(N[b+2]<=N[b+1] && N[b+1]<=N[b]){
          ans++;
       // printf("%d", ans);
    }
     
    }
     printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
s=input()
t=input()
d={}
for i in range(len(s)):
    if s[i] in d.keys():
        if d[s[i]]!=t[i]:
            print("No")
            exit()
    else:
        if t[i] in d.values():
            print("No")
            exit()
        else:
            d[s[i]]=t[i]

print("Yes")


Measured memory_bytes: 3632
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

A,B,C,K = LI()

a_value = min(A,K)
b_value = 0
c_value = 0
if K-A > 0:
    b_value = min(B,K-A)
    if K-A-B>0:
        c_value = K-A-B
ans = 1 * a_value + 0 * b_value + (-1) * c_value
print(ans)

Measured memory_bytes: 61860
#include <stdio.h>
#include <math.h>

int main(){
	int q;
	double x;

	while(1){
		scanf("%d",&q);
		if(q == -1){
			break;
		}

		x = q/2.0;
		while(fabs(pow(x,3)-q) >= 0.00001*q){
			x = x - (pow(x,3)-q*1.0)/(3.0*pow(x,2));
		}

		printf("%f\n",x);
	}

	return 0;
}

Measured memory_bytes: 692
import numpy as np
n, d = list(map(int, input().split()))
a = list(map(int, input().split()))
Max = 0
Sum = 0
a = np.array(a)
a = a*0.5 + 0.5
ans = []

if d == 1:
  print(max(a))
elif n == d:
  print(sum(a))
else:
  for i in range(n-d+1):
    left = a[i]
    right = a[i+d-1]

    if i == 0:
      Sum = sum(a[i:i+d])
      Max = sum(a[i:i+d])
      ans = a[i:i+d]
    else:
      Sum = Sum + right - a[i-1]

      if Sum >= Max:
        Max = Sum
        ans = a[i:i+d]
      else:
        pass

  print(sum(ans))

Measured memory_bytes: 33836
N = int(input())
lis_p = list(map(int, input().split()))

lis_ans = sorted(lis_p)

count = 0
for i in range(N):
    if lis_p[i] != lis_ans[i]:
        count += 1

if count == 2 or count == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 38384
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b;
    if(a>b){
        cin>>c;
        if(b>c) cout<<c<<" "<<b<<" "<<a;
        else if(c>a)    cout<<b<<" "<<a<<" "<<c;
        else  cout<<b<<" "<<c<<" "<<a;  
    }
    else{
        cin>>c;
        if(a>c) cout<<c<<" "<<a<<" "<<b;
        else if(c>b)    cout<<a<<" "<<b<<" "<<c;
        else    cout<<a<<" "<<c<<" "<<b;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3096
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Queue;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;



public class Main{
	
	static int posx;
	static int posy;
	static int type;
	static int diff;
	static int INF = Integer.MAX_VALUE;
	static int[][] d;
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd (long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}



	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}


	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}


	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}


	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 long X=sc.nextLong();
	 long Y=sc.nextLong();
	 
     long result = 0;
     while(X<=Y) {
    	X*=2;
    	 result++;
     }
     System.out.println(result);
     
	 
	 
 }
	


}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std ;
signed main() {
  int n ; cin >> n ; int cnt = 0 ;
  int k ; cin >> k ;
  std::vector< int > v ;
  for(register int i = 1 ; i <= n ; i ++) {
    int x ;cin >> x ;
    v.push_back(x) ;
  }
  for(auto x : v)
    if(x >= k) cnt ++ ;
  cout << cnt << endl ;
  return 0 ;
}

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>
using namespace std;
using ll = long long;
vector<pair<ll,ll>> p;
set<int> s,t;
ll ans = 0,n;
ll solve(int x){
	int l1 = 0,l2 = 0,r1 = n + 1,r2 = n + 1;
	auto it = s.upper_bound(x);
	if(it!=s.end()){
		r1 = *it;
		it++;
		if(it!=s.end()){
			r2 = *it;
		}
	}
	it = t.upper_bound(-x);
	if(it!=t.end()){
		l1 = *it; l1 *= -1;
		it++;
		if(it!=t.end()){
			l2 = *it; l2 *= -1;
		}
	}
	return (r1 - x)*(l1 - l2) + (x - l1)*(r2 - r1);
}
int main(){
	int i;
	cin >> n;
	for(i=0;i<n;i++){
		int x; cin >> x;
		p.push_back({x,i + 1});
	}
	sort(p.rbegin(),p.rend());
	for(i=0;i<n;i++){
		int ind = p[i].second;
		s.insert(ind); t.insert(-ind);
		ans += p[i].first*solve(ind);
	}
	cout << ans << endl;
}

Measured memory_bytes: 11248
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<cassert>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<bitset>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 10e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

const int a[3] = {3, 5, 7};

set<int> num;

void dfs(int m, int d, vector<int> used) {
    if(d >= 3 && used[0] && used[1] && used[2]) num.insert(m);
    if(d == 9) return;
    for(int i=0;i<3;i++) {
        vector<int> new_used(used);
        new_used[i] = 1;
        dfs(m * 10 + a[i], d+1, new_used);
    }
    return;
}

int main() {
    int n, ans = 0;
    cin >> n;
    vector<int> used(3, 0);
    dfs(0, 0, used);
    for(int m: num) {
        if(m <= n) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

typedef tuple<ll, ll, ll> T;

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<T> c;
    REP(i,n) {
        int a, b;
        cin >> a >> b;
        c.push_back(make_tuple(a+b, a, b));
    }
    sort(c.begin(), c.end(), greater<>());
    ll choku = 0;
    ll aoki = 0;
    REP(i,n) {
        if (i % 2 == 0) choku += get<1>(c[i]);
        else aoki += get<2>(c[i]);
    }
    cout << choku-aoki << endl;
    return 0;
}

Measured memory_bytes: 4980