akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <iomanip>
using namespace std;

int N,M,S,G;

struct state{
    int node,velocity;
    double ti;
    int pre_node;
    bool operator<(const state& right)const{
        return ti>right.ti;
    }
};

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

double dp[31][31][31];
double inf = 1e9;

int main(){
    while(cin >> N >> M && N>0){
        cin >> S >> G;
        vector<vector<edge>> v(N+1);
        int x,y,d,c;
        for(int i=0;i<M;i++){
            cin >> x >> y >> d >> c;
            v[x].push_back({y,d,c});
            v[y].push_back({x,d,c});
        }
        for(int i=1;i<=N;i++) for(int j=1;j<=30;j++) for(int k=1;k<=N;k++) dp[i][j][k] = inf;
        dp[S][1][0] = 0;
        priority_queue<state> Q;
        Q.push({S,0,0,0});
        while(!Q.empty()){
            state now = Q.top(); Q.pop();
            if(dp[now.node][now.velocity][now.pre_node]<now.ti) continue;
            for(auto& x:v[now.node]){
                if(now.pre_node==x.to) continue;
                for(int dv=-1;dv<=1;dv++){
                    if(now.velocity+dv<=0 || now.velocity+dv>x.upp) continue;
                    state ne;
                    ne.node = x.to; ne.velocity = now.velocity+dv;
                    ne.ti = now.ti+1.0*x.dist/ne.velocity;
                    ne.pre_node = now.node;
                    if(dp[ne.node][ne.velocity][ne.pre_node]>ne.ti){
                        dp[ne.node][ne.velocity][ne.pre_node] = ne.ti;
                        Q.push(ne);
                    }
                }
            }
        }
        double ans = inf;
        for(int i=1;i<=N;i++) ans = min(ans,dp[G][1][i]);
        if(ans>=inf) cout << "unreachable" << endl;
        else{
            cout << fixed;
            cout << setprecision(10) << ans << endl;
        }
    }
}


Measured memory_bytes: 3896
/********************************
*** ******** ********** *********
*** * ****** ********* * ********
*** ** ***** ******** *** *******
*** *** **** ******* ***** ******
*** **** *** ****** ******* *****
*** ***** ** ***** +++++++++ ****
*** ****** * **** *********** ***
*** *******  *** ************* **
*** ******** ** *************** *
**********_**********************
* |   /  / \  \     /    /\     *
* |  /  |   |  \   /    /  \    *
* | /   |   |   \ /    /    \   *
* |+\   |   |    |    /______\  *
* |  \  |   |    |   |        | *
* |   \  \_/     |   |        | *
********************************/
#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define lsb(i) (i & -i)
#define Pi 3.141592653589793238
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define all(a) a.begin(), a.end()
#define remax(a, b) (a = ((a<b) ? b : a))
#define remin(a, b) (a = ((a<b) ? a : b))
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define precise(a) cout<<fixed<<setprecision(a)
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

lli power(lli x,lli y,lli p) { 
	lli res = 1;	 
	x = x % p; 
	while (y > 0) 
	{ 
		if (y & 1) 
			res = (res*x) % p; 
		y = y>>1; 
		x = (x*x) % p; 
	} 
	return res; 
} 



void solve(){
	lli n, m, k; cin >> n >> m >> k;
	lli s = m * k;
	if(s < n) cout << "No";
	else cout << "Yes";
    return;
}

int main(){
    fastIO;
    lli t = 1;
	// cin >> t;
	NA(i,0,t) {
		// cout << "Case #" << i+1 << ": "; 
		solve();
	}
	return 0;
}



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

int n,a[300][300];
int main() {
    scanf("%d",&n);
    for(int i=0;i<n;i++)for(int j=0;j<n;j++) scanf("%d",&a[i][j]);

    long long ans=0;
    for(int i=0;i<n;i++)for(int j=i+1;j<n;j++) if(i!=j) {
        int mx=2e9+1;
        for(int k=0;k<n;k++)if(i!=k && j!=k) mx=min(mx,a[i][k]+a[k][j]);
        if(mx < a[i][j]) {
            puts("-1");
            return 0;
        }else if(mx>a[i][j]) ans += a[i][j];
    }
    printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    int in,i = 0,syako[1000];
    while(cin >> in){
        if(in != 0){
            syako[i] = in;
            i++;
        }
        else{
            cout << syako[i - 1] << endl;
            i--;
        }
    }
}


