akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll h, w;
  while (cin >> h >> w) {
    if (h!=0 && w!=0) {
      rep(i, h) {
        rep(j, w) {
          if (i%2 == 0) {
            if (j%2 == 0) {
              cout << '#';
            } else {
              cout << '.';
            }
          } else {
            if (j%2 == 0) {
              cout << '.';
            } else {
              cout << '#';
            }
          }
        }
        cout << endl;
      }
      cout << endl;
    }
  }
}


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

using namespace std;

const int MAXN = 100005;
const int LOG = 19;

int n, k, sol;
int a[MAXN], dub[MAXN], par[LOG][MAXN], bio[MAXN];
vector <int> v[MAXN];
set < pair <int, int> > st;

void dfs (int x) {
    dub[x] = 1 + dub[par[0][x]];
    st.insert({-dub[x], x});
    for (auto sus : v[x]) dfs(sus);
}

void precompute () {
    for (int i=1; i<=n; i++) {
        par[0][i] = a[i];
    }
    par[0][1] = 1;
    for (int i=1; i<LOG; i++) {
        for (int j=1; j<=n; j++) {
            par[i][j] = par[i - 1][par[i - 1][j]];
        }
    }
}

int kth (int x, int k) {
    if (k > n) return 1;
    int pot = 0;
    while (k > 0) {
        if (k & 1) x = par[pot][x];
        k /= 2;
        pot++;
    }
    return x;
}

