akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;
const long double EPS = 0.00000001;

long long int N, M, K, W, H, L, R;
long long int ans;



int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	string s[2];
	cin >> s[0];
	cin >> s[1];
	long long int dp[52] = {};
	if (s[0][0] != s[1][0]) {
		dp[0] = 6;
		dp[1] = 6;
		M = 2;
	}
	else {
		dp[0] = 3;
		M = 1;
	}
	bool flag[52] = {};
	flag[0] = true;
	for (int i = M; i < N; i++) {
	//	cout << i << endl;
		flag[i] = true;
		if (s[0][i] == s[1][i]) {
			if (flag[i - 1]) {
				dp[i] = dp[i - 1] * 2;
				dp[i] %= MOD;
			}
			else {
				dp[i] = dp[i - 2] * 1;
				dp[i] %= MOD;
			}
		}
		else {
			if (flag[i - 1]) {
				dp[i] = dp[i - 1] * 2;
				dp[i] %= MOD;
				dp[i + 1] = dp[i];
				i++;
			}
			else {
				dp[i] = dp[i - 2] * 3;
				dp[i] %= MOD;
				dp[i + 1] = dp[i];
				i++;
			}
		}
	}
	cout << dp[N - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
	double a, b, c, d, e, f, x, y;

	while (cin >> a) {
		cin >> b;
		cin >> c;
		cin >> d;
		cin >> e;
		cin >> f;
	
		x = (c*e - f*b) / (a*e - d*b);
		y = (c*d - f*a) / (b*d - e*a);

		if (x <= 0.0001 && -0.0001 <= x) {
			x = 0;
		}
		if (y <= 0.0001 && -0.0001 <= y) {
			y = 0;
		}

		x *= 1000.0;
		round(x);
		x /= 1000.0;

		y *= 1000.0;
		round(y);
		y /= 1000.0;

		cout << fixed << setprecision(3) << x << " ";
		cout << fixed << setprecision(3) << y << endl;

	}
	return 0;
}


Measured memory_bytes: 3216
#B - Cakes and Donuts
function main()
    N = parse(readline())
    a = 0
    ANSWER = "No"
    for i in 0:div(N,4)
        a = (N - 4i) / 7
#        @show a
        if ceil(a) == floor(a)
            ANSWER = "Yes"
            break
        end
    end
    print(ANSWER)
end

main()

Measured memory_bytes: 111824
import java.util.*;
 
public class Main{
  public static void main(String args[]){
    
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int value = 700;
    
    if (S.substring(0, 1).equals("o")){
      value += 100;
    }
    if (S.substring(1, 2).equals("o")){
      value += 100;
    }
     if (S.substring(2, 3).equals("o")){
      value += 100;
    }
    
    System.out.println(value);
    
  }
}

Measured memory_bytes: 21840
import bisect
def LI():
  return list(map(int,input().split()))

N,M,K = map(int,input().split())
A = LI()
B = LI()

cumA = [0]
for a in A:
  cumA.append(cumA[-1]+a)

cumB = [0]
for b in B:
  cumB.append(cumB[-1]+b)

res = 0
for i in range(N+1):
  cuma = cumA[i]
  if cuma > K: continue
  rem = K-cuma
  deskb = bisect.bisect_right(cumB, rem)-1

  res = max(res, i+deskb)

print(res)

Measured memory_bytes: 127144
import java.util.*;
import java.util.stream.Collectors;

public class Main{
  public static void main(String[] args){
    
    Scanner scan = new Scanner(System.in);
    int val  = scan.nextInt();
    int val2 = scan.nextInt();
    int val3 = scan.nextInt();
    
    List<Integer> prelist = new ArrayList<Integer>();
    prelist.add(val);
    prelist.add(val2);
    prelist.add(val3);
    
    
    
    //List<Integer> list = prelist.stream().distinct().collect(Collectors.toList());
    List<Integer> list = new ArrayList<Integer>(new HashSet<>(prelist));
    
    System.out.println(list.size());
    
    
    
    
    
  }
}

Measured memory_bytes: 35692
N= int(input())
plList=['' for i in range(N)]
tmList=[0 for i in range(N)]

for i in range(N):
    pl,tm=input().split()
    plList[i]=pl
    tmList[i]=int(tm)

i=plList.index(input())
print(sum(tmList[i+1:]))

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

const int INF=1e18;
int dp[510][510];

signed main()
{ 
  int N,X,Y; cin>>N>>X>>Y;
  
  for(int i=0;i<500;i++){
    for(int j=0;j<500;j++){
      dp[i][j]=INF;
    }
  }
  dp[0][0]=0;
  
  for(int i=0;i<N;i++){
    int a,b,c; cin>>a>>b>>c;
    for(int j=500-a;j>=0;j--){
      for(int k=500-b;k>=0;k--){
        if(dp[j][k]==INF) continue;
        dp[j+a][k+b]=min(dp[j+a][k+b],dp[j][k]+c);
      }
    }
  }
  
  int ans=INF;
  for(int k=1;;k++){
    if(k*X<500 and k*Y<500){
      ans=min(ans,dp[k*X][k*Y]);
    }else break;
  }
  cout<<(ans==INF? -1:ans)<<endl;
  
  return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,t,a;
  cin>>n>>t>>a;
  vector<double> x(n);
  int p=0;
  for(int i=0;i<n;i++){
    int h;
    cin>>h;
    x.at(i)=abs(a-(t-0.006*h));
    p=(x.at(i)<x.at(p)?i:p);
  }
  cout<<p+1<<endl;
}

