akhauriyash/Code-Regression huggingface dataset:
#include <iostream> 
#include <vector> 
#include <algorithm> 
#include <bits/stdc++.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <functional> 
#include<math.h> 
#include<cstring>
using namespace std;
int main(void){
    // Your code here!
   int N;
   cin >> N;
   vector<vector<int>> lack(3, vector<int>(100010));
   for(int i = 1;i <= N; i++){
       cin >> lack.at(0).at(i);
       cin >> lack.at(1).at(i);
       cin >> lack.at(2).at(i);
   }
   
   
   vector<vector<int>> dp(3, vector<int>(100010));
   dp.at(0).at(0) = 0;
   dp.at(1).at(0) = 0;
   dp.at(2).at(0) = 0;
   
   for(int i = 1; i <= N; i++){
       dp.at(0).at(i) = max(dp.at(1).at(i-1) + lack.at(0).at(i) , dp.at(2).at(i-1) + lack.at(0).at(i));
       dp.at(1).at(i) = max(dp.at(0).at(i-1) + lack.at(1).at(i) , dp.at(2).at(i-1) + lack.at(1).at(i));
       dp.at(2).at(i) = max(dp.at(0).at(i-1) + lack.at(2).at(i) , dp.at(1).at(i-1) + lack.at(2).at(i));
   }
   int ans = dp.at(0).at(N);
   ans = max(ans , dp.at(1).at(N));
   ans = max(ans , dp.at(2).at(N));
   cout << ans<< endl;
}

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

starts = [0]*N
for _ in range(N):
    starts[_] = list(map(int, input().split()))

ends = [0]*M
for _ in range(M):
    ends[_] = list(map(int, input().split()))

for _ in range(N):
    cand = [abs(starts[_][0] - e[0]) + abs(starts[_][1] - e[1]) for e in ends]
    print(cand.index(min(cand))+1)


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

