akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

const int NMAX = 200005, LOG = 20;
const int INF = 0x3f3f3f3f;

vector<int> T1[NMAX], T2[NMAX];
int father[NMAX], level[NMAX];
int anc[LOG][NMAX];

int dist[NMAX];

void dfs(int node, int prev) {
    father[node] = prev;
    for (int to: T2[node]) {
        if (to != prev) {
            level[to] = level[node] + 1;
            dfs(to, node);
        }
    }
}

int goUp(int x, int lvl) {
    for (int k = LOG - 1; k >= 0; --k) {
        if (lvl & (1 << k)) {
            x = anc[k][x];
        }
    }
    return x;
}

int lca(int x, int y) {
    if (level[y] > level[x]) {
        y = goUp(y, level[y] - level[x]);
    } else if (level[x] > level[y]) {
        x = goUp(x, level[x] - level[y]);
    }
    if (x == y) {
        return x;
    }
    for (int k = LOG - 1; k >= 0; --k) {
        if (anc[k][x] != anc[k][y]) {
            x = anc[k][x];
            y = anc[k][y];
        }
    }
    return father[x];
}

int xdist(int x, int y) {
    return level[x] + level[y] - 2 * level[lca(x, y)];
}

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, r1, r2;
    cin >> n >> r1 >> r2;

    for (int i = 1; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        T1[x].push_back(y);
        T1[y].push_back(x);
    }
    for (int i = 1; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        T2[x].push_back(y);
        T2[y].push_back(x);
    }
    dfs(r2, -1);
    father[r2] = r2;

    for (int i = 1; i <= n; ++i) {
        anc[0][i] = father[i];
    }
    for (int k = 1; k < LOG; ++k) {
        for (int i = 1; i <= n; ++i) {
            anc[k][i] = anc[k - 1][anc[k - 1][i]];
        }
    }

    memset(dist, INF, sizeof dist);
    queue<int> q;
    dist[r1] = 0;
    q.push(r1);
    int ans = 0;
    while (!q.empty()) {
        int node = q.front();
        q.pop();
        ans = max(ans, 2 * level[node]);

        for (int to: T1[node]) {
            if (xdist(node, to) > 2) {
                cout << "-1\n";
                return 0;
            }
            if (dist[to] > dist[node] + 1 && dist[node] + 1 < level[to]) {
                dist[to] = dist[node] + 1;
                q.push(to);
            }
            if (dist[to] > dist[node] + 1 && dist[node] + 1 <= level[to]) {
                ans = max(ans, 2 * level[to]);
            }
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 48636
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int d = sc.nextInt();
        long x = sc.nextInt();
        sc.close();
        for(int i = 1 ; i <= 10 ; i++){
            x = r * x - d;
            System.out.println(x);
        }
    }
}

Measured memory_bytes: 35664
#include <iostream>
#include <vector>
#include <string>
using namespace std;
struct item{
	string name;
	int year;
	int value;
};
int main(){
	int n,m,a,b;
	item x;
	string s;
	vector<item> v;
	bool check;
	while(1){
		cin >> n >> m;
		if(n == 0)break;
		v.clear();
		for(int i = 0;i < n;i++){
			cin >> s >> a >> b;
			x.name = s;
			x.year = b;
			x.value = a;
			v.push_back(x);
		}
		for(int i = 0;i < m;i++){
			check = false;
			cin >> a;
			for(int j = 0;j < v.size();j++){
				if(v[j].year >= a && v[j].year - v[j].value < a){
					cout << v[j].name << " " << a - (v[j].year - v[j].value) << endl;
					check = true;
				}
			}
			if(!check)cout << "Unknown" <<endl;
		}
	}
	return 0;
}

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


Measured memory_bytes: 2052
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_accepted(void) {
	string s;
	cin >> s;
	bool judge_a = false, judge_b = false, judge_c = false;

	int cnt_c = 0;
	for (int i = 0; i < s.size(); i++) {
		if (i == 0) {
			if (s[i] == 'A') judge_a = true;
			else             break;
		}
		else if (s[i] == 'C'){
			if (i >= 2 && i < s.size() - 1) {
				cnt_c++;
			}
		}
		else {
			if (s[i] < 'a') {
				judge_c = false;
				break;
			}
			else judge_c = true;
		}
	}

	if (cnt_c == 1) judge_b = true;

	if (judge_a & judge_b & judge_c) {
		cout << "AC" << endl;
	}
	else {
		cout << "WA" << endl;
	}
}

int main()
{
	b_accepted();
    return 0;
}

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

const int N = 100010;

int n, a[N], b[N];

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	int cnt = 0;
	for(int i = 1; i <= n; ++i) if(a[i] == a[i - 1]) b[++cnt] = a[i];
	n -= cnt;
	if(cnt & 1) --n;
	printf("%d\n", n);
	return 0;
}

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

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

  unsigned long long ans;

  ans = k;
  for(int i=1;i<n;i++) {
    ans = ans * (k-1);
  }

  cout << ans <<endl;

  return 0;
}


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