Measured memory_bytes: 256
#include <iostream>


using namespace std;

int main(){
  int N,K;
  cin>>N>>K;
  int count[101] = {0};
  for(int i = 0; i<K; i++){
    int d;
    cin >> d;
    for(int j=0;j<d;j++){
     int A;
      cin >>A;
      count[A]++;
    }
  }
  int sum = 0;
  for(int i=1; i<=N; i++){
   if(count[i]==0)
     sum++;
  }
  cout << sum <<endl;
 return 0; 
}


Measured memory_bytes: 3600
S = int(input())

upper = S // 100
downer = S % 100

flag = 0
if(upper <= 12 and upper > 0):
  flag += 1

if(downer <= 12 and downer > 0):
  flag += 2  
if(flag == 0):
  print('NA')
elif(flag == 1):
  print('MMYY')
elif(flag == 2):
  print('YYMM')
else:
  print('AMBIGUOUS')

Measured memory_bytes: 3064
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let s: Vec<char> = it.next().unwrap().chars().collect();
    const MOD: u64 = 1_000_000_007;
    let mut dp = vec![1; n];
    for (i, c) in s.iter().enumerate() {
        let mut next = vec![0; n - i];
        if *c == '>' {
            for j in 1..(n - i) {
                next[0] += dp[j];
                next[j] += MOD - dp[j];
            }
        } else {
            for j in 0..(n - i) {
                next[j] += dp[j];
                *next.last_mut().unwrap() += MOD - dp[j];
            }
        }
        next[0] %= MOD;
        for j in 1..(n - i) {
            next[j] = (next[j] + next[j - 1]) % MOD;
        }
        next.pop();
        dp = next;
    }
    println!("{}", dp[0]);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<int(n);i++)
using namespace std;
int main(){
    string s;
    cin >> s;

    bool flag=true;
    int count=0;
    for(int i=0;i<s.length();i++){
        if(s[0]!='A') flag=false;
        if(2<=i && i<=s.length()-2){
            if(s[i]=='C') ++count;
            else if(s[i]=='A'||s[i]=='B'||('D'<=s[i]&&s[i]<='Z')) flag=false;
        }
        else if(i!=0){
            if('A'<=s[i] && s[i]<='Z') flag=false;
        }
    }
    if(count!=1) flag=false;
    if(flag) cout << "AC" << endl;
    else cout << "WA" << endl;
    return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    int l = 0, r = 0;
    for (int i = 0; i < m;i++){
        int a;
        cin >> a;
        if(a<x)l++;
        if(a>x)r++;
    }
    int ans = min(l,r);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
ll n,dp[100005][2],a[100005];
bool p[1000005];
int main(void){
    for(int i=2;i<=1000;i++)if(!p[i])for(int j=i*2;j<=1000000;j+=i)p[j]=true;
    scanf("%lld",&n);
    for(int i=0;i<n;i++)scanf("%lld",a+i);
    if(!p[a[0]])dp[1][0]=1;
    for(int i=1;i<n;i++){
        dp[i+1][1]=(dp[i+1][1]+dp[i][0])%M;
        if(!p[a[i]]&&a[i-1]<a[i])dp[i+1][0]=(dp[i+1][0]+dp[i][0])%M;
        if(i>1&&!p[a[i]]&&a[i-2]<a[i])dp[i+1][0]=(dp[i+1][0]+dp[i][1])%M;
    }
    cout<<(dp[n][0]+dp[n][1])%M<<endl;
}



Measured memory_bytes: 6492
/*
  Author - KISHAN TIWARI
  Dream bigger. Do bigger.
  Wake up with determination. Go to bed with satisfaction.
*/
//Sometimes later becomes never. Do it now.
#include<bits/stdc++.h>
using namespace std;
#define ll           long long
#define f(i,a,b)     for(ll i=a;i<b;i++)
#define mod          1000000007
#define fi           first
#define se           second
#define pa           pair <ll,ll>
#define mp           make_pair
#define pb           push_back
#define ve           vector<ll>
#define vep          vector< pa >
#define all(a)       a.begin(), a.end()
#define sz(x)        (ll)x.size()
#define c(t)         cout<<t<<"\n"
using namespace std;
void solve()
{  ll n,k;
cin>>n>>k;
ll x=(n-1)*(n-2)/2;
if(k>x)
    c(-1);
else
{   vep v;
    f(i,2,n+1)
     v.pb(mp(1,i));
     ll i=2;
    while(i<=n)
    {  ll j=i+1;
        while(j<=n)
        {
        if(k==x)
           {
               j=n+1;
               i=n+1;
               break;
               break;
           }
        v.pb(mp(i,j));
        x--;
        j++;
        }
        i++;
    }
    c(sz(v));
    f(i,0,sz(v))
    cout<<v[i].first<<" "<<v[i].second<<"\n";
}
}
int main()
{
    ios::sync_with_stdio(true);
   //freopen ("input.txt","r",stdin);
   //freopen ("output.txt","w",stdout);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--)
    {

        solve();
    }
return 0;
}


Measured memory_bytes: 512
n,x,y=map(int, input().split(" "))
dp=[0]*(n-1)

for i in range(1,n):
  for j in range(i+1,n+1):
    dp[min(j-i,abs(x-i)+abs(y-j)+1)-1] += 1

for i in range(n-1):
  print(dp[i])

Measured memory_bytes: 3444
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,k,cont;
    cin>>a>>b>>c>>k;
    while(a>=b)
    {
        cont++;
        b=b*2;
    }
    while(b>=c)
    {
        cont++;
        c=c*2;
    }
    if(cont>k)
    {
        cout<<"No";
    }
    else
    {
        cout<<"Yes";
    }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n1,n0;
	char z;
	
	while(cin>>z)
	{
		int k=z-'0';
		if(k==1)
		{
			n1++;
		}
		else
		    n0++;
	}
	
	cout<<min(n0,n1)*2;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int Q = input.nextInt();
		String S = input.next();
		int[] AC = new int[N]; //# of AC substrings up to ith index
		for (int i = 1; i < N; i++) {
			AC[i] = AC[i-1];
			if (S.charAt(i)=='C'&&S.charAt(i-1)=='A') AC[i]++;
		}
		//System.out.println(AC[N-1]);
		for (int i = 0; i < Q; i++) {
			int L = input.nextInt();
			int R = input.nextInt();
			System.out.println(AC[R-1]-AC[L-1]);
		}
	}
}

