akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;

void swap(string& a,string& b){
    string t=a;
    a=b;
    b=t;
}

void Bubble(string* array,int n){
    for(int i=0;i<n;++i){
        for(int j=n-1;j>i;--j){
            if(array[j][1]<array[j-1][1]){
                swap(array[j],array[j-1]);
            }
        }
    }
    for(int i=0;i<n;++i){
        cout<<array[i];
        if(i!=n-1){cout<<" ";}
    }
    cout<<"\n";
}

void Select(string* array,int n){
    for(int i=0;i<n;++i){
        int min=i;
        for(int j=i;j<n;++j){
            if(array[j][1]<array[min][1]){min=j;}
        }
        swap(array[i],array[min]);
    }
    for(int i=0;i<n;++i){
        cout<<array[i];
        if(i!=n-1){cout<<" ";}
    }
    cout<<"\n";
}

void IsStable(string* array,string* original,int n){
    bool yes_or_no=true;
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            for(int k=0;k<n;++k){
                for(int l=k+1;l<n;++l){
                    if(original[i][1]==original[j][1] && array[l]==original[i] && array[k]==original[j]){
                        yes_or_no=false;
                    }
                }
            }
        }
    }
    if(yes_or_no) cout<<"Stable\n";
    else cout<<"Not stable\n";
}

int main(){
    int n;
    cin>>n;
    string* array=new string[n];
    for(int i=0;i<n;++i){
        cin>>array[i];
    }
    string* array2=new string[n];
    for(int i=0;i<n;++i){
        array2[i]=array[i];
    }
    string* original=new string[n];
    for(int i=0;i<n;++i){
        original[i]=array[i];
    }
    Bubble(array,n);
    IsStable(array,original,n);
    Select(array2,n);
    IsStable(array2,original,n);
}

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

int main(){
  int K;
  cin >> K;
  int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  cout << a[K-1] <<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
signed main(){
	string s;
  cin>>s;
  ll n,a,b,f=0;
  n = s.size();
  a = (n - 1) / 2;
  b = (n + 3) / 2 - 1;
  for(ll i=0;i<a;i++){
    if(s[i]==s[b]){
      f++;
    }
    b++;
  }
  if(f==a){
    cout<<"Yes\n";
  }else{
    cout<<"No\n";
  }
  return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,a[22][22],f[22][1<<21];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			cin>>a[i][j];
	f[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=(1<<i)-1;j<(1<<n);j++)
		{
			int x=j,cnt=0;
			while(x)
			{
				cnt+=(x%2);
				x/=2;
			}
			if(cnt==i)
			{
				for(int k=1;k<=n;k++)
					if(a[k][i] && (j>>(k-1))&1)
						f[i][j]=(f[i][j]+f[i-1][j-(1<<(k-1))])%mod;
			}
		//	cout<<j<<' '<<cnt<<' '<<f[i][j]<<endl;
		}
	}
	cout<<f[n][(1<<n)-1]<<endl;
	return 0;
}


Measured memory_bytes: 162048
#include<bits/stdc++.h>
#define L long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define aa first
#define bb second
#define mp make_pair
#define mpp(a,b,c) mp(mp(a,b),c)
using namespace std;
int n,s,t,d,w[100010];
set<pii> f;
vector<int> x[100010],y[100010];
L p;
bool u[100010];
struct point
{
	int x,y,p;
}a[100010];
inline bool cmp(point a,point b)
{
	return a.x<b.x || a.x==b.x && a.y<b.y;
}
inline bool cmp2(point a,point b)
{
	return a.y<b.y || a.y==b.y && a.x<b.x;
}
inline void add(int i,int j,int k)
{
	x[i].pb(j);
	y[i].pb(k);
	x[j].pb(i);
	y[j].pb(k);
}
inline void dfs(int i)
{
	int j;
	u[i]=1;
	for(j=0;j<x[i].size();j++)
	  {
	   p+=y[i][j];
	   if(!u[x[i][j]])
	     dfs(x[i][j]);
	  }
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k;
	scanf("%d%d%d",&n,&s,&t);
	for(i=1;i<=n;i++)
	  {
	   scanf("%d%d",&j,&k);
	   a[i].x=j+k;
	   a[i].y=j-k;
	   a[i].p=i;
	  }
	d=max(abs(a[s].x-a[t].x),abs(a[s].y-a[t].y));
	sort(a+1,a+n+1,cmp);
	for(i=1;i<=n;i++)
	  f.insert(mpp(a[i].x,a[i].y,i));
	f.insert(mpp(2.1e9,2.1e9,n+1));
	f.insert(mpp(-2.1e9,-2.1e9,0));
	for(i=1;i<=n;i++)
	  {
	   if((L)a[i].x-d>-2.1e9)
	   {
	   j=(*f.lower_bound(mpp(a[i].x-d,a[i].y-d,0))).bb;
	   k=(*--f.lower_bound(mpp(a[i].x-d,a[i].y+d,1e9))).bb;
	   if(j<=k)
	     {
	      w[j]++;
	      w[k]--;
	      add(a[i].p,a[j].p,1);
		 }
	   }
	   if((L)a[i].x+d<2.1e9)
	   {
	   j=(*f.lower_bound(mpp(a[i].x+d,a[i].y-d,0))).bb;
	   k=(*--f.lower_bound(mpp(a[i].x+d,a[i].y+d,1e9))).bb;
	   if(j<=k)
	     {
	      w[j]++;
	      w[k]--;
	      add(a[i].p,a[j].p,1);
		 }
	   }
	  }
	for(i=1,k=0;i<n;i++)
	  {
	   k+=w[i];
	   if(k)
	     add(a[i].p,a[i+1].p,k);
	   w[i]=0;
	  }
	f.clear();
	sort(a+1,a+n+1,cmp2);
	for(i=1;i<=n;i++)
	  f.insert(mpp(a[i].y,a[i].x,i));
	f.insert(mpp(2.1e9,2.1e9,n+1));
	f.insert(mpp(-2.1e9,-2.1e9,0));
	for(i=1;i<=n;i++)
	  {
	   if((L)a[i].x-d>-2.1e9)
	   {
	   j=(*f.lower_bound(mpp(a[i].y-d,a[i].x-d+1,0))).bb;
	   k=(*--f.lower_bound(mpp(a[i].y-d,a[i].x+d-1,1e9))).bb;
	   if(j<=k)
	     {
	      w[j]++;
	      w[k]--;
	      add(a[i].p,a[j].p,1);
		 }
	   }
	   if((L)a[i].x+d<2.1e9)
	   {
	   j=(*f.lower_bound(mpp(a[i].y+d,a[i].x-d+1,0))).bb;
	   k=(*--f.lower_bound(mpp(a[i].y+d,a[i].x+d-1,1e9))).bb;
	   if(j<=k)
	     {
	      w[j]++;
	      w[k]--;
	      add(a[i].p,a[j].p,1);
		 }
	   }
	  }
	for(i=1,k=0;i<n;i++)
	  {
	   k+=w[i];
	   if(k)
	     add(a[i].p,a[i+1].p,k);
	  }
	dfs(s);
	p/=4;
	printf("%lld\n",p);
	return 0;
}