Measured memory_bytes: 3060
import math
N = int(input())
Nfact = math.factorial(N)
ans = 1
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
c = factorize(Nfact)
for a,b in c:
  ans *= b+1
print(ans%(10**9+7))

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

int main()
{
    int n = 0;
    std::cin >> n;

    int k = 0;
    std::cin >> k;

    std::vector<bool> map(n, false);

    for (auto type = 0; type < k; ++type)
    {
        int len = 0;
        std::cin >> len;
        for (auto index = 0; index < len; ++index)
        {
            auto ni = 0;
            std::cin >> ni;
            map[ni - 1] = true;
        }
    }
    
    int result = 0;
    for (const auto& val : map)
    {
        if (!val)
        {
            ++result;
        }
    }
    std::cout << result;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int dp[100007][3]={-1};
int counter=0;
int fn(int ch,int n,vector<int>&A,vector<int>&B,vector<int>&C){
    //base_case already initialized in main()
    if(dp[n][ch]!=-1){
    	//cout<<"halat kharab\n";
        return dp[n][ch];
    }
    int op1=-(INT_MAX);
    int op2=-(INT_MAX);
    int op3=-(INT_MAX);
    if(ch==0){
        op2=B[n]+fn(1,n+1,A,B,C);
        op3=C[n]+fn(2,n+1,A,B,C);
        counter++;
    }
    else if(ch==1){
            op1=A[n]+fn(0,n+1,A,B,C);
            op3=C[n]+fn(2,n+1,A,B,C);
            counter++;
    }
    else{
        op1=A[n]+fn(0,n+1,A,B,C);
        op2=B[n]+fn(1,n+1,A,B,C);
        counter++;
    }
    dp[n][ch]=max(op1,max(op2,op3));
    return dp[n][ch];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int>A(n);
    vector<int>B(n);
    vector<int>C(n);
    //memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++)
            dp[i][j]=-1;
    }
    for(int i=0;i<n;i++){
        cin>>A[i]>>B[i]>>C[i];
    }
    dp[0][0]=A[0];
    dp[0][1]=B[0];
    dp[0][2]=C[0];
    //cout<<endl<<endl;
    //cout<<counter<<"why\n";
   // cout<<endl<<endl;
   cout<< max(A[0]+fn(0,1,A,B,C),max(B[0]+fn(1,1,A,B,C),C[0]+fn(2,1,A,B,C)))<<endl;
   /*for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    return 0;
}


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

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

fn main() {
    const MINE: char = '#';
    let h: u32 = read();
    let w: u32 = read();
    let dx = [1, 0, -1, 0, 1, -1, -1, 1];
    let dy = [0, 1, 0, -1, 1, 1, -1, -1];
    let mut board: Vec<Vec<char>> = (0..h).map(|_| read::<String>().chars().collect()).collect();
    for y in 0..h {
        for x in 0..w {
            if board[y as usize][x as usize] == MINE {
                continue
            }
            let mut num: u32 = 0;
            for i in 0..8 {
                let ny = (y as i32) + dy[i as usize];
                let nx = (x as i32) + dx[i as usize];
                if(nx >= 0 && nx < w as i32 && ny >= 0 && ny < h as i32 && board[ny as usize][nx as usize] == MINE) {
                    num += 1;
                }

            }
            board[y as usize][x as usize] = std::char::from_digit(num as u32, 10).unwrap();
        }
    }
    for y in 0..h {
        for x in 0..w {
            print!("{}", board[y as usize][x as usize]);
        }
        println!("");
    }
}

Measured memory_bytes: 4352
from collections import Counter

# UnionFind
# https://note.nkmk.me/python-union-find/
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def max_children(self):
        return max([self.size(x) for x in range(self.n)])

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# print('input >>')
N, M = map(int,(input().split()))
ABs = []
for _ in range(M):
    ABs.append(tuple(map(lambda x:int(x)-1,(input().split()))))

uf = UnionFind(N)
for AB in ABs:
    A, B = AB
    uf.union(A, B)
    
# print(uf.max_children())
print(uf.max_children())

# print('-----output-----')
# print(ans)

Measured memory_bytes: 118464
import datetime

s = input()
t = '2019/04/30'
date_1 = datetime.datetime.strptime(s, '%Y/%m/%d')
date_2 = datetime.datetime.strptime(t, '%Y/%m/%d')

if date_1 <= date_2:
	print('Heisei')
else:
	print('TBD')

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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    cout<<n*(n+1)/2;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(x)					(x).begin(),(x).end()
#define REP(i, n)				for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF						(int)2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
template<class T>
void deleteJufukuAndSort(vector<T> &vect)
{
	sort(vect.begin(), vect.end());
	vect.erase(unique(vect.begin(), vect.end()), vect.end());
}


int main()
{
	int N;
	cin >> N;
	vector<ll> A(N);
	REP(i, N) cin >> A[i];
	deleteJufukuAndSort(A);

	if (A.size() == N) {
	    cout << "YES" <<  endl;
	} else {
	    cout << "NO" <<  endl;
	} 
    return 0;
}


Measured memory_bytes: 1920
from collections import deque

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

s=""

for i in range(1,n):
  if a[i-1]+a[i]>=l:
    s="p"
    break

if s=="":
  print("Impossible")
  exit()
print("Possible")
  
for j in range(1,i):
  print(j)
for j in range(1,len(a)-i):
  print(len(a)-j)
  
print(i)
  


Measured memory_bytes: 14436
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}

// 負の数にも対応した mod (a = -11 とかでも OK)
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

// 逆元計算 (ここでは a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}


unsigned long long nCr(long n, long r) {
    unsigned long long ans = 1;
    for (long i = 1 ; i < r + 1; ++i) {
        ans = ans * (n-i+1);
        ans %= mop;
        ans = ans * modinv(i, mop);
        ans %= mop;
    }
    return ans;
}

int main() {
    
    long x,y;
    cin >> x >> y;
    if(2*x < y or 2*y < x or (x+y)%3 != 0){
        cout << 0 << endl;
        return 0;
    }
    if (x > y){
        ll t = x;
        x = y;
        y = t;
    }
//    long tmp = x / 3;
    long numX = y - (x+y)/3;
    long numY = x - (x+y)/3;
//    cout << numX << " " << numY << endl;

    cout << nCr(numX+numY, numX) << endl;


}

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

int main(){
    int a,b;
    string str;

    cin >> a >> str >> b;

    if(str[0] == '+'){
        cout << a + b << '\n';
    }
    else{
        cout << a - b << '\n';
    }

    return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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

int main() {
    string S;
    cin >> S;

    int n = S.size();
    ll ans = 0;

    for(int bit=0; bit < (1 << (n-1)); ++bit) {
        ll tmp = 0;
        for(int i=0; i<n; ++i) {
            tmp *= 10;
            tmp += S[i] - '0';

            if (bit & (1<<i)) {
                ans += tmp;
                tmp = 0;
            }
        }

        ans += tmp;
    }

    cout << ans << endl;

}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

ll n;
ll array_sum(ll x){
	return (x + n/x*x) * (n/x) / 2;
}

int main(){
	cin >> n;
	ll ans = 0;
	rep(i,n){
		ans += array_sum(i+1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,i;cin>>N;int H[N];
  for(i=0;i<N;i++)cin>>H[i];
  for(i=N-1;i>0;i--){
    if(H[i-1]>H[i]){
      if(H[i-1]-H[i]==1)H[i-1]--;
      else break;
    }
  }
  if(i==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
    public void solve(){
        Scanner sc=new Scanner(System.in);
        for(int r=0;r<4;r++){
            int num=sc.nextInt();
            int su=sc.nextInt();
            switch(num){
                case 1:
                System.out.println(su*6000);
                break;
                case 2:
                System.out.println(su*4000);
                break;
                case 3:
                System.out.println(su*3000);
                break;
                case 4:
                System.out.println(su*2000);
                break;
            }
        }
    }
    public static void main(String[]args){
        Main obj=new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17308
# -*- coding: utf-8 -*-
n,q = map(int, input().split())

cnt = [0 for _ in range(n)]

edge = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)

for _ in range(q):
    p,x = map(int, input().split())
    cnt[p-1] += x

for v in range(n):
    for u in edge[v]:
        cnt[u] += cnt[v]

print(" ".join([str(x) for x in cnt]))


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

vector<ll> v;
bool seica[333333];

void f(){
	for(int i = 2;i < 333333;i++){
		if(i % 7 == 1 || i % 7 == 6){
			if(!seica[i]){
				v.PB(i);
				for(int j = 2*i;j < 333333;j+=i){
					seica[j] = true;
				}
			}
		}
	}
}
	

int main(){
	
	int n;
	f();
	while(cin >> n,n!=1){
		cout << n << ':';
		
		REP(i,v.size()){
			if(n % v[i] == 0){
				printf(" %d",v[i]);
			}
			if(v[i] > n)break;
		}
		printf("\n");
	}
	return 0;
}



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

bool isN(char c){
	for(int i = 2; i <= 9; i++){
		if(c == ('0' + i)) return true;
	}
	return false;
}


int CtoN(char c){
	if(c == 'm') return 1000;
	else if(c == 'c') return 100;
	else if(c == 'x') return 10;
	else if(c == 'i') return 1;
	return 0;
}


int main(){
	int n;
	cin >> n;
	string s, t;
	//int s_sum = 0, t_sum = 0;
	for(int i = 0; i < n; i++){
		int s_sum = 0, t_sum = 0;
		cin >> s >> t;
		//transfar s
		int temp = 0;
		for(int j=0; j < (int)s.size(); j++){
			if(isN(s[j])) temp = s[j] - '0';
			else if(temp){
				s_sum += temp * CtoN(s[j]);
				temp = 0;
			}
			else if(temp == 0) s_sum += CtoN(s[j]);
		}
		
		//transfar t
		temp = 0;
		for(int j=0; j < (int)t.size(); j++){
			if(isN(t[j])) temp = t[j] - '0';
			else if(temp){
				t_sum += temp * CtoN(t[j]);
				temp = 0;
			}
			else if(temp == 0) t_sum += CtoN(t[j]);
		}
		
		string sum = to_string(s_sum + t_sum);
		int len = sum.size();
		//cout << "len = " << len << endl;
		for(int j = 0; j < len; j++){
				if(len == 1){
					if(sum[j] == '0') ;
					else if(j == 0 and sum[j] == '1') cout << "i";
					else if(j == 0 and sum[j] != '1') cout << sum[j] << "i";
				}
				if(len == 2){
					if(sum[j] == '0') ;
					else if(j == 0 and sum[j] == '1') cout << "x";
					else if(j == 0 and sum[j] != '1') cout << sum[j] << "x";
					else if(j == 1 and sum[j] == '1') cout << "i";
					else if(j == 1 and sum[j] == '1') cout << sum[j] << "i";
				}
				if(len == 3){
					if(sum[j] == '0') ;
					else if(j == 0 and sum[j] == '1') cout << "c";
					else if(j == 0 and sum[j] != '1') cout << sum[j] << "c";
					else if(j == 1 and sum[j] == '1') cout << "x";
					else if(j == 1 and sum[j] != '1') cout << sum[j] << "x";
					else if(j == 2 and sum[j] == '1') cout << "i";
					else if(j == 2 and sum[j] != '1') cout << sum[j] << "i";
				}
				if(len == 4){
					if(sum[j] == '0') ;
					else if(j == 0 and sum[j] == '1') cout << "m";
					else if(j == 0 and sum[j] != '1') cout << sum[j] << "m";
					else if(j == 1 and sum[j] == '1') cout << "c";
					else if(j == 1 and sum[j] != '1') cout << sum[j] << "c";
					else if(j == 2 and sum[j] == '1') cout << "x";
					else if(j == 2 and sum[j] != '1') cout << sum[j] << "x";
					else if(j == 3 and sum[j] == '1') cout << "i";
					else if(j == 3 and sum[j] != '1') cout << sum[j] << "i";
				}
		}
		cout << endl;
	}
	
	return 0;
}


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

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

    vector<string> S(N);
    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
    }

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

    string ans;
    for (int i = 0; i < N; i++)
    {
        ans += S[i];
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val x = (0 until n).map { sc.next().toLong() }
    println(problem094c(n, x))
}

fun problem094c(n: Int, x: List<Long>): String {
    val sorted = x.sorted()
    val res = LongArray(n) { 0 }
    for (i in 0 until n) {
        res[i] = if (x[i] <= sorted[n / 2 - 1]) {
            sorted[n / 2]
        } else {
            sorted[n / 2 - 1]
        }
    }
    return res.joinToString("\n")
}

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

int main() {
  int N; cin >> N;
  string S; cin >> S;
  int ans = 1;
  for (int i = 0; i < N-1; i++) {
    if (S.at(i) != S.at(i+1)) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    m=m*6;
    h=h*30;
    h=h+(m/360)*30;
    //cout<<h<<" "<<m<<'\n';
    double n= abs(h-m);
    double ans=a*a + b*b - 2*a*b*cos(n/ 57.295779513);
    cout << fixed << setprecision(10) << sqrt(ans)<<'\n';
    return 0;
}

Measured memory_bytes: 4232
N, K = input().split()
N = int(N)
K = int(K)

half = 0
zero = 0


for i in range(1,N+1):
    if i % K == 0:
        zero += 1

    if K % 2 == 0 and i % K == int(K/2):
        half += 1


print(half**3 + zero**3)


Measured memory_bytes: 3060
def divisor_count(n):
    count = 0
    for i in range(1, n + 1):
        if n % i == 0:
            count += 1
    return count


N = int(input())
c = 0
if N >= 105:
    for i in range(105, N + 1, 2):
        if divisor_count(i) == 8:
            c += 1
print(c)

Measured memory_bytes: 2940
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

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

func main() {
	sc.Split(bufio.ScanWords)

	s, t := next(), next()

	fmt.Println(t + s)
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
typedef tree<int, null_type,
		less_equal<int>, 
		rb_tree_tag,tree_order_statistics_node_update> ordered_mset;
		
typedef tree<int, null_type,
		less<int>, 
		rb_tree_tag,tree_order_statistics_node_update> ordered_set;
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

const int mx=1e5+5;
const ll mod=1e9+7;

int baje[mx];
ll dp[mx];

void solve()
{
	int n,m;
	cin>>n>>m;
	
	for(int i=1;i<=m;i++)
	{
		int x;
		cin>>x;
		baje[x]=1;
	}
	
	dp[0]=1;
	if(!baje[1]) dp[1]=1;
	
	for(int i=2;i<=n;i++)
	{
		if(!baje[i])
		{
			dp[i]=dp[i-1]+dp[i-2];
			dp[i]%=mod;
		}
	}
	
	cout<<dp[n];
	
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
	
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	
	return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
int main()
{
int S, b, s, h, m;
scanf("%d", &S);
b = S/60;
s = S%60;
h = b/60;
m = b%60;
if(S>=0 && S<=86400)
{ 
printf("%d:%d:%d\n", h, m, s);
}

return 0;
}



Measured memory_bytes: 2100
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      s: chars,
      t: chars,
    }
    let mut ans = n*2;
    for i in 0..n {
        let mut ok = true;
        for j in 0..n {
            if i+j >= n {
                break;
            }
            if s[i+j] != t[j] {
                ok = false;
            }
        }
        if ok {
            ans = min(ans, i+n);
        }
    }
    puts!("{}\n", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#define LL long long
using namespace std;
const int maxn = 1e5+10;
const double pi=acos(-1.0);

LL read(){
	LL x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}
struct node{
    LL x,y;
    double ang;
}a[maxn];

int cmp(node a,node b){
	return a.ang<b.ang;
}

int main(){
    int n,i,p=1;
    LL nowx=0,nowy=0,ans=0;
    n=read();
    for(register int i=1;i<=n;i++){
		a[i].x=read();a[i].y=read();
		a[i].ang=atan2(a[i].y,a[i].x);
	}
	sort(a+1,a+n+1,cmp);
    for(register int i=1;i<=n;i++){
        while(p<i+n && a[p].ang-a[i].ang<pi){
			nowx+=a[p].x;
			nowy+=a[p++].y;
			ans=max(ans,nowx*nowx+nowy*nowy);
        }
		nowx-=a[i].x;nowy-=a[i].y;ans=max(ans,nowx*nowx+nowy*nowy);
        a[i+n].x=a[i].x;a[i+n].y=a[i].y;a[i+n].ang=a[i].ang+2*pi;
    }
    printf("%.11lf\n" ,sqrt(ans));
    return 0;
}

Measured memory_bytes: 384
#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 A, B;
  cin >> A >> B;

  if (A * B % 2 == 0)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
   int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
    int a1=a*b;
    int a2=c*d;
   if(a1>a2){
    printf("%d",a1);
  }
    else{
   printf("%d",a2);  
}
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, M;
	cin >> N >> M;
	cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>


using namespace std;
int main()
{

    int r;
    cin>>r;
if(r>=100 &&  r<=999 ){
    if(r%10==r/100){
        cout<<"Yes";
    }
    
else {
    cout<<"No";
}

 }
else cout<<"WRONG";
    return 0;
}


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

B = [0] * N

out = []
for idx in range(N, 0, -1):
    a = A[idx - 1]

    q = N // idx

    cnt = 0
    for j in range(2, q + 1):
        if B[idx * j - 1] == 1:
            cnt += 1

    r = cnt % 2

    if a == 0:
        if r == 1:
            B[idx - 1] = 1
            out.append(idx)
        else:
            B[idx - 1] = 0
    else:
        if r == 1:
            B[idx - 1] = 0
        else:
            B[idx - 1] = 1
            out.append(idx)

g = sum(B)
print(g)

if g != 0:
    print(*out)


Measured memory_bytes: 14012
n = gets.to_i
h = gets.split.map(&:to_i)

ans = 0
cur = h[0]
j = 0
(0...(h.length-1)).each do |i|
  if h[i] >= h[i+1]
    j += 1
  else
    if ans < j
      ans = j
    end
    cur = h[i+1]
    j = 0
  end
end
if ans < j
  ans = j
end
p ans

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

int main(){
  long long A,B,V,W,T;
  cin>>A>>V>>B>>W>>T;
  if(abs(A-B)<= (V-W)*T){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}

int find_id_dec(vector<int> a, int x, int id){ //xより小さく、絶対値が最小のインデックス
    int abs_id=id+1;
    FOR(i, id+1, a.size()){
        if(a[i] < x && abs(x - a[abs_id]) > abs(x - a[i])){
            abs_id = i;
        }
    }
    return abs_id;
}

int find_id_inc(vector<int> a, int x, int id){ //xより大きく、絶対値が最小のインデックス
    int abs_id=id+1;
    FOR(i, id+1, a.size()){
        // printf("i=%d, ab=%d, x=%d, abs=%d\n", i, abs_id, x, abs(x-a[i]));
        if(a[i] > x && abs(x - a[abs_id]) > abs(x - a[i])){
            abs_id = i;
        }
    }
    return abs_id;
}

void printvec(vector<int> a){
    rep(i, a.size()-1){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[a.size()-1]);
}

void decrement(vector<int> a){
    int n = a.size();
    int id=n-2;
    if(id<0) return;
    while(a[id] < a[id+1]) {
        if(id==0){
            return;
        }
        id--;
    }
    int swap_id = find_id_dec(a, a[id], id);
    swap(a[id], a[swap_id]);
    reverse(a.begin()+id+1, a.end());
    printvec(a);
}

void increment(vector<int> a){
    int n = a.size();
    int id=n-2;
    if(id<0) return;
    while(a[id] > a[id+1]) {
        if(id==0){
            return;
        }
        id--;
    }
    int swap_id = find_id_inc(a, a[id], id);
    swap(a[id], a[swap_id]);

    reverse(a.begin()+id+1, a.end());
    printvec(a);
}
 
int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) {
        cin >> a[i];
        b[i] = a[i];
        c[i] = a[i];
    }

    decrement(a);
    printvec(b);
    increment(c);

    return 0;
}


Measured memory_bytes: 3272
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

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

    var(int, N, K);
    vector<i64> a(N);
    read(a);

    vector<i64> x;
    x.reserve(N * N);
    rep(l, 0, N) {
        i64 sum = 0;
        rep(r, l, N) {
            sum += a[r];
            x.push_back(sum);
        }
    }

    dump(x);
    dump(x.size(), N * (N + 1) / 2);

    i64 ans = 0;
    for (i64 b = (1LL) << 50; b > 0; b >>= 1) {
        const i64 mask = ans | b;
        int cnt = 0;
        for (const i64 e: x) {
            if ((e & mask) == mask) ++cnt;
        }

        if (cnt >= K) ans = mask;
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 6016
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    const char White = '.';
    const char Black = '#';

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());

        long y = long.Parse(input.ReadLine());

        for(int i=1; i<n; i++) {
            long x = long.Parse(input.ReadLine());
            //if(Math.Max(x,y) % Math.Min(x,y) == 0) {
            //    y = Math.Max(x, y);
            //} else {
                y = Lcm(y, x);
            //}
        }

        return y;
    }

    static long Lcm(long m, long n) {
        var x1 = Math.Max(m, n);
        var x2 = Math.Min(m, n);
        var gcd = Gcd(x1, x2);
        return x1 /gcd * x2;
    }

    static long Gcd(long m, long n) {
        //ユークリッド互除法
        if (m < n) { var t = m; m = n; n = t; }

        while (true) {
            var mod = m % n;
            if (mod == 0) return n;
            m = n;
            n = mod;
        }
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,a,b;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout<<"OK";
            return 0;
        }
    }
    cout<<"NG";
   return 0;
}






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

int main()
{
	int n,m;
	cin >> n >> m;
	vector<vector<int>> v(n, vector<int>(m, 0));
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> v[i][j];
		}
	}
	vector<int> x(m);
	for (int i = 0; i < m; i++)
	{
		cin >> x[i];
	}
	vector<int> ans(n);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			ans[i] += v[i][j] * x[j];
		}
	}

	for (int i = 0; i < n; i++)
	{
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;

void bfs(vector<string>&f, vector<vector<ll>>&cnt, ll k, ll xs, ll ys, ll xg, ll yg) {
  ll h = f.size();
  ll w = f[0].size();

  queue<pll> que;
  que.push(pll(xs, ys));
  cnt[ys][xs] = 0;
  vector<ll> dx = {-1, 0, 0, 1};
  vector<ll> dy = {0, 1, -1, 0};

  while (!que.empty()) {
    pii p = que.front();
    ll x = p.first, y = p.second;
    //cout << x << " " << y << endl;
    que.pop();
    if ((x == xg) && (y == yg)) break;
    for (int i = 0; i < 4; i++) {
      for (int j = 1; j <= k; j++) {
        ll nx = x + dx[i] * j, ny = y + dy[i] * j;
        if ((nx >= 0) && (nx < w) && (ny >= 0) && (ny < h) && (f[ny][nx] == '@')) break;
        if ((nx >= 0) && (nx < w) && (ny >= 0) && (ny < h) && (f[ny][nx] == '.') && (cnt[ny][nx] == -1)) {
          cnt[ny][nx] = cnt[y][x] + 1;
          que.push(pll(nx, ny));
        }
        else if ((nx >= 0) && (nx < w) && (ny >= 0) && (ny < h) && (f[ny][nx] == '.') && (cnt[ny][nx] != -1)) {
          if (cnt[ny][nx] > cnt[y][x] + 1) cnt[ny][nx] = cnt[y][x] + 1;
          else if (cnt[ny][nx] < cnt[y][x] + 1) break;
        }
      }
    }
  }
}

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

  ll h, w, k;
  cin >> h >> w >> k;
  ll xs, ys, xg, yg;
  cin >> xs >> ys >> xg >> yg;
  vector<string> f(h);
  for (int i = 0; i < h; i++) cin >> f[i];

  vector<vector<ll>> cnt(h, vector<ll>(w, -1));

  bfs(f, cnt, k, ys-1, xs-1, yg-1, xg-1);
  //cout << "Y" << endl;

  /*for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) cout << cnt[i][j] << " ";
    cout << endl;
  }*/
  cout << cnt[xg-1][yg-1] << endl;
}


