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

int N, K, ans, trash, rndUp;

int main(){
	cin >> N; cin >> K;
	for(int i = 0; i < N; i++) cin >> trash;
	if(N == K) ans = 1;
	else{
		if((N-K)%(K-1) != 0) rndUp = 1;
		else rndUp = 0;
		ans = ((N-K)/(K-1))+1+rndUp;
	}
	cout << ans;
	return 0;
}

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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

llint my_binary_search(llint ary[], llint key, llint left, llint right) {
	llint middle;
	if (right < left) {
		return -(INF64);
	} else {
		middle = left + (right - left) / 2;
		if (ary[middle] > key) {
			return my_binary_search(ary, key, left, middle - 1);
		} else if (ary[middle] < key) {
			return my_binary_search(ary, key, middle + 1, right);
		} else {
			return middle;
		}
	}
}

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	
	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for(int i = 0; i < N; i++) par[i] = i;
	}
	
	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}
	
	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}
	
	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main (void)
{
	//INPUT
	llint N,M;
	cin >> N>>M;
	// vector<pair<llint,bool> > p;
	// llint buff;
	// string buf;
	// bool bufs;
	// rep(i,0,M) {
	// 	cin >> buff >> buf;
	// 	if (buf == "WA") {
	// 		bufs = false;
	// 	} else {
	// 		bufs = true;
	// 	}
	// 	p.push_back(make_pair(buff,bufs));
	// }
	
	
	
	//SOLVE
	llint ans=0;
	llint ans2=0;
	
	vector<llint> state(N+1,0);
	vector<llint> pena(N+1,0);
	
	llint in1;
	string in2;
	rep(i,0,M) {
		cin >> in1 >> in2;
		if (in2 == "WA") {
			if (state[in1] == 0) {
				pena[in1]++;
			} else {
				
			}
		} else {
			if (state[in1] == 0) {
				ans++;
				state[in1] = 1;
				ans2 += pena[in1];
			} else {
				
			}
		}
	}
	
	//OUTPUT
	cout << ans << " " << ans2 << endl;
	
	return 0;
}






Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}
int n;
vvi a;
vi d;
queue<int> q;

void Breadth(int pos) {
	q.push(pos);
	d[pos] = 0;
	while (!q.empty()) {
		pos = q.front();
		q.pop();
		rep(i, n) {
			if (a[pos][i] == 1 && d[i] == -1) {
				q.push(i);
				d[i] = d[pos]+1;
			}
		}
	}
}


int main() {
	cin >> n;
	a.resize(n, vi(n, 0));
	d.resize(n, -1);
	rep(i, n) {
		int num,m;
		cin >>num >>m;
		rep(i, m) {
			int tmp;
			cin >> tmp;
			a[num - 1][tmp - 1] = 1;
		}
	}
	Breadth(0);

	rep(i, n) {
		cout << i + 1 << " " << d[i] << endl;
	}
}



Measured memory_bytes: 3140
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int x = sc.nextInt();
        //int X = x/50;
        int count = 0;
        for (int a = 0;a <= A;a++ ){
            for (int b = 0;b <= B;b++ ){
                for (int c = 0;c <= C;c++ ){
                    if(x == (a*500 + b*100 + c *50)){
                        count +=1;
                    }
                }
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String O = sc.next();
		String E = sc.next();
		
		String S = "";
		
		for(int i = 0; i < E.length(); i++) {
			S += O.substring(i, i + 1) + E.substring(i, i + 1);
		}
		
		if(O.length() - E.length() == 1) {
			System.out.println(S + O.substring(O.length() - 1, O.length()));
		} else {
			System.out.println(S);
		}
		
		
		
	}
}


Measured memory_bytes: 21972
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)

A,B = 0,0
for i in range(n):
  if i == 0 or i%2 == 0:
    A += a[i]
  else:
    B += a[i]

if A > B:
  print(A-B)
else:
  print(B-A)

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


class Magatro
{
    static int N, x;
    static int[] a;
    static void Main()
    {
        string[] q = Console.ReadLine().Split(' ');
        N = int.Parse(q[0]);
        x = int.Parse(q[1]);
        long cnt = 0;
        a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        for(int i = 1; i < N; i++)
        {
            int wa = a[i] + a[i - 1];
            if (wa < x)
            {
                continue;
            }
            int sa = wa - x;
            cnt += sa;
            if (sa <= a[i])
            {
                a[i] -= sa;
            }
            else
            {
                sa -= a[i];
                a[i] = 0;
                a[i - 1] -= sa;
            }
        }
        Console.WriteLine(cnt);
    }
}



