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

int main(){

    string a, b;
    cin >> a >> b;

    for(int i=0, size1 = a.size(); i<size1; i++){
        int count = 0;  //一致する文字数
        int c = i;  //参照する添え字
        for(int j=0, size2 = b.size(); j<size2; j++){
            if(a[c]==b[j]){
                count++;
                c++;
            }
        }
    if(count==b.size()) cout << i << endl;
    }
    return 0;
}


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

ll costs[20];
ll ups[20][20];

ll cost(ll choice, ll n, ll m, ll x){
    ll tot_cost = 0;
    ll under[m];
    ll i,j;
    for(i = 0; i<m; i++){
        under[i] = 0;
    }
    for(i = 0; i<n; i++){
        if((choice&(1<<i))){
            tot_cost += costs[i];
            for(j = 0; j<m; j++) under[j] += ups[i][j];
        }
    }
    /*
    cout<<choice<<": ";
    for(i = 0; i<m; i++) cout<<under[i]<<" ";
    cout<<endl;i
    */
    for(i = 0; i<m; i++){
        if(under[i] < x) return -1;
    }
    return tot_cost;
}

int main(){
    ll n,m,x,i,j;
    cin>>n>>m>>x;
    for(i = 0; i<n; i++){
        cin>>costs[i];
        for(j = 0; j<m; j++){
            cin>>ups[i][j];
        }
    }
    /*
    for(i = 0; i<n; i++){
        cout<<costs[i]<<" ";
        for(j = 0; j<m; j++) cout<<ups[i][j]<<" ";
        cout<<endl;
    }
    */
    ll min_cost = 1e9;
    bool flag = false;
    for(i = 0; i<(1<<n); i++){
        ll tmp = cost(i,n,m,x);
        //cout<<"choice: "<<i<<" cost: "<<tmp<<endl;
        if(tmp == -1) continue;
        else{
            flag = true;
            if(tmp < min_cost) min_cost = tmp;
        }
    }
    if(flag) cout<<min_cost<<endl;
    else cout<<"-1\n";
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
}P;
P Q[LEN];
int head, tail, n;
void enqueue(P x){
    Q[tail] = x;
    tail = (tail+1) % LEN;
}
P dequeue(){
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}
int min(int a, int b){
    return a<b ? a:b;
}
int main(void){
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);
    for(i = 1; i<= n; i++){
        scanf("%s", Q[i].name); 
        scanf("%d", &Q[i].t);
    }
    head = 1; tail = n+1;
    while(head != tail){
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if(u.t > 0) enqueue(u);
        else{
            printf("%s %d\n", u.name, elaps);
        }
    }
    return 0;
}


Measured memory_bytes: 11868
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int n;
ll a[222222];
ll b[222222];
ll c[222222];

int main(void){
  scanf("%d",&n);
  for(int i = 0; i < n; i++){
    scanf("%lld",a+i);
  }

  for(int i = 0; i < n; i++){
    ll x = a[i] - (i+1);
    c[i+1] = x;
  }
  
  sort(c+1, c+n+1);

  for(int i = 1; i <= n; i++){
    b[i] += b[i-1] + c[i];
  }

  ll best = 1LL<<60;
  for(int i = 1; i <= n; i++){
    ll x = 0;
    x += abs(b[i-1] - c[i]*(i-1));
    x += abs(b[n] - b[i] - c[i]*(n-i));
    best = min(best, x);
  }
  printf("%lld\n",best);
}




Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define fi first
#define se second
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 1e6 + 9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll, ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}





void test_case()
{

    int n;
    cin>>n;

    // cout<<n<<endl;
    vector<int> a(n),  p(200005,1);
    int  q = 0, z = 0;



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


    sort(all(a));

    for(auto it : a) {
        // cout<<it<<" ";
    }


       for (int i = 1; i <= n; i++)
        { p[i] = p[i - 1] * 2 % mod;}


    // cout<<a[0]<<endl;

    q = p[n - 1];

    for (int i = n - 1; i >= 0; i--) {
        z = (z + q * a[i]) % mod;
        q = (q + p[n - 2]) % mod;
    }
    cout << z * p[n] % mod;



    




    
    
    
}

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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

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

using namespace std;

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

