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

int main(){
  long long N;
  cin >> N;
  vector<long long>P(N),Q(N);

  for(int i=0;i<N;i++){
    int p;
    cin >> p;
    P.at(i)=p;
  }

  for(int i=0;i<N;i++){
    int q;
    cin >> q;
    Q.at(i)=q;
  }

  for(int i=N-1;i>0;i--){
    int count=0;
    for(int j=0;j<i;j++){
      if(P.at(j)<P.at(i)){
        count++;
      }
    }
    P.at(i) -= count;
  }
  for(int i=N-1;i>0;i--){
    int count=0;
    for(int j=0;j<i;j++){
      if(Q.at(j)<Q.at(i)){
        count++;
      }
    }
    Q.at(i) -= count;
  }

  vector<long long>keisu(N-1);
  keisu.at(0)=1;
  if(N>2){
    for(int i=1;i<N-1;i++){
      keisu.at(i) = keisu.at(i-1)*(i+1);
    }
  }

  long long p,q;
  for(int i=0;i<N-1;i++){
    p += (P.at(i)-1)*keisu.at(N-2-i);
  }
  for(int i=0;i<N-1;i++){
    q += (Q.at(i)-1)*keisu.at(N-2-i);
  }

  if(p>=q){
    cout << p-q << endl;
  }
  else{
    cout << q-p << endl;
  }
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {
	
	int n;
	scanf("%d", &n);
	int tmp, bef;
	scanf("%d", &bef);
	ll sum = 0;
	rep(i, n - 1) {
		scanf("%d", &tmp);
		sum += (bef >= tmp);
		bef = tmp;
	}
	printf("%lld\n%d\n", sum + 1, n);

	Please AC;
}


Measured memory_bytes: 3228
# AOJ 1014: Computation of Minimum Length of Pipeline
# Python3 2018.7.5 bal4u

import sys
from sys import stdin
input = stdin.readline
import heapq

while True:
	s, d = map(int, input().split())
	if s == 0: break
	visited = [0]*100
	Q = []
	to = [[] for i in range(100)]
	for i in range(s):
		visited[i] = 1
		c = list(map(int, input().split()))
		for j in range(d):
			if c[j] > 0: heapq.heappush(Q, (c[j], i, s+j))
	for i in range(d-1):
		c = list(map(int, input().split()))
		for j in range(i+1, d):
			if c[j-i-1] > 0:
				to[s+i].append((s+j, c[j-i-1]))
				to[s+j].append((s+i, c[j-i-1]))

	ans = k = 0
	while k < d:
		while True:
			c, a, b = heapq.heappop(Q)
			if visited[a] == 0 or visited[b] == 0: break
		ans, k = ans+c, k+1
		if visited[a]: a = b
		visited[a] = 1;
		for e, c in to[a]:
			if visited[e] == 0:	heapq.heappush(Q, (c, a, e))
	print(ans)



Measured memory_bytes: 5944
n = int(input())
P = [int(input())-1 for _ in range(n)]
A = [0]*n
for i, p in enumerate(P):
    A[p] = i

#print(A)

m = 0
temp = 0
for i in range(1, n):
    if A[i-1] < A[i]:
        temp += 1
    else:
        m = max(m, temp)
        temp = 0
else:
    m = max(temp, m)
print(n-m-1)


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

int main() {
  int N, M, c;
  cin >> N >> M;
  
  vector<int> a(M);
  vector<int> b(M);
  
  for(int i=0;i < M;i++){
    cin >> a.at(i) >> b.at(i);
  }
  for(int i=0;i < N;i++){
    c=0;
    for(int j=0;j < M;j++){
      if(a.at(j) == i+1)
        c++;
      if(b.at(j) == i+1)
        c++;
    }
    cout << c << endl;
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, q;
  cin >> n >> q;
  vector<int> graph[n];
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  vector<int> cnt(n);
  rep(i, q) {
    int p, x;
    cin >> p >> x;
    --p;
    cnt[p] += x;    
  }
  //rep(i, n) cout << cnt[i] << '\n';
  int root = 0;
  vector<int> parent(n, -1);
  vector<int> order;
  stack<int> stk;
  stk.push(root);
  while (!stk.empty()) {
    int cur = stk.top();
    stk.pop();
    order.push_back(cur);
    for (auto next : graph[cur]) {
      if (next == parent[cur]) continue;
      parent[next] = cur;
      cnt[next] += cnt[cur];
      stk.push(next);
    }
  }
  rep(i, n) cout << cnt[i] << ' ';  
  return 0;
}

/*
root = 1
parent = [0] * (N+1)
order = []
stack = [root]
while stack:
    cur = stack.pop()
    order.append(cur)
    for next in graph[cur]:
        if next == parent[cur]:
            continue
        parent[next] = cur
        stack.append(next)
*/

Measured memory_bytes: 18948
#include<stdio.h>

int main(){
  int A,B,C;
  int N;
  
  scanf("%d",&A);
  scanf("%d",&B);
  scanf("%d",&C);
  scanf("%d",&N);
  int p=0;
  int i,j,k;
  for(i=0;i<=A;i++){
    for(j=0;j<=B;j++){
      for(k=0;k<=C;k++){
        if(N == i*500+j*100+k*50)
          p++;
      }
    }
  }
  
  printf("%d\n",p);
  return 0;
}
  


Measured memory_bytes: 128
import sys
n = int(input())
a = [list(map(int,input().split())) for i in range(n)]

h,j,k = 0,0,0

for i in range(n):
    t = abs(h - a[i][0])
    dx = abs(j - a[i][1])
    dy = abs(k - a[i][2])
    if t >= dx + dy:
        if t % 2 != (dx + dy) % 2:
            print("No")
            sys.exit()
    else:
        print("No")
        sys.exit()
    h = a[i][0]
    j = a[i][1]
    k = a[i][2]
print("Yes")


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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (long long)1e18 + 1;

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

    int N;
    std::cin >> N;
    set<int> D;
    REP(i, N) {
        int d;
        std::cin >> d;
        D.insert(d);
    }

    std::cout << D.size() << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int N, K;
	int[] L, R;
	long MOD = 998244353L;
	long[] memo;

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		N = Integer.parseInt(tokens[0]);
		K = Integer.parseInt(tokens[1]);
		L = new int[K];
		R = new int[K];
		for (int i = 0; i < K; ++i) {
			tokens = in.readLine().split(" ");
			L[i] = Integer.parseInt(tokens[0]);
			R[i] = Integer.parseInt(tokens[1]);
		}
		memo = new long[N];
		Arrays.fill(memo, 0L);
		memo[0] = 1L;
	}

	void calc() {
		long[] diffs = new long[N];
		Arrays.fill(diffs, 0L);
		diffs[1] = -1L;
		for (int i = 0; i + 1 < N; ++i) {
			for (int k = 0; k < K; ++k) {
				int l = i + L[k];
				int r = i + R[k] + 1;
				if (l < N) {
					diffs[l] += memo[i] + MOD;
					diffs[l] %= MOD;
				}
				if (r < N) {
					diffs[r] -= memo[i] + MOD;
					diffs[r] %= MOD;
				}
			}
			memo[i + 1] = memo[i] + diffs[i + 1];
			memo[i + 1] += MOD;
			memo[i + 1] %= MOD;
		}
	}

	void showResult() {
		System.out.println(memo[N - 1]);
	}
}

