akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <set>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926535;

class UnionFind {
	std::vector<int> p;

public:
	UnionFind(int n) : p(n, -1) {}

	int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); }

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

	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (p[y] < p[x]) std::swap(x, y);
		if (p[x] == p[y]) --p[x];
		p[y] = x;
		return true;
	}
};
ll fast(ll n, ll k) {
	if (k == 0) {
		return 1;
	}
	if (k == 1) {
		return n;
	}
	if (k % 2 == 0) {
		ll tmp = fast(n, k / 2);
		return tmp * tmp % MOD;
	}
	else {
		ll tmp = fast(n, k / 2);
		tmp = tmp * tmp % MOD;
		return n * tmp % MOD;
	}
}

int main() {
	ll N;
	cin >> N;
	vector<ll> sanka(N);

	map<ll, ll> mp;

	for (ll i = 0; i < N; i++)
	{
		cin >> sanka[i];
		mp[sanka[i] + (i+1)] += 1;
	}

	ll ans = 0;
	for (ll i = 0; i < N; i++)
	{
		ll diff = (i +1) - sanka[i];

		ans += mp[diff];
	}
	cout << ans << endl;
}

Measured memory_bytes: 27288
n = int(input())
a = list(chr(i*97) for i in range(10))
ans = 'a'

def dfs():
    global ans, n
    if len(ans) == n:
        print(ans)
    else:
        max1 = 'a'
        for i in range(len(ans)):
            max1 = max(max1, ans[i])
        for i in range(ord(max1) - 95):
            ans += chr(i+97)
            dfs()
            ans = ans[:-1]

dfs()


Measured memory_bytes: 4404
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)