Measured memory_bytes: 18008
# -2進数を求める
N = int(input())

if N == 0:
    print(0)
else:
    ans = ""
    while N != 0:
        if N % 2 != 0:
            N -= 1
            ans = "1" + ans
        else:
            ans = "0" + ans
        N = N // (-2)
    print(ans)


Measured memory_bytes: 2940
//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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 ) * } } ; }
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" ) } ; }
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 ) * } } ; }
//入力マクロここまで

fn main() {
    input! {
        n: usize,
        t : u64,
        ct:[(u64,u64);n],
    }

    let (cs, _): (Vec<_>, Vec<_>) = ct.iter().filter(|x| x.1 <= t).cloned().unzip();

    let ans = match cs.iter().min() {
        Some(x) => x.to_string(),
        None => "TLE".to_string(),
    };

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


Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

vector<int> a(3);

int main()
{
    for (size_t i = 0; i < 3; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    cout << (a[0] + a[1] == a[2] ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
def cul_dis(start,goal):
    return abs(start[0]-goal[0])+abs(start[1]-goal[1])

H,W,d = map(int,input().split())
number_pos = {}

for h in range(H) :
    state = list(map(int,input().split()))
    for i,number in enumerate(state):
        number_pos[number] = [h,i]

Q = int(input())

exams = []
for _ in range(Q):
    exams.append(list(map(int,input().split())))

mp_consume = [0 for i in range(H*W)]

for i in range(H*W)[::-1]:
    if i+d <= H*W-1:
        mp_consume[i] = mp_consume[i+d]+cul_dis(number_pos[i+1],number_pos[i+d+1])

for [start,goal] in exams:
    ans = mp_consume[start-1]-mp_consume[goal-1]
    print(ans)



Measured memory_bytes: 49768
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
    char a, b;
    cin >> a >> b;
    if(a == 'H'){
        cout << b << endl;
    }else{
        if(b == 'H'){
            cout << 'D' << endl;
        }else{
            cout << 'H' << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	// your code goes here
	int v[120]; // how many people live in
	for(int i=0;i<120;i++){
		v[i] = 0;
	}
	int n;
	cin >> n;
	for(int i=0;i<n;i++) {
		int b, f, r, m;
		cin >> b >> f >> r >> m;
		v[(b-1)*30 + (f-1) * 10 + r - 1] += m;
	}
	for(int i=0;i<120;i++) {
		if(i%10 == 9) {
			cout << " " << v[i] << endl;
		} else {
			cout << " " << v[i];
		}
 
		if(i%30 == 29 && i/30 != 3) {
			cout << "####################" << endl;
		}
	}
 
	return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

class segtree{
public:
	static const int N=1<<18;
	int dp[1<<19];
	segtree(){
		memset(dp,0,sizeof(dp));
	}
	void update(int k,int v){
		k+=N-1;
		dp[k]+=v;
		while(k>0){
			k=(k-1)/2;
			dp[k]=dp[k*2+1]+dp[k*2+2];
		}
	}

	int query(int a,int b,int k=0,int l=0,int r=N){
		if(b<=l || r<=a)return 0;
		if(a<=l && r<=b)return dp[k];
		int mid=(l+r)/2;
		int vl=query(a,b,k*2+1,l,mid);
		int vr=query(a,b,k*2+2,mid,r);
		return vl+vr;
	}
};

class segtree_mx{
public:
	static const int N=1<<18;
	int dp[1<<19];
	segtree_mx(){
		memset(dp,-1,sizeof(dp));
	}
	void update(int k,int v){
		k+=N-1;
		dp[k]=v;
		while(k>0){
			k=(k-1)/2;
			dp[k]=max(dp[k*2+1],dp[k*2+2]);
		}
	}

	int query(int a,int b,int k=0,int l=0,int r=N){
		if(b<=l || r<=a)return -1;
		if(a<=l && r<=b)return dp[k];
		int mid=(l+r)/2;
		int vl=query(a,b,k*2+1,l,mid);
		int vr=query(a,b,k*2+2,mid,r);
		return max(vl,vr);
	}
};

class segtree_mn{
public:
	static const int N=1<<18;
	int dp[1<<19];
	segtree_mn(){
		for(int i=0;i<N*2;i++){
			dp[i]=(1<<25);
		}
	}
	void update(int k,int v){
		k+=N-1;
		dp[k]=v;
		while(k>0){
			k=(k-1)/2;
			dp[k]=min(dp[k*2+1],dp[k*2+2]);
		}
	}

	int query(int a,int b,int k=0,int l=0,int r=N){
		if(b<=l || r<=a)return (1<<25);
		if(a<=l && r<=b)return dp[k];
		int mid=(l+r)/2;
		int vl=query(a,b,k*2+1,l,mid);
		int vr=query(a,b,k*2+2,mid,r);
		return min(vl,vr);
	}
};

int n,k;
int a[200005];
segtree seg;
segtree_mx seg_mx;
segtree_mn seg_mn;

int main(void){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	bool flag=false;
	int ans=0;
	ll rev=0;
	for(int i=0;i<k;i++){
		seg.update(a[i],1);
		rev+=seg.query(a[i]+1,n+1);
	}
	for(int i=0;i<n;i++){
		seg_mx.update(i,a[i]);
		seg_mn.update(i,a[i]);
	}
	if(rev==0){
		flag=true;
	}
	ans++;
	for(int i=k;i<n;i++){
		bool flag2=true;
		if(a[i]<seg_mx.query(i-k+1,i)){
			flag2=false;
		}
		if(a[i-k]>seg_mn.query(i-k+1,i)){
			flag2=false;
		}
		rev-=seg.query(0,a[i-k]);
		seg.update(a[i-k],-1);
		seg.update(a[i],1);
		rev+=seg.query(a[i]+1,n+1);
		if(!flag2){
			if(rev==0){
				if(!flag){
					flag=true;
					ans++;
				}
			}else{
				ans++;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 7168
#include <stdio.h>
int main(){
    int n,m,l;
    int i,j,k;
    int a[110][110];
    int b[110][110];
    long long c[110][110]={0};
    scanf("%d %d %d",&n,&m,&l);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<l;j++){
            scanf("%d",&b[i][j]);
        }
    }
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            for(k=0;k<m;k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
            if(j!=0) printf(" ");
            printf("%ld",c[i][j]);
        }
        puts("");
    }
    return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) c.begin(), c.end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    string s;
    cin >> s;
    int a[26] = {};
    for (auto c : s){
        if (a[c - 'a']){
            cout << "no" << endl;
            return 0;
        }
        a[c - 'a'] = 1;
    }
    cout << "yes" << endl;
    return 0;
}

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

long MAX = 1000000;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long N;
    cin >> N;
    long ans = MAX;
    for (int i = 0; i <= N; ++i)
    {
        long cc = 0;
        long t = i;
        while (t > 0)
        {
            cc += t % 6;
            t /= 6;
        }
        t = N - i;
        while (t > 0)
        {
            cc += t % 9;
            t /= 9;
        }
        ans = min(ans, cc);
    }
    cout << ans << endl;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int n,m,p;
    while(cin>>n>>m>>p,n){
        int x;
        double res=0,a;
        REP(i,n){
            cin >> x;
            res+=x*100;
            if(i==m-1)a=x;
        }

        res*=(100-p);
        res/=100;
        int ans=res/a;
        if(a==0)cout << 0 << endl;
        else cout << ans << endl;

    }
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 1000010
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  
  REP(i,n-1){
    if(a[i] == a[i+1]){
      cout << "NO";
      return 0;
    }
  }
  
  cout << "YES";
  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt();

        sc.close();

        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n - i; j++) {
                for (int k = 0; k <= n - i - j; k++) {
                    if (10000 * i + 5000 * j + 1000 * k == y &&
                            i + j + k == n) {
                        System.out.println(i + " " + j + " " + k);
                        return;
                    }
                }
            }
        }
        System.out.println("-1 -1 -1");
    }
}


Measured memory_bytes: 23252
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
ll MOD = 1000000007;
#define INF (1e9)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A+B > C+D) cout << "Left" << endl;
    else if (A+B < C+D) cout << "Right" << endl;
    else cout << "Balanced" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

ll dp[3000][3000][4];
ll V[3000][3000];

int main() {
  
  int R, C, K;
  cin >> R >> C >> K;
  rep(i,K) {
    ll r, c, v;
    cin >> r >> c >> v;
    V[r - 1][c - 1] = v;
  }
  rep(i,R) {
    if (i > 0) {
      rep(j,C) rep(k,4) dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][k]);
    }
    if (V[i][0] > 0) dp[i][0][1] = dp[i][0][0] + V[i][0];
    for (int j = 1; j < C; j++) {
      for (int k = 1; k <= 3; k++) {
        if (V[i][j] == 0) {
          dp[i][j][k] = dp[i][j - 1][k];
          continue;
        }
        dp[i][j][k] = max(dp[i][j - 1][k], dp[i][j - 1][k - 1] + V[i][j]);
        if (k == 1) {
          dp[i][j][k] = max(dp[i][j][k], dp[i][j][0] + V[i][j]);
        }
      }
    }
  }

  ll ans = 0;
  rep(i,4) ans = max(ans, dp[R - 1][C - 1][i]);
  cout << ans << endl;

  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (auto& i : vec) cin >> i;

    double l = 0., r = 1.0;
    for (int c = 0; c < 27; c++) {
        double m = (l + r) / 2.0;
        set<int> s;
        s.insert(1);

        for (int i = 0; i < N; i++) {
            int lo_n = ceil((1.0 - m) * (double)vec[i]);
            int up_n = (1.0 + m) * vec[i];

            set<int> ns;
            for (auto j : s) {
                int v = up_n / j;
                int u = ceil((double)lo_n / j);
                for (; u <= v; u++) if (u != 0) ns.insert(j * u);
            }

            s = ns;
        }

        if (s.size() > 0) r = m;
        else l = m;
    }

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

    return 0;
}