Measured memory_bytes: 53828
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
   	ll n,k;
  	cin>>n>>k;
  	ll ans=0;
  	ll vall,valh,store;
  	for(ll i=k;i<=n+1;i++)
  	{
    	valh= i*n;
      	valh -= (i*(i-1))/2;
      	vall = (i*(i-1))/2;
 	    store= (valh-vall)+1 ;
     	store%= MOD;
      	ans+=store;
      	ans%=MOD;
  	}
  cout<<ans;
   return 0;
}
    



Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	string str;
	cin >> str;
	int Q, op;
	cin >> Q;
	int opt, flag = 0;char c;
	while(Q--){
		cin >> op;
		if(op == 1){//reverse
			if(!flag)flag = 1;
			else	flag = 0;
		}
		else{
			cin >> opt >> c;
			if(flag)if(opt == 1)opt = 2;else	opt = 1;
			if(opt == 1){//beginning
				str.insert(str.begin(),c);
			}
			else{//ending
				str.push_back(c);
			}
		}
	}
	if(flag)
		reverse(str.begin(), str.end());
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
   

    ll a;
    string s;
    cin >> a >> s;
    if(a >= 3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll x, n;
    cin>>x>>n;
    if(n == 0){
        cout<<x<<endl;
        return 0;
    }
    vector<ll> p(n);
    for(ll i=0;i<n;++i){
        cin>>p[i];
    }

    vector<ll> q(n);
    for(ll i=0;i<n;++i){
        q[i] = abs(p[i] - x);
    }
    sort(q.begin(), q.end());

    vector<ll> count(110, 0);
    for(ll i=0;i<n;++i){
        count[q[i]]++;
    }
    if(count[0] == 0){
        cout<<x<<endl;
        return 0;
    }

    ll sx = 0;
    for(ll i=1;i<101;++i){
        if(count[i] != 2){
            sx = i;
            break;
        }
    }

    ll ans = x - sx;
    for(ll i=0;i<n;++i){
        if(p[i] == ans){
            ans = x + sx;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var intArr = cin.ReadLine.Split(' ');

            var r = int.Parse(intArr[0]);
            var d = int.Parse(intArr[1]);
            var x = int.Parse(intArr[2]);

            for (int i = 0; i < 10; i++)
            {
                x = r * x - d;
                WriteLine(x);
            }
        }

    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

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

using namespace std;

int n;
vector<int> edges[100010];
std::string s;

int all_number, all_white, max_white;

bool _all_black;
int _max_down;

inline void dfs(int x, int pre) {
	bool all_black = s[x] == 'B';
	int max1 = 0, max2 = 0, max_down = 0, deg = pre >= 0;
	for (vector<int>::iterator it = edges[x].begin(); it != edges[x].end(); ++it)
		if ((*it) != pre) {
			dfs(*it, x);
			if (!_all_black) {
				++deg;
				all_black = false;
			}
			max_down = max(max_down, _max_down);
			max2 = max(max2, _max_down);
			if (max1 < max2) swap(max1, max2);
		}
	
	if (all_black) { // the subtree is all black
		_all_black = true;
		_max_down = 0;
	} else {
		_all_black = false;
		++all_number;
		int is_white = ((s[x] == 'W') + deg) & 1;
		all_white += is_white;
		_max_down = max_down + is_white;
		max_white = max(max_white, max1 + max2 + is_white);
	}
}

int main() {
	ios::sync_with_stdio(false);
	
	cin >> n;
	for (int i = 1; i < n; ++i) {
		int u, v;
		cin >> u >> v;
		--u, --v;
		edges[u].push_back(v);
		edges[v].push_back(u);
	}
	cin >> s;
	
	for (int i = 0; i < n; ++i)
		if (s[i] == 'W') {
			dfs(i, -1);
//			cerr << all_number << " " << all_white << " " << max_white << "\n";
			if (all_number == 1) cout << 1 << "\n";
			else {
				cout << 2 * (all_number - 1) + all_white - 2 * max_white << "\n";
			}
			return 0;
		}
	cout << "0\n";
}

Measured memory_bytes: 11472
#include <stdio.h>
#define N 100005
 
char suits[N];
int num[N];
 
int partition(int A[], int p, int r) {
  int x = A[r];
  int i = p - 1;
  int j, temp;
 
  for (j = p; j < r; j++) {
    if (num[A[j]] <= num[x]) {
      i++;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }
 
  i++;
  temp = A[i];
  A[i] = A[r];
  A[r] = temp;
 
  return i;
}
 
void quicksort(int A[], int p, int r) {
  if (p < r) {
    int q = partition(A, p, r);
    quicksort(A, p, q-1);
    quicksort(A, q+1, r);
  }
}
 
int isStable(int A[], int n) {
  int i;
 
  for(i = 2; i <= n; ++i) {
    if(num[A[i-1]] == num[A[i]] && A[i-1] > A[i])
      return 0;
  }
 
  return 1;
}
 
 
int main() {
  int n, i;
  char dump;
  int C[N];
  scanf("%d%c", &n, &dump);  
 
  for (i = 1; i < n + 1; ++i) {
    scanf("%c%c%d%c", &suits[i], &dump, &num[i], &dump);
    C[i] = i;
  }
 
  quicksort(C, 1, n);
 
  if (isStable(C, n))
      printf("Stable\n");
  else printf("Not stable\n");
 
  for (i = 1; i < n + 1; ++i) {
    printf("%c %d\n", suits[C[i]], num[C[i]]);
  }
  
  return 0;
}



Measured memory_bytes: 2572
b, c = map(int, input().split())
max_l = 0
min_r = b
for i in range(c):
    l, r = map(int, input().split())
    max_l = max(l, max_l)
    min_r = min(r, min_r)
print(min_r - max_l + 1 if min_r >= max_l else 0)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    string S;
    while(cin >> S){
        vector<long long> cnt(26, 0);
        for(auto& c : S) cnt[c - 'a']++;
        long long res = 0;
        for(int i=0;i<26;i++){
            long long m = 0;
            for(int j=i+1;j<26;j++) m += cnt[j];
            res += cnt[i] * m;
        }
        cout << res + 1 << endl;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;
int a[26];
int main(void){
	int N;
	cin >> N;
	string s;
	cin >> s;
	for(int i=0;i<N;i++){
		a[(int)s[i]-'a']++;
	}
	ll ans = 1;
	for(int i=0;i<26;i++){
		if(a[i]>0){
			ans *= (a[i]+1);
			ans %= mod;
		}
	}
	cout << ans-1 << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#define REP(i,n) for (int i=1;i<=(n);++i)
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,a,b) for (int i=(a);i>=(b);--i)
#define FEC(p,u) for (edge*p=head[u];p;p=p->nxt)
using namespace std;
typedef long long LL;

char s[600000];
int n, nxt[600000], nxt2[600000];
int main(){
	scanf("%s", s+1);
	n = strlen(s+1);
	FOR(i,2,n) {
		int j = nxt[i-1];
		for (; j > 0 && s[j+1] != s[i]; j = nxt[j]);
		if (s[j+1] == s[i]) nxt[i] = j+1; else nxt[i] = 0;
		
		j = nxt2[i-1];
		for (; j > 0 && s[n+1-(j+1)] != s[n+1-i]; j = nxt2[j]);
		if (s[n+1-(j+1)] == s[n+1-i]) nxt2[i] = j+1; else nxt2[i] = 0;
	}
	int L = n-nxt[n];
	if (n%L || L == n) printf("1\n1\n");
	else if (L == 1) printf("%d\n%d\n", n, 1);
	else {
		int t(0);
		REP(i,n-1) if ((nxt[i] == 0 || i%(i-nxt[i])) && (nxt2[n-i] == 0 || (n-i)%(n-i-nxt2[n-i]))) ++t;
		printf("%d\n%d\n", 2, t);
	}
	return 0;
}


Measured memory_bytes: 4608
#include<iostream>
using namespace std;
int main(){
	int k,s,res=0;
	cin>>k>>s;
	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
			if(s-(i+j)<=k&&s-(i+j)>=0){
				res++;
			}
		}
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int     tHP, tAT, aHP, aAT;

    scanf("%d %d %d %d", &tHP, &tAT, &aHP, &aAT);

    for(;;){

        //前半ターン
        aHP -= tAT;
        if( aHP<=0 ){ printf("Yes\n"); return 0; }


        //後半ターン
        tHP -= aAT;
        if( tHP<=0 ){ printf("No\n"); return 0; }
    }
    return 0;
}

Measured memory_bytes: 1624
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    map<string, ll> mp;

    rep(i, n) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }

    ll ans = 0;
    for(auto p : mp) {
        ll x = p.second;
        ans += x*(x-1)/2; 
    }

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

Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
#include <set>

std::set <int> s;

int main()
{
    int n;
    std::cin >> n;
    for(int i = 1;i <= n;i++)
    {
        int x;
        std::cin >> x;
        if(s.find(x) != s.end())
        {
            s.erase(x);
        }
        else
        {
            s.insert(x);
        }
    }
    std::cout << s.size();
    // system("pause");
    return 0;
}

Measured memory_bytes: 8144
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();
const int N=1e6+10;
vector<int>f(N,0);


bool coprime()
{
	for(int i=2;i<=N;i++)
	{
		int cnt=0;
		for(int j=i;j<=N;j+=i)
		{
			cnt+=f[j];
		}
		if(cnt>=2)
		{
			return 0;
		}
	}
	return 1;
}

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	int n;
	cin>>n;

	vector<int>a(n);

	for(i=0;i<n;i++)
	{
		cin>>a[i];
		f[a[i]]=1;
	}

	int gc=0;

	for(i=0;i<n;i++)
	{
		gc=gcd(a[i],gc);
	}

	if(gc>1)
	{
		cout<<"not coprime"<<endl;
	}
	else
	{
		bool flag=coprime();

		if(flag)
		{
			cout<<"pairwise coprime"<<endl;
		}
		else
		{
			cout<<"setwise coprime"<<endl;
		}
	}

}

Measured memory_bytes: 18748
#include <bits/stdc++.h>
using namespace std;
const int N = 305;
bool banned[N];
int my_sport[N], followers[N];
int pref[N][N];
int main(){
    int n,m;
    cin >> n >> m;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < m; ++j){
            scanf("%d",&pref[i][j]);
            --pref[i][j];
        }
    for(int i = 0; i < n; ++i)
        followers[pref[i][0]]++;
    int ans = n;
    for(int times = 0; times < m; ++times){
        int most_popular = 0;
        for(int i = 0; i < m; ++i)
            if(followers[i] > followers[most_popular])
                most_popular = i;
        ans = min(ans,followers[most_popular]);
        if(times == m-1)
            break;
        banned[most_popular] = true;
        for(int i = 0; i < n; ++i)
            while(banned[pref[i][my_sport[i]]]){
                followers[pref[i][my_sport[i]]]--;
                my_sport[i]++;
                followers[pref[i][my_sport[i]]]++;
            }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 640
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [tuple(map(int, input().split())) for i in range(M)]

ans = min(a) + min(b)

for x, y, c in xyc:
    x -= 1
    y -= 1
    ans = min(ans, a[x]+b[y] - c)
print(ans)


Measured memory_bytes: 29024
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr,0,sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9+7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t  main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int a, b;
        cin >> a >> b;
        set<int> s;
        for(int i = 1; i <= 100000; i++){
            int A = (int)(i * 0.08);
            int B = (int)(i * 0.10);
            if(A == a and B == b){
                s.insert(i);
            }
        }
        if(s.size() == 0){
            cout << "-1\n";
        }else{
            cout << *s.begin() << '\n';
        }
    } 
}