int main() {

  int a = 0, tmp;

  for(int i=0; i<3; i++) {
    cin >> tmp;
    a += tmp;
  }

  if ( a >= 22 ){
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    int max_a = *max_element(all(A));
    int min_a = *min_element(all(A));
    if (max_a - min_a >= 2) {
        cout << "No" << endl;
        return 0;
    }
    if (max_a == min_a) {
        if (N == A[0] + 1 || 2 * A[0] <= N) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    else {
        int max_cnt = 0;
        int min_cnt = 0;
        for (auto& a : A) {
            if (a == max_a) {
                ++max_cnt;
            }
            else {
                ++min_cnt;
            }
        }
        int rest_cnt = max_a - min_cnt;
        if (rest_cnt > 0 && rest_cnt * 2 <= max_cnt) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<ll,ll>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
    ll n;
    cin >> n;
    vector < pair<P, ll> > a;
    //vector < pair<P, int> > b;
    REP(i,n){
        ll x,y,h;
        cin >> x >> y >> h;
        P p = mk(x,y);
        a.pb(mk(p,h));
    }
    ll rx,ry,rh;
    REP(i,101){
        REP(j,101){
            ll h = 0;
            bool f = true;
            bool t = true;
            REP(k,n){
                if(t){
                    h = a[k].second + abs(a[k].first.first - i) + abs(a[k].first.second - j);
                    if(a[k].second != 0){
                        t = false;
                        k = -1;
                    }
                }else{
                    if((a[k].second + abs(a[k].first.first - i) + abs(a[k].first.second - j)) != h){
                        if(a[k].second != 0){
                            f = false;
                            break;
                        }
                        if(abs(a[k].first.first - i) + abs(a[k].first.second - j) <= h){
                            f = false;
                            break;
                        }
                        
                    }
                    
                }
               
            }
            
            if(f){
                rx = i;
                ry = j;
                rh = h;
                cout << rx << " " << ry << " " << rh << endl;
                return 0;
            }
        }
    }
    



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<int> > Graph;
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; }

    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;}
const ll INF = 1e16;

int main(){
    ll n;
    cin >> n;
    vector<ll>k;
    vector<ll>g;
    rep(i,n){
        ll v;
        cin >> v;
        if(i%2==0){
            k.push_back(v);
        }
        else{
            g.push_back(v);
        }
    }
    map<ll,ll>ki;
    map<ll,ll>gu;
    rep(i,k.size()){
        ll now = k[i];
        ki[now]++;
    }
    rep(i,g.size()){
        ll now = g[i];
        gu[now]++;
    }
    ll gm=0,km=0;
    ll gtwo=0,ktwo=0;
    ll kans=0,gans=0;
    for(auto itr=ki.begin();itr!=ki.end();itr++){
        ll now = itr->second;
        if(now>km){
            ktwo=km;
            km=now;
            kans=itr->first;
        }
        else if(now>ktwo){
            ktwo=now;
        }
    }
    for(auto itr=gu.begin();itr!=gu.end();itr++){
        ll now = itr->second;
        if(now>gm){
            gtwo=gm;
            gm=now;
            gans=itr->first;
        }
        else if(now>gtwo){
            gtwo=now;
        }
    }
    ll s;
    if(gans!=kans){
        s=gm+km;
    }
    else{
        s=max(gm+ktwo,km+gtwo);
    }
    cout << n-s << endl;
    return 0;
}


Measured memory_bytes: 7284
#include<stdio.h>
#define N 100000

int A[N + 1];

int Partition(int p, int r){
  int x, i, j, arr;
  x = A[r];
  i = p - 1;
  for(j = p; j < r; j++){
    if(A[j] <= x){
      i++;
      arr = A[i];
      A[i] = A[j];
      A[j] = arr;
    }
  }
  arr = A[i + 1];
  A[i + 1] = A[r];
  A[r] = arr;

  return i + 1;
}


main(){
  int i, r, q, p = 0;
  
  scanf("%d", &r);
  for(i = 0; i < r; i++){
    scanf("%d", &A[i]);
  }
  
  q = Partition(p, r - 1);
  for(i = 0; i < r; i++){
    if(i == q){
      printf("[%d]", A[i]);
    } else {
      printf("%d", A[i]);
    }

    if(i != r - 1){
     printf(" ");
    }
  }
  printf("\n");
  return 0;
}

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

using namespace std;

int main(void) {
	string text;
	
	getline(cin, text);
	
	for(int i = text.size() - 1; i >= 0; i--) {
		cout << text[i];
	}
	cout << endl;
	
	return 0;
}

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

#define MAX 1000

int main(void)
{
    int i;

    while (1) {
        int n_students;
        scanf("%d", &n_students);

        if (n_students == 0) {
            break;
        } else {
            int points[MAX];
            for (i = 0; i < n_students; i++) {
                scanf(" %d", &points[i]);
            }

            double ave = 0;
            for (i = 0; i < n_students; i++) {
                ave += points[i];
            }
            ave /= n_students;

            double variance = 0;
            for (i = 0; i < n_students; i++) {
                variance += pow(points[i] - ave, 2);
            }
            variance /= n_students;

            double deviation = sqrt(variance);

            printf("%f\n", deviation);
        }
    }

    return 0;
}

Measured memory_bytes: 636
#include <stdio.h>
int main() {
	int n, m, a, sum = 0;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d", &a);
		sum += a;
	}
	printf("%d\n", n < sum ? -1 : n - sum);
	return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

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

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;
  int size=0;
  char com[20];
  int np=0,nd=0;
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%s%d",com,&key);
    if(com[0]=='i') {insert(key);np++;size++;}
    else if(com[0]=='d'){
      if(strlen(com)>6){
        if(com[6]=='F') deleteFirst();
        else if(com[6]=='L') deleteLast();
      } else{
        deleteKey(key);nd++;
      }
      size--;
    }
  }
  printList();
  return 0;
}