Measured memory_bytes: 10680
S = list(input())

is_easy = True
for i in range(len(S)):
    if i % 2 == 1:
        if S[i] not in ['L', 'U', 'D']:
            is_easy = False
    if i % 2 == 0:
        if S[i] not in ['R', 'U', 'D']:
            is_easy = False

if is_easy:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  if(k<=a){
    cout << k << endl;
  }
  else if(k<=a+b){
    cout << a << endl;
  }
  else{
    cout << a-(k-a-b) << endl;
  }
}

Measured memory_bytes: 3636
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
#include <map>
#include <utility>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
using vvc = vector<vector<char> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
 //各位の和　
int wa(ll x)
{
ll sum = 0;
while(x!=0){
  sum += x% 10;
  x /= 10;
}
return sum;
}
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)
//reverse 回文
//if(isupper('A'))->大なら真


//グローバル変数宣言
ll p=0,q=0,r=0;

int main()
{
  ll x;
  cin>>x;
  p=x/100;
  q=x%100;
  if (q<=p*5)
  {
    print(1)
  }else print(0)
  
}

Measured memory_bytes: 3636
function main(input) {
    const pair = new Map();
    pair.set('A','T');
    pair.set('T','A');
    pair.set('C','G');
    pair.set('G','C');
    console.log(pair.get(input.trim()));    
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){
  int N;

  while(std::cin >> N){
    std::vector<std::pair<int, int>> edges;
    for(int i = 0; i < N-1; ++i){
      int u, v; std::cin >> u >> v;
      edges.emplace_back(u, v);
    }

    int64_t ans = 0;
    for(int i = 1; i <= N; ++i){
      ans += (int64_t)i * (N - i + 1);
    }

    for(auto [u, v] : edges){
      if(u > v) std::swap(u, v);

      ans -= (int64_t)u * (N - v + 1);
    }

    std::cout << ans << "\n";
  }
  
  return 0;
}