Measured memory_bytes: 31488
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;

const ll MOD = 2019;


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

	map<ll, ll> m;
	for (ll i = 2; i * i <= 2e4 + 5; i++) {
		for (ll j = 2; j * j <= 2e4 + 5; j++) {
			for (ll k = 2; k * k <= 2e4 + 5; k++) {
				ll num = i * i + j * j + k * k;
				if (num % 2 != 0) {
					continue;
				}

				if (i + j <= k || j + k <= i || k + i <= j) {
					continue;
				}

				m[num / 2]++;
				
			}
		}
	}


	for (int i = 1; i <= n; i++) {
		cout << m[i] << endl;
	}
}

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

int a[200005],b[200005];

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

Measured memory_bytes: 1792
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=5e2+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll ispm[10000];
vector<ll> pm;
ll d[MAXn][MAXn];


ll lcm(vector<ll> v)
{
  ll res = 1;
  for(ll x:v)
  {
    ll g = __gcd(x,res);
    res = (res / g) * x;
  }
  return res;
}

int main()
{
    IOS();
    for(int i = 2;SZ(pm) < 1010;i++)
    {
      if(!ispm[i])pm.pb(i);
      for(int j = 0;pm[j] * i < 10000;j++)
      {
        ispm[pm[j] * i] = 1;
        if(i % pm[j] == 0)break;
      }
    }
    debug(pm.back());
    ll n;
    cin>>n;
    REP(i,n + 2)REP(j,n + 2)
    {
      if((i + j) % 2 != 0)continue;
      ll a = (i + j) / 2 ,b = (i + n + 1 - j) / 2 + n + 2 + 1;
      d[i][j] = pm[a] * pm[b];
      debug(i,j,a,b);
    }
    REP1(i,n)REP1(j,n)
    {
      if((i + j) % 2 == 0)continue;
      vector<ll> tmp;
      tmp.pb(d[i-1][j]);
      tmp.pb(d[i][j - 1]);
      tmp.pb(d[i+1][j]);
      tmp.pb(d[i][j + 1]);
      d[i][j] = lcm(tmp) + 1;
    }

    REP1(i,n)
    {
      REP1(j,n)cout<<d[i][j]<<" \n"[j==n];
    }

}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define Clear(arr) memset(arr,0,sizeof arr)
#define oo 2000000000
#define inf 1000000000000000000
#define P1 31
#define P2 37
#define M  1000000007
#define M2 1000000009
#define pii pair<ll,ll>
typedef long long ll;
using namespace std;
const int N = 355001;
const int SQRTN = 320;
const int LOGN = 20;
const long double PI = acos(-1);
const long double TAU = 2*PI;

