akhauriyash/Code-Regression huggingface dataset:
# https://atcoder.jp/contests/abc135/tasks/abc135_b
# B - 0 or 1 Swap

N = int( input() )
plist = list( map( int, input().split()))
sorted_list = sorted( plist )

diff = 0
for n in range( N ):
    if plist[ n ] != sorted_list[ n ]:
        diff += 1

if diff == 0 or diff == 2:
    print( 'YES' )
else:
    print( 'NO' )

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

#define int long long
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define reps(i, n) for (int (i) = 1; (i) <= (n); (i)++)
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.141592653589793238462643383279;
const int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

int N;
int s[110000];
unordered_map<int, int> mp;

// オーバーフロー怖いけど、通るやろ！ｗ
signed main() {
    cin >> N;
    rep(i, N) {
        cin >> s[i];
        for (int j = 2; j * j * j <= s[i]; j++) { while (s[i] % (j * j * j) == 0) { s[i] /= (j * j * j); }}
        mp[s[i]]++;
    }
    int ans = 0;
    if (mp[1] > 0) { ans++, mp[1] = 0; }
    rep(i, N) {
        int cur = s[i], counter = 1;
        for (int j = 2; j * j * j <= s[i]; j++) {
            if (cur % (j * j) == 0) {
                counter *= j;
                cur /= (j * j);
            } else if (cur % j == 0) {
                counter *= j * j;
                cur /= j;
            }
        }
        int rt = round(sqrt(cur));
        if (rt * rt == cur) { counter *= rt; }
        else { counter *= cur * cur; }
        ans += max(mp[s[i]], mp[counter]);
        mp[s[i]] = mp[counter] = 0;
    }
    cout << ans << endl;
}

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

#define DEBUG(x) cerr << #x << " = " << x << endl

int main() {
    while(true) {
        int N, L; cin >> N >> L;
        if(N == 0 && L == 0) break;
        vector<int> pos(N);
        // L=-1, R=1
        vector<int> dir(N);
        for(int i = 0; i < N; i++) {
            int p; char d;
            cin >> d >> p;
            pos[i] = p;
            dir[i] = (d == 'R') ? 1 : -1;
        }
        int last = 0;
        int lastsecond = 0;
        int second = 0;
        int lastPos = (int)1e9;
        vector<int> live(N, 1);
        while(true) {
            second++;
            vector<int> on(L + 1, 0);
            for(int i = 0; i < N; i++) {
                if(live[i]) {
                    pos[i] += dir[i];
                    on[pos[i]]++;
                }
            }
            for(int i = 0; i < N; i++) {
                if(live[i]) {
                    if(on[pos[i]] >= 2) {
                        dir[i] *= -1;
                    }
                }
            }
            for(int i = 0; i < N; i++) {
                if(live[i]) {
                    if(pos[i] == 0 || pos[i] == L) {
                        live[i] = 0;
                        if(second == lastsecond) {
                            if(pos[i] < lastPos) {
                                last = i;
                                lastsecond = second;
                                lastPos = pos[i];
                            }
                        }
                        else {
                            last = i;
                            lastsecond = second;
                            lastPos = pos[i];
                        }
                    }
                }
            }
            bool f = false;
            for(int i = 0; i < N; i++) {
                if(live[i]) f = true;
            }
            if(!f) break;
        }
        cout << lastsecond << ' ' << last + 1 << endl;
    }
}

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

