akhauriyash/Code-Regression huggingface dataset:
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N = int(input())
    nums = defaultdict(int)
    for _ in range(N):
        s = input()
        nums[s] += 1
    mmax = max(nums.values())
    nums = dict(nums)
    keys = sorted(nums.keys())
    for s in keys:
        if mmax == nums[s]:
            print(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41848
#define ll long long
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;
int a[27];

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

	string s;
	cin >> s;

	int flag = 0;
	
	for(auto w:s){
		a[w-'a']++;
		if(a[w-'a'] > 1){
			flag = 1;
			break;
		}
	}
	cout << ((flag == 1) ? "no":"yes") << endl;


	return 0;
}


Measured memory_bytes: 256
import sys

def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N,K = LI()
A = LI()

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

B = [0]  # Aの累積和をKで割ったもの
for i in range(N):
    B.append((B[-1]+A[i]) % K)

from collections import defaultdict

# 要素の個数がKを超えないことに注意

if N < K:
    d = defaultdict(int)
    for n in B:
        d[n] += 1
    ans = 0
    for n in d.keys():
        m = d[n]
        ans += m*(m-1)//2
    print(ans)
else:
    d = defaultdict(int)
    ans = 0
    for i in range(N):  # A[i]から始まる部分列を考える
        if i == 0:
            for j in range(K):
                d[B[j]] += 1
            ans += d[B[i]]-1
        elif i <= N-K+1:
            d[B[K+i-1]] += 1
            d[B[i-1]] -= 1
            ans += d[B[i]]-1
        else:
            d[B[i-1]] -= 1
            ans += d[B[i]]-1
    print(ans)



Measured memory_bytes: 138544
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			b[i] = a[i];
		}
		Arrays.sort(b);
		int ans = 0;
		for(int i = 0; i < n; i++) {
			int ind = binarySearch(b, a[i]);
			if(Math.abs(i - ind) % 2 != 0) {
				ans++;
			}
		}
		System.out.println(ans/2);
	}
	public static int binarySearch(int[] arr, int b) {
		int l = 0;
		int r = arr.length-1;
		while(l <= r) {
			int mid = (l+r)/2;
			if(arr[mid] < b) {
				l = mid+1;
			} else if(arr[mid] > b) {
				r = mid - 1;
			} else {
				return mid;
			}
		}
		return -1;
	}
}


Measured memory_bytes: 60204
/// ITNOG :)))
/// SAliB
#include <bits/stdc++.h>

using namespace std;

#define pb                      push_back
#define pp                      pop_back
#define mp                      make_pair
#define fi                      first
#define sec                     second
#define xmax(x,y)               ((x) = max((x),(y)))
#define xmin(x,y)               ((x) = min((x),(y)))
#define all(x)                  (x).begin(),(x).end()
#define mem(x , y)              memset(x , y , sizeof(x))
#define _                       ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define debug1(a)               cout << string(40 , '*') << '\n' << #a << " ---> " << a << '\n';
#define debug2(a , b)           cout << string(40 , '*') << '\n' << #a << " ---> " << a << '\n' << #b << " ---> " << b << '\n';
#define debug3(a , b , c)       cout << string(40 , '*') << '\n' << #a << " ---> " << a << '\n' << #b << " ---> " << b << '\n' << #c << " ---> " << c << '\n';
#define debug4(a , b , c , d)   cout << string(40 , '*') << '\n' << #a << " ---> " << a << '\n' << #b << " ---> " << b << '\n' << #c << " ---> " << c << '\n' << #d << " ---> " << d << '\n';
#define connect(a , b , c)      a[b].pb(c) , a[c].pb(b)
//
typedef long long int ll            ;
typedef unsigned long long int ull  ;
typedef unsigned int uint           ;
typedef long double ld              ;
typedef string str                  ;
typedef pair < int , int > pii      ;
typedef pair < pii , int > ppi      ;
typedef pair < int , pii > pip      ;
typedef pair < ll , ll> pll         ;
typedef pair < ll , pll> plp        ;
typedef pair < pll , ll> ppl        ;
typedef vector < ll > vl            ;
typedef vector < ld > vld           ;
typedef vector < int > vi           ;
typedef vector < str > vs           ;
//
inline int   iin()  { int x   ; scanf("%d" , &x)   ;  return x; }
inline ll    lin()  { ll  x   ; scanf("%lld" , &x) ;  return x; }
inline ll    Lin()  { ll  x   ; scanf("%I64d" , &x);  return x; }
//
inline int   iout(int  x)  { printf("%d" , x)   ;  }
inline ll    lout(ll   x)  { printf("%lld" , x) ;  }
inline ll    Lout(ll   x)  { printf("%I64d" , x);  }
//
const int maxn4 = 1e4 + 85 , maxn5 = 1e5 + 69 , maxn6 = 1e6 + 85 , maxn7 = 1e7 + 69 , maxn8 = 1e8 + 85 , maxn9 = 1e9 + 69 , modi1 = 1e7 + 7 , modi2 = 1e9 + 7;
const ll mod1 = 1e7 + 7 , mod2 = 1e9 + 7;
int mn = INT_MAX , mx = INT_MIN;
//
vi g[maxn6];
int dfs(int v , int p = -1)
{
	int ans = 0;
	for(int u : g[v])
		if (u != p)
			ans ^= dfs(u , v) + 1;
	return ans;
}
int main()
{_
	int n;cin >> n;
	for(int i = 0; i < n - 1; i++)
    {
		int u , v;cin >> u >> v;
		--u, --v;
		g[u].pb(v);
		g[v].pb(u);
	}
	cout << (dfs(0) ? "Alice" : "Bob");
}