Measured memory_bytes: 5368
#include<iostream>
#include<vector>
#include <algorithm>

using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<n; i++)


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

    vector<int>card(N);
    rep(i, N) {
        cin >> card[i];
    }

    sort(card.begin(), card.end(), greater<int>());

    int ans = 0;
    rep(i, N) {
        if (i % 2 == 0) {
            ans += card[i];
        }
        else {
            ans -= card[i];
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

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

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

//map<pair<string, string>, int> mpi;
//
//ll n, f;
//
//int main(){
//	cin >> n >> f;
//	REP(i, n){
//		ll m;
//		cin >> m;
//		REP(i, m){
//		cin>>
//		}
//	}
//}

ll a, b, c, d;

int main(){
	cin >> a >> b >> c >> d;
	cout << max(a*b, c*d) << endl;
}

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

int main() {
  int N, Q; cin >> N >> Q;
  int qt, x;
  map<int, int> usmin, lsmin;
  usmin[N-1]=N-2;
  lsmin[N-1]=N-2;
  long black = ((long)(N-2))*(N-2);
  for (int q = 0; q < Q; q++) {
    cin >> qt >> x; x--;
    if (qt == 1) {
      auto it = lsmin.upper_bound(x);
      black -= it->second;
      if (usmin.find(it->second+1) != usmin.end()) usmin[it->second+1] = min(usmin[it->second+1], x-1);
      else usmin[it->second+1] = x-1;
    } else {
      auto it = usmin.upper_bound(x);
      black -= it->second;
      if (lsmin.find(it->second+1) != lsmin.end()) lsmin[it->second+1] = min(lsmin[it->second+1], x-1);
      else lsmin[it->second+1] = x-1;
    }
  }
  cout<<black<<endl;
}

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

int main(){
	int n;
	scanf("%d", &n);
	int a[n];
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		a[i]--;
	}
	sort(a,a+n);
	reverse(a,a+n);
	int c = 0;
	while(c + 1 < n && c + 1 <= a[c+1]){
		c++;
	}
	int d = a[c] - c;
	int e = 0;
	for(int i = c+1; i < n; i++){
		if(a[i] >= c) e++;
	}
	if(d % 2 || e % 2){
		printf("First\n");
	} else {
		printf("Second\n");
	}
}


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


int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	int i,t1=1000000,t2=0;
	string a;
	cin>>a;
	for (i=0;i<a.size();i++){
		if (a[i]=='A'){
			t1=min(t1,i);
		}
		else if(a[i]=='Z'){
			t2=max(t2,i);
		}
	}
	cout<<t2-t1+1;
	return 0;
}

