akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

#define fillInt(xs)        \
  for (int i = 0; i < (xs).size(); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs)       \
  for (int i = 0; i < (xs).size(); i++) \
    scanf("%ld", &xs[i]);
#define fillDouble(xs)       \
  for (int i = 0; i < (xs).size(); i++) \
    scanf("%lf", &xs[i]);
#define fillString(xs)       \
  for (int i = 0; i < (xs).size(); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

long sum[32][2];

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

  long n, k;
  cin >> n >> k;

  cout << (abs(n-k) >= 2 ? "Alice" : "Brown") << endl;
}


Measured memory_bytes: 888
// Find Symmetries

#include <cstdio>

char matrix[320][320];

bool is_symmetric(char matrix[][320], int n, int step)
{
    bool symmetric = true;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            if (matrix[i][(j + step) % n] != matrix[j][(i + step) % n])
            {
                symmetric = false;
                break;
            }
        }
    }
    return symmetric;
}

int main()
{
    int n;
    int res = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%s", &matrix[i]);

    for (int i = 0; i < n; ++i)
    {
        if (is_symmetric(matrix, n, i)) ++res;
    }
    printf("%d\n", res*n);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll unsigned long long
using namespace std;
 int a,b;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>a>>b;
  bool t=false;
  for(int i=1;i<=10000;i++)
  {
      if( (floor((double)(i*0.08)))==a && (floor((double)(i*0.10)))==b)
      {
          cout<<i<<endl;
          t=true;
          break;
      }
  }
  if(!t){
     cout<<-1<<endl;
  }
  
}

Measured memory_bytes: 256
n = int(input())
if n == 2:
  print(1)