Measured memory_bytes: 33536
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i=0; i<n; i++){
        cin >> d[i];
    }

    int sum=0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n;j++){
            sum += d[i]*d[j];
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
V = n + m
par = [i for i in range(0, V)]
sizes = [1] * V


def find(x):
    if x == par[x]:
        return x
    par[x] = find(par[x])
    return par[x]


def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if sizes[x] < sizes[y]:
        x, y = y, x
    par[y] = x
    sizes[x] += sizes[y]


for i in range(0, n):
    for l in [int(k)for k in input().split()][1:]:
        unite(i, l - 1 + n)
r = "YES"
if len([i for i in range(0, n)if find(i) != find(0)]) > 0:
    r = "NO"
print(r)


Measured memory_bytes: 12592
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n,a[N],b[N],c[N<<1];
ll sum[N<<1];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
    ll ans=1e18,res=0;
    for(int i=1;i<=n;i++) res+=a[i];
    ans=min(ans,res);
    res=0;
    for(int i=1;i<=n;i++) res+=b[i];
    ans=min(ans,res);
    for(int i=1;i<=n;i++) c[i]=a[i],c[i+n]=b[i];
    sort(c+1,c+1+n+n);
    for(int i=1;i<=n+n;i++) sum[i]=sum[i-1]+c[i];
    for(int i=1;i<=n;i++)
    {
        if(a[i]<=c[n]&&b[i]<=c[n]) res=sum[n];
        else if(a[i]<=c[n-1]||b[i]<=c[n-1]) res=sum[n-1]+max(a[i],b[i]);
        else res=sum[n-2]+a[i]+b[i];
        ans=min(ans,res);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#ifdef _MSC_VER
#  define __builtin_popcount __popcnt
#endif
#define int long long
using namespace std;
using ll = long long;
using ld = long double;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const long double PI = acos(-1.0);
inline void my_io() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cout << fixed << setprecision(15);
}
signed main() {
	my_io();
	int n;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    private static void solver(InputReader sc, PrintWriter out) throws Exception {
          String s = sc.next();
          if(s.equals("ABC"))
              out.println("ARC");
          else
              out.println("ABC");
    }
    private static int gcd (int a, int b) {
        if (b == 0)
            return a;
        else
            return gcd (b, a % b);
    }
    private static long helper(long x){
        long ans = (x * (x-1))/2;
        return ans;
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int[] readIntArray(int n){
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        }
    }
}
class Pair{
    long x;
    long y;
    Pair(long x, long y){
        this.x  =x ;
        this.y =y;
    }
}


Measured memory_bytes: 32744
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p=0
for i in range(n):
    if a[i]<b[i]:
        p+=(b[i]-a[i])//2
    elif b[i]<a[i]:
        p-=(a[i]-b[i])
if p>=0:
    print('Yes')
else:
    print('No')

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

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

 int main(){

 int a,b,c;
  cin>>a>>b>>c;

  swap(a,b);
  swap(a,c);

  cout<<a<<" "<<b<<" "<<c<<endl;

 return 0;
 }

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
struct T {
  int by, bx, ay, ax;
};

int main()
{
  int h, w; cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w, 0));
  int sum = 0;
  rep(i, h) rep(j, w) {
    cin >> a[i][j];
    sum += a[i][j];
  }

  vector<T> ans;
  rep(i, h) {
    if (i%2 == 0) {
      for (int j=0; j<w-1; j++) {
        if (a[i][j]%2==1) {
          a[i][j]--;
          a[i][j+1]++;
          ans.push_back(T{i, j, i, j+1});
        }
      }
      if (i<h-1 && a[i][w-1]%2==1) {
        a[i][w-1]--;
        a[i+1][w-1]++;
        ans.push_back(T{i, w-1, i+1, w-1});
      }
    } else {
      for (int j=w-1; j>=1; j--) {
        if (a[i][j]%2==1) {
          a[i][j]--;
          a[i][j-1]++;
          ans.push_back(T{i, j, i, j-1});
        }
      }
      if (i<h-1 && a[i][0]%2==1) {
        a[i][0]--;
        a[i+1][0]++;
        ans.push_back(T{i, 0, i+1, 0});
      }
    }
  }
  cout << ans.size() << endl;
  for (auto v:ans) {
    printf("%d %d %d %d\n", v.by+1, v.bx+1, v.ay+1, v.ax+1);
  }

  return 0;
}