Measured memory_bytes: 640
n = gets.to_i
t = gets.split.map(&:to_i)
m = gets.to_i
p, x = m.times.map { gets.split.map(&:to_i) }.transpose

sum = t.inject(:+)
p.each_with_index do |pi, i|
  puts sum - t[pi - 1] + x[i]
end

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  string s, t;
  cin >> s >> t;
  sort(all(s));
  sort(all(t), greater<char>());
  if (s < t) cout << "Yes" << '\n';
  else cout << "No" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


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


int main(){
    string n,m;
    cin >> n >> m;
    sort(n.begin(),n.end());
    sort(m.begin(),m.end(),greater<char>());
    if(n<m)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;  
}

Measured memory_bytes: 256
/*input
7
100 130 130 130 115 115 150
*/

// #include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <cstdint>
#include <tuple>
#endif
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
const long long lim = 2e5+100;
typedef long long int lld;
typedef long long ll;

#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }


#define popcount __builtin_popcountll

ll powP(ll x, ll y) {
    ll ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}


vector<pair<ll,ll> > V;
ll Array[lim], C[lim];
vector<pair<ll,ll> > Allstocks;

int main(){

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

    lld T,i,p,j,l,e,r,b,c,k,m,q,a,d,w,x,y,u,v,z,t,curr,prev,sum=0,val,countA=0,indicator=0,pos,h,minA,maxA,type,n,ans=0,left,right;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>Array[i];
    Array[0]=mod; Array[n+1]=0; prev=0;
    for(int i=1;i<=n+1;i++) {
        if(Array[i]<Array[i-1]) {
            V.push_back(make_pair(Array[prev],Array[i-1]));
            prev=i;
        }
    }
    val=1000;
    for(auto i: V) {
        val = (val/i.first)*i.second + val - (val/i.first)*i.first;
    }

    cout<<val<<endl;
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n, k;
    while(cin>>n>>k){
        ll ans=0;
        int x, y;
        set<int> st;
        for(int i=0; i<k; ++i){
        	scanf("%d",&x);
        	for(int j=0; j<x; ++j){
            	scanf("%d",&y);
            	st.insert(y);
        	}
        }
        cout<<n-(int)st.size()<<endl;
    }
  return 0;
}




Measured memory_bytes: 3704
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;

int main(){
  ll n;
  cin>>n;
  vll p(n),q(n);
  vll g(n);
  rep(i,n){
    g[i]=i+1;
  }
  
  rep(i,n) cin>>p[i];
  rep(i,n) cin>>q[i];
  ll pp=0;
  ll qq=0;
  ll cu=1;
  do {
    ll pc=0;
    ll qc=0;
    rep(i,n){
      if(g[i]==p[i]) pc++;
      if(g[i]==q[i]) qc++;
    }
    if(pc==n) pp=cu;
    if(qc==n) qq=cu;
    cu++;
  } while (next_permutation(g.begin(), g.end()));
  COUT(abs(pp-qq));
}

Measured memory_bytes: 256
N,D = map(int,input().split())
A=[[int(i) for i in input().split()] for _ in range(N)]
ans=int()

for i in range(N):
  if A[i][0]*A[i][0]+A[i][1]*A[i][1]<=D*D:
    ans+=1
print(ans)
  


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

using namespace std;

