akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, int> pdd;

const ll mod = 1e9 + 7;
const int N = 20, M = 1e5 + 10;
const ll INF = 1e18;
const int inf = 0x3f3f3f3f;
const double eps = 1e-4;

#define pi acos(-1)
#define mk make_pair

int vis[120];

int main()
{
    int n, m;
    cin >> n >> m;
    while (m--)
    {
        int q;
        cin >> q;
        while (q--)
        {
            int x;
            cin >> x;
            vis[x] = 1;
        }
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++)
    {
        if (!vis[i])
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

/*

*/

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

using namespace std;

int main(){
  string inStr;
  cin >> inStr;
  
  int R=inStr.length();
  int M=inStr.length()/2;//中央ワード
  bool Pali=true;//強い回文初期値。false発生でNoを出力する。
  for(int i=0,j=M+1;i<M;){
    
    if(inStr[i]!=inStr[j])Pali=false;
    
    if(Pali==false)break;
    i++;
    j++;
  }
  if(Pali==true)cout << "Yes" << endl;
  if(Pali==false)cout << "No" << endl;
    
    
    
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#define For(i,x,y) for(register int i=(x); i<=(y); i++)
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll qpow(ll a, ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1)ans=(ans%mod)*(a%mod)%mod;
        a=a%mod*(a%mod)%mod;
        n>>=1;
    }
    return ans;
}
const int maxn=1e5+10;
ll inv[maxn],a[maxn];
int main()
{
    ll ans=0,cnt=1;
    int n;
    cin>>n;
    For(i,1,n)cin>>a[i],cnt=cnt%mod*(i%mod)%mod;//先计算方案数
    For(i,1,n)inv[i]=(qpow(i,mod-2)+inv[i-1])%mod;
    For(i,1,n)ans+=(a[i]%mod)*(inv[i]+inv[n-i+1]-1)%mod;//这里减1，是减去自身的重复。
    cout<<cnt*(ans%mod)%mod<<endl;
    return 0;
}


Measured memory_bytes: 5152
N, K = map(int,input().split())
lists = []
listb = [1 for i in range(N)]

for i in range(K):
    d = int(input())
    lista = list(map(int, input().split()))
    lists.append(lista)

for i in lists:
    for j in i:
        listb[j-1] -= 1
    
cnt = 0

for i in listb:
    if i == 1:
        cnt += 1
        
print(cnt)

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

using namespace std;

typedef long long int ll;

#define FOR(i,l,r) for(i=l;i<r;i++)

#define REP(i,n) FOR(i,0,n)

#define ALL(x) x.begin(),x.end()

#define P pair<ll,ll>

#define F first

#define S second

signed main(){

  ll N,i,ans=0;cin>>N;
  string S[N];
  REP(i,N)cin>>S[i];
  sort(S,S+N);
  REP(i,N)if(i==0||S[i-1]!=S[i])ans++;
  cout<<ans<<endl;

  return 0;

}

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

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

const int INF = 1e9;
const int mod = 1e9+7;

int n,ans;

int judge(int x)
{
    int flag[10] = {};
    while(x){
        flag[x%10]++;
        x /= 10;
    }
    if(flag[3] && flag[5] && flag[7]) return 1;
    else return 0;
}

void dfs(ll x)
{
    if(x > n) return;
    ans += judge(x);
    dfs(x*10+3);
    dfs(x*10+5);
    dfs(x*10+7);
}

int main()
{
    cin >> n;

    dfs(0);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b,c,n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d",&a,&b,&c);
    if(a*a+b*b==c*c)
      printf("YES\n");
    else if(a*a+c*c==b*b)
      printf("YES\n");
    else if(b*b+c*c==a*a)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;


#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define MUL(a,b) a=(a*b)%mod

ll MAX=1e18+1;

ll a,b;

void Solve(ll A, ll B){
    ll SMALL=0;
    ll BIG=MAX/(A+B);
    while(BIG>SMALL+1){
        ll MID=(BIG+SMALL)/2;
        if(A*MID>=a && B*MID>=b) BIG=MID;
        else SMALL=MID;
    }
    a=A*BIG; b=B*BIG;
    return;
}
int main(){
    ll N; cin>>N;
    a=1; b=1;
    rep(i,N){
        ll x,y; cin>>x>>y;
        Solve(x,y);
    }
    cout<<a+b<<endl;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

int main() {
  int k, n;
  cin >> k >> n;
  k--;
  int MIN = max(-1000000, n-k);
  int MAX = min(1000000, n+k);
  FORe(i, MIN, MAX) printf("%d%c", i, i==MAX?'\n':' ');

  return 0;
}

Measured memory_bytes: 256
n = int(input())

def dot(a,b):
    return a[0] * b[0] + a[1] * b[1]
def s(a):
    return a[0]**2 + a[1]**2

for i in range(n):
    points = [int(j) for j in input().split()]
    p0 = points[:2]
    p1 = points[2:4]
    p2 = points[4:6]
    p3 = points[6:8]
    a = [p0[0]-p1[0],p0[1]-p1[1]]
    b = [p2[0]-p3[0],p2[1]-p3[1]]
    c = dot(a,b)**2/(s(a) * s(b))
    if c == 0: print(1)
    elif c == 1: print(2)
    else: print(0)

Measured memory_bytes: 7840
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <map>
#include <cstdlib>
#include <istream>
#include <set>
#include <queue>
#define rep0(i,n) for (long long int i = 0; i <= (n); ++i)
#define rep1(i,n) for (long long int i = 1; i <= (n); ++i)
#define REP(a,b) for (long long int i = a; i <= (b); ++i) 
#define MOD 100000007
#define ps push_back 
using namespace std;
typedef long long ll;
int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rep0(i, n - 1)cin >> a[i];
	sort(a.begin(), a.end());
	cout << a[n - 1] - a[0] << endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1);
const int MOD = 998244353;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 1000005;
const int MAXV = 3;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    printf("%d\n", (n + 999) / 1000 * 1000 - n);
    return 0;
}

Measured memory_bytes: 3808
#include<iostream>
#include<algorithm>

using namespace std;

bool used[10];

int table[15][1050][1 << 10];
int z = (1 << 10) - 1;
int solve(int x, int y){
    if(x > 10)return 0;
    if(x < 0)return 0;
    if(y > 1050)return 0;
    if(y < 0)return  0;
    int &res = table[x][y][z];
    if(res != -1)return res;
    res = 0;
    if(x == 0)return res = (y == 0);
    for(int i = 0;i < 10;i++){
	if(used[i])continue;
	used[i] = true;
	z ^= 1 << i;
	res += solve(x - 1, y - x * i);
	z ^= 1 << i;
	used[i] = false;
    }
    return res;
}

int main(){
    for(int i = 0;i < 15;i++)
	for(int j = 0;j < 1050;j++)
	    for(int k = 0;k < (1 << 10);k++)
	    table[i][j][k] = -1;
    int n, s;
    while(cin >> n >> s)
	cout << solve(n, s) << endl;
    return 0;
}

Measured memory_bytes: 64160
#include<stdio.h>
#include<string.h>
int main()
{
    char w[100], main[200], cpy[100];
    int wl,mainlen,i,j,c=0,y = 0;

    scanf("%s",&main)   ; mainlen=strlen(main) *2;
    scanf("%s",&w)    ; wl=strlen(w);

    strcpy(cpy,main);
    strcat(main,cpy);

    for(i=0;  i< mainlen-wl ; i++)
    {
        for(j=0; j<wl;j++)
        {
            if(main[i+j] == w[j]) c++;
        }
        if(c==wl) y=1;
        else c=0;
    }

    if(y==1) printf("Yes\n");
    else printf("No\n");

    return 0;


}




Measured memory_bytes: 2752
N = int(input())
xyh = []

for i in range(N):
    x,y,h = map(int,input().split())
    xyh.append((x,y,h))
    if h > 0:
        ids = i

dct = 0
for cx in range(101):
    for cy in range(101):
        if dct:
            break
        dct = 1
        h = xyh[ids][2] + abs(xyh[ids][0]-cx) + abs(xyh[ids][1]-cy)
        
        for i in range(N):
            if xyh[i][2] != max(h - abs(xyh[i][0]-cx) - abs(xyh[i][1]-cy),0):
                dct = 0
                break

        if dct:
            print(cx,cy,h)  

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

using namespace std;

main(){
	while(true){
		int a,b;
		cin >> a >> b;
		if(a==0 && b==0){
			break;
		}
		for(int i = 0; i<a; i++){
			for(int h = 0; h<b; h++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
}


Measured memory_bytes: 3024
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-03 00:40:04
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  priority_queue<int> pq;

  while (1) {
    string s; cin >> s;
    if (s == "end") break;
    if (s == "insert") {
      int n; cin >> n;
      pq.push(n);
    } else {
      cout << pq.top() << '\n'; pq.pop();
    }
  }

  return 0;
}


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

// main.cpp

int main() {
  std::array<std::string, 3> c;
  std::copy_n(std::istream_iterator<std::string>(std::cin), 3, c.begin());
  std::cout << c[0][0] << c[1][1] << c[2][2] << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>

#define INF 1000000000000000000
using namespace std;
typedef long long ll;

const ll mod = 1000000007;

int main(){
	int n;
	ll p = 1LL;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		p *= (ll)i;
		p %= mod;
	}
	cout << p << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String a = scan.next();
		a= scan.next();
		String b= scan.next();
		if((Integer.parseInt(a)*10+Integer.parseInt(b))%4==0){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

}


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

using namespace std;


using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int64 T1, T2, A1, A2, B1, B2;
  cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

  if(A1 < B1) {
    swap(A1, B1);
    swap(A2, B2);
  }

  if(T1 * A1 + T2 * A2 == T1 * B1 + T2 * B2) {
    cout << "infinity" << endl;
    return 0;
  }

  int64 S = T1 * A1 + T2 * A2;
  int64 T = T1 * B1 + T2 * B2;
  if(S > T) {
    cout << 0 << endl;
    return 0;
  }

  // A1*T1*x+A2*T2*(x-1)>=B1*T1*x+B2*T2*(x-1)
  // (A1*T1+A2*T2)*x-(B1*T1+B2*T2)*x≧A2*T2-B2*T2

  int64 U = B2 * T2 - A2 * T2;
  if(U % (T - S) == 0) cout << U / (T - S) * 2 - 2 << endl;
  else cout << U / (T - S) * 2 - 1 << endl;
}




Measured memory_bytes: 256
from itertools import accumulate


def dijkstra(n, s, adj_list):
    # 始点sから各頂点への最短距離
    # n: 頂点数
    from heapq import heappush, heappop

    dists = [float('inf')] * n
    dists[s] = 0
    heap, rem = [(0, s)], n - 1

    while heap and rem:
        cost, src = heappop(heap)
        if dists[src] < cost:
            continue
        rem -= 1

        for dest, _cost in adj_list[src]:
            newcost = cost + _cost
            if dists[dest] > newcost:
                dists[dest] = newcost
                heappush(heap, (newcost, dest))

    return dists


N, M, S, T = map(int, input().split())
S -= 1
T -= 1
adj_yen = [[] for _ in range(N)]
adj_snuuk = [[] for _ in range(N)]
for _ in range(M):
    u, v, a, b = map(int, input().split())
    u -= 1
    v -= 1
    adj_yen[u].append((v, a))
    adj_yen[v].append((u, a))
    adj_snuuk[u].append((v, b))
    adj_snuuk[v].append((u, b))
yen_cost = dijkstra(N, S, adj_yen)
snuuk_cost = dijkstra(N, T, adj_snuuk)
ans = list(accumulate([10**15-yen-snuuk for yen, snuuk in zip(yen_cost, snuuk_cost)][::-1], max))[::-1]
print('\n'.join(map(str, ans)))


Measured memory_bytes: 87264
#include <stdio.h>
int main(){
    int r,d,x,i;
    int ret;
    int tmpx;
    scanf("%d %d %d",&r,&d,&x);
    tmpx = x;
    for(i=0;i<10;i++){
        tmpx = r * tmpx - d;
        printf("%d\n",tmpx);
    }

    return 0;
}


Measured memory_bytes: 128
function Main(input) {
  i = input.trim();
  if('Sunny' == i ) {
    console.log('Cloudy');
  } else if('Cloudy' == i){
    console.log('Rainy');
  } else {
    console.log('Sunny');
  }
  /*
  var weather = ['Sunny', 'Cloudy', 'Rainy'];
  var n = weather.indexOf(i);
  if(n == 2) {
    n = 0;
  } else {
    n++;
  }
  console.log(weather[n]);
  */

}
Main(require('fs').readFileSync('/dev/stdin', 'utf-8'));


Measured memory_bytes: 22084
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(A * N, B) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 55

int N;
int A[SIZE],B[SIZE],C[SIZE];

int main(){

	scanf("%d",&N);

	for(int i = 0; i < N; i++){

		scanf("%d",&A[i]);
		A[i]--;
	}

	for(int i = 0; i < N; i++){

		scanf("%d",&B[i]);
	}

	for(int i = 0; i < N-1; i++){

		scanf("%d",&C[i]);
	}

	int ans = 0;
	for(int i = 0; i < N; i++){

		ans += B[A[i]];

		if(i > 0 && A[i] == A[i-1]+1){

			ans += C[A[i-1]];
		}
	}

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

	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bytes"
	"fmt"
	"io"
	"os"
	"strings"
)

func main() {
	if false {
		test()
	} else {
		solve(os.Stdin, os.Stdout)
	}
}

func solve(r io.Reader, w io.Writer) {
	var n int // number of participants
	var m int // number of languages
	fmt.Fscanln(r, &n, &m)

	g := make(map[int][]int)

	for i := 0; i < n; i++ {
		var langs int
		fmt.Fscan(r, &langs)
		g[i] = make([]int, 0, langs)
		for j := 0; j < langs; j++ {
			var lang int
			fmt.Fscan(r, &lang)
			langi := n + lang - 1
			g[i] = append(g[i], langi)
			g[langi] = append(g[langi], i)
		}
	}

	seen := make([]bool, n+m)
	q := []int{0}
	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		if !seen[v] {
			seen[v] = true
			q = append(q, g[v]...)
		}
	}

	for i := 0; i < n; i++ {
		if !seen[i] {
			fmt.Fprintln(w, "NO")
			return
		}
	}
	fmt.Fprintln(w, "YES")
	return
}

func test() {
	tests := []struct {
		in   string
		want string
	}{
		{
			in: `4 6
3 1 2 3
2 4 2
2 4 6
1 6`,
			want: `YES
`,
		},
		{
			in: `4 4
2 1 2
2 1 2
1 3
2 4 3`,
			want: `NO
`,
		},
	}
	for i, tt := range tests {
		fmt.Printf("=== TEST %d\n", i)
		buf := new(bytes.Buffer)
		solve(strings.NewReader(tt.in), buf)
		if got := buf.String(); got != tt.want {
			fmt.Printf("%d: got %v, want %v\n", i, got, tt.want)
		}
	}
}


Measured memory_bytes: 18816
import bisect

A, B, Q = map(int, input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
X = [int(input()) for _ in range(Q)]

def distance(t, s, x):
    dis = abs(t-s) + min(abs(t-x), abs(s-x))
    return dis

def near_search(x, L):
    temp = bisect.bisect_left(L, x)
    if temp == len(L):
        can_f = L[-1]
        can_s = L[-1]
    elif temp == 0:
        can_f = L[0]
        can_s = L[0]
    else:
        can_f = L[temp-1]
        can_s = L[temp]
    return can_f, can_s

for x in X:
    s_f, s_s = near_search(x, S)
    t_f, t_s = near_search(x, T)
    total = min(distance(t_f, s_f, x), distance(t_s, s_f, x), distance(t_f, s_s, x), distance(t_s, s_s, x))
    print(total)

Measured memory_bytes: 16168
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	int sum = 0;
	vector<int> l(n);

	int MAX = 0;
	for (int i = 0; i < n; i++) {
		cin >> l[i];
		sum += l[i];
		MAX = max(MAX, l[i]);
	}

	if (MAX < sum - MAX) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = [0] * 100001
ans = 0
for i in range(N):
	if A[i] <= 100000:
		B[A[i]] += 1
	else:
		ans += 1
for i in range(100001):
	if B[i] < i:
		ans += B[i]
	else:
		ans += B[i] - i
print(ans)
	


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI acos(-1.0)
#define sq(n) (n)*(n)

using namespace std;
typedef long long ll;

int main() {
    FAST;

    ll n,k,sum=0;
    cin>>n>>k;
    ll a[1001];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(ll i=0;i<k;i++)
    {
        sum+=a[i];
    }
    cout<<sum<<endl;



    return 0;
}




Measured memory_bytes: 3664
import java.io.ByteArrayInputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    String INPUT = "";

    public static void main(String[] args) throws Exception {
        new Main().run();
    }

    void run() {
        Scanner sc = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(new ByteArrayInputStream(INPUT.getBytes()));
        PrintWriter out = new PrintWriter(System.out);

        solve(sc, out);
        out.flush();
    }

    void solve(Scanner sc, PrintWriter out) {
        int n, x;
        
        for (;;) {
        	n = sc.nextInt();
        	x = sc.nextInt();
        	if (n == 0 && x == 0) break;
        	int cnt = 0;
        	for (int i = 1; i <= n; i++) {
        		for (int j = i+1; j <= n; j++) {
        			for (int k = j+1; k <= n; k++) {
        				if (i+j+k == x) cnt++;
					}
				}
			}
			System.out.println(cnt);
		}
    }
}



Measured memory_bytes: 26520
a, b = gets.split.map(&:to_i)

def ans1(a, b)
  ans = (a / 0.08).ceil
  (ans * 0.1).floor == b ? ans : -1
end

def ans2(a, b)
  ans = (b / 0.10).ceil
  (ans * 0.08).floor == a ? ans : -1
end

ans = ans1(a, b)
ans = ans2(a, b) if ans == -1

puts ans


Measured memory_bytes: 3836
s=input()
k=int(input())
""" 
if s[0]=='1':
    print(s[0])
else:
"""
one_num=0

for i in range(len(s)):
    if s[i]=="1":
        one_num+=1
    else:
        break
if k<=one_num:
    print(1)#1 s[0]

elif one_num==0:
    #no one
    print(s[0])#2~9

else: #k>one_num
    print(s[one_num])







Measured memory_bytes: 3060
/*input
5
10 -4 -8 -11 3
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back

#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)

#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int raise(int a,int n,int m = MOD){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int floor1(int n,int k){
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}

int ceil1(int n,int k){
    return floor1(n+k-1,k);
}

void solve(){
     int minus = 0;
     int n;
     int sum = 0;
     int minn = INF;
     cin >> n;
     RE(i,n){
       int x;cin >> x;
       minn = min(minn,abs(x));
       sum += abs(x);
       minus += (x < 0);
       minus%=2;
     }
     //cout << sum << " " << minn <<endl;
     if(minus)cout << sum-2*minn;
     else cout << sum;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
  return 0;
}

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

using namespace std;
const int N = 1e5 + 2;
int k, a[N];

long long last(long long x) {
   for(int i = 1; i <= k; ++i) {
      x = x - (x % a[i]);
   }
   return x;
}
int main() {
  // freopen("J.in", "r", stdin);
   cin >> k;
   for(int i = 1; i <= k; ++i)cin >> a[i];

   long long st = 1, dr = 1e16, ans1 = -1, ans2 = -1;
   while(st <= dr) {
      auto mid = (st + dr) >> 1;
      if(last(mid) <= 2) {
         ans1 = mid;
         st = mid + 1;
      } else dr = mid - 1;
   }


   st = 1;
   dr = 1e16;
   while(st <= dr) {
      auto mid = (st + dr) >> 1;
      if(last(mid) >= 2) {
         ans2 = mid;
         dr = mid - 1;
      } else st = mid + 1;
   }
   if(ans1 == -1 || last(ans1) != 2)cout << -1;
   else cout << ans2 << ' ' << ans1;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

long N, T;
// 所要時間, 満足度
vector<pair<long, long>> dishes;

void solve() {
  cin >> N >> T;
  rep (i, N) {
    long A, B;
    cin >> A >> B;
    dishes.push_back(make_pair(A, B));
  }
  sort(dishes.begin(), dishes.end());
  map<long, long> mp;
  mp[0] = 0;
  rep (i, N) {
    for (auto it = mp.rbegin(); it != mp.rend(); it++) {
      if (it->first >= T) continue;
      long next_time = it->first + dishes[i].first;
      long next_manzoku = it->second + dishes[i].second;
      mp[next_time] = max(mp[next_time], next_manzoku);
    }
  }
  long ans = 0;
  for (auto it: mp) ans = max(ans, it.second);
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 640
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val ab = (0 until m).map { sc.next().toInt() to sc.next().toInt() }
    println(problem075c(n, m, ab))
}

fun problem075c(n: Int, m: Int, ab: List<Pair<Int, Int>>): Int {
    var count = 0
    for (i in 0 until m) {
        val routes = Array(n) { mutableListOf<Int>() }
        for (j in 0 until m) {
            if (i == j) continue
            val (a, b) = ab[j]
            routes[a - 1].add(b - 1)
            routes[b - 1].add(a - 1)
        }
        if (routes.find { it.isEmpty() } != null) {
            count++
            continue
        }

        val visited = Array(n) { false }
        val queue = ArrayDeque<Int>()
        queue.offer(routes[0][0])
        visited[routes[0][0]] = true
        while (!queue.isEmpty()) {
            val current = queue.poll()
            for (k in 0 until routes[current].size) {
                val next = routes[current][k]
                if (visited[next]) continue
                visited[next] = true
                queue.offer(next)
            }
        }
        if (visited.count { !it } != 0) count++
    }
    return count
}

Measured memory_bytes: 31264
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
////////////////////////////////////////

int main() {
	ll X, Y;
	cin >> X >> Y;
	ll ans = 0;
	while (X <= Y) {
		ans++;
		X *= 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  int n,k;
  cin >> n >> k;

  int mx=(n-1)*(n-2)/2;
  if(mx<k){
    puts("-1");
    return 0;
  }
  vector<pii> ans;
  rep(i,n-1){//ウニを作る，頂点nを真ん中とする
    ans.pb(pii(i+1,n));//i->n
  }
  int add=mx-k;//追加する辺の数
  vector<pii> edge;//辺の候補
  rep(i,n-1)rep(j,i) edge.pb(pii(i+1,j+1));
  rep(i,add) ans.pb(edge[i]);
  cout << ans.size() << endl;
  rep(i,sz(ans)){
    cout << ans[i].fi << " " << ans[i].se << endl;
  }
  return 0;
}


Measured memory_bytes: 384
N, K = map(int, input().split())
arr = list(map(int, input().split()))

ans =[]
if arr[0]>0:
    ans.append(arr[K-1])

if arr[-1]<0:
    ans.append(abs(arr[-1*(K)]))

for i in range(N-K+1):
    if arr[i]*arr[i+K-1]<=0:
        left =2*abs(arr[i])+abs(arr[i+K-1])
        right=2*abs(arr[i+K-1])+abs(arr[i])
        ans.append(min(left,right))

print(min(ans))

Measured memory_bytes: 86584
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <string>
#include <numeric>
#include <functional>
using namespace std;

int main()
{
	int N, M;
	int res = 0;
	cin >> N >> M;
	vector<int> K(N);
	vector<vector<int>> A(N);
	vector<int> cnt(M);
	for (int i = 0;i < N;i++) {
		cin >> K[i];
		A[i].resize(K[i]);
		for (int j = 0;j < K[i];j++) {
			cin >> A[i][j];
		}
	}

	for (int i = 1;i <= M;i++) {
		for (int j = 0;j < N;j++) {
			for (int k = 0;k < K[j];k++) {
				if (A[j][k] == i) {
					cnt[i - 1]++;
					if (cnt[i - 1] == N) {
						res++;
					}
				}
			}
		}
	}
	cout << res << endl;
}


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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll A; cin >> A;
    long double B; cin >> B;
    long double ans=A*B;
    cout << (ll)ans << endl;
}


Measured memory_bytes: 3708
import java.util.*;


public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int count = 0;
        String str = sc.next();
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == '1') {
                count++;
            }
        }
        System.out.println(count);
    }
}

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

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll powMod(ll a, ll b) {
    if (b == 0) {
        return 1;
    } else if (b & 1) {
        return a * powMod(a, b - 1) % MOD;
    } else {
        ll half = powMod(a, b / 2);
        return half * half % MOD;
    }
}

ll calcComb(ll n, ll k) {
    if (k > n - k) {
        return calcComb(n, n - k);
    } else {
        ll ansMul = 1;
        ll ansDiv = 1;
        for (ll i = 0; i < k; ++i) {
            ansMul *= (n - i);
            ansDiv *= (k - i);
            ansMul %= MOD;
            ansDiv %= MOD;
        }
        ll ans = ansMul * powMod(ansDiv, MOD - 2) % MOD;
        return ans;
    }
}

int main() {
    ll n, m;
    cin >> n >> m;
    ll mcp = m;
    ll ans = 1;
    for (ll i = 2; i * i <= mcp; ++i) {
        if (mcp % i == 0) {
            ll cnt = 0;
            while (mcp % i == 0) {
                ++cnt;
                mcp /= i;
            }
            ans *= calcComb(n + cnt - 1, n - 1);
            ans %= MOD;
        }
    }
    if (mcp != 1) {
        ans *= calcComb(n + 1 - 1, n - 1);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;

using namespace std;

int main(){
    string s; cin >> s;
    sort(s.begin(), s.end());
    if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
ll inf = 1e18;
ll MAX = (1 << 18);
int n,m;
pair<pair<ll,ll>,ll> p[100010];
ll seg[1 << 18];

void input() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> p[i].fi.se >> p[i].fi.fi >> p[i].se;
    }
}

void insert(int a, ll b) {
    int now = a + (1 << 17);
    while (now > 0) {
        seg[now] = min(seg[now], b);
        now /= 2;
    }
}

ll mi(int left, int right) {
    left += (1 << 17);
    right += (1 << 17);
    ll ret = inf;
    while (left < right) {
        if (right % 2 == 0) {
            ret = min(ret, seg[right]);
            right--;
        }
        if (left % 2 != 0) {
            ret = min(ret, seg[left]);
            left++;
        }
        left /= 2;
        right /= 2;
    }
    if (left == right) {
        ret = min(ret, seg[left]);
    }
    return ret;
}

void solve() {
    sort(p,p+m);
    for (int i = 0; i < (1 << 18); i++) {
        seg[i] = inf;
    }
    insert(1,0);
    for (int i = 0; i < m; i++) {
        // cout << p[i].fi.se << " " << p[i].fi.fi << " " << p[i].se << endl;
        ll mii = mi(p[i].fi.se,p[i].fi.fi);
        mii += p[i].se;
        insert(p[i].fi.fi,mii);
    }
    if (seg[n + (1 << 17)] == inf) {
        cout << -1 << endl;
    } else {
        cout << seg[n + (1 << 17)];
    }
}

int main(int argc, char *argv[]) {
    input();
    solve();
    return 0;
}


Measured memory_bytes: 4608
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int dp[2][100005];

int main() {
	int n, m, k;
	while(cin >> n >> m >> k) {
		if(n == 0 && m == 0 && k == 0) break;

		memset(dp, 0, sizeof(dp));
		REP(j, 1, m + 1) {
			dp[1][j] = 1;
		}

		rep(i, n) {
			rep(j, 100005) {
				if(dp[i & 1][j] == 0) continue;
				REP(k, 1, m+1) {
					dp[(i+1)&1][j+k] += dp[i&1][j];
				}
				dp[i&1][j] = 0;
			}
		}

		double ans = 0, t = 1;
		rep(i, n) {
			t *= m;
		}

		rep(j, 100005) {
			if(dp[n&1][j] == 0) continue;

			double l = j - k;
			if(l <= 0) l = 1;
			ans += (dp[n & 1][j] / t) * l;
		}

		cout << fixed;
		cout.precision(20);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 2020
import Data.List
import Control.Applicative

main = do
  [k,s] <- map read . words <$> getLine
  print $ sum $ (`map` [max 0 (s-k-k)..min k (s-0-0)])
   $ \x -> 1 - max 0 (s-x-k) + min k (s-x-0)
                


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
bool ok[10];

bool cheak(int n){
    bool ret = true;
    while(n>0){
        if(!ok[n%10])ret=false;
        n/=10;
    }
    return ret;
}
void solve(ll N, long long K, std::vector<long long> D){
    rep(i,10)ok[i]=true;
    rep(i,K)ok[D[i]]=false;
    REP(i,N,10*N){
        if(cheak(i)){
            cout<<i<<endl;
            break;
        }
    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    ll N;
    cin>>N;
    long long K;
    scanf("%lld",&K);
    std::vector<long long> D(K);
    for(int i = 0 ; i < K ; i++){
        scanf("%lld",&D[i]);
    }
    solve(N, K, std::move(D));
    return 0;
}


Measured memory_bytes: 256
int main(int argc, char** argv){
  int k, s;
  int x, y, z, ans = 0;
  
  scanf("%d %d\n", &k, &s);
  for (x=0; x<=k; x++) {
    for (y=0; y<=k; y++) {
      z = s - x - y;
      if ( (z>=0) && (z<=k) ) {
        ans++;
      }
    }
  }
  printf("%d", ans);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

ll N,M,V,P;
VL A;
bool solve(ll mid){
  if(mid==N) return false;
  if(mid<P) return true;
  if(A[mid]+M<A[P-1]) return false;
  ll sum=(P+N-mid-1)*M;
  rep(i,mid-P+1) sum+=A[mid]+M-A[P-1+i];
  if(sum>=M*V) return true;
  return false;
}

int main(){
  cin>>N>>M>>V>>P;
  ll B;
  rep(i,N){
    cin>>B;
    A.pb(B);
  }
  sort(all(A),greater<ll>());
  ll ng=N;
  ll ok=0;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    if(solve(mid)) ok=mid;
    else ng=mid;
  }
  cout<<ok+1<<endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int k;
	cin >> k;
	ll res = 0;
	rep(i,1,k+1)rep(j,1,k+1)rep(r,1,k+1)res += __gcd(i,__gcd(j,r));
	cout << res << '\n';
}


Measured memory_bytes: 3648
n,m=map(int,input().split())
h=list(map(int,input().split()))
ab=[list(map(int,input().split())) for i in range(m)]

ans=[1 for i in range(n)]

for i in range(m):
    aa=ab[i][0]-1
    bb=ab[i][1]-1
    if h[aa]>h[bb]:
        ans[bb]=0
    elif h[aa]<h[bb]:
        ans[aa]=0
    else:
        ans[aa]=0
        ans[bb]=0

print(sum(ans))

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

using namespace std;

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   int a,b,c;
   cin >> a >> b >> c;
   if((c >= a && c <= b) || (c >= b && c <= a))cout << "Yes";
   else cout << "No";
   return 0;
}

Measured memory_bytes: 256
def shuffle(x, cnt, sum)
  ret = []
  while sum + $cards[cnt][2] < x
    ret << $cards[cnt]
    sum += $cards[cnt][2]
    cnt += 1
  end
  t, b, len = $cards[cnt]
  len1 = x - sum
  m = t - 1 + len1
  ret << [t, m, len1]
  sum += len1
  if len1 < len
    $cards[cnt] = [m+1, b, len - len1]
  else cnt += 1
  end
  [ret, cnt, sum]
end

def shuffle2(x, y)
  btm, cnt, sum = shuffle(x, 0, 0)
  mid, cnt, sum = shuffle(y, cnt, sum)
  $cards[cnt..-1] + mid + btm
end

while true
  n = gets.to_i
  break if n == 0
  m = gets.to_i
  p, q, r = gets.split.map(&:to_i)
  $cards = [[1,n,n]]
  m.times do 
    x, y = gets.split.map(&:to_i)
    $cards = shuffle2(x, y)
  end
  top, cnt, sum = shuffle(p-1, 0, 0)
  mid, cnt, sum = shuffle(q, cnt, sum)
  ret = 0
  for cds in mid
    if cds[0] <= r
      ret += (cds[1] <= r ? cds[1] : r) - cds[0] + 1
    end
  end
  p ret
end

Measured memory_bytes: 88792
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int cou = 0;
  int ans = 0;
  string T ="AGCT";
  for(int i=0;i<S.size();i++){
    bool isAGCT = false;
    for(int j=0;j<4;j++){
      if(S.at(i) == T.at(j)) isAGCT = true;
    }
    if(!isAGCT) cou = 0;
    else{
      cou++;
      ans= max(cou, ans);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto A = RD-1;
	auto B = RD-1;
	auto C = RD-1;
	auto D = RD-1;
	auto S = RD!string;

	bool ans;
	if (C > D)
	{
		foreach (i; B..D+1)
		{
			if (i >= N-1) break;
			if (S[i] == '.' && S[i-1] == '.' && S[i+1] == '.')
			{
				ans = true;
				break;
			}
		}
	}
	else
	{
		ans = true;
	}

	foreach (i; A..C)
	{
		if (S[i] == '#' && S[i+1] == '#')
		{
			ans = false;
			break;
		}
	}
	foreach (i; B..D)
	{
		if (S[i] == '#' && S[i+1] == '#')
		{
			ans = false;
			break;
		}
	}

	writeln(ans ? "Yes" : "No");
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, j, n) for (int i = int(j); i < (int)(n); i++)
#define repll(i, j, n) for (ll i = ll(j); i < (ll)(n); i++)
#define repback(i, n, k) for (int i=int(n); i >= (int)(k); --i)
typedef long long ll;

int main() {
    ll W, H, x, y;
    cin >> W >> H >> x >> y;
    if((x == (double)W/2.0) and (y == (double)H/2.0)) {
        printf("%lf %d", double(W)*double(H)/2.0, 1);
    } else {
        printf("%lf %d", double(W)*double(H)/2.0, 0);
    }
    return 0; 
}

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

typedef long long ll;


int main(){
  int n, q;
  cin >> n;
  vector<int> S(n);
  for(int i=0;i<n;i++)
    cin >> S.at(i);
  cin >> q;
  vector<int> T(q);
  for(int i=0;i<q;i++)
    cin >> T.at(i);


  int count;
  for(int t :T){
    for(int s:S){
      if(s == t){
        count++;
        break;
      }
    }
  }
  cout << count << endl;



}



Measured memory_bytes: 3120
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n,dp[22][2100000],m;
bool a[22][22];
int main(){
	cin>>n;
	m=1;
	for(int i=1;i<=n;i++)
		m*=2;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			cin>>a[i][j];
	for(int i=1;i<=n;i++)
		if(a[1][i])
			dp[1][(1<<(i-1))]=1;
	for(int i=2;i<=n;i++)//21
		for(int j=0;j<m;j++)//2^21
			if(__builtin_popcount(j)==i)
				for(int k=1;k<=n;k++)//21
					if(a[i][k]&&(j&(1<<(k-1))))
						dp[i][j]=(dp[i][j]+dp[i-1][j^(1<<(k-1))])%mod;
	cout<<dp[n][m-1];
	return 0;
}

Measured memory_bytes: 162048
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	b , c = IN()
	s = list(range(c-b+1,c+b-1+1))
	print(' '.join([str(c) for c in s]))
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
using namespace std;
int a[200005];
void insertionSort(int *arr, int n) {
	for (int i = 1; i <= n - 1; i++) {
		int v = arr[i];//记录当前元素的值
		int j = i - 1;
		while (j >= 0 && arr[j] > v) {//将当前元素之前的所有元素视为已排好的数组
			arr[j + 1] = arr[j];		//根据当前值的大小找到当前值的位置
			j--;
		}
		arr[j + 1] = v; //并将当前值插入数组中
		for (int i = 0; i < n - 1; i++)
			cout << arr[i] << " ";
		cout << arr[n - 1] << endl;
	}
}
int main()
{

	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n - 1; i++)
		cout << a[i] << " ";
	cout << a[n - 1] << endl;
	insertionSort(a, n);
	return 0;
}


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

#define ll long long
#define mii make_pair<int ,int>
#define mll make_pair<ll, ll>
#define pii pair<int ,int>
#define pll pair<ll, ll>
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define vi vector <int>
#define vvi vector <vector <int> >
#define vl vector <ll>
#define vvl vector <vector <ll> >
#define vb vector <bool>
#define vvb vector <vector <bool> >

bool cmp(int a, int b)
{
    return a > b;
}

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

    int n, m;
    double sum = 0;
    cin >> n >> m;
    vector <double> a(n);
    rep(i, 0, n)
    {
        cin >> a[i];
        sum += a[i];
    }
    sort(a.begin(), a.end(), cmp);

    double s = sum / (4 * (double)m);
    if (a[m - 1] < s)
        cout << "No";
    else
        cout << "Yes";

}


Measured memory_bytes: 256
#include<stdio.h>
#define rep(a,b) for(int i = a;i <= b;i++)

int main(void){
  int N,M; scanf("%d%d",&N,&M);
  int A[110]; rep(1,N){scanf("%d",&A[i]);}
  long int SUM = 0; rep(1,N){SUM += A[i];}

  int cnt = 0; rep(1,N){if(A[i]*4*M >= SUM){cnt += 1;}}

  if(cnt >= M){printf("Yes");}
  else{printf("No");}

  return 0;
}


Measured memory_bytes: 128