else:
  nfac = [1]
  for i in range(2,int(n**0.5)+1):
    if n%i==0:
      nfac.append(i)
  print((nfac[len(nfac)-1]-1)+(n//nfac[len(nfac)-1]-1))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 4003, M = 924844033;

int n, k;

int dp[N][N][2];
int f[N];

bool solv()
{
    scanf("%d%d", &n, &k);
    vector<int> v;
    for (int i = 1; i <= k; ++i)
    {
        int q = 0;
        for (int j = i; j <= n; j += k)
            ++q;
        if (v.empty())
            v.push_back(q);
        else
            v.push_back(v.back() + q);
        v.push_back(v.back() + q);
    }
    int u = 0;
    dp[1][0][0] = 1;
    for (int i = 2; i <= n * 2; ++i)
    {
        if (i == v[u] + 1)
        {
            ++u;
            for (int j = 0; j <= n; ++j)
            {
                if (j == 0)
                    dp[i][j][0] = dp[i - 1][j][0];
                else
                {
                    dp[i][j][0] = (dp[i - 1][j][0] + dp[i - 1][j][1]) % M;
                }
            }
        }
        else
        {
            for (int j = 0; j <= n; ++j)
            {
                if (j == 0)
                    dp[i][j][0] = dp[i - 1][j][0];
                else
                {
                    dp[i][j][0] = (dp[i - 1][j][0] + dp[i - 1][j][1]) % M;
                    dp[i][j][1] = (dp[i - 1][j - 1][0]);
                }
            }
        }
    }
    f[0] = 1;
    for (int i = 1; i < N; ++i)
        f[i] = (f[i - 1] * 1LL * i) % M;
    int ans = 0;
    for (int j = 0; j <= n; ++j)
    {
        if (j % 2 == 0)
            ans = (ans + ((dp[n * 2][j][0] + dp[n * 2][j][1]) * 1LL * f[n - j]) % M) % M;
        else
            ans = (ans - ((dp[n * 2][j][0] + dp[n * 2][j][1]) * 1LL * f[n - j]) % M + M) % M;
    }
    printf("%d\n", ans);
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


Measured memory_bytes: 124544
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

vector<ll> factmemo, factmemoInv;
ll factmemoMod = -1;

ll factorial(int n, int M){
  if(factmemoMod == M) return factmemo[n];
  if(n <= 1) return 1;

  ll res = 1;
  for(int i=1; i<=n; i++) res = res * i % M;
  return res;
}

ll power(ll k, ll n, int M){
  ll res = 1;
  while(n > 0) {
    if (n & 1) res = res * k % M;
    k = k * k % M;
    n /= 2;
  }
  return res;
}

void initFactorial(int n, int M){
  factmemo.assign(n+1, 0);
  factmemoInv.assign(n+1, 0);
  factmemoMod = M;
  factmemo[0] = 1;
  for(int i=1;i<=n;i++) factmemo[i] = factmemo[i-1] * i % M;
  factmemoInv[n] = power(factmemo[n], M-2, M);
  for(int i=n;i>0;i--) factmemoInv[i-1] = factmemoInv[i] * i % M;
}

//nCm nPm nHm (mod M)

/*Combination*/
ll C(int n, int m, int M){
  if(n < m) return 0;
  if(m == 0 || n == m) return 1;

  if(factmemoMod == M)
    return factmemo[n] * factmemoInv[m] % M * factmemoInv[n-m] % M;

  ll numer = factorial(n, M);
  ll denom = factorial(m, M) * factorial(n-m, M) % M;

  denom = power((int)denom, M-2, M);

  return numer * denom % M;
}
/*Permutation*/
ll P(int n, int m, int M){
  if(n < m) return 0;
  if(m == 0) return 1;

  if(factmemoMod == M)
    return factmemo[n] * factmemoInv[n-m] % M;

  ll numer = factorial(n, M);
  ll denom = factorial(n-m, M);

  denom = power((int)denom, M-2, M);

  return numer * denom % M;
}
/*Combination with Repetitions*/
ll H(int n, int m, int M){
  if(n == 0 && m == 0) return 1;
  return C(n+m-1, m, M);
}


int main() {
  int N;
  ll x[SIZE];

  scanf("%d", &N);

  initFactorial(N, mod);

  for (int i=0; i<N; i++) {
    scanf("%lld", x+i);
  }


  ll t = 0, ans = 0;

  ll A = 0, B = 1;

  for (int i=1; i<N; i++) {
    ll d = (x[i] - x[i-1]);

    A = (A * i + B) % mod;
    B = B * i % mod;

    ans += A % mod * d % mod * factmemo[N-i-1] % mod * C(N-1, i, mod) % mod;
  }

  cout << ans % mod << endl;

  return 0;
}


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

int main(){
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];
    
    int cnt = 0;

    int i = 0;
    while (i < n - 1){
        if(a[i] < a[i + 1]){
            i ++;
            while (i < n - 1){
                if (a[i] <= a[i + 1]) i ++;
                else{
                    i ++;
                    cnt ++;
                    break;
                }
            }
        }
        else if(a[i] > a[i + 1]){
            i ++;
            while (i < n - 1){
                if (a[i] >= a[i + 1]) i ++;
                else{
                    i ++;
                    cnt ++;
                    break;
                }
            }
        }
        else i++;
    }
    cout << cnt + 1 << endl;
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{

  float t, x;
  cin >> t >> x;
  pr(t / x);

  return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
using namespace std;
int n,m;
int a[100010];
int res=0;
inline int gcd(int x,int y)
{
	if (!y) return x;
	else return gcd(y,x%y);
}
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++) cin >>a[i];
	a[n]=m;
	n++;
	sort(a,a+n);
	for (int i=1;i<n;i++)
	{
		res=gcd(res,a[i]-a[i-1]);
	}
	cout <<res;
	return 0;
} 

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int h,n;
  cin>>h>>n;
  constexpr int INF = 1000000000;
  vecint dp(h+10001,INF);
  dp[0] = 0;
  for(auto&& i:irange(0,n)) {
    int a,b;
    cin>>a>>b;
    for(auto&& j:irange(0,h+10001)) {
      if (j>=a) {
        dp[j] = min(dp[j], dp[j-a] + b);
      }
    }
  }
  int ans = INF;
  for(auto&& i:irange(h,h+10001)) {
    ans = min(ans, dp[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
import math
from decimal import Decimal

a, b, c = list(map(int, input().split()))

# ra+rb<rc
# a+b+2rab<c
# 2rab<c-a-b
# 4ab<(c-a-b)**2

if ((c-a-b)>0) and (4*a*b<(c-a-b)**2):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main(){
    ll q,s1max=-INF,s2min=INF;
    multiset<ll> s1,s2;
    cin >> q;
    ll judge, a, b, minval = 0, minpos;
    REP(i,q){
        cin >> judge;
        if (judge == 1){
            cin >> a >> b;
            minval += b;
            if (a <= s1max)
            {
                minval += s1max - a;
                s1.insert(a);
                s1.insert(a);
                s1.erase(s1.find(s1max));
                s2.insert(s1max);
                s2min = s1max;
                s1max = *s1.rbegin();
                minpos = s1max;
            }
            else if (a >= s2min)
            {
                minval += a - s2min;
                s2.insert(a);
                s2.insert(a);
                s2.erase(s2.find(s2min));
                s1.insert(s2min);
                s1max = s2min;
                s2min = *s2.begin();
                minpos = s1max;
            }else
            {
                s1.insert(a);
                s2.insert(a);
                s1max = s2min = a;
                minpos = a;
            }
        }
        else
        {
            cout << minpos << " " << minval << endl;
        }
    }
}

Measured memory_bytes: 18944
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOrg = sS.Length;
            string sOut = "Yes";
            for (int i = 0; i < sS.Length; i++)
            {
                string sOne = sS.Substring(i, 1);
                int iTmp = sS.Replace(sOne, "").Length;
                if ((iOrg - iTmp) % 2 == 1) { sOut = "No"; break; }
            }

            // 出力
            Console.WriteLine("{0}", sOut.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int n;
    cin >> n;
    string op;
    int a, b;
    string p;
    for(int i=0;i<n;i++){
        cin >> op;
        if(op=="print"){
            cin >> a >> b;
            string sub=s.substr(a, b-a+1);
            cout << sub << endl;
        }
        else if(op=="reverse"){
            cin >> a >> b;
            string sub=s.substr(a, b-a+1);
            reverse(sub.begin(), sub.end());
            s.replace(a, sub.length() , sub);
        }
        else if(op=="replace"){
            cin >> a >> b;
            cin >> p;
            s.replace(a,p.length() , p);//(start, len, str)
        }
    }
    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

string ans = "D H";

int main()
{
    int r = 1;
    for(int i = 0;i < 2;i++)
    {
        string s; cin >> s;
        if(s.front() == 'D')
        {
            r *= -1;
        }
    }
    cout << ans[r + 1];
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(), B = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[A], b = new int[B];
		for (int i = 0; i < A; i++) {
			a[i] = sc.nextInt();
		}
		for (int i = 0; i < B; i++) {
			b[i] = sc.nextInt();
		}
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < m; i++) {
			min = Math.min(min, a[sc.nextInt()-1]+b[sc.nextInt()-1]-sc.nextInt());
		}
		Arrays.parallelSort(a);
		Arrays.parallelSort(b);
		min = Math.min(min, a[0]+b[0]);
		System.out.println(min);
		sc.close();
	}
}

Measured memory_bytes: 151512
from math import sqrt, factorial

N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]

all_sum = 0

for i in range(N):
    xi, yi = xy[i]
    for j in range(i + 1, N):
        xj, yj = xy[j]
        all_sum += sqrt((xi - xj) ** 2 + (yi - yj) ** 2)

fN = factorial(N)

all_sum /= fN
all_sum *= factorial(N - 1) * 2

print(all_sum)


Measured memory_bytes: 3060
H,W=map(int,input().split())
s=[list(input()) for _ in range(H)]

dp=[]
blacks=[]
whites=[]
black=0
white=0
#DP=[]
#print(s)

for h in range(H):
    dp.append([0]*W)
    #DP.append([0]*W)
    for w in range(W):
        #print(s[h][w],dp[h][w])
        if s[h][w]==".":
            if h!=0 and w==0:
                dp[h][w]=dp[h-1][w]
                #DP[h][w]=DP[h-1][w]+1
            elif h==0 and w!=0:
                dp[h][w]=dp[h][w-1]
                #DP[h][w]=DP[h][w-1]+1
            elif h==0 and w==0:
                dp[h][w]=0
                #DP[h][w]=1
            else:
                dp[h][w]=min(dp[h-1][w],dp[h][w-1])
                #DP[h][w]=min(DP[h-1][w],DP[h][w-1])+1
        else:
            if h!=0 and w==0:
                if s[h-1][w]=="#":
                    dp[h][w]=dp[h-1][w]
                else:
                    dp[h][w]=dp[h-1][w]+1
                #DP[h][w]=DP[h-1][w]
            elif h==0 and w!=0:
                if s[h][w-1]=="#":
                    dp[h][w]=dp[h][w-1]
                else:
                    dp[h][w]=dp[h][w-1]+1
                #DP[h][w]=DP[h][w-1]
            elif h==0 and w==0:
                dp[0][0]=1
                #DP[0][0]=0
            else:
                if s[h-1][w]=="." and s[h][w-1]=="#":
                    dp[h][w]=min(dp[h-1][w]+1,dp[h][w-1])
                elif s[h-1][w]=="#" and s[h][w-1]==".":
                    dp[h][w]=min(dp[h-1][w],dp[h][w-1]+1)
                elif s[h-1][w]=="#" and s[h][w-1]=="#":
                    dp[h][w]=min(dp[h-1][w],dp[h][w-1])
                elif s[h-1][w]=="." and s[h][w-1]==".":
                    dp[h][w]=min(dp[h-1][w]+1,dp[h][w-1]+1)
        #print(dp)
                
print(dp[H-1][W-1])

Measured memory_bytes: 3316
import math

def is_prime(n):
    if n==1 :
        return False

    for k in range(2,int(math.sqrt(n))+1):
        if n%k==0:
            return False

    return True

count = [0]
buf = 0
for i in range(1, 10**5 + 2):
    if i % 2 == 0:
        count.append(buf)
        continue

    hantei1 = is_prime(i)
    hantei2 = is_prime((i+1)//2)

    if hantei1 and hantei2:
        buf += 1

    count.append(buf)

q = int(input())

for i in range(q):
    l,r = map(int,input().split())
    print(count[r]-count[l-1])

Measured memory_bytes: 53340
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int A,B,C,D,E,F,x,y;
double mx=-1;
int main(){
	cin>>A>>B>>C>>D>>E>>F;
	A*=100,B*=100;
	for(int a=0;a<=F/A;a++){
		for(int b=0;b<=(F-a*A)/B;b++){
			for(int c=0;c<=(F-a*A-b*B)/C;c++){
				for(int d=0;d<=(F-a*A-b*B-c*C)/D;d++){
					int w=a*A+b*B,s=c*C+d*D;
					if(s<=w/100*E&&w+s<=F){
						if(s*1.0/(w+s)>mx){
							mx=s*1.0/(w+s),x=w+s,y=s;
						}
					}
				}
			}
		}
	}
	printf("%d %d\n",x,y); 
	return 0;
}

Measured memory_bytes: 3760
#include <stdio.h>

int main(void){
    int x[5];
    int i;
    
    for(i=0;i<5;i++){
        scanf("%d",&x[i]);
    }
    
    for(i=0;i<5;i++){
        if(x[i]==0){
            printf("%d\n",i+1);
        }
    }
    
    return 0;
}

Measured memory_bytes: 2152
N,Q = list(map(int,input().split()))
S = input()
A = [0]
cnt = 0

for i in range(1,N):
    if(S[i-1]+S[i]=='AC'):
        cnt += 1
    A.append(cnt)

for i in range(Q):    
    l,r = list(map(int,input().split()))
    print(A[r-1]-A[l-1])

Measured memory_bytes: 6216
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- スペース区切り整数の入力
    [b, c] <- words <$> getLine
    -- 出力
    putStrLn $ if b == c then "H" else "D"


Measured memory_bytes: 380
n = int(input())
h = []
y = map(int, input().split())

for z in y:
    h.append(z)

v = 1
f = h[0]
for i in range(n):
    if i != 0:
        if f <= h[i]:
            if f < h[i]:
                v += 1
                f = h[i]
            else:
                v += 1

print(v)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
using namespace std;
string s;
int main()
{
	cin>>s;
	int len=s.length();
	for(int i=len-1;i>=0;i--)
		if((s[i]=='b' && s[len-1-i]=='d')||(s[i]=='d' && s[len-1-i]=='b')||(s[i]=='p' && s[len-1-i]=='q')||(s[i]=='q' && s[len-1-i]=='p'))
			continue;
		else
		{
			cout<<"No";
			return 0;
		}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
using namespace std;
typedef long long int lli;
int main(void)
{
    int N, K;
    cin >> N >> K;
    if (N % K == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3580
import itertools
N, M, Q = map(int, input().split())
List = [list(map(int, input().split())) for i in range(Q)]
Max = 0
 
for a in itertools.combinations_with_replacement(range(1, M+1), N):
  A = list(a)
  A.sort()
  point = 0
  for i in range(Q):
    ai = List[i][0]
    bi = List[i][1]
    if ai < 1 or N < ai or bi < 1 or N < bi:
      continue
    if A[bi-1]-A[ai-1] == List[i][2]:
      point += List[i][3]
  if Max < point:
    Max = point
 
print(Max)

Measured memory_bytes: 73836
from itertools import product
n,k = map(int, input().split())
d = list(map(int, input().split()))

nums = []
for i in range(10):
  if i not in d: nums.append(i)

for i in range(len(str(n)), 6):
  for j in product(nums, repeat=i):
    t = ""
    if j[0] != 0:
      for k in j:
        t += str(k)
      if int(t) >= n:
        print(t)
        exit()
    

Measured memory_bytes: 9180
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	int x=28;
	int W=365;
	int cal[13]={0,31,x,31,30,31,30,31,31,30,31,30,31};
	int cal2[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
	int y1,m1,d1,y2,m2,d2;
	bool F=false;
	while(1){F=false;
		int ans=0;
		cin>>y1>>m1>>d1>>y2>>m2>>d2;if(y1<0||m1<0||d1<0||y2<0||m2<0||d2<0)break;
		if(y1!=y2){
			if(y1%4==0)F=true;
			if(y1%100==0)F=false;
			if(y1%400==0)F=true;

			if(F==false)cal[2]=28;
			else cal[2]=29;
			ans+=cal[m1]-d1+1;
			//cout<<ans<<endl;
			for(int i=m1+1;i<=12;i++)
			{ans+=cal[i];
		//	cout<<ans<<endl;
			}
			d1=1;m1=1;y1++;
			//cout<<ans<<endl;
		}
		while(y1!=y2){F=false;
				if(y1%4==0)F=true;
			if(y1%100==0)F=false;
			if(y1%400==0)F=true;
			if(F==false)W=365;
			else  W=366;
			ans+=W;
			y1++;
			//cout<<ans<<endl;
		}
		while(m1!=m2){F=false;
			if(y1%4==0)F=true;
			if(y1%100==0)F=false;
			if(y1%400==0)F=true;

			if(F==false)cal[2]=28;
			else cal[2]=29;

			for(int i=m1;i<m2;i++)
				ans+=cal[i];
			m1=m2;
		}
		ans+=d2-d1;
		cout<<ans<<endl;
	}
	return 0;
}

			

Measured memory_bytes: 1160
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

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

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}";
  return o;
}



int main() {
  int N,M;
  cin >> N;
  vector<vector<int>> g(N,vector<int>(N,100000));
  char e;
  rep(i,N)rep(j,N){
    cin >> e;
    int inte = e-'0';
    if (inte==1) g[i][j]=1;
  }
  
  vector<vector<int>> dis;
  dis=g;
  rep(k,N)rep(i,N)rep(j,N){
    if (i==j) dis[i][j]=0;
    if (max(dis[i][j],dis[i][k]+dis[k][j])<100000&&dis[i][j]%2!=(dis[i][k]+dis[k][j])%2){
      cout << -1 << endl;
      return 0;
    }
    chmin(dis[i][j],dis[i][k]+dis[k][j]);
  }

  int res=2;
  rep(i,N){
    rep(j,N) chmax(res,dis[i][j]+1);
  }
  cout << res << endl;
}

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

int main() {
  int N;
  string a;
  cin >> N;
  int p,w,g,y = 0;
  if((N>=1)&&(N<=100)){
    for(int i = 0;i<N;i++){
      cin >> a;
      if((a == "P")||(a == "W")||(a == "G")||(a == "Y")){
        if(a == "P")
          p++;
        if(a == "W")
          w++;
        if(a == "G")
          g++;
        if(a == "Y")
          y++;
      }
      else{
        cout << "error" << endl;
      }
    }
      
    if((p==0)||(w==0)||(g==0)){
        cout << "error" << endl;
    }
    else if(y>0){
      cout << "Four" << endl;
    }
    else{
      cout << "Three" << endl;
    }
  }
  else{
    cout << "error" << endl;
  }
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main() {
	int n,k;cin>>n>>k;
	vec a(n);
	rep(i,n) cin>>a[i];

	rep(ki,k){
		vec b(n);
		rep(i,n){
			int l = max(0, i-a[i]);
			int r = min(i+a[i]+1, n);
			b[l]++; b[r]--;
		}

		rep(i,n) b[i+1] += b[i];
		if(a==b) break;
		a = b;
	}

	rep(i,n) cout<<a[i]<<endl;
	return 0;
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, a, b; cin >> n >> a >> b;
	if(a == 1){
		if(b == n){
			for(int i = n; i >= 1; i--) cout << i << " "; cout << endl;
		} else {
			cout << -1 << endl;
		}
	} else if(b == 1) {
		if(a == n){
			for(int i = 1; i <= n; i++) cout << i << " "; cout << endl;
		} else {
			cout << -1 << endl;
		}
	} else {
		if(a + b - 1 > n || 1ll * a * b < n) cout << -1 << endl;
		else {
			vector<vector<int> > bl;
			for(int i = 0; true; i++){
				vector<int> now;
				for(int j = 0; j < a; j++) if(i * a + j + 1 <= n) now.push_back(i * a + j + 1);
				bl.push_back(now);
				if(now.back() == n) break;
			}
			vector<vector<int> > rbl;
			int miss = b - bl.size();
			for(int i = bl.size() - 1; i >= 0; i--){
				while(bl[i].size() > 1 && miss){
					rbl.push_back({bl[i].back()});
					bl[i].pop_back();
					miss--;
				}
				rbl.push_back(bl[i]);
			}
			vector<int> ans;
			for(int i = 0; i < rbl.size(); i++){
				for(int v : rbl[i]) ans.push_back(v);
			}
			bool oka = true, okb = true;
			{
				vector<int> lis;
				for(int v : ans){
					int pt = lower_bound(lis.begin(), lis.end(), v) - lis.begin();
					if(pt == lis.size()) lis.push_back(v);
					else lis[pt] = v;
				}
				oka &= lis.size() == a;
			}
			{
				vector<int> lis;
				for(int v : ans){
					int pt = lower_bound(lis.begin(), lis.end(), -v) - lis.begin();
					if(pt == lis.size()) lis.push_back(-v);
					else lis[pt] = -v;
				}
				okb &= lis.size() == b;
			}
			if(ans.size() == n && oka && okb){
				for(int i = 0; i < n; i++) cout << ans[i] << " "; cout << endl;
			} else {
				cout << -1 << endl;
			}
		}
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#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=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int x, y, z;
  cin>>x>>y>>z;
  cout<<z<<' '<<x<<' '<<y<<'\n';
  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let (_n, m) = i.read2::<usize, usize>();
    let mut py = Vec::new();
    for c in 0..m {
        py.push((i.read2::<usize, usize>(), c));
    }
    py.sort();

    let mut p_last = None;
    let mut idx = 0;

    let mut rs = vec![(0, 0); m];
    for ((p, _y), c) in py {
        if Some(p) != p_last {
            idx = 0;
            p_last = Some(p);
        }
        idx += 1;
        rs[c] = (p, idx);
    }

    for r in rs {
        writeln!(o, "{:>06}{:>06}", r.0, r.1).unwrap();
    }
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 11768
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    A = 100 * A;
    B = 100 * B;
    set<int> w;
    set<int> s;
    for (int i = 0; i <= F; i += A) for (int j = 0; j <= F; j += B)
        if(i+j<=F) w.insert(i+j);
    for (int i = 0; i <= F; i += C) for (int j = 0; j <= F; j += D)
        if(i+j<=F) s.insert(i+j);

    long double maxnoudo = 0;
    int maxWaterAll = 0;
    int maxSato     = 0;
    for (auto W : w) for(auto S:s){
        if(W+S>F) break;
        if(E*(W/100)<S) break;
        if((long double)W*maxnoudo < (long double)S){
            maxnoudo = (long double)S/W;
            maxWaterAll = W+S;
            maxSato = S;
        }

    }
    cout << (maxWaterAll==0?A:maxWaterAll) << " " << maxSato << endl;
}


Measured memory_bytes: 3664
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [long(input_raw[0])]
    input_raw = read_func().strip().split()
    D = []
    for i in range(N):
        D.append(long(input_raw[i]))

    D.sort()

    D_ = []
    flag = False
    for i in range(N):
        if flag == False:
            D_.append(D[i])
            flag = True
        else:
            D_.append(24 - D[i])
            flag = False

    min_score = sys.maxint
    for i in range(N):
        for j in range(i + 1, N):
            min_score = min(min_score, abs(D_[i] - D_[j]))

    for i in range(N):
        min_score = min(min_score, D[i])

    print min_score


if __name__ == '__main__':
    main()


Measured memory_bytes: 3056
from collections import Counter
N = int(input())
V = input().split(' ')
V_even = V[1::2]
V_odd = V[0::2]
#偶数列の要素を数え上げ
V_even_Count = Counter(V_even)
#奇数列の数え上げ
V_odd_Count = Counter(V_odd)

#偶数列の格納
X = []
for x in V_even_Count.most_common(2):
  X.append(x)
if len(X) == 1:
  X.append(('i',0))
#奇数列の格納
Y = []
for y in V_odd_Count.most_common(2):
  Y.append(y)
if len(Y) == 1:
  Y.append(('j',0))

A,B,C,D = X[0],X[1],Y[0],Y[1]
if A[0] != C[0]:
  print(N-A[1]-C[1])
else:
  if B[1] <= D[1]:
    print(N-A[1]-D[1])
  else:
    print(N-B[1]-C[1])


Measured memory_bytes: 19692
import java.util.*;

class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
   
   		int i, j;
		int n = 3;
    	int[] a = new int[4];
    	for(i = 0; i < n; i++) a[i] = sc.nextInt();
		
		for(i = 1; i < n; i++){
			a[3] = a[i];
			for(j = i - 1; j >= 0 && a[j] > a[3]; j--){
				a[j + 1]  = a[j];
			}
				if(j != i - 1){
					a[j + 1] = a[3];
				}
		}
		System.out.println(a[0] + " " + a[1] + " " + a[2]);
	}
}


Measured memory_bytes: 26248
#include<stdio.h>
int main(){
  int a,b;
  char op;
  int res;

  while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op == '?') break;
    if(op == '+'){
      res = a+b;
    }else if(op == '-'){
      res = a-b;
    }else if(op == '*'){
      res = a*b;
    }else if(op == '/'){
      res = a/b;
    }
    printf("%d\n",res);
  }
  return 0;
}


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

int insertion(vector<int> &A, int g) {
  int cnt = 0;
  int N = A.size();
  for (int i = g; i < N; i++) {
    int v = A[i];
    int j = i - g;
    while (j >= 0 && A[j] > v) {
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j + g] = v;
  }
  return cnt;
}

void print_array(vector<int> &v) {
  int N = v.size();
  for (int i = 0; i < N; i++) {
    cout << v.at(i);
    if (i != N-1) cout << " ";
  }
  cout << endl;
}

int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  rep(i, N) {
    cin >> v.at(i);
  }
  vector<int> G;
  for (int h = 1; h < N; h = 3 * h + 1) {
    G.push_back(h);
  }
  int m = G.size();
  if (m == 0) {
    m = 1;
    G.push_back(1);
  } else {
    reverse(G.begin(), G.end());
  }
  int cnt = 0;
  rep(i, m) {
    cnt += insertion(v, G[i]);
  }
  cout << m << endl;
  print_array(G);
  cout << cnt << endl;
  rep(i, N) {
    cout << v[i] << endl;
  }
}


Measured memory_bytes: 6716
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			int N = Integer.parseInt(str);
			str = br.readLine();
			String[] s = str.split(" ",0);
			int[] count = new int[100000];
			Arrays.fill(count, 0);
			for(int i=0; i< N;i++) {
				count[Integer.parseInt(s[i])]++;
			}
			int x = 0;
			for(int i = 0; i < 99998 ; i++) {
				int total = count[i]+count[i+1]+count[i+2];
				if (total > x) {
					x = total;
				}
			}
			System.out.println(x);
//			long max  = 1000000007;
		}catch (Exception e) {
			System.exit(0);
		}
	}

}


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