int main(){

	int w,h,n;
	cin>>w>>h>>n;
	int x[n],y[n],a[n];
	rep(i,n)cin>>x[i]>>y[i]>>a[i];

	int l=0,r=w,t=h,b=0;
	rep(i,n){
		switch(a[i]){
		case 1:
			l=max(l,x[i]);
			break;
		case 2:
			r=min(r,x[i]);
			break;
		case 3:
			b=max(b,y[i]);
			break;
		case 4:
			t=min(t,y[i]);
			break;
		}
	}
	if(r-l<0 || t-b<0)cout<<0;
	else cout<<(r-l)*(t-b);
	cout<<endl;

	return 0;
}


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

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            //ここから
            string S = IO.ReadLineToString();
            int max = 0;
            for(int i = 0; i < S.Length; i++)
            {
                int m = 0;
                for(int j = i; j < S.Length; j++)
                {
                    string str = S.Substring(j, 1);
                    if (str == "A" || str == "C" || str == "G" || str == "T")
                    {
                        m++;
                    }
                    else
                    {
                        break;
                    }
                }
                max = m > max ? m : max;
            }


            //ここまで
            Console.WriteLine(max);
            Console.ReadKey();
        }
    }
    
    class Func
    {
        long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(int a, int b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(int a, int b) { return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }
        static public int Conbin(int n, int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); }
        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < (long)Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    class IO
    {
        static public string ReadLineToString(){return Console.ReadLine();}
        static public int ReadLineToInt(){return int.Parse(Console.ReadLine());}
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray(){return Console.ReadLine().Split(' ').ToArray();}
        static public int[] ReadLineToIntArray(){return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();}
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList(){return Console.ReadLine().Split(' ').ToList();}
        static public List<int> ReadLineToIntList(){return Console.ReadLine().Split(' ').Select(int.Parse).ToList();}
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }   
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (max(a, c) >= min(b, d))
        cout << 0 << endl;
    else
        cout << min(b, d) - max(a, c) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		long[] a = new long[N];
		int four = 0;
		int two = 0;
		int odd = 0;
		for (int i = 0; i < N; i++) {
			a[i] = in.nextLong();
			if (a[i] % 4 == 0) {
				four++;
			} else if (a[i] % 2 == 0) {
				two++;
			} else {
				odd++;
			}
		}
		if (odd + two % 2 <= four + 1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		in.close();
	}
}

Measured memory_bytes: 47828
import sys
import math
N,x = list(map(int,input().split()))
a = list(map(int,input().split()))
ans = sum(a)
mini = a
nx = 0
for i in range(1,N):
	nx += x
	mini = [k if k < mini[j-1] else mini[j-1] for j,k in enumerate(a)]
	s = sum(mini) + nx
	ans = min(s,ans)
print(ans)




Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    }
    public void solve() throws Exception {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int a = scan.nextInt();
        String s = scan.next();
        if (a < 3200) {
            System.out.println("red");
        } else {
            System.out.println(s);
        }
    }
}


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


#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define fastIO ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);cerr.tie(NULL);
#define endl '\n'
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define inf INT_MAX
#define minf INT_MIN

typedef long long int lli;

using namespace std;

ofstream outfile;
ifstream infile;

int main()
{
	infile.open("input.txt");
	outfile.open("output.txt");

	
	string s;
	cin >> s;
	cout << s.substr(0, s.size()-8);
}

Measured memory_bytes: 256
n=input()
while True:
    dic={}
    for i in range(n):
        L=raw_input().split()
        dic[(-(3*int(L[1])+1*int(L[3])),i)]=L[0]
    for i in sorted(dic):
        print "%s,%d"%(dic[i],-i[0])
    n=input()
    if n==0:break
    print

Measured memory_bytes: 4228
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val a = sc.nextInt()
  val b = sc.nextInt()
  val c = sc.nextInt()
  val d = sc.nextInt()
  val e = sc.nextInt()


  var sum = 0
  sum += calc(a)
  sum += calc(b)
  sum += calc(c)
  sum += calc(d)
  sum += calc(e)

  val list = mutableListOf<Int>()
  list.add(left(a))
  list.add(left(b))
  list.add(left(c))
  list.add(left(d))
  list.add(left(e))
  val min = list.min()!!


  println(sum + min - 10)
}

private fun calc(a: Int): Int {
  if (a % 10 == 0) return a

  val ret = a / 10 + 1
  return ret * 10
}

private fun left(a: Int): Int {
  if (a % 10 == 0) return 10
  return a % 10
}

Measured memory_bytes: 31396
#include<bits/stdc++.h>
using namespace std;
template<typename V>
bool tomin(V&x,V y){if(y<x){x=y;return true;}return false;}
template<typename V>
bool tomax(V&x,V y){if(x<y){x=y;return true;}return false;}
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
#define lowbit(x) ((x)&-(x))
const int M=1e5+5,Mod=1e9+7;
int n,K;
vector<int>E[M];
ll dfs(int x,int f){
    ll ret=1;
    if(x==1){
        for(int i=K-1,j=1;j<=E[x].size();i--,j++){
            ret*=i;
            ret%=Mod;
        }
    }else{
        for(int i=K-2,j=1;j<=E[x].size()-1;i--,j++){
            ret*=i;
            ret%=Mod;
        }
    }
    for(auto v:E[x]){
        if(v==f)continue;
        ret*=dfs(v,x);
        ret%=Mod;
    }
    return ret;
}
int main(){
    scanf("%d%d",&n,&K);
    for(int i=1;i<n;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        E[x].push_back(y);
        E[y].push_back(x);
    }
    printf("%d\n",K*dfs(1,0)%Mod);
}

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