int main() {
  
  ll N; 
  cin >> N;
  vector<ll> L(N+1);
  rep(i, N){
    cin >> L[i];
  }
  ll ans = 0;

  //sort(L.begin(), L.end());
  for(ll i= 0; i< N-2; i++){
    //cout << "i" << endl;
    for(ll j= i+1; j< N-1; j++){
      //cout << "j" << endl;
      for(ll k= j+1; k<N; k++){
        if(L[i]+L[j]>L[k] && L[i]+L[k]>L[j] && L[k]+L[j]>L[i] && L[k]!=L[j] && L[k]!=L[i] && L[j]!=L[i]){
          ++ans;
        }
        //cout << "k" << endl;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
def slove():
    import sys, collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    s = ["".join(sorted(list(str(input().rstrip('\n'))))) for _ in range(n)]
    s = collections.Counter(s).most_common()
    t = 0
    for i, v in s:
        for j in range(1, v):
            t += j
    print(t)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 72540
#include<bits/stdc++.h>
using namespace std;
int n,k;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	if(k==1){
		cout<<0<<endl;
		return 0;
	} 
	int few=1;
	int most=n-(k-1);
	cout<<most-few<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll get(string &s)
{
    ll ans = (s[0]-'0')*100 + (s[2]-'0')*10 + (s[3]-'0');
    return ans;
}
int main() {
    ll a;
    string b;
    cin >>a >> b;
    ll x = a*get(b);
    cout << x/100;
}


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

int main(){
  ll n,k,sum=0;
  cin >> n >> k;
  vector<ll> v(n);
  r(i,n)cin >> v[i];
  sort(v.begin(),v.end());
  r(i,n-k)sum+=v[i];
  cout<<sum<<endl;
}

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

using namespace std;

typedef long long ll;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
	int w,a,b;
	cin >> w >> a >> b;
	int ans = 0;
	int t = b-(a+w),p = a-(b+w);
	if(t>=0) ans = t;
	else if(p>=0) ans = p;
	cout << ans << "\n";
    
	return 0;
}

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

int a[110];
int n, k;

//a[0], a[1], a[2]. ... , a[n - 1]?????????x?????????????????????????????????
int binary_search(int x){
    int res = 0;
	int l = 0, r = n - 1;
	//[l, r)???????????????????????????????????§??°?????????
	while(r - l >= 0){
		int m = (l + r) / 2;
        res++;
		if(a[m] == x) return res; //x??????????????£?????´???
		else if(a[m] > x) r = m - 1;
		else if(a[m] < x) l = m + 1;
	}
	//x???????????????????????£?????´???
	return res;
}

int main(){
    while(cin >> n, n){
        for(int i = 0; i < n; i++){
            cin >> a[i];
        }
        cin >> k;
        sort(a, a + n);
        cout << binary_search(k) << endl;
    }
}

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

int main(){
  ll n,ans=0;cin>>n;
  map<ll,ll> x,y;
  for(int i=1;i<=n;i++){
    int tmp;cin>>tmp;
    x[i+tmp]++;
    y[i-tmp]++;
  }
  for(auto p:x){
    ll t=p.first;
    ans+=p.second*y[t];
  }

  cout<<ans;
}

Measured memory_bytes: 37852
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vint;
#define loop(i,n) for(int i=0;i<n;++i)
#define INF 10000000000

int main(){
    int n,k;
    cin >> n >> k;
    vint w(n);
    loop(i,n){
        cin >> w[i];
    }

    int l=0,r=INF;
    while(r-l>1){
        int m=(l+r)/2;

        //最大積載量を調べる。
        int count=1,now=0;
        loop(i,n){
            if(w[i]>m){
                count=INF;
                break;
            }
            now+=w[i];
            if(now>m){
                ++count;
                now=w[i];
            }
        }

        if(count<=k){
            r=m;
        }else{
            l=m;
        }
    }
    cout << r << endl;
}


Measured memory_bytes: 3120
// clang-format off

#include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ")" << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define sum(v) accumulate(all(v), 0)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!odd(n))

#define INF 1000000000
#define MOD 1000000007

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>

using namespace std;

// clang-format on

int knapsack(int numberOfItem, int maxWeight, int weightOfItems[],
             int valueOfItems[]) {
  map<pair<int, int>, int> mm;

  function<int(int, int)> _knapsack = [&](int i, int j) -> int {
    auto p = mp(i, j);
    if (mm.count(p)) {
      return mm[p];
    }
    int r;
    if (i == numberOfItem) {
      r = 0;
    } else if (j < weightOfItems[i]) {
      r = _knapsack(i + 1, j);
    } else {
      r = max(_knapsack(i + 1, j),
              _knapsack(i + 1, j - weightOfItems[i]) + valueOfItems[i]);
    }
    mm[p] = r;
    return r;
  };

  return _knapsack(0, maxWeight);
}

main {
  int N, W;
  cin >> N >> W;
  int w[N], v[N];
  rep(i, N) cin >> w[i] >> v[i];
  cout << knapsack(N, W, w, v) << endl;
  bye;
}


Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
typedef int lli;
#define mod 1000000007
#define F first
#define S second
#define pb push_back
#define eb emplace_back
/*unordered_map<int,int>mp;
mp.reserve(1024);
mp.max_load_factor(0.25);
*/
int main()
{
    //freopen("input.txt","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    lli n,t,i,j,k;
    cin>>n;
    double sum=0;
    double ar[n];
    for(i=0;i<n;i++)
    {
        cin>>ar[i];
        sum+=1/ar[i];
    }
    sum=1/sum;
    cout<<fixed<<setprecision(5)<<sum;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define   ll    long long int
#define   sz    200010

using namespace std;


ll num[sz];

int main()
{


    ll n,m,i,j,k,p,c=0,a;

    cin>>n;


    for(i=1;i<=n;i++)
     {
       cin>>num[i];
    }

    sort(num+1,num+n+1);

    ll g=num[1];

    for(i=2;i<=n;i++)
    {
        g=__gcd(g,num[i]);
    }

   cout<<g<<endl;

    return 0;

}


Measured memory_bytes: 1024
n,m=map(int,input().split())
s=input()[::-1]
i=0
ans=[]
while i<n:
  for j in range(min(n-i,m),0,-1):
    if s[i+j]=="0":
      ans.append(j)
      i+=j
      break
    if j==1:print(-1);exit()
print(*ans[::-1])

Measured memory_bytes: 6408
#include <stdio.h>
int main(){
  int j, n, tmp, cnt = 0;
  int A[100];
  int flag = 1;

  scanf("%d", &n);
  for(j = 0; j < n; j++)
    scanf("%d", &A[j]);

  while(flag == 1){
    flag = 0;
    for(j = n-1; j >= 1; j--){
      if(A[j] < A[j-1]){
        tmp = A[j];
        A[j] = A[j-1];
        A[j-1] = tmp;
        flag = 1;
        cnt++;
      }
    }
  }
  for(j = 0; j < n-1; j++)
    printf("%d ", A[j]);
  printf("%d\n", A[j]);
  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline void LB(vector<T>& v, T& a) { return *lower_bound(ALL(v),a); }
template <typename T> inline void LBP(vector<T>& v, T& a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline void UB(vector<T>& v, T& a) { return *upper_bound(ALL(v),a); }
template <typename T> inline void UBP(vector<T>& v, T& a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) os << v[i] << " \n"[i+1==v.size()]; return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> 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...)); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

void yes() {
  cout << "Yes" << endl;
  exit(0);
}
void no() {
  cout << "No" << endl;
  exit(0);
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int N;
  cin >> N;
  vector<int> a(N);
  cin >> a;
  if (N == 2) yes();
  SORT(a);
  int p = 0, q = 0;
  REP(i,N) {
    p += (a[i] == a[0]);
    q += (a[i] == a[N-1]);
  }
  if (a[N-1] - a[0] > 1) no();
  if (a[0] + 1 == a[N-1]) {
    if (a[0] == 1) {
      if (p == 1 && q == N-1) yes();
      else no();
    } else {
      if (q == 1) no();
      else if (p <= a[0] && a[0] <= p-1+(q/2)) yes();
      else no();
    }
  } else {
    if (a[0] == N-1) yes();
    else if (1 <= a[0] && a[0] <= (N/2)) yes();
    else no();
  }

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
int n,i,a[100005];
int read(){
	char ch=getchar();
	int xx=0;
	while(ch<'0'||ch>'9')
		ch=getchar();
	while(ch>='0'&&ch<='9'){
		xx=xx*10+ch-'0';
		ch=getchar();
	}
	return xx;
}
int main(){
	n=read();
	for(i=1;i<=n;i++)
		a[i]=read();
	sort(a+1,a+n+1);
	if(n%3!=0){
		if(a[1]!=0){
			printf("No\n");
			return 0;
		}
		for(i=2;i<=n;i++)
			if(a[i]!=a[i-1]){
				printf("No\n");
				return 0;
			}
		printf("Yes\n");
		return 0;
	}
	else{
		for(i=1;i<=n;i++)
			if(i!=1&&i!=n/3+1&&i!=n/3*2+1)
				if(a[i]!=a[i-1]){
					printf("No\n");
					return 0;
				}
		if((a[1]^a[n/3+1]^a[n/3*2+1])==0)
			printf("Yes\n");
		else
			printf("No\n");
		return 0;
	}
	return 0;
}




Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(Math.max(a*b,Math.max(a+b,a-b)));
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20)
#define int long long
#define double long double
const int INF = 1e18, MOD = 1e9 + 7;

string s;
int k;

signed main() {
    INCANT;
    cin>>s>>k;
    for (int i = 0; i < s.size(); i++) {
        if (i == s.size() - 1) {
            k %= 26;
            s[i] = (s[i] - 'a' + k) % 26 + 'a';
        } else {
            int t = ('z' - s[i] + 1) % 26;
            if (k >= t) {
                k -= t;
                s[i] = 'a';
            }
        }
    }
    cout<<s<<endl;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

int main(){
	int s, d, m;
	while(cin >> s >> d >> m){
		int num = 0;
		vector<int> w;
		vector<int> p;
		vector<P> idx;
		rep(i, s){
			int k;
			cin >> k;
			idx.push_back(MP(num, num+k-1));
			num += k;
			rep(j, k){
				int we, pr;
				cin >> we >> pr;
				w.push_back(we);
				p.push_back(pr);
			}
		}

		vector<int> ww;
		vector<int> pp;
		rep(i, d){
			int f;
			cin >> f;
			for(int j = idx[f].first; j <= idx[f].second; j++){
				ww.push_back(w[j]);
				pp.push_back(p[j]);
			}
		}

		int n = ww.size();
		vector<int> dp(m+1, 0);
		rep(i, n){
			for(int j = m; j >= pp[i]; j--){
				dp[j] = max(dp[j], dp[j-pp[i]] + ww[i]);
			}
		}
		int answ = 0;
		int ansp = 0;
		rep(i, m+1){
			if(answ < dp[i]){
				answ = dp[i];
				ansp = i;
			}
		}
		cout << answ << ' ' << ansp << endl;
	}

	return 0;
}

Measured memory_bytes: 1312
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string s;
  cin >> s;
  int ans=0;
  rep(i,s.size()-1){
    if(s.at(i)!=s.at(i+1)){
      ans++;
    }
  }
  cout << ans;
}
    

Measured memory_bytes: 3732
#include<bits/stdc++.h>
const int M=1e9+7;// M=1e9+7;//M=300000;//
const int N=5e5+5;
typedef long long int ll;
using namespace std;
 
ll cnt(0),n,m,x,y,i,j,temp,k,ans(0),sum(0),mn(M),mx(-9e9);

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	mx=1;
	while(n--)
	{
		cin>>x>>y;
		if(x==y)
		{
			cnt++;
		}else cnt=0;
		
		mx=max(cnt,mx);
	}
	if(mx>=3)
	{
		cout<<"Yes";
	}else cout<<"No";
}

Measured memory_bytes: 3648
N = int(input())
f = [[] for i in range(N)]
for i in range(N-1):
    a,b,c = map(int,input().split())
    f[a-1].append([b-1,c])
    f[b-1].append([a-1,c])
from collections import deque
d = deque()
s = [-1]*N
Q,K = map(int,input().split())
d.append(K-1)
s[K-1] = 0
while len(d) > 0:
    z = d.popleft()
    for i,j in f[z]:
        if s[i] == -1:
            s[i] = j+s[z]
            d.append(i)
for i in range(Q):
    x,y = map(int,input().split())
    print(s[x-1]+s[y-1])

Measured memory_bytes: 50484
class scc_graph:
    def __init__(self,N):
        self.N = N
        self.edges = []
    
    def add_edge(self,v,w):
        self.edges.append((v,w))

    def scc_ids(self):
        N = self.N
        edges = self.edges
        start = [0]*(N+1)
        elist = [0]*len(edges)
        for e in edges:
            start[e[0]+1] += 1
        for i in range(1,N+1):
            start[i] += start[i-1] 
        counter = start[:]
        for e in edges:
            elist[counter[e[0]]] = e[1]
            counter[e[0]] += 1        
        now_ord = group_num = 0
        visited = []
        low = [0]*N
        order = [-1]*N
        ids = [0]*N
        parent = [-1]*N
        stack = []
        for i in range(N):
            if order[i] == -1:
                stack.append(i)
                stack.append(i)
                while stack:
                    v = stack.pop()
                    if order[v] == -1:
                        low[v] = order[v] = now_ord
                        now_ord += 1
                        visited.append(v)
                        for i in range(start[v],start[v+1]):
                            to = elist[i]
                            if order[to] == -1:
                                stack.append(to)
                                stack.append(to)
                                parent[to] = v
                            else:
                                low[v] = min(low[v],order[to])
                    else:
                        if low[v] == order[v]:
                            while True:
                                u = visited.pop()
                                order[u] = N
                                ids[u] = group_num
                                if u == v:
                                    break
                            group_num += 1
                        if parent[v] != -1:
                            low[parent[v]] = min(low[parent[v]],low[v])
        for i,x in enumerate(ids):
            ids[i] = group_num-1-x

        return group_num,ids
    
    def scc(self):
        group_num,ids = self.scc_ids()
        groups = [[] for _ in range(group_num)]
        for i,x in enumerate(ids):
            groups[x].append(i)
        return groups
    
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
N,M = map(int,readline().split())
ab = list(map(int,read().split()))
sg = scc_graph(N)

it = iter(ab)
for a,b in zip(it,it):
    sg.add_edge(a,b)

scc = sg.scc()
print(len(scc))
for group in scc:
    print(str(len(group))+' '+' '.join(map(str,group)))


Measured memory_bytes: 212956
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int t[100050],x[100050],y[100050];
bool vis[100050],dis;
int main(){
	int n,len,i;
	scanf("%d",&n);
	len=n;
	i=0;
	t[0]=0;
	x[0]=0;
	y[0]=0;
	while(len--){
		i++;
		scanf("%d%d%d",&t[i],&x[i],&y[i]);
		if(((abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2!=(t[i]-t[i-1])%2)||((abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))>(t[i]-t[i-1]))){
			vis[i]=0;
		}
		else vis[i]=1;
	}
	for(int j=1;j<=i;j++){
		if(vis[j]==0){
			dis=0;
			break;
		}
		else dis=1;
	}
	if(dis==0) printf("No\n");
	else printf("Yes\n");
}

Measured memory_bytes: 1536
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
//#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
//#define EXIST(s, e) ((s).find(e)!=(s).end())
//#define SORT(c) sort(begin(c),end(c))
//#define pb emplace_back
//#define MP make_pair
//#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007

//ここから編集する
bool solve() {
    int N;
    cin >> N;
    if (N == 0) return false;
    vector<vector<int> > field(25, vector<int>(25, 0));
    vector<vector<int> > used(25, vector<int>(25, 0));
    int cx = 10, cy = 10;
    used[cx][cy] = 1;
    rep(i, 0, N) {
        int x, y;
        cin >> x >> y;
        field[x][y] = 1;
    }
    int M;
    cin >> M;
    char dir[4] = {'N', 'S', 'W', 'E'};
    int dx[4] = {0, 0, -1, 1};
    int dy[4] = {1, -1, 0, 0};
    rep(i, 0, M) {
        char d;
        cin >> d;
        int l;
        cin >> l;
        rep(j, 0, 4) {
            if (d == dir[j]) {
                rep(k, 0, l) {
                    cx += dx[j];
                    cy += dy[j];
                    used[cx][cy] = 1;
                }
                break;
            }
        }

    }

    rep(x, 0, 25) {
        rep(y, 0, 25) {
            if (field[x][y] == 1 && used[x][y] == 0) {
                cout << "No" << endl;
                return true;
            }
        }
    }
    cout << "Yes" << endl;
    return true;
}

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

    while (solve());

    return 0;
}



Measured memory_bytes: 3160
def resolve():
    import sys
    from collections import deque
    input = sys.stdin.readline
    input()
    A = [int(i) for i in input().split()]
    input()
    B = [int(i) for i in input().split()]

    A = deque(A)
    B = deque(B)
    while len(A) > 0 and len(B) > 0:
        a = A.popleft()
        b = B.popleft()
        if a == b:
            continue
        elif a < b:
            print(1)
            return
        else:
            print(0)
            return
    if len(B) > 0:
        print(1)
    else:
        print(0)


resolve()



Measured memory_bytes: 6112
import java.io.*;
class Main
{
	public static void main(String[] args)throws IOException
	{
	BufferedReader br=
	new BufferedReader(new InputStreamReader(System.in));

	String str1=br.readLine();
	String str2[]=str1.split(" ");
	int a =Integer.parseInt(str2[0]);	
	int b =Integer.parseInt(str2[1]);
	int c =a*b;
	int d =2*(a+b);
	System.out.println(c+" "+d);
	}
}

Measured memory_bytes: 24244
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int a = in.nextInt();
    int b = in.nextInt();
    int c = in.nextInt();

    if (a > b) {
      int t = a;
      a = b;
      b = t;
    }
    if (b > c) {
      int t = b;
      b = c;
      c = t;
    }
    if (a > b) {
      int t = a;
      a = b;
      b = t;
    }
    System.out.println(a +" " +  b + " " + c);
  }
}

