akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

long long calcLucasNumber(int n, vector<long long> &memo){
    if(n == 0)  
        return 2;
    else if(n == 1) 
        return 1;

    if(memo[n] != -1)
        return memo[n];
    
    memo[n] = calcLucasNumber(n-1, memo) + calcLucasNumber(n-2, memo);
    return memo[n];
}

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

    vector<long long> memo(100, -1);
    cout << calcLucasNumber(N,memo) << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
ve = Counter(v[::2]).most_common()
vo = Counter(v[1::2]).most_common()

if ve[0][0] == vo[0][0]:
    if len(ve) == len(vo) == 1:
        ans = n - max(ve[0][1], vo[0][1])
    else:
        ans = n - max(ve[0][1]+vo[1][1], vo[0][1]+ve[1][1])
else:
    ans = n - ve[0][1] - vo[0][1]
print(ans)


Measured memory_bytes: 20700
#include <bits/stdc++.h>
using namespace std;
char c;
int main(){
	int cur=0,ans=0;
	for(int i=0;i<3;i++){
		cin>>c;
		if(c=='R')cur++;
		else cur=0;
		ans=max(ans,cur);
	}
	cout<<ans;
}

Measured memory_bytes: 3616
#include <stdio.h>
int main(void)
{
  int i,x,y;
  for(i=0;i<=3000;i++){
    scanf("%d %d",&x,&y);
    if(x<y){
      printf("%d %d\n",x,y);
    }else if(x>y){
      printf("%d %d\n",y,x);
    }else if(x==0&&y==0){
      break;
    }else if(x==y){
      printf("%d %d\n",x,y);
    }
  }
  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;
public class Main { 
    public static void main(String[] args) { 
        try (Scanner sc = new Scanner(System.in)) { 
            String line = sc.nextLine(); 
            String answer = ""; 
            int length = line.length(); 
            for (int i = 0; i < length; i++) { 
                char ch = line.charAt(i); 
                if (Character.isLowerCase(ch)) { 
                    ch = Character.toUpperCase(ch); 
                } else { 
                    ch = Character.toLowerCase(ch); 
                } 
                answer+=ch;
            } 
            System.out.println(answer); 
        } 
    } 
}


Measured memory_bytes: 31084
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O30")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << (x) << "\n")
using ll = long long; using ld = long double; using namespace std;

#ifndef __GNUC__
string text =
R"X(
6
3 14 159 2 6 53
58 9 79 323 84 6
2643 383 2 79 50 288
)X";
stringstream iss{text};
#endif 

class Festival
{
	ll N{0};
	vector<vector<ll>> A;
	void inp( ) {
		iss >> N; A.resize(3, vector<ll>(N));
		rep(a, 3) {	rep(i, N) { iss >> A[a][i]; };}
		sort(begin(A[0]), end(A[0]));
		sort(begin(A[2]), end(A[2]));
	}
	void biSearch( ) {
		ll cnt{0};
		for (auto &b : A[1]) {
			auto itA = lower_bound(begin(A[0]), end(A[0]), b);//A<bなる最大要素の位置
			auto itC = upper_bound(begin(A[2]), end(A[2]), b);//b<Cなる最小要素の位置
			cnt += (end(A[2]) - itC) * (itA - begin(A[0]));
		}
		p(cnt);
	}
public:
	void procedures( ) {
		inp( );	biSearch( );
	}
};
int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	class Festival a; a.procedures( );
}

Measured memory_bytes: 6336
#include<iostream>
#include<queue>
using namespace std;
int H,W;
int sx,sy,gx,gy;
string s[1000];
int col[1000][1000];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
main()
{
	cin>>H>>W>>sx>>sy>>gx>>gy;
	sx--,sy--,gx--,gy--;
	for(int i=0;i<H;i++)cin>>s[i];
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)col[i][j]=-1;
	int sz=0;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)if(s[i][j]=='.'&&col[i][j]<0)
	{
		col[i][j]=sz;
		queue<pair<int,int> >P;
		P.push(make_pair(i,j));
		while(!P.empty())
		{
			int x=P.front().first,y=P.front().second;
			P.pop();
			for(int r=0;r<4;r++)
			{
				int tx=x+dx[r],ty=y+dy[r];
				if(tx<0||ty<0||tx>=H||ty>=W)continue;
				if(s[tx][ty]=='.'&&col[tx][ty]<0)
				{
					col[tx][ty]=sz;
					P.push(make_pair(tx,ty));
				}
			}
		}
		sz++;
	}
	vector<vector<int> >G(sz);
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)if(col[i][j]>=0)
	{
		int u=col[i][j];
		for(int dx=-2;dx<=2;dx++)for(int dy=-2;dy<=2;dy++)
		{
			int x=i+dx,y=j+dy;
			if(x<0||y<0||x>=H||y>=W||s[x][y]=='#')continue;
			int v=col[x][y];
			if(u!=v)G[u].push_back(v);
		}
	}
	vector<int>dist(sz,(int)1e9);
	dist[col[sx][sy]]=0;
	queue<int>P;
	P.push(col[sx][sy]);
	while(!P.empty())
	{
		int u=P.front();P.pop();
		for(int v:G[u])if(dist[v]>dist[u]+1)
		{
			dist[v]=dist[u]+1;
			P.push(v);
		}
	}
	int ans=dist[col[gx][gy]];
	if(ans<1e9)cout<<ans<<endl;
	else cout<<-1<<endl;
}

