akhauriyash/Code-Regression huggingface dataset:
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
#define MAXM 10000
#define MAXL 110
#define MAXN 110

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

struct edge {
    int to, dist, cost;
};

struct state {
    int pos, yosan, all_cost;
};

vector<edge> G[MAXN];
int N, M, L;

int dijkstra(void) {
    int d[MAXN][MAXL];
    for (int i = 1; i <= N; i++) 
        for (int j = 0; j <= L; j++)
            d[i][j] = INF;

    d[1][L] = 0;
    state s; s.pos = 1; s.yosan = L; s.all_cost = 0;
    queue<state> que;
    que.push(s);
    while (!que.empty()) {
        state now = que.front(); que.pop();
        if (d[now.pos][now.yosan] < now.all_cost) continue;
        for (int i = 0; i < G[now.pos].size(); i++) {
            edge e = G[now.pos][i];
            // 雇わない
            if (d[e.to][now.yosan] > now.all_cost + e.cost) {
                d[e.to][now.yosan] = now.all_cost + e.cost;
                state s; s.pos = e.to; s.yosan = now.yosan; s.all_cost = now.all_cost + e.cost;
                que.push(s);
            }
            // 雇う
            if (now.yosan >= e.dist && d[e.to][now.yosan-e.dist] > now.all_cost) {
                d[e.to][now.yosan-e.dist] = now.all_cost;
                state s; s.pos = e.to; s.yosan = now.yosan-e.dist; s.all_cost = now.all_cost;
                que.push(s);
            }
        }
    }
    int ret = INF;
    for (int i = 0; i <= L; i++) {
        ret = min(ret, d[N][i]);
    }
    return ret;
}

int main(void) {
    while (1) {
        cin >> N >> M >> L;
        if (N == 0 && M == 0 && L == 0) break;
        for (int i = 0; i < MAXN; i++) G[i].clear();
        for (int i = 0; i < M; i++) {
            int a, b, d, e;
            cin >> a >> b >> d >> e;
            edge es; es.to = b; es.dist = d; es.cost = e;
            G[a].push_back(es);
            es.to = a; G[b].push_back(es);
        }
        cout << dijkstra() << endl;
    }
    return 0;
}

Measured memory_bytes: 1536
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt(), l=sc.nextInt(), i, j;
        String[] s = new String[101];
        String tmp;
        for(i=0;i<n;i++)
            s[i] = sc.next();
        for(i=0;i<n;i++){
            for(j=i+1;j<n;j++){
                if(s[i].compareTo(s[j])>0){
                    tmp = s[i];
                    s[i] = s[j];
                    s[j] = tmp;
                }
            }
        }
        for(i=0;i<n;i++)
            System.out.print(s[i]);
        System.out.println();
    }
}


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

using namespace std;

#define ll long long
#define ld long double
#define pll pair <ll , ll>

#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair

#define X first
#define Y second

#define LB(x) (x & (-x))
#define BIT(a,b) ((ll)(a&(1<<b))==0 ? false : true)

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

    ll x,y;
    cin>>x>>y;

    if (abs(x-y)<=1)
    {
        cout<<"Brown"<<endl;
    }
    else
    {
        cout<<"Alice"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

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

fn main() {
    let (n, k) = get!(usize, usize);
    let d: Vec<usize> = util::gets();

    let ans = (n..)
        .find(|&x| {
            let mut a = x;
            while a > 0 {
                if d.binary_search(&(a % 10)).is_ok() {
                    return false;
                }
                a /= 10;
            }
            true
        })
        .unwrap();

    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;
import java.text.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String[] arr = sc.nextLine().split(" ");
      double pi = Math.PI;
      
      double a = Double.parseDouble(arr[0]);
      double b = Double.parseDouble(arr[1]);
      double degree = Double.parseDouble(arr[2]);
      double radian = degree * pi/180.0;
      
      double s = 0.50 * a * b * Math.sin(radian);
      double l = a * a + b * b - 2.0 * a * b * Math.cos(radian);
      l = Math.sqrt(l);
      l += a + b;
      
      double h = 2.0 * s / a;
      
      System.out.println(String.format("%.5f",s));
      System.out.println(String.format("%.5f",l));
      System.out.println(String.format("%.5f",h));
      
   }//main
   
   
}//class

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