const int MOD = 1e9+7;

struct Combination {
	vector<long long> inv,finv,fac;
	Combination(int n, int kmax) : inv(kmax+1),finv(kmax+1),fac(kmax){
		if(kmax>=1){
			inv.at(1)=1;
			finv.at(1)=1;
			fac.at(0) = n;
		}
	for(int i=2; i<=kmax; i++) inv.at(i) = MOD - inv.at(MOD%i) * (MOD/i) %MOD;
	for(int i=2; i<=kmax; i++) finv.at(i) = finv.at(i-1) * inv.at(i) % MOD;
	for(int i=1; i<kmax; i++) fac.at(i) = fac.at(i-1) * (n-i) % MOD;
	}
	int comb(int k) {return (k ? fac.at(k-1) * finv.at(k) % MOD : 1 );}
};

int main() {
	
int x, y;
	cin >> x >> y;
	int k=x+y;
	bool flg = 1;
	if(k%3!=0) flg=0;
	k/=3;
	if(x<k || y<k) flg=0;
	int d = x-k;
	int ans = 0;
	if(flg) {
		Combination C(k,d);
		ans = C.comb(d);
	}
	cout << ans << endl;
  
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    map<ll, ll> verts;
    pair<ll, ll> prev = {-1, 0};
    ll ans = 1;
    cin >> N;
    rep(i, N) {
        ll temp;
        cin >> temp;
        if(i == 0 && temp != 0) {
            cout << 0 << endl;
            return 0;
        }
        verts[temp]++;
    }
    if(verts[0] > 1) {
        cout << 0 << endl;
        return 0;
    }
    iter(i, verts) {
        if(i.first - prev.first != 1) {
            cout << 0 << endl;
            return 0;
        }
        if(i.first != 0) {
            rep(j, i.second) (ans *= prev.second) %= 998244353LL;
        }
        prev = i;
    }
    cout << ans << endl;
    return 0;
}


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

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static int n, m, k;
	static long mod = 998244353;
	static Boolean[][][] memo;
	static String s;
	static HashMap<Integer, Integer> nums;
	static ArrayList<Integer>[] ad;
	static int inf = 1000000;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int[] occ = new int[n];
		int ans = 0;
		int k = sc.nextInt();
		for (int i = 0; i < k; i++) {
			int l = sc.nextInt();
			for (int j = 0; j < l; j++)
				occ[sc.nextInt() - 1]++;
		}
		for (int i = 0; i < n; i++)
			if (occ[i] == 0)
				ans++;
		System.out.println(ans);
		out.flush();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public int[] nextArrInt(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextArrLong(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 35364
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		for (int i = a; i <= b; i++) {
			if (i % k == 0) {
				System.out.println("OK");
				sc.close();
				return;
			}
		}
		System.out.println("NG");
		sc.close();
	}

}

Measured memory_bytes: 27084
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())

x1 = (a1-b1) * t1
x2 = (a2-b2) * t2 + x1
      
if x2 ==0:
    print("infinity")
elif x1*x2>0:
    print(0)
else:
    print(abs(x1) // abs(x2) * 2 + (abs(x1)%abs(x2) > 0))

Measured memory_bytes: 3064
use itertools::Itertools;
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        q: usize,
        abcd: [(usize, usize, usize, usize); q],
    }
    println!(
        "{}",
        &(1..=m)
            .combinations_with_replacement(n)
            .map(|able| {
                abcd.iter().fold(0, |sum, &(a, b, c, d)| {
                    sum + if able[b - 1] - able[a - 1] == c { d } else { 0 }
                })
            })
            .max()
            .unwrap()
    );
}


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


