akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(){
    bool is_prime[60000];
    is_prime[0] = is_prime[1] = false;
    for(int i=2; i<60000; i++){
        is_prime[i] = true;
    }

    for(int i=2; i*i<60000; i++){
        if(is_prime[i]){
            for(int j=i*i; j<60000; j+=i){
                is_prime[j] = false;
            }
        }
    }
    while(true){
        int n;
        cin>>n;
        if(n==0)break;
        int count=0;
        for(int i=0;i<=n/2;i++){
            if(is_prime[i]){
                if(is_prime[n-i])
                    count++;
            }
        }
        cout<<count<<endl;
    }
    return 0;
}



Measured memory_bytes: 3064
//minamoto
#include<bits/stdc++.h>
#define R register
#define inline __inline__ __attribute__((always_inline))
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=3005,M=2e5+5;
struct node{
	int x,y;
	inline bool operator <(const node &b)const{return x+y>=b.x+b.y;}
}p[N];
int fac[M],ifac[M],f[N],g[N],h,w,n,m,res,t;
inline int calc(R int x,R int y){return 1ll*fac[x+y]*ifac[x]%P*ifac[y]%P;}
int main(){
	scanf("%d%d%d",&h,&w,&n),m=h+w;
	fp(i,1,n)scanf("%d%d",&p[i].x,&p[i].y);
	fac[0]=ifac[0]=1;fp(i,1,m)fac[i]=mul(fac[i-1],i);
	ifac[m]=ksm(fac[m],P-2);fd(i,m-1,1)ifac[i]=mul(ifac[i+1],i+1);
	p[++n]={1,1},p[++n]={h,w},sort(p+1,p+1+n);
	f[1]=1;
	fp(i,2,n)fp(j,1,i-1)if(p[j].x>=p[i].x&&p[j].y>=p[i].y)
		t=calc(p[j].x-p[i].x,p[j].y-p[i].y),
		upd(f[i],mul(g[j],t)),
		upd(g[i],mul(f[j],t));
	printf("%d\n",dec(g[n],f[n]));
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back

using namespace std;

typedef pair< int, int > P;
typedef pair< int, P > iP;
typedef long long LL;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const int MOD = (10^9 + 7);

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int c1, c2, c3, c4;
    c1 = c2 = c3 = c4 = 0;
    for(int i = 0; i < 3; ++i) {
        int a, b;
        cin >> a >> b;
        if( a == 1 || b == 1 ) c1++;
        if( a == 2 || b == 2 ) c2++;
        if( a == 3 || b == 3 ) c3++;
        if( a == 4 || b == 4 ) c4++;
    }
    if( c1 == 3 || c2 == 3 || c3 == 3 || c4 == 3 ) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 256
Q = {
    1: 2,
    2: 5,
    3: 5,
    4: 4,
    5: 5,
    6: 6,
    7: 3,
    8: 7,
    9: 6,
}

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

# 桁数の最大
dp = [-1] * (N + 1)
dp[0] = 0

for a in A:
    for i in range(Q[a], N + 1):
        if dp[i - Q[a]] >= 0:
            dp[i] = max(dp[i], dp[i - Q[a]] + 1)

# 整数の復元
ans = ''

# 大きな数から試す
A.sort(reverse=True)

i = N
while i:
    for a in A:
        if i - Q[a] >= 0 and dp[i - Q[a]] == dp[i] - 1:
            ans += str(a)
            i -= Q[a]
            break

print(ans)

Measured memory_bytes: 41964
#include <stdio.h>
#include <stdlib.h>
int main()
{
  int a,b,c,d,min;
  int m=0,n=0,z=0,x=0,q=0,w=0;
  scanf("%d%d%d%d%*c",&a,&b,&c,&d);
  m=a+c;
  n=a+d;
  z=b+c;
  x=b+d;
  q=maxi(m,n);
  w=maxi(z,x);
  min=maxi(q,w);
  printf("%d",min);
}
maxi(int x,int y)
{
    return(x<y?x:y);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<complex>
using namespace std;

int main(){
    char str[102];
    int len,n=0,ans=0;
    while (fgets(str,102,stdin)!=NULL) {
        len=strlen(str)-1;
        for (int i=0;i<len;++i) {
            if(str[i]>='0' && str[i]<='9'){
                n*=10;
                n+=str[i]-'0';
            } else {
                ans+=n;
                n=0;
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3036
using System;
using System.Linq;
using static System.Console;
using static System.Math;
class E { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split().Select(x => int.Parse(x)).ToArray();
	const long Mod = 1000000007;
	public K()
	{
		var N = F();
		int[] A = G(), B = G();
		var a = 1L;
		for (var i = 0; a != 0 && i < N; i++)
		{
			var l = i == 0 || A[i - 1] < A[i] ? A[i] : 0;
			var r = i == N - 1 || B[i] > B[i + 1] ? B[i] : 0;
			if (l == 0 && r == 0) a = a * Min(A[i], B[i]) % Mod;
			else a *= (r == 0 || r <= A[i]) && (l == 0 || l <= B[i]) ? 1 : 0;
		}
		WriteLine(a);
	}
}

Measured memory_bytes: 25296
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Vector;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		sieve();
		
		int n=s.nextInt();
		
		int[] arr=new int[n];
		
		for(int i=0;i<n;i++)
		{
			arr[i]=s.nextInt();
		}
		
		int gcd=arr[0];
		
		for(int i=0;i<n;i++)
		{
			gcd=gcd(gcd,arr[i]);
		}
		
		if(gcd>1)
		{
			System.out.println("not coprime");
		}
		else if(gcd==1)
		{
			HashMap<Integer,Integer> map=new HashMap<>();
			
			int p=0;
			
			for(int i=0;i<n;i++)
			{
				HashMap<Integer,Integer> temp=getFactorization(arr[i]);
				
				for(Map.Entry<Integer,Integer> entry:temp.entrySet())
				{
					if(map.containsKey(entry.getKey()))
					{
						p=1;
						break;
					}
					else
					{
						map.put(entry.getKey(), 1);
					}
				}
				
				if(p==1)
				{
					break;
				}
			}
			
			if(p==1)
			{
				System.out.println("setwise coprime");
			}
			else
			{
				System.out.println("pairwise coprime");
			}
		}
		
	}
	
	public static int gcd(int a,int b)
	{
		if(b==0)
			return a;
		
		return gcd(b,a%b);
	}
	
	static final int MAXN = 1000001; 
    
    // stores smallest prime factor for every number 
    static int spf[] = new int[MAXN]; 
       
    // Calculating SPF (Smallest Prime Factor) for every 
    // number till MAXN. 
    // Time Complexity : O(nloglogn) 
    static void sieve() 
    { 
        spf[1] = 1; 
        for (int i=2; i<MAXN; i++) 
       
            // marking smallest prime factor for every 
            // number to be itself. 
            spf[i] = i; 
       
        // separately marking spf for every even 
        // number as 2 
        for (int i=4; i<MAXN; i+=2) 
            spf[i] = 2; 
       
        for (int i=3; i*i<MAXN; i++) 
        { 
            // checking if i is prime 
            if (spf[i] == i) 
            { 
                // marking SPF for all numbers divisible by i 
                for (int j=i*i; j<MAXN; j+=i) 
       
                    // marking spf[j] if it is not  
                    // previously marked 
                    if (spf[j]==j) 
                        spf[j] = i; 
            } 
        } 
    } 
       
    // A O(log n) function returning primefactorization 
    // by dividing by smallest prime factor at every step 
    static HashMap<Integer,Integer> getFactorization(int x) 
    { 
        HashMap<Integer,Integer> map=new HashMap<>();
        
        while (x != 1) 
        { 
            map.put(spf[x],1);
            x = x / spf[x]; 
        } 
        return map; 
    } 
	
}

Measured memory_bytes: 66876
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

void solve(int n){
  int maxi=0;
  string s[n];
  for(int i=0;i<n;i++){
    cin>>s[i];
    maxi=max(maxi,(int)s[i].size());
    for(int j=s[i].size()-1;j>=0;j--){
      if(s[i][j]=='.'){s[i][j]='+';break;}
    }
  }
  
  for(int i=0;i<maxi;i++){
    int start,end;
    bool plus=false;
    for(int j=0;j<n;j++){
      if(s[j].size()<i){
	plus=false;
	continue;
      }else if(s[j][i]!='.'&&s[j][i]!='+'){
	// cout<<i<<" "<<j<<endl;
	plus=false;
      }else if(s[j][i]=='+'&&!plus){
	start=j;plus=true;
      }else if(s[j][i]=='+'&&plus){
	//cout<<"in line"<<endl;
	end=j;plus=false;
	for(int k=start+1;k<end;k++)s[k][i]='|';
	j--;
      }
    }
  }
  
  for(int i=0;i<n;i++){
    /*cout<<s[i]<<endl;*/
    for(int j=0;j<s[i].size();j++){
      if(s[i][j]!='.')cout<<s[i][j];
      else cout<<" ";
    }
    cout<<endl;
  }
}

int main(){
  int n;
  while(cin>>n,n){
    solve(n);
  }
  return 0;
}



Measured memory_bytes: 3792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

public class Program
{
    public static void Main(string[] args)
    {
        new Magatro().Solve();
    }
}

class Magatro
{
   

    private void Scan()
    {
      
    }

    public void Solve()
    {
        Scan();
        string[] line = Console.ReadLine().Split(' ');
        if (line[0].Last() == line[1].First() && line[1].Last() == line[2].First())
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 13268
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class129
    {
        static void Main()
        {
            var HW = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long H = HW[0], W = HW[1];
            if (H % 2 == 0 || W % 2 == 0)
            {
                if (H > 1 && W > 1)
                    Console.WriteLine(H * W / 2);
                else
                    Console.WriteLine(1);
            }
            else
            {
                if (W >1&&H>1)
                    Console.WriteLine(H * (W / 2) + H / 2 + 1);
                else
                    Console.WriteLine(1);
            }
        }
    }
}


Measured memory_bytes: 11348
#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
ll read()
{
	ll 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;
}
struct Point{double x,y;}p0,p1;
struct Circle{Point x;double r;}c;
Point operator +(Point a,Point b){return (Point){a.x+b.x,a.y+b.y};}
Point operator -(Point a,Point b){return (Point){a.x-b.x,a.y-b.y};}
Point operator *(Point a,double b){return (Point){a.x*b,a.y*b};}
Point operator /(Point a,double b){return (Point){a.x/b,a.y/b};}
bool operator >(Point a,Point b){return a.x>b.x||(a.x==b.x&&a.y>b.y);}
double dot(Point a,Point b){return a.x*b.x+a.y*b.y;}
double norm(Point a){return a.x*a.x+a.y*a.y;}
double abs(Point a){return sqrt(norm(a));}
void read(Point &a){a.x=read(),a.y=read();}
void read(Circle &a){read(a.x),a.r=read();}
void print(Point a){printf("%.8lf %.8lf",a.x,a.y);}
Point Project(Point p0,Point p1,Point p)
{
	Point base=p1-p0,hypo=p-p0;
	double r=dot(base,hypo)/norm(base);
	return p0+base*r;
}
pair<Point,Point>getintersection(Circle c,Point p0,Point p1)
{
	Point pr=Project(p0,p1,c.x),e=(p1-p0)/abs(p1-p0);
	double base=sqrt(c.r*c.r-norm(pr-c.x));
	return make_pair(pr+e*base,pr-e*base);
}
int main()
{
	read(c);
	int q=read();while(q--)
	{
		read(p0),read(p1);
		pair<Point,Point>p=getintersection(c,p0,p1);
		if(p.first>p.second)swap(p.first,p.second);
		print(p.first);putchar(' ');print(p.second);
		printf("\n");
	}
	return 0;
}



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

#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl

using namespace std;
typedef long long  ll;

const int N = 2e5 + 4 , MOD = 1e9 + 7;
int fact[N] , invfact[N] , H , W , k , ans[3004];
pair<int , int> BLACKCELLS[3004];

int mul(int a , int b , int m){
    return (1LL * (a % m) * (b % m)) % m;
}

int powMOD(int x , int n , int m = MOD){
    if(!n)return 1;
    int ret = 1;
    if(n & 1)ret = mul(x , powMOD(x , n - 1 , m) , m);
    else{
        int y = powMOD(x , n / 2 , m);
        ret = mul(y , y , m);
    }
    return ret;
}

int nCr(int n , int r){
    return mul(mul(fact[n] , invfact[r] , MOD) , invfact[n - r] , MOD);
}

void pre(){
    fact[0] = invfact[0] = 1;
    for(int i = 1 ; i < N ; ++i)
        fact[i] = mul(i , fact[i - 1] , MOD);

    invfact[N - 1] = powMOD(fact[N - 1] , MOD - 2 , MOD);
    for(int i = N - 2; ~i ; --i)
        invfact[i] = mul(invfact[i + 1] , i + 1 , MOD);


    for(int i = 0 ; i < k ; ++i)
        ans[i] = nCr(BLACKCELLS[i].first + BLACKCELLS[i].second , BLACKCELLS[i].first);
}



void solve(int i , int j){
    int nx = BLACKCELLS[i].first , ny = BLACKCELLS[i].second , x = BLACKCELLS[j].first , y = BLACKCELLS[j].second;
    ans[i] -= mul(nCr(nx + ny - x - y , nx - x) , ans[j] , MOD);
    if(ans[i] < 0)ans[i] += MOD;
}

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

    for(int i = 0 ; i < k ; ++i)
        cin >> BLACKCELLS[i].first >> BLACKCELLS[i].second , BLACKCELLS[i].first-- , BLACKCELLS[i].second--;

    BLACKCELLS[k++] = {H - 1 , W - 1};
    sort(BLACKCELLS , BLACKCELLS + k);

    pre();

    for(int i = 0 ; i < k ; ++i){
        for(int j = 0 ; j < i ; ++j){
            if(BLACKCELLS[i].second >= BLACKCELLS[j].second)
                solve(i , j);
        }
    }

    cout << ans[k - 1] << '\n';
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define int long long

using namespace std;
const int MODN=1e9+7;
/* Iterative Function to calculate (x^y)%p in O(log y) */
int quick_pow(int x, unsigned int y, int p) 
{ 
    int res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 
int32_t main(){
	int x,y;cin>>x>>y;
	
	if((2*y-x<0)||(2*y-x)%3!=0){
		cout<<0<<endl;
		return 0;
	}
	int xx=(2*y-x)/3;
if(((x-xx)<0) || ((x-xx)%2!=0)){
	cout<<0<<endl;
	return 0;
}
	int yy=(x-xx)/2;
	x=xx;y=yy;
	int a=1;
	for(int i=1;i<=(x+y);i++){
		a*=i;
		a%=MODN;
	}
	int bx=1;
	for(int i=1;i<=x;i++){
		bx*=i;
		bx%=MODN;
	}
	int by=1;
	for(int i=1;i<=y;i++){
		by*=i;
		by%=MODN;
	}
	int b=(bx*by)%MODN;
	int las=quick_pow(b,MODN-2,MODN);
	int ans=(a*las)%MODN;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int N;
string S;
int ruisekiwa[100];

int main() {
	cin >> N;
	cin >> S;
	ruisekiwa[0] = S[0] == '(' ? +1 : -1;
	for (int i = 1; i < S.size(); i++) {
		if (S[i] == '(')ruisekiwa[i] += ruisekiwa[i - 1] + 1;
		else ruisekiwa[i] += ruisekiwa[i - 1] - 1;
	}

	string mae, ato;
	for (int i = 0; i < S.size(); i++) {
		if (ruisekiwa[i] < 0) {
			mae += '(';
			for (int j = i + 1; j < S.size(); j++) {
				ruisekiwa[j]++;
			}
		}
	}
	for (int i = 0; i < ruisekiwa[S.size() - 1]; i++) {
		ato += ')';
	}
	cout << mae + S + ato << endl;
	return 0;
}

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

int main(){

    int n,a,b;
    cin >>n>>a >>b;
    ll ans=0;

    for(int i=1;i<=n;i++){
        int d[5];
        ll t=1;
        rep(j,5){
            d[j]=i/t%10;
            t*=10;
        }
        int te=0;
        rep(i,5){
            te+=d[i];
        }
        if(te>=a&&te<=b){
            ans+=i;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Text;

namespace Atcoder
{
    class Program
    {
        private const long COMDIV = 1000000007;
        static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());
            var AB = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = AB[0]; i <= AB[1]; i++)
            {
                if (i % K == 0)
                {
                    Console.WriteLine("OK");
                    return;
                }
            }

            Console.WriteLine("NG");
        }
        
    }
}

Measured memory_bytes: 28024
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = readInteger >>= print . solve 100

solve n x
	| x <= n = 0
	| otherwise = 1 + solve n' x
	where
		n' = n * 101 `div` 100

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 20 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;
int a[N];
int x[N][N];
int y[N][N];

void solve(int testCase){

    scanf("%d" , &n);

    for(int i = 1 ; i <= n ; i ++){
            scanf("%d" , &a[i]);

            for(int j = 1 ; j <= a[i] ; j ++){
                    scanf("%d %d" , &x[i][j] , &y[i][j]);
                    x[i][j] --;
            }
    }

    int ans = 0;
    for(int mask = 0 ; mask < (1 << n) ; mask ++){
            int tmp = 0;
            bool ok = 1;
            for(int i = 1 ; i <= n ; i ++){
                    if(!(mask & (1 << (i-1))))continue;
                    for(int j = 1 ; j <= a[i] ; j ++){
                            if(y[i][j]){
                                    if(!(mask & (1 << x[i][j])))ok = 0;
                            }
                            else {
                                    if(  mask & (1 << x[i][j])) ok = 0;
                            }
                    }
            }
            if(ok)
            ans = max(ans , __builtin_popcount(mask));
    }

    printf("%d\n" , ans);
}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


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

using namespace std;

const int INF=INT_MAX;

struct lst
{
    private:
        int n;
        vector<int> node;
        vector<int> lazy;
        vector<bool> lflg;
    public:
        lst(int sz)
        {
            n=1; while(n<sz) n*=2;
            node.resize(2*n-1, INF);
            lazy.resize(2*n-1, 0);
            lflg.resize(2*n-1, false);
        }
    void lazy2node(int k, int l, int r)
    {
        if(lflg[k])
        {
            node[k]=lazy[k];
            lflg[k]=false;
            prop(k, l, r);
        }
    }
    void prop(int k, int l, int r)
    {
        if (r-l>0)
        {
            lazy[2*k+1]=lazy[2*k+2]=node[k];
            lflg[2*k+1]=lflg[2*k+2]=true;
        }
    }

    void update(int qa, int qb, int v, int k=0, int l=0, int r=-1)
    {
        if(r<0) r=n-1;
        lazy2node(k, l, r);
        if(qb<l || r<qa) return;
        if(qa<=l && r<=qb) 
        {
            node[k] = v;
            prop(k, l, r);
        }
        else
        {
            int m=(l+r)/2;
            update(qa, qb, v, 2*k+1, l, m);
            update(qa, qb, v, 2*k+2, m+1, r);
        }
    }

    int get(int qa, int qb, int k=0, int l=0, int r=-1)
    {
        if(r<0) r=n-1;
        lazy2node(k, l, r);
        if(qb<l || r<qa) return INF;
        if(qa<=l && r<=qb) return node[k];
        else
        {
            int m=(l+r)/2;
            int lv = get(qa, qb, 2*k+1, l, m);
            int lr = get(qa, qb, 2*k+2, m+1, r);
            return min(lv, lr);
        }
    }
};

int main()
{
    int n, q;
    scanf("%d %d", &n, &q);
    lst tree = lst(n);
    for(int i=0; i<q; i++)
    {
        int t;
        scanf("%d", &t);
        if(t)
        {
            int s;
            scanf("%d", &s);
            printf("%d\n", tree.get(s,s));
        }
        else
        {
            int s, t, v;
            scanf("%d %d %d", &s, &t, &v);
            tree.update(s, t, v);
        }
    }
    return 0;
}


Measured memory_bytes: 4928
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<functional>

using namespace std;

#define ll long long

int main() {
	int x, ans;
	cin >> x;
	for (int i = 1;i<=sqrt(x); i++) {
		for (int j = 2;j<10; j++) {
			if (pow(i, j)<=x) {
				ans = max(ans,(int)pow(i, j));
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	ll N;
	scan(N);
	ll ans=0;
	rep1(i,N){
		ans+=(N/i*i+i)*(N/i)/2;
	}
	prin(ans);
	return 0;
}


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

int main(){
    int N;
    cin>>N;
    int n=N;
    
    int sum=0;
    while (n>0) {
        sum+=n%10;
        n=n/10;
    }
    
    if (N%sum==0) {
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    
}


Measured memory_bytes: 256
from math import atan2, degrees

a, b, x = map(int, input().split())


if a * a * b <= 2 * x:
    c = 2 * (a * a * b - x) / (a * a)
    print("{:.9f}".format(degrees(atan2(c, a))))
else:
    c = 2 * x / (a * b)
    print("{:.9f}".format(degrees(atan2(b, c))))


Measured memory_bytes: 3060
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ').Select(txt => int.Parse(txt)).ToList();

        for (int i = 0; i < 5; i++)
        {
            if (inputs[i] == 0)
            {
                Console.WriteLine(i + 1);
                break;
            }
        }
    }
}

Measured memory_bytes: 27892
#include <iostream>
#include <algorithm>

using namespace std;

const int inf = 1000000;

int main()
{
  int s, t, u, e, m;

  while(cin>>e && e){
    bool f = true;
    m = inf+1;
    for(int z = 0; z <= 100; z++){
      s = z*z*z;
      for(int y = 0; y <= 1000; y++){
	t = y*y + s;
	if(e-t >= 0){
	  m = min(m, (z+y+(e-t)));
	}
      }
    }

    cout << m << endl;
  }

  return 0;
}

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

int main() {
    int n;cin>>n;
    int a[2][n],s[2][n];
    
    for(int i=0;i<2;++i){
        for(int j=0;j<n;++j){
        cin>>a[i][j];
        }
    }
    s[0][0]=a[0][0];
    for(int i=1;i<n;++i){
        s[0][i]=s[0][i-1]+a[0][i];
    }
    s[1][0]=a[0][0]+a[1][0];
    for(int i=1;i<n;++i){
        s[1][i]=max(s[1][i-1],s[0][i])+a[1][i];
//    cout<<s[1][i]<<endl;      
    }

    cout<<s[1][n-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18;
int n;
ll a[N];
ll k;
bool check(ll x) //num of <=x 
{
	ll cnt = 0;
	for(int i=1; i<=n; i++)
	{
		if(a[i]==0)
		{
			if(x>=0) cnt += n - 1;
		}
		else if(a[i]<0)
		{
			ll up = x/a[i];
			while(up*a[i]>x) up++;
			int l = 1, r = n, ans = n+1;
			while(l<=r)
			{
				int mid = (l+r)>>1;
				if(a[mid]>=up) ans = mid, r = mid - 1;
				else l = mid + 1;
			}
			//[ans, n]
			if(ans<=i) ans++;
			cnt += n - ans + 1;
		}
		else
		{
			ll up = x/a[i]; 
			while(up*a[i]>x) up--;
			int l = 1, r = n, ans = 0;
			while(l<=r)
			{
				int mid = (l+r)>>1;
				if(a[mid]<=up) ans = mid, l = mid + 1;
				else r = mid - 1;
			}
			//[1, ans] 
			if(ans>=i) ans--;
			cnt += ans;
		}
	}
	assert(cnt%2==0);
	cnt /= 2;
	return cnt >= k;
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> k;
 	for(int i=1; i<=n; i++) cin >> a[i];
 	sort(a+1, a+n+1);
 	ll l = -LINF, r = LINF, ans = 0;
	while(l<=r)
	{
		ll mid = (l+r)>>1;
		if(check(mid)) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1792
def lid(l: int):
    "print # of l-length"
    print("#" * l)


def wall(l: int):
    "print #, . of l-length-2, and # at rightmost"
    print("#" + "." * (l - 2) + "#")


def buildframe(size: tuple):
    for i in range(size[0]):
        if i == 0 or i == size[0] - 1:
            lid(size[1])
        else:
            wall(size[1])
    print()  # for blank line


while 1:
    d = tuple(map(int, input().split()))
    if d[0] == d[1] == 0:
        break
    buildframe(d)



Measured memory_bytes: 5612
#include <iostream>
#include <cmath>
#include <queue>
#include <cstdio>
#include <cstring>
#include <algorithm>

#define INF 0x7f7f7f7f
#define PI acos(-1.0)

#define L(x)    (x) << 1
#define R(x)    (x) << 1 | 1
#define lowbit(x)   (x)&(-x)
#define Mid(l, r)   (l + r) >> 1
#define Min(x, y)   (x) < (y) ? (x) : (y)
#define Max(x, y)   (x) < (y) ? (y) : (x)
#define iabs(x)     (x) < 0 ? -(x) : (x)
#define CLR(arr, val)    memset(arr, val, sizeof(arr))

using namespace std;

char map[1024][1024];
bool vis[1024][1024];
int cur, h, w;
int dir[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};

struct node {
	int x, y, step;
} sta, now;

bool check(int x, int y) {
	if (x >= 0 && x < h && y >= 0 && y < w && !vis[x][y] && map[x][y] != 'X')	return true;
	return false;
}



void bfs(node s) {
	memset(vis, 0, sizeof(vis));

	queue<node> que;
	s.step = 0;
	que.push(s);
	node next;
	while (!que.empty()) {
//		cout << "h\n";
		s = que.front();
//		cout << s.x << ' ' << s.y << ' ' << cur << endl;
		que.pop();
		if (map[s.x][s.y] == cur + '0')	{
			sta = s;
			return ;
//			s.step;
		}

//		cout << "a\n";
		for (int i = 0; i < 4; i++) {
//			cout << i << endl;
			next.x = s.x + dir[i][0];
			next.y = s.y + dir[i][1];
			next.step = s.step + 1;
			if (check(next.x, next.y)) {
				vis[next.x][next.y] = true;
				que.push(next);
			}

		}
	}
}

int main() {
	int n;
	while (cin >> h >> w >> n) {
//		memset(map, 0, sizeof(map));
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> map[i][j];
				if (map[i][j] == 'S')	sta.x = i, sta.y = j, map[i][j] = '.';
			}
		}
		sta.step = 0;
		int ans = 0;
		for (cur = 1; cur <= n; cur++) {
			bfs(sta);
			ans += sta.step;
			//cout << ans << endl;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3244
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <stack>

using namespace std;

int main(){
	int n, r;
	while(cin >> n >> r, n || r){
		int p, c;
		stack<int> S,P,C;
		for(int i = 1; i <= n; i++){
			S.push(i);
		}
		while(r){
			cin >> p >> c;
			while(--p){
				P.push(S.top());
				S.pop();
			}
			while(c){
				C.push(S.top());
				S.pop();
				c--;
			}
			while(!P.empty()){
				S.push(P.top());
				P.pop();
			}
			while(!C.empty()){
				S.push(C.top());
				C.pop();
			}
			r--;
		}
		cout << S.top() << "\n";
	}
	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll maxn=2e5+1;
void solve()
{
	ll N;
	cin>>N;
	string s;
	cin>>s;
	ll ans=1;
	for(ll i=1;i<s.length();i++)
	{
		if(s[i]!=s[i-1])
		{
			ans++;
		}
	}
	cout<<ans<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1,p=0;
	//cin>>T;
	do
	{
		solve();
		p++;
	}while(p<T);
	return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
#define crap ios_base::sync_with_stdio(0);cin.tie(0)
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define int ll

using namespace std;
const int N = 1e5+5;
int A[N];
int n;
int dp[N];

int solve(int i){
	if(i==n-1) return 0;
	if(i>=n) return INT_MAX;
	int a=INT_MAX,b=INT_MAX;
	if(dp[i]!=-1) return dp[i];
	if(i+2<n){
		a = min(a, abs(A[i+2]-A[i]) + solve(i+2));
	}
	if(i+1<n){
		b = min(b,abs(A[i+1]-A[i]) + solve(i+1));
	}
	return dp[i]=min(a,b);
}

int32_t main()
{
    
   
    crap;
    memset(dp,-1,sizeof(dp));
        cin>>n;
        for(int i=0;i<n;i++) cin>>A[i];

    int ans = solve(0);
	cout<<ans<<endl;
   
   
   
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

//AのN乗(mod M)を高速に計算する(O(logN))
//Aの逆元を取る場合、modpow(A, MOD-2, MOD)で求まる
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

const int MAX = 5100000;
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;
}


signed main() {
  COMinit();

  int K;
  cin >> K;
  string S;
  cin >> S;

  int N = (int)S.size();

  int ans = 0;
  for( int i = 0; i <= K; i++ ){
    int now = 1;
    now = modpow(25, i, MOD);
    now %= MOD;
    now *= COM(i+N-1, N-1);
    now %= MOD;
    now *= modpow(26, K-i, MOD);
    now %= MOD;
    ans += now;
    ans %= MOD;
  }
  cout << ans << endl;

}


Measured memory_bytes: 124836
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

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


	string ans;
	while (1) {
		C -= B;
		if (C <= 0) {
			ans = "Yes";
			break;
		}
		A -= D;
		if (A <= 0) {
			ans = "No";
			break;
		}
	}

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

Measured memory_bytes: 3628
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int INF = 999999999;
int n;
int main() {
	while (cin >> n, n) {
		vector<int> p(n + 1), t(n + 1);
		for (int i = 0; i < n; i++) cin >> p[i + 1] >> t[i + 1];
		vector<vector<int> > dp(n + 1, vector<int>(4, INF));
		dp[0][0] = 0;
		for (int i = 1; i <= n; i++) {
			bool flag1 = false;
			for (int j = 1; j <= 3; j++) {
				int d1 = p[i - 1] + p[i];
				int t1 = p[i - 1] * (j + 1) + p[i];
				if(t[i] - t[i - 1] >= t1) dp[i][1] = min(dp[i][1], dp[i - 1][j] + d1);
			}
			for (int j = 0; j <= 2; j++) {
				int d1 = abs(p[i - 1] - p[i]);
				int t1 = d1 * (j + 1);
				if (t[i] - t[i - 1] >= t1) dp[i][j + 1] = min(dp[i][j + 1], dp[i - 1][j] + d1);
			}
		}
		int ret = INF;
		for (int i = 1; i <= 3; i++) ret = min(ret, dp[n][i] + p[n]);
		if (ret != INF) {
			cout << "OK " << ret << endl;
		}
		else {
			int res = 0;
			for (int i = 1; i <= n; i++) {
				if (dp[i][1] == INF && dp[i][2] == INF && dp[i][3] == INF) {
					res = i;
					break;
				}
			}
			cout << "NG " << res << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
int gcd(int x, int y, int z){
    return (int)__gcd(x, __gcd(y, z));
}
int main(){
    int n; cin >> n;
    int64 sum = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++){
                sum += gcd(i, j, k);
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
int main(void)
{
  int a[4][3][10]={},b,f,r,v,n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
  scanf("%d%d%d%d",&b,&f,&r,&v);
  a[b-1][f-1][r-1]+=v;
    }
  for(b=0;b<4;b++)
    {
      for(f=0;f<3;f++)
	{
	  for(v=0;v<10;v++)
	    {
	      printf(" %d",a[b][f][v]);
	    }
	  printf("\n");
	}
      if(b!=3){ 
  for(i=0;i<20 ;i++ ){printf("#");}
  printf("\n");
      }
    }
  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
using ulong = unsigned long;
using ll = long long;
const int M = 1e9 + 7;
#pragma unused(M)

string s;
int cnt;
bool tsumu(string ab){
    int idx = 0;
    for(uint i=0;i<s.size();i++){
        if(s[i] == ab[idx % 2]){
            idx++;
        }else if(cnt == 0 && i != s.size() - 1){
            cnt++;
        }else{
            // cout << (s.size() % 2 == 0 ? "Second" : "First") << endl;
            // return 0;
            return false;
        }
    }
    return true;
}

int main(){
    cin >> s;
    if(s.front() == s.back()){
        cout << (s.size() % 2 == 0 ? "First" : "Second") << endl;
    }else{
        cout << (s.size() % 2 == 0 ? "Second" : "First") << endl;
    }
    return 0;
    map<char, int> cs;
    for(char c : s){
        cs[c]++;
    }
    for(uint i=1;i<s.size()-1;i++){
        if(s[i-1] != s[i+1]){
            s.erase(i);
        }
    }
    if(cs.size() == 2){
        cout << "Second" << endl;
        return 0;
    }
    char c1 = s[0], c2 = s[1];
    // string ab = {c1, c2};
    // tsumu({c1, c2});
    if(!tsumu({c1, c2})){
        cnt = 0;
        if(!tsumu({s[0], s[2]})){
            cout << (s.size() % 2 == 0 ? "Second" : "First") << endl;
            return 0;
        }else{
            cout << (cnt == 0 ? "Second" : "First") << endl;
        }
    }else{
        cout << (cnt == 0 ? "Second" : "First") << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
    int d[4][10][3];
    int i,j,k,b,f,r,v,n;
    for(i=0;i<4;i++){
        for(j=0;j<10;j++){
            for(k=0;k<3;k++){
                d[i][j][k]=0;
            }
        }
    }
    cin>> n;
    for(i=0;i<n;i++){
        cin>> b>>f>>r>>v;
        d[b-1][r-1][f-1]+=v;
    }
    for(i=0;i<4;i++){
        for(k=0;k<3;k++){
            for(j=0;j<10;j++){
                cout<< " "<< d[i][j][k];
            }
            cout<<endl;
        }
        if(i!=3){
            cout<< "####################";
            cout<<endl;
        }
    }


}

Measured memory_bytes: 1164
n = int(input())
def make_divisors(k):
     divisors = []
     for i in range(1, int(k**0.5)+1):
        if n % i == 0:
            divisors.append(i)
     return divisors
print(make_divisors(n)[-1] + n//make_divisors(n)[-1] - 2)

Measured memory_bytes: 3060
#include <iostream>      
using namespace std;
int main() 
{
	int height[10];
	for(int i=0;i<10;i++){
		cin>>height[i];
	
	}
	
	for(int c=0;c<9;c++){
		for(int j=c+1;j<10;j++){
			if(height[c]<height[j]){
				int B;
				B=height[c];
				height[c]=height[j];
				height[j]=B;
				
			}
			
		}
	}
	for(int a=0;a<3;a++){
		cout<<height[a]<<endl;	
		
	}
	return 0; 
} 

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

struct UnionFind
{
    int i;
    vector<int> par;
    vector<int> size;
    UnionFind(int n): par(n),size(n,1){
        for(i = 0;i < n;++i){
            par[i] = i;
        }
    }
    
    int root(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = root(par[x]);
        }
    }
    
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry){
            return;
        }else{
            if(size[rx] < size[ry]){
                swap(rx,ry);
            }
            par[ry] = rx;
            size[rx] += size[ry];
            return;
        }
    }
    
    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    
    int get_size(int x){
        return size[root(x)];
    }
};

int main()
{
    ll i,j;
    ll n,m;
    cin >> n >> m;
    UnionFind uf(n);
    for(i = 0;i < m;++i){
        ll a,b;
        cin >> a >> b;
        --a;    --b;
        uf.unite(a,b);
    }
    ll ans = 0;
    for(i = 0;i < n;++i){
        if(uf.root(i) != i) continue;
        ll tmp = uf.get_size(i);
        ans = max(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4788
import math

N = int(input())

ans = 10**13
flag = 0
nijou = math.sqrt(N)


for i in range(2,int(nijou +1e-9)+1):
    if N%i == 0:
        j = N//i
        
        if ans > (j-1)+(i-1):
            ans = (j-1)+(i-1)

        flag = 1

        
    else:
        continue

if flag == 0:
    ans = N-1

print(ans)

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

int main()
{
  int a[3];
  cin>>a[0]>>a[1]>>a[2];
  int cnt=0,cnt1=0;
  for(int i=0;i<3;i++)
  {
    if(a[i]==5)
      cnt++;
    if(a[i]==7)
      cnt1++;
  }
  if(cnt==2 && cnt1==1)
    cout<<"YES"<<"\n";
  else
    cout<<"NO"<<"\n";
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const X = parseInt(arg[0].split(" ")[0]);
    const Y = parseInt(arg[0].split(" ")[1]);
    
    let answer = 0;
    
    if(X === 1) {
        answer += 300000;
    }
    
    if(X === 2) {
        answer += 200000;
    }
    
    if(X === 3) {
        answer += 100000;
    }
    
    if(Y === 1) {
        answer += 300000;
    }
    
    if(Y === 2) {
        answer += 200000;
    }
    
    if(Y === 3) {
        answer += 100000;
    }
    
    if(X === 1 && Y === 1) {
        answer += 400000;
    }    
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 22080
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define debug_array(a,n) for (ll bccc=(0); bccc<(n); bccc++) cout<<a[bccc]<<" "
#define debug_vector(a) for(ll bccc=(0); bccc<(a.size());bccc++) cout<<a[bccc]<<" "
#define F           first
#define S           second
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
/* ll t = 0;
ordered_multiset me;
...
me.insert({x, t++});
me.erase(me.lower_bound({x, 0}));
cout << me.order_of_key({x, 0}) << "\n";

///////////   t is insertion time
*/
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long double lld;
lld pi=3.14159265358;
ll powr(ll a,ll b)
{
    ll c=1;
    ll i;
    for(i=0;i<b;i++)
        c*=a;
    return c;
}
ll hell=1000000007;
//ll hell=998244353   ;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
// to generate random number , use rng() ... eg cout<<rng();
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    ll n;
    cin>>n;
    cout<<n*n*n;
    return 0;
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

int main() {
    int w, h, n;
    cin >> w >> h >> n;
    int xlo = 0;
    int xhi = w;
    int ylo = 0;
    int yhi = h;
    vi x(n), y(n), a(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i] >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        if (a[i] == 2)
            chmin(xhi, x[i]);
        else if (a[i] == 1)
            chmax(xlo, x[i]);
        else if (a[i] == 4)
            chmin(yhi, y[i]);
        else if (a[i] == 3)
            chmax(ylo, y[i]);
    }
    cout << max(0, (xhi - xlo)) * max(0, (yhi - ylo)) << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
ll n, q; 
vector<vector<ll>> adj;
vector<ll> sum;
vector<ll> res;
void dfs(ll s, ll cnt)
{
    cnt += sum[s];
    res[s] = cnt;
    for(auto i : adj[s])
    {
        if(res[i] == -1) dfs(i, cnt);
    }
}
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> q;
    sum.assign(n, 0);
    adj.assign(n, vector<ll>());
    F0R(i, n - 1)
    {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    F0R(qr, q)
    {
        ll p, x;
        cin >> p >> x;
        p--;
        sum[p] += x;
    }
    res.assign(n, -1);
    dfs(0, 0);
    for(auto i : res) cout << i << " ";
    return 0;
}

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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#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,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int R, C, N;
int f(int x, int y){
  if(x == 0) return y;
  if(y == C) return C + x;
  if(x == R) return C + R + (C - y);
  if(y == 0) return C + R + C + (R - x);
  return -1;
}

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

  cin >> R >> C >> N;
  vector<PII> xs;
  REP(i,N){
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int ix1 = f(x1, y1);
	int ix2 = f(x2, y2);
	if(ix1 < 0 || ix2 < 0) continue;
	if(ix1 > ix2) swap(ix1, ix2);
	xs.EB(ix1, i+1);
	xs.EB(ix2, -(i+1));
  }
  SORT(xs);

  bool ok = true;
  stack<int> st;
  REP(i,SZ(xs)){
	if(xs[i].SS > 0)
	  st.push(xs[i].SS);
	else{
	  if(st.empty() || st.top() != -xs[i].SS){
		ok = false;
		break;
	  }
	  st.pop();
	}
  }
  cout << (ok?"YES": "NO") << endl;

  return 0;
}


Measured memory_bytes: 3444