Measured memory_bytes: 5232
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200020


int main(){
	int a[N];
	int dp[N];
	f(i, N){
		a[i] = 0;
		dp[i] = MOD;
	}
	dp[0] = 0;
	int n, k;
	int x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
	f(i, n){
		scanf("%d", &a[i]);
	}
	f(i, n){
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i] - a[i + 1]));
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i] - a[i + 2]));
	}

	printf("%d\n", dp[n-1]);


	return 0;
}

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

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; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    int X,Y,Z,K; cin>>X>>Y>>Z>>K;
    vector<ll> A(X),B(Y),C(Z);
    rep(i,X)cin>>A[i];
    rep(i,Y)cin>>B[i];
    rep(i,Z)cin>>C[i];
    sort(A.rbegin(),A.rend());
    sort(B.rbegin(),B.rend());
    sort(C.rbegin(),C.rend());
    vector<ll> E;
    rep(i,X){
        rep(j,Y)E.push_back(A[i]+B[j]);
    }
    sort(E.rbegin(),E.rend());
    vector<ll> F;
    rep(i,min(K,X*Y)){
        rep(j,Z){
            F.push_back(E[i]+C[j]);
        }
    }
    sort(F.rbegin(),F.rend());
    rep(i,K)cout<<F[i]<<endl;
}


Measured memory_bytes: 44044
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(30) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> S;
  rep(i,0,10)rep(j,0,10)rep(k,0,10){
    A=S.find(to_string(i),0);
    B=S.find(to_string(j),A+1);
    C=S.find(to_string(k),B+1);
    if(A!=string::npos&&B!=string::npos&&C!=string::npos)sum++;
  }
  Out(sum);
}

Measured memory_bytes: 256
L = list(input())
N = len(L)
if '0' not in L:
    L = ['1'] + ['0']*N
    N += 1
else:
    for i in range(N):
        t = L[N-i-1]
        if t == '0':
            L[N-i-1] = '1'
            break
        else:
            L[N-i-1] = '0'
res = 0
MOD = 10**9+7
buff = 1
for d, char in enumerate(L):
    if char == '1':
        res = (res + buff * pow(3, N-1-d, MOD))%MOD
        buff = (2 * buff) % MOD
print(res)



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

      using namespace std;
      #define           ff                first
      #define           ss                second
      #define           PF                printf
      #define           pb                push_back
      #define           odd(i)            (i & 1)
      #define           nl                printf("\n");
      #define           toDecimal(s,base) stoi(s,nullptr,base)
      #define           even(i)           (!(i & 1))
      #define           pf(x)             printf("%d",x)
      #define           iin(x)            scanf("%d",&x)
      #define           din(x)            scanf("%lf",&x)
      #define           lin(x)            scanf("%lld",&x)
      #define           pfl(x)            printf("%lld",x)
      #define           all(x)            x.begin(),x.end()
      #define           rall(x)           x.rbegin(),x.rend()
      #define           rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
      #define           DB(x)             cerr << __LINE__ << ": " << #x << " = " << (x) << endl
      #define           file_in           freopen("input.txt", "r", stdin)
      #define           file_out          freopen("output.txt", "w", stdout)
      #define           pfd(x,y)          cout << fixed << setprecision(x) << y
      #define           show(x)           for(auto it : x) cout << it << " "
      #define           showp(x)          for(auto it : x) cout << it.ss << " "
      #define           fast              ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
      #define           first_set(x)      __builtin_ffs(x)
      #define           lead_zero(x)      __builtin_clz(x)
      #define           trail_zero(x)      __builtin_ctz(x)
      #define           set_bits(x)      __builtin_popcount(x)
      #define           ERAGE(x)         x.erase(unique(all(x)),x.end())

      int main(){
            //file_in;
            //file_out;
            int tc = 1;
            //iin(tc);
            while(tc--){
                  int a,b,c;
                  iin(a);
                  iin(b);
                  iin(c);
                  a = a - b;
                  if(c >= a) cout << c - a << "\n";
                  else cout << 0 << "\n";

            }

      }
 /*****************************************************
 *   Duplicate line 	Ctr + D                       *
 *   Swap line above 	Ctr + T                       *
 *   Line cut	      Ctr + L                       *
 *   Line comment       Ctr + Shift + c               *
 *   Line delete	      Ctr + Shift + L               *
 *   move line          Alt+up/down                   *
 *****************************************************/
 /*****************************************************
 *     tie(a,b,c) = mt(1,2,3); // assign              *
 *     tie(a,b) = mt(b,a); // swap(a,b)               *
 *     tuple<int, int, int, char> t (3, 4, 5, 'g');   *
 *     int a, b;                                     *
 *     tie(b, ignore, a, ignore) = t;                *
 *****************************************************/
