akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.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 sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    string s;cin>>s;
    int l=0,r=0;
    rep(i,n){
        if(s[i]=='('){
            r++;
        }else{
            if(r>0)r--;
            else l++;
        }
    }
    rep(i,r)s+=')';
    reverse(s.begin(),s.end());
    rep(i,l)s+='(';
    reverse(s.begin(),s.end());
    cout<<s<<endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <cassert>
#include <set>
#include <map>
#include <bitset>
#include <unordered_set>
#include <string>
#include <cstring>
#include <cmath>
#include <numeric>
#define forn(x, n)             for (int x = 0; x < n; x++)
#define fore(x, a, b, c)       for (int x = a; x <= b; x += c)
#define forr(x, a)             for (int x = a; x >= 0; x--)
#define all(container)         (container).begin(), (container).end()
#define rall(container)        (container).rbegin(), (container).rend()
#define sz(container)          (int) container.size()
#define mp                     make_pair
#define fi                     first
#define se                     second

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector< vector< int > > vvi;
typedef vector<bool> vb;
typedef vector<long long> vll;

#ifdef LOCAL_DEFINE
    #include "DEBUG.hpp"
#else
    #define debug(...) 0
#endif

void read(int &a) {scanf("%d", &a);}
void read(ll &a) {scanf("%lld", &a);}
void read(char* a, string& s) {scanf("%s", a); s = string(a);}
void read(float &a) {scanf("%f", &a);}
void read(double &a) {scanf("%lf", &a);}

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

void solve() {
    string s, t;
    cin >> s >> t;
    if (sz(t) - sz(s) != 1) 
        cout << "No\n";
    else {
        bool ok = true;
        forn(i, sz(s)) if (s[i] != t[i]) ok = false;
        cout << (ok ? "Yes\n" : "No\n");
    }
}

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    while (T--)
        solve();
    return 0;
}

Measured memory_bytes: 3656
#include<cstdio>
#include<iostream>
using namespace std;
const int N=1e2+10;
int n,m,d;
double k,base,ans;
int main(){
	scanf("%d%d%d",&n,&m,&d);
	k=1.0/double(n)*double(m-1);
	base=k/double(n)*2.0;
	ans=base*double(n-d);
	if(d==0)printf("%.10lf\n",k);
	else printf("%.10lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, k;

int main(){
	cin >> n >> k;
	cout << n-k+1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
//cout << fixed << setprecision(0)
int main() { 
  int n,a,b;cin>>n>>a>>b;
  cout << min(n*a,b) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	while(true){
		int h = sc.nextInt();
		int w = sc.nextInt();
		if(h==0 && w==0) break;
		for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
		System.out.print("#");
		}
		System.out.println(); 
		 }
		System.out.println();
		}
         
        }
}

Measured memory_bytes: 27120
N = int(input())
A = list(map(int, input().split()))
INF = 10 ** 9 + 7
s = A[0] * A[1] % INF
tmp = A[0]
for n in range(2,N):
  tmp += A[n-1] % INF
  s = (s + A[n] * tmp) % INF
print(s)

Measured memory_bytes: 105204
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int N, v[100010];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	sort(v, v + N);
	double an = v[0];
	for (int i = 1; i < N; i++) {
		an = (double)(an + v[i]) / 2;
	}
	cout << an;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(void){
    int S,h,m,s;
    cin >> S;
    h=S/3600;
    m=S%3600/60;
    s=S%60;
    cout << h << ":" << m << ":";
    cout << s <<endl;
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <string.h>
#define MAX 246913

using namespace std;

int main(void){
	bool prime[MAX];

	memset(prime,true,sizeof(prime));
	prime[0]=prime[1]=false;
	for(int i=2;i<MAX;i++)
		if(prime[i])
			for(int j=2;i*j<MAX;j++)
				prime[i*j]=false;

	for(int n;cin >> n,n;){
		int c=0;
		for(int i=n+1;i<=2*n;i++)
			if(prime[i])
				c++;
		cout << c << endl;
	}

	return 0;
}

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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> data(n + 1);
  for(int i = 0; i < n + 1; i++){
    if(i == 0){
      data.at(0) == 0;
      continue;
    }
    cin >> data.at(i);
    data.at(i) += data.at(i - 1);
  }
  int count = 0;
  int bound = 0;
  for(int i = 0; bound <= x; i++){
  if(i == data.size() - 1){
    count++;
    break;
  }
    count++;
    bound = data.at(i + 1);
  }
  cout << count << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
	string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
	long n = long.Parse(input[0]);
	long k = long.Parse(input[1]);
	long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
  long aim = 0;//1の位置
  long answer = long.MaxValue;

  for(long i = 0; i < n; i++)
  {
    if(nums[i] == 1) aim = i;
  }

  for(long i = 0; i < n-k+1; i++)
  {
    if(i <= aim && aim <= i+k-1)
    {
      long num = ((i+k-2)/(k-1)) + ((n-i-2)/(k-1)) + 1;
      //Console.WriteLine(((i+k-2)/(k-1)) +" "+ ((n-i-2)/(k-1)));
      answer = Math.Min(num,answer);
    }
  }
  
	Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。
	}
}

