akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#define ordered_set tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update>
#pragma 03
using namespace std;
using namespace __gnu_pbds;
ll a[200005], b[200005], c[400005], d[200005], lps[200005];
ll n;
void clps(){ 
    ll l = 0; lps[0] = 0; ll i = 1; 
    while (i < n){ 
        if (d[i] == d[l]) l++, lps[i] = l, i++; 
        else if (l != 0) l = lps[l - 1]; 
        else lps[i] = 0, i++;  
    } 
} 
vll fp;
void kmp(){
  	clps();
    ll i = 0, j = 0;
    while (i < 2 * n - 1){ 
        if (d[j] == c[i]){ 
            j++; i++; 
        } 
        if (j == n){
			fp.pb(i - j); 
            j = lps[j - 1]; 
        } 
        else if ((i < 2 * n - 1) && (d[j] != c[i])){ 
            if (j != 0) j = lps[j - 1]; 
            else i++; 
        } 
    } 
} 
int main(){
	cin >> n;
	for (ll i = 0; i < n; i++) cin >> a[i];
	for (ll i = 0; i < n; i++) cin >> b[i];
	for (ll i = 0; i < n; i++) c[i] = a[i] ^ a[(i + 1) % n];
	for (ll i = 0; i < n; i++) d[i] = b[i] ^ b[(i + 1) % n];
	for (ll i = n; i < 2 * n - 1; i++) c[i] = c[i - n];
	kmp();
	for (ll i = 0; i < fp.size(); i++) cout << fp[i] << " " << (b[0] ^ a[fp[i]]) << endl;
}

Measured memory_bytes: 14576
package main