Measured memory_bytes: 26080
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            String S = reader.readLine();
            int L = S.length();

            int a = 0;
            while (true) {
                if (L - a < 5) {
                    break;
                }

                String s = S.substring(a, a + 5);

                if (s.equals("dream")) {
                    a += 5;
                    if (L - a >= 2 && S.subSequence(a, a + 2).equals("er")) {
                        if (L - a < 3 || S.charAt(a + 2) != 'a') {
                            a += 2;
                        }
                    }
                } else if (s.equals("erase")) {
                    a += 5;
                    if (L - a >= 1 && S.charAt(a) == 'r') {
                        a += 1;
                    }
                } else {
                    break;
                }
            }

            if (a == L) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }

}


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

using namespace std;


int main() {
  int dp[1000000];
  int n;
  string s;
  cin >> n;
  cin >> s;
  dp[0] = 0;

  for (int i=1;i<n;i++) {
    if (s[i] == 'E') {
      dp[0]++;
    }
  }
  
  int m;
  m = dp[0];
  for (int i=1;i<n;i++) {
    char previous = s[i-1];
    char current = s[i];

    if (previous == 'W' && current == 'W') {
      dp[i] = dp[i-1] + 1;
    }
    if (previous == 'E' && current == 'E') {
      dp[i] = dp[i-1] - 1;
    }
    if (previous == 'W' && current == 'E'){
      dp[i] = dp[i-1];
    } 
    if (previous == 'E' && current == 'W'){
      dp[i] = dp[i-1];
    }

    m = min(dp[i], m);
  }

  cout << m << endl;
  return 0;
}


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