int n;
int calc(int x){
    int r=0;
    while(x){
        r+=x%10;
        x/=10;
    }
    return r;
}
ll ans = 1234665787;
signed main(){
    cin >> n ;
    for(int i = 1 ; i < n ; i++){
        ans = min(ans,1ll*calc(i)+calc(n-i));
    }
    cout << ans << endl;






}


Measured memory_bytes: 256
function Main(input) {
    tmp = input.split("\n");
    k = parseInt(tmp[0], 10);
    tmp2 = tmp[1].split(" ");
    a = parseInt(tmp2[0], 10);
    b = parseInt(tmp2[1], 10);
    result = "NG";

    for (let i = a; i <= b; i++) {
        if (i % k == 0) {
            result = "OK";
        }
    }

    console.log(result);

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29472
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>

using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define inf 1000000007
#define mod 1000000007
#define ull unsigned long long
#define ll long long
template <class T,class U>inline void Max(T &a,U b){if(a<b)a=b;}
template <class T,class U>inline void Min(T &a,U b){if(a>b)a=b;}

#define max(a,b) (a>b?a:b)
ll N, K;
ll dp[100005];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	cin >> N >> K;
	if (K==0) {cout << N*N << endl; return 0;}
	dp[0] = 0;

	rep(n,1,N+1) {
		ll c = N/n;
		ll res = N-c*n;
		dp[n] = dp[n-1] + c*max(n-K, 0) + max(res-K+1,0); 
	}

	cout << dp[N] << endl;
}

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