Measured memory_bytes: 22452
n,q=map(int,input().split())
s=[0]*-~n
w=m=0
for _ in[0]*q:
 a,v=map(int,input().split())
 s[a]+=v
 if v<0 and a==w:m=max(s);w=s.index(m)
 elif s[a]>m:w,m=a,s[a]
 elif s[a]==m:w=min(w,a)
 print(w,m)


Measured memory_bytes: 13956
import numpy
N,D=map(int,input().split())
X=[list(map(int,input().split())) for i in range(N)]
A=0
for i in range(N):
    for j in range(N-i-1):
        Z=numpy.linalg.norm(numpy.array(X[i])-numpy.array(X[i+j+1]))
        if Z.is_integer()== True:
            A=A+1
print(A)            


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

int main(){
    int n;
    while(cin>>n,n){
        string s;
        cin>>s;
        vector<vector<int>> chunk;
        for(int i=0;i<n;i++){
            vector<int> ch;
            for(;i<n;i++){
                if(s[i]=='u') break;
                ch.push_back(s[i]-'0');
            }
            if(ch.size()!=0){
                chunk.push_back(ch);
            }
        }
        bool isdead=false;
        for(int i=0;i<chunk.size();i++){
            vector<int> check(10,0);
            for(int j=0;j<chunk[i].size();j++){
                if(check[chunk[i][j]]==true){
                    isdead=true;
                }
                check[chunk[i][j]]=true;
            }
        }

        if(isdead){
            cout<<"UNSAFE"<<endl;
            continue;
        }
        set<pair<int,int>> st;
        queue<pair<int,int>> que;
        for(int i=0;i<chunk.size();i++){
            int ss=0;
            for(int j=0;j<chunk[i].size();j++){
                pair<int,int> x=make_pair(ss,chunk[i][j]);
                st.insert(x);
                que.push(x);
                ss+=(1<<chunk[i][j]);
            }
        }

        while(!que.empty()){
            pair<int,int> val=que.front(); que.pop();
            int ss=val.first;
            int dea=val.second;
            for(auto it=st.begin();it!=st.end();it++){
                int sss=it->first;
                int deaa=it->second;
                if(sss+ss==(sss|ss)){
                    if((sss&(1<<dea))&&(ss&(1<<deaa))){
                       isdead=true; 
                    }
                    else if(sss&(1<<dea)){
                        pair<int,int> x=make_pair(ss|sss,deaa);
                        if(!st.count(x)){
                            st.insert(x);
                            que.push(x);
                        }
                    }
                    else if(ss&(1<<deaa)){
                        pair<int,int> x=make_pair(ss|sss,dea);
                        if(!st.count(x)){
                            st.insert(x);
                            que.push(x);
                        }
                    }
                }
            }


        }
        cout<<(isdead ? "UNSAFE" : "SAFE")<<endl;
    }
    return 0;
}

Measured memory_bytes: 3512
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n;
		int m, h;
		int sum = 0;
		int wordLength = 0;
		int count = 0;
		ArrayList<String> wordsList = new ArrayList<String>();
		ArrayList<Integer> shufflesList = new ArrayList<Integer>();
		while (true) {
			n = sc.next();
			if (n.equals("-")) {
				break;
			}
			wordsList.add(n);
			m = sc.nextInt();
			for (int i = 0; i < m; i++) {
				h = sc.nextInt();
				sum += h;
			}
			wordLength = sum % n.length();
			shufflesList.add(wordLength);
			sum = 0;
			count++;
		}
		for (int i = 0; i < count; i++) {
			char[] array = wordsList.get(i).toCharArray();
			int shuffle = shufflesList.get(i);
			for (int j = shuffle; j < array.length; j++) {
				System.out.print(array[j]);
			}
			for (int j = 0; j < shuffle; j++) {
				System.out.print(array[j]);
			}
			System.out.println();
		}
		sc.close();
	}
}


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

