akhauriyash/Code-Regression huggingface dataset:
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fucking interest
*******************************
Higher, higher, even higher, to the point you won’t even be able to see me
https://www.a2oj.com/Ladder16.html
*******************************
300IQ as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int X = Integer.parseInt(st.nextToken());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         HashSet<Integer> set = new HashSet<Integer>();
         for(int x: arr)
            set.add(x);
         if(!set.contains(X))
            System.out.println(X);
         else
         {
            for(int d=1; d <= 1000; d++)
            {
               int val = X-d;
               if(!set.contains(val))
               {
                  System.out.println(val);
                  return;
               }
               val = X+d;
               if(!set.contains(val))
               {
                  System.out.println(val);
                  return;
               }
            }
         }
      }
   }

Measured memory_bytes: 32668
#include <iostream>
#include <sstream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <iomanip>
#include <functional>
#include <array>
#include <climits>

using namespace std;
using ll = long long;
const ll MOD = (ll)1e9 + 7;

ll a[51] = { 1 };
ll p[51] = { 1 };

ll f(ll n, ll x)
{
    if (n == 0)
    {
        return x <= 0 ? 0 : 1;
    }
    else if (x <= 1 + a[n - 1])
    {
        return f(n - 1, x - 1);
    }
    else
    {
        return p[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1]);
    }
}

int main()
{
    ll n, x;
    cin >> n >> x;

    for (ll i = 1; i <= n; i++)
    {
        a[i] = a[i - 1] * 2 + 3;
        p[i] = p[i - 1] * 2 + 1;
    }

    ll sum = f(n, x);
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 384
fun main(args: Array<String>) {
    val n = readLine()!!
    val list = readLine()!!.split(" ").map(String::toInt).toMutableList()
    var num = 0
    var breakFrag = false
    while(true) {
        num += 1
        for((index, value) in list.withIndex()) {
            if(value % 2 == 0) {
                list[index] = value / 2
            } else if(value % 2 != 0) {
                breakFrag = true
                num -= 1
                break
            }
        }
        if(breakFrag) {
            break
        }
    }
    print(num)
}

Measured memory_bytes: 37736
rooms = [[[0]*10 for _ in range(3)] for _ in range(4)]

n = int(input())
for i in range(n):
    b, f, r, v = [int(j) for j in input().split()]
    rooms[b-1][f-1][r-1] += v
for b in range(4):
    for f in range(3):
        print(" " + " ".join([str(i) for i in rooms[b][f]]), end="")
        print()
    if b < 3:
        print("#" * 20)


Measured memory_bytes: 5608
using System;
using System.Collections.Generic;
using System.Linq;

class MainClass
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var str = Console.ReadLine()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
            .Select(x =>
            {
                var num = int.Parse(x);
                var count = 0;
                var before = num;
                while (true)
                {
                    if (before % 2 == 0)
                    {
                        count++;
                        before = before / 2;
                    }
                    else
                    {
                        break;
                    }
                }
                return count;
            })
            .ToList();
        Console.WriteLine(str.Sum());
        Console.ReadLine();
    }
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