Measured memory_bytes: 34472
#include<iostream>

int main()
{
	int a, b, l, s;//a, b:???????????????, l:????????¢?????¨????????????, s:????????¢?????¢???
	std::cin>>a>>b;//??\???
	//l??¨s????????????????¨????
	l=2*(a+b);
	s=a*b;
	std::cout<<s<<" "<<l<<std::endl;//??????
	return 0;
}

Measured memory_bytes: 1164
using System;

namespace abcb149
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            double a = double.Parse(str[0]);
            double b = double.Parse(str[1]);
            double k = double.Parse(str[2]);
            double u = b - (k - a);
            if (a + b < k)
                Console.WriteLine("0" + " " + "0");
            if (u < 0)
                b = 0;
            else 
            if (k > a)
                Console.WriteLine("{0} {1}", 0, b-(k-a));
            else
                Console.WriteLine("{0} {1}", a - k, b);
            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 13396
n = int(input())
ar = [int(x) for x in input().split()]

cnt = {}
for x in ar:
        def add(x):
                if x in cnt:
                        cnt[x] += 1
                else:
                        cnt[x] = 1
        add(x-1)
        add(x)
        add(x+1)

counts = map(lambda x: x[1], cnt.items())
ans = max(counts)

print(ans)


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

using namespace std;

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

        int n;
        cin >> n;

        int s = 0;
        int k = n;
        while(k) {
                s += k%10;
                k/=10;
        }
        if (n%s == 0)
                cout << "Yes" << endl;
        else
                cout << "No" <<endl;
        return 0;
}

Measured memory_bytes: 256
/* Author : Prasuk Jain */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int              long long int
#define ull              unsigned long long
#define ld               long double
#define ull              unsigned long long
#define fo(i, n)         for(int i=0; i<n; i++)
#define FOR(i, a, b)     for(int i=a; i<b; i++)
#define rfor(i, n)       for(int i=n-1; i>=0; i--)
#define RFOR(i, a, b)    for(int i=b-1; i>=a; i--)
#define tr(it, v)        for(auto it=a.begin(); it!=a.end(); it++)
#define vi               vector<int>
#define mp               make_pair
#define pb(x)            push_back(x)
#define pii              pair<int,int>
#define vi               vector<int>
#define mii              map<int,int>
#define pqb              priority_queue<int>
#define PI 3.1415926535897932384626
#define pqs              priority_queue<int,vi,greater<int>>
#define hcf(x, y)        __gcd(x, y)
#define lcm(x, y)        boost::math::lcm(x,y)
#define setpre(x, y)     fixed << setprecision(y) << x
#define setbits(x)       __builtin_popcountll(x)
#define zerolead(x)      __builtin_clzll(x)
#define zerotrail(x)     __builtin_ctzll(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
const int  mod = 1e+7;
const int inf = 1e18;
bool isprime(int a){if(a <=1)return false;for(int i=2;i*i<=a;i++)
{if(a%i==0)return false;}return true;}

//*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!//

