akhauriyash/Code-Regression huggingface dataset:
from collections import deque

def bfs():
    global ok
    q = deque()
    q.append(1)
    ok[1] = 1
    while q:
        i = q.popleft()
        for j in G[i]:
            if ok[j] == 0:
                ok[j] = 1
                q.append(j)
    return

n, m = map(int, input().split())
G = [[] for _ in range(200001)]
for x in range(1, n + 1):
    l = list(map(int, input().split()))
    for i in range(1, l[0] + 1):
        y = l[i] + 100000
        G[x].append(y)
        G[y].append(x)
ok = [0] * 200001
bfs()
print("YES" if sum(ok[1 : n + 1]) == n else "NO")

Measured memory_bytes: 36220
#include<bits/stdc++.h>
#include <string>
using namespace std;
#include<chrono>
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define foo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define MIN3(a,b,c)         MIN(a,MIN(b,c))
#define MAX3(a,b,c)         MAX(a,MAX(b,c))
#define MIN4(a,b,c,d)       MIN(a,MIN(b,MIN(c,d)))
#define MAX4(a,b,c,d)       MAX(a,MAX(b,MAX(c,d)))
#define MAX5(a,b,c,d,e)     MAX(MAX3(a,b,c),MAX(d,e))
#define MIN5(a,b,c,d,e)     MIN(MIN3(a,b,c),MIN(d,e))
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void DFS(int n);
bool isprime(ll n);
int gcd(int a,int b);
void rstgraph(int n);

const int mod = pow(10,9)+7;
const int N = 3e5, M = N;
//=======================================================================================
vi g[N];
int vis[N];
int nodes=0;
ll ans=0;
void iluzn() {
 int n,d;
 cin>>n>>d;
 int ans=0;
 while(n--)
 {
  ll x,y;
  cin>>x>>y;
  x=abs(x);
  y=abs(y);
  ll p=ceil(sqrt(x*x+y*y));
  if(p<=d)
    ++ans;
 }
 cout<<ans;
}


int main() {
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t=1;
   
    // cin>>t;
    while(t--)
     {
      iluzn();
     
      }
    return 0;
}
int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
bool isprime(ll n){
    if(n<=1)
        return false;
    if(n==2)
        return true;
    if(n%2==0)
        return false;
    ll rt = sqrt(n);
    for(ll i=3;i<rt;i+=2){
        if(n%i==0)
            return false;
    }
    return true;
}
int gcd(int a,int b){
    if(a%b){
        return gcd(b,a%b);
    }
    else{
        return b;
    }
}
void ipgraph(int m){
  int u, v;
  while(m--){
    cin>>u>>v;
    g[u].pb(v);
    // g[v].pb(u);
  }
}

void DFS(int n)
{  ++nodes;
    vis[n] = 1;
    for(vector<int>::iterator i = g[n].begin(); i != g[n].end() ; i++)
    {
        if(!vis[*i])
            DFS(*i);
    }
}
void rstgraph(int n){
  int i;
  fo(i,n+1){
    g[i].clear();
    vis[i]=0;
  }
  nodes=0;
}

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    sort(a.begin(), a.end());
    int ma = 0;
    vector<vector<bool>> used(n, vector<bool>(n));
    for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) {
        if (used[i][j]) continue;
        used[i][j] = true;
        int diff = a[j] - a[i];
        int tmp = 2, pre = j;
        for (int k = a[j] + diff; k <= a.back(); k += diff) {
            int itr = lower_bound(begin(a), end(a), k) - begin(a);
            if (a[itr] != k) break;
            tmp++;
            used[pre][itr] = true;
            pre = itr;
        }
        ma = max(ma, tmp);
    }
    cout << ma << endl;
    return 0;
}


Measured memory_bytes: 6312
#include<vector>
#include<cstdio>
#include<queue>
#include<algorithm>
#define MN 410001
using namespace std;

