akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod= 1e9+7;

bool cmp(ll &a, ll &b){
	return abs(a)>abs(b);
}

int main(){
	int n,k;
	cin>>n>>k;
	vector<ll>v(n);
	for(ll &x:v){
		cin>>x;
	}	
	sort(v.begin(),v.end(),cmp);

	int negs=0;
	for(int i=0;i<k;i++){
		negs+=(v[i]<0);
	}
	if(negs%2==1){
		
		int c1=-1,c2=-1,d1=-1,d2=-1;

		for(int i=0;i<k;i++){
			if(v[i]<0)c1=i;
			if(v[i]>=0)d1=i;
			
		}
		for(int i=k;i<n;i++){
			if(v[i]>=0 && c2==-1)c2=i;
			if(v[i]<0 && d2==-1)d2=i;
		}
		
		if(c1!=-1 && c2!=-1 && d1!=-1 && d2!=-1){
			if(v[c1]*v[d2]< v[c2]*v[d1]){
				swap(v[c1],v[c2]);
			}else{
				swap(v[d1],v[d2]);
			}
		}else if(c1!=-1 && c2!=-1){
			swap(v[c1],v[c2]);
		}else if(d1!=-1 && d2!=-1){
			swap(v[d1],v[d2]);
		}else{
			reverse(v.begin(),v.end());
		}
	}

	ll ret= 1;
	for(int i=0;i<k;i++){
		ret*=v[i];
		ret%=mod;
	}
	//cout<<'\n';
	ret=(mod+ret)%mod;
	cout<<ret<<'\n';
	return 0;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 999999999ll
#define MIN -999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
int main() {
  ll a,b;
  cin>>a>>b;
  ll B=2*b;
  if(a>=B){
    cout<<a-B;
  }
  else{
    cout<<0;
  }
}

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

int main(){
    double H, W, x, y;
    cin >> W >> H >> x >> y;
    if((x == 0 || x == W) && (y == 0 || y == H)){
        printf("%.12lf 0\n", H * W / 2);
        return 0;
    }
    if((W * y == H * x) || (W * y == H * (W - x))){
        if((2*x == W) && (2*y == H)){
            printf("%.12lf 1\n", H * W / 2);
        }else{
            printf("%.12lf 0\n", H * W / 2);
        }
        return 0;
    }
    printf("%.12lf 0\n", H * W / 2);

    return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>h(n); for(auto&&i:h)cin>>i;
	int ans=0;
	h.emplace_back(1e9+1);
	for(int i=1,p=h.front(),t=0;i<=n;++i){
		if(p>=h.at(i))++t;
		else ans=max(ans,t),t=0;
		p=h.at(i);
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3952
N = int(input())
Dict = {}
List = []

for i in range(N):
    post = input()
    if post in Dict:
        Dict[post]+=1
    else:
        Dict[post]=1

Max = max(list(Dict.values()))
for i in list(Dict.items()):
    if i[1]>=Max:
        List.append(i[0])
for i in sorted(List):
    print(i)

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

using ll = long long;

#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 pb push_back
#define mp make_pair
#define fill(x, y) memset(x, y, sizeof(x))
#define even(x) x % 2 == 0
#define odd(x) x % 2 != 0
#define all(x) x.begin(), x.end()
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

// these functions return the position of result of Binary Search.
#define LB(s, t, x) (int) (lower_bound(s, t, x) - s)
#define UB(s, t, x) (int) (upper_bound(s, t, x) - s)

ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dx8[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[] = { 0, 0, -1, 1, -1, 1, -1, 1 };

template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }
// auto dp = make_v<int>(4, h, w);
// fill_v(dp, 0);

const ll INF_LL = (1ll << 60);
const int INF_INT = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

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; }

inline tuple<ll, ll> rotate45(tuple<ll, ll> p) { ll x = get<0>(p), y = get<1>(p); return tuple<ll, ll>(x + y, x - y); }
inline bool rangeCheck2D(int nx, int ny, int Width, int Height) { return nx >= 0 and nx < Width and ny >= 0 and ny < Height; }
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};
int main(void)
{
	cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);
ll N; cin >> N;
	string s; cin >> s;
	ll ans = 0;
	REP(i, s.size()) {
		string s1 = s.substr(0, i);
		string s2 = s.substr(i, s.size()-i);
		set<char> s1s;
		REP(j, s1.size()) s1s.insert(s1[j]);
		set<char> s2s;
		REP(j, s2.size()) {
			if (s1s.find(s2[j])!=s1s.end()) {
				s2s.insert(s2[j]);
			}
		}
		chmax(ans, (ll)s2s.size());
	}	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}


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

	ll ret = 0;
	ll t = 0;
	for (int i = 1; i <= k; ++i)
	{
		for (int j = 1; j <= k; ++j)
		{
			for (int m = 1; m <= k; ++m)
			{
				t = GCD(i, j);
				ret += GCD(t, m);
			}
		}
	}

	cout << ret << endl;
	return 0;
}

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

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int mod = 1e9+7;