void coderprasukj(){ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int32_t main() {
    //coderprasukj();
    double t, n, k, x, y;
    cin >> t;
    cout << 2*PI*t << "\n";
    
    return 0;
}



Measured memory_bytes: 3788
from collections import deque

s = deque(input())
q = int(input())

inv = False
for _ in range(q):
    com, *query = input().split()
    if com == "1":
        if not inv:
            inv = True
        else:
            inv = False
    else:
        f, c = query
        if not inv:
            if f == "1":
                s.appendleft(c)
            else:
                s.append(c)
        else:
            if f == "1":
                s.append(c)
            else:
                s.appendleft(c)


s = "".join(s)
print(s if not inv else s[::-1])


Measured memory_bytes: 8692
n = int(input())
a = list(map(int,input().split()))
div = min(a)
flag = 0
while flag == 0:
    for i in range(n):
        if a[i] % div != 0:
            a[i] = a[i] % div
    if div == min(a):
        flag = 1
    else:
        div = min(a)
print(div)
    


Measured memory_bytes: 15020
#EOFERROR
# import math
# import copy
# from functools import reduce
# n = int(input())
# a = list(map(int,input().split()))
# ans = reduce(math.gcd,a)
# if n<=2 or (min(a)==max(a)):
#     print(max(a))
# else:
#     for i in range(n):
#         _a = copy.copy(a)
#         _a.pop(i)
#         tmp = reduce(math.gcd,_a)
#         if tmp > ans:
#             print(tmp)
#             break
#         else:
#             pass

def gcd(a,b):
    if b>a :
        a,b = b,a
    while b:
        a,b = b,a%b
    return a

def cul(n,x):
    l = len(x)
    b = [x[i] for i in range(l)]
    b.pop(n)
    tmp = b[0]
    for i in range(1,l-1):
        tmp = gcd(tmp,b[i])
    return tmp

import sys
p = 50
N = int(input())
if p>N : p=N
a = list(map(int,input().split()))

ans = 0

for i in range(p):
    s = cul(i,a[:p])
    if s>ans : ans=s

print(ans)

Measured memory_bytes: 14056
import bisect
import operator
import os
import sys
from functools import reduce


class SegmentTree:
    # http://codeforces.com/blog/entry/18051
    def __init__(self, values, op=operator.add):
        """
        :param list values:
        :param callable op: 結合律を満たす二項演算
        """
        self._size = len(values)
        self._op = op
        tree = [None] * self._size * 2
        tree[self._size:] = values[:]
        for i in reversed(range(1, self._size)):
            tree[i] = self._op(tree[i << 1], tree[i << 1 | 1])
        self._tree = tree

    def set(self, i, value):
        """
        values[i] = value
        :param int i:
        :param value:
        """
        i += self._size
        self._tree[i] = value
        i >>= 1
        while i > 0:
            self._tree[i] = self._op(self._tree[i << 1], self._tree[i << 1 | 1])
            i >>= 1

    def add(self, i, value):
        """
        values[i] = values[i]・value
        :param int i:
        :param value:
        """
        new_value = self._op(self._tree[self._size + i], value)
        self.set(i, new_value)

    def get(self, l, r=None):
        """
        [l, r) に op を順番に適用した値
        :param int l:
        :param int|None r:
        """
        if r is None:
            return self._tree[self._size + l]
        ret_l = []
        ret_r = []
        l += self._size
        r += self._size
        while l < r:
            if l & 1:
                ret_l.append(self._tree[l])
                l += 1
            if r & 1:
                r -= 1
                ret_r.append(self._tree[r])
            l >>= 1
            r >>= 1
        return reduce(self._op, ret_l + ret_r)

    def __len__(self):
        return self._size

    def get_values_copy(self):
        return self._tree[self._size:]


if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 998244353

N = int(sys.stdin.buffer.readline())
XD = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N)]

XD.sort()
X = [x for x, d in XD]
D = [d for x, d in XD]

# R[i]: i 番目のロボットがどこまで行くか
st = SegmentTree(list(range(N)), op=max)
for i, (x, d) in reversed(list(enumerate(XD))):
    ri = bisect.bisect_left(X, x + d) - 1
    st.set(i, st.get(i, ri + 1))
R = st.get_values_copy()

# dp[i]: ロボット i からロボット N - 1 までを使うときの組み合わせの数
dp = [0] * (N + 1)
dp[-1] = 1
for i, r in reversed(list(enumerate(R))):
    # 使わない場合
    dp[i] += dp[i + 1]
    # 使う場合
    dp[i] += dp[r + 1]
    dp[i] %= MOD
# print(dp)
print(dp[0])


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

#define int long long

const int N = 2222;
const int mod = 1e9 + 7;

int dp[N][N] , n , k , fac[N * N] , inv[N * N];

int Pow(int x , int y = mod - 2) {
	int res = 1;
	for(; y ; y >>= 1 , x = x * x % mod) {
		if(y & 1) {
			res = res * x % mod;
		}
	}
	return res;
}

int C(int x , int y) {
	if(x < y)
	return 0;
	return fac[x] * inv[x - y]  % mod * inv[y] % mod;
}

void Add(int &x , int y) {
	(x += y) %= mod;
}

main(void) {
	scanf("%lld%lld" , &n , &k);
	if(k == 1) {
		puts("1");
		return 0;
	}
	fac[0] = 1;
	for(int i = 1;i <= 4e6;++ i) 
	fac[i] = fac[i - 1] * i % mod;
	inv[4000000] = Pow(fac[4000000]);
	for(int i = 4000000 - 1;i >= 0;-- i) {
		inv[i] = inv[i + 1] * (i + 1) % mod;
	}
	dp[0][0] = 1;
	int All = n * k;
	for(int i = 0;i <= n;++ i) {
		for(int j = n;j >= 0;-- j) 
		if(dp[i][j]){
			if(j) {
				Add(dp[i][j - 1] , dp[i][j] * (n - i + j) % mod * C(All - (i + (i - j) * (k - 1) + 1) , k - 2));
			}
			Add(dp[i + 1][j + 1] , dp[i][j]);
		}
	}
	printf("%lld\n" , dp[n][0]);
}

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

const int M=1000005;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> cnt(M,0);
    for(int x:a){
        if(cnt[x]!=0){
            cnt[x]=2;
            continue;
        }
        for(int j=x;j<M;j+=x) cnt[j]++;
    }
    int ans=0;
    for(int x:a){
        if(cnt[x]==1) ans++;
    }
    cout << ans << endl;
}

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

#define int long long
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int A, B;

int g(int l, int r, int k, bool zero) {
  int K = (1LL<<(k-1));
  int br = 2*K-r;
  if (l >= K || l+1 >= br) return 2*K;
  int s = r+1;
  int e = 0;
  rep(j, 60) if (l&(1LL<<j)) e = j+1;
  s += 1LL<<e;
  s = min(s, 2*K);
  assert(s <= 2*K);
  //cout<<"g("<<l<<", "<<r<<", k="<<k<<") = "<<s<<"\n";
  return s;
}

