akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<=b&&b<=c)printf("%d\n",a+b);
    else if(a<=b&&c<=b)printf("%d\n",a+c);
    else if(b<=a&&a<=c)printf("%d\n",a+b);
    else if(b<=a&&c<=a)printf("%d\n",b+c);
    else if(c<=a&&a<=b)printf("%d\n",a+c);
    else printf("%d\n",b+c);
}

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

using ll = long long;
void solve(long long N){
    ll ret = numeric_limits<ll>::max();
    for(ll i=1; i*i<=N; ++i){
        if(N%i==0){
            ll tmp = N/i + i - 2;
            if(tmp<ret) ret = tmp;
        }
    }
    cout << ret << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int n,h[100005],dp[100005];
main(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>h[i];
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    for(int i=3;i<=n;i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n]<<endl;
}

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

long nC2(int n) {
    long ans = 1;
    for (int i = n; i > n - 2; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < 2 + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

int main() {
  int N,M;
  int ans;

  cin >> N >> M;

  ans = nC2(N) + nC2(M);

  cout << ans << endl;

  return 0;
}


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

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

int N;
int A[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i];
	sort(A,A+N);
	ll ret=0;
	multiset<int> M;
	FOR(i,N) {
		x=A[N-1-i];
		if(i==0) M.insert(x);
		else {
			ret+=*M.rbegin();
			y=*M.rbegin();
			M.erase(M.find(y));
			M.insert(x);
			M.insert(x);
		}
	}
	cout<<ret<<endl;
}


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


Measured memory_bytes: 13788
H, W, K = map(int, input().split())
c = [list(input()) for _ in range(H)]
ans = 0
for i in range(1 << H):
    for j in range(1 << W):
        cnt = 0
        for x in range(H):
            for y in range(W):
                if (i>>x)&1==1 and (j>>y)&1 and c[x][y] == '#':
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)



Measured memory_bytes: 9180
#include <iostream>
#include <string>
using namespace std;
int main(void){
  int a;
  int b;
  cin >> a >> b;
  
  for(int n = 0; n <= 20; n++){
    int c = (a-1)*(n-1) + a;
    if(c >= b){
      cout << n;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define all(v)           ((v).begin()), ((v).end())
#define sz size()
#define clr(v,d)         memset(v,d,sizeof(v))
#define rep(i, v)        for(int i=0;i<(v).sz;++i)
#define lp(i, n)         for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)     for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)     for(int i=(j);i>=(int)(n);--i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define sci(a)	scanf("%d",&a)
#define scii(a, b)	scanf("%d%d",&a, &b)
#define pri(a)	printf("%d\n",a)
#define prii(a, b)	printf("%d %d\n",a, b)
#define DB1(a)          std::cout<<#a<<"="<<(a)<<endl
#define DB2(a,b)        std::cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<endl
#define DB3(a,b,c)      std::cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<endl
#define DB4(a,b,c,d)    std::cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<endl
#define DB5(a,b,c,d,e)  std::cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<endl
typedef pair<int, int> pii;
typedef long long ll;
const ll  inf = 1000000000000000000LL;
const double EPS = 1e-9;
const ll mod = 1000000007ll;
#define PI acos(-1)

const int maxn = 300500;




int main(){
	//freopen("uva.txt", "r", stdin);
	string s; cin >> s;
	cout << count(s.begin(), s.end(), '1');
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main (){
  int N, M;
  cin >> N >> M;
  unsigned long long A[N];
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    A[i] /= 2;
  }

  unsigned long long t = 1;
  for (int i = 0; i < N; ++i) {
    unsigned long long a = A[i];
    unsigned long long x = a * t;
    unsigned long long r = a % t;
    while(r != 0){
      a = t;
      t = r;
      r = a % t;
    }
    t = x / t;
    if (t > M) {
      cout << 0 << endl;
      return 0;
    }
  }
  for (int i = 0; i < N; ++i) {
    if ((t / A[i]) % 2 == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  unsigned long long ans = M / t;
  cout << (ans + 1) / 2 << endl;

  return 0;
}


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

int
main(void)
{
        int A;
        int B;

        scanf("%d %d\n", &A, &B);

        if (A <= 5)
                B = 0;
        else if (A <= 12)
                B /= 2;

        printf("%d", B);

        return 0;
}


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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

int main()
{
    int a, b;
    cin >> a >> b;

    for(int i = 1; i <= 2000; i++)
    {
        if((int)(i * 0.08) == a && (int)(i * 0.1) == b)
        {
            cout << i;
            return 0;
        }
    }
    cout << "-1";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
int main() {
    int K = 0;
    vector<int> in(5, 0);
    for (int i = 0; i < 5; i++) cin >> in[i];
    cin >> K;
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 5; j++) {
            if (max(in[i], in[j]) - min(in[i], in[j]) > K && i != j) {
                printf("%s\n", ":(");
                return 0;
            }
        }
    }
    printf("%s\n", "Yay!");
    return 0;
}

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

#ifdef _DEBUG
    #include "/home/v-o_o-v/deb.h"
    #define deb(x...)cerr << "[" << #x << "] = [";_print(x);
#else
    #define deb(x...)
#endif

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
   
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++)cin >> a[i];
    sort(a, a + n);
    reverse(a, a + n);
    int ans = 0;
    for(int i = 0; i < k; i++)ans += a[i];
    cout << ans << '\n';
    return 0;
}
// Write Here


Measured memory_bytes: 3632
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int main() {
    //4
    //0 1 2 3
    //2 3 4 4
    int N;
    cin >> N;
    vector<int>X(N), Y(N);
    for (int i = 0; i < N; i++) {
        cin >> X[i];
        Y[i] = X[i];
    }
    sort(X.begin(), X.end());
    for (int i = 0; i < N; i++) {
        if (Y[i] <= X[N / 2 - 1])cout << X[N / 2] << endl;
        else cout << X[N / 2 - 1] << endl;
    }

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  for(int i = 0; i < n; ++i) cin >> l.at(i);
  
  sort(l.begin(), l.end());
  long long ans = 0;
  for(int i = 0; i < n; ++i){
    for(int j = i+1; j < n; ++j){
      int ab = l.at(i) + l.at(j);
      for(int k = j+1; k < n; ++k){
        int c = l.at(k);
        if(ab > c) ans++;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Foldable
import           Data.Maybe
import qualified Data.Sequence         as Seq

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  [n, l] <- getIntList
  t <- replicateM n BS.getLine
  let s = Seq.unstableSort $ Seq.fromList t
      ans = BS.concat $ toList s
  BS.putStrLn ans

Measured memory_bytes: 636
N = int(input())
M = 0
r = 0
if N>1000000:
    M = N


for i in range(min(N,1000000)):
    m = i + 1
    j = int(N/(m))
    r = r + int(m*j*(1+j)/2)

if M!=0:
    for i in range(10):
        k = int(M/(i+1))
        if k > 1000000:
            r = r + (i+1)*int((k-1000000)*(k+1000001)/2)

print(r) 

Measured memory_bytes: 9132
#include <stdio.h>
#define MAX 100

int main()
{
  int i,j,n,k,u,v,M[MAX][MAX]={};

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

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

  return 0;
}

Measured memory_bytes: 652
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll pre[200005];
int a[200005];


int main() {
int n,i,c,k;
    scanf("%d%d%d",&n,&c,&k);
   int ans = 0;
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    int pr = 0;
    int co = 0;
    for(i=0;i<n;i++)
        {
        if(a[i] <= a[pr] + k)
            {
            co++;
            if(co==c)
                {
                ans++;
                co = 0;
                pr = i+1;
            }
        }
        else {
            ans++;
            co = 1;
            pr = i;
        }
    }
    if(co)ans++;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void) {

    int n;
    cin>>n;
    vector<pair<ll,ll>> v(n);
    rep(i,n){
        ll x,l;
        cin>>x>>l;
        v[i]=mp(l+x,x);
    }
    Sort(v);
    ll max=-INF-100000LL;
    int rem=0;

    // rep(i,n)cout<<v[i].first<<endl;

    rep(i,n){
        // cout<<v[i].first<<" "<<2*v[i].second<<" "<<max<<endl;
        if(2*v[i].second-v[i].first>=max){
            max=v[i].first;
        } else {
            rem++;
        }
    }
    fin(n-rem);


}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define pi acos(-1)
using namespace std;
int main ()
{
  string s;
  int k;
  cin>>k>>s;
  if(s.length()<=k)
    cout<<s;
 else
 {
     for(int  i=0;i<k;i++)
        cout<<s[i];
     cout<<"...";
 }
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n, r;
	cin >> n >> r;
	if (n < 10) {
		cout << r + 100 * (10 - n) << endl;
	} else {
		cout << r << endl;
	}
}

Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define sz(x) int(x.size())

typedef long long ll;

using namespace std;

int n;

int main(int argc, const char * argv[]) {
    // input from txt
    
    /////////
    //write//
    /////////
    
    cin >> n;
    ll res = 0;
    for(int i=1; i<n; i++){
        res+=i;
    }
    
    if(n == 1)cout << "0" << endl;
    else cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N, K;
	std::string S;
	in >> N >> K >> S;

	std::vector<std::pair<LL, LL>>stand;
	rep(i, S.length())
	{
		if (S[i] == '0')
		{
			LL start = i;
			LL last = 0;
			for (int j = i; j < S.length(); ++j)
			{
				if (S[j] == '1')
				{
					i = j - 1;
					last = j - 1;
					break;
				}
				if (j == (LL)S.length() - 1)
				{
					i = j;
					last = j;
					break;
				}
			}
			stand.push_back(std::make_pair(start, last));
		}
	}
	std::sort(stand.begin(), stand.end());

	LL ans = 0;
	if (stand.size() == 0) ans = N;
	rep(i, stand.size())
	{
		LL nextI = std::min((LL)stand.size() - 1, i + K - 1);
		LL before = (i == 0 ? stand[i].first : stand[i].first - stand[i - 1].second - 1);
		LL after = (nextI == stand.size() - 1 ? N - stand[nextI].second - 1 : stand[nextI + 1].first - stand[nextI].second - 1);
		LL res = before + after + (stand[nextI].second - stand[i].first + 1);
		ans = std::max(ans, res);
	}
	out << ans << std::endl;
}


Measured memory_bytes: 1528
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std;

const int N=200010;
int n,a[N];
ll ans,sm1[N],sm2[N],sm3[N],mn1[N],mn2[N],mn3[N];

int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i]),ans+=a[i];
	rep(i,1,n) sm1[i]=sm1[i-1]+a[i];
	rep(i,1,n) sm2[i]=sm2[i-1]+((a[i]&1)?1:(a[i]?0:2));
	rep(i,1,n) sm3[i]=sm3[i-1]+(!(a[i]&1));
	rep(i,1,n) mn1[i]=min(mn1[i-1],sm1[i]-sm2[i]);
	rep(i,1,n) mn2[i]=min(mn2[i-1],sm2[i]+mn1[i]-sm3[i]);
	rep(i,1,n) mn3[i]=min(mn3[i-1],sm3[i]+mn2[i]-sm2[i]);
	rep(i,0,n) ans=min(ans,sm2[i]+mn3[i]+sm1[n]-sm1[i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 10368
import collections
import math
def combination(a, b):
    tmp = 1
    for i in range(a - b + 1, a + 1):
        tmp *= i
    return tmp // math.factorial(b)
 
N = int(input())
listA = list(map(int, input().split()))
# 各数字の出現回数をカウント
countA = dict(collections.Counter(listA).most_common())
countA_calc = {k: v * (v -1) // 2 for (k, v) in countA.items()}
countA_calc2 = {k: (v - 1) * (v -2) // 2 for (k, v) in countA.items()}
summery = sum(countA_calc.values())
for i in listA:
    print(summery - countA_calc[i] + countA_calc2[i])

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

int n,m;
int g[110][110], deg[110];
vector<int> V, use;

int rec(int d, int k){
  if(k==0){
    int res = 0;
    for(int a : use){
      int v = 1e9;
      for(int b: use){
	if(a!=b)v = min(v, g[a][b]);
      }
      res += v;
    }
    return res;
  }
  if(d==V.size())return 0;

  int res = rec(d+1,k);
  if(k){
    for(int a : use){
      if(!g[a][V[d]])return res;
    }

    use.push_back(V[d]);
    res = max(res, rec(d+1,k-1));
    use.pop_back();
  }
  return res;
}

int cal(int k){
  V.clear();
  rep(i,n){
    if(deg[i]>=k-1)V.push_back(i);
  }
  return rec(0,k);
}

int main(){
  cin >> n >> m;
  rep(i,m){
    int a,b,c;
    cin >> a >> b >> c; a--; b--;
    g[a][b] = g[b][a] = c;
    deg[a]++; deg[b]++;
  }

  int res = 0;
  for(int k=2;k*(k-1)/2<=m;k++)res = max(res, cal(k));
  cout << res << endl;
}

Measured memory_bytes: 1268
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int n;
	scanf("%d", &n);

	int t[n];
	int x[n];
	int y[n];

	for(int i = 0; i < n; i++) {
		scanf("%d %d %d", &t[i], &x[i], &y[i]);
	}

	for(int i = 0; i < n; i++) {
		if(t[i] % 2 != (abs(x[i]) + abs(y[i])) % 2) {
			printf("No\n");
			return 0;
		} else {
			if(t[i] < (abs(x[i]) + abs(y[i]))) {
				printf("No\n");
				return 0;

			}
		}
	}

	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

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

	int left = 0;
	int right = N - 1;	//０枚目からカウント

	for (int i = 0; i < M; i++)
	{

		left = max(left, (L[i]-1));
		right = min(right, (R[i]-1));
	}

	if((right - left + 1)>=0)	cout << (right - left + 1);
	if ((right - left + 1) < 0)
	{
		int ans = 0;
		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 1024
def bitadd(a,w,bit): #aにwを加える(1-origin)
 
    x = a
    while x <= (len(bit)-1):
        bit[x] += w
        x += x & (-1 * x)
 
def bitsum(a,bit): #ind 1～aまでの和を求める

    if a == 0:
        return 0
 
    ret = 0
    x = a
    while x > 0:
        ret += bit[x]
        x -= x & (-1 * x)
    return ret


alp = "abcdefghijklmnopqrstuvwxyz"

al = {}

for i in range(26):
    al[alp[i]] = i

N = int(input())

BITS = [ [0] * (N+1) for i in range(26) ]

S = list(input())

for i in range(N):

    bitadd(i+1,1,BITS[al[S[i]]])

Q = int(input())
for i in range(Q):

    qs,x,y = input().split()
    qs = int(qs)
    
    if qs == 1:
        x = int(x)
        bitadd(x,-1,BITS[al[S[x-1]]])
        bitadd(x,1,BITS[al[y]])
        S[x-1] = y

    else:
        x = int(x)
        y = int(y)

        ans = 0
        for j in range(26):
            ans += min(1 , bitsum(y,BITS[j]) - bitsum(x-1,BITS[j]))

        print (ans)


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

#define ll long long 
#define sz(x) (int)x.size()

int g[55];

using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		--u,--v;
		g[u]++;
		g[v]++;
	}
	for(int i=0;i<n;i++){
		cout<<g[i]<<'\n';
	}
	
	
}

Measured memory_bytes: 3608
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,a[105],m;
bool ok=1;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        int x;
        scanf("%d",&x);
        m=max(m,x);
        ++a[x];
    }
    if(m&1){
        for(int i=1;i<=m/2;++i)if(a[i])ok=0;
        if(a[m/2+1]!=2)ok=0;
        for(int i=m/2+2;i<=m;++i)if(a[i]<2)ok=0;
    }
    else{
        for(int i=1;i<m/2;++i)if(a[i])ok=0;
        if(a[m/2]!=1)ok=0;
        for(int i=m/2+1;i<=m;++i)if(a[i]<2)ok=0;
    }
    if(ok)puts("Possible");
    else puts("Impossible");
    //system("pause");
    return 0;
}


Measured memory_bytes: 256
from fractions import gcd
n, x = tuple(map(int, input().split(' ')))
d = 0
l = list(map(int, input().split(' ')))
for i in range(n):
  s = l[i]
  if i == 0:
    d = abs(s - x)
  else:
    d = gcd(d, abs(s-x))
print(d)


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

int main(){
  string a, b;
  cin >> a >> b;
  
  string plus = a + b;
  
  int sq = (int)sqrt(stod(plus));
  if(to_string(sq * sq) == plus) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const float pi = 3.1415926535;
unsigned GetDigit(unsigned num){
    return to_string(num).length();
}

int main() {
  int n,ans=0;
  cin >> n;
  vector<int>p(n+1);
  vector<int>l_min(n+1);
  for (int i = 0; i < n; i++) {
    cin >> p.at(i);
  }
  
  l_min.at(0) = p.at(0);

  for (int i = 1; i < n; i++) {
    l_min.at(i) = min(l_min.at(i-1),p.at(i-1));
    if (l_min.at(i) >= p.at(i)) {
      ans++;
    }
  }
  ans++; 
  cout << ans << endl;
}

Measured memory_bytes: 4836
import sys
input = sys.stdin.readline
from collections import *

N, K = map(int, input().split())
A = list(map(int, input().split()))

for i in range(N):
    if A[i]==1:
        mark = i
        break

ans = 10**18

for i in range(N-K+1):
    if i<=mark<=i+K-1:
        ans = min(ans, 1+(i+K-1-1)//(K-1)+(N-i-K+K-1-1)//(K-1))

print(ans)

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

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

int main() {
	int n;
	cin>>n;
	int t[110000],x[110000],y[110000];
	t[0]=x[0]=y[0]=0;
	for(int i=1;i<=n;++i){
		cin>>t[i]>>x[i]>>y[i];
	}
	bool can=true;
	for(int i=0;i<n;i++){
		int dt=t[i+1]-t[i];
		int dist=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
		if(dt<dist) can=false;
		if(dt%2!=dist%2) can=false;
	}
	if(can) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main() {
    int N,M,X,i,A,left,right;
    
    left = 0;
    right =0;
    
    scanf("%d %d %d",&N,&M,&X);
    
    for (i=1;i<M+1;i++) {
        
        scanf("%d",&A);
    
        if (A < X) left++;
        if (X < A) right++;
    
    }
    
    if (left<right) printf("%d\n",left);
    if (right<left) printf("%d\n",right);
    
    
    
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int solve(int,int); //yes->1
int A[2000],M[2000],n;

main(){
  int q,i;

  scanf("%d",&n);
  for(i=0 ; i<n ; i++) scanf("%d",&A[i]);

  scanf("%d",&q);
  for(i=0 ; i<q ; i++) scanf("%d",&M[i]);

  for(i=0 ; i<q ; i++){
    if(solve(0,M[i]) == 1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i,int M){
  if(M-A[i]==0) return 1;
  if(i+1>n) return 0;
  if(solve(i+1,M-A[i]) ||  solve(i+1,M)) return 1;
  return 0;
}

Measured memory_bytes: 584
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

int n, m;

void main() {
    scan(n, m);
    writeln((n - 1) * (m - 1));
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#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)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    string x;
    cin >> x;
    int mod = 0;
    rep(i,n)if(x[i]=='1')mod++;
    ll mod1[n];
    ll modm1[n];
    mod1[n-1]=(1%(mod+1));
    if(mod-1>0)modm1[n-1]=(1%(mod-1));
    for(int i=n-1;i>0;i--){
        mod1[i-1]=(mod1[i]*2)%(mod+1);
        if(mod-1>0)modm1[i-1]=(modm1[i]*2)%(mod-1);
    }
    int f[mod+5];
    f[0]=0;
    rep(i,mod+2){
        int t = (i+1)%__builtin_popcount(i+1);
        f[i+1]=f[t]+1;
    }
    ll sum1 = 0;
    ll summ1 = 0;
    rep(i,n){
        if(x[i]=='1'){
            sum1+=mod1[i];
            sum1 %= mod+1;
        }
    }
    rep(i,n){
        if(x[i]=='1'){
            summ1+=modm1[i];
            if(mod-1>0)summ1 %= mod-1;
        }
    }
    // sum1%=(mod+1);
    // summ1%=(mod-1);
    rep(i,n){
        ll res;
        if(x[i]=='1'){
            if(mod==1){
                cout << 0 << endl;
                continue;
            }
            res = summ1;
            res -= modm1[i];
            if(res<0)res+=(mod-1);
            cout << f[res]+1 << endl;
        }else{
            res = sum1;
            res += mod1[i];
            res %= mod+1;
            cout << f[res]+1 << endl;
        }
    }
}

Measured memory_bytes: 6740
import java.util.*;
import java.io.*;
class Main{
  public static void main(String args[]){
    int a=readI(),b=readI();
    pl(a*b+"");
  }

  static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
  public static String readL(){
    try{
      return br.readLine();
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static String readS(){
    StringBuilder sb = new StringBuilder();
    while(true){
      try{
        int k = br.read();
        if(k==-1||(char)k==' '||(char)k=='\n'){break;}
        sb.append((char)k);
      }catch(IOException e){
        e.printStackTrace();
      }
    }
    return sb.toString();
  }
  public static int readI(){
    return stoi(readS());
  }
  public static long readLong(){
    return Long.parseLong(readS());
  }
  public static String[] readSs(){
    return readL().split(" ");
  }
  public static int[] readIs(){
    return stoi(readSs());
  }
  public static int stoi(String s){
    return Integer.parseInt(s);
  }
  public static int[] stoi(String s[]){
    int a[]=new int[s.length];
    for(int i=0;i<s.length;i++){
      a[i]=stoi(s[i]);
    }
    return a;
  }
  public static String itos(int i){
    return String.valueOf(i);
  }
  public static String[] itos(int[] a){
    String s[]=new String[a.length];
    for(int i=0;i<a.length;i++){
      s[i]=itos(a[i]);
    }
    return s;
  }
  public static String ctos(char c){
    return String.valueOf(c);
  }
  public static String cstos(char[] c){
    return new String(c);
  }
  public static char stoc(String s){
    return s.charAt(0);
  }
  public static char[] stocs(String s){
    return s.toCharArray();
  }
}


Measured memory_bytes: 36384
#include <iostream> 
#include <sstream> 
#include <iomanip> 
#include <algorithm> 
#include <cmath> 
#include <string> 
#include <vector> 
#include <list> 
#include <queue> 
#include <stack> 
#include <set> 
#include <map> 
#include <bitset> 
#include <numeric> 
#include <climits> 
#include <cfloat> 
using namespace std; 

int dy[] = {0, 1, 0, -1};
int dx[] = {1, 0, -1, 0};

class Dice
{
public:
    vector<int> pip; // ì¼kãºÌÚ
    Dice(){
        pip.assign(6, -1);
    }
    void roll(int d){ // ì¼kE¶Éñ]
        int dir[][4] = {{4,2,5,0},{4,3,5,1},{4,0,5,2},{4,1,5,3},{0,3,2,1},{0,1,2,3}};
        int tmp = pip[dir[d][0]];
        for(int i=0; i<3; ++i)
            pip[dir[d][i]] = pip[dir[d][i+1]];
        pip[dir[d][3]] = tmp;
    }
};

vector<vector<int> > mesh;
vector<vector<bool> > check;
Dice dice;
void solve(int y, int x)
{
    dice.pip[5] = mesh[y][x];
    check[y][x] = true;
    for(int i=0; i<4; ++i){
        int y1 = y + dy[i];
        int x1 = x + dx[i];
        if(!check[y1][x1] && mesh[y1][x1] != 0){
            dice.roll(i);
            solve(y1, x1);
            dice.roll((i+2)%4);
        }
    }
}

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

    while(--n >= 0){
        mesh.assign(7, vector<int>(7, 0));
        vector<int> num(6, 0);
        int y1, x1;
        for(int i=1; i<=5; ++i){
            for(int j=1; j<=5; ++j){
                cin >> mesh[i][j];
                if(mesh[i][j] != 0){
                    ++ num[mesh[i][j]-1];
                    if(mesh[i][j] == 1){
                        y1 = i;
                        x1 = j;
                    }
                }
            }
        }

        if(count(num.begin(), num.end(), 1) < 6){
            cout << "false" << endl;
            continue;
        }

        check.assign(7, vector<bool>(7, false));
        dice = Dice();
        solve(y1, x1);
        if(dice.pip[0] + dice.pip[2] == 7 && dice.pip[1] + dice.pip[3] == 7 && dice.pip[4] + dice.pip[5] == 7)
            cout << "true" << endl;
        else
            cout << "false" << endl;
    }

    return 0;
}

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

typedef pair<long long, long long> data_t;

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  vector<int> a(N+1);
  a[0]=0;
  for(int i=0;i<N;i++){
    a[i+1]=a[i];
    if(S[i]=='I')
      a[i+1]++;
    else
      a[i+1]--;
  }
  cout<<*(max_element(a.begin(),a.end()))<<endl;
}


Measured memory_bytes: 256
N,K = map(int,input().split(" "))
x = [x for x in map(int,input().split(" "))]

o = []

for i in range(N-K+1):
    l = x[i]
    r = x[i+K-1]
    if r < 0:
        o.append(-l)
    elif 0 < l:
        o.append(r)
    else:
        o.append(min(-l,r)*2+max(-l,r))

print(min(o))

Measured memory_bytes: 14568
#include<iostream>
#include<queue>
#include<vector>
#include<string>
using namespace std;
int dp[1 << 16], n; vector<pair<int, int>>x;
int col[4][4]; queue<int>Q;
int main() {
	for (int i = 0; i < (1 << 16); i++)dp[i] = 999999999; dp[0] = 0;
	cin >> n; for (int i = 0; i < n; i++) { int a, b; cin >> a >> b; x.push_back(make_pair(a, b)); }
	Q.push(0); for (int i = 0; i < 4; i++) { string V; cin >> V; for (int j = 0; j < 4; j++) { if (V[j] == 'R')col[i][j] = 1; if (V[j] == 'B')col[i][j] = 2; if (V[j] == 'G')col[i][j] = 3; } }
	while (!Q.empty()) {
		int a1 = Q.front(); Q.pop(); int F[4][4];
		for (int i = 0; i < 16; i++) {
			if ((a1 / (1 << i)) % 2 == 1)F[i / 4][i % 4] = col[i / 4][i % 4];
			else F[i / 4][i % 4] = 0;
		}
		for (int i = 0; i < x.size(); i++) {
			for (int j = 1 - (int)x[i].first; j <= 3; j++) {
				for (int k = 1 - (int)x[i].second; k <= 3; k++) {
					for (int o = 1; o < 4; o++) {
						int G = a1;
						for (int l = max(-j, 0); l < min(4 - j, x[i].first); l++) {
							for (int m = max(-k, 0); m < min(4 - k, x[i].second); m++) {
								int cx = j + l, cy = k + m, cl = cx * 4 + cy;
								if (F[cx][cy] >= 1 && col[cx][cy] != o) { G -= (1 << cl); }
								else if (F[cx][cy] == 0 && col[cx][cy] == o) { G += (1 << cl); }
							}
						}
						int bits = G;
						if (dp[bits] > dp[a1] + 1) { dp[bits] = dp[a1] + 1; Q.push(bits); }
					}
				}
			}
		}
	}
	cout << dp[65535] << endl;
	return 0;
}

Measured memory_bytes: 3528
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
#include<map>
#include<set>
using namespace std;

int main() {
	string s;
	cin >> s;
	int b = 0;
	int e = s.length() - 1;
	int x = 0;
	while (b < e) {
		if (s[b] == s[e]) {
			b++;
			e--;
		}
		else {
			if (s[b] == 'x') {
				b++;
				x++;
			}
			else if (s[e] == 'x') {
				e--;
				x++;
			}
			else{
				cout << -1;
				return 0;
			}
		}

	}
	cout << x;
	return 0;
}





Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000

template <typename T>
struct Dinic{
	struct edge{
		int to;
		T weight;
		int ind;
	};
	vector<vector<edge>> E;
	T inf;
	
	Dinic(vector<vector<pair<int,T>>> &e,T iv = 1000000001){
		inf = iv;
		E.resize(e.size(),vector<edge>());
		for(int i=0;i<e.size();i++){
			for(int j=0;j<e[i].size();j++){
				edge t = {e[i][j].first,e[i][j].second,0};
				E[i].push_back(t);
			}
		}
		for(int i=0;i<e.size();i++){
			for(int j=0;j<e[i].size();j++){
				E[i][j].ind = E[E[i][j].to].size();
				edge t = {i,0,j};
				E[E[i][j].to].push_back(t);
			}
		}
	}
	
	T maximum_flow(int s,int t){
		
		int ret = 0;
		
		while(true){
			vector<int> dis(E.size(),-1);
			queue<int> Q;
			Q.push(s);
			dis[s] = 0;
			while(Q.size()!=0){
				int u = Q.front();
				Q.pop();
				for(int i=0;i<E[u].size();i++){
					if(E[u][i].weight<=0)continue;
					int v = E[u][i].to;
					if(dis[v]!=-1)continue;
					dis[v] = dis[u]+1;
					Q.push(v);
				}
			}
			if(dis[t]==-1)break;
			
			vector<int> it(E.size(),0);
			
			while(true){
				T F = dfs(s,t,inf,it,dis);
				if(F==0)break;
				ret+=F;
			}
		}
		return ret;
	}
	
	T dfs(int now,int t,T f,vector<int> &it,vector<int> &dis){
		if(now==t)return f;
		
		for(int &i=it[now];i<E[now].size();i++){
			int to = E[now][i].to;
			int weight = E[now][i].weight;
			if(weight<=0||dis[now]+1!=dis[to]){
				continue;
			}
			T F = dfs(to,t,min(f,weight),it,dis);
			if(F!=0){
				E[now][i].weight-=F;
				E[E[now][i].to][E[now][i].ind].weight+=F;
				return F;
			}
		}
		return 0;
	}
	
};

int main(){

	int H,W;
	cin>>H>>W;
    
	int sy,sx,ty,tx;
	vector<vector<pair<int,int>>> E(H+W+2,vector<pair<int,int>>());
	
	vector<string> S(H);
	for(int i=0;i<H;i++)cin>>S[i];
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(S[i][j]=='S')sy=i,sx=j;
			if(S[i][j]=='T')ty=i,tx=j;
			if(S[i][j]=='o'){
				E[i].emplace_back(H+j,1);
				E[H+j].emplace_back(i,1);
			}
		}
	}
	
	E[H+W].emplace_back(sy,300);
	E[H+W].emplace_back(H+sx,300);
	E[ty].emplace_back(H+W+1,300);
	E[H+tx].emplace_back(H+W+1,300);
	
	Dinic<int> D(E);
	int ans = D.maximum_flow(H+W,H+W+1);
	if(ans>=300)cout<<-1<<endl;
	else cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i > 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  
  REP(i, H){
    REP(j, W){
      int c = ((i < B && j < A) || (i >= B && j >= A)) ? 0 : 1;
      cout << c;
    }
    cout << endl;
  };
};


Measured memory_bytes: 1280
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if (a + b >= c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();

	}

}


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

template <typename T>
struct Heap {
	Heap *l, *r;
	T val;
	Heap() {}
	Heap(int v) : l(nullptr), r(nullptr), val(v) {}
};

template <typename T>
Heap<T>* meld(Heap<T>* a, Heap<T>* b) {
	if (a == nullptr) return b;
	if (b == nullptr) return a;
	if (a->val < b->val) swap(a, b);
	a->r = meld(a->r, b);
	swap(a->l, a->r);
	return a;
}

template <typename T>
Heap<T>* pop(Heap<T>* a) {
	return meld(a->l, a->r);
}

Heap<int> pool[2000000];
int it;

int main()
{
	cin.sync_with_stdio(false);
	string S;
	int val;
	Heap<int>* pq = nullptr;
	while (cin >> S, S != "end") {
		if (S == "extract") {
			printf("%d\n", pq->val);
			pq = pop(pq);
		}
		else {
			cin >> val;
			pool[it] = Heap<int>(val);
			pq = meld(pq, &pool[it++]);
		}
	}
	return 0;
}

Measured memory_bytes: 38368
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a[3], k;
    for (int i = 0; i < 3; ++i)
        scanf("%lld", &a[i]);
    scanf("%lld", &k);
    sort(a, a + 3);
    long long sum = a[2];
    while(k--){
        sum *= 2;
    }
    printf("%lld\n", a[0] + a[1] + sum);
    return 0;
}


Measured memory_bytes: 256
N = map(int,input())
D = map(int,input().split())
M = map(int,input())
T = map(int,input().split())

D_dict = {}
for d in D:
    if d not in D_dict:
        D_dict[d] = 0
    D_dict[d]+=1
flag = True
for t in T:
    if t not in D_dict:
        flag = False
        break
    D_dict[t]-=1
    if D_dict[t] < 0:
        flag = False
        break
if flag:
    print("YES")
else:
    print("NO")

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

int main(){
    int n;
    cin >> n;
    int mn = 2000000000;
    int maxprice = -2000000000;
    for(int i = 0; i < n; i++){
        int price;
        cin >> price;
        if(i > 0 && maxprice < (price - mn)){
            maxprice = price - mn;
        }
        if(price < mn) {
            mn = price;
        }
    }

    cout << maxprice << endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
int main() {
    int n, h[30], max=0, cnt=0;
    cin >> n;
    rep(i, n){
        cin >> h[i];
    }
    rep(i, n){
        if (h[i] >= max) cnt++, max = h[i];
    }
    cout << cnt;
}

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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;



signed main() {
    rep(i,0,9)rep(j,0,9){
        cout<<i+1<<'x'<<j+1<<'='<<(i+1)*(j+1)<<endl;
    }



    return 0;
}



Measured memory_bytes: 3084
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


struct Node_tag{
    int key;
    struct Node_tag *prev;
    struct Node_tag *next;
};

typedef struct Node_tag Node;


void init_sentinel(Node *sentinel){
    sentinel->prev = sentinel;
    sentinel->next = sentinel;
}

void print_list(Node *sentinel){
    Node* cur;
    int cnt = 0;
    cur = sentinel->next;
    while(cur != sentinel){
        if(cnt > 0){
            putchar(' ');
        }
        cnt++;
        printf("%d", cur->key);
        cur = cur->next;
    }
    putchar('\n');
}

void insert(Node *sentinel, int key){
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->prev = sentinel;
    x->next = sentinel->next;
    (sentinel->next)->prev = x;
    sentinel->next = x;  
}

void delete_node(Node *sentinel, Node *x){
    if(x == sentinel){
        return;
    }
    (x->prev)->next = x->next;
    (x->next)->prev = x->prev;
    free(x);
}

Node* search_by_key(Node *sentinel, int key){
    Node *cur;
    cur = sentinel->next;
    while (cur != sentinel){
        if(cur->key == key){
            break;
        }
        cur = cur->next;
    }
    return cur;
}

void delete_by_key(Node *sentinel, int key){
    delete_node(sentinel, search_by_key(sentinel, key));
}

int main(void){
    int n, i;
    int key;
    char com[20];
    Node *sentinel = (Node *)malloc(sizeof(Node));

    init_sentinel(sentinel);

    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%s %d", com, &key);
        if(com[0] == 'i'){ // command is insert x
            insert(sentinel, key);
        }
        else if(com[0] == 'd'){
            if(strlen(com) > 6 && com[6] == 'F'){ // if command is 'deleteFirst'
                delete_node(sentinel, sentinel->next);
            }
            else if(strlen(com) > 6 && com[6] == 'L'){ // if command is 'deleteLast'
                delete_node(sentinel, sentinel->prev);
            }
            else{ // command is delete x
                delete_by_key(sentinel, key);
            }
        }
    }

    print_list(sentinel);

    return 0;
}



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

int n,d,x,points[10][10],ans=0;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n>>d;
	for(int i=0;i<n;i++){
		for(int j=0;j<d;j++){
			cin>>points[i][j];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			int sum = 0;
			for(int k=0;k<d;k++){
				sum += ((points[i][k] - points[j][k]) * (points[i][k] - points[j][k]));
			}
			int sq;
			sq = sqrt(sum);
			if(sq * sq == sum)
				ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	static final int mod = (int) 1e9 + 7;
	static final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int[] DX8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, DY8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static final String nextLine = "\n";

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		String s = fs.next();
		int a[] = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = s.charAt(i)-'0'-1;
		}
		int parity = 0;//奇数1が一番下に、何回寄与するか
		boolean oneExist = false;
		for(int i=0;i<n;i++) {
			if(a[i]==1) {
				oneExist = true;
				int t = 0;
				if(((n-1)&i)==i)t = 1;//lucasの定理により、n-1Ciが奇数かどうか判定
				parity = (parity + t) % 2;
			}
		}
		if(parity == 1) {
			System.out.println(1);
			return;
		}
		if(oneExist) {
			System.out.println(0);
			return;
		}
		parity = 0;
		for(int i=0;i<n;i++) {
			if(a[i]==2) {
				int t = 0;
				if(((n-1)&i)==i)t=1;
				parity = (parity + t)%2;
			}
		}
		if(parity == 1) {
			System.out.println(2);
			return;
		}
		System.out.println(0);
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 33824
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long

int main() {
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	int n = s.sz;
	int n1 = (n - 1) / 2;
	string h = s;
	reverse(h.begin(), h.end());
	bool ch1 = (h == s);
	h = "";
	for(int i = 0; i < n1; ++i) h += s[i];
	string k = h;
	reverse(k.begin(), k.end());
	bool ch2 = (k == h);
	h = "";
	n1 = (n + 3) / 2;
	for(int i = n1 - 1; i < n; ++i) h += s[i];
	k = h;
	reverse(k.begin(), k.end());
	if(ch1 && ch2 && k == h)cout << "Yes";
	else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
    int n;
    cout << fixed << setprecision(8);

    while (cin >> n, n) {
        vector<double> S(n);
        double sum = 0, Sum = 0;
        for (auto &s: S) {
            cin >> s;
            sum += s;
            Sum += s * s;
        }
        cout << sqrt(Sum / n - pow(sum / n, 2)) << endl;
    }

    return 0;
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
    int N, M, K;
    cin >> N >> M >> K;

    vector<long long> A(N+1);
    vector<long long> B(M+1);
    vector<long long> AA(N+1);
    vector<long long> BB(M+1);

    A.at(0) = 0;
    B.at(0) = 0;
    AA.at(0) = 0;
    BB.at(0) = 0;

    int Alimit = N;

    for(int i = 1; i <= N; i++){
        cin >> A.at(i);
        AA.at(i) = AA.at(i-1) + A.at(i);
        if(AA.at(i-1) <= K && AA.at(i) > K){
            Alimit = i-1;
        }
    }

    for(int i = 1; i <= M; i++){
        cin >> B.at(i);
        BB.at(i) = BB.at(i-1) + B.at(i);
    }

    int total;
    total = Alimit;

    for(int i = Alimit; i >= 0; i--){

        if(total >= (i+M)){
            break;
        }

        if(AA.at(i) + BB.at(total - i + 1) <= K){ // totalよりも1冊多く本を読める
            for(int j = total - i + 1; j <= M; j++){
                if(AA.at(i) + BB.at(j) > K){
                    break;
                }
                total++;
                if(j == M){
                    cout << total << endl;
                    return 0;
                }
            }

        }

    }

    cout << total << endl;

}

Measured memory_bytes: 9572
<?php
$str = trim(fgets(STDIN));
$str2 = trim(fgets(STDIN));
$array = explode(' ', $str);
$array2 = explode(' ', $str2);

$N = (int)$array[0];
$T = (int)$array[1];

$total = $T;
for($i = 0; $i < $N - 1; $i++){
    $total += min($array2[$i+1] - $array2[$i], $T);
}
echo $total;


Measured memory_bytes: 23028
#include <stdio.h>

int main(void){
    int A,B,C,X,Y,Z,tmp;
    
    scanf("%d",&X);
    scanf("%d",&Y);
    scanf("%d",&Z);
    
    A=X; B=Y; C=Z;
    
    tmp=A;
    A=B;
    B=tmp;
    
    tmp=A;
    A=C;
    C=tmp;
    
    printf("%d %d %d\n",A,B,C);
    
    return 0;
}

Measured memory_bytes: 128