int main() {
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}




Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int nmax=100005;
vector<int> v[nmax];
int q[nmax],grad[nmax],val[nmax],c[nmax],scos[nmax];
int n,i,x,y,j,p,u;
int main()
{
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(i=1;i<=n-1;i++)
    {
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
        grad[x]++;grad[y]++;
    }
    for(i=1;i<=n;i++)
        cin>>c[i];
    sort(c+1,c+n+1);
    for(i=1;i<=n;i++)
        if(grad[i]==1)
              q[++u]=i;
    long long ans=0;
    for(p=1;p<=u;p++)
    {
       x=q[p];scos[x]=1;
       for(i=0;i<v[x].size();i++)
        if(!scos[v[x][i]])
           y=v[x][i];
        grad[x]--;grad[y]--;
        if(grad[y]==1)
            q[++u]=y;
        val[x]=c[p];
        if(p<n) ans+=1LL*val[x];
    }
    cout<<ans<<'\n';
    for(i=1;i<=n;i++)
        cout<<val[i]<<' ';
    return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int p=1000000007;
  map<int,int> pf;
  int mf=1;
  for(int64_t i=2;i*i<=m;i++){
    while(m%i==0){
      m/=i;
      pf[i]++;
      mf=max(mf,pf[i]);
    }
  }
  if(m!=1)
    pf[m]++;
  vector<int64_t> f(n+mf+1,1);
  for(int i=1;i<=n+mf;i++)
    f.at(i)=f.at(i-1)*i%p;
  int q=p-2;
  vector<bool> b;
  while(q>0){
    b.push_back(q%2);
    q/=2;
  }
  vector<int64_t> fi(n+mf+1,1);
  for(int i=b.size()-1;i>=0;i--){
    fi.at(n+mf)=fi.at(n+mf)*fi.at(n+mf)%p;
    if(b.at(i))
      fi.at(n+mf)=fi.at(n+mf)*f.at(n+mf)%p;
  }
  for(int i=n+mf;i>=1;i--)
    fi.at(i-1)=fi.at(i)*i%p;
  int c=1;
  for(auto x:pf)
    c=c*f.at(n-1+x.second)%p*fi.at(n-1)%p*fi.at(x.second)%p;
  cout<<c<<endl;
}

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

#define int long long
#define test int t; cin >> t; while (t--)
#define deb(x) cerr << "[" << #x  << " : "<< x << "]\n";
#define pb push_back
#define pp pop_back
#define mkp make_pair 
#define f first
#define s second
#define all(x) x.begin(),x.end()

#define MOD 1000000007
#define MAX 50000

typedef long double ld;
const int N = 1e5 + 10;
const int maxn = 2e6 + 10;
const long double Pie = acos(-1);

signed main() {

    ld n, x, t;
    cin >> n >> x >>t;
    
    if (n <= x)
    {
        cout << t;
    }
    else
    {
        ld k = ceil(n / x);
        cout << (int)(k * t);
    }

	return 0;
}



Measured memory_bytes: 3728
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    char[] ch;

    private int getSum(char[] num) {
        int ret = 0;
        for(char c : num) {
            ret += c - '0';
        }
        return ret;
    }

    private void solve() {
        ch = next().toCharArray();

        long sum = getSum(ch);

        for(int i = 0;i < ch.length;i++) {
            if (i == 0) {
                ch[i] = (char)(ch[i] - 1);
            } else {
                ch[i] = '9';
            }
        }

        sum = Math.max(sum,getSum(ch));

        out.println(sum);


    }
    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

const ll MOD=1e9+7;

ll ad(ll x,ll y=0){
  return (x+y)%MOD;
}

ll mlt(ll x,ll y=1){
  return (x*y)%MOD;
}

int main(){
  char c;
  for(;cin>>c;){
    if(c=='A') cout<<'T';
    if(c=='T') cout<<'A';
    if(c=='G') cout<<'C';
    if(c=='C') cout<<'G';
  }
  cout<<endl;
}

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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N; cin >> N;
    vector<pair<int,int>> S_top;
    vector<pair<int,int>> S_bottom;
    REP(i,N){
        string s;
        cin >> s;

        int count = 0;
        REPR(j,s.size()-1){
            if(s[j] == ')'){
                count ++;
            }else if(s[j] == '('){
                if(count > 0){
                    count --;
                    s.erase(j,2);
                }else{
                    count = 0;
                }
            }
        }
        if(s.size() != 0){
            int c = 0;
            REP(j,s.size()){
                if(s[j] == ')'){
                    c++;
                }
            }
            if((int)s.size()-2*c >= 0){
                S_top.push_back(make_pair(c, s.size()-c));
            }else{
                S_bottom.push_back(make_pair(s.size()-c, c));
            }
        }
    }

    sort(ALL(S_top));
    sort(ALL(S_bottom), greater<pair<int,int>>());

    int q = 0;
    bool ok = true;

    for(auto i: S_top){
        q -= i.first;
        if(q<0){
            ok = false;
        }else{
            q += i.second;
        }
    }

    for(auto i: S_bottom){
        q -= i.second;
        if(q<0){
            ok = false;
        }else{
            q += i.first;
        }
    }

    if (q != 0){
        ok = false;
    }

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


    return 0;
}

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