#define ll long long
#define db double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 2e5 + 123;
const ll inf = 1e18;
int n, p[3][N];
ll pr[3][N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	int odd = n & 1;
	n /= 2;
	for (int i = 0; i < n; i++) {
		cin >> p[0][i] >> p[1][i];
	}
	ll ans = -inf;
	int x, old;
	if (odd) {
		cin >> x;
		old = p[1][n - 1];
		p[1][n - 1] = max(p[1][n - 1], x);
	}
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < n; j++) {
			if (j > 0) {
				pr[i][j] = pr[i][j - 1];
			}
			pr[i][j] += p[i][j];
		}
	}
	ans = max(ans, pr[0][n - 1]);
	for (int i = 0; i < n; i++) {
		ll res = 0;
		if (i > 0) {
			res = pr[0][i - 1] - pr[1][i - 1];
		}
		ans = max(ans, res + pr[1][n - 1]);
	}
	
	if (odd) {
		p[0][n - 1] += x;
		p[1][n - 1] = old;
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < n; j++) {
				if (j > 0) {
					pr[i][j] = pr[i][j - 1];
				}
				if (j == 0) {
					pr[i][j] = 0;
				}
				pr[i][j] += p[i][j];
			}
		}
		ll tmp = -inf;
		for (int i = 0; i < n - 1; i++) {
			ll zero = 0;
			if (i > 0) {
				zero = pr[0][i - 1];
			}
			ll one = 0;
			if (i > 0) {
				one = pr[1][i - 1];
			}
			ans = max(ans, pr[0][n - 1] - pr[0][i] + max(zero, one + tmp));
			ll res = 0;
			if (i > 0) {
				res = pr[0][i - 1] - pr[1][i - 1];
			}
			tmp = max(tmp, res);
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 6000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int MAXN = 1e6 + 5, MAXM = 2e6 + 5, BOUND = 2e5, MOD = 10000, INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0), eps = 1e-6;
#define mid l + ((r-l)>>1)
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define lc(x) c[x][0]
#define rc(x) c[x][1]
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
char gdffsaw;
#define G gdffsaw=getchar()
#define GO G;while(gdffsaw<'-')G
#define in(z) GO;z=gdffsaw&15;G;while(gdffsaw>'-')z*=10,z+=gdffsaw&15,G
int read() {
	int x = 0, f = 1; char ch = getchar();
	while (ch<'0' || ch>'9') { if (ch == '-')f = -1; ch = getchar(); }
	while (ch >= '0'&&ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int H, W, h, w;
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> H >> W >> h >> w;
	cout << W * H - h * W - (H - h)*w << '\n';
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (h, w, a, b) = readLine()!!.split(' ').map { it.toInt() }
    val s1 = "0".repeat(a) + "1".repeat(w - a)
    val s2 = "1".repeat(a) + "0".repeat(w - a)
    for (i in 0 until h) {
        println(if (i < b) s1 else s2)
    }
}


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

#define F first
#define S second
#define ll long long
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()

using namespace std;

typedef pair<int,int> pi;
typedef pair<int,pair<int,int>> pii;
typedef vector<int> vi;

map<string,int> n;

main(){
	n["SUN"] = 7;
	n["MON"] = 6;
	n["TUE"] = 5;
	n["WED"] = 4;
	n["THU"] = 3;
	n["FRI"] = 2;
	n["SAT"] = 1;
	string s;
	cin >> s;
	cout << n[s];
	return 0;
}

Measured memory_bytes: 256
A=input()
B=input()
a=[0 for s in range(len(A))]
b=[0 for t in range(len(A))]

count=1
count2=1
for i in range(len(A)):
    j=i
    if a[i] == 0:
        while A.find(A[i],j) != -1:
            a[A.find(A[i],j)]=count
            j=A.find(A[i],j)+1
        count+=1
    j=i
    if b[i] == 0:
        while B.find(B[i],j) != -1:
            b[B.find(B[i],j)]=count2
            j=B.find(B[i],j)+1
        count2+=1
        
if a == b:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 6832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
#define F first
#define S second
#define fi(a, b) for(ll i=(a);i<=b;i++)
#define fj(a, b) for(ll j=(a);j<=b;j++)
#define fid(a, b) for(ll i=(a);i>=b;i--)
#define fjd(a, b) for(ll i=(a);i>=b;j--)

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v : V) os << v << " ";
    os << "]";
	return os;
}
template<class T> ostream& operator<<(ostream &os, set<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class T> ostream& operator<<(ostream &os, multiset<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, unordered_map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}

// Kevin Mathew T
// Birla Institute of Technology, Mesra
// LinkedIn - https://www.linkedin.com/in/KevinMathewT/
// GitHub - https://github.com/KevinMathewT
// CodeForces - https://codeforces.com/profile/KevinMathew
// CodeChef - https://www.codechef.com/users/KevinMathew
// HackerRank - https://www.hackerrank.com/KevinMathew

const ll N = 100010, M = 1e9 + 7;
ll n, a[N];
string s;
vector<pair<char, ll> > v;

void solve(){
	cin >> s;
	v.push_back({'R', 1});
	fi(1, s.size() - 1) if(s[i] == v.back().F) v.back().S++; else v.push_back({s[i], 1});
	// cout << v << "\n";

	fi(0, s.size()) a[i] = 0;
	ll start = 0;
	fi(0, v.size() - 1) {
		a[start + v[i].S - 1] = (v[i].S + v[i + 1].S) / 2;
		a[start + v[i].S] = (v[i].S + v[i + 1].S) / 2;

		if((v[i].S + v[i + 1].S) % 2 == 1) {
			if(v[i].S % 2 == 1) a[start + v[i].S - 1]++;
			else a[start + v[i].S]++;
		} 

		start += v[i].S + v[i + 1].S;
		i++;
	}

	fi(0, s.size() - 1) cout << a[i] << " ";
	cout << '\n';
}

int main(){
	// freopen("input.txt", "r", stdin);		//Comment
	// freopen("output.txt", "w", stdout);		//this out.
	ios::sync_with_stdio(false);			//Not
	cin.tie(NULL);							//this.
	cout.tie(0);							//or this.

	// ll T;
	// cin >> T;
	// while(T--)
		solve();

	return 0;
}

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

int main(){
  int n; cin>>n;
  int cnt=0;
  for (int i=0; i<n; i++){
    int d1,d2; cin>>d1>>d2;
    if (d1==d2) cnt+=1;
    else cnt=0;
    if (cnt==3){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <bits/stdc++.h> 
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n)cin >> a[n-1-i];
  ll m=2,M=2;
  if(a[0]!=2){
    cout << -1 << endl;
    return 0;
  }
  REP(i,1,n){
    M+=a[i-1]-1;
    if(M%a[i]!=0){
      M-=M%a[i];
    }
    if(m%a[i]!=0){
      m+=a[i]-m%a[i];
    }
    if(m>M || M<a[i]){
      cout << -1 << endl;
      return 0;
    }
  }
  M+=a[n-1]-1;
  
  cout << m << ' ' << M << endl;
return 0;}

Measured memory_bytes: 1024
import java.io.*;

class Main {
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
       
            int w = Integer.parseInt(br.readLine());
            int[] amida = new int[w+1];
            amida[0]=0;
            for(int i=0; i<=w; i++){
                amida[i] = i; 
            }
            int a,b;
            int temp;
            int n = Integer.parseInt(br.readLine());
            for(int i=0; i<n; i++){
                String[] values = br.readLine().split(",");
                a = Integer.parseInt(values[0]);
                b = Integer.parseInt(values[1]);
                
                temp = amida[a];
                amida[a] = amida[b];
                amida[b] = temp;
            }
            
            for(int i=1; i<=w; i++){
                System.out.println(amida[i]);
            }
            
        
        
    }
}

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

using namespace std;

int main() {
  long long n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  n--;
  for (long long pos = 0; pos <= n; pos++) {
    long long from = a + c * pos - d * (n - pos);
    long long to = a + d * pos - c * (n - pos);
    if (from <= b && b <= to) {
      puts("YES");
      return 0;
    }
  }
  puts("NO");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

struct DoubleCum
{
	int m_H, m_W;
	vector<vector<int>> m_cum;

	DoubleCum(vector<vector<int>> V)
	{
		m_H = V.size();
		assert(0 < m_H);
		m_W = V[0].size();
		m_cum.resize(m_H + 1, vector<int>(m_W + 1));
		for (int i = 0; i < m_H; i++)
		{
			for (int j = 0; j < m_W; j++)
			{
				m_cum[i + 1][j + 1] = m_cum[i][j + 1] + m_cum[i + 1][j] - m_cum[i][j] + V[i][j];
			}
		}
	}

	int Area(int max_x, int max_y, int min_x, int min_y)
	{
		return m_cum[max_y + 1][max_x + 1] - m_cum[max_y + 1][min_x] - m_cum[min_y][max_x + 1] + m_cum[min_y][min_x];
	}

	void Show()
	{
		for (int i = 0; i <= m_H; i++)
		{
			for (int j = 0; j <= m_W; j++)
			{
				cout << m_cum[i][j] << " ";
			}
			cout << endl;
		}
	}
};

void execute()
{
	int H, W, K;
	cin >> H >> W >> K;

	vector<vector<int>> grid(H, vector<int>(W, 0));
	vector<vector<int>> cum(H + 1, vector<int>(W + 1, 0));
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			char tmp;
			cin >> tmp;
			grid[i][j] = (tmp - '0');
		}
	}
	DoubleCum dc = DoubleCum(grid);
	//dc.Show();
	int ans = INF32;

	for (int i = 0; i < (1 << H - 1); i++) //512
	{
		int count = __builtin_popcount(i);
		int l_limit = 0;

		for (int j = 0; j < W; j++) // 1000
		{

			int t_limit = 0;
			for (int k = 0; (1 << k) <= i + (1 << H - 1); k++) //10
			{
				if ((1 << k) & i + (1 << H - 1))
				{
					if (K < dc.Area(j, k, j, t_limit))
					{
						goto L_Impossible;
					}

					if (K < dc.Area(j, k, l_limit, t_limit))
					{
						l_limit = j;
						count++;
					}
					t_limit = k + 1;
				}
			}
		}

		ans = min(ans, count);
	L_Impossible:;
	}

	cout << ans << endl;

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 384
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


class Info:
    def __init__(self,arg_loc,arg_num):
        self.loc = arg_loc
        self.num = arg_num

    def __lt__(self,another):
        if self.num != another.num:
            return self.num > another.num
        else:
            return self.loc < another.loc

while True:

    N,M = map(int,input().split())
    if N == 0 and M == 0:
        break

    table = [0]*M

    for row in range(N):
        input_array = list(map(int,input().split()))
        for col in range(M):
            if input_array[col] == 1:
                table[col] += 1

    info = []
    for i in range(M):
        info.append(Info(i+1,table[i]))

    info.sort()

    print("%d"%(info[0].loc),end="")
    for i in range(1,M):
        print(" %d"%(info[i].loc),end="")
    print()





Measured memory_bytes: 13864
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        HashSet<Integer> broken = new HashSet<>();
        for (int i = 0; i < m; i++) {
            broken.add(scan.nextInt());
        }
        long[] dp = new long[n + 5];
        dp[0] = 1;
        for (int i = 1; i <= n; i++) {
            if (broken.contains(i)) continue;
            long prev = dp[i - 1];
            long prev2 = 0;
            if (i - 2 >= 0) {
                prev2 = dp[i - 2];
            }
            dp[i] = prev + prev2;
            dp[i] %= 1_000_000_007;
        }
        System.out.println(dp[n]);
    }
}