import (
	"bufio"
	"fmt"

	//	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

func stringToint(s string) int {
	i, _ := strconv.ParseInt(s, 10, 64)
	return int(i)
}

func noResult() {
	fmt.Println(0)
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	buf := make([]byte, 10000)
	scanner.Buffer(buf, 1000000)
	line := make([]string, 0, 0)
	data := make([]int, 0, 0)

	scanner.Scan()
	line = append(line, scanner.Text())

	scanner.Scan()
	line = append(line, scanner.Text())

	if len(line) < 2 {
		noResult()
		return
	}

	input := strings.Split(line[1], " ")

	for _, s := range input {
		data = append(data, stringToint(s))
	}

	if len(data) != stringToint(line[0]) {
		noResult()
		return
	}

	sort.Ints(data)
	totalNum := 0

	if len(data)%2 != 0 {
		if data[0] != 0 {
			noResult()
			return
		} else {
			for i := 0; i < (len(data)-1)/2; i++ {
				if !(data[i*2+1] == int((i+1)*2) && data[i*2+2] == int((i+1)*2)) {
					noResult()
					return
				}
			}
			totalNum = (len(data) - 1) / 2
		}
	} else {
		for i := 0; i < len(data)/2; i++ {
			if !(data[i*2] == int((i+1)*2)-1 && data[i*2+1] == int((i+1)*2)-1) {
				noResult()
				return
			}
		}
		totalNum = len(data) / 2
	}

	var remain int
	remain = 1
	for i := 0; i < totalNum; i++ {
		remain = (remain * 2) % 1000000007
	}
	fmt.Println(remain)
}


Measured memory_bytes: 8192
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main() {
    int n, k;
    cin >> n >>  k;
    vector<ll> as(n + 1, 1);
    for (int i = 1; i <= n; i++) {
        cin >> as[i];
    }

    for (int i = k + 1; i <= n; i++) {
        if (as[i - k] < as[i]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

}


Measured memory_bytes: 4836
a,b,k = map(int,input().split())
if a+k-1 >= b-k+1:
    ans = list(range(a,b+1))
else:
    ans = list(range(a,a+k))+list(range(b-k+1,b+1))
for i in range(len(ans)):
    print(ans[i])

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

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

  string ans = "Good";
  if (S.at(0) == S.at(1) || S.at(1) == S.at(2) || S.at(2) == S.at(3))
    ans = "Bad";

  cout << ans << endl;
}

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

using namespace std;

int main()
{
   int n;
   cin>>n;
   vector<int> p(n),q(n);
   rep(i,n) cin>>p[i];
   rep(i,n) cin>>q[i];
   vector<int> a(n);
   rep(i,n) a[i]=i+1;
   
   map<vector<int>, int> mp;
  int j=1;
   do{
       mp[a] = j;
     j++;
   }while(next_permutation(a.begin(),a.end()));
   
   int ans = abs(mp[p] - mp[q]);
   cout<<ans<<endl;
   
   return 0;
}

Measured memory_bytes: 8544
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}

int ma[100005];

signed main() {
	int n, t;
	cin >> n >> t;
	int a[100005];
	rep(i, n) {
		cin >> a[i];
	}
	ma[n - 1] = 0;
	for (int i = n - 1; i >= 1; i--) {
		ma[i - 1] = max(a[i], ma[i]);
	}
	int ans = 0;
	rep(i, n) {
		ans = max(ans, ma[i] - a[i]);
	}
	int cnt = 0;
	rep(i, n) {
		if (ans == ma[i] - a[i]) cnt++;
	}
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 1920
n=int(input())
d=[0]*100
for i in range(n+1):
  s=str(i)
  d[int(s[0])*10+int(s[-1])]+=1

ans=0
for i in range(1,10):
  for j in range(1,10):
    ans+=d[10*i+j]*d[10*j+i]
print(ans)

Measured memory_bytes: 9196
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18



int main(){
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    int one;
    rep(i,N){
        cin >> A[i];
        if(A[i] == 1) one = i;
    }
    int ans = 0;
    if((N-K) % (K-1) == 0) ans = (N-K)/(K-1) + 1;
    else ans = (N-K)/(K-1) + 2;
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>

int main(){
	int k, s, a, b, c,cnt=0;
	scanf("%d%d", &k, &s);
	for (a = 0; a <= k; a++)
		for (b = 0; b <= k; b++) {
			c = s - a - b;
			if (0 <= c && c <= k)
				cnt++;
		}
			

	printf("%d", cnt);
	return 0;

}

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

using ll = long long;

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	int N; cin >> N;
	vector<ll> L(N), R(N);
	for (int i = 0; i < N; i++) {
		cin >> L[i] >> R[i];
	}

	ll cost = 0;
	ll los = 0, his = 0;
	priority_queue<ll, vector<ll>, less<ll>> lo;
	priority_queue<ll, vector<ll>, greater<ll>> hi;
	lo.push(L[0]), hi.push(L[0]);

	for (int i = 1; i < N; i++) {
		los -= (R[i] - L[i]);
		his += (R[i-1] - L[i-1]);

		ll vlo = lo.top() + los;
		ll vhi = hi.top() + his;
		if (vlo <= L[i] && L[i] <= vhi) {
			lo.push(L[i] - los);
			hi.push(L[i] - his);
		} else if (vhi < L[i]) {
			cost += L[i] - vhi;
			hi.pop();
			lo.push(vhi - los);
			hi.push(L[i] - his);
			hi.push(L[i] - his);
		} else if (L[i] < vlo) {
			cost += vlo - L[i];
			lo.pop();
			hi.push(vlo - his);
			lo.push(L[i] - los);
			lo.push(L[i] - los);
		}
	}

	cout << cost << '\n';

	return 0;
}


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

int main() {
  int i, j;
  int n;
  int temp;
  int* x = (int*)malloc(sizeof(int) * 200010);

  scanf("%d", &n);
  for (i = 1; i <= n;i++) {
    scanf(" %d", &x[i]);
  }
  //printf("OK\n");
  //fflush(stdout);
  if (n % 2 == 0) {
    for (i = n / 2; i > 0;i--){
      printf("%d", x[i * 2]);
      printf(" ");
    }
    temp = n / 2;
    for (i = 1; i <= temp; i++) {
      printf("%d", x[i * 2 - 1]);
      printf(" ");
    }
  }
  else {
    temp = n / 2;
    for (i = temp; i >= 0;i--){
      printf("%d", x[i * 2 + 1]);
      printf(" ");
    }
    for (i = 1; i <= temp; i++) {
      printf("%d", x[i * 2]);
      printf(" ");
    }
  }
  
  return 0;
}

Measured memory_bytes: 2816
#include <iostream>
using namespace std;
int n,a[100000];
long long ans;
int main(){
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    ans+=a[0]/2;
    a[0]%=2;
    for(int i=1;i<n;i++){
        if(a[i-1]>0&&a[i]>0){
            ans++;
            a[i]--;
        }ans+=a[i]/2;
        a[i]%=2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int x=sc.nextInt(), a=sc.nextInt(), b=sc.nextInt();
    x-=a;
    while(b<=x){
      x-=b;
    }
    System.out.println(x);
  }
}

Measured memory_bytes: 35576
#include<stdio.h>


using namespace std;

void output(int array[], int n){

	for(int k = 0;k < n; k++){
		if(k != n-1){
			printf("%d ",array[k]);
		}else{
			printf("%d\n",array[k]);
		}
	}
}

int main(){

	int array[1000];
    int n ;

    scanf("%d", &n);
	for(int i = 0; i < n; i++){
        scanf("%d", &array[i]);
	}

    output(array, n);


	int v = 0;
	int j = 0;
	for(int i = 1; i < n; i++){
		v = array[i];
		j = i-1;
        while(j >= 0 && array[j] > v){
            array[j+1] = array[j];
			j--;
		}
		array[j+1] = v;
        
        output(array, n);
		}
	}



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

typedef long long ll;
typedef vector<ll> v1;
typedef vector<vector<ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

ll t1,t2;
ll a1,a2;
ll b1,b2;
ll x1,x2;

int main(){
    cin >> t1 >> t2;
    cin >> a1 >> a2;
    cin >> b1 >> b2;
    x1 = a1-b1;
    x2 = a2-b2;
    if(x1*t1+x2*t2 == 0){ cout << "infinity" << endl;return 0;}
    if(x1*t1 > 0 && x1*t1+x2*t2 > 0){
        cout << 0 << endl;
        return 0;
    }
    if(x1*t1 < 0 && x1*t1+x2*t2 < 0){
        cout << 0 << endl;
        return 0;
    }
    if(x1*t1 > 0 && x1*t1+x2*t2 < 0){
        if(x1*t1%abs(x1*t1+x2*t2) == 0){
            cout << 1+((x1*t1)/abs(x1*t1+x2*t2))*2-1 << endl;
            return 0;
        }else{
            cout << 1+((x1*t1)/abs(x1*t1+x2*t2))*2 << endl;
            return 0;
        }
    }
    if(x1*t1 < 0 && x1*t1+x2*t2 > 0){
        if(abs(x1*t1)%abs(x1*t1+x2*t2) == 0){
            cout << 1+(abs(x1*t1)/abs(x1*t1+x2*t2))*2-1 << endl;
            return 0;
        }else{
            cout << 1+(abs(x1*t1)/abs(x1*t1+x2*t2))*2 << endl;
            return 0;
        }
    }
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  int n;
  cin>>n;

  int a[n];
  int b[n];
  rep(i,0,n) cin>>a[i]>>b[i];

  sort(a,a+n);
  sort(b,b+n);

  if(n % 2 == 1){
    cout<<b[n/2]-a[n/2]+1<<'\n';
  }else{
    int t1 = a[n/2] + a[n/2-1];
    int t2 = b[n/2] + b[n/2-1];
    int ans = t2 - t1;
    cout<<ans+1<<'\n';
  }

  return 0;
}

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

using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
using ii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vii = vector<ii>;
using vvii = vector<vii>;
using vd = vector<ld>;

template<class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<class TIn, class TOut = null_type>
using order_tree = tree<TIn, TOut, less<TIn>, rb_tree_tag,
	tree_order_statistics_node_update>;
// .find_by_order(int r) and .order_of_key(TIn v)

constexpr int INF = 2000000010;
constexpr ll LLINF = 9000000000000000010LL;
constexpr ld PI = acos(-1);

void solve() {
	int h, w;
	cin >> h >> w;

	vector<string> B(h);
	for (string &s : B) cin >> s;

	vector<vector<int>> dp(h, vector<int>(w, h+w+100));
	dp[0][0] = (B[0][0] == '#' ? 1 : 0);
	for (int r = 0; r < h; ++r)
		for (int c = 0; c < w; ++c) {
			if (r > 0) {
				int tr = dp[r-1][c];
				if (B[r-1][c] == '.' && B[r][c] == '#')
					++tr;
				dp[r][c] = min(dp[r][c], tr);
			}
			if (c > 0) {
				int tr = dp[r][c-1];
				if (B[r][c-1] == '.' && B[r][c] == '#')
					++tr;
				dp[r][c] = min(dp[r][c], tr);
			}
		}
	cout << dp.back().back() << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(12);
	
	solve();
	
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

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

#define INF INT_MAX / 2 - 1
#define PI 2*acos(0.0)
#define ll long long

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
	string s;
	cin >> s;
	replace(s.begin(), s.end(), ',', ' ');
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin
# import numpy as np
# import sys
# sys.setrecursionlimit(10**4)

def _li(): return list(map(int, stdin.readline().split()))
def _li_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def _lf(): return list(map(float, stdin.readline().split()))
def _ls(): return stdin.readline().split()
def _i(): return int(stdin.readline())
def _f(): return float(stdin.readline())
def _s(): return stdin.readline()[:-1]


N = _i()
b_list = _li()

ans = []
for i in range(N, 0, -1):
    cand = []
    for j in range(i):
        if b_list[j] == (j+1):
            cand.append(j)
    if len(cand) == 0:
        print(-1)
        exit()
    else:
        a = b_list.pop(cand[-1])
        ans.append(a)

for a in ans[::-1]:
    print(a)


Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    char a,b,c,d;
    scanf("%c %c %c %c",&a,&b,&c,&d);
    if(a==b && b==c && c==d && a==d)
        printf("No\n");
    else if(a==c && b==d)
        printf("Yes\n");
    else if(a==d && b==c)
        printf("Yes\n");
    else if(a==b && c==d)
    printf("Yes\n");
     else
        printf("No\n");
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    int l,r,d;
    cin >> l >> r >> d;
    int ans = 0;
    FOR(i, l, r+1) {
        if (i % d == 0) {
            ans++;
        }
    }
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
const int MOD=1000000007;
const int nmax=3123;
int n,dp[nmax];
ll res;
char s[nmax];
int main(){
    scanf("%d",&n);
    scanf("%s",s+1);
    dp[1]=1;
    for(int i=2; i<=n; ++i){
        if(s[i-1]=='<'){
            int tmp=0;
            for(int j=1; j<=i; ++j){
                int tmp2=dp[j];
                dp[j]=dp[j-1]+tmp;
                if(dp[j]>=MOD)dp[j]-=MOD;
                tmp=tmp2;
            }
        }
        else
            for(int j=i-2; j>0; --j){
                dp[j]+=dp[j+1];
                if(dp[j]>=MOD)dp[j]-=MOD;
            }
    }
    for(int i=1; i<=n; ++i)res+=dp[i];
    res%=MOD;
    printf("%lld",res);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,le;
struct pnt{
	int x,y,id;
} a[111111];
pair<int,pair<int,int> > e[1111111];
int ace[111111];
bool cmp_x(pnt x,pnt y){
	return x.x < y.x;
}
bool cmp_y(pnt x,pnt y){
	return x.y < y.y;
}
int dis(pnt x,pnt y){
	return min((int)labs(x.x-y.x),(int)labs(x.y-y.y));
}
int ancestor(int x){
	return x-ace[x]?ace[x]=ancestor(ace[x]):x;
}
int main(){
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		scanf("%d%d",&a[i].x,&a[i].y);
		a[i].id=i;
	}
	sort(a,a+n,cmp_x);
	for(int i=1; i<n; i++)
		e[le++]=make_pair(dis(a[i],a[i-1]),make_pair(a[i].id,a[i-1].id));
	sort(a,a+n,cmp_y);
	for(int i=1; i<n; i++)
		e[le++]=make_pair(dis(a[i],a[i-1]),make_pair(a[i].id,a[i-1].id));
	sort(e,e+le);
	for(int i=0; i<n; i++)
		ace[i] = i;
	int res = 0;
	for(int i=0; i<le; i++){
		int x=e[i].second.first,y=e[i].second.second;
		if(ancestor(x) != ancestor(y)){
			res += e[i].first;
			ace[ancestor(x)] = ancestor(y);
		}
	}
	printf("%d\n",res);
	return 0;
}


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

#define ll long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 500005
int a[mxn],sz[mxn];
ll ans[mxn];
ll gans=0;

void init(int n){
for(int i=1; i<=n; ++i){
    a[i]=i;
    sz[i]=1;
    ans[i]=0;
}
}

int root(int i){
while(i!=a[i]){
    a[i]=a[a[i]];
    i=a[i];
}
return i;
}

ll nc2(ll n){
return 1LL*n*(n-1)/2;
}

void unn(int p,int q){
p=root(p);
q=root(q);
if(p==q)return;
if(sz[p]>sz[q])swap(p,q);
a[q]=a[p];
gans=gans+ans[p]+ans[q];
ans[p]=nc2(sz[p]+sz[q]);
gans-=ans[p];
sz[p]+=sz[q];
sz[q]=0;
}

int main(){
sp;
int n,m;
cin>>n>>m;
init(n);
vector<pi> v;
for(int i=0; i<m;++i){
    int x,y;
    cin>>x>>y;
    v.pb({x,y});
}
stack<ll> an;
gans=nc2(n);
reverse(v.begin(),v.end());
for(auto &it:v){
    an.push(gans);
    unn(it.f,it.s);
}
while(!an.empty()){
    cout<<an.top()<<"\n";
    an.pop();
}
return 0;}


Measured memory_bytes: 7924
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
using P = std::pair<int, int>;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int h,w;
P dist[1001001][4];
std::string s[1001001];

bool check(int i, int j){
	return (0<=i && i<h && 0<=j && j<w && s[i][j]=='.');
}

int ver(int i, int j){
	return i*w+j;
}

std::queue<P> que;

int main(void){
	int x,y,z,i,j,k,l,dx[4]={-1,0,0,1},dy[4]={0,-1,1,0},sx,sy,gx,gy,p,q,ans=INF;
	P tmp;
	std::fill(dist[0],dist[1001001],P(INF,INF));
	std::cin >> h >> w >> l;
	std::cin >> sx >> sy >> gx >> gy;
	--sx; --sy; --gx; --gy;
	for(i=0; i<h; ++i){
		std::cin >> s[i];
	}
	for(k=0; k<4; ++k){
		dist[ver(sx,sy)][k] = P(0,0);
		que.push(P(ver(sx,sy),k));
	}
	while(!que.empty()){
		x = que.front().first/w;
		y = que.front().first%w;
		// std::cout << x << " " << y << " " << z << std::endl;
		z = que.front().second;
		que.pop();
		p = ver(x,y);
		for(k=0; k<4; ++k){
			if(!check(x+dx[k],y+dy[k])){
				continue;
			}
			q = ver(x+dx[k],y+dy[k]);
			tmp = dist[p][z];
			if(z==k){
				tmp.second++;
				tmp.first += tmp.second/l;
				tmp.second %= l;
			}else{
				if(tmp.second){
					++tmp.first;
				}
				tmp.second = 1;
			}
			if(tmp < dist[q][k]){
				dist[q][k] = tmp;
				que.push(P(q,k));
			}
		}
	}
	for(k=0; k<4; ++k){
		ans = std::min(ans,dist[ver(gx,gy)][k].first + (!!dist[ver(gx,gy)][k].second));
	}
	std::cout << ((ans<INF)?ans:(-1)) << std::endl;
	return 0;
}

Measured memory_bytes: 68292
// Problem : B - Bingo
// Contest : AtCoder Beginner Contest 157
// URL : https://atcoder.jp/contests/abc157/tasks/abc157_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb emplace_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
using namespace std;
using namespace __gnu_pbds;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}

void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int a[3][3];
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
cin>>a[i][j];
int n;cin>>n;
while(n--)
{
	int b;cin>>b;
	for(int i=0;i<3;i++)
	for(int j=0;j<3;j++)
	if(a[i][j]==b)
	a[i][j]=-1;
}
for(int i=0;i<3;i++){
	int count=0;
for(int j=0;j<3;j++)
if(a[i][j]==-1)
count++;
if(count==3)
{
	cout<<"Yes";return;
}
}
for(int i=0;i<3;i++)
{int count=0;
for(int j=0;j<3;j++)
{
	if(a[j][i]==-1)
	count++;
}
if(count==3)
{
	cout<<"Yes\n";return;
}
}
if((a[1][1]+a[2][2]+a[0][0]==-3)||(a[0][2]+a[1][1]+a[2][0]==-3))
{
	cout<<"Yes\n";return;
}
cout<<"No\n";
}


int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
while(t--)
{
    solve();
}
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    vector<int> cnt(m+1);
    for(int i=0; i<n; ++i){
        int k;
        cin >> k;
        for(int j=0; j<k; ++j){
            int a;
            cin >> a;
            ++ cnt[a];
        }
    }

    int ans = 0;
    for(int i=1; i<=m; ++i){
        if(cnt[i] == n)
            ++ ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/**

author:	©LoneWolfDON
Git: MahinHossainMunna

**/
/*

*/
#include <stdio.h>

int main()
{
    int K, A, B;

    scanf("%d%d%d", &K, &A, &B);

    int multiple = (B / K) * K;

    if (A <= multiple)
        printf("OK\n");

    else
        printf("NG\n");

    return 0;
 }


Measured memory_bytes: 1620
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];
int vis[maxn];
int main()
{
  ios::sync_with_stdio(0);
  int n, m;
  int x;
  string s;
  cin >> n >> m;
  int cnts = 0;
  int cntt = 0;
  while(m --){
    cin >> x >> s;
    if(s == "AC"){
      if(vis[x] == 0){
        vis[x] = 1;
        a[x] ++;
        cntt += a[x];
        cnts ++;
      }
    }
    else{
      if(vis[x] == 0){
        a[x] ++;
      }
    }
  }
  printf("%d %d\n", cnts, cntt - cnts);
  return 0;
}


Measured memory_bytes: 1024
import math
n,d = map(int,input().split())
ls = [[int(i) for i in input().split()] for i in range(n)]
count = 0
for i in range(1,n):
    for j in range(i):
        check = 0
        for k in range(d):
            check += (abs(ls[i][k] - ls[j][k]))**2
        check = math.sqrt(check)
        if check - int(check) == 0:
            count += 1
print(count)

Measured memory_bytes: 38384
import math

a,b,x=map(int,input().split())
x_th=a*a*b/2
if x>=x_th:
    theta_rad=math.atan((2*b)/a-(2*x)/(a**3))
    print(math.degrees(theta_rad))
else:
    theta_rad=math.atan((a*b*b)/(2*x))
    print(math.degrees(theta_rad))


Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int x, y;
	int b[10000], s[10000];
	int soe = 0;
	int maxsoe;
	
	while ((x != 0) || (y != 0)){
		scanf("%d %d", &x, &y);
		
		if (x < y){
			b[soe] = y;
			s[soe] = x;
		}
		else if (y < x){
			b[soe] = x;
			s[soe] = y;
		}
		else {
			b[soe] = x;
			s[soe] = y;
		}
	
	++soe;
	}
	
	maxsoe = soe;
	
	for (soe = 0; maxsoe != 1; ++soe){
		
		printf("%d %d\n", s[soe], b[soe]);
		
		--maxsoe;
	}
	
	
	return 0;
	
}