\


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM(sieve)
// --> sieve
// ---- inserted library file sieve.cc

// sieve(upto) returns the list of prime numbers up to upto.
//   Size: upto(1e8).size() ... 5.7e6,  upto(1e9).size() ... 5.1e7
//   Performance: upto(1e8) ... 0.7sec,   upto(1e9) ... 9.2sec
vector<int> sieve(int upto) {
  vector<int> res;
  vector<bool> tbl(upto+1);
  ll lim = (int)(sqrt((double)upto)) + 1;
  for (int x = 2; x <= upto; x++) {
    if (tbl.at(x))  continue;
    res.push_back(x);
    if (x > lim)  continue;
    for (int y = x * 2; y <= upto; y += x) tbl.at(y) = true;
  }
  return res;
}

/*
  Prime Factorization
    Two versions:
      - prfac(n)
      - prfac(n, primes)
            primes should contain prime numbers at least up to sqrt(n)
 */

const vector<int> dummy_primes;

vector<pair<ll, int>> prfac(ll n, const vector<int>& primes = dummy_primes) {
  vector<int> tmp_primes;
  if (primes.size() == 0) {
    tmp_primes = sieve((int)sqrt((double)n) + 1);
  }
  const vector<int>& prms = primes.size() == 0 ? tmp_primes : primes;

  vector<pair<ll, int>> res;
  ll x = n;
  for (ll p : prms) {
    if (x == 1)  break;
    if (p * p > x)  break;
    if (x % p != 0)  continue;
    int c = 1;
    x /= p;
    while (x % p == 0) {
      c += 1;
      x /= p;
    }
    res.push_back(make_pair(p, c));
  }
  if (x != 1)  res.push_back(make_pair(x, 1));
  return res;
}

/*
vector<pair<ll, int>> prfac(ll n) {
  return prfac(n, sieve((int)(sqrt((double)n)) + 1));
}
*/

/*
    List of divisors
      - getDivisors(n)
      - getDivisors(n, primes)
            primes should contain prime numbers at least up to sqrt(n)
    Note: the results are NOT sorted
 */

// gdsub ... aux function used in getDivisors()
vector<ll> gdsub(int i, int n, auto fs) {
  if (i == n) { return vector<ll>({1}); }
  auto part = gdsub(i+1, n, fs);
  ll p  = fs.at(i).first;
  int r = fs.at(i).second;
  ll pp = p;    // pp = p^m, for m \in [1, r]
  int partOrigLen = part.size();
  for (int m = 1; m <= r; m++) {
    for (int j = 0; j < partOrigLen; j++) {
      part.push_back(pp * part.at(j));
    }
    pp *= p;
  }
  return part;
}

vector<ll> getDivisors(ll n, const vector<int>& primes = dummy_primes) {
  auto fs = prfac(n, primes);
  return gdsub(0, fs.size(), fs);
}

/*
vector<ll> getDivisors(ll n) {
  auto fs = prfac(n);
  return gdsub(0, fs.size(), fs);
}
*/

// ---- end sieve.cc
// @@ !! LIM  -- end mark --

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  auto g = [&](ll n) -> ll {
    ll cnt = 0;
    while (n > 0) {
      cnt++;
      n /= 10;
    }
    return cnt;
  };

  ll N; cin >> N;
  ll ans = 20;
  for (ll n : getDivisors(N)) {
    ll m = N / n;
    ll x = max(g(n), g(m));
    ans = min(ans, x);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3784
import java.util.*;
public class Main{
 
public static void main(String[] args){
int f=0;
int s=0;
Scanner x= new Scanner(System.in);
for(int i=0;i<3;i++){
int temp=x.nextInt() ;
if(temp== 5)
f++;
else if(temp==7)
s++;
 
}
if(s==1 &&f==2)
System.out.print("YES");
else
System.out.print("NO");
}
 
}

Measured memory_bytes: 9424
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


int main(){
	int l;
	while(cin>>l,l){
	int sum=0;
	int i;
	vi m(12),n(12);
	for(i=0;i<12;i++){
		cin>>m[i]>>n[i];
	}
	for(i=0;i<12;i++){
		sum+=m[i]-n[i];
		if(sum>=l){
			break;
		}
	}
	if(i==12){
		cout<<"NA"<<endl;
	}else{
		cout<<i+1<<endl;
	}}
}

Measured memory_bytes: 1192
#include <iostream>
#include <set>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <map>
#include <cstdio>
using namespace std;
#define rep(i,n) for(i = 0; i < n; i++)
#define repe(i,n) for(i = 0; i <= n; i++)
#define FOR(i,m,n) for(i = m, i < n; i++)
#define repr(i,n) for(i = n; i >= 0; i--)
#define INF = 999999999
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD = 1000000007;

  
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << min(a,b) + min(c,d) << endl;

  return 0;  
}

       


Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


n = ni()

ans = 0
for i in range(10):
    if n <= 111*i:
        ans = 111*i
        break
        
print(ans)

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

