akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long
typedef pair<int, int> P;

int main(){
  string S, T;
  cin >> S >> T;
  int target = 0, start = -1, now = 0;
  rep(i, S.size()){
    while (true) {
      if (target >= T.size()) {
        start = i;
      }
      if (S[now] == T[target] || S[now] == '?') {
        now += 1;
        target += 1;
      }else{
        now = i+1;
        target = 0;
        break;
      }
    }
  }
  if (start != -1) {
    FOR(i, start, start+T.size()){
      S[i] = T[i-start];
    }
  }else{
    cout << "UNRESTORABLE" << endl;
    exit(0);
  }
  rep(i, S.size()){
    if (S[i] == '?') {
      S[i] = 'a';
    }
  }
  cout << S << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long 
#define pb push_back
#define mk make_pair
using namespace std;

int main()
{
	lld n;

	cin>>n;

	string s;
	cin>>s;

	lld count=0;

	lld ans=0,red=0,green=0,blue=0;
	lld k=0;


	for(lld i=0;i<n;i++)
	{
		if(s[i]=='R')
			red++;

		else if(s[i]=='B')
			blue++;

		else if(s[i]=='G')
			green++;
	}

	for(lld i=0;i<n;i++)
	{
		for(lld j=i;j<n;j++)
		{
			k = (2*j - i);

			if(k<n && k>j && s[i]!=s[j] && s[j]!=s[k] && s[k]!=s[i])
				count++;
		}
	}

	ans = (lld)red*green*blue - (lld)count;

	cout<<ans<<endl;
}

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

using namespace std;

int main(){
        int N;
        cin>>N;
        vector <int> d(N);
        for(int i=0;i<N;i++){
                cin>>d[i];
        }
        sort(d.begin(), d.end());
        int res=N;
        for(int i=1;i<N;i++){
                if(d[i]==d[i-1]){
                        res--;
                }
        }
        cout<<res<<endl;
        return 0;
}


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

int main() {
    int a, b, c=0;
    
    cin >> a >> b;
    
    if(a+b == 3) c = 3;
    else if(a+b == 4) c = 2;
    else c = 1;
    
    cout << c;
    
    return 0;
}


Measured memory_bytes: 256
// Bismillahir Rahmanir Rahim .Ya Allah...
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mod = 1e9+7,INF = 1e9;
const int mx = 1e5+5;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    cout<<1-n<<endl;
    return 0;
}


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

int main(){
	int a[5];
	int k;
	int i;

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

	if(a[4] - a[0] > k){
		cout << ":(";
		return 0;
		}

	cout << "Yay!";
	return 0;
}


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

public class Program
{
    public static void Main(string[] args)
    {
        new B().test();
    }
}

public class B
{
	public void test()
	{
		// 普通の文字列取得
		// 英語小文字のみ
		var input = CommonRead.ReadStr();

		var returnValue = true;

		var one = new string(input.Reverse().ToArray());

		// 普通の回文
		if (!input.Equals(one))
		{
			returnValue = false;
		}
		
		var alen = Convert.ToInt32(Math.Floor((double)((input.Length - 1) / 2)));
		var astr = input.Substring(0, alen);
		one = new string(astr.Reverse().ToArray());

		// 2個め回文
		if (!astr.Equals(one))
		{
			returnValue = false;
		}

		var blen = Convert.ToInt32(Math.Floor((double)((input.Length + 3) / 2)));
		var bstr = input.Substring(blen - 1);
		one = new string(bstr.Reverse().ToArray());

		// 3個め回文
		if (!bstr.Equals(one))
		{
			returnValue = false;
		}


		//出力
		Console.WriteLine(returnValue? "Yes": "No") ;
	}
}
static class CommonRead
{
    public static string ReadStr()
    {
        return Console.ReadLine();
    }
    public static string[] ReadStrA()
    {
        return ReadStr().Split(' ');
    }
    public static List<string> ReadStrL()
    {
        return ReadStrA().ToList();
    }
    public static int ReadInt()
    {
        return Convert.ToInt32(ReadStr());
    }
    public static int[] ReadIntA()
    {
        return ReadStrA().Select(s => Convert.ToInt32(s)).ToArray();
    }
    public static List<int> ReadIntL()
    {
        return ReadStrA().Select(s => Convert.ToInt32(s)).ToList();
    }
    public static long ReadLong()
    {
        return Convert.ToInt64(ReadStr());
    }
    public static long[] ReadLongA()
    {
        return ReadStrA().Select(s => Convert.ToInt64(s)).ToArray();
    }
    public static List<long> ReadLongL()
    {
        return ReadStrA().Select(s => Convert.ToInt64(s)).ToList();
    }

