akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

int popcount(string n) {
    int res = 0;
    for (auto d : n) {
        if (d == '1') res++;
    }
    return res;
}

int Xmod(string X, int m) {
    int tmp = 0;
    for (auto d : X) {
        tmp = (2 * tmp + d-'0') % m;
    }
    return tmp;
}

int main() {
    int N;
    cin >> N;
    string X;
    cin >> X;
    int X_popcount = popcount(X);
    int Xmodp = Xmod(X, X_popcount+1);
    int Xmodm;
    if (X_popcount > 1) {
        Xmodm = Xmod(X, X_popcount-1);
    }
//    cout << X_popcount << " " << Xmodp << " " << Xmodm << endl;
    
    vector<int> imodp(N), imodm(N);
    imodp[0] = 1 % (X_popcount+1);
    rep(i,1,N) imodp[i] = (2*imodp[i-1]) % (X_popcount+1);
    if (X_popcount > 1) {
        imodm[0] = 1 % (X_popcount-1);
        rep(i,1,N) imodm[i] = (2*imodm[i-1]) % (X_popcount-1);
    }

    rep(i,0,N) {
        if (X[i] == '0') {
            int tmp = (Xmodp + imodp[N-i-1]) % (X_popcount+1);
            int count = 1;
            while (tmp > 0) {
                count++;
                tmp %= __builtin_popcount(tmp);
            }
            cout << count << endl;
        } else {
            if (X_popcount == 1) {
                cout << 0 << endl;
            } else {
                int tmp = (Xmodm - imodm[N-i-1]) % (X_popcount-1);
                if (tmp < 0) tmp += (X_popcount-1);
                int count = 1;
                while (tmp > 0) {
                    count++;
                    tmp %= __builtin_popcount(tmp);
                }
                cout << count << endl;
            }
        }
    }
    
}

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  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(Y.begin(), Y.end());
  int midg = Y[(N + 1) / 2], midl = Y[(N + 1) / 2 - 1];
  for (int i = 0; i < N; i++) {
    if (X[i] < midg)
      cout << midg << '\n';
    else
      cout << midl << '\n';
  }
  return 0;
}


Measured memory_bytes: 3840
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright  : @Huki_Hara
# Created    : 2015-03-11

for _ in range(int(input())):
    l=[0]
    r=[0]
    c=True
    n=map(int, input().split())
    for i in n:
        if l[-1] > i and r[-1] > i:
            c=False
            break
        if l[-1] < i:
            l.append(i)
        else:
            r.append(i)
    print("YES" if c else "NO" )

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

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define INF   (1e9 + 7)

ll A, B;
char op;