int main() {
  int n,m;
  cin >> n>>m;
  int ans=0;
  vector<int>a(m),b(m);
  rep(i,m){
    cin>>a.at(i)>>b.at(i);
    a.at(i)--;
    b.at(i)--;
  }
  vector<vector<bool>>x(n,vector<bool>(n));
  rep(i,m){
    x.at(a.at(i)).at(b.at(i))=true;
    x.at(b.at(i)).at(a.at(i))=true;    
  }
  vector<int>r;
  rep2(i,1,n){
    r.push_back(i);
  }
  sort(r.begin(), r.end());
  do {
    bool ch=true;
    if(!x.at(0).at(r.at(0))){
      ch=false;
    }
    rep(i,r.size()-1){
      if(!x.at(r.at(i)).at(r.at(i+1))){
        ch=false;
      }
    }
    if(ch){
      ans++;
    }
  } while (next_permutation(r.begin(), r.end()));
 
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

char so[1000001];


int key(int n){
	int s=0,maxi=0;;
	for(int i=0;i<=n;i++){
		if(so[i]==0 && n%i==0){
			s+=i;
			maxi=i;
		}
	}
	
	return maxi*2-s;
}

int main(){
	so[0]=so[1]=1;
	
	for(int i=2;i*i<1000001;i++){
		if(so[i]==1)continue;
		for(int j=2;j*i<1000001;j++){
			so[i*j]=1;
		}
	}
	
	int a,b;
	while(cin>>a>>b){
		if(a==0 && b==0)break;
		//printf("a %d b %d ",key(a),key(b));
		puts(key(a)>key(b)?"a":"b");
	}
}

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

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    string S;
    cin >> S;
    int one = 0;
    int zero = 0;
    rep(i, S.size()){
        if(S[i] == '1'){
            one++;
        }else{
            zero++;
        }
    }
    cout << min(one, zero)*2 << endl;
return 0;}
/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;
const int INT_INF = 1e9;
long long gcd(long long x, long long y) {
	long long m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}


void solve() {
	int N; cin >> N;
	int ans = N * 800;
	ans -= 200 * (N / 15);
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




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

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

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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int N; cin >> N;
	vi A(N);
	for(auto &x : A)cin >> x;
	ll res = 0;
	int maxi = A[0];
	forn(i,1,N){
		if(A[i] > maxi){
			maxi = A[i];
			continue;
		}
		res += maxi-A[i];
	}
	cout << res << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 3956
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  string s,t;cin>>s>>t;
  s=s+s;
  rep(i,s.size()){
  	if(s.substr(i,s.size()/2)==t){
  		cout<<"Yes"<<endl;
  		return 0;
  	}
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("outp.txt","w",stdout);
    #endif
    ll x,a,b,f=0;
    cin>>x;
    for(ll i=0;i<=120;i++)
    {
        for(ll j=-64;j<i;j++)
        {
                if(pow(i,5)-pow(j,5)==x)
                {
                    a=i;b=j;
                    f=1;
                    break;
                }
            if(f==1)
                break;
        }
    }
    cout<<a<<" "<<b;
}

    


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

std::vector<std::string> res;
std::string s;
void func(int i, std::bitset<256> used, std::string& tmp)
{
    if(i==s.size()){
        res.push_back(tmp);
        return;
    }

    if(s[i]=='a' || used[s[i]]){
        tmp += s[i];
        func(i+1,used,tmp);
        tmp.pop_back();
    }
    if(s[i]!='z' && !used[s[i]+1]){
        tmp += (s[i]+1);
        used[s[i]+1] = true;
        func(i+1,used,tmp);
        used[s[i]+1] = false;
        tmp.pop_back();
    }
}

int main()
{
    using namespace std;

    while(true)
    {
        res.clear();
        std::cin >> s;
        if(s=="#"){
            break;
        }

        std:string tmp;
        func(0,0,tmp);
        std::sort(res.begin(), res.end());
        res.erase(std::unique(res.begin(), res.end()),res.end());

        cout << res.size() << endl;
        if(res.size()>10){
            
            for(int32_t i = 0; i < 5; i++)
            {
                cout << res[i] << endl;
            }
            for(int32_t i = res.size()-5; i < res.size(); i++)
            {
                cout << res[i] << endl;
            }
            
        }
        else{
            for(int32_t i = 0; i < res.size(); i++)
            {
                cout << res[i] << endl;
            }
        }
    }

}


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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N;
    cin >> N;
    ll Ai;
    vector<vector<int>> A(N);
    for(int i=1;i<N;i++){
        cin >> Ai;
        A[Ai-1].push_back(i);
    }
    for(int i=0;i<N;i++){
        cout << A[i].size() << endl;
    }

    return 0;
}

Measured memory_bytes: 14028
#include <bits/stdc++.h> 
#include <time.h>
#define F(i,a,b) for(long long i=a;i<=(b);++i)
#define dF(i,a,b) for(long long i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e5+10;
const int N = 1e5+10;
const int E = 2e5+10;  
ll a,b,n,x;

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