Measured memory_bytes: 624
#include <stdio.h>

int main()
{
	int N = 0;
	scanf("%d", &N);

    int a = N/100;              //百の位
    int b = N/10 - a*10;        //十の位
    int c = N - a*100 - b*10;   //一の位

    if((7 == a) || (7 == b) || (7 == c)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

	return 0;
}

Measured memory_bytes: 1624
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	int i;
	string s;
	cin >> s;
	sort(s.begin(),s.end());
	if(s[0]!=s[2]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}



Measured memory_bytes: 256
s=input()
s2="".join([c+" " for c in s])
res=0
for i in range(2**(len(s)-1)):
    t=list(s2)
    for j in range(len(s)-1):
        if (i>>j)&1:
            t[2*j+1]="+"
    res+=eval("".join([c for c in t if c!=" "]))
print(res)


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

using ll = long long;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}

int main() {
  string S; cin >> S;
  ll ans = 0;
  unordered_map<ll, ll> m; m[0] = 1;
  reverse(all(S));
  ll tmp = 0, ten = 1;
  REP(i, S.size()) {
    tmp += char_to_int(S[i]) * ten;
    tmp %= 2019;
    ten *= 10; ten %= 2019;
    m[tmp]++;
  }
  for(auto x: m) {
    ans += 0.5 * x.second * (x.second - 1);
  }
  cout << ans << endl;
}

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