    public static decimal ReadDecimal()
    {
        return Convert.ToDecimal(ReadStr());
    }
    public static decimal[] ReadDecimalA()
    {
        return ReadStrA().Select(s => Convert.ToDecimal(s)).ToArray();
    }
    public static List<decimal> ReadDecimalL()
    {
        return ReadStrA().Select(s => Convert.ToDecimal(s)).ToList();
    }

    public static double ReadDouble()
    {
        return Convert.ToDouble(ReadStr());
    }
    public static double[] ReadDoubleA()
    {
        return ReadStrA().Select(s => Convert.ToDouble(s)).ToArray();
    }
    public static List<double> ReadDoubleL()
    {
        return ReadStrA().Select(s => Convert.ToDouble(s)).ToList();
    }

}



Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <iomanip>

#include <map>
#include <set>
#include <queue>
#include <stack>

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdbl vector<double>
#define vstr vector<string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int N,M;
bool red[100000];
int cnt[100000];
const int INF = 1e8;

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

	cin >> N >> M;

	// red : 最終的に赤玉を残せるかの配列
	// cnt : 玉がいま何個あるかの配列

	// 玉の数の遷移は球の色の選び方によらない
	// 一旦赤玉が入った箱は、玉の数が0にならなければ、最終的に赤玉を残せる
	// 玉の数が0になると赤玉を出さなくてはいけないため、redをfalseにする
	rep(i,N){
		red[i] = false;
		cnt[i] = 1;
	}
	red[0] = true;
	
	FOR(i,1,M+1){
		int x,y;
		cin >> x >> y;
		x--;
		y--;

		if(red[x]) red[y] = true;
		cnt[x]--;
		cnt[y]++;
		if(cnt[x] == 0) red[x] = false;
	}

	int ans = 0;
	rep(i,N){
		if(red[i]) ans++;
	} 
	
	cout << ans << endl;
}

Measured memory_bytes: 768
data class Test(val b: Long, val l: Long, val u: Long)

fun divCeil(x: Long, y: Long): Long = (x + y - 1) / y

fun main(args: Array<String>) {
  val (nRaw, x) = fastReadLongs(2)
  val n = nRaw.toInt()
  val tests = Array(n, {
    val (b, l, u) = fastReadLongs(3)
    Test(b, l, u)
  })
  var currentDiff = tests.map { -it.l * it.b }.sum()
  fun maxGain(test: Test): Long = test.l * test.b + test.u * (x - test.b)
  fun requiredScore(test: Test, score: Long): Long {
    if (score > maxGain(test)) throw RuntimeException()
    if (score <= test.l * test.b) {
      return divCeil(score, test.l)
    } else {
      return test.b + divCeil(score - test.l * test.b, test.u)
    }
  }
  tests.sortByDescending { maxGain(it) }

  var ans = 0L
  for (i in 0 until n) {
    if (currentDiff + maxGain(tests[i]) <= 0) {
      ans += x
      currentDiff += maxGain(tests[i])
    } else {
      var min = x
      for (k in i until n) {
        if (currentDiff + maxGain(tests[k]) >= 0) {
          min = Math.min(min, requiredScore(tests[k], -currentDiff))
        }
      }
      for (k in 0 until i) {
        val tmpDiff = currentDiff + maxGain(tests[i]) - maxGain(tests[k])
        min = Math.min(min, requiredScore(tests[k], -tmpDiff))
      }
      ans += min
      break
    }
  }

  // if (currentScore < 0) throw RuntimeException()

  println(ans)
}

// Reads multiple ints in a line, separate by a space.
// It works even if the actual number of ints is smaller than n.
// WARNING: This function does not work for -2^63.
// NOTE: This function does not handle error cases.
// Verified: ARC096D
fun fastReadLongs(n: Int): LongArray {
  val xs = LongArray(n)
  val s = readLine()!!
  var currentValue = 0L
  var isNegative = false
  var currentIndex = 0
  for (c in s) {
    if (c == ' ') {
      xs[currentIndex] = currentValue * if (isNegative) -1L else 1L
      currentValue = 0
      isNegative = false
      currentIndex++
    } else if (c == '-') {
      isNegative = true
    } else {
      currentValue *= 10
      currentValue += c - '0'
    }
  }
  xs[currentIndex] = currentValue * if (isNegative) -1L else 1L
  return xs
}

Measured memory_bytes: 77944
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()


int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    map<char,int> mp;
    rep(i,n) mp[s.at(i)]++;
    
    long long ans = (long long)mp['R']*mp['G']*mp['B'];

    for(int i=0; i<=n-3; i++){
        for(int j=i+1; j<=n-2; j++){
            int k = j+(j-i);
            if(k>=n) break;
            if(s.at(i)!=s.at(j) && s.at(j)!=s.at(k) && s.at(k)!=s.at(i)) ans--;
        }
    }
    
    dunk(ans);
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n,L;
int ar[100005];
int main(){
  cin>>n>>L;
  REP(i,n) scanf("%d",&ar[i]);

  REP(i,n-1) if(ar[i]+ar[i+1]>=L){
    dump(i);
    puts("Possible");
    REP(j,i) printf("%d\n",j+1);
    for(int j=n-2;j>=i;--j) printf("%d\n",j+1);
    return 0;
  }
  puts("Impossible");


  return 0;
}