Measured memory_bytes: 3624
/*input
4
RRGB
*/
#include <bits/stdc++.h>
using namespace std; 
#define int long long int
#define max(x, y) ((x) > (y) ? (x) :(y))
#define pii pair< int , int> 
#define vi vector<int>
#define REP( i , st , en ) for ( int i =st; i < (int)en; i++)
#define REPD( i , en , st ) for ( int i =en; i >= (int)st; i--)
#define SZ(a) (int)a.size()
#define all(v) v.begin() , v.end()
#define pb push_back
#define F first
#define S second
#define bitch_i_m_on_fiyaah_yeahhhh ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// const int mod = 998244353;
const int mod = 1e9+7;
ostream& operator << ( ostream&  o, vector<int> s){for ( int i = 0;  i < (int)s.size() ; i++)o << s[i] << " ";o << "\n";return o;}
void  add( int &a, int b){a = a + b;if ( a< 0 ) a += mod; if ( a> mod ) a-= mod;}
void sub( int &a, int b){a = a - b;if ( a < 0) a += mod;}
int mul( int a , int b){return ((a %mod) * (b %mod) ) %mod;}
int exp( int a , int pow){ return (pow == 0 ? 1 : ( pow & 1  ? mul ( a ,exp( mul(a, a) , pow /2) ) : exp(mul(a ,a) , pow/2)));}
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
// const int inf = 1e18;
const int maxn = 6e5 +5;
void solve(int test ) 
{	
	int n;
	cin >> n;
	vector<int> v;
	string s;
	cin >> s;
	int r =0 , g =0  , b = 0;
	for ( int i = 0 ; i < n ; i++) {
		if ( s[i] == 'R') v.push_back(1) , r++;
		else if ( s[i] == 'G') v.push_back(2) , g++;
		else v.push_back( 3) , b++;
	}
	int ans = r * g  * b ;
	for ( int i = 0 ;i < n ; i++) {
		for ( int j = i +1 ; j < n ; j++){
			int dif = j - i;
			int k = j + dif;
			if ( k < n && (v[i] ^ v[j] ^ v[k]) == 0) ans--;
		}
	}
	cout << ans;

}
signed main(){
	bitch_i_m_on_fiyaah_yeahhhh
	int t =1; 
	// cin >> t;
	auto start = chrono::steady_clock::now();
	for ( int i = 0 ; i < t; i++)
	solve(i+1 );
	auto end = chrono::steady_clock::now();
	auto diff = end - start;
	// cout <<  (chrono::duration <double, milli> (diff).count()  / 1000 .0 )<< " s" << endl;
}

Measured memory_bytes: 3740
#include <stdio.h>
void insertionSort(int *A, int N)
{
  int v, j, i, k;

  for(i = 1; i < N+1; i++){
    for(k = 0; k < N; k++){
      if(k != N-1) printf("%d ", A[k]);
      else printf("%d\n", A[N-1]);
    }
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }
  }
}

int main(void)
{
  int a[100], n, i;
  scanf("%d", &n);

  for(i = 0; i < n; i++)
    scanf("%d", &a[i]);

  insertionSort(a, n);

  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
ll power(ll a,ll b)
{ll result=1;
while(b>0)
{if(b%2==1)
 result*=a;
 a*=a;
 b/=2;
}
return result;
}
int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);
double d,t,s;
cin>>d>>t>>s;
double temp=d/s;
if(temp<=t)
cout<<"Yes";
else
cout<<"No";
}


Measured memory_bytes: 3736
N = int(input())
L = list(map(int, input().split()))
s = []
c = 0
for i in range(1, len(L)):
  if L[i-1] < L[i]:
    s.append(c)
    c = 0
  else:
    c += 1
s.append(c)
print(max(s))


Measured memory_bytes: 20388
N = int(input())
ans = float('inf')
for i in range(1,N):
	num = i
	j = N - num
	d = 0
	while num != 0:
		d += (num % 10)
		num //= 10
	while j != 0:
		d += (j % 10)
		j //= 10

	ans = min(d,ans)

print(ans)

Measured memory_bytes: 3064
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    long long a,b;
    cin >> a >> b;
    long long sol =  1;
    long long fact =2;
    
    set<long long> set1;
    set<long long> set2;
    while(fact * fact <= a)
    {
        if(a % fact == 0)
        { 
            set1.insert(fact);
            while(a%fact ==0)
            {
                a/=fact;
            }
        }
        fact++;
    }
    if(a!= 1)
        set1.insert(a);
    fact = 2;
    while(fact * fact <= b)
    {
        if(b % fact == 0)
        { 
            set2.insert(fact);
            while(b%fact ==0)
            {
                b/=fact;
            }
        }
        fact++;
    }
    if(b!= 1)
        set2.insert(b);
    for(auto &elem : set1)
    {
        if(set2.find(elem) != set2.end())
        {
            sol++;
        }
    }
    cout << sol;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   string S,T;
   cin >> S >> T;
   int A,B;
   cin >> A >> B;
   string U;
   cin >> U;
   if(U==S){
      A--;
   }
   else{
      B--;
   }
   cout << A << " " << B << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1e9;