int n, k;
int main() {
  cout << fixed << setprecision(12);
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  double ans = 0.0;
  for (int i = 1; i <= n; i++) {
    double tmp = 1.0/n;
    double money = i;
    while (money < k) {
      money *= 2.0;
      tmp /= 2.0;
    }
    ans += tmp;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdint>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

vector<bool> sieve(int x) { // range...[0,x]
    vector<bool> flags(x + 1, true);
    flags[0] = false, flags[1] = false;
    for(int i = 2; i * i <= x; i++) {
        if(!flags[i])
            continue;
        for(int mult = i * i; mult < x; mult += i)
            flags[mult] = false;
    }
    return flags;
}

int main() {
    auto primes = sieve(100010);
    vector<int> sum(100010);
    FOR(i, 1, 50001) {
        if(primes[i] && primes[2 * i - 1]) {
            sum[2 * i - 1]++;
        }
    }

    rep(i, 100001) { sum[i + 1] += sum[i]; }
    int Q;
    cin >> Q;
    while(Q--) {
        int l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l - 1] << "\n";
    }
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    int A[500][500];
    pair<int, int> pos[500*500];
    for(int i=0; i<N*N; i++){
        int p;
        cin >> p;
        p--;
        A[p/N][p%N] = i;
        pos[i] = {p/N, p%N};
    }

    auto encode = [&](int i, int j){ return i*N+j; };
    auto inside = [&](int i, int j){ return i>=0 && i<N && j>=0 && j<N; };
    int dx[] = {0, 0, -1, 1};
    int dy[] = {1, -1, 0, 0};

    int D[500][500];
    for(int i=0; i<N; i++) for(int j=0; j<N; j++) D[i][j] = min({i, N-1-i, j, N-1-j});
    
    int ans = 0;
    for(int T=0; T<N*N; T++){
        int i = pos[T].first, j = pos[T].second;
        ans += D[i][j];
        queue<pair<int, int>> que;
        que.emplace(i, j);
        while(que.size()){
            auto p = que.front(); que.pop();
            int s = p.first, t = p.second;
            int d2 = D[s][t] + (A[s][t] > T);
            for(int k=0; k<4; k++){
                int x = s+dx[k], y = t+dy[k];
                if(inside(x, y) && d2 < D[x][y]){
                    D[x][y] = d2;
                    que.emplace(x, y);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7468
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def r_sort(a) a.sort{|a,b|b<=>a} end

n = inp[0]
p n*(n-1)/2


Measured memory_bytes: 1788
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

ll inf=9223372036854775806,ans=0;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a[3],d1,d2,ans=0;
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	d1=a[2]-a[0];
	d2=a[2]-a[1];
	ans+=d1/2;
	d1%=2;
	ans+=d2/2;
	d2%=2;
	if (d1+d2==1){
		ans+=2;
	}
	else if (d1+d2==2){
		ans++;
	}
	cout<<ans;
	return 0;
}

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

string s[]{"Sunny","Cloudy","Rainy"};
int main()
{
    string tmp;
    cin>>tmp;
    for(int i=0;i<3;++i)
    {
        if(tmp==s[i])
            cout<<s[(i+1)%3]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <tuple>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<vector<int,int>> vii;
#define rep(i,n) for (int i=0;i<n;i++);

ll mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    bool ans = false;
    for (int i=1;i<=9;i++){
        for (int j=1;j<=9;j++){
            if (i*j==n) ans = true;
        }
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

#define MOD 1000000007


int main(){
    int N; cin >> N;
    int M; cin >> M;
    long long memo[100010] = {};
    memo[0] = 1;
    for(int i = 1; i <= max(N, M); i++){
        memo[i] = memo[i-1] * i % MOD;
    }
    long long ans = 1;
    if(abs(N-M) > 1) ans = 0;
    else if(N==M){
        ans = memo[N] * memo[M] * 2 % MOD;
    }
    else{
        ans = memo[N] * memo[M] % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<vector>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int n,s[500010];
inline int lowbit(int x){return x&-x;}
inline void add(int x,int k)
{
	if(!x)return ;
	while(x<=n)
	{
		s[x]+=k;
		x+=lowbit(x);
	}
}
inline int getsum(int x)
{
	int sum=0;
	while(x)
	{
		sum+=s[x];
		x-=lowbit(x);
	}return sum;
}
struct node
{
	int l,id;
}ul;
vector<node>q[500010];
int pre[500010],p[500010];
int ans[500010];
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    n=read();int Q=read();
    for(int i=1;i<=n;i++)
    {
    	int uf=read();
    	pre[i]=p[uf],p[uf]=i;
    }
    for(int i=1;i<=Q;i++)
    {
    	ul.l=read();int r=read();ul.id=i;
    	q[r].push_back(ul);
    }
    for(int i=1;i<=n;i++)
    {
    	add(i,1),add(pre[i],-1);
    	int uf=getsum(i);
    	for(int j=0;j<q[i].size();j++)ans[q[i][j].id]=uf-getsum(q[i][j].l-1);
    }
    for(int i=1;i<=Q;i++)pr2(ans[i]);
    return 0;
}

Measured memory_bytes: 33208
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;

    char A,B;

int main(){
    cin>>A>>B;
    if(A!=B)cout<<(A>B?">":"<");
    else cout<<"=";
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    while(true){
        int n, m, t, p;
        cin >> n >> m >> t >> p;

        if(n == 0 && m == 0 && t == 0 && p == 0){
            break;
        }

        vector<vector<int>> a(n*2, vector<int>(m*2, 0));
        rep(i, n){
            rep(j, m){
                a[i][j] = 1;
            }
        }
        rep(i, t){
            int d, c;
            cin >> d >> c;

            if(d == 1){
                for(int j = c; j < n + c; j++){
                    int s = c*2-1;
                    if(s-j < 0){
                        break;
                    }
                    rep(k, m){
                        a[j][k] += a[s-j][k];
                        a[s-j][k] = 0;
                    }
                }
                for(int j = c; j < n + c; j++){
                    rep(k, m){
                        a[j-c][k] = a[j][k];
                        a[j][k] = 0;
                    }
                }
                n = max(c, n-c);
            }

            if(d == 2){
                for(int j = c; j < m + c; j++){
                    int s = c*2-1;
                    if(s-j < 0){
                        break;
                    }
                    rep(k, n){
                        a[k][j] += a[k][s-j];
                        a[k][s-j] = 0;
                    }
                }
                for(int j = c; j < m + c; j++){
                    rep(k, n){
                        a[k][j-c] = a[k][j];
                        a[k][j] = 0;
                    }
                }
                m = max(c, m-c);
            }
        }

        rep(i, p){
            int x, y;
            cin >> x >> y;
            cout << a[x][y] << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3188
#include<stdio.h>

int main(void)
{
  int N,i,A;
  char S[100000];
  scanf("%d\n",&N);
  scanf("%s",&S);
  
  A=1;
  
  for(i=0;i<=N-2;i++){
    if(S[i]!=S[i+1]){
      A=A+1;
    }
  }
  
  printf("%d",A);
  
  return 0;
}

Measured memory_bytes: 256
def main():

    H, W = map(int, input().split())

    mat = []
    for _ in range(H):
        A = input()

        flag = False
        for a in A:
            if a != '.':
                flag = True
        if flag:
            mat.append(A)

    l = []
    for i in range(W):
        flag = True
        for ary in mat:
            if ary[i] != '.':
                flag = False
                break
        if not flag:
            l.append(i)

    for s in mat:
        for i in l:
            print(s[i], end="")
        print()

main()

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int r;
  cin >> r;
  if(r < 1200) cout << "ABC" << endl;
  else if(r < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;

  return 0;
}


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


int main() {
    string s; cin >> s;

    int n = 753;
    int diff = 753;

    for (int i = 0; i < s.size() - 2; ++i) {
        if(abs(stoi(s.substr(i,3)) - n) < diff) diff = abs(stoi(s.substr(i,3)) - n);
    }
    print(diff);

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	static class Dice {
		private int[] sides;

		Dice(String line) {
			String[] sides = line.split(" ");
			this.sides = new int[sides.length];
			for (int i = 0; i < sides.length; i++) {
				this.sides[i] = Integer.parseInt(sides[i]);
			}
		}

		Dice(int[] sides) {
			this.sides = sides;
		}

		private static int[][] eastTable = {
			{6, 2, 4, 1, 3, 6},
			{3, 6, 0, 5, 6, 2},
			{1, 5, 6, 6, 0, 4},
			{4, 0, 6, 6, 5, 1},
			{2, 6, 5, 0, 6, 3},
			{6, 3, 1, 4, 2, 6}
		};

		public static int getEast(Dice dice, final int tnum, final int snum) {
			boolean tflag = false;
			boolean sflag = false;
			int top = 0;
			int south = 0;
			int[] sides = dice.sides;
			for (int i = 0; i < sides.length; i++) {
				if (tnum == sides[i]) {
					top = i;
					tflag = true;
					if (sflag) {
						break;
					}
				} else if (snum == sides[i]) {
					south = i;
					sflag = true;
					if (tflag) {
						break;
					}
				}
			}

			int east;
			int eastSide = eastTable[top][south];

			if (eastSide == 6) {
				east = -1;
			} else {
				east = sides[eastSide];
			}

			return east;
		}

		public static boolean isIdentification(Dice dice1, Dice dice2) {
			boolean isEqual = false;

			for (int i = 0; i < 6; i++) {
				if (isEqual) {
					break;
				}

				if (dice1.sides[0] == dice2.sides[i] && dice1.sides[5] == dice2.sides[5-i]) {
					for (int j = 0; j < 6; j++) {
						if (isEqual) {
							break;
						} else if (j == i) {
							continue;
						}

						if (dice1.sides[1] == dice2.sides[j] && dice1.sides[4] == dice2.sides[5-j]) {
							for (int k = 0; k < 6; k++) {
								if (isEqual) {
									break;
								} else if (k == i || k == j) {
									continue;
								}

								if (dice1.sides[2] == dice2.sides[k] && dice1.sides[3] == dice2.sides[5-k]) {
									if (dice1.sides[2] == Dice.getEast(dice2, dice2.sides[i], dice2.sides[j])) {
										isEqual = true;
									} else if (dice2.sides[k] == dice2.sides[5-k]) {
										isEqual = true;
									}
								}
							}
						}
					}
				}
			}

			return isEqual;
		}
	}

	public static void main(String[] args) {
		try {
			BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			boolean isEqual = false;

			int n = Integer.parseInt(in.readLine());
			Dice[] dices = new Dice[n];
			for (int i = 0; i < n; i++) {
				dices[i] = new Dice(in.readLine());
			}
			in.close();

			for (int i = 0; i < n; i++) {
				if (isEqual) break;
				
				for (int j = i+1; j < n; j++) {
					if (Dice.isIdentification(dices[i], dices[j])) {
						isEqual = true;
						break;
					}
				}
			}

			System.out.println(isEqual ? "No" : "Yes");
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}

Measured memory_bytes: 18040
#include<iostream>
#include<vector>
#include<algorithm>
#include<bitset>
using namespace std;
typedef long long ll;

int main() {
	//s'<t'とできるか
	string s, t;
	cin >> s >> t;
	vector<int> sv,tv;
	for (int i = 0; i < s.length(); i++) {
		sv.push_back((int)s[i]);
	}
	sort(sv.begin(), sv.end());
	for (int i = 0; i < t.length(); i++) {
		tv.push_back((int)t[i]);
	}
	sort(tv.begin(), tv.end());
	reverse(tv.begin(), tv.end());
	int i = 0;
	while (1) {
		if (sv[i] < tv[i]) {
			cout << "Yes" << endl;
			break;
		}
		if (sv[i] > tv[i]) {
			cout << "No" << endl;
			break;
		}
		if ((sv.size() - 1) == i && (tv.size() - 1) == i) {
			cout << "No" << endl;
			break;
		}
		if ((sv.size() - 1) == i) {
			cout << "Yes" << endl;
			break;
		}
		if((tv.size() - 1) == i) {
			cout << "No" << endl;
			break;
		}
		i++;
	}
	return 0;
}

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

int main()
{
  int d, n, ans;
  cin >> d >> n;
  if(n == 100) n = 101;
  if(d == 0) ans = n;
  if(d == 1) ans = n * 100;
  if(d == 2) ans = n * 10000;
  cout << ans << endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
l=[[] for _ in range(3)]
ans=1
p=10**9+7
flag=1
for i in range(N):
    cnt=0
    piv=A[i]
    ind=[]
    for j in range(3):
        if len(l[j])==piv:
            cnt=cnt+1
            ind.append(j)
    if len(ind)==0:
        flag=0
        break
    l[ind[0]].append(piv)
    ans=(ans*cnt)%p
    #print(l,ans)
    #input()
if flag==1:
    print(ans%p)
else:
    print(flag)



Measured memory_bytes: 54744
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int N;
  scanf("%d", &N);
  
  char *S = NULL;
  S = (char *)malloc(sizeof(char) * N);
  scanf("%s", S);

  int *cnt = NULL;
  cnt = (int *)malloc(sizeof(int) * N);
  int cnt_min;

  cnt[0]=0;
  for(int i=1; i<N; i++){
    if(S[i]=='E'){
      cnt[0]++;
    }
  }
  cnt_min=cnt[0];

  for(int i=1; i<N; i++){
    cnt[i]=cnt[i-1];
    if(S[i-1]=='W') cnt[i]++;
    if(S[i]=='E') cnt[i]--;
    
    if(cnt[i]<cnt_min){
      cnt_min = cnt[i];
    }
  }

  printf("%d\n", cnt_min);

  free(S);
  free(cnt);
  
  return 0;
}

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

#define ll long long
#define int long long
#define loop(i,s,e) for(int i=s;i<e;i++)
#define rloop(i,s,e) for(int i=e;i>=s;i--)
#define fr first
#define sc second
#define pb push_back
#define  vii vector<int>
#define vll vector<ll>
#define vpii vector<pair<int ,int >>
#define vpll vector<pair<ll, ll> >
#define  pii pair<int,int>
#define lb(v,x) lower_bound(v.begin(),v.end(),x);
#define ub(v,x) upper_bound(v.begin(),v.end(),x);
const long mod =1e8;
const int N = 5e6+5;
const long long inf= 1e18;

ll gcd(ll a ,ll b){if(b==0) return a;return gcd(b,a%b);}
ll mul(ll a ,ll b){return (a%mod * b%mod )%mod;}
ll mpower(ll a, ll b){if(b==0) return 1;ll temp=mpower(a,b/2);if(b%2==0){return mul(temp,temp);}else{	return mul(mul(temp,temp) , a);}}
ll inv(ll a){return mpower(a,mod-2);}
ll ncr(ll n, ll r){if(r==0)return 1;ll ans=n%mod;ans=mul(ans,ncr(n-1,r-1));ans=mul(ans,inv(r));	return ans;}
ll power(ll a, ll b){if(b==0) return 1;ll temp=power(a,b/2);if(b%2==0)return temp*temp;else return temp*temp*a;}
ll add(ll a, ll b){return (a%mod + b%mod)%mod;}
int n,m,q,a,b,c,d;



void solve()
{
   cin>>a>>b>>n;
   ll x= min(n,b-1);
   ll ans =(a*x)/b;
   cout<<ans;
}

int32_t main()
{
	ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;//cin>>t;
	while(t--){
        solve();
	}
}

Measured memory_bytes: 3648
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#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 ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(a + b == 15) {
        cout << "+" << endl;
    } else if(a * b == 15) {
        cout << "*" << endl;
    } else {
        cout << "x" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
using namespace std;
#define MAX_N 100

int A[MAX_N];
map<char,int> Map;
int main()
{
  int n;
  char mark;
  int d;
  int Digit[4][13];
  for(int i = 0;i < 4;i++){
    for(int j = 0;j <13;j++){
      Digit[i][j] =0;
    }
  }
  cin >> n;
  while(n--){
    cin >>mark>>d;
    if(mark=='S')
      Digit[0][d-1] =1;
    else if(mark =='H')
      Digit[1][d-1] =1;
    else if(mark =='C')
      Digit[2][d-1] =1;
    else
      Digit[3][d-1] =1;
  }
  for(int i = 0;i <4;i++){
    for(int j = 0;j < 13;j++){
      if(!Digit[i][j]){
	if(i ==0)
	  cout <<'S' <<" "<< j+1<<endl;
	else if(i ==1)
	  cout <<'H' <<" "<<j+1<<endl;
	else if(i ==2)
	  cout<<'C'<<" "<<j+1<<endl;
	else if(i ==3)
	  cout<<'D'<<" "<<j+1<<endl;
      }
    }
  }
	
  
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void)
{
	char map[13][13];
	char empty;
	int i, j;
	
	while (1){
		for (i = 0; i < 8; i++){
			scanf("%s", map[i]);
			getchar();
		}
		for (i = 0; i < 8; i++){
			for (j = 0; j < 8; j++){
				if (map[i][j] == '1' && map[i][j + 1] == '1' && map[i + 1][j] == '1' && map[i + 1][j + 1] == '1')  printf("A\n");
				if (map[i][j] == '1' && map[i + 1][j] == '1' && map[i + 2][j] == '1' && map[i + 3][j] == '1') printf("B\n");
				if (map[i][j] == '1' && map[i][j + 1] == '1' && map[i][j + 2] == '1' && map[i][j + 3] == '1') printf("C\n");
				if (map[i][j] == '1' && map[i + 1][j] == '1' && map[i + 1][j - 1] == '1' && map[i + 2][j - 1] == '1') printf("D\n");
				if (map[i][j] == '1' && map[i][j + 1] == '1' && map[i + 1][j + 1] == '1' && map[i + 1][j + 2] == '1') printf("E\n");
				if (map[i][j] == '1' && map[i + 1][j] == '1' && map[i + 1][j + 1] == '1' && map[i + 2][j + 1] == '1') printf("F\n");
				if (map[i][j] == '1' && map[i][j + 1] == '1' && map[i + 1][j] == '1' && map[i + 1][j - 1] == '1') printf("G\n");
			}
		}
		
		if (scanf("%c", &empty) == EOF) break;
	}
	
	return (0);
}

Measured memory_bytes: 0
n, k = map(int, input().split())
s = input()

prev = s[0]
line = []
cnt = 1
for v in s[1:]:
    if v != prev:
        prev = v
        line.append(cnt - 1)
        cnt = 1
    else:
        cnt += 1
line.append(cnt - 1)

k = min(len(line) // 2, k)
print(sum(line) + k * 2 - (len(line) // 2 == k and len(line) % 2 == 0))


Measured memory_bytes: 45680
import sys
from math import ceil
input=sys.stdin.readline
_lii=lambda :list(map(int, input().strip('\n').split()))
_i=lambda :input().strip('\n')
res=[]
g={'AC':0, 'WA':0, 'TLE':0, 'RE':0}
for _ in range(int(input())):
	g[input().strip('\n')]+=1
for c in g.keys():
	print(c, 'x', g[c])
	#res.append(ans)
#print('\n'.join(map(str, res)))

Measured memory_bytes: 9204
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			int a = sc.nextInt();
			int b = sc.nextInt();
			int d = 0;
			int r = 0;
			double f = (double)a / b;
			d = a / b;
			r = a % b;
			System.out.printf("%d %d %f",d ,r ,f);
	}
}

Measured memory_bytes: 26408
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


vector<int> deduplicate(vector<int> a) {
    sort(a.begin(),a.end());
    auto itr=unique(a.begin(),a.end());
    a.resize(itr-a.begin());
    return a;
}

int main() {
    ios_base::sync_with_stdio(false); 

    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    vector<int> xx,yy;
    rep(i,3010) {
        rep(j,3010) {
            int s=a*100*i+b*100*j;
            int t=c*i+d*j;
            if (s>0 && s<=f) xx.push_back(s);
            if (t>=0 && t<=f) yy.push_back(t);
        }
    }
    vector<int> x=deduplicate(xx),y=deduplicate(yy);
    double r=0;
    int sw=a*100,su=0;
    rep(i,x.size()) {
        rep(j,y.size()) {
            if (x[i]+y[j]<=f && 1.0*y[j]/(x[i]+y[j])>r && 1.0*y[j]/(x[i]+y[j])<=1.0*e/(100+e)) {
                r=1.0*y[j]/(x[i]+y[j]);
                sw=x[i]+y[j];
                su=y[j];
            }
        }
    }
    cout << sw << ' ' << su << endl;

    return 0;
}

Measured memory_bytes: 2292
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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


Measured memory_bytes: 3560
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))


SINT32 main() {
    SINT64 ans = 0;
    SINT64 max = 5;

    SINT64 max2 = 0;

    SINT64 n;
    scanf("%lld",&n);

    
    SINT64 *data = malloc(sizeof(SINT64)*max);
    for (SINT32 i = 0; i < max; i++) {
        scanf("%lld", &data[i]);
        if (i == 0) {
          max2 =  data[i];
        }

        if (data[i] < max2) {
            max2 = data[i];
        }
    }


    if ((n %max2) == 0) {
        ans =  n /max2 + 4;
    } else {
        ans = n /max2 + 5;
    }


    printf("%lld\n",ans);
    free(data);
	return 0;
}

Measured memory_bytes: 128