int i, count[1001],n;
string s;

int main(){
	cin >> n;
	for(i=0; i<n; i++){
		cin >> s;
		if(s == "AC"){
			count[0]++;
		}else if(s == "WA"){
			count[1]++;
		}else if(s == "TLE"){
			count[2]++;
		}else {
			count[3]++;
		}
	}
	printf("AC x %d\n", count[0]);
	printf("WA x %d\n", count[1]);
	printf("TLE x %d\n", count[2]);
	printf("RE x %d\n", count[3]);
}

Measured memory_bytes: 3724
use std::collections::HashSet;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn exe(n: usize, a: Vec<u64>) -> String {
    let uniq: HashSet<u64> = a.into_iter().collect();
    if n == uniq.len() {
        "YES".to_string()
    } else {
        "NO".to_string()
    }
}

fn main() {
    input! {
        n: usize,
        a: [u64; n],
    }
    let ans = exe(n, a);
    println!("{}", ans);
}


Measured memory_bytes: 12540
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int n = sc1.nextInt();
		int i = sc1.nextInt();
		int ans = 0;

		ans = n - i + 1;

		System.out.println(ans);

		sc1.close();

	}

}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
#define sz(x) (int)x.size()
#define ms(a,b) memset(a, b, sizeof(a))
#define int long long
#define sc(n) scanf("%d", &n)
#define scl(n) scanf("%lld", &n)
#define printcas(cas) printf("Case %lld: ", cas++)
#define nl printf("\n")
#define pr(n) printf("%d", n)
#define prnl(n) printf("%d", n)
#define sc2(n, m) scanf("%d %d", &n, &m)
#define scl2(n, m) scanf("%lld %lld", &n, &m)
#define pb push_back
#define all(a) (a.begin()),(a.end())
#define For(i, n) for (int i = 0; i < (n); ++i)
#define For1(i, n) for (int i = 1; i<=n; ++i)
#define Rev1(i, n) for (int i = n; i>=1; --i)
#define D(x) cout << #x << " = " << x << endl
#define input freopen("/Users/shahadat/Desktop/input.txt", "r", stdin)
#define output freopen("/Users/shahadat/Desktop/output.txt", "w", stdout)
#define valid(x,y) x>=0 && y>=0 && x<n && y<n
#define EL printf("\n")
#define ff  first
#define ss  second

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