const int MOD = 1000000007;

int n, m, x;
vector<vector<int>> a;
vector<int> c;
ll dfs(int u, int s, vector<ll> und) {
   if (u == n) {
      rep(i, 0, m) if (und[i] < x) return INF;
      return s;
   }
   ll ans = dfs(u + 1, s, und);
   rep(i, 0, m) { und[i] += a[u][i]; }
   ans = min(dfs(u + 1, s + c[u], und), ans);
   return ans;
}

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

   cin >> n >> m >> x;
   a.resize(n);
   c.resize(n);

   rep(i, 0, n) {
      cin >> c[i];
      rep(j, 0, m) {
         int t;
         cin >> t;
         a[i].push_back(t);
      }
   }
   ll ans = dfs(0, 0, vector<ll>(m, 0));
   if (ans == INF)
      cout << -1 << endl;
   else
      cout << ans << endl;
   return 0;
}

Measured memory_bytes: 3672
#include<stdio.h>
#include<string.h>

int main(void){
	char s[100000];
	int l;
	int i,j;
	int n[26] = {};
	int th;
	int num;



	scanf("%s",s);
	
	l = strlen(s);

	for(i=2;i<=2;i++){
		th = i / 2 + 1;

		for(j=0;j<26;j++){
			n[j] = 0;
		}

		for(j=0;j<i;j++){
			num = s[j] - 'a';
			n[num]++;
			if(n[num] >= th){
				printf("%d %d\n",1,i);
				return 0;
			}
		}

		for(j=i;j<l;j++){
			num = s[j-i] - 'a';
			n[num]--;
			num = s[j] - 'a';
			n[num]++;
			if(n[num] >= th){
				printf("%d %d\n",j-i+2,j+1);
				return 0;
			}

		}
	}
	if(l > 2){
		for(i=3;i<=3;i+=2){
			th = i / 2 + 1;

			for(j=0;j<26;j++){
				n[j] = 0;
			}

			for(j=0;j<i;j++){
				num = s[j] - 'a';
				n[num]++;
				if(n[num] >= th){
					printf("%d %d\n",1,i);
					return 0;
				}
			}

			for(j=i;j<l;j++){
				num = s[j-i] - 'a';
				n[num]--;
				num = s[j] - 'a';
				n[num]++;
				if(n[num] >= th){
					printf("%d %d\n",j-i+2,j+1);
					return 0;
				}

			}
		}
	}



	printf("-1 -1\n");

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MOD = (1e+9) + 7;

int main() {
    cin>>N;
    vec a(N);
    rep(i,N) cin>>a[i];
    multiset<ll> mset;
    rep(i,N){
        auto ite = mset.lower_bound(a[i]);
        if(ite == mset.begin()){
            mset.insert(a[i]);
        }else{
            --ite;
            mset.erase(ite);
            mset.insert(a[i]);
        }
    }
    cout<<mset.size()<<endl;
}


Measured memory_bytes: 5760
#include <iostream>
#include <map>
using namespace std;
int main(void){
    int n, a[200000], max_a;
    map<int, int> p;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
        p[a[i]]++;
    }
    auto itr = p.end();
    itr--;
    max_a = itr->first;
    bool flag = false;
    if(itr->second > 1)flag = true;
    for(int i=0;i<n;i++){
        if(flag || a[i] < max_a){
            cout << max_a << endl;
        }else{
            itr = p.end();
            itr--;
            itr--;
            cout << (itr->first) << endl;
        }
    }
}


Measured memory_bytes: 7936
#include<stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  switch(n%10){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      printf("hon");
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      printf("pon");
      break;
    default:
      printf("bon");
  }
}

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

