akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);

int main()
{
	ll n;
	cin>>n;
	ll h[n],dp[n],i;
	for(i=0;i<n;i++)
	{
		dp[i]=mod;
		cin>>h[i];
	}
	dp[0]=0;
	for (i = 0; i < n; ++i)
	{
		if(i+1<n)
			dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
		if(i+2<n)
			dp[i+2]=min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
	}
	cout<<dp[n-1];
} 

Measured memory_bytes: 1792
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 C = sc.nextInt();
    int K = sc.nextInt();
    int ans = 0;

    int cntA = 0;
    for (int i = 0; i < A; i++) {
      if (cntA == K) {
        break;
      }
      ans += 1;
      cntA++;
    }

    int cntB = 0;
    for (int i = 0; i < B; i++) {
      if (cntB == K - cntA) {
        break;
      }
      ans += 0;
      cntB++;
    }

    int cntC = 0;
    for (int i = 0; i < C; i++) {
      if (cntC == K - cntA - cntB) {
        break;
      }
      ans -= 1;
      cntC++;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 35864
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

bool debug=false;
/*---------------------------------------------------*/

int main(){
    int a,b,sum,keta;
    while(cin>>a>>b){
        sum=a+b;
        for(keta=1;;keta++){
            sum=sum/10;
            if(sum==0)break;
        }
        cout<<keta<<endl;
    }
    return 0;
}

Measured memory_bytes: 3016
#include<iostream>
//#include<cmath>
//#include<cstring>
//#include<vector>
#include<bits/stdc++.h>
//#include<algorithm>

using namespace std;
int main(){
  int k,x;
  cin>>k>>x;
  if(k*500>=x){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }

  return 0;
}

/*---------
 double n,m,a;
    cin>>n>>m>>a;
    cout<<(ceil(n/a)*ceil(m/a));

*/




/* int n;
  cin >> n;_.-
  for (int y=0; y<2*n+1; y++) {
    int c = 0;
    for (int x=0; x<2*n+1; x++) {
      int nx = x;
      int ny = y;
      if (nx>n) {
        nx -= (nx-n)*2;
      }
      if (ny>n) {
        ny -= (ny-n)*2;
      }
      int p = nx+ny-n;
      if (p>=0) {
        cout << p;
        c++;
        if (c >= 2*ny+1) {
          break;
        } else {
          cout << " ";
        }
      } else {
        cout << "  ";
      }
    }
    cout << endl;
  }
  return 0;
}*/
 /*----------my code--------------
  int n,a,b,c,d,space,i,j,apply;
    cin>>n;
    b=2*n+1;
    for(i=0;i<b;i++){
        space=2(n-1);
        for(j=0;j<b;j++){
            if(space>0){
                apply=space/2;
                for()
            }
        }

        int n,a,b,c,d,space,i,j,k,apply,index;
    cin>>n;
    b=2*n+1;
    for(i=0;i<b;i++){
        space=2(n-i);
        apply=space/2;
        for(j=0,k=0;j<b;j++,k++){
            if(space>1){
                    if(k<i){
                            index=apply+1;
                a[index]=k;
            index++;
            }
            if(k>=i){
                a[]
            }
            }
            }
        }
    }

   for
    }*/
    /*--------------------

    int main() {
	int n;
	cin>>n;
	int x[n],y[n];
	for(int i=0;i<n;i++)
	{
		cin>>x[i]>>y[i];
	}
	int u=0,d=0,l=0,r=0,ans=0;
	for(int i=0;i<n;i++)
	{
		u=0;d=0;l=0;r=0;
		for(int j=0;j<n;j++)
		{
			if(x[i]==x[j]&&y[i]>y[j])d=1;
			if(x[i]==x[j]&&y[i]<y[j])u=1;
			if(y[i]==y[j]&&x[i]>x[j])l=1;
			if(y[i]==y[j]&&x[i]<x[j])r=1;
		}
		if(d&&u&&l&&r)ans++;
	}
	cout<<ans<<endl;
}-----------*/


Measured memory_bytes: 3604
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s []byte
	fmt.Scan(&s)
	var ans string
	// for bit := 0; bit < (1 << uint(len(s)-1)); bit++ {
	for bit := 0; bit < (1 << 3); bit++ {
		sum, _ := strconv.Atoi(string(s[0]))
		ans = string(s[0])
		for j := 0; j < len(s)-1; j++ {
			t, _ := strconv.Atoi(string(s[j+1]))
			if bit&(1<<uint(j)) != 0 {
				sum += t
				ans += "+" + string(s[j+1])
			} else {
				sum -= t
				ans += "-" + string(s[j+1])
			}
		}
		if sum == 7 {
			fmt.Println(ans + "=7")
			return
		}
		// fmt.Printf("bit %05b, sum %d, ans %s\n", bit, sum, ans)
	}
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	W, H, x, y := sc.nextFloat(), sc.nextFloat(), sc.nextFloat(), sc.nextFloat()
	total := W * H
	fmt.Print(total / 2)
	fmt.Print(" ")
	if x == W/2 && y == H/2 {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long L[]; L = new long[n];
    for (int i = 0; i < n; i++){
      long l = scan.nextLong();
      L[i] = l;
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
      for (int j = i+1; j < n; j++){
        for (int k = j+1; k < n; k++){
          if (L[i] == L[j] || L[i] == L[k] || L[j] == L[k]){
            continue;
          }else{
            if (L[i]+L[j] > L[k] && L[i]+L[k] > L[j] && L[j]+L[k] > L[i]){
              ans++;
            }
          }
        }
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 36832
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;


void Main(){
    string s, t; cin >> s;
    t = s;
    reverse(all(s));
    if(s == t) puts("Yes");
    else puts("No");
    return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3572
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
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();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,K;
  cin>>N>>K;
  ll L[K],R[K];
  REP(i,N) cin>>L[i]>>R[i];
  
  ll DP[N]={},SDP[N+1]={};
  DP[0]=1,SDP[1]=1;
  
  for(int i=1; i<N; ++i){
    REP(j,K){
      ll left=max(0ll,i-R[j]);
      ll right=max(0ll,i-L[j]+1);
      DP[i]+=SDP[right]-SDP[left];
      DP[i]=(DP[i]%MMOD+MMOD)%MMOD;
    }
    SDP[i+1]=SDP[i]+DP[i];
    SDP[i+1]=(SDP[i+1]%MMOD+MMOD)%MMOD;
  }
  
  cout<<DP[N-1]<<endl;
  return 0;
}

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

int main() {
  string number;
  int sum = 0;
  while(1){
    cin >> number;
    if(number.size() <= 1 && stoi(number) == 0) break;
    sum = 0;
    for(unsigned int i = 0; i < number.size(); i++){
      string num{number[i]};
      sum += stoi(num);
    }
    cout << sum << endl;
  }
  return 0;
}



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

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

int main(){
  long long n, k;
  cin >> n >> k;

  vector<long long> a(n);
  rep(i, n) cin >> a.at(i);

  vector<long long> ikisaki(n+1);
  long long lastcity = 1;
  long long shuuki = 1;
  ikisaki.at(0) = 1;
  bool flag = true;

  vector<long long> itta(n+1, -1); 
  int j=1;
  int saisho = 0;
  
  while(flag){
    //cout << j << " " << lastcity << endl; 
    ikisaki.at(j) = a.at(lastcity-1);
    lastcity = a.at(lastcity-1);
    if(itta.at(lastcity-1) == -1){
      itta.at(lastcity-1) = j;
      j++;      
    }else{
      saisho = itta.at(lastcity-1);
      shuuki = j-itta.at(lastcity-1);
      flag = false;
    }
    
    
  }

  //rep(i, ikisaki.size()) cout << ikisaki.at(i);
  //cout << endl;
  //cout << saisho;

  if(k<saisho) cout << ikisaki.at(k);
  else{
    long long amari = (k-saisho)%shuuki;
    cout << ikisaki.at(saisho+amari);
  }
  
  
}


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

int main(){
    int n;
    cin >> n;
    int A[n], Ans = 1, up = 0, down = 0;
    for(int i=0;i<n;i++){
        cin >> A[i];
        if(i==0){continue;}
        if(A[i-1] == A[i]){continue;}
        if(A[i-1] < A[i]){
            if(down != 0){
                down = 0;
                Ans++;
            }
            else{
                up++;
            }
        }
        else if(A[i-1] > A[i]){
            if(up != 0){
                up = 0;
                Ans++;
            }
            else{
                down++;
            }
        }
    }

    cout << Ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>

using namespace std;
int main() {

	long long n=0;

	cin >> n;
	long double x=0;
	string u;

	long double sum=0;
	for (int i = 0; i<n; i++) {
		long double x = 0;
		string u;
		cin >> x >> u;
		if (u == "JPY") {
			sum += x;
		}
		else {
			sum += x * 380000.;
		}
	}
	cout << sum << endl;
	return 0;

}

Measured memory_bytes: 256
N, M, K = map(int, input().split())
A_temp = [int(i) for i in input().split()]
B_temp = [int(i) for i in input().split()]

A, B = [0]*(N+1), [0]*(M+1)
for i in range(1, N+1):
    A[i] = A[i-1] + A_temp[i-1]
    
for j in range(1, M+1):
    B[j] = B[j-1] + B_temp[j-1]
    
ans = 0
for a in range(N+1):
    if A[a] > K:
        break
    for b in range(ans-a+1, M+1):
        if A[a] + B[b] > K:
            break
        ans = max(ans, a+b)
        
print(ans)

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    string s, t; cin >> s >> t;
    cout << t << s << endl;

    return 0;
}


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

int main(){
    int A,B,C,X,count=0;

    cin>>A>>B>>C>>X;

    for(int i=0;i<=A;i++){
        for(int j=0;j<=B;j++){
            for(int k=0;k<=C;k++){
                if(500*i+100*j+50*k==X) count++;
            }
        }
    }

    cout<<count<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,i,F[45];
  scanf("%d",&n);
  F[0] = 1;
  F[1] = 1;
  for(i=2;i<=n;i++)F[i] = F[i-1] + F[i-2];
  printf("%d\n",F[n]);
  return 0;
}

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int64_t> p(N);
  for(int i=0;i<N;i++){
    cin>>p.at(i);
  }
  vector<pair<int,int>> q(M);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    q.at(i)=make_pair(b,a);
  }
  sort(p.begin(), p.end());
  sort(q.begin(), q.end());
  reverse(q.begin(), q.end());
  int a=0,A=0;
  for(int i=0;i<M;i++){
    int b,c;
    tie(b,c)=q.at(i);
    for(int j=a;j<a+c;j++){
      if(j>=N){
        A=1;
        break;
      }
      else if(p.at(j)>=b){
        A=1;
        break;
      }
      else{
        p.at(j)=b;
      }
    }
    a+=c;
    if(A==1){
      break;
    }
  }
  int64_t Z=0;
  for(int i=0;i<N;i++){
    Z+=p.at(i);
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N, K;
	int R, S, P;
	string T;
	cin >> N >> K;
	cin >> R >> S >> P;
	cin >> T;

	lint ans = 0;
	for (int i = 0; i < min(N, K); i++)
	{
		int before = 0;

		for (int j = 0; j * K + i < N; j++)
		{
			if (T[j * K + i] == 'r')
			{
				if (before == 3)
				{
					before = 0;
				}
				else
				{
					ans += P;
					before = 3;
				}
			}
			if (T[j * K + i] == 's')
			{
				if (before == 1)
				{
					before = 0;
				}
				else
				{
					ans += R;
					before = 1;
				}
			}
			if (T[j * K + i] == 'p')
			{
				if (before == 2)
				{
					before = 0;
				}
				else
				{
					ans += S;
					before = 2;
				}
			}
		}
	}
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(){
 int N, n, i;
 unsigned long a[3];
 a[0] = 2;
 a[1] = 1;

 scanf("%d",&N);
 for(i=0; i<N-1;i++){
  n = i % 3;
  a[(n+2)%3] = a[n] + a[(n+1)%3];
  //printf("%3d:%ld\n",i+3,a[(n+2)%3]);
 }
 if(N==1){
  printf("1");
 }else if(N==0){
  printf("2");
 }else{
  printf("%ld",a[(n+2)%3]);
 }
 return 0;
}

Measured memory_bytes: 128
#include <iostream>

const long long MOD = 1e9 + 7;
const long long MAX = 5000;
using ll = long long;
using namespace std;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  COMinit();

  ll s;
  cin >> s;
  ll ans = 0;
  for (ll i = 1; i * 3 <= s; i++) {
    ll t = s - i * 2;
    ans = (ans + COM(t - 1, i - 1)) % MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3748
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var s = Console.ReadLine();
        int count = 0;
        for (int i = 0, j = s.Length - 1; i < j; i++, j--)
        {
            if (s[i] != s[j])
            {
                count++;
            }
        }

        Console.WriteLine(count);
    }
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

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

    char sign[2] = {'-', '+'};
    bool f = false;
    for(ll i=-1; i<2; i+=2) {
        for(ll j=-1; j<2; j+=2) {
            for(ll k=-1; k<2; k+=2) {
                if((S[0]-'0')+i*(S[1]-'0')+j*(S[2]-'0')+k*(S[3]-'0')==7) {
                    cout << S[0] << sign[(i+1)/2] << S[1] << sign[(j+1)/2] << S[2] << sign[(k+1)/2] << S[3] << "=7" << endl;
                    f = true;
                    break;
                }
            }
            if(f) break;
        }
        if(f) break;
    }

    return 0;
}

/*



*/

Measured memory_bytes: 3620
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int res = 0;
        
        boolean a[] = {false,false,false,false,false,false,false,false,false,false};
        boolean b[] = {false,false,false,false,false,false,false,false,false,false};
        boolean c[] = {false,false,false,false,false,false,false,false,false,false};
        
        for(int i = 0;i < S.length();i++){
            int a1 = Character.getNumericValue(S.charAt(i));
            if(!a[a1]){
                a[a1] = true;
                for(int j = i + 1;j < S.length();j++){
                    int b1 = Character.getNumericValue(S.charAt(j));
                    if(!b[b1]){
                        b[b1] = true;
                        for(int k = j + 1;k < S.length();k++){
                            int c1 = Character.getNumericValue(S.charAt(k));
                            if(!c[c1]){
                                c[c1] = true;
                                res++;
                            }
                        }
                        for(int q = 0;q < 10;q++){
                            c[q] = false;
                        }
                    }
                }
                for(int q = 0;q < 10;q++){
                    b[q] = false;
                }
            }
        }
        
      	System.out.println(res);
    }
}


Measured memory_bytes: 23380
# from sys import exit
A, B = [int(n) for n in input().split()]
# N = int(input())
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())
# exit()
if A >= 13:
    print(B)
