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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  
  if(A==B && B==C){
    cout << "No" << endl;
    return 0;
  }
  else if(A==B || B==C || C==A){
    cout << "Yes" << endl;
    return 0;
  }
  
  cout << "No" << endl;
}

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

int main()
{
	int n;
	int f = 0;
  	cin>>n;
  	while(n>0){
    	if(n%10==7){
        	cout<<"Yes";
          	f = 1;
          	break;
        }
      	n /= 10;
    }
  	if(f==0){
    	cout<<"No";
    }
  	return 0;
}

Measured memory_bytes: 3080
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}


fun solve(out: PrintWriter) {
    val n = readInteger()
    val k = readInteger()
    val xList = readIntegerList()
//    var ans = 0
//    for (x in xList) {
//        ans += Math.min(Math.abs(x) * 2, Math.abs(k - x) * 2)
//    }
    xList.fold(0) { acc, i -> acc + Math.min(Math.abs(i) * 2, Math.abs(k - i) * 2) }
        .let(::println)
//    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 36040
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int G[501][501];
int main(){
    int n,m,q; cin >> n >> m >> q;
    REP(i,m){
        int l,r; cin >> l >> r;
        G[l][r]++;
    }
    REP(i,501){
        REP(j,501){
            if(j==0) continue;
            G[i][j] += G[i][j-1];
        }
    }
    REP(i,q){
        int p,q;cin >> p >> q;
        int ans = 0;
        FOR(i,p,q+1){
            ans += G[i][q] - G[i][p-1];
        }
        cout << ans << endl;
    }

}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <stack>

using namespace std;

int main()
{
	int m, d, mt = 0;
	cin >> m >> d;
	for (int i = 4; i <= m; i++) {
		int j = 2, k = 2;
		while (d >= 10 * j + k) {
			if (j * k == i) {
				mt++;
			}
			if (k <= 8) {
				k++;
			}
			else {
				j++;
				k = 2;
			}
		}
	}
	cout << mt;
	
}

Measured memory_bytes: 256
n, m, x = $stdin.gets.split.map(&:to_i)
a = $stdin.gets.split.map(&:to_i)

# a.unshift(0)

tozero = 0
ton = 0

tozero = a.select{|e| e<x}.length
ton = a.select{|e| e>x}.length

puts [tozero, ton].min


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)

#define mp make_pair
#define fi first
#define se second

#define bit(n) (1LL<<(n))

i64 H,W;
vector<string> S;

i64 bfs(i64 sh, i64 sw){
  vector<vector<i64>> dist(H,vector<i64>(W,-1));
  queue<pair<i64,i64>> que;
  dist[sh][sw] = 0;
  que.push({sh,sw});

  i64 h,w,nh,nw;
  while(!que.empty()){
    h = que.front().fi;
    w = que.front().se;
    que.pop();
    rep(dir,4){
      nh = h+dy[dir];
      nw = w+dx[dir];
      if(nh<0 || H<=nh || nw<0 || W<=nw) continue;
      if(S[nh][nw] == '#') continue;
      if(dist[nh][nw] == -1){
        dist[nh][nw] = dist[h][w] + 1;
        que.push({nh,nw});
      }
    }
  }
  return(dist[h][w]);
}

void Main()
{
  cin >> H >> W;
  rep(i,H){
    string s;
    cin >> s;
    S.push_back(s);
  }

  i64 ans = 0LL;
  rep(h,H) rep(w,W){
    if(S[h][w]=='.'){
      ans = max(ans,bfs(h,w));
    }
  }
  cout << ans << '\n';
}

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int n = Integer.parseInt(br.readLine());
			
			if(n == 0){
				break;
			}
			
			String[] tmpArray = br.readLine().split(" ");
			
			final int OFF = 0;
			final int ON = 1;
			int position = OFF;
			int right = OFF;
			int left = OFF;
			int count = 0;
			for(int i = 0; i < n; i++){
				String com = tmpArray[i];
				
				if(com.equals("lu")){
					left = ON;
				}
				if(com.equals("ld")){
					left = OFF;
				}
				if(com.equals("ru")){
					right = ON;
				}
				if(com.equals("rd")){
					right = OFF;
				}
				
				if(left == right && left != position){
					position = left;
					count++;
				}
			}
			
			System.out.println(count);
		}
	}

}

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

int main() {
  int N,i,x,c,m;
  cin >> N;
  m = 40;
  for (i = 0;i < N;i++) {
    c = 0;
    cin >> x;
    while (x % 2 == 0) {
      x /= 2 ;
      c++;
    }
    if (m > c) {
      m = c;
    }
  }
  cout << m << endl;
}

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