int main() {
	int n;
	cin >> n;
	int gra = 0, br = 0, gre = 0, c = 0, bl = 0, y = 0, o = 0, r = 0, t = 0;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		if(x < 400) gra = 1;
		else if(x < 800) br = 1;
		else if(x < 1200) gre = 1;
		else if(x < 1600) c = 1;
		else if(x < 2000) bl = 1;
		else if(x < 2400) y = 1;
		else if(x < 2800) o = 1;
		else if(x < 3200) r = 1;
		else t++;
	}
	int a = gra + gre + br + bl + c + y + o + r;
	if(a != 0) cout << a << " " << a + t << endl;
	else cout << "1 " << t << endl;
	return 0;
}

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

using namespace std;

int main(){
    vector<int> v;

    int k,n; cin >> k >> n;

    for(int i=0;i<n;i++){ int a;
        cin >> a; v.push_back(a);
    }

    int ans = k*2;

    for(int i=0;i<n;i++){

        int before, next;

        if(i==0){ before = -(k-v[n-1]);}
        else {before = v[i-1];}

        ans= min(k-abs(v[i]-before),ans);
    }
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    for (int i=k;i<n;i++) {
        if (a[i] > a[i-k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 4068
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using boost::multiprecision::cpp_int;
using namespace std;
#define ll long long int
#define F first
#define S second
//#define endl "\n"
//#define nl cout<<endl;
#define pb push_back
#define ull unsigned long long 
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
//#define mod 100000007
#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 
bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
    return false;
}
bool cmp(int n, pair<int, int> const& p)
{
    return (p.first < n);
}
//me
ll const mod = 1e9+7;//998244353;
ll const inf = 1e18;
ll const maxn = 2e5+1;


void solve()
{    

     ll h,w; cin >> h >> w;
     ll a[h][w];
     ll c[10][10];

     f(i,0,10)f(j,0,10) cin >> c[i][j];
     f(i,0,h)f(j,0,w) cin >> a[i][j];

     for(ll k=0; k<10; k++)
          for(ll i=0; i<10; i++){
               for(ll j=0; j<10; j++){
                    c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
          }
     }

     ll tot = 0;
     f(i,0,h)f(j,0,w){
          if(a[i][j]!=-1)
               tot += c[a[i][j]][1];
     }
     cout << tot ;
     
}

int main() {
Knucklehead 
//*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/ 
          
          ll t;
          /**/t=1;
          /*/cin>>t;/**/
          f(testcases,0,t){
               //cout << "Case #" <<testcases+1<<": ";
               solve();
          }
 
 
    return 0;
}

Measured memory_bytes: 3924
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#include<set>
#include<map>
#include<utility>
#include<string>
#include<vector>

using namespace std;

#define LL long long
#define trio pair<int,pair<int,int>>

int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
bool IA(int x,int y,int xl,int yl){return(x>=0&&x<xl&&y>=0&&y<yl);}

int h,w,ans=0;
char s[22][22];

int main(){
	cin>>h>>w;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>s[i][j];
	for(int i=0;i<h;i++)for(int j=0;j<w;j++){
		if(s[i][j]=='#')continue;
		int dist[22][22]={},mx=0;
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)dist[i][j]=12345;
		dist[i][j]=0;
		priority_queue<trio,vector<trio>,greater<trio>>q;
		q.push({0,{i,j}});
		while(!q.empty()){
			auto tp=q.top();
			q.pop();
			int x=tp.second.first;
			int y=tp.second.second;
			for(int d=0;d<4;d++){
				int nx=x+dx[d];
				int ny=y+dy[d];
				if(IA(nx,ny,h,w)&&s[nx][ny]=='.'&&dist[nx][ny]>tp.first+1){
					q.push({tp.first+1,{nx,ny}});
					dist[nx][ny]=tp.first+1;
					mx=max(mx,dist[nx][ny]);
				}
			}
		}
		ans=max(ans,mx);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	
	// ll t;   cin>>t;
	// for(ll tt = 1; tt <= t; tt++)
	// {
	//     //Code
	    
	// }
	ll n, d;	cin>>n>>d;
	int ans = 0;
	for(ll i=0; i<n; i++)
	{
		ll x, y;	cin>>x>>y;
		ll a = x*x + y*y;
		if(d*d >= a)
			ans++;
		// cout<<"//"<<" ";
	}
	cout<<ans;
}


Measured memory_bytes: 3652
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int[][] delta = new int[][]{{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] g = new char[h][w];
		for (int i = 0; i < h; i++) {
			g[i] = sc.next().toCharArray();
		}

		int answer = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (g[i][j] != '.') continue;
				boolean[][] visited = new boolean[h][w];
				Queue<int[]> q = new LinkedList<>();
				q.offer(new int[]{i, j, 0});
				visited[i][j] = true;
				while (!q.isEmpty()) {
					int[] p = q.poll();
					for (int k = 0; k < 4; k++) {
						int ny = delta[k][0] + p[0];
						int nx = delta[k][1] + p[1];
						if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
						if (g[ny][nx] != '.' || visited[ny][nx]) continue;
						visited[ny][nx] = true;
						q.offer(new int[]{ny, nx, p[2] + 1});
					}

					if (q.isEmpty()) answer = Math.max(answer, p[2]);
				}
			}
		}
		System.out.println(answer);
	}
}