Measured memory_bytes: 1152
import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  xs <- words <$> getLine
  putStrLn $ map head xs

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

toTup2 :: [[a]] -> [(a, a)]
toTup2 = map (\ys -> case ys of y : z : zs -> (y, z))

encIdx2 :: Int -> (Int, Int) -> Int
encIdx2 mx (y, x) = y * mx + x

decIdx2 :: Int -> Int -> (Int, Int)
decIdx2 mx idx = (idx `div` mx, idx `mod` mx)

encIdx3 :: (Int, Int) -> (Int, Int, Int) -> Int
encIdx3 (my, mx) (z, y, x) = z * my * mx + y * mx + x

decIdx3 :: (Int, Int) -> Int -> (Int, Int, Int)
decIdx3 (my, mx) idx = (z, y, x)
  where
    basez = my * mx
    z = idx `div` basez
    y = (idx `mod` basez) `div` mx
    x = idx `mod` mx

while :: Monad m => m Bool -> m () -> m ()
while cond body = do
  b <- cond
  when b $ do
    body
    while cond body


Measured memory_bytes: 508
use std::io::*;
use std::str::FromStr;

fn main(){
    let (a,b,c,d) = (read::<i32>(),read::<i32>(),read::<i32>(),read::<i32>());
    println!("{}", if a+b<c+d {"Right"} else if a+b>c+d {"Left"} else {"Balanced"})
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
#include<stdio.h>
int main(void)
{
	int n,i,x,y;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		if(i%3==0){
			printf(" %d",i);
		}
		else{
			x=i;
			while(1){
				y=x%10;
				if(y==3){
					printf(" %d",i);
					break;
				}
				x=x/10;
				if(x==0) break;
			}
		}
	}
	printf("\n");
	
	return 0;
}



Measured memory_bytes: 2768
def dot(a,b):return a[0]*b[0] + a[1]*b[1]
def cross(a,b):return a[0]*b[1] - a[1]*b[0]

q = int(input())
for i in range(q):
    x0,y0,x1,y1,x2,y2,x3,y3 = [int(i) for i in input().split()]
    a = [x1-x0,y1-y0]
    b = [x3-x2,y3-y2]
    if dot(a,b) == 0 : print(1)
    elif cross(a,b) == 0 : print(2)
    else : print(0)

Measured memory_bytes: 7748
N = int(input())
T,A=[int(x) for x in input().split()]
H = [int(x) for x in input().split()]
ans=1
Temp = abs(T -A - 0.006*H[0])

for i in range(N):
    _Temp = abs(T -A - 0.006*H[i])
    if Temp > _Temp:
        Temp = _Temp
        ans=i+1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 2005;
const int MAXC = 8005;
const int MAXM = 200005;
const int O = 2000, OO = 4000;
const LL MOD = 1e9 + 7;
const LL INV2 = (MOD+1)>>1;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, m, a[MAXM], b[MAXM], cnt[MAXN][MAXN];
LL fac[MAXC], inv[MAXC], finv[MAXC], dp[MAXN<<1];

inline void Inc(LL &x, LL y) {
	x += y; if (x >= MOD) x -= MOD;
}

inline LL C(int x, int y) {
	return fac[x] * finv[y] % MOD * finv[x-y] % MOD;
}