Measured memory_bytes: 19776
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<climits>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

int main(){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3100
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N, K = zz()
A = zz()

for i in range(K, N):
    # print(i, i-K)
    if (A[i] > A[i - K]):
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 64768
#include <bits/stdc++.h>
using namespace std;
int n;
int main()
{
	deque<int> Q;
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
	{
		int val;
		scanf("%d", &val);
		if(i & 1) Q.push_back(val);
		else Q.push_front(val);
	}
	if((n & 1)) reverse(Q.begin(), Q.end());
	for(auto v : Q) 
		printf("%d ", v);
	return 0;
}
		

Measured memory_bytes: 4608
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int N;

int division_count(int n){
    int cnt = 0;
    int range = sqrt(n);

    for(int j = 1; j <= range; j++){
        if(n % j == 0) cnt+=2;
    }
    if(n > 1 && n == pow(range,2)) cnt--; //n = 1の時に注意(1は平方数ではない)

    return cnt;
}

int solve(){
    int ans = 0;
    for(int i = 1; i <= N; i++)
        if(i % 2 == 1 && division_count(i) == 8) ans++;
    return ans;
}

int main(){
    cin >> N;
    // printf("%d\n",division_count(N));
    cout << solve() << endl;
}


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

int main() {
  vector<char> vec = {'A','B','C','D','E','F','G',
                      'H','I','J','K','L','M','N',
                      'O','P','Q','R','S','T','U',
                      'V','W','X','Y','Z',};
  int N;
  string S;
  cin >> N >> S;
  for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < 26; j++) {
      if (S.at(i) == vec.at(j)) {
        S.at(i) = vec.at((j + N)%26);
        break;
      }
    }
  }
  
  cout << S << endl;
}