int main() {

	int w, a, b; cin >> w >> a >> b;
	int ans;
	if (a <= b && b <= a + w) {
		ans = 0;
	}
	else if (a <= b + w && b + w <= a) {
		ans = 0;
	}
	else if (a + w < b) {
		ans = b - (a + w);
	}
	else {
		ans = a - (b + w);
	}
	cout << ans << endl;
	return 0;
}

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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int  h, w;
char c[55][55];

int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

bool check(int x, int y) {
    return x >= 0 && x < w && y >= 0 && y < h && c[x][y] == '#';
}

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    cin >> h >> w;

    // 処理
    rep(y, h) rep(x, w) cin >> c[x][y];
    rep(y, h) rep(x, w) {
        if (c[x][y] == '#') continue;
        int cnt = 0;
        rep(i, 8) {
            int cx = x + dx[i], cy = y + dy[i];
            if (check(cx, cy)) cnt++;
        }
        c[x][y] = '0' + cnt;
    }

    // 出力
    rep(y, h) {
        rep(x, w) cout << c[x][y];
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
ev = Counter([v[i] for i in range(0, n, 2)])
od = Counter([v[i] for i in range(1, n, 2)])
evk = list(ev.keys())
odk = list(od.keys())
ev_key = evk[0]
for k in evk:
    if ev[k] > ev[ev_key]:
        ev_key = k
od_key = odk[0]
for k in odk:
    if od[k] > od[od_key]:
        od_key = k
evv = list(ev.values()) + [0]
evv.sort(reverse = True)
odv = list(od.values()) + [0]
odv.sort(reverse = True)

if ev_key != od_key:
    print(n - evv[0] - odv[0])
else:
    print(min(n - evv[0] - odv[1], n - evv[1] - odv[0]))

Measured memory_bytes: 99680
#include <stdio.h>

int main(void)
{
	int h,m,s,S;
	scanf("%d",&S);
	h=S/3600;
	m=S/60-h*60;
	s=S-(h*3600+m*60);
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    if (a<b) {
      for (int i=0;i<b;i++) {
        System.out.print(a);
      }
    }else{
      for (int i=0;i<a;i++) {
        System.out.print(b);
      }
    }
    System.out.println();
  }
}


Measured memory_bytes: 21716
#include <stdio.h>
int main(void){
	int m,f,b;
	scanf("%d %d %d",&m,&f,&b);
	if(b<m){
		printf("0\n");
	}else if((m+f)<b){
		printf("NA\n");
	}else{
		printf("%d\n",b-m);
	}
	return 0;
}
	


Measured memory_bytes: 2720
#include <bits/stdc++.h>
using namespace std;
long long MINF = -1LL << 60;

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

    long long ans = MINF;
    ans = max(ans, a*c);
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);



    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

const ll p = 1000000007;

#define MAXN 100000

bool visited[MAXN];
vector<ll> connected[MAXN];
ll white[MAXN], black[MAXN];

bool dfs(ll i){
  if(visited[i]) return false;
  visited[i] = true;
  white[i] = 1, black[i] = 1;
  for(ll k : connected[i]){
    if(dfs(k)){
      white[i] *= (white[k]+black[k]);
      black[i] *= white[k];
      white[i] %= p, black[i] %= p;
    }
  }
  return true;
}


int main(){
  ll n;
  cin >> n;
  REP(i,n-1){
    ll x,y;
    cin >> x >> y;
    x--, y--;
    connected[x].push_back(y);
    connected[y].push_back(x);
  }
  fill(visited,visited+n,false);
  dfs(0);
  cout << (black[0]+white[0])%p << endl;
  return 0;
}


Measured memory_bytes: 11520
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint ret[514][514];
int inf=1000000000;
void cal(int H,int W,int h,int w){
	rep(i,H) rep(j,W){
		if(j%w==w-1) ret[i][j]=-inf;
		else ret[i][j]=(inf-1)/(w-1);
	}
}
int main()
{
	int H,W,h,w;
	cin>>H>>W>>h>>w;
	if(H%h==0 && W%w==0){
		cout<<"No"<<endl;return 0;
	}
	if(W%w==0){
		cal(W,H,w,h);
		rep(i,505) REP(j,i+1,505) swap(ret[i][j],ret[j][i]);
	}
	else{
		cal(H,W,h,w);
	}
	cout<<"Yes"<<endl;
	rep(i,H){
		rep(j,W){
			cout<<ret[i][j];
			if(j<W-1) cout<<' ';else cout<<endl;
		}
	}
}