int main()
{
	int N, K;
	int di, a;
	cin >> N >> K;
	vector<bool> sunuke;
	sunuke.resize(N);
	for (int i = 0; i < N; i++)
	{
		sunuke[i] = false;
	}

	for (int i = 0; i < K; i++)
	{
		cin >> di;
		for (int j = 0; j < di; j++)
		{
			cin >> a;
			sunuke[a - 1] = true;
		}



	}


	cout << count(sunuke.begin(), sunuke.end(), false) << endl;
	return 0;
}

Measured memory_bytes: 3632
defmodule Main do
  def main() do
    n = IO.gets("") |> String.trim() |> String.to_integer()
    a = Enum.map(1..n, fn _ -> IO.gets("") |> String.trim() |> String.split(" ") |> Enum.uniq() |> length() end)
    |> Enum.join() |> String.contains?("111")
    if a, do: IO.puts("Yes"), else: IO.puts("No")
  end
end

Measured memory_bytes: 30760
n, k = map(int, input().split())
pos = []
for i in range(n):
    x, y = map(int, input().split())
    pos.append((x, y))

pos.sort()
minSq = 4000000000000000000

for l in range(n):
    lx, ly = pos[l]
    que = []
    for r in range(l, n):
        rx, ry = pos[r]
        que.append(ry)
        sizes = sorted(que)
        n_sizes = len(que)
        if n_sizes < k:
            continue
        for i_top in range(k - 1, n_sizes):
            top = sizes[i_top]
            bottom = sizes[i_top - k + 1]
            minSq = min(minSq, (top - bottom) * (rx - lx))

print(minSq)


Measured memory_bytes: 3064
def pb(n,x):
  if n == 0:
    if x <= 0:
      return 0
    else:
      return 1
  elif x <= 1+a[n-1]:
    return pb(n-1,x-1)
  else:
    return p[n-1] + 1 + pb(n-1,x-2-a[n-1]) 

n, x = map(int, input().split())
a = [1]
p = [1]
for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)
print(pb(n,x))

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		int cnt = 700;
		String S = sc.next();
    
      	for(int i=0;i<3;i++){
        	if(S.charAt(i)=='o')cnt += 100;
        }
      	System.out.println(cnt);
      
      	
    }
}

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

using namespace std;

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

const int N = 100010;
const double eps = 1e-6;

int n;
int v[N];
PII a[N], b[N];

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> v[i];
    for(int i = 0; i < N; i++) a[i].second = b[i].second = i;

    bool only_one = true;
    for(int i = 1, cnt = 0; i <= n; i += 2)
    {
        if(!a[v[i]].first) cnt++;
        if(cnt > 1) only_one = false;
        a[v[i]].first++;
    }
    for(int i = 2, cnt = 0; i <= n; i += 2)
    {
        if(!b[v[i]].first) cnt++;
        if(cnt > 1) only_one = false;
        b[v[i]].first++;
    }

    sort(a, a + N);
    sort(b, b + N);
    reverse(a, a + N);
    reverse(b, b + N);

    int res;
    if(only_one)
    {
        if(a[0].second == b[0].second) res = n / 2;
        else res = 0;
    }
    else
    {
        if(a[0].second == b[0].second)
        {
            if(a[0].first > b[0].first) res = n - a[0].first - b[1].first;
            else if(a[0].first < b[0].first) res = n - a[1].first - b[0].first;
            else res = n - a[0].first - max(a[1].first, b[1].first);
        }
        else res = n - a[0].first - b[0].first;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;



ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a,ll b) {
	return a / gcd(a, b) * b;
}



int main() {
	int i, j, k;
	ll N, M, K;
	ll ans = 0;
	cin >> N;
	cout << N / 2 + N % 2;
	

	
	return 0;


}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var H = ReadLongs();

            var maxCount = 0L;
            var currentCount = 0L;
            var preHeight = H[0];
            for (int i = 1; i < N; i++)
            {
                if (preHeight >= H[i])
                {
                    currentCount++;
                }
                else
                {
                    maxCount = Math.Max(maxCount, currentCount);
                    currentCount = 0;
                }

                preHeight = H[i];
            }
            maxCount = Math.Max(maxCount, currentCount);

            return maxCount;
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28636
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