const int INF = 1e18;
int const N = 1e6 + 10;
const int M = 510;
int const MOD = 1e9 + 7;


int a[110];
int32_t main(){
    
    int n, k;
    cin>>n>>k;
    for(int i = 1; i<=n; i++){
        cin>>a[i];
    }
    
    vector<int> dp(k + 5, 1LL);
    for(int i = 1; i<=n; i++){
        vector<int> temp(k + 5, 0LL);
        
        for(int j = 0; j<=a[i]; j++){
            temp[j] = dp[j];
        }
        
        int te = 0;
        for(int j = a[i] + 1; j<=k; j++){
            temp[j] = (dp[j] - dp[te] + MOD) % MOD;
            te++;
        }
        if(i == n){
            dp = temp;
            break;
        }

        for(int j = 1; j<=k; j++){
            temp[j] = temp[j] + temp[j-1];
            temp[j] %= MOD;
        }

        dp = temp;
    }
    cout<<dp[k]<<endl;

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
//using Graph = vector<vector<int>>;


const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
ll gcd(ll a,ll b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
ll lcm(ll a,ll b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}









int main() {
 double n,x ,t;
 cin >> n >> x >> t;
 cout << fixed << setprecision(0)<< ceil(n / x) * t << endl;
}


Measured memory_bytes: 3824
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
int n,k;
long long Mod,c[310][310],f[310][310],s[310][310];
int main()
{
	scanf("%d%d%lld",&n,&k,&Mod);
	for (int i=0;i<=n;i++)
	{
		c[i][0]=1;
		for (int j=1;j<=i;j++)
		{
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%Mod;
		}
	}
	for (int i=k;i>=0;i--)
	{
		f[i][0]=1;
		for (int j=1;j<=n;j++)
		{
			for (int h=0;h<j;h++)
			{
				f[i][j]=(f[i][j]+s[i+1][j-h-1]*f[i][h]%Mod*c[j-1][h]%Mod)%Mod;
			}
		}
		for (int j=0;j<=n;j++)
		{
			s[i][j]=(s[i+1][j]+f[i][j])%Mod;
		}
	}
	printf("%lld\n",f[0][n]);
    return 0;
}
//顺风不浪，逆风不怂。

Measured memory_bytes: 2432
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<string.h>
int *bubblesort(int *N,int len){
    int i,j;
    for(i=0;i<len;i++){
        for(j=len-1;j>i;j--){
            if(N[j]<N[j-1]){
                int temp=N[j];
                N[j]=N[j-1];
                N[j-1]=temp;
            }
        }
    }
    return N;
}
int main(void){
    int K,T;
    scanf("%d %d",&K,&T);
    int a[T];
    for(int i=0;i<T;i++){
        scanf("%d",&a[i]);
    }
    int now=-1;
    int sum=0;
    int hanbetu=0;
    int *N=bubblesort(a,T);
    int maxx=N[T-1];
    sum=maxx-(K-maxx)-1;
    if(sum<0){
        sum=0;
    }

    printf("%d\n",sum);


}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    char b;
    cin >> b;
    if (b == 'A') cout << 'T' << endl;
    else if (b == 'T') cout << 'A' << endl;
    else if (b == 'C') cout << 'G' << endl;
    else if (b == 'G') cout << 'C' << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextLine().length();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < l; i++) {
			sb.append("x");
		}
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 23764
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

void solve(){
	int k, n;
	int x;
	int prev, tmp, ans = 0;
	cin >> k >> n;
	cin >> x;
	prev = x;
	for(int i = 1; i < n; i++){
		cin >> tmp;
		ans = max(ans, tmp - prev);
		prev = tmp;
	}
	ans = max(ans, x + (k - prev));
	cout << k - ans << "\n";
}

int main(){
	#ifndef RAY
		//freopen("input.txt", "r", stdin);
	#endif
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		int t = 1;
		//cin >> t;
		while(t--){
			solve();
		}
	return 0;
}	


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

int main() {
    int K, N;
    cin >> K >> N;
    vector<int> A(N);

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

    int dMax = A.at(0) + K - A.at(N-1);

    for(int i = 0; i < N-1; i++){
            if (A.at(i+1) - A.at(i) > dMax) dMax = A.at(i+1) - A.at(i);

    }

    cout << K - dMax << endl;
}


Measured memory_bytes: 1152
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
	long long int a,b,n,x,y;
while(1){	a=0;
	b=0;
	scanf("%lld",&n);
	if(n==0) break;
	for(long long int i=0;i<n;i++){
		scanf("%lld %lld",&x,&y);
		if(x>y) {a+=(x+y);}
		if(x<y) {b+=(x+y);}
		if(x==y){
			a+=x;
			b+=y;
		}
	}
	printf("%lld %lld\n",a,b);}
	return 0;
}

