akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define ALL(v) (v).begin(),(v).end()
const ll MOD = 1e9 + 7;
string A[1000];
int dist[1000][1000];
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int main() {
	int H, W;
	cin >> H >> W;
	memset(dist, -1, sizeof(dist));
	queue<P> Q;
	for (int i = 0; i < H; i++) {
		cin >> A[i];
		for (int j = 0; j < W; j++) {
			if (A[i][j] == '#') {
				dist[i][j] = 0;
				Q.push(P(i, j));
			}
		}
	}
	while (!Q.empty()) {
		P p = Q.front(); Q.pop();
		for (int i = 0; i < 4; i++) {
			int nx = p.second + dx[i], ny = p.first + dy[i];
			if (0 > nx || nx >= W || 0 > ny || ny >= H || dist[ny][nx] != -1) continue;
			dist[ny][nx] = dist[p.first][p.second] + 1;
			Q.push(P(ny, nx));
		}
	}
	int ans = 0;
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) ans = max(ans, dist[i][j]);
	cout << ans << endl;
}


Measured memory_bytes: 21556
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
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;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int R = nextLong();
  int C = nextLong();

  vector<string> s(R);
  REP(i, R) {
    cin >> s[i];
  }
  vector<string> ans = s;

  int src = R*C;
  int snk = R*C+1;

  atcoder::mf_graph<ll> graph(R * C + 2);


  int dr[4] = {0, 1, 0, -1};
  int dc[4] = {1, 0, -1, 0};
  REP(i, R) REP(j, C) if ((i + j) % 2 == 0) {
    REP(k, 4) {
      int ii = i + dr[k];
      int jj = j + dc[k];
      if (0 <= ii && ii < R && 0 <= jj && jj < C && s[i][j] == '.' && s[ii][jj] == '.') {
        graph.add_edge(i*C+j, ii*C+jj, 1);
      }
    }
  }
  REP(i, R) REP(j, C) {
    if ((i + j) % 2 == 0) graph.add_edge(src, i*C+j, 1);
    else graph.add_edge(i*C+j, snk, 1);
  }

  int f = graph.flow(src, snk);
  {
    int e = 0;
    REP(i, R) REP(j, C) if ((i + j) % 2 == 0) {
      REP(k, 4) {
        int ii = i + dr[k];
        int jj = j + dc[k];
        if (0 <= ii && ii < R && 0 <= jj && jj < C && s[i][j] == '.' && s[ii][jj] == '.') {
          auto edge = graph.get_edge(e);
          e++;
          if (edge.flow > 0) {
            if (k == 0) { ans[i][j] = '>'; ans[ii][jj] = '<'; }
            if (k == 1) { ans[i][j] = 'v'; ans[ii][jj] = '^'; }
            if (k == 2) { ans[i][j] = '<'; ans[ii][jj] = '>'; }
            if (k == 3) { ans[i][j] = '^'; ans[ii][jj] = 'v'; }
          }
        }
      }
    }
  }

  cout << f << endl;
  REP(i, R) cout << ans[i] << endl;


  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 5664
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i=0; i<n; i++) cin >> h[i];

    vector<int> dp(n);
    dp[1] = abs(h[1] - h[0]);
    for(int i=2; i<n; i++) {
        int min_cost = 2e9;
        for(int j=max(i-k, 0); j<=i-1; j++) {
            if(min_cost > dp[j] + abs(h[i] - h[j]))
                min_cost = dp[j] + abs(h[i] - h[j]);
        }
        dp[i] = min_cost;
    }
        
    cout << dp[n-1] << endl;

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[110];
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a+n, greater<int>());
    int Alice = 0;
    int Bob = 0;
    for(int i = 0; i < n; ++i) {
        if(i%2==0) Alice += a[i];
        else Bob += a[i];
    }
    cout << Alice-Bob << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

typedef long long ll;
using namespace std;