void init() {
	read(n);
	for (int i=1;i<=n;++i) {
		read(a[i]); read(b[i]);
		++cnt[a[i]][b[i]];
	}
	fac[0] = fac[1] = inv[0] = inv[1] = finv[0] = finv[1] = 1;
	for (int i=2;i<MAXC;++i) {
		fac[i] = fac[i-1] * i % MOD;
		inv[i] = (MOD-MOD/i) * inv[MOD%i] % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
}

void solve() {
	LL ans = 0;
	for (int i=0;i<=OO;++i) {
		for (int j=0;j<=OO;++j) {
			if (i < O && j < O) Inc(dp[j], cnt[O-i][O-j]);
			if (j) Inc(dp[j], dp[j-1]);
			if (i > O && j > O) Inc(ans, dp[j] * cnt[i-O][j-O] % MOD);
		}
	}
	for (int i=1;i<=n;++i) {
		ans = (ans - C(a[i]*2+b[i]*2, a[i]*2) + MOD) % MOD;
	}
	ans = ans * INV2 % MOD;
	printf("%lld\n", ans);
}

int main() {
	init();
	solve();
	return 0;
}


Measured memory_bytes: 17664
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    a = i_input()
    b = i_input()
    c = i_input()
    x = i_input()
    ans = 0
    for i in range(a+1):
        for k in range(b+1):
            for j in range(c+1):
                if i*500+k*100+j*50 == x:
                    ans += 1
    print(ans)



if __name__=="__main__":
    main()


Measured memory_bytes: 9900
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
int main() {
   int n;
   cin >> n;
   map<string,int> map;
   rep(i,n){
      string s;
      cin >> s;
      sort(s.begin(),s.end());
      map[s]++;
   }
   long long ans = 0;
   for(auto& p : map){
      int s = p.second;
      ans += (long long)s*(s-1)/2;
   }
   cout << ans << endl;
   return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int H, W; cin >> H >> W;
	int y, x;
	REP(i,H){
		REP(j,W){
			string s; cin >> s;
			if(s == "snuke"){
				y = i;
				x = j;
			}
		}
	}
	
	cout << (char)(x +'A') << y+1 << endl;

	return 0;

}


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

int main(){
  int h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;
  int ans = (h2-h1)*60;
  ans += m2;
  ans -= m1;
  ans -= k;
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int n,k,x,ts;
bool no[11],f;
int main()
{
	cin>>n>>k;
	for (int i=1;i<=k;i++)
	{
		cin>>x;
		no[x]=1;
	}
	for (int i=n;i<=100000;i++)
	{
		ts=i;f=0;
		while(ts)
		{
			if (no[ts%10]) f=1;
			ts/=10;
		}
		if (!f) 
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
using namespace std;

int n;
int a[100005];
int used[3];

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
		a[i]=a[i]%4;
		if(!a[i]) used[0]++;
		if(a[i]==2) used[1]++;
		if(a[i]==1||a[i]==3) used[2]++;
	}
	if(!used[0]&&!used[2]){
		puts("Yes");
		return 0;
	}
	if(used[0]+1<used[2]+min(1,used[1])) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 640
N = int(input())
S = input()
cnt_w = S.count("W")
cnt_r = S.count("R")
cl_chg = min(cnt_w, cnt_r)

sw = S[:cnt_r].count("W")
sr = S[cnt_r:].count("R")
swap = min(sw, sr)
print(min(cl_chg, swap))

Measured memory_bytes: 9496
n = int(input())
A = [int(i) for i in input().split()]

sum0 = sum(A)

b = sum0 // n
c = -(-sum0 // n)
sum1 = 0
sum2 = 0
for a in A:
    sum1 += (a-b) ** 2
    sum2 += (a-c) ** 2
    
print(min(sum1, sum2))


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
class TEST
{
    public static void Main()
    {
     int num=int.Parse(Console.ReadLine());
        string str=Console.ReadLine();

            string x=str.Substring(0,num/2);
        string y =str.Substring(num / 2);
   //     Console.WriteLine(x);
      //  Console.WriteLine(y);
     //   Console.ReadKey();
        if(x==y)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }


}

Measured memory_bytes: 27324
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int r, d, x;

	cin >> r >> d >> x;
	int wkx;
	wkx = r * x - d;
	for (int i = 0; i < 10; i++) {
		cout << wkx << endl;
		wkx = r * wkx - d;
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    srep(i,1,500000){
        double nn = (double)i * 1.08;
        int nnn = (int)nn;
        if(nnn == n){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 922337203685477580LL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

template<class T>
struct RMQ {
  T ex;
  int n;
  vector<T> dat, laz;
  RMQ(int n_):ex(0) {
    n = 1;
    while(n < n_) n <<= 1;
    dat.assign(2*n-1, 0);
    laz.assign(2*n-1, ex);
  }
  inline int chld(int k) {return k*2+1;}
  inline int chrd(int k) {return k*2+2;}
  void eval(int k) {
    if(laz[k] == ex) return;
    if(k < n-1) {
      laz[chld(k)] += laz[k];
      laz[chrd(k)] += laz[k];
    }
    dat[k] += laz[k];
    laz[k] = ex;
  }
  void update(int a, int b, T x, int k, int l, int r) {
    eval(k);
    if(a <= l and r <= b) {
      laz[k] += x;
      eval(k);
    } else if(a < r and l < b) {
      update(a, b, x, chld(k), l, (l+r)>>1);
      update(a, b, x, chrd(k), (l+r)>>1, r);
      dat[k] = min(dat[chld(k)], dat[chrd(k)]);
    }
  }
  inline void update(int a, int b, T x) {update(a, b, x, 0, 0, n);}
  T query(int a, int b, int k, int l, int r) {
    eval(k);
    if(r <= a or b <= l) return LINF;
    if(a <= l and r <= b) return dat[k];
    return min(query(a, b, chld(k), l, (l+r)>>1), query(a, b, chrd(k), (l+r)>>1, r));
  }
  inline T query(int a, int b) {return query(a, b, 0, 0, n);}
};

//head

int h, w;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> h >> w;
  RMQ<ll> rng1(w), rng2(w);
  rep(i, w) {
    rng1.update(i, i+1, -i);
  }
  rep(iipejwor, h) {
    int a, b;
    cin >> a >> b;
    a--;
    rng1.update(0, a, 1);
    rng2.update(0, a, 1);
    if(b != w) {
      rng1.update(b+1, w, 1);
      rng2.update(b+1, w, 1);
      ll X = rng1.query(0, b+1);
      X += b+1;
      //cout << iipejwor << ' ' << X << endl;
      X -= rng2.query(b, b+1);
      //cout << iipejwor << ' ' << X << endl;
      rng1.update(b, b+1, X);
      rng2.update(b, b+1, X);
    }
    rng1.update(a, b, INF);
    rng2.update(a, b, INF);
    ll ans = rng2.query(0, w);
    if(ans < INF) cout << ans << '\n';
    else cout << "-1\n";

  }
}

Measured memory_bytes: 19476
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }
        String arr01[] = mylist.get(0).split(" ");

        String arr02[] = mylist.get(1).split(" ");

        List<String> list01 = Arrays.asList(arr02);

        List<Integer> list02 = list01.stream().map(Integer::valueOf).collect(Collectors.toList());

        //        System.out.println(list02);

        int maxdata = 0;
        int cnt = 0;

        for (int i = 0; i < list02.size() - 1; i++) {

            //            System.out.println(list02.get(i) + " " + list02.get(i + 1));
            if (list02.get(i) >= list02.get(i + 1)) {
                cnt += 1;
            } else {

                //                System.out.println(maxdata + " " + cnt);
                maxdata = Math.max(maxdata, cnt);
                cnt = 0;
            }
        }

        //        System.out.println(maxdata + " " + cnt);
        maxdata = Math.max(maxdata, cnt);

        System.out.println(maxdata);

    }

}


Measured memory_bytes: 52256
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 1001000
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);

    ll n;cin>>n;
    string s;cin>>s;
    ll r[n+1]={0},g[n+1]={0},b[n+1]={0};
    if(s[n-1]=='R')r[n]=1;
    else if(s[n-1]=='G')g[n]=1;
    else b[n]=1;
    for(ll i=n-1;i>=1;i--)
    {
        if(s[i-1]=='R')
        {
            r[i]=r[i+1]+1;
            g[i]=g[i+1];
            b[i]=b[i+1];
        }
        else if(s[i-1]=='G')
        {
            r[i]=r[i+1];
            g[i]=g[i+1]+1;
            b[i]=b[i+1];
        }
        else
        {
            r[i]=r[i+1];
            g[i]=g[i+1];
            b[i]=b[i+1]+1;
        }
    }
    ll ans=0;
    for(ll i=1;i<=n-2;i++)
    {
        for(ll j=i+1;j<=n-1;j++)
        {
            if(s[i-1]!=s[j-1])
            {
                ll diff=j-i;
                ll k=diff+j;
                if(k<=n)
                {
                    if(s[k-1]!=s[i-1] && s[k-1]!=s[j-1])
                    {
                        if(s[k-1]=='R')ans+=r[j]-1;
                        else if(s[k-1]=='G')ans+=g[j]-1;
                        else ans+=b[j]-1;
                    }
                    else
                    {
                        if('B'!=s[i-1] && 'B'!=s[j-1])ans+=b[j];
                        if('R'!=s[i-1] && 'R'!=s[j-1])ans+=r[j];
                        if('G'!=s[i-1] && 'G'!=s[j-1])ans+=g[j];
                    }
                }
                else
                {
                    if('B'!=s[i-1] && 'B'!=s[j-1])ans+=b[j];
                    if('R'!=s[i-1] && 'R'!=s[j-1])ans+=r[j];
                    if('G'!=s[i-1] && 'G'!=s[j-1])ans+=g[j];
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3676
#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)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    string s;
    cin >> s;
    int cnt0 = 0, cnt1 = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i]=='0'){
            cnt0++;
        }else{
            cnt1++;
        }
    }
    cout << min(cnt0, cnt1)*2 << endl;


    return 0;
}


Measured memory_bytes: 512
from bisect import bisect_left
from bisect import bisect_right

n,m = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)

a_count = [0]*110000
a_sum = [0]*110000

for i in range(n):
    a_count[a[i]] += 1
    a_sum[a[i]] += a[i]

for i in range(100005,0,-1):
    a_count[i] += a_count[i+1]
    a_sum[i] += a_sum[i+1]

def chk(x):
    case = 0
    for i in range(n):
        case += n-bisect_right(a,x-a[i]-1)
    if case >= m:
        ch = True
    else:
        ch = False
    return ch


l = 2*a[-1]+1    #NG
r = 1 #OK

while abs(r-l) > 1:
    kk = (r+l)//2
    if chk(kk):
        r = kk
    else:
        l = kk

ans = 0
sm = sum(a)

l = r

case = 0
for i in range(n):
    num = n-bisect_right(a,l-a[i]-1)
    case += num
    ans += num*a[i]*2

ans -= (case-m)*l

print(ans)

Measured memory_bytes: 57220
N, M = map(int, raw_input().split())
num_ball = [1] * N
red_ball = [1] + [0] * (N-1)
for i in range(M):
    x, y = map(int, raw_input().split())
    x -= 1
    y -= 1
    
    if red_ball[x]:
        red_ball[y] = 1
    
    num_ball[x] -=1
    num_ball[y] +=1
    
    if num_ball[x] == 0:
        red_ball[x] = 0
        
print sum(red_ball)

Measured memory_bytes: 7284
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
set<int> s;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    if(s.size()==2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       N: usize,
       a:[usize;N],
    }

    let mut ans: usize = 0;
    for &item in &a {
        ans = ans ^ item;
    }
    mydbg!(ans);
    for &item in &a {
        echo!(ans ^ item);
    }

    //echo!(ans);
}


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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a==b && a==c)		cout << 1 << endl;
	else if(a==b || b==c || c==a)	cout << 2 << endl;
	else				cout << 3 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

