akhauriyash/Code-Regression huggingface dataset:
X, K, D = map(int, input().split())
if abs(X) < abs(X - D) and abs(X) < abs(X + D):
    if K % 2 == 0:
        print(abs(X))
    else:
        print(min(abs(X - D), abs(X + D)))
else:
    if abs(X - D) < abs(X + D):
        if K * D <= abs(X):
            print(abs(X - (K * D)))
        else:
            remain = K - (abs(X) // D)
            X = X - (abs(X) // D) * D
            if remain % 2 == 0:
                print(abs(X))
            else:
                print(abs(X - D))
    elif abs(X - D) >= abs(X + D):
        if K * D <= abs(X):
            print(abs(X + (K * D)))
        else:
            remain = K - (abs(X) // D)
            X = X + (abs(X) // D) * D
            if remain % 2 == 0:
                print(abs(X))
            else:
                print(abs(X+D))


Measured memory_bytes: 9236
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;
	cin>>n;
	vector<int> a(n);
	int lo=1e6+1,p_lo,hi=-1e6-1,p_hi;
	for(int i=0;i<n;++i){
		int x;
		cin>>x;
		a[i]=x;
		if(x<lo){
			lo=x;
			p_lo=i;
		}
		if(x>hi){
			hi=x;
			p_hi=i;
		}
	}
	if(lo<0) lo=-lo;
	if(hi<0) hi=-hi;
	vector<pair<int,int>> res;
	if(lo<hi){
		for(int i=0;i<n;++i)
			if(i!=p_hi)
				res.emplace_back(p_hi+1,i+1);
		for(int i=2;i<=n;++i)
			res.emplace_back(i-1,i);
	}
	else{
		for(int i=0;i<n;++i)
			if(i!=p_lo)
				res.emplace_back(p_lo+1,i+1);
		for(int i=n-1;i>=1;--i)
			res.emplace_back(i+1,i);
	}
	cout<<int(res.size())<<'\n';
	for(auto it:res)
		cout<<it.first<<' '<<it.second<<'\n';
}




Measured memory_bytes: 3672
#include<stdio.h>
int main(){
    int a,b,c,d,m,i;
    scanf("%d%d%d%d",&a,&b,&c,&d);
m=a*b;
i=c*d;
      if(m<=i){
          printf("%d\n",i);}
      else{
          printf("%d\n",m);
      }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv){
  // 受け取り
  int N, M;
  cin >> N >> M;
  vector<pair<long long, int>> menu;
  for(int cnt0=0; cnt0<N; cnt0++) {
    long long tmpA;
    int tmpB;
    cin >> tmpA >> tmpB;
    menu.push_back(make_pair(tmpA, tmpB));
  }

  // ソートして安いやつから順に取れるだけ取る
  sort(menu.begin(), menu.end());
  
  int m = M;
  int idx=0;
  long long ans=0;
  while(m != 0){
    int add = min(menu[idx].second, m);
    m -= add;
    ans += menu[idx].first*add;
    idx++;
  }
  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 2420
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(A.Distinct().Count() == A.Length ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 39196
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)((n>>m)&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}


ll n,ans;
ll a[999];
int main(){
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	rep(i,1,n-1)if(a[i-1]==a[i]&&a[i]==a[i+1])ans++,a[i]=-1;
	rep(i,1,n)if(a[i-1]==a[i])ans++,a[i]=-2;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
import itertools
import math
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
juretu=list(range(1,N+1))
so = math.factorial(N)
p=[]
for v in itertools.permutations(juretu, N):
  p.append(list(v))

P_v = [False,0]
Q_v = [False,0]
for i,v in enumerate(p):
  if P == v:
    P_v = [True,i+1]
  if Q == v:
    Q_v = [True,i+1]
  if P_v[0] and Q_v[0]:
    print(abs(P_v[1] - Q_v[1]))
    break



Measured memory_bytes: 10356
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=100+10,dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int a[N][N],n,m,sz[N][N];
string str;
struct P{
    int x,y;
};
void bfs(){
    sz[0][0]=1;
    queue<P>q;
    P p,ne;
    p.x=0;p.y=0;
    q.push(p);
    while(!q.empty()){
        p=q.front();
        q.pop();
        int x=p.x,y=p.y;
        for(int i=0;i<4;i++){
            ne.x=x+dx[i];
            ne.y=y+dy[i];
            if(ne.x>=0&&ne.x<n&&ne.y>=0&&ne.y<m){
                if(sz[ne.x][ne.y]>sz[x][y]+1&&a[ne.x][ne.y]!=1) {
                    sz[ne.x][ne.y]=sz[x][y]+1;
                    q.push(ne);
                }
            }
 
        }
    }
 
}
int main() {
    while(~scanf("%d%d",&n,&m)){
        int sum=0;
        for(int i=0;i<n;i++){
            cin>>str;
            for(int j=0;j<m;j++){
                sz[i][j]=10000;
                if(str[j]=='.'){
                    sum++;
                    a[i][j]=0;
                }
                else {
                    a[i][j]=1;
                }
            }
        }
        bfs();
        printf("%d\n",sz[n-1][m-1]==10000?-1:sum-sz[n-1][m-1]);
 
    }
    return 0;
}


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

int main(){
  int n;
  double t,a;
  cin>>n>>t>>a;
  double h[n];
  double mn = 999999999;
  int ans = -1;
  for(int i=0;i<n;i++){
    cin>>h[i];
    double k = t-h[i]*0.006;
    if(abs(k-a)<mn){
      mn = abs(k-a);
      ans = i+1;
    }
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
//#define MOD 1000000007
//#define pii pair<int,int>
//#define unmap unordered_map<int,int>
//#define ll long long int
using namespace std;

void solve() {
    int s, w;
    cin >> s >> w;
    if (w >= s)
        cout << "unsafe" << "\n";

    else
        cout << "safe" << "\n";

}





int main()
{


    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(Int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(Int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using Int = long long;
using ll = long long;
using P = pair<Int,Int>;
using vi = vector<Int>;
using vvi = vector<vi>;
using vp = vector<P>;
using vvp = vector<vp>;

const Int INF = (1LL<<50);

void solve(long long N, long long K){
  Int ans = 0;
  REP(b, max(K, 1LL), N+1){
    // a < b
    dump(b, ans);
    ans += b - K;
    // a >= b
    dump(b, ans);
    REP(x, 1, N/b + 1){
      Int ub = min(N+1, (x+1) * b);
      Int lb = x * b + K;
      ans += max(ub - lb, 0LL);
    }
    if(!K) ans--;
    dump(b, ans);
  }
  cout << ans << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  solve(N, K);
  return 0;
}


Measured memory_bytes: 256
import collections

n = int(input())

alp = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
alpcnt = [50]*26

for i in range(n):
  S = list(input())
  C = collections.Counter(S)
  for j in range(26):
    alpcnt[j] = min(alpcnt[j],C[alp[j]])

for i in range(26):
  print(alp[i]*alpcnt[i], end = "")
  

Measured memory_bytes: 69684
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#define x first
#define y second

template<typename T>inline void check_min(T a,T &b){if(a<b)b=a;}
template<typename T>inline void check_max(T a,T &b){if(a>b)b=a;}

namespace yy
{
	const int N=201000,M=N*20;

	struct bit
	{
		bool s[N];
		inline int lowbit(int x){return x&(-x);}
		void init(){memset(s,0,sizeof(s));}
		void inc(int p){p++;for(;p<N;p+=lowbit(p))s[p]=1;}
		bool query(int p){p++;bool ret=0;for(;p;p-=lowbit(p))ret|=s[p];return ret;}
	}T;

	struct node
	{
		int L,R,ty;
		node(int a=0,int b=0,int c=0):L(a),R(b),ty(c){}
		bool operator < (const node &h) const {return L==h.L?R==h.R?ty<h.ty:R<h.R:L>h.L;}
	};

	node s[M];

	int begin[N],next[M*2],to[M*2],w[M*2];
	int pos[N];
	int n,m,e,tot,cnt,S;

	void add(int x,int y,int z,bool k=1)
	{
		to[++e]=y;
		next[e]=begin[x];
		begin[x]=e;
		w[e]=z;
		if(k)add(y,x,z,0);
	}

	void work(int dis,int dep)
	{
		for(int L=1,R;L<=n;L=R+1)
		{
			for(R=L;R<n && pos[R+1]-pos[R]<=dis;R++);
			if(dep>1)add(L,R,dep-1);
			else s[++tot]=node(L,R,1);
		}
	}
	void initialize()
	{
		scanf("%d%d",&n,&m);
		for(int i=1;i<=n;i++)
			scanf("%d",pos+i);
		tot=0,cnt=1;
		for(int tmp=m;;tmp/=2,cnt++)
		{
			work(tmp,cnt);
			if(!tmp)break;
		}
		S=1<<(cnt-1);
	}

	inline int ins(int k,int i){return k|(1<<(i-1));}
	int f[N*4],g[N*4];

	void dp()
	{
		for(int i=0;i<S;i++)
			f[i]=0,g[i]=n+1;
		for(int k=0;k<S;k++)
		{
			int p=f[k]+1;
			for(int i=begin[p];i;i=next[i])
				if(!(k&(1<<(w[i]-1))))
					check_max(to[i],f[ins(k,w[i])]);
			p=g[k]-1;
			for(int i=begin[p];i;i=next[i])
				if(!(k&(1<<(w[i]-1))))
					check_min(to[i],g[ins(k,w[i])]);
		}
	}

	bool ans[N];

	void solve()
	{
		initialize();
		dp();
		
		for(int k=0;k<S;k++)
			s[++tot]=node(f[k]+1,g[S-k-1]-1,0);
		std::sort(s+1,s+tot+1);
		T.init();

		for(int i=1;i<=tot;i++)
		{
			if(!s[i].ty)T.inc(s[i].R);
			else if(T.query(s[i].R))
			{
				for(int j=s[i].L;j<=s[i].R;j++)
					ans[j]=1;
			}
		}
		for(int i=1;i<=n;i++)
			printf("%s\n",ans[i]?"Possible":"Impossible");
	}
}

int main()
{
//	freopen("E.in","r",stdin);
//	freopen("E.out","w",stdout);
	yy::solve();
	return 0;
}


Measured memory_bytes: 71040
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int n, k;
    cin >> n >> k;

    int ans = 0;

    if (n >= 13) {
        ans += ((n - 2) / 11) * 5;
        n = ((n - 2) % 11) + 2;
    }

    for (int i = 1; i < n - 1; ++i) {
        for (int j = 2; j <= 6; ++j) {
            if ((9 * (i * 7 + j)) % 11 == k) {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    cout << max({A + B, A - B, A * B}) << endl;
    return 0;
}


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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N,M,Q; cin >> N >> M >> Q;
	string S,T; cin >> S; cin >> T;
	vector<int> ln(M+2,-1e9),rn(M+2,1e9),ls(M+2,-1e9),rs(M+2,1e9);
	vector<int> ue(N+2,-1e9),de(N+2,1e9),uw(N+2,-1e9),dw(N+2,1e9);
	repp(i,0,M){
		ln[i+1] = ln[i]; ls[i+1] = ls[i];
		if(T[i] == 'N') ln[i+1] = i+1;
		else ls[i+1] = i+1;
	}
	repm(i,M,0){
		rn[i] = rn[i+1]; rs[i] = rs[i+1];
		if(T[i-1] == 'N') rn[i] = i;
		else rs[i] = i;
	}
	repp(i,0,N){
		ue[i+1] = ue[i]; uw[i+1] = uw[i];
		if(S[i] == 'E') ue[i+1] = i+1;
		else uw[i+1] = i+1;
	}
	repm(i,N,0){
		de[i] = de[i+1]; dw[i] = dw[i+1];
		if(S[i-1] == 'E') de[i] = i;
		else dw[i] = i;
	}
	repp(rep_q,0,Q){
		int a,b,c,d; cin >> a >> b >> c >> d;
		vector<int> v(6),h(6);
		h[0] = a; v[0] = b; h[5] = c; v[5] = d;
		if(S[a-1] == 'E'){
			h[1] = uw[a]; h[2] = dw[a];
		} else {
			h[1] = ue[a]; h[2] = de[a];
		}
		if(S[c-1] == 'E'){
			h[3] = uw[c]; h[4] = dw[c];
		} else {
			h[3] = ue[c]; h[4] = de[c];
		}
		if(T[b-1] == 'N'){
			v[1] = ls[b]; v[2] = rs[b];
		} else {
			v[1] = ln[b]; v[2] = rn[b];
		}
		if(T[d-1] == 'N'){
			v[3] = ls[d]; v[4] = rs[d];
		} else {
			v[3] = ln[d]; v[4] = rn[d];
		}
		vector<vector<int>> ans(6,vector<int>(6,1e8)),p(6,vector<int>(6,0));
		ans[0][0] = 0;
		int x = 0, y = 0;
		while(x != -1){
			p[x][y] = 1;
			int xx = -1, yy = -1, zz = 1e8;
			repp(i,0,6) repp(j,0,6) if(!p[i][j]){
				if(h[x] == h[i] && h[x] > 0 && h[x] <= N && (((S[h[x]-1]=='W')^(v[y]<v[j])) || v[y] == v[j])) ans[i][j] = min(ans[i][j],ans[x][y]+abs(v[j]-v[y]));
				if(v[y] == v[j] && v[y] > 0 && v[y] <= M && (((T[v[y]-1]=='N')^(h[x]<h[i])) || h[x] == h[i])) ans[i][j] = min(ans[i][j],ans[x][y]+abs(h[i]-h[x]));
				if(zz > ans[i][j]){
					xx = i; yy = j; zz = ans[i][j];
				}
			}
			x = xx; y = yy;
		}
		cout << (ans[5][5]==1e8?-1:ans[5][5]) << endl;
	}
	return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

    int n;
    cin >> n;
    vi x(n), y(n), h(n);
    REP(i, n) cin >> x[i] >> y[i] >> h[i];
    REP(xi, 101) REP(yi, 101) {
        int hh = 0;
        bool f = true;
        REP(i, n) {
            if(h[i] == 0) continue;
            int temp = h[i] + abs(x[i] - xi) + abs(y[i] - yi);
            if(hh == 0) hh = temp;
            else {
                if(hh != temp) {
                    f = false;
                    break;
                }
            }
        }
        if(!f) continue;
        REP(i, n) {
            if(h[i] == 0) {
                if(hh - abs(x[i] - xi) - abs(y[i] - yi) > 0)
                f = false;
            }
        }
        if(!f) continue;

        cout << xi << " " << yi << " " << hh << endl;
    }

    return 0;
}

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

using namespace std;

int main(void){
    unsigned long long int n=0;
    vector<pair<unsigned long long int, unsigned long long int> > tasks;
    cin >> n;
    for(int i=0; i<n; i++){
        unsigned long long int tmp1;
        unsigned long long int tmp2;
        cin >> tmp1;
        cin >> tmp2;
        tasks.emplace_back(tmp2, tmp1);
    }


    sort(tasks.begin(),tasks.end());

    unsigned long long int sum = 0;
    bool flag = true;
    for(int i=0; i<n;i++){
        sum += tasks[i].second;
        if(sum > tasks[i].first){
            flag = false;
        }
        // cout << " " << tasks[i].first << "/"<< sum << endl;
    }

    if(flag){
        cout << "Yes";
    }else{
        cout << "No" ;
    }

    return 0;
}


Measured memory_bytes: 6384
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    ll a, b, z = 0, y = mod;
    cin >> n;
    while (n--) {
        cin >> a >> b;
        z += a;
        if (a > b) y = min(y, b);
    }
    if (y == mod) cout << 0;
    else cout << z - y;
}


Measured memory_bytes: 768
s = input()
t = input()
ls = len(s)
lt = len(t)
dp = [[0 for _ in range(lt+1)] for _ in range(ls+1)]
for i in range(ls):
    for j in range(lt):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])
#back trace
ans = []
while i >= 0 and j >= 0:
    if dp[i+1][j+1] == dp[i][j] + 1 and s[i] == t[j]:
        ans.append(s[i])
        i -= 1
        j -= 1
    elif dp[i+1][j+1] == dp[i+1][j]:
        j -= 1
    else: i -= 1
ans.reverse()
print(''.join(ans))

Measured memory_bytes: 119772
/*
 Shahadat Hossain
 I.C.T Department
 Comilla University
 Session: 2013-2014
 */

#include<bits/stdc++.h>
using namespace std;

//#define int long long
#define valid(x,y) x>=0 && y>=0 && x<n && y<n
#define all(x) x.begin(),x.end()
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define ms(a,b) memset(a, b, sizeof(a))
#define eps 1e-5
#define input freopen("/Users/shahadat/Desktop/input.txt", "r", stdin)
#define output freopen("/Users/shahadat/Desktop/output.txt", "w", stdout)
#define d(x) cout << #x << " = " << x << endl
#define dd(x,y) cout << #x << " = " << x << "   " << #y << " = " << y << endl
#define ddd(x,y,z) cout << #x << " = " << x << "   " << #y << " = " << y << "   " << #z << " = " << z << endl
//fprintf(stdout,"\nTIME: %.3lf sec\n", (double)clock()/(CLOCKS_PER_SEC));
//int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
#define bit(n,k) (((n)>>(k))&1)
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define pr(x) {cout << (x) << '\n';  }
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define mask(i) ((1LL<<(i)))
#define endl '\n'
double const PI = acos(-1);
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

int const N = 1e5+10;
int const M = 505;
int const MOD = 998244353;
const int INF = 1e9 + 5;

void solve(){
    int n;
    cin >> n;
    
    vector<int> h(n);
    for(int& x: h)
        cin >> x;
    
    vector<int> dp(n, INF);
    
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j : {i + 1, i + 2}){
            if(j < n)
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }
    cout << dp[n - 1] << endl;
}

int32_t main(){
    solve();
}


Measured memory_bytes: 1024
N, K = map(int, input().split())
putting = []
for i in range(0, N):
	putting.append(list(map(int, input().split())))
putting.sort(key = lambda v: v[0])
sum = 0
for i in range(0, N):
	sum += putting[i][1]
	if K <= sum:
		print(putting[i][0])
		break

Measured memory_bytes: 64604
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>

using namespace std;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;
const double pi = 3.141592653589;

/* typedef */

typedef long long ll;

/* global variables */

/* function */

/* main */
int main() {

    int n, x;

    while (1) {
        cin >> n >> x;

        if (!(n + x)) return 0;

        int ans = 0;
        for (int i = 1; i <= n-2; i++) {
            for (int j = i+1; j <= n-1; j++) {
                int k = x - i - j;
                if (j < k && k <= n) 
                        ans++;
            }
        }

        cout << ans << '\n';

    }

}



Measured memory_bytes: 3084
s = input()
n = len(s) - 1
a = 0
for i in range(2 ** n):
    f = s[0]  
    for j in range(n):  
        if ((i >> j) & 1):
            f += "+"
        f += s[j + 1]
    a += sum(map(int, f.split("+")))

print(a)

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

typedef long long ll;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll a, b;
	cin>>a>>b;
	
	if(a > 9 || b > 9) cout<<-1<<endl;
	else cout<<(a*b)<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>

using namespace std;

int main()
{
  int R;
  cin >> R;
  if (R < 1200) {
    cout << "ABC" << endl;
  }
  else if (R < 2800) {
    cout << "ARC" << endl;
  }
  else {
    cout << "AGC" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split(" ")))

count = 0

for c in range(N):
    if c == 0:
        H_max = H[c]
        count += 1
    else:
        if H_max <= H[c]:
            H_max = H[c]
            count += 1
        else:
            pass

print(count)
        

Measured memory_bytes: 2940
#include<stdio.h>
int main()
{
	int a,b,c,d,h;
	while(scanf("%d %d %d %d",&a,&b,&c,&d)!=EOF)
	{
		if(b<a)
		{
			h=a;
			a=b;
			b=h;
		}
		if(d<c)
		{
			h=c;
			c=b;
			b=h;
		}
		if((a<=b&&b<=c&&c<=d)||(c<=d&&d<=a&&a<=b))
		h=0;
		else if(a<=c&&c<=b&&b<=d)
		h=b-c;
		else if(a<=c&&c<=d&&d<=b)
		h=d-c;
		else if(c<=a&&a<=b&&b<=d)
		h=b-a;
		else if(c<=a&&a<d&&d<=b)
		h=d-a;
		printf("%d\n",h);
	}
	return 0;
}

Measured memory_bytes: 128
n = int(input())
cnt = 0

def lucas(n, ans1, ans2):
    if(n >= 2):
        for _ in range(n-1):
            ans = ans1 + ans2
            ans1 = ans2
            ans2 = ans
        return ans
            
    elif(n == 0):
        return 2
    elif(n == 1):
        return 1

print(lucas(n, 2, 1))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii;
#define pb push_back
#define debug(x) cout << x << endl
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const LL INF64 = 1e18;

const int N = 1e5 + 5;

int main() {
	fastio;
	LL a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a <= k)
		puts("Yay!");
	else puts(":("); 
	return 0;
}
		

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

int main() {
  ll n,l,r;
  cin >> n >> l >> r;
  if(n==1) {
    if(l==r) {
      cout << 1 << endl;
    }
    else {
      cout << 0 << endl;
    }
    return 0;
  }
  if(r<l) {
    cout << 0 << endl;
    return 0;
  }
  ll ans=(r-l)*(n-2)+1;
  cout << ans << endl;
}

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

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

#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

inline void INP();
const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N+2];

bool check(string str)
{
      int n1 = str.length();
      int i = 0, j = n1 -1;
      while(i < j)
      {
            if(str[i] != str[j])return false;
            i++;
            j--;
      }

      return true;
}
void solve()
{
      
      string str;
      cin >> str;
      n = str.length();
      int x= (n+3)/2;
      string s1 = str.substr(0,(n-1)/2);

      string s2 = str.substr(x-1);

      if(check(str) and check(s1) and check(s2) )cout << "Yes";
      else cout <<"No";

}


int32_t main()
{
      
      ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);
      //INP(); 
      int t = 1;
      //cin >> t;
      while(t--) solve();

}











inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

void chmax(Int& a, Int b) { if (a < b) { a = b; } }

int main() {
	Int N, W;
	cin >> N >> W;
	vector<Int> w(N), v(N);
	for (int i = 0; i < N; ++i) {
		cin >> w[i] >> v[i];
	}

	vector<vector<Int>> dp(N + 1, vector<Int>(3 * N + 1, -1));
	dp[0][0] = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = N; j > 0; --j) {
			for (int k = 3 * N; k >= 0; --k) {
				int kx = k - (w[i] - w[0]);
				if (kx < 0 || dp[j - 1][kx] < 0) { continue; }
				chmax(dp[j][k], dp[j - 1][kx] + v[i]);
			}
		}
	}

	Int ans = 0;
	for (Int j = 1; j <= N; ++j) {
		for (Int k = 0; k <= 3 * N; ++k) {
			if (k + j * w[0] > W) { break; }
			chmax(ans, dp[j][k]);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
    using namespace std;
    int main(){
        string S;
        cin >> S;

        if(S=="SUN"){
            cout << 7 << endl;
        }else if(S=="MON"){
            cout << 6 << endl;
        }else if(S=="TUE"){
            cout << 5 << endl;
        }else if(S=="WED"){
            cout << 4 << endl;
        }else if(S=="THU"){
            cout << 3 << endl;
        } else if(S=="FRI"){
            cout << 2 << endl;
        }else if(S=="SAT"){
            cout << 1 << endl;
        }
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    for (int i = 0; i < b; i++) {
        int x;
        cin >> x;
        a -= x;
    }
    cout << (a < 0 ? - 1 : a) << '\n';
}

Measured memory_bytes: 3644
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int product = a*b;
        if (product%2 == 0){
            System.out.println("Even");
        }
        else {
            System.out.println("Odd");
        }
    }
}


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

using namespace std;

int main() {
    int n , k , r , s , p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;

    string played(n , 'n');

    auto opp = [](char c) {
        if (c == 'r') return 'p';
        if (c == 's') return 'r';
        return 's';
    };

    auto score = [&](char c) {
        if (c == 'r') return r;
        if (c == 's') return s;
        return p;
    };

    int ans = 0;
    for (int i = 0 ;i < n ;i++) {
        char want = opp(t[i]);
        if (i < k || played[i - k] != want) {
            ans += score(want);
            played[i] = want;
        }
    }

    cout << ans;
}

Measured memory_bytes: 512
object Main extends App {
  var num = readInt
    var get = readLine
  var r = 0
  var b = 0
  for(i <- 0  to num-1) {
    if(get(i)=='R')
    r+=1
    else
    b+=1
  }
  if(r>b)
      println("Yes")
  else
  println("No")
    }

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



int main() {
  string ans="No";
  rep(i, 3){
    char c;
    cin >> c;
    if(c == '7') ans="Yes";
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
#include<ctime>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;

#define ll long long
#define MP make_pair
int n,m,num=0;
vector<vector<int>> e;

void dfs(int crtv,int nextv,vector<vector<int>> nowe,vector<int> nowv){

    nowe[crtv][nextv]=0;
    nowe[nextv][crtv]=0;

    bool jud=true;
    for (int i = 0; i < n; i++) {
        if(nowv[i]==0)jud=false;
    }
    if(jud){
        
        num++;
        return;
    }

    

    for (int i = 0; i < n; i++) {
        if(nowe[nextv][i]==1&&nowv[i]==0){
            nowv[i]=1;
            dfs(nextv,i,nowe,nowv);
            nowv[i]=0;
        }
    }





    return;
}

int main(void) {
    cin>>n>>m;
    int tn,tm;

    e.resize(n);
    for (int i = 0; i < e.size(); i++) {
        e[i].resize(n);
    }

    for (int i = 0; i < m; i++) {
        cin>>tn>>tm;
        e[tn-1][tm-1]=1;
        e[tm-1][tn-1]=1;
    }
    vector<int> v(n);
    v[0]=1;
    for (int i = 0; i < n; i++) {
        if(e[0][i]==1&&v[i]==0){
            v[i]=1;
            dfs(0,i,e,v);
            v[i]=0;
        }
    }

    cout<<num<<"\n";

    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
int a,b,c,d=0;
cin>>a>>b>>c;
a=a*100;
b=b*10;
d=a+b+c;
if (d%4==0)cout<<"YES";
else
    cout <<"NO";
return 0;
}





Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int A,B,C;
  scanf("%d",&A);
  scanf("%d",&B);
  scanf("%d",&C);
  if(A==B && A!=C){
    printf("Yes");
  }
  else if(A==C && A!=B){
   printf("Yes");
  }
  else if(B==C && B!=A){
    printf("Yes");
  }
  else if(A==B && B==C){
    printf("No");
  }
  else if(A!=B && B!=C){
    printf("No");
  }
  return 0;
 }

Measured memory_bytes: 1700
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
ll bg = 20000001;
#define ff(i,n) for(i=0;i<n;i++) 
void dfs(ll i,ll vis[],ll p[],vector<vector<ll> > &adj,ll par)
{
	vis[i] = 1;
	p[i] = par;
	ll j;
	for(j=0;j<adj[i].size();j++)
	{
		if(vis[adj[i][j]]==0)
		{
			dfs(adj[i][j],vis,p,adj,i);
		}
	}
}
ll dp[140000][26];
string s;
ll fun(ll l,ll r,ll alpha)
{
	ll mid = (l+r)/2;
	if(l==r)
	{
		if((s[l-1]-'a')!=alpha)
		   return 1;
		else
		   return 0;   
	}
	ll l1 = ((r-mid)-(dp[r][alpha]-dp[mid][alpha])) + fun(l,mid,alpha+1);
	ll l2 = ((mid-l+1)-(dp[mid][alpha]-dp[l-1][alpha])) + fun(mid+1,r,alpha+1);
	ll l3 = min(l1,l2);
	return l3;
}
int main()
{
	ll test,t;
	t=1;
	for(test=1;test<=t;test++)
	{
		ll i,n,a=0;
		cin>>n;
		ll arr[n];
		ff(i,n)
		    cin>>arr[i];
		ff(i,n)
		    if(i%2==0 && arr[i]%2==1)    
		      a++;
		cout<<a;      
	}
	return 0;
} 

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

const ld PI = acos(-1);

void turn(ld & x, ld & y, ld alpha) {
	ld nx = x * cos(alpha) - y * sin(alpha);
	ld ny = x * sin(alpha) + y * cos(alpha);
	x = nx, y = ny;
}

int a, b, h, m;

void read() {
	cin >> a >> b >> h >> m;	
}

ld dist(ld x1, ld y1, ld x2, ld y2) {
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

ld ans;

void run() {
	ld x1 = 0, y1 = a;
	turn(x1, y1, (ld)h * 30 * PI / 180 + (ld) m * 6 * PI / 180 / 12);
	//cout << "t1 = " << (ld) h * 30 / 180 << endl;
	ld x2 = 0, y2 = b;
	turn(x2, y2, (ld)m * 6 * PI / 180);
	
	//cout << "t2 = " << (ld)m * PI / 30 << endl;
	//cout << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
	ans = dist(x1, y1, x2, y2);
}

void write() {
	cout.precision(20);
	cout << ans << endl;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 4184
from collections import defaultdict

N=int(input())
A=list(map(int,input().split()))
C=defaultdict(int)
B=[]
for a in A:
    C[a]+=1
ans=0
for i,v in C.items():
    if i>v:
        ans+=v
    elif i<=v:
        ans+=v-i
print(ans)


Measured memory_bytes: 18676
def popcount(x):
    return bin(x).count("1")


n=int(input())
x=input()
num=int(x,2)
cnt=popcount(num)

A=[]
for i in range(n):
    number=num
    if x[i]=="1" and cnt==1:A.append(-1)
    elif x[i]=="1":
        number %=cnt-1
        A.append((number-pow(2,n-i-1,cnt-1))%(cnt-1))
    else:
        number %=cnt+1
        A.append((number+pow(2,n-i-1,cnt+1))%(cnt+1))

for i in A:
    ans=i
    if ans==-1:print(0)
    else:
        point=1
        while ans!=0:
            ans %=popcount(ans)
            point +=1
        print(point)

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

int main() {
  vector<int> v(3);
  cin >> v[0] >> v[1] >> v[2];
  if(v[0] == v[1] && v[1] == v[2] && v[2] == v[0]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3592
import sys
from collections import deque
import copy
def main():
    N, M = map(int, input().split())
    H = [int(i) for i in input().split()]
    dp = [[] for i in range(N)]
    color = [0 for i in range(N)]
    for i in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        dp[a].append(b)
        dp[b].append(a)
    count = 0 
    for i in range(N):
        if color[i] == 1:
            continue
        flag = True
        for j in range(len(dp[i])):
            if H[i] <= H[dp[i][j]]:
                flag = False
                break
            else:
                color[dp[i][j]] = 1
        if flag:
            count += 1
    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 94068
#include <iostream>

int a, b;
int f;

int main(){
    std::cin >> a >> b;
    if(a == b)f = -1;
    else if(a == 1)f = 0;
    else if(b == 1)f = 1;
    else if(a > b)f = 0;
    else if(b > a)f = 1;

    if(f == 0)std::cout << "Alice" << std::endl;
    if(f == 1)std::cout << "Bob" << std::endl;
    if(f == -1)std::cout << "Draw" << std::endl;
    
    
    return 0;
}

Measured memory_bytes: 256
def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    total_T_in_A = [0] * (N+1)
    # total_T_in_B = [0] * M
    # total_T_in_B[0] = B[0]
    total_T_in_B = [0] * (M+1)

    for i in range(1, N+1):
        total_T_in_A[i] = total_T_in_A[i-1] + A[i-1]

    for i in range(1, M+1):
        # total_T_in_B[i] = total_T_in_B[i-1] + B[i]
        total_T_in_B[i] = total_T_in_B[i-1] + B[i-1]

    result = 0
    for i in range(N+1):
        # A から i 冊読むときにかかる時間
        i_A_T = total_T_in_A[i]
        
        if K < i_A_T:
            continue

        if K == i_A_T:
            result = max(result, i)
            continue

        rem_T = K - i_A_T

        # total_T_in_B は累積和を格納した、ソート済の配列
        # B_i <= rem_T < B_i+1 となるような B_i を二分探索によって探す
        first = total_T_in_B[1]
        last = total_T_in_B[M]
        if rem_T < first:
            result = max(result, i)
            continue
        if last <= rem_T:
            result = max(result, i + M)
            continue

        # assume that first <= rem_T <= last
        first_i = 1
        last_i = M
        while first_i < last_i:
            if abs(last_i - first_i) <= 1:
                break
            mid_i = (first_i + last_i) // 2
            if rem_T < total_T_in_B[mid_i]:
                last_i = mid_i
            else:
                first_i = mid_i
        result = max(result, i + first_i)

    print(result)

main()


Measured memory_bytes: 117864
import java.util.*;

public class Main {
  
    public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		
		String[] inputArray = line.split(" ");
		
		double timeAtB = Double.valueOf(inputArray[0]);
		double rateAtB = Double.valueOf(inputArray[1]);
		
		System.out.println(Double.toString(timeAtB / rateAtB));
    
    }
}

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

int main() {
	int n,m,x,y,i;
	cin>>n>>m;
	vector <pair <pair <int,int>,int > > v,v1;
	int a[n+1],co[n+1];
	memset(a,0,sizeof(a));
	memset(co,0,sizeof(co));
	for(i=0;i<m;i++)
	  {
	  	 cin>>x>>y;
	  	 v.push_back({{x,y},i});
	  	 ++a[x];
	  }
	sort(v.begin(),v.end());
	vector <string > vs;
	vs.resize(m);
	for(i=0;i<m;i++)
	  {  string s,s2,sx;
	  	  s=to_string(v[i].first.first);
	  	  s2=to_string(co[v[i].first.first]+1);
	  	  co[v[i].first.first]++;
	  	  for(int j=0;j<6-s.size();j++)
	  	     sx+='0';
	  	    sx+=s;
	  	  for(int j=0;j<6-s2.size();j++)
	  	     sx+='0';
	  	   sx+=s2;
	  	  vs[v[i].second]=sx; 
	  }
	for(i=0;i<m;i++)
	  cout<<vs[i]<<'\n';
	return 0;
}

Measured memory_bytes: 9716
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    string S;
    cin >> S;
    long long cnt = 0;
    long long ans = 0;
    for(int i=S.size()-1; i>=0; i--){
        if(S[i] == 'B') ans += cnt;
        else cnt++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
    switch (str) {
      case "A" :
        System.out.println("T");
        break;
      case "T" :
        System.out.println("A");
        break;
      case "G" :
        System.out.println("C");
        break;
      case "C" :
        System.out.println("G");
        break;
    }
  }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s, t;
  cin >> s >> t;
  int count = 0;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) != t.at(i)) count++;
  }
  
  cout << count << endl;
  
    
}

Measured memory_bytes: 3920
#include<stdio.h>

int main()
{

  int a, b;
  //窓とカーテンサイズの入力
  
  scanf("%d %d", &a, &b);
  
  if (a >= 2*b)
  {
    printf("%d", a-2*b);
  } else {
  	printf("%d", 0);
  }
  
  return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    ll T = 1900;
    ll t = 100;
    ll N,M;
    cin >> N >> M;
    ll out = (T*M+t*(N-M))*pow(2,M);
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

abcd = input()

a, b, c ,d = int(abcd[0]), int(abcd[1]), int(abcd[2]), int(abcd[3])

if (a + b + c + d == 7):
    print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif (a + b + c - d == 7):
    print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif (a + b - c + d == 7):
    print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif (a - b + c + d == 7):
    print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif (a - b - c + d == 7):
    print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif (a - b + c - d == 7):
    print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif (a + b - c - d == 7):
    print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d) + "=7")
elif (a - b - c - d == 7):
    print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d) + "=7")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<ll, ll>;