int main(){
    int n;
    string s;
    int k;
    cin >> n >> s >> k;
    for(int i=0;i<n;i++){
        if(s[i]!=s[k-1]){
            s[i]='*';
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 2000001

int B[N],C[N];

void CountingSort(int A[],int B[],int m,int n){
  int i,j;
  for(i=0;i<m+1;i++){
    C[i]=0;
  }
  for(j=1;j<n+1;j++){
    C[A[j]]++;
  }
  for(i=1;i<m+1;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<n+1;i++){
    printf("%d",B[i]);
    if(i!=n){
      printf(" ");
    }
  }
  printf("\n");
}
int main(){
  int A[N];
  int i,j,m,n;
  m=0;
  scanf("%d",&n);
  for(i=1;i<n+1;i++){
    scanf("%d",&A[i]);
    if(m<=A[i]-1){
      m=A[i];
    }
  }
    CountingSort(A,B,m,n);
    return 0;
  }



Measured memory_bytes: 17360
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    int s, p;
    REP(i, n) {
        cin >> s >> p;
        v[i] = make_pair(p, s);
    }
    SORT(v);
    int ans = 0;
    int now = 0;
    REP(i, n) {
        if (v[i].first < v[i].second + now) {
            cout << "No" << endl;
            return;
        }
        now += v[i].second;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1792
N = gets.chomp.to_i
monster = gets.chomp.split(" ").map(&:to_i)
breaves_power = gets.chomp.split(" ").map(&:to_i)

total_beated = 0
for town in (N-1).downto(0) do
  breave_power = breaves_power[town]
  beated1 = 0
  beated2 = 0

  if monster[town+1] > 0
    beated1 = breave_power - monster[town+1]
    if beated1 < 0
      beated1 = breave_power
    else
      beated1 = monster[town+1]
    end
    breave_power -= beated1
    monster[town+1] = monster[town+1] - beated1
  end

  if monster[town] > 0
    beated2 = breave_power - monster[town]
    if beated2 < 0
      beated2 = breave_power
    else
      beated2 = monster[town]
    end
    monster[town] = monster[town] - beated2
  end

  total_beated += beated1 + beated2
end

p total_beated


Measured memory_bytes: 17572
n = int(input())

tasks = []

for _ in range(n):
    a, b = map(int, input().split())
    tasks.append((a, b))

tasks.sort()
by_due = sorted(tasks, key=lambda x: x[1])

worked = 0
for i in range(n):
    a, b = by_due[i]
    worked += a
    if worked > b:
        print('No')
        break
else:
    print('Yes')



Measured memory_bytes: 33364
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) cout << #var << ": " << var << endl
using namespace std;
using Int = int64_t;
using Uint = uint64_t;
constexpr Uint mod = 1e9 + 7;
constexpr Int INF = INT_MAX;
template<typename T>
using Grid = vector<vector<T>>; // 二次元配列。[y][x]
template<typename T, typename U>
using Umap = unordered_map<T, U>;
template<typename T>
using Uset = unordered_set<T>;
template<typename T>
using P = pair<T, T>;

int main() {

	Int N, R; cin >> N >> R;
	Int ans = 0;
	if (N >= 10)ans = R;
	else {
		ans = R +	 100 * (10 - N);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = int(input())
p = list(map(int,input().split()))
sorted_p = sorted(p)
cnt = 0
ret = "YES"
for pi,spi in zip(p,sorted_p):
    if pi != spi:
        cnt+=1
    if cnt > 2:
        ret = "NO"
        break
print(ret)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/


int main(){
    int H,W; cin >> H >> W;
    vector<string> s(H);
    rep(i,H) cin >> s[i];

    vector<vector<int>> dist(H,vector<int>(W,INF));
    dist[0][0] = 0;
    queue<pair<int,int>> que;
    que.push(make_pair(0,0));
    while(!que.empty()){
        int x = que.front().first;
        int y = que.front().second;
        que.pop();

        for(int k=0;k<4;k++){
            int nx=x+dx[k];
            int ny=y+dy[k];
            if(nx<0 || nx>=H || ny<0 || ny>=W) continue;
            if(s[nx][ny] == '#') continue;
            if(dist[nx][ny] != INF) continue;
            dist[nx][ny] = dist[x][y] + 1;
            que.push(make_pair(nx,ny));
        }
    }

    if(dist[H-1][W-1] == INF){
        cout << -1 << endl;
        return 0;
    }

    int bn = 0;
    rep(i,H) rep(j,W) if(s[i][j] == '#') bn++;
    cout << H * W - dist[H-1][W-1] - 1 - bn << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * 2019/06/09
 * AtCoder Beginner Contest 129
 * 
 * B - Balance
 * 
 * @author rued97
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] Ws = new int[N];
		for(int i = 0; i < N; i++) {
			Ws[i] = sc.nextInt();
		}
		
		int S1 = 0;
		int S2 = 0;
		int S1i = 0;
		int S2i = N - 1;
		
		while(S1i <= S2i) {
			if(S1 < S2) {
				S1 += Ws[S1i];
				S1i++;
			} else {
				S2 += Ws[S2i];
				S2i--;
			}
		}
		
		int result;
		if(S1 > S2) {
			result = S1 - S2;
		} else {
			result = S2 - S1;
		}

		System.out.println(result);
	}
	
}


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

typedef long long ll;
typedef long double ld;

ll dpr[105][2][2];

struct dp{
    ll mat[2][2];
};

dp jedan;

dp komb(dp a, dp b){
    dp res;
    res.mat[0][0] = min(a.mat[0][1] + min(b.mat[1][0], b.mat[0][0]), a.mat[0][0] + b.mat[1][0]);
    res.mat[0][1] = min(a.mat[0][1] + min(b.mat[0][1], b.mat[1][1]), a.mat[0][0] + b.mat[1][1]);
    res.mat[1][0] = min(a.mat[1][0] + b.mat[1][0], a.mat[1][1] + min(b.mat[0][0], b.mat[1][0]));
    res.mat[1][1] = min(a.mat[1][1] + min(b.mat[0][1], b.mat[1][1]), a.mat[1][0] + b.mat[1][1]);
    return res;
}

dp pw(int b){
    if(b == 1) return jedan;
    dp res = pw(b/2);
    res = komb(res, res);
    if(b%2) res = komb(res, jedan);
    return res;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    string s;
    cin >> s;
    ll k;
    cin >> k;
    int n = s.size();
    if(n == 1){
        cout << k/2;
        return 0;
    }
    dpr[0][1][1] = 1;
    dpr[0][0][1] = 1;
    dpr[0][1][0] = 1000;
    for(int i=1; i<n; i++){
        dpr[i][1][1] = 1 + min(dpr[i-1][1][1], dpr[i-1][1][0]);
        dpr[i][0][1] = 1 + min(dpr[i-1][0][1], dpr[i-1][0][0]);
        dpr[i][1][0] = dpr[i-1][1][1];
        if(s[i] != s[i-1]) dpr[i][1][0] = min(dpr[i][1][0], dpr[i-1][1][0]);
        dpr[i][0][0] = dpr[i-1][0][1];
        if(s[i] != s[i-1]) dpr[i][0][0] = min(dpr[i][0][0], dpr[i-1][0][0]);
    }
    if(s[0] != s[n-1] || k == 1){
        cout << k*min(min(min(dpr[n-1][0][0], dpr[n-1][0][1]), dpr[n-1][1][0]), dpr[n-1][1][1]);
        return 0;
    }
    for(int i=0; i<=1; i++){
        for(int j=0; j<=1; j++){
            jedan.mat[i][j] = dpr[n-1][i][j];
        }
    }
    dp res = pw(k);
    cout << min(min(min(res.mat[0][0], res.mat[0][1]), res.mat[1][0]), res.mat[1][1]);
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, A, B int
	fmt.Scan(&N, &A, &B)

	ans := 0
	for i := 1; i <= N; i++ {
		sum := 0
		n := i
		for n > 0 {
			sum += n % 10
			n /= 10
		}
		if A <= sum && sum <= B {
			ans += i
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
using namespace std;
int MOD=1e9+7;
template<typename T>
class Matrix{
    public:
    int size;
    vector<vector<T>> mat;
    Matrix(int n){
        size=n;
        mat.resize(n,vector<T>(n));
    }
    void in(T value,int i,int j){
        mat[i][j]=value;
    }
    T out(int i,int j){
        return mat[i][j];
    }
    Matrix<T> mul(Matrix<T> A,Matrix<T> B){
        int n=A.size;
        Matrix<T> res(n);
        for(int i=0;i<n;++i){
            for(int j=0;j<n;++j){
                T sum=0;
                for(int k=0;k<n;++k){
                    sum+=A.out(i,k)*B.out(k,j);
                    sum%=MOD;
                }
                res.in(sum,i,j);
            }
        }
        return res;
    }
    Matrix<T> matpow(Matrix<T> A,long long k){
        Matrix<T> res(A);
        k--;
        while(k>0){
            if(k&(1<<0)){
                res=mul(res,A);
            }
            k/=2;
            A=mul(A,A);
        }
        return res;
    }
};


int main(){
    long long n,k;cin>>n>>k;
    Matrix<long long> mat(n);
    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
            int buf;cin>>buf;
            mat.in(buf,i,j);
        }
    }
    Matrix<long long> res(n);
    res=mat.matpow(mat,k);
    long long sum=0;
    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
            sum+=res.out(i,j);
            sum%=MOD;
        }
    }
    cout<<sum<<"\n";
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main() {
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if (x > 0 && x < W && y > 0 && y < H) {
		if (x + r <= W && y + r <= H) {
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}

	}
	else {
		printf("No\n");
	}

}


Measured memory_bytes: 2116
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))

d = {}
for i in range(N):
    d[i] = set()

for _ in range(M):
    A, B = list(map(int, input().split()))
    d[A-1].add(B-1)
    d[B-1].add(A-1)

cnt = 0
for i in range(N):
    good = True
    for neighbor in d[i]:
        if H[neighbor] >= H[i]:
            good = False

    if good:
        cnt += 1
        # print('good', i)

print(cnt)


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

void selectionSort(int[], int);

int main() {
  int n, a[100];
  scanf("%d", &n);
  for(int i = 0; i < n; i++) scanf("%d", &a[i]);
  selectionSort(a, n);
  
  printf("\n");
  return 0;
}

void selectionSort(int a[], int n) {
  int minj, count = 0;
  for(int i = 0; i < n; i++) {
    minj = i;
    for(int j = i; j < n; j++) {
      if(a[j] < a[minj]) {
        minj = j;
      }
    }
    if(i != minj) count++;
    swap(a[i], a[minj]);
  }
  printf("%d", a[0]);
  for(int i = 1; i < n; i++) printf(" %d", a[i]);
  printf("\n%d", count);
}


Measured memory_bytes: 3204
#include<iostream>
#include<string>

using namespace std;

class dice{
private:
	int D1;
	int D2;
	int D3;
	int D4;
	int D5;
	int D6;
public:
	dice(int d1,int d2,int d3,int d4,int d5,int d6){
	D1=d1;
	D2=d2;
	D3=d3;
	D4=d4;
	D5=d5;
	D6=d6;
	}
	void turn(char a){
		int front=D2;
		int back=D5;
		int top=D1;
	        int botton=D6;
		int right=D3;
		int left=D4;
		if(a=='E'){
			top=D4;
			right=D1;
			left=D6;
			botton=D3;
		}
		if(a=='N'){
			top=D2;
			front=D6;
			botton=D5;
			back=D1;
		}
		if(a=='S'){
			top=D5;
			front=D1;
			botton=D2;
			back=D6;
		}
		if(a=='W'){
			top=D3;
			left=D1;
			botton=D4;
			right=D6;
		}
		D1=top;
		D2=front;
		D3=right;
		D4=left;
		D5=back;
		D6=botton;
	}

	int dice2(int n1,int n2){
	for(int i=0;i<4;i++){
		turn('E');
		for(int j=0;j<4;j++){
			turn('S');
			for(int k=0;k<4;k++){
				turn('E');
				if(n1==D1&& n2==D2){
					return D3;
				}
			}
		}
	}
	}
};

int main(){
	int d[6];
	int a,b;
	int n;
	int front,back,right,left,top,botton;
	
	for(int i=0;i<6;i++)
		cin>>d[i];
	
	dice p(d[0],d[1],d[2],d[3],d[4],d[5]);
	cin>>n;	
	for(int i=0;i<n;i++){
		cin>>a>>b;
		cout<<p.dice2(a,b)<<endl;
	}
	
				
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>     
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#define INF 2000000
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define mk make_pair
#define en endl
#define RE return 0
#define int ll
#define P pair<int,int>
using namespace std;
int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}
int lcm(int a,int b){if(a==0){return b;} return a/gcd(a,b)*b;}

signed main(){
	string s; cin>>s;
	int ans=INF;
	for(int i=0; i<s.size()-2; i++){
		int n=0;
		for(int j=0; j<3; j++){
			int p=pow(10, 2-j);
			int ss=s[i+j]-'0';
			n+=ss*p;
		}
		ans=min(ans, abs(n-753));
	}
	cout<<ans<<en;
}



Measured memory_bytes: 256
import sys
from itertools import accumulate

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    s = input()

    b = [0] * n
    w = [0] * n
    for i in range(n):
        if s[i] == "#":
            b[i] += 1
        else:
            w[i] += 1

    b = [0] + list(accumulate(b))
    w = [0] + list(accumulate(w))
    res = f_inf
    for i in range(n + 1):
        c_b = w[-1] - w[i]
        c_w = b[i]
        res = min(res, c_b + c_w)
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 27936
#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];
	}
	cout << "AC x " << mp["AC"] << "\n";
	cout << "WA x " << mp["WA"] << "\n";
	cout << "TLE x " << mp["TLE"] << "\n";
	cout << "RE x " << mp["RE"] << "\n";
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
 
 
 