Measured memory_bytes: 64760
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
map<long long ,long long>dp;
long long solve(long long x)
{
if(dp[x])
{
return dp[x];
}
else
{
return dp[x]=((solve(x/2)+solve((x-1)/2)+solve((x-2)/2)))%mod;
}
}
int main()
{
dp[0]=1;
dp[1]=2;
long long nn;
cin>>nn;
cout<<solve(nn)<<endl;
return 0;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;

signed main(){

    auto g = [&](i64 k, i64 n){

        vector<vector<vector<i64>>> v(n + 1);
        for(i64 i = 0; i < k; ++i)
            v[1].emplace_back(1, i);

        for(i64 i = 2; i <= n; ++i){
            for(auto& x : v[i - 1]){
                for(i64 j = 0; j < k; ++j){
                    auto w = x;
                    w.emplace_back(j);
                    v[i].emplace_back(w);
                }
            }
        }

        vector<vector<i64>> a;
        for(auto& vv : v)
            for(auto& vvv : vv){

                while(vvv.size() != n)
                    vvv.emplace_back(-1);

                a.emplace_back(vvv);
            }

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

        auto& l = a[(a.size() + 1) / 2 - 1];
        for(i64 i = 0; i < n; ++i){
            ++l[i];
        }
        return l;

    };

    auto f = [&](i64 k, i64 n){

        // これは戻りたい個数
        i64 ba = n / 2;
        // これはデフォルトの値
        i64 val = (k + 1) / 2;

        i64 back = 0;
        vector<i64> dif;
        for(i64 i = 0; i < n; ++i){
            back = back * k + 1;
            dif.emplace_back(back);
            if(back > MOD)
                break;
        }

        i64 su = 0;
        i64 t = 0;
        for(; t < n; ++t){
            su += (val - 1) * dif[t] + 1;
            if(su >= ba)
                break;
        }

        su -= ba;
        // [0,t]桁目までを0にして、suだけインクリメントする
        vector<i64> ret(n, (k + 1) / 2);
        for(i64 i = 0; i <= t; ++i)
            ret[i] = 0;


        for(i64 i = t; i >= 0; --i){
            if(!su)
                break;
            --su;
            i64 nex = su / dif[i];
            su -= nex * dif[i];
            ret[i] = nex + 1;
        }
        reverse(ret.begin(), ret.end());
        return ret;
    };

    auto h = [&](i64 k, i64 n){
        vector<i64> v(n, k);
        v[0] = k / 2;
        return v;
    };

    auto p = [&](vector<i64> v){
        cout << v[0];
        for(i64 i = 1; i < v.size(); ++i){
            if(v[i])
                cout << " " << v[i];
        }
        cout << endl;
    };

    auto dbg = [&](i64 k, i64 n){
        auto v1 = g(k, n);
        auto v2 = k & 1 ? f(k, n) : h(k, n);
        if(v1 != v2){
            cout << "err!!!!--------   " << k << ", " << n << endl;
            p(v1);
            p(v2);
            abort();
        }
    };

    auto solve = [&](i64 k, i64 n){
        p(k & 1 ? f(k, n) : h(k, n));
    };

    /*
    for(i64 k = 1; k <= MOD; k += 2){
        for(i64 n = 1; n < 15; ++n){
            dbg(k, n);
        }
    }

    dbg(3, 6);
    */

    i64 k, n;
    cin >> k >> n;
    solve(k, n);
}


Measured memory_bytes: 6636
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>
using namespace std;

int N;
pair<int, int> points[100];

bool comp(pair<int, int> a, pair<int, int> b)
{
    return atan2(a.second, a.first) < atan2(b.second, b.first);
}

int main()
{
    double ans = 0;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> points[i].first >> points[i].second;
    }

    sort(points, points + N, comp);

    for (int l = 0; l < N; l++)
    {
        for (int r = l + 1; r <= N; r++)
        {
            pair<int, int> sum[2];
            for (int i = 0; i < N; i++)
            {
                if (l <= i && i < r)
                {
                    sum[0].first += points[i].first;
                    sum[0].second += points[i].second;
                }
                else
                {
                    sum[1].first += points[i].first;
                    sum[1].second += points[i].second;
                }
            }
            ans = max(ans, max(sqrt(pow(sum[0].first, 2) + pow(sum[0].second, 2)), sqrt(pow(sum[1].first, 2) + pow(sum[1].second, 2))));
        }
    }
    
    cout << setiosflags(ios::fixed) << setprecision(12) << ans << endl;
    // system("pause");
}

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