P sub(ll h, ll w){
    if(h % 2 == 0 || w % 2 == 0) return P(h*w/2, h*w/2);
    if(h > w) swap(h, w);
    ll l = (w + 1) / 2;
    return P(h * l, h * (w - l));
}

int main(){
    ll H, W;
    cin >> H >> W;
    ll ans = H * W;
    for(ll h = 1; h <= H - 1; ++h){
        vector<ll> a(3);
        a[0] = h * W;
        auto p = sub(H - h, W);
        a[1] = p.first; a[2] = p.second;
        sort(ALL(a));
        ans = min(ans, a[2] - a[0]);
    }
    for(ll w = 1; w <= W - 1; ++w){
        vector<ll> a(3);
        a[0] = w * H;
        auto p = sub(W - w, H);
        a[1] = p.first; a[2] = p.second;
        sort(ALL(a));
        ans = min(ans, a[2] - a[0]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// SPDX-License-Identifier: X11
// 2020-08-31
// Red Scarf (500pt)

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

#define ul32 uint_least32_t

int main() {
  ul32 N;
  scanf("%u\n", &N);
  ul32 *A = (ul32 *) calloc(N, sizeof(ul32));
  for (ul32 i = 0; i < N; i++)
    scanf("%u", &A[i]);

  ul32 all = A[0];
  for (ul32 i = 1; i < N; i++)
    all ^= A[i];

  for (ul32 i = 0; i < N - 1; i++)
    printf("%u ", A[i] ^ all);
  printf("%u\n", A[N - 1] ^ all);

  free(A);
}


Measured memory_bytes: 3200
#! usr/bin/perl

use strict;
use warnings;

chomp(my$N = <STDIN>);
my $result = 101;

sub digit {
    my $n = shift;
    my @digit = split //,$n;
    my $digit = @digit;
}

sub max {
    my ($a,$b) = @_;
    $a > $b ? $a : $b;
}

foreach my $a (1..sqrt($N)) {
    if ($N % $a == 0) {
        my $max_digit = &max(&digit($a),&digit($N/$a));
        if ($max_digit < $result) {
            $result = $max_digit;
        }
    }
}
print "$result\n";



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

multiset <int> st, dr;

long long ans, act;
int pozact;

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

    vector <pair <int, int>> v(n);

    for (auto & i : v)
        cin >> i.first >> i.second;

    for (int d(0); d <= 1; d++) {
        st.clear();
        dr.clear();

        pozact = 0, act = 0;
        for (auto i : v) {
            st.insert(i.second);
            dr.insert(i.first);
        }

        int dir = d;
        while (1) {
            if (dir == 0) { /// stanga
                if (st.empty() || *st.begin() > pozact) {
                    act += abs(pozact);
                    break;
                }
                int a = *st.begin();
                st.erase(st.begin());
                act += abs(pozact - a);
                pozact = a;
            }
            else {
                if (dr.empty() || *dr.rbegin() < pozact) {
                    act += abs(pozact);
                    break;
                }
                int a = *dr.rbegin();
                dr.erase(dr.find(a));
                act += abs(pozact - a);
                pozact = a;
            }
            dir = 1 - dir;
        }

        ans = max(ans, act);
    }

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


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

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

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

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

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

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

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

// ---- ----

// G13E_5.cpp

const LL MOD = 1000000007;

void mat_prod(LL a[3][3], LL b[3][3], LL c[3][3], LL MOD = MOD) { // a = b * c;
	LL d[3][3];
	inc(i, 3) {
	inc(j, 3) {
		d[i][j] = 0;
	}
	}
	
	inc(i, 3) {
	inc(j, 3) {
	inc(k, 3) {
		(d[i][j] += b[i][k] * c[k][j]) %= MOD;
	}
	}
	}
	
	inc(i, 3) {
	inc(j, 3) {
		a[i][j] = d[i][j];
	}
	}
	
	return;
}

void mat_exp(LL a[3][3], LL b[3][3], LL c, LL MOD = MOD) { // a = b ^ c;
	LL t[60][3][3];
	if(true) {
		inc(i, 3) {
		inc(j, 3) {
			t[0][i][j] = b[i][j];
		}
		}
		inc(i, 60 - 1) {
			mat_prod(t[i + 1], t[i], t[i], MOD);
		}
	}
	
	inc(i, 3) {
	inc(j, 3) {
		a[i][j] = 0;
	}
	}
	inc(i, 3) { a[i][i] = 1; }
	inc(i, 60) {
		if((c >> i) & 1) {
			mat_prod(a, a, t[i], MOD);
		}
	}
	
	return;
}



LL n, m, x[100002];

int main() {
	cin >> n >> m;
	inc1(i, m) { cin >> x[i]; }
	x[0] = 0;
	x[m + 1] = n + 1;
	
	LL a[3][3] = { { 2, 1, 1 }, { 2, 1, 0 }, { 1, 1, 1 } };
	LL b[3][3] = { { 1, 0, 0 }, { 2, 1, 0 }, { 1, 1, 1 } };
	LL c[3][3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
	LL d[3][3];
	
	inc(i, m + 1) {
		if(i != 0) { mat_prod(c, b, c, MOD); }
		mat_exp(d, a, x[i + 1] - x[i] - 1, MOD);
		mat_prod(c, d, c, MOD);
	}
	
	cout << c[2][0] << endl;
	
	return 0;
}


Measured memory_bytes: 1024