akhauriyash/Code-Regression huggingface dataset:
import java.awt.Point;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	private void solve() {
		Scanner in = new Scanner(System.in);
		int x1 = in.nextInt();
		int y1 = in.nextInt();
		int x2 = in.nextInt();
		int y2 = in.nextInt();
		
		if(y2<y1){
			int sp = y2;
			y2 = y1;
			y1 =sp;
			sp = x2;
			x2 = x1;
			x1 = sp;
		} // y1 < y2
		
		int N = in.nextInt();
		
		if(x1==x2){
			boolean exist = false;
			for (int i = 0; i < N; i++) {
				int x = in.nextInt();
				int y = in.nextInt();
				if(x==x1 && y1<y && y<y2) exist = true;
			}
			System.out.println(100L*(y2-y1)+((!exist)?0:10*Math.PI-20));
			
		}else if(y1==y2){
			boolean exist = false;
			if(x1>x2){
				int sp = x2; x2 = x1; x1 = sp;
			}
			for (int i = 0; i < N; i++) {
				int x = in.nextInt();
				int y = in.nextInt();
				if(y==y1 && x1<x && x<x2) exist = true;
			}
			System.out.println(100L*(x2-x1)+((!exist)?0:10*Math.PI-20));
			
		}else{
			LinkedList<Point> queue = new LinkedList<>();
			for (int i = 0; i < N; i++) {
				queue.offer(new Point(in.nextInt(),in.nextInt()));
			}
			Collections.sort(queue,
					(x1<x2)?
					(a,b)->((Point)a).x-((Point)b).x :
					(a,b)->((Point)b).x-((Point)a).x
			);
			
			BinaryPoints tree = new BinaryPoints();
			while(!queue.isEmpty()){
				Point p = queue.poll(); 
				if(between(p.x,x1,x2) && between(p.y,y1,y2))
					tree.add(p.y);
			}
			int max = tree.lis();
			double ans = 100L*(Math.abs(x2-x1)+(y2-y1));
			if(max==Math.min(Math.abs(x2-x1), y2-y1)+1){
				ans += (5*Math.PI-20)*(max-1) + 10*Math.PI-20;
			}else{
				ans += (5*Math.PI-20)*max;
			}
			System.out.println(ans);
			
		}
	}
	
	private boolean between(int target, int edge1, int edge2){
		return Math.min(edge1,edge2)<=target 
				&& target<= Math.max(edge1, edge2);
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
}


class BinaryPoints{
	ArrayList<Integer> dp;
	
	public BinaryPoints(){
		dp = new ArrayList<Integer>();
	}
	
	public void add(int y){
		int index = lowerBound(y,0,dp.size());
		if(index>=dp.size()){
			dp.add(y);
		}else{
			dp.set(index, y);
		}
	}
	
	public int lis(){
		return dp.size();
	}
	
	public int lowerBound(int y, int left, int right){// [left,right)
		if(right==left) return right;
		int index = (left+right)/2;
		if(dp.get(index)>=y){
			return lowerBound(y,left,index);
		}else{
			return lowerBound(y,index+1,right);
		}
	}
}


Measured memory_bytes: 118612
inp = input()

for i in range(1<<4):
    ans = ''
    for j in range(len(inp)-1):
        if i & (1<<j):
            ans = ans+inp[j]+'+'
        else:
            ans = ans+inp[j]+'-'
    ans = ans+inp[-1]

    if eval(ans) == 7:
        print(ans+'=7')
        break


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    private static FastScanner fs = new FastScanner();
    public static void main(String[] args) {

    int k = fs.nextInt();
    String a = "ACL";
    for(int i=1;i<k;i++) a+="ACL";
        System.out.println(a);
    }


    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

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

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

        long nextLong() {
            return Long.parseLong(next());
        }
        int  gcd(int a,int b)
        {
            while (b > 0)
            {
                int  temp = b;
                b = a % b;
                a = temp;
            }
            return a;
        }
        private int upper(int arr[],int key){
            int low = 0;
            int high = arr.length-1;
            while(low < high){
                int mid = low + (high - low+1)/2;
                if(arr[mid] <= key){
                    low = mid;
                }
                else{
                    high = mid-1;
                }
            }
            return low;
        }
        public int lower(int arr[],int key){
            int low = 0;
            int high = arr.length-1;
            while(low < high){
                int mid = low + (high - low)/2;
                if(arr[mid] >= key){
                    high = mid;
                }
                else{
                    low = mid+1;
                }
            }
            return low;
        }
    }
}

Measured memory_bytes: 36564
#include <iostream>

using namespace std;