Measured memory_bytes: 1028
//I AM THE CREED
/* //I AM THE CREED
/* package codechef; // don't place package name! */
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.StringTokenizer; 
import java.util.*;
import java.awt.Point;
public class Main{
    public static void main(String[] args) throws IOException 
    { 
  
        Scanner input = new Scanner(System.in);
        while(input.hasNext()){
            long x=input.nextLong();
            long k=input.nextLong();
            long d=input.nextLong();
            x=Math.abs(x);
            if(k<=x/d){
                System.out.println(x-k*d);
                continue;
            }
            long min=Long.MAX_VALUE;
            if((k-(x/d))%2==0){
                min=x%d;
            }
            else{
                min=d-(x%d);
            }
            System.out.println(min);
        }
        
    }
    


}

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

class Program
{
    static void Main(string[] args)
    {
        string[] inputBuf = Console.ReadLine().Split(' ');
        int N = int.Parse(inputBuf[0]);
        int K = int.Parse(inputBuf[1]);
        int Q = int.Parse(inputBuf[2]);
        int[] point = Enumerable.Repeat<int>(0, N).ToArray();

        for (int i = 0; i < Q; i++)
            point[int.Parse(Console.ReadLine()) - 1] += 1;

        foreach (var i in point)
        {
            if (K - (Q - i) <= 0)
                Console.WriteLine("No");
            else
                Console.WriteLine("Yes");
        }
    }
}

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

int main() {
  int H,W;
  cin >> H >> W;
  int c[26]={};
  for(int i=0;i<H*W;i++){
    char a;
    cin >> a;
    c[a-'a']+=1;
  }
  int d[26];
  int x=0,y=0;
  for(int i=0;i<26;i++){
    d[i]=c[i]%4;
    if(d[i]==1)x+=1;
    if(d[i]==2)y+=2;
    if(d[i]==3){
      x+=1;
      y+=2;
    }
  }
  if((H%2)*(W%2)>=x && (H%2)*(W-(W%2))+(W%2)*(H-(H%2))>=y)cout << "Yes";
  else cout << "No";
}

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

int main(void){
    int n, w;
    cin >> n >> w;
    int v[n], o[n];
    for(int i = 0; i < n; i++) cin >> v[i] >> o[i];

    int dp[n + 1][w + 1];
    fill(dp[0], dp[n + 1], -1);
    dp[0][0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= w; j++){
            if(dp[i][j] >= 0){
                int val = dp[i][j] ,wei = j;
                dp[i + 1][j] = max(dp[i + 1][j], val);
                val += v[i]; wei += o[i];
                if(wei <= w) dp[i + 1][wei] = max(dp[i + 1][wei], val);
            }
        }
    }

    int mx = -1;
    for(int j = 0; j <= w; j++) mx = max(dp[n][j], mx);

    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 7016