#define ll long long int

using namespace std;

int main() {
    ll n, m, x;
    cin >> n >> m >> x;
    vector<ll> A(m);
    for (auto & a : A) {
        cin >> a;
    }
    ll left = 0, right = 0;
    for (auto a : A) {
        if (a < x) ++left;
        else ++right;

    }

    cout << min(left, right) << endl;

}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
ll n, m, dist[100005];
vector<ll> adjlist[100005], topo;
bool visited[100005];
void dfs(ll x){
	for (auto i:adjlist[x]){
		if (visited[i])continue;
		visited[i] = 1;
		dfs(i);
	}
	topo.pb(x);
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n >> m;
	for (ll i = 0; i < m; i++){
		ll a, b;cin >> a >> b;
		adjlist[a].pb(b);
		//adjlist[b].pb(a);
	}
	//visited[1] = 1;
	for (ll i = 1; i <= n; i++){
		if (visited[i] == 0){
			visited[i] = 1;
			dfs(i);
		}
	}
	reverse(topo.begin(), topo.end());
	for (auto i:topo){
		//cout << i << ' ';
		for (auto j:adjlist[i]){
			dist[j] = max(dist[j], dist[i] +1);
		}
	}
	//cout << '\n';
	ll ans = 0;
	for (ll i = 1;i <= n; i++)ans = max(ans, dist[i]);
	cout << ans;
	//for (ll i = 1; i <= n ; i++)cout << dist[i] << ' ';
	
}