int main(void) {
  string s;
  cin >> s;
  int r = 0;
  for(int i = 0; i < s.length(); ++i){
    if (s[i] == '1')
      r += 1;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
// import java.io.BufferedReader;
// import java.io.IOException;
// import java.io.InputStreamReader;
// import java.util.ArrayList;
// import java.util.Arrays;
// import java.util.Collections;
// import java.util.List;
// import java.util.HashSet;
// import java.util.Set;
// import java.util.Map;
// import java.util.HashMap;

import java.math.*;

public class Main {
    private static Scanner sc;
    private static final long mod = 1000000007;

    public static void main(final String[] args) {
        final Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private static String getUpperAlpha(int i) {
        return String.valueOf((char) (i + 64));
    }

    /* i=1 return a */
    private static String getLowerAlpha(int i) {
        return String.valueOf((char) (i + 96));
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null)
                br.close();
        }

        public String next() throws IOException {
            if (i < s.length)
                return s[i++];
            String st = br.readLine();
            while (st == "")
                st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }

        public long[] nextLongArray(int n) throws NumberFormatException, IOException {
            long[] ret = new long[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextLong();
            }
            return ret;
        }

        public int[] nextIntArray(int n) throws NumberFormatException, IOException {
            int[] ret = new int[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextInt();
            }
            return ret;
        }
    }

    private void solve() {
        try {
            String s = sc.next();
            String t = sc.next();
            int count = 0;
            for (int i = 0; i < s.length(); i++) {
                if (!s.substring(i, i + 1).equals(t.subSequence(i, i + 1)))
                    count++;
            }
            System.out.println(count);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}


Measured memory_bytes: 52188
N,M = map(int,input().split())
D = sorted([list(map(int,input().split())) for n in range(N)])
ans = 0
num = 0

for a,b in D:
  num+=b
  ans+=a*b
  if M<=num:
    ans-=a*(num-M)
    break

print(ans)

Measured memory_bytes: 28280
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> x(n);
    for(int i = 0; i < n; ++i){
        cin >> x.at(i);
    }
    ll ans = 0;
    for(int i = 0; i < n - 1; ++i){
        ans += min(b, a * (x.at(i + 1) - x.at(i)));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
import sys
import itertools as it
input = sys.stdin.readline

N, M, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

AS = list(it.accumulate(A))
BS = list(it.accumulate(B))
AS.insert(0,0)
BS.insert(0,0)
max = 0
j = M
for i in range(N+1):
    if AS[i] > K:
        break
    while j >= 0:
        if AS[i] + BS[j] <= K:
            if max < i + j:
                max = i + j
            break
        j -= 1

print(max)

Measured memory_bytes: 124244
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        char a[] = sc.next().toCharArray();
        int len = a.length;

        Map<Character, TreeSet<Integer>> map = new HashMap<>();
        for (int i = 0; i < len; i++) {
            map.putIfAbsent(a[i], new TreeSet<>());
            map.get(a[i]).add(i + 1);
        }

        int data[] = new int[len + 1];
        BitSet bset = new BitSet();
        data[len] = 0;
        for (int i = len - 1; i >= 0; i--) {
            bset.set(a[i] - 'a');
            data[i] = data[i + 1];
            if (bset.cardinality() == 26) {
                bset.clear();
                data[i]++;
            }
        }

        int p = 0;
        int ansLen = data[0] + 1;
        char ans[] = new char[ansLen];
        for (int i = 0; i < ansLen; i++) {
            for (char c = 'a'; c <= 'z'; c++) {
                if (!map.containsKey(c)) {
                    ans[i] = c;
                    p = len + 1;
                    break;
                } else {
                    Integer next = map.get(c).higher(p);
                    if (next == null || (data[p] - data[next] == 1)) {
                        ans[i] = c;
                        p = getOrDefault(next, len + 1);
                        break;
                    }
                }
            }
        }

        System.out.println(new String(ans));
    }

    private int getOrDefault(Integer n, int def) {
        return n == null ? def : n;
    }

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


Measured memory_bytes: 49584
import heapq

N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*N
for i in range(N):
    he=[]
    if i == 0:
        dp[i] = 0
    else:
        for j in range(K):
            heapq.heappush(he, dp[i-(j+1)]+abs(h[i]-h[i-(j+1)]) if i-(j+1) >= 0 else float('inf'))
        dp[i] = heapq.heappop(he)
print(dp[N-1])


Measured memory_bytes: 56928
#include <stdio.h>

int main()
{
  int n,x,i;

  scanf("%d",&n);
  
  for(i = 1; i <= n; i++)
  {
    x = i;
    if(x % 3 == 0)
    {
      printf(" %d",i);
    }
    else
    {
      while(x != 0)
      {
        if(x % 10 == 3) 
        {
          printf(" %d",i);
          break;
        }
        x /= 10;      
      }
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vl;typedef vector<vl> vvl;typedef pair<ll,ll> pl;typedef vector<pl> vp;const ll INF=1001001001;const ll LINF=1001001001001001001;const ll D4[]={0,1,0,-1,0};const ll D8[]={0,1,1,0,-1,-1,1,-1,0};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;}
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()

void f(vl &c,ll l, ll r){
    if(r-l<=2)return;
    ll N=r-l;
    ll t=1;
    while(t*2<N)t*=2;
    
    ll diff=N-t;
    fore(i,l+diff,r-diff-1)c[i]=0;
    f(c,l,l+diff);
    f(c,r-diff-1,r);
}
void solve(long long N, string a){
    vl b0(N);
    rep(i,N)b0[i]=a[i]-'0';
    N--;
    vl b(N);
    rep(i,N)b[i]=abs(b0[i]-b0[i+1]);

    bool con1=0;
    rep(i,N)if(b[i]==1)con1=1;
    if(con1){
        rep(i,N)if(b[i]==2)b[i]=0;
    }else{
        rep(i,N)if(b[i]==2)b[i]=1;
    }
    vl c(N,1);
    //f(c,0,N);
    rep(i,N){
        c[i]=(N-1==(i|(N-1-i))?1:0);
    }

    ll ans=0;
    rep(i,N){
        ans=(ans+b[i]*c[i])%2;
    }
    if(!con1)ans*=2;
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    string a;cin>>a;
    solve(N, std::move(a));
}


Measured memory_bytes: 24836
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define INF 0x3f3f3f3f
const int maxn=1e5+10;
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
bool ab[maxn],ac[maxn],bc[maxn];
bool match(char c1,char c2)
{
    return c1=='?'||c2=='?'||c1==c2;
}

int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
    string a,b,c;
    cin>>a>>b>>c;
    int A=a.length(),B=b.length(),C=c.length();
    _rep(i,0,A-1)
    {
        _rep(j,0,B-1)
            if(!match(a[i],b[j]))
                ab[i-j+4000]=true;
        _rep(j,0,C-1)
            if(!match(a[i],c[j]))
                ac[i-j+4000]=true;
    }
    _rep(i,0,B-1)
        _rep(j,0,C-1)        
            if(!match(b[i],c[j]))
                bc[i-j+4000]=true;
    int M=2000,ans=3*M;
    for(int i=-2*M;i<=2*M;i++)
        for(int j=-2*M;j<=2*M;j++)
        {
            if(!ab[i+4000]&&!ac[j+4000]&&!bc[j-i+4000])
            {
                int L=min(0,min(i,j));
                int R=max(A,max(B+i,C+j));
                ans=min(ans,R-L);
            }
        }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rusha() scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb() scanf("%d",&t);while(t--)
#define debug(x) cout<<"LBWNB    "<<x<<"---\n"
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define p() puts("")
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
using namespace std;
typedef long long ll;
const int mod=998244353;
const int inf=1e9+7;
const int maxn=2e5+10;
int t,n,m,k;
int a[12][1024];
int b[12][1024];
int main(){
    scanf("%d%d%d",&n,&m,&k);
    rep(i,1,n) rep(j,1,m) scanf("%1d",&a[i][j]);
    int g=(1<<n)-1;
    int sum=inf;
    rep(p,0,g){
         rep(i,1,n) rep(j,1,m) b[i][j]=0;
         int d=1,s=0;
         rep(i,1,n){
            rep(j,1,m) b[d][j]+=a[i][j];
            if(p&(1<<(i-1))) d=i+1,s++;
         }
         ///printf("%d:\n",p);
         ///rep(i,1,n) {rep(j,1,m) printf("%d",b[i][j]);puts("");}
         rep(j,1,m){
             bool f=1,ff=0;
             rep(i,1,n){
                if(b[i][j]>k) ff=1;
                if(b[i][j]+b[i][j-1]>k) f=0;
            }
            if(ff) {s=inf;break;}
            if(f)  rep(i,1,n) b[i][j]+=b[i][j-1];
            else s++;
         }
         ///printf("%d:%d\n\n",p,s);
         sum=min(sum,s);
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(){
	int D;
	scanf("%d", &D);
	if(D == 25){
		printf("Christmas\n");
	}
	else if(D == 24){
		printf("Christmas Eve\n");
	}
	else if(D == 23){
		printf("Christmas Eve Eve\n");
	}
	else{
		printf("Christmas Eve Eve Eve\n");
	}
	return 0;
}

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

public class Main{

	public static void main(String[] args) {
		ArrayList<Integer> rows = new ArrayList<>();
		ArrayList<Integer> columns = new ArrayList<>();
		Scanner sc = new Scanner(System.in);
		boolean flag = true;
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			if (H >= 1 && H <= 300 && W >= 1 && W <= 300) {
				rows.add(H);
				columns.add(W);
			} else {
				flag = false;
				break;
			}
		}
		if (flag == true) {
			for (int i = 0; i < rows.size(); i++) {
				for (int j = 0; j < rows.get(i); j++) {
					for (int k = 0; k < columns.get(i); k++) {

						System.out.print("#");
					}

					System.out.println();
				}

				System.out.println();
			}
		}

	}

}

Measured memory_bytes: 32792
memo = [2, 1] + 85 * [0]
def luca(n):
	if memo[n] != 0 :
		return memo[n]
	else :
		memo[n] = luca(n - 1) + luca(n - 2)
		return memo[n]

n = int(input())
print(luca(n))


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

int main(){
  int a, b, k;
  cin >> a >> b >>k;
  int count = 0;
  for (int i = min(a, b); i >0; i--){
    if (a%i ==0 && b%i ==0){
      count += 1;
      if( count == k){
        cout << i << endl;
        break;
      }
      
    }
    
    else
      continue;
  }
}
  
      
      
   


Measured memory_bytes: 256
from collections import deque
inf=10**5


def BFS():
    color=[["white" for _ in range(w*2-1)] for _ in range(h*2-1)]
    D=[[inf for _ in range(w*2-1)] for _ in range(h*2-1)]

    color[0][0]="gray"
    D[0][0]=1

    queue=deque([[0,0]])
    while len(queue)>0:
        a,b=queue.popleft()
        for c,d in [[-1,0],[1,0],[0,-1],[0,1]]:
            X,Y=a+c*2,b+d*2
            if 0<=X<h*2-1 and 0<=Y<w*2-1:
                if C[X-c][Y-d]=="|" or C[X-c][Y-d]=="_" or color[X][Y]!="white":continue
                else:
                    color[X][Y]="gray"
                    D[X][Y]=min(D[a][b]+1,D[X][Y])
                    queue.append([X,Y])
        color[a][b]="black"

    return D[-1][-1]


while 1:
    w,h=map(int,input().split())
    if w==0 and h==0:break
    C=[["." for _ in range(w*2-1)] for _ in range(h*2-1)]
    for i in range(h*2-1):
        for j,k in enumerate(list(map(int,input().split()))):
            if i%2==0:C[i][1+j*2]="|" if k==1 else "."
            else:C[i][j*2]="_" if k==1 else "."
    D=BFS()
    print(D if D!=inf else 0)


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int n = read();
  vi w;
  REP(i, n) w.PB(read());
  vi foward;
  int tmp = 0;
  REP(i, n - 1) {
    tmp += w[i];
    foward.PB(tmp);
  }
  tmp = 0;
  vi backward;
  for (int i = n - 1; i > 0; i--) {
    tmp += w[i];
    backward.PB(tmp);
  }
  int ans = 100000000;
  REP(i, n - 1) { chmin(ans, abs(foward[i] - backward[n - 2 - i])); }
  print(ans);
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>=13){
		printf("%d\n",b);
	}else if(a<=5){
		printf("0\n");
	}else{
		printf("%d\n",b/2);
	}
	return 0;
}

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


int main(){
    
	double a,b,x;
	cin>>a>>b>>x;
	x/=a;
	
	double ng = 0.0;
	double ok = M_PI/2.0;
	
	for(int i=0;i<10000;i++){
		double mid = (ng+ok)/2.0;
		double X = atan2(a,b);
		if(X>mid){
			//triangle
			double r = b/cos(mid);
			double S = r * b * sin(mid) / 2.0;
			if(S>x)ok=mid;
			else ng=mid;
		}
		else{
			double aa = a/tan(mid);
			double S = a*b-aa*a/2.0;
			if(S>x)ok=mid;
			else ng=mid;
		}
	}
	
	cout<<fixed<<setprecision(15)<<(90.0-ok*180/M_PI)<<endl;
	
	
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
    int i,j;
    int t;
    cin >> t;
    rep(_,t){
        int n,m;
        cin >> m >> n;
        vector<pii> ans;//(m,n)の約数
        ans.push_back(pii(1,0));
        ans.push_back(pii(0,1));
        ans.push_back(pii(-1,0));
        ans.push_back(pii(0,-1));
        ans.push_back(pii(m,n));
        ans.push_back(pii(-n,m));
        ans.push_back(pii(-m,-n));
        ans.push_back(pii(n,-m));
        int sum = n*n + m*m;
        int lim = sqrt(sum)+1;
        bool c = true;
        loop(i,1,lim)if(sum%i==0){
            int a = i;
            int b = sum/i;
            rep(x,sqrt(a)+1){
                int y = sqrt(a-x*x);
                if(x*x + y*y == a){
                    if((x*m+y*n)%(x*x+y*y) == 0 && (x*n-y*m)%(x*x+y*y) == 0){
                        bool o = true;
                        rep(j,8){
                            if(ans[j].first == x && ans[j].second == y)o = false;
                        }
                        if(o){
                            c = false;
                        }
                    }
                }
            }
            rep(x,sqrt(b)+1){
                int y = sqrt(b-x*x);
                if(x*x + y*y == b){
                    if((x*m+y*n)%(x*x+y*y) == 0 && (x*n-y*m)%(x*x+y*y) == 0){
                        bool o = true;
                        rep(j,8){
                            if(ans[j].first == x && ans[j].second == y)o = false;
                        }
                        if(o){
                            c = false;
                        }
                    }
                }
            }
        }
        if(c){
            cout << "P" << endl;
        }else{
            cout << "C" << endl;
        }
    }
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long int ll;
typedef double d;
typedef pair<int, int> pr;
typedef priority_queue<int> p_int_max;
typedef priority_queue<int, vector<int>, greater<int>> p_int_min;

char c;
int a, b;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    rep(i, 3)
    {
        cin >> c;
        if (c == 'A')
            a++;
        else if (c == 'B')
            b++;
    }
    if (a && b)
        cout << "Yes\n";
    else
        cout << "No\n";
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        sc.useDelimiter(",");
//        DecimalFormat df = new DecimalFormat("0.00000000");
        long n = Long.parseLong(sc.next());
        long k = Long.parseLong(sc.next());
        long b = n / k;
        List<Long> digits = new ArrayList<>();
        if (b > 0) digits.add(n % k);
        while (b >= k) {
            b /= k;
            digits.add(b % k);
        }
        out.println(digits.size() + 1);
        out.flush();
    }
}

Measured memory_bytes: 21844
a=int(input())
if a==1 or a==8 or a==15 or a==22 or a==29:
    print("fri")
if a==2 or a==9 or a==16 or a==23 or a==30:
    print("sat")
if a==3 or a==10 or a==17 or a==24:
    print("sun")
if a==4 or a==11 or a==18 or a==25:
    print("mon")
if a==5 or a==12 or a==19 or a==26:
    print("tue")
if a==6 or a==13 or a==20 or a==27:
    print("wed")
if a==7 or a==14 or a==21 or a==28:
    print("thu")


Measured memory_bytes: 5592
# C


S = input()
N = len(S)
# 回分判定
ss = ""
for s in S:
    if s == 'x':
        pass
    else:
        ss += s
if ss != ss[::-1]:
    print(-1)
    exit()
if ss == "":
    print(0)
    exit()
# 真ん中を決める
# x の位置と個数を求める
n = len(ss)
if n % 2 == 0:
    cnt = 0
    for i in range(n//2+1):
        for j in range(cnt, N):
            if S[j] == "x":
                continue
            else:
                cnt = j+1
                break
        if i == n//2-1:
            left_center = cnt-1
    right_center = cnt-1
    # 真ん中の分を先に計算する
    ans = (abs(right_center - left_center) % 2)
    # centerから両側に展開していく
    count = 0
    x_left = []
    x_right = []
    for i in range(left_center):
        if S[left_center-1 - i] == 'x':
            count += 1
        else:
            x_left.append(count)
            count = 0
    x_left.append(count)
    count = 0
    for i in range(right_center+1, N, 1):
        if S[i] == 'x':
            count += 1
        else:
            x_right.append(count)
            count = 0
    x_right.append(count)
    ans = 0
    for i in range(len(x_left)):
        ans += abs(x_left[i] - x_right[i])
    print(ans)
else:
    cnt = 0
    for i in range(n//2+1):
        for j in range(cnt, N):
            if S[j] == "x":
                continue
            else:       # S[j] != "x" なら ss[i] と S[j] は一致する
                cnt = j + 1
                break
    center = cnt-1
    # print(center)
    # center から両側に展開していき，center からの位置と x の個数を求める
    distans = 0     # x 以外の文字が出るたびに更新する
    count = 0
    x_left = []
    x_right = []
    for i in range(center):
        if S[center-1 - i] == "x":
            count += 1
        else:
            x_left.append([distans, count])
            distans += 1
            count = 0
    x_left.append([distans, count])
    distans = 0
    count = 0
    for i in range(center+1, N):
        if S[i] == "x":
            count += 1
        else:
            x_right.append([distans, count])
            distans += 1
            count = 0
    x_right.append([distans, count])
    # print(x_left)
    # print(x_right)
    ans = 0
    for i in range(len(x_left)):
        ans += abs(x_left[i][1] - x_right[i][1])
    print(ans)


Measured memory_bytes: 16604
#include<stdio.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
int n,m;
char s[120][120];
inline bool cheh(int x){
	fo(i,1,m) if (s[x][i]=='#') return 0;
	return 1;
}
inline void delh(int x){
	fo(i,x,n-1) fo(j,1,m) s[i][j]=s[i+1][j];
	n--;
}
inline bool chel(int x){
	fo(i,1,n) if (s[i][x]=='#') return 0;
	return 1;
}
inline void dell(int x){
	fo(j,x,m-1) fo(i,1,n) s[i][j]=s[i][j+1];
	m--;
}
int main(){
	scanf("%d%d",&n,&m);
	fo(i,1,n) scanf("%s",s[i]+1);
	while (1){
		bool ok=0;
		fo(i,1,n) if (cheh(i)){
			delh(i);
			ok=1;//continue;//null
			break;//
		}
		fo(i,1,m) if (chel(i)){
			dell(i);
			ok=1;//continue;//null
			break;//
		}
		if (!ok) break;
	}
	//printf("%d %d\n",n,m);
	fo(i,1,n){
		fo(j,1,m) putchar(s[i][j]);
		putchar('\n');
	}
	return 0;
} 

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

using namespace std;

int main()
{
    vector<int> ABC(3);
    int index;
    cin >> ABC[0] >> ABC[1] >> ABC[2];

    auto itr = find(ABC.begin(), ABC.end(), 5);
    if (itr != ABC.end()) {
        index = distance(ABC.begin(), itr);
        ABC.erase(ABC.begin()+index);
    }

    itr = find(ABC.begin(), ABC.end(), 7);
    if (itr != ABC.end()) {
        index = distance(ABC.begin(), itr);
        ABC.erase(ABC.begin() + index);
    }

    itr = find(ABC.begin(), ABC.end(), 5);
    if (itr != ABC.end()) {
        index = distance(ABC.begin(), itr);
        ABC.erase(ABC.begin() + index);
    }

    if (ABC.size() == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3600
H, W = map(int, input().split())
maze = [input() for _ in range(H)]
p_flg = [[0]*W for _ in range(H)]
dyx = [(-1,0),(1,0),(0,-1),(0,1)]

def bfn(y,x,cnt):
    stack = [(y,x,cnt)]
    p_flg[y][x] = cnt
    while stack:
        sy, sx, cnt= stack.pop(0)
        cnt += 1
        for dy, dx in dyx:
            ny, nx = sy+dy, sx+dx
            if ny == H-1 and nx == W-1:
                return cnt
            elif 0<=ny<H and 0<=nx<W:
                if maze[ny][nx] !="#" and not p_flg[ny][nx]:
                    p_flg[ny][nx] = cnt
                    stack.append((ny,nx,cnt))
    return 0

def main():
    n_obs = 0
    for h in range(H):
        for w in range(W):
            if maze[h][w] == "#":
                n_obs += 1
    n_path = bfn(0,0,1) -1
    if n_path == -1:
        print(-1)
        return
    else:
        ans = H*W - n_obs - n_path -1
        print(ans)

if __name__ == "__main__":
    main()

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

int main(){
  int n; cin >> n;
  int p[n+1], a[n+1], b[n+1];
  for(int i=1; i<=n; i++){
    cin >> p[i];
    a[i] = i*n;
    b[i] = n*(n-i+1);
  }
  
  for(int i=1; i<=n; i++){
    b[p[i]] += i-1;
  }

  for(int i=1; i<=n; i++) 
    cout << a[i] << " ";
  cout << endl;

  for(int i=1; i<=n; i++)
    cout << b[i] << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long
#define maxn 100005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
ll ans;
int m;
multiset<int> pm;
void work(vector<pi> g, int tp) {
	sort(g.begin(), g.end());
	pm.clear();
	int mx = 0, cnt = 0;
	for (int i = 0; i < g.size(); i++) {
		if (pm.size() && ((*pm.begin()) < g[i].fi)) {	
			#define iter multiset<int>::iterator
			iter x = pm.lower_bound(g[i].fi);
			x--;
			pm.erase(x);
		}
		else {
			cnt++, mx = g[i].fi;
		} 	
		pm.insert(g[i].se);
	}
//	cout << cnt << endl;
	if (cnt % 2 == tp) {
		ll nans = 1ll * m * (cnt - 1) + (m - mx);
		ans = min(ans, nans);
	}
}
int main() {
	ans = 1e18;
	int n;
	cin >> n >> m;
	vector<pi> r(n);
	for (int i = 0; i < n; i++)
		scanf("%d%d", &r[i].fi, &r[i].se);
	work(r, 0);
	for (int i = 0; i < n; i++)
		swap(r[i].fi, r[i].se), 
		r[i].fi = m - r[i].fi, 
		r[i].se = m - r[i].se;
	work(r, 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 15236
a=input()

def dfs(i,f):
    if i==3:
        if eval(f)==7:
            print(f+'=7')
            exit()
    else:
        dfs(i+1,f+'+'+a[i+1])
        dfs(i+1,f+'-'+a[i+1])

print(dfs(0,a[0]))

Measured memory_bytes: 3060
import sys
from functools import reduce
import copy
import math


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    S = inputs[0]
    K = int(inputs[1])

    sets = set()
    for i in range(len(S)):
        j = i
        while j < len(S) and j - i <= K:
            j += 1
        sets.add(S[i:j])
    new_sets = set()

    for k in sets:
        for i in range(len(k)):
            j = i
            while j < len(k) and j - i <= K:
                j += 1
                new_sets.add(k[i:j])
    l = list(new_sets)
    l.sort()
    return l[K-1]


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(2))
    print(ret)


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

//#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

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

#define INF   (1e9 + 7)
#define MAX_N (50)

int N;
string S[MAX_N];
int COUNT[26];

void solve() {
  for (int i = 0; i < 26; i++) COUNT[i] = 1000;

  for (int i = 0; i < N; i++) {
    int cnt[26];
    for (int j = 0; j < 26; j++) cnt[j] = 0;
    for (int j = 0; j < S[i].size(); j++) cnt[S[i][j] - 'a']++;
    for (int j = 0; j < 26; j++) COUNT[j] = min(COUNT[j], cnt[j]);
    for (int j = 0; j < 26; j++) debug_printf("%d ", COUNT[j]);
    debug_printf("\n");
  }
  for (int j = 0; j < 26; j++) {
    for (int k = 0; k < COUNT[j]; k++) {
      printf("%c", j + 'a');
    }
  }
  printf("\n");
}

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) cin >> S[i];

  solve();

  return 0;
}


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


void solve(long long T, long long X){
  cout << T * 1.0 / X << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long T;
    scanf("%lld",&T);
    long long X;
    scanf("%lld",&X);
    solve(T, X);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<int > vi;

int main() {
	ll A[3];
	cin >> A[0] >> A[1] >> A[2];
	sort(A, A + 3);
	for (int i = 0; i < 3; i++) {
		if (A[i] % 2 == 0) {
			cout << "0" << endl;
			return 0;
		}
	}
	cout << A[1] * A[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b%mod;
}
signed main(){
	int n;
	string s,t;
	cin>>n>>s>>t;
	f(i,n){
		cout<<s[i]<<t[i];
	}
	cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s,t;
  cin>>s>>t;
  if(s.size()>t.size())cout<<"GREATER"<<endl;
  if(s.size()<t.size())cout<<"LESS"<<endl;
  if(s.size()==t.size()){
      if(s>t)cout<<"GREATER"<<endl;
      if(s<t)cout<<"LESS"<<endl;
      if(s==t)cout<<"EQUAL"<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

//二項係数
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int N,M;
    cin>>N>>M;
    COMinit();
    ll ans=1;
    for(ll i=M;i>=M-N+1;i--){
        ans*=i;
        ans%=MOD;
    }
    ll mul=0;
    rep(i,N+1){
        ll now=-1;
        if(i%2==0)now=1;
        now*=COM(M-i,N-i);now%=MOD;
        now*=finv[i];now%=MOD;
        mul+=now;
        mul%=MOD;
    }
    mul*=fac[N];
    mul%=MOD;
    ans*=mul;
    ans%=MOD;
    if(ans<0)ans+=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 15520
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>

int a,b;

int main(){
    cin>>a>>b;
    if(a>=10||b>=10){
        cout<<-1<<endl;
    }
    else{
        cout<<a*b<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<cstring>
#include<string>
using namespace std;
int db(int n){
	int t=0;
	while(n){
		t++;
		n/=10;
	}
	int w=1;
	for(int i=1;i<=t;i++){
		w*=10;
	}
	return w;
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int a,b,c;
	scanf("%d %d",&a,&b);
	c=db(b)*a+b;
	int d=(int)sqrt(c*1.0);
	if(d*d==c)printf("Yes\n");
		else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

vll p{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 57, 71, 73, 79, 83, 89, 97};
vll fac(101, 0);

void fact(ll n){
    ll i = 2;
    while(n >= 2){
        if(n % i == 0){
            n /= i;
            fac[i]++;
            i = 2;
        }else{
            i++;
        }
    }
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    repr(i, 1, n+1){
        fact(i);
    }
    ll ans = 0;
    rep(i, 101)repr(j, i+1, 101)rep(k, 101){
        if(j == k || k == i) continue;
        if(fac[i] >= 4 && fac[j] >= 4 && fac[k] >= 2) ans++;
    }
    rep(i, 101)rep(j, 101){
        if(i == j) continue;
        if(fac[i] >= 14 && fac[j] >= 4) ans++;
        if(fac[i] >= 24 && fac[j] >= 2) ans++;
    }
    rep(i, 101){
        if(fac[i] >= 74) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define grt() greater<int>()
#define grtl() greater<long long>()

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

    int fb;

    ll cnt;

    if (b > n)
    {
        cnt = n;
    }
    else
    {
        cnt = b;
        for (ll i = cnt; i > 0; i --)
        {
            fb = i / b;

            if (fb < 1)
            {
                break;
            }
            cnt--;
        }
    }

    cout << (cnt * a) / b - a * (cnt / b) << endl;
}

Measured memory_bytes: 3612
#include <iostream>

using namespace std;

int gcd(int n,int m){
  if (n%m==0) {
    return m;
  }
  if (m%n==0) {
    return n;
  }
  if (m>n) {
    return gcd(n,m%n);
  } else {
    return gcd(m,n%m);
  }
}

int main(){
  long long i,N,M;
  cin >> N >> M;
  string S,T;
  cin >> S;
  cin >> T;
  long long g=gcd(N,M);
  int f=0;
  for (i=0;i<g;i++) {
    if (S[i*(N/g)]!=T[i*(M/g)]) {
      f=1;
      break;
    }
  }
  if (f==0) {
    cout << N*M/g << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main()
{
	int n,m;
	int x[105]={0};
	int a[105],b[105];
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		x[a[i]]++;x[b[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		printf("%d\n",x[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	long long a, b, c;

	std::cin >> a >> b >> c;

	long long count = 0;

	if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
		std::cout << 0 << std::endl;
		return 0;
	}

	long long sum = a + b + c;

	while (true) {
		a = (sum - a) / 2;
		b = (sum - b) / 2;
		c = (sum - c) / 2;

		count++;
		if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
			break;
		}

		if (a == b && a == c) {
			std::cout << -1 << std::endl;
			return 0;
		}
	}

	std::cout << count << std::endl;

	return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
  input! {
    X: u64,
  }

  for A in -118..=119 {
    for B in -119..=118 {
      if (A as f64).powi(5) - (B as f64).powi(5) == X as f64 {
        println!("{} {}", A, B);
        return;
      }
    }
  }
}


Measured memory_bytes: 2136
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int[] menus = new int[5];
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	
	static boolean read(){
		if( !sc.hasNext() )return false;
		for(int i = 0; i < menus.length; i++){
			menus[i] = sc.nextInt();
		}
		return true;
	}
	
	static void solve(){
		int pasta = Math.min(menus[0], Math.min(menus[1], menus[2]));
		int juice = Math.min(menus[3], menus[4]);
		System.out.println(pasta + juice -50);
	}

}

Measured memory_bytes: 17172
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
	for (T& x: vec) { is >> x; }
	return is;
}

//ei1333さんのGitHubから https://ei1333.github.io/luzhiled/
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
//ここまで

int main() {
	int N, Q;
	cin >> N;
	cin >> Q;
	vector< int > A(N);
	cin >> A;
	BinaryIndexedTree<int> bit(N);
	int colr[N+1] = {};
	REP(i, N+1) colr[i] = -1;
	vector<tuple<int, int, int>> qs;
	for(int i = 0; i < Q; i++) {
		int l, r;
		cin >> l >> r;
		qs.push_back(make_tuple(l, r, i));
	}
	sort(qs.begin(), qs.end(), [](const tuple<int,int,int>& x , const tuple<int,int,int>& y){return get<1>(x) < get<1>(y);});
	int anss[Q] = {};
	int nowi = 0, nowq = 0;
	while(nowi < N || nowq < Q ){
		while(nowi < get<1>(qs[nowq])){
			if(colr[A[nowi]]>=0) bit.add(colr[A[nowi]], -1);
			bit.add(nowi, 1);
			colr[A[nowi]] = nowi;
			nowi++;
		}
		int l, r, ind;
		tie(l, r, ind) = qs[nowq];
		anss[ind] = bit.sum(r-1) - bit.sum(l-2);
		/*
		cout << ind << " " << l << " " << r << " " ;
		REP(i, N) cout << bit.sum(i) - bit.sum(i-1) << " ";
		cout << bit.sum(l-2) << " " << bit.sum(r-1) << endl;
		*/
		nowq++;
	}
	for(int i = 0; i < Q; i++) {
		cout << anss[i] << "\n";
	}
}

Measured memory_bytes: 17480
n = int(input())
li = []
ans = 0.0
x = 0

for i in range(n):
    li.append(list(map(int,input().split())))

for i in range(n-1):
    for j in range(i+1,n):
        ans += 2*(n-1)*(((li[i][0]-li[j][0])**2+(li[i][1]-li[j][1])**2))**0.5
        x += 1

print(ans/x/2)

Measured memory_bytes: 3188
#include<stdio.h>

int main(){

int C=0;
for(int i=1;i<1000;i++)
{if(i%3==0)C+=200;else C+=195;}


int n,y,m,d;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d%d%d",&y,&m,&d);
if(y==0&&m==0&&d==0)break;

int c=0;
for(int i=1;i<y;i++)
{if(i%3==0)c+=200;else c+=195;}

for(int i=1;i<m;i++){
if(y%3==0)c+=20;
else if(i%2==0)c+=19;
else c+=20;
}
c+=d;
int s=C-c+1;

printf("%d\n",s);
}
return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    ii(x); string ans = "ARC";
    if(x < 1200) ans = "ABC"; out(ans);
}

Measured memory_bytes: 256
/*
 *Author : zsenshi
 DP 
 */
#include <bits/stdc++.h> //Only for gcc compilers
#define mt make_tuple
#define eb emplace_back
#define pb push_back
#define dg(x) cout << #x << ":"<<x<<endl
#define dg2(x,y) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<endl
#define dg3(x,y,z) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<endl
#define dg4(x,y,z,zz) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<' '<<#zz<<':'<<zz<<endl
#define rep(i,begin,end) for(__typeof(end) i = (begin)-((begin) > (end)); i != (end) - ((begin) > (end)); i += 1-2*((begin) > (end)))
using namespace std;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vector<pii>> vvpi;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  cout << n*n*n << "\n";
}


Measured memory_bytes: 256