int main() {
  long long n,k;
  cin >> n >> k;
  long long l = (n/k)*(n/k)*(n/k);
  if (k % 2) {
    cout << l << endl;
  }
  else {
    long long m = ((n+k/2)/k)*((n+k/2)/k)*((n+k/2)/k);
    cout << l+m << endl;
  }
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;
 
int main(){
	int n;
	cin >> n;

	int arr[n];

	for(int i=0; i<n; i++) {
		cin >> arr[i];
	}
	for(int i=n-1; i>=0; i--) {
		if(i==0) {
			cout << arr[i] << endl;
		}else {
			cout << arr[i] << " ";
		}
	}

	return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>

int main(void) {
	int N, X,i;
	scanf("%d %d", &N, &X);
	int L[100] = {};
	for ( i = 0; i < N; i++) {
		scanf("%d", &L[i]);
	}
	int total=0;
	for ( i = 0; total <= X&&(i<N+1); i++) {
		total += L[i];
	}
	printf("%d", i);

	return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix dinic next_combination topcoder lcm

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

    Int(n);
    vvi data(n, vi(n));
    rep(i, n) {
        rep(j, n) {
            cin >> data[i][j];
        }
    }

    vvi graph = data;
    rep(i, n) {
        graph[i][i] = 0;
    }
    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }

    bool ok = true;
    rep(i, n) {
        rep(j, n) {
            if (graph[i][j] != data[i][j]) {
                ok = false;
                break;
            }
        }
        if (!ok) break;
    }
    if (!ok) {
        std::cout << -1 << std::endl;
        return 0;
    }

    int ans = 0;
    rep(i, n) {
        rep(j, n) {
            int tmp = graph[i][j];
            bool yui = false;
            rep(k, n) {
                if (i == k || j == k) continue;
                //std::cout << i << " " << k << " " << j << std::endl;
                if (tmp == graph[i][k] + graph[k][j]) {
                    yui = true;
                    break;
                }
            }
            if (!yui) {
                ans += graph[i][j];
            }
        }
    }
    std::cout << ans / 2 << std::endl;


    return 0;
}


Measured memory_bytes: 1664
import java.util.*; 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        Queue<String> qProcess = new LinkedList<String>();
        Queue<Integer> qTime = new LinkedList<Integer>();        
        int totalTime = 0;
        for (int i = 0; i < n; i++) {
            qProcess.add(sc.next());
            qTime.add(sc.nextInt());
        }         
        while (qProcess.size()>0) {
            if (qTime.peek() - q > 0) {
                qProcess.add(qProcess.poll());
                qTime.add(qTime.poll()-q);
                totalTime = totalTime + q;
            } else {
                totalTime = totalTime + qTime.poll();
                System.out.println(qProcess.poll() + ' ' + totalTime);
            }
        }
    }
}


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

int main()
{
	//input
	int N; cin >> N;
	pair<pair<string, int>, int> p[110];
	for (int i = 0; i < N; i++){
		string S; int t;
		cin >> S >> t;
		p[i] = make_pair(make_pair(S, -t), i);
	}
			
	//compute
	sort(p, p+N);
	
	//output
	for (int i = 0; i < N; i++){
		cout << p[i].second+1 << endl;
	}
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: i64,
    };
    let mut ans: i64 = 0;
    for i in 1..=10 {
        let pay = 1000 * i;
        if pay >= n {
            ans = pay;
            break;
        }
    }
    println!("{}", ans - n);
}


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