elif 6 <= A <= 12:
    print(B//2)
else:
    print(0)


Measured memory_bytes: 2940
S = list(map(str, input()))

def f():
	for i in range(1, len(S)):
		if S[i - 1] == S[i]:
			return i, i + 1
	for i in range(2, len(S)):
		if S[i - 2] == S[i - 1] or S[i - 1] == S[i] or S[i - 2] == S[i]:
			return i - 1, i + 1
	return -1, -1
			
print(*f())

Measured memory_bytes: 48368
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <array>

using namespace std;
using ll = long long;

int main()
{
    ll N;
    array<ll, 200001> A, B;
    cin >> N;
    for (ll i = 0; i < N; i++) cin >> A[i] >> B[i];

    sort(A.begin(), A.begin() + N);
    sort(B.begin(), B.begin() + N);

    if (N % 2)
    {
        cout << B[N / 2] - A[N / 2] + 1 << endl;
    }
    else
    {
        cout << (B[N / 2] + B[N / 2 - 1]) - (A[N / 2] + A[N / 2 - 1]) + 1 << endl;
    }
}

Measured memory_bytes: 6764
N, M = map(int, input().split())
V = list(map(int, input().split()))
ans = [1]*N

for i in range(M):
    A,B = map(int, input().split())
    if V[A-1] < V[B-1]:
        ans[A-1] = 0
    elif V[A-1] > V[B-1]:
        ans[B-1] = 0
    else:
        ans[A-1] = 0
        ans[B-1] = 0

print(sum(ans))

Measured memory_bytes: 19964
#C - Maximal Value
N = int(input())
B = list(map(int,input().split()))
A = [B[0]]
for i in range(1,N-1):
    if B[i] > B[i-1]:
        A.append(B[i-1])
    else:
        A.append(B[i])
A.append(B[-1])
print(sum(A))

Measured memory_bytes: 9128
N,M=map(int,input().split())#N 種類の数 M 選ぶ品物の数
A=list(map(int,input().split()))#得票数

m=sum(A)/(4*M)

A=[i for i in A if i>=m]

if len(A)>=M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll a, b, c; cin >> a >> b >> c;
    vi cost(3);
    cost[0] = a;
    cost[1] = b;
    cost[2] = c;
    sort(all(cost));
    cout << cost[0] + cost[1] << endl;
}

