akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MAX 100005
using namespace std;

int main()
{
    string str;
    
    cin>>str;
    
    int n = str.size();
    
    int i = 0, j = n - 1, cnt = 0;
    while(i < j){
        if(str[i] != str[j])
            cnt++;
        i++, j--;
    }
    
    cout<<cnt<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main()
{
	long long int a, n=0, i;
	scanf("%lld", &a);
	for (i = 1; i <= a; i++)
	{
		if (i % 3 != 0 && i % 5 != 0)
		{
			n += i;
		}
	}
	printf("%lld", n);
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    set<string> s;
    rep(i,n){
      string t;
      cin>>t;
      s.insert(t);
    }
    cout<<s.size()<<endl;
    return 0;
}


Measured memory_bytes: 19172
#include <stdio.h>

int main(void) {
  int A, B;
  scanf("%d %d", &A, &B);
  int X = 0;
  for(int i = 0; i < 2; i++) {
    if(A >= B) {
      X += A;
      A--;
    } else if(B > A) {
      X += B;
      B--;
    }
  }

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


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

class Cube{
public:
  int f[6];
  Cube(){}
  void roll_z(){ roll(1, 2, 4, 3);}
  void roll_y(){ roll(0, 2, 5, 3);}
  void roll_x(){ roll(0, 1, 5, 4);}
  void roll(int i, int j, int k, int l){
    int t = f[i]; f[i] = f[j]; f[j]= f[k]; f[k] = f[l]; f[l] = t;
  }
  void move(char ch){
    if ( ch == 'E' ) for ( int i = 0; i < 3; i++ ) roll_y();
    if ( ch == 'W' ) roll_y();
    if ( ch == 'N' ) roll_x();
    if ( ch == 'S' ) for ( int i = 0; i < 3; i++ ) roll_x();
  }
};

int main(){
  Cube c;
  string com;

  for (int i = 0; i <6; i++ ) cin >> c.f[i];
  cin >> com;

  for ( int i = 0; i < com.size(); i++ ) c.move(com[i]);

  cout << c.f[0] << endl;

  return 0;
}

Measured memory_bytes: 3152
#include<cstdio>
#include<algorithm>
#include<cstring>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int N=5e3+5;
const int inf=1e9;
int n,m,head[N],nxt[N],go[N],sum;
int dis[2005][2005],tot;
struct node
{
	int x,y;
}e[N];
inline void add(int x,int y)
{
	go[++tot]=y;
	nxt[tot]=head[x];
	head[x]=tot;
}
inline void dfs(int x,int fa,int dep)
{
	if (dep>(m/2))sum++;
	for(int i=head[x];i;i=nxt[i])
	{
		int v=go[i];
		if (v!=fa)
		{
			dfs(v,x,dep+1);
		}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	fo(i,1,n-1)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
		e[i].x=x,e[i].y=y;
	}
	int ans=inf;
	if (m%2)
	{
		fo(i,1,n-1)
		{
			sum=0;
			dfs(e[i].x,e[i].y,0);
			dfs(e[i].y,e[i].x,0);
			ans=min(ans,sum);
		}
	}
	else
	{
		fo(i,1,n)
		{
			sum=0;
			dfs(i,0,0);
			ans=min(ans,sum);
		}
	}
	printf("%d\n",ans==inf?n:ans);
} 

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

namespace ABC148D
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var As = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

            if (!As.Contains(1))
            {
                Console.WriteLine(-1);
                return;
            }

            if (As.Length == 1 && As[0] == 1)
            {
                Console.WriteLine(0);
                return;
            }

            var ans = 0;
            var j = 1;
            for (var i = 0; i < N; i++)
            {
                if (As[i] == j)
                    j++;
                else
                    ans++;
            }

            if (ans > 0)
                Console.WriteLine(ans);
            else if (j - 1 == N)
                Console.WriteLine(0);
            else
                Console.WriteLine("-1");
        }
    }
}

Measured memory_bytes: 33628
N = int(input())
S = input()

dp = [0 for _ in range(N)]
dp[0] = S[1:].count("E")

for i in range(1,N):
	if S[i-1] == "W" and S[i] == "W":
		dp[i] = dp[i-1] + 1
	elif S[i-1] == "E" and S[i] == "E":
		dp[i] = dp[i-1] - 1
	else:
		dp[i] = dp[i-1]

print(min(dp))

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

using namespace std;

const int MOD = 2019;

int main()
{
	long long L, R;
	cin >> L >> R;

	long long ans = MOD;

	for (long long i = L; i < R && i < L + MOD; ++i) {
		for (long long j = i + 1; j <= R && j < i + 1 + MOD; ++j) {
			ans = min(ans, (i * j) % MOD);
		}
	}

	cout << ans << endl;
}


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