int sc1() {int x; scanf("%d", &x); return x;}
 
long long sc2() {long long x; scanf("%lld", &x); return x;}
 
 
 
#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>
#define  MAX              100007;
 
 
int bs(int arr[2002],int l,int h,int x)
{
    int index=-1;
    while(l<=h)
    {
        int mid=(l+h)/2;
 
        if(arr[mid]==x) {
            index=mid;
            l=mid+1;
        }
        else if(arr[mid]<x)
        {
            index=mid;
            l=mid+1;
            //cout<<"66"<<endl;
        }
        else
        {
            h=mid-1;
        }
 
    }
 
    return index;
}
 
 
 
 
int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
 
    //int arr[]={10,20,30,40,50,60,60};
 
    //cout<<bs(arr,0,6,5)<<endl;
 
    // int tes=Int;
 
    // for(int te=1;te<=tes;te++){
 
    int n = Int;
 
    int arr[n + 1];
   
 
    for(int i = 0; i < n; i++)
    {
        arr[i] = Int;
    }
    sort(arr,arr+n);
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            int x=arr[i]+arr[j];
 
            int p=bs(arr,0,n-1,x-1);
 
            ans+=(p>j?p-j:0);
 
 
        }
    }
    // printf("Case %d: ", te);
 
    cout<<ans<<endl;