Measured memory_bytes: 256
def run_length_compress(S):
    res = [[S[0], 1]]
    for c in S[1:]:
        if c == res[-1][0]:
            res[-1][1] += 1
        else:
            res.append([c, 1])
    return res


S = input()
N = len(S)
K = int(input())
T = run_length_compress(S)
if T[0][1] == N:
    print(N * K // 2)
    exit()
ans = sum(l // 2 for _, l in T) * K
if T[0][0] == T[-1][0]:
    head, tail = T[0][1], T[-1][1]
    ans += ((head + tail) // 2 - head // 2 - tail // 2) * (K - 1)
print(ans)


Measured memory_bytes: 9160
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
using ll = long long;
using P = pair<int,int>;

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;

  if((b-a <= k)&&
  (c-a <= k)&&
  (d-a <= k)&&
  (e-a <= k)&&
  (c-b <= k)&&
  (d-b <= k)&&
  (e-b <= k)&&
  (d-c <= k)&&
  (e-c <= k)&&
  (e-d <= k)) {
    cout << "Yay!" << endl;
  }
  else {
  cout << ":(" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>
#include <stack>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

ostream& operator<<(ostream& os, const pair<char, int>& unit) {
  return os << unit.first << "^" << unit.second;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int N = 300010;

int n, l;
int x[N], t[N];
bool canl[N], canr[N];

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  cin >> n >> l;
  for (int i = 1; i <= n; ++i)
    cin >> x[i];
  for (int i = 1; i <= n; ++i)
    cin >> t[i];
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans += (t[i] - 1) / l / 2;
    t[i] %= l * 2;
    if (t[i] == 0) t[i] += l * 2;
    canr[i] = (l - x[i]) * 2 >= t[i];
    canl[i] = x[i] * 2 >= t[i];
    ++ans;
  }
  int l = 0, r = 0;
  for (int i = 1; i < n; ++i)
    if (canr[i] && l) {
      --l;
      r += canl[i];
      --ans;
    } else if (canr[i] && !canl[i]) {
      if (r) {
        --r;
        ++l;
      }
    } else if (canl[i]) {
      ++l;
    }
  if (!canr[n])
    ++ans;

  cout << ans * ::l * 2;

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


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

	ll N , T , A;

	cin >> N >> T >> A;

	ll ans_idx;
	ld ans_diff = 100000.0;
	rep(i,N){
		ll h;
		cin >> h;

		ld temp = T - 0.006 * h;
		if(abs(A-temp) < ans_diff){
			ans_diff = abs(A-temp);
			ans_idx = i + 1;
		}
	}

	cout << ans_idx << endl;


	//cout << fixed << setprecision(16) << ans << endl;
	return 0;
}


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

int main()
{
    char a;
    cin >> a;

    if (isupper(a))
    {
        cout << "A" << endl;
    }
    else
    {
        cout << "a" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

a_1, a_2, a_3 = map(int, readline().split())
if a_1 + a_2 + a_3 >= 22:
    print('bust')
else:
    print('win')


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

typedef long long LL;
#define loop(i,n) for(int i = 0; i < n; i++)
#define pii pair<LL, int>
#define vi vector<int> 
#define pb push_back

LL factorial(int r) {
    if (r == 0) return 1;
    LL res = 1;
    for (int i = 2; i <= r; i++) res *= i;
    return res;
}

LL C(int n, int r) {
    LL res = 1;
    for (int i = n; n - i < r; i--) {
        res = res * i;
    }
    return res / factorial(r);
}

int main () {
#ifdef DEBUG
    freopen("in.txt", "r", stdin);
#endif
    int n, m;
    LL f[7] = {0};
    LL pow2[7] = {0};
    pow2[0] = 1;
    for (int i = 1; i < 7; i++) pow2[i] = 2 * pow2[i - 1];
    cin >> n >> m;
    double res = 0, prob = 1;
    for (int itr = 1; itr < 10000; itr++) {
        res += (m * 1900 + ((n - m) * 100)) * prob;
        prob *= (1 - 1.0 / pow2[m]);
    }
    cout << res << endl;
    return 0; 
}

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

int H,W;
void nextpos(int &x, int &y){
  if(x%2==0){
    if(y==W-1) x++;
    else y++;
  }else{
    if(y==0) x++;
    else y--;
  }
  return;
}

int main() {
  cin >> H >> W;
  int coloring[110][110];
  
  int N; cin >> N;
  int cx=0;
  int cy=0;
  for(int i=0; i<N; i++){
    int ai; cin >> ai;
    while(ai>0){
      coloring[cx][cy]=i+1;
      nextpos(cx,cy);
      ai--;
    }
  }
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cout << coloring[i][j];
      if(j==W-1) cout << endl;
      else cout << " ";
    }
  }
}

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

int main(){
  int n;
  scanf("%d",&n);
  int a[n];
  if(n % 2 == 0){
    for(int i = 0;i < n/2;i++){
      scanf("%d",&a[n/2+i]);
      scanf("%d",&a[n/2-i-1]);
    }
  }else{
    scanf("%d",&a[(n-1)/2]);
    for(int i = 0;i < (n-1)/2;i++){
      scanf("%d",&a[(n-1)/2+1+i]);
      scanf("%d",&a[(n-1)/2-i-1]);
    }
  }
  for(int i = 0;i < n;i++){
    printf("%d ",a[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1000000007;
const int INF=1001001001;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int A,B;
  cin>>A>>B;
  if(B%A==0){cout<<A+B<<endl;}
  else{cout<<B-A<<endl;}
  return 0;  
}

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

vector<ll> distances;
vector<bool> visited;
vector<vector<pair<ll,ll>>> adjlist;

void dfs(ll start, ll depth) {
	distances[start]=depth;
	visited[start]=true;
	for (pair<ll,ll> p : adjlist[start])
		if (!visited[p.first])
			dfs(p.first,depth+p.second);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n; cin>>n;
	adjlist.resize(n+1);
	distances.resize(n+1);
	visited.resize(n+1);
	for (ll i=0; i<n-1; i++) {
		ll a,b,c; cin>>a>>b>>c;
		adjlist[a].push_back({b,c});
		adjlist[b].push_back({a,c});
	}

	ll q,k; cin>>q>>k;
	dfs(k,0);
	while (q--) {
		ll x,y; cin>>x>>y;
		cout << distances[x] + distances[y] << endl;
	}
	return 0;
}



Measured memory_bytes: 14336
# -*- coding: utf-8 -*-
import sys;
import string;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

from functools import lru_cache
#@lru_cache(maxsize = None)

# 整数の入力
n = int(input())

# スペース区切りの整数の入力
#a = [x for x in map(int, input().split())]
#a, p = map(int, input().split())
#print(n, q, file=sys.stderr)

# 改行区切りの整数の入力
#a = []
#for x in range(n):
#  a.append(int(input()))

# 文字列の入力
#s = input()

# 出力
#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(len(set(a)))

#cache = dict()


def doit():
  rs = {}
  for x in range(n):
    s, p = input().split()
    p = int(p)
    #print(s, p, file=sys.stderr)
    if not s in rs:
      rs[s] = {}
    rs[s][p] = x + 1
  #print(rs, file=sys.stderr)
    
  slist = sorted(rs)
  for x in slist:
    for y in sorted(rs[x].items(), reverse=True):
      print(y[1])

try:
#  print ((a * 3 + p) // 2)
  doit()
except Exception as e:
  print(e, file=sys.stderr)


Measured memory_bytes: 4080
#include<cstdio>
#include<vector>
#include<cmath>
#include<complex>
using namespace std;
const double EPS = 1e-10;
typedef complex<double> P;

bool zero(double a) { return abs(a) <= EPS; }

int n, x[10], y[10], l[10];
P dir[10];
double r[10];

bool canClear(P p, int i1, int i2) {
  for (int i = 0; i < n; i++) if (i != i1 && i != i2 && EPS + r[i] < abs(p - dir[i])) return false;
  return true;
}

bool check(double h) {
  for (int i = 0; i < n; i++) {
    if (-EPS > ((double)l[i] - h)) return false;
    if (zero((double)l[i] - h)) r[i] = 0.0;
    r[i] = sqrt((double)l[i] * l[i] - h * h);
  }
  for (int i = 0; i < n; i++) if (canClear(dir[i], -1, -1)) return true;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      double d = abs(dir[j] - dir[i]);
      if (d - r[i] - r[j] > EPS) return false;
      if (r[i] - r[j] - d > EPS) continue;
      if (r[j] - r[i] - d > EPS) continue;
      double A = atan2((dir[j] - dir[i]).imag(), (dir[j] - dir[i]).real());
      double S = acos((d*d + r[i]*r[i] - r[j]*r[j]) / (2 * d * r[i]));
      if (canClear(dir[i] + polar(r[i], A + S), i, j)) return true;
      if (canClear(dir[i] + polar(r[i], A - S), i, j)) return true;
    }
  }
  return false;
}

double getH() {
  double lb = 1.0, ub = 300.0;
  while (!zero(ub - lb)) {
    double ave = (lb + ub) / 2;
    if (check(ave)) lb = ave;
    else ub = ave;
  }
  return lb;
}

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) break;
    for (int i = 0; i < n; i++) scanf("%d%d%d", &x[i], &y[i], &l[i]);
    for (int i = 0; i < n; i++) dir[i] = P(x[i], y[i]);
    if (n == 1) printf("%f\n", (double)l[0]);
    else printf("%f\n", getH());
  }
}



Measured memory_bytes: 3132
# https://atcoder.jp/contests/abc126/tasks/abc126_b

STRS = %w[NA YYMM MMYY AMBIGUOUS]
S = gets.chomp

f1, f2 = S.scan(/../).map { |w| w.between?('01', '12') ? 1 : 0 }

puts STRS[f1 * 2 + f2]



Measured memory_bytes: 1788
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;
#define ll long long

int main(){
  int N, M;
  cin >> N >> M;
  vector<bool> from_1(N, false), to_N(N, false);
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    if(a == 1)
      from_1[b-1] = true;
    if(b == N)
      to_N[a-1] = true;
  }
  bool ans = false;
  for(int i=0; i<N; i++){
    if(from_1[i] && to_N[i]){
      ans = true;
      break;
    }
  }
  if(ans)
    cout << "POSSIBLE" << endl;
  else
    cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<unordered_map>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<bitset>
#include<sstream>
using namespace std;
#define int long long
#define ll long long
#define str string
#define db double
#define ac() cout<<"Yes"<<endl
#define wa()  cout<<"No"<<endl
#define ddd cout<<"---debug---"<<endl;
#define ff(a,b) for(signed long long (a)=1;(a)<=(b);(a)++)
#define fff(a,b) for(signed long long (a)=0;(a)<(b);(a)++)
#define re readdd()
#define pr(a) printtt(a)
#define pee puts("");
#define eee putchar(' ');
#define pss(a) push_back(a)
#define ps(a) push(a)
#define SZ(x) x.size()
#define epp empty()
#define all(x) x.begin(),x.end()
#define PA pair<int,int>
#define asd signed QP;scanf("%d",&QP);while(QP--)
typedef vector<int> VE;
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//
int ppow(int a,int b,int mod){a%=mod;//
int ans=1%mod;while(b){if(b&1)ans=(long long)ans*a%mod;
a=(long long)a*a%mod;b>>=1;}return ans;}
int readdd(){int x=0,f=1;char c=getchar();//
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')f=-1,c=getchar();
while(isdigit(c))x=x*10+c-'0',c=getchar();
return f*x;}
void printtt(int x){if(x<0)putchar('-'),x=-x;
if(x>=10)printtt(x/10);putchar(x%10+'0');}
bool addd(int a,int b){return a>b;}
int lowbit(int x){return x&-x;}
const int dx[4]={0,0,1,-1};
const int dy[4]={1,-1,0,0};
//
const double eps=1e-6;
const int mod=1e9+7;
const int modd=mod-1;
//
const int maxm=3e6+5;
int a[maxm];
void solve(){
    int n=re;
    ff(i,n-1){
        a[re]++;
    }
    ff(i,n)pr(a[i]),pee;
}
signed main(){
//    while(1)
        solve();
    return 0;
}
/*

*/


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

using namespace std;
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(vr) vr.begin(),vr.end()
const ll N=1e5+10,inf=1e18;
ll dp[N],p[N],n,A,B;
int main()
{
    //freopen("ss.inp","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>A>>B;
    for (int i=1;i<=n;i++) cin>>p[i],dp[i]=inf;
    dp[n+1]=inf;
    p[n+1]=n+1;
    for (int i=0;i<=n;i++)
    {
        ll cnt=0;
        for (int j=i+1;j<=n+1;j++)
            if (p[j]>p[i]) dp[j]=min(dp[j],dp[i]+(j-i-1-cnt)*A+cnt*B);
            else cnt++;
    }
    cout<<dp[n+1];
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 998244353
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=100000 ;
///Power
ll  power(ll  i,ll  j)
{
    if(j==0)
    return 1 ;
    ll t=power(i,j/2)%maa ;
    if(j%2==0)
    return (t%maa*t%maa)%maa ;
    else
    return ((t%maa*t%maa)%maa*(i%maa)%maa)%maa ;
}
int main()
{
   fast ;
  string s ;
  cin>>s ;
  ll a=0,b=0 ;
  for(ll i=0;i<3;i++)
  {
      if(s[i]=='A')
        a++ ;
      else
        b++ ;
  }
     if(a==3||a==0)
        cout<<"No"<<endl ;
     else
        cout<<"Yes"<<endl ;


}


Measured memory_bytes: 256
let rec yy y z m e =
  let x = e - (y*y + z*z*z) in
  if x >= 0 then yy (y+1) z (min m (x+y+z)) e else m

let rec zzz z m e =
  if z*z*z <= e then zzz (z+1) (yy 0 z m e) e else m

let rec solve () =
  let e = read_int () in
  if e == 0 then exit 0
  else print_int (zzz 0 e e); print_newline (); solve ()

let () =
  solve ()

Measured memory_bytes: 2324
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String a=sc.nextLine();
    String b=sc.nextLine();
    sc.close();
    boolean isAequalB=true;
    if(a.length()>b.length()){
      System.out.println("GREATER");
    }else if(a.length()<b.length()){
      System.out.println("LESS");
    }else{
      for(int i=0;i<a.length();i++){
        int aCap=Integer.parseInt(a.substring(i,i+1));
        int bCap=Integer.parseInt(b.substring(i,i+1));
        if(aCap>bCap){
          System.out.println("GREATER");
          isAequalB=false;
          break;
        }else if(aCap<bCap){
          System.out.println("LESS");
          isAequalB=false;
          break;
        }
      }
      if(isAequalB){
        System.out.println("EQUAL");
      }
    }
  }
}

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

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N, a = -1, b = -1, ca = 0, cb = 0, x; cin >> N;

    cin >> x;
    a = x, ca++;

    for(int i=0;i<N-1;i++){
        cin >> x;
        if(a>-1 and b>-1 and x!=a and x!=b) {cout << "No" << endl; return 0;}
        if(x==a) ca++;
        else b = x, cb++;
    }

    if(b==-1){
        if(a==N-1 or N/2>=a) {cout << "Yes" << endl; return 0;}
        else {cout << "No" << endl; return 0;}
    }

    if(a>b) swap(a, b), swap(ca, cb);
    if(b!=a+1) {cout << "No" << endl; return 0;}
    if(b>ca and cb/2>=b-ca) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<cmath>