int main() {
  int K, S; cin >> K >> S;
  int ans = 0;
  for(int x = 0; x <= K; x++) {
    for(int y = 0; y <= K; y++) {
      int z = S - x - y;
      if(z >= 0 && z <= K) ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
main () {
	int n,m;
	cin >>n >>m;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			if ((i * 4 + j * 2 == m || i * 2 + j * 4 == m) && i + j == n) {
				cout <<"Yes";
				return 0;
			}
		}
	}
	cout <<"No";
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();

    //setとすることで自動的に重複を除いてくれる
    set<char> p;
    rep(i,n){
        p.insert(s.at(i));
    }

    //重複がないならpとsの要素数は一致するはず
    if((int)p.size() == n){
        cout << "yes" << endl;
    }
    else{
        cout << "no" << endl;
    }
    
}


Measured memory_bytes: 256
import java.util.*;
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 && b < c){
		    System.out.println("Yes");
		} else {
		    System.out.println("No");
		}
	}
}



Measured memory_bytes: 26412
#include<bits/stdc++.h>
//using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<62)-1
#define MAX 1000000000
signed main(){
    int N; std::cin>>N;
    std::vector<std::pii> A(N);
    rep(i,0,N) std::cin>>A[i].second>>A[i].first;
    sort(ALL(A));
    int ans=0;
    std::map<int,int> M;
    rep(i,0,N) M[A[i].second]++;
    rep(i,0,N){
        int X=A[i].first-A[i].second+1;
        auto it=rbegin(M);
        std::pii p=*it;
        if(p.first==A[i].second&&p.second==1){
            it++;
            p=*it;
        }
        int q=A[0].first;
        if(i==0) q=A[1].first;
        X+=std::max(0ll,q-p.first+1);
        ans=std::max(ans,X);
    }
    std::map<int,int> m,n;
    rep(i,0,N) n[A[i].second]++;
    rep(i,0,N-1){
        m[A[i].second]++;
        n[A[i].second]--;
        if(n[A[i].second]==0) n.erase(A[i].second);
        auto p=*rbegin(m),q=*rbegin(n);
        int X=std::max(0ll,A[0].first-p.first+1),Y=std::max(0ll,A[i+1].first-q.first+1);
        ans=std::max(ans,X+Y);
    }
    std::cout<<ans<<std::endl;
}

Measured memory_bytes: 14336
import sys
sys.setrecursionlimit(10**6)

#a = int(input())
#b = list(map(int, input().split()))
n, k = map(int, input().split())
s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

s = [ch for ch in s]
s[k-1] = s[k-1].lower()
s = ''.join(s)

print(s)

Measured memory_bytes: 61856
#include<stdio.h>
int main()
{
	int a,b,c,d,e;
	1<=a<=100;
	1<=b<=100;
	1<=c<=100;
	scanf("%d %d %d",&a,&b,&c);
	d=b-a;
	e=c-b;
	if(d==e)
		printf("YES");
		else
			printf("NO");

	
}

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