int main()
{
	string s;
	cin>>s;
	bool check=false;
	
	if(s=="hihihi")
	{
		cout<<"Yes"<< endl;
		return 0;
	}
	if(s=="hihihihi")
	{
		cout<<"Yes"<< endl;
		return 0;
	}
	if(s=="hihihihihi")
	{
		cout<<"Yes"<< endl;
		return 0;
	}
	
	for(int i=0; i<s.size(); i+=2)
	{
		if(s.substr(i,i+2)=="hi")
			check=true;
		else
		{
			check=false;
			cout<<"No"<< endl;
			break;
		}
	}
	
	if(check==true)
		cout<<"Yes"<< endl;
	
	return 0;
}

Measured memory_bytes: 256
def calc(sign, A):
    cumsum_A = [0 for _ in range(len(A))]
    cumsum_A[0] = A[0]
    for i in range(len(cumsum_A) - 1):
        cumsum_A[i + 1] = cumsum_A[i] + A[i + 1]
    ret, offset = 0, 0
    for a in cumsum_A:
        b = a + offset
        if sign * b <= 0:
            diff = sign - b
            offset += diff
            ret += abs(diff)
        sign *= (-1)
    return ret


def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    print(min([calc(1, A), calc(-1, A)]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 14648
#include<iostream>
#include<string>

using namespace std;

int main(){
    string S;
    cin >> S;
    int count,prise = 700;
    if(S[0] == 'o')prise+=100;
    if(S[1] == 'o')prise+=100;
    if(S[2] == 'o')prise+=100;
    cout << prise << endl;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
	string s;
	int ans = 700;

	cin >> s;

	if (s[0]=='o')
	{
		ans += 100;
	}

	if (s[1]=='o')
	{
		ans += 100;
	}

	if (s[2]=='o')
	{
		ans += 100;
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
memo = {0:1}
def fact(x):
  if x in memo:
    return memo[x]
  else:
    memo[x] = x * fact(x - 1)
    return memo[x]
n, k = map(int, input().split())
if n > k:print(0)
else:print(fact(k) // fact(k - n) % 1000000007)


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

int main(){    
  int X,N;
  cin >> X >> N;
  vector<int> vec1(N);
  vector<int> vec2(N);
  for(int i = 0; i < N; i ++){
    cin >> vec1[i];
  }
  for(int i = 0; i < N; i ++){
    vec2[i] = abs(X - vec1[i]);
  }
  sort(vec2.begin(), vec2.end());
  if(N == 0) cout << X << endl;
  else if(vec2[0] != 0){
    cout << X << endl;
  }
  else{
    for(int i = 1; i < 100; i++){
      if(count(vec1.begin(), vec1.end(), X - i) == 0){
        cout << X - i << endl;
        break;
      }
      else if(count(vec1.begin(), vec1.end(), X + i) == 0){
        cout << X + i << endl;
        break;
      }
    }
  }
}
 

Measured memory_bytes: 3632
N, M, X = map(int,input().split())
A=[]
for i in range(N):
    A.append(list(map(int, input().split())))
    
pr=10**9
for s in range(2**N):
    x_m = [0]*13
    for i in range(N):
        b = (s >> i) & 1
        if b == 1:
            for j in range(M+1):
                x_m[j] += A[i][j]
 
    xOk = True
    for j in range(1,M+1):
        if x_m[j] < X:
            xOk = False
    
    if xOk == True:
        pr = min(pr, x_m[0])
 
if pr<10**9:
    print(pr)
else:
    print(-1)

Measured memory_bytes: 9128
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
	Scanner in=new Scanner(System.in);
	int a=in.nextInt();
	int b=in.nextInt();
	if(a<b)
		System.out.println("a < b");
	else if(a>b)
		System.out.println("a > b");
	else
		System.out.println("a == b");
	}
}

Measured memory_bytes: 26236
import java.util.Scanner;

/**
 * Main
 */
public class Main {

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        int tmp = A;
        A = B;
        B = tmp;

        tmp = A;
        A = C;
        C = tmp;

        System.out.print(A + " ");
        System.out.print(B + " ");
        System.out.println(C);
        
    }
}

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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			D();
		}

		public static void D()
		{
			Scanner cin = new Scanner();
			int n = cin.NextInt();
			int k = cin.NextInt();
			string s = cin.Next();

			List<int> nums = new List<int>();
			char value = s[0];
			int count = 0;
			for (int i = 0; i < n; ++i) {
				if (s[i] == value) {
					++count;
				} else {
					nums.Add(count);
					value = s[i];
					count = 1;
				}

				if (i == n - 1) {
					nums.Add(count);
				}
			}

			if (s[0] == '0') {
				nums.Insert(0, 0);
			}

			if (s[n - 1] == '0') {
				nums.Add(0);
			}

			int l = k * 2 + 1;

			if (nums.Count <= l) {
				Console.WriteLine(n);
			} else {
				
				long initial = 0;
				for (int i = 0; i < l; ++i) {
					initial += nums[i];
				}

				long last = initial;
				long max = initial;
				for (int i = 2; i <= nums.Count - l; i += 2) {
					long num = last - nums[i - 1] - nums[i - 2] 
						+ nums[i + l - 1] + nums[i + l - 2];
					if (num > max) {
						max = num;
					}

					last = num;
				}

				Console.WriteLine(max);
			}
		}



	}

	public class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}


		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}


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