// }
 
 
    return 0;
}
 

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

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

  vector<int> A(N);
  for (int n = 0; n < N; n++){
    int t;
    cin >> t;
    A.at(n) = t;
  }

  int n;
  int64_t last_val = A[0];
  int64_t cur_val;
  int64_t money = 1000;
  
  for (n = 1; n < N; n++){
    cur_val = A[n];
    if (cur_val > last_val){
      int64_t units = money / last_val;
      money = money + (cur_val - last_val) * units;
    }
    last_val = cur_val;
  }
  cout << money << endl;
  return 0;
}


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

using namespace std;

int main() {
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  bool invalid = true;
  vector<string> board(n);
  for (int i = 0; i < n; ++i) {
    cin >> board[i];
    if (board[i] != string(n, '.')) {
      invalid = false;
    }
  }
  if (invalid) {
    cout << -1 << "\n";
    return 0;
  }
  int bad = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (board[j][i] == '.') {
        ++bad;
        break;
      }
    }
  }
  int ans = n * 2;
  for (int i = 0; i < n; ++i) {
    if (board[i] != string(n, '.')) {
      int extra = 1;
      for (int j = 0; j < n; ++j) {
        if (board[j][i] == '#') {
          extra = 0;
          break;
        }
      }
      for (int j = 0; j < n; ++j) {
        if (board[i][j] == '.') {
          ++extra;
        }
      }
      ans = min(ans, bad + extra);
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3932
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
typedef pair< int , int> P;
int gcd( int x, int y ){
   return y ? gcd(y, x%y) : x;
 }
bool pairCompare(const P& firstElof, const P& secondElof)
{
  if(firstElof.second!= secondElof.second)    return firstElof.second> secondElof.second;
  else return firstElof.first< secondElof.first;
}
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
while(  std::cin >> x>>y){
if(x==0)return 0;
  std::vector< int > v(x);
  rep(i,x)std::cin >> v[i];
  sort(rall(v));
  rep(i,x){
    if((i+1)%y==0)continue;
    z+=v[i];
  }
  std::cout << z << '\n';
  z=0;
}
}



Measured memory_bytes: 3108
a, b = map(float, input().split())

_a = int(a / 0.08)
_b = int(b / 0.1)

m = min(_a, _b)

ans = -1

while m < 1010:
    if int(m * 0.08) == a and int(m * 0.1) == b:
        ans = m
        break
    m += 1

print(ans)

Measured memory_bytes: 38384
#include <iostream>
using namespace std;
#define ll long long
#define inf 10000000000000

ll dp[3001][3001];
ll a[3001];

ll rec (ll l, ll r) {
  if (dp[l][r] != inf) return dp[l][r];
  if (l == r) return a[l];
  return dp[l][r] = max(-1 * rec(l, r - 1) + a[r], -1 * rec(l + 1, r)+ a[l]);    
}

int main () {
  ll n;
  cin >> n;
  for (ll i = 0; i <= 3000; i++) {
    for (ll j = 0; j <= 3000; j++) {
      dp[i][j] = inf;  
    }  
  }
  for (ll i = 0; i < n; i++) cin >> a[i];
  cout << rec(0, n - 1) << endl;  
}

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

int main()
{
	int n;
	cin >> n;
	ll ans = 0;
	for(int i = 0;i<n;i++)
	{
		int l ,r;
		cin >> l >> r;
		r++;
		ans += r-l;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.random;
     
void main() {
  auto x = readln.chomp.split.map!(to!int);
  int cnt;
  foreach (i; x[0]..x[1]+1) if (x[2] % i == 0) cnt++;
  cnt.writeln;
}

Measured memory_bytes: 1056
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    if(s=="Sunny")
    cout<<" Cloudy\n ";
    else if(s=="Cloudy")
    cout<<" Rainy\n ";
    else if(s=="Rainy")
    cout<<"Sunny\n ";
    return 0;
}

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

int main() {
    stack<int> S;
    int a, b, x;
    string s;
    
    while ( cin >> s ) {
        if ( s[0] == '-' ) {
            a = S.top(); 
            S.pop();
            b = S.top();
            S.pop();
            S.push( b-a );
        } else if ( s[0] == '+' ) {
            a = S.top();
            S.pop();
            b = S.top();
            S.pop();
            S.push( a+b );
        } else if ( s[0] == '*' ) {
            a = S.top();
            S.pop();
            b = S.top();
            S.pop();
            S.push( a*b );
        } else {
            S.push( atoi( s.c_str() ) );
        }
    }
    
    cout << S.top() << endl;
    
    return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)

/////////////////////////////////////////////////////////

class XY{
public:
  int x, y;
  XY() {x = y = 0;}
};

void Main(){
  XY S, T;
  cin >> S.x >> S.y >> T.x >> T.y;
  rep(i, 0, T.x - S.x) cout << 'R';
  rep(i, 0, T.y - S.y) cout << 'U';
  rep(i, 0, T.x - S.x) cout << 'L';
  rep(i, 0, T.y - S.y) cout << 'D';
  cout << 'D';
  rep(i, 0, T.x - S.x + 1) cout << 'R';
  rep(i, 0, T.y - S.y + 1) cout << 'U';
  cout << 'L';
  cout << 'U';
  rep(i, 0, T.x - S.x + 1) cout << 'L';
  rep(i, 0, T.y - S.y + 1) cout << 'D';
  cout << 'R';
  cout << endl;
}

/////////////////////////////////////////////////////////

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

  Main();
}


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

namespace _068
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());

            int ans = 1;
            int maxDivide2Cnt = 0;

            for (int i = 1; i <= num; i++)
            {
                int divide2cnt = GetDivide2Cnt(i);

                if (divide2cnt > maxDivide2Cnt)
                {
                    ans = i;
                    maxDivide2Cnt = divide2cnt;
                }

            }

            Console.WriteLine(ans);
        }


        private static int GetDivide2Cnt(int n)
        {
            int ret = 0;
            
            if (n % 2 != 0)
            {
                return ret;
            }

            return 1 + GetDivide2Cnt(n / 2);

        }
    }
}



