akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
deque<int> deq;
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

char s[305][305];
int d[305];
int a[305][305];

int main(){
    int h,w,k;
    cin >> h>> w>>k;
    rep(i,h){
        rep(j,w){
            cin >> s[i][j];
            if(s[i][j]=='#'){
                d[j]++;
            }
        }
    }
    int temp=1;
    int c=0;
    rep(i,w){
        if(d[i]>0){
            rep(j,h){
                if(s[j][i]=='#'){
                    c++;
                    if(c<=1){
                        a[j][i]=temp;
                    }else{
                        temp++;
                        a[j][i]=temp;
                    }
                }else{
                    a[j][i]=temp;
                }
            }
            c=0;
        }else{
            if(i==0){
                rep(j,h){
                    a[j][i]=-1;
                }
                temp--;
            }else{
                if(a[0][i-1]==-1){
                    rep(j,h){
                        a[j][i]=-1;
                    }
                    temp--;
                }else{
                    rep(j,h){
                        a[j][i]=a[j][i-1];
                    }
                    temp--;
                }
            }
        }
        temp++;
    }
    rep(i,h){
        rep(j,w){
            cerr<<a[i][j]<<' ';
        }
        cerr<<endl;
    }
    cerr<<endl;
    rep(i,w){
        rep(j,h){
            if(a[j][w-i-1]==-1){
                a[j][w-i-1]=a[j][w-i];
            }
        }
    }
    rep(i,h){
        rep(j,w){
            cout<<a[i][j]<<' ';
        }
        cout<<endl;
    }
    return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

#define MOD 1000000007

int main(){
  int n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  LL ans=1;
  int i=1;
  if(s[0]==t[0]) ans=3;
  else{
    ans=6;
    i++;
  }
  for(;i<n;i++){
    if(s[i]==t[i]){
      if(s[i-1]==t[i-1]) ans=ans*2%MOD;
    }else{
      if(s[i-1]==t[i-1]) ans=ans*2%MOD;
      else ans=ans*3%MOD;
      i++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define E endl
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);
     
int main()
{
	ll x,n;
	cin>>x>>n;
	if(x<n)
	cout<<"0";
	else
	cout<<"10";
}

Measured memory_bytes: 256
import java.util.*;

public class Main {


    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = sc.nextInt();
        }

        int q = sc.nextInt();
        int[] mArr = new int[q];
        for (int i = 0; i < mArr.length; i++) {
            mArr[i] = sc.nextInt();
        }

        for (int m : mArr) {
            System.out.println(solve(arr, 0, m) ? "yes" : "no");
        }

    }

    // i番目以降の配列を使って、mを作る
    static boolean solve(int[] arr, int i, int m) {
        if (i == arr.length - 1) {
            return arr[i] == m || m == 0;
        }
        return solve(arr, i + 1, m) || solve(arr, i + 1, m - arr[i]);
    }

}


Measured memory_bytes: 26792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define ln "\n"
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define ppll pair<ll,pll>
#define vll vector<ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define sll stack<ll>
#define qll queue<ll>
#define pqll priority_queue<ll>
#define mp make_pair
#define f first
#define s second
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define Test ll tt;cin>>tt; while(tt--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define init(x,n,v) for(ll i=0;i<=n;i++) x[i]=v
#define scan(x,n)  for(ll i=0;i<n;i++) cin>>x[i]
#define scan1(x,n) for(ll i=1;i<=n;i++) cin>>x[i]
#define all(x) x.begin(),x.end()
ll mod = 1e9+7;
#define N 300005

int main() 
{
	fast_io;
	// Test
    ll n,i,k,j;
    cin>>n>>k;
    ll arr[n],dp[n];
    scan(arr,n); init(dp,n-1,1e9);
    dp[0]=0;
    for(i=1;i<n;i++)
      for(j=1;j<=k&&i-j>=0;j++)
       dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
    cout<<dp[n-1];
	return 0;
}

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

const int INF = 1000;

int main() {
  int N, sum, min_m, X, store, max_donut;
  int m[100];
  sum = 0;
  min_m = INF;
  cin >> N >> X;
  for (int i = 0; i < N; i++) {
    cin >> m[i];
    sum += m[i];
    if (m[i] < min_m) min_m = m[i];
  }
  store = X - sum;
  max_donut = store / min_m + N;
  cout << max_donut << endl;
}

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

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    for(int i=0; i<N; i++) {
        cin >> x[i];
    }

    int ans = numeric_limits<int>::max();
    for(int i=0; i+K-1<N; i++) {
        if(x[i] <= 0 && x[i+K-1] <= 0 || x[i] >= 0 && x[i+K-1] >= 0) {
            ans = min(ans, max(abs(x[i]), abs(x[i+K-1])));
        } else {
            ans = min(ans, max(abs(x[i]), abs(x[i+K-1])) + 2*min(abs(x[i]), abs(x[i+K-1])));
        }
    }

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


Measured memory_bytes: 640
extern crate core;

use std::io::{self, Read};

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input.trim().to_string());
    println!("{}", output);
}