int main() {
	int n, m;
	string s[100], t[100];
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> s[i];
	}
	cin >> m;
	for (int i = 0;i < m;i++) {
		cin >> t[i];
	}
	int ma = 0;
	for (int i = 0;i < n;i++) {
		int count = 0;
		for (int j = 0;j < n;j++) {
			if (s[i] == s[j]) {
				count++;
			}
		}
		for (int j = 0;j < m;j++) {
			if (s[i] == t[j]) {
				count--;
			}
		}
		ma = max(ma, count);
	}
	cout << ma << endl;



	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int64_t mod = 1000003;
vector<int> doublestep(int p){
  vector<int> y = {};
  while (p != 0){
    y.push_back(p%2);
    p /= 2;
  }
  reverse(y.begin(), y.end());
  return y;
}
int64_t doubling(int z, int num){
  vector<int> y = doublestep(num);
  int64_t tet = 1;
  for (int i=0;i<y.size();i++){
    if (y.at(i) == 1){
      tet *= z;
      tet %= mod;
    }
    if (i != y.size() - 1){
      tet *= tet;
      tet %= mod;
    }
  }
  return tet;
}
const vector<int> modi = doublestep(mod-2);
int64_t inved(int64_t s){
  int64_t y = 1;
  for (int i=0;i<modi.size();i++){
    if (modi.at(i) == 1){
      y *= s;
      y %= mod;
    }
    if (i != modi.size() - 1){
      y *= y;
      y %= mod;
    }
  }
  return y;
}
int main(){
  vector<int64_t> frac = {1};
  for (int i=0;i<mod;i++){
    frac.push_back((frac.at(i)*(i+1))%mod);
  }
  int Q;
  cin >> Q;
  for (int i=0;i<Q;i++){
    int x, d, n;
    cin >> x >> d >> n;
    if (x == 0){
      cout << 0 << endl;
    }
    else{
      if (d == 0){
        cout << doubling(x, n) << endl;
      }
      else{
        if (n >= mod){
          cout << 0 << endl;
        }
        else{
          int64_t xinvd = (x * inved(d) - 1 + mod) % mod;
          if (xinvd + n >= mod){
            cout << 0 << endl;
          }
          else{
            int64_t dn = doubling(d, n);
            int64_t val = dn;
            val *= frac.at(xinvd + n);
            val %= mod;
            val *= inved(frac.at(xinvd));
            val %= mod;
            cout << val << endl;
          }
        }
      }
    }
  }
  return 0;
}

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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty; // sx < tx, sy < ty

  string ans = "";
  for (int i=0; i<abs(ty-sy); i++)
    ans += "U";
  for (int i=0; i<abs(tx-sx); i++)
    ans += "R";
  for (int i=0; i<abs(ty-sy); i++)
    ans += "D";
  for (int i=0; i<abs(tx-sx); i++)
    ans += "L";

  ans += "L";
  for (int i=0; i<abs(ty-sy)+1; i++)
    ans += "U";
  for (int i=0; i<abs(tx-sx)+1; i++)
    ans += "R";
  ans += "D";

  ans += "R";
  for (int i=0; i<abs(ty-sy)+1; i++)
    ans += "D";
  for (int i=0; i<abs(tx-sx)+1; i++)
    ans += "L";
  ans += "U";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T & a, const T & b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };


/******************************************************************************************/



int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	int h, a;
	cin >> h >> a;
	cout << (h - 1) / a + 1 << endl;
		


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<ll> check(5);
  rep(i, n){
    string s;
    cin >> s;
    char c = s[0];
    if(c == 'M') check[0]++;
    else if(c == 'A') check[1]++;
    else if(c == 'R') check[2]++;
    else if(c == 'C') check[3]++;
    else if(c == 'H') check[4]++;
  }
  ll ans = 0;
  rep(a, 3){
    for(int b = a + 1; b < 4; b++){
      for(int c = b + 1; c < 5; c++){
        ans += check[a] * check[b] * check[c];
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
  int data[10];
  int count=10;
  for (int i = 0; i < count; i++) {
    cin>>data[i];
  }
  sort(data,data+10);
  for (int i = 0; i < 3; i++) {
    cout<<data[9-i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3148
words = lambda t : list(map(t, input().split()))
n = int(input())
s = input()
ans = 0
for i in range(len(s)-2):
    if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':
        ans += 1
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	
	int K, n, sum;
	
	while(true){
		cin >> K;
		if(K == 0){
			break;
		}
		sum = 0;
		for(int i = 0; i < K * (K - 1) / 2; i++){
			cin >> n;
			sum += n;
		}
		sum /= (K - 1);
		printf("%d\n", sum);
	}
	
	return 0;
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    ll Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;
    S = min({S, H*2, Q*4});
    ll ans = S* N;
    ans = min(ans, N/2 * D + (N%2)*S);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
void fun(int x1,int y1,int x2,int y2,int &x3,int &y3){
	y3=y2+x2-x1,x3=x2-y2+y1;
/*	int y31=y2+x2-x1,y32=y2-x2+x1;
	int x31=x2-(y31-y2)*(y2-y1)/(x2-x1),x32=x2-(y32-y2)*(y2-y1)/(x2-x1);
	if( (x2-x31)*(y2-y1)-(x2-x1)*(y2-y31) > 0 )
		x3=x31,y3=y31;
	else
		x3=x32,y3=y32; */
}
int main() {
	int n;
	 int x1,y1,x2,y2,x3,y3,x4,y4;
	 cin>>x1>>y1>>x2>>y2;
	 fun(x1,y1,x2,y2,x3,y3);
	 fun(x2,y2,x3,y3,x4,y4);
	 cout<<x3<<' '<<y3<<' '<<x4<<' '<<y4<<endl;
	return 0;
	}


Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long n, k, s;

long max = 1000000000;

int main(){
    scanf("%ld%ld%ld", &n, &k, &s);
    if(s == max){
        for(int i = 0; i < k; i++){
            printf("%ld ", max);
        }
        for(int i = k; i < n; i++){
            printf("1 ");
        }
    }else{
        for(int i = 0; i < k; i++){
            printf("%ld ", s);
        }
        for(int i = k; i < n; i++){
            printf("%ld ", max);
        }
    }
    printf("\n");
}


Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;
#include "atcoder/all"
using namespace atcoder;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;

signed main(){
	int N, Q;
	cin >> N >> Q;
	dsu d(N);
	REP(_, Q) {
		int t, a, b;
		cin >> t >> a >> b;
		if(t == 0) d.merge(a, b);
		else out(d.same(a, b));
	}
}

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

// #include "../../Template.cpp"

void solve() {
    int32_t n; cin >> n;
    vector<int> arr(n, 0);
    for(int i = 0; i < n; i ++) cin >> arr[i];
    vector<vector<int>> dp(2, vector<int>(n+1, 0.0));
    dp[0][0] = 1.0;
    for(int32_t i = 1; i <= n; i ++) {
        for(int32_t j = 0; j <= n; j ++) {
            if(j<=i) {
                if(j == 0)
                    dp[i%2][j] = dp[(i+1)%2][j]*(1.0-arr[i-1]);
                else 
                    dp[i%2][j] = (dp[(i+1)%2][j]*(1.0-arr[i-1])) + (dp[(i+1)%2][j-1]*arr[i-1]);
            }
        }
    }
    // for(auto i:dp) {for(auto j:i) cout << j << " "; cout << endl;}
    int ans = 0;
    int32_t l = (n/2);
    for(int32_t i = l+1; i <= n; i ++) {
        ans += dp[n%2][i];
    }
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<vector>
#include<map>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);

	int n,k;
	while(cin>>n>>k)
	{
		if(n%k==0)
			cout<<"0"<<endl;
		else
			cout<<"1"<<endl;
	} 

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, q; cin >> n >> q;
    bool ans[n+2];
    memset(ans, 0, sizeof(ans));
    ans[1] = true;
    int cur = 1;
    while (q--) {
        ans[cur-1] = ans[cur+1] = true;
        int a, b; cin >> a >> b;
        if (cur == a) cur = b;
        else if (cur == b) cur = a;
        swap(ans[a], ans[b]);
    }
    ans[cur-1] = ans[cur+1] = true;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (ans[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
  int64_t p,v,p1,v1,p2,v2,t;
  cin >> p1 >> v1 >> p2 >> v2 >> t;
  p=abs(p2-p1);
  if(v1<=v2) {
    cout << "NO" << endl;
    return 0;
  }
  v=v1-v2;
  if ( p<=v*t ) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3608
def shortest_from_zero(section):
    negative = section[0]
    positive = section[1]
    distance = positive - negative
    return min(distance + abs(negative), distance + positive)


if __name__ == '__main__':
    ans = 100000000000
    n, k = map(int, input().split())
    x_list = list(map(int, input().split()))

    for i in range(n - k + 1):
        section = [min(0, x_list[i]), max(0, x_list[i + k - 1])]
        if ans > shortest_from_zero(section):
            ans = shortest_from_zero(section)
    print(ans)

Measured memory_bytes: 14484
#include <bits/stdc++.h>
#include<iostream>
#define point complex<double>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int N=2e5+10,mod=1e9+7;
ll inf=LONG_LONG_MAX;
ll a[N];
int GCD(int a, int b) {
	if(b==0)
    	return a;
	else
    	return GCD(b, a%b);
}
int LCM(int a, int b){
	return (a*b)/GCD(a,b);
}


int main()
{
  /* ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);*/


int ans[200][200];
int h,w,n;
cin>>h>>w>>n;
for(int i=1;i<=n;i++)cin>>a[i];
int ind=1;
for(int i=1;i<=h;i++){
        if(i%2)
    for(int j=1;j<=w;j++){
        ans[i][j]=ind;
a[ind]--;
if(a[ind]==0)ind++;
    }
    else {
        for(int j=w;j>=1;j--){
            ans[i][j]=ind;
            a[ind]--;
if(a[ind]==0)ind++;
        }
    }
}
for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cout<<ans[i][j]<<' ';
        }
        cout<<endl;

}







    return 0;
}


Measured memory_bytes: 3788
"""
author : halo2halo
date : 30, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())
L = [0] * N

for _ in range(M):
    a, b = map(int, readline().split())
    L[a - 1] += 1
    L[b - 1] += 1

for i in L:
    print(i)


Measured memory_bytes: 3060
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
const ll MAX_N = 100000;
ll coord[MAX_N]; // 各エッジの座標
vector<vector<P>> graph(MAX_N);

//DFS
bool dfs(ll v, ll x){
	coord[v] = x;
	REP(i, graph[v].size()){ // エッジvにつながる各ノードに対し
		if (coord[graph[v][i].first]==INF 
			&& !dfs(graph[v][i].first, x + graph[v][i].second)){
			// 隣接するエッジの座標が未定なら
			return false;
		}
		if (coord[graph[v][i].first]!=INF 
		    && coord[graph[v][i].first]!=x + graph[v][i].second){
			// 隣接するエッジの座標が矛盾するなら
			return false;
		}
	}
	return true;
}
 

int main() {
	// 入力
	ll N, M;
	cin >> N >> M;
	// vector<vector<P>> graph(N); // 連結リスト
	// graph(N): N個のエッジを持つグラフを表す連結リスト
	// graph[i]: エッジiの連結情報を持つ
	// vector<P>: エッジiの連結情報のリスト
	// P: pair (隣接するエッジ, ノードの重み)
	// [エッジ, 隣接するエッジ, ノードの重み]
	REP(i, M){
		ll l, r, d;
		cin >> l >> r >> d;
		l--, r--; // 1始まりを0始まりに
		graph[l].pb(P(r,d)); // L->Rのノード情報をappend
		graph[r].pb(P(l,-d)); // R->Lのノード情報をappend
	}
 
	// 解法
	bool ans = true;
	REP(i, N) coord[i] = INF;
	REP(i, N){ // 各エッジに対して
		if (coord[i]==INF){ // エッジiの座標が未確定なら
			if (!dfs(i, 0)){ //エッジiの座標を0と置いてdfs開始
				ans = false; // 矛盾が生じたら判定をfalseに
				break;
			}
		}
		if (ans==false) break;
	}
	if (ans) printf("Yes\n"); // 最後まで矛盾が見られなったらYes
	else printf("No\n");
	// REP(i, N){
	// 	printf("人%lld: %lld \n", i+1, coord[i]);
	// }
}


Measured memory_bytes: 16512
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main() {
	int y, m, d;
	while (cin >> y >> m >> d) {
		string mode;
		if (y < 1868)mode = "pre-meiji";
		else if (y == 1868) {
			int k = m * 100 + d;
			if (k < 908)mode = "pre-meiji";
			else mode = "meiji";
		}
		else if (y > 1868 && y < 1912)mode = "meiji";
		else if (y == 1912) {
			int k = m * 100 + d;
			if (k < 730)mode = "meiji";
			else mode = "taisho";
		}
		else if (y > 1912 && y < 1926)mode = "taisho";
		else if (y == 1926) {
			int k = m * 100 + d;
			if (k < 1225)mode = "taisho";
			else mode = "showa";
		}
		else if (y > 1926 && y < 1989)mode = "showa";
		else if (y == 1989) {
			int k = m * 100 + d;
			if (k < 108)mode = "showa";
			else mode = "heisei";
		}
		else mode = "heisei";
		if (mode == "pre-meiji")cout << mode << endl;
		else {
			cout << mode << ' ';
			if (mode == "meiji")cout << y - 1867;
			else if (mode == "taisho")cout << y - 1911;
			else if (mode == "showa")cout << y - 1925;
			else cout << y - 1988;
			printf(" %d %d\n", m, d);
		}
	}
}

Measured memory_bytes: 3232
#include <stdio.h>

int main(void)
{
	int n;
	int temp;
	int i;
	int MONEY;
	
	MONEY = 100000;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		temp = MONEY * 0.05;
		MONEY += temp;
		if (MONEY % 1000 > 0){
			temp = MONEY % 1000;
			MONEY -= temp;
			MONEY += 1000;
		}
	}
	
	printf("%d\n", MONEY);
	
	return 0;
}

Measured memory_bytes: 592