Measured memory_bytes: 31488
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
int main(){
	int n,m,ans,A;
	cin>>n>>A;
	cout<<n*n-A<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>

int main(){
    int n;
    scanf("%d", &n);
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    for(int i=0;i<n;i++){
        char s[3];
        scanf("%s", s);
        if(s[0] == 'A') ac++;
        else if(s[0] == 'W') wa++;
        else if(s[0] == 'T') tle++;
        else re++;
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", ac,wa,tle,re);
    return 0;
}

Measured memory_bytes: 1728
a,b,c,x,y = map(int, input().split())
ab = a+b
ans = 0
if ab>=c*2:
    ans = c*min(x,y)*2
else:
    ans = ab*min(x,y)

if x>y:
    if a<c*2:
        ans = ans + (x-y)*a
    else:
        ans = ans + (x-y)*2*c
elif x<y:
    if b<c*2:
        ans = ans + (y-x)*b
    else:
        ans = ans + (y-x)*2*c
print(ans)

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

const int N = 1e3 + 10;
const int mod = 1e9 + 7;

int n, m, d[N][N], use[N][N];
char a[N][N];

int zn(int x, int y)
{
    if (a[x][y] == '#')
    {
        return 0;
    }
	if (x == 1 && y == 1)
	{
		return 1;
	} else if (x == 1)
	{
		return d[x][y - 1];
	} else if (y == 1)
	{
		return d[x - 1][y];
	} else
	{
		return (d[x - 1][y] + d[x][y - 1]) % mod;
	}
}

int main ()
{
	cin >>n >>m;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			cin >>a[i][j];
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			d[i][j] = zn(i, j);
			//cout <<d[i][j] <<" ";
		}
		//cout <<endl;
	}
	cout <<d[n][m];
	return 0;
}

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

using LL = long long;

bool valid(auto y, auto x, auto H, auto W) {return 0 <= y && y < H && 0 <= x && x < W;}

vector<pair<int, int>> next(auto y, auto x) {return {{y-1, x}, {y+1, x}, {y, x-1}, {y, x+1}};}
vector<vector<int>> bfs(auto H, auto W, auto S, auto T) {
  vector<vector<int>> res(H, vector<int>(W, -1));
  auto N = S.size();
  using Node = tuple<int, int, int>;
  queue<Node> q;
  for(auto i = 0; i < N; ++i) q.emplace(i, S[i], T[i]);
  while(!q.empty()) {
    int i, y, x;
    tie(i, y, x) = q.front();
    q.pop();
    if(~res[y][x]) continue;
    res[y][x] = i;
    for(auto p: next(y, x)) if(valid(p.first, p.second, H, W)) if(!~res[p.first][p.second]) q.emplace(i, p.first, p.second);
  }
  return res;
}