from collections import Counter
n = int(input())
v = list(map(int,input().split()))

e = Counter(v[::2])
o = Counter(v[1::2])

ev = sorted([(k,i) for k, i in e.items()],key = lambda z:z[1],reverse = True) + [(0,0)]
od = sorted([(k,i) for k, i in o.items()],key = lambda z:z[1],reverse = True) + [(0,0)]

if ev[0][0] != od[0][0]:
    print(n - ev[0][1] - od[0][1])
else:
    print(n - max(ev[0][1] + od[1][1], ev[1][1] + od[0][1]))


Measured memory_bytes: 21560
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

int V;
const int MAX_V=200;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u, int v){
    G[u].pb(v); G[v].pb(u);
}

bool dfs(int v){
    used[v]=true;
    for(int &to : G[v]){
        int w=match[to];
        if(w<0||!used[w]&&dfs(w)){
            match[v]=to;
            match[to]=v;
            return true;
        }
    }
    return false;
}

int bipartite_matching(){
    int res=0;
    memset(match, -1, sizeof(match));
    rep(v,0,V){
        if(match[v]<0){
            memset(used, 0, sizeof(used));
            if(dfs(v)){
                res++;
            }
        }
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>>N;
    V=2*N;
    int a[N], b[N], c[N], d[N];
    rep(i,0,N) cin>>a[i]>>b[i];
    rep(i,0,N) cin>>c[i]>>d[i];
    rep(i,0,N){
        rep(j,0,N){
            if(a[i]<c[j]&&b[i]<d[j]) add_edge(i,j+N);
        }
    }
    cout <<bipartite_matching()<<"\n";
}

Measured memory_bytes: 256
import sys
import math
import itertools

def main():
  a,b,c,k = map(int, input().split())
  r = 0

  if a > k:
    r = k
    k = 0
  else:
    r = a
    k = k - a

  if b > k:
    k = 0
  else:
    k = k - b

  r -= k
    

  print(r)
    

if __name__ == '__main__':
  main()

Measured memory_bytes: 9212
//============================================================================
// Name        : abc108.cpp
// Author      : sep
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cmath>
#include <ctime>
#include <functional>
#include <algorithm>
#include <vector>
#include <cctype>

using namespace std;

inline void main108A() {

	long int n;
	long int res;

	cin >> n;

	if (n % 2 == 1) {

		res = (n / 2) * (n / 2 + 1);
	} else {
		res = (n / 2) * (n / 2);
	}

	cout << res;

}

inline void main108B() {

	long long int x1, x2, y1, y2;
	long long int x3, x4, y3, y4;
	long long int dx, dy;
	double sides;

	cin >> x1 >> y1 >> x2 >> y2;

	dx = x2 - x1;
	dy = y2 - y1;

	x3 = x2 - dy;
	y3 = y2 + dx;

	x4 = x3 - dx;
	y4 = y3 - dy;

	cout << x3 << " " << y3 << " " << x4 << " " << y4;

}

int main() {

#ifdef TEST
	struct timespec startTime, endTime;
	while (1) {
		clock_gettime(CLOCK_REALTIME, &startTime);
#endif

		main108B();

#ifdef TEST
		cout << flush;
		cerr << flush;
		cerr << endl << "Elapsed Time:";
		clock_gettime(CLOCK_REALTIME, &endTime);
		if (endTime.tv_nsec < startTime.tv_nsec) {
			cerr << endTime.tv_sec - startTime.tv_sec - 1 << "."
					<< endTime.tv_nsec + 1000000000 - startTime.tv_nsec << "s"
					<< endl;
		} else {
			cerr << endTime.tv_sec - startTime.tv_sec << "."
					<< endTime.tv_nsec - startTime.tv_nsec << "s" << endl;
		}

		cerr << endl;
	}
#endif

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,m,i,a,b,c,d,min,w[1001];
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++){
		min=0;
		scanf("%d %d",&a,&b);	
		if(a>=b) min=b;
		else min=a;
		c=n-a+1; d=n-b+1;
		if(c<=min) min=c;
		if(d<=min) min=d;
		w[i]=min%3;
	}
	for(i=0;i<m;i++){
		if(w[i]==0) printf("3\n");
		else printf("%d\n",w[i]);
	}	
	return 0;
}

Measured memory_bytes: 2760
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#define int long long
using namespace std;
const int maxn = 1e2+10;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int to[maxn<<1],net[maxn<<1],h[maxn],e=1;
inline void add(int x,int y){
	to[++e]=y;net[e]=h[x];h[x]=e;
}

int k,m,n;
struct node{
	int x,y;
}a[maxn],b[maxn];
int dep[maxn],fa[maxn];
inline void dfs(int x){
	dep[x]=dep[fa[x]]+1;
	for(register int i=h[x];i;i=net[i]){
		int y=to[i];
		if(y==fa[x])continue;
		fa[y]=x;
		dfs(y);
	}
	return;
}

int vis[maxn];
int LCA(int x,int y){
	vis[x]=vis[y]=1;
	while(dep[x]!=dep[y]){
		if(dep[x]<dep[y])swap(x,y);
		x=fa[x];vis[x]=1;
	}
	if(x==y)return x;
	while(x!=y){
		x=fa[x];y=fa[y];
		vis[x]=vis[y]=1;
	}
	return x;
}