Measured memory_bytes: 4992
import java.io.*

val pw = PrintWriter(System.out)
const val MOD = 1000000007L
const val INF = 2147483647
const val LINF = 9223372036854775807L

fun main(args: Array<String>) {
    solve()
    pw.flush()
}

fun solve() {
    val o = next()
    val e = next()

    var index = 0
    while(index < o.length){
        print(o[index])
        if(index == e.length) break
        print(e[index])
        index++
    }
    println()

}

fun println(v: String) {
    pw.println(v)
}

fun print(v: String) {
    pw.print(v)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ").toMutableList()
fun nextIntList(index: Int = 0) = next().split(" ").map { it.toInt() + index }.toMutableList()
fun nextLongList(index: Long = 0L) = next().split(" ").map { it.toLong() + index }.toMutableList()
fun nextDoubleList() = next().split(" ").map { it.toDouble() }.toMutableList()

fun ary(n: Int, init: String = "") = Array(n) { init }
fun intAry(n: Int, init: Int = 0) = IntArray(n) { init }
fun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }
fun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }
fun ary2(n: Int, m: Int, init: String = "") = Array(n) { Array(m) { init } }
fun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }
fun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }
fun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }
fun ary3(n: Int, m: Int, k: Int, init: String = "") = Array(n) { Array(m) { Array(k) { init } } }
fun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }
fun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }
fun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }

fun abs(n: Int): Int = Math.abs(n)
fun abs(n: Long): Long = Math.abs(n)
fun abs(n: Double): Double = Math.abs(n)
fun max(vararg values: Int) = if (values.isEmpty()) -INF else values.max()!!
fun max(vararg values: Long) = if (values.isEmpty()) -LINF else values.max()!!
fun min(vararg values: Int) = if (values.isEmpty()) INF else values.min()!!
fun min(vararg values: Long) = if (values.isEmpty()) LINF else values.min()!!
fun swap(a: String, b: String) = Pair<String, String>(b, a)
fun swap(a: Int, b: Int) = Pair<Int, Int>(b, a)
fun swap(a: Long, b: Long) = Pair<Long, Long>(b, a)
fun swap(a: Double, b: Double) = Pair<Double, Double>(b, a)



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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

using ll    = long long;
using vll   = vector<ll>;
using pll   = pair<ll,ll>;
using ld    = long double;

const ll mod = (ll)1e9 + 7;
const ll mxN = (ll)4e5 + 3;

void solve() {
	ll n;cin>>n;
	vll A(n); 
	ll odd=0;
	for(int i=0;i<n;i++) {
		cin>>A[i];
		if(A[i]<0) odd^=1,A[i]*=-1;
	}
	if(odd) cout<<accumulate(all(A),0LL)-*min_element(all(A))*2<<"\n";
	else cout<<accumulate(all(A),0LL);
}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
//	pre();
//	ll t;cin>>t;while (t--)
		solve();
}


Measured memory_bytes: 3976
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map(String::toInt)
    val B = readLine()!!.split(" ").map(String::toInt)
    val C = listOf(0) + readLine()!!.split(" ").map(String::toInt)
    val ans = B.sum() + (0 until A.size - 1).map { if (A[it] + 1 == A[it + 1]) C[A[it]] else 0 }.sum()
    println(ans)
}

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

#define y1 as214
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define fr front()
#define pb push_back
#define t top()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , n) for(int i = 0 ; i < n ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define ll long long
#define oo 1e17

const int N = 3e3 + 5;
const int VAL = 1e5 + 5;
int n , m , k , mod = 1e9 + 7;
ll fact[2 * VAL] , dp[N] , g[2 * VAL];
ii a[N];

int mulmod(int a , int b)
{
    return (1LL * a * b) % mod;
}

void mult(ll &a , int b)
{
    a = (1LL * a * b) % mod;
}

void addmod(ll &a , int b)
{
    a = (a + b) % mod;
}

void subtract(ll &a , int b)
{
    a = (((a - b) % mod + mod) % mod);
}

int powmod(ll a , int b)
{
    ll res = 1;
    while(b)
    {
        if(b & 1)
            mult(res , a);
        mult(a , a);
        b >>= 1;
    }
    return res;
}

inline int C(int n , int k)
{
    return mulmod(fact[n] , mulmod(g[k] , g[n - k]));
}