int main() {
	int H, W;
  cin >> H >> W;
  vector<vector<char> > a;
  vector<char> z;
  for (int i = 0; i<W; i++) {
    z.push_back('?');
  }
  
  for (int i = 0; i<H; i++) {
    int count=0;
    vector<char> b;

 	for (int j = 0; j<W; j++) {      
      char ness;cin >> ness;b.push_back(ness);
      if (b[j] == '.'){
        count++;
      }
    }
	if (count != W) {    
    	a.push_back(b);
    }
    else {
    	a.push_back(z);
    }
   
  }
  
  for (int i = 0; i<W; i++) {
    int count_i = 0;
    for (int j = 0; j<H; j++) { 
      if (a[j][i] == '.' || a[j][i] == '?'){
        count_i++;
      }
    }
    if (count_i == H)  {
      for (int j = 0; j<H; j++) { 
        a[j][i] = '?';
      }
    }
  }
  
  for (int i = 0; i<H; i++) {
    int cnt=0;
    for (int j = 0; j<W; j++) {   
      if (a[i][j] != '?') {
      	cout << a[i][j];
      }else{cnt++;}
    }    
    if(cnt!=W)cout << endl;

  }      
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

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

	class Edge{
		int to;
		int cost;
		Edge(int to, int cost){
			this.to=to;
			this.cost=cost;
		}
	}

	ArrayList<ArrayList<Edge>> g = new ArrayList<ArrayList<Edge>>();
	int d[];
	int INF = 2000000005;
	boolean ans = true;
	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		for(int i=0; i<n; i++) g.add(new ArrayList<Edge>());
		d = new int[n];
		for(int i=0; i<n; i++) d[i] = INF;
		for(int i=0; i<m; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			int d = sc.nextInt();
			l--; r--;
			g.get(l).add(new Edge(r,d));
			g.get(r).add(new Edge(l,-d));
		}
		for(int i=0; i<n; i++) {
			if(d[i] == INF) {
				dfs(i);
			}
		}
		System.out.println(ans ? "Yes" : "No");
		sc.close();
	}

	private void dfs(int r) {
		ArrayDeque<Integer> s = new ArrayDeque<Integer>();
		s.push(r);
		d[r]=0;
		while(!s.isEmpty()) {
			int u = s.pop();
			for(Edge e : g.get(u)) {
				if(d[e.to] == INF) {
					d[e.to] = d[u] + e.cost;
					s.push(e.to);
				}else {
					if(d[e.to] != d[u] + e.cost) {
						ans = false;
					}
				}
			}
		}
	}
}


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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(0)





void solve() {

	int n;
	cin >> n;
	vector<int> v(n);
	int x;
	for(int i = 0; i < n - 1; i++) {
		cin >> x;
		v[x - 1]++;
	}
	for(auto &e: v) {
		cout << e << "\n";
	}




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	fix;
	solve();

	return 0;
}

Measured memory_bytes: 3964
def main():
    N = int(input())
    health = set(map(int, input().split()))
    min_num = min(health)
    for i in health:
        while i % min_num != 0:
            temporary_min_num = min_num
            min_num = i % min_num
            i =  temporary_min_num
    print(min_num)

main()


Measured memory_bytes: 19728
#include <stdio.h>

int main(void){
    // Your code here!
    int a,b,c;
    int max,sum=0;
    
    scanf("%d%d%d",&a,&b,&c);
    
    if(a > b ){
        max = a;
    }
    else{
        max = b;
    }
    
    if(c > max){
        max = c;
    }

    if(max == (a+b+c-max)){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
}


Measured memory_bytes: 128
#include <stdio.h>
#include <memory.h>
int map[101][101],line[5]={0,1,0,-1,0},sign;
void set(int x,int y,int d,int c){
    int i;
    if(d)
        for(i=0;i<4;i++){
            map[y+i][x]=c;
            map[y+i][x+1]=c;
        }
    else
        for(i=0;i<4;i++){
            map[y][x+i]=c;
            map[y+1][x+i]=c;
        }
}
void search(int x,int y,int gx,int gy,int c){
    int i;
    if(map[y][x]!=c)
        return;
    if(x==gx&&y==gy){
        sign=1;
        return;
    }
    map[y][x]=0;
    for(i=0;i<4;i++)
        search(x+line[i+1],y+line[i],gx,gy,c);
}
int main(void){
    int w,h,xs,ys,xg,yg,n,i,c,d,x,y;
    for(;memset(map,0,sizeof(map)),sign=0,scanf("%d %d",&w,&h),h;){
        scanf("%d %d %d %d %d",&xs,&ys,&xg,&yg,&n);
        for(i=0;i<n;i++){
            scanf("%d %d %d %d",&c,&d,&x,&y);
            set(x,y,d,c);
        }
        if(map[ys][xs])
            search(xs,ys,xg,yg,map[ys][xs]);
        printf("%s\n",sign?"OK":"NG");
    }
    return 0;
}

Measured memory_bytes: 632
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int a, b; 
    string s;
    cin >> a >> b >> s;

    bool flag = true;
    for(int i = 0; i <s.size(); i++) {
        if(i == a)  {
            if(s[i]!='-') flag = false;
        }else {
            if(!(iswdigit(s[i])) ) {
                flag = false;
            }
        }
    }

    if(flag) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int cnt = (N + 1) / 2;
    cout << fixed << setprecision(12) << cnt/(double)N << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
W = [int(i) for i in input().split()] 
onon = 0
hoge = sum(W)
nowresult = sum(W)
for i in range(N):
    onon += W[i]
    hoge -= W[i]
    result = abs(onon - hoge)
    if result <= nowresult:
        nowresult = result
print(nowresult)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    double p1, s1, p2, s2;
    int x, y;
    scanf("%lf %lf %lf %lf", &p1, &s1, &p2, &s2);
    x = ceil(p2/s1);
    y = ceil(p1/s2);
    if(x<=y){
        printf("Yes\n");
    }
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 1676
n = input()
for i in range(2 ** 3):
    result = int(n[0])
    formura = n[0]
    for j in range(3):  
        if ((i >> j) & 1): 
            result -= int(n[j+1])
            formura += "-"+n[j+1]
        else:
            result += int(n[j+1])
            formura += "+"+n[j+1]
    
    if result == 7:
        print(formura+"=7")
        break

Measured memory_bytes: 3064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

use std::cmp::max;

fn main() {
    input! {
        w: i64,
        h: i64,
        n: i64,
        xya: [(i64, i64, i64); n],
    }
    let mut p = (0,0,w,h);
    for (x,y,a) in xya {
        match a {
           1 => if p.0 < x { p.0 = x },
           2 => if p.2 > x { p.2 = x },
           3 => if p.1 < y { p.1 = y },
           4 => if p.3 > y { p.3 = y },
           _ => panic!()
        };
    }
    println!("{}", max(p.2-p.0,0) * max(p.3-p.1,0));
}


Measured memory_bytes: 4352
import heapq
from collections import defaultdict, deque
from math import ceil, factorial
from fractions import gcd
import sys
sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 10**9+7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))