int main(){
cin >> a >> b >> c >> d >> n;

int l025 = a;
int l05 = min(b, l025 * 2);
int l1 = min(c, l05 * 2);
int l2 = min(d, l1 * 2);
 
 cout << l2 * 1ll * (n / 2) + l1 * 1ll * (n % 2);
 
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  ll N;
  cin >> N;

  ll dp[61][3]={}; //[上位i桁まで][Nとの差(どれだけ低いか)]=(vの通り).jは2以上は2に。

  dp[60][0]=1;

  repr(i,59,0){ //桁dp
    rep(j,3){ //012
      rep(k,3){ //(00)(01)(11) a,bの組。01は必ず可換で,00と11はvが必ず異なる。
        ll j2 = min((ll)2,2*j+(N>>i &1)-k);
        if(j2>=0) {
          dp[i][j2]+=dp[i+1][j];
          dp[i][j2]%=MOD;
        }
      }
    }
  }

  cout << ((dp[0][0]+dp[0][1]+dp[0][2])%MOD) <<"\n";
}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll L;
ll A[200050];
ll sum[200050];
ll even[200050];
ll odd[200050];
ll even_after[200050];
ll even_before[200050];
ll odd_after[200050];
ll odd_before[200050];
 
int main() {
    //cout.precision(10);
    cin >> L;
    for(int i = 1; i <= L; i++) {
        cin >> A[i];
        sum[i] = sum[i - 1] + A[i];
        even[i] = even[i - 1];
        if(A[i] % 2 == 1) even[i]++;
        if(A[i] == 0) even[i] += 2;
        odd[i] = odd[i - 1];
        if(A[i] % 2 == 0) odd[i]++;
    }
    even_before[0] = 0;
    for(int i = 1; i <= L; i++) {
        even_before[i] = min(even_before[i - 1] + (even[i] - even[i - 1]), sum[i]);
        odd_before[i] = min(odd_before[i - 1] + (odd[i] - odd[i - 1]), even_before[i]);
        //cout << i << " " << even_before[i] << " " << odd_before[i] << endl;
    }
    for(int i = L; i >= 1; i--) {
        even_after[i] = min(even_after[i + 1] + (even[i] - even[i - 1]), sum[L] - sum[i - 1]);
        odd_after[i] = min(odd_after[i + 1] + (odd[i] - odd[i - 1]), even_after[i]);
    }
    ll ans = 1e16;
    for(int i = 1; i <= L + 1; i++) {
        ans = min(ans, odd_before[i - 1] + odd_after[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12800
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;

int N,M;
vector<vector<int>> G;
bool ans = false;

void bfs(){
    vector<int> d(N,-1);
    vector<int> used(N,-1);
    queue<int> q;
    q.push(0);
    d[0] = 0;
    used[0] = 1;
    while(!q.empty()){
        int u = q.front();
        q.pop();
        for(auto next : G[u]){
            if(used[next] == -1){
                q.push(next);
                d[next] = d[u] + 1;
                used[next] = 1;
            }
        }
    }
    if(d[N-1] == 2) ans = true;
}

int main(){
    cin >> N >> M;
    G = vector<vector<int>>(N);
    rep(i,M){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    bfs();
    if(ans) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 13936
n = gets.to_i

arr = Array.new(10){Array.new(10,0)}
ans = 0

n.times do |i|
    i = (i + 1).to_s
    x, y = i[0].to_i, i[-1].to_i
    ans += arr[y][x] * 2 + (x == y ? 1 : 0)
    arr[x][y] += 1
end

puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

/* ll comb(ll x, ll y);
int main(void);

ll comb(ll x, ll y){

}
 */

int main(void){

    int N;
    cin >> N;

    vector<string> S;
    rep(i,N){
        string s;
        cin >> s;
        S.push_back(s);
    }

    rep(i,N){
        sort(all(S[i]));
    }
    sort(all(S));

    string T = S[0]; 
    ll cnt = 0;
    ll ans = 0;
    rep(i,N){
        if(S[i] == T){
            cnt++;
        }else{
            ans += cnt*(cnt-1)/2;
            T = S[i];
            cnt = 1;
        }
    }
    if(cnt>1){
        ans += cnt*(cnt-1)/2;
    }

   /* rep(i,N){
       cout << S[i] << endl;
   } */

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


Measured memory_bytes: 7412
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <cmath>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll BIGP = 1000000007L;
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //
    ll N;
    cin >> N;
    vector<ll> p(N);
    ll cnt = 0;
    rep(i, N)
    {
        ll p;
        cin >> p;
        if (p != i + 1)
        {
            ++cnt;
        }
    }
    if (cnt <= 2)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
    //
    //
    return 0;
}

Measured memory_bytes: 3648
//************************
//*  Date: 2018.9.28     *
//*  Problem:            *
//*  Author: xuziyuan    * 
//************************

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,t,mc=1e9;
int ti[110],c[110];

int main()
{
	cin>>n>>t;
	repn(i,n)
	{
		cin>>c[i]>>ti[i];
		if(ti[i]>t) continue;
		if(c[i]<mc) mc=c[i];
	}
	if(mc==1e9) puts("TLE");
	else cout<<mc<<endl;
	rt0;
}

Measured memory_bytes: 384
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<string> S;
  
  for (auto&& i : S)
    i = 'x';


  return S;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(0) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n, a, b, c = map(int, input().split())
d = {"A": a, "B": b, "C": c}
pl = [input() for _ in range(n)]
res = []
for i in range(n):
    p = pl[i]
    if d[p[0]] == d[p[1]] == 0:
        exit(print("No"))
    elif d[p[0]] == 0:
        res.append(p[0])
        d[p[0]] += 1
        d[p[1]] -= 1
    elif d[p[1]] == 0:
        res.append(p[1])
        d[p[0]] -= 1
        d[p[1]] += 1
    elif i == n - 1:
        res.append(p[0])
    elif p[0] in pl[i + 1]:
        res.append(p[0])
        d[p[0]] += 1
        d[p[1]] -= 1
    else:
        res.append(p[1])
        d[p[0]] -= 1
        d[p[1]] += 1

print("Yes")
for p in res:
    print(p)

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

public class Main {
	public static void main(String[] args) {      
      Scanner sc = new Scanner(System.in);
      int[] dice = new int[6];
      for (int i=0; i<6; i++) {
        dice[i] = sc.nextInt();
      }
      String str = sc.next();
      for (int g=0; g<str.length(); g++) {
        switch (str.charAt(g)) {
          case 'S':
            int[] diceafters = {dice[4],dice[0],dice[2],dice[3],dice[5],dice[1]};
            for (int i=0; i<6; i++) dice[i] = diceafters[i];
             Arrays.fill(diceafters,0);
            break;
          case 'E':
            int[] diceaftere = {dice[3],dice[1],dice[0],dice[5],dice[4],dice[2]};
            for (int i=0; i<6; i++) dice[i] = diceaftere[i];
            Arrays.fill(diceaftere,0);
            break;
          case 'N':
            int[] diceaftern = {dice[1],dice[5],dice[2],dice[3],dice[0],dice[4]};
            for (int i=0; i<6; i++) dice[i] = diceaftern[i];
            Arrays.fill(diceaftern,0);
            break;
          case 'W':
            int[] diceafterw = {dice[2],dice[1],dice[5],dice[0],dice[4],dice[3]};
            for (int i=0; i<6; i++) dice[i] = diceafterw[i];
            Arrays.fill(diceafterw,0);
            break;
        }
      }
        System.out.println(dice[0]);
    }
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	int N(50100);
	vector<bool>p(N, true); p[0] = p[1] = false;
	for (int i = 2; i <= sqrt(N); i++) {
		if (p[i]) {
			for (int j = i + i; j < N; j += i)p[j] = false;
		}
	}
	int n;
	while (cin >> n, n) {
		int ans(0);
		for (int i = 2; i <= n / 2; i++) {
			if (p[i] && p[n - i])ans++;
		}

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

Measured memory_bytes: 3092
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


def count_loop(start, idx_map):
    count = 0
    idx = start
    while True:
        idx = idx_map[idx]
        count += 1
        if idx == 0:
            break
    return count


A, B = zip(*sorted(zip(A, B), key=lambda x: x[1]))
idx_map = sorted(range(N), key=lambda i: A[i])
A = sorted(A)

check_1 = all(A[i] <= B[i] for i in range(N))
check_2 = any(A[i + 1] <= B[i] for i in range(N - 1))
check_3 = count_loop(0, idx_map) <= N - 2

if check_1 and (check_2 or check_3):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 112372
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    string s; cin >> s;
    int c = 0;
    rrep(i, 1, s.size()) {
        if (s[i] != s[i - 1]) c++;
    }
    cout << c << endl;
}


Measured memory_bytes: 512
dp[1<<17],h[1<<17],i,j,n;
main(k)
{
	for(scanf("%*d%d",&k);~scanf("%d",h+n);n++)dp[n]=n*1e4;
	for(;i<n;i++)for(j=0;j++<k;)dp[i+j]=fmin(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
	printf("%d",dp[n-1]);
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

const ll mod = static_cast<ll>(1e9) + 7;

ll H, W, K;
vector<string> S;

const ll MAXW = 300;
const ll MAXH = 300;
ll A[MAXH][MAXW];

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

    S.assign(H, string());
    for (auto& s : S) { cin >> s; }

    ll k = 1;

    // 上から順番に埋めていくパターン
    rep (y, H)
    {
        ll xx = -1;

        // 順番に埋めていく
        rep (x, W)
        {
            A[y][x] = k;
            if (S[y][x] == '#') { ++k; xx = x; }
        }

        // 見つかった場合は最後を埋めて終わらせる
        if (xx != -1)
        {
            REP(x, xx, W) { A[y][x] = k - 1; }
            continue;
        }

        // 見つからなかった場合は上の人に任せる
        rep (x, W)
        {
            if (y != 0 && A[y - 1][0] != 0)
            {
                A[y][x] = A[y - 1][x];
            }
            else
            {
                A[y][x] = 0;
            }
        }
    }

    // 下から順番に埋めていくパターン
    rep (y, H - 1)
    {
        const ll yy = H - y - 2;

        // 既に埋まっている
        if (A[yy][0] != 0) { continue; }

        rep (x, W)
        {
            A[yy][x] = A[yy + 1][x];
        }
    }

    rep (y, H)
    {
        rep (x, W) { cout << A[y][x] << " "; }
        cout << endl;
    }

    return 0;
}


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

int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if (r <= x && x <= w - r && r <= y && y <= h - r)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
//ABC 085 C

#include <iostream>

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

using namespace std;

int main(){
	long long int n,y;
	cin >> n >> y;
	y = y/1000;
	
	long long int x10,x5,x1;
	
	for(int i=0;i<=n;i++){
		x10 = i;
		for(int k=0;k<=n-i;k++){
			x5 = k;
			x1 = n-x5-x10;
			if (x1<0) continue;
			if (10*x10+5*x5+x1==y){
				printf("%lld %lld %lld\n",x10,x5,x1);
				return 0;
			}
		}
	}
	
	printf("-1 -1 -1\n");
	return 0;
	
}


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

int search(int l, int r)
{
    long long ans;
    long long a, b;

    a = l;
    b = l + 1;

    ans = (a * b) % 2019LL;

    for (long long i = l; i < r && i <= l + 2019; i++) {
        for (long long j = i + 1; j <= r && j <= l + 4038; j++) {
            if (ans > (i * j) % 2019LL) {
                ans = (i * j) % 2019LL;
            }
        }
    }

    return ans;
}

int main(int argc, char *argv[])
{
    int l, r;
    int ans;

    std::cin >> l >> r;

    ans = search(l, r);

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<62;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

int main(){
    ll S; cin >> S;
    vector<ll> X(3,0);
    vector<ll> Y(3,0);

    X[1] = 1e9;
    X[2] = 1;

    Y[2] = (S+(X[1]-1))/X[1];
    Y[1] = X[1]*Y[2]-S;

    cout << X[0] << " " << Y[0] << " ";
    cout << X[1] << " " << Y[1] << " ";
    cout << X[2] << " " << Y[2] << endl;    
    
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll k,a,b,x,i,j,z,n;
    cin>>n;
    x=100,a=0;
    while(x<n){
        x+=x/100;
        a++;
    }
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[1009][1009],b[1009][1009];
    int h,w;
    long long m=1000000007;
    char x;cin>>h>>w;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {cin>>x;
        if(x=='#')
        x=0;
        else
        x=1;
        a[i][j]=x;}
    }
    for(int i=0;i<=h;i++)
    b[i][0]=0;
    for(int i=0;i<=w;i++)
    b[0][i]=0;
    b[0][1]=1;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(a[i][j]==1)
            b[i][j]=((b[i-1][j])%m+(b[i][j-1])%m)%m;
            else if(a[i][j]==0)
            b[i][j]=0;
        }
    }
    cout<<b[h][w];
return 0;
}



Measured memory_bytes: 8192
import math
N, Q = map(int, input().split())
queries = []
for i in range(Q):
    v, w = map(int, input().split())
    queries.append([v, w])

if N == 1:
    for v, w in queries:
        print(min(v, w))
else:
    for v, w in queries:
        if 1 in [v, w]:
            print(1)
        else:
            # v < w にする
            v, w = min(v,w), max(v, w)
            v -= 2
            w -= 2
            v_parents = [v]
            isReported = False
            while v > 0:
                v_parents.append(v // N - 1)
                v = v//N-1
            while w > 0:
                w = w // N-1
                if w in v_parents:
                    print(w+2)
                    isReported = True
                    break
            if not isReported:
                print(1)
        

Measured memory_bytes: 71384
using System;
using System.Text;

namespace CGL_1_C_Counter_Clockwise
{
	class Program
	{
		static void Main ( string[] args )
		{
			int[] inputNum = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);
			int inputCount = int.Parse (Console.ReadLine ());

			StringBuilder output = new StringBuilder (inputCount * 18);

			Vector2 point1 = new Vector2 (inputNum[0], inputNum[1]);
			Vector2 point2 = new Vector2 (inputNum[2], inputNum[3]);

			for (int lp = 0; lp < inputCount; lp++)
			{
				inputNum = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);
				Vector2 point3 = new Vector2 (inputNum[0], inputNum[1]);

				int result = Vector2.PointState (point1, point2, point3);

				switch (result)
				{
					case Vector2.Counter_Clockwise: output.AppendLine ("COUNTER_CLOCKWISE"); break;
					case Vector2.Clockwise: output.AppendLine ("CLOCKWISE"); break;
					case Vector2.OnlineBack: output.AppendLine ("ONLINE_BACK"); break;
					case Vector2.OnlineFront: output.AppendLine ("ONLINE_FRONT"); break;
					case Vector2.OnSegment: output.AppendLine ("ON_SEGMENT"); break;
				}
			}

			Console.Write (output);
		}
	}


	class Vector2
	{
		public Vector2 ( decimal x, decimal y )
		{
			this.X = x;
			this.Y = y;
		}

		public decimal X { private set; get; }
		public decimal Y { private set; get; }

		public static Vector2 operator + ( Vector2 ob1, Vector2 ob2 )
		{
			return new Vector2 (ob1.X + ob2.X, ob1.Y + ob2.Y);
		}
		public static Vector2 operator - ( Vector2 ob1, Vector2 ob2 )
		{
			return new Vector2 (ob1.X - ob2.X, ob1.Y - ob2.Y);
		}
		public static Vector2 operator * ( Vector2 ob, decimal scalar )
		{
			return new Vector2 (ob.X * scalar, ob.Y * scalar);
		}

		public decimal Length ()
		{
			return X * X + Y * Y;
		}
		public static decimal DotProduct ( Vector2 ob1, Vector2 ob2 )
		{
			return ob1.X * ob2.X + ob1.Y * ob2.Y;
		}
		public static decimal CrossProduct ( Vector2 ob1, Vector2 ob2 )
		{
			return ob1.X * ob2.Y - ob1.Y * ob2.X;
		}

		public const int Counter_Clockwise = 1;
		public const int Clockwise = -1;
		public const int OnlineBack = 2;
		public const int OnlineFront = -2;
		public const int OnSegment = 0;

		public static int PointState ( Vector2 point1, Vector2 point2, Vector2 point3 )
		{
			Vector2 line1 = point2 - point1;
			Vector2 line2 = point3 - point1;

			decimal crossProduct = CrossProduct (line1, line2);

			if (crossProduct > 0m)
			{
				return Counter_Clockwise;
			}
			else if (crossProduct < 0m)
			{
				return Clockwise;
			}
			else if (DotProduct (line1, line2) < 0m)
			{
				return OnlineBack;
			}
			else if (line1.Length () < line2.Length ())
			{
				return OnlineFront;
			}

			return OnSegment;
		}
	}
}

Measured memory_bytes: 9236
# -*- coding: utf-8 -*-
from collections import Counter
import math
N = int(input())

As = list(map(int, input().split()))

li2 = []
li4 = []
liother = []

for a in As:
    if a%4 == 0:
        li4.append(a)
    elif a%2 == 0:
        li2.append(a)
    else:
        liother.append(a)

if len(li4) >= len(liother):
    print('Yes')
elif len(li4) == len(liother)-1 and len(li2) == 0:
    print('Yes')
else:
    print('No')


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

int main() {
  string a,b,c;
  char t = 'a';
  cin >> a >> b >> c;
  reverse(a.begin(),a.end());
  reverse(b.begin(),b.end());
  reverse(c.begin(),c.end());
  while(true){
    if(t == 'a'){
      if(a.size() == 0){
        break;
      }
      t = a.at(a.size() - 1);
      a.pop_back();
    }
    if(t == 'b'){
      if(b.size() == 0){
        break;
      }
      t = b.at(b.size() - 1);
      b.pop_back();
    }
    if(t == 'c'){
      if(c.size() == 0){
        break;
      }
      t = c.at(c.size() - 1);
      c.pop_back();
    }
  }
  if(t == 'a'){
    cout << 'A' << endl;
  }else if(t == 'b'){
    cout <<'B' << endl;
  }else{
    cout << 'C' << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int N, X;
	int ans = 1;
	cin >> N >> X;

	int x = 0;
	for (int i = 0; i < N; i++)
	{
		int l;
		cin >> l;
		x += l;
		if (x <= X) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1073741824")
#pragma GCC optimize("Ofast")

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<deque>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<fstream>
#include<iterator>
#include<functional>
#include<bitset>
#include<memory>
#include<sstream>
#include<new>
#include<cassert>
#include<iomanip>

using namespace std;
using namespace placeholders;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<bool, bool> pbb;
typedef pair<ld, ld> pdd;

const int inf = (int)1e9 + 9;
const ll linf = (ll) 1e18;
const ld eps = 1e-9;
const int mod = (int) 1e9 + 7;
const int smod = 16769023;
const ll lmod = 27644437;
const ld pi = acos(-1);

#define it(v) v.begin(), v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define scn second
#define sgn(x) (x > 0 ? 1 : (x == 0 ? 0 : -1))

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	vector<vi> m(3, vi(3));
	for (int i = 0; i < 3; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> m[i][j];
		}
	}
	for (int i = -100; i <= 100; i++)
	{
		for (int j = -100; j <= 100; j++)
		{
			for (int u = -100; u <= 100; u++)
			{
				bool flag = true;
				for (int k = 0; k < 3; k++)
				{
					if (!(m[0][k] - i == m[1][k] - j && m[0][k] - i == m[2][k] - u))
					{
						flag = false;
						break;
					}
				}
				if (flag)
				{
					cout << "Yes";
					return 0;
				}
			}
		}
	}
	cout << "No";
}

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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

typedef struct node{
    int bit;
    int consume_mp;
}node;

int main(){
    int n, a, b, c;
    scanf("%d %d %d %d", &n, &a, &b, &c);
    int l[n];
    rep(i, 0, n){
        scanf("%d", &l[i]);
    }
    int x = (int)pow(2, n) - 1;
    node a_mp[x], b_mp[x], c_mp[x];
    rep(i, 1, x+1){
        node buf;
        buf.bit = i;
        buf.consume_mp = 0;
        int len_sum = 0;
        rep(j, 0, n){
            int y = 1 << j;
            if(i&y){
                len_sum += l[j];
                buf.consume_mp += 10;
            }
        }
        buf.consume_mp -= 10;
        a_mp[i-1] = buf;
        a_mp[i-1].consume_mp += abs(len_sum - a);
        b_mp[i-1] = buf;
        b_mp[i-1].consume_mp += abs(len_sum - b);
        c_mp[i-1] = buf;
        c_mp[i-1].consume_mp += abs(len_sum - c);
    }
    /*rep(i, 0, x){
        printf("%d ", a_mp[i].consume_mp);
    }
    printf("\n");
    rep(i, 0, x){
        printf("%d ", b_mp[i].consume_mp);
    }
    printf("\n");
    rep(i, 0, x){
        printf("%d ", c_mp[i].consume_mp);
    }
    printf("\n");*/
    int ans = INT_MAX;
    rep(i, 0, x){
        rep(j, 0, x){
            rep(k, 0, x){
                if((a_mp[i].bit&b_mp[j].bit) || (b_mp[j].bit&c_mp[k].bit) || (c_mp[k].bit&a_mp[i].bit)){
                    continue;
                }
                int buf = a_mp[i].consume_mp + b_mp[j].consume_mp + c_mp[k].consume_mp;
                if(ans > buf){
                    ans = buf;
                    //printf("(%d,%d,%d) : %d %d : %d %d : %d %d\n", i, j, k, a_mp[i].bit, a_mp[i].consume_mp, b_mp[j].bit, b_mp[j].consume_mp, c_mp[k].bit, c_mp[k].consume_mp);
                }
            }
        }
    }
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
#define rrep(i, n) for(i = n - 1; i >= 0; i--)
using namespace std;

int toInt(string s) {
	int ret = 0;
	int i;
	rep(i, s.length()) {
		ret *= 10;
		ret += s[i] - '0';
	}
	return ret;
}

int main() {
	string a, b;
	cin >> a >> b;
	string s = a + b;
	int n = toInt(s);
	
	int i;
	for (i = 1; i * i < n; i++);
	if (i * i == n) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	return 0;
}

Measured memory_bytes: 256
import Control.Monad

out a b = (show a) ++ "x" ++ (show b) ++ "=" ++ (show $ a * b)

main = do
    let lst = [1,2,3,4,5,6,7,8,9]
    let hoge = concat $ map (\x -> map (out x) lst) lst
    forM_ hoge $ \x -> putStrLn x







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

int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        mp[s]++;
    }
    int p = 0;
    vector<string> v;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        int tmp = itr->second;
//        cout << tmp << endl;
        if(p < tmp){
            p = tmp;
            v.clear();
            v.push_back(itr->first);
        }
        else if(p == tmp) v.push_back(itr->first);
    }
    for(auto itr = v.begin(); itr != v.end(); itr++){
        cout << *itr << endl;
    }
    return 0;
}


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

#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define sz size()
#define x first
#define y second
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;
ll a[100100];
ll n, A, B, zz;

bool check(ll k) {
	ll cnt = 0;
	for(int i = 1; i <= n; i++) {
		if(k * B >= a[i]) continue;
		ll cur = (a[i] - k * B)/(A - B);
		cnt += cur;
		if((a[i] - k * B) % (A - B)) cnt++;
	}

	return cnt <= k;
}

int main() {
		
	cin >> n >> A >> B;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	
	
	ll L = 0, R = (ll)1e9;

	while(L < R) {
		ll mid = (L + R)/2;
		if(check(mid)) {
			R = mid;
		} else {
			L = mid + 1;
		}
	}
	
	cout << R;

	return 0;
}

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

int main() {
  string s1, s2;
  cin >> s1 >> s2;

  string s3 = "";
  s3.push_back(s2[2]);
  s3.push_back(s2[1]);
  s3.push_back(s2[0]);
  string s4 = "";
  s4.push_back(s1[2]);
  s4.push_back(s1[1]);
  s4.push_back(s1[0]);

  if (s1 == s3 && s2 == s4) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <math.h>
using namespace std;
int main() {

        int a, b;
        char c;
        while(true){
        scanf("%d %c %d", &a, &c, &b);
        if (c == '+') { printf("%d\n", a + b); }
        if (c == '-') { printf("%d\n", a - b); }
        if (c == '*') { printf("%d\n", a * b); }
        if (c == '/') { printf("%d\n", a / b); }
        if (c == '?') return 0;}
}


Measured memory_bytes: 2684
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ll long long int
#define Pi atan(1)*4
using namespace std;
int main(){
	io; 
	int a[3];
	for(int i = 0;i < 3;++i){
		cin >> a[i];
	}
	sort(a,a+3);
	if((a[1] == a[0] && a[1] != a[2]) || (a[1] == a[2] && a[1] != a[0])){
		cout << "Yes" ;
	}
	else{
		cout << "No";
	}
	return 0;
} 

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int w, a, b;
    cin >> w >> a >> b;

    if (a <= b && b <= a + w || a <= b + w && b + w <= a + w)
        OP(0);
    else
        OP(min(abs(a + w - b), abs(b + w - a)));

    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N;
		N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		Arrays.sort(A);
		System.out.println(A[N - 1] - A[0]);
		sc.close();
	}

}


Measured memory_bytes: 23764
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		if (a <= 5) {
			System.out.println(0);
		} else if (a <= 12) {
			System.out.println(b / 2);
		} else {
			System.out.println(b);
		}
	}

	/**
	 * *汎用メソッド<br>
	 * 入力した配列に対する順列を取得
	 *
	 * @param numArray
	 * @return
	 */
	private static List<Integer[]> getPermutation(int[] numArray) {
		List<Integer[]> permutation = new ArrayList<>();
		Integer[] ans = new Integer[numArray.length];
		boolean[] used = new boolean[numArray.length];

		return buildPermutaion(permutation, numArray, ans, used, 0);
	}

	/**
	 * *汎用メソッド(内部)<br>
	 * 入力した配列に対する順列を作成
	 *
	 * @param list
	 * @param numArray
	 * @param ans
	 * @param used
	 * @param depth
	 * @return
	 */
	private static List<Integer[]> buildPermutaion(List<Integer[]> list, int[] numArray, Integer[] ans, boolean[] used,
			int depth) {

		// 全部使い切った時=>できた順列を返す
		if (depth == numArray.length) {
			list.add(ans.clone());
			return list;
		}
		// 使い切っていない場合

		for (int i = 0; i < numArray.length; i++) {
			if (used[i]) {
				continue;
			}
			ans[depth] = numArray[i];
			used[i] = true;
			list = buildPermutaion(list, numArray, ans, used, depth + 1);

			used[i] = false;
		}

		return list;
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}

class Status {
	int row = 0;
	int col = 0;
	int candies = 0;

	public Status(int row, int col, int candies) {
		this.row = row;
		this.col = col;
		this.candies = candies;
	}
}


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

#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define mo 998244353
string str;
//map<int, int>::iterator itr; 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;cin>>n;
    string s;cin>>s;
    int l=0,r=s.size()-1;
    int c=0,f=0;
    while(l<r){
        if(s[l]=='R'){
            l++;
        }
        else if(s[r]=='W'){
            r--;
        }
        else if(s[l]=='W'&&s[r]=='R'){
            c++;
            l++;r--;
        }
        else{
            c++;
            l++;
        }
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 3732
#include <iostream>
#include <math.h>
#include <string>
using namespace std;

int main(){
    char a;
    int sum=0;
    for(int i=0;i<3;i++){
        cin>>a;
        if(a=='1')sum++;
        else if(a=='0');
    }
    cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

int n, A[55], B[55];
int pos[55][55];

int can(int idx, int x, int L) {
	int chk[55] = {};
	vector <int> v;
	rep(i, 51) if(pos[idx][i]) chk[i] = 1, v.pb(i);
	rep(i, szz(v)) {
		int t = v[i];
		for(int r=1;r<=L;r++) {
			if(chk[t % r] == 0) chk[t % r] = 1, v.pb(t % r);
		}
	}
	return chk[x];
}

void solve() {
	scanf("%d", &n);
	rep(i, n) scanf("%d", A+i);
	rep(i, n) scanf("%d", B+i);
	rep(i, n) pos[i][A[i]] = 1;
	ll ans = 0;
	for(int i=50;i;i--) {
		int ok = 1;
		rep(j, n) {
			if(!can(j, B[j], i-1)) { ok = 0; break; }
		}
		if(ok == 0) {
			ans |= 1LL << i;
			rep(a, n) {
				vector <int> v;
				rep(j, 51) if(pos[a][j]) v.pb(j % i);
				for(int e : v) pos[a][e] = 1;
			}
		}
	}
	
	rep(i, n) if(pos[i][B[i]] == 0) {
		puts("-1");
		return;
	}
	printf("%lld\n", ans);
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}

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

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vector<vector<t>>;
typedef long long ll;
typedef vc<int> vi;
typedef vvc<int> vvi;
typedef pair<int, int> pi;

#define uset unordered_set
#define umap unordered_map

#define endl "\n"

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()

#define all(a) a.bg, a.ed

template <class t, class u>
ostream &operator<<(ostream &os, const pair<t, u> &p) {
    return os << "( " << p.first << ", " << p.second << " )";
}

template <class t>
ostream &operator<<(ostream &os, const vc<t> &v) {
    os << "[ ";
    for (int i = 0; i < v.size(); i++) {
        os << v[i];
        if (i != v.size() - 1) {
            os << ", ";
        }
    }
    return os << " ]";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // cout << fixed << setprecision(18);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution

    int n, t, a;
    cin >> n >> t >> a;
    long double bestTempDiff = INT_MAX;
    int ret = 0;
    int x;
    for (int i = 1; i <= n; i++) {
        cin >> x;
        auto temp = t - x * 0.006;
        auto diff = abs(temp - a);
        if (diff < bestTempDiff) {
            bestTempDiff = diff;
            ret = i;
        }
    }
    cout << ret << endl;
}


Measured memory_bytes: 3640
from sys import stdin

n,m,x = [int(x) for x in stdin.readline().split()]
a_lst = [int(x) for x in stdin.readline().split()]

cost_left = sum([1 for i in range(0, x) if i in a_lst])
cost_right = sum([1 for i in range(x+1, n+1) if i in a_lst])

print(min(cost_left, cost_right))

Measured memory_bytes: 9188
rot = {
    "North": (1,5,2,3,0,4),
    "East" : (3,1,0,5,4,2),
    "West" : (2,1,5,0,4,3),
    "South": (4,0,2,3,5,1),
    "Right": (0,2,4,1,3,5),
    "Left" : (0,3,1,4,2,5)
}
while 1:
    n = input()
    if not n:
        break
    dice = [1,2,3,4,5,6]
    nxt = [0]*6
    ans = 0
    for i in xrange(n):
        r = rot[raw_input()]
        for i in xrange(6):
            nxt[i] = dice[r[i]]
        dice, nxt = nxt, dice
        ans += dice[0]
    print ans+1

Measured memory_bytes: 4252
n = int(input())
a = []
b = []
for i in range(n):
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)
a.reverse()
b.reverse()
ans = 0
for i in range(n):
    if (a[i] + ans) % b[i]:
        ans += b[i] - (a[i] + ans) % b[i]
print(ans)

Measured memory_bytes: 11048
n = int(input())
value = list(map(int, input().split()))
cost = list(map(int, input().split()))
true_value = []

for i in range(n):
    t = value[i]-cost[i]
    true_value.append(t)

true_value_a = [i for i in true_value if i >  0]

print(sum(true_value_a))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define FT() int t; scanf("%d",&t); while(t--)
#define pb push_back
#define nl printf("\n")
#define fi(i,start,end) for(int i=start; i < (int)end ; ++i)
#define ip(n)   scanf("%d",&n)
#define mz(a)   memset(a,0,sizeof(a))
#define inpArr(A,n) fi(i,0,n)   ip(A[i]);
#define print(a)  for(auto i : a)   cout<<i<<" "; nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll max(ll a,ll b)   {return a>b?a:b;}
ll min(ll a,ll b)   {return a<b?a:b;}
const int N = 2e5+1;
vector<int> adj[N];
vector<int> vis(N);
void dfs(int root,int val)
{
    vis[root] = val;
    for(auto i : adj[root])
        if(!vis[i])
            dfs(i,val);
}
int main() {
    #ifndef ONLINE_JUDGE
    freopen("D:/Sublime/Rough/input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    //std::cout << std::fixed;
    //std::cout << std::setprecision(6);
    Fastio;
    int n,m;
    cin>>n>>m;
    while(m--)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    int val = 0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
            dfs(i,++val);
    }
    int a[val+1];
    mz(a);
    int mx = 0;
    for(auto i : vis)
        a[i]++;
    for(int i=1;i<=val;i++)
        mx = max(mx,a[i]); 
    //print(a);
    cout<<mx;
    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
    #endif
    
    return 0;
}

Measured memory_bytes: 21148
h,w = gets.split.map(&:to_i)
a = h.times.map{gets.chomp}
h.times do |i|
    if i%2 == 0
        puts "#"*(w-1)+"."
    else
        puts "#"+a[i][1..-1]
    end
end
puts
h.times do |i|
    if i%2 == 1
        puts "."+"#"*(w-1)
    else
        puts a[i][0..-2]+"#"
    end
end

Measured memory_bytes: 3324
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
vector<vector<ll> >G(100010);
vector<ll>path1(0);
vector<ll>path2(0);
vector<ll>visited(100010);
ll cnt=0;
void dfs(ll i,ll p){
    visited[i]=1;
    ll cnt1=0;
    for(auto e:G[i]){
        if(visited[e])continue;
        if(cnt1&&i>1)break;
        if(i==1)cnt++;
        dfs(e,i);
        cnt1++;
    }
    if(cnt>2)return;
    if(cnt==1&&i>1)path1.pb(i);
    if(cnt==2&&i>1)path2.pb(i);
}
int main(){
    ll n,m;cin>>n>>m;
    rep(i,m){
        ll a,b;cin>>a>>b;
        G[a].pb(b);
        G[b].pb(a);
    }
    dfs(1,0);
    cout<<path1.size()+path2.size()+1<<endl;
    rep(i,path1.size()){
        cout<<path1[i]<<' ';
    }
    cout<<1<<' ';
    reverse(all(path2));
    rep(i,path2.size()){
        cout<<path2[i]<<' ';
    }
    cout<<endl;
}

Measured memory_bytes: 12276