int main(){
    int n;
    cin >> n;
    map<int, int> mp;
    set<int> st;
    rep(i, n) {
        int a;
        cin >> a;
        ++mp[a];
        st.insert(a);
    }
    int cnt = 0;
    for ( auto tmp_mp: mp ) {
        if ( tmp_mp.second >= 2 ) {
            cnt += tmp_mp.second - 1;
        }
    } 
    if ( cnt & 1 ) {
        cout << st.size() - 1 << endl;
    }
    else {
        cout << st.size() << endl;
    }
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

#define __STDC_FORMAT_MACROS
#define p64 PRId64

using namespace std;
using ll = int64_t;

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || '9' < c) break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

int main()
{
    int N;

    gc(N);

    vector<ll> A(N, 0);

    REP(i, N)
    {
        gc(A[i]);
    }

    ALL(sort, A);

    ll tmp = 0;
    int ngidx = 0;
    REP(i, N)
    {
        if (i != 0 && 2 * tmp < A[i]) ngidx = i;

        tmp += A[i];
    }

    cout << N - ngidx << endl;
    return 0;
}


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

int main() {
	int i,j,k,c=0,n;
	string s;
	cin>>s;
	cout<<"2018/";
	for(i=0;i<s.size();i++)
	{
		if(s[i]=='/'&&i!=s.size()-3)
			cout<<s[i+1]<<s[i+2]<<"/";
		else if(s[i]=='/'&&i==s.size()-3)
			cout<<s[i+1]<<s[i+2];
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n, m;
int cnt[200010];
int ccnt[200010];
vector<int> vi;

int main() {
	cin >> n >> m;
	rep(i, m) {
		int num;
		cin >> num;
		cnt[num] = 1;
		ccnt[num] = 1;
		vi.push_back(num);
	}
	reverse(ALL(vi));
	rep(i, vi.size()) {
		if (ccnt[vi[i]])cout << vi[i] << endl;
		ccnt[vi[i]] = 0;
	}
	rep(i, n) {
		if (cnt[i + 1] == 0)cout << i + 1 << endl;
	}
}

Measured memory_bytes: 4988
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 10000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int n, m;
	cin >> n >> m;
	
	int g = m / n;
	if(m % n == 0){
		cout << g << endl;
		return 0;
	}
	for(int i = g; i >= 1; --i){
		if((m - i * n) % i == 0){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}



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

int D[3];
int main()
{
	//freopen("/home/zz7/CFInput","r",stdin);
	for(int i=0;i<3;i++)
	scanf("%d",&D[i]);
	sort(D,D+3);
	cout<<D[1]-D[0]+D[2]-D[1]<<'\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(a,b,c) for(int i=a;i<b;i+=c)  
typedef pair<ll , pair<ll, ll> > pi;
int pow(int x,int y){
    int res=1;
    while(y){
        if(y&1) res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}   
struct Compare {
    constexpr bool operator()(pi const & a,
                              pi const & b) const noexcept
    { return a.first < b.first || (a.first == b.first && a.second.first > b.second.first); }
 
};
void prefix_function( string s,ll arr[] )
{
     long long border=0; arr[0]=0;
    for(long long i=1;i<s.size();i++)
    {
      while(border>0 && s[i]!=s[border])
        border=arr[border-1];
     
     if(s[i]==s[border])
         border++;
      else
       border=0;
      
      arr[i]=border;
    }
}
ll mod=998244353;
ll add( ll a , ll b)
{
    return (((a%mod)+(b%mod))%mod);
}
ll mul(ll a,ll b)
{
  return (((a%mod)*(b%mod))%mod);
}
//send mod-2 for a^-1 if mod is a prime number
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}
ll dsu_arr[100000];
ll dsu_sz[100000];
void dsu(ll n)
{
    for(ll i=0;i<=n;i++)
    {
        dsu_arr[i]=i;
        dsu_sz[i]=1;
    }
}
ll find(ll x)
{
     ll root=x;
    while (root!=dsu_arr[root])
    {
        root=dsu_arr[root];
    }
    while(x!=dsu_arr[x])
    {
        dsu_arr[x]=root;
        x=dsu_arr[x];
    }
    return root;
}
ll merge(ll x,ll y)
{
    ll root1=find(x);
    ll root2=find(y);
    
    if(root1==root2)
    return 0ll;
 
    if(dsu_sz[x]>dsu_sz[y]){
    dsu_arr[root2]=root1;
    dsu_sz[x]+=dsu_sz[y];
    }
    else
    {
         dsu_sz[y]+=dsu_sz[x];
        dsu_arr[root1]=root2;
    }
    return 1ll;
}


int main()
{
 string s1,s2;
 cin>>s1>>s2;
 ll ans=2000;
 for(ll i=0;i<=s1.size()-s2.size();i++)
 {
     ll baal=0;
     for( ll j=0;j<s2.size();j++)
     {
         if(s1[i+j]==s2[j])
         baal++;
     }
     ll k=(s2.size());
     ans=min(ans,k-baal);
 }
if(ans==2000)
ans=0;
cout<<ans<<endl;
}



   
      
    
        



Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s[200005];
map<string,int>mp;
int main()
{
    int n;
    cin>>n;
    int cnt=0;
    int maxx=0;
    for(int i=0;i<n;i++)
    {
        string h;
        cin>>h;
        int p=mp[h]++;
        p++;
        if(p>maxx)
            maxx=p;

    }
    map<string,int>::iterator it;
    for(it= mp.begin();it!=mp.end();it++)
    {
        if(it->second==maxx)
            s[cnt++]=it->first;
    }
    sort(s,s+cnt);
    for(int i=0;i<cnt;i++)
        cout<<s[i]<<endl;

}


Measured memory_bytes: 26752
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int n,a[100005]={0};
int main()
{
	cin>>n;
	int i;
	for(i=1;i<=n;i++)
	{
		int temp;
		scanf("%d",&temp);
		a[temp]++;
	}
	int sum=0,res=0;
	for(i=1;i<=100005;i++)
	{
		sum+=a[i];
		if(a[i]>1)res+=a[i]-1;
	}
	if(res%2==0)
	{
		cout<<sum-res;
	}
	else
	{
		cout<<sum-res-1;
	}
	return 0;
 } 

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	auto d = [](int n){
		int res = 0;
		for(; n; n /= 10) res += n % 10;
		return res;
	};
	int n, ans = inf; cin >> n;
	for(int i = 1; i < n; i++) ans = min(ans, d(i) + d(n - i));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//
// Created by tac on 2016/10/11.
//

#include <cstdlib>
#include <iostream>

int pow3(int n) {
    return n * n * n;
}

int main() {
    int n;

    std::cin >> n;

    std::cout << pow3(n) << std::endl;

    return EXIT_SUCCESS;
}

Measured memory_bytes: 3048
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    string::iterator ai = a.begin(), bi = b.begin(), ci = c.begin();
    char turn = 'a';
    while(true){
        if(turn == 'a'){
            if(ai == a.end()){
                cout << "A" << endl;
                return 0;
            }
            turn = *ai;
            ai++;
        }else if(turn == 'b'){
            if(bi == b.end()){
                cout << "B" << endl;
                return 0;
            }
            turn = *bi;
            bi++;
        }else if(turn == 'c'){
            if(ci == c.end()){
                cout << "C" << endl;
                return 0;
            }
            turn = *ci;
            ci++;
        }
    }

    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

ll dp[301][301];

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


	int N, M;
	scanf("%d %d", &N, &M);

	int xm[301][4], xM[301][4];
	rep1(i, N) {
		xm[i][1] = N;
		xm[i][2] = N;
		xM[i][2] = -1;
		xM[i][3] = -1;
	}
	rep(i, M) {
		int l, r, x;
		scanf("%d %d %d", &l, &r, &x);
		chmin(xm[r][x], l);
		chmax(xM[r][x], l);
	}

	const int mod = 1e9 + 7;
	dp[0][0] = 1;
	int mj = 0;
	int mk = 0;
	rep1(i, N) {
		for (int j = i - 1; j >= mj; j--) {
			auto dpj = dp[j];
			for (int k = i - 1; k >= max(j, mk); k--) {
				dpj[i] += dpj[k];
				dp[k][i] += dpj[k];
			}
		}

		for (int j = i; j > xm[i][2]; j--) {
			for (int k = i; k >= max(j, mk); k--) dp[j][k] = 0;
		}
		for (int j = xm[i][2]; j > max(xM[i][3], mj - 1); j--) {
			for (int k = i; k > max(xm[i][1], mk - 1); k--) dp[j][k] = 0;
			if (i % 4 == 0) {
				for (int k = xm[i][1]; k > max(xM[i][2], mk - 1); k--) {
					dp[j][k] %= mod;
				}
			}
			for (int k = xM[i][2]; k >= mk; k--) dp[j][k] = 0;
		}
		for (int j = xM[i][3]; j >= mj; j--) {
			for (int k = i; k >= max(j, mk); k--) dp[j][k] = 0;
		}
		if (mj <= xM[i][3]) mj = xM[i][3] + 1;
		if (mk <= xM[i][2]) mk = xM[i][2] + 1;
	}

	ll kotae = 0;
	rep(j, N + 1) rep(k, N + 1) {
		kotae += dp[j][k] % mod;
	}
	printf("%lld", kotae% mod);

	Would you please return 0;
}

Measured memory_bytes: 896
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        long a = sc.nextLong(), b = sc.nextLong(), x = sc.nextLong();
                        System.out.println(b / x - a / x + (a % x == 0 ? 1 : 0));
                }
        }
}

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