n, k, c = mii()
s = si()


def get_positions():
    res = []
    i = 0
    while i < n and len(res) < k:
        if s[i] == 'o':
            res.append(i)
            i += c+1
        else:
            i += 1
    return res


l = get_positions()
s = s[::-1]
r = get_positions()
for i in range(k):
    r[i] = n-1-r[i]
s = s[::-1]

lastL = [-1] * (n+1)
for i in range(k):
    lastL[l[i]+1] = i
for i in range(n):
    if lastL[i+1] == -1:
        lastL[i+1] = lastL[i]

lastR = [-1] * (n+1)
for i in range(k):
    lastR[r[i]] = i
for i in reversed(range(n)):
    if lastR[i] == -1:
        lastR[i] = lastR[i+1]


for i in range(n):
    if s[i] == 'x':
        continue
    li = lastL[i]
    ri = lastR[i+1]
    cnt = 0
    if li != -1:
        cnt += li + 1
    if ri != -1:
        cnt += ri + 1
    if li != -1 and ri != -1 and r[ri]-l[li] <= c:
        cnt -= 1
    if cnt >= k:
        continue
    print(i+1)

Measured memory_bytes: 38668
import java.util.*;

public class Main {
	private static final Scanner sc = new Scanner(System.in);

	public static void main(String... args) {
		while (sc.hasNext()) {
			final int N = sc.nextInt();
			if (N == 0)
				break;
			solve(N);
		}
	}

	private static void solve(final int N) {
		sc.nextLine();
		final String[] lines = new String[N];
		for (int i = 0; i < N; i++)
			lines[i] = sc.nextLine();
		final Map<String, Integer> map = new HashMap<String, Integer>();
		for (int i = 0; i < N; i++)
			map.put(lines[i].split(" ", 2)[0], i);
		final int[] powers = new int[N];
		final long[] masks = new long[N];
		for (int i = 0; i < N; i++) {
			final String[] ss = lines[i].split(" ");
			powers[i] = Integer.parseInt(ss[1]);
			masks[i] = 1L << i;
			final int M = Integer.parseInt(ss[2]);
			for (int j = 0; j < M; j++)
				masks[i] |= 1L << map.get(ss[3 + j]);
		}
		System.out.println(powers[0] + dfs(N, 1, masks[0], powers, masks));
	}

	private static int dfs(final int N, final int c, final long used, final int[] powers, final long[] masks) {
		if (c == N)
			return 0;
		int ret = 0;
		if ((used & 1L << c) == 0) {
			ret = dfs(N, c + 1, used | masks[c], powers, masks) + powers[c];
			long rem = 0L;
			for (int k = c + 1; k < N; k++)
				if ((used & 1L << k) == 0)
					rem |= masks[k];
			if ((rem & 1L << c) == 0)
				return ret;
		}
		return Math.max(ret, dfs(N, c + 1, used, powers, masks));
	}

	private static void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 13000