fn max_v(start: f64, end: f64, v: f64, now: f64) -> f64 {
    if now < start {
        let d = start - now;
        v + d
    } else if end < now {
        let d = now - end;
        v + d
    } else {
        v
    }
}

fn run(input: String) -> String {
    let mut iter = input.split("\n");
    iter.next();
    let ts = iter.next()
        .unwrap()
        .split_whitespace()
        .map(|x| x.parse::<f64>().unwrap())
        .collect::<Vec<_>>();

    let vs = iter.next()
        .unwrap()
        .split_whitespace()
        .map(|x| x.parse::<f64>().unwrap())
        .collect::<Vec<_>>();

    //(t,v)
    let mut list = ts.clone().into_iter().zip(vs).collect::<Vec<_>>();

    //(start,end,v)
    let mut vec = Vec::new();
    let mut time_sum = 0.0;
    for (t, v) in list {
        vec.push((time_sum, time_sum + t, v));
        time_sum += t;
    }
    vec.push((0.0, 0.0, 0.0));
    vec.push((time_sum, time_sum, 0.0));

    //0.5sごとの瞬間の速度
    let mut v_list = Vec::new();
    for t in 0..time_sum.round() as i32 + 1 {
        for t in vec![t as f64, t as f64 + 0.5] {
            let min = vec.clone()
                .into_iter()
                .map(|x| max_v(x.0, x.1, x.2, t))
                .fold(0.0 / 0.0, f64::min);
            v_list.push(min);
        }
    }

    //0.5sごとの平均の速度
    let mut v_list2 = Vec::new();
    for i in 0..v_list.len() - 1 {
        v_list2.push((v_list[i] + v_list[i + 1]) / 2.0);
    }

    //平均の速度の合計を2で割る
    ((v_list2.into_iter().sum::<f64>() / 2.0) - 0.125).to_string()
}

fn round025(x: f64) -> f64 {
    (x * 4.0).round() / 4.0
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!(super::run($input.to_string()), $output.to_string());
                }
            )*
        }
    }
}