int main() {
  scanf("%lld %c %lld", &A, &op, &B);
  if (op == '+') {
    printf("%lld\n", A + B);
  } else if (op == '-') {
    printf("%lld\n", A - B);
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, X, M;
  cin >> N >> X >> M;
  map<long, long> mp;
  vector<long> data;
  long baf = X;
  mp[X];
  data.push_back(X);
  for(long i = 0; i < N - 1; i++){
    baf = (baf * baf) % M;
    if(mp.count(baf) != 0 || baf == 0)break;
    mp[baf];
  	data.push_back(baf);
  }
  long ans = 0;
  long flag = 0, size;
  if(baf == 0){
    for(long i = 0; i < data.size(); i++)ans += data.at(i);
  } else {
    for(long i = 0; i < data.size(); i++){
      if(baf == data.at(i)){
        flag = 1;
        size = data.size() - i;
      }
      if(flag == 0)ans += data.at(i);
      else ans += data.at(i) * ((N - i + size - 1) / size);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6628
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int x, y;
string s;

int main() {
    cin >> s >> x >> y;

    int cnt = 0;
    VVi v(2);
    bool isFirst = true, isHor = true;
    for (auto c: s) {
        if (c == 'F') {
            cnt++;
            continue;
        }
        if (isFirst) {
            x -= cnt;
        } else if (cnt > 0) {
            v[isHor].push_back(cnt);
        }
        isFirst = false;
        isHor = !isHor;
        cnt = 0;
    }
    if (isFirst) {
        x -= cnt;
    } else if (cnt > 0) {
        v[isHor].push_back(cnt);
    }

    int def = 20000, width = 8000;
    V<bool> canReachV(40000, false), canReachH(40000, false);
    canReachV[def] = true;
    canReachH[def] = true;
    for (auto u: v[0]) {
        V<bool> buf(40000, false);
        REP2(i, def-width, def+width+1) {
            if (canReachV[i]) {
                buf[i+u] = true;
                buf[i-u] = true;
            }
        }
        canReachV = buf;
    }
    for (auto u: v[1]) {
        V<bool> buf(40000, false);
        REP2(i, def-width, def+width+1) {
            if (canReachH[i]) {
                buf[i+u] = true;
                buf[i-u] = true;
            }
        }
        canReachH = buf;
    }

    if (canReachV[def+y] && canReachH[def+x]) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;
#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) (((n%m) + m)%m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'



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

	int n;
	cin >> n;

	bool flag = true;

	rep(i, 0, n)
	{
		int x;
		cin >> x;
		if (x & 1)
			continue;

		if (x % 3 == 0)
			continue;
		if (x % 5 == 0)
			continue;
		flag = false;
	}

	if (flag)
		cout << "APPROVED\n";
	else
		cout << "DENIED\n";

	return 0;
}


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

int32_t main() {
	// freopen("in", "r", stdin);
	int n, L;
	cin >> n >> L;
	vector<int> v(n);
	for(int &b : v) cin >> b;
	int id = -1;
	for(int i = 1; i < v.size(); i++) {
		if(v[i - 1] + v[i] >= L) {
			id = i;
		}
	}
	if(id == -1) {
		cout << "Impossible" << endl;
	} else {
		cout << "Possible" << endl;
		for(int i = 1; i < id; i++) {
			cout << i << endl;
		}
		for(int i = n - 1; i >= id; i--) {
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
	int X, Y;
  cin >> X >> Y;
  int flag = 0;
  for(int i = 1; i<= X;i++){
    if(i*2 + (X-i) * 4 == Y){
      flag = 1;
      break;
    }
    else if(i*4 + (X-i) *2 == Y){
      flag = 1;
      break;
    }
  }
  if(flag)cout << "Yes" <<endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf (ll)(1e18)
#define mod 1000000007

int main()
{
    int t=1;
    //cin>>t;

    while( t-- )
    {
        ll x;
        cin>>x;

        for( int i=-120 ; i<=120 ; i++ )
        {
            for( int j=-120 ; j<=120 ; j++ )
            {
                ll ans=pow( i,5 )-pow( j,5 );
                if( ans==x )
                {
                    cout<<i<<" "<<j;
                    return 0;
                }
            }
        }
    }
    return 0;
}












Measured memory_bytes: 3984
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int X = scanner.nextInt();
    if (X == 3 || X == 5 || X == 7) {
      System.out.println("YES");
      return;
    }
    System.out.println("NO");
  }
}


Measured memory_bytes: 22608
#AGC027-A
n,x = map(int,input().split())
a = list(map(int,input().split()))

a.sort()

cnt = 0
flg = True
for i in range(n):
    if a[i] <= x:
        x -= a[i]
        cnt += 1
        
    else:
        flg = False
        break
        
if flg and x != 0:
    cnt -= 1
print(cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair <int, int>
#define iiii pair <int, pii>
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i, x) for(int (i) = 0; (i) < (x); (i)++)
inline int getint() {
  int x = 0, p = 1; char c = getchar();	
  while (c <= 32) c = getchar();
  if (c == 45) p = -p, c = getchar();
  while (c > 32) x = x * 10 + c - 48, c = getchar();
  return x * p;
}
using namespace std;
//ruogu_alter
const int N = 1e5 + 5;
int n, m, a[N], b[N], c[N], id[N], par[N];
ll f[N], s[N];
bool vis[N];
vector<int> g[N];
//
int findset(int x) {
  return par[x] == x ? x : par[x] = findset(par[x]);
}
bool cmp(int x, int y) {
  return a[x] < a[y];
}
int main() {
  n = getint(); m = getint();
  rep(i, n) {
    a[i] = getint(), b[i] = getint();
    a[i] = max(a[i] - b[i], 0);
    par[i] = id[i] = i;
    f[i] = a[i] + b[i]; s[i] = b[i];
  }
  rep(i, m) {
    int x = getint() - 1, y = getint() - 1;
    g[x].emplace_back(y);
    g[y].emplace_back(x);
  }
  sort(id, id + n, cmp);
  rep(ii, n) {
    int x = id[ii]; vis[x] = true;
    rep(i, g[x].size()) {
      int to = findset(g[x][i]);
      if (!vis[to] || to == x) continue;
      f[x] = min(f[x] + s[to], s[x] + max(f[to], 1ll * a[x]));
      s[x] += s[to]; par[to] = x;
    }
  }
  cout << f[findset(0)] << endl;
  return 0;
}


Measured memory_bytes: 9084
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
inf = 10**10
parent = [inf]*n
q = {}
for i in range(n):
    a,b = map(int,input().split())
    if a not in q.keys():
        parent[i] = a
        q[a] = 0
    q[a] += b
parent.sort()
cnt = 0
for p in parent:
    cnt += q[p]
    if cnt >= k:
        print(p)
        break


Measured memory_bytes: 11240
import java.io.*;

public class Main {
  public static void main(String[] args) {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    try {
      int[] alphabet = new int[26];
      String str;
      while((str = reader.readLine()) != null) {
        str = str.toLowerCase();
        byte[] asciiStr = str.getBytes("US-ASCII");
        for (int i = 0; i < asciiStr.length; i++) {
          if (asciiStr[i] >= 97 && asciiStr[i] <= 122) {
            alphabet[asciiStr[i] - 97]++;
          }
        }
      }
      for (int i = 0; i < 26; i++) {
        System.out.printf("%c : %d\n", i + 97, alphabet[i]);
      }
    }
    catch (IOException e) {
      System.out.println(e);
    }
  }
}

Measured memory_bytes: 24712
N, K = map(int, input().split())
A = list(map(int, input().split()))

for _ in range(K):
    B = [0] * N
    for i, d in enumerate(A):
        l = max(0, i-d)
        r = min(N-1, i+d)
        B[l] += 1
        if r+1 < N:
            B[r+1] -= 1
    
    for i in range(1, N):
        B[i] += B[i-1]
    
    A = B.copy()
    if min(A) == N:
        break

print(" ".join(map(str, A)))

Measured memory_bytes: 171880
#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,A,B; cin >> N >> A >> B;
	int x = 0, y = 0, z = 0;
	repp(i,0,N){
		int p; cin >> p;
		if(p <= A) ++x;
		else if(p <= B) ++y;
		else ++z;
	}
	cout << min(x,min(y,z)) << endl;
	return 0;
}


Measured memory_bytes: 256
<?php
$W=trim(fgets(STDIN));
$w=strtolower($W);
$C=0;
while(1){
  $T=trim(fgets(STDIN));
  if($T=='END_OF_TEXT') break;
  foreach(explode(' ',strtolower($T)) as $t) if($t==$w) ++$C;
}
echo $C;
?>

Measured memory_bytes: 15288
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <cstdlib>  // abs() for integer
#include <cmath>
#include <bitset>
#include <iomanip>
using namespace std;

int main (){
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i=0;i<N;i++){
        cin >> H[i];
    }
    vector<int> sabun(N-1);
    for (int i = 0;i<N-1;i++)
        sabun[i] = H[i+1]-H[i];
    int answer = 0;
    int tmp=0;
    for (int i = 0;i<N-1;i++){
        if (sabun[i]>0) tmp=0;
        else tmp++;
        
        if (tmp > answer ) answer = tmp;
        
    }
    cout << answer;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int a, b;
	cin >> a >> b;
	cout << (a-1)*(b-1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
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; }
const ll INF = 1e18;

ll h,w;
ll a[90][90];
ll b[90][90];

bool dp[90][90][14000];

int main(){
    cin >> h >> w;
    rep(i,h)rep(j,w)cin>>a[i][j];
    rep(i,h)rep(j,w)cin>>b[i][j];
    rep(i,h)rep(j,w)rep(k,13000)dp[i][j][k]=false;
    dp[0][0][0]=true;
    rep(i,h){
        rep(j,w){
            rep(k,13000){
                if(dp[i][j][k]){
                    ll x = abs(a[i][j]-b[i][j]);
                    dp[i+1][j][k+x]=true;
                    dp[i+1][j][abs(k-x)]=true;
                    dp[i][j+1][k+x]=true;
                    dp[i][j+1][abs(k-x)]=true;
                }
            }
        }
    }
    ll y = abs(a[h-1][w-1]-b[h-1][w-1]);
    ll ans = INF;
    rep(i,13000){
        if(dp[h-1][w-1][i]){
            chmin(ans,abs(i-y));
            chmin(ans,abs(i+y));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 93296
#include <bits/stdc++.h>
using namespace std;
int m;
vector<int>p;
vector<int>s;
int maxn,minn;


int main(){
  int i,j,now=0,ni=0;
  while(1){
  cin >> m >> minn >> maxn;
  now = 0;
  if(m==0&&maxn==0&&minn==0)break;
  for(i=0;i<m;i++){
    cin >> j;
    p.push_back(j);
  }
  sort(p.begin(),p.end());
  for(i=0;i<m-1;i++)  s.push_back(p[i+1]-p[i]);
  for(i=m-minn-1;i>=m-maxn-1;i--){
    // cout << " bbb"<<s[i];
    if(s[i]>=now){
      now = s[i];
      ni = i;
      //cout <<"aaa"<< now << " "<< ni << endl;
    }
  }
  //cout <<endl<< ni << endl;
  cout << m-1-ni << endl;
  while(p.size())p.pop_back();
  while(s.size())s.pop_back();
  }
  return 0;
}



Measured memory_bytes: 3120
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int[] h = new int[N+1];
	for(int i = 0; i<N; i++) {
	    h[i] = sc.nextInt();
	}
	int[] cost = new int[N];

	cost[0] = 0;
	cost[1] = Math.abs(h[1]-h[0]);

	for(int i = 2; i<N; i++) {
	    int c1 = cost[i-1] + (int)(Math.abs(h[i] - h[i-1]));
	    int c2 = cost[i-2] + (int)(Math.abs(h[i] - h[i-2]));
	    cost[i] = Math.min(c1,c2);
	}
	System.out.println(cost[N-1]);


    }
}

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

void print(int* A, int N) {
	for (int i = 0; i < N; i++) {
		if (i != 0) {
			cout << " ";
		}
		cout << A[i];
	}
	cout << endl;
}

void insertionSort(int* A, int N) {
	int v = 0, j = 0;
	for (int i = 0; i < N; i++) {
		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		print(A, N);
	}
}

int main()
{
	int i, j[100];
	cin >> i;
	int c=0, temp = i;
	while (temp--) {
		cin >> j[c++];
	}
	insertionSort(j, i);
    return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin>>n;
    cin>>s;
    int sum=0,ans=0;
    for (int i=0;i<n;i++){
        if (s[i]=='I'){
            sum++;
            ans=max(ans,sum);
        }
        else{
            sum--;
            ans=max(ans,sum);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;



int main(){
    ll S;
    cin >> S;
    
    if(S==1000000000000000000){
        cout<<"0 0 0 1000000000 1000000000 0"<<endl;
        return 0;
    }
    
    ll x1,y1,x2,y2;
    
    ll x1y2, x2y1;
    
    x1y2 = 1000000000 - S%(1000000000);
    x2y1 = S+x1y2;
    
    x1=1;
    y2=x1y2;
    
    x2 = x2y1/1000000000;
    y1 = 1000000000;
    
    
    cout << "0 0 " << x1 << " " << y1 << " " << x2 << " " << y2 <<endl;
    
    //cout<< "S= " << (2*x2-x1)*y1 - (y1-y2)*(x2-x1) - x2*y2 <<  endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int K;
  int result = -1;
  int k = 7;
  cin >> K;
  vector<int> A(K);
  for(int a = 0;a < K;a++){
   if(k % K == 0){
    result = a + 1;
     break;
   }
    
   
     
     k = k * 10 + 7;
    k %= K;
  }
  cout << result << endl;
}

Measured memory_bytes: 7160
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define int long long
#define double long double
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n;
string command, s;
set<string> st;
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> command >> s;
		if (command == "insert")st.insert(s);
		else if (st.find(s) != st.end())puts("yes");
		else puts("no");
	}
	return 0;
}


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

using namespace std;

int A[3][3];
int n,t;
bool check[3][3];

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

    memset(check,false,sizeof(check));

    for(int i=0;i<3;i++)
    {
    	for(int j=0;j<3;j++)
    	{
    		cin >> A[i][j];
    	}
    }

    cin >> n;

    for(int i=0;i<n;i++)
    {
    	cin >> t;
    	for(int y=0;y<3;y++)
    	{
    		for(int x=0;x<3;x++)
    		{
    			if(A[y][x]==t)
    			{
    				check[y][x] = true;
    			}
    		}
    	}
    }

    bool res = false;

    for(int i=0;i<3;i++)
    {
    	int cnt = 0;
    	for(int j=0;j<3;j++)
    	{
    		if(check[i][j]==true)
    		{
    			cnt++;
    		}
    	}
    	if(cnt==3)
    	{
    		res = true;
    	}
    }

    for(int j=0;j<3;j++)
    {
    	int cnt = 0;
    	for(int i=0;i<3;i++)
    	{
    		if(check[i][j]==true)
    		{
    			cnt++;
    		}
    	}
    	if(cnt==3)
    	{
    		res = true;
    	}
    }

    int cnt = 0;
    for(int i=0;i<3;i++)
    {
    	if(check[i][i]==true)
    	{
    		cnt++;
    	}
    }
    if(cnt==3)
    {
    	res = true;
    }

    cnt = 0;
    for(int i=0;i<3;i++)
    {
    	if(check[i][2-i]==true)
    	{
    		cnt++;
    	}
    }
    if(cnt==3)
    {
    	res = true;
    }

    if(res)
    {
    	cout << "Yes" << '\n';
    }
    else
    {
    	cout << "No" << '\n';
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

template<class T>
inline bool chmax(T& a, const T b) { return a < b && (a = b, true); }

int main() {

	string s;
	cin >> s;

	int ans = 0, cnt = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == 'R') cnt++;
		else cnt = 0;
		chmax(ans, cnt);
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 3640
n, m, k = map(int, input().split())

MOD = 998244353

def mod(n):         
  return n % MOD

def modpow(a, n):   #mod(a**n)を高速で求める
    res = 1  
    digit = len(str(bin(n))) - 2
    for i in range(digit):
      if (n >> i) & 1:
        res *= mod(a)
        res = mod(res)
      a = mod(a**2)
    return mod(res)
  
def inverse(a):     #aの逆元を求める
  return modpow(a, MOD-2)

MAX = 1000000           #適当な数を入力
fac, finv, inv = [[0]*MAX for i in range(3)]
def combinit():     #MAXまでの下準備
  fac[0] = fac[1] = 1
  finv[0] = finv[1] = 1
  inv[1] = 1
  for i in range(2, MAX):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD

def modcomb(n, k):      #mod(nCk)を計算、ただしn<MAX
  if (n < k):
    return 0
  if (n < 0 or k < 0):
    return 0
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
combinit()          #下準備の実行 O(MAX)

ans = 0
for i in range(k+1):
  ans += mod(m*modpow(m-1, n-1-i)*modcomb(n-1, i))
  
print(mod(ans))

Measured memory_bytes: 96236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  int ans = 0;
  bool X[101] = {false};
  for (int i = 0; i < N; i++) {
    cin >> d[i];
    X[d[i]] = true;
  }
  for (int i = 0; i < 101; i++) {
    if (X[i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
int n;
int b[1000];
cin>>n;
for (int i=0;i<n-1;i++)
cin>>b[i];
int c[1000];
c[0]=b[0];
for (int i=1;i<n-1;i++)
{c[i]=min(b[i-1],b[i]);
}
c[n-1]=b[n-2];
int sum=0;
for (int i=0;i<n;i++)
sum+=c[i];
cout <<sum;

}

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


int main(){

  int a,b;

  while(cin >> a >> b){
    int count = 1;
    a += b;
    while(a / 10 != 0){
      a /= 10;
      count++;
    }
    cout << count << endl;
    count = 1;
  }


    return 0;
}

Measured memory_bytes: 3052
import numpy as np

N, W = map(int, input().split())

dp = [float("INF")]*(N*10**3 + 1)
dp = np.array(dp)
dp[0] = 0

for i in range(N):
    w, v = map(int, input().split())
    dp[v:] = np.minimum(dp[:-v] + w, dp[v:])

print(np.max(np.where(dp <= W)))

Measured memory_bytes: 15944
/** omgursocute **/
#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, l;
	cin >> n >> l;

	int sum = 0;
	int smallest = INT_MAX;
	int pos = 0;
	for(int i = 1; i <= n; i++) {
		sum += (l+i-1);
		if(smallest > abs(l+i-1)) {
			smallest = abs(l+i-1);
			pos = i;
		}
	}

	cout << sum - (l+pos-1);

/*
 *
 *	sum - (l+i-1)
 *	|(l+i-1)|
 *
 */


	return 0;
}




Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <bits/stdc++.h>

using namespace std;

class AX {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        int a, b;
        cin >> a >> b;
        cout << max(a + b, max(a - b, a * b)) << endl;
    }
};


int main() {
    AX solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
import sys
N=int(input())
s=[int(input()) for i in range(N)]
num=sum(s)

if num%10!=0:
    print(num)
else:
    for i in range(N):
        s=sorted(s)
        if s[i]%10==0:
            continue
        else:
            print(num-s[i])
            sys.exit()
    print(0)

Measured memory_bytes: 9096
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
int w[1010];
int sum, num, ans = HINF<int>();

int main(){
	cin >> n;
	REP(i, n)cin >> w[i], sum += w[i];
	REP(i, n){
		ans = min(ans, abs(num - (sum - num)));
		num += w[i];
	}
	ans = min(ans, abs(num - (sum - num)));
	cout << ans << endl;
}

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

int main(){
    
    int x = 0;
    int k = 0;
    char s[100] = {};
    int stack[200] = {};
    
    while( scanf("%s", s) != EOF ){
        
        if ( s[0] == '+' ){
            
            x = stack[k-2] + stack[k-1];
            
            stack[k-2] = x;
            
            k = k-1;

        } else if ( s[0] == '-' ){
            
            x = stack[k-2] - stack[k-1];
            
            stack[k-2] = x;
            
            k = k-1;

        } else if ( s[0] == '*' ){
            
            x = stack[k-2] * stack[k-1];
            
            stack[k-2] = x;
            
            k = k-1;

        } else {
            
            stack[k] = atoi(s);
            
            k += 1;

        }
        
        //cout << stack[k-1] << endl;
        
    }
    
    cout << stack[0] << endl;
    
    return 0;
    
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define int long long
using namespace std;
//const int MOD = pow(10, 9) + 7;
const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}

signed main()
{
  int N;
  cin >> N;
  vector<int> W(N);
  for (int i = 0; i < N; i++)
  {
    cin >> W.at(i);
  }

  for (int i = 1; i < N; i++)
  {
    W.at(i) += W.at(i - 1);
  }

  int ans = INF;
  for (int i = 0; i < N; i++)
  {
    int S1 = W.at(i);
    int S2 = W.at(W.size() - 1) - S1;
    chmin(ans, abs(S1 - S2));
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from itertools import combinations as comb
from collections import Counter as C
from collections import defaultdict as dd
sys.setrecursionlimit(10**5)
def y(f):
    if f:
        print('Yes')
    else:
        print('No')
def Y(f):
    if f:
        print('YES')
    else:
        print('NO')

n = int(input())
if n % 2 == 0:
    print(0.5)
else:
    print((n - n // 2) / n)


Measured memory_bytes: 64108
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e6 + 1;

vi get_factor(int n)  
{  
	vi ret;  
	for(int i = 1; i*i <= n; i++){
		if(n%i)
			continue;
		ret.pb(i);
		if(i != n/i)
			ret.pb(n/i);
	}
    return ret;  
}

int solve(){
	int n;
	cin>> n;
	int m[mxn] = {}, cnt[mxn] = {};
	vi v(n);
	rep(i, 0, n){
		cin>> v[i];
		cnt[v[i]]++;
		vi tmp = get_factor(v[i]);
		for(auto fac: tmp)
			m[fac]++;
	}
	int ans = 0;
	rep(i, 0, n){
		vi tmp = get_factor(v[i]);
		cnt[v[i]]--;
		for(auto fac: tmp)
			m[fac]--;
		bool ok = false;
		for(auto fac: tmp)
			if(cnt[fac] > 0)
				ok = true;
		if(!ok)
			ans++;
		cnt[v[i]]++;
	}
	cout<< ans<< "\n";
	return 0;
}
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


Measured memory_bytes: 7928
from collections import Counter

n = int(input())
a = list(map(int,input().split()))

a_count = Counter(a)

ans = 0
for i in a_count:
    if int(i) > a_count[i]:
        ans += a_count[i]
    else:
        ans += a_count[i] - int(i)

print(ans)

Measured memory_bytes: 18676
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int num1;
        int num2;
        int tmp;
        
        while (true) {
        
            num1 = sc.nextInt();
            num2 = sc.nextInt();
            if (num1 > num2) {
                tmp = num1;
                num1 = num2;
                num2 = tmp;
            }
            if (num1 == 0 && num2 == 0){break;}
            System.out.println(num1 + " " + num2);
        }
        
    }
}


Measured memory_bytes: 35928
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int calc(int a) {
	int ret = 0;
	while (a) {
		ret += a % 10;
		a /= 10;
	}
	return ret;
}

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

	int ret = INT_MAX;
	REP(a, 1, N - 1) {
		int b = N - a;
		int tmp = calc(a) + calc(b);
		ret = min(ret, tmp);
	}

	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
use std::io::BufRead;

fn main() {
    let stdin = std::io::stdin();
    let (h, w): (usize, usize) = stdin.lock().gets().split(' ').values();
    let mut map = Vec::new();
    map.push(vec![b'.'; w + 2]);
    for mut line in stdin.lock().lines().take(h).map(|x| x.unwrap().into_bytes()) {
        line.insert(0, b'.');
        line.push(b'.');
        map.push(line);
    }
    map.push(vec![b'.'; w + 2]);
    let mut isolated = false;
    for y in 1..(h + 1) {
        for x in 1..(w + 1) {
            isolated |= map[y][x] == b'#' &&
                map[y][x - 1] == b'.' && map[y][x + 1] == b'.' &&
                map[y - 1][x] == b'.' && map[y + 1][x] == b'.';
        }
    }
    println!("{}", if isolated { "No" } else { "Yes" });
}

trait Gets { fn gets(&mut self) -> String; }
impl<T: std::io::BufRead> Gets for T {
    fn gets(&mut self) -> String { self.lines().next().unwrap().unwrap() } }

trait Values<T> { fn values(&mut self) -> T; }
impl<'a, I, T1, T2> Values<(T1, T2)> for I
    where I: Iterator<Item=&'a str>,
          T1: std::str::FromStr, T1::Err: std::fmt::Debug,
          T2: std::str::FromStr, T2::Err: std::fmt::Debug {
    fn values(&mut self) -> (T1, T2) {
        (self.next().unwrap().parse().unwrap(),
         self.next().unwrap().parse().unwrap())
    }
}


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

int main(){
  int H, W;
  cin >> H >> W;
  
  for (int i = 0; i < H + 2; i++){
    if (i == 0 || i == H + 1){
      for (int j = 0; j < W + 2; j++){
        if (j != W + 1){
          cout << "#";
        }
        else{
          cout << "#" << endl;
        }
      }
    }
    else{
      vector<char> line(W);
      for (int j = 0; j < W; j++){
        cin >> line.at(j);
      }
      cout << "#";
      for (int j = 0; j < W; j++){
        cout << line.at(j);
      }
      cout << "#" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <set>
#include <tuple>
#include <vector>

using namespace std;
using ll = long long;

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

    ll N;
    cin >> N;
    vector<ll> A;
    vector<ll> C;
    ll s = 0;
    for (ll i = 0; i < N; ++i) {
        ll a;
        cin >> a;
        A.push_back(a);
        s += a;
        C.push_back(s);
    }
    ll ans = 999999999999999999;
    ll left = 0;
    ll right = 2;
    for (ll i = 1; i < N - 2; ++i) {
        while (
            left < i &&
            abs(2 * C[left + 1] - C[i]) < abs(2 * C[left] - C[i])
        ) ++left;
        while (
            right < N &&
            abs(2 * C[right + 1] - C[N - 1] - C[i]) < abs(2 * C[right] - C[N - 1] - C[i])
        ) ++right;
        ans = min(
            ans,
            max(C[left], max(C[i] - C[left], max(C[right] - C[i], C[N - 1] - C[right]))) \
            - min(C[left], min(C[i] - C[left], min(C[right] - C[i], C[N - 1] - C[right])))
        );
    }
    cout << ans << endl;
}


Measured memory_bytes: 3564
integer(16) N,M,K
integer(16) waruno
integer(16) ans,tmp,i,j,com
read*,N,M,K
waruno=10**9+7
com=combination(N*M-2,K-2,waruno)
ans=0
do i=0,M-1
  do j=0,N-1
    tmp=mod((i+j)*(M-i)*(N-j)*com*merge(1,2,i*j==0),waruno)
    ans=mod(ans+tmp,waruno)
  end do
end do
print"(i0)",ans

contains

function combination(n,k,l)
implicit none
integer(16),intent(in)::n,k,l
integer(16) combination,i
integer(16),allocatable,dimension(:)::Kaijo
allocate(Kaijo(0:N))
Kaijo(0)=1
do i=1,N
  Kaijo(i)=mod(Kaijo(i-1)*i,l)
end do
  
combination=mod(Kaijo(N)*inv(Kaijo(K),l)*inv(Kaijo(N-K),l),l)

end function combination

function inv(K,L)
integer(16),intent(in)::k,l
integer(16) l2,y
integer(16) inv
inv=1
l2=l-2
y=k
do
  if(mod(l2,2)==1)inv=mod(inv*y,l)
  y=mod(y*y,l)
  l2=l2/2
  if(l2==0)exit
end do
end function inv
end

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

const int MAXN = 3e5+5;
const int INF = 1e9+7;
#define ll long long
#define pb push_back
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

ll MOD(ll a){
    return ((a%INF)+INF)%INF;
}

ll inv(ll a){
    return poww(a,INF-2,INF);
}

ll w[MAXN],val[MAXN],dp[MAXN];

int main()
{
    fast_io;
    //cout << fixed << setprecision(15);

    int n,cap;cin >> n >> cap;
    for(int i=1;i<=n;++i) cin >> w[i] >> val[i];

    for(int i=1;i<=n;++i){
        for(int j=cap;j>=1;--j){
            if(j>=w[i]) dp[j] = max(dp[j],dp[j-w[i]] + val[i]);
            else break;
        }
    }
    cout << dp[cap];
}


Measured memory_bytes: 5120
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>

using namespace std;

int N;
int a[20];
double opt;
int getNum[20];
int sel[20];

const double EPS=(1e-10);
bool EQ(double a,double b){
  return abs(a-b)<EPS;
}

bool check(int *tmparry){
  sort(tmparry,tmparry+3);
  return (tmparry[2]<tmparry[0]+tmparry[1]);
}
void dfs(int pos,int cur){
  if(pos==6){
    for(int i=0;i<6;i++)sel[i]=getNum[i];
    sort(sel,sel+6);
    const int size=3;
    const int plc[]={1,4,5};
    const int plc2[]={0,2,3};
    int comb=(1<<size)-1;
    while(comb<(1<<6)){
      int x=comb&-comb,y=comb+x;
      comb=((comb&~y)/x>>1)|y;
      int cnt=0;
      for(int i=0;i<6;i++){
	if((comb>>i)&1){
	  sel[plc[cnt++]]=getNum[i];
	}
      }
      cnt=0;
      int tmp[3];
      for(int i=0;i<6;i++)
	if(!((comb>>i)&1))
	  tmp[cnt++]=getNum[i];
      sort(tmp,tmp+3);
      // 6!通りの組み合わせをすべて試す
      do{
	for(int i=0;i<3;i++)sel[plc2[i]]=tmp[i];
	int tmparry[3];
	for(int i=0;i<3;i++)tmparry[i]=a[sel[i]];
	if(!check(tmparry))continue;
	tmparry[0]=a[sel[0]];tmparry[1]=a[sel[4]];tmparry[2]=a[sel[3]];
	if(!check(tmparry))continue;
	tmparry[0]=a[sel[2]];tmparry[1]=a[sel[5]];tmparry[2]=a[sel[3]];
	if(!check(tmparry))continue;
	tmparry[0]=a[sel[1]];tmparry[1]=a[sel[5]];tmparry[2]=a[sel[4]];
	if(!check(tmparry))continue;
	double theta=a[sel[1]]*a[sel[1]]+a[sel[4]]*a[sel[4]]-a[sel[5]]*a[sel[5]];
	theta/=(2.0*a[sel[1]]*a[sel[4]]);
	theta=acos(theta);
	double x0=a[sel[4]]*cos(theta);double y0=a[sel[4]]*sin(theta);
	double a0=a[sel[1]];
	double l1=a[sel[2]];double l2=a[sel[0]];double l3=a[sel[3]];
	double x1=(a0*a0+l2*l2-l1*l1)/(2.0*a0);
	double y1=((-2*x0*x1)+x0*x0+y0*y0+l2*l2-l3*l3)/(2.0*y0);
	double h=sqrt(l2*l2-(x1*x1+y1*y1));
	double s=(a[sel[1]]+a[sel[4]]+a[sel[5]])/2.0;
	double S=sqrt(s*(s-a[sel[1]])*(s-a[sel[4]])*(s-a[sel[5]]));
	double V=(S*h)/3.0;
	if(!EQ(opt,V)&&opt<V)
	  opt=V;
      }while(next_permutation(tmp,tmp+3));
    }
  }
  else{
    // cur以降から選ぶ
    for(int i=cur;i<N;i++){
      getNum[pos]=i;
      dfs(pos+1,i+1);
    }
  }
}

int main(){
  while(cin>>N&&N){
    memset(getNum,0,sizeof(getNum));
    opt=-1;
    for(int i=0;i<N;i++)cin>>a[i];
    dfs(0,0);
    printf("%.10f\n",opt);
  }
  return 0;
}

Measured memory_bytes: 940
N, x = map(int, input().split())

if x == 1 or x == 2*N-1:
    print("No")
else:
    print("Yes")
    center = [x-1, x, x+1]
    left = list(range(1, x-1))
    right = list(range(x+2, 2*N))
    others = left + right

    ans = others[N-2:] + center + others[:N-2]
    print(*ans, sep="\n")


Measured memory_bytes: 19256
input_list = input()

str_list = list(input_list)

str_len = len(str_list)

start = ''.join(str_list[0:(str_len - 1) // 2])
end = ''.join((str_list[((str_len + 3) // 2) - 1:]))

if start == end:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    int N, tmp;
    cin >> N;
    vector<P> a;
    REP(i, N){
        cin >> tmp;
        a.push_back(P(tmp, i+1));
    }
    sort(a.begin(), a.end());

    REP(i, N){
        printf("%d ", a[i].second);
    }
    printf("\n");

    return 0;
}


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

#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define v(t) vector<t>
#define vv(t) vector<vector<t>>
#define vn(t,n,val) vector<t>(n,val)
#define vvn(t,r,c,val) vector<vector<t>>(r, vector<t>(c,val))
#define vvv(t) vector<vector<vector<t>>>
#define vvvn(t,l,b,h,val) vector<vector<vector<t>>>(l,vector<vector<t>>(b,vector<t>(h)))

int main() {
	sp;

	////////////////To Remove//////////////
	// freopen("../../input.txt", "r", stdin);
	// freopen("../../output.txt", "w", stdout);
	///////////////////////////////////////

	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes";
	else cout<<"No";

  	return 0;
}

Measured memory_bytes: 256
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#ifdef LOCAL
#include "debug.h"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> 
using ordered_set= tree<T, null_type, 
		less<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

const int mx=5e5+5;

int ara[mx],bit[mx],ans[mx],last[mx];

void update(int indx,int val)
{
	for(;indx<mx;indx+=(indx&-indx)) bit[indx]+=val;
}

int sum(int indx)
{
	int tot=0;
	for(;indx>0;indx-=(indx&-indx)) tot+=bit[indx];
	return tot;
}

int sum(int l,int r)
{
	return sum(r)-sum(l-1);
}

struct query
{
	int l;
	int r;
	int id;
	
	bool operator<(const query &a) const
	{
		return r<a.r;
	}
} ques[mx];

void solve()
{
	int n,q;
	cin>>n>>q;
	
	for(int i=1;i<=n;i++) cin>>ara[i];
	
	for(int i=1;i<=q;i++)
	{
		cin>>ques[i].l>>ques[i].r;
		ques[i].id=i;
	}
	
	sort(ques+1,ques+q+1);
	memset(last,-1,sizeof(last));
	
	int curr=1;
	
	for(int i=1;i<=n;i++)
	{
		if(last[ara[i]]==-1) 
		{
			last[ara[i]]=i;
			update(i,1);
		}
		else
		{
			update(last[ara[i]],-1);
			last[ara[i]]=i;
			update(i,1);
		}
		
		while(ques[curr].r==i)
		{
			ans[ques[curr].id]=sum(ques[curr].l,ques[curr].r);
			curr++;
		}
	}
	
	for(int i=1;i<=q;i++) cout<<ans[i]<<"\n";
}
	
			

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int testcase=1;
	//cin>>testcase;
	
	for(int i=1;i<=testcase;i++)
	{
		//cout<<"Case "<<i<<": ";
		solve();
	}
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}


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

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

using ll = long long;
using ull = unsigned ll;

int main() {
  ll a[10000];
  int n;
  ll sum = 0;
  cin >> n;
  rep(i, n) cin >> a[i], sum += a[i];
  sort(a, a + n);
  cout << a[0] << ' ' << a[n - 1] << ' ' << sum << endl;
  return 0;
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; cin>>n;
	map<ll, ll> p;
	rep(i, n){
		ll temp; cin>>temp;
		p.ins(mp(temp, i));
	}

	vll q;
	q.pb(-1); q.pb(-1);
	q.pb(n); q.pb(n);

	ll ans=0;
	for(int i=n; i>=1; i--){
		ll left=0, right=q.size()-1;
		while(right-left>1){
			int mid = (right+left)/2;
			if (q[mid]>p[i]){
				right = mid;
			}else{
				left = mid;
			}
		}
		ans+=i*(q[left]-q[left-1])*(q[right]-p[i]);
		ans+=i*(p[i]-q[left])*(q[right+1]-q[right]);
		q.ins(q.begin()+right, p[i]);
	}
	cout << ans << "\n";

	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int n=s.size();
    vector<int>dp(n,0);
    for(int i=0;i<n-1;i++){
        if(s[i]==s[i+1]){
            dp[i+1]=dp[i];
        }
        else {
            dp[i+1]=dp[i]+1;
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 3800