int f(int l, int r, int k, bool zero) {
  if (k == 0) return r-l+1;
  //cout<<"f("<<l<<", "<<r<<", "<<k<<")\n";
  int mask = 1LL<<k;
  if ((r & mask) == 0) return f(l, r, k-1, zero);
  if ((l & mask) > 0 && (r & mask) > 0) return f(l-mask, r-mask, k-1, false);
  return f(l, mask-1, k, zero) + g(r-mask, mask-1-l, k, false);
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> A >> B;
  cout << f(A, B, 60, true) << "\n";
  return 0;
}


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

#define N 100000

int main(void)
{
    int n;
    string s[N];
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> s[i];
    }
    
    int cnt[4] = {0};
    for (int i = 0; i < n ; i++){
        if (s[i]=="AC"){
            cnt[0]++; 
        }

        else if (s[i]=="WA"){
            cnt[1]++; 
        }

        else if (s[i]=="TLE"){
            cnt[2]++; 
        }
        else{
            cnt[3]++;
        }
        
    }
    cout << "AC x " << cnt[0] << endl;
    cout << "WA x " << cnt[1] << endl;
    cout << "TLE x " << cnt[2] << endl;
    cout << "RE x " << cnt[3] << endl;


    return 0;
}


Measured memory_bytes: 6756
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 2*1000*1000 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

void sol( ){
    int n ;
    cin >> n ;
    vector< pair<int,int> > v(n) ;
    for(auto &i:v)cin>>i.F >> i.S ;
    for( int i=0;i+2<n;i++){
        int j=0;
        for(;j<3;j++){
            if(v[i+j].F!=v[i+j].S)
                break ;
        }
        if(j==3){
            cout << "Yes" << nl ;
            return ;
        }
    }
    cout << "No" << nl ;
}

signed main( ){
  timesaver ;
//  int t = 1 ; cin >> t ; while(t--)
  {
      sol( );
  }
}