int main(){
	int n, num;
	char a[1100] = {};
	istringstream ss;
	set<int> s;
	
	cin>>n;
	
	for(int i = 0; i < n; i++){
		cin>>a[i];
	}
	
	for(int i = 0; i < 4; i++){
		for(int j = 0; j+i < n; j++){
			string temp;
			for(int k = 0; k <= i; k++){
				temp += a[j+k];
			}
			ss = istringstream(temp);
			ss >> num;
			s.insert(num);
		}
	}
	
	for(int i = 0; ; i++){
		if(s.count(i) == 0){
			cout<<i<<endl;
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 3296
#pragma GCC optimize("Ofast")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define SZ(n)       ((int)(n).size())
#define all(n)      (n).begin(), (n).end()
#define anal           '\n'
#define mod         1000000007
#define fst         first
#define sec         second
#define pr(n)       cerr << n  << " ";
#define pfor(a)     for(auto (w) : (a)) pr(w)
//const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-



//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
int main(){
I_AM_SPEED;
#ifndef ONLINE_JUDGE  
        freopen("input.in", "r", stdin);
        freopen("output.in", "w", stdout);
#endif 
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
    
  int n; cin >> n;
  int cnt = 0;
  bool ans = false;
  while(n--){
      int x, y; cin >> x >> y;
      if(x == y) cnt++;
      else cnt = 0;

      if(cnt >= 3) ans = true;
  }
  if(ans) cout << "Yes\n";
  else cout << "No\n";
  
    
  
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//printclock; 
return  0 ;      
}        



      

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define int long long
using namespace std;
int k,n,ans;
int a[2000005];
signed main(){
	scanf("%lld",&k);
	scanf("%lld",&n);
	for (register int i=1; i<=n ; ++i) scanf("%lld",&a[i]);
	for (register int i=1; i<n; ++i) ans=max(ans,a[i+1]-a[i]);
	ans=max(ans,k-a[n]+a[1]);
	printf("%lld\n",k-ans);
return 0;	
}

Measured memory_bytes: 1792
n,m = map(int, input().split())
As = [list(input()) for i in range(n)]
Bs = [list(input()) for i in range(m)]

for i in range(n-m+1):
    for j in range(n-m+1):
        cut = []
        for k in range(m):
            cut.append(As[j+k][i:i+m])
        # print(i,j,cut)
        if cut == Bs:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3064
#include <stdio.h>
#define alpha 26

int main(void){
  int i, cnt[alpha] = {0};
  char ch;

  while (scanf("%c", &ch) != EOF)
    if ('a' <= ch && ch <= 'z')
      cnt[ch - 'a']++;
    else if ('A' <= ch && ch <= 'Z')
      cnt[ch - 'A']++;

  for(i = 0; i < alpha; i++)
    printf("%c : %d\n", 'a' + i, cnt[i]);

  return 0;
}

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

int main()
{


	int n,d;
	cin >> n >> d;
	vector<int> x(n),y(n);
	for (int i=0;i<n;++i)
	{
		cin >> x[i] >> y[i];
	}

	int64_t d2=(int64_t)d*d;
	int count=0;
	for (int i=0;i<n;++i)
	{
		if ((int64_t)x[i]*x[i]+(int64_t)y[i]*y[i]<=d2)
		{
			++count;
		}
	}
	cout << count << endl;
}





Measured memory_bytes: 4836
#include <stdio.h>
int main(){
  int n;//n:トレーニングした回数 
  long long power=1;//power:パワー
  scanf("%d",&n );
  for(int i=1;i<=n;i++){
    power*=(long long)i;
    power%=1000000007;
  }
  printf("%d",power);
}

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

int main(){
  int f,i,j,N,a[100001],m;
  vector<int> v;
  set<int> se;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
  }

  m=max(a[0],a[1]);
  auto p=se.insert(1);
  v.push_back(1);
  for(i=1;i*i<=m;i++){
    if(a[0]%i==0){
      p=se.insert(i);
      if(p.second)v.push_back(i);
      p=se.insert(a[0]/i);
      if(p.second)v.push_back(a[0]/i);
    }
    if(a[1]%i==0){
      p=se.insert(i);
      if(p.second)v.push_back(i);
      p=se.insert(a[1]/i);
      if(p.second)v.push_back(a[1]/i);
    }
  }
  sort(v.begin(),v.end(),greater<int>());

  i=0;
  while(1){
    f=0;
    for(j=0;j<N;j++){
      if(a[j]%v[i]!=0){
        if(f==0){
          f=1;
        }else{
          f=2;
          break;
        }
      }
    }
    if(f<2){
      printf("%d\n",v[i]);
      return 0;
    }
    i++;
  }
  return 0;
}

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

using namespace std;

#define bug(x) cerr << #x << " = " << x << '\n'
#define ll     long long
#define maxn

int main() {
        //freopen(".inp","r",stdin);

        int k = 0;
        cin >> k;
        ll p = 0;
        for(int i = 1; i <= 1000000; ++ i) {
            p = 10LL * p % k;
            p = (p + 7) % k;
            if(p == 0) return cout << i, 0;
        }
        cout << -1;
}



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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define vi vector<int>

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const int N = 100005;

int a[N], b[N], c[N], perm[N];
vector<int> vec;
int main(){
	int n; sd(n);
	ll totala = 0, totalb = 0;
	ll sm = 0;
	for(int i = 1; i <= n; i++) sd(a[i]), totala+= a[i], perm[i] = i;
	for(int i = 1; i <= n; i++){
		sd(b[i]), totalb += b[i];
		if(a[i] < b[i]){
			vec.push_back(i);
		}
		c[i] = a[i];
	}
	sort(perm + 1, perm + n + 1, [](int i, int j){return a[i] - b[i] > a[j] - b[j];});
	ll curr = 0;
	int iter = 0;
	for(int i = 1; i <= n; i++){
		int ind = perm[i];
		int lft = c[ind] - b[ind];
		for(; iter < vec.size() && lft >= 0;){
			int t = max(0, min(lft, b[vec[iter]] - c[vec[iter]]));
			c[vec[iter]] += t;
			lft -= t;
			c[ind] -= t;
			if(c[vec[iter]] == b[vec[iter]]){
				iter++;
			} else break;
		}

	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(c[i] != a[i]) ans++;
		if(c[i] < b[i]){
			ans = -1;
			break;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 2172
/*
    B - Time Limit Exceeded
    https://atcoder.jp/contests/abc112/tasks/abc112_b
*/
#include <bits/stdc++.h>
using namespace std;

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

    int n, t, cost = 1001;
    cin >> n >> t;

    for (int i = 0; i < n; i++) {
        int ci, ti;
        cin >> ci >> ti;
        if (ti <= t) {
            cost = min(cost, ci);
        }
    }
    if (cost != 1001)
        cout << cost << endl;
    else
        cout << "TLE" << endl;
}

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

const long long INF = 1LL << 60;

int N, W;
int w[110], v[110];

long long dp[110][100010];

int main() {
    cin >> N >> W;
    for(int i = 1; i <= N; i++)
        cin >> w[i] >> v[i];

    for(int i = 0; i < 110; i++)
        for(int j = 0; j < 100010; j++)
            dp[i][j] = INF;

    dp[0][0] = 0;

    for(int i = 1; i <= N; i++) {
        for(int j = 0; j <= 100000; j++) {
            if(j >= v[i]) dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
            dp[i][j] = min(dp[i][j], dp[i - 1][j]);
        }
    }

    int res = 0;
    for(int j = 0; j <= 100000; j++)
        if(dp[N][j] <= W) res = j;

    cout << res << endl;
}

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

#define ll long long
#define llu unsigned long long
#define pb push_back
#define mp make_pair
#define tc int t; cin>>t;while(t--)
#define sfi(x) scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define f(i,a,n) for(int i=a ; i<n; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int main()
{
    double a, b, h, m;
    cin>>a>>b>>h>>m;
    h=h*5 + (ld)(m/12);
    double angle=(abs(h-m)*3.14159265358979323846)/30;
    double ans= sqrt(a*a+b*b-2*a*b*cos(angle));
    cout<<fixed<<setprecision(20)<<ans;
}



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

int main() {
    int n, w; cin >> n >> w;
    long long dp[w+1] = {0};
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        int u; long long v; cin >> u >> v;
        for (int j = w; j >= 0; j--) {
            if (u+j > w) continue;
            dp[u+j] = max(dp[u+j], dp[j]+v);
            ans = max(ans, dp[u+j]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
N,M=map(int, input().split())

sc = []
for i in range(M):
    sc.append(list(map(int, input().split())))
for i in range(10**N):
    ans = str(i)
    if len(ans) == N and all(ans[s-1] == str(c) for s,c in sc):
        print(ans)
        quit()
print(-1)

Measured memory_bytes: 3064
from functools import reduce
import heapq, sys


input = sys.stdin.readline
N = int(input())
XD = sorted([tuple(map(int, input().split())) for _ in range(N)], key=lambda x: x[0], reverse=True)
P = 998244353


class Node:
    def __init__(self, ch):
        self.ch = ch
        if len(self.ch) == 0:
            self.score = 2
        else:
            self.score = reduce(lambda a, b: (a * b) % P, [ch.score for ch in self.ch]) + 1

hq = []  # (x, Node)
heapq.heapify(hq)
for x, d in XD:
    ch = []
    while len(hq) != 0 and hq[0][0] < x+d:
        ch.append(heapq.heappop(hq)[1])
    heapq.heappush(hq, (x, Node(ch)))

ans = reduce(lambda a, b: (a * b) % P, [node.score for x, node in hq])
print(ans)




Measured memory_bytes: 149336
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func solve(H, W int) {
	a := make([][]int, H+2)
	b := make([][]int, H+2)
	for i := 0; i < H+2; i++ {
		a[i] = make([]int, W+2)
		b[i] = make([]int, W+2)
	}
	for y := 0; y < H; y++ {
		for x := 0; x < W; x++ {
			a[y+1][x+1] = 1
		}
	}
	for y := 0; y < H; y++ {
		for x := 0; x < W; x++ {
			for dy := -1; dy <= 1; dy++ {
				for dx := -1; dx <= 1; dx++ {
					if a[y+dy+1][x+dx+1] == 1 {
						b[y+dy+1][x+dx+1]++
					}
				}
			}
		}
	}
	for y := 0; y < H+2; y++ {
		out(a[y])
	}
	out("----")
	for y := 0; y < H+2; y++ {
		out(b[y])
	}
	ans := 0
	for y := 1; y <= H; y++ {
		for x := 1; x <= W; x++ {
			if b[y][x]%2 == 1 {
				ans++
			}
		}
	}
	out(ans)
}

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

	N, M := getInt(), getInt()

	// solve(N, M)

	if M == 1 && N == 1 {
		out(1)
		return
	}
	if M == 2 && N == 2 {
		out(0)
		return
	}
	if M == 1 {
		out(N - 2)
		return
	}
	if N == 1 {
		out(M - 2)
		return
	}

	N = max(0, N-2)
	M = max(0, M-2)
	out(N * M)

}


Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod1 1000000007
#define mod2 1000000009
int getTheAnswer() {
    return 42;
}

using namespace std;
using ll=long long;

class CMarks {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        int n,k;
        cin>>n>>k;
        vector<ll> a(n);
        for (int i=0;i<n;i++)
            cin>>a[i];
        for (int i=k;i<n;i++){
            if (a[i]>a[i-k])
                cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
	}
};


int main() {
	CMarks solver;
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4780
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static class Walk implements Comparable<Walk>{
		int cost;
		int pos;
		int use = 2;
		
		public Walk(int cost, int pos, int use) {
			super();
			this.cost = cost;
			this.pos = pos;
			this.use = use;
		}

		@Override
		public int compareTo(Walk o) {
			if(this.cost - o.cost == 0){
				return this.use - o.use;
			}else{
				return this.cost - o.cost;
			}
		}
		
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(true){
			final int n = sc.nextInt();
			final int m = sc.nextInt();
			
			if(n == 0 && m == 0){
				break;
			}
			
			int[][] adj = new int[n][n];
			
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					adj[i][j] = -1;
				}
			}
			
			for(int i = 0; i < m; i++){
				final int from = sc.nextInt() - 1;
				final int to = sc.nextInt() - 1;
				final int cost = sc.nextInt();
				
				adj[from][to] = adj[to][from] = cost;
			}
			
			
			PriorityQueue<Walk> queue = new PriorityQueue<Walk>();
			queue.add(new Walk(0,0,2));
			
			boolean[][] visited = new boolean[n][3];
			
			while(!queue.isEmpty()){
				Walk walk = queue.poll();
				
				if(walk.pos == n - 1 && (walk.use != 1)){
					System.out.println(walk.cost);
					break;
				}
				
				//System.out.println(walk.pos + " " + walk.use + " " + walk.cost);
				
				if(visited[walk.pos][walk.use]){
					continue;
				}else{
					visited[walk.pos][walk.use] = true;
				}
				
				
				for(int to = 0; to < n; to++){
					if(adj[walk.pos][to] != -1){
						if(walk.use == 1){
							if(!visited[to][0]){
								queue.add(new Walk(walk.cost, to, 0));
							}					
						}else{
							if(walk.use == 2){
								if(!visited[to][1]){
									queue.add(new Walk(walk.cost, to, 1));
								}
							}
							
							if(!visited[to][walk.use]){
								queue.add(new Walk(walk.cost + adj[walk.pos][to], to, walk.use));
							}
						}
					}
				}
			}
			
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n ,j ,k ,x , sum = 0;
    cin >> n >> k;
    multiset<ll, greater<ll> > mons;
    for ( ll i = 0; i < n; i++ )
    {
        cin >> x;
        sum += x;
        mons.insert(x);
    }
    multiset<ll, greater<ll>> ::iterator it;
    for( j = 0, it = mons.begin(); j < k && it != mons.end(); it++, j++)
    {

        x = *it;
        sum -=  x;
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 9600
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    var N = nl()
    val ans = ArrayBuffer[Int]()
    var k = 0
    while(N != 0) {
      val sign = if(k % 2 == 0) 1 else -1
      // 次の位で表現できないなら必ずこの位の成分をもっている
      if (N % (1L << (k + 1)) != 0) {
        ans += 1
        N -= sign * (1L << k)
      } else {
        ans += 0
      }
      k += 1
    }

    if (ans.isEmpty) out.println(0)
    else out.println(ans.reverse.mkString)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    rep(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    rep(n) { i =>
      rep(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    rep(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Int](as.length + 1)
    rep(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

Measured memory_bytes: 25512
#include <stdio.h>

void minMax(int x, int y, int X, int Y, int* min, int* max) {
  if (x < y) {
    *min = X;
    *max = Y;
  } else {
    *min = Y;
    *max = X;
  }
}

int main(void) {
  int N, M;
  scanf("%d %d", &N, &M);
  int H[N];
  int good[N];
  for (int n = 0; n < N; ++n) {
    scanf("%d", &H[n]);
    good[n] = 1;
  }
  
  for (int m = 0; m < M; ++m) {
    int A, B;
    scanf("%d %d", &A,&B);
    --A; --B;
    
    if (H[A] < H[B]) {
      good[A] = 0;
    } else if (H[B] < H[A]) {
      good[B] = 0;
    } else {
      good[A] = good[B] = 0;
    }
  }
  
  int numGood = 0;
  for (int n = 0; n < N; ++n) {
    //fprintf(stderr, "good[%d] = %d\n", n+1, good[n]);
    if (good[n]) ++numGood;
  }
  printf("%d\n", numGood);
  
  return 0;
}

Measured memory_bytes: 2920
import sys

input=sys.stdin.readline

N,M=map(int,input().split())
edge=[[] for i in range(N)]
for i in range(M):
    u,v=map(int,input().split())
    edge[u-1].append(v-1)
    edge[v-1].append(u-1)

def is_bipartgraph():
    color=[0]*N
    used=[False]*N
    b=0
    nb=0
    for i in range(N):
        if not used[i]:
            flag=True
            stack=[(i,1)]
            black=0
            white=0
            while stack:
                v,c=stack.pop()
                if not used[v]:
                    color[v]=c
                    black+=(c==1)
                    white+=(c==-1)
                    used[v]=True
                    for nv in edge[v]:
                        if color[nv]==color[v]:
                            flag=False
                        elif color[nv]==0:
                            stack.append((nv,-c))
            b+=flag
            nb+=(not flag)
    return (b,nb)

a=0
for i in range(N):
    if not edge[i]:
        a+=1

b,nb=is_bipartgraph()
rest=N-(b+nb)
b-=a
print(a*N+nb*(a+nb+b)+b*(a+nb+2*b)+rest*a)


Measured memory_bytes: 75868
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstring>
#include<set>
#include<map>
#include<utility>
using namespace std;

#define MAX_V 100001
#define INF 1000000000000000
using namespace std;
struct edge{int to;int cost;};
typedef pair<pair<int,int>,int> P;

int V;
vector<edge> G[MAX_V];
long d[MAX_V];
pair<int ,int> g[310][310];
int n,m,a,b,l,c,q;
void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P> > que;
    g[s][s]={0,0};
    que.push(P({0,0},s));
    while(!que.empty()){
        P p=que.top(); que.pop();
        int v=p.second;
        if(g[s][v]<p.first) continue;
        for(int i=0;i<G[v].size();i++){
            edge e=G[v][i];
            pair<int,int> cc;
            if(g[s][v].second+e.cost<=l){
                cc={g[s][v].first,g[s][v].second+e.cost};
            }
            else{
                cc={g[s][v].first+1,e.cost};
            }
            if(g[s][e.to]>cc||g[s][e.to].first==-1){
                g[s][e.to]=cc;
                que.push(P(cc,e.to));
            }
        }
    }
}


int main(){
    scanf("%d%d%d",&n,&m,&l);
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            g[i][j].first=-1;
            g[i][j].second=0;
        }
    }
    for(int i=0;i<m;i++){
        scanf("%d%d%d",&a,&b,&c);
        if(c<=l){
            /*g[a][b].first=l;
            g[a][b].second=l-c;
            g[b][a].first=l;
            g[b][a].second=l-c;*/
            G[a].push_back({b,c});
            G[b].push_back({a,c});
        }
    }
    for(int i=1;i<=n;i++){
        dijkstra(i);
    }
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%d%d",&a,&b);
        printf("%d\n",g[a][b].first);
    }
}

Measured memory_bytes: 4736
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    k <- getInt
    [a,b] <- getIntList
    putStrLn $ if any (\x -> x `mod` k == 0) [a..b] then "OK" else "NG"

Measured memory_bytes: 3780
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
#include <map>
using namespace std;

const double PI=acos(-1);

int main(){
    string x;
    cin >> x;
    bool z = true;
    int a = 0;
    for(int i = 0; i < x.length(); i++){
        if(x[i] != '9'){
            z = false;
        }
        a += x[i] - '0';
    }
    if(z){
        cout << x.length()*9 << endl;
    }else if(x.length() == 1){
        cout << (x[0] - '0') << endl;
    }else if(x[0] == '1'){
        int b = (x.length() - 1)*9;
        if(a > b) cout << a << endl;
        else cout << b << endl;
    }else{
        int b = (x.length() - 1)*9 + (x[0] - '1');
        if(a > b) cout << a << endl;
        else cout << b << endl;
    }
    return 0;
}

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

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

  vector<int> l(n);
  for (int i = 1; i < n; i++) {
    l[i] += l[i - 1];
    if (s[i - 1] == 'W') l[i]++;
  }
  vector<int> r(n);
  for (int i = n - 2; i >= 0; i--) {
    r[i] += r[i + 1];
    if (s[i + 1] == 'E') r[i]++;
  }

  int ans(n);
  for (int i = 0; i < n; i++) {
    ans = min(ans, l[i] + r[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3076
// Problem : D - I hate Factorization
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define FIO ios_base::sync_with_stdio(0); cin.tie(0);
#define T() int tt; cin >> tt; rep1(qq,1,tt)
#define rep(i,start,lim) for(int i=start;i<lim;i++)
#define rep1(i,start,lim) for(int i=start; i<=lim; ++i)
#define repd(i,start,lim) for(int i=start;i>=lim;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define br cout<<"\n"
#define MOD (1000000007LL)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define eps (1e-6)
#define what_is(x) cerr << #x << " is " << x << "\n";
#define int long long int
#define infll 9e18
#define inf 1e12

#define lnode (2 * node + 1)
#define rnode (2 * node + 2)

using namespace std;

typedef pair<int, int> pii;

const int N = 3 * 1e6 + 2;

int n, x;

int32_t main(){

  FIO
  //cout << fixed << setprecision(10);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  cin >> x;
  
  for(int a = 0; a < 1000; ++a){
    int A = a * a * a * a * a;
    for(int b = -1000; b < 1000; ++b){
      int B = b * b * b * b * b;
      if(A - B == x){
        return cout << a << ' ' << b << '\n', 0;
      }
    }    
  }
  
	return 0;
}






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

using namespace std;

using ll = int64_t;
using ull = uint64_t;
using ld = long double;

int main() {
#ifdef NIZNIY_MAGAZIN_MIR_V_CENTRE_VINNITSY
    freopen("in", "r", stdin);
#endif
    int a, b, c;
    cin >> a >> b >> c;
    int x, y;
    cin >> x >> y;
    x *= 2;
    y *= 2;
    int ans = 2e9 + 7;
    for (int ba = 0; ba <= x; ba++) {
        int morea = x - 2 * ba, moreb = y;
        morea = max(morea, 0);
        int takec = morea;
        morea -= takec;
        moreb -= takec;
        moreb = max(moreb, 0);
        int cb = min(b, c + c);
        int cans = ba * a + takec * c;
        int adans = min(cb * (moreb / 2) + c * (moreb % 2), cb * ((moreb + 1) / 2));
        ans = min(ans, cans + adans);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
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; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    ll n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;



}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    solve();


    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j=0,c=0;
    string s,x;
    cin >>s>>x;
    for(int i=0;s[i]!='\0';i++)
    {
        if(s[i]==x[j])
        c++;
        j++;
    }
    cout<<c<<endl;
    return 0;

}



Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

typedef pair<ll, ll> P;

ll n, q, k, a, b, c, x, y;
vector<P> es[100000];
ll d[100000];

void dfs(int v, int pa, ll x) {
	d[v] = x;
	REP(i, es[v].size()) if (es[v][i].second != pa) dfs(es[v][i].second, v, x + es[v][i].first);
}

int main(int argc, char **argv) {
	cin >> n;
	REP(i, n - 1) {
		cin >> a >> b >> c;
		--a; --b;
		es[a].push_back(MP(c, b));
		es[b].push_back(MP(c, a));
	}
	cin >> q >> k;
	--k;
	dfs(k, -1, 0);
	REP(i, q) {
		cin >> x >> y;
		--x; --y;
		cout << (d[x] + d[y]) << endl;
	}
	return 0;
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define inlld(x) scanf("%lld", &x)
#define ind(x) scanf("%d", &x)
#define inlld2(x, y) scanf("%lld%lld", &x, &y)
#define inlld3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define ind2(x, y) scanf("%d%d", &x, &y)
#define ind3(x, y, z) scanf("%d%d%d", &x, &y, &z)

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

typedef long long ll;
typedef long double ld;

using namespace std;

ll n, dp[N][2];
vector<ll> adj[N];

void dfs(ll u, ll col, ll p)
{
	if (dp[u][col] != -1)
	{
		return;
	}
	dp[u][col] = 1;
	for (auto v : adj[u])
	{
		if (v == p)
			continue;
		if (col == 0)
		{
			dfs(v, 0, u);
			dfs(v, 1, u);
			dp[u][col] *= (dp[v][0] + dp[v][1]) % MOD;
		}
		else
		{
			dfs(v, 0, u);
			dp[u][col] *= dp[v][0];
		}
		dp[u][col] %= MOD;
	}
	// printf("%lld %lld %lld\n", u, col, dp[u][col]);
}

int main()
{
	inlld(n);
	for (ll a = 1; a < n; a++)
	{
		ll u, v;
		inlld2(u, v);
		adj[u].pb(v);
		adj[v].pb(u);
		dp[a][0] = dp[a][1] = -1;
	}
	dp[n][0] = dp[n][1] = -1;
	dfs(1, 0, 0);
	dfs(1, 1, 0);
	printf("%lld\n", (dp[1][0] + dp[1][1]) % MOD);
	return 0;
}

Measured memory_bytes: 18984
#include<iostream>
#define rep(i,N) for( i = 1; i <= N; i++ )
using namespace std;

int n;
int data[102][102];
int rui[102][102];		//rui[i][j] = (1,1)を左上とするi*j行列の要素和

int main(){
	int i,j,k,l;
	cin >> n;
	rep(i,n){
		rep(j,n){
			cin >> data[i][j];
		}
	}
	
	//左→右
	rep(i,n){
		rep(j,n){
			rui[i][j] = rui[i][j-1] + data[i][j];
		}
	}
	//上→下
	rep(j,n){
		rep(i,n){
			rui[i][j] = rui[i-1][j] + rui[i][j];
		}
	}
	
	int ans = -1145141919;
	rep(i,n){
		rep(j,n){
			rep(k,n){
				rep(l,n){
					if( k < i || l < j )
						continue;
					//左上(i,j), 右下(k,l)とする行列の要素和を求める
					int mats = rui[k][l] - rui[k][j-1] - rui[i-1][l] + rui[i-1][j-1];
					ans = max( ans, mats );
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1240
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){

  NodePointer cur = nil->next;
  while(1){
    if( cur == nil ) return NULL;
    if( cur->key == key ) return cur;
    cur = cur->next;
  }
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){

  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if( t == nil ) return;
  deleteNode(t);

}

void delete(int key){
  NodePointer t;
  t=listSearch(key);
  if(t==NULL) return;
  deleteNode(t);

}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->prev = nil;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}

Measured memory_bytes: 31788
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

s = arr_data[0][0]


cnt1 = s.find("C")
cnt2 = s.find("F", cnt1)

#print(cnt1,cnt2)

print("Yes" if 0 <= cnt1 < cnt2 else "No")

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

using namespace std;

int main() {
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << w * h / 2 << " ";
    if (w / 2 == x && h / 2 == y) {
        cout << 1;
    }
    else
    {
        cout << 0;
    }


    return 0;
}

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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

signed main(){
	int h,n;
	cin>>h>>n;
	P ab[1010];
	rep(i,n){
		cin>>ab[i].first>>ab[i].second;
	}
	sort(ab,ab+n);
	int dp[10010];
	rep(i,h+1)dp[i]=INF;
	rep(i,n){
		rep(j,ab[i].first+1){
			chmin(dp[j],ab[i].second);
		}
	}
	dp[0]=0;
	rep(i,1,h+1){
		rep(j,n){
			chmin(dp[i],dp[max(0ll,i-ab[j].first)]+ab[j].second);
		}
	}
	cout<<dp[h]<<endl;
}


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

using namespace std;

int main()
{
	string x;cin>>x;
	int length=x.length();
	
	if(x[length-1]=='s'){
		x.insert(length,"es");
	} else{
		x.insert(length,"s");	
	}
	
	cout<<x.c_str();
    return 0;
}

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


class Vector:
    def __init__(self, a):
        self.a = a

    def __add__(self, b):
        c = []
        for i, j in zip(self.a, b.a):
            c.append(i + j)
        return Vector(c)


class UnionFind:
    def __init__(self, n):
        self.parent = [-1] * n
        self.rank = [1] * n
        self.count = [Vector([1, 0] if i % 2 == 0 else [0, 1])
                      for i in range(n)]

    def get_root(self, i):
        while self.parent[i] != -1:
            i = self.parent[i]
        return i

    def is_same_tree(self, i, j):
        return self.get_root(i) == self.get_root(j)

    def merge(self, i, j):
        i = self.get_root(i)
        j = self.get_root(j)
        if i == j:
            return

        if self.rank[i] > self.rank[j]:
            self.parent[j] = i
            self.rank[i] = max(self.rank[i], self.rank[j] + 1)
            self.count[i] += self.count[j]
        else:
            self.parent[i] = j
            self.rank[j] = max(self.rank[j], self.rank[i] + 1)
            self.count[j] += self.count[i]


uf = UnionFind(2 * 10 ** 5)
for _ in range(n):
    x, y = [int(i) - 1 for i in input().split()]
    uf.merge(2 * x, 2 * y + 1)

ans = 0
for i, j in zip(uf.count, uf.parent):
    if j == -1:
        a = i.a
        ans += a[0] * a[1]
print(ans - n)


Measured memory_bytes: 104376
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int main() {
  string s;
  cin >> s;
  cout << (s == "RRR" ? 3
                      : (s == "RRS" or s == "SRR" ? 2 : (s == "SSS" ? 0 : 1)))
       << endl;
  return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] array = new int[n];
		for(int i = 0; i < n; i++)
			array[i] = sc.nextInt();
		Arrays.sort(array);
		int count;
		for(count = 0; x > 0 && count < array.length; count++) {
			x -= array[count];
		}
		if(x != 0)
			count--;
		System.out.println(count);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
char s[100];
void no(){
	puts("NO");
	exit(0);
}
int main(){
	scanf("%s",s+1);
	int now=1;
	if (s[now]=='A')now++;
	if (s[now]=='K')now++;
	else no();
	if (s[now]=='I')now++;
	else no();
	if (s[now]=='H')now++;
	else no();
	if (s[now]=='A')now++;
	if (s[now]=='B')now++;
	else no();
	if (s[now]=='A')now++;
	if (s[now]=='R')now++;
	else no();
	if (s[now]=='A')now++;
	if (now<=strlen(s+1))no();
	puts("YES");
}

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

int main()
{
    int n;
    int i;
    
    cin >> n;
    
    int a[n];
    
    for(i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    sort(a, a+n);
    
    cout << a[n-1]-a[0] << "\n";
    
    return 0;
}

Measured memory_bytes: 256