Measured memory_bytes: 11092
n = int(input())
l = [[i,0] for i in range(1,n+1)]
a = list(map(int,input().split()))
for i in range(n):
  l[i][1] = a[i]
l.sort(key=lambda x:x[1])
for i in range(n):
  print(l[i][0],end = " ")

Measured memory_bytes: 27360
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner(os.Stdin)
	s := sc.ScanInts(3)

	if s[0]+s[1] >= s[2] {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner(r io.Reader) *Scanner {
	s := &Scanner{bufio.NewScanner(r)}
	s.sc.Split(bufio.ScanWords)
	return s
}

func (s *Scanner) ScanInt() int {
	s.sc.Scan()
	i, e := strconv.Atoi(s.sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) ScanInts(len int) []int {
	a := make([]int, len)
	for i := 0; i < len; i++ {
		a[i] = s.ScanInt()
	}
	return a
}


Measured memory_bytes: 640
#include<stdio.h>
#include<algorithm>
using namespace std;
char in[110];
int main(){
	scanf("%s",in);
	for(int i=0;in[i];i++){
		for(int j=i+1;in[j];j++){
			if(in[i]=='C'&&in[j]=='F'){printf("Yes\n");return 0;}
		}
	}
	printf("No\n");
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, k = map(int, input().split())
a = sorted(list( map(int, input().split()) ))
f = sorted(list( map(int, input().split()) ), reverse=True)

lft = -1
rgt = 10**12
while rgt-lft > 1:
    mid = ( rgt+lft ) // 2
    cnt = 0

    for i, e in enumerate(a):
        cnt += max( 0, e-mid//f[i] )

    if cnt <= k:
        rgt = mid
    else:
        lft = mid

print(rgt)

Measured memory_bytes: 108492
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	if(s.back()=='s')
		s += 'e';
	s += 's';
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    int n,k,i,cnt=0;
    cin >> n >> k;
    vector<int > h(n);
    FOR(i, 0, n){
        cin >> h[i];
        if(h[i]>=k){
            cnt+=1;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}

int n;
int p[100];
int q[100];
int r[100];
int b[100];
int used[100];
int res[100];

void dfs(int v) {
	if (used[v]) {
		return;
	}
	used[v] = 1;
	if (r[v] != -1) {
		dfs(r[v]);
	}
	if (b[v] != -1) {
		dfs(b[v]);
	}
	int al = r[v] != -1 ? res[r[v]] : 1;
	int ar = b[v] != -1 ? res[b[v]] : 1;
	al /= gcd(q[v], al);
	ar /= gcd(p[v], ar);
	int lcm = ar / gcd(ar, al) * al;
	res[v] = lcm * (p[v] + q[v]);
}

int main()
{
	cin.sync_with_stdio(false);
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			cin >> p[i] >> q[i] >> r[i] >> b[i];
			int g = gcd(p[i], q[i]);
			p[i] /= g;
			q[i] /= g;
			r[i]--; b[i]--;
		}
		fill(used, used + n, 0);
		fill(res, res + n, 0);
		int ans = 0;
		for (int i = 0; i < n; i++) {
			dfs(i);
			ans = max(ans, res[i]);
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3176
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <time.h>
#include <algorithm>
using namespace std;
#define INF 2147483647

/********************************* Main *********************************/
int main() {
	ios_base::sync_with_stdio(false);
  
	int n; cin >> n; 
	double odd_num = 0;
	if (n % 2 == 0) {
		odd_num = n / 2; 
	}
	else {
		odd_num = n / 2 + 1; 
	}

	double proba = 0.0;
	proba = odd_num / n; 

	printf("%.10f\n", proba);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll L[87];
    L[0] = 2;
    L[1] = 1;
    for(int i = 2; i <= 86; i++) {
        L[i] = L[i-1] + L[i-2];
    }
    int n;
    cin >> n;
    cout << L[n] << endl;
    return 0;
}


Measured memory_bytes: 256
using System;

namespace AtCorder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var takoyakisStr = Console.ReadLine().Split(' ');
            var takoyakis = new int[takoyakisStr.Length];
            for (var i = 0; i < takoyakisStr.Length; i++)
            {
                takoyakis[i] = int.Parse(takoyakisStr[i]);
            }

            var result = 0;

            for (int i = 0; i < takoyakis.Length; i++)
            {
                for (int j = i + 1; j < takoyakis.Length; j++)
                {
                    result += takoyakis[i] * takoyakis[j];
                }
            }

            Console.WriteLine(result);
        }
    }
}



Measured memory_bytes: 11092
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b,t = LI()
print(t//a*b)

Measured memory_bytes: 38256
#include<iostream>
#include<cmath>
int main(){float a,b,c,d,e,f,g,h,i,j,k,l,n,s;for(std::cin>>n;n--;)std::cin>>g>>h>>i>>j>>k>>l,a=i-k,d=j-l,b=k-g,e=l-h,c=g-i,f=h-j,a=sqrt(d=d*d+a*a),b=sqrt(e=e*e+b*b),c=sqrt(f=f*f+c*c),s=(a+b+c)/2,s=sqrt(s*(s-a)*(s-b)*(s-c)),s*=s*16,a=d*(e+f-d),b=e*(f+d-e),c=f*(d+e-f),g-=d=(a*g+b*i+c*k)/s,h-=e=(a*h+b*j+c*l)/s,printf("%.3f %.3f %.3f\n",d,e,sqrt(g*g+h*h));}

Measured memory_bytes: 0
// https://atcoder.jp/contests/abc113/tasks/abc113_a

#include <iostream>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int x, y;

  cin >> x >> y;

  cout << x + y / 2 << '\n';

  return 0;
}


Measured memory_bytes: 256
def f(flg, an):
    accum = 0
    ret = 0
    for i, ai in enumerate(an):
        accum += ai
        if flg:
            flg = False
            if accum <= 0:
                ret += -accum + 1
                accum = 1
        else:
            flg = True
            if 0 <= accum:
                ret += accum + 1
                accum = -1
    return ret


def main():
    an = [int(ai) for ai in open(0).read().split()[1:]]
    print(min(f(False, an), f(True, an)))
    return


main()


Measured memory_bytes: 14524
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scan_init()
	x := scanInt()
	sum := 0
	sum += 1000 * (x/500)
	sum += 5 * ((x%500)/5)
	fmt.Print(sum)
}

var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}

var rdr = bufio.NewReaderSize(os.Stdin, 200000)

func readLine() string {
	buf := make([]byte, 0, 200000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
func readLineToNumber() int {
	S := readLine()
	number, _ := strconv.Atoi(S)
	return number
}
func readLineToSlice() []string {
	S := readLine()
	list := strings.Split(S, "")
	return list
}
func readLineToNumberSlice(memo map[string]int) []int {
	// err時は-1を代入
	S := readLine()
	intList := make([]int, len(S))
	for i := 0; i < len(S); i++ {
		if val, ok := memo[string(S[i])]; ok {
			intList[i] = val
		} else {
			intList[i] = -1
		}
	}
	return intList
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define PB push_back
#define pb push_back
#define sz(a) ((LL)(a).size())
#define all(a) (a).begin(),a.end()
#define forn(i, n) for(LL i = 0; i < n; ++i)
#define ALL(x) x.begin(), x.end()
#define ll long long
#define MAXN 100
vector<int> b;
bool canPut(int pos , int val , vector<int> putted)
{
	int cnt = 0;
	for(int i = 0; i < pos; i++)
		cnt += putted[i];
	return val - 1 == cnt;
}
int main()
{
	int n;
	cin >> n;
	b.resize(n);
	for(auto &x : b)
		cin >> x;
	vector<int> putted(n);
	vector<int> ans;
	for(int i = 0; i < n; i++)
	{
		bool was = false;
		for(int j = n - 1; j >= 0; j--)
		{
			if(putted[j])
				continue;
			if(canPut(j , b[j] , putted))
			{
				ans.PB(b[j]);
				was = true;
				putted[j] = 1;
				break;
			}
		}
		if(!was)
		{
			cout << -1;
			return 0;
		}
	}
	
	for(auto x : ans)
		cout << x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int

int main() {

    fastio;

    ll n;
    string s;
    ll count = 0;

    cin >> n >> s;

    for(ll i = 0; i < n-2; i++) if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') count++;

    cout << count;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        String S = sc.next();

        int non = 0;
        for(int i=0; i<S.length(); i++){
            if(i%2==0 && S.charAt(i)== 'L'){
 		            non++;
	}
}
        for(int i=0; i<S.length(); i++){	       
            if(i%2!=0 && S.charAt(i)== 'R'){
 		            non++;
            }
}
	    if(non>0){
	        System.out.println("No");
	    }else{
	        System.out.println("Yes");	        
	    }
	}
}

Measured memory_bytes: 22740
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

int dp[31];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int N, K;
    cin >> N >> K;

    vector<int> A(N);
    vector<int> B(N);
    int ans = 0;
    REP(i, N) {
        cin >> A[i] >> B[i];
        if ((K | A[i]) == K) {
            ans += B[i];
        }
    }

    CLR(dp, 0);

    REP(j, 30) {
        if ((K & (1 << j)) == 0) continue;
        int t = K;
        t ^= 1 << j;
        t |= (1 << j) - 1;
        REP(i, N) {
            if ((t | A[i]) == t) {
                dp[j] += B[i];
            }
        }
    }

    REP(j, 30) {
        ans = max(ans, dp[j]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define INF ((ll)1<<31)-1
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int gcd(int a,int b){
	if(!a)return b;
	return gcd(b%a,a);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
int h,w,a[600][600],ans;
signed main(){
	cin>>h>>w;
	rep(i,h){
		rep(j,w){
			cin>>a[i][j];
			ans+=a[i][j]*(h-i)*(i+1)*(w-j)*(j+1);
		}
	}
	cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 5452
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

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

  if(a == 1) a += 13;
  if(b == 1) b += 13;

  if(a > b) cout << "Alice" << endl;
  else if(a < b) cout << "Bob" << endl;
  else cout << "Draw" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    string ans;
    if(a <= 0 && 0 <= b){
        ans = "Zero";
    }else if(a > 0 && b > 0){
        ans = "Positive";
    }else {
        if((b + a -1)%2) ans = "Negative";
        else ans = "Positive";
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	a := getInt()
	b := getInt()
	c := getInt()

	fmt.Println(sum(a, b, c) - max(a, b, c))
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}

func sum(ns ...int) int {
	var sum int
	for _, n := range ns {
		sum += n
	}
	return sum
}

func min(ns ...int) int {
	var min int
	min = ns[0]
	for _, n := range ns {
		if min > n {
			min = n
		}
	}
	return min
}

func max(ns ...int) int {
	var max int
	for _, n := range ns {
		if max < n {
			max = n
		}
	}
	return max
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();

		for(int i=1;i<s.length();i++) {
			if(s.charAt(i-1) == s.charAt(i)) {
				System.out.println("Bad");
				return;
			}
		}
		System.out.println("Good");
	}
}


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

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

    int a4 = 0, a2 = 0, a1 = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a % 4 == 0) a4++;
        else if (a % 2 == 0) a2++;
        else a1++;
    }

    if (a4 >= a1) cout << "Yes" << endl;
    else if (a2==0 && a4+1==a1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP(a, b) make_pair(a, b)
#define Y first
#define X second
#define L first
#define R second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef pair<pi, pi> pipi;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int W, H, used[52][52][52][52];
int dy[] = {0,-1,0,1}, dx[] = {-1,0,1,0};
char len[52][52], rin[52][52];

struct P{
  int rx, ry, lx, ly;
  P(int ly, int lx, int ry, int rx):ly(ly),lx(lx),ry(ry),rx(rx){};
};

int main(){
  while(scanf("%d%d", &W, &H) && W){
    rep(i, H) scanf("%s%s", len[i], rin[i]);

    int ly, lx, ry, rx;
    rep(i, H) rep(j, W){
      if(len[i][j] == 'L'){ ly = i, lx = j; len[i][j] = '.';}
      if(rin[i][j] == 'R'){ ry = i, rx = j; rin[i][j] = '.';}
    }

    memset(used, 0, sizeof(used));
    queue<P>q;
    q.push(P(ly, lx, ry, rx));
    used[ly][lx][ry][rx] = 1;

    while(!q.empty()){
      P now = q.front(); q.pop();
      rep(d, 4){
	int nly, nlx, nry, nrx;
	if(d%2){
	  nly = now.ly + dy[d], nlx = now.lx;
	  if(nly < 0 || nly >= H || len[nly][nlx] == '#') nly = now.ly; 
	  nry = now.ry + dy[d], nrx = now.rx;
	  if(nry < 0 || nry >= H || rin[nry][nrx] == '#') nry = now.ry; 
	}else{
	  nly = now.ly, nlx = now.lx + dx[d];
	  if(nlx < 0 || nlx >= W || len[nly][nlx] == '#') nlx = now.lx; 	    
	  nry = now.ry, nrx = now.rx + -1*dx[d];
	  if(nrx < 0 || nrx >= W || rin[nry][nrx] == '#') nrx = now.rx;
	}

	  //	  pipi next = MP(MP(nly, nlx), MP(nry, nrx));
	if(len[nly][nlx] == '%' && rin[nry][nrx] == '%'){
	  puts("Yes"); goto e;
	}
	if(len[nly][nlx] == '%' || rin[nry][nrx] == '%') continue;
       
	if(used[nly][nlx][nry][nrx] != 0) continue;
	//	  printf("%d %d %d %d\n", next.L.Y, next.L.X, next.R.Y, next.R.X);
	q.push(P(nly, nlx, nry, nrx));
	used[nly][nlx][nry][nrx] = 1;
      }
    }
    puts("No");
  e:;

  }
  return 0;
}

Measured memory_bytes: 30664
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll a,v; cin>>a>>v;
	ll b,w; cin>>b>>w;
	ll t; cin>>t;
	ll dist = abs(a-b);
	if(v<=w)
	{
		cout<<"NO\n"; return 0;
	}
	if(abs(v-w)*t>=dist)
	{
		cout<<"YES\n";
	}
	else
	{
		cout<<"NO\n";
	}
}	


Measured memory_bytes: 3652