int main() {
  LL H, W, A, B, C, N;
  cin >> H >> W >> A >> B >> C >> N;

  vector<LL> S(N), T(N);
  for(auto i = 0; i < N; ++i) cin >> S[i] >> T[i];

  ++H;
  ++W;

  auto PIC = bfs(H, W, S, T);
  auto distance = [&](auto y, auto x, auto i) {return abs(S[i] - y) + abs(T[i] - x);};

  // Dijkstra
  enum {STOP, NORTH, EAST, SOUTH, WEST};
  using V = tuple<LL, LL, LL>;         // y, x, direction
  using Node = tuple<LL, LL, LL, LL>;  // cost, vertex
  const LL dy[5] = {0, -1, 0, 1, 0};
  const LL dx[5] = {0, 0, 1, 0, -1};
  map<V, LL> d;
  priority_queue<Node, vector<Node>, greater<Node>> q;
  q.emplace(0, S.front(), T.front(), STOP);
  while(!q.empty()) {
    LL cost, y, x, dir;
    tie(cost, y, x, dir) = q.top();
    q.pop();
    if(d.count(V(y, x, dir))) continue;
    d[V(y, x, dir)] = cost;
    if(y == S.back() && x == T.back() && dir == STOP) break;
    if(dir == STOP) {
      for(auto ndir: {NORTH, EAST, SOUTH, WEST}) {
        if(!d.count(V(y, x, ndir))) q.emplace(cost + distance(y, x, PIC[y][x]) * C + B, y, x, ndir);
        auto ny = y + dy[ndir], nx = x + dx[ndir];
        if(!d.count(V(ny, nx, STOP))) if(valid(ny, nx, H, W)) q.emplace(cost + C, ny, nx, STOP);
      }
    } else {
      if(!d.count(V(y, x, STOP))) q.emplace(cost, y, x, STOP);
      auto ny = y + dy[dir], nx = x + dx[dir];
      if(!d.count(V(ny, nx, dir))) if(valid(ny, nx, H, W)) q.emplace(cost + A, ny, nx, dir);
    }
  }
  cout << d[V(S.back(), T.back(), STOP)] << endl;
}

Measured memory_bytes: 122808
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        long time = sc.nextLong();
        
        long sec = time % 60;
        
        long minuteAll = time / 60;
        long minute = minuteAll % 60;
        long hour = minuteAll / 60;
        
        System.out.println(hour + ":" + minute + ":" + sec);
    }
}