tests! {
    test1: "1
100
30" => "2100",
    test2: "2
60 50
34 38" => "2632",
    test3: "3
12 14 2
6 2 7" => "76",
    test4: "1
9
10" => "20.25",
    test5: "10
64 55 27 35 76 119 7 18 49 100
29 19 31 39 27 48 41 87 55 70" => "20291",
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    if(K%2 == 0) cout << A-B << endl;
    else cout << B-A << endl;
}

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

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  int max = A*10 + B + C;
  max = (B*10+A+C > max ? B*10+A+C : max);
  max = (C*10+A+B > max ? C*10+A+B : max);
  
  cout << max << endl;
  
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = b[a[0]-1]
for i in range(1, n):
    ans += b[a[i]-1]
    if a[i-1] + 1 == a[i]:
        ans += c[a[i-1]-1]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
    #include <sstream>
    #include <iomanip>
    #include <cstdio>
    #include <cstdlib>
    #include <cmath>
    #include <cctype>
    #include <cstring>
    #include <vector>
    #include <list>
    #include <queue>
    #include <deque>
    #include <stack>
    #include <map>
    #include <set>
    #include <algorithm>
    #include <iterator>
    #include <bitset>
    #include <ctime>



    using namespace std;

    #define FOR(i,a,b) for(int i = (a); i < (b); i++)
    #define rep(i,n) FOR(i,0,n)
    #define RFOR(i,b,a) for(int i = (b) - 1; i>= (a); i--)
    #define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
    #define FILL(a, value) memset(a, value, sizeof(a)

    #define SZ(a) (int)a.size()
    #define ALL(a) a.begin(), a.end()
    #define PB push_back
    #define MP make_pair

    typedef  long long LL;
    typedef vector<int> VI;
    typedef pair<int, int> PII;

    const double PI = acos(-1.0);
    const int INF = 1000 * 1000 * 1000 + 7;
    const LL LINF = INF * (LL)INF;

    const double EPS = 1e-7;
    const int MAX = 20 * 1000 + 47;
    const int MAS = 1e5 * 3;
    const int MOD = 1000 * 1000 * 1000 + 7;

    double DIST(double x1, double x2, double y1, double y2)
    {
        return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
    }
    


    int main()
    {
        int n; 
        cin >> n; 
        vector<double >  dp(n + 1);   
        dp[0] = 1;
        rep(i, n)
        {
            double x;
            cin >> x;
            for(int j = i + 1; j >= 0 ; j-- )
            {
                dp[j] = (j == 0 ? 0 : dp[j - 1] * x) + dp[j] * (1 - x); 
            }
        }
        double ans = 0; 
        rep(i, n + 1)
        {
            int b = n - i;
            if (i > b)
            {
                ans += dp[i]; 
            }
        }
        cout << fixed << setprecision(10) << ans << endl;

    }










Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int N, K; cin >> N >> K;
    vector<int> count(N);
    for (int i = 0; i < N; i++) {
        int a; cin >> a; a--;
        count[a]++;
    }
    sort(count.rbegin(), count.rend());
    int num = 0;
    for (int i = 0; i < K; i++) {
        num += count[i];
    }
    cout << N - num << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3932
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;

#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()

typedef long long ll;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int a, b, c;
    cin >>  a >> b >> c;
    a += b + c;
    if (a >= 22) {
        cout << "bust";
    } else {
        cout << "win";
    }

    return 0;
}


Measured memory_bytes: 892
n,t=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(n)]
arr=sorted(arr,key=lambda x:x[1])
arr=sorted(arr,key=lambda x:x[0])
dp=[[0]*3001 for _ in range(n+1)]
maxs=[0]
for i in range(n-2,-1,-1):
  maxs.append(max(maxs[-1],arr[i+1][1]))
maxs=maxs[::-1]
for i in range(n):
  a,b=arr[i]
  for j in range(t):
    if j-a<0:
      continue
    dp[i+1][j]=max(dp[i][j],dp[i][j-a]+b)
  dp[i+1][a]=max(dp[i][a],b)
ans=0
for i in range(n):
  tmp=max(dp[i+1][:t])+maxs[i]
  ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 121944