main()
{
    //freopen("Y.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin >> n >> m >> k;
    fact[0] = 1;
    FOR(i , 1 , n + m)
        fact[i] = mulmod(fact[i - 1] , i);
    g[n + m] = powmod(fact[n + m] , mod - 2);
    FORD(i , n + m - 1 , 0)
        g[i] = mulmod(g[i + 1], i + 1);
    FOR(i , 1 , k)
        cin >> a[i].fi >> a[i].se;
    sort(a + 1 , a + 1 + k);
    FOR(i , 1 , k)
    {
        dp[i] = (C(a[i].fi + a[i].se - 2 , a[i].fi - 1));
        FOR(j , 1 , i - 1)
            if(a[j].fi <= a[i].fi && a[j].se <= a[i].se)
                addmod(dp[i] , mulmod(-dp[j] , C(a[i].fi - a[j].fi + a[i].se - a[j].se , a[i].fi - a[j].fi)));
    }
    ll res = C(n + m - 2 , n - 1);
    FOR(i , 1 , k)
        subtract(res , mulmod(dp[i] , C(n - a[i].fi + m - a[i].se , n - a[i].fi)));
    cout << res;
}


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

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

using namespace std;

/*long C(long n, long r){
    if(n < r) return 0;
    long p[n+1][n+1];
    p[0][0] = 1;
    for(int i = 1; i <= n; i++){
        p[i][0] = 1;
        p[i][i] = 1;
        for(int j = 1; j <= i-1; j++){
            p[i][j] = p[i-1][j] + p[i-1][j-1];
        }
    }
    return p[n][r];
}*/

 
void solve() {
    string s;
    cin >> s;
    int n = s.length();
    cout << s[0] << n-2 << s[n-1] << endl;
}
 
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    al = []
    bl = []
    for _ in range(n):
        a, b = map(int, input().split())
        al.append(a)
        bl.append(b)
    al.sort()
    bl.sort()
    if n%2:
        print(bl[n//2]-al[n//2]+1)
    else:
        print(bl[n//2]+bl[n//2-1]-al[n//2]-al[n//2-1]+1)

if __name__ == "__main__":
    main()

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    string ans = "Yes";
    for(int i=0; i<s.size(); i++)
    {
        if(i%2==0 && s.at(i) != 'h') ans = "No";
        else if(i%2==1 && s.at(i) != 'i') ans = "No";
    }
    if(s.length()%2==1) ans = "No";
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#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>;
using Graph = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    int h,w;
    cin>>h>>w;
    char maze[h][w];
    int w_cnt=0;
    rep(i,h){
        rep(j,w){
            cin>>maze[i][j];
            if(maze[i][j]=='.')w_cnt++;
            
        }
    }
    vector<vector<int>> dist(h,vector<int>(w,-1));
    dist[0][0]=0;

    queue<pair<int,int>>que;
    que.push(make_pair(0,0));

    while(!que.empty()){
        pair<int,int> current_pos=que.front();
        int y=current_pos.first;
        int x=current_pos.second;
        que.pop();

        rep(i,4){
            int next_x=x+dx[i];
            int next_y=y+dy[i];
            if(next_x<0||next_x>=w||next_y<0||next_y>=h)continue;
            if(maze[next_y][next_x]=='#')continue;

            if(dist[next_y][next_x]==-1){
                que.push(make_pair(next_y,next_x));
                dist[next_y][next_x]=dist[y][x]+1;
            }
        }
    }
    if(dist[h-1][w-1]==-1)cout<<-1<<endl;
    else cout<<w_cnt-dist[h-1][w-1]-1<<endl;


    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<tuple>
#include<ctime>
#include<functional>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p; 
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))

int main(){
    ll A,B,C,K,ans=0;
    cin>>A>>B>>C>>K;
    if(A>K){
        ans=K;
    }
    else if(A<=K && K<=A+B) ans=A;
    else if(A+B<K && A+B+C>K) ans=A-(K-A-B);

    else ans=A-C;

    p(ans);
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using ll = long long;
using  INT = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)

using namespace std;
/*........................................DEFINE FUNCTIONS.........................................*/


/*....................................DEFINE GLOBAL VARIABLES .....................................*/

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;
}



/*.........................................kemkemG0................................................*/
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N;
	cin >> N;

	VI A(N);
	REP(i, N)cin >> A[i];

	sort(ALL(A));
	int m = A[0];

	int mm=m;

	REP(i, N) {
		(A[i] % m != 0) ? chmin(m, A[i] % m) : 1;
	}

	if(mm==m){cout<<mm<<endl; return 0;}


	REP(aa, m + 2) {
		REP(i, N) {
			(A[i] % m != 0) ? chmin(m, A[i] % m) : 1;
		}
	}

	cout << m << endl;


















	return 0;
}













Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back