Measured memory_bytes: 9588
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int n;
int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}

void solve() {
   int m,d;
   cin >> m >> d;
   int ans = 0;
   for(int i = 4;i <= m;i++){
       for(int j = 22;j <= d;j++){
           if((j/10)*(j%10) == i && j%10 >= 2){
               ans++;
           }
       }
   }
   cout << ans << endl;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin>>a;
  long long int n[a];
  for(int i=0;i<a;i++){
    cin>>n[i];
  }

  long long int d;
  int m=0;
  for(int i=0;i<a;i++){
    for(int j=0;j<a;j++){
        if(n[i]<n[j]){
            d=n[i];
            n[i]=n[j];
            n[j]=d;
        }
    }
  }
  /**for(int i=0;i<a;i++){
    cout<<n[i]<<endl;
  }**/
  for(int i=0;i<a-1;i++){
    for(int j=i+1;j<a;j++){
        if(n[i]!=n[j]){
        d=n[i]+n[j];
        for(int k=j+1;k<a;k++){
            if(n[k]!=n[i] && n[k]!=n[j])
            {if(d>n[k])
                m++;
            }
        }
        }
    }
  }
  cout<<m;


}


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

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

    int start = 0, end = 1e5+1;
    rep(i, m) {
        int l, r;
        cin >> l >> r;
        start = max(start, l);
        end = min(end, r);
    }

    int ans = max(end - start + 1, 0);

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i, n) for (int i = 0 ; i< (n); ++i)
using namespace std;
typedef long long ll;

int main () {
	ll n;
	cin >> n;
	ll ans = 1e18;
	for (ll i = 1; i * i <= n;++i) {
		if (n % i != 0) continue;
		ll j = n /i;
		ans = min(ans, i + j - 2);
	}
	cout << ans << endl;
}


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