/*input
101
86
119
108
57
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}




int main()
{
	IOS;
	int a[5];
	REP(i,5) cin>>a[i];
	int ans=0;
	REP(i,5) ans+=(a[i]-1)/10*10+10;
	REP(i,5) a[i]%=10,a[i]+=(a[i]==0)*10;

	ans-=10-*min_element(a,a+5);
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
N = int(input())
W = tuple(map(int, input().split()))
total1 = W[0]
total2 = sum(W[1:])
ans = abs(total2 - total1)
for i in range(1, N):
    total1 += W[i]
    total2 -= W[i]
    ans = min(ans, abs(total2 - total1))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define For(i,n) for(int i=0; i<n; i++)
#define M0D 1000000007
using namespace std;

int main(){

  long long N,K;
  long long num=0, numnum=0;
  long long ans=0;
  cin >> N >> K;
  int A[N];
  For(i, N) cin >> A[i];

  For(i, N) for(int j=i+1; j<N; j++){
    if(A[i]>A[j]) num++;
  }
  ans += num*K;
  ans %= M0D;

  num = 0;
  sort(A, A+N);
  For(i, N) For(j, i) if(A[i]>A[j]) num++;
  ans += (K*(K-1)/2)%M0D*num;
  cout << ans%M0D << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
from operator import itemgetter

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    n = ii()

    ac = 0
    wa = 0
    tle = 0
    re = 0
    for s in [input().rstrip() for _ in range(n)]:
        if s == "AC":
            ac += 1
        elif s == "WA":
            wa += 1
        elif s == "TLE":
            tle += 1
        else:
            re += 1
    
    print("AC x", ac)
    print("WA x", wa)
    print("TLE x", tle)
    print("RE x", re)

    return

main()


Measured memory_bytes: 16308
import java.util.*;
	import java.lang.Math;
    public class Main 
	{
		public static void main(String args[])
		{
			Scanner scan = new Scanner(System.in);
			String a = scan.next();
			String b = scan.next();
			String c=b.concat(a);
			//char array[]=c.toCharArray();
			//Arrays.sort(array);
			System.out.println(c);
		}
    }

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

int main() {
  int H, W;
  scanf("%d%d", &H, &W);

  string grid[50];
  for (int i = 0; i < H; i++) {
    cin >> grid[i];
  }
  // 8方向探索時のx, yの変化量を定義しておく
  const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (grid[i][j] == '#') {
        continue;
      }

      int num = 0;
      for (int d = 0; d < 8; d++) {
        const int next_i = i + dy[d];
        const int next_j = j + dx[d];
        // ボード外は探索しない
        if (next_i < 0 or H <= next_i) continue;
        if (next_j < 0 or W <= next_j) continue;
        if (grid[next_i][next_j] == '#') num++;
      }
      grid[i][j] = char(num + '0');
    }
  }

  for (int i = 0; i < H; i++) {
    cout << grid[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 256
a = list(map(int,input().split()))

if a[0] == 1 and a[1] == 1:
  print("Draw")
  
elif a[0] == 1 or a[1] == 1:
  if a[0] == 1:
    print("Alice")
  elif a[1] == 1:
    print("Bob")
    
else:
  if a[0] == a[1]:
    print("Draw")
  elif a[0] > a[1]:
    print("Alice")
  else:
    print("Bob")

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

using namespace std;

const int MAXN=1<<22;
const int MOD=1e9+7;
int dp[MAXN];
int n;
bool ok[32][32];

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>ok[i][j];
		}
	}
	
	dp[0]=1;
	for(int i=1;i<(1<<n);i++){
		for(int j=0;j<n;j++){
			int now=__builtin_popcount(i)-1;
			if((i&(1<<j))&&ok[now][j]){
				dp[i]=(dp[i]+dp[i^(1<<j)])%MOD;
			}
		}
	}
	cout<<dp[(1<<n)-1]<<endl;
	return 0;
}
 

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

int main() {
    int n;
    while(cin >> n, n) {
      vector<int> v;
      while(n--) {
	int t; cin >> t;
	v.push_back(t);
      }

      sort(v.begin(), v.end());

      long long sum = 0, ans = 0;
      for(int i = 0; i < v.size(); i++) {
	ans += sum;
	sum += v[i];
      }
      cout << ans << endl;
    }
}

Measured memory_bytes: 1320
/*    特徴    */

/*    教訓    */

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

#define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

// -------- template end - //


// - library ------------- //

template<typename T>
void ms_eraseone(multiset<T> &ms, T key){
  auto it = ms.find(key);
  if (it != ms.end()) ms.erase(it);
}

// --------- library end - //


int main(){

  string X = is();
  ll s = 0;
  ll d = 0;
  for (char c : X){
    if (c =='S') s++;
    else if (s) s--, d++;
  }
  cout << X.size() - d - d << endl;


  
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    string A, B;
    cin >> A >> B;
    int N = stoi( A + B );
    int M = sqrt( N );
    cout << ( M * M == N ? "Yes" : "No" ) << endl;
    return 0;
}

Measured memory_bytes: 256
A, B, H, M = list(map(int, input().split()))


s = M / 60
t = H + s
u = t / 12  # 全体を１としたときの長針の位置

v = M / 60

w = abs(u-v) * 360

import math
cos = math.cos(math.radians(w))
# print(cos)
ans = math.sqrt((A ** 2) + (B ** 2) - 2 * A * B * cos)

# print(u, v, w)
print(ans)