Measured memory_bytes: 29852
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;
ll n, w;
ll ans;
ll dp[100009];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n >> w;
    
    for(ll i = 0; i < n; ++i){
        ll x, y;
        cin >> x >> y;
        for(ll j = 1e5; j >= x; --j){
            dp[j] = max(dp[j-x] + y, dp[j]);
            //cout << i << " " << j << " " << dp[j] << "\n";
        }
    }
    cout << dp[min(w, (ll)1e5)] << "\n";
    
}

Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
#include<iomanip>
#include<string.h>
#include<set>
#include<map>
#include<cmath>
#include<vector>
#include<iomanip>
#include<queue>
using namespace std;
#define inf e18
#define x first
//#define y second
#define ll long long
#define ii pair<ll, ll>
#define vi vector<ll>
#define vii vector<ii>
#define pb push_back
#include<stack>
#define mp make_pair
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll a, b, c;
ll n, k;

int main()
{
    ios
    ll i, j,m;
    cin>>n>>a>>b;
    if(n<=a){
        cout<<1;
        return 0;
    }
    if(b>=a){
        cout<<-1;
        return 0;
    }
    cout<<1+2*((n-a+(a-b-1))/ (a-b));
}


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

int main(void)
{
    int N;
    cin >> N;
    vector<long> v(N, 0);
    for(int i=0; i<N; i++)
    {
        cin >> v[i];
    }
    
    sort(v.begin(), v.end(), greater<long>());
    
    vector<long> point;
    point.push_back(v[0]);
    
    for(int i=1; i<N; i++)
    {
        point.push_back(v[i]);
        point.push_back(v[i]);
    }
    
    long sum = 0;
    for(int i=0; i<N-1; i++)
    {
        sum += point[i];
    }
    
    cout << sum << endl;
    
    return 0;
}

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

using namespace std;

/******************************************************************************
	Main
******************************************************************************/
int main()
{
	int a = -1, b = -1;
	cin >> a >> b;
	assert(a >= 1 && a <= 20);
	assert(b >= 1 && b <= 20);
	cout << ((a < 10 && b < 10) ? a * b : -1) << endl;

	return 0;
}


Measured memory_bytes: 256
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
const int MOD = 1000000007;

#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
#define mod_mul(x, y) x*y%MOD
#define mod_add(x, y) (x+y)%MOD
#define mod_sub(x, y) (x-y)%MOD
#define INF 100000


long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
}

long lcm( long m, long n ){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}


long nCr(long n, long r){
    if(n==r || r==0){
        return 1;
    } else {
        return mod_add(nCr(n-1,r),nCr(n-1,r-1));
    }
}

int dp[41][401][401];
int A[40];
int B[40];
int C[40];