int main(void) {

    int n;
    scanf("%d", &n);

    int *A = new int[n], *B = new int[n], max = -1;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &A[i]);
        if (A[i] > max) {
            max = A[i];
        }
    }

    int *C = new int[max + 1];
    memset(C, 0, sizeof(int) * (max + 1));

    for (int i = 0; i < n; ++i) {
        ++C[A[i]];
    }

    for (int i = 1; i < max + 1; ++i) {
        C[i] += C[i - 1];
    }

    for (int i = n - 1; i >= 0; --i) {
        B[C[A[i]] - 1] = A[i];
        --C[A[i]];
    }

    printf("%d", B[0]);
    for (int i = 1; i < n; ++i) {
        printf(" %d", B[i]);
    }
    printf("\n");

    delete[] C;
    delete[] B;
    delete[] A;

    return 0;
}

Measured memory_bytes: 16764
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    long[] rk = new long[n];
    long[] gk = new long[n];
    long[] bk = new long[n];
    if(s.charAt(n - 1) == 'R') {
      rk[n - 1] = 1;
    } else if(s.charAt(n - 1) == 'G') {
      gk[n - 1] = 1;
    } else {
      bk[n - 1] = 1;
    }
    for(int i = n - 2; i >= 0; i--) {
      if(s.charAt(i) == 'R') {
        rk[i] = rk[i + 1] + 1;
        gk[i] = gk[i + 1];
        bk[i] = bk[i + 1];
      } else if(s.charAt(i) == 'G') {
        gk[i] = gk[i + 1] + 1;
        rk[i] = rk[i + 1];
        bk[i] = bk[i + 1];
      } else {
        bk[i] = bk[i + 1] + 1;
        rk[i] = rk[i + 1];
        gk[i] = gk[i + 1];
      }
    }
    long ans = 0;
    for(int i = 0; i < n - 2; i++) {
      for(int j = i + 1; j < n - 1; j++) {
        int k = j + (j - i);
        if((s.charAt(i) == 'R') && (s.charAt(j) == 'G')) {
          if(k < n) {
            if(s.charAt(k) == 'B') {
              ans += (bk[j + 1] - 1);
            } else {
              ans += bk[j + 1];
            }
          } else {
            ans += bk[j + 1];
          }
        }
        if((s.charAt(i) == 'R') && (s.charAt(j) == 'B')) {
          if(k < n) {
            if(s.charAt(k) == 'G') {
              ans += (gk[j + 1] - 1);
            } else {
              ans += gk[j + 1];
            }
          } else {
            ans += gk[j + 1];
          }
        }
        if((s.charAt(i) == 'G') && (s.charAt(j) == 'R')) {
          if(k < n) {
            if(s.charAt(k) == 'B') {
              ans += (bk[j + 1] - 1);
            } else {
              ans += bk[j + 1];
            }
          } else {
            ans += bk[j + 1];
          }
        }
        if((s.charAt(i) == 'G') && (s.charAt(j) == 'B')) {
          if(k < n) {
            if(s.charAt(k) == 'R') {
              ans += (rk[j + 1] - 1);
            } else {
              ans += rk[j + 1];
            }
          } else {
            ans += rk[j + 1];
          }
        }
        if((s.charAt(i) == 'B') && (s.charAt(j) == 'R')) {
          if(k < n) {
            if(s.charAt(k) == 'G') {
              ans += (gk[j + 1] - 1);
            } else {
              ans += gk[j + 1];
            }
          } else {
            ans += gk[j + 1];
          }
        }
        if((s.charAt(i) == 'B') && (s.charAt(j) == 'G')) {
          if(k < n) {
            if(s.charAt(k) == 'R') {
              ans += (rk[j + 1] - 1);
            } else {
              ans += rk[j + 1];
            }
          } else {
            ans += rk[j + 1];
          }
        } 
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 40564
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    if(B % A == 0) cout << A + B << endl;
    else cout << B - A << endl;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int n = c/a;
    cout <<  n * b << endl;
}

Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let S = read![String; N];

    let mut frequencies = HashMap::new();
    for s in S {
        *frequencies.entry(s).or_insert(0) += 1;
    }

    let max_frequency = frequencies.values().cloned().max().unwrap();
    let mut most_frequent = frequencies
        .iter()
        .filter_map(|(k, &v)| if v == max_frequency { Some(k) } else { None })
        .collect::<Vec<_>>();
    most_frequent.sort();

    for s in most_frequent {
        println!("{}", s);
    }
}