Measured memory_bytes: 9564
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<int> n(N + 1, 0);
  for (int x = 1; x <= 100; x++)
  {
    for (int y = 1; y <= 100; y++)
    {
      for (int z = 1; z <= 100; z++)
      {
        long long ans = x * x + y * y + z * z + x * y + y * z + z * x;
        if (ans <= N)
        {
          n[ans]++;
        }
      }
    }
  }

  for (int i = 1; i < n.size(); i++)
  {
    cout << n[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3572
#include<stdio.h>
int main(){
    char S[3+1];
    scanf("%s",S);
    if((S[0]=='A')&&(S[1]=='B')&&(S[2]=='C')){
        printf("ARC\n");
    }else if((S[0]=='A')&&(S[1]=='R')&&(S[2]=='C')){
        printf("ABC\n");
    }
}

Measured memory_bytes: 1644
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

int main(){
  int n = in();
  int m = in();
  string str;
  in(str);
  foreach(i,str)i-='0';
  vector<int> dp(n+1,false);
  dp[0]=true;
  {
    int cnt = 1;
    rep(i,1,n+1){
      if(!str[i] and cnt){
        dp[i]=true;
        ++cnt;
      }
      if(i>=m and dp[i-m])--cnt;
    }
  }
  if(!dp[n]){
    cout << -1 << endl;
    return 0;
  }
  vector<int> ans;
  int pos = n;
  while(pos){
    rep(i,max(0,pos-m),n){
      if(dp[i]){
        ans.push_back(pos-i);
        pos = i;
        break;
      }
    }
  }
  reverse(all(ans));
  foreach(i,ans){
    output(i);
  }
  outendl();
  return 0;
}


Measured memory_bytes: 1528
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		String[] a = scanner.next().split("");
		String[] b = scanner.next().split("");
		
		scanner.close();
		
		int result = 0;
		
		for (int i = 0; i < a.length; i++) {
			
			if (a[i].equals(b[i])) {
				
			} else {
				result++;
			}
		}
		
		System.out.println(result);
	}

}