int main(){
    int N, M_a, M_b;
    cin >> N >> M_a >> M_b;

    //int dp[45][405][405] = {INF};
    //std::vector<std::vector<std::vector<int>>> dp;

    for (int i = 0; i <= 40; i++) {
        for (int j = 0; j <= 400; j++) {
            for (int k = 0; k <= 400; k++) {
                dp[i][j][k] = INF;
            }
        }
    }

    for (int i = 0; i < N; i++) {
        int a,b,c; cin >> A[i] >> B[i] >> C[i];
    }
    dp[0][0][0] = 0;

    for (int i = 0; i < N; ++i) {
        for(int a = 0; a <= 400; ++a){
            for(int b = 0; b <= 400; ++b){
                if(dp[i][a][b] == INF) continue;
                dp[i+1][a+A[i]][b+B[i]] = min(dp[i+1][a+A[i]][b+B[i]], dp[i][a][b]+C[i]);
                dp[i+1][a][b] = min(dp[i][a][b], dp[i+1][a][b]);
            }
        }
    }

    int ans = INF;
    for(int a = 1; a <= 400; ++a){
        for(int b = 1; b <= 400; ++b){
            if(a*M_b==b*M_a) ans = min(ans, dp[N][a][b]);
        }
    }


    if(ans == INF) ans = -1;

    cout << ans << endl;


    return 0;

}


Measured memory_bytes: 25984
using System;
using System.Linq;

namespace CADDi2018
{
    class C
    {
        static void Main(string[] args)
        {
            //input
            long[] input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long N = input[0];
            long P = input[1];

            if (N == 1) { Console.WriteLine(P); return; }

            long[] Array = new long[(int)Math.Ceiling(Math.Sqrt(P))];
            long p = P;
            long res = 1;
            for (int i = 2; i < Math.Sqrt(P); i++)
            {
                //素因数分解
                while (p % i == 0)
                {
                    Array[i]++;
                    p /= i;
                }
                Array[i] /= N;
                res *= (long)Math.Pow(i, Array[i]);
            }

            //Console.WriteLine(string.Join(",", Array));
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 19936
a, b, x = gets.split.map(&:to_i)
if x <= a * a * b / 2
  l = ((2.to_f * x) / (a * b))
  deg = (Math.atan (b / l)) * 180.0 / Math::PI
else
  v = a * a * b - x
  l = (2.to_f * v) / (a * a)
  deg = (Math.atan (l / a)) * 180.0 / Math::PI
end
puts deg



Measured memory_bytes: 1788
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

n, = I()
a = I()

d = dd(int)
for i in a:
    d[i] += 1

def get(x):
    return x * (x - 1) // 2

total = 0
for i in d:
    total += get(d[i])

for i in range(n):
    ans = total - get(d[a[i]]) + get(d[a[i]] - 1)
    print(ans)

Measured memory_bytes: 30628
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] a={0,0,0};
        int i,t,j;
        for(i=0;i<3;i++){
            a[i] = sc.nextInt();
        }
        for(i=0;i<3;i++){
            for(j=i+1;j<3;j++){
                if(a[i]>a[j]){
                    t=a[i];
                    a[i]=a[j];
                    a[j]=t;
                }
            }
        }
 
        System.out.println(a[0]+" "+a[1]+" "+a[2]);
    }
}


Measured memory_bytes: 26216
import java.util.Scanner;
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();
	if (a < b && b < c) {
	    System.out.println("Yes");
	} else {
	    System.out.println("No");
	}
    }
}

Measured memory_bytes: 12000
#include <iostream>
#include <climits>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;

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

const int inf = INT_MAX/3;
int riku[210][210];
int umi[210][210];
int dp[1010][210]; // [ツ妥ョツ配][ツ船ツづ個暗環置]