Measured memory_bytes: 256
import itertools
n,m,x=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
costl=[]
for p in itertools.product([0,1],repeat=n):
  al=[0]*m
  cost=0
  for i in range(n):
    if p[i]==1:
      cost+=l[i][0]
      for j in range(1,m+1):
        al[j-1]+=l[i][j]
  if all(mm>=x for mm in al):
    costl.append(cost)
print(min(costl) if len(costl)>=1 else -1)

Measured memory_bytes: 9176
#include <stdio.h>

long A,B,C,K;

int main()
{
    scanf("%ld %ld %ld %ld",&A,&B,&C,&K);
    if(K<=A)
	printf("%ld\n",K);
    else if(A<K && K<=A+B)
	printf("%ld\n",A);
    else
	printf("%ld\n",A-(K-A-B));
    return 0;
}



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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

ll calc(ll a, ll b) {
    if (a <= 0 && b <= 0) {
        return max(abs(a), abs(b));
    }
    if (a >= 0 && b >= 0) {
        return max(abs(a), abs(b));
    }
    ll c1 = abs(b) + abs(b) + abs(a);
    ll c2 = abs(a) + abs(a) + abs(b);
    return min(c1, c2);
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> candles(n);
    rep(i, n) cin >> candles[i];

    ll ans = INF;
    for (int i = 0; i + k <= n; i++) {
        ll now = calc(candles[i], candles[i + k - 1]);
        cmin(ans, now);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		final long N = in.nextLong();
		final long K = in.nextLong();
		if(N < K) System.out.println(Math.min(N, K - N));
		else {
			long mod = N % K;
			System.out.println((mod == 0) ? 0 : (Math.min(mod, Math.abs(K - mod))));
		}
	}
}

Measured memory_bytes: 22868
N = int(input())
H = list(map(int, input().split()))
 
c = 0
c_max = 0
for i in range(N-1):
  c = (c + 1) * (H[i+1] <= H[i])
  c_max = c * (c >= c_max) + c_max * (c < c_max)


print(c_max)

Measured memory_bytes: 14252
N,M=map(int,raw_input().split())

S= raw_input()
T= raw_input()

def gcd(a,b):
    g=1
    for i in range(1,min(a,b)+1):
        if a%i==0 and b%i==0:
            g=i
    return g
    
g=gcd(N,M)

flag=True
for i in range(g):
    if S[i*(N/g)]!=T[i*(M/g)]:
        flag=False
        break

if flag:
    print N*M/g
else:
    print -1

Measured memory_bytes: 5124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		int ans = 0;
		for (int i = 0; i < s.length(); i++){
			if (s.charAt(i) == '+'){
				ans++;
			} else {
				ans--;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21588