int main() {
  int A, B, C;
  scanf("%d%d%d", &A, &B, &C);

  int array[3] = {A, B, C};
  int array_len = sizeof(array) / sizeof(array[0]);
  sort(array, array + array_len);

  int is_even_count = 0;
  for (auto i : array) {
    if (i % 2 == 0) is_even_count++;
  }

  int ans = 0;
  if (is_even_count == 3 || is_even_count == 0) {
    ans += (array[2] - array[0]) / 2;
    ans += (array[2] - array[1]) / 2;
  } else if (is_even_count == 2) {
    for (int i = 0; i < 3; i++) {
      if (array[i] % 2 == 0) array[i]++;
    }
    ans++;
    ans += (array[2] - array[0]) / 2;
    ans += (array[2] - array[1]) / 2;
  } else if (is_even_count == 1) {
    for (int i = 0; i < 3; i++) {
      if (array[i] % 2 != 0) array[i]++;
    }
    ans++;
    ans += (array[2] - array[0]) / 2;
    ans += (array[2] - array[1]) / 2;
  }

  printf("%d", ans);
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};


int main(){
  int A, B; cin >> A >> B;
  cout << (A + B) % 24 << endl;
}


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

int main()
{
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    int dp[n + 2];
    memset(dp,0,sizeof(dp));
    dp[0] = 0;
    dp[1] = (abs(a[1] - a[0]));
    for(int i = 2; i <= n; i++)
    {
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]) );
    }
    cout << dp[n - 1] << '\n' ;
    return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/22  Problem: ABC 053 D / Link: http://abc053.contest.atcoder.jp/tasks/abc053_d  ----- */


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

	LL N; cin >> N;
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	SORT(a);
	DD(De(a));
	map<LL, LL>m;
	FOR(i, 0, N) {
		m[a[i]]++;
	}
	LL ans = N;
	int left_two = 0;
	for (auto it : m) {
		if (it.second > 1) {
			if (it.second % 2 == 0) {
				left_two++;
			}
			ans -= it.second - 1;
		}
	}
		
	ans -= (left_two % 2);
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 7296
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/*-------------ここまで---------------------------------------------*/

//C++(GCC9.2.1)

signed main() {
    //宣言
    int a, b, k;
    cin >> a >> b >> k;
    if (a + b < k) cout << "0" << " " << "0" << endl;
    else if (a + b >= k && a >= k) cout << a - k << " " << b << endl;
    else cout << "0" << " " << b - (k - a) << endl;
    return 0;
}

Measured memory_bytes: 3552
// https://atcoder.jp/contests/abc093/tasks/abc093_b

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

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int a, b, k;
  vector<int> r;

  cin >> a >> b >> k;

  FOR(i, a, b + 1)
  {
    if (i - a < k || b - i < k)
      r.push_back(i);
  }

  REP(i, r.size())
  {
    cout << r[i] << '\n';
  }

  return 0;
}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n;
vll p;
vll inv;
lli mem,longest;

int main(){
  cin >> n;
  p = vll(n+1);
  inv = vll(n+1);
  for(lli i = 1;i <= n;i++) cin >> p[i];
  for(lli i = 1;i <= n;i++) inv[p[i]] = i;
  for(lli i = 1;i <= n;i++){
    if(inv[i] < inv[i-1]) mem = 0;
    mem++;
    longest = max(longest,mem);
  }

  cout << n-longest << endl;
  return 0;

}


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

import static java.lang.Integer.parseInt;