Measured memory_bytes: 17248
import sys
sys.setrecursionlimit(10**7)


def dfs(v):
    global ans
    if all(visited[i] == 1 for i in range(n)):
        ans = ans + 1
        return
    for i in range(n):
        if gra[v][i] == 1 and visited[i] == 0:
            visited[i] = 1
            dfs(i)
            visited[i] = 0
    return


if __name__ == '__main__':
    n, m = map(int, input().split())
    ans = 0
    visited = [0]*n
    gra = [[0]*n for _ in range(n)]
    visited[0] = 1
    for _ in range(m):
        a, b = map(lambda x: int(x) - 1, input().split())
        gra[a][b] = 1
        gra[b][a] = 1
    dfs(0)
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)
#define all(a) a.begin(), a.end()
#define gr greater<LL>()

using namespace std;

void dfs(LL acc, int prev, int curr, vector<vector<LL>> &edges, vector<LL> &res){
    LL acc2 = acc+res[curr];
    for(auto dst: edges[curr]){
        if(dst!=prev){
            dfs(acc2, curr, dst, edges, res);
        }
    }
    res[curr]=acc2;
}

void solve(long long N, long long Q, std::vector<long long> a, std::vector<long long> b, std::vector<long long> p, std::vector<long long> x){
    vector<LL> ans(N, 0);
    vector<vector<LL>> edges(N);
    rep(i, Q){
        ans[p[i]-1] += x[i];
    }
    rep(i, N-1){
        edges[a[i]-1].emplace_back(b[i]-1);
        edges[b[i]-1].emplace_back(a[i]-1);
    }
    dfs(0, -1, 0, edges, ans);
    for(auto a:ans){
        cout << a << " ";
    }
    cout << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> a(N-1);
    std::vector<long long> b(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    std::vector<long long> p(Q);
    std::vector<long long> x(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&p[i]);
        scanf("%lld",&x[i]);
    }
    solve(N, Q, std::move(a), std::move(b), std::move(p), std::move(x));
    return 0;
}


Measured memory_bytes: 36736
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

string ans;
int main(){
    string n;
    cin >> n;
    if(n[0] == '9'||n[1] == '9') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int h[] = new int[n];
		for(int i = 0; i < n; ++i)
			h[i] = sc.nextInt();
		sc.close();
		String ans[] = {"Yes", "No"};
		int an = 0;
		for(int i = n - 1; i > 0; --i) {
			int tmp = h[i - 1] - h[i];
			if(tmp > 0) {
				if(tmp > 1) {
					an = 1;
					break;
				}
				h[i - 1]--;
			}
		}
		System.out.println(ans[an]);
	}
}


Measured memory_bytes: 51932
N,K = map(int, input().split())
P = [int(i) for i in input().split()]
total, maxS = 0, 0
S = [0]
for p in P:
    total += p*(p+1)/2/p
    S.append(total)

for i in range(N-K+1):
    if maxS < S[i+K]-S[i]:
        maxS = S[i+K]-S[i]
print(maxS)

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