Measured memory_bytes: 57560
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
struct poi{
  int X;int Y;int Z;
  bool operator<(const poi&R)const{
    return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
  }
};
/*
ll GCD(ll A,ll B){
  return (B==0)?(A):(GCD(B,A%B));
}
ll LCM(ll A,ll B){
  return A/GCD(A,B)*B;
}
*/
int main(){
	int N,K;
	ll X[50],Y[50];
	vector<pair<ll,ll> > Z;
	cin>>N>>K;
	FOR(i,0,N){
		cin>>X[i]>>Y[i];
		Z.PB(MA(X[i],Y[i]));
	}
	sort(X,X+N);
	sort(Y,Y+N);
	ll ans=-1;
	FOR(i,0,N){
		FOR(j,i+1,N){
			FOR(k,0,N){
				FOR(l,k+1,N){
					ll xl=X[i],xr=X[j];
					ll yl=Y[k],yr=Y[l];
					int cnt=0;
					FOR(m,0,N){
						if(xl<=Z[m].FI&&Z[m].FI<=xr){
							if(yl<=Z[m].SE&&Z[m].SE<=yr){
								cnt++;
							}
						}
					}
					if(cnt>=K){
                      if(ans==-1){
                        ans=abs(xl-xr)*abs(yl-yr);
                      }else{
						ans=min(ans,(ll)abs(xl-xr)*abs(yl-yr));
                      }
					}
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,=pin()
    temp=1
    for a in sorted(pin()):
        temp*=a
        if temp>10**18:
            print(-1)
            return
    print(temp)
#%%submit!
resolve()


Measured memory_bytes: 84744
import java.util.Scanner;

public class Main{
		
	public static void main(String args[]){
		  
	    Scanner sc = new Scanner(System.in);
	    
	    int n = sc.nextInt();
	    int a[] = new int[n];
	    int ri[] = new int[n];
	    int le[] = new int[n];
	    
	    for(int i = 0; i < n; i++) {
	    	a[i] = sc.nextInt();
	    }
	    
	    int ans = 0;
	    le[0] = 0;
	    for(int i = 1; i < n; i++) {
	    	le[i] = gcd(le[i-1], a[i-1]);
	    }
	    
	    ri[n-1] = 0;
	    for(int i = n-2; i >= 0; i--) {
	    	ri[i] = gcd(ri[i+1], a[i+1]);
	    }
	    
	    for(int i = 0; i < n; i++) {
	    	ans  = Math.max(ans, gcd(le[i], ri[i]));
	    }
	    
	    System.out.println(ans);
	}
	  
	public static int gcd(int n, int m) {
		if(m == 0) {
			return n;
		}else {
			return gcd(m, n%m);
		}
	}
}

Measured memory_bytes: 50288
#include<stdio.h>

#define WHITE 1
#define GRAY 2
#define BLACK 3

int d[101],f[101],time=0,colar[101],M[101][101],n;

void visit(int u){
  int v;

  colar[u]=GRAY;
  d[u]=++time;

  for(v=1;v<=n;v++){
    if(M[u][v]==0)continue;
    if(colar[v]==WHITE)
      visit(v);
  }
  colar[u]=BLACK;
  f[u]=++time;
}

int main(){
  int i,j,k,u,v;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    colar[i]=WHITE;
    for(j=1;j<=n;j++){
      M[i][j]=0;
    }
  }

  for(i=1;i<=n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    if(k==0)continue;
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      M[u][v]=1;
    }
  }

  for(u=1;u<=n;u++){
    if(colar[u]==WHITE)
      visit(u);
  }

  for(u=1;u<=n;u++){
    printf("%d %d %d\n",u,d[u],f[u]);
  }

  return 0;
}



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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
// using Graph = vector<vector<int>>;

struct edge {
    int from, to, cost, cost2;
    edge(){}
    edge(int _from, int _to, int _cost, int _cost2)
    : from(_from), to(_to), cost(_cost), cost2(_cost2) {}
    bool operator> (const edge& e) const {
        if (cost2 != e.cost2)   return cost2 > e.cost2;
        if (cost != e.cost)     return cost > e.cost;
        if (to != e.to)         return to > e.to;
        return from > e.from;
    }
};
using Graph = vector<vector<edge>>;

// undirected
void addEdge(Graph& G, int x, int y, int c, int c2) {
    G[x].emplace_back(x, y, c, c2);
    G[y].emplace_back(y, x, c, c2);
}
vi dijkstra(const Graph& G, int s, int g) {
    int n = G.size();
    using State = pair<int, int>;
    priority_queue<State, vector<State>, greater<State>> pq;   // cost, vertex
    vector<int> d(n, inf);
    d[s] = 0;
    pq.push(State(0, s));

    while (!pq.empty()) {
        auto p = pq.top(); pq.pop();
        int v = p.second;
        if (v == g) break;
        if (d[v] < p.first) continue;
        for (const auto& e : G[v]) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                pq.push(State(d[e.to], e.to));
            }
        }
    }
    return d;
}

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

    int n, m;
    while (cin >> n >> m, n) {
        Graph G(n);
        rep(i, m) {
            int u, v, d, c;
            cin >> u >> v >> d >> c;
            u--, v--;
            addEdge(G, u, v, d, c);
        }

        auto d = dijkstra(G, 0, -1);
        int ans = 0;
        rep2(i, 1, n) {
            int mi = inf;
            for (const auto& e : G[i]) {
                if (d[i] == d[e.to] + e.cost) {
                    chmin(mi, e.cost2);
                }
            }
            ans += mi;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 5204
#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>;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
int main() {
    ll n, k; cin >> n >> k;
    combination c(200005);
    mint ans = 0;
    for(ll i=k;i<=n+1;i++) {
        ll left = (n)*(n+1)/2 - (n-i)*(n+1-i)/2;
        ll right = i*(i-1)/2;
        //printf("l:%lld r:%lld\n", left, right);
        ans += left - right+ 1;
    }
    cout << ans.x;
}


Measured memory_bytes: 6428
public class Main {


  private static void solve() {
    char[] s = ns();
    for (int i = 0; i < s.length - 1; i ++) {
      if (s[i] == s[i + 1]) {
        System.out.println("Bad");
        return;
      }
    }
    System.out.println("Good");
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 23124
n ,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
point = [k-q]*n
for i in range(q):
    point[a[i]-1] += 1
for j in range(n):
    if point[j] > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 15344
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define eb emplace_back
#define mkp make_pair
#define MOD 100000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;	cin>>k;
  	cout<<a[k-1];
}

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

using namespace std;

const int maxn = 30;

char s[maxn];

string t = "YAKI";

bool f()
{
	for(int i=0;i<4;i++)
		if(s[i]!=t[i])
			return 0;
	return 1;
}
int main()
{
	scanf("%s", s);
	if(f())
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn =1e6+10;
const int mod=1e9+7;
vector<vector<int>>d(maxn);
int h,w,k;
string s[maxn];
int sx,sy,ex,ey;
int xx[5]={58,0,0,1,-1};
int yy[5]={58,1,-1,0,0};

void bfs()
{
    queue<pair<int,int>>q;
    q.push({sx,sy});
    d[sx][sy]=0;
    while(!q.empty())
    {
        int x=q.front().first;
        int y=q.front().second;
        if(x==ex&&y==ey)
        {
            return;
        }
        q.pop();
        for(int i=1;i<=4;i++)
        {
            for(int j=0;j<k;j++)
            {
                int tx=xx[i]+x;
                int ty=yy[i]+y;
                if(i==1)
                    ty+=j;
                if(i==2)
                    ty-=j;
                if(i==3)
                    tx+=j;
                if(i==4)
                    tx-=j;
                if(tx<0||ty<0||tx>h-1||ty>w-1||s[tx][ty]=='@'||d[tx][ty]<d[x][y]+1)
                {
                    break;
                }
                if(d[tx][ty]>d[x][y]+1) //同样长的话不能走 否则TLE
                {
                    d[tx][ty]=d[x][y]+1;
                    q.push({tx,ty});
                }
            }
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>h>>w>>k;
    cin>>sx>>sy>>ex>>ey;
    sx--,sy--,ex--,ey--;
    for(int i=0;i<h;i++)
        cin>>s[i];
    int g=1e9;
    for(int i=0;i<h+5;i++)
    {
        for(int j=0;j<w+5;j++)
        {
            d[i].pb(g);
        }
    }
    bfs();
    if(d[ex][ey]==1e9)
    {
        cout<<-1<<'\n';
    }
    else
        cout<<d[ex][ey]<<'\n';





}


Measured memory_bytes: 84484
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    

    class Program
    {
        
        
        
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] p_ary = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int dif_cnt = 0;

            for(int i = 0; i < N; i++)
            {
                if(p_ary[i] != i + 1)
                {
                    dif_cnt++;
                }
            }
            
            if(dif_cnt <= 2)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }

        }
    }
}

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

int main()
{
	int n;
	cin >> n;
	int arr[n];
	for(int i=0;i<n;i++)arr[i] = i;
	pair<int,int>co[n];
	for(int i=0;i<n;i++){
		cin >> co[i].first >> co[i].second;
	}
	double sum = 0.0;
	do{
		double temp = 0.0;
		for(int i=1;i<n;i++){
			int a = arr[i-1];
			int b = arr[i];
			double t1 = co[b].first-co[a].first;
			double t2 = co[b].second-co[a].second;
			double t = t1*t1+t2*t2;
			temp += sqrt(t);
		}
		sum += temp;
	}while(next_permutation(arr,arr+n));
	int mult = 1;
	for(int i=1;i<=n;i++){
		mult *= i;
	}
	printf("%.10lf\n",sum/mult);
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Restaurant[] restAry = new Restaurant[n];
		for(int i = 0; i < n; i++){
			String s = sc.next();
			int p = sc.nextInt();
			restAry[i] = new Restaurant(i + 1, s, p);
		}
		Arrays.sort(restAry);
		for(Restaurant rest : restAry){
			rest.printNum();
		}
	}
}
class Restaurant implements  Comparable<Restaurant>{
	int num;
	String cityName;
	int point;
	Restaurant(int n, String s, int p){
		num = n;
		cityName = s;
		point = p;
	}
	@Override
	public int compareTo(Restaurant rest) {
		int ret = this.cityName.compareTo(rest.cityName);
		if(ret != 0){
			return ret;
		}
		return Integer.compare(this.point, rest.point) * -1;
	}
	void printNum(){
		System.out.println(this.num);
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> cnt(n+1,0);
    vector<int> a(n+1);
    repr(i,1,n+1){cin>>a.at(i);}
    repr(i,1,n+1){
        cnt[a[i]]=cnt[a.at(i)-1]+1;
    }
    int res = 0;
    rep(i,n+1){res = max(res,cnt[i]);}
    cout << n-res << endl;
    return 0;
}


Measured memory_bytes: 1792
def isprime(n):
    from math import floor,sqrt
    if n <= 1:
        return False
    for i in range(2,floor(sqrt(n))+1):
        if n % i == 0:
            return False
    return True

n = int(input())
ans = []
for i in range(n):
    po = int(input())
    if isprime(po):
        ans.append(po)  
print(len(ans))


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

using namespace std;

bool check(const string& s, const string& t) {
    unordered_map<char, int> sHash, tHash;
    int index = 0;
    for (int i = 0; i < s.length(); ++i) {
        if (sHash.find(s[i]) != sHash.end()) {
            if (tHash.find(t[i]) == tHash.end()) {
                return false;
            } else {
                if (sHash[s[i]] != tHash[t[i]]) {
                    return false;
                }
            } 
        } else {
            if (tHash.find(t[i]) != tHash.end()) {
                return false;
            } else {
                sHash[s[i]] = tHash[t[i]] = index++;
            }
        }
    }
    return true;
}

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

    string s, t;
    cin >> s >> t;
    if (check(s, t)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
const double PI = acos(-1);

typedef complex<double> Point;
typedef vector<Point> VP;

int main(void){
    int n;
    cin >> n;
    VP ps(n);
    rep(i,n){
        double x,y;
        cin >> x >> y;
        ps[i] = Point(x,y);
    }
    double M = 1000;
    double res = 0;
    rep(i,M){
        Point inf = polar(1e9, 2.0*PI*(i/M));
        VP used;
        Point p(0,0);
        rep(j,n){
            if (abs(ps[j]-inf) < 1e9) {
                p += ps[j];
            }
        }
        res = max(res, abs(p));
    }
    printf("%.20f\n", res);
    return 0;
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())

# a + b < c
# a + 2ab + b < c
# 2ab < c - a - b
# if c - a - b < 0 
# 

if c - a - b < 0:
    print("No")
    exit()

if 4 * a * b < (c - a- b) ** 2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int b;
  cin >> a >> b;
  int x;
  x = (a+b)/2;
  double X;
  double A = a;
  double B = b;
  X = (A+B)/2;
   
  double different;
  different = X - x;
  
  double plus;
  plus = different *2;
    
  cout << x+plus << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  int S;
  int h, m, s;

  scanf("%d", &S);
  h = S/3600;
  m = (S/60) % 60;
  s = S % 60;
  printf("%d:%d:%d\n", h, m, s);

  return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
#include <numeric>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l

int gcd(int a, int b) {
	if (a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int main() {
	int a, b, t;
	cin >> a >> b >> t;
	cout << (t / a)*b << endl;
	cin >> t;

}

Measured memory_bytes: 256
unittest
{
	assert( [ "2", "2", "2", "100" ].parse.expand.solve == 2 );
	assert( [ "5", "1", "0", "150" ].parse.expand.solve == 0 );
	assert( [ "30", "40", "50", "6000" ].parse.expand.solve == 213 );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto a = input.front.strip.to!( long );
	input.popFront;
	auto b = input.front.strip.to!( long );
	input.popFront;
	auto c = input.front.strip.to!( long );
	input.popFront;
	auto x = input.front.strip.to!( long );
	return tuple( a, b, c, x );
}

auto solve( long a, long b, long c, long x )
{
	auto r = 0L;
	
	auto am = a * 500;
	auto bm = b * 100;
	auto cm = c * 50;
	
	for( auto ai = 0; ai <= am && ai <= x; ai += 500 )
	{
		if( ai + bm + cm < x ) continue; 
		
		for( auto bi = 0; bi <= bm && ai + bi <= x; bi += 100 )
		{
			if( ai + bi + cm < x ) continue; 
			r++;
		}
	}
	
	return r;
}


Measured memory_bytes: 256