Measured memory_bytes: 28428
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int h,w;
  cin >> h >> w;
  int k;
  cin >> k;
  
  vector<string>vec(h);
  rep(i,h) cin >> vec[i];
  int ans = 0;
  for(int bith=0;bith<(1<<h);bith++){
    for(int bitw=0;bitw<(1<<w);bitw++){
      int res = 0;
      rep(i,h){
        rep(j,w){          
          if((bith & (1<<i))||(bitw & (1<<j)))continue;
          if(vec[i][j]=='#')res++;
        }
      }
      if(res==k)ans++;
    }
  }
  cout << ans << endl;
      
  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N,K;
    cin>>N>>K;
    vector<int> p(N);
    REP(i,N) cin>>p[i];
    sort(All(p));
    int ans = 0;
    REP(i,K) ans += p[i];
    cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  if(a+b>=c) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

int calc_truck_num(std::vector<int> wi, int P){
	std::vector<int> truck;
	truck.push_back(0);
	for (int i = 0; i < wi.size(); ++i){
		if(truck.back()+wi[i]<=P){
			truck.back() += wi[i];
		}else{
			truck.push_back(wi[i]);
		}
	}
	return truck.size();
}

int main(int argc, char const *argv[]){
	int n,k,w;
	int cnt = 0;
	int right = 0;
	int left = 0;
	int center;

	std::vector<int> wi;

	std::cin >> n >> k;
	for (int i = 0; i < n; ++i){
		std::cin >> w;
		wi.push_back(w);
		right += w; 
		if(w>left) left = w;
	}

	while(right-left>1){
		center = (right+left)/2;
		if(calc_truck_num(wi,center)>k){
			left = center;
		}else{
			right = center;
		}
	}

	if(calc_truck_num(wi,left)<=k){
		std::cout << left << std::endl;
	}else{
		std::cout << right << std::endl;
	}

	return 0;
}