int main(){	
	
	int n;
	cin >> n;
	vector<long long> a(n),b(n),c(n);
	
	for(int i=0;i<n;i++)cin >> a[i];
	for(int i=0;i<n;i++)cin >> b[i];
	for(int i=0;i<n;i++)cin >> c[i];
	
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	
	long long ans=0;
	for(int i=0;i<n;i++){
		long long itr_a=lower_bound(a.begin(),a.end(),b[i])-a.begin();
		long long itr_c=upper_bound(c.begin(),c.end(),b[i])-c.begin();
		itr_c=n-itr_c;
		ans+=itr_a*itr_c;
	}
	cout << ans << endl;		
	return 0;
}


Measured memory_bytes: 5624
#include <bits/stdc++.h>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
const int INF =100100100;
const int MOD = (int)1e9+7;
const double EPS = 1e-9;
typedef long long ll;
typedef long li;
#define pb push_back 
#define mp make_pair

signed main (){	
	vector <int> a;
	int temp;
	rep(i,3){
		cin >> temp;
		a.pb(temp);
	}
	sort(a.begin(),a.end());
	cout << a[2]*10+a[1] + a[0] << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ans=0,max=0;
	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='D')
		  ans--;
		else
		  ans++;
		if(ans>max) max=ans;
	}
	cout<<max<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<queue>
#include<cassert>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define S second
#define F first
using namespace std;
typedef pair<int,int> P;
struct Pox
{
  P cur;
  int man;
  int cost;  
  Pox(P cur=P(-1,-1),int man=-1,int cost=-1):cur(cur),man(man),cost(cost){}
  bool operator < (const Pox &a)const
  {
    return cost > a.cost;
  }
};

int H,W;
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
int G[8][8];
int mincost[8][8][4];//mincost[a][b][c] := the minumum number of push, P(a,b) the direction is c
P cargo,src,dest;

int rev(int i)
{
  if(i == 0)return 1;
  else if(i == 1)return 0;
  else if(i == 2) return 3;
  else if(i == 3)return 2;
  assert(false);
}


bool isOK(P p,P q)
{
  bool used[H][W];
  rep(i,H)rep(j,W)used[i][j] = false;
  queue<P> que;
  que.push(p);
  used[p.S][p.F] = true;
  while(!que.empty())
    {
      P pos = que.front(); que.pop();
      if(pos == q)return true;
      rep(i,4)
	{
	  int nx = pos.F + dx[i];
	  int ny = pos.S + dy[i];
	  if(!(0 <= nx && nx < W && 0 <= ny && ny < H))continue;
	  if(G[ny][nx] == 1 || G[ny][nx] == 2)continue;
	  if(used[ny][nx])continue;
	  used[ny][nx] = true;
	  que.push(P(nx,ny));
	}
    }
  return false;
}

int main()
{
  while(cin >> W >> H,W|H)
    {
      rep(i,H)
	rep(j,W)
	{
	  cin >> G[i][j];
	  if(G[i][j] == 2)cargo = P(j,i),G[i][j] = 0;//cargo no basy wo kaeru
	  else if(G[i][j] == 3)dest = P(j,i);
	  else if(G[i][j] == 4)src = P(j,i);
	  mincost[i][j][0] = mincost[i][j][1] = mincost[i][j][2] = mincost[i][j][3] = inf;
	}


      priority_queue<Pox> Q;
      rep(i,4)
	{
	  int nx = cargo.F + dx[i];
	  int ny = cargo.S + dy[i];
	  if(!(0 <= nx && nx < W && 0 <= ny && ny < H))continue;
	  if(G[ny][nx] == 1)continue;
	  if(isOK(src,P(nx,ny)))
	    Q.push(Pox(cargo,i,0)),mincost[cargo.S][cargo.F][i] = 0;	  
	}


      while(!Q.empty())
	{
	  Pox pox = Q.top(); Q.pop();
	  G[pox.cur.S][pox.cur.F] = 2;
	  //cout << "pox : cargo = (" << pox.cur.F << "," << pox.cur.S << ") ," << pox.man << "," << pox.cost << endl;
	  if(pox.cur == dest)
	    {
	      cout << pox.cost << endl;
	      goto F;
	    }


	  P man = P(pox.cur.F + dx[pox.man],pox.cur.S + dy[pox.man]);
	  rep(i,4)
	    {
	      int nx = pox.cur.F + dx[i];
	      int ny = pox.cur.S + dy[i];
	      int rnx = pox.cur.F - dx[i];
	      int rny = pox.cur.S - dy[i];
	      if(!(0 <= nx && nx < W && 0 <= ny && ny < H))continue;
	      if(!(0 <= rnx && rnx < W && 0 <= rny && rny < H))continue;
	      if(G[ny][nx] == 1 || G[rny][rnx] == 1)continue;
	      if(mincost[ny][nx][rev(i)] <= pox.cost+1)continue;
	      if(isOK(man,P(rnx,rny)))
		Q.push(Pox(P(nx,ny),rev(i),pox.cost+1)),mincost[ny][nx][rev(i)] = 0;	  
	    }
	  G[pox.cur.S][pox.cur.F] = 0;
	}

      cout << -1 << endl;
    F:;
    }
  return 0;
}

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