int main() {
	int n,m;
	cin >> n >> m;
	vector<vector<int>> to(n);
	vector<int> visited(n,-1);  // 道しるべ無しなら-1、有るならその番号
	rep(i,m) {
		int a,b;
		cin >> a >> b;
		a--;b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	queue<int> q;
	q.push(0);
	visited[0] = 0;

	// visitedを埋める
	while(!q.empty()) {
		int now = q.front();
		//cout << now << endl;
		q.pop();
		for (int next : to[now]) {
			if (next!=0 && visited[next]==-1) {
				visited[next] = now;
				q.push(next);
			}
		}
	}

	bool is_placed = true;
	for (int i=1;i<n;i++) if (visited[i]==-1) is_placed = false;
	if (is_placed) {
		cout << "Yes" << endl;
		for (int i=1;i<n;i++) cout << visited[i]+1 << endl;
	}
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 10244
n, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

steps = Array.new(n + 1, -1)
visited = []
to_visit = 1
i = 0
cycles = 1

while steps[to_visit] == -1
  steps[to_visit] = visited.size
  visited << to_visit
  to_visit = as[to_visit - 1]
end

i = steps[to_visit]
cycles = visited.size - i

if k < i
  puts visited[k]
else
  puts visited[i + ((k - i) % cycles)]
end

Measured memory_bytes: 30556
#include<iostream>
#include<array>
#include<vector>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <tuple>
#include<cmath>

using llint = long long int;
using namespace std;

string S;
int inf = 1000000007;

int main() {
	cin >> S;
	char c = S[0];
	int N = S.size();
	int k = inf;
	if (count(S.begin(), S.end(), '0') == N || count(S.begin(), S.end(), '1') == N) { cout << N << endl; return 0; }
	for (int i = 1; i < N; i++) {
		if (c != S[i]) {
			//cout << i << endl;
			//後半が大きい場合後半Flip
			if (i < N - i) {
				k = min(k, N - i);
			}
			//前半が大きい場合前半Flip
			else if (i > N - i) {
				k = min(k, i);
			}
			//ちょうど中間
			else {
				k = N / 2;
			}
			c = (c == '0' ? '1' : '0');
		}
	}
	cout << k << endl;
	return 0;
}



Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    S = lines.pop(0)
    L = R = 0
    for i, s in enumerate(S):
        if i % 2 == 0:
            if s == '0':
                L += 1
            else:
                R += 1
        else:
            if s == '1':
                L += 1
            else:
                R += 1
    print(min(L,R))
    
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define deb(x) cout << "[" << (#x) << "=" << x << "]" << '\n';
#define deb2(x,y) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "]" << '\n';
#define deb3(x,y,z) cout << "[" << (#x) << "=" << x << "] [" << (#y) << "=" << y << "] [" << (#z) << "=" << z << "]" << '\n';

const int N=1e5+7;
int n,m,k,q,l,r,x,y,z;
int a[N],b[N],c[N];
string s,t;
int ans=0,cnt=0;

void solve(){
	cin>>n>>m;
	cout<<n*m;LOL
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int _=1; //cin>>_;
  for(int i=1 ; i<=_ ; i++) solve();
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int n, k;
	cin >> n >> k;
	cout << n - k + 1 << endl;
}



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

int main() {
    ll n;
    while (cin >> n && n != -1) {
        ll base = 4;
        string ans;
        while (n) {
            ans += to_string(n % base);
            n /= base;
        }
        reverse(ans.begin(), ans.end());
        if (ans.empty()) cout << 0 << endl;
        else cout << ans << endl;
    }
}


Measured memory_bytes: 3244
n, t = map(int, input().split())
a, b, ab = [], [], []
for _ in range(n):
    ab.append(tuple(map(int, input().split())))
ab.sort(key=lambda x:x[0])
for i in ab:
    a.append(i[0])
    b.append(i[1])

# dp[i][j] = 0~i番目の料理でj分以内に完食できる美味しさの合計の最大値
# 0 <= i < n-1, 0 <= j <= t-1
dp = [[0 for _ in range(min([t, a[0]]))] + [b[0] for _ in range(t-a[0])]]
for i in range(1, n-1):
    dp.append([])
    for j in range(min([t, a[i]])):
        dp[i].append(dp[i-1][j])
    for j in range(a[i], t):
        dp[i].append(max([dp[i-1][j], dp[i-1][j-a[i]]+b[i]]))

ans = []
for i in range(1, n):
    ans.append(dp[i-1][t-1] + b[i])
print(max(ans))

Measured memory_bytes: 124248
import java.util.Scanner;

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

        while(true)
        {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H==0 && W==0) break;

            int i,k;
            for(i=0; i<H; i++)
            {
                for(k=0; k<W; k++)
                {
                    if(i==0 || i==H-1) System.out.printf("#");
                    else
                    {
                        if(k==0 || k==W-1) System.out.printf("#");
                        else System.out.printf(".");
                    }
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
        sc.close();
    }
}


Measured memory_bytes: 57172
let () =
  Scanf.scanf "%d" @@ fun n ->
  Array.init n (fun i -> Scanf.scanf " %d" (fun x -> x))
  |> Array.fold_left (fun (s, p) v -> if p = v then (s+1, -1) else (s, v)) (0, -2)
  |> fst |> Printf.printf "%d\n"

Measured memory_bytes: 384
<?php

fscanf(STDIN, "%d %d %d", $A, $B, $C);
if ($A > $B) {
    if ($B <= $C && $C <= $A ) {
        echo 'Yes';
    } else {
        echo 'No';
    }
} elseif ($A < $B) {
    if ($A <= $C && $C <= $B ) {
        echo 'Yes';
    } else {
        echo 'No';
    }
} elseif ($A == $B) {
     if ($A == $C)  {
         echo 'Yes';
     } else {
        echo 'No';
     }
}

Measured memory_bytes: 4856
#include<bits/stdc++.h>
using namespace std;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define T int t = 0; cin >> t; while(t--)
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef  long double lld;
const ll mod = 1e9 + 7;
const ll mx = 1e5 + 1;

void input(){
    int h, a; cin >> h >> a;
    cout << (int)ceil((double)h / (double)a) << endl;
}
int main(){
    input();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF=1001001001;
int main(void){
    int n;
    cin>>n;
    vector<int> x(n);
    rep(i,n) cin>>x[i];
    long long int ans=INF;
    rep(i,100){
        long long int ansx=0;
        rep(j,n){
            ansx+=(i-x[j])*(i-x[j]);
        }
        if(ans>ansx) ans=ansx;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#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;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	int a[n];
	map<int, int64_t> cntr;
	rep(i,n) {
		cin >> a[i];
		cntr[i - a[i]]++;
	}
	int64_t ans = 0;
	rep(i,n) {
		cntr[i - a[i]]--;
		ans += cntr[a[i] + i];
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 27156
<?php
define("MOD", 10**9+7);
fscanf(STDIN, "%d%d", $N, $M);
$dp = array_fill(0, 2**$N, 10**18);
$dp[0] = 0;

for($i = 0; $i < $M; $i++){
    fscanf(STDIN, "%d%d", $a, $b);
    $c = array_map("intval", explode(" ", trim(fgets(STDIN))));
    $mask = 2**$N-1;
    foreach($c as $cc){
        $cc--;
        $mask = $mask ^ (1 << $cc);
    }
    for($j = 0, $J = 2**$N; $j < $J; ++$j){
        $new = $dp[$j&$mask] + $a;
        if($dp[$j] > $new){
            $dp[$j] = $new;
        }
    }
}
if($dp[2**$N-1] == 10**18){
    echo -1;exit;
}
echo $dp[2**$N-1];


Measured memory_bytes: 4984
def main():
    N = int(input())
    t,x,y = 0,0,0
    ans = 'Yes'
    for i in range(N):
        ti,xi,yi = (int(x) for x in input().split())
        dt = ti - t
        dist = abs(xi-x) + abs(yi-y)
        if dt < dist or dist%2 != dt%2:
            ans = 'No'
            break
        else:
            t,x,y = ti,xi,yi
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll const mod=1000000007;
ll const md=998244353;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);
for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ifstream in("txt.in");
ofstream out("txt.out");

#define mp make_pair
#define pb push_back
#define fi first
#define se second

vector<int> v[100005];
int dp[100005];
ll cnt;int vis[100005];

int dfs(ll t){
if(vis[t])return dp[t];
vis[t]=1;
int u=v[t].size();
for(int i=0;i<u;++i){
    dp[t]=max(dp[t],dfs(v[t][i])+1);
}

  return dp[t];
}




int main()
{
    cout<<fixed<<setprecision(12);
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cout.tie(0);

    ll n,k;
    cin>>n>>k;
    for(int i=1;i<=k;++i){
        ll x,y;cin>>x>>y;
        v[x].pb(y);
    }
    int cnt=0;
    for(int i=1;i<=n;++i){
       cnt=max(cnt,dfs(i));
    }
    cout<<cnt<<'\n';


    return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int n;
    cin>>n;
    cout<<n*n*n<<endl;

    return 0;
}


Measured memory_bytes: 256
/////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  Last Updated: 2018-10-23 ...Maybe
//
//    I hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -DDEBUG_LOCAL'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REAP(i,0,n)
#define REAP(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REAP,_REP,)(__VA_ARGS__)

#define _REPR(i,n) REAPR(i,n,0)
#define REAPR(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define REPR(...) _overload3(__VA_ARGS__,REAPR,_REPR,)(__VA_ARGS__)

#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()

#define coutALL(a) {int loop_coutALL=0;for(auto e:a) cout<<(loop_coutALL++?" ":"")<<e; cout<<endl;}

#define coutYN(a) cout<<((a)?"YES":"NO")<<endl;
#define coutYn(a) cout<<((a)?"Yes":"No")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;

#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)

const int INF=1145141919;
//const long long INF=114514191911451419;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename T> istream &operator >> (istream &is, vector<T> &v){for(T &x:v) is>>x;return is;}
template<typename T> ostream &operator << (ostream &os, vector<T> &v){int i=0;for(T &x:v) os<<(i++?" ":"")<<x;return os;}

ll rev(ll n){ll x=0;for(;n>0;){x=x*10+n%10;n/=10;}return x;}

template<class T> ll upper(T n,T m){return (n+m-1)/m;};
template<class T> ll rounding(T n){return (long double)n+0.5;};

template<class T> bool inG(T x,T n){return 0<=x && 0<n;}
template<class T> bool outG(T x,T n){return x<0 || n<=x;}

inline int qp(int a,ll b){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
inline int qp(int a,ll b,int mo){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

inline ll fac(ll k,ll n){ll a=1;for(int i=0;i<n;i++)a*=k--;return a;}
inline ll fac(ll k,ll n,int mo){ll a=1;for(int i=0;i<n;i++)a*=k--,a%=mo;return a;}

inline int dsum(ll n){int a=0;for(;n;n/=10)a+=n%10;return a;}

struct Arithmetic{Arithmetic(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}};

//#define DEBUG_LOCAL

#ifdef DEBUG_LOCAL
template<typename T> void deb(T a){cerr<<"deb: "<<a<<"です"<<endl;}
#define debl {cerr<<"debug: "<<__LINE__<<"行目だ"<<endl;}
void what_cr(){cout<<__GCC_ATOMIC_CHAR16_T_LOCK_FREE<<" ←？"<<endl;}
//ori_func S

//ori_func E
#else
template<typename T>void deb(T a){}
#define debl
void what_cr(){}void t_t(){}
#endif

signed main(){

  Arithmetic Exception;

  int n;
  cin>>n;

  cout<<qp(sqrt(n),2)<<endl;
  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



int N;
int p[110000];
vector<int> v;

int main () {
  cin >> N;

  rep(i, N) cin >> p[i]; 

  bool continued = false;
  int tmp = 0;

  rep(i, N) {
    if (p[i] == i) {
      if (continued) {
        tmp++;
      } else {
        tmp = 1;
        continued = true;
      }
    } else {
      if (continued) {
        v.push_back(tmp);
        tmp = 0;
        continued = false;
      }
    }
  }

  if (continued) {
    v.push_back(tmp);
  }

  int ans = 0;

  Rep(i, v.size()) {
    if (v[i] % 2 == 0) {
      ans += (v[i] / 2);
    } else {
      ans += (v[i] / 2 + 1);
    }
  }

  cout << ans << "\n";
}

Measured memory_bytes: 1024
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

# 1のくらいが最も小さいものを最後に注文する

a1 = a%10
b1 = b%10
c1 = c%10
d1 = d%10
e1 = e%10

times = [a,b,c,d,e]
ones = [a1,b1,c1,d1,e1]

# 全て一緒の場合、
#if len(list(set(ones))) == 1:

ones = [10 if i==0 else i for i in ones]

sum = 0

min_index = ones.index(min(ones))
sum += times[min_index]
del times[min_index]
for i in times:
	# 1のくらいは切り上げ: 28
	if i%10==0:
		sum += i
	else:
		sum += (i//10+1)*10

print(sum)

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

#define N 26
#define NIL -1

//array
int parent[N];
int leftc[N];
int rightc[N];

int sibling[N];
int degree[N];
int depth[N];
int height[N];

int root;


//calculate depth
void caldepth(int now,int down){
  // printf("%d %d\n", now, down);

  if(rightc[now]==NIL && leftc[now]==NIL){
    
    
    return; 
  }
  
  //  if(now!=root){
    depth[down]=depth[now]+1;
    /* }  
  if(now==root){
    depth[now]=0;
    depth[down]=depth[now]+1;
    }*/
  
  if(leftc[now]!=NIL) caldepth(leftc[now],leftc[leftc[now]]);
  if(leftc[now]!=NIL) caldepth(leftc[now],rightc[leftc[now]]);
  if(rightc[now]!=NIL) caldepth(rightc[now],leftc[rightc[now]]);
  if(rightc[now]!=NIL) caldepth(rightc[now],rightc[rightc[now]]);
  
}

//calculate height
void calheight(int now,int up){
  if(parent[now]==NIL){
    return;
  }
  else if(height[up]<height[now]+1){
    height[up]=height[now]+1;
    calheight(up,parent[up]);
  }

 
  

}


int main(){

  int i,j,id,n,child1,child2;

  //load data
  scanf("%d",&n);
  
  //initialize
  for(i=0;i<N;i++){
    parent[i]=NIL;
    leftc[i]=NIL;
    rightc[i]=NIL;
    sibling[i]=NIL;
    degree[i]=0;
    depth[i]=0;
    height[i]=0;
  }

  for(i=0;i<n;i++){
    
    //load data
    scanf(" %d %d %d",&id,&child1,&child2);

    //set parent
    parent[child1]=id;
    parent[child2]=id;
    
    //set left right
    leftc[id]=child1;
    rightc[id]=child2;
    
    //set sibling
    sibling[child1]=child2;
    sibling[child2]=child1;

    //set degree
    if(child1!=NIL){
      degree[id]++;
      depth[child1]++;
    }
    if(child2!=NIL){
      degree[id]++;
   
    }

  }
  //find root
  for(i=0;i<n;i++){
    if(parent[i]==NIL){
      root=i;
      break;
    }
  }

  //test
  /*for(i=0;i<n;i++){
    printf("%d %d %d\n", i, leftc[i], rightc[i]);
    }*/
  //calculate depth
  if(leftc[root]!=NIL){
    caldepth(root,leftc[root]);
  }
  if(rightc[root]!=NIL){
    caldepth(root,rightc[root]);
  }
  
  //find leaf & calculateheight
  for(i=0;i<n;i++){
    if(leftc[i]==NIL && rightc[i]==NIL){
      calheight(i,parent[i]);
    }
  }

  
  //print
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,parent[i],sibling[i],degree[i],depth[i],height[i]);

    if(parent[i]==NIL)printf("root");
    else if(leftc[i]==NIL&&rightc[i]==NIL)printf("leaf");
    else if(leftc[i]!=NIL ||rightc[i]!=NIL)printf("internal node");

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

//I was tired.

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using    namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using ll = long long;
#define pb push_back
#define pi acos(-1)
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main()
{
    FastIO;
    ll t, i, j, k, n, a, b, c, x, y, cnt = 0;
    vector < ll > v;
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> a;
        v.pb(a);
    }
    for(i = 1; i <= n; i++){
        if(i % 2 == 1 && v[i - 1] % 2 == 1)
            cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//絶対値
long long int change_plus(long long int a) {
	if (a < 0) { return -a; }
	if (a >= 0) { return a; }
}
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

int main() {
	long long int n, m, k,p;
	char str[30],str2[15],str3[15];
	scanf(" %c",&str[0]);
	if (str[0] == 'a' || str[0] == 'i' || str[0] == 'u' || str[0] == 'e' || str[0] == 'o') { printf("vowel"); }
	else {
		printf("consonant");
	}
	
		
	
}

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

int main() {

    int n;
    cin >> n;

    map <int,int> a;
    rep(i,n){
        int tmp;
        cin >> tmp;
        a[i+1] = tmp;
    }

    int cu = 1;
    rep(i,n){
        int next = a[cu];
        cu = next;
        if(next == 2){
            cout << i+1 << endl;
            return 0;
        } 
    }
    
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
	double cx,cy,r,x1,x2,y1,y2,slope,cross_x,cross_y,k,div_x,div_y,ans1_x,ans1_y,ans2_x,ans2_y;
	int q;
	bool X_FLG,Y_FLG;

	scanf("%lf %lf %lf",&cx,&cy,&r);
	scanf("%d",&q);

	for(int i=0;i<q;i++){
		scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);

		X_FLG = false,Y_FLG = false;

		if(y1 == y2){
			X_FLG = true;
		}else if(x1 == x2){
			Y_FLG = true;
		}else{
			slope = (y2-y1)/(x2-x1);
		}

		if(X_FLG){
			cross_x = cx;
			cross_y = y1;
		}else if(Y_FLG){
			cross_x = x1;
			cross_y = cy;
		}else{
			cross_x = (cy*(x2-x1)*(y2-y1)+cx*(x2-x1)*(x2-x1)-y1*(y2-y1)*(x2-x1)+x1*(y2-y1)*(y2-y1))/((y2-y1)*(y2-y1)+(x2-x1)*(x2-x1));
			cross_y = ((x1-x2)*cross_x+cy*(y2-y1)+cx*(x2-x1))/(y2-y1);
		}

		k = sqrt(r*r-((cx - cross_x)*(cx-cross_x)+(cy-cross_y)*(cy-cross_y)));

		if(X_FLG){
			printf("%.8lf %.8lf %.8lf %.8lf\n",cross_x - k,y1,cross_x+k,y1);
		}else if(Y_FLG){
			printf("%.8lf %.8lf %.8lf %.8lf\n",x1,cross_y-k,x1,cross_y+k);
		}else{
			div_x = k*(x2-x1)/(sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
			div_y = k*(y2-y1)/(sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));

			ans1_x = cross_x-div_x;
			ans1_y = cross_y-div_y;

			ans2_x = cross_x+div_x;
			ans2_y = cross_y+div_y;

			if(ans1_x < ans2_x){
				printf("%.8lf %.8lf %.8lf %.8lf\n",ans1_x,ans1_y,ans2_x,ans2_y);
			}else if(fabs(ans1_x-ans2_x) < 0.00000001 && ans1_y <= ans2_y){
				printf("%.8lf %.8lf %.8lf %.8lf\n",ans1_x,ans1_y,ans2_x,ans2_y);
			}else{
				printf("%.8lf %.8lf %.8lf %.8lf\n",ans2_x,ans2_y,ans1_x,ans1_y);
			}
		}
	}

	return 0;
}



Measured memory_bytes: 2708
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4

int main(){
  int K; cin >> K;
  string S; cin >> S;

  if (S.size()<=K) cout << S << endl;
  else cout << S.substr(0,K) << "..." << endl;
  return 0;
}

Measured memory_bytes: 3612
#!/usr/bin/env python3

N, M, K = map(int, input().split())
mod = 998244353

table = [0]
inv_table = [0]
M_table = []

tmp = pow(M - 1, N - 1, mod)
for i in range(K + 1):
    if i > 0:
        tmp *= pow(M - 1, mod - 2, mod)
        tmp %= mod
    M_table.append(tmp)

tmp = 1
for i in range(1, N + 1):
    tmp *= i
    tmp %= mod
    table.append(tmp)

tmp = 1
for i in range(1, N + 1):
    tmp *= pow(i, mod - 2, mod)
    tmp %= mod
    inv_table.append(tmp)

def cmb(n, r):
    if r == 0:
        return 1
    if n == r:
        return 1
    return table[n] * inv_table[r] * inv_table[n - r]

if M == 1:
    if N - 1 == K:
        print(1)
    else:
        print(0)
    exit()

ans = 0
for i in range(K + 1):
    ans += M * M_table[i] * cmb(N - 1, i)
    ans %= mod

print(ans)

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

class Node{
public:
	string word;
	list <int> page;
	Node(string w,list<int> p){
		word=w;page=p;
	}
	bool operator < ( const Node &o ) const{
		return word > o.word;
	}
};
typedef list<Node> DB;
DB db;
list<Node>::iterator
getKey(string word){
	list<Node>::iterator it=db.begin();
	for(;it!=db.end();it++){
		if(it->word==word)return it;
	}
	return it;
}

list<Node>::iterator
getInsertPointWord(string word){
	list<Node>::iterator it=db.begin();
	for(;it!=db.end();it++){
		if(word < it->word)return it;
	}
	return it;
}
list<int>::iterator
getInsertPointNum(int num,list<Node>::iterator it){
	list<int>::iterator itp=it->page.begin();
	for(;itp!=it->page.end();itp++){
		if(num < *itp)return itp;
	}
	return itp;
}

void print(){
	list<Node>::iterator it=db.begin();
	for(;it!=db.end();it++){
		cout<<it->word<<endl;
		list<int>::iterator itp=it->page.begin();

		for(int i=0;itp!=it->page.end();itp++,i++){
			if(i)cout<<" ";
			cout<<*itp;
		}
		cout<<endl;
	}
}
int
main(){
	string word;
	int page;
	for(;cin>>word;){
		cin>>page;
		list<Node>::iterator it=getKey(word);
		if(it==db.end()){
			it=getInsertPointWord(word);
			list <int> pages;pages.push_back(page);
			db.insert(it,Node(word,pages));
		}
		else{
			list<int>::iterator itp=getInsertPointNum(page,it);
			it->page.insert(itp,page);
		}
	}
	print();
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    int n = scanner.nextInt();
    int k = scanner.nextInt();
    
    int num = k;
    for(int i = 0; i < n - 1; i++) {
      num = num * (k - 1);
    }
    System.out.println(num);
  }
}

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

#define pb push_back
#define mp make_pair
#define ft first
#define sc second
#define ull unsigned long long int
#define lli long long int
#define li long int

#define si(n) scanf("%d",&n)
#define sl(n) scanf("%ld",&n)
#define sll(n) scanf("%lld",&n)

#define pi(n) printf("%d",n)
#define pl(n) printf("%ld",n)
#define pll(n) printf("%lld",n)

using namespace std;

const int MAX=1e5+5;

int main() {
    // freopen("a.in","r",stdin);
    // freopen("a.out","w",stdout);
    lli N, two = 2;
    cin >> N;
    lli Num = N * two;
    Num /= (__gcd(N, two));

    cout << Num << "\n";


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[10000]={0};

int main(){
    int s,ans=1; cin >> s; a[s]++;
    while(1){
        if (s%2==0){a[s/2]++;
            if (a[s/2]==2) break;
            s=s/2; ans++;
        } else {a[3*s+1]++;
            if (a[3*s+1]==2) break;
            s=3*s+1; ans++;
        }
    }
    cout << ans+1 << endl;
}



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

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n) cin>>a[i];
	int pre=-999;
	rep(i,n){
		if(pre<=a[i]-1){
			pre=a[i]-1;
		} else if(pre<=a[i]){
			pre=a[i];
		} else {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 640
#include<iostream>             
using namespace std;           
                               
int main(){                    
        int a,b;               
        cin >> a >> b;         
        int ans = 0;           
        if(a > b){             
                ans += a;   
                a--;           
        }else{                 
                ans += b;   
                b--;           
        }                      
        if(a > b){             
                ans += a;   
                a--;           
        }else{                 
                ans += b;   
                b--;           
        }                      
        cout << ans << endl;                                                                          
}


Measured memory_bytes: 3152
# from scipy.sparse import csr_matrix
# import string
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    N, M = map(int, input().split())
    A = sorted(list(map(int, input().split())), reverse=True)
    val = 1 / (4 * M)
    cnt = 0
    i = 0
    while True:
        if i < N:
            if A[i]/sum(A) >= val:
                cnt += 1
                i += 1
            else:
                break
        else:
            break
    if cnt >= M:
        print('Yes')
    else:
        print('No')


resolve()

Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int p = 998244353;
long long n, r, g, b, rg, rb, gb;
string s;
int main()
{
	cin >> n >> s;
	long long ans = 1;
	for (int i = 1; i <= n; i++)
		ans = (1ll * ans * i) % p;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'R')
		{
			if (gb) { ans = (ans * gb) % p; gb--; }
			else if (g) { ans = (ans * g) % p; g--; rg++; }
			else if (b) { ans = (ans * b) % p; b--; rb++; }
			else r++;
		}
		else if (s[i] == 'G')
		{
			if (rb) { ans = (ans * rb) % p; rb--; }
			else if (r) { ans = (ans * r) % p; r--; rg++; }
			else if (b) { ans = (ans * b) % p; b--; gb++; }
			else g++;
		}
		else
		{
			if (rg) { ans = (ans * rg) % p; rg--; }
			else if (g) { ans = (ans * g) % p; g--; gb++; }
			else if (r) { ans = (ans * r) % p; r--; rb++; }
			else b++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int a=0,a2=0,a4=0;
  rep(i,n){
    int t;
    cin >> t;
    if(t%4==0){
      a4++;
    }else if(t%2==0){
      a2++;
    }
  }
  a = n - a2 - a4;
  bool flag = false;
  if(a + a2%2 <= a4 + 1){
    flag = true;
  }



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


Measured memory_bytes: 256
n = int(input())
a_list = [int(x) for x in input().split()]

flg = False

for a in a_list:
  if a%2==0:
    if a%3!=0 and a%5 !=0:
      flg = True
      break

if flg:
  print('DENIED')
else:
  print('APPROVED')

Measured memory_bytes: 3060
import sys
# sys.setrecursionlimit(100000)
from collections import deque


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    s = deque(list(input()))
    q = input_int()
    inverse = False
    for _ in range(q):
        data = input().split()
        if len(data) == 1:
            inverse = not inverse
        else:
            if (data[1] == "1" and not inverse) or (data[1] == "2" and inverse):
                s.appendleft(data[2])
            else:
                s.append(data[2])
    if inverse:
        print("".join(reversed(s)))
    else:
        print("".join(s))
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 100208
N,K=map(int,raw_input().split())
d={}
l=map(int,raw_input().split())
for i in l:
  if not i in d:
    d[i]=1
  else:
    d[i]+=1
c=0
e=sorted(d.items(),key=lambda x:x[1])[:len(d.items())-K]
for i in e:
  c+=i[1]
print(c)


Measured memory_bytes: 52932