int main(){
    ll H,W;
    cin >> H >> W;
    ll ans = 1e9;
    for(ll i=1;i<H;i++){
        ll h1 = (H-i)/2,h2 = (H-i)-h1;
        ll ma = max({i,h1,h2}),mi = min({i,h1,h2});
        ans = min(ans,W*(ma-mi));
        ll w1 = W/2,w2 = W-w1;
        ans = min(ans,max({i*W,(H-i)*w1,(H-i)*w2})-min({i*W,(H-i)*w1,(H-i)*w2}));
    }
    for(ll i=1;i<W;i++){
        ll w1 = (W-i)/2,w2 = (W-i)-w1;
        ll ma = max({i,w1,w2}),mi = min({i,w1,w2});
        ans = min(ans,H*(ma-mi));
        ll h1 = H/2,h2 = H-h1;
        ans = min(ans,max({i*H,(W-i)*h1,(W-i)*h2})-min({i*H,(W-i)*h1,(W-i)*h2}));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, m; cin >> n >> m;
    vector<ll> imos(n+2);
    REP(i, m) {
        ll l, r; cin >> l >> r;
        imos[l]++; imos[r+1]--;
    }

    vector<ll> vec(n+1);
    vec[0] = imos[0] + imos[1];
    FOR(i, 1, n+1) {
        vec[i] = vec[i-1] + imos[i+1];
    }
    cout << count(ALL(vec), m) << endl;
    return 0;
}

Measured memory_bytes: 1792
public class Main {
  private static void solve() {
    int n = ni();
    if (n >= 1000) System.out.println("ABD");
    else System.out.println("ABC");
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




Measured memory_bytes: 23124
#include<stdio.h>

int p,q,r;

int main(){
  scanf("%d%d%d",&p,&q,&r);
  if(p<=q&&p<=r&&q<=r)printf("%d",p+q);
  else if(p<=q&&p<=r&&q>=r)printf("%d",p+r);
  else if(p>=q&&p<=r&&q<=r)printf("%d",p+q);
  else if(p>=q&&p>=r&&q<=r)printf("%d",q+r);
  else if(p<=q&&p>=r&&q>=r)printf("%d",p+r);
  else printf("%d",q+r);
  return 0;
}

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

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W;
	cin >> H >> W;
	vector< vector<char> > ans(H + 2, vector<char>(W + 2, '#'));
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> ans[i][j];
		}
	}
	for (int i = 0; i < H + 2; i++) {
		for (int j = 0; j < W + 2; j++) {
			cout << ans[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.Searching._
import scala.annotation.tailrec
import scala.collection.immutable.{NumericRange, Queue}
import scala.collection.mutable
import scala.io.StdIn.readLine

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    val W, H = sc.nextInt
    val c = sc.next
    for (i <- Range(0, H)) {
      for (j <- Range(0, W)) (
        if ((i == 0 || i == H - 1) && (j == 0 || j == W - 1)) (print("+"))
        else if ((i == 0 || i == H - 1)) (print("-"))
        else if ((j == 0 || j == W - 1)) (print("|"))
        else if (i == H / 2 && j == W / 2) (print(c))
        else (print("."))
        )
      println("")
    }
  }

  def gcd(i: Long, j: Long): Long = {
    if (i < j) (gcd(j, i)) else (if (j == 0) (i) else (gcd(j, i % j)))
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    solve(sc)
  }
}


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

using namespace std;

using ll = long long;

std::vector<std::vector<ll>> d;

void warshall_floyd(int n){
    for(int i=0; i<n; i++){
        for(int j= 0; j<n; j++){
            for(int k = 0; k<n; k++){
                d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
            }
        }
    }
}

int main(){
    int h,w; cin >> h >> w;
    d.resize(10);
    for(int i = 0; i<10; i++){
        d[i].resize(10);
        for(int j = 0; j<10; j++){
            cin >> d[i][j];
        }
    }
    warshall_floyd(10);
    int ans = 0;
    for(int i = 0; i<h; i++){
        for(int j = 0; j<w; j++){
            int a;
            cin >> a;
            if(a==-1) continue;
            ans += d[a][1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
long mod = 1e9+7;
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main(void){
    long n;
    cin >> n;
    long a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    long sum = 0,sum2=0;
    for(int i=0;i<n;i++){
        sum += a[i];
        sum %= mod;
    }
    for(int i=0;i<n;i++){
        sum2 += (a[i]*a[i])%mod;
        sum2 %= mod;
    }
    long ans = (sum*sum)%mod-sum2;
    if(ans<0) ans += mod;
    long inv2 = modinv(2,mod);
    cout << (ans*inv2)%mod << endl;
}

Measured memory_bytes: 5116
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

ll h;
ll w;
ll k;
vvector<int> choco;

void setup(){
  h = in();
  w = in();
  k = in();
  choco.resize(h,vector<int>(w));
  rep(i,h){
    rep(j,w){
      char d;
      in(d);
      choco[i][j] = d-'0';
    }
  }
}

vvector<int> team(int part){
  vvector<int> res;
  int ln = 2;
  rep(i,0,h){
    int d = (bit(i)&part)?1:0;
    if(ln!=d){
      res.push_back(vector<int>(0));
      res.back().push_back(i);
      ln = d;
    }else{
      res.back().push_back(i);
    }
  }
  return res;
}

int func(int part){
  vvector<int> teams = team(part);
  int n = teams.size();
  vector<int> cnt(n,0);
  int res = n-1;
  auto is_over = [&](vector<int> line){
                   foreach(i,line){
                     if(i>k)return true;
                   }
                   return false;
                 };
  rep(x,w){
    rep(i,n){
      foreach(j,teams[i]){
        cnt[i]+=choco[j][x];
      }
    }
    if(is_over(cnt)){
      cnt.assign(n,0);
      ++res;
      rep(i,n){
        foreach(j,teams[i]){
          cnt[i]+=choco[j][x];
        }
      }
    }
    if(is_over(cnt)){
      return INT32_MAX;
    }
  }
  return res;
}

int main(){

  setup();
  int ans = INT32_MAX;

  rep(i,bit(h)){
    chmin(ans,func(i));
  }


  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
s = gets.chomp.split('')
ans = 100
s.uniq.each do |c|
    i = 0
    max = 0
    s.each do |t|
        if c == t
            i = 0
        else
            i += 1
            max = [i, max].max
        end
    end
    ans = [ans, max].min
end

puts ans

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

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


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

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    int N,i;
    cin >> N >> i;
    int ans = N - i +1;
    cout << ans << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> w(n);
    rep(i,n) cin >> w[i];
    int sum = 0;
    int ans = 1e9;
    rep(i,n) sum += w[i];
    rep(i,n-1) {
        int x = 0;
        rep(j,i+1) x +=w[j];
        ans = min(abs(2*x-sum),ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,n,x=5;
    scanf("%d",&n);
    for(i=1;i<=9;i++)
    {
        if(n%i==0 && n/i<=9)
        {
            printf("Yes\n");
            x=1;
            break;
        }

    }
    if(x==5)
    printf("No\n");


    return 0;



}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
  char a[1000],b[1000];
  int i;
  scanf("%s%s",a,b);
  if(strlen(a)==strlen(b)){
    for(i=0;i<strlen(a);i++){
      if(a[i]<b[i]) {printf("LESS");return 0;}
      else if(a[i]>b[i]) {printf("GREATER");return 0;}
    }
    printf("EQUAL");
  }
  else{
    if(strlen(a)>strlen(b)) printf("GREATER");
    else printf("LESS");
  }
  return 0;
}

Measured memory_bytes: 128
N = int(input())
dic = [0]*N
dist = [[float('inf')]*N for i in range(N)]
for i in range(N):
  dic[i] = [int(c) for c in input().split()]
  for j in range(N):
    dist[i][j] = dic[i][j]
ans = 0
log = []
for k in range(N):
  for i in range(N-1):
    for j in range(i+1,N):
      dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])
for i in range(N-1):
  for j in range(i+1,N):
    if dist[i][j]<dic[i][j]:
      print(-1)
      import sys
      sys.exit()
    flag = False
    for k in range(N):
      if k==i or k==j:
        continue
      if dist[i][j] == dist[i][k]+dist[k][j]:
        flag = True
    if flag:
      continue
    ans += dic[i][j]
print(ans)


Measured memory_bytes: 77020
#include <stdio.h>

int main (){
    int R,G;
    int peformance;

    scanf("%d",&R);
    scanf("%d",&G);

    if(R,G <=4500 && R,G >=0){
    peformance = (( G * 2 ) - R);
    printf("%d\n",peformance);

    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<n+1;i++)

using namespace std;
using std::swap;

vector<long long int> v;
vector<long long int> w;



int main() {
	string N;
	cin >> N;
	if (N.substr(0, 1) == "7") {
		cout << "Yes" << "\n";
		return 0;
	}else if (N.substr(1, 1) == "7") {
		cout << "Yes" << "\n";
		return 0;
	}else if (N.substr(2, 1) == "7") {
		cout << "Yes" << "\n";
		return 0;
	}
	else {
		cout << "No" << "\n";
	}
	return 0;
}

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

		using namespace std;

		int main()
		{ios_base::sync_with_stdio(false);
		    cin.tie(NULL);
		    int n,sum=0;
		    cin >> n;
		    int a[n+1];
			for (int i = 1; i <= n; i++) {
				cin >> a[i];
				while (a[i] % 2 == 0) { a[i] /= 2; sum++; }
			}
			cout << sum << endl;
			return 0;

		}

Measured memory_bytes: 3644
module String = struct
  include String
  let to_list s = 
    let rec to_list_aux acc = function
      | 0 -> acc
      | n -> to_list_aux (s.[n - 1] :: acc) (n - 1) in
    to_list_aux [] (String.length s)
end

module CharMap = Map.Make (Char)

let () = 
  let h, w = Scanf.scanf "%d %d\n" (fun h w -> h, w) in
  let ass = Array.init h (fun _ -> String.to_list @@ Scanf.scanf "%s\n" (fun as_ -> as_)) in
  Array.fold_left (fun m as_ ->
    List.fold_left (fun m c ->
      CharMap.add c (1 + try CharMap.find c m with Not_found -> 0) m) m as_) CharMap.empty ass
  |> CharMap.bindings
  |> List.fold_left (fun (possible, (fours, twos, ones)) (_, x) ->
      let fours' = min fours (x / 4) in
      let twos' = min twos ((x - 4 * fours') / 2) in
      let ones' = min ones (x - 4 * fours' - 2 * twos') in
      (possible && x - 4 * fours' - 2 * twos' - ones' = 0, (fours - fours', twos - twos', ones - ones')))
    (true, ((h / 2) * (w / 2), (h mod 2) * (w / 2) + (h / 2) * (w mod 2), (h mod 2) * (w mod 2)))
  |> fst
  |> (function true -> "Yes" | false -> "No")
  |> print_endline

Measured memory_bytes: 2816
#include <stdio.h>

int main(void)
{
	int N, T, t[200000], ans = 0, i;
	scanf("%d%d", &N, &T);
	for (i = 0; i < N; ++i) scanf("%d", &t[i]);
	for (i = 1; i < N; ++i) {
		if (t[i] - t[i - 1] > T) ans += T;
		else ans += t[i] - t[i - 1];
	}
	printf("%d", ans + T);
	return 0;
}

Measured memory_bytes: 896
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
#define int long long
#define mod 1000000007
#define rep(n,i)  for(int i=0; i<(int)(n);i++)
#define all(v)  v.begin(),v.end()
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int kurai(int x00, int y00) {
	int z00 = (x00%jousu(10,y00)) / jousu(10, y00-1);
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}


signed main() {
	int n,a,b;
	cin >> n;
	a = sqrt(n);
	for (int i = a+1; i >= 1; i--) {
		if (n % i == 0) {
			b = n / i;
			cout << i + b - 2 << endl;
			return 0;
		}
	}
}


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

int main()
{
  int P, place[4][2] = {{10,}, {50,}, {100,}, {500,}};
  bool flag = false;
  while (cin >> P && P) {
    int total = 0;
    for (int i = 0; i < 4; i++) {
      cin >> place[i][1];
      total += (place[i][0] * place[i][1]);
    }
    P -= total;
    P = -P;
    for (int i = 3; i >= 0; i--) {
      place[i][1] = place[i][1] - P / place[i][0]; 
      P = P % place[i][0];
    }
    if (flag) cout << endl;
    for (int i = 0; i < 4; i++) {
      if (place[i][1] > 0) cout << place[i][0] << " " << place[i][1] << endl;
    }
    flag = true;
  }

  return 0;
}

Measured memory_bytes: 1164
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  int N;
  cin >> N;
  int max_i =  N / 7;
  string ans = "No";
  for(int i=0; i < max_i+1; i++){
    if((N-i*7) % 4 == 0){
      ans = "Yes";
      break;
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[100009];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin>>n>>k;
    int arr[n+1];
    for(int i=0;i<n;i++){ 
            cin>>arr[i];
            dp[arr[i]]=1;
    }
    for(int i=0;i<arr[0];i++) dp[i]=0;
    int flag=0;
    for(int i=arr[0]+1;i<k+1;i++){
        flag=0;
        for(int j=0;j<n;j++){
            if(i-arr[j]>=0 and dp[i-arr[j]]==0){ 
                dp[i]=1;
                flag=1;
                break;
            }
        }
        if(flag==0) dp[i]=0;
    }
    string ans= (dp[k]==1?"First\n":"Second\n") ;
    cout<<ans;
   
}

Measured memory_bytes: 640
void main(){
	int k = _scan();
	writeln((k/2)*((k+1)/2));
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2724
////   template  ///////////////////////////////////////////////////////
#include <stdlib.h>
#include <sys/time.h>
#include <stdio.h>
#include <sys/resource.h>
#include <iostream>
#include<utility>
#include<vector>
using namespace std;

class timer{
	enum KIND{ REAL, CPU }; // real_time or cpu_time
	double t0; // start
	double t1; // end
	KIND kind_of_time; // default is real_time
	double get_realtime(){struct timeval tv; gettimeofday(&tv, NULL);
		return tv.tv_sec + (double)tv.tv_usec*1e-6;}
	double get_cputime(){struct rusage RU; getrusage(RUSAGE_SELF, &RU); 
		return RU.ru_utime.tv_sec + (double)RU.ru_utime.tv_usec*1e-6;}
public:
	timer(){kind_of_time = REAL;}
	void set(KIND k){kind_of_time = k;}
	void start(){t0 = get_realtime();}
	void stop(){t1 = get_realtime();}
	void print(){printf("TotalTime : %.3fsec\n", t1-t0);}
};
////////////////////////////////////////////////////////////////////////

int lcm(int x, int y);
int gcd(int a, int b);

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

	int x, y;
	vector<int>::iterator i;
	x = v.at(0);
	for(i=v.begin()+1; i!=v.end(); i++){
		y = *i;
		x = lcm(x, y);
	}
	cout << x << endl;
	
    return 0;
}

int gcd(int a, int b)
{
	int r;
	while(1){
		r = a%b;
		if( !r ){ return b; }
		else{ a = b; b = r; }
	} 
}


int lcm(int x, int y) 
{
	if(x<y)swap(x, y);
	
	if(!(x%y)) return x;
	
	return x*y/gcd(x, y);
}

Measured memory_bytes: 1212
//
// Created by Huang,Zhiqiang on 2018/6/26.
//

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

typedef long long ll;

const int max_arr = 200005;
ll a[max_arr];
ll addsums[max_arr];
ll xorsums[max_arr];
ll n;

int main() {
    cin >> n;
    for (int i= 0; i <= n; i++) {
        addsums[i] = 0;
        xorsums[i] = 0;
    }
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) {
        addsums[i] = addsums[i - 1] + a[i];
        xorsums[i] = xorsums[i - 1] ^ a[i];
    }
    ll l = 1, r = 1;
    ll ans = 0;
    for(; r <= n; r++) {
        for (;l <= n && addsums[r] - addsums[l - 1] != (xorsums[r] ^ xorsums[l - 1]); l++);
        ans += r - l + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, 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;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int K, X; cin >> K >> X;
  vector<int> ans;
  ans.push_back(X);
  for (int i = 1; i <= K - 1; i++) {
    if (X - i >= -1000000) ans.push_back(X - i);
    if (X + i <= 1000000) ans.push_back(X + i);
  }
  sort(ans.begin(), ans.end());
  rep(i, ans.size()) cout << ans[i] << " ";
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
using std::cin;
using std::cout;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	auto swap = [](int &a, int &b) -> void { int t = a; a = b; b = t; };
	if(a > b) swap(a, b);
	if(a > c) swap(a, c);
	if(b > c) swap(b, c);
	cout << a << ' ' << b << ' ' << c << '\n';
	return 0;
}


Measured memory_bytes: 3104
#include<cstdio>
#include<cstring>
#define inlien inline
#define retrun return
#define cpnst const
int F[333][333][333],n,m,mod;
inline void pre()
{
	register int i,ii,iii;
	for(i=0;i<=n;i++)
		for(ii=1;ii<=m;ii++)
			for(iii=i;~iii;iii--)
			{
				if(iii)(F[i][ii][iii-1]+=F[i][ii][iii])%=mod;
				else(F[i][ii+1][i]+=F[i][ii][iii])%=mod;
				int t=F[i][ii][iii]*1ll*(iii+1)%mod;
				(F[i+1][ii][iii]+=t)%=mod;
			}
}
int main()
{
	scanf("%d%d%d",&n,&m,&mod),F[0][1][0]=1;
	pre(),printf("%d\n",F[n][m][0]);
}
/*
Giving the world a better yourself is giving yourself a better world. 
*/

Measured memory_bytes: 131072
fun main(args : Array<String>) {
    val (x, k, d) = readLine()!!.split(" ").map { it.toLong() }

    val t = Math.abs(x) / d
    val tr = Math.abs(x) % d

    if (t >= k) {
        println(Math.abs(x) - (d * k))
    } else {
        if (tr == 0L) {
            if ((k - t) % 2L == 0L) {
                println(0)
            } else {
                println(d)
            }
        } else {
            if (tr < d - tr) {
                if ((k - t) % 2L == 0L) {
                    println(tr)
                } else {
                    println(d - tr)
                }
            } else {
                if ((k - (t + 1)) % 2L == 0L) {
                    println(d-tr)
                } else {
                    println(tr)
                }
            }
        }
    }
}

Measured memory_bytes: 36388
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <map>
#include <unordered_map>
#include <limits>
#include <cmath>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main()
{
    ll N, M, X;
    scanf("%lld %lld %lld", &N, &M, &X);
    vector<ll> C(N);
    vector<vector<ll>> A(N, vector<ll>(M));
    for (ll i = 0; i < N; i++)
    {
        cin >> C[i];
        for (ll j = 0; j < M; j++)
            cin >> A[i][j];
    }

    vector<ll> skill(M, 0);
    ll count = pow(2, N);
    ll mincost = 10000000;
    bool ans = false;
    for (ll i = 0; i < count; i++)
    {
        ll cost = 0;
        for (ll j = 0; j < N; j++)
        {
            if ((i >> j) & 1)
            {
                for (ll k = 0; k < M; k++)
                {
                    skill[k] += A[j][k];
                }
                cost += C[j];
            }
        }

        bool res = true;
        for (ll k = 0; k < M; k++)
        {
            if (skill[k] < X)
            {
                res = false;
                break;
            }
        }
        for (ll k = 0; k < M; k++)
            skill[k] = 0;

        if (res)
            mincost = min(mincost, cost);
        ans |= res;
    }

    if (ans)
        printf("%lld", mincost);
    else
        printf("-1");
}


Measured memory_bytes: 4268
n=int(input())
dp=[0]*(n+120)
dp[100]=1
dp[101]=1
dp[102]=1
dp[103]=1
dp[104]=1
dp[105]=1

for i in range(100,n+1):
    if not dp[i]: continue
    dp[i+100:i+106]= [1]*6
print(dp[n])


Measured memory_bytes: 73896
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):string|string[]=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):string|string[]=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let a = t.s()
  t.o(a[2]==a[0]?'Yes':'No')
}
main()

Measured memory_bytes: 7372
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main()
{
	string s;
	cin >> s;
	rep(i,s.size()){
		if (i % 2 == 0)
		{
			if (s[i] == 'L'){
				cout << "No" << endl;
				return 0;
			}
		}
		else
		{
			if(s[i] == 'R'){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define bit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int run(string S) {
  int ret = 0;
  for (int i=1; i<int(S.size()); i++) {
    if (S[i-1] == S[i]) {
      ret++;
      if (S[i-1] == '0') {
        S[i] = '1';
      } else {
        S[i] = '0';
      }
    }
  }

  return ret;
}

int main(int argc, char** argv) {
  string S;
  cin >> S;

  int ret = INF;
  // 0
  if (S[0] == '0') {
    chmin(ret, run(S));   // 0
    S[0] = '1';
    chmin(ret, run(S)+1); // 1
  } else {
    chmin(ret, run(S));   // 1
    S[0] = '0';
    chmin(ret, run(S)+1);
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    int n;
    cin >> n;
    string sn = to_string(n);
    int sum = 0;
    for(int i = 0; i < sn.size(); i++){
        sum += sn[i]-'0';
    }
    if(n%sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String W = scan.next().toLowerCase();
		int cnt = 0;
		while(true) {
			String s = scan.next();
			if(s.equals("END_OF_TEXT")) {
				break;
			}
			if(s.toLowerCase().equals(W)) {
				cnt++;
			}
		}
		scan.close();
		System.out.println(cnt);
	}
}


Measured memory_bytes: 26056
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    bool check = false;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        check = check || (a % 2);
    }
    if(check){
        cout << "first\n";
    }else{
        cout << "second\n";
    }
}

Measured memory_bytes: 256
# coding: utf-8
def main():
    k = int(input())
    a, b = map(int, input().split())
    n = a//k
    num = 0
    while num <= b:
        num = k * n
        if a <= num and num <= b:
            print("OK")
            quit()
        n += 1
    print("NG")

if __name__ == '__main__':
    main()

Measured memory_bytes: 9176
import bisect

N = int(input())
A = sorted([int(i) for i in input().split()])
B = sorted([int(i) for i in input().split()])
C = sorted([int(i) for i in input().split()])

ans = 0

for i in B:
    zyo = bisect.bisect_left(A, i)
    ge = bisect.bisect_right(C, i)
    ans += (N-ge)*zyo
    #print(ans, zyo, ge)
print(ans)

Measured memory_bytes: 23156
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int x;
		// scanf("%d",&x);
		x = scan.nextInt();
		
		// printf("%d",x*x*x);
		System.out.println(x*x*x);
	}
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}
}

Measured memory_bytes: 26120
#include<iostream>
#include<cmath>
using namespace std;
int c[2]={0,1};

int main()
{
	int n,i=0,k,t;
	int s[3000]={0};
	cin>>n;
	if(n==0)
	{
		cout<<"0"<<endl;
		return 0;
	}
	while(n!=0)
	{
		k=n%(-2);
		t=n/(-2);
		if(k<0)
		{
			k=k-(-2);
			t++;
		}	
		i++;
		n=t;
		s[i]=c[k];	
	}
	for(;i>=1;i--)
		cout<<s[i]; 
	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
ll ans=0;
string s;
ll power(ll a,ll b) {
    if (b==0) return (ll)1;
    ll c = power(a,b/2);
    c = (c*c)%mod;
    if (b&1) return (a*c)%mod;
    else return c;
}
int ct=0;
void ch(string a,int p) {
    ll ct1=0,ct2=0;
    for (auto it:s) {
        if (it==a[2]) {
            ans += ct2 * power(3,ct-p);
            ans %= mod;
        }
        if (it==a[1]) {
            ct2 += ct1;
            ct2 %= mod;
        }
        if (it==a[0]) {
            ct1 = (ct1+1)%mod;
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>s;
    for (auto it:s) {
        if (it=='?') {
            ct++;
        }
    }
    ch("ABC",0);
    ch("?BC",1);
    ch("A?C",1);
    ch("AB?",1);
    ch("A??",2);
    ch("?B?",2);
    ch("??C",2);
    ch("???",3);
    cout<<ans<<endl;
}


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

int main() {
	int n, sum = 0;
	cin >> n;
	int v[n];
	for(int i = 0; i < n; i++) {
		cin >> v[i];
		sum += v[i];
	}
	for(int i = 0; i < n; i++) {
		if(v[i] >= sum - v[i]) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Numerics;

class Myon
{
    //chokudaiさんのコードをコピペ
    static Scanner cin;
    public Myon() { }
    public static int Main()
    {
        //Console.SetOut(new Printer(Console.OpenStandardOutput()));
        cin = new Scanner();
        new Myon().calc();
        Console.Read();

        return 0;
    }


    public void calc()
    {
        int n = cin.nextInt();
        int k = cin.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = cin.nextInt();

        int count = 0;
        for (int i = 0; i < n; i++) if (a[i] >= k) count++;

        showL(count);


    }



    public void backetSort(ref int[] a)
    {
        //max a << a.len に対して有効なソート
        //よってa = int[] とする
        long n = a.Length;
        var count = new int[n];
        var loc = new long[n];//loc[i] は i が終わる 位置 max index where c[index] = loc[i]
        for (long i = 0; i < n; i++) count[a[i]]++;
        loc[0] = count[0] - 1;
        for (long i = 0; i < n-1; i++) loc[i+1] = loc[i] + count[i+1]; 
        long index = 0;

        for(int i = 0; i < n; i++)
        {
            while (index <= loc[i]) a[index++] = i; //incex <= loc[i] == index < loc[i] + 1
        }
    }

    public static void showL(long n) { Console.WriteLine(n); }
    public static void showL(string s) { Console.WriteLine(s); }
}

class Printer : StreamWriter
{
    public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
    public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
    public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { }
}

class Scanner
{
    string[] s;
    int i;

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

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

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

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 19168
n,k = map(int, input().split())
d = list(map(int, input().split()))



while True:
    a = str(n)
    flag = False
    for i in range(len(d)):
        if str(d[i]) in a:
            flag = True
            n+=1
            break
    if not flag:
        break

print(n)

Measured memory_bytes: 41456
#include <stdio.h>
int	main(void)
{
	long long int N;
	scanf("%lld", &N);
	long long int arr[N];
	int index =0;
	while (index <N)
	{
		scanf("%lld",&(arr[index]));
		index++;
	}
	index =0;
	while (index <N)
	{
		if(arr[index]%2 ==0)
		{
			if(arr[index]%3 !=0 && arr[index]%5 !=0)
			{
				printf("DENIED\n");
				return(0);
			}
		}
		index++;
	}
	printf("APPROVED\n");
	return (0);
}


Measured memory_bytes: 128