namespace ConsoleApp15
{
    class Class320
    {
        static void Main()
        {
            string abcd = Console.ReadLine();
            for(int i = 0; i < (1 << 3); i++)
            {
                int sum = 0;
                sum += abcd[0] - '0';
                for(int j = 0; j < 3; j++)
                {
                    if ((i & (1 << j)) > 0) sum += abcd[j + 1]-'0';
                    else sum -= abcd[j + 1]-'0';
                }

                if (sum == 7)
                {
                    string line = abcd[0].ToString();
                    for(int j = 0; j < 3; j++)
                    {
                        line += (i & (1 << j)) > 0 ? "+" : "-";
                        line += abcd[j + 1].ToString();
                    }
                    line += "=7";
                    Console.WriteLine(line);
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pl;
const ll N = 1e3 + 50;
const ll MOD = 1e9+7;

ll n, k;

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

    ll left = 0, right = 0;
    for(int i=1;i<k;i++) {
        left += (i - 1);
        right += (n + 1 - i);
    }

    ll cnt = 0;
    for(int i=k;i<=n+1;i++) {
        left += (i - 1);
        right += (n + 1 - i);

        cnt = (cnt + right - left + 1) % MOD;
    }

    cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
string S;

int main()
{
    cin >> S;
    for (int i = 0; i < S.length(); i++)
    {
        cout << 'x';
    }
    cout << endl;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

alice = 0
bob = 0

for i in range(1,N+1):
    if i%2 == 1:
        alice += a.pop(a.index(max(a)))
    else:
        bob += a.pop(a.index(max(a)))
print(alice - bob)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = (l); i <= (r); i++)
#define LOG(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
typedef long long ll;

int r = 0; 
int main() {
	cin >> r;
	cout << r * r << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
long long a,b,i,n,ans;
int main(){
    cin>>n;
    for( i=sqrt(n);i>=1;i--)
    {
        if(n%i==0) 
		break;  	
	}
	b=n/i;
	while(b>0)
	{
	   b=b/10;
	   ans++;
	}
	cout<<ans;
  return 0;
} 

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]

use std::collections::*;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let ma: usize = sc.read();
    let mb: usize = sc.read();
    let abc: Vec<(usize, usize, i32)> = (0..n).map(|_| (sc.read(), sc.read(), sc.read())).collect();
    let inf = 10000000;
    let init: Vec<Vec<i32>> = (0..401)
        .map(|i| {
            (0..401)
                .map(|j| if i == 0 && j == 0 { 0 } else { inf })
                .collect()
        })
        .collect();
    let dp = abc.iter().fold(init, |acc, &v| {
        let (a, b, c) = v;
        (0..401)
            .map(|i| {
                (0..401)
                    .map(|j| {
                        let res = acc[i][j];
                        if i >= a && j >= b {
                            std::cmp::min(res, acc[i - a][j - b] + c)
                        } else {
                            res
                        }
                    })
                    .collect()
            })
            .collect()
    });
    let cand = (1..)
        .take_while(|x| x * ma <= 400 && x * mb <= 400)
        .map(|y| dp[y * ma][y * mb])
        .min();
    let ans = match cand {
        Some(t) => {
            if t == inf {
                -1
            } else {
                t
            }
        }
        None => -1,
    };
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);
    String S = scan.nextLine();
    String tmp = S.replace(String.valueOf(S.charAt(0)), "");
    if (tmp.length() == 2 && tmp.charAt(0) == tmp.charAt(1)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21716
#!/usr/bin/env python3
import sys

def solve(N: int, M: int, R: int, r: "List[int]", A: "List[int]", B: "List[int]", C: "List[int]"):
    from scipy.sparse import coo_matrix    
    from scipy.sparse.csgraph import floyd_warshall
    from itertools import permutations
    from functools import reduce
    # coo_matrix((data, (i, j)), [shape=(M, N)])
    mat = floyd_warshall(coo_matrix((C, (A, B)), shape=(N+1, N+1)).tocsr(), directed=False)
    f = lambda a, b: (a[0]+mat[a[1]][b], b)
    return int(min(reduce(f, q, (0, s))[0] for s, *q in permutations(r)))

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
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
    M = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    r = [int(next(tokens)) for _ in range(R)]  # type: "List[int]"
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    C = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    print(solve(N, M, R, r, A, B, C))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()

Measured memory_bytes: 39564
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main() {
	char c[3][3];
	cin >> c[0][0] >> c[0][1] >> c[0][2];
	cin >> c[1][0] >> c[1][1] >> c[1][2];
	cin >> c[2][0] >> c[2][1] >> c[2][2];
	cout << c[0][0] << c[1][1] << c[2][2] << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(All(a));
  ll c1 = a[n-1];
  ll ans;
  ll j = INF;
  rep(i,n-1) {
    ll t = a[i];
    if (abs(2*t-c1) < j) {
      j = abs(2*t-c1);
      ans = t;
    }
  }
  cout << c1 << ' ' << ans << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}


Measured memory_bytes: 3936
#include <bits/stdc++.h>
    
using namespace std;
typedef long long ll;
    
int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> H;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        H.push_back(tmp);
    }
    std::sort(H.begin(), H.end(), greater<ll>());

    ll count = 0;
    for (int i = 0; i < N; i++) {
        if (K-- <= 0) {
            count += H[i];
        }
        // cout << H[i] << " " << K << " " << count << "\n";
    }
    cout << count;

    return 0;
}

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

using namespace std;
const int mod = 1e9+7;

int main(){
	int h,w;
	cin >> h >> w;
	vector<vector<int> > dp(h+1,vector<int>(w+1));
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			char ch;
			cin >> ch;
			dp[i+1][j+1] = (ch=='.');
		//	cout << ch << " ";
		}
		//cout << endl;
	}  
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			if(i+j==2) continue; 
			if(dp[i][j]){
				dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
			}
		}
	}
	
	cout << dp[h][w];
	return 0;
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

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

    lint ans = 0;
    for (int a = 1; a <= N; a++) {
        int a_mod  = a % K;
        int bc_mod = (K - a_mod) % K;

        if ((bc_mod + bc_mod) % K != 0) continue;

        lint cnt = (N + bc_mod) / K;

        ans += cnt * cnt;
    }

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

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main() {
    string s; cin >> s;
    int n = s.size();
    char c;
    int l, r, d = 0;
    if (n%2) { l = n/2 - 1; r = n/2 + 1; c = s[n/2]; }
    else { l = n/2-1; r = n/2; c = s[r]; }
    while (0 <= l && r < n && c == s[l] && c == s[r]) d++, l--, r++;
    cout << d + (1+n)/2 << endl;
}


Measured memory_bytes: 512
import java.io.*;class Main{public static void main(String a[])throws Exception{int i,j;boolean f;float l[]=new float[8];BufferedReader B=new BufferedReader(new InputStreamReader(System.in));for(String s;(s=B.readLine())!=null;System.out.println(f?"NO":"YES")){a=s.split(",");f=false;for(j=0;j<2;j++){for(i=0;i<8;i++)l[i]=Float.valueOf(a[(4*j+i)%8]);f|=((l[0]-l[2])*(l[5]-l[1])+(l[1]-l[3])*(l[0]-l[4]))*((l[0]-l[2])*(l[7]-l[1])+(l[1]-l[3])*(l[0]-l[6]))<0;}}}}


Measured memory_bytes: 24332