int dp[2][1<<21];
signed main(){
	n=read();
	for(register int i=1;i<n;i++){
		int x=read(),y=read();
		a[i].x=x;a[i].y=y;
		add(x,y);add(y,x);
	}
	m=read();
	for(register int i=1;i<=m;i++){
		b[i].x=read();b[i].y=read();
	}
	dfs(1);
	dp[0][0]=1;
	for(register int i=1;i<n;i++){
		int w=0;
		for(register int j=1;j<=m;j++){
			memset(vis,0,sizeof(vis));
			int z=LCA(b[j].x,b[j].y);
			if(vis[a[i].x]==1 && vis[a[i].y]==1)w|=1<<(j-1);
		}
		memset(dp[i&1],0,sizeof(dp[i&1]));
		for(register int j=0;j<(1<<m);j++){
			dp[i&1][j|w]+=dp[(i-1)&1][j];
			dp[i&1][j]+=dp[(i-1)&1][j];
		}
	}
	printf("%lld\n",dp[(n-1)&1][(1<<m)-1]);
	return 0;
}

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


using namespace std;


const int MAXN = 200 * 1000 + 132;




int n, x, a[2][5] = {-1, 0, 1, -3, -2, 1, 0, -1, 3, 2};
bool mark[MAXN];

int main() {
	cin >> n >> x;
	if (n == 1)
		return cout << "Yes\n" << x, 0;
	if ((x == 1) || (x == ((n << 1) - 1)))
		return cout << "No", 0;
	cout << "Yes\n";
	if (x == n) {
		for (int i = 1; i <= ((n << 1) - 1); i++)
			cout << i << ' ';
		return 0;	
	}
	if (x < n) {
		for (auto i : a[1])
			mark[x + i] = true;
		int p = 1;
		for (int i = 1; i <= ((n << 1) - 1); )
			if (abs(p - n) > 2) {
				if (!mark[i])
					cout << i << ' ', p++;
				i++;
			}
			else
				cout << x + a[1][p - n + 2] << ' ', p++;
		return 0;
	}
	for (auto i : a[0])
		mark[x + i] = true;
	int p = 1;
	for (int i = 1; i <= ((n << 1) - 1); )
		if (abs(p - n) > 2) {
			if (!mark[i])
				cout << i << ' ', p++;
			i++;
		}
		else
			cout << x + a[0][p - n + 2] << ' ', p++;
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

 
void solve(){
    int n, m, c;
    cin >> n >> m >> c;
    
    vi b(m);
    for(int i = 0; i < m; i++) cin >> b[i];
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int x;
        int sum = c;
        for(int j = 0; j < m; j++){
            cin >> x;
            sum += x * b[j];
        }
        if(sum > 0) cnt++;
    }
    cout << cnt;
}

 
int main() {
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <string>

using namespace std;

string s;
int y, m, d;

int main(void)
{
	while(1){
		cin >> s;
		if(s == "#") break;
		cin >> y >> m >> d;
		
		if(make_pair(y, make_pair(m, d)) > make_pair(31, make_pair(4, 30))){
			s = "?", y -= 30;
		}
		cout << s << " " << y << " " << m << " " << d << endl;
	}
	return 0;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int s;
  Int flg=0;
  while(cin>>s,s){
    if(flg) cout<<endl;
    flg=1;
    Int n=4;
    Int ans=1e8;
    vector<Int> v(n),a(n,0);
    for(Int i=0;i<4;i++) cin>>v[i];
    vector<Int> c({10,50,100,500});
    for(Int i=0;i<=v[0];i++){
      for(Int j=0;j<=v[1];j++){
	for(Int k=0;k<=v[2];k++){
	  for(Int l=0;l<=v[3];l++){
	    Int tmp=c[0]*i+c[1]*j+c[2]*k+c[3]*l-s;
	    if(tmp<0) continue;
	    Int res=v[0]+v[1]+v[2]+v[3];
	    res-=i+j+k+l;
	    for(Int x=3;x>=0;x--){
	      res+=tmp/c[x];
	      tmp%=c[x];
	    }
	    //cout<<i<<" "<<j<<" "<<k<<" "<<l<<":"<<res<<endl;
	    if(res<ans){
	      ans=res;
	      a[0]=i;
	      a[1]=j;
	      a[2]=k;
	      a[3]=l;
	    }
	  }
	}
      }
    }
    for(Int i=0;i<4;i++)
      if(a[i]) cout<<c[i]<<" "<<a[i]<<endl;      
  }
  return 0;
}



Measured memory_bytes: 2980
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> query;
typedef vector<vector<ll>> matrix;

vector<int> children[100005];
int n;

int solve(int curr) {
  vector<int> ret;
  for(int out: children[curr]) {
    ret.push_back(solve(out));
  }
  sort(ret.begin(), ret.end());
  reverse(ret.begin(), ret.end());
  int ans = ret.size();
  int idx = 1;
  for(int out: ret) {
    ans = max(ans, idx+++out);
  }
  return ans;
}

void solve() {
  cin >> n;
  for(int i = 2; i <= n; i++) {
    int par;
    cin >> par;
    children[par].push_back(i);
  }
  cout << solve(1) << "\n";
}

void casesolve() {
  int t;
  cin >> t; cin.ignore();
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 15104