using namespace std;

typedef pair<int, int> P;
typedef long long ll;
const int INF = 100000000;

ll gcd( ll a, ll b ){
    ll tmp;
    if( a < b ) { tmp = a; a = b; b = tmp; }
    if( b < 1 ) return -1;

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

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


//入力
int n, m;
int k[20];
int s[20][20];
int p[20];


int main(){

    cin >> n >> m;

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

    for(int i = 1; i <= m; i++) cin >> p[i];

    int ans = 0;

    for(int i = 0; i < (1 << n); i++){
        bool light_can_all_on = true;

        for(int j = 1; j <= m; j++){
            int sum = 0;

            for(int l = 1; l <= k[j]; l++){
                if(i & (1 << (s[j][l] - 1))) sum += 1;
            }

            if(sum % 2 != p[j]){
                light_can_all_on = false;
                break;
            }
        }

        if(light_can_all_on){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;

void solve() {
	ll n;
	string s;
	cin >> n >> s;

	ll right = 0, left = 0, swap = 0;
	for (ll i = 0; i < n; ++i) {
		if (s[i] == 'W') {
			++left;
		} else {
			++right;
		}
	}
	ll ans = min(right, left);

	for (ll i = 0; i < right; ++i) {
		if (s[i] == 'W') {
			++swap;
		}
	}
	ans = min(ans, swap);

	cout << ans << '\n';
}


int main()
{
	std::ios::sync_with_stdio(false);
	solve();
	return 0;
}


Measured memory_bytes: 3764
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, K: int):
    def gcd(a, b):
        return a if b == 0 else gcd(b, a % b)
    ret = 0
    if N <= K:
        ret = min(K - N, N)
    else:
        tmp = N % K
        ret = min(K - tmp, tmp)
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.*;
import java.awt.geom.*;
public class Main {

	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			Point2D []  plist = new Point2D[n];
			for(int i = 0; i < n; i++){
				String [] a = sc.next().split(",");
				double x = Double.parseDouble(a[0]);
				double y = Double.parseDouble(a[1]);
				plist[i] = new Point2D.Double(x, y);
			}
			

			Point2D [] res = convexHull(plist);
			System.out.println(n - res.length);
		}
	}

	private Point2D [] convexHull(Point2D [] plist) {
		int n = plist.length;
		Comparator< Point2D > com = new Comparator< Point2D >() {
			public int compare(Point2D o1, Point2D o2) {
				if(o1.getX() < o2.getX()) return -1;
				else if(o1.getX() > o2.getX()) return 1;
				else if(o1.getY() < o2.getY()) return -1;
				else if(o1.getY() > o2.getY()) return 1;
				else return 0;
			}
		};
		Arrays.sort(plist, com);
		int k = 0;
		Point2D [] qs = new Point2D[n * 2];

		for(int i = 0; i < n; i++){
			while(k > 1 && new Line2D.Double(qs[k-2] , qs[k-1]).relativeCCW(plist[i]) > 0){
				k--;
			}
			qs[k++] = plist[i];
		}
		
		for(int i = n - 2, t = k; i >= 0; i--){
			while(k > t && new Line2D.Double(qs[k-2] , qs[k-1]).relativeCCW(plist[i]) > 0){
				k--;
			}
			qs[k++] = plist[i];
		}
		Point2D [] res = Arrays.copyOf(qs, k-1);
		return res;
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <unordered_map>
#include <cmath>
using namespace std;
const long long M = 1000000007;

long long factorial(int n){
  long long a = 1;
  for(long long i = 1; i <= n; i++){
    a *= i;
   cout << a << endl;
  }

  return a;
}

vector<long long> prime_list(long long n){
  vector<long long> p;
  vector<bool> furui(n+1, true);
  furui[0] = furui[1] = false;
  for(long long i = 2; i <= (int)sqrt(n); i++){
    if(furui[i]){
      for(long long j = i + i; j <= n; j += i){
        furui[j] = false;
      }
    }
  }
  for(long long i = 2; i <= n; i++){
    if(furui[i]){
      p.push_back(i);
    }
  }
  return p;
}

long long divide_times(long long n, long long d){
  long long ans = 0;
  while(n % d == 0){
    n /= d;
    ans++;
  }
  return ans;
}

int main(){
  int n;
  cin >> n;
  // long long fact = factorial(n);
  auto plist = prime_list(n);

  unordered_map<long long, long long> mp;
  for(long long i = 0; i < plist.size(); i++){
    mp[plist[i]] = 0;
  }

  for(long long i = 1; i <= n; i++){
    for(long long j = 0; j < plist.size(); j++){
      long long d = plist[j];
      long long t = divide_times(i, d);
      mp[d] += t;
    }
  }

  long long ans = 1;
  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    ans *= itr->second + 1;
    ans %= M;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
//#include <windows.h>
//#include <iomanip>
//#include <math.h>
//#define pi 3.14159
 
using namespace std;
 
int main() {
	//cout << fixed << setprecision(2);
	
	int a, b;
	
	cin >> a >> b;
	
	cout << a*b << " " << (2*a)+(2*b) << endl ;
	
   	return 0;
}

Measured memory_bytes: 1164
//       In the name of         ****                      God                     ****

/*

Copyright (C)          JadedBeast

                                   Morocco

created : 10/3/2019

*/

#include <bits/stdc++.h>

using namespace std;
const unsigned int mod =1e9+7;
inline void Boost() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}
int H,W;
char m[1001][1001];
int DP[1001][1001];
long long dp(int h,int w){
	if(h==H && w==W)
		return 1;
	if(m[h][w]=='#')
		return DP[h][w]=0;
	if(h>H || w>W )
		return 0;
	if(DP[h][w]!=-1)
		return DP[h][w];
	if(h<H || w<W)
		return DP[h][w]=(dp(h+1,w)+dp(h,w+1))%mod;

	return 0;

}


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



	for (int i=1 ;i<=H ;i++)
		for(int j=1 ;j<=W;j++)
			cin >> m[i][j];

	memset(DP,-1,sizeof(DP));


	cout << dp(1,1)<<endl;

    return 0;
}


Measured memory_bytes: 5248
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
using namespace std;

int main()
{
    int i, j, f[200000], w[20000], v[20000],h, n;
    cin >> h >> n;
    for(i = 0 ;i < h;i++)
    {
        f[i] = 1e10;
    }
    for(i = 0;i < n;i++)
    {
        cin >> w[i] >> v[i];
    }
    for(i = 0;i < n;i++)
    {
        for(j = 0;j < h;j++)
        {
            f[j] = min(f[j],f[j - w[i]] + v[i]);
        }
    }
    cout << f[h - 1] << endl;

    return 0;
}


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

int main() {
int  K;
    cin >> K ;
if (K==8||K==12||K==18||K==20||K==27)
  cout << 5 << endl;  
  else if (K==4||K==6||K==9||K==10||K==14||K==21||K==22||K==25||K==26)
     cout << 2 << endl;  
  else if (K==16) cout << 14 << endl;
  else if (K==24) cout << 15 << endl;
  else if (K==32) cout << 51 << endl;
  else if (K==28||K==30) cout << 4 << endl;
  else cout << 1 << endl;
}


Measured memory_bytes: 256