akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)

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

// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;
// const double PI = M_PI;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  while (true) {
    int N;
    cin >> N;
    if (N == 0) {
      break;
    }
    vector<int> w(N);
    rep(i, N) { cin >> w[i]; }
    int dp[N][N + 1]; // [l, r)
    rep(i, N) { fill(dp[i], dp[i] + N + 1, 0); }

    for (int W = 2; W <= N; W++) {
      for (int l = 0; l < N; l++) {
        int r = l + W;
        if (r > N) {
          continue;
        }
        if (dp[l + 1][r - 1] == W - 2 && abs(w[l] - w[r - 1]) <= 1) {
          dp[l][r] = dp[l + 1][r - 1] + 2;
        }
        for (int k = l + 1; k < r; k++) {
          dp[l][r] = max(dp[l][r], dp[l][k] + dp[k][r]);
        }
      }
    }

    cout << dp[0][N] << endl;
  }
  return 0;
}



Measured memory_bytes: 3504
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[3] = {1,0,-1};
int dy[3] = {1,0,-1};
const int MOD = 1000000007;

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int H,W;
  char masu[101][101];
  cin >> H >> W;
  REP(i,H)
    cin >> masu[i];
  REP(i,H){
    cout << masu[i] << endl;
    cout << masu[i] << endl;
  }
  return 0;  
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
#define rep(i,n) for(int i=1; i<=n; i++)

class Dice{
private:
    
public:
    int *number,*work;
    Dice(){
        number = new int[7];
        work = new int[7];
    }
    ~Dice(){
        delete[] number;
        delete[] work;
    }
    
    void roll(char ch){
        rep(i,6) work[i]=number[i];
        switch(ch){
            case 'E':
                setnum(work[4],work[2],work[1],work[6],work[5],work[3]);
                break;
            case 'S':
                setnum(work[5],work[1],work[3],work[4],work[6],work[2]);
                break;
            case 'W':
                setnum(work[3],work[2],work[6],work[1],work[5],work[4]);
                break;
            case 'N':
                setnum(work[2],work[6],work[3],work[4],work[1],work[5]);
                break;
        }
    }
    
    void setnum(int n1, int n2, int n3, int n4, int n5, int n6){
        number[1] = n1;
        number[2] = n2;
        number[3] = n3;
        number[4] = n4;
        number[5] = n5;
        number[6] = n6;
    }
    
    void init(int i, int n){
        number[i]=n;
    }
};

int main(){
    Dice dice;
    int num;
    rep(i,6){
        scanf("%d",&num);
        dice.init(i,num);
    }
    getchar();
    char ch;
    while((ch = getchar()) != '\n'){
        dice.roll(ch);
    }
    cout << dice.number[1] << endl;
}


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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int h,n;
    cin>>h>>n;
    vector<int> A(n);
    for(auto &a : A ) cin>>a;
    int sum = accumulate(A.begin(),A.end(),0);
    if(sum < h) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
#include <list>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll table[61][61];
ll N,M;


void func(){

	ll sum = 0;
	int num_1;

	for(int k = 0; k <= N; k++){
		sum += table[N][k];
		if(sum >= M){
			num_1 = k;
			break;
		}
	}

	ll loc = sum-M+1;
	ll upper_num = 0;

	for(int digit = N; digit >= 1; digit--){
		if(num_1 == 0){
			for(int i = 0; i < digit; i++)printf("%d",0);
			break;
		}
		if(num_1 == digit){
			for(int i = 0; i < digit; i++)printf("%d",1);
			break;
		}

		if(upper_num+table[digit-1][num_1-1] >= loc){
			printf("1");
			num_1--;
		}else{
			upper_num += table[digit-1][num_1-1];
			printf("0");
		}
	}
	printf("\n");
}