#define rep(i,n) for(int i = 0; i < (int)n; ++i)

#define INF 100000000

int main() {
  int N, K;
  cin >> N >> K;
  int digit = 0;
  while(K <= N){
    digit++;
    N /= K;
  }
  digit++;
  cout << digit << endl;
  return 0;
}

Measured memory_bytes: 256
n, k = gets.split.map &:to_i
trees = []
 
n.times do
  trees << gets.to_i
end
 
trees.sort!
ans = 1E9
 
for i in 0 .. n - k
  min = trees[i + k - 1] - trees[i]
  ans = [min, ans].min
end
 
puts ans

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    rep(i, n / r + 1) {
        rep(ii, (n - i * r) / g + 1) {
            if ((n - i * r - ii * g) % b == 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;//×Ô¶¯È¡Ä£2^64 
const double pi=acos(-1.0);
const int mod = 1e9+7; // 998244353;
const int inf = 0x7fffffff;//2^31-1	
const ll INF = 0x7fffffffffffffff;
const int dx[]={-1,0,1,0},dy[]={0,1,0,-1};
//double begin_time=clock();    double end_time=clock();printf("time= %f ms\n",end_time-begin_time);
//bool operator < (const mmp &a) const{return x<a.x||x==a.x&&y<a.y;}       //map<int,map<int,int> >z;
//map<int,int>::iterator it;for(it=z.begin();it!=z.end();it++)printf("%d %d\n",it->first,it->second);
//ll pow(ll a,ll b){ll s=1;while(b){if(b&1){s=(s*a)%mod;b--;}b/=2;a=a*a%mod;}return s;}  //¿ìËÙÃÝÈ¡Ä£ 
//lower_bound(begin,end,num); µÚÒ»¸ö>=numµÄÊý×Ö upper_bound(begin,end,num); µÚÒ»¸ö>numµÄÊý×Ö,·µ»ØµØÖ·
//freopen("input.in","r",stdin);     freopen("output.out","w",stdout);      //ÎÄ¼þ¶ÁÐ´Ìá½» 
//reverse(s.begin(),s.end());   //·­×ª×Ö·û´® ||        floor(); ÏòÏÂÈ¡Õû  ceil(); ÏòÉÏÈ¡Õû
//x&(x-1)==0 //ÊÇ2µÄN´Î·½||         x%9 //x¸÷¸öÎ»µÄºÍ||           log10(x)+1   //xµÄÎ»Êý|| 
//ÊýÖáÉÏµÄn¸öµãÒÆ¶¯µ½Í¬Ò»Î»ÖÃ£¬ÒÆ¶¯µ½¸Ã×éÊý×ÖµÄÖÐÎ»ÊýµÄ×Ü¾àÀë×î¶Ì


int main()
{
	double a,b,c,d,e,f,T;
	//scanf("%d",&T);
	//while(T--)
	{
		scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
		c=c*30+(d/60)*30;
		d=d*6;
		c=fabs(c-d);
		if(c>360-c)c=360-c;
		double n;
		n=a*a+b*b-2*b*a*cos(pi*c/180);
		printf("%.10f\n",sqrt(n)); 
		
	}
	
}





Measured memory_bytes: 4252
N, K = [int(x) for x in input().split()]
S = input()
conv = {'A': 'a', 'B': 'b', 'C': 'c'}
for i, s in enumerate(S):
    if (i != K-1):
        print(s, end="")
    else:
        print(conv[s], end="")
print()


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

int main() {
    int n;
    double prob;
    cin >> n;
    if( n % 2 == 0 ){
        prob = double(n/2) / n;
    }else{
        prob = double(n/2+1) / n;
    }
    cout << prob <<endl;
}

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

#define fst first
#define snd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;
const ll _INF = 1e18+7;


int main(){
	setIO();
	int x = 0; string s;
	cin >> s;
	for (int i = 0; i < (int)s.size(); i++){
		x += (s[i]-48);
	}
	if (x%9) cout << "No\n";
	else cout << "Yes\n";
}

Measured memory_bytes: 3776
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <list>
using namespace std;

//??\?????????????????????????§???????
struct Edge {
	vector<int> in_n, out_n;
	void set_in(int a) { in_n.emplace_back(a); }
	void set_out(int a) { out_n.emplace_back(a); }
};

int main() {
	//Wiki:?????????????????????????????¢?????´??????????????????

	int V, E; cin >> V >> E;
	vector<Edge> edge(V + 1);
	list<int> L;    //??????????????????????????????????????????????????????????????????
	queue<int> S;   //??\???????????????????????????????????????????????????

					//?????????
	for (int i = 0; i < E;i++) {
		int s, t; cin >> s >> t;
		edge[s].set_out(t);
		edge[t].set_in(s);
	}

	//??\???????????????????????????????????????????????¢?´¢
	for (int i = 0; i < V;i++) {
		if (edge[i].in_n.size() == 0) { S.push(i); }
	}

	while (!S.empty()) {
		//S???????????????n???????????????
		int n = S.front(); S.pop();
		//L???n???????????????
		L.push_back(n);

		/*
		for each n ???????????? e ??¨????????????????????? m do
		??? e ?????°????????????????????????
		if m ?????????????????\??????????????£?????????????????° then
		m ??? S ???????????????
		*/

		int size = edge[n].out_n.size();
		for (int i = 0; i < size; i++) {
			int m = edge[n].out_n[0];

			edge[n].out_n.erase(edge[n].out_n.begin());

			for (int j = 0; j < edge[m].in_n.size();j++) {
				if (edge[m].in_n[j] == n) {
					edge[m].in_n.erase(edge[m].in_n.begin() + j);
					break;
				}
			}
			if (edge[m].in_n.size() == 0) {
				S.push(m);
			}
		}
	}
	for (int n : L) {
		cout << n << endl;
	}
	return 0;
}

Measured memory_bytes: 4404
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
int ceil(int a,int b){
    return (a+b-1)/b;
}
int main(void){
   int n;
   cin>>n;
   if(n>=1200) cout<<"ARC"<<endl;
   else cout<<"ABC"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
#define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

// xのn乗%modを計算
ll mod_pow(ll x,ll n,ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

int main() {

    ll n,m;
    cin>>m>>n;
    ll ans=mod_pow(m,n,MOD);
    fin(ans);
}




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

int main(void){
    int n;
    cin >> n;
    
    int input;
    int odd[100001] = {0};
    int even[100001] = {0};
    int i;
    for(i = 1; i <= n; i++){
        cin >> input;
        if(i % 2 == 1){
            odd[input]++;
        }else{
            even[input]++;
        }
    }
    
    int odd_max = 0, even_max = 0;
    for(i = 1; i <= 100000; i++){
        if(odd[i] > odd[odd_max]){
            odd_max = i;
        }
        if(even[i] > even[even_max]){
            even_max = i;
        }
    }
    
    sort(odd, odd + 100001, greater<int>());
    sort(even, even + 100001, greater<int>());
    if(odd_max == even_max){
        if(odd[0] + even[1] > odd[1] + even[0]){
            cout << n - (odd[0] + even[1]) << endl;
        }else{
            cout << n - (odd[1] + even[0]) << endl;
        }
    }else{
        cout << n - (odd[0] + even[0]) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1024
import sys

N = int(sys.stdin.readline().strip())
A = list(map(int, sys.stdin.readline().strip().split()))

ans = 1
if 0 in A:
    print(0)
    sys.exit()
for a_i in A:
    ans *= a_i
    if ans > 10**18:
        print(-1)
        sys.exit()

print(ans)

Measured memory_bytes: 21800
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
  char find_str[10];
  int ling_qty;

  scanf("%s",&find_str);
  scanf("%d",&ling_qty);
 
  char str_buff[11];
  char str_sum[20];

  int find_count = 0;
  for(int i = 0; i < ling_qty; i++){
    scanf("%s",str_buff);
    strcpy(str_sum,str_buff); 
    strcat(str_sum,str_buff);
    if(strstr(str_sum,find_str) != NULL) find_count++;
  }
  printf("%d\n",find_count); 
}

Measured memory_bytes: 2724
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())

def solve():
    N = INT()

    print(0, flush=True)
    s0 = input()
    if s0 == 'Vacant':
        exit()

    ng = -1
    ok = N
    while True:
        mid = (ok + ng) // 2
        print(mid, flush=True)
        s = input()
        if s == 'Vacant':
            exit()

        if ( mid % 2 == 0 and s == s0 ) or ( mid % 2 == 1 and s != s0 ):
            ng = mid
        else:
            ok = mid

if __name__ == '__main__':
    solve()

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

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

    if(K <= A) cout << A-K << " " << B << endl;
    else if(A < K <= B && A + B > K) cout << 0 << " " << B - K + A << endl;
    else cout << 0 << " " << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    long long int N,H,W,i,j,k,ans,count,cost,tmp;
    long long int S[200010];
    long long int Ssum[200010];
    string T,U,V,ans2;
    bool flag;
    count=0;
    ans=std::pow(10,18);
    flag=false;
    cin >>T;
    for (i=T.size()-1;i>0;i--){
        //cout <<i <<endl;
        if (i%2==0){
            U=T.substr(0,i/2);
            V=T.substr(i/2,U.size());
            if (U==V){
                ans=U.size()*2;
                cout << ans<<endl;
                return 0;
            }
            
            
            }
        }
    
    

    
    //cout << ans<<endl;

    return 0;
    
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <complex>
#include <queue>

using namespace std;
typedef long long ll;
typedef complex<double> Point;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define DEC(i, s) for (int i = (s); i >= 0; i--)

#define SIZE(v) (int)((v).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define FIND(m, w) ((m).find(w) != (m).end())

int n;
double R;
Point points[3000];

struct Node {
  Point p;
  double w;
  int bound;
  Node(Point p, double w, int bound) : p(p), w(w), bound(bound) {;}
  bool operator<(const Node &rhs) const {
    return bound < rhs.bound;
  }
};

int main() {
  R = 1.0;
  while (scanf("%d", &n), n) {
    priority_queue<Node> que;
    REP(i, n) {
      double x, y;
      scanf("%lf %lf", &x, &y);
      points[i] = Point(x, y);
      que.push(Node(points[i], R, 10000));
    }
    int ans = 1;
    while (!que.empty()) {
      Node node = que.top();
      que.pop();
      if (node.bound <= ans) { break; }
      int lans = 0;
      int nbound = 0;
      REP(i, n) {
        double dist = abs(points[i] - node.p);
        if (dist < R) {
          lans++;
          nbound++;
        } else if (dist < R + node.w * 1.41421356) {
          nbound++;
        }
      }
      ans = max(ans, lans);
      if (nbound <= ans) { continue; }
      const double dx[4] = { -1, -1, 1, 1 };
      const double dy[4] = { -1, 1, -1, 1 };
      double nw = node.w / 2.0;
      REP(i, 4) {
        double nx = node.p.real() + nw * dx[i];
        double ny = node.p.imag() + nw * dy[i];
        que.push(Node(Point(nx, ny), nw, nbound));
      }
    }
    printf("%d\n", ans);
  }
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion
#pragma region chminmax
template <typename T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    int n, w;
    cin >> n >> w;
    vector<P> b(n);
    // v, w
    rep(i, n) cin >> b[i].first >> b[i].second;

    vector<vector<int>> dp(n + 1, vector<int>(w + 1));
    rep(i, n)
    {
        rep(j, w + 1)
        {
            if (j - b[i].second >= 0)
            {
                chmax(dp[i + 1][j], dp[i][j - b[i].second] + b[i].first);
                chmax(dp[i + 1][j], dp[i + 1][j - b[i].second] + b[i].first);
            }
            chmax(dp[i + 1][j], dp[i][j]);
        }
    }
    cout << dp[n][w] << endl;

    return 0;
}


Measured memory_bytes: 6840
#include <stdio.h>

int main()
{
  unsigned int a, b, x, y;
  unsigned int rem;

  while(scanf("%d %d", &a, &b) != EOF)
    {
      x = a;
      y = b;

      while(b != 0)
	{
	  if(a < b)
	    {
	      int tmp = a;
	      a = b;
	      b = tmp;
	    }
	  
	  rem = a % b;
	  a = b;
	  b = rem;
	}
      printf("%d %d\n", a, x * (y / a));
    }
  return 0;
}

Measured memory_bytes: 596
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val s = readLine() ?: return
    1.until(n).map {
        val a = s.substring(0, it).toList().distinct()
        val b = s.substring(it, s.length).toList().distinct()
        if (a.size > b.size) {
            a.size - (a - b).size
        } else {
            b.size - (b - a).size
        }
    }.max()?.let {
        println(it.toString())
    }
}

Measured memory_bytes: 33952
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int r;

  std::cin >> r;

  std::cout << r * r << std::endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
ans, cnt = 0, 0
tmp = h[0]
for i in range(1,n):
  if tmp >= h[i]:
    ans += 1
    tmp = h[i]
  else:
    ans = 0
    tmp = h[i]
  if ans > cnt:
    cnt = ans
print(cnt)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
*/

ll N, M;
vector<ll> g[MAX];
ll clr[MAX];

void dfs(ll c, ll u) {
  if(clr[u]!=-1) return;
  
  clr[u]=c;
  
  for(ll i=0; i<g[u].size(); i++)
    dfs(1-c, g[u][i]);
    
}

int main(void) {
  ll i, j, k;
  
  cin >> N >> M;
  
  
  for(i=0; i<M; i++) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  
  memset(clr, -1, sizeof(clr));
  dfs(0, 0);
  
  
  for(i=0; i<N; i++) {
    for(j=0; j<g[i].size(); j++) {
      if(clr[i]==clr[g[i][j]]) { //not bipartite graph
        pt(N*(N-1)/2-M);
        return 0;
      }
    }
  }
  
  ll cnt=0;
  for(i=0; i<N; i++) if(clr[i]==0) cnt++;
  pt(cnt*(N-cnt)-M);
  
}



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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  string s;cin>>s;
  bool c=false;
  rep(i,s.size()){
    if(c && s[i]=='F'){
      cout<<"Yes";
      return 0;
    }
    if(s[i]=='C')c=true;
  }
  cout<<"No";
  return 0;
}

Measured memory_bytes: 256
require 'tsort'

n = gets.to_i
a = gets.split.map(&:to_i)

memo = Array.new(n)
res = 0

calc = ->x{
  if memo[x]==nil
    i = 0
    y = x
    loop do
      if memo[y]==nil
        memo[y] = i
        i += 1
        y = (y + a[y]) % n
      elsif memo[y]==false
        break
      else
        res += i - memo[y]
        break
      end
    end
  end
  y = x
  while memo[y]
    memo[y] = false
    y = (y + a[y]) % n
  end
}

n.times(&calc)
p res


Measured memory_bytes: 15644
//10
#include<iostream>
#include<algorithm>

using namespace std;

struct DP{
  int d,p;
  bool operator<(DP a)const{
    return p>a.p;
  }
};

int main(){
  for(int n,m;cin>>n>>m,n|m;){
    DP dp[10000];
    for(int i=0;i<n;i++){
      cin>>dp[i].d>>dp[i].p;
    }
    sort(dp,dp+n);
    int p=0;
    for(int i=0;i<n;i++){
      if(dp[i].d>m){
	p+=(dp[i].d-m)*dp[i].p;
	m=0;
      }else{
	m-=dp[i].d;
      }
    }
    cout<<p<<endl;
  }
  return 0;
}

Measured memory_bytes: 1252
def main():
    import sys
    input = sys.stdin.readline
    
    n = int(input())
    arr = list(map(int, input().split()))
    
    ans = [i for i in range(n)]
    ans.sort(key = lambda x : arr[x])
    
    ans = [i + 1 for i in ans]
    print(*ans)
    
    return 0

main()


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

const int inf = 1e9 + 7;
const int mnx = 5e2 + 9;

int a[mnx][mnx];
bool del[mnx];
int ptr[mnx];
int cnt[mnx];
int n, m;

bool check(int lim){
    for(int i = 1; i <= n; i++){
        ptr[i] = 1;
    }
    for(int i = 1; i <= m; i++){
        del[i] = 0;
    }
    while(true){
        for(int i = 1; i <= m; i++){
            cnt[i] = 0;
        }
        for(int i = 1; i <= n; i++){
            cnt[a[i][ptr[i]]]++;
        }
        bool found = 0;
        for(int i = 1; i <= m; i++){
            if (cnt[i] > lim) {
                del[i] = 1;
                found = 1;
            }
        }
        if(!found){
            break;
        }
        for(int i = 1; i <= n; i++){
            while(ptr[i] <= m && del[a[i][ptr[i]]]) {
                ptr[i]++;
            }
            if (ptr[i] > m) {
                return 0;
            }
        }
    }
    return 1;
}

int main(){

cin >> n >> m;

for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
        cin >> a[i][j];
    }
}

int l = 1, r = n, ans = 0;

while(l <= r){
    int mid = (l + r) >> 1;
    if(check(mid)){ r = mid - 1; ans = mid; }
    else{ l = mid + 1; }
}

cout << ans << '\n';

return 0;

}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    int bu[5] = {0};
    rep(i, 0, 6){
        int n; cin >> n;
        bu[n]++;
    }
    bool f = true;
    Rep(i, 1, 4){
        if(bu[i] == 0 || bu[i] >= 3) f = false;
    }
    if(f) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 256
import sys
Sd = input()
T = input()
candidate = []
ans = ""

for i in range(len(Sd) - len(T) + 1):
    flag = True
    for j in range(len(T)):
        if Sd[i+j] != T[j] and Sd[i+j] != "?":
            flag = False
    if flag:
        candidate.append(Sd[:i] + T + Sd[i+len(T):])

if not candidate:
    print("UNRESTORABLE")
    sys.exit(0)

for i in candidate:
    s = ""
    for j in i:
        if j =="?":
            s += "a"
        else:
            s += j
    if ans =="":
        ans = s
    else:
        ans = min(ans, s)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
 
int stringcmp(const char *a, const char *b);
 
int main() {
    char a[1000000], b[1000000];
 
    scanf("%s%s", a, b);
 
    //printf("%s\n%s\n", a, b);
 
    if (stringcmp(a, b) > 0) {
        printf("GREATER\n");
    } else if (stringcmp(a, b) < 0) {
        printf("LESS\n");
    } else {
        printf("EQUAL\n");
    }
    return 0;
}
 
int stringcmp(const char *a, const char *b) {
    if (strlen(a) > strlen(b)) {
        return 1;
    } else if (strlen(a) < strlen(b)) {
        return -1;
    } else {
        return strcmp(a, b);
    }
}

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

int INF = 1001001001;
vector<P> to[100005];
vector<ll> dist(100005);

void dfs(int k, int d, ll r){
    dist[k] = r;
    int x = to[k].size();
    for (int i = 0; i < x; i++){
        if(to[k][i].first == d)continue;
        int nex = to[k][i].first;
        ll omomi = to[k][i].second;
        dfs(nex, k, r+omomi);
    }

    return;
}

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

    rep(i, N-1){
        int a, b, c; cin >> a >> b >> c;
        a--;
        b--;
        to[a].push_back(make_pair(b, c));
        to[b].push_back(make_pair(a, c));
    }

    int Q, K; cin >> Q >> K;
    K--;
    dfs(K, -1, 0);

    rep(i, Q){
        int x, y; cin >> x >> y;
        x--;
        y--;
        ll ans = dist[x] + dist[y];
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 15568