void brisi (int x) {
    if (bio[x]) return;
    bio[x] = 1;
    st.erase({-dub[x], x});
    for (auto sus : v[x]) {
        brisi(sus);
    }
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for (int i=1; i<=n; i++) {
        cin >> a[i];
        if (i > 1) v[a[i]].push_back(i);
    }
    if (a[1] != 1) sol++;
    precompute();
    dfs(1);
    while (!st.empty()) {
        int x = st.begin() -> second;
        if (kth(x, k) == 1) break;
        sol++;
        brisi(kth(x, k - 1));
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 25216
//This Code was made by Chinese_zjc_.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <ctime>
// #include<windows.h>
#define int long long
#define double long double
using namespace std;
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
const int MOD = 1000000007;
int n, a[500005], cnt0, ans, dp[1 << 20][2], cnt, sum[1 << 20];
int power(int A, int B)
{
    int res = 1;
    while (B)
    {
        if (B & 1)
        {
            res = res * A % MOD;
        }
        A = A * A % MOD;
        B >>= 1;
    }
    return res;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
        a[i] ^= a[i - 1];
        if (a[i] == 0)
        {
            ++cnt0;
        }
    }
    for (int i = 1; i <= n; ++i)
    {
        dp[a[i]][0] = 1;
    }
    for (int i = 1; i < n; ++i)
    {
        if (a[i])
        {
            (dp[a[i]][0] = dp[a[i]][0] + dp[a[i]][1] * (cnt - sum[a[i]])) %= MOD;
            (dp[a[i]][1] = dp[a[i]][0] + dp[a[i]][1]) %= MOD;
            sum[a[i]] = cnt;
        }
        else
        {
            ++cnt;
        }
    }
    if (a[n])
    {
        (ans = dp[a[n]][0] + dp[a[n]][1] * (cnt - sum[a[n]])) %= MOD;
    }
    else
    {
        ans = power(2, cnt0 - 1);
        for (int i = 1; i < 1 << 20; ++i)
        {
            (ans += dp[i][1]) %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 32124
import collections
n = int(input())
s = [input() for _ in range(n)]
s_count = collections.Counter(s)
print("AC x {}".format(s_count["AC"]))
print("WA x {}".format(s_count["WA"]))
print("TLE x {}".format(s_count["TLE"]))
print("RE x {}".format(s_count["RE"]))

Measured memory_bytes: 16608
#include<iostream>
#include<vector>
#include <map>
#include <utility>
#include <algorithm>
#include <functional>

using namespace std;
int main() {
	char a;
	cin >> a;
	if (a == 'a'||a == 'i'||a == 'u'||a == 'e'||a == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)

      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w,r;
string s,s1,s2;
vl v;
//vl vis,d;
ll a[30][30];vl dp(1<<22,-1);

ll sg(ll x){
    if(x==0)return 1;
    if(dp[x]!=-1)return dp[x];
    ll p=0;
    fo(i,n)p+=(((1<<i)&x)>0);
    dp[x]=0;
    fo(i,n){
        if(a[p-1][i]==1&&((1<<i)&x))dp[x]+=sg(x^(1<<i)),dp[x]%=mod;
    }
    //cout<<x<<" "<<dp[x]<<" "<<p<<el;
    return dp[x];
}

int main() {
    IOS;
    cin>>n;
    fo(i,n)fo(j,n)cin>>a[i][j];
    cout<<sg((1<<n)-1);
    return 0;
}



Measured memory_bytes: 33024
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	if m == 0 {
		fmt.Println(n * 100)
		return
	}
	md := 1
	for i := 0; i < m; i++ {
		md *= 2
	}
	d := float64(md)
	sum := float64(0)
	for i := 0; ; i++ {
		v := float64(1900*m*(i+1)+100*(n-m)*(i+1)) / d
		if v < 0.001 {
			break
		}
		sum += v
		d *= float64(md)
		d /= float64(md - 1)
	}
	fmt.Println(math.Ceil(sum))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int A, B;
int main() {
  cin >> A >> B;

  int ans;
  if (A <= 5) {
    ans = 0;
  } else if (A <= 12) {
    ans = B / 2;
  } else {
    ans = B;
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main()
{
	int n, d, x;
	cin >> n >> d >> x;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		x += (d-1)/a + 1;
	}
	cout << x << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
bool dp[8000][16001][2];
int ori = 8000;
int main()
{
	string s;
	int tarx, tary, n, f = 0, tcount[2] = {0, 0};
	cin >> s >> tarx >> tary;
	s += 'T';
	n = s.size();
	for(; f < n && s[f] == 'F'; ++f){}
	dp[0][ori][0] = true;
	dp[0][ori + f][1] = true;
	for(int i = f, isx = true, fcount = 0; i < n; ++i)
	{
		if(s[i] == 'T')
		{
			for(int j = 0; j <= 16000; ++j)
			{
				if(dp[tcount[isx]][j][isx])
				{
					if(0 <= j - fcount)
					{
						dp[tcount[isx] + 1][j - fcount][isx] = true;
					}
					if(j + fcount <= 16000)
					{
						dp[tcount[isx] + 1][j + fcount][isx] = true;
					}
				}
			}
			++tcount[isx];
			fcount = 0;
			isx = !isx;
		}
		else
		{
			++fcount;
		}
	}
	printf(dp[tcount[0]][tary + ori][0] && dp[tcount[1]][tarx + ori][1] ? "Yes\n" : "No\n");
}

Measured memory_bytes: 123392
pattern = %w(# .)
while true
  h, w = gets.chomp.split(/\s/).map(&:to_i)
  break if h == 0 && w == 0
  h.times do |i|
    w.times do |j|
      print pattern[(j + (i % 2)) %2]
    end
    puts ""
  end
  puts ""
end

Measured memory_bytes: 8740
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int , int> pi;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2<<endl;
	return 0;
};


Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 200006
#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
typedef long long ll;
int n , a , b;
int occ[MAXN];
void solve() {
	cin >> a >> b >> n;
	cout << ( a * min( n , b - 1 ) ) / b << endl;
}

signed main() {
//    int T;cin >> T;while( T-- ) solve();
    solve();
}

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

int main(void) {
    while (true) {
        string x;cin>>x;
        if (x == "0") break;
        int sum = 0;
        for (int i = 0; i < x.size(); i++) {
            sum += stoi(x.substr(i, 1));
        }
        cout << sum << endl;
    }
    return 0;
}


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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
constexpr long long MOD(long long in) {
	return in % mod;
}

std::string s;
std::map<char, int> m;
int main() {
	std::cin >> s;

	for (int i = 0; i < 4; ++i)
		++m[s[i]];

	int num = m.size();
	bool ok = true;
	for (auto mm : m) {
		if (mm.second != 2)
			ok = false;
	}

	if (num == 2 && ok)
		std::cout << "Yes" << std::endl;
	else
		std::cout << "No" << std::endl;
	return 0;
}


Measured memory_bytes: 256
import fractions
import math

def main():
    buf = input()
    buflist = buf.split()
    A = int(buflist[0])
    B = int(buflist[1])
    C = int(buflist[2])
    D = int(buflist[3])
    l = (C * D) // fractions.gcd(C, D)
    cA = A // C * C + (0 if A % C == 0 else C)
    cB = B // C * C
    c_count = max(0, (cB - cA) // C + 1)
    dA = A // D * D + (0 if A % D == 0 else D)
    dB = B // D * D
    d_count = max(0, (dB - dA) // D + 1)
    lA = A // l * l + (0 if A % l == 0 else l)
    lB = B // l * l
    l_count = max(0, (lB - lA) // l + 1)
    selected = c_count + d_count - l_count
    unselected = (B - A + 1) - selected
    print(unselected)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5076
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

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

map<int,bool>m;
int WA[100100];

int main()
{
    weewoo;
    ll n,d;
    cin >> n >> d;
    ll ac=0;
    ll wa=0;
    for(int i=0;i<d;i++){
        int x;string y;
        cin >> x >> y;
        if(!m[x]){
            if(y=="WA")
                WA[x]++;
            else{
                ac++;
                m[x]=1;
            }
        }
    }
    for(int i=1;i<=n;i++){
        if(m[i])
            wa+=WA[i];
    }
    cout << ac << ' ' << wa << endl;
    return 0;
}


Measured memory_bytes: 5248
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<stack>
#include<vector>
//#include<conio.h>
#include<string>
#include<map>
#include<cstdlib>
#include<queue>
#include<math.h>
#include<time.h>
#include<set>
#include<cstdio>
#include<stdio.h>
#include<algorithm>
using namespace std;
char s[3];
int main(){
	cin>>s;
	if(s[0]=='9'||s[1]=='9') cout<<"Yes\n";
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define exchange(a,b) do{__typeof(a) __t; __t=a; a=b; b=__t;}while(0)
#define parent(i) (i/2)
#define left(i) (i*2)
#define right(i) (i*2+1)
#define MAX_N 500001

int N;
int heap[MAX_N];

void maxHeapify(int A[], int i) {
  int l = left(i);
  int r = right(i);
  int largest;
  if(l <= N && A[l] > A[i]) {
    largest = l;
  } else {
    largest = i;
  }
  if(r <= N && A[r] > A[largest]) {
    largest = r;
  }
  if(largest != i) {
    exchange(A[i], A[largest]);
    maxHeapify(A, largest);
  }
}

void buildMaxHeap(int A[]) {
  int i;
  for(i = N/2; i >= 1; --i) {
    maxHeapify(A, i);
  }
}

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

Measured memory_bytes: 2356
N, K = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

def g(n, k, h):
    g = abs(h[1] - h[0])
    gk = [0] * n
    gk[1] = g
    for i in range(2, n):
        h_i = h[i]
        j = max(i - k, 0)
        g = min(abs(h_i - h_j) + h_k for h_j, h_k in zip(h[j:i], gk[j:i]))
        gk[i] = g
    return g

print(g(N, K, h))


Measured memory_bytes: 13976
#include<bits/stdc++.h>
#define MAXN 110
using namespace std;
int main()
{
    int n,a[2][MAXN],up[MAXN],down[MAXN];
    cin >> n;
    for(int i = 0;i < 2;i++){
        for(int j = 0;j < n;j++){
            cin >> a[i][j];
            if(i == 0){
                if(j == 0){
                    up[j] = a[i][j];
                }
                else{
                    up[j] = up[j - 1] + a[i][j];
                }
            }
        }
    }
    down[n - 1] = a[1][n - 1];
    for(int j = n - 2;j >= 0;j--){
        down[j] = down[j + 1] + a[1][j];
    }
    int sum = 0;
    int maxs = 0;
    for(int i = 0;i < n;i++){
        sum = up[i] + down[i];
        maxs = max(maxs,sum);
    }
    cout << maxs << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#define N 1001

int max(int a,int b){
  if(a>b)return a;
  else return b;
}

int lcs(char a[],char b[]){
  int i,j,c[N][N]={};
   int maxl=0;
   int xl=strlen(a);
   int yl=strlen(b);

   for(i=0;i<=xl;i++)c[i][0]=0;
   for(j=1;j<=yl;j++)c[0][j]=0;

   for(i=1;i<=xl;i++){
     for(j=1;j<=yl;j++){
       if(a[i-1]==b[j-1])
	 c[i][j]=c[i-1][j-1]+1;
       else
	 c[i][j]=max(c[i-1][j],c[i][j-1]);
       maxl=max(maxl,c[i][j]);
     }
   }

   return maxl;
 }


int main(){
  char A[N],B[N];
  int i,n;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",A);
    scanf("%s",B);
    printf("%d\n",lcs(A,B));
  }

  return 0;
}



Measured memory_bytes: 5712
/**
 * 
 */
import java.util.Scanner;

/**
 * @author Neeraj
 *
 */
 class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		if(s.equals("ABC"))
			System.out.println("ARC");
		else
			System.out.println("ABC");
			
			
	}

}


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

string s[3];

int main() {
	int player = 0;
	int cor[3] = {0};
	
	cin >> s[0] >> s[1] >> s[2];
	
	while (true) {
		if (cor[player] == s[player].length()) break;
		char dischard = s[player][cor[player]++];
		player = dischard - 'a';
	}
	cout << (char)(player + 'A') << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

struct unionfind
{
    vector<ll> d;

    unionfind(ll n) : d(n, -1) {}

    ll root(ll x)
    {
        if (d[x] < 0)
        {
            return x;
        }
        else
        {
            return d[x] = root(d[x]);
        }
    }

    bool unite(ll x, ll y)
    {
        x = root(x);
        y = root(y);

        if (x == y)
        {
            return false;
        }

        if (d[x] > d[y])
        {
            swap(x, y);
        }

        d[x] += d[y];
        d[y] = x;
        return true;
    }

    bool same(ll x, ll y)
    {
        return root(x) == root(y);
    }

    ll size(ll x)
    {
        return -d[root(x)];
    }
};

int main(void)
{
    ll n, m;

    cin >> n >> m;

    unionfind u(n + 1);
    stack<P> s;
    set<ll> t;
    vector<ll> ans(m, 0);

    for (ll i = 0; i < m; i++)
    {
        ll a, b;

        cin >> a >> b;

        a--;
        b--;

        s.push(P(a, b));
    }

    ll res = 0;

    ans[m - 1] = (n * n - n) / 2;

    for (ll i = 1; i < m; i++)
    {
        P p = s.top();
        s.pop();

        if (u.same(p.first, p.second))
        {
            ans[m - i - 1] = ans[m - i];
        }
        else
        {
            ans[m - i - 1] = ans[m - i] - u.size(p.first) * u.size(p.second);
        }

        u.unite(p.first, p.second);
    }

    for (auto a : ans)
    {
        cout << a << endl;
    }
}


Measured memory_bytes: 3896
#include<iostream>

using namespace std;

int main(void){

    char str[100];
    bool flag = true;

    cin >> str;

    for(int i = 0;str[i] != '\0';i++){
        if(!(str[i] == 'R' || str[i] == 'U' || str[i] == 'D') && i % 2 == 0) flag = false;
        if(!(str[i] == 'L' || str[i] == 'U' || str[i] == 'D') && i % 2 != 0) flag = false;
    }

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#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<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n/i) res.push_back(n / i);
    }
  }
  return res;
}

int main() {
  ll n, ans = 0; cin >> n;
  vector<ll> a = divisor(n);
  for (auto u : a) {
    if (u == 1) continue;
    ll n2 = n;
    while (n2 % u == 0) {
      n2 /= u;
    }
    if (n2 % u == 1) {
      ans++;
    }
  }
  vector<ll> b = divisor(n-1);
  ans += (ll)b.size() - 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
//
int GCD(int A,int B){
  if(B==0){
    return A;
  }else{
    return GCD(B,A%B);
  }
}
int main(){
  int X,Y;
  cin>>X>>Y;
  int N=GCD(X,Y);
  int U=(X/N)+(Y/N);
  cout<<(U-1)*N+1<<endl;
  return 0;
}


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

#define ll long long
#define pq priority_queue
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int main() {
   string a, b;
   cin >> a >> b;
   string s = a + b;
   int c = stoi(s);
   for (int i = 1; i <= 1000000; i++) {
      if (i*i == c) {
         puts("Yes");
         return 0;
      }
   }
   puts("No");

   return 0;
}

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

using namespace std;

const int N=100005;

vector<int>e[N],d[N];
int n;

int dfs(int x){
	for(int v:e[x])d[x].push_back(dfs(v));
	sort(d[x].begin(),d[x].end());
	int a=0,c=d[x].size();
	for(int v:d[x])a=max(a,v+c--);
	return a;
}

int main(){
	scanf("%d",&n);
	for(int i=2,u;i<=n;i++)scanf("%d",&u),e[u].pb(i);
	printf("%d\n",dfs(1));
	return 0;
}

Measured memory_bytes: 18944
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define MOD 1000000007
lli a[100010];
lli b[200020];
lli c[200020];
lli n, m;
lli fun1(lli x)
{
	lli res = 0ll;
	for (lli i = 1ll; i <= n; ++i)
		res += b[max(0ll, x - a[i])];
	return res;
}
lli fun2(lli x)
{
	lli res = 0ll;
	for (lli i = 1ll; i <= n; ++i)
		res += (c[max(0ll, x - a[i])] + a[i] * b[max(0ll, x - a[i])]);
	return res;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m;
	for (lli i = 1ll; i <= n; ++i)
	{
		cin >> a[i];
		b[a[i]]++;
		c[a[i]] += a[i];
	}
	for (lli i = 100000ll; i >= 0ll; --i)
	{
		b[i] += b[i + 1];
		c[i] += c[i + 1];
	}
	lli l = 0ll, r = 200000ll, mid;
	while (l < r)
	{
		mid = (l + r + 1ll) / 2ll;
		if (fun1(mid) >= m)
			l = mid;
		else
			r = mid - 1ll;
	}
	cout << fun2(l + 1ll) + (m - fun1(l + 1ll))*l;
}

Measured memory_bytes: 2560
import java.util.PriorityQueue
import kotlin.comparisons.compareByDescending
fun main(arg: Array<String>) {
    val (N, M) = listOfInt()
    val jobs = Array(M) { mutableListOf<Int>() }
    repeat(N) {
        val (A, B) = listOfInt()
        if (A <= M) jobs[M - A].add(B)
    }
    var ans = 0L
    val q = PriorityQueue<Int>(N, compareByDescending { it })
    for (n in (0 until M).reversed()) {
        jobs[n].forEach { q.add(it) }
        if (q.size > 0) {
            ans += q.poll()!!
        }
    }
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }


Measured memory_bytes: 69772
n = int(input())
a = [list(map(int,input().split())) for _ in range(n)]

now = 0
p = [0,0]
for i in range(n):
    t = a[i][0] - now
    dis = abs(a[i][1] - p[0]) + abs(a[i][2] - p[1])
    
    if dis <= t:
        if t % 2 == 0:
            if dis % 2 != 0:
                print('No')
                exit()
        else:
            if dis % 2 != 1:
                print('No')
                exit()
    else:
        print('No')
        exit()
        
    p[0] = a[i][1]
    p[1] = a[i][2]
    now = a[i][0]
else:
    print('Yes')

Measured memory_bytes: 27324
/**
*    author:  yuya1234
*    created: 14.07.2020 14:08:21
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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; }
template<class T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T>T lcm(T a,T b){return gcd(a,b)*(a/gcd(a,b))*(b/gcd(a,b));}


int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  //std::cout << std::fixed << std::setprecision(15);

  int n;
  cin>>n;

  ll t[n];
  REP(i,n)cin>>t[i];

  ll ans=t[0];
  FOR(i,1,n-1)
  {
    ans=lcm(ans,lcm(t[i-1],t[i]));
  }

  cout<<ans<<endl;


  return 0;
}

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

#define int long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

signed main() {
    int x, y;
    cin >> x >> y;
    if ( x == y || x % y == 0 ) cout << -1 << endl;
    else cout << x*1000000007 << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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


Measured memory_bytes: 256
import java.io.InputStream
import java.io.BufferedReader

fun main(args: Array<String>) {
  val inputStream = System.`in`
  val allText = inputStream.bufferedReader()
                           .use(BufferedReader::readText)
  allText.trim().split('\n')
         .map { s->
            val l = s.split(' ').map{ t -> t.toDouble() }
            val adbc = l[0]*l[4]-l[1]*l[3]
            val x = l[2]*l[4]-l[1]*l[5]
            val y = l[0]*l[5]-l[2]*l[3]
            "%.3f %.3f".format(x/adbc+0, y/adbc+0)
         }
         .forEach{ println(it) }
}


Measured memory_bytes: 31868
from collections import deque

n = int(input())
a = list(map(int,input().split()))

d = deque()

for i in range(n):
    if n%2 == 0 and i%2 == 0:
        d.append(a[i])
    elif n%2==1 and i%2==1:
        d.append(a[i])
    else:
        d.appendleft(a[i])
print(' '.join(map(str,list(d))))

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

using namespace std;

typedef long long ll;

struct FenwickTree{
	vector<ll> data;
	FenwickTree(int n):data(n+1){}
	void AddRange(int i,int x){
		for(;i;i-=i&-i)
			data[i]+=x;
	}
	void AddRange(int i,int j,int x){
		AddRange(i,-x);
		AddRange(j,x);
	}
	int Get(int i){
		ll res=0;
		for(i++;i<data.size();i+=i&-i)
			res+=data[i];
		return res;
	}
};

int main()
{
	const int MOD=1e9+7;
	vector<ll> f(100001); f[0]=1;
	for(int i=1;i<f.size();i++)
		f[i]=f[i-1]*i%MOD;
	
	for(int n,r;cin>>n>>r && n;){
		int a[n]; iota(a,a+n,0);
		for(int i=0;i<r;i++){
			int x,y; cin>>x>>y; x--,y--;
			swap(a[x],a[y]);
		}
		
		FenwickTree rank(n);
		for(int i=1;i<n;i++)
			rank.AddRange(i,n,1);
		
		int res=0;
		for(int i=0;i<n;i++){
			res=(res+f[n-1-i]*rank.Get(a[i]))%MOD;
			rank.AddRange(a[i]+1,n,-1);
		}
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3132
#!venv/bin/python
#from collections import defaultdict 
from itertools import combinations
import math
import datetime
import numpy
from pprint import pprint
N = int(input())
A = [int(x) for x in input().split()]

ans = []

ans1 = 0
plus = 1
for i in range(N):
    ans1 += plus * A[i]
    plus *= -1

ans.append(ans1)
plus = -1
for i in range(1,N):
    t = i - 1
    a = ans[t] + plus * 2 * A[t]
    plus *= -1
    ans.append(a)

print(" ".join([str(abs(s)) for s in ans]))



Measured memory_bytes: 28144
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e2 + 7;
const int mod = 1e9+7;
int n,m;
char a[N][N];
bool x[N],y[N];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%s",a[i]+1);
    }
    for(int i=1;i<=n;i++){
        bool flag=1;
        for(int j=1;j<=m;j++){
            if(a[i][j]=='#'){
                flag=0;break;
            }
        }
        if(flag)x[i]=1;
    }
    for(int j=1;j<=m;j++){
        bool flag=1;
        for(int i=1;i<=n;i++){
            if(a[i][j]=='#'){
                flag=0;break;
            }
        }
        if(flag)y[j]=1;
    }
    for(int i=1;i<=n;i++){
        if(x[i])continue;
        bool flag=0;
        for(int j=1;j<=m;j++){
            if(y[j])continue;
            flag=1;
            putchar(a[i][j]);
        }
        if(flag)puts("");
    }
}

Measured memory_bytes: 256
/***********
* Coded by *
*   ACS    *
***********/

// p: Problem F. Largest Rectangle
// j: VJUDGE
// c: Contest1 Div 1

#include <bits/stdc++.h>

#define cic(in,n) for(int i=in;i<n;i++)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define All(a) a.begin(),a.end()
#define PB push_back
#define FIND(m,v) (m.find(v) != m.end())
#define print(n) cout<<n<<"\n"
#define CLR(m) memset(m, 0, sizeof(m))

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
const int MAX = 2e3 + 100, mod = 1e9 + 7, oo = INT_MAX;

int m, n, Mx[MAX][MAX], Upx[MAX][MAX];

int Lw[MAX], stk[MAX];
int BestRectangleByLine(int H[MAX])
{
    rep(i,0,n) Lw[i] = 1;  // Clean Memory
    for(int i = 0, pl = 0; i < n; stk[pl++] = i++)  // Find prev[i];
    {
        for(; pl > 0 && H[i] <= H[stk[pl-1]] ; pl--); // prev[i] = stk[pl]
        if(pl == 0) Lw[i] += i;
        else        Lw[i] += i - stk[pl-1] - 1;
    }
    for(int i = n-1, pl = 0; i >= 0; stk[pl++] = i--) // Find next[i];
    {
        for(; pl > 0 && H[i] <= H[stk[pl-1]] ; pl--);    // next[i] = stk[pl]
        if(pl == 0) Lw[i] += n - 1 - i;
        else        Lw[i] += stk[pl-1] - i - 1;
    }
    int solve = 0;
    rep(i,0,n) solve = max(solve, Lw[i]*H[i]);
    return solve;
}

int BestRectangle()
{
    rep(i,0,n) Upx[0][i] = ((Mx[0][i] == 0)?1:0);
    int solve = BestRectangleByLine(Upx[0]);
    rep(i,1,m)
    {
        rep(j,0,n)
            if(!Mx[i][j]) Upx[i][j] += Upx[i-1][j] + 1;
            else Upx[i][j] = 0;
        solve = max(solve, BestRectangleByLine(Upx[i]));
    }
    return solve;
}


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

    cin >> m >> n;
    rep(i,0,m) rep(j,0,n) cin >> Mx[i][j];
    print(BestRectangle());
    return 0;
}






Measured memory_bytes: 26148
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include <set>
typedef long long ll;
using namespace std;
int a[1000005],maxx=-1,minn=1e9,mid;
double midd;
ll sum,sum1;
int main()
{
	int n,i,j;
	cin>>n>>i;
	j=n-i+1;
	cout<<j;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

int main()
{
	long n;
	std::cin >> n;
	std::string text;

	long value = 0;
	int max;
	for (max = 1;; ++max)
	{
		value += std::pow(26, max);

		if (value >= n)
		{
			//std::cout << value << std::endl;
			break;
		}
	}

	for (int i = max; i >= 1; --i)
	{
		long pog = std::pow(26, i - 1);
		for (int j = 25;; j--)
		{
			if (value - pog < n)
			{
				text += char(0x61 + j);

				break;
			}
			else value -= pog;
		}
	}
	std::cout << text << std::endl;
}


Measured memory_bytes: 4008
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >

using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=2e5+10, mod=1e9+7;
vector<ll> G[N];
ll n , q;
ll ans[N];

void dfs(int v,int par,ll val){
    ans[v] += val;
    for(auto u:G[v]){
        if(u!=par){
            dfs(u,v,ans[v]);
        }
    }
}

int main ()
{
    FASTIO
    cin >> n >> q;
    for(int i=0;i<n-1;i++){
        ll u ,v;
        cin >> u >> v;
        G[u].pb(v);
        G[v].pb(u);
    }
    while(q--){
        ll v,x;
        cin >> v >> x;
        ans[v] += x;
    }
    dfs(1,-1,0);
    for(int i=1;i<=n;i++)cout << ans[i] << ' ';
    cout << endl;
    return 0;
}
/**

*/


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

int main()
{
	int n, x, i, coun=0;
	bool flag = true;
	cin >> n;
	while (n--)
	{	flag=true;
		cin >> x;
		if (x == 2) {coun++; continue;}
		else;
		
		int k= sqrt(x);
		
		if (x % 2 == 0)continue;
		else 
		{
			for (i = 3; i <= k; i++)
				if (x% i == 0)
					flag = false;
		}

		if (flag)
		coun++;
	}
	cout << coun<<endl;
	return 0;
}


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

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0;i < s.size()/2;i++){
        if (s[i] != s[s.size()-i-1]) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
# 初期入力　　２０２０－０７２７　21：50
import sys
input = sys.stdin.readline  #文字列では使わない
X = int(input())
ans =0
Possible =[]
if X >=2000:
    ans =1
else:
    Possible =[(i*100,i*105) for i in range(1,21)]
    for p in Possible:
        if p[0] <= X <=p[1]:
            ans =1
            break
print(ans)

Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

void mex(ll i,vector<ll>&ans,vector<vector<ll>>&G,set<ll>base){
  for(auto u:G[i]){
    base.erase(ans[u]);
  }
  ans[i]=*base.begin();
}

bool solve(){
  ll n,K;cin>>n>>K;
  vector<vector<ll>>G(K+1);
  vector<ll>a(n);
  rep(i,n)cin>>a[i];

  vector<bool>dp(K+1,false);
  rep(i,K+1){
    dp[i]=false;
    rep(j,n){
      if(i-a[j]>=0)dp[i] = (!dp[i-a[j]]) or dp[i];
    }
  }

  cout<<(dp[K] ? "First" : "Second")<<endl;

  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 2560
n, m = gets.split(" ").map(&:to_i)

a = []
n.times do |i|
    a[i] = gets.split(" ").map(&:to_i)
end

b = []
m.times do |i|
    b[i] = gets.to_i
end

a.each do |x|
    k = 0
    x.size.times do |i|
        k += x[i] * b[i]
    end
    print k, "\n"
end



Measured memory_bytes: 6976
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	double k;
	cin>>n;
	if (n%2==0)  k=0.5;
	else k=((n/2)+1)*1.0/n;
	cout<<fixed<<setprecision(10)<<k<<endl;
	return 0;
}

Measured memory_bytes: 256
S=input()
p=0
g=0
for i in range(len(S)):
    if S[i]=="p":
        p+=1
    elif S[i]=="g":
        g+=1

if len(S)%2==0:
    print(int(len(S)/2)-p)
else:
    print(int((len(S)-1)/2)-p)


Measured memory_bytes: 3316
s=str(input())
if 1<=int(s[:2])<=12 and 1<=int(s[2:])<=12:
  print("AMBIGUOUS")
elif 1<=int(s[:2])<=12:
  print("MMYY")
elif 1<=int(s[2:])<=12:
  print("YYMM")  
else:
  print("NA")


Measured memory_bytes: 9072
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <queue>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

class Compare
{
	public:
		bool operator() (const pair<int,int> p,const pair<int,int> p2)
		{
			if(p.first == p2.first) return p.second < p2.second;
			else return p.first > p2.first;
		}
};

int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<pair<int,int> > v;
		rep(i,n)
		{
			
			vector<pair<int,int> > temp;
			vector<string> data;
			int num;
			cin >> num;
		
			int cnt = 0;
			while(cnt != 10)
			{
				int a,b,last;
				cin >> a;

				if(a == 10)
				{
					temp.push_back(make_pair(a,0));
					cnt++;
					data.push_back("st");

					if(cnt == 10)
					{
						int t;
						cin >> t;

						if(t == 10)
						{
							int t2;
							cin >> t2;
							temp.push_back(make_pair(t,0));
							data.push_back("st");

							temp.push_back(make_pair(t2,0));
							data.push_back("st");
							
						}
						else
						{
							int t2;
							cin >> t2;
							temp.push_back(make_pair(t,t2));
							if(t+t2 == 10) data.push_back("sp");
							else data.push_back("no");
						}
					}
				}
				else
				{
					cin >> b;
					temp.push_back(make_pair(a,b));
					cnt++;

					if(a + b == 10)
					{
						data.push_back("sp");
						
						if(cnt == 10)
						{
							int t;
							cin >> t;
							temp.push_back(make_pair(t,0));
							
							if(t == 10) data.push_back("st");
							else data.push_back("no");
						}
					}
					else
					{
						data.push_back("no");
					}
				}
			}
			
			int ans = 0;
			rep(i,10)
			{
				if(data[i] == "no")
				{
					ans += temp[i].first + temp[i].second;
				}
				else if(data[i] == "sp")
				{
					ans += temp[i].first + temp[i].second + temp[i+1].first;
				}
				else if(data[i] == "st")
				{
					ans += temp[i].first + temp[i].second + temp[i+1].first + temp[i+1].second;
					if(data[i+1] == "st") ans += temp[i+2].first;
				}
			}	
			v.push_back(make_pair(ans,num));
		}

		sort(v.begin(),v.end(),Compare());

		rep(i,v.size())
		{
			cout << v[i].second << " " << v[i].first << endl;
		}
	}
	return 0;
}	

Measured memory_bytes: 1220
package main

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

func main() {
	N := nextInt64()
	ans := (N * (N - 1)) / 2
	fmt.Println(ans)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func Max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Min(s, v)
	}
	return s
}

func MaxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Max(s, v)
	}
	return s
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 640
# Studying https://atcoder.jp/contests/abc175/submissions/16084621

(R,C,K),*RCV = $<.map{|ln| ln.split.map(&:to_i) }

Rs = Array.new(R){ [] }
RCV.each{|s,d,v|
	Rs[s-1] << [d-1,v]
}

r0 = [0]*C
while r = Rs.shift
	r.empty? and next or r.sort!

	vs = [0]*4
	until r.empty?
		c,v = r.shift
		vs[0] = r0[c]
		vs[3] = vs[2]+v if vs[3] < vs[2]+v
		vs[2] = vs[1]+v if vs[2] < vs[1]+v
		vs[1] = vs[0]+v if vs[1] < vs[0]+v
		r0[c] = vs.max
	end

	c = 0
	r0[c] = r0[c-1] if r0[c] < r0[c-1] while C > c+=1
end

p r0[-1]


Measured memory_bytes: 36832
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=305,mod=998244353;
int n,k,m,a[N],sum[N];
int dp[N][N][N];
//dp[i][j][h] 第i个坑，用了j个1，移动了k次的方案数
char s[N];
int main()
{
    scanf("%s%d",s+1,&k);
    for(int i=1;s[i];i++) m+=s[i]=='1';
    int t=0;
    for(int i=1;s[i];i++)
        if(s[i]=='0') a[++n]=t,t=0;
    else t++;
    a[++n]=t;
    for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
    k=min(k,m);
    dp[0][0][0]=1;
    for(int i=0;i<n;i++)
        for(int j=sum[i];j<=sum[n];j++)
            for(int h=0;h<=k;h++)
        {
            for(int f=j;f<=sum[n];f++)
                if(f>=sum[i+1]&&h+f-j-a[i+1]<=k)
            {
                if(i+1==n&&f-j>a[i+1]) break;
                int cost=f-j<=a[i+1]?0:f-j-a[i+1];
                dp[i+1][f][h+cost]=(dp[i+1][f][h+cost]+dp[i][j][h])%mod;
            }
        }
    ll ans=0;
    for(int i=0;i<=k;i++) ans=(ans+dp[n][m][i])%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 30712
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  int N;in(N);
  vector<pair<int,int>>xy[30];
  rep(i,N){
    int A;in(A);
    rep(j,A){
      int x,y;
      in(x,y);
      x--;
      xy[i].pb(mp(x,y));
    }
  }
  int ans=0;
  for(int i=0;i<1<<N;i++){
    bool f=true;
    int cnt=0;
    for(int j=0;j<N;j++){
      if(i&1<<j){
        cnt++;
        for(auto e:xy[j]){
          if(e.sd==1&&(i&(1<<e.ft))==0)f=false;
          if(e.sd==0&&(i&(1<<e.ft))!=0)f=false;
        }
      }
    }
    if(f)ans=max(ans,cnt);
  }
  out(ans);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include <complex>
#include <iostream>
#include <cmath>
#include <vector>

constexpr double pi = 3.14159265358979323846264338327950288419716939937510582097494459;

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

		if (n == 0) {
			return 0;
		}

        std::vector<std::complex<double>> arr;
        arr.reserve(n);

		for (int i = 0; i < n; i++) {
			double x, y;

            std::cin >> x >> y;

			arr.emplace_back(x, y);
		}

		int max = 1;
		for(int i = 0; i < n; i++) {
		    for(int j = i + 1; j < n; j++) {
				auto sub = arr[j] - arr[i];

				if (std::abs(sub) >= 2) {
					continue;
				}
				auto sum = arr[j] + arr[i];

				{
					auto center = sum/2. + sub*std::polar(std::sqrt(1-std::abs(sub/2.) * std::abs(sub/2.))/std::abs(sub), pi/2);

					int counter = 0;
					for(int k = 0; k < n; k++) {
						if(i == k || j == k || std::abs(arr[k]-center) <= 1) {
							counter++;
						}
					}
					if (max < counter) {
						max = counter;
					}
				}

				{
					auto center = sum/2. + sub*std::polar(std::sqrt(1-std::abs(sub/2.) * std::abs(sub/2.))/std::abs(sub), -pi/2);

					int counter = 0;
                    for(int k = 0; k < n; k++) {
						if(i == k || j == k || std::abs(arr[k]-center) <= 1) {
							counter++;
						}
					}
					if (max < counter) {
						max = counter;
					}
				}
			}
		}

        std::cout << max << std::endl;
	}
}



Measured memory_bytes: 3168
#!/usr/bin/python3
import sys
input = lambda: sys.stdin.readline().strip()
x, n = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
for i in reversed(range(0, x + 1)):
    if i not in p:
        lt = i
        break
for i in range(x + 1, 102):
    if i not in p:
        gt = i
        break
print(lt if abs(lt - x) <= abs(gt - x) else gt)

Measured memory_bytes: 9072
import java.util.Scanner;

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){
		System.out.println("a < b");
	}else if(a>b){
		System.out.println("a > b");
	}else{
		System.out.println("a == b");
	}
	}
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i)
    cin >> A[i];

  int sum = 0;
  for (int i = 0; i < N; ++i)
    sum += A[i];
  vector<int> X(N);
  for (int i = 1; i < N; i += 2)
    sum -= 2 * A[i];
  X[0] = sum;
  for (int i = N - 1; i >= 1; --i)
    X[i] = 2 * A[i] - X[(i + 1 + N) % N];

  for (int i = 0; i < N; ++i) {
    cout << X[i];
    if (i == N - 1)
      cout << endl;
    else
      cout << ' ';
  }
}

Measured memory_bytes: 2048
n = gets.to_i
a = gets.split.map(&:to_i)
count = Hash.new(0)
a.each do |i|
  count[i] += 1
end
ans = 0
count.each do |key, val|
  if key < val
    ans += val - key
  elsif key > val
    ans += val
  end
end
p ans

Measured memory_bytes: 14468
#include<iostream>
using namespace std;
int main()
{
    int x,y,a,b;
    cin>>x>>y;
    a=y-2*x;
    b=4*x-y;
    if(a%2==0 && a/2>=0 && b%2==0 && b/2>=0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3516