int main(){

	for(ll n = 1; n <= 60; n++){
		table[n][0] = 1;
		table[n][1] = n;
		for(ll k = 2; k <= n; k++){
			table[n][k] = (table[n][k-1]*(n-(k-1)))/k;
		}
	}

	while(true){
		scanf("%lld %lld",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}

	return 0;
}

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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S; cin >> S;
    int X = 0;
    int ans = 0;
    rep(i, N) {
        if (S[i] == 'I') X++;
        else X--;
        ans = max(ans, X);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int gcd(int x, int y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

int main()
{
    int n, ans = 0, a;
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        cin>>a;
        ans = gcd(ans, a);
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256
Option Infer On
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N = NextInt()
        Dim M = Pow(10, 9) + 7

        Dim ans = 1L

        For i As Integer = 1 To N
            Dim j = i Mod M
            ans = (ans * j) Mod M
        Next

        WriteLine(ans)
    End Sub

    Function Pow(a As Long, b As Integer) As Long
        Dim result = 1L
        For i = 1 To b
            result *= a
        Next
        Return result
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 22596
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a;
    int b;
    
    cin >> a;
    cin >> b;
    
    if( (a * b) % 2 == 1){
        cout << "Odd" << endl;
    }
    if( (a * b) % 2 == 0){
        cout << "Even" << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
    int a,b,c,d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    if (a * b > c * d)
    {
        printf("%d", a * b);
    }
    
    else if (c * d > a * b)
    {
        printf("%d", c * d);
    }
    
    else if (a * b == c * d)
    {
        printf("%d", a * b);
    }
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
 
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  int max = 0;
  ll sum = 0;
  
  rep(i,n){
    if(max > a[i]){
      sum += max - a[i];
    }
    else max = a[i];
  }
  cout << sum << endl;
  return 0;
}

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

int main() {
    int a,b;
    cin>>a>>b;

    if(a%3==0 || b%3==0 || (a+b)%3==0) cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long  
#define PI   3.14159265358979323846 

 void solve()
 { 
  int n;
  cin>>n;
  if(n>=400 and n<= 599)cout<<8;
  else if(n>=600 and n<= 799)cout<<7;
  else if(n>=800 and n<= 999)cout<<6;
  else if(n>=1000 and n<= 1199)cout<<5;
  else if(n>=1200 and n<= 1399)cout<<4;
  else if(n>=1400 and n<= 1599)cout<<3;
  else if(n>=1600 and n<= 1799)cout<<2;
  else if(n>=1800 and n<= 1999)cout<<1;
  
 }
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
     ll t=1; 
     // cin >> t;
     while (t--) solve();
     return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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


    int ans = (n - 2) / (k - 1) + 1;

    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
char a[10000];
int len,c,f;
int main()
{
	cin>>a;
	len=strlen(a);
	for(int i=0;i<len;i++)
	{
		if(a[i]=='C')c=1;
		if(c==1&&a[i]=='F')
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

bool cycle(int i){
    int d[5];
    REP(j, 5){
        d[j] = i % 10;
        i /= 10;
    }
    if (d[0] == d[4] && d[1] == d[3]){
        return true;
    }else{
        return false;
    }
}

int main()
{
    int A, B;
    cin >> A >> B; 
    int ans = 0;
    for(int i = A; i < B + 1; ++i){
        if (cycle(i)) ans += 1;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
string S;
cin >> S;

  
string ans ="";
 

for(int tmp=0;tmp<(1 << 3);tmp++){
  bitset<3> op(tmp);
  int sum = S[0]-'0';
  ans = S.at(0);
  for (int i=1; i<4;i++){
    if(op.test(i-1) == 1){
      sum += S.at(i)-'0';
      ans +="+";
      ans += S.at(i);
    }
    else{
      sum -= S.at(i)-'0';
      ans += "-";
   	  ans += S.at(i);
    }
  }  

    if(sum == 7){
      ans += "=7";
        cout << ans;
      return 0;
  }

}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define double long double
using namespace std;
typedef pair<int, int>P;
void pyes() { cout << "Yay!" << endl; }
void pno() { cout << ":(" << endl; }
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
//繰り返し二乗法
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
//xCy
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int f(int x) {
	int ans = 1;
	for (int i = 1; i <= x; i++) {
		ans *= i;
		ans %= mod;
	}
	return ans;
}
struct edge { int to, cost; };
signed main(){
	int ans = 0;
	string s;
	cin >> s;
	int n = s.size();
	for (int i = 0; i < n / 2; i++) {
		if (s[i] != s[n - 1 - i])ans++;
	}
	cout << ans << endl;
	ggr
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long;
#define dbg(x) cout<<#x<<"--------------"<<x<<endl;
#define dl cout<<"LINE"<<__LINE__<<endl;
using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	
	string s1,s2,s;int a,b;
	cin>>s1>>s2;
	cin>>a>>b;
	cin>>s;
	if(s==s1)cout<<a-1<<" "<<b<<endl;
	if(s==s2)cout<<a<<" "<<b-1<<endl;
	 
	
	
	
		
	return 0;
}

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    int x, n;
    cin >> x >> n;
    
    vint nums(n);
    rep(i, n) {
        cin >> nums[i];
    }

    std::sort(nums.begin(), nums.end());

    int abs = 0;
    while(true) {
        int tmp = x - abs;
        
        int left = -1;
        int right = n;
        while (right - left > 1) {
            int mid = left + (right - left) / 2;
            if (nums[mid] <= tmp) {
                left = mid;
            } else {
                right = mid;
            }
        }
        if (left >= 0) {
            if (nums[left] != tmp) {
                cout << tmp << endl;
                return 0;
            }
        } else {
            cout << tmp << endl;
            return 0;
        }

        tmp = x + abs;
        left = -1;
        right = n;
        while (right - left > 1) {
            int mid = left + (right - left) / 2;
            if (nums[mid] <= tmp) {
                left = mid;
            } else {
                right = mid;
            }
        }
        if (left >= 0) {
            if (nums[left] != tmp) {
                cout << tmp << endl;
                return 0;
            }
        } else {
            cout << tmp << endl;
            return 0;
        }

        abs++;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n,d,x,b,sum=0;
	cin>>n>>d>>x;
	r(i,n){
		cin>>b;
		int a=1;
		while(a<=d){
			sum++;
			a+=b;
		}
	}
	cout<<sum+x<<endl;
}

Measured memory_bytes: 256
get = gets.chomp.split.map(&:to_i)
a = get[0]
b = get[1]
c = get[2]

flag = 0
loop do
  flag = a%b
  if flag == 0
    break
  end
  a = b
  b = flag
end

if c%b == 0
  puts "YES"
else
  puts "NO"
end


Measured memory_bytes: 1788
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans1=[0]*n
ans2=[0]*n

ans1[0]=min(a[0],b[0])
ans2[0]=min(a[1],b[0]-min(a[0],b[0]))

for i in range(1,n):
    ans1[i]=min(a[i]-ans2[i-1],b[i])
    ans2[i]=min(a[i+1],b[i]-ans1[i])

print(sum(ans1)+sum(ans2))


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  multiset<ll> s;
  s.insert(a[0]);
  for (int i = 1; i < n; i++) {
    auto it = s.lower_bound(a[i]);
    if (it == s.begin()) {
      s.insert(a[i]);
    } else {
      it--;
      s.erase(it);
      s.insert(a[i]);
    }
  }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 5760
/*input
3 3 2
1 4 3
2 5 7
8 9 6
1
4 8
*/
#include <bits/stdc++.h>
using namespace std;
long long a[305][305],n,m,d;
map<int,pair<int,int>> mp;
vector<int> prefix[900005];
int main(){
	ios_base::sync_with_stdio(0);
	cin>>n>>m>>d;
	int q,l,r;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			cin>>a[i][j];
			mp[a[i][j]] = {i,j};
		}
	}
	for(int mod = 0; mod<d;++mod){
		int x = (mod?mod:d);
		if(mod==0) prefix[0].push_back(0);
		int dis = 0;
		prefix[mod].push_back(dis);
		for(int y=x+d;y<=n*m;y+=d){
			dis += abs(mp[y].first-mp[y-d].first) + abs(mp[y].second-mp[y-d].second);
			prefix[mod].push_back(dis);
		}
	}
	for(cin>>q;q--;){
		int l,r;
		cin>>l>>r;
		int mod = l%d;
		l-=mod,r-=mod;
		cout<<prefix[mod][r/d]-prefix[mod][l/d]<<'\n';
	}
}

Measured memory_bytes: 30720
#include <iostream>
using namespace std;
int main(void){
    
    int H, W;
    cin >> H >> W;
    
    while(H != 0 && W != 0){
        
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
            
                if(((i + j)%2 == 0)) cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W;

    }
    
    return 0;
}


Measured memory_bytes: 3104
# https://atcoder.jp/contests/abc142/tasks/abc142_c

N = int(input())
A_list = list(map(int, input().split()))

# ans = str(A_list.index(1) + 1)
# for i in range(2, N + 1):
#     tmp = str(A_list.index(i) + 1)
#     ans = ' '.join([ans, tmp])



ans_list = [0] * N

for i in range(N):
    ans_list[A_list[i] - 1] = i + 1

# リストを空白区切りで出力
print(*ans_list)

Measured memory_bytes: 14004
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	long  a, b, c;
	cin >> a >> b >> c;
	if (c - a - b <= 0)
	{
		cout << "No";
		return 0;
	}
	long long migi = (long long)(c - (a + b));
	migi *= migi;
	long long hidari = 4 *(long long)a * (long long)b;
	bool isok = hidari < migi;
	cout << (isok ? "Yes" : "No");
}


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

int main(){
  int N, A, min=30; //2^30=(2^10)^3=(1,024)^3>(10^3)^3=10^9
  cin >> N;
  
  for(int i=0; i<N; i++){
	int count = 0;
    cin >> A;
    while(!(A%2)){
      A /=2;
      count ++;
      if(count > min) break;
    }
    if (min > count) min = count;
  }
  cout << min;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;

	int N = b - a;

	int def = 0;
		rep(i,N){
		def = i + def;
	}

	cout << def - a << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

void warshall(std::vector< std::vector<int> > &c) {
	for(int i = 0; i < 10; ++i) {
		for(int j = 0; j < 10; ++j) {
			for(int k = 0; k < 10; ++k) {
				c[j][k] = std::min(c[j][k], c[j][i] + c[i][k]);
			}
		}
	}
}

int main(void) {
	// input
	int h, w;
	std::cin >> h >> w;
	std::vector< std::vector<int> > c(10);
	for(int i = 0; i < 10; ++i) {
		c[i].resize(10);
		for(int j = 0; j < 10; ++j) {
			std::cin >> c[i][j];
		}
	}
	std::vector<int> a(h * w);
	for(int i = 0; i < h * w; ++i) std::cin >> a[i];

	// calc costs
	warshall(c);

	// sum costs
	int sum_cost = 0;
	for(int i = 0; i < h * w; ++i) {
		if(a[i] == -1) continue;
		sum_cost += c[a[i]][1];
	}

	std::cout << sum_cost << std::endl;

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
char s[100005];
int main(){
	int n,ans=1;scanf("%d%s",&n,s);
	for(int i=1;s[i];i++)if(s[i]!=s[i-1])ans++;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 384
n = int(input())
xyl = []
for _ in range(n):
    x,y = map(int,input().split())
    xyl.append((x,y))

ans = n
set_cover = []
for i in range(n):
    for j in range(i+1, n):
        p = xyl[j][0] - xyl[i][0]
        q = xyl[j][1] - xyl[i][1]
        tmp = n
        for k in range(n):
            for l in range(n):
                x = xyl[l][0] - xyl[k][0]
                y = xyl[l][1] - xyl[k][1]
                if p == x and q == y:
                    tmp -= 1
        ans = min(ans, tmp)
print(ans)


Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans[] = new int[n];
		for (int i = 1; i < n; ++i) {
			int a = sc.nextInt();
			ans[a - 1]++;
		}
		sc.close();
		for (int a : ans)
			System.out.println(a);
	}
}


Measured memory_bytes: 61780
from fractions import gcd

A, B = map(int, input().split())

n = gcd(A, B)
ans = 1

tmp = n
l = []
for i in range(2, int(-(-n**0.5//1))+1):
    if tmp % i == 0:
        l.append(i)
        while tmp % i == 0:
            tmp //= i

if tmp != 1:
    l.append(tmp)

if l == []:
    l.append(n)

if len(l) == 1 and l[0] == 1:
    print(1)
else:
    print(len(l) + 1)


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI a(n);
	rep(i, n) cin>>a[i];
	
	auto b =a; sort(all(b));
	bool ok =true;
	
	rep(i, n){
		if(i%2){
			if(i + n%2 != b[i]) ok=false;
		}else{
			if(i + (n%2==0) != b[i]) ok=false;
		}
	}
	
	if(!ok){puts("0"); return 0;}
	ll ans = 1;
	rep(i, n/2) ans = ans * 2LL %MD;
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 1024
n,m=map(int,input().split())

tree=[[] for _ in range(n)]

for _ in range(m):
    a,b=map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

result=[-1]*n
result[0]=0
from collections import deque
stack=deque([0])
while len(stack)>0:
    key=stack.popleft()
    for item in tree[key]:
        if result[item]==-1:
            result[item]=key+1
            stack.append(item)

if -1 in stack:
    print("No")
    exit()
else:
    print("Yes")   
    for item in result[1:]:
        print(item)
    




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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int main()
{
    string a,b;
    cin >> a >> b;
    
    string key = a+b;

    ll ans = 0;
    rep(i,key.size()) ans += (key[i]-'0')*pow(10,key.size()-i-1);

    rep(i,ans)
    {
        if( i*i == ans )
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
n = int(input())
xyz = [0] * ((10 ** 4) + 1)
for x in range(1, (10 ** 2) + 1):
    for y in range(1, (10 ** 2) + 1):
        for z in range(1, (10 ** 2) + 1):
            v = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + x * z - 1
            if v < 10 ** 4 + 1:
                xyz[v] += 1
for i in range(n):
    print(xyz[i])


Measured memory_bytes: 9140
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 20001
#define MCONS 1001

using namespace std;

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

    char ch; cin >> ch;
    if(ch == 'A')
        cout << "T";
    else if(ch == 'T')
        cout << "A";
    else if(ch == 'C')
        cout << "G";
    else
        cout << "C";
    
    return 0;
}




Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
		
            String str;
            int sum=0;
			while( true ) {
				str = kb.readLine();
				if( "0".equals( str ) ) { break; }
				
				char[] strArr = str.toCharArray();
				sum=0;
           		for( int i=0; i<strArr.length; i++ ) {
           			sum += ( strArr[i] - '0' );
           		}
				System.out.println( sum );
			}
			
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}

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

using namespace std;

#define endl "\n"
#define ll unsigned long long
//#define int long long int
#define vi vector <int >
#define vii vector < pii >
#define vll vector <ll >
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
//#define double long double
#define a first
#define b second

double dp[302][302][302];
vi arr(302);
int n;
double zero = 0;

double f(int a1, int a2, int a3){
    if(a1 == 0 && a2 == 0 && a3 == 0){
        return 0;
    }

    if(dp[a1][a2][a3] != -1) return dp[a1][a2][a3];

    double ans = 0;

    if(a1)
        ans += f(max(a1 - 1, 0), a2, a3)*((double)a1/(a1 + a2 + a3));
    if(a2)
        ans += f(a1 + 1, max(a2 - 1, 0), a3)*((double)a2/(a1 + a2 + a3));
    if(a3)
        ans += f(a1, a2 + 1, max(a3 - 1, 0))*((double)a3/(a1 + a2 + a3));

    return dp[a1][a2][a3] = ans + double(n)/(a1 + a2 + a3);
}

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

    cin >> n;
    int a1 = 0, a2 = 0, a3 = 0;
    forn(i, n){
        cin >> arr[i];
        a1 += (arr[i] == 1);
        a2 += (arr[i] == 2);
        a3 += (arr[i] == 3);
    }
    forn(i, 302)
        forn(j, 302)
            forn(k, 302)
                dp[i][j][k] = -1;

    printf("%.16f\n", f(a1, a2, a3));

    return 0;
}

Measured memory_bytes: 215552
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,num=1;
  char now;
  while(cin>>n,n!=0){
    string str,str2,ansstr="";
    num=1;
    int k=0;
    cin>>str;
    for(int i=0;i<n;i++){
      now=str[0];
      ansstr="";
      for(int j=0;j<str.size();j++){
	if(j==(str.size()-1)){
	  if(num>=1&&num<=9){
	    str2=num+'0';
	    str2+=now;
	  }
	  if(num>=10&&num<=99){
	    str2=(num/10)+'0';
	    str2+=(num%10)+'0';
	    str2+=now;
	  }
	  if(num==100){
	    str2="100";
	    str2+=now;
	  }
	  ansstr+=str2;
	}else if(str[j]!=str[j+1]){
	  if(num>=1&&num<=9){
	    str2=num+'0';
	    str2+=now;
	  }
	  if(num>=10&&num<=99){
	    str2=(num/10)+'0';
	    str2+=(num%10)+'0';
	    str2+=now;
	  }
	  if(num==100){
	    str2="100";
	    str2+=now;
	  }
	  num=1;
	  now=str[j+1];
	  ansstr+=str2;
	}else if(str[j]==str[j+1])
	  num++;
      }
      str=ansstr;
      num=1;
    }
    cout<<str<<endl;
  }
  return 0;
}

Measured memory_bytes: 3240
#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>;
int main(){
    int n , m , x ;
    cin >> n >> m >> x ;
    vector<int> C(12);
    vector<vector<int>> pa(n, vector<int>(m));
    rep(i,n) {
        cin >> C.at(i);
        rep(j,m){
            cin >> pa.at(i).at(j);
        }
    }
    int ans = 100100100;
    int count = 0;
    
    for (int tmp = 0; tmp < (1 << n); tmp++) {
  bitset<12> s(tmp);
  // (ビット列sに対する処理)
      count =0;
      vector<int> Ans(m);
  rep(i,n){
       
      if (s.test(i)){
      count += C.at(i);
      rep(j,m){
          Ans.at(j) += pa.at(i).at(j);
      }

      }
  }
  bool can = true;
  rep(i,m){
      if(Ans.at(i)< x){
          can = false;
      }
  }
  if(can){
      ans = min(count,ans);
  }
}
if(ans == 100100100){
    cout << -1 << endl;
}
else cout << ans << endl;
}

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

const int N = 205;
int n;
char s[N][N];

struct Edge
{
    int num;
    int next;
}edge[2 * N * N];
int tot, last[N];
int q[N * 2];
bool used[N];
int sign[N], anss;
int l, r;

void Add(int i, int j)
{
    tot++;
    edge[tot].num = j;
    edge[tot].next = last[i];
    last[i] = tot;
}

bool bfs(int s)
{
    while (l <= r)
    {
        int u = q[l];
        l++;
        for (int k = last[u]; k != 0; k = edge[k].next)
        {
            int v = edge[k].num;
            if (used[v] == 1)
            {
                if (abs(sign[v] - sign[u]) != 1) return 0;
                else continue;
            }
            else
            {
                used[v] = 1;
                sign[v] = sign[u] + 1;
                anss=max(sign[u]+ 1, anss);
                r++;
                q[r] = v;
            }
        }
    }
    return 1;
}

int main()
{
    scanf ("%d", &n);
    for (int i = 1; i <= n ;i++)
        scanf ("%s", s[i] + 1);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
        {
            if (s[i][j] == '1')
            {
                Add(i, j);
                Add(j, i);
            }
        }
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        anss = 1;
        memset(q,0,sizeof(q));
        l = r = 1;
        q[1] = i;
        memset(used,0,sizeof(used));
        memset(sign,0,sizeof(sign));
        sign[i] = 1;
        used[i] = 1;
        if (bfs(i) == 1)
            ans = max(ans, anss);
    }
    if (ans !=0) printf ("%d", ans);
    else printf ("-1");
}


Measured memory_bytes: 896
# Sunny -> Cloudy -> Rainy -> Sunny ...
# 標準入力はSunny Cloudy Rainyのいずれか

S = input()

if S == "Sunny":
    print("Cloudy")
elif S == "Cloudy":
    print("Rainy")
elif S == "Rainy":
    print("Sunny")

Measured memory_bytes: 9032
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int N;

	cin >> N;

	if (N % 4 == 0 || N % 7 == 0) {
		cout << "Yes" << endl;
		return 0;
	}

	for (int i = 0; i <= N / 4; i++) {
		if ((N - i * 4)%7 == 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}

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

Measured memory_bytes: 256
N,X = map(int,input().split())
L = list(map(int,input().split()))
for i in range(N):
  L[i] = abs(L[i]-X)
L.sort()
def gcd(x,y):
  while y != 0:
    k = x
    x = y
    y = k%y
  return x
cur = L[0]
for i in range(1,N):
  cur = gcd(L[i],cur)
print(cur)

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
	const char *comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#define pi 3.141592653589
#define MOD 1000000007
#define to() int t; cin>>t; while(t--)
#define pb push_back
#define in insert
#define mp make_pair
#define ff first
#define ss second
#define si(s) s.size()
#define fori(it,v) for(it=v.begin();it!=v.end(); it++)
#define for1(low,high,k) for(int i=low;i<high;i+=k)
#define for11(low,high,k) for(int j=low;j<high;j+=k)
#define for2(low,high,k) for(int i=low;i<=high;i+=k)
#define rev(high,low,k)  for(int i=high;i>=low ;i-=k)
#define all(x) x.begin(), x.end()
#define fil(x,i) memset(x,i,sizeof(x));
#define setbits(x) __builtin_popcount(x)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;

void i_o() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin) ;
	freopen("output.txt", "w", stdout) ;
#endif
}

const ll M=998244353;
const int N=2e5+5;
ll bit[N];

void add(int idx,ll val){
	for(;idx<N;idx+=idx&-idx){ bit[idx]+=val%M; bit[idx]%=M; }
}

ll sum(int idx){
	ll res=0;
	for(;idx>0;idx-=idx&-idx){
			res+=bit[idx]%M;
			res%=M;
	}
	return res;
}

ll val(int idx){
	if(idx==1) return sum(1);
	else return (sum(idx)-sum(idx-1)+M)%M;
}

void rangeadd(int l,int r,ll val){
	add(l,val); add(r+1,-val);
}

int main()
{
	boost; i_o();
	int n,k; cin>>n>>k;
	vector<pair<int,int> >v(k);
	for1(0,k,1) cin>>v[i].ff>>v[i].ss;
	sort(all(v));
	rangeadd(1,1,1);
	for(int i=1;i<n;i++){
		ll res=sum(i);
		res%=M;
		//trace(i,res);
		for(int j=0;j<k;j++){
			if(v[j].ff+i>n) break;
			rangeadd(i+v[j].ff,min(n,v[j].ss+i),res);
			int l=i+v[j].ff,r=min(n,v[j].ss+i);
			//trace(l,r,res);
		}
	}
	ll ans=(sum(n)+M)%M;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=(ll)(1e9+7);
ll run();

int main() {
#ifdef home
    freopen("i", "r", stdin);
    freopen("d", "w", stderr);
#endif
    cout.precision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    run();
    return 0;
}
const ll inf = (1e9+5);
void max_self(ll &a, ll b) {
    a = max(a, b);
}
void min_self(ll &a, ll b) {
    a = min(a, b);
}
void mul(ll &a, ll b) {
    a = (a * b) % mod;
}
void add_self(ll &a, ll b){
    a+=b;
    if(a>=mod)
        a-=mod;
}
ll gcd(ll a, ll b){
    return b?gcd(b,a%b):a;
}

const int MAX_N = 1e5+5;
vector<int> adj[MAX_N];
pair<int,int >  dp[MAX_N];

void dfs(int u, int p){
    ll b=1,w=1;
//    bool hasChild = false;
    for(int v: adj[u]) if(v!=p){
        dfs(v,u);
        b = (b*(ll)dp[v].second)%mod;
        w = (w*(ll)(dp[v].second+dp[v].first))%mod;
//        hasChild = true;
    }
//    if(hasChild){
//        dp[u] = {b,w};
//    }
//    else {
//        dp[u] = {1,1};
//    }
    dp[u] = {b,w};
}

ll run() {
    int n;
    cin>>n;
    for(int i=1;i<n;i++){
        int x,y;
        cin>>x>>y;
        adj[x].emplace_back(y);
        adj[y].emplace_back(x);
    }

    dfs(1,-1);
    ll ans = (dp[1].first+dp[1].second)%mod;
    cout<<ans;
    return 0;
}















Measured memory_bytes: 13440
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int q = Integer.parseInt(sc.next());
        for(int i = 0; i < q; i++){
            char[] x = sc.next().toCharArray();
            char[] y = sc.next().toCharArray();
            System.out.println(lcs(x, y));
        }
    }
    
    static int lcs(char[] x, char[] y){
        
        int m = x.length;
        int n = y.length;
        int[][] c = new int[m+1][n+1];
        for(int i = 1; i <= m; i++){
            for(int j = 1; j <= n; j++){
                if(x[i-1] == y[j-1]){
                    c[i][j] = c[i-1][j-1] +1;
                }else if(c[i-1][j] >= c[i][j-1]){
                    c[i][j] = c[i-1][j];
                }else{
                    c[i][j] = c[i][j-1];
                }
            }
        }
        return c[m][n];
    }
}


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

using namespace std;

int main(){
    int N, M, p[100002], box[100002] = {0},
     cntAC = 0, cntWA[100002] = {0};
    string S[100002];

    cin >> N >> M;
    for(int i = 0; i < M; i ++){
        cin >> p[i] >> S[i];
        if(box[p[i]] == 0 && S[i] == "WA"){
            cntWA[p[i]] ++;
        }
        if(box[p[i]] == 0 && S[i] == "AC"){
            box[p[i]] = 1;
            cntAC ++;
        }
    }

    for(int j = 1; j <= N; j ++){
        if(box[j] == 1)cntWA[0] += cntWA[j];
    }
    
    cout << cntAC << " " << cntWA[0] << endl;

    return 0;
}

Measured memory_bytes: 7896
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k,a[15],L,ans,cnt,MIN=1e18;
int main(void){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<(1<<(n-1));i++){
        L=a[0];
        cnt=0;
        ans=0;
        for(int j=1;j<n;j++){
            if((i>>(j-1))&1){
                cnt++;
                if(L>=a[j]){
                    ans+=L-a[j]+1;
                    L++;
                }
            }
            L=max(L,a[j]);
        }
        if(cnt+1>=k){
            MIN=min(ans,MIN);
        }
    }
    cout<<MIN<<endl;
}


Measured memory_bytes: 256
n = int(input())
reds = sorted([list(map(int,input().split())) for i in range(n)],key=lambda reds: -reds[1])
blues = sorted([list(map(int,input().split())) for i in range(n)])

res = 0

for c,d in blues:
  for a,b in reds:
    if a<c and b<d:
      reds.remove([a,b])
      res+=1
      break
      
print(res)


Measured memory_bytes: 9184
#include <stdio.h>
#include <ctype.h>

int main(void){
    char keyword[11]={0};
    char target[1001]={0};
    int index=0, counter=0;
    
    scanf("%s", keyword);/*gets(keyword);*/
    
    
    for(index=0; strlen(keyword) > index; index++){
        keyword[index] = tolower(keyword[index]);
        
    }
    
    
    while(scanf("%s", target) && strcmp(target, "END_OF_TEXT")){
        
        
        for(index=0; strlen(target) > index; index++){
            target[index] = tolower(target[index]);
            
        }
        
        
        if(!strcmp(target, keyword)){
            counter++;
            
        }
    }
    
    printf("%d\n", counter);
    
    return 0;
}

Measured memory_bytes: 552
#include <iostream>
#include <vector>
#include <set>

using namespace std;

void count_friends(const vector<set<int>>& friends, int person, set<int>& visited, int& count)
{
	if (visited.count(person) == 1)
		return;
	count++;
	visited.insert(person);
	for (set<int>::iterator it = friends[person].begin(); it != friends[person].end(); it++)
	{
		if (visited.count(*it) == 1)
			continue;
		count_friends(friends, *it, visited, count);
	}
}

int main()
{
	int n, m;
	cin >> n >> m;
	vector<set<int>> friends(n);
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		a--; b--;
		if (friends[a].count(b) == 1)
			continue;
		friends[a].insert(b);
		friends[b].insert(a);
	}
	int max_count = 0;
	set<int> temp;
	for (int i = 0; i < n; i++)
	{
		int count = 0;
		count_friends(friends, i, temp, count);
		if (count > max_count)
			max_count = count;
	}
	cout << max_count << endl;
	return 0;
}

Measured memory_bytes: 56240
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[3] = {1,0,-1};
int dy[3] = {1,0,-1};
const int MOD = 1000000007;

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int H,W;
  char masu[51][51];
  cin >> H >> W;
  REP(i,H)cin >> masu[i];
  for(int i=0;i<H;i++)REP(j,W){
      if(masu[i][j] == '#'){
        REP(p,3)REP(q,3){
          if(p == 1 && q == 1)
            continue;
          if(i+dy[p] < H && i+dy[p] >= 0 && j+dx[q] >= 0 && j+dx[q] < W){
            if(masu[i+dy[p]][j+dx[q]] == '.')
              masu[i+dy[p]][j+dx[q]] = '1';
            else if(masu[i+dy[p]][j+dx[q]] == '#')
              continue;
            else
              masu[i+dy[p]][j+dx[q]]++;
          }
        }
      }
    }
  REP(i,H)REP(j,W){
    if(masu[i][j] == '.')
      masu[i][j] = '0';
  }
  REP(i,H)cout << masu[i] << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


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

using ll = long long;
#define REP(i, n) for(int (i)=0; (i)< (n); ++i)
#define REPR(i, n) for(int (i)=(n); (i)>=0; --i)
#define FOR(i, n, m) for(int (i)=(n); (i)<(m); ++i)
//#define INF 1e9
constexpr ll INF = 1LL << 62;
constexpr int mod = 1e9+7;

int main(){
  ll N, K;
  cin >> N >> K;
  ll a = N % K;
  cout << min(a, abs(a-K)) << endl;
  return 0;
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
 
int n;
vi in;
void f(){
	vi w(n);
	bool h=true;
	for(int i=n-1;i>=0;i--){
		int c=0;
		for(int j=i;j<n;j+=i+1)c+=w[j];
		w[i]=(c%2)!=in[i];
	}
	int c=0;
	rep(i,n)c+=w[i];
	cout<<c<<endl;
	rep(i,n)if(w[i])cout<<i+1<<endl;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>n;
	in=vi(n);
	rep(i,n)cin>>in[i];
	f();
}












Measured memory_bytes: 3968
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
  public static void main(String[] args) {
	  FastReader sc = new FastReader();
	  String s = sc.next();
	  long[] res = new long[2];
	  helper(s, 1, s.substring(0, 1) , res);
	  System.out.println(res[0]);
  }
  
  private static void helper(String s, int pos, String currTmp, long[] res) {
	  if (pos == s.length()) {
		  // System.out.println(currTmp);
		  res[0] += computeFormula(currTmp);
	  } else {
		  if (pos < s.length()) {
			  helper(s, pos + 1, currTmp + s.charAt(pos), res);
			  helper(s, pos + 1, currTmp + "+" + s.charAt(pos), res);
		  }
	  }
  }
  
  private static long computeFormula(String s) {
	  long res = 0;
	  long num = 0;
	  for (int i = 0; i < s.length(); i++) {
		  char c = s.charAt(i);
		  
		  if (c == '+') {
			  res += num;
			  num = 0;
		  } else {
			  num *= 10;
			  num += c - '0';
			  if (i == s.length() - 1) {
				  res += num;
				  num = 0;
			  }
		  }
	  }

	  return res;
  }
  
  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }
  
    String next() { 
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException  e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

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

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

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

    String nextLine() {
      String str = "";
        try{
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
      }
  }
}


Measured memory_bytes: 23252
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
int main(void)
{
    int T,t,x,y,n,k,mx=0;
    scanf("%d %d",&n,&x);
    if(n<6)
        printf("0\n");
    else if(n<13)
        printf("%d\n",x/2);
    else
        printf("%d\n",x);
    return 0;
}









Measured memory_bytes: 256
from math import gcd

def solve():
    K = int(input())
    ans = 0

    for i in range(1,K+1):
        for k in range(1,K+1):
            b = gcd(i, k)
            for m in range(1,K+1):
                ans += gcd(b, m)
    return ans

print(solve())



Measured memory_bytes: 9048
def scc_puzzle(N: int, M: int) -> int:
    if 2 * N < M:
        # c が余る場合、余った c が 4 つごとに
        # 1 組みの `Scc` が作れる。
        return N + (M - 2 * N) // 4

    return M // 2


if __name__ == "__main__":
    N, M = map(int, input().split())
    ans = scc_puzzle(N, M)
    print(ans)


Measured memory_bytes: 2940
# include<iostream>
using namespace std;
int main ()
{
	int A,B,C;
	cin>>A>>B>>C;
	int temp;
	temp = A;
	A = B;
	B = temp ;
	temp = A;
	A = C;
	C = temp;
	cout<<A<<" "<<B<<" "<<C<<endl; 
 } 

Measured memory_bytes: 256