int main(){
  int n,m;
  int taku[1010];

  while(scanf("%d%d",&n,&m),n|m){
    //init
    //rep(i,210)rep(j,210)riku[i][j]=umi[i][j]=inf;
    rep(i,210){
      fill(riku[i], riku[i]+210, inf);
      fill(umi[i], umi[i]+210, inf);
    }
    rep(i,210)riku[i][i]=umi[i][i]=0;
    //rep(i,1010)rep(j,210)dp[i][j]=inf;
    rep(i,1010) fill(dp[i], dp[i]+210, inf);

    rep(i,m){
      int a,b,c; char l;
      scanf(" %d %d %d %c ",&a,&b,&c,&l);
      a--, b--;
      if( l=='S' ){
	int d = min(umi[a][b],c);
	umi[a][b] = umi[b][a] = d;
      }else{
	int d = min(riku[a][b],c);
	riku[a][b] = riku[b][a] = d;
      }
    }
    int R; cin>>R;
    rep(i,R){
      int r; scanf("%d",&r); r--;
      taku[i] = r;
    }

    // worshal
    rep(k,n)rep(i,n)rep(j,n){
      if( riku[i][k]!=inf && riku[k][j]!=inf ){
	riku[i][j] = min(riku[i][j], riku[i][k]+riku[k][j]);
      }
      if( umi[i][k]!=inf && umi[k][j]!=inf ){
	umi[i][j] = min(umi[i][j], umi[i][k]+umi[k][j]);
      }
    }

    dp[1][taku[0]] = 0;
    REP(r,1,R){
      int v = taku[r-1];
      int u = taku[r];
      rep(j,n){
	if( riku[v][u]!=inf ) dp[r+1][j] = min(dp[r+1][j], dp[r][j]+riku[v][u]);
	if( riku[v][j]==inf ) continue;
	rep(i,n){
	  if( umi[j][i]==inf || riku[i][u]==inf )continue;
	  dp[r+1][i] = min(dp[r+1][i], dp[r][j]+riku[v][j]+umi[j][i]+riku[i][u]);
	}
      }
    }
    int ans = inf;
    rep(i,n)ans=min(ans,dp[R][i]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define SORT(v) sort(ALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;

#define HOGE COUT("HOGE")

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
int main() {
    int k,a,b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; i++) {
        if (i%k==0) {
            COUT("OK");
            return 0;
        }
    }
    COUT("NG");
}


Measured memory_bytes: 3624
import java.util.*;
//import java.io.*;
import java.util.stream.IntStream;

public class Main{
    static int sum=0;
    public static void main (String args[]){
        //初期処理
        Scanner sc=new Scanner(System.in);
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // try{
            // int n = Integer.parseInt(br.readLine());
        Vector p1 = new Vector(sc.nextInt(), sc.nextInt());
        Vector p2 = new Vector(sc.nextInt(), sc.nextInt());
        int n = sc.nextInt();
        for(int i=0; i<n; i++){
            Vector p = new Vector(sc.nextInt(), sc.nextInt());

            Vector ans = p.reflection(p1,p2);
            System.out.println(ans.x + " " + ans.y);

        }

    }
}

class Vector{
    public static double EPS = 1e-10;
    public double x,y;

    public Vector(){}
    public Vector(double x, double y){this.x=x;this.y=y;}

    public Vector plus(Vector p){return new Vector(this.x+p.x, this.y+p.y);}
    public Vector minus(Vector p){return new Vector(this.x-p.x, this.y-p.y);}
    public Vector multiple(double a){return new Vector(this.x*a, this.y*a);}
    public Vector divide(double a){return new Vector(this.x/a, this.y/a);}

    public double abs(){return Math.sqrt(this.norm());}
    public double norm(){return x*x+y*y;}

    
    public static double dot(Vector a, Vector b){
        return a.x*b.x+a.y*b.y;
    }

    public static double cross(Vector a, Vector b){
        return a.x*b.y-a.y*b.x;
    }

    //point.projectで垂線の足の座標
    public Vector project(Vector seg1, Vector seg2){
        Vector seg = seg2.minus(seg1);
        Vector relPoint = this.minus(seg1);
        double t = dot(seg, relPoint)/seg.norm();
        return seg1.plus(seg.multiple(t));
    }
    
    public Vector reflection(Vector seg1, Vector seg2){
        Vector projected = this.project(seg1, seg2);
        Vector ashi = projected.minus(this);
        return this.plus(ashi.multiple(2));
    }
}


Measured memory_bytes: 35248
#include "bits/stdc++.h"
    #define in std::cin
    #define out std::cout
    #define rep(i,N) for(int i=0;i<N;++i)
    typedef long long int LL;

    std::string S;

    int main()
    {
    	in>>S;
    	S[0]=2,S[1]=0,S[2]=1,S[3]=8;
    	out<<"2018"<<S.substr(4)<<std::endl;
    	return 0;
    }


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int W[128];
int L[128];

int main()
{
	int N;

	cin >> N;
	

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

		if (i == 0)
		{
			L[i] = w;
		}
		else
		{
			L[i] = L[i - 1] + w;
		}
	}

	int kekka = 100*100+1;

	for (int i = 1; i < N-1; i++)
	{
		kekka = min(kekka, abs(L[N - 1] - 2 * L[i]));
	}

	cout << kekka << endl;

	return 0;
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int soin[1001];

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int n;
	cin >> n;

	for(int i=1; i<=n; i++){
		int x = i;
		for(int j=2; j*j<=x; j++){
			if(x % j == 0){
				x /= j;
				soin[j]++;
				j--;
			}
		}
		if(x > 1) soin[x]++;
	}

	ll ans = 1;
	for(int i=1; i<=1000; i++){
		if(soin[i] > 0){
			ans *= soin[i] + 1;
		}
		ans %= MOD;
	}

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


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int number;
    cin >> number;
    char ch = number;
    if('A' <= ch && ch <= 'Z') cout << 1 << endl;
    else if('a' <= ch && ch <= 'z') cout << 2 << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#define N 405
using namespace std;

typedef long long ll;
ll h, w, s, c1, c2;
ll dy[4] = {-1, 0, 1, 0};
ll dx[4] = {0, 1, 0, -1};
bool v[N][N];
char a[N][N];

void f(ll p, ll q) {
	ll i;
	if (v[p][q]) return;
	v[p][q] = 1;
    if (a[p][q] == '#') c1++;
    else c2++;
    for (i = 0; i < 4; i++) {
		if (a[p][q] != a[p + dy[i]][q + dx[i]]) f(p + dy[i], q + dx[i]);
    }
}

int main()
{
	ll i, j;
	cin >> h >> w;
	for (i = 0; i <= h + 1; i++) for (j = 0; j <= w + 1; j++) v[i][j] = 1;
	for (i = 1; i <= h; i++) for (j = 1; j <= w; j++) v[i][j] = 0;
	for (i = 1; i <= h; i++) {
		scanf("%s", &a[i][1]);
	}
	for (i = 1; i <= h; i++) {
		for (j = 1; j <= w; j++) {
			c1 = c2 = 0;
			f(i, j);
			s += c1 * c2;
		}
	}
    cout << s << endl;
    return 0;
}

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

using namespace std;

#define int          long long
#define mem(a , v)   memset(a , v , sizeof a)
#define all(v)       v.begin() , v.end()
#define err(x)       cerr << #x << " is : " << x << endl
#define endl         "\n"



const int MOD   =   1e9 + 7;
const int N     =   1e6 + 20;
const int big   =   1e14;

void solve()
{
    int n;
    cin >> n;
    string s;
    map <string , int> m;
    for(int i = 0 ; i < n ; i++)
    {
        cin >> s;
        m[s]++;
    }

    string a[4] = {"AC" , "WA" , "TLE", "RE"};

    for(int i = 0 ; i < 4 ; i++)
        cout << a[i] << " x " << m[a[i]] << endl;
    return;
}


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

    int t = 1;
    //cin >> t;
    while(t--)
        solve();
    return 0;
}


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

int main() {
    string str;
    while (cin >> str) {
        int count1 = 0;
        int count2 = 0;
        for (int i = 0; i < (int)str.size() - 2; i++) {
            if (str[i] == 'I' && str[i+1] == 'O' && str[i+2] == 'I') count1++;
            if (str[i] == 'J' && str[i+1] == 'O' && str[i+2] == 'I') count2++;
        }
        cout << count2 << endl << count1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3032
N, Q = map(int, input().split())
S = input()

AC_num = [0 for _ in range(N)]

i = -1

while(True):
  i = S.find("AC", i + 1)
  
  if i == -1:
    break
  
  AC_num[i + 1] += 1

for i in range(N - 1):
  AC_num[i + 1] += AC_num[i]

for _ in range(Q):
  l, r = map(int, input().split())
  
  print(AC_num[r - 1] - AC_num[l - 1])
  

Measured memory_bytes: 7692
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ_problem_01
{
    class Program
    {
        const int White = 0;
        const int Gray = 1;
        const int Black = 2;
        static int time;

        static int Next(int u, int n, int[,] data, Stack<int> s)
        {
            for (int v = 0; v < n; v++)
            {
                
                if (data[u, v] == 1 && color[v] == White)
                {
                    color[v] = Gray;
                    s.Push(v);
                    des[v] = ++time;
                    return v;
                }
            }

            return -1; 
        }

        static void DfsVisit(int n, int u)
        {
              
            Stack<int> s = new Stack<int>();

           
            s.Push(u);
            color[u] = Gray;
            des[u] = ++time;

            while (s.Count != 0)
            {
                u = s.Peek();
                int v = Next(u, n, data, s);

                
                if (v == -1)
                {
                    color[u] = Black;
                    fin[s.Pop()] = ++time;
                }

            }

        }

       
        static void Dfs(int n)
        {

            
            for (int i = 0; i < n; i++)
            {
                color[i] = White;
            }

            time = 0;  

            for(int u = 0; u < n; u++)
            {
                if (color[u] == White)
                {
                    DfsVisit(n, u);
                }
            }
        }

        static int[,] data;
        static int[] color;
        static int[] des;
        static int[] fin;

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            data = new int[n, n];
            color = new int[n];
            fin = new int[n];
            des = new int[n];

           
            for (int i = 0; i < n; i++)
            {
                string[] str = Console.ReadLine().Split(' ');

                int u = int.Parse(str[0]) - 1;
                int k = int.Parse(str[1]);
                for (int j = 2; j < k + 2; j++)
                {
                    int v = int.Parse(str[j]) - 1;   
                    data[u, v] = 1;      
                }
            }

            Dfs(n);

            for (int i = 0; i < n; i++)
            {
                Console.WriteLine($"{i + 1} {des[i]} {fin[i]}");
            }

        }

    }

}




Measured memory_bytes: 16368
// SeeAlso: https://atcoder.jp/contests/abc151/tasks/abc151_a

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    char c;
    cin >> c;
    c++;
    print(c);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(q) (q).begin(),(q).end()

int main(){
  int N; cin>>N;
  vector<int> A(N),B(N),Ac(N),Bc(N);
  int a=1;
  for(int i=0;i<N;i++)
    cin>>A[i];
  for(int i=0;i<N;i++)
    cin>>B[i];
  vector<int> ans(29,0);
  for(int i=0;i<29;i++){
    for(int j=0;j<N;j++){
      Ac[j]=A[j]%(a*2);
      Bc[j]=B[j]%(a*2);
    }
    sort(all(Bc));
    for(int j=0;j<N;j++){
      ans[i]+=distance(lower_bound(all(Bc),a-Ac[j]),lower_bound(all(Bc),2*a-Ac[j]));
      ans[i]+=distance(lower_bound(all(Bc),3*a-Ac[j]),Bc.end());
      ans[i]%=2;
    }
    a*=2;
  }
  a=1;
  int fl=0;
  for(int i=0;i<29;i++){
    fl+=ans[i]*a;
    a*=2;
  }
  cout<<fl;
}

Measured memory_bytes: 3328
//main関数

#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin>>n;
    vector<tuple<string,int,int>> guide(n);
    int i=0;
    for(auto &p:guide){
        string s;
        int a;
        cin>>s>>a;
        p=make_tuple(s,-a,i);
        i++;
    }
    sort(guide.begin(),guide.end());
    // for(auto &p:guide){
    //     string s;
    //     int x,y;
    //     tie(s,x,y)=p;
    //     cout<<s<<" "<<x<<" "<<y<<endl;
    // }
    vector<int> A(n);//i番目の店が何番目に掲載されるか
    for (int i=0;i<n;i++){
        int x;
        tie(ignore,ignore,x)=guide.at(i);
        A.at(i)=x;
    }
    for(int v:A){
        cout<<v+1<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define ill long long
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int a;
  cin >> a;
  if(a % 1000 == 0) cout << 0;
  else cout << 1000 - a % 1000;
}


Measured memory_bytes: 3632
P1 = [int(x) for x in input().split()]
P2 = [int(x) for x in input().split()]
P3 = [int(x) for x in input().split()]
P = [0] * 4
count = 0
for i in range(0,2):
    P[P1[i]-1] += 1
    P[P2[i]-1] += 1
    P[P3[i]-1] += 1
for i in range(0,4):
    if P[i] == 3:
        count = 1
if count == 0:
    print("YES")
else:
    print("NO")

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

int gcd(int p,int q){
    if(p%q == 0){
        return q;
    }
        return gcd(q,p%q);
}

int main(){
    string s,t; cin >> s >> t;

    if(s == t.substr(0,t.size()-1)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
ll fact[2000100];
ll moduloexp(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)res=(1LL*res*a)%MOD;
		b/=2;
		a=(1LL*a*a)%MOD;
	}
	return res;
}
ll comb(ll n,ll r){
	if(n<r)
		return 0;  
	return (1LL*fact[n]*moduloexp((1LL*fact[n-r]*fact[r])%MOD,MOD-2))%MOD;
}
void init(){
	fact[0]=1;
	for(int i=1;i<2000010;i++)
		fact[i]=(fact[i-1]*i)%MOD;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	init();
	int r1, r2, c1, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	ll ans = 0;
	for(int i = r1; i <= r2; i++){
		ans = (ans + comb(i + c2 + 1, i + 1) - comb(i + c1, i + 1) + MOD) % MOD;
		//cout << ans << '\n';
	}
	cout << ans << '\n';

}

Measured memory_bytes: 15872
n = int(input())
a = 0
b = 0
ab = 0
b_a = 0
for i in range(n):
    s = input()
    if s[0] == "B" and s[-1] == "A":
        b_a += 1
    elif s[0] == "B":
        b += 1
    elif s[-1] == "A":
        a += 1
    for j in range(len(s) - 1):
        if s[j] == "A" and s[j + 1] == "B":
            ab += 1
if a > b:
    a, b = b, a
ans = ab
if b == 0:
    if b_a != 0:
        ans += b_a - 1
elif a + b == 1:
    ans += b_a
else:
    ans += b_a + a
print(ans)


Measured memory_bytes: 3064
S = str(input())
N = len(S)
if S == S[::-1]:
    S1 = S[:((N-1)//2)]
    S2 = S[((N + 1)//2):]
    if S1 == S1[::-1] and S2 == S2[::-1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3060
import random
D = int(input())
cs = list(map(int,input().split()))
ss =[]
for i in range(D):
  ss.append(list(map(int,input().split())))
for r in range(10):
  ts = []
  for i in range(D):
    ts.append(random.randint(1, 26))
  if r ==0:
    maxts = ts
  last = [0] * 26
  total =0
  for i in range(D):
    t = ts[i]
    last[t-1] = i+1
    genten=0
    for j in range(26):
      genten += cs[j] *(i+1 - last[j])
      total += ss[i][t-1]-genten
    if r==0:
      maxtsscore = total
    else:
      if maxtsscore < total:
        maxtsscore = total
        maxts = ts
for z in maxts:
  print(z)
  
 


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

int dp[100005][5], v[100005][5];

int main(){

    int n; scanf("%d", &n);
    for(int i = 1; i <= n; i++)
        scanf("%d %d %d", &v[i][0], &v[i][1], &v[i][2]);
    
    for(int i = 1; i <= n; i++)
        for(int j = 0; j < 3; j++)
            for(int k = 0; k < 3; k++)
                if(j != k)
                    dp[i][j] = max(dp[i][j], dp[i-1][k] + v[i][j]);
    int res = max(dp[n][0], max(dp[n][1], dp[n][2]));
    printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 4096
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define P pair<int, int>
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int s, w;
    cin >> s >> w;
    if(s <= w){
        cout << "unsafe" << endl;
    }
    else{
        cout << "safe" << endl;
    }
    solve();
    return 0;
}



Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
//get the biggest element.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

int main() {
  //cin.tie(0);ios::sync_with_stdio(false);
  double a, b, x;
  cin >> a >> b >> x;
  
  double s = x / a;
  double ans = 0;
  if (s > (a * b / 2)) {
    double h = 2 * (a * b - s) / a;
    ans = atan2(h, a) / acos(-1) * 180;
  } else {
    double hh = 2 * (x / (a * b));
    ans = atan2(b, hh) / acos(-1) * 180;
  }
  cout << fixed << setprecision(15);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4168
using System;
class Program
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();
        if (input == "A")
            Console.WriteLine('T');
        if (input == "T")
            Console.WriteLine('A');
        if (input == "C")
            Console.WriteLine('G');
        if (input == "G")
            Console.WriteLine('C');
    }
}


Measured memory_bytes: 11092
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    auto nk = aryread();
    bool b = (nk[0] + 1) / 2 >= nk[1];
    writeln(b ? "YES" : "NO");
}


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

int main(){
  set<char> s;
  s.insert('a');
  s.insert('e');
  s.insert('i');
  s.insert('o');
  s.insert('u');
  char c;
  cin >> c;
  if(s.count(c)){
    cout << "vowel"  << endl;
  }else{
    cout << "consonant" << endl;
  }
  return 0;
}


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

// 簡易UF
struct UF{
    vector<int> p;
    int n;

    UF(int siz){
        n = siz;
        p.resize(n, 0);
        for(int i = 0; i < n; i++)  p[i] = i;
    }

    bool same(int x, int y){
        return parent(x) == parent(y);
    }

    int parent(int x){
        if(p[x] != x)   p[x] = parent(p[x]);
        return p[x];
    }

    void unite(int x, int y){
        x = parent(x), y = parent(y);
        p[x] = y;
    }
};

struct data{
    int cost, i, j;
    data(int a, int c, int d) : cost(a), i(c), j(d) {};
    bool operator< (const data other){
        return cost < other.cost;
    }
};

// O(N * M) 速いはず

int main(){
    int n, m;
    cin >> n >> m;

    vector<data> v;
    int s, d, c;
    
    for(int i = 0; i < m; i++){
        cin >> s >> d >> c;
        s--, d--;
        v.push_back(data({c,s,d}));
    }
    sort(v.begin(), v.end());

    int sptCost = 0, ans = 0, anssum = 0;
    vector<int> cand;
    UF uf(n);
    for(int x = 0; x < m; x++){
        int cost = v[x].cost, i = v[x].i, j = v[x].j;
        if(uf.same(i,j))    continue;
        sptCost += cost;
        cand.push_back(x);
        uf.unite(i,j);
    }

    for(int ng : cand){
        UF tmp(n);
        int tmpc = 0, edge = 0;
        for(int x = 0; x < m; x++){
            int cost = v[x].cost, i = v[x].i, j = v[x].j;
            if(ng == x || tmp.same(i,j))    continue;
            edge++;
            tmpc += cost;
            tmp.unite(i,j);
        }
        if(edge != n-1 || tmpc > sptCost)  ans++, anssum += v[ng].cost;
    }

    cout << ans << " " << anssum << endl;

    return 0;
}


Measured memory_bytes: 3808
#include<stdio.h>

void swap(char* pX, char* pY)
{
    char tmp;

    tmp = *pX;
    *pX = *pY;
    *pY = tmp;
}

int main(void)
{
    char a[101], b[101];
    int numA=0;
    int numB=0;

    scanf("%s", a);
    scanf("%s", b);

    while('\0' != a[numA]) {
        numA++;
    }

    while('\0' != b[numB]) {
        numB++;
    }

    for(int i=0; numA>i; i++) {
        for(int j=numA-1; i<j; j--) {
            if(a[j] < a[j-1]) {
                swap(&a[j], &a[j-1]);
            }
        }
    }

    for(int i=0; numB>i; i++) {
        for(int j=numB-1; i<j; j--) {
            if(b[j] > b[j-1]) {
                swap(&b[j], &b[j-1]);
            }
        }
    }

    int i=0;
    while(i<=numA) {
        if(a[i] < b[i]) {
            printf("Yes\n");
            return 0;
        }
        else if((a[i] > b[i]) || ('\0'==b[i])) {
            printf("No\n");
            return 0;
        }
        else {
            i++;
            continue;
        }
    }

    printf("Yes\n");

    return 0;
}

Measured memory_bytes: 128
# -*- coding: utf8 -*-

import sys


types = ['A', 'B', 'C', 'D', 'E', 'F', 'G']


def main():
    while True:
        try:
            data = []
            for i in xrange(8):
                data.append(raw_input())

            check_figure(data)

            # 空行
            raw_input()
        except EOFError:
            break


def check_figure(data):
    # 最初の1を探す
    for i in xrange(8):
        for j in xrange(8):
            if data[i][j] == "1":
                for t in types:
                    if check_pattern(data, pattern(t, i, j)):
                        print t
                        return
                return


def pattern(p, i, j):
    if p == 'A':
        return [(i, j), (i, j + 1), (i + 1,  j), (i + 1, j + 1)]
    elif p == 'B':
        return [(i, j), (i + 1, j), (i + 2, j), (i + 3, j)]
    elif p == 'C':
        return [(i, j), (i, j + 1), (i, j + 2), (i, j + 3)]
    elif p == 'D':
        return [(i, j), (i + 1, j - 1), (i + 1, j), (i + 2, j - 1)]
    elif p == 'E':
        return [(i, j), (i, j + 1), (i + 1, j + 1), (i + 1, j + 2)]
    elif p == 'F':
        return [(i, j), (i + 1, j), (i + 1, j + 1), (i + 2, j + 1)]
    elif p == 'G':
        return [(i, j), (i, j + 1), (i + 1, j - 1), (i + 1, j)]
    else:
        return None


def check_pattern(data, block):
    for p in block:
        if is_out_of_bounds(p[0], p[1]) or (data[p[0]][p[1]] == '0'):
            return False

    return True


def is_out_of_bounds(x, y):
    if x < 0 or x >= 8 or y < 0 or y >= 8:
        return True
    else:
        return False


main()

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

using namespace std;

int main() {
  int N, Y;
  cin >> N >> Y;
  for (int i = 0; i <= N; ++i)
    for (int j = 0; j <= N - i; ++j)
      if (10000 * i + 5000 * j + 1000 * (N - i - j) == Y) {
        cout << i << " " << j << " " << (N - i - j) << endl;
        return 0;
      }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}

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

bool validMonth(int n) {
    return n > 0 && n < 13;
}

void solve()
{
    char c;
    int f = 0, s = 0;
    for (int i = 0; i < 2; ++i) {
        cin >> c;
        f = f * 10 + (c - '0');
    }
    for (int i = 0; i < 2; ++i) {
        cin >> c;
        s = s * 10 + (c - '0');
    }
    string ans;
    if (validMonth(f) && validMonth(s)) ans = "AMBIGUOUS";
    else if (validMonth(f)) ans = "MMYY";
    else if (validMonth(s)) ans = "YYMM";
    else ans = "NA";
    cout << ans << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
long long int dp[100005][100];
long long int ar[100];
int br[100];
class solution {
private:
	int n, w;
	long long int serc(int w, int x) {
		if (x == n) return 0;
		if (dp[w][x] != -1) return dp[w][x];
		dp[w][x] = serc(w, x + 1);
		if (w >= br[x]) dp[w][x] = max(dp[w][x], ar[x] + serc(w - br[x], x + 1));
		return dp[w][x];
	}
	long long int max(long long int a, long long int b) {
		if (a > b) return a;
		return b;
	}
	void reset() {
		for (int i = 0; i <= w; i++) {
			for (int j = 0; j < n; j++) {
				dp[i][j] = -1;
			}
		}
	}
public:
	solution() {
		scanf("%d %d", &n, &w);
		for (int i = 0; i < n; i++) {
			scanf("%d %lld", &br[i], &ar[i]);
		}
		reset();
		printf("%lld\n", serc(w, 0));
	}
};

#ifndef L0C4L
int main() {
	solution();
	return 0;
}
#endif

Measured memory_bytes: 78336
n,k = gets.chomp.split(" ").map(&:to_i)
h_arr = gets.chomp.split(" ").map(&:to_i)

# i番目にたどり着くまでのコストの総和の最小値
dp = [0, (h_arr[1] - h_arr[0]).abs]
(2..n-1).each do |i|
  step = k < i ? k : i
  min = 100000000000000
  (1..step).each do |j|
    tmp = dp[i-j] + (h_arr[i] - h_arr[i-j]).abs
    min = tmp if tmp < min
  end
  dp[i] = min
end
puts dp[n-1]

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

int main() {
  	int n;
	cin>>n;
  	int mem[n];
  	int num=0;
  	int min_num = 0;
  	for ( int i=0; i<n; i++ ) {
      cin>>mem[i];
      if ( i == 0 ) {
        min_num = mem[i];
      }
      else if ( min_num > mem[i] ) {
        min_num = mem[i];
      }
      if ( min_num >= mem[i] ) {
      	num++;
      }
    }
  	cout<<num<<endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> data(n);
  for(int i = 0; i < n; i++){
    cin >> data.at(i);
  }
  int count = 0;
  int big_mount = data.at(0);
  for(int i = 0; i < n; i++){
    if(i == 0){
      count++;
    }
    else if(data.at(i) >= data.at(i - 1) && big_mount <= data.at(i)){
      count++;
      if(big_mount <= data.at(i)){
        big_mount = data.at(i);
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);

    if ((a == b && a != c) || (a == c && a != b) || (b == c && a != b)) printf("%s\n", "Yes");
    else printf("%s\n", "No");

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, A[100000];
ll res, m;

int main() {
	cin >> N;
	for (int i = 0; i != N; ++i)
		cin >> A[i];
	sort(A, A + N);
	if (N & 1) {
		for (int i = N - 1; i != N / 2; --i) {
			res += A[i] * 2;
		}
		for (int i = 0; i != N / 2 - 1; ++i) {
			res -= A[i] * 2;
		}
		res -= A[N / 2 - 1] + A[N / 2];
		for (int i = N - 1; i != N / 2 + 1; --i) {
			m += A[i] * 2;
		}
		m += A[N / 2 + 1] + A[N / 2];
		for (int i = 0; i != N / 2; ++i) {
			m -= A[i] * 2;
		}
		res = max(res, m);
	}
	else {
		for (int i = N - 1; i != N / 2; --i) {
			res += A[i] * 2;
		}
		for (int i = 0; i != N / 2 - 1; ++i) {
			res -= A[i] * 2;
		}
		res += A[N / 2];
		res -= A[N / 2 - 1];
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 640
# abc121_b.py
N, M, C = map(int,input().split())
B = list(map(int,input().split()))
cnt = 0
for i in range(N):
    A = list(map(int,input().split()))
    ans = 0
    for j in range(M):
        ans += A[j]*B[j]
    ans += C
    if ans > 0:
        cnt += 1
print(cnt)        




Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)


ll nck(ll n, ll k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  if(k == 0 || k == n) return 1;
  ll nume = 1, deno = 1;
  for(int i=0; i<k; i++){
    nume *= (n-i);
    deno *= (i+1);
  }
  return (ll)(nume/deno);
}

int main(){
    ll n, m;
    cin >> n >> m;
    ll ans = nck(n, 2) + nck(m, 2);
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<pair<int,int>> V;
  for(int i = 0; i < N; ++i){
    int a, b;
    cin >> a >> b;
    V.emplace_back(a,b);
  }
  sort(V.begin(), V.end());
  priority_queue<int> pq;
  int j = 0;
  long long ans = 0;
  for(int i = 0; i < M; ++i){
    while(j < N and V[j].first <= i+1)
      pq.push(V[j].second), ++j;
    if(not pq.empty()){
      ans += pq.top();
      pq.pop();
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1908