Measured memory_bytes: 28688
#include <iostream>
                    #include <cstdlib>
                    #include <cmath>
                    using namespace std;
                   
     
                    int main(void)
                    {
                    unsigned long long n, max, ans = 999999999;
    cin >> n;
                    max = sqrt((double)n);
                    for (unsigned long long i = 1; i <= max; i++)
    {
                    if ((n % i) == 0 && ans > (log10(double(n / i)) + 1)) ans = log10(double(n / i)) + 1;
    }
                    cout << ans << endl;
                    return 0;
                    }

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] w = sc.next().split("");
		for (int i = 0; i < w.length; i++) {
			if (!w[i].equals(".")) {
				int count = 0;
				String tem = w[i];
				for (int j = i; j < w.length; j++) {
					if (w[j].equals(tem)) {
						count++;
						w[j] = ".";
					}
				}
				if (count % 2 != 0) {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
const int N=100010;
char s[N];
int main(){
	scanf("%s",s+1);
	int cnt=0;
	for (int i=1; s[i]; ++i)
		if (s[i]!=s[i-1]) ++cnt;
	cout<<cnt-1;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ipr pair<ll,ll>
#define ps push_back
#define fs first
#define sc second
#define endl "\n"
#define mod 1000000007
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n,i,j,k,y;

	cin>>n>>y;
	ll x,f=0;
	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++){
			x=(y-10000*i-5000*j);
			if(x%1000==0){
				k=x/1000;
				if(i+j+k==n&&i>=0&&j>=0&&k>=0){
					cout<<i<<" "<<j<<" "<<k<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"-1 -1 -1\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=405;
ll dp[N][N],sum[N];
int a[N];
int main()
{
	int n;
	scanf("%i",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%i",&a[i]);
		sum[i]=sum[i-1]+a[i];
	}
	for(int i=1;i<=n;i++)
	{
		for(int l=1;l<=n-i+1;l++)
		{
			int r=l+i-1;
			if(i==1) dp[l][r]=0;
			else
			{
				dp[l][r]=9e18;
				for(int k=l;k<r;k++)
				{
					dp[l][r]=min(dp[l][r],dp[l][k]+dp[k+1][r]+sum[r]-sum[l-1]);
				}
			}
		}
	}
	printf("%lld\n",dp[1][n]);
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define itn int
#define tin int
#define tni int
#define x first
#define y second
bool dbg = false;
int N;
P e[222];
int X, Y;
double l(int X, int Y)
{
    double x, y;
    x = X;
    y = Y;
    return sqrt(X * X + Y * Y);
}

void solve()
{
    sort(e, e + N, [](P a, P b) {
        return (atan2(a.x, a.y) < atan2(b.x, b.y));
    });
    FOR(i, 0, N)
    {
        e[i + N] = e[i];
    }
    double ans = 0;
    FOR(i, 0, N)
    {
        FOR(j, i + 1, i + 1 + N)
        {
            int X = 0, Y = 0;
            FOR(k, i, j)
            {
                X += e[k].x;
                Y += e[k].y;
            }
            ans = max(ans, l(X, Y));
            // cout << fixed << setprecision(11) << i << " " << j - 1 << " " << l(X, Y) << endl;
        }
    }
    cout << fixed << setprecision(20) << ans << endl;
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(i, 0, N)
    {
        cin >> e[i].x >> e[i].y;
    }
    solve();
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

const int MAXN = 5005;
const ll oo = 1e18;

void minimize(ll &a, ll b) {a = min(a, b);}

int n, a[MAXN], siz[MAXN];
vector<int> g[MAXN];
ll dp[MAXN][MAXN][2];

void DFS(int u, int par) {
    dp[u][0][a[u] < 0] = a[u];
    siz[u] = 1;

    for(int v: g[u]) {
        if (v == par) continue;

        DFS(v, u);

        vector<vector<ll> > tmp(siz[u], vector<ll>(2, 0));
        fto(a, 0, siz[u]-1) {
            fto(compU, 0, 1) {
                tmp[a][compU] = dp[u][a][compU];
                dp[u][a][compU] = oo;
            }
        }

        fto(a, 0, siz[u]-1) {
            fto(b, 0, siz[v]-1) {
                fto(compU, 0, 1) {
                    if (tmp[a][compU] == oo) continue;
                    fto(compV, 0, 1)
                        minimize(dp[u][a+b][compU|compV], tmp[a][compU] + dp[v][b][compV]);
                    if (dp[v][b][0] < oo)
                        minimize(dp[u][a+b+1][compU], tmp[a][compU]);
                    if (dp[v][b][1] < 0)
                        minimize(dp[u][a+b+1][compU], tmp[a][compU]);
                }
            }
        }

//        debug(u);
//        fto(comp, 0, 1) {
//            debug(comp);
//            fto(k, 0, n) printf("%lld ", dp[u][k][comp]);
//            puts("");
//        }
//        puts("");

        siz[u] += siz[v];
    }
}

int main () {
    scanf("%d", &n);
    fto(i, 1, n) scanf("%d", &a[i]);
    fto(i, 1, n-1) {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].pb(v); g[v].pb(u);
    }

    fto(u, 1, n)
        fto(k, 0, n)
            fto(comp, 0, 1)
                dp[u][k][comp] = oo;

    DFS(1, -1);

//    fto(comp, 0, 1) {
//        debug(comp);
//        fto(u, 1, n) {
//            fto(k, 0, n) printf("%lld ", dp[u][k][comp]);
//            puts("");
//        }
//    }

    int ans = n;
    fto(k, 0, n-1) {
        if (dp[1][k][0] < oo)
            ans = min(ans, k);
        if (dp[1][k][1] < 0)
            ans = min(ans, k);
    }

    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 392576
#include<bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
#define For(i, j, k) for(int i = j; i <= k; ++i)
using namespace std;

inline void File() {
#ifndef ONLINE_JUDGE
	freopen("ARC091F.in", "r", stdin);
	freopen("ARC091F.out", "w", stdout);
#endif
}

const int N = 1e3 + 10;
int SG[N], n, k, vis[N], x, ans;

int main() {
	cin >> n;
	For(i, 1, n) {
		scanf("%d%d", &x, &k);
		while(x % k > 0) x -= ((x % k - 1) / (x / k + 1) + 1) * (x / k + 1);
		ans ^= (x / k);
	}
	printf("%s\n", ans ? "Takahashi" : "Aoki");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	string aa = to_string(a);
	string bb = to_string(b);
	string na, nb;
	for (int i = 0; i < b; i++)
		na += aa;
	for (int i = 0; i < a; i++)
		nb += bb;
	if (na < nb)
		cout << na;
	else
		cout << nb;
	return 0;
}


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

const int N=8,M=8;
char A[N][M];

int main()
{
	while(cin>>A[0]){
		for(int i=1;i<N;i++)
			cin >> A[i];
		int s,t;
		for(int i=N-1;i>=0;i--)
			for(int j=M-1;j>=0;j--)
				if(A[i][j]=='1'){
					s=i; t=j;
				}
				//A[s][t]=='1' && A[s][t]=='1' & A[s][t]=='1'
		if(A[s+1][t]=='1' && A[s][t+1]=='1' && A[s+1][t+1]=='1') cout << "A" <<endl;
		else if(A[s+1][t]=='1' && A[s+2][t]=='1' && A[s+3][t]=='1') cout <<"B" << endl;
		else if(A[s][t+1]=='1' && A[s][t+2]=='1' && A[s][t+3]=='1') cout <<"C"<<endl;
		else if(A[s+1][t]=='1' && A[s+1][t-1]=='1' && A[s+2][t-1]=='1') cout << "D" <<endl;
		else if(A[s][t+1]=='1' && A[s+1][t+1]=='1' && A[s+1][t+2]=='1') cout << "E" << endl;
		else if(A[s+1][t]=='1' && A[s+1][t+1]=='1' && A[s+2][t+1]=='1') cout << "F" << endl;
		else if(A[s][t+1]=='1' && A[s+1][t]=='1' && A[s+1][t-1]=='1') cout << "G" <<endl;
	}
	return 0;
}

Measured memory_bytes: 1136