/**
 * Greatest Common Divisor
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int a, b;
			a = parseInt(line.substring(0, line.indexOf(' ')));
			b = parseInt(line.substring(line.indexOf(' ') + 1));
			System.out.println(gcd(a, b));
		}
	}

	static int gcd(int a, int b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}
}

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

using namespace std;
using llong = long long int;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

// const static int MOD = 1000000007;
const static int INF = 1000000000;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, h, m;
    cin >> a >> b >> h >> m;
    
    double dega = (double)h / 12 + ((double)m / 60) / 12, degb = (double)m / 60;
    double theta = 2 * M_PI * (dega - degb);
    double l = pow(a, 2) + pow(b, 2) - 2 * a * b * cos(theta);
    l = sqrt(l);

    cout << setprecision(20) << l << endl;

    return 0;
}

Measured memory_bytes: 4132
#include <bits/stdc++.h>
#define PB push_back
#define MP std::make_pair
#define FI first
#define SE second
#define M 1000005
#define INF 1000000000
int n;
int read(){
	char c=getchar();int ans=0;
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') ans=ans*10+c-'0',c=getchar();
	return ans;
}
void Write(int x){
	if (x<10) putchar(x+'0');
	else Write(x/10),putchar(x%10+'0');
	return;
}
void link(int x,int y){return Write(x),putchar(' '),Write(y),putchar('\n'),void();}
int main(){
	n=read();if (!(n&(n-1))) return !printf("No");printf("Yes\n");
	link(1,2),link(2,3),link(3,n+1),link(n+1,n+2),link(n+2,n+3);
	for (int i=4;i<n;i+=2) link(1,i),link(1,i+1),link(i,n+i+1),link(i+1,n+i);
	if (!(n&1)){
		for (int i=4;i<n;i++){
			int j=i^1^n;
			if (j!=3&&j<n) link(i,n),link(j,n*2),exit(0);
		}
		assert(0);
	}
	return 0;
}


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  string s;
  cin >> s;
  if (s=="ABC")
	cout << "ARC" << endl;
  else
	cout << "ABC" << endl;
	
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

    }else{
        cout << "x" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        long maxsum=0;
        long minsum=0;
        int mod=1000000007;
        int[] a=new int[n];
        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
        }
        Arrays.sort(a);
        Mods m=new Mods(n+1,mod);
        for(int i=0;i<n;i++){
            maxsum=((((long)m.modNCR(i,k-1)*(long)a[i])%mod+mod)%mod+maxsum)%mod;
            minsum=((((long)m.modNCR(n-i-1,k-1)*(long)a[i])%mod+mod)%mod+minsum)%mod;
        }
        System.out.println(((maxsum-minsum)+mod)%mod);
 
    }


}
class Mods {
    private int mod;
    private int[] fact;
    //modは十分大きい素数にすること!
    public Mods(int len,int mod){
        fact=new int[len+1];
        fact[0]=fact[1]=1;
        this.mod=mod;
        for(int i=2;i<=len;i++){
            fact[i]=modMult(fact[i-1],i);
        }
    }
    int modSum(int a,int b){
        return (int)(((long)a+(long)b)%mod);
    }
    int modMult(int a,int b){
        return (int)((((long)a*(long)b)%mod+mod)%mod);
    }
    private int pow2(int a,int times){
        if(times==0)return a;
        else return pow2((int)((long)a*(long)a%mod),times-1);
    }
    int modPow(int a,int b){
        int output=1;
        if(b==0)return 1;
        for(int i=0;i<Math.log(b)/Math.log(2)+1;i++){
            if((b&(int)Math.pow(2, i))>0){
                output=modMult(pow2(a,i),output);
            }
        }
        return output;
    }
    int modDivide(int a,int b){
        return modMult(a,modPow(b,mod-2));
    }
    int modNCR(int n,int r){
        if(n<r)return 0;
        if(n==r)return 1;
        return modDivide(modDivide(fact[n],fact[r]),fact[n-r]);
    }
}

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

template <class T>
T gcd(T x, T y) {
  if (!x)
    return y;
  return gcd(y % x, x);
}

template <class T>
T lcm(T x, T y) {
  return x * y / gcd(x, y);
}


int main() {
  long long A, B, C, D;
  cin >> A >> B >> C >> D;

  long long x = B / C - (A-1) / C;
  long long y = B / D - (A-1) / D;
  long long z = B / lcm(C, D) - (A-1) / lcm(C, D);

  cout << (B - A + 1) - (x + y - z) << endl;
  return 0;
}


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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 n;
  cin >> n;
  string ans;
  while(n > 0){
    --n;
    ans += char('a' + n % 26);
    n /= 26;
  }
  reverse(all(ans));
  ANS(ans);
  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  while(1) {
    int n;
    cin>>n;
    if(!n) break;
    string s;
    cin>>s;
    uint32_t l = 0;
    vector<uint32_t> p(1024);
    bool ok = true;
    REP(i,n-1) {
      if (isdigit(s[i])) {
        l |= 1 << (s[i] - '0');
      } else {
        l = 0;
      }
      if (!isdigit(s[i+1])) continue;
      int next = s[i+1] - '0';
      if ((l >> next) & 1) ok = false;
      p[l] |= 1 << next;
    }
    REP(i,1<<10) {
      for(int u = (1 << 10) - 1; u >= 0; --u) {
        u &= i;
        uint32_t v = i ^ u;
        if (!u || !v) continue;
        if (p[v] & u) {
          if (p[u] & v) {
            ok = false;
          } else {
            p[i] |= p[u];
          }
        } else if (p[u] & v) {
          p[i] |= p[v];
        }
      }
    }
    if (ok) {
      cout << "SAFE" << endl;
    } else {
      cout << "UNSAFE" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n;
  cin>>n;
  long long ans=n+1;
  for(ll i=2;i*i<=n;i++)
    if(n%i==0)
      ans=min(ans,i+n/i);
  cout<<ans-2;
  return 0;
}

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

int main(){
  string S;
  cin >> S;
  int N=S.size();
  
  int ju=0;
  
  for(int i=0;i<(N-1)/2;i++){
    if(S.at(i)==S.at((N-1)/2-i-1)){
      ju++;
    }
  }
    
  int ko=0;
    
  for(int i=(N+3)/2-1;i<N;i++){
    if(S.at(i)==S.at(N-i-1)){
      ko++;
    }
       }
       
  if(ju==(N-1)/2&&ko==N-(N+3)/2+1){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
       }
    

Measured memory_bytes: 256