int main(){
    string S;
    cin >> S;
    for(int i=1; i<4; i++){
        if(S.at(i)==S.at(i-1)){
            cout << "Bad" << endl;
            break;
        }else if(i==3){
            cout << "Good" << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    long double a,b,c;
    cin >> a >> b >> c;
    long double sa,sb,sc;
    sa=pow(a,0.5);
    sb=pow(b,0.5);
    sc=pow(c,0.5);
    if(sa+sb+0.00000000000001<sc)cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const string YES = "Yes";
const string NO = "No";

void solve(long long H, long long N, std::vector<long long> A){
    long long sum = 0;
    REP(i, N) sum += A[i];
    if (sum >= H) cout << YES << '\n';
    else cout << NO << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(H, N, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>

const int MaxN = 2e5;
typedef long long LL;
using namespace std;

LL a[MaxN + 5];
int nxt[MaxN + 5];
int n;
int main() 
{
	while(~scanf("%d", &n)) {
		for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
		int last = n + 1;
		for (int i = n; i >= 1; i--) {
			nxt[i] = last; if(a[i] > 0) last = i;
		}
		LL res = 0;
		for (int i = 1; i <= n; i++) {
			int now = i; LL tmp1 = a[i], tmp2 = a[i];
			for (;;) {
				if(now > n) break;
				if((tmp1 ^ a[nxt[now]]) != tmp2 + a[nxt[now]]) {
					now = nxt[now] - 1;
					break;
				}
				now = nxt[now];
				tmp1 ^= a[now]; tmp2 += a[now];
			}
			if(now == n + 1) res += (now - i);
			else res += (now - i + 1);
		}
		printf("%lld\n", res);
	}
	return 0;
}


Measured memory_bytes: 2560
/*
Rathin Bhargava
IIIT Bangalore

*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 

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

  vector<pair<int,int> > v;
  for(int i=0;i<m;i++)
  {
    int a,b;
    cin >> a >> b;
    a--; b--;
    v.pu(mp(a,b));
  }

  vector<int> counter(n,1),vis(n),check(n);
  vis[0] = 1;
  check[0] = 1;

  for(int i=0;i<v.size();i++)
  {
    int a = v[i].fi, b = v[i].se;
    if(check[a]) check[b] = 1;
    if(vis[a]) vis[b] = 1;
    counter[a]--;
    if(!counter[a]) check[a] = 0;
    counter[b]++;

  }

  for(int i=0;i<v.size();i++)
  {
    int a = v[i].fi, b = v[i].se;
  }

  int cnt = 0;
  for(int i=0;i<n;i++) 
  {
    if(check[i]) cnt++;
  }

  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 2164
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		int n=s.nextInt();
		int m=s.nextInt();
		
		ArrayList<Integer>[] arr=new ArrayList[n+1];
		
		for(int i=0;i<n+1;i++)
		{
			ArrayList<Integer> list=new ArrayList<>();
			arr[i]=list;
		}
		
		for(int i=0;i<m;i++)
		{
			int a=s.nextInt();
			int b=s.nextInt();
			
			arr[a].add(b);
			arr[b].add(a);
		}
		
		int[] visited=new int[n+1];
		int[] ans=new int[n+1];
		
		bfs(arr,visited,ans);
		
		int p=0;
		
		for(int i=2;i<n+1;i++)
		{
			if(ans[i]==0)
			{
				p=1;
				break;
			}
		}
		
		if(p==0)
		{
			System.out.println("Yes");
			
			for(int i=2;i<n+1;i++)
			{
				System.out.println(ans[i]);
			}
		}
		else
		{
			System.out.println("No");
		}
		
	}
	
	public static void bfs(ArrayList<Integer>[] arr,int[] visited,int[] ans)
	{
		Queue<pair> q=new LinkedList<pair>();
		
		pair p=new pair(1,-1);
		q.add(p);
		
		visited[1]=1;
		
		while(!q.isEmpty())
		{
			pair curr=q.poll();
			
			ans[curr.node]=curr.pre;
			
			for(int i=0;i<arr[curr.node].size();i++)
			{
				int now=arr[curr.node].get(i);
				
				if(visited[now]==0)
				{
					pair pp=new pair(now,curr.node);
					q.add(pp);
					
					visited[now]=1;
				}
			}
		}
	}
	
}

class pair
{
	int node;
	int pre;
	
	public pair(int node,int pre)
	{
		this.node=node;
		this.pre=pre;
	}
}

Measured memory_bytes: 78112
from queue import Queue


def main():
    h, w, k = map(int, input().split())
    sx, sy, gx, gy = map(lambda z: int(z) - 1, input().split())
    c = [list(input().replace('\n', '')) for _ in range(h)]
    c[sx][sy] = 0
    q = Queue()
    q.put((sx, sy))
    while not q.empty():
        x, y = q.get()
        d = c[x][y]
        # 南へ移動
        for i in range(1, k + 1):
            if x + i >= h:
                break
            if c[x + i][y] == '@':
                break
            elif isinstance(c[x + i][y], int) and c[x + i][y] < d + 1:
                break
            elif isinstance(c[x + i][y], int) and c[x + i][y] == d + 1:
                continue
            else:
                c[x + i][y] = d + 1
                q.put((x + i, y))
        # 北へ移動
        for i in range(1, k + 1):
            if x - i < 0:
                break
            if c[x - i][y] == '@':
                break
            elif isinstance(c[x - i][y], int) and c[x - i][y] < d + 1:
                break
            elif isinstance(c[x - i][y], int) and c[x - i][y] == d + 1:
                continue
            else:
                c[x - i][y] = d + 1
                q.put((x - i, y))
        # 東へ移動
        for i in range(1, k + 1):
            if y + i >= w:
                break
            if c[x][y + i] == '@':
                break
            elif isinstance(c[x][y + i], int) and c[x][y + i] < d + 1:
                break
            elif isinstance(c[x][y + i], int) and c[x][y + i] == d + 1:
                continue
            else:
                c[x][y + i] = d + 1
                q.put((x, y + i))
        # 西へ移動
        for i in range(1, k + 1):
            if y - i < 0:
                break
            if c[x][y - i] == '@':
                break
            elif isinstance(c[x][y - i], int) and c[x][y - i] < d + 1:
                break
            elif isinstance(c[x][y - i], int) and c[x][y - i] < d + 1:
                continue
            else:
                c[x][y - i] = d + 1
                q.put((x, y - i))
    print(-1 if c[gx][gy] == '.' else c[gx][gy])


if __name__ == '__main__':
    main()


Measured memory_bytes: 199212
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
    Node *cur = nil->next;
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void init() {
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

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

void deleteNode(Node *t) {
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

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

    printList();

    return 0;
}



Measured memory_bytes: 33816
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

int main(){
  int a, b;
  cin >> a >> b;

  if (a >= 13)
    cout << b << endl;
  else if(a >= 6)
    cout << b/2 << endl;
  else
    cout << 0 << endl;

  return 0;
}

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

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)

typedef pair<int, int> P;

const int MOD = (int) 1e9 + 7;

template<class T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}

template<class T>
bool chmin(T &a, const T &b) {
	if (b < a) {
		a = b;
		return 1;
	}
	return 0;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	int a[n];
	REP(i, n) cin >> a[i];
	
	int sum = 0;
	int cnt = 1;
	REP(i, n) {
		if (a[i] == a[i + 1]) {
			cnt += 1;
		} else {
			sum += cnt / 2;
			cnt = 1;
		}
		if (i == n - 2) {
			sum += cnt / 2;
			break;
		}
	}
	
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n;
  cin >> n;
  ll cnt = 0;
  bool ans = false;
  rep(i, n) {
    ll d1, d2;
    cin >> d1 >> d2;
    if (d1 == d2) cnt++;
    else cnt = 0;
    
    if (cnt == 3) {
      ans = true;
      break;
    }
  }

  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;


  return 0;
}


Measured memory_bytes: 3620
import sys
N = int(input())
D1 = [0] * N
D2 = [0] * N
for i in range(N):
    D1[i], D2[i],= map(int, input().split())
s=0
for i in range(N):
    if D1[i]==D2[i]:
        s=s+1
    else:
        s=0
    if s>=3:
        print('Yes')
        sys.exit()
print('No')

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

using namespace std;
using ll = long long;


int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> x(n), y(n);
    for(int i = 0; i < n; i++)cin >> x[i] >> y[i];
    int ans = 0;
    for(int I = 0; I < n; I++) {
        int X = x[I], Y = y[I];
        map<pair<int,int>,int> mp;
        for(int i = 0; i < n; i++) {
            if(I == i)continue;
            int gc = __gcd(abs(X - x[i]), abs(Y - y[i]));
            mp[{(X - x[i]) / gc, (Y - y[i]) / gc}]++;
        }
        int nax = 0;
        for(auto i : mp) {
            nax = max(nax, i.second);
        }
        nax++;
        ans = max(ans, nax);
    }
    cout << (ans >= k) << endl;
}


Measured memory_bytes: 3344
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

template<typename Monoid,typename F>
class SegmentTree{
private:
    int sz;
    vector<Monoid> seg;
    const F op;//演算
    const Monoid e;//単位元
public:
    SegmentTree(int n,const F op,const Monoid &e):op(op),e(e){
        sz = 1;
        while(sz<=n) sz <<= 1;
        seg.assign(2*sz,e);
    }
    void set(int k, const Monoid &x){
        seg[k+sz] = x;
    }
    void build(){
        for(int i=sz-1;i>0;i--){
            seg[i] = op(seg[2*i],seg[2*i+1]);
        }
    }
    void update(int k,const Monoid &x){
        k += sz;
        seg[k] = x;
        while(k>>=1){
            seg[k] = op(seg[2*k],seg[2*k+1]);
        }
    }
    Monoid query(int l,int r){
        Monoid L = e,R = e;
        for(l+=sz,r+=sz;l<r;l>>=1,r>>=1){
            if(l&1) L = op(L,seg[l++]);
            if(r&1) R = op(seg[--r],R);
        }
        return op(L,R);
    }
    Monoid operator[](const int &k)const{
        return seg[k+sz];
    }
};

template <class T>
class Compress{
    map<T,int> idx;
    map<int,T> value;
    vector<T> cmp;
public:
    int N;
    Compress(vector<T> v){
        for(auto& x:v) cmp.push_back(x);
        sort(cmp.begin(),cmp.end());
        cmp.erase(unique(cmp.begin(),cmp.end()),cmp.end());
        N = cmp.size();
        for(int i=0;i<N;i++) idx[cmp[i]] = i;
    }
    int id(T val){return idx[val];}
    T val(int id){return cmp[id];}
};

struct I{
    int l,r;
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<int> X(N),L(N);
    vec<int> v;
    vec<I> interval;
    for(int i=0;i<N;i++){
        cin >> X[i] >> L[i];
        int l = X[i]-L[i],r = X[i]+L[i];
        v.push_back(l);
        v.push_back(r);
        interval.push_back({l,r});
    }
    int inf = 2e9;
    int ma = 0;
    sort(interval.begin(),interval.end(),[](I& a,I& b){
        return (a.r!=b.r? a.r<b.r:a.l<b.l);
    });

    int ans = 0;
    int now = -inf;
    for(int i=0;i<N;i++){
        if(now<=interval[i].l){
            ans++;
            now = interval[i].r;
        }
    }
    cout << ans << endl;
/*    auto op = [](int a,int b){return max(a,b);};
    SegmentTree<int,decltype(op)> seg(n,op,0);

    for(int i=0;i<N;i++){
        int res = seg.query(0,interval[i].l+1);
        seg.update(interval[i].r,res+1);
    }
    cout << seg.query(0,n) << endl;*/
}

Measured memory_bytes: 2924
n = int(input())
w = list(map(int, input().split()))
s1 = 0
s2 = 0
count = ''
ncount = 0
for i in range(1, n):
  for j in range(1, i+1):
    s1 += w[j-1]
  for k in range(i+1, n+1):
    s2 += w[k-1]
  count = s1 - s2
  s1 = 0
  s2 = 0
  if count < 0:
    count = count * -1
  if ncount > count:
    ncount = count
  elif i == 1:
    ncount = count
print(ncount)

Measured memory_bytes: 3064
//AtCoder ABC094 B - Toll Gates
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N,M,X;cin>>N>>M>>X;
    unordered_map<ll,ll> amt;
    for(ll i=1;i<=M;++i){
        ll a;
        cin>>a;
        amt[a]++;
    }    
    //0に行く場合
    ll pt=X;
    ll ans0=0;
    while(pt>=0){
        --pt;
        auto itr = amt.find(pt);
        if(itr!=amt.end()) ++ans0;
    }
    //Nに行く場合
    pt = X;
    ll ans1=0;
    while(pt<=N){
        ++pt;
        auto itr = amt.find(pt);
        if(itr!=amt.end()) ++ans1;
    }
    //cout<<ans0<<","<<ans1<<endl;
    cout<<min(ans0,ans1)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

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

void solve(istream& cin, ostream& cout) {
  long double a, b, h, m;
  cin >> a >> b >> h >> m;
  long double sx = a * cos(m * pi / 30);
  long double sy = a * sin(m * pi / 30);
  long double lx = b * cos((h + m / 60) * pi / 6);
  long double ly = b * sin((h + m / 60) * pi / 6);
  long double ans = sqrt((lx - sx) * (lx - sx) + (ly - sy) * (ly - sy));
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 4184
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l,A[10];
string s,s1,s2,s3;
int main()
{
	cin>>s;
  s3="keyence";
  for(long long i=0;i<7;i++)
    s1+=s[i];
  if(s1=="keyence") { cout<<"YES"; return 0; }
  for(long long i=s.size()-7;i<s.size();i++)
    s2+=s[i];
  if(s2=="keyence") { cout<<"YES"; return 0; }
  for(long long i=0;i<s.size();i++)
  {
    if(s[i]==s3[l]) { k=1; l++; }
    else if(s[i]!=s3[l] && k!=1) { cout<<"NO"; return 0; }
    else if(s[i]!=s3[l] && k==1) break;
  }
  f=6; k=0;
  for(long long i=s.size()-1;i>=0;i--)
  {
    if(s[i]==s3[f]) { k=1; f--; }
    else if(s[i]!=s3[f] && k!=1) { cout<<"NO"; return 0; }
    else if(s[i]!=s3[f] && k==1) break;
  } 
  //cout<<l<<" "<<f<<" "<<s3<<endl;
  if(l+6-f>=7) cout<<"YES";
    else cout<<"NO";
  
}

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

int main(){
  int A, B;

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

  int c;
  c = B + A;

  bool ans = false;

  if (c % 2 == 0) ans = true;

  if (ans) printf("%d\n", c / 2);
  else printf("IMPOSSIBLE\n");

  return 0;
}

Measured memory_bytes: 128
import sys

input = sys.stdin.readline

N, X, Y = map(int, input().split())
X -= 1
Y -= 1

ans = [0 for _ in range(N - 1)]

for i in range(N - 1):
    for j in range(i + 1, N):
        d1 = abs(j - i)
        d2 = abs(X - i) + 1 + abs(j - Y)
        ans[min(d1, d2) - 1] += 1

[print(ans[i]) for i in range(N - 1)]


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

int N, M, A[1 << 18], B[1 << 18];
int cnt[1 << 18];

int main() {
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> A[i] >> B[i];
		if (A[i] > B[i]) swap(A[i], B[i]);
		cnt[A[i]]++; cnt[B[i]]--;
	}
	for (int i = 1; i <= N; i++) cnt[i] += cnt[i - 1];
	for (int i = 1; i <= N; i++) {
		if (cnt[i] % 2 == 1) { cout << "NO" << endl; return 0; }
	}
	cout << "YES" << endl;
	return 0;
}

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

using namespace std;
int n;
char ans[1005][1005];
char a3[5][5]={"abb","a.c","ddc"};
char a5[6][6]={"aabbc","bxx.c","b..ya","a..ya","accbb"};
char a4[6][6]={"abcc","abdd","ccab","ddab"};
char a7[8][8]={
	"aabbcc.",
	"dd.dd.c",
	"..d..dc",
	"..d..db",
	"dd.dd.b",
	"..d..da",
	"..d..da"};
void dfs(int p){
	if (n-p>5){
		for (int i=p;i<p+3;i++)
			for (int j=p;j<p+3;j++){
				ans[i][j]=a3[i-p][j-p];
			}
		dfs(p+3);
	}else{
		if (n-p==4){
			for (int i=p;i<p+4;i++)
				for (int j=p;j<p+4;j++){
					ans[i][j]=a4[i-p][j-p];
				}
		}
		return;
	}
}
int main(){
	scanf("%d",&n);
	if (n<=2){
		cout << -1 ;
		return 0;
	}
	for (int i=0;i<n;i++)
		for (int j=0;j<n;j++)
			ans[i][j]='.';
	int pos =0;
	if (n==7||n==11){
		pos+=7;
		for (int i=0;i<7;i++){
			for (int j=0;j<7;j++)
				ans[i][j]=a7[i][j];
		}
	}
	if (n==3||n==6||n==9){
		while (pos<n){
			for (int i=0;i<3;i++){
				for (int j=0;j<3;j++){
					ans[i+pos][j+pos]=a3[i][j];
				}
			}
			pos+=3;
		}
		for (int i=0;i<n;i++){
			for (int j=0;j<n;j++)
				cout << ans[i][j] ;
			cout << '\n';
		}
		return 0;
	}
	int p=(n-pos)/4-(n-pos)%4;
	int q=(n-pos)%4;
	while (p--){
		for (int i=pos;i<pos+4;i++)
			for (int j=pos;j<pos+4;j++){
				ans[i][j]=a4[i-pos][j-pos];
			}		
		pos+=4;
	}
	while (q--){
		for (int i=pos;i<pos+5;i++)
			for (int j=pos;j<pos+5;j++){
				ans[i][j]=a5[i-pos][j-pos];
			}		
		pos+=5;
	}
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++)
			cout << ans[i][j] ;
		cout << '\n';
	}
}

Measured memory_bytes: 2176
#include"bits/stdc++.h"

#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define SORT(v) (sort(v.begin(),v.end()))
using ll = long long;
using namespace std;

void solve();

int main() {

	solve();
	return 0;

}

void solve() {

	ll n, k,ans=0;
	cin >> n >> k;
	vector<ll> v(n);
	REP(i, n) {
		cin >> v[i];
	}
	SORT(v);
	FOR(i, n - k , n) {
		ans += v[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  
  int exp = -1;
  int sum = 0;
  rep(i, 0, n) {
    int p;
    cin >> p;
    sum += p;
    exp = max(p, exp);
  }
  sum -= exp/2;
  cout << sum << "\n";

}


Measured memory_bytes: 256
from collections import defaultdict
n = int(input())
As =list(map(int,input().split(" ")))
q = int(input())
s = sum(As)
di = defaultdict(lambda :0)
for a in As:
    if a not in di:
        di[a] = 1
    else:
        di[a] += 1
anss = []
for _ in range(q):
    b,c =list(map(int,input().split(" ")))
    
    diff1 = di[b] * b
    temp = di[b]
    di[b] = 0
    diff2 = temp * c
    di[c] += temp
    s -= diff1
    s += diff2
    anss.append(s)
print("\n".join(list(map(str,anss))))


Measured memory_bytes: 34128
drc = [(0, 1), (1, 0)]


def dfs(r, c):
    if (r, c) in memo:
        return memo[r, c]
    ret = ''
    for dr, dc in drc:
        nr, nc = r + dr, c + dc
        if nr < H and nc < W and board[nr][nc].isdigit():
            cand = dfs(nr, nc)
            if len(cand) > len(ret) or (len(cand) == len(ret) and cand > ret):
                ret = cand
    memo[r, c] = board[r][c] + ''.join(ret)
    return board[r][c] + ret


while True:
    W, H = map(int, input().split())
    if not (W | H):
        break
    board = [input() for _ in range(H)]
    memo = dict()
    ans = ''
    for r in range(H):
        for c in range(W):
            if board[r][c].isdigit() and board[r][c] != '0':
                cand = dfs(r, c)
                if len(cand) > len(ans) or (len(cand) == len(ans) and cand > ans):
                    ans = cand
    print(ans)

Measured memory_bytes: 7940
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

ll dp[202020];
vector<vector<ll>> place(202020);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> c(n);
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
        place[c[i]].push_back(i);
    }
    dp[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        (dp[i] += dp[i - 1]) %= MOD;
        ll color = c[i - 1];
        ll itr = lower_bound(ALL(place[color]), i - 1) - place[color].begin();
        if (itr > 0)
        {
            ll j = place[color][itr - 1];
            if ((i - 1) - j > 1)
            {
                (dp[i] += dp[j + 1]) %= MOD;
            }
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 13568
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int ans = 0;
  char s[100005];
  scanf("%s", s);
  int n = strlen(s);
  for (int i = 0; i < n; i++)
  {
    if (s[i] == '1')
      ans++;
  }
  printf("%d\n", MIN(ans, n - ans) * 2);
  return 0;
}


Measured memory_bytes: 256
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [| for i in 1..n -> stream.ReadLine() |> f |]
  member this.ScanMatrix n f  = [ for i in 1..n do yield stream.ReadLine().Split() |> Array.map f ]
  member this.ScanCharMatrix n = [ for i in 1..n -> stream.ReadLine().ToCharArray() ]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let N,M_ = util.Scan2 int
let M = int64 M_
let Xs = util.ScanMatrix N int64 |> List.sortBy (Array.item 0)

let rec rfn cnt price (xs: int64 [] list) =
  match xs with
  | [] -> failwith "somethin wrong"
  | x::xs ->
      let p, n = x.[0], x.[1]
      if n + cnt < M
        then rfn (cnt+n) (price+n*p) xs
        else price + (M-cnt) * p

rfn 0L 0L Xs
|> printfn "%d"

util.Close()


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

void Main()
{
    int n;
    cin >> n;
    unordered_set<int> s;
    for (size_t i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if(s.count(a)) {
            cout << "NO" << endl;
            return;
        }
        s.insert(a);
    }
    cout << "YES" << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 11376
import java.util.Scanner;

class Main{



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		String ss = sc.next();
		long k = sc.nextLong();
		if(ss.charAt(0) != '1'){
			System.out.println(ss.charAt(0));
			return;
		}else{
			for(int i = 0;i < k;i++){
				if(ss.charAt(i) != '1'){
					System.out.println(ss.charAt(i));
					return;
				}
			}
			System.out.println(1);
			
			
		}
		
	
	}


}

class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



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

int main() {
  long long int N, M, K;
  cin >> N >> M >> K;
  vector<long long int> A(N), B(M);
  for (long long int i = 0; i < N; i++) cin >> A.at(i);
  for (long long int i = 0; i < M; i++) cin >> B.at(i);
  
  vector<long long int> S(N + 1), T(M + 1);
  S.at(0) = 0;
  T.at(0) = 0;
  for (long long int i = 0; i < N; i++) S.at(i + 1) = S.at(i) + A.at(i);
  for (long long int i = 0; i < M; i++) T.at(i + 1) = T.at(i) + B.at(i);
  
  long long int ans = 0;
  for (long long int X = 0; X <= N; X++) {
    long long int t = K - S.at(X);
    long long int left = 0, right = M + 1;
    while (right - left > 1) {
      long long int mid = (left + right) / 2;
      if (T.at(mid) <= t) left = mid;
      else right = mid;
    }
    if (t >= 0) ans = max(ans, X + left);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 9592
program ABC166_C
  integer,allocatable::H(:),A(:),B(:),c(:)
  read(*,*)N,M
  allocate(H(N),A(M),B(M),c(N))
  c=1
  read(*,*)H
  do i=1,M
     read(*,*)A(i),B(i)
     if(H(A(i))>=H(B(i))) c(B(i))=0
     if(H(A(i))<=H(B(i))) c(A(i))=0
  end do
  write(*,*)sum(c)
end program ABC166_C

Measured memory_bytes: 4444
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main(void){
    int n; bool okay=true;
    cin >> n;
    int T[n+1], x[n+1], y[n+1];
    T[0]=x[0]=y[0]=0;
    for(int i = 1; i < n+1; i++){
        cin >> T[i] >> x[i] >> y[i];
        if(i){
            int t = T[i] - T[i-1];
            int r = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
            if(t<r) okay=false;
            if((t-r)%2) okay=false;
        }
    }

    if(okay) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

const ll MOD = 1e9+7;

ll N;

ll cnt(ll K){

  ll min_val = K * (K-1) / 2;
  
  ll max_val = N * (N+1) / 2 - (N-K) * (N-K+1)/2;

  return (max_val - min_val + 1) % MOD;

}

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

  ll K;
  cin >> N >> K;
  
  ll ans = 0;
  for(ll i = K; i <= N+1; i++){
    ans = (ans + cnt(i)) % MOD;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int main(void)
{
	int a, b, k;
	int i;
	int min;
	int count = 0;
	
	scanf("%d%d%d", &a, &b, &k);
	
	if(a > b) {
		min = b;
	} else {
		min = a;
	}
	
	for(i = min; i > 0; i--) {
		if( (a % i == 0) && (b % i == 0) ) {
			count++;
			if(count == k) {
				printf("%d", i);
				return 0;
			}
		}
	}
	
	return 0;
}

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

string S;

int main()
{
    cin >> S;
    reverse(S.begin(),S.end());
    int sum = 0;
    int N = S.size();
    long long ans = 0;
    for(int i = 0; i < N; i++)
    {
        if(S[i] == 'B')
        {
            ans += i - sum;
            sum++;
        }
    }

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


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

int main() {
    int K;
    cin >> K;
    long int ans = 0;
    rep(a, K){
        rep(b, K){
            rep(c, K){
                ans+=gcd(gcd(a,b),c);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
int main(){
    int i,flag=0;
    char arr[100];
    scanf("%s", arr);
    for(i=0;i<strlen(arr);i++){
        if((i+1)%2==0){
            if(arr[i]=='R') flag = 1;
        }
        else{
            if(arr[i]=='L') flag = 1;
        }
    }
    if(flag == 1)
        printf("No\n");
    else
        printf("Yes\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
int n;
char str[3300];
ll dp[3300][3300];
int main() {
    scanf("%d%s",&n,str+2);
    dp[1][1]=1;
    for(int i=2;i<=n;i++)
        if(str[i]=='<')
            for(int j=2;j<=i;j++)
                dp[i][j]=(dp[i-1][j-1]+dp[i][j-1])%mod;
        else
            for(int j=i-1;j;j--)
                dp[i][j]=(dp[i][j+1]+dp[i-1][j])%mod;
    ll ans=0;
    for(int i=1;i<=n;i++)ans=(ans+dp[n][i])%mod;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 76416
#include<cstdio>
int a[100000];
int main() {
	int k, i, j;
	long long min = 2, max = 2;
	scanf("%d", &k);
	for (i = 0; i < k; i++) {
		scanf("%d", &a[i]);
	}
	for (i = k - 1; i >= 0; i--) {
		min += (a[i] - min%a[i]) % a[i];
		max -= max%a[i];
		if (min > max) {
			printf("-1");
			return 0;
		}
		max += a[i] - 1;
	}
	printf("%lld %lld", min, max);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
    int  W, H,x, y, r;
    cin >> W >> H >> x>> y>>r;
    const char *ret;
    if(x>=r &&
      x+r<=W &&
      y>=r &&
      y+r <= H){
        ret = "Yes";
      } else {
        ret = "No";
    }
    cout << ret << endl;
}


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

//#pragma GCC optimize("Ofast")

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const int NN = 1e9 + 7;
const int N = 2e5 + 7;
const int M = 26;
const ll mod = 1e9 + 7;
const int inf = 1e9 + 7;
const dl rf = 1e-14;
const int B = sqrt(N);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,k;
ll a[N];

void solve1()
{
    cin >> n >> k;
    vector < ll > A , B;
    ll ans = 1;
    for( int i = 1; i <= n; i++ ){
        cin >> a[i];
        if( a[i] < 0 )A.push_back( -a[i] );
        else B.push_back( a[i] );
        ans = ans * a[i];
        ans %= mod;
    }
    if( n == k ){
        cout << (ans + mod) % mod;
        return;
    }
    ans = 1;
    if( (int)A.size() + (int)B.size() < k ){
        cout << 0;
        return;
    }
    sort( A.rbegin() , A.rend() );
    sort( B.rbegin() , B.rend() );
    if( B.empty() ){
        if( k % 2 )reverse( A.begin() , A.end() );
        for( int i = 0; i < k; i++ ){
            ans *= -A[i];
            ans %= mod;
        }
        cout << (ans + mod) % mod;
    }else{
        swap( A , B );
        int n1 = (int)A.size();
        int n2 = (int)B.size();
        int i = 0 , j = 0 , s = 0;
        while( s < k ){
            s += 1;
            if( s == k ){
                ans *= A[i];
                ans %= mod;
                break;
            }
            if( i + 1 < n1 && j + 1 < n2 ){
                if( A[i] * A[i + 1] > B[j] * B[j + 1] ){
                    ans *= A[i] % mod;
                    ans %= mod;
                    i += 1;
                }else{
                    ans *= B[j] * B[j + 1] % mod;
                    ans %= mod;
                    s += 1;
                    j += 2;
                }
            }else{
                if( j + 1 < n2 ){
                    if( i < n1 && A[i] > B[j] * B[j + 1] ){
                        ans *= A[i];
                        ans %= mod;
                        i += 1;
                    }else{
                        ans *= B[j] * B[j + 1] % mod;
                        s += 1;
                        ans %= mod;
                        j += 2;
                    }
                }else{
                    ans *= A[i];
                    ans %= mod;
                    i += 1;
                }
            }
        }
        cout << (ans + mod) % mod;
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


Measured memory_bytes: 6644
city = [0, 0, 0, 0]
for i in range(3):
    a, b = ([int(x)-1 for x in input().split()])
    city[a] += 1
    city[b] += 1
    if city[a] > 2 or city[b] > 2:
        print('NO')
        exit()

print('YES')


Measured memory_bytes: 2940
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(System.in);
		int w = Integer.parseInt(sc.next());
		int h = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());
		sc.close();
//		double a = Math.min(x*h, (w-x)*h);
//		double b = Math.min(w*y, w*(h-y));
//		double c = Math.max(a, b);
		double c = (double)w*h/2;
		int fuku = 0;
		if(w==2*x && h == 2*y) fuku = 1;
		System.out.println(String.format("%.6f %d", c, fuku));
	}
}


Measured memory_bytes: 23892
package main

import (
        "fmt"
)

func solution(s, t string) string {
        l := len(s)
        for i := 0; i < l; i++ {
                s = string(s[l-1]) + s[:l-1]
                if s == t {
                        return "Yes"
                }
        }
        return "No"
}

func main() {
        var s, t string
        fmt.Scan(&s, &t)
        fmt.Println(solution(s, t))
}

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

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  
  swap(x,y);
  swap(x,z);
  cout << x << " " << y << " " << z << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String[] inputs = reader.readLine().split(" ");
        int X = Integer.parseInt(inputs[0]);
        int Y = Integer.parseInt(inputs[1]);
        int Z = Integer.parseInt(inputs[2]);

        int num = 0;
        while (num <= (X - Z) / (Y + Z)) {
            num += 1;
        }

        System.out.println(num-1);

    }
}

Measured memory_bytes: 24916
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)


int H, A[MAX + 1] = {};

void maxHeapfy(int i) {
	int l, r, largest;
	l = i * 2;
	r = i * 2 + 1;
	if (l <= H && A[i] < A[l]) {
		largest = l;
	}
	else {
		largest = i;
	}
	if (r <= H && A[r] > A[largest]) {
		largest = r;
	}
	if (largest != i) {
		swap(A[i], A[largest]);
		maxHeapfy(largest);
	}

}
void HIK(int i,int key) {
	if (A[i] > key) {
		return;
	}
	A[i] = key;
	while (i > 1 && A[i / 2] < A[i]) {
		swap(A[i], A[i / 2]);
		i = i / 2;
	}
}

void insert(int key) {
	H++;
	A[H] = -INFTY;
	HIK(H, key);

}

void extract() {
	if (H < 1) {
		return ;
	}
	int max;
	max = A[1];
	A[1] = A[H];
	H--;
	maxHeapfy(1);
	cout << max << endl;
}

int main() {
	int i;
	string order;
	H = 0;
	while (true) {
		cin >> order;
		if (order == "end") {
			break;
		}
		if (order == "insert") {
			cin >> i;
			insert(i);
			//cout << "ins" << endl;
		}
		if (order == "extract") {
			
			extract();
		}


	}

	return 0;
}


Measured memory_bytes: 7100
l,a,b,m = map(int,input().split())

# c111 -> 1001001001みたいなやつを求める
# n : 塊の数
# l : 一つの塊(00..001)の長さ
# m : mod
# ex) n=3, l=2 -> 10101
def c111(n, l, m):
    if n <= 1:
        return 1
    if n % 2 == 1:
        return (c111(n - 1, l, m) * pow(10, l, m) + 1) % m
    half = c111(n // 2, l, m)
    return (half * pow(10, (n // 2) * l, m) + half) % m

# c123 -> 1002003004みたいなやつを求める
# n : 塊の数
# l : 一つの塊(00..001)の長さ
# m : mod
# ex) n=3, l=2 -> 10203
def c123(n, l, m):
    if n <= 1:
        return 1
    if n % 2 == 1:
        return (c123(n - 1, l, m) + c111(n, l, m)) % m
    half = c123(n // 2, l, m)
    return (half * pow(10, (n // 2) * l, m) + half + (n // 2) * c111(n // 2, l, m)) % m

fst = a
lst = a + b * (l - 1)

fst_l = len(str(fst))
lst_l = len(str(lst))

res = 0
margin = 0
for keta in reversed(range(fst_l, lst_l + 1)):
    num_l = a + b * ((10 ** (keta - 1) - a + b - 1) // b)
    num_r = a + b * ((10 ** keta - a + b - 1) // b - 1)
    if keta == fst_l:
        num_l = fst
    if keta == lst_l:
        num_r = lst
    if num_l > num_r:
        continue
    sz = (num_r - num_l) // b + 1
    _111 = num_l * c111(sz, keta, m)
    _123 = b * c123(sz - 1, keta, m)
    if sz == 1:
        _123 = 0
    res += (pow(10, margin, m) * (_111 + _123)) % m
    margin += sz * keta
print(res % m)

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

#define fastIO \
ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl "\n"
#define ll long long
#define MOD 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pii pair<int,int> 

int main(){
	int n;
	cin >> n;
	vector <int> b(n-1);
	for(int i=0;i<n-1;i++)	cin >> b[i];
	ll int ans = b[n-2];
	for(int i=n-2;i>0;i--){
		ans += min(b[i-1], b[i]);
	}
	ans += b[0];
	cout << ans << endl;
	return 0;
}

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

int main(){
	int n,i,x,s=0,t=0;
	cin>>n;
	int a[n];
	for(i=1;i<=n;i++) cin>>a[i];
	while(true){
		for(i=1;i<=n;i++){
			if(a[i]%2==0){
				a[i]/=2;
			}else{
				cout<<s;
				return 0;
			}
		}
		s++;
	}
	return 0;
}

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

#define fi first
#define se second

const int N = 123;

using namespace std;

int n;
int m;
int used[N][N];
char a[N][N];

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

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        cin >> n >> m;
        used[1][0] = 1;
        for(int i = 1; i <= n; i++){
                for(int j = 1; j <= m; j++){
                        cin >> a[i][j];
                        if(a[i][j] == '.'){
                                continue;
                        }
                        if(!used[i - 1][j] && !used[i][j - 1]){
                                cout << "Impossible" << "\n";
                                return 0;
                        }
                        used[i - 1][j] = used[i][j - 1] = 0;
                        used[i][j] = 1;
                }
        }
        if(used[n][m]){
                cout << "Possible" << "\n";
        } else{
                cout << "Impossible" << "\n";
        }
}


Measured memory_bytes: 256
import sys

figure, condition_num = [int(n) for n in input().rstrip().split()]

candidate_num = [-1]*figure

for _ in range(condition_num):
    from_left, num = [int(n) for n in input().rstrip().split()]
    from_left-=1
    if candidate_num[from_left] ==-1:
        candidate_num[from_left] = num
    elif candidate_num[from_left]!=num:
        print(-1)
        sys.exit()

if len(candidate_num)>1 and candidate_num[0]==0:
    print(-1)
    sys.exit()

if candidate_num[0]==-1:
    if len(candidate_num)>1:
        candidate_num[0]=1
    else:
        candidate_num[0]=0

answer=str(candidate_num[0])

for i in range(1,figure):
    if candidate_num[i]==-1:
        candidate_num[i]=0

    answer+=str(candidate_num[i])

print(answer)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

#include <valarray>
typedef valarray<double> P;
double dot(const P &a, const P &b){return (a*b).sum();}
double norm(const P &a){return sqrt(dot(a,a));}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,q; cin >> n >> q;
	vector<P> ps(n,P(3));
	vector<double> r(n);
	vector<ll> l(n);
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin >> ps[i][j];
		}
		cin >> r[i] >> l[i];
	}
	while(q--){
		ll res=0;
		P a(3),b(3);
		for(int i=0;i<3;i++){
			cin >> a[i];
		}
		for(int i=0;i<3;i++){
			cin >> b[i];
		}
		P v=b-a;
		for(int i=0;i<n;i++){
			bool ok=0;
			P vv=ps[i]-a;
			double t=dot(v,vv)/norm(v)/norm(v);
			if(0.0<=t&&t<=1.0){
				// double h=norm(ps[i]-a)*sqrt(1-dot(v,ps[i]-a)/norm(v)/norm(ps[i]-a));
				P p=a+t*v;
				if(r[i]+1e-5>=norm(p-ps[i]))ok=1;
			}
			if(norm(ps[i]-a)<=r[i]+1e-5)ok=1;
			if(norm(ps[i]-b)<=r[i]+1e-5)ok=1;
			if(ok){
				res+=l[i];
			}
		}
		printf("%lld\n",res);
	}
}



Measured memory_bytes: 3296