Measured memory_bytes: 4496
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>

#define ull unsigned long long
#define ul unsigned long
#define ll long long
#define size_t long long
// std::sort(&a[0], &a[4], [](auto& x, auto& y){return x[0] < y[0];});
//accumulate(&arr2[n], &arr2[m-1], 0);
using namespace std;

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

  ll L,R;
  std::cin >> L >> R;
  ll ans = 2020;
  for (size_t i = L; i <= L+min(R-L,(ll)2019) - 1; i++) {
    for (size_t j = i+1; j <= L + min(R-L,(ll)2019) ; j++) {
      ans = min(ans,((i % 2019)*(j % 2019)%2019));
      if(ans == 0) break;
    }
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
using namespace std;
ll h[10], f[1010], n, c[1000];
int main() {
	scanf("%lld", &n);
	rep(i, 1, 4200) {
		if (i % 7 == 1) ++ h[1]; else 
			h[i % 7] += h[(i + 6) % 7];
		if (i % 7 == 0) f[i / 7] = h[0];
	}
	for (int i = 600; i; -- i) c[i] = n / f[i], n %= f[i];
	int sum = 0;
	rep(i, 1, 600) {
		printf("FESTIVA");
		rep(j, 1, c[i]) printf("L");
		sum += c[i] + 7;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
using namespace std;
const int maxn=300005;
int h,w,n,ans,tree[maxn<<2],lazy[maxn<<2],top[2],st[2][maxn<<2];
struct node{int x,y;
}d[maxn];
bool cmp(const node&a,const node&b)
{
	return a.x<b.x;
}
void pushdown(int rt)
{
	if(lazy[rt])
	{
		tree[rt<<1]+=lazy[rt];
		tree[rt<<1|1]+=lazy[rt];
		lazy[rt<<1]+=lazy[rt];
		lazy[rt<<1|1]+=lazy[rt];
		lazy[rt]=0;
	}
}
int max(int x,int y)
{
	return x>y?x:y;
 } 
void update(int L,int R,int x,int l,int r,int rt)
{
	if(L<=l&&R>=r)
	{
		tree[rt]+=x;
		lazy[rt]+=x;
		return ;
	}
	pushdown(rt);
	int mid=(l+r)>>1;
	if(L<=mid)update(L,R,x,lson);
	if(R>mid)update(L,R,x,rson);
	tree[rt]=max(tree[rt<<1],tree[rt<<1|1]);
}
void solve()
{
	sort(d+2,d+1+n,cmp);
    memset(tree,0,sizeof(tree));
    memset(lazy,0,sizeof(lazy));
    top[0]=top[1]=0;
    st[0][0]=st[1][0]=1;
    update(1,n,h<<1,1,n,1);
    for(int i=2;i<=n;i++)
    {
    	update(1,i-1,(d[i].x-d[i-1].x)<<1,1,n,1);
        ans=max(ans,tree[1]);
        if(d[i].y>=(h>>1))
        {
            update(st[0][top[0]],i-1,(d[i].y-h)<<1,1,n,1);
            while(top[0]&&d[st[0][top[0]]].y>=d[i].y)
            {
                update(st[0][top[0]-1],st[0][top[0]]-1,(d[i].y-d[st[0][top[0]]].y)<<1,1,n,1);
                top[0]--;
            }
            st[0][++top[0]]=i;
        }
        else
        {
            update(st[1][top[1]],i-1,-d[i].y<<1,1,n,1);
            while(top[1]&&d[st[1][top[1]]].y<=d[i].y)
            {
                update(st[1][top[1]-1],st[1][top[1]]-1,(d[st[1][top[1]]].y-d[i].y)<<1,1,n,1);
                top[1]--;
            }
            st[1][++top[1]]=i;
        }
    }
}
int main()
{
    scanf("%d%d%d",&w,&h,&n);
    n++;
    for(int i=2;i<=n;++i)
        scanf("%d%d",&d[i].x,&d[i].y);
    d[++n].x=w,d[n].y=h;
    solve();
    swap(w,h);
    for(int i=1;i<=n;i++)
        swap(d[i].x,d[i].y);
    solve();
    printf("%d\n",ans);
}

Measured memory_bytes: 17280
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(i,n) for(int i = -1; i < (n); i++)
#define PI 3.141592653589793

using namespace std;
using ll = unsigned long long;


int main() {

	string s;
	cin >> s;
	char S[4] = { s[0],s[1],s[2],s[3] };

	sort(s.begin(), s.end());
	bool ans = false;
	if (s[0] == s[1] && s[2] == s[3]&&s[0]!=s[2]) ans = true;
	puts(ans ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 3592
while True:
    N,M = map(int,input().split())
    if N+M==0:
        break
    A = [[0]for i in range(M+1)]
    r = int(input())
    for i in range(r):
        t,n,m,s = map(int,input().split())
        if s==1:
            if A[m][0]==0:
                A[m].append(t)
            A[m][0]+=1
        else:
            A[m][0]-=1
            if A[m][0]==0:
                A[m].append(t)
    q = int(input())
    for i in range(q):
        ts,te,m = map(int,input().split())
        ans = 0
        for i in range(0,len(A[m])):
            if i%2==1:
                a,b = A[m][i],A[m][i+1]
                if ts<=a and a<=te and te<=b:
                    ans += te-a
                elif a<=ts and te<=b:
                    ans += te-ts
                elif a<=ts and ts<=b and b<=te:
                    ans += b-ts
                elif ts<=a and b<=te:
                    ans += b-a
        print(ans)


Measured memory_bytes: 7036
MOD = 10 ** 9 + 7
N = gets.to_i
A = gets.split.map(&:to_i)

#N = 3 * 10 ** 5
#A = N.times.map{rand((2**57)..(2**60))}

ans = 0
61.times do |i|
  cnt = 0
  N.times do |j|
    if A[j][i] == 1
      cnt += 1
    end
  end
  now = (cnt * (N - cnt)) % MOD
  now = (now * 2 ** i) % MOD
  #i.times{ now = (now*2) % MOD }
  ans += now
  ans %= MOD
end
p ans

Measured memory_bytes: 34820
s = input()
t = input()
m = len(s)
n = len(t)
res = float('inf')

for i in range(m-n+1):
  S = s[i:i+n:]
  judge = True
  for j in range(n):
    if not(S[j] == t[j] or S[j] == "?"):
      judge = False
      break
  if judge:
    res = i
    
if res == float('inf'):
  print("UNRESTORABLE")
  exit()

ans = ""
for i in range(m):
  if s[i] != "?":
    ans += s[i]
  else:
    if res <= i and i < res + n:
      ans += t[i-res]
    else:
      ans += "a"
print(ans)

Measured memory_bytes: 3188