Measured memory_bytes: 3656
#include<stdio.h>
int main(){
    int r,d;
    int x;
    int i;
    int now;

    scanf("%d %d %d",&r,&d,&x);
    now = x;
    for(i=0;i<10;i++){
        now = now*r-d;
        printf("%d\n",now);
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

// struct fast_io {
	// fast_io(){
		// std::cin.tie(nullptr);
		// std::ios::sync_with_stdio(false);
	// };
// } fio;

constexpr int num = 26;
int D;
vector<int> c(num);

vector<vector<int>> s; 

int point(vector<int> &t){
	int res = 0;
	
	vector<int> last(num);
	
	for(int i = 0; i < D; i++){
		res += s[i][t[i]];
		
		for(int j = 0; j < num; j++){
			last[j]++;
		}
		
		last[t[i]] = 0;
		
		for(int j = 0; j < num; j++){
			res -= c[j] * last[j];
		}
	}
	
	return res + 1'000'000;
}

vector<int> solve(int Z){
	vector<int> t(D);
	vector<int> con(num);
	vector<int> last(num);
	
	for(int i = 0; i < D; i++){
		
		
		for(int j = 0; j < num; j++){
			cin>>s[i][j];
			
			if(s[i][t[i]] + last[t[i]] * last[t[i]]/Z * c[t[i]] < s[i][j] + last[j] * last[j]/Z * c[j]) {
				
				
				t[i] = j;
			}
		}
		
		for(int j = 0; j < num; j++){
			if(j == t[i]) {
				last[j] = 0;
			} else {
				last[j]++;
			}
		}
		
		con[t[i]]++;
	}
	
	return t;
}

vector<int> t;
int p;

void change(int U){
	vector<int> con1(D), con2(D), con(D);
	vector<int> last(num);
	vector<int> nt(t);
	
	vector<pair<int,int>> s;
	
	for(int i = 0; i < D; i++){
		if(t[i] == U) con1[i] = 0;
		else if(i) con1[i] = con1[i-1] + 1;
		else con1[i] = 1;
		
		// s.push_back({con1[i], i});
	}
	
	for(int i = D-1; i >= 0; i--){
		if(t[i] == U) con2[i] = 0;
		else if(i+1!=D) con2[i] = con2[i+1] + 1;
		else con2[i] = 1;
	}
	
	
	for(int i = 0; i < D; i++){
		s.push_back({min(con1[i], con2[i]), i});
	}
	
	// cout<<"U = "<<U<<endl;
	
	sort(s.begin(), s.end(), greater<pair<int,int>>());
	
	for(int i = 0; i < s.size(); i++){//cout<<"i = "<<i<<endl;
		nt[s[i].second] = U;
		// cout<<s[i].second<<" "<<s[i].first<<endl;
		
		int np = point(nt);
		
		if(p < np) {
			t = nt;
			p = np;
		}
	}
}

vector<pair<int,int>> con(vector<int> &t){
	vector<pair<int,int>> con(num);
	
	for(int i = 0; i < D; i++){
		con[t[i]].first++;
	}
	
	for(int i = 0; i < num; i++){
		// cout<<i<<" "<<con[i].first<<endl;
		con[i].second = i;
	}
	
	sort(con.begin(), con.end());
	
	return con;
}

signed main(){
	cout<<fixed<<setprecision(10);
	
	// vector<int> t;
	// srand(time(NULL));
	
	cin>>D;
	
	// D = 365;
	
	s.resize(D, vector<int>(num));
	t.resize(D, 0);
	
	for(int i = 0; i < num; i++){
		cin>>c[i];
		// c[i] = rand()%100;
	}
	
	// int p;
	
	p = 0;
	// cout<<1<<" "<<p<<endl;
	
	for(int i = 1; i <= 20; i++){
		vector<int> nt;
		
		nt = solve(i);
		int np = point(nt);
		
		if(p < np) {
			t = nt;
			p = np;
		}
	}
	
	vector<pair<int,int>> c = con(t);
	
	for(int i = 0; i < c.size(); i++){//cout<<i<<endl;
		// int x = rand()%num, np;
		// int x = i%num;
		int x = c[i].second;
		int tx;
		vector<int> nt;
		
		change(x);

		
	}
	
	con(t);
	
	for(int i = 0; i < D; i++){
		cout<<t[i]+1<<endl;
	}
	
	// cout<<point(t)<<endl;
	
	return 0;
}

Measured memory_bytes: 3760
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	int n;
	scanf("%d",&n);
	if(n>=1000)puts("ABD");
	else puts("ABC");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(b-a==c-b)
    {
        cout << "YES" << endl;
    }else
    {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3564
N=int(input())
A=list(map(int,input().split()))
c=0
s=0
Az=[]
for i in A:
    if i<0:
        c+=1

    s+=abs(i)
    Az.append(abs(i))
if c%2==0:
    print(s)
else:
    print(s-2*min(Az))


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

int main()
{
	string s;
	cin>>s;
	
	bool f=1;
	
	if(s[0]!='A') f=0;
	
	int v=0;
	for(int i=2;i<=s.length()-2;i++){
		if(s[i]=='C') v++;
		else if(s[i]<'a'||'z'<s[i]) f=0;
	}
	if(v!=1) f=0;
	
	if(s[1]<'a'||'z'<s[1]) f=0;
	if(s[s.length()-1]<'a'||'z'<s[s.length()]) f=0;
	
	if(f==1) cout<<"AC"<<endl;
	else cout<<"WA"<<endl;
	
	return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))

b = 0

for i in range(N):
  if a[i]%2 == 0:
    if a[i]%3 != 0:
      if a[i]%5 != 0:
        b = 1
        break

if b == 1:
  print("DENIED")
else:
  print("APPROVED")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;

int main(){
  int n, s = 0; cin >> n;
  map<int, int> m; vector<bool> v(1000000, 1);
  rep(i, n){
    int a; cin >> a; m[a]++;
  }
  rep(i, 1000000){
    if(m.count(1)) break;
    if(m.count(i+1)) rep(j, 1000000/(i+1)-1) v[(i+1)*(j+2)-1] = 0;
  }
  for(auto p: m) if(p.se == 1 && v[p.fi-1]) ++s;
  if(m[1] == 1) s = 1;
  if(m[1] > 1) s = 0;
  cout << s << "\n";
  return 0;
}

Measured memory_bytes: 13072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T,class U> void outs(T a,U b){if((ll)(a)>=inf-100||(ll)(a)<=-inf+100)out(b);else out(a);}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n,k,q,ans=inf;cin>>n>>k>>q;
    vi v(n);
    rep(i,n)cin>>v[i];
    for(ll x:v){
        ll id=0;
        vvi c(n);
        rep(i,n){
            if(v[i]<x)id++;
            else c[id].pb(v[i]);
        }
        rep(i,n)sort(all(c[i]));
        vi s;
        rep(i,n)rep(j,c[i].size()-k+1)s.pb(c[i][j]);
        sort(all(s));
        if(q>s.size())continue;
        chmin(ans,s[q-1]-x);
    }
    out(ans);
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void){
    
    int n,max,count;
    max=0;
    scanf("%d",&n);
    
    char s[n+1];
    scanf("%s",s);
    
    for(int i=0; i<n; i++){
        count=0;
        int a[26]={};
        
        for(int j=0; j<i; j++)
            a[s[j]-'a']=1;
        
        for(int j=i; j<n; j++){
            if(a[s[j]-'a']==1){
                count++;
                a[s[j]-'a']=0;
            }
        }
        if(max<count)
            max=count;
    }
    printf("%d",max);
}

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    string res = "NO";
    if(a == 7) {
        if(b == 5 && c == 5) {
            res = "YES";
        }
    } else if(b == 7) {
        if(a == 5 && c == 5) {
            res = "YES";
        }
    } else if(c == 7) {
        if(b == 5 && a == 5) {
            res = "YES";
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

// DAME:
/*
    n-1回のswapでどんな順番にすることができることは自明 -> 最高n-1回
    今回はn-2回

    1. A, Bをソートして対応させた時に B_i >= A_iが満たされなかったら "No"
    2. A, Bのソート順に対応させるために何回swapするのかを巡回置換をサイクル分解することで求める
        (サイクル分解の方法)
            1. A, Bの元のindexを取得、
            2. 隣接リスト表現のように,ソートしたA_i、B_iに対応するindexを
                    G[A_iのindex] = B_iのindex
               のように格納する
            3. 任意の数字aで, G[a]からindexを辿り、G[b] = aとなるまで続ける
            4. その時に、全てのindexを使用した場合は、サイクルが1個しか存在しないことがわかる

    3. 2.で求めた時にサイクルが２個以上になったら、n-2以下になるため "Yes"
    4. サイクルが１個の時は、ソートにn-1回かかることがわかるため、ソートから一回でもswapできれば、n-2以下にすることができる
    5. ソート順 A_{i+1} <= B_{i}が一つでもあれば、A_{i+1}を一個左(A_{i+1}とB_iを対応)にずらすことが可能 -> n-2以下にすることができる
    6. それ以外の場合は、ソート順のみ A_i <= B_i　を満たすが、ソートさせるにはn-1回のswapが必要なため, "No"
*/

int main() {
    int n;
    cin >> n;
    vector<pair<ll, int>> A(n), B(n);
    rep(i, n){
        ll tmp;
        cin >> tmp;
        A[i] = make_pair(tmp, i);
    }
    rep(i, n){
        ll tmp;
        cin >> tmp;
        B[i] = make_pair(tmp, i);
    }

    sort(A.begin(), A.end()); sort(B.begin(), B.end());

    // 最低条件
    rep(i, n){
        if(A[i].first > B[i].first){
            cout << "No" << endl;
            return 0;
        }
    }

    // 巡回置換の表示
    vector<int> G(n);
    rep(i, n) G[A[i].second] = B[i].second;

    // サイクルが1個かどうか
    int cur = G[0];
    int count = 0;
    rep(i, n){
        if(cur == 0) break;
        cur = G[cur];
        count++;
    }

    // サイクルが2個以上あったらYes
    if(count < n-1){
        cout << "Yes" << endl;
        return 0;
    }

    // ソート順から一回以上swapできるかどうか
    rep(i, n-1){
        if(A[i+1].first <= B[i].first){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
int a[4];
int main()
{
	cin>>a[1]>>a[2]>>a[3];
	int maxx=max(a[1],max(a[2],a[3]));
	int minn=min(a[1],min(a[2],a[3]));
	cout<<maxx-minn;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b;	ci(a>>b);
  if(a<b) co(0)
  else co(10)
}

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

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

int main(){
    int N;
    cin >> N;
    int ans;
    ans = modpow(10,N,1000000007)-modpow(9,N,1000000007)-modpow(9,N,1000000007)+modpow(8,N,1000000007);
    cout << (ans+10000000070) % 1000000007 << endl;
    return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M, ans;
vector <int> Graph[55];

bool visited[55];
int Solve(int A, int B){
  fill(visited, visited + N + 1, false);
  queue<int> que; que.push(A);
  visited[A] = true;

  while (!que.empty()){
    int Q = que.front(); que.pop();
    for (int i = 0; i < Graph[Q].size(); i++){
      int next = Graph[Q][i];
      if (visited[next]) continue;
      if (Q == A && next == B) continue;
      if (Q == B && next == A) continue;
      que.push(next); visited[next] = true;
    }
  }

  if (!visited[B]) ans++;

  return 0;
}

int main(){
  cin >> N >> M;
  for (int i = 0; i < M; i++){
    int A, B; cin >> A >> B;
    Graph[A].push_back(B);
    Graph[B].push_back(A);
  }

  for (int i = 1; i <= N; i++){
    for (int j = 0; j < Graph[i].size(); j++){
      Solve(i, Graph[i][j]);
    }
  }
  cout << ans / 2 << endl;

  return 0;
}


Measured memory_bytes: 3620
using System;

class Program
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    var input = Console.ReadLine().Split(' ');
    int T = int.Parse(input[0]);
    int A = int.Parse(input[1]);
    var list = new int[N];
    double ans = 100000;
    int goal = 0;
    input = Console.ReadLine().Split(' ');
    for(int i = 0; i < N; i++)
    {
      list[i] = int.Parse(input[i]);
      double t = T - list[i] * 0.006;
      double a = Math.Abs(A - t);
      if(ans > a)
      {
        ans = a;
        goal = i;
      }
    }
    Console.WriteLine(goal + 1);
  }
}


Measured memory_bytes: 11164
import math

a, b, x = map(int, input().split(' '))

x = x / a

if x > a * b / 2:
    print(math.atan2((a * b - x) * 2, a ** 2) * 180 / math.pi)
else:
    print(math.atan2(b ** 2, x * 2) * 180 / math.pi)


Measured memory_bytes: 9348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e15+7;
const ll N = 100;
ll a,b;
char m[N][N];

int main(){
	cin>>a>>b;
	FOR(i,0,50){
		FOR(j,0,100){
			m[i][j]='.';
		}
	}
	FOR(i,50,100){
		FOR(j,0,100){
			m[i][j]='#';
		}
	}
	a--;
	b--;
	int i=51,j=1;
	while(a){
		a--;
		m[i][j]='.';
		i+=2;
		if(i>=98){
			i=51;
			j+=2;
		}
	}
	i=1;
	j=1;
	while(b){
		b--;
		m[i][j]='#';
		i+=2;
		if(i>=48){
			i=1;
			j+=2;
		}
	}
	cout<<100<<" "<<100<<endl;
	FOR(i,0,100){
		FOR(j,0,100){
			cout<<m[i][j];
		}
		cout<<endl;
	}

	return 0;
}

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

using namespace std;

int main(){
    int H,W; cin >> H >> W;
    vector<vector<char>> s(H,vector<char>(W));

    int dw[4] ={1,0,-1,0};
    int dh[4] ={0,1,0,-1};
    bool can = true;

    for(int h=0; h<H; h++){
        for(int w=0; w<W; w++){
            cin >> s.at(h).at(w);
        }
    }

    for(int h=0; h<H; h++){
        for(int w=0; w<W; w++){
            if(s[h][w] == '#'){
                int flg = 0;
                for(int i=0; i<4; i++){
                    int nh = h+dh[i];
                    int nw = w+dw[i];
                    if(nh < 0 || nh >=H || nw <0 || nw>=W){flg++;}
                    else if(s[nh][nw] == '.') flg++;
                }
                if(flg == 4) can = false;
            }
        }
    }
    
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;


}

Measured memory_bytes: 3604
#include "bits/stdc++.h"
#include "math.h"
#include "string.h"
#include "algorithm"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
int main(){
  int n,k;
  cin>>n>>k;
  vll h(n);
  
  REP(i,n){
    cin>>h[i];
  }
  sort(h.begin(),h.end());
  reverse(h.begin(),h.end());
  ll ans=0;
  FOR(i,k,n){
    ans+=h[i];
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 1792
L,N=map(int,input().split())
X=[int(input()) for i in range(N)]
S=[0]
for x in X:
  S.append(S[-1]+x)

ans=0
for i in range(N):
  a=2*X[i]
  d=(N-i-1)//2
  if (N-i)%2:
    a+=2*(S[i+d+1]-S[i+1])
    a+=2*(L*d-(S[N]-S[N-d]))
    a-=X[i+d]
  else:
    a+=2*(S[i+d+1]-S[i+1])
    a+=2*(L*(d+1)-(S[N]-S[N-d-1]))
    a-=L-X[N-d-1]
  ans=max(ans,a)
X_new=[]
S_new=[0]
for x in X[::-1]:
  X_new.append(L-x)
  S_new.append(S_new[-1]+L-x)

for i in range(N):
  a=2*X_new[i]
  d=(N-i-1)//2
  if (N-i)%2:
    a+=2*(S_new[i+d+1]-S_new[i+1])
    a+=2*(L*d-(S_new[N]-S_new[N-d]))
    a-=X_new[i+d]
  else:
    a+=2*(S_new[i+d+1]-S_new[i+1])
    a+=2*(L*(d+1)-(S_new[N]-S_new[N-d-1]))
    a-=L-X_new[N-d-1]
  ans=max(ans,a)
print(ans)




Measured memory_bytes: 91220
import java.util.*;
import java.lang.Math;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = Integer.parseInt(sc.next());

    for (int i = 1; i < 10; i++) {
      if (n % i ==0 && n / i < 10) {
        System.out.println("Yes");
        return;
      }
    }

    System.out.println("No");
  }
}

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


void solve(long long N, long long D, long long X, std::vector<long long> A){
    long long ans = 0;
    vector<long long> a(N);
    for(long long n = 0; n < N; ++n){
        for(long long j = 0; j < D; ++j){
            if(j * A[n] + 1 <= D){
                a[n]++;
            }
        }
    }
    ans = accumulate(a.begin(), a.end(), 0) + X;
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    long long X;
    scanf("%lld",&X);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, D, X, std::move(A));
    return 0;
}


Measured memory_bytes: 256
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100005

int main()
{
	
	io

	ll a,b,c;
	cin>>a>>b>>c;
	ll rhs=(c-a-b);
	if(rhs<=0)
	{
		cout<<"No";
		exit(0);
	}
	rhs=(rhs*rhs);
	ll lhs=(4ll*(a*b));
	if(lhs<rhs)
		cout<<"Yes";
	else
		cout<<"No";
	
}

Measured memory_bytes: 256
import itertools
import sys

input = sys.stdin.readline


def main():
    # クリティカルパルかなんか？
    # 累積和つかう？
    # 仕事が期限までに終わらせるかどうか
    # ナーススケジューリング問題？
    # 締切とタスクの合計値
    # 累積和となんかやと思うんやがな…
    # うーん、答えがわからん
    N = int(input())
    task_list = sorted(
        [[int(i) for i in input().split()] for _ in range(N)], key=lambda x: x[1]
    )
    print(
        "Yes"
        if all(
            [
                j <= i[1]
                for i, j in zip(
                    task_list, itertools.accumulate(map(lambda x: x[0], task_list))
                )
            ]
        )
        else "No"
    )


if __name__ == "__main__":
    main()

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

int main() {
  int64_t a,b;
  cin>>a>>b;
  if(a<=0 && b<=0) cout<<"IMPOSSIBLE"<<endl;
  else if((a+b)%2==1) cout<<"IMPOSSIBLE"<<endl;
  else {
    cout<<(a+b)/2<<endl;
  }
}



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

int main(){

	int a,b;
	int d,r;
	double f;

	cin >> a >> b;

	d = a / b;
	r = a % b;
	f = a*1.0 / b;

	cout << d << " " << r << " " << fixed << setprecision(8) << f << endl;

	cin >> a;


	return 0;
}


Measured memory_bytes: 3284