Measured memory_bytes: 17160
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		vector<int> p(n);
		REP(i,n) cin >> p[i];
		int cnt = 0;
		REP(i,n){
			p[i]--;
			if(p[i] == i) {
				swap(p[i],p[i+1]);
				cnt++;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}


Measured memory_bytes: 640
s = input()

if s=='MON':
    print(6)
elif s=='TUE':
    print(5)
elif s=='WED':
    print(4)
elif s=='THU':
    print(3)
elif s=='FRI':
    print(2)
elif s=='SAT':
    print(1)
elif s=='SUN':
    print(7)

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 200000+5
#define MOD 20190823
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline void read(int &f){
	f=0;
    ll x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
} 
int n;
int ans=0;
int cnt[15][15];
int t=1;
int main()
{
    read(n);
    for(int i=1;i<=n;i++){
        if(i>=10*t){
            t*=10;
        }
        cnt[i/t][i%10]++;
    }
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            ans+=cnt[i][j]*cnt[j][i];
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,N;
  cin>>H>>N;
  
  int arr[N];
  int sum=0;
  
  for(int i=0;i<N;i++){
    cin>>arr[i];
  }
  
  
  for(int i=0;i<N;i++){
    sum += arr[i];
  }
  
  if(sum >= H) 
    cout<<"Yes";
  else{
    cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 640
def count_sort(arr):
    max_num = max(arr)
    min_num = min(arr)

    count = [0] * (max_num - min_num + 1)
    for ele in arr:
        count[ele - min_num] += 1
    return [ele for ele, cnt in enumerate(count, start=min_num) for _ in range(cnt)]

n=int(input())
S=list(map(int,input().split()))
S=count_sort(S)
print(' '.join(list(map(str,S))))


Measured memory_bytes: 224392
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
  
int main()
{
  int N;
  cin >> N;

  vector<int> A(N);
  REP(i, N) cin >> A[i];
  
  int x = 1;
  vector<int> B(N,0);
  int flag = 0;
  int cnt = 0;
  while(B.at(x-1)==0){
    B.at(x-1) = 1;
    x = A.at(x-1);
    cnt++;
    if(x==2){
      flag = 1;
      break;
    }
  }

  if(flag == 1){
    cout << cnt << endl;
  }else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <time.h>
#include <tr1/unordered_map>
#include <tr1/unordered_set>
using namespace std::tr1;
using namespace std;
/* cau troi cho Garena nhap de con Bach */
#define FSYNC ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define int long long
#define endl '\n'
#define inf 0x3f3f3f3f
#define lb lower_bound
#define pob pop_back
#define ub upper_bound
#define ite ::iterator
#define db(x) {cout <<"#db " << x << endl;}
#define here() {cout <<"here \n";}
#define mod 1000000007
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
const int MOD = 1e9 + 7;
const int _MOD = 998244353;
const int N = 2e5 + 5;

int ST[N][20];
vi x;
int T[N];
int L,q,n;
int solve(int l,int r){
	if(l == r) return 0;
	if(r < l) swap(l,r);
	l --, r--;
	int ans = 0;
	for(int i = 17 ; i >= 0 ; i --){
		if(ST[l][i] < r){
			ans |= (1<<i);
			l = ST[l][i];
		}
	}
	return ans + 1;
}
signed main(){
	cin >> n ;
	for(int i = 0 ; i < n ; i ++){
		int u;cin >> u;x.pb(u);
	}
	cin >> L >> q;//cout << endl;
	for(int i = 0 ; i <= 19 ; i ++)
		for(int j = 0 ; j <n ; j ++)
			ST[j][i] = -1;
	for(int i = 0 ; i < n ; i ++){
		vector<int>ite it = x.begin() + i;
		ST[i][0] = ub(it,x.end(),x[i] + L) - x.begin() - 1;
		//cout << ST[i][0] << " ";
	}
	//cout << endl;
	
	for(int j = 1 ; j <= 19 ; j ++)
		for(int i = 0 ; i < n ; i ++)
			if(ST[i][j-1] != -1) ST[i][j] = ST[ST[i][j-1]][j-1];
	
	for(int i = 1 ; i <= q; i ++){
		int a,b;cin >> a >> b;
		cout << solve(a,b) << endl;
	}
	return 0;
}


Measured memory_bytes: 18548
#include <stdio.h>

int main(){
    int A, B;
    scanf("%d %d", &A, &B);
    int al, au, bl, bu;
    al = A*12.5+0.9;
    au = ((A+1)*12.5) - 0.1;
    bl = B*10;
    bu = (B+1)*10-1;
    int i;
    int ans = -1;
    for(i=al; i<=au; i++){
        if(i>=bl && i<= bu){
            ans = i;
            goto END;
        }
    }
    END:;
    printf("%d\n", ans);
    return 0;
}

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

ll a,b,n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>a>>b>>n;
    
    ll x;
    if (b-1<=n) x=b-1;
    else x=n;
    
    cout<<a*x/b;
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_set>
#include <numeric>
#include <iterator>
#include <unordered_map>
#include <array>
#include <map>
#include <cstring>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctgmath>
#include <set>
#include <queue>
#include <fstream>
#include <ostream>
#include <random>
#include <chrono>

using namespace std;

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

	char c;
	cin >> c;

	if (c == 'A')
	{
		cout << 'T';
	}
	if (c == 'T')
	{
		cout << 'A';
	}
	if (c == 'C')
	{
		cout << 'G';
	}
	if (c == 'G')
	{
		cout << 'C';
	}
	cout << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int N,W[100+10],s1=0,s2=0,ans=114514;
signed main(){
  cin >> N;
  rep(i,N){
    cin >> W[i];
    s2+=W[i];
  }
  rep(i,N){
    s1+=W[i];
    s2-=W[i];
    chmin(ans,abs(s1-s2));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
p[]={-1,0,1,-2,2,-2,2,-2,2,-1,0,1};
P[]={-2,-2,-2,-1,-1,0,0,1,1,2,2,2};
s[]={-1,0,1,-1,0,1,-1,0,1};
S[]={-1,-1,-1,0,0,0,1,1,1};
m[10],M[10],n;int D(x,y,d){int i=0,j;
for(;i<12;i++)for(j=0;j<9;j++)if(x+p[i]==m[d]+s[j]&&y+P[i]==M[d]+S[j]&&0<=x+p[i]&&x+p[i]<10&&0<=y+P[i]&&y+P[i]<10)if(d==n-1||D(x+p[i],y+P[i],d+1))return 1;
return 0;}
main(X,Y,i){for(;scanf("%d%d%d",&X,&Y,&n)>2;puts(D(X,Y,0)?"OK":"NA"))for(i=0;i<n;i++)scanf("%d%d",m+i,M+i);exit(0);}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
int main(){
    ll N,M;
    cin>>N>>M;
    VL H(N);
    rep(i,0,N){
        cin>>H[i];
    }
    VVL G(N);
    rep(i,0,M){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    ll ma=0;
    ll ans=0;
    rep(i,0,N){
        ma=0;// 忘れてた
        for(auto g:G[i]){
            ma = max(ma, H[g]);
            //cout<<g; 
            //cout<<ma<<endl;
        }
        //cout<<endl;
        if(ma<H[i])ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 9792
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define rep(i,x) for(ll i = 0;i<x;i++)
#define REP(i,x) for(ll i = 1;i<=x;i++)
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << "\n"
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T, class U> inline bool chmin(T& a, const U& b){ if(a > b){ a = b; return 1; } return 0; }
template<class T, class U> inline bool chmax(T& a, const U& b){ if(a < b){ a = b; return 1; } return 0; }
template<class T, class U> inline bool change(T& a,U& b){if(a > b){swap(a,b);return 1;}return 0;}
//0の場合のアレンジに注意
template<class T>
T gcd(T a,T b){
    if(a == 0)return b;
    else if(b == 0)return a;
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
template<class T>
T lcm(T a,T b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
template<class T>
inline bool isp(T n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
vector<ll> fac(cmax),finv(cmax),inv(cmax);

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if(fac[0] == 0)COMinit();
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
ll mypow(ll n,ll m){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n);
        m >>= 1;
        n *= n;
    }
    return res;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll N;
    cin >> N;
    vector<ll> up(N),down(N);
    vecin(up);vecin(down);
    ll ans = 0;
    rep(i,N){
        ll cnt = 0;
        rep(j,i + 1){
            cnt += up[j];
        }
        for(ll j = i;j < N;j++){
            cnt += down[j];
        }
        chmax(ans,cnt);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 26564
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

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


const long long int mod = 1000000007;
const long long int INF = 1e18;
long long int N,M,sum=0,A[200005],b[1005],c[1005][30],dp[2005][2005]={},four[1000]={},dp2[2000500]={};
pll key[1005];
string S[6];



int main()
{
    cout << fixed << setprecision(18);
    cin>>N;
    cout<<3*N*N<<endl;
    
    

}


Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<char>a(n);
    rep(i,n)cin>>a[i];
    set<char>s;
    rep(i,n)s.insert(a[i]);
    if(s.size()==3)cout<<"Three"<<"\n";
    else cout<<"Four"<<"\n";
}


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

int n;
int a[100];

vector<pair<int, int>> ans;

void solveNeg() {
	for (int i = n - 2; i >= 0; --i) {
		ans.push_back(make_pair(i + 1, i));
	}
}

void solvePos() {
	for (int i = 1; i < n; ++i) {
		ans.push_back(make_pair(i - 1, i));
	}
}

void solve() {

	cin >> n;
	int mx = 0, mn = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		// mx = max(mx, a[i]);
		// mn = min(mn, a[i]);
		if (a[i] > a[mx]) mx = i;
		if (a[i] < a[mn]) mn = i;
	}

	if (a[mx] == a[mn]) {
		cout << 0 << '\n';
		return;
	}

	if (a[mx] < 0) {
		solveNeg();
	} else if (a[mn] >= 0) {
		solvePos();
	} else {
		if (a[mx] + a[mn] >= 0) {
			for (int i = 0; i < n; ++i) if (a[i] < 0) {
				ans.push_back(make_pair(mx, i));
			}
			solvePos();
		} else {
			for (int i = 0; i < n; ++i) if (a[i] >= 0) {
				ans.push_back(make_pair(mn, i));
			}
			solveNeg();
		}
	}
	cout << ans.size() << '\n';
	for (auto x : ans) {
		cout << x.first + 1 << ' ' << x.second + 1 << '\n';
	}


}

int main() {
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin);
#endif

	solve();

#ifdef _LOCAL_
	cout << '\n' << 1.0 * clock() / CLOCKS_PER_SEC << '\n';
#endif
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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 (a>b) { a=b; return 1; } return 0; }


#define MAX_N 100000
int par[MAX_N+1]; //親
int ran[MAX_N+1]; //木の深さ

//n要素で初期化
void init(int n) {
    rep(i,n) {
		par[i] = i; ran[i] = 0;
	}
}

//木の根を求める
int root(int x){ return par[x]==x ? x : par[x]=root(par[x]); }

//x,yの属する集合の併合
void unite(int x, int y) {
	x = root(x); y = root(y);
	if(x == y) return ;

	if(ran[x] < ran[y]) par[x] = y;
	else {
		par[y] = x;
		if(ran[x] == ran[y]) ran[x]++;
	}
}

//x,yが同じ集合に属するか
bool same(int x, int y) { return root(x) == root(y); }

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

    int N, M; cin >> N >> M;
    init(N);
    rep(i,M) {
        int x, y, z; cin >> x >> y >> z;
        x--; y--;
        unite(x, y);
    }
    set<int> r;
    rep(i,N) r.insert(root(i));
    cout << r.size() << endl;
    return 0;
}



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

using namespace std;
typedef vector<double> vi;

double probability(vi v, int n) {

    vector<vi> dp(n + 1, vi(n + 1));
    double tails = 1.0;
    for (int head = 1; head <= n; ++head) {
        dp[0][head] = 0.0;
    }
    for (int coin = 1; coin <= n; ++coin) {
        tails = (1 - v[coin - 1]) * (tails);
        dp[coin][0] = tails;
    }
    dp[0][0] = 1;
    for (int coin = 1; coin <= n; ++coin) {
        for (int head = 1; head <= n; ++head) {

            if (head > coin)
                dp[coin][head] = 0;
            else {
                dp[coin][head] = dp[coin - 1][head] * (1 - v[coin - 1]) + dp[coin - 1][head - 1] * (v[coin - 1]);
            }
        }
    }
    double ans = 0;
    for (int head = (n + 1) / 2; head <= n; ++head) {
        ans += dp[n][head];
    }
    return ans;

}

int main() {
    int n;
    scanf("%d", &n);
    vi v(static_cast<unsigned long>(n));
    for (auto &it: v)cin >> it;
//    for (auto &it: v)cout <<  it << ' ';
    cout << fixed << setprecision(15);
    cout <<  probability(v, n);

}

Measured memory_bytes: 70784
//by spj
#include <bits/stdc++.h>
using namespace std;
vector < int > g[200005];
int n,dist1[200005],dist2[200005];
void dfs1(int pos,int depth)
{
	if(dist1[pos] != -1)
		return;
	dist1[pos] = depth;
	for(int i = 0;i < g[pos].size();i++)
		dfs1(g[pos][i],depth + 1);
}
void dfs2(int pos,int depth)
{
	if(dist2[pos] != -1)
		return;
	dist2[pos] = depth;
	for(int i = 0;i < g[pos].size();i++)
		dfs2(g[pos][i],depth + 1);
}
int main()
{
	cin >> n;
	for(int i = 0;i < n - 1;i++)
	{
		int x,y;
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	memset(dist1,-1,sizeof(dist1));
	memset(dist2,-1,sizeof(dist2));
	dfs1(1,0);
	dfs2(n,0);
	int cnt1 = 0,cnt2 = 0;
	for(int i = 1;i <= n;i++)
		if(dist1[i] <= dist2[i])
			cnt1++;
		else
			cnt2++;
	if(cnt1 > cnt2)
		puts("Fennec");
	else
		puts("Snuke");
	return 0;
}

Measured memory_bytes: 12800
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    int A,B,C,D,E,F;
    cin>>A>>B>>C>>D>>E>>F;
    set<int> sugar,water;
    

    REP(i,31){
        REP(j,31){
            if(100*A*i+100*B*j>F) continue;
            water.insert(100*A*i+100*B*j);
        }
    }

    REP(i,3001){
        REP(j,3001){
            if(C*i+D*j>=F) continue;
            sugar.insert(C*i+D*j);
        }
    }


    int ans_w=100*A;
    int ans_s=0;
    
    for(auto itr=water.begin();itr!=water.end();itr++){
        int w=(*itr);
        auto itr2=sugar.upper_bound(F-w);
        itr2--;
        int s=(*itr2);
        while((w*E)<(100*s)){
            itr2--;
            s=(*itr2);
        }
        if(w!=0&&(s+w)<=F){
            int cur=s*(ans_w+ans_s);
            int bef=ans_s*(w+s);
            
            if(cur>bef){
                ans_w=w;
                ans_s=s;
            }
        }
        
    }

    // for(auto itr=sugar.begin();itr!=sugar.end();itr++){
    //     int s=*itr;
    //     auto itr2=water.upper_bound(F-s);
    //     itr2--;
    //     int w=*itr2;
    //     if(w!=0&&(w*E)>=(100*s)&&(s+w)<=F){
    //         int cur=s*(ans_w+ans_s);
    //         int bef=ans_s*(w+s);
            
    //         if(cur>bef){
    //             ans_w=w;
    //             ans_s=s;
    //         }
    //     }
        
    // }
    cout<<(ans_w+ans_s)<<" "<<ans_s<<endl;


}

Measured memory_bytes: 3752
a = gets.split(" ").map{|s| s.to_i};
if a[0] < a[1] then
  if a[1] < a[2] then
    puts a[0].to_s + " " + a[1].to_s + " " + a[2].to_s;
  elsif a[0] < a[2] then
    puts a[0].to_s + " " + a[2].to_s + " " + a[1].to_s;
  else
    puts a[2].to_s + " " + a[0].to_s + " " + a[1].to_s;
  end
else
  if a[0] < a[2] then
    puts a[1].to_s + " " + a[0].to_s + " " + a[2].to_s;
  elsif a[1] < a[2] then
    puts a[1].to_s + " " + a[2].to_s + " " + a[0].to_s;
  else
    puts a[2].to_s + " " + a[1].to_s + " " + a[0].to_s;
  end
end

Measured memory_bytes: 8664
a_len = int(input())
a_ar = sorted([int(n) for n in input().split(" ")])
b_len = int(input())
b_ar = [int(n) for n in input().split(" ")]
dp = [0 for n in range(2001)]
for a in a_ar:
    new_dp = dp[:]
    new_dp[a] = 1
    for i,d in enumerate(dp):
        if d and i + a <= 2000:
            new_dp[i + a] = 1
        elif i + a > 2000:
            break
    dp = new_dp
for b in b_ar:
    if dp[b]:
        print("yes")
    else:
        print("no")

Measured memory_bytes: 7792
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define exists(s,x) (s).find(x)!=(s).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
#define fi first
#define se second
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}
inline ll modpow(ll x, ll y) {
    ll res = 1;
    while(y) {
        if(y&1) res = mul(res,x);
        y >>= 1;
        x = mul(x,x);
    }
    return res;
}

const int MAX = 1000005;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    COMinit();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    ll K; cin >> K;
    if(K==1) {
        cout << (ll)N * (N-1) << endl;
        return 0;
    }
    if(K>=N) {
        cout << COM(2*N-1,N) << endl;
        return 0;
    }
    ll ans = 0;
    for(ll i=0; i<=K; ++i) {
        ll tmp = mul(COM(N,i), COM(N-1,i));
        ans = add(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  ll int a, b, c, d;
  cin >> a >> b >> c >> d;
  ll int w = a * c;
  ll int x = a * d;
  ll int y = b * c;
  ll int z = b * d;
  ll int m = max(w, x);
  m = max(m, y);
  m = max(m, z);
  cout << setprecision(20) << m << '\n';
}

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

int main(){
	int m1,d1,m2,d2;
  cin>>m1>>d1;
  cin>>m2>>d2;
  if(m1<m2){
  	cout<<1;
  }
  else{
    
    if(m1==12 && m2==1){
    	cout<<1;
    }
  	cout<<0;
  }
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define maxm 
#define mod 
#define maxn 

int main()
{
	int n, x, s = 0, t = 0;
	
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		if (x & 1) s++;
		else if (x % 4 == 0) t++;
	}	
	if (t >= s) puts("Yes");
	else if (t + 1 == s && t + s == n) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	string s;
	cin >> s;
	int N = s.size();
	for(int i = 1; i < N; i++)
		if(s[i - 1] == s[i]) {
			cout << i << " " << i + 1 << "\n";
			return 0;
		}
	for(int i = 2; i < N; i++)
		if(s[i - 2] == s[i]) {
			cout << i - 1 << " " << i + 1 << "\n";
			return 0;
		}
	cout << "-1 -1\n";
	return 0;
}


Measured memory_bytes: 512
#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>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class UnionFind {
    vector<int> p;//p[i]はiの属する組織
    vector<int> sz;

public:
    UnionFind(int n) {
        p.resize(n);
        sz.resize(n);

        for (int i = 0; i < n; i++) {
            p[i] = i;
            sz[i] = 1;
        }
    }

/* xの属する集合を返す */
    int find(int x) {
        if (p[x] == x) return x;
        return p[x] = find(p[x]);
    }

/* yにxを統合する */
    void unite(int x, int y) {
        sz[find(y)] += sz[find(x)];
        sz[find(x)] = 0;
        p[find(x)] = p[find(y)];
    }

/* xとyが属する集合が同じかを判定する */
    bool same(int x, int y) {
        return find(x) == find(y);
    }

/* xに属する集合のサイズを求める */
    int size(int x) {
        return sz[find(x)];
    }
};

class Solve {
public:
    void solve() {
        Int N, M, K;
        cin >> N >> M >> K;
        UnionFind uf(N), neri(N); // neri_block!!!
        vector<vector<Int>> G(N); // friend graph

        for (int i = 0; i < M; ++i) {
            Int a, b;
            cin >> a >> b;
            a--, b--;
            G[a].push_back(b);
            G[b].push_back(a);
            if (!uf.same(a, b)) {
                uf.unite(a, b);
            }

        }


        vector<Int> ans(N);
        for (int i = 0; i < N; ++i) {
            Int tmp = uf.size(i) - G[i].size() - 1;
            ans[i] = tmp;
        }

        for (int i = 0; i < K; ++i) {
            Int a, b;
            cin >> a >> b;
            a--, b--;
            if (uf.same(a, b)) {
                ans[a]--, ans[b]--;
            }
        }
        for (auto e : ans) {
            cout << e << " ";
        }
        cout << endl;

    }
};


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

    Solve().solve();


    return 0;
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

vint rig(vint v){
    vector<vint>r(4);
    rep(i,4){
        r[i]=v;
        rotate(r[i].begin(),r[i].begin()+i,r[i].end());
    }
    sort(all(r));
    return r[0];
}

int en(vint v){
    int r=0;
    rep(i,v.size())r=r*1000+v[i];
    return r;
}

int N;
vector<int>C[400];
signed main(){
    cin>>N;
    map<int,int>cnt;
    map<int,int>way;
    rep(i,N){
        C[i].resize(4);
        rep(j,4)cin>>C[i][j];
        C[i]=rig(C[i]);
        cnt[en(C[i])]++;

        vint v=C[i];
        set<vint>s;
        rep(k,4){
            s.insert(v);
            rotate(v.begin(),v.begin()+1,v.end());
        }
        way[en(C[i])]=4/s.size();
    }

    int ans=0;
    rep(i,N){
        cnt[en(C[i])]--;
        vint X=C[i];
        reps(j,i+1,N){
            vint Y=C[j];
            cnt[en(C[j])]--;
            reverse(all(Y));

            rep(ii,4){

                vint wanna(4);
                rep(k,4){
                    vint v(4);
                    v[0]=X[(k+1)%4];
                    v[1]=X[k];
                    v[2]=Y[k];
                    v[3]=Y[(k+1)%4];
                    v=rig(v);
                    wanna[k]=en(v);
                }
                sort(all(wanna));
                vpint want;
                rep(k,4){
                    if(want.size()==0||want.back().fi!=wanna[k]){
                        want.push_back(pint(wanna[k],1));
                    }
                    else{
                        want[want.size()-1].se++;
                    }
                }

                int tmp=1;
                rep(k,want.size()){
                    int e=want[k].fi;
                    int f=want[k].se;
                    if(cnt.find(e)==cnt.end()){
                        tmp=0;
                        continue;
                    }
                    int hoge=cnt[e];
                    int piyo=way[e];
                    rep(l,f)tmp*=(hoge-l)*piyo;
                }
                ans+=tmp;
                rotate(Y.begin(),Y.begin()+1,Y.end());
            }
            cnt[en(C[j])]++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main() {
    long long a, b, k;
    cin >> a >> b >> k;
    if(k > a){
        k -= a;
        a = 0;
        if(k > b){
            cout << 0 << " " << 0;
        }else{
            cout << 0 << " " << b - k;
        }
    }else cout << a - k << " " << b;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;



int main() {
	int n;
	cin >> n;
	
	ll min = 1000000000;
	int cnt_nega = 0;
	ll sum = 0;
	
	for (int i = 0; i < n;i++) {
		int a;
		cin >> a;

		if (a < 0) {
			cnt_nega++;
		}

		int abs_a = abs(a);
		sum += abs_a;
		if (abs_a < min) {
			min = abs_a;
		}
		

	}

	if (cnt_nega % 2 != 0) {
		sum -= 2 * min;
	}
	cout << sum;
	
}


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(true){
        
        c -= b;
        if(c<=0){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a<=0){
            cout << "No" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3620
#include <complex>
#include <cmath>
#include <iostream>
using namespace std;

typedef complex<double> xy_t;
xy_t P[110];

int main() {
  //入力例　読み込んだ点の個数をNとする
  int N = 0;
  double x,y;
  while (~scanf("%lf,%lf", &x, &y)) {
    P[N++] = xy_t(x,y);
	}
	//面積計算
	double sum = 0.0;
	for (int i = 0; i+2 < N; ++i) {
	  xy_t a = P[0], b = P[i+1], c = P[i+2];
	  xy_t ab = P[i+1] - P[0], bc = P[i+2] - P[i+1], ca = P[0] - P[i+2];
	  double z = (abs(ab) + abs(bc) + abs(ca))/2;
	  double s = sqrt(z*(z-abs(ab))*(z-abs(bc))*(z-abs(ca)));
	  sum += s;
	  }
	printf("%.6f\n", abs(sum));
}

/* 自分のMac環境ではコンパイルも通り、正しい答えが出力されるのですがオンラインジャッジではコンパイルエラーになってしまいます。どうしてでしょうか? */

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
//cin.ignore();	// better to use 2 times getline(cin,s);
// g++ iterator.cpp -std=c++17
//cout << (A + B == C ? "YES" : "NO") << endl;
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
   	cin.tie(NULL);
   	cout.tie(NULL);}


int main(void)
{
	fast();
	string s;
	cin>>s;
	if(s.size%2!=0)
	{
		cout<<"No"<<endl;
	}
	else
	{
		if(s.size==2)
		{
			if(s=="hi")
			{
				cout<<"Yes"<<endl;
			}
			else
			{
				cout<<"No"<<endl;
			}
		}
		else if(s.size==4)
		{
			if(s=="hihi")
			{
				cout<<"Yes"<<endl;
			}
			else
			{
				cout<<"No"<<endl;
			}
		}
		else if(s.size==6)
		{
			if(s=="hihihi")
			{
				cout<<"Yes"<<endl;
			}
			else
			{
				cout<<"No"<<endl;
			}
		}
		else if(s.size==8)
		{
			if(s=="hihihihi")
			{
				cout<<"Yes"<<endl;
			}
			else
			{
				cout<<"No"<<endl;
			}
		}
		else if(s.size==10)
		{
			if(s=="hihihihihi")
			{
				cout<<"Yes"<<endl;
			}
			else
			{
				cout<<"No"<<endl;
			}
		}
	}
}

Measured memory_bytes: 256