signed main(){
    int A,B,C,D;cin>>A>>B>>C>>D;
    string ans="";
    REP(i,C-A)ans+='R';
    REP(i,D-B)ans+='U';
    REP(i,C-A)ans+='L';
    REP(i,D-B)ans+='D';
    ans+='D';
    REP(i,C-A+1)ans+='R';
    REP(i,D-B+1)ans+='U';
    ans+='L';
    ans+='U';
    REP(i,C-A+1)ans+='L';
    REP(i,D-B+1)ans+='D';
    ans+='R';
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set> 
using namespace std;
int main(void){
    int a,b,k;
    std::cin >> a >>b >>k;
    std::set<int> st; 
    for (int i = a; i <= min(b,a+k-1); i++) {
        st.insert(i);
    }
    for (int i = max(b-k+1,a+k); i<=b; i++) {
        st.insert(i);
    }
    for (auto i : st) {
        std::cout << i << std::endl;
    }
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int H, A;
signed main() {
    cin >> H >> A;
    cout << (H + A - 1) / A << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,sum=0;
  cin>>n;
  vector<int> a(n+1),b(n+1),c(n);
  for(int i=1;i<=n;i++) cin>>a[i];
  for(int i=1;i<=n;i++) cin>>b[i];
  for(int i=1;i<n;i++) cin>>c[i];
  sum+=b[a[1]];
  for(int i=2;i<=n;i++){
    sum+=b[a[i]];
    if(a[i]==(a[i-1]+1)) sum+=c[a[i]-1];
  }
  cout<<sum<<"\n";
  return 0;
}
  
  

Measured memory_bytes: 256
N=int(input())
a=[0]*N
for i in range(N):
    a[i]=int(input())
flag=False
cnt=1
j=0
while flag==False and cnt<=N:
    if a[j]==2:
        flag=True
    else:
        j=a[j]-1
        cnt+=1
if flag==True:
    print(cnt)
else:
    print(-1)


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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    bool even=true;
    for(int i=0;i<n;i++){
        even&=(a[i]%2==0);
    }
    cout<<(even ? "second" : "first")<<endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	int x, y;
	cin >> x >> y;
	bool flag = false;
	if ((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)) flag = true;
	if ((x == 4 || x == 6 || x == 9 || x == 11) && (y == 4 || y == 6 || y == 9 || y == 11)) flag = true;
	if ((x == 2 ) && (y == 2)) flag = true;
	string S = (flag) ? "Yes" : "No";
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#define llint long long int
using namespace std;
int main(void){
	llint i,l,k,ans=0;cin>>l>>k;
	llint dp[201]={0};//brack end
	llint ddp[201]={0};//white end
	ddp[0]=1;
	for(i=0;i<=l;i++){
		dp[i+1]+=ddp[i];
		dp[i+k]+=ddp[i];
		ddp[i+1]+=dp[i];
		ans+=dp[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3120
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
for i in range(0,N):
    if A[i]>B[i]:
        ans+=B[i]
        A[i]-=B[i]
    else:
        ans+=A[i]
        B[i]-=A[i]
        A[i]=0
        if A[i+1]>B[i]:
            ans+=B[i]
            A[i+1]-=B[i]
        else:
            ans+=A[i+1]
            A[i+1]=0
print(ans)

Measured memory_bytes: 18476
// D - Integer Cards
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

	vector<pair<ll,int>> X;
	for(int n=N; n; --n){
		ll a; cin>>a;
		X.emplace_back(a,1);
	}
	while(M--){
		int b; ll c; cin>>b>>c;
		X.emplace_back(c,b);
	}
	sort(X.begin(), X.end());

	ll ans = 0;
	int end = X.size()-N-1;
	for(int i=end+N; i>=end && N>0; --i){
		int c = min(X[i].second, N);
		ans += X[i].first * c;
		N -= c;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 6256
#include<bits/stdc++.h>
using namespace std; 
char a[10010];
bool c,f;
int main() {
    cin>>a;
    for(int i=0;i<strlen(a);i++) {
        if(a[i]=='C') c=1;
        if(a[i]=='F'&&c==1) f=1;
    }
    if(f==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl; 
    return 0;
}

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

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	cout << (A - 1) * (B - 1) << endl;

	return 0;
}

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

constexpr int MAX_N = 8;

int N, A[3];
int l[MAX_N];

int dfs(int n, array<int, 3> a) {
  if (n == N) {
    int mp{};
    for (int i{}; i < 3; ++i) {
      if (a[i] == 0) {
        return 10000;
      }
      mp += abs(A[i] - a[i]);
    }
    mp -= 30;
    return mp;
  }

  int ret[4];
  for (int i{}; i < 3; ++i) {
    array<int, 3> na{a};
    na[i] += l[n];
    ret[i] = dfs(n + 1, na) + 10;
  }
  ret[3] = dfs(n + 1, a);
  sort(ret, ret + 4);

  return ret[0];
}

int main() {
  cin >> N;
  for (int i{}; i < 3; ++i)
    cin >> A[i];
  for (int i{}; i < N; ++i)
    cin >> l[i];

  array<int, 3> a{};
  cout << dfs(0, a) << endl;
  return 0;
}


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

using namespace std;

#define long long long
#define INF 2e18
#define MOD (long) (1e9 + 7)
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long n;
        cin >> n;

        vector<long> a(n);
        for (auto &x : a) {
            cin >> x;
        }
        long k = 0;
        for (long i = 0; i < n; i++) {
            if (a[i] == k+1) k++;
        }
        if (k == 0) {
            puts("-1");
            return 0;
        }
        long l = 1;
        long ans = 0;
        for (long i = 0; i < n; i++) {
            if (a[i] != l) ans++;
            else l++;
        }
        printf("%lld\n", ans);
    }
}


Measured memory_bytes: 4788
#include<stdio.h>

int main() {
	char s[1100];

	while(true) {
		scanf("%s",s);
		if(s[0] == '0')
			break;
		int sum = 0;

		for(int i = 0;s[i] != '\0';i++) {
			sum += s[i] - '0';
		}
		printf("%d\n",sum);
	}
}



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

int main(){
	while(1){
		int n,k;
		cin >> n >> k;
		if(n == 0) break;

		vector<int> a(k);
		for(int i=0; i<k; i++){
			cin >> a[i];
		}
		sort(a.begin(), a.end());

		vector<int> cons{0, 0};
		int curr=0, last=0;
		for(int i=(a[i]==0)?1:0; i<k; i++){
			if(a[i] == last+1){
				last = a[i];
				curr++;
				continue;
			}
			cons.push_back(curr);
			if(a[i] >= last+3){
				cons.push_back(0);
			}
			curr = 1;
			last = a[i];
		}
		cons.push_back(curr);

		if(a[0]!=0){
			cout << *max_element(cons.begin(), cons.end()) << endl;
		}else{
			int ans = 0;
			for(int i=0; i<(int)cons.size()-1; i++){
				ans = max(ans, cons[i]+cons[i+1]+1);
			}
			cout << ans << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3464
#include <iostream>
#include <algorithm>
#include <cstring>
#include <stdio.h>

using namespace std;
#define N_MAX 100000
long int N;
long int H;
long int b[N_MAX+1];

int comp(const void * a, const void *b){
	return *(long int*)b - *(long int*)a;
}

int main(void){
	//scanf ("%d %d\n", &N, &H);
	cin >> N >> H;
	long int a;
	long int max_a=0;
	for (long int i=0; i<N; i++){
		//scanf ("%d %d\n", &a, &b[i]);
		cin >> a >> b[i];
		max_a = max(max_a, a);
	}
	qsort((void * )b, N, sizeof(long int), comp);

	long int turn = 0;
	for (long int i=0; i<N; i++){
		if (max_a > b[i]) continue;
		H -= b[i];
		turn++;
		if (H <= 0){
			cout << turn << "\n";
			return 0;		
		}
	}
	cout <<turn + (H/ max_a) + (H%max_a==0 ? 0 : 1)  << "\n";
	return 0;
}

Measured memory_bytes: 1788
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

    P c[100010];
int main(){
    int N,M;
    cin>>N>>M;
    for(int i=0;i<N;i++){
        int a,b;
        cin>>a>>b;
        c[i]=make_pair(a,b);
    }
    sort(c,c+N);
    LL ans=0;
    int cnt=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<c[i].second;j++){
            ans+=c[i].first;
            cnt++;
            if(cnt>=M){
                cout<<ans;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1024
a,b,c,d,e,f = map(int,input().split())
a *= 100
b *= 100
den = -1
sugar = 0
water = 0
for i in range(0,f+1,a):
    for j in range(0,f-i+1,b):
        for k in range(0,f-i-j+1,c):
            for l in range(0,f-i-j-k+1,d):
                w = i+j
                s = k+l
                if w == 0: break
                if s/w > e/100: continue
                x = s/(w+s)
                if x > den:
                    den = x
                    water = w
                    sugar = s
        else:
            continue
        break
print(sugar+water,sugar)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
using vs= vector<string>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

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

  rep(i,0,s.size()){
    if(s[i]+n>'Z'){
      cout << (char)(s[i]+n-26);
    }else{
      cout << (char)(s[i]+n);
    }
  }

  return 0;
}


Measured memory_bytes: 256
a, b, c, d, e, f = map(int, input().split())
water = [False for _ in range(31)]
water[0] = True
for g in [a, b]:
    for i in range(31):
        if i - g < 0:
            continue
        elif water[i - g]:
            water[i] = True
            
salt = [False for _ in range(3001)]
salt[0] = True
for g in [c, d]:
    for i in range(3001):
        if i - g < 0:
            continue
        elif salt[i - g]:
            salt[i] = True

water_cand = []
for i, tf in enumerate(water):
    if tf:
        water_cand.append(i * 100)
salt_cand = []
for i, tf in enumerate(salt):
    if tf:
        salt_cand.append(i)
        
ans = [0, 0]
max_ratio = -1
for w in water_cand:
    if w == 0:
        continue
    for s in salt_cand:
        if w + s > f:
            break
        if w // 100 * e < s:
            break
        ratio = 100 * s / (w + s)
        if max_ratio < ratio:
            max_ratio = ratio
            ans = [w + s, s]
print(*ans)

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

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

#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = 5e5+10;

int main(){
fast;
char c;
cin>>c;
if(c>='A' and c<='Z') {
    cout<<"A"<<endl;
} else {
    cout<<"a"<<endl;
}
return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
constexpr int tv[]={-3,-1,1,3};
constexpr int p10[]={100000000,10000000,1000000,100000,10000,1000,100,10,1};
 
int main(){
    int h,v;
    string a="123456789",b="123456789";
    using data=pair<int,int>;
    
    while(cin>>h>>v, h or v){
        int tc[]={v,h,h,v};
        rep(i,9)cin>>a[i];
        rep(i,9)cin>>b[i];
        int sa=stoi("1"+a)-1000000000,sb=stoi("1"+b)-1000000000;

        unordered_map<int,int> s;

        priority_queue<data> q;
        q.emplace(0,sa);
        
        while(1){
            int cost=q.top().fs;
            int board=q.top().sc;
            if(board==sb){
                cout<<-cost<<endl;
                break;
            }
            q.pop();
            int index=to_string(board).find('0');
            if(index==-1)index=0;
            rep(i,4){
                int fixed=(index+tv[i]+9)%9;
                int next=board;
                int fx=next/p10[fixed]%10;
                next=next-p10[fixed]*fx+p10[index]*fx;
                if((s.find(next)==s.end() || s[next]<cost-tc[i]) && cost-tc[i]>-2000){
                    q.emplace(cost-tc[i], next);
                    s[next]=cost-tc[i];
                }
            }
        }
    }
}



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

struct Problem {

    void Solve() {
        UL A, B, C, D; cin >> A >> B >> C >> D;
        UL TA = (A - 1) / D + 1;
        UL TB = (C - 1) / B + 1;
        if (TA >= TB) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    //cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        int index;

        Scanner scan = new Scanner(System.in);
        index = Integer.valueOf(scan.next());
        int[] a = new int[index];
        int[] b =new int[index];
        int[] c =new int[index];

        for(int i=0;i<index;i++)
            a[i] = Integer.valueOf(scan.next());
        for(int i=0;i<index;i++)
            b[i] = Integer.valueOf(scan.next());
        for(int i=0;i<index-1;i++)
            c[i] = Integer.valueOf(scan.next());

        int answer= 0;
        for(int i=0;i<index;i++){
            answer += b[a[i] - 1];
            if(i != 0){
                if(a[i] == a[i-1]+ 1)
                    answer += c[a[i-1] - 1];
            }
        }
        System.out.println(answer);

    }
}


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

int main(){
	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"a < b"<<endl;
	}else if(a>b){
		cout<<"a > b"<<endl;
	}else{
		cout<<"a == b"<<endl;
	}
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  int day;
  if(S == "SUN"){
    day = 7;
  }
  else if(S == "MON"){
    day = 6;
  }
  else if(S == "TUE"){
    day = 5;
  }
  else if(S == "WED"){
    day = 4;
  }
  else if(S == "THU"){
    day = 3;
  }
  else if(S == "FRI"){
    day = 2;
  }
  else if(S == "SAT"){
    day = 1;
  }
  
  cout << day << endl;
}

Measured memory_bytes: 256
// -*- mode:c++; coding:utf-8; indent-tabs-mode:nil; -*-
// ALDS1_4-A: Linear Search

#include <cstdio>

static int linear_search(const int as[], const int target) {
  int i = 0;
  while (as[i] != target) {
    ++i;
  }
  return i;
}

int main(void) {
  int n;
  std::scanf("%d", &n);
  int ss[n+1]; // n+1(sentinel)
  for (auto i = 0; i < n; ++i) {
    std::scanf("%d", &ss[i]);
  }

  int q;
  std::scanf("%d", &q);
  int c = 0;
  for (auto i = 0; i < q; ++i) {
    int t;
    std::scanf("%d", &t);
    ss[n] = t; // sentinel
    auto j = linear_search(ss, t);
    if (j != n) ++c;
  }

  std::printf("%d\n", c);

  return 0;
}
// end

Measured memory_bytes: 2744
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int[] nums = new int[n];
		int[] maxLeft = new int[n];
		int[] maxRight = new int[n];
		// int[] res = new int[n];
		
		for (int i = 0; i < n; i++) {
			nums[i] = sc.nextInt();
			
			if (i == 0) {
			maxLeft[i] = nums[i];
			} else {
				maxLeft[i] = Math.max(maxLeft[i-1], nums[i]);
			}
		}
		// System.out.println(Arrays.toString(maxLeft));
		
		for (int i = n - 1; i >= 0; i--) {
			if (i == n - 1) {
				maxRight[i] = nums[i];
			} else {
				maxRight[i] = Math.max(maxRight[i+1], nums[i]);
			}
		}
		// System.out.println(Arrays.toString(maxRight));
		
		for (int i = 0; i < n; i++) {
			if (i == 0) {
				// res[i] = maxRight[1];
				System.out.print(maxRight[1] + " ");
			} else if (i == n - 1){
				// res[i] = maxLeft[i - 1];
				System.out.println(maxLeft[i - 1]);
			} else {
				//res[i] = Math.max(maxRight[i+1], maxLeft[i-1]);
				System.out.print(Math.max(maxRight[i+1], maxLeft[i-1]) + " ");
			}
		}
		
	}
	
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 65960
n = int(input())
s = input()

l = 0
r = n - 1
ans = 0
while r > l:

    while r > l:
        if s[l] == 'W': break
        else: l += 1
    while r > l:
        if s[r] == 'R': break
        else: r -= 1
    if r > l:
        ans += 1
        r -= 1
        l += 1
print(ans)

Measured memory_bytes: 9384
package main

import (
    "fmt"
    "strings"
)

func main() {
    var b []string = strings.Split(scanString(), "")
    var a []string = []string{}
    for _, v := range b {
        switch v {
            case "A":
            a = append(a, "T")
            case "T":
            a = append(a, "A")
            case "C":
            a = append(a, "G")
            case "G":
            a = append(a, "C")
        }
    }
    fmt.Println(strings.Join(a, ""))
}

func scanInt() (num int) {
    fmt.Scan(&num)
    return
}

func scanInts(len int) (nums []int) {
    var num int
    for i := 0; i < len; i++ {
        fmt.Scan(&num)
        nums = append(nums, num)
    }
    return
}

func scanString() (str string) {
    fmt.Scan(&str)
    return
}

func scanStrings(len int) (strs []string) {
    var str string
    for i := 0; i < len; i++ {
        fmt.Scan(&str)
        strs = append(strs, str)
    }
    return
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
//---------------------------------------------------------------------------------------------------

int main(void){
    // Your code here!
    string O,E; cin >> O >> E;
    string ans = "";
    rep(i,O.size()+E.size()) {
        if (i % 2 ==0) {
            ans += O[i/2];
        } else ans += E[i/2];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3596