bool f(int x) {
  for (int i=2; i*i<=x; i++) {
    if (x%i==0) return false;
  }
  return true;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  int x; cin>>x;
  while (!f(x)) x++;
  cout<<x;
  

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
vector<int> V;
void dfs(int n, int bits) {
    if (n == 0) {
        V.push_back(bits);
        return;
    }
    if ((bits&1) != 1) dfs(n-1, (bits<<1) + 1);
    dfs(n-1, bits<<1);
}
void Main(){
    int H = read(), W = read(), K = read(), mod = 1e9+7;
    if (W == 1) {
        printf("1\n");
        return;
    }
    int_fast64_t dp[H+1][W] = {};
    dp[0][0] = 1;
    dfs(W-1, 0);
    for (int i = 1; i<=H; i++) {
        for (auto v:V) {
            for (int j = 0; j<W; j++) {
                if ((v>>j)&1) dp[i][j] += dp[i-1][j+1];
                else if ((v>>(j-1))&1) dp[i][j] += dp[i-1][j-1];
                else dp[i][j] += dp[i-1][j];
                dp[i][j] %= mod;
            }
        }
    }
    printf("%lld\n", dp[H][K-1]);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct E {
  int to, index;
};
using G = vector<vector<E>>;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vi d(n);
  REP(i, n) cin >> d[i];
  G g(n);
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back({b, (int)i});
    g[b].push_back({a, (int)i});
  }
  vi wei(m, -1);
  vi col(n, -1);
  {
    int cnt = 0;
    int mi = *min_element(ALL(d));
    REP(i, n) if (d[i] == mi) cnt++;
    if (cnt == 1) {
      cout << -1 << endl;
      return 0;
    }
    vi ok(n);
    REP(i, n) for (auto e : g[i]) {
      if (d[i] == mi && d[e.to] == mi) {
        ok[i] = 1;
        ok[e.to] = 1;
        wei[e.index] = mi;
        if (col[i] == -1 && col[e.to] == -1) {
          col[i] = 0;
          col[e.to] = 1;
        } else if (col[i] == -1) {
          col[i] = 1 - col[e.to];
        } else if (col[e.to] == -1) {
          col[e.to] = 1 - col[i];
        }
      }
    }
    REP(i, n) {
      if (d[i] == mi && ok[i] == 0) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  int mi = *min_element(ALL(d));
  auto cmp = [&](int a, int b) { return d[a] > d[b]; };
  priority_queue<int, vi, decltype(cmp)> q(cmp);
  REP(i, n) {
    if (d[i] > mi)
      q.push(i);
  }
  while (!q.empty()) {
    int p = q.top();
    q.pop();
    if (col[p] != -1)continue;
    bool ok = false;
    for (auto e : g[p]) {
      if (col[e.to] != -1) {
        col[p] = 1 - col[e.to];
        wei[e.index] = d[p];
        ok = true;
        break;
      }
    }
    if (!ok) {
      for (auto e : g[p]) {
        if (d[e.to] == d[p]) {
          col[p] = 0;
          col[e.to] = 1;
          wei[e.index] = d[p];
          ok = true;
          break;
        }
      }
    }
    if (!ok) {
      cout << -1 << endl;
      return 0;
    }
  }
  REP(i, n) { cout << "BW"[col[i]]; }
  cout << endl;
  REP(i, m) {
    if (wei[i] == -1)
      cout << INF - 1 << endl;
    else
      cout << wei[i] << endl;
  }
}


Measured memory_bytes: 14200
def main():
    s = input()
    ans = list(input())
    s = reversed(s)
    for si in s:
        if si == "C":
            ans = ans[1:] + [ans[0]]
        if si == "J":
            ans = [ans[-1]] + ans[:-1]
        if si == "E":
            tmp = [ans[len(ans) // 2]] if len(ans) & 1 else []
            ans = ans[len(ans) // 2 + (len(ans) & 1):] + tmp + ans[: len(ans) // 2]
        if si == "A":
            ans = ans[::-1]
        if si == "M":
            for i in range(len(ans)):
                if ans[i].isdecimal():
                    ans[i] = int(ans[i])
                    ans[i] = str((ans[i] + 1) % 10)
        if si == "P":
            for i in range(len(ans)):
                if ans[i].isdecimal():
                    ans[i] = int(ans[i])
                    ans[i] = str((ans[i] - 1) % 10)

    print("".join(ans))



if __name__ == "__main__":
    for _ in range(int(input())):
        main()


Measured memory_bytes: 5608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

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

#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define vin(v, N) vi v; rep(i, N) {int x; cin >> x; v.push_back(x);}
#define vout(v, N) rep(i, N) {cout << v[i] << " ";} cout << endl;

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

const int MAX_N = 2e5 + 5;

void solve() {
    ll N, x, M;
    cin >> N >> x >> M;
    unordered_map<ll, ll> map;
    ll ans = x;
    map[x] = 0;
    for (ll i = 1; i < N; i++) {
        x = (x * x) % M;
        if (map.find(x) != map.end()) {
            ll n = i - map.find(x)->second;
            ll t = (N - i) / n;
            ll remain = (N - i) % n;
            ll s=0;
            rep(j, n) {
                if (j < remain) {
                    ans += x;
                }
                s += x;
                x = (x * x) % M;
            }
            ans += s * t;
            cout << ans;
            return;
        }
        map[x] = i;
        ans += x;
    }
    cout << ans;
}

//#define LOCAL 1

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();

    return 0;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

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

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


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

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

int main() {
    ll N; cin >> N;

    ll ans=0;
    for(ll i=1 ; i <= sqrt(N); i++){
        if(N % i == 0){
            if(i!=1) if(N / (i-1) == N % (i-1)) ans += i-1;
            if(N/i!=1) if(N / (N/i-1) == N % (N/i-1)) ans += N/i-1;
        }
    }

    pl(ans)

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> v(n);
  for (int i = 0; i < n; i++) cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end());
  for (auto p : v) cout << p.first << " " << p.second << endl;
  return 0;
}


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

int main()
{
    long long int a,b,c;
    cin >> a >> b >> c;
    set<long long int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    if(s.size()==2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
//A,Elebereth Gilthoniel mantae!
//For Temeria!
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<cstdio>
#include<map>
#include<stack>
#include<queue>
#include<cstring> 
using namespace std;;
char s[500008];int nxt[500008];int n; int dp[500008];int op;
int main()
{
	cin>>n;scanf("%s",&s);nxt[n]=n;
	for(int i=n-1;i>=0;i--)
	{
		nxt[i]=nxt[i+1];if(s[i]=='0') nxt[i]=i;else op++;
	}
	for(int i=0;i<=n;i++) dp[i]=n+233;dp[0]=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='0')
		{
			dp[i+1]=min(dp[i],dp[i+1]);
			continue;
		}
		dp[i+1]=min(dp[i]+1,dp[i+1]);
		if(s[i+1]=='0')
		{
			for(int j=i+2;j<n;j++)
			{
				if(s[j]=='0')
				{
					break;
				}
				dp[j+1]=min(dp[i]+1,dp[j+1]);
			}
		}
		else
		{
			if(s[nxt[i]+1]=='1')dp[nxt[i]+1+1]=min(dp[i]+1,dp[nxt[i]+1+1]);
		}
	}
	cout<<op-dp[n];
	return 0;
}

Measured memory_bytes: 4608
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef pair<int, pi> pii;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define fax(i, a) for (int i = 0; i < (a); i++)
#define f0x(i, a, b) for (int i = (a); i < (b); i++)
#define faxd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define f0xd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define memeset memset

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 200005;
const ld PI = 4*atan((ld)1);

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
vector<int> adj[MX]; bool vis[MX];
void dfs(int v){
	vis[v] = true;
	for(int e : adj[v]){
		if(!vis[e]){
			dfs(e);
		}
	}
}
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
	int n,m; cin >> n >> m;
	ll ans = 0;
	fax(i,m){
		int u,v,w; cin >> u >> v >> w;
		u--; v--;
		adj[u].pb(v); adj[v].pb(u);
	}
	fax(i,n){
		if(!vis[i]){
			dfs(i);
			++ans;
		}
	}
	cout << ans;
}


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

int main(){
	int a,b,h,m; cin >> a >> b >> h >> m;
  	double hx,hy,sx,sy;
  	double pi=M_PI;
  	hx=a * cos(pi/2 - pi*h/6 - pi*m/360);
    hy=a* sin(pi/2 - pi*h/6 - pi*m/360);
  	sx=b* cos(pi/2 - pi*m/30);
  	sy = b*sin(pi/2 - pi*m/30);
  	double ans= sqrt(pow(hx-sx,2.0)+pow(hy-sy,2.0));
  	cout << fixed << setprecision(20) << ans << endl;
}


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

total = N * M

sumi = 4
if N >= 2 and M >= 2:
    hen = (N-2) * 2 + (M-2) * 2
    ans = total - sumi - hen
elif N == 1 and M > 1:
    hen = M-2
    ans = hen
elif N > 1 and M == 1:
    hen = N - 2
    ans = hen
else:
    ans = 1


print(ans)





Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <queue>
using namespace std;

int pathLength(int N, string bookState);

int main(){
    int testNum, N;
    string bookState;
    cin>>testNum;
    
    queue<int> result;
    
    for (int i = 1; i <= testNum; i++) {
        cin>>N>>bookState;
        result.push(pathLength(N, bookState));
    }
    
    for (int i = 1;  i <= testNum; i++) {
        printf("%d\n",result.front());
        result.pop();
    }
    
}

int pathLength(int N, string bookState){
    int steps[N + 1], length = 0;
    int upperShelf[ 2 * N + 2 ], lowerShelf[ 2 * N + 2 ];
    int down = -1, up = -1;
    int sum;
    
    upperShelf[0] = 0, upperShelf[2*N + 1] = 0, lowerShelf[0] = 0, lowerShelf[2*N +1] = 0;
    
    for (int i = 1; i <= 2 * N; i++) {
        if(bookState[i - 1] == 'Y')
            upperShelf[i] = 1;
        else
            upperShelf[i] = 0;
        
        if(bookState[i - 1 + 2 * N] == 'Y')
            lowerShelf[i] = 1;
        else
            lowerShelf[i] = 0;
        
    }
    
    for (int i = 0; i <= N; i++) {
        sum = (upperShelf[2*i] || upperShelf[2*i+1]) + (lowerShelf[2*i] || lowerShelf[2*i+1]);
        if (sum == 0) {
            steps[i] = 0;
        }
        else if (sum == 1){
            steps[i] = 1;
        }
        else
            steps[i] = 2;
    }
    
    for (int i = 0; i <= N; i++) {
        if (steps[i] > 0) {
            down = i;
            break;
        }
    }
    
    for (int i = N; i >= 0; i--) {
        if (steps[i] > 0) {
            up = i;
            break;
        }
    }
    
    if (down == up) {
        if (down >= 0) {
            if ((lowerShelf[2*down] || lowerShelf[2*down+1]) == 1) {
                steps[down] = 3;
            }
        }
    }
    else{
        if ((lowerShelf[2*down] || lowerShelf[2*down+1]) == 1 && (upperShelf[2*down] || upperShelf[2*down+1]) == 0) {
            steps[down] = 2;
        }
        if ((lowerShelf[2*up] || lowerShelf[2*up+1])==1 && (upperShelf[2*up] || upperShelf[2*up+1])==0) {
            steps[up] = 2;
        }
    }
    
    for(int i = 0; i <= N; i++){
        length += steps[i];
    }
    return length + N;
}

Measured memory_bytes: 3508
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]
#![allow(clippy::suspicious_arithmetic_impl)]

// using Rust(1.42.0)
// My Library Repo is at "https://github.com/Loptall/prcn_lib"
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"

/*
    AtCoder Language Update 2020204 お疲れ様でした! 有難いです
*/

// Dep crates are...
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::{i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_integer::{binomial, gcd, lcm, Integer};
use permutohedron::Heap;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

// code...
fn main() {
    input! {
        k: usize,
        a: usize, b: usize
    }

    let mut ans = "NG";
    for i in a..=b {
        if i % k == 0 { ans = "OK" }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2136
import java.math.BigDecimal;
import java.util.*;

public class Main {


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

       int a = sc.nextInt();
       int b = sc.nextInt();

        if((a + b) % 2  != 0){
            System.out.println("IMPOSSIBLE");
        } else {
            System.out.println((a + b) / 2);
        }

    }


}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define INF 1LL<<60
#define pi 3.14159265358979323846
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}

int main(){
    ll a,b;cin>>a>>b;
    ll ans;
    if(a<=0 && 0<=b){ans=0;}
    else if(a>0 && b>0){ans=1;}
    else{
        if((b-a+1)%2==0){ans=1;}
        else{ans=-1;}
    }

    if(ans==0){cout<<"Zero"<<endl;}
    if(ans==1){cout<<"Positive"<<endl;}
    if(ans==-1){cout<<"Negative"<<endl;}

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return sorted 約数s 1 <= x <= n
vector<ll> divv(ll n) {
  vector<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.push_back(i);
      if(i*i != n) v.push_back(n/i);
    }
  }
  sort(ALL(v));
  return v;
}

bool chk(string &s, ll a,ll b){
    fr(i,a - 1, b - 1){
        auto j = i +1;
        if(s[i] == '#' && s[j]== '#') {
            return false;
        }
    }
    return true;
}

int main() {
    ll n,x,m;
    cin>>n>>x>>m;
    pr(min(n+x,min(x+m,m+n)));

    
    return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  
  int res = 1;
  for(int i=0; i<n; i++){
    if(res*2 <= res+k){
      res = res*2;
    }else{
      res = res+k;
    }
  }
  
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
	int W, a, b;
  	cin >> W >> a >> b;
    
    if(a>b){ swap(a,b); }
	if(a+W>=b){ cout << 0 << endl; return;}
    else{ cout << b-a-W << endl; return;}
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int main() {
	ll a[3];
	REP(i, 3) cin >> a[i];
	
	sort(a, a + 3);
	
	ll ans = 1ll<<60;
	do {
		if (a[0] % 2 == 0) ans = 0;
		chmin(ans, a[1] * a[2]);
	} while (next_permutation(a, a + 3));
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
M,K = list(map(int,input().split()))

if M==0:
    if K==0:
        print("0 0")
    else:
        print(-1)
elif M==1:
    if K==0:
        print("0 0 1 1")
    else:
        print(-1)
else:
    if K==0:
        ans = []
        for i in range(2**M):
            ans.append(i)
            ans.append(i)
        #ans = list(map(str,ans))
        print(*ans)
    elif K<2**M:
        ans = [0,K,0]
        ansc = []
        for i in range(1,2**M):
            if i!=K:
                ansc.append(i)
                
        ans =ans+ansc + [K] +ansc[::-1]
        #ans = list(map(str,ans))
        print(*ans)
    else:
        print(-1)

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

class Info
{
    private:
        int co_cnt, unco_cnt, pena;
    public:
        Info();
        int getCcnt() { return co_cnt; }
        int getPena() { return pena; }
        void wrongProcessing() { unco_cnt++; }
        void correctProcessing( int time );
};

class Sum
{
    private:
        int correct_sum;
        int pena_sum;
        int team;
    public:
        Sum() { correct_sum = 0; pena_sum = 0; team = 0; };
        int getCorrectSum(){ return correct_sum; }
        int getPenaSum(){ return pena_sum; }
        int getTeam(){ return team; }
        void setCorrectSum( int a ) { correct_sum = a; }
        void setPenaSum( int a ) { pena_sum = a; }
        void setTeam( int a ) { team = a; }
};

Info::Info()
{
    co_cnt = 0;
    unco_cnt = 0;
    pena = 0;
}

void Info::correctProcessing( int time )
{
    if( co_cnt == 1 )
        return;
    pena += unco_cnt * 1200 + time;
    co_cnt = 1;
    unco_cnt = 0;
}

void swap( Sum& a, Sum& b );
void bubbleSort( Sum* a, int n, int k );

int main()
{
    int t, p, s;
    string c;

    while( cin >> t >> p >> s )
    {
        if( t + p + s == 0 )
            break;
        
        Info a[t][p];

        for( int i = 0; i < s; i++ )
        {
            int x, y, z;
            cin >> x >> y >> z >> c;

            if( c == "WRONG" )
                a[x-1][y-1].wrongProcessing();
            else
                a[x-1][y-1].correctProcessing( z );
        }

        Sum b[t];
        for( int i = 0; i < t; i++ )
        {
            int x = 0, y = 0;
            for( int j = 0; j < p; j++ )
            {
                x += a[i][j].getCcnt();
                y += a[i][j].getPena();
            }
            b[i].setCorrectSum( x );
            b[i].setPenaSum( y );
            b[i].setTeam( i + 1 );
        }

        bubbleSort( b, t, 0 );
        bubbleSort( b, t, 1 );
        bubbleSort( b, t, 2 );

        for( int i = 0; i < t; i++ )
            cout << b[i].getTeam() << " " << b[i].getCorrectSum() << " " << b[i].getPenaSum() << endl;

    }
    
    return 0;
}

void swap( Sum& a, Sum& b )
{
    Sum c = a;
    a = b;
    b = c;
}

void bubbleSort( Sum* a, int n, int k )
{
    for( int i = 0; i < n; i++ )
    {
        for( int j = n - 1; j > i; j-- )
        {
            if( k == 0 && a[j].getCorrectSum() > a[j-1].getCorrectSum() )
                swap( a[j], a[j-1] );
            if( k == 1 && a[j].getCorrectSum() == a[j-1].getCorrectSum() && a[j].getPenaSum() < a[j-1].getPenaSum() )
                swap( a[j], a[j-1] );
            if( k == 2 && a[j].getCorrectSum() == a[j-1].getCorrectSum() && a[j].getPenaSum() == a[j-1].getPenaSum() && a[j].getTeam() < a[j-1].getTeam() )
                swap( a[j], a[j-1] );
        }
    }
}


Measured memory_bytes: 3172
/******
author :- Mahmoud Tarek.
*******/

#include<bits/stdc++.h>

using namespace std ;

#define rg register
#define dbg(v) cerr << #v << " " << v ;
typedef long long ll ;

int main() {

   int n ;
   string s ;
   map<string, int> mp ;
   cin >> n ;
   for(int i = 0 ; i < n ; i++){
      cin >> s ;
      mp[s]++ ;
   }

   int mx = 0 ;
   vector<string> vec ;
   for(auto i: mp){
      mx = max(i.second, mx) ;
   }

   for(auto i: mp){
      if(mx == i.second){
        vec.push_back(i.first) ;
      }
   }

   sort(vec.begin(), vec.end()) ;
   for(auto i: vec) cout << i << "\n" ;


}

/*
 Empty set of troubles.
*/


Measured memory_bytes: 26868
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;

int N;
vector<int> H;

int main()
{
  cin >> N;
  H.resize(N);
  REP(i,0,N) cin >> H[i];

  int ans = 1;
  REP(i,1,N) {
    bool flag = true;
    REP(j,0,i) {
      if (H[j] > H[i]) {
        flag = false; break;
      }
    }
    if (flag) ++ans;
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define mp make_pair
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forlr(i, l, r) for (int i = int(l); i < int(r); i++)
#define repeat(n) for (int hjfjke = 0; hjfjke < int(n); hjfjke++)
#define all(c) c.begin(), c.end()
#define ll long long

const int mod = 1000000007;

vector<int> gr[100500];
int dp[100500][2];

void calc(int v, int par = -1) {
    dp[v][0] = 1;
    dp[v][1] = 1;
    if (gr[v].size() == 0 || (gr[v].size() == 1 && par != -1)) {
        return;
    }

    for (int x : gr[v])
        if (x != par) {
            calc(x, v);
            dp[v][0] = (dp[v][0] * 1ll * (dp[x][0] + dp[x][1])) % mod;
            dp[v][1] = (dp[v][1] * 1ll * dp[x][0]) % mod;
        }
}

int32_t main() {
    std::iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(10);

    int n;
    cin >> n;
    forn(i, n - 1) {
        int v, u;
        cin >> v >> u;
        v--;
        u--;
        gr[v].push_back(u);
        gr[u].push_back(v);
    }

    calc(0);

    cout << (dp[0][0] + dp[0][1]) % mod;

    return 0;
}

Measured memory_bytes: 13440
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 200005;
const int K = 25;
int ans[N];
int b[N], g[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        int x;
        cin >> x;
        int y = 1;
        while(y <= x){
            b[i]++;
            y += y;
        }
        if (y == x + x){
            g[i] = 1;
            b[i]--;
        }
    }
    int ans = 0;
    int c = 0;
    for (int i = 1; i <= n; i++){
        if (g[i]){
            if (b[i] > c) ans += b[i] - c;
            c = b[i];
        } else{
            if (c == 0){
                c = b[i];
                ans += b[i];
            } else{
                if (b[i] > c){
                    ans += (b[i] - c);
                    c = b[i];
                } else{
                    c = b[i] - 1;
                }
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  int x, min, ans;
  cin >> n >> x;
  min = x;
  ans = 1;
  for(int i=0; i<(n-1); i++){
    cin >> x;
    if(x <= min){
      min = x;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
R, G, B, N = (int(i) for i in input().split())

c = 0
for r in range(N//R, -1, -1): 
    new1 = N - r*R
    for g in range(new1//G, -1, -1):
        new2 = new1 - g*G
        if new2%B == 0:
            c +=1
    
print(c)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int x[200000];
int main()
{
    int k,n,i,j,len=0,Min=1000000000;
    scanf(" %d %d",&n,&k);
    for(i=0;i<n;i++){
        scanf(" %d",&x[i]);
    }
    for(i=0;i<=n-k;i++){
        if(x[i]<0&&x[i+k-1]>0){
            if(-x[i]>x[i+k-1])  len=2*x[i+k-1]-x[i];
            else len=x[i+k-1]-2*x[i];
        }
        else if(x[i]<0) len=-x[i];
        else len=x[i+k-1];
        if(Min>len){
            Min=len;
        }
    }
    printf("%d",Min);
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main()
{
    int a,b; /*���؁ia�F�̗� b�F�U���́j*/
    int c,d; /*�؁ic�F�̗� d�F�U���́j*/
    int i=0;

    do{
        scanf("%d%d%d%d",&a,&b,&c,&d);
    }while(a<1||a>100||b<1||b>100||c<1||c>100||d<1||d>100);

    while(a>0&&c>0){
        if(i%2==1)
            a=a-d;
        if(i%2==0)
            c=c-b;
        i++;
    }
    
    if(c<=0)
        printf("Yes");
    if(a<=0)
        printf("No");
    
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i=1; i < (int)(n); i++)
#define rrep(i, n) for (int i=((int)(n)-1); i>=0; i--)
#define rreps(i, n) for (int i=((int)(n)-1); i>0; i--)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;
using p = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  int N; cin >> N;
  vector<string> s(N);
  rep (i, N) cin >> s.at(i);
  map<string, int> map;
  rep (i, N) {
    map[s[i]] ++;
  }
  int ans = 0;
  for (auto ite=map.begin(); ite != map.end(); ite++) {
    ans ++;
  }
  printf("%d\n", ans);
  return 0;
}


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

int main(){
	LL n;
	cin>>n;
	LL min=n-1;
	LL num=1;
	for(LL i=1;i<=sqrt(n);i++){
		LL b;
		if(n%i==0){
			b=n/i;
		}else{
			continue;
		}
		LL diff=abs(i-b);
		if(diff<min){
			min=diff;
			num=i;
		}
	}
	LL b=n/num;
	int cnt=0;
	while(b>0){
		b/=10;
		cnt++;
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}


int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    ll n = readInt(), a = readInt(), b = readInt();
    if (n == 1) {
    	if (a == b) {
    		cout << 1;
    		return 0;
    	} else {
    		cout << 0;
    		return 0;
    	}
    }
    if (b < a) {
    	cout << 0;
    	return 0;
    }
	cout << (n - 2) * (b - a) + 1;
    return 0;          
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

int N;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N;
	cout << N + N * N + N * N * N;
}

Measured memory_bytes: 3636
from sys import stdin


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]  # 親
        self.rank = [1] * n  # 木の高さ
        self.size = [1] * n  # size[i] は i を根とするグループのサイズ

    def find(self, x):  # x の根を返す
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])  # 経路圧縮
            return self.parent[x]

    def unite(self, x, y):  # x, y の属する集合を併合する
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def is_same(self, x, y):  # x, y が同じ集合に属するか判定する
        return self.find(x) == self.find(y)

    def group_size(self, x):  # x が属する集合の大きさを返す
        return self.size[self.find(x)]

    def group_members(self, x):  # x が属する集合の要素を返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):  # すべての根をリストで返す
        return [i for i, x in enumerate(self.parent) if i == x]

    def group_count(self):  # 木の数を返す
        return len(self.roots())

    def all_group_members(self):  # すべての木の要素を辞書で返す
        return {r: self.group_members(r) for r in self.roots()}

    def __str__(self):  # print 表示用
        return '\n'.join('{}: {}'.format(r, self.group_members(r)) for r in self.roots())


def get_result(data):
    N, M, K = data[0]
    A, B = [0] * M, [0] * M
    C, D = [0] * K, [0] * K
    direct = [[] for _ in range(N)]  # 同じ集合の友達もしくはブロック関係の人
    uf = UnionFind(N)

    for i in range(M):
        A[i], B[i] = data[1+i]
        # 入力時に 0-index に合わせる
        A[i] -= 1
        B[i] -= 1
        direct[A[i]].append(B[i])
        direct[B[i]].append(A[i])
        uf.unite(A[i], B[i])

    for i in range(K):
        C[i], D[i] = data[1+M+i]
        # 入力時に 0-index に合わせる
        C[i] -= 1
        D[i] -= 1
        if uf.is_same(C[i], D[i]):
            direct[C[i]].append(D[i])
            direct[D[i]].append(C[i])

    ans = [0] * N
    for i in range(N):
        ans[i] = uf.group_size(i) - len(direct[i]) - 1
    return ' '.join(list(map(str, ans)))


if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)


Measured memory_bytes: 106636
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K; 
    cin >> N >> K;
    int A[N];
    int cnt[N] = {};
    int ans = 0;
    int kind = 0;
    rep(i, N) cin >> A[i];
    rep(i, N) cnt[A[i]-1]++;
    sort(cnt, cnt+N);
    rep(i, N) if (cnt[i] > 0) kind++;
    rep(i, kind - K) {
        if (cnt[i] != 0 ) ans += cnt[i];
        else {
            K--; continue;
        }
    }
    cout << ans << endl;

    return 0;
}


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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

using ll = long long;
using namespace std;

int main() {
    ll n;
	string s;
  
    cin >> n >> s;
  
    char prev = s[0];
    ll ans = 0;
  	REP(i, n-1){
        if(s[i+1]!=prev){
            ans++;
        }
        prev = s[i+1];
    }
    cout << setprecision(20) << ans + 1 << endl;

    return 0;
}

Measured memory_bytes: 512
using System;

namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            int count;
            while((count = int.Parse(Console.ReadLine())) != 0) {
                ++count;
                var data = new int[count, count];
                for(int i=0; i < count - 1; ++i) {
                    var val = Console.ReadLine().Split();
                    for(int l=0; l < count - 1; ++l) {
                        data[i, l] = int.Parse(val[l]);
                        data[i, count - 1] += data[i, l];
                    }
                }
                for(int i=0; i < count; ++i) {
                    for(int l=0; l < count - 1; ++l) {
                        data[count -1, i] += data[l, i];
                    }
                }
                for(int i=0; i < count; ++i) {
                    for(int l=0; l < count; ++l) {
                        Console.Write("{0,5}",data[i,l]);
                    }
                    Console.WriteLine();
                }
            }
        }
    }
}

Measured memory_bytes: 13936
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
// 素因数分解
typedef pair<long long, long long> P;
vector<P> prime_factorize(long long n)
{
vector<P> res;
for (long long p = 2; p * p <= n; ++p)
{
if (n % p != 0)
continue;
int num = 0;
while (n % p == 0)
{
++num;
n /= p;
}
res.push_back(make_pair(p, num));
}
if (n != 1)
res.push_back(make_pair(n, 1));
return res;
}
// 因数分解
long long gcd(long long x, long long y)
{
  if (y == 0)
  {
    return x;
  }
  else
  {
    return gcd(y, x % y);
  }
}
const int MOD = 1000000007;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    bool ok = true;
    rep(i,n){
        int a;
        cin >> a;
        if(a%2==0){
            if(!(a%3==0||a%5==0)){
                ok = false;
            }
        }
    }
    if(ok){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }
    return 0;
}

Measured memory_bytes: 3612
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    K = inputInt()
    X = inputInt()
    Y = inputInt()
    
    if N <= K:
        print(N*X)
    else:
        print((K*X) + ((N-K)*Y))
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 39280
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int>> g;
vector<vector<int>> dp(3000,vector<int>((1<<12),-1));
int n,m,a,b,c;

int getans(int curr , int bits){
    if(bits == 0){
        return 0;
    }
    if(curr == m){
        return 1000000000;
    }
    if(dp[curr][bits] != -1){
        return dp[curr][bits];
    }
    int v = bits;
    for(int i = 0 ; i < n ; i += 1){
        if((1 << i) & bits){
            if((1 << i) & g[curr].second){
                v -= (1 << i);
            }
        }
    }
    int ret = min(getans(curr+1,bits),g[curr].first + getans(curr+1,v));
    return dp[curr][bits] = ret;
}

int main(){
    cin >> n >> m;
    g.resize(m);
    for(int i = 0 ; i < m ; i += 1){
        cin >> a >> b;
        g[i].first = a;
        int v = 0;
        for(int j = 0 ; j < b ; j += 1){
            cin >> c;
            v += (1 << (c-1));
        }
        g[i].second = v;
    }
    int v = (1 << n)-1;
    int g = getans(0,v);
    if(g >= 1000000000){
        cout << -1;
    }else{
        cout << g;
    }
}

Measured memory_bytes: 50432