int main(){
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> a(100005,0);
  int sum = 0;
  for(int i=0; i<n-1; i++){
    if(s.at(i) == 'A' && s.at(i+1) == 'C'){
      sum++;
    }
    a.at(i+1) = sum;
  }
  for(int i=0; i<q; i++){
    int l,r;
    cin >> l >> r;
    l--;
    r--;
    cout << a.at(r) - a.at(l) << endl;
  }

  return 0;
}


Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n;
string s;

bool fun(int l, int r)
{
  	r--;
    while (l < r) {
        if (s[l] != s[r]) return false;
        l++; r--;
    }
    return true;
}

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s;
    n = s.length();
    if (!fun(0, n)) cout << "No" << E;
    else {
        if (!fun(0, n / 2) || !fun(n / 2 + 1, n)) cout << "No" << E;
        else cout << "Yes" << E;
    }
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
#define all(v) v.begin(),v.end()
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main(){
    int n,k;
    cin >> n >> k;
    if(k%2==1){
        ll x=n/k;
        cout << x*x*x << endl;
        return 0;
    }
    else{
        ll x=n/k;
        ll l=k/2;
        ll y=(n+l)/k;
        cout << x*x*x + y*y*y << endl;
        return 0;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Integer;
import java.lang.Math;

class Item {
  private int value;
  private int weight;

  public Item(int value, int weight) {
    this.set(value, weight);
  }

  public void set(int value, int weight) {
    this.value = value;
    this.weight = weight;
  }

  public int getValue() {
    return this.value;
  }

  public int getWeight() {
    return this.weight;
  }
  

}

class Main {
  private static int[][] dp;

  private static int calc(int N, int W, Item[] item) {
    if (N <= 0) {
      return 1;
    }

    for (int i = 1; i < N + 1; i++) {
      for (int j = 0; j < W + 1; j++)  {
        int candidate1 = dp[i - 1][j];
        int candidate2 = 0;

        if ((j - item[i].getWeight() >= 0) && (item[i].getWeight() <= W)) {
          candidate2 = (dp[i - 1][j - item[i].getWeight()] + item[i].getValue());
        } else {
          candidate2 = Integer.MIN_VALUE;
        }

        dp[i][j] = Math.max(candidate1, candidate2);
        //System.out.println(((j - item[i].getWeight() >= 0) && (item[i].getWeight() <= W)) + " candidate1 " + candidate1 + " candidate2 " + candidate2);
        //System.out.println("dp[" + i + "]" + "[" + j + "], " + dp[i][j]);
      }
    }

    return dp[N][W];
  }

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int W = sc.nextInt();
    Item[] item = new Item[N + 1];
    item[0] = new Item(0, Integer.MIN_VALUE);
    for (int i = 1; i < N + 1; i++) {
      int value = sc.nextInt();
      int weight = sc.nextInt();
      item[i] = new Item(value, weight);
    }
    dp = new int[N + 1][W + 1];

    // init kind of coin(i) == 0;
    int i = 0;
    for (int j = 0; j < W + 1; j++) {
      dp[i][j] = 0;
    }

    int result = calc(N, W, item);

    System.out.println(result);
  }
}

Measured memory_bytes: 30696
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = 16714589;
const int N = 1e5 + 555; // TL MB
const double PI = acos(-1.0);
double eps = 1e-6;

void solve()
{
	int n, m;
	cin >> n >> m;
	vector<bool> bad(n + 1, true);
	vector<int> h(n + 1);
	for(int i = 1; i <= n; ++i){
		cin >> h[i];
	}
	for(int i = 0; i < m; ++i)
	{
		int a, b;
		cin >> a >> b;
		if(h[a] <= h[b]) bad[a] = false;
		if(h[b] <= h[a]) bad[b] = false;
	}
	int res = 0;
	for(int i = 1; i <= n; ++i) res += bad[i];
		cout << res;
}


 
 
int main()
{
	Red;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
  	int T = 1; 
  	//cin >> T; 
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
    return 0;
}

Measured memory_bytes: 3708