int n,m,x[MN],bo[MN][2],y[MN],ln;
char s[MN];
vector <int> v[MN];
bool B[MN];
queue<int> q;
int main(){
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	for (int i=1;i<=n;i++) s[i]=s[i]=='B',B[i]=1;
	for (int i=1;i<=m;i++){
		scanf("%d%d",&x[i],&y[i]);
		v[x[i]].push_back(y[i]);
		v[y[i]].push_back(x[i]);
		bo[x[i]][s[y[i]]]++;bo[y[i]][s[x[i]]]++;
	}
	for (int i=1;i<=n;i++)
	if (!bo[i][0]||!bo[i][1]) q.push(i),B[i]=0;
	while (!q.empty()){
		ln++;
		int k=q.front();q.pop();
		for (int i=0;i<v[k].size();i++)
		if (--bo[v[k][i]][s[k]]==0&&B[v[k][i]]) q.push(v[k][i]),B[v[k][i]]=0;
	}
	puts(ln==n?"No":"Yes");
} 

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var D = ReadInt();
            if (D == 25) Console.WriteLine("Christmas");
            else if (D == 24) Console.WriteLine("Christmas Eve");
            else if (D == 23) Console.WriteLine("Christmas Eve Eve");
            else if (D == 22) Console.WriteLine("Christmas Eve Eve Eve");

            Console.WriteLine();
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int llu;
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pair<int,int>>
#define pb push_back
#define mp map<lli,lli>
#define INF 1000000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
int main()
{
    int n;
    cin>>n;
    string s[4]={"AC","WA","TLE","RE"};
    int a[4]={0};
    for(int i=0;i<n;i++)
    {
        string t;
        cin>>t;
        if(t==s[0])
        a[0]++;
        else if(t==s[1])
        a[1]++;
        else if(t==s[2])
        a[2]++;
        else if(t==s[3])
        a[3]++;
    }
    for(int i=0;i<4;i++)
    {
        cout<<s[i]<<" x "<<a[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3596
n, q = map(int, input().split())
s = list(input())
l = []
r = []
for _ in range(q):
    line = list(map(int, input().split()))
    l.append(line[0])
    r.append(line[1])
ac = []
count = 0
for i in range(1, n):
    if s[i-1] == "A" and s[i] == "C":
        count += 1
    ac.append(count)
for i in range(q):
    right = ac[r[i]-2]
    if l[i] < 2:
        left = 0
    else:
        left = ac[l[i]-2]
    print(right-left)

Measured memory_bytes: 69880
// F.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef pair<int, int> II;

bool solve(vector<string> ss) {
	vector<II> v;
	for (string s : ss) {
		int cnt = 0, mn = 0;
		for (char c : s) {
			if (c == '(') {
				++cnt;
			} else {
				--cnt;
				mn = min(mn, cnt);
			}
		}
		v.emplace_back(II(mn, cnt));
	}
	int cnt = 0;
	vector<II> mp;
	vector<pair<int, II>> mm;
	for (auto kv : v) {
		if (kv.first >= 0) {
			cnt += kv.second;
		} else if (kv.second >= 0) {
			mp.emplace_back(kv);
		} else {
			mm.emplace_back(make_pair(kv.second - kv.first, kv));
		}
	}
	bool ans = true;
	sort(mp.rbegin(), mp.rend());
	for (auto kv : mp) {
		if (cnt + kv.first < 0) {
			ans = false;
		}
		cnt += kv.second;
	}
	sort(mm.rbegin(), mm.rend());
	for (auto kv : mm) {
		if (cnt + kv.second.first < 0) {
			ans = false;
		}
		cnt += kv.second.second;
	}
	if (cnt != 0) {
		ans = false;
	}
	return ans;
}

int main(int argc, char* argv[]) {
	cout.precision(20);
#ifdef _MSC_VER
	while (true)
#endif
	{
		int n = -1;
		cin >> n;
		if (n < 0) return 0;
		vector<string> v(n);
		for (int i = 0; i < n; ++i) {
			cin >> v[i];
		}
		bool ans = solve(v);

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


Measured memory_bytes: 85620
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Program
{

    public void Proc()
    {
        this.SetPrimeNumbers();
        System.Text.StringBuilder ans = new System.Text.StringBuilder();
        while(true) {
            string inpt = Reader.ReadLine();
            if(inpt == null) {
                break;
            }
            int num = int.Parse(inpt);
            ans.AppendLine((GetIdx(0, this.PrimeNumbers.Count-1, num)+1).ToString());
        }
        Console.Write(ans.ToString());

    }

    private int GetIdx(int min, int max, int target) {
        if(PrimeNumbers[min]>target) {
            return -1;
        }
        if(PrimeNumbers.Last()<target) {
            return PrimeNumbers.Count - 1;
        }
        if(max-min<=1) {
            if(PrimeNumbers[max]==target) {
                return max;
            }
            return min;
        }

        int mid = (max + min) / 2;
        if(PrimeNumbers[mid] == target) {
            return mid;
        }
        if(PrimeNumbers[mid]>target) {
            return GetIdx(min, mid, target);
        } else {
            return GetIdx(mid, max, target);
        }
    }

    private List<int> PrimeNumbers = new List<int>();
    private void SetPrimeNumbers() {
        int max = 1000000;
        bool[] flag = new bool[max + 1];
        for (int i = 2; i <= max; i++) {
            if (flag[i]) {
                continue;
            }
            this.PrimeNumbers.Add(i);
            for (int j = 1; j <= max / i; j++) {
                flag[i * j] = true;
            }
        }
    }

    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"



10
3
11

";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

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

int main(void) {
    int64_t A,B,C;
    
    cin >> A >> B >> C;
    if(A == B) {
        if(B != C) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    } else if(A == C) {
            cout << "Yes\n";
    } else if(B == C) {
            cout << "Yes\n";
    } else {
            cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
def fanc():
   s = []
   H,W = list(map(int, input().split()))
   for i in range(H):
      s.append(input())

   b = 0
   for i in range(H):
      for j in range(W):
         if s[i][j] == "#":
            b = b+1

   flag = [[0 for _ in range(W)] for _ in range(H)]
   Q = []
   Q.append((0,0,0))
   flag[0][0] = 1

   while Q != []:
      v = Q.pop(0)
      if v[0:2] == (H-1,W-1):
         return H*W - b - v[2] -1
      else:
         if v[0] != 0: # up
            if (flag[v[0]-1][v[1]]==0)and(s[v[0]-1][v[1]]=="."):
               Q.append((v[0]-1, v[1],v[2]+1))
               flag[v[0]-1][v[1]] = 1
         if v[0] != H-1: # down
            if (flag[v[0]+1][v[1]]==0)and(s[v[0]+1][v[1]]=="."):
               Q.append((v[0]+1, v[1], v[2]+1))
               flag[v[0]+1][v[1]] = 1
         if v[1] != 0: # left
            if (flag[v[0]][v[1]-1]==0)and(s[v[0]][v[1]-1]=="."):
               Q.append((v[0], v[1]-1, v[2]+1))
               flag[v[0]][v[1]-1] = 1
         if v[1] != W-1: # left
            if (flag[v[0]][v[1]+1]==0)and(s[v[0]][v[1]+1]=="."):
               Q.append((v[0], v[1]+1, v[2]+1))
               flag[v[0]][v[1]+1] = 1
   return -1

print(fanc())


Measured memory_bytes: 3192
import std.stdio;

int type(double height) {
  auto list = [165.0, 170.0, 175.0, 180.0, 185.0];
  foreach(int i, x; list) {
    if (height < x) return i;
  }
  return 5;
}

void main() {
  int[] freq = new int[6];
  int n; readf("%d\n", &n);
  foreach(i; 0..n) {
    double x; readf("%f\n", &x);
    freq[type(x)]++;
  }
  foreach(int i, x; freq) {
    write(i + 1, ":");
    for(int j = 0; j < x; j++) write("*");
    writeln;
  }
}

Measured memory_bytes: 1088
N = gets.to_i
digits = N.to_s.size

def dfs(digits_size, digits = [], &block)
  if digits.size == digits_size
    block.call(digits)
    return
  end
  [7, 5, 3].each do |n|
    dfs(digits_size, digits + [n], &block)
  end
end

ans = 0
(3..digits).each do |d|
  dfs(d) do |list|
    is_ok = list.join('').to_i <= N &&
      list.count { |n| n == 7 } >= 1 &&
      list.count { |n| n == 5 } >= 1 &&
      list.count { |n| n == 3 } >= 1
    ans += 1 if is_ok
  end
end
puts ans


Measured memory_bytes: 1916
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int r = 0;
		int c = 0;
		int[][] sp_sheet;

		Scanner sc= new Scanner( System.in );


		r = sc.nextInt();
		c = sc.nextInt();

		sp_sheet = new int[r+1][c+1];

		for( int i = 0 ; i < r ; i++ ) {
			for ( int j = 0 ; j < c ; j++ ) {

				sp_sheet[i][j] = sc.nextInt();

				if ( j == 0 ) {
					sp_sheet[i][c] = 0;
				}
				sp_sheet[i][c] += sp_sheet[i][j];

				if ( i == 0 ) {
					sp_sheet[r][j] = 0;
				}
				sp_sheet[r][j] += sp_sheet[i][j];
			}
			if ( i == 0 ) {
				sp_sheet[r][c] = 0;
			}
			sp_sheet[r][c] += sp_sheet[i][c];
		}

		for( int i = 0 ; i < ( r + 1 ) ; i++ ) {
			for ( int j = 0 ; j < ( c + 1 ) ; j++ ) {
				System.out.print( sp_sheet[i][j] );
				if ( j != c ) {
					System.out.print( " " );
				}
			}
			System.out.print( "\n" );
		}
		sc.close();
	}
}


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

vector<vector<int>> MOVE_A = {{0,1},{0,-1},{1,0},{-1,0}};


void bfs(int H, int W, int Sh, int Sw, vector<string> &S, vector<vector<bool>> &visited, queue<pair<int,int>> &now_pos) {
  queue<pair<int,int>> q;
  q.push(make_pair(Sh, Sw));
  int h, w, y, x;
  while (!q.empty()) {
    tie(h, w) = q.front(); q.pop();
    now_pos.push(make_pair(h, w));
    for (auto next: MOVE_A) {
      y = h + next[0];
      x = w + next[1];
      if (y < 0 || H <= y || x < 0 || W <= x) continue;
      if (visited[y][x]) continue;
      q.push(make_pair(y, x));
      visited[y][x] = true;
    }
  }
}


void move_b(int H, int W, int Sh, int Sw, vector<string> &S, vector<vector<bool>> &visited, queue<pair<int,int>> &next_pos) {
  int h, w;
  for (int i: {-2, -1, 0, 1, 2}) {
    h = Sh + i;
    if (h < 0 || H <= h) continue;
    for (int j: {-2, -1, 0, 1, 2}) {
      w = Sw + j;
      if (w < 0 || W <= w) continue;
      if (visited[h][w]) continue;
      next_pos.push(make_pair(h, w));
      visited[h][w] = true;
    }
  }
}


int main() {
  int H, W, Ch, Cw, Dh, Dw;
  cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
  Ch--; Cw--; Dh--; Dw--;
  vector<string> S(H);
  rep(i,H) cin >> S[i];

  vector<vector<bool>> visited(H, vector<bool>(W, false));
  rep(h,H) rep(w,W) if (S[h][w] == '#') visited[h][w] = true;
  queue<pair<int,int>> now_pos;
  queue<pair<int,int>> next_pos;
  next_pos.push(make_pair(Ch, Cw));
  visited[Ch][Cw] = true;
  int h, w, ans = 0;
  while (true) {
    while (!next_pos.empty()) {
      tie(h, w) = next_pos.front(); next_pos.pop();
      bfs(H, W, h, w, S, visited, now_pos);
    }

    if (visited[Dh][Dw]) break;

    while (!now_pos.empty()){
      tie(h, w) = now_pos.front(); now_pos.pop();
      move_b(H, W, h, w, S, visited, next_pos);
    }
    if (next_pos.empty()) {
      ans = -1;
      break;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5708
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

const int bound = 2010;
ll dp[bound][bound];

int main(){
	int n, m; cin >> n >> m;
	vector<int> s(n);
	vector<int> t(m);
	for( auto &k : s ) cin >> k;
	for( auto &k : t ) cin >> k;
	// init
	for( int i = 0; i < bound; ++i ) dp[i][0] = 1;
	for( int j = 0; j < bound; ++j ) dp[0][j] = 1;
	for( int i = 0; i < n; ++i ){
		for( int j = 0; j < m; ++j ){
			dp[i+1][j+1] = ( dp[i+1][j] + dp[i][j+1] ) % mod;
			if( s[i] != t[j] ) dp[i+1][j+1] = ( dp[i+1][j+1] - dp[i][j] + mod ) % mod;
		}
	}
	/*
	for( int i = 0; i < 6; ++i ){
		for( int j = 0; j < 6; ++j ){
			cout << dp[i][j] << ' ';
		} cout << endl;
	}
	*/
	cout << dp[n][m] << endl;
}

Measured memory_bytes: 31744
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

void solve(){
    int n,q,a;
    cin>>n>>q;
    fenwick_tree<ll> ft(n);
    fr(i,n){
        cin>>a;
        ft.add(i,a);
    }
    {
        int t,l,r;
        fr(_,q){
            cin>>t>>l>>r;
            if(t) cout<<ft.sum(l,r)<<'\n';
            else ft.add(l,r);
        }
    }
}

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


Measured memory_bytes: 8252
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        if(a+b+c >= 22){
            System.out.println("bust");
        }else{
            System.out.println("win");
        }
        
    }
}



Measured memory_bytes: 21844
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long s = 0;
        for(int i = 1 ; i <= a ; i++ ){
            if(a % i == 0 && b % i == 0){
                s = (long)i;
            }
        }
        long q = a * b / s;
        System.out.println(q);
        sc.close();
    }
}

Measured memory_bytes: 35776
//And Then. How Many Are There?
#include<bits/stdc++.h>
using namespace std;

int n;
int x[24], y[24], r[24], c[24];
int bit[24]; //??????????????¨???????????????
short int dp[1<<24];

//a??¨b???????????????true
bool dis(int i, int j){
  return (x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]) < (r[i]+r[j])*(r[i]+r[j]);
}

//b:??????????????????????????¨???????????????
int solve(int b){
  if(dp[b]!=-1)return dp[b];

  int mx=0;
  for(int i=0; i<n-1; i++){//1???????????????
    if((bit[i]&b)!=bit[i])continue;//??????????????????
    if((b&(1<<i))!=0)continue;//??¢??????????????????
   
    for(int j=i+1; j<n; j++){//2???????????????
      if((bit[j]&b)!=bit[j])continue;//??????????????????
      if((b&(1<<j))!=0)continue;//??¢??????????????????
      if(c[i] != c[j])continue;//????????????

      mx = max(mx, solve(b|(1<<i)|(1<<j))+2);
    }
  }
  return dp[b]=mx;
}

int main(){
  while(cin >> n, !(n==0)){
    memset(bit, 0, sizeof(bit));
    memset(dp, -1, sizeof(dp));
    for(int i=0; i<n; i++){
      cin >> x[i] >> y[i] >> r[i] >> c[i];
      for(int j=0; j<i; j++)if(dis(i, j))bit[i] = bit[i]|(1<<j);
    }
    cout<<solve(0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 33936
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);

		int r = sc.nextInt();
		int D = sc.nextInt();
		int x = sc.nextInt();
		for (int i=0;i<10;i++) {
			x = r * x - D;
			System.out.println(x);
		}
	}

}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 19924
#include<iostream>
#include<string>
#include<stdio.h>

using namespace std;

int main()
{
	string S;
	cin >> S;
	for (int i = 0; i < (int)S.size(); i++) {
		char c = S[i];
	}
	if (S[0] == S[1] && S[1] == S[2]) {
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 256
using System;
namespace Solution {
    class Solution {
        public static void Main(string[] args){
            for(int i = 1; i <= 9; i++) {
                for(int j = 1; j <= 9; j++) {
                    System.Console.WriteLine("{0}x{1}={2}", i, j, i*j);
                }
            }
        }
    }
}

Measured memory_bytes: 9084
import numpy as np
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
ans = 0
for i in range(N):
  A = list(map(int, input().split()))
  tmp = C
  for j in range(M):
    tmp += A[j]*B[j]
  if tmp>0:
    ans += 1
print(ans)

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

int main(){
    int n, m, i, j;
    cin >> n >> m;
    long long res = 0, x[n], y[n], z[n], a[8] = {1,1,1,1,-1,-1,-1,-1}, b[8] = {1,1,-1,-1,1,1,-1,-1}, c[8] = {1,-1,1,-1,1,-1,1,-1};
    for(i=0; i<n; i++){
        cin >> x[i] >> y[i] >> z[i];
    }
    for(i=0; i<8; i++){
        long long t = 0, s[n] = {};
        for(j=0; j<n; j++){
            s[j] = x[j]*a[i] + y[j]*b[i] + z[j]*c[i];
        }
        sort(s, s+n, greater<long long>());
        for(j=0; j<m; j++){
            t += s[j];
        }
        res = max(res, t);
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    string S;
    cin >> S;
    string ans = "Good";
    for ( int i = 0; i < 3; i++ ) {
        if ( S[i] == S[i+1] ) ans = "Bad";
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
const int N = 2e5 + 10;
int mod = 1e9 + 7;
typedef long long ll;
bool suger[3001];
bool water[3333];
int main()  
{
  // freopen("in.txt", "r", stdin);
   int a, b, c, d, e, f;
   while (cin >> a >> b >> c >> d >> e >> f)
   {
   		double ans = 0;
   		double sd = 1.0*e/(e+100);
   		int wat = 0, sug = 0;
   		memset(suger, 0, sizeof(suger));
   		memset(water, 0, sizeof(suger));
   		for (int i = 0; i <= f; i++)
   		{
   			for (int j = 0; j <= f; j++)
   			{
   				int cur = i*c + j*d;
   				if (cur <= 3000)
   					suger[cur] = true;
   				cur = i*a + j * b;
   				if (cur <= 30)
   				{   					
   					water[cur*100] = true;
   				}
   			}

   		}
   		// printf("%d %d\n", suger[934], water[1700]);
   		for (int i = 0; i <= f; i++)
   			for (int j = 0; j <= f - i; j++) 
   				if (i == 0 && j == 0)
   					continue;
   				else
	   			{
	   				double cur = 1.0*i/(i + j);
	   				// if (i == 10 && j == 100)
	   					
	   				if (cur > sd)
	   					continue;
	   				if (suger[i] && water[j])
	   				{
	   					// printf("sug:%d water:%d %f\n", i, j, cur);
	   					if (cur >= ans)
	   					{
	   						ans = cur;
	   						wat = j;
	   						sug = i;
	   					}
	   				}
	   			}
	   	printf("%d %d\n", wat + sug, sug);

   }
   return 0;
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
// typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 998244353;
const lli e3 = 1 << 12;
const lli INF = 1ll << 63;

class union_find {
private:
  vll *par;
  vll *rnk;
public:
  union_find (lli n){
    par = new vll(n);
    iota(par->begin(),par->end(),0);
    rnk = new vll(n,0);
  }
  lli find(lli x){
    if(par->at(x) == x) return x;
    else return par->at(x) = find(par->at(x));
  }
  void unite(lli x,lli y){
    x = find(x);y = find(y);
    if(x == y)return;
    if(rnk->at(x) < rnk->at(y)) par->at(x) = y;
    else {
      par->at(y) = x;
      if(rnk->at(x) == rnk->at(y)) rnk->at(x)++;
    }
  }
  bool same(lli x,lli y){
    return find(x) == find(y);
  }
};

union_find uf(e5);
lli n,m;
lli a[e5],b[e5];
vll ans;
lli cnt[e5];
lli huben;

int main(){
  cin >> n >> m;
  huben = n*(n-1)/2;
  ans.push_back(huben);
  fill(cnt,cnt+n+1,1);
  for(lli i = 0;i < m;i++){
    cin >> a[i] >> b[i];


  }
  for(lli i = m-1;i >= 0;i--){
    if(!uf.same(a[i],b[i])){
      lli x = cnt[uf.find(a[i])];
      lli y = cnt[uf.find(b[i])];
      uf.unite(a[i],b[i]);
      cnt[uf.find(a[i])] = x+y;
      huben -= x*y;
    }
    ans.push_back(huben);
  }
  for(lli i = ans.size()-2;i >= 0;i--){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 23540
import sys
input = sys.stdin.readline
from itertools import chain

def readlines(*xy):
    for n in xy:
        yield sorted(map(int, input().split()), reverse=True)[:n]
    
    yield list(map(int, input().split()))

def main():
    x, y, a, b, c = map(int, input().split())
    apples = sorted(chain(*readlines(x,y)), reverse=True)
    print(sum(apples[:x+y]))


main()




Measured memory_bytes: 22576
S = input()
num_children = [0 for s in S]
def run_length(S):
  c = 1
  result = []
  for i in range(len(S)):
    try:
      if (S[i] == S[i+1]):
        c += 1
      else:
        result.append(c)
        c = 1
    except:
      result.append(c)
      return result
rl = run_length(S)
start = 0
for i in range(len(rl)):
  try:
    num_r = rl[i]
    num_l = rl[i+1]
  except:
    pass
  if (i % 2 == 0):   
    num_children[start+num_r-1] += (num_r + 1) // 2 + num_l // 2
    num_children[start+num_r] += (num_l + 1) // 2 + num_r // 2
  start += int(rl[i])
for i in num_children:
  print(str(i),end=' ')

Measured memory_bytes: 5616
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

const (
	INF_INT = 1000000000000000000
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

func main() {
	n := readf()
	N := int(n)

	maxMulti := math.Ceil(math.Sqrt(n))
	min := INF_INT
	a := 1
	for float64(a) <= maxMulti {
		if N%a == 0 {
			tmp := a + int(math.Ceil(float64(N)/float64(a))) - 2
			if min > tmp {
				min = tmp
			}
		}
		a = a + 1
	}

	fmt.Println(min)
}

/*-------------------inputs-------------------*/

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func subL(list []int) []int {
	sl := make([]int, len(list)-1)
	for i := range list {
		if i == len(list)-1 {
			continue
		}
		sub := list[i+1] - list[i]
		sl[i] = sub
	}
	return sl
}


Measured memory_bytes: 640
#include <stdio.h>

int getClassIndex(double weight)
{
	if( weight <= 48.0 )
	{
		return (0);
	}
	else if( weight <= 51.0 )
	{
		return (1);
	}
	else if( weight <= 54.0 )
	{
		return (2);
	}
	else if( weight <= 57.0 )
	{
		return (3);
	}
	else if( weight <= 60.0 )
	{
		return (4);
	}
	else if( weight <= 64.0 )
	{
		return (5);
	}
	else if( weight <= 69.0 )
	{
		return (6);
	}
	else if( weight <= 75.0 )
	{
		return (7);
	}
	else if( weight <= 81.0 )
	{
		return (8);
	}
	else if( weight <= 91.0 )
	{
		return (9);
	}
	else
	{
		return (10);
	}
}

int main(void)
{
	char* weightClass[] = {"light fly", "fly", "bantam", "feather", "light", "light welter", "welter", "light middle", "middle", "light heavy", "heavy"};
	double weight;
	
	while( scanf( "%lf", &weight ) != EOF )
	{
		printf( "%s\n", weightClass[ getClassIndex( weight ) ] );
	}
	return (0);
}

Measured memory_bytes: 608
#include<stdio.h>
int main()
{
    long long N,a[150000],b[150000],i,x;
    scanf("%lld",&N);
    for(i=1; i<=N; i++)
    {
        scanf("%lld",&a[i]);
         x=a[i];
         b[x-1]=i;
    }

    for(i=0; i<N; i++)
    {
        printf("%lld ",b[i]);
    }
    return 0;
}


Measured memory_bytes: 2816
eval'A=0,#'+`tr ' ' ,`;f=->a{l=[[0,i=-1]];a.map{|x|l.pop while(t=l[-1])[0]>x;l<<[x,i+=1];i-t[1]}}
r=0;A.zip(f[A],f[A.reverse].reverse){|a,b,c|r+=a*b*c};p r

Measured memory_bytes: 48568
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left #bisect_left(list, value)
#from fractions import gcd
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input():
    return sys.stdin.readline()[:-1]
def pri(x):
    if type(x) is list:
        print('\n'.join(map(str, x)))
    else:
        print(x)

S = input()
N = len(S)
rS = ''.join(list(reversed(S)))

S2 = S[:(N-1)//2]
rS2 = ''.join(list(reversed(S2)))

S3 = S[(N+3)//2-1:]
rS3 = ''.join(list(reversed(S3)))

if S==rS and S2==rS2 and S3==rS3:
    print('Yes')
else:
    print('No')




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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int N; cin >> N;
  vi32 v(N + 1);
  reps(i, N) {
    int a; cin >> a;
    v[i] = a;
  }
  int ans = 0;
  vector<bool> f(N + 1);
  reps(i, N) {
    if (f[i]) continue;
    if (i == v[v[i]]) {
      ans++;
      f[v[i]] = true;
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 640
#pragma region // {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

namespace { namespace unolight {
// Read Input
template<class T> void _R( T &x ) { cin>>x; }
void _R( int &x ) { scanf("%d",&x); }
void _R( int64_t &x ) { scanf("%" PRId64,&x); }
void _R( double &x ) { scanf("%lf",&x); }
void _R( char &x ) { scanf(" %c",&x); }
void _R( char *x ) { scanf("%s",x); }
void R() {}
template<class T, class... U> void R( T& head, U&... tail ) { _R(head); R(tail...); }
// Write Output
template<class T> void _W( const T &x ) { cout<<x; }
void _W( const int &x ) { printf("%d",x); }
void _W( const int64_t &x ) { printf("%" PRId64,x); }
void _W( const double &x ) { printf("%.16f\n",x); }
void _W( const char &x ) { putchar(x); }
void _W( const char *x ) { printf("%s",x); }
template<class T> void _W( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W( const T& head, const U&... tail ) { _W(head); putchar(sizeof...(tail)?' ':'\n'); W(tail...); }

#ifdef UNOLIGHT
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
#pragma endregion // }}}

void main() {
    string t="keyence";
    string s;
    cin >> s;
    int n=s.size(), m=t.size();
    for ( int i=0; i<=m; i++ ) {
        string w=s.substr(0,i) + s.substr(n-m+i);
        if ( w==t ) {
            cout << "YES" << '\n';
            return;
        }
    }
    cout << "NO" << '\n';
}

}} // {{{ main
int main() { unolight::main(); return 0; }
// }}}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N, M;
  cin >> N >> M ;
  int sum = N; 
  if (M == 1) {
    cout << 0;
    return 0;
  }
  for (int i = 1; i < M; i++) {
    if (sum >= M) {
      cout << i;
      return 0;
    }
    sum += N - 1;
  }
}

Measured memory_bytes: 3620
(defn input []
  (->> (clojure.string/split (read-line) #"\s")
    (map #(Integer/parseInt %))))

(defn TwoSwithches [[A B C D]]
  (let [t (- (min B D) (max A C))]
    (if (pos? t) t 0)))

(-> (input)
  TwoSwithches
  println)

Measured memory_bytes: 65408
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans=0,x[5];
    ll minOp=10;
    for(int i=0;i<5;i++){
        dbg cout<<ans<<endl;
        ll in=0;
        cin >>in;
        x[i]=in;
        ans+=in;
        dbg cout<<ans<<endl;
        if (in%10<minOp && in%10>0){
            ans-=in%10;
            ans+=minOp%10;
            minOp=in%10;
        }
        if (ans%10>0){
            ans=((ans/10)+1)*10;
        }
    }
    minOp=minOp%10;
    ans=((ans/10))*10;
    ans+=minOp;

    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <array>
#include <string>

typedef std::array<int, 26> Count;
typedef long long int llint;

int main(void){
  int n;
  std::cin >> n;

  std::map<Count, int> counting;

  for(int i=0; i<n; i++){
    std::string s;
    std::cin >> s;

    Count cnt = {};
    for(const auto& elem: s){
      cnt[elem-'a']+=1;
    }
    if(counting.find(cnt) == counting.end()) counting[cnt] = 0;
    counting[cnt]++;
  }

  llint ret = 0;
  for(const auto& elem: counting){
    llint num = elem.second;
    //std::cout << num << std::endl;
    ret += num * (num-1) / 2;
  }

  std::cout << ret << std::endl;
  return 0;
}


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

int n, k;

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

    long long ans = 0;
    for (int b=k+1; b<=n; b++) {
        ans += (b-k) * (n/b);
        if (n%b >= k) ans += n%b + min(0, 1-k);
    }

    cout << ans << '\n';
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
s=input().rstrip()
k=int(input())
n=len(s)
if s[n-1]==s[0]:
    x=s[0]
    a=0
    while a<n:
        if s[a]==x:
            a+=1
        else:
            break
    b=0
    while b<n:
        if s[n-1-b]==x:
            b+=1
        else:
            break
    if a==n:
        ans=(n*k)//2
        print(ans)
    else:
        ans=0
        p='!'
        l=0
        for i in range(a,n-b):
            if s[i]==p:
                l+=1
            else:
                ans+=l//2
                l=1
            p=s[i]
        ans+=l//2
        ans=ans*k+a//2+b//2+((a+b)//2)*(k-1)
        print(ans)
else:
    ans=0
    p='!'
    l=0
    for i in range(n):
        if s[i]==p:
            l+=1
        else:
            ans+=l//2
            l=1
        p=s[i]
    ans+=l//2
    print(ans*k)




Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	scanf("%d",&n);
	double s=0;
	int arr[n];
	for(int i=0;i<n;i++)
		scanf("%d",arr+i);
	sort(arr,arr+n);
	s=arr[0];
	for(int i=1;i<n;i++)
	{
		s+=arr[i];
		s/=2.0;
	}
	printf("%0.5lf\n",s);
	return 0;
}

Measured memory_bytes: 256
H,W =map(int,input().split())

a=[list(input()) for i in range(H)]
l_idx=[]
c_idx=[]
for i in range(H):
    for j in range(W):
        if a[i][j]=="#":
            l_idx.append(i)
            c_idx.append(j)

for i in range(W-1,-1,-1):
    if not i in c_idx:
        for j in range(H):
            a[j].pop(i)

for i in range(H):
    if i in l_idx:
        print("".join(a[i]))

Measured memory_bytes: 39024
'use strict';

Array.prototype._sort = Array.prototype.sort;
Array.prototype.sort = function (fn) {
	if (fn) {
		return this._sort(fn);
		
	} else if (typeof this[0] === 'number') {
		return this._sort((a, b) => a - b);
	
	} else {
		return this._sort();
	}
};

function gcd(a, b) {
	while (true) {
		if (a > b) {
			a = a % b;
			if (a === 0) return b;
		} else {
			b = b % a;
			if (b === 0) return a;
		}
	}
}

class Graph {
	constructor() {
		this.nodes = new Map();
		this.edges = [];
	}
	
	static fromNodePair(pairs) {
		let graph = new Graph(),
			nodes = graph.nodes,
			edges = graph.edges;
		
		for (let ab of pairs) {
			let a = ab[0], b = ab[1];
			
			if (!nodes.has(a)) nodes.set(a, []);
			if (!nodes.has(b)) nodes.set(b, []);
			
			let nodeA = nodes.get(a),
				nodeB = nodes.get(b);
			
			nodeA[nodeA.length] = b;
			nodeB[nodeB.length] = a;
			edges[edges.length] = [a, b];
		}
		
		return graph;
	}
}

const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');

const NK = lines[0].split(' ').map(Number);
const N = NK[0];
const K = NK[1];
const AB = lines.slice(1).map(l => l.split(' ').map(Number));

let graph = Graph.fromNodePair(AB),
	nodes = graph.nodes,
	edges = graph.edges;

let result = N;
const r = Math.floor(K / 2);

for (let i = 0; i < N; i++) {
	let visited = new Set(),
		que = [],
		d = 0,
		isBust = 0;
	
	if (K & 1) {
		// Odd
		if (i >= N - 1) break;
		que[que.length] = edges[i][0];
		que[que.length] = edges[i][1];
		visited.add(edges[i][0]);
		visited.add(edges[i][1]);
	} else {
		//Even
		que.push(i + 1);
		visited.add(i + 1);
	}
	
	while (que.length > 0) {
		if (d === r) {
			result = Math.min(result, N - visited.size);
			isBust = true;
			break
		}

		d++;
		
		let nextQue = [];

		for (let fromNode of que) {
			for (let nextNode of nodes.get(fromNode)) {
				if (visited.has(nextNode)) continue;
				
				nextQue[nextQue.length] = nextNode;
				visited.add(nextNode);
			}
		}
		
		que = nextQue;
	}
	
	if (!isBust || result === 0) {
		result = 0;
		break;
	}
}

console.log(result);

Measured memory_bytes: 20724
N,M = gets.split.map(&:to_i)
$es = {}
M.times {
  a,b = gets.split.map(&:to_i)
  $es[a] ||= {}; $es[b] ||= {}
  $es[a][b] = $es[b][a] = 1
}
def dig(status, a, depth = 0)
  return 1 if depth == N
  $es[a].keys.map { |b|
    s = 1 << b
    status & s == 0 ? dig(status | s, b, depth+1) : 0
  }.inject(:+)
end

p dig(1 << 1, 1, 1)

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

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

    string s, t;
    cin >> s >> t;

    for(int i = 0; i < s.length(); i++)
        if(s[i] != t[i]){
            cout << "No\n";
            return 0;
        }

    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
  int n,m,i,j;
  string sd,t,ans;
  cin >> sd >> t;
  n=sd.size();
  m=t.size();
  for (i=n-m;i>=0;i--){
    for (j=0;j<m;j++) if (sd[i+j]!='?' && sd[i+j]!=t[j]) break;
    if (j==m) break;
  }
  if (i==-1){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  ans=sd;
  for (j=0;j<m;j++) ans[i+j]=t[j];
  for (j=0;j<n;j++){
    if (j>=i && j<i+m) continue;
    if (sd[j]=='?') ans[j]='a';
    else ans[j]=sd[j];
  }
  cout << ans << endl;
  return 0;
}

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

vector<long int> DP(300001,1);
vector<long int> memonckmodp(300001,0);
vector<long int> memoexpbkp(300001,0);
bool flag = 0;

long int expbkp(long int b,long int k,long int p){
  if(memoexpbkp[b])return memoexpbkp[b];
  long int qb = b;
  b = DP[b];
  vector<long int> modp(1,b);
  long int q = b,ans = 1;
  for(long int i = 1;i < 34;i++){
    q = (q*q)%p;
    modp.push_back(q);
  }
  q = 1;
  for(long int i = 0;i <= 34;i++){
    if(k & q)ans = (ans * modp[i])%p;
    q *= 2;
  }
  memoexpbkp[qb] = ans;
  return ans;
}

long int nckmodp(long int n,long int k,long int p){
  if(memonckmodp[k] )return memonckmodp[k];
  long int ans = (((DP[n] * expbkp(k,p-2,p))%p) * expbkp(n-k,p-2,p))%p;
  memonckmodp[k] = ans;
  memonckmodp[n-k] = ans;
  return ans;
}

long int G(long int A,long int B){
  long int ans = 1,i = 2;
  while(i <= A && i <= B){
    while(1){
      if(A%i == 0 && B%i == 0 && i <= A && i <= B){
        A /= i;
        B /= i;
        ans *= i;
      }
      else break;
    }
    i++;
  }
  return ans;
}

vector<long int> first(long int N,long int A,long int B,long int K){
  vector<long int> ans;
  for(long int i = 0;i <= N && A * i <= K;i++){
    if((K - A * i)%B == 0 && (K - A * i + B - 1)/B <= N){
      ans.push_back(i);
      ans.push_back((K-A*i)/B);
      return ans;
    }
  }
  flag = 1;
  ans.push_back(0);
  ans.push_back(0);
  return ans;
}

int main() {
  long int N,A,B,K,sum = 0,p = 998244353;
  for(long int i = 1;i <= 300000;i++)DP[i] = (DP[i - 1] * i)%p;
  cin >> N >> A >> B >> K;
  vector<long int> v = first(N,A,B,K);
  long int a = A / G(A,B),b = B / G(A,B),X = v[0],Y = v[1];
  if(flag)cout << 1 << endl;
  else{
    while(X >= 0 && Y >= 0 && X <= N && Y <= N){
      sum = (sum + nckmodp(N,X,p) * nckmodp(N,Y,p))%p;
      X += b;
      Y -= a;
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 7296
#include<stdio.h>
 
int main(void){
	int N=0,max=0,sum=0;
  	scanf("%d",&N);
	int p[N];
  for(int i=0;i<N;i++){
  	scanf("%d",&p[i]);
    if(max<p[i]) {
    	max=p[i];
    }
    sum+=p[i];
  }
  sum-=max/2;
  printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }
    
    static final char[] alphabet = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        String S = scan.next();

        char[] charS = S.toCharArray();
        for (int i = 0; i < charS.length; i++) {
            int pos = Arrays.binarySearch(alphabet, 0, 26, charS[i]);
            pos = (pos + N) % 26;
            os.print(alphabet[pos]);
        }
        os.println();
    }
}

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

int main(){
    int n,tmp=0,ans=0;
    cin >> n;
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='I')tmp++;
        if(s[i]=='D')tmp--;
        if(ans<tmp)ans=tmp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, k = input().split()
a = int(a)
b = int(b)
k = int(k)
s = set()

for i in range(k):
   if a <= (a+i) <= b:
      s.add(a+i)
for j in range(k):
   v = b - (k - j - 1)
   if a <= v <= b:
      s.add(v)

for l in sorted(s):
   print(l)


Measured memory_bytes: 3060
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e16;
const double EPS=1e-8;
const ll mod = 1000000007;


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


Measured memory_bytes: 256
#include<stdio.h>

int gcd(int a, int b){
  int tmp,r;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  
  return b;
}

int main(){
  
  int N;
  
  scanf("%d",&N);
  int i;
  int gcdd;
  int A[N];
  for(i=0;i<N;i++)
    scanf("%d ",&A[i]);
  gcdd =A[0];
  for(i=1;i<N;i++){
    gcdd = gcd(gcdd,A[i]);
  }
  
  printf("%d\n",gcdd);
  return 0;
}
    
  


Measured memory_bytes: 512