akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int max_size = 0;
vector<int> parent, cnt;
int find(int x) {
	return (x == parent[x] ? x : (parent[x] = find(parent[x])));
}
void merge(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y) return;
	parent[x] = y;
	cnt[y] += cnt[x];
	cnt[x] = 1;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n, m;
	cin >> n >> m;
	parent.resize(n + 1);
	cnt.resize(n + 1);
	for (int i = 0; i <= n; i++) {
		parent[i] = i; 
		cnt[i] = 1;
	}
	while (m--) {
		int u, v;
		cin >> u >> v;
		merge(u, v);
	}

	for (int i = 0; i <= n; i++) {
		if (max_size < cnt[i]) max_size = cnt[i];
	}
	cout << max_size << '\n';
	return 0;
}


Measured memory_bytes: 4688
x = int(input())
while(True):
  if x == 2 or x == 3:
    print(x)
    break
  y = True
  for i in range(2, x//2+1):
    if x % i == 0:
      y = False
      break
  if y == True:
    print(x)
    break
  else:
    x += 1


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int Ull;
typedef pair<int ,int> PII;
template <typename T>
inline T  read()
{
    char c=getchar();
    T x=0,f=1;
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c))x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x*f;
}
template <typename T>
inline void write(T x) 
{
    if(x < 0) x = (~x) + 1, putchar('-');
    if(x / 10) write(x / 10);
    putchar(x % 10 | 48);
}
const int INF = 0x3f3f3f3f;
const int N = 1e5+10;
int main(){
    //ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n = read<int>();
    int ans = 0;
    int x = n%1000;
    ans = 1000 - x;
    if(ans == 1000) ans = 0;
    cout<<ans;
} 


Measured memory_bytes: 3628
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};


#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


ll dp[110][100010] = {INF};



void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s; cin >> s;
    int length = s.length();
    int ans = 0;
    for (int i = 0; i < length; i++) {
        if(i < (length-i-1)){
            if(s[i]!=s[length-i-1]) ans++;
        }
    }
    cout << ans << endl;
}



signed main() {
    
    
    solve();
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
typedef pair<int,int> pii;
LL n,a,b,ans,aa,bb,tt;
int main()
{
    scanf("%lld %lld %lld",&n,&a,&b);
    if(abs(a-b)%2==0)printf("%lld",abs(a-b)/2);
    else
    {
        ans=min(max(a,b)-1,n-min(a,b));
        tt=a,aa=1,bb=b-tt;
        ans=min(ans,tt+(abs(aa-bb)/2));
        tt=n-b+1,aa=a+tt,bb=n;
        ans=min(ans,tt+(abs(aa-bb)/2));
        printf("%lld",ans);
    }
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int) n;i++)
#define rep1(i,m,n) for(int i=(int) m;i<(int) n;i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
    if(x>=0) return ;
    else x=-x; return;
}

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

const ll INF = 1LL << 60;

int N;
ll W;
vector<ll> weight(110),value(110);
//DPテーブル
vector<vector<ll>> dp(110,vector<ll>(100100,0));

int main() {
    cin >> N >> W;
    rep(i,N) cin >> weight.at(i) >> value.at(i);

    rep(i,N) {
        rep(sum_w,W+1) {
            if(sum_w-weight.at(i)>=0) {
                chmax(dp.at(i+1).at(sum_w),dp.at(i).at(sum_w-weight.at(i))+value.at(i));
            }
            chmax(dp.at(i+1).at(sum_w),dp.at(i).at(sum_w));
        }
    }
    cout << dp.at(N).at(W) << endl;
}

Measured memory_bytes: 87296
/**
 *   @FileName	d.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.14 21:15:33
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

 
int main() {
    int n;cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<bool> p(1000001,false);
    sort(a.begin(), a.end());
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (i > 0 && a[i-1] == a[i]) continue;
        if (i < n - 1 && a[i + 1] == a[i]) {
            
        } 
        else if (!p[a[i]]) ans++;
        else continue;
        for (int j = a[i]; j <= 1000000; j+=a[i]) {
            p[j] = true;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4316
#include<iostream>
using namespace std;
int main()
{

   int A, B;
   cin >> A >> B;
    if (A % 2 == B % 2)
    {
        cout << (A+B) / 2 << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}



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

int main()
{
    int n,m;
    cin>>n>>m;
    long long arr[n+5];
    for(int i=0;i<n;i++)cin>>arr[i];
    sort(arr,arr+n);
    vector<pair<long long,long long> >v;
    for(int i=0;i<m;i++)
    {
        long long a,b;
        cin>>a>>b;
       if(a>0) v.push_back(make_pair(b,a));
    }

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

    int idx=0;

    for(int i=0;i<n;i++)
    {
       if(arr[i]<v[idx].first&&v[idx].second>0)
       {
           arr[i]=v[idx].first;
           v[idx].second--;
           if(v[idx].second==0)idx++;
           if(idx==v.size())break;
       }
    }

    long long sum=0;
    for(int i=0;i<n;i++)sum+=arr[i];
    cout<<sum<<endl;
}


Measured memory_bytes: 3188
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

//~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

int main() {

    int N;
    cin >> N;

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

    LL minV = 10000000000000LL;
    LL maxV = -1;

    for(int i = 0;i<N;i++) minV = min(minV, A[i]);
    for(int i = 0;i<N;i++) maxV = max(maxV, A[i]);

    cout << maxV - minV << endl;

}

































Measured memory_bytes: 764
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000009
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b))<<endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
w_arr = gets.chomp.split(" ").map(&:to_i)

s1 = 0
s2 = w_arr.sum
min_abs = (s1 - s2).abs

w_arr.each do |w|
  s1 += w
  s2 -= w
  tmp_abs = (s1 - s2).abs
  min_abs = tmp_abs if tmp_abs < min_abs
end

puts min_abs


Measured memory_bytes: 14320
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll n,k; cin >> n >> k;
	vector<ll> a(n); for(auto &s : a) cin >> s;
	vector<bool> dp(k+1);
	for(ll i = 0; i <= k; i++) for(ll s : a) if(s <= i && !dp[i - s]) dp[i] = true;
	cout << (dp[k] ? "First" : "Second") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 10000

int main(void)
{
	long int sum=0;
	int ai,n,min,max;
	
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		scanf("%d",&ai);
		if(i==1)	max=min=ai;
        	if(max<ai)	max=ai;
        	else if(min>ai)	min=ai;
        	sum+=ai;
	}
    	printf("%d %d %ld\n",min,max,sum);
    	return 0;
}


Measured memory_bytes: 2116
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n + 1); rank.resize(n + 1); diff_weight.resize(n + 1);
        for (int i = 1; i <= n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main() {
    //cout.precision(10);
    UnionFind<int> field;
    int n, m;
    cin >> n >> m;
    field.init(n);
    for(int i = 0; i < m; i++){
        int l, r, d;
        cin >> l >> r >> d;
        if(field.issame(l, r)){
            if(field.diff(l, r) != d){
                cout << "No" << endl;
                return 0;
            }
            continue;
        }
        field.merge(l, r, d);
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1536
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

// vector 操作  vector<int> data(10,5) 10が5個　data(10) 要素数10
// v.size(), v.empty(), v.insert(itr,値), v.erase(itr) (first,last),
// sort(itr), find(all(x),値),reverse(itr),accumulate(itr,0) 積算,
//v.swap
// stringも同じ itrがただの数字になる
// s.substr(n,m)n番目以降m文字取り出す　erase(n,m)も  s.find
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()

using namespace std;

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

    if(a<b){
        REP(i,b){
        cout << a ;
        }
    }
    else{
        REP(i,a){
        cout << b ;
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if (h <= 0 && w <= 0) {
                break;
            }
            for (int i = 0; i < w; i++) {
                System.out.printf("#");
            }
            System.out.println();
            for (int j = 1; j < h - 1; j++) {
                System.out.printf("#");
                for (int i = 1; i < w - 1; i++) {
                    System.out.printf(".");
                }
                System.out.printf("#");
                System.out.println();
            }
            for (int i = 0; i < w; i++) {
                System.out.printf("#");
            }
            System.out.printf("\n\n");
        }
        sc.close();
    }
}


Measured memory_bytes: 57844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define X first
#define Y second
#define mod 1e9+7
#define pb push_back
#define mp make_pair
#define abs(x) ((x)>0?(x):(-(x)))
#define F(n) Fi(i,n)
#define Fi(i,n) Fl(i,0,n)
#define Fl(i,l,n) for(int i=l;i<n;i++)
#define memres(a) memset(a,0,sizeof(a))
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,a[16][16]={0},ans=0;
	cin>>n;
	F(n){
		a[i+1][i+1]=2;
		int k;
		cin>>k;
		Fi(j,k){
			int b,c;
			cin>>b>>c;
			if(c==1)a[i+1][b]=2;
			else a[i+1][b]=1;
		}
	}
	F(1<<n){
		int t=i,cc=0;
		bool f[16];
		Fi(k,n){	
		if(t&1)f[k+1]=true,cc++;
		else f[k+1]=false;
		t/=2;
	}
	bool ch=false;
	 Fi(j,n){
	 	if(f[j+1]){
		 	for(int k=0;k<n;k++){
		 		if(f[k+1]&&a[j+1][k+1]==1){ch=true;break;}
		 		if(!f[k+1]&&a[j+1][k+1]==2){ch=true;break;}
			 }
			 if(ch)break;
		 }
	 }
	 if(!ch)ans=max(ans,cc); 
	}
	cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    ll k;
    cin>>a>>b>>c>>k;
    if(a>k){
        sum=k;
    }else if(k<=a+b){
        sum=a;
    }else{
        sum=a;
        k=k-a-b;
        sum-=k;
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3608
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
const int INF = 1e9 + 7;
int main(){
    double a, b, c;  cin>>a>>b>>c;
    cout<<(a*b)/2;
    
}

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

n=int(n)
sec_set = set()

for i in range(10):
    first = ln.find(str(i))
    if first == -1:
        continue
    for j in range(10):
        second = ln[(first+1):].find(str(j))
        if second == -1:
            continue
        for k in range(10):
            third = ln[(first + second+2):].find(str(k))
            if third == -1:
                continue
            else:
                sec_set.add(str(i)+str(j)+str(k))
print(len(sec_set))


Measured memory_bytes: 38512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dice_II
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split(' ');
            string[] input2 = Console.ReadLine().Split(' ');

            
                

            Dice dice1 = new Dice(input1);
            Dice dice2 = new Dice(input2);

            List<string> result1 = new List<string>();
            List<string> result2 = new List<string>();
            string ctr = " zzzxyyyzxxxzyyyzxxxyzzz";

            for (int i = 0; i < ctr.Length; i++)
            {
                dice1.Rotate(ctr[i]);
                for (int j = 0; j < ctr.Length; j++)
                {
                    dice2.Rotate(ctr[j]);
                    if (dice1.top.Equals(dice2.top) && dice1.front.Equals(dice2.front))
                    {
                        if (dice1.right.Equals(dice2.right))
                        {
                            if (dice1.back.Equals(dice2.back))
                            {
                                if (dice1.right.Equals(dice2.right))
                                {
                                    if (dice1.bottom.Equals(dice2.bottom))
                                    {
                                        Console.WriteLine("Yes");
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }

            }
            Console.WriteLine("No");
            
        }
    }

    class Dice
    {
        public string top, front, right, left, back, bottom;

        public Dice(string[] input)
        {
            this.top = input[0];
            this.front = input[1];
            this.right = input[2];
            this.left = input[3];
            this.back = input[4];
            this.bottom = input[5];
        }

        void RotateX()
        {
            string temp = this.top;
            this.top = this.front;
            this.front = this.bottom;
            this.bottom = this.back;
            this.back = temp;
        }

        void RotateY()
        {
            string temp = this.front;
            this.front = this.right;
            this.right = this.back;
            this.back = this.left;
            this.left = temp;
        }

        void RotateZ()
        {
            string temp = this.top;
            this.top = this.left;
            this.left = this.bottom;
            this.bottom = this.right;
            this.right = temp;
        }

        public void Rotate(char ctr)
        {
            switch (ctr)
            {
                case 'x':
                    RotateX();
                    break;
                case 'y':
                    RotateY();
                    break;
                case 'z':
                    RotateZ();
                    break;
                default:
                    break;
            }
        }

    }
}



Measured memory_bytes: 17840
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]
c=[[] for i in range(N)]
for a,b in AB:
    c[a-1].append(b-1)
    c[b-1].append(a-1)
v=[0]*N
def f(v,x):
    p=x
    r=[x+1]
    while 1:
        f=0
        for n in c[p]:
            if v[n]==0:
                v[n]=1
                r.append(n+1)
                f=1
                break
        if f==0:
            break
        p=n
    return r
a,b=AB[0]
v[a-1]=v[b-1]=1
r=f(v,a-1)[::-1]+f(v,b-1)
print(len(r))
print(*r)

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

int main(){
  int A,B,C,D,E,F; cin >> A >> B >> C >> D >> E >> F;
  int ressum=0,ressug=0;
  double den=0;
  for(int i=0; i<=F/(100*A); i++){
    for(int j=0; j<=(F-i*100*A)/(100*B); j++){
      for(int k=0; k<=(F-i*100*A-j*100*B)/C; k++){
        for(int l=0; l<=(F-i*100*A-j*100*B-k*C)/D; l++){
          if((i*A+j*B)*E>=k*C+l*D){
            if(den<=(double)(100*(k*C+l*D))/(double)(i*100*A+j*100*B+k*C+l*D)){
              den=(double)(100*(k*C+l*D))/(double)(i*100*A+j*100*B+k*C+l*D);
              ressum=i*100*A+j*100*B+k*C+l*D;
              ressug=k*C+l*D;
            }
          }
        }
      }
    }
  }
  cout << ressum << " " << ressug << endl;
}

Measured memory_bytes: 256
#!/usr/bin/python3
import math
K = int(input())
sum_gcd = 0
for a in range(1,K+1):
    for b in range(1,a+1):
        for c in range(1,b+1):
            if a == b and b == c :
                sum_gcd += math.gcd(math.gcd(a,b),c)
            elif a == b or b == c or c == a:
                sum_gcd += 3 * math.gcd(math.gcd(a,b),c)
            else:
                sum_gcd += 6 * math.gcd(math.gcd(a,b),c)
print(sum_gcd)

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

long tree[100001];
long rank_[100001];

int main(void) {
  long N, M; cin >> N >> M;
  for (long i = 1; i <= N; i++) {tree[i] = 0; rank_[i] = 1;}

  for (long i = 0; i < M; i++) {
    long x, y, z; cin >> x >> y >> z;
    vector<long> list_x = {x};
    vector<long> list_y = {y};
    while (tree[x] != 0) {
      list_x.push_back(tree[x]);
      x = tree[x];
    }
    while (tree[y] != 0) {
      list_y.push_back(tree[y]);
      y = tree[y];
    }
    if (x == y) continue;
    if (rank_[x] > rank_[y]) for (long ys : list_y) tree[ys] = x;
    if (rank_[x] < rank_[y]) for (long xs : list_x) tree[xs] = y;
    if (rank_[x] == rank_[y]) {
      for (long xs : list_x) tree[xs] = y;
      rank_[y]++;
    }
  }

  long a = 0;
  for (long i = 1; i <= N; i++) if (tree[i] == 0) a++;
  cout << a << endl;

  return 0;
}


Measured memory_bytes: 1792
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=0
for i in range(N):
    ans=ans+B[A[i]-1]
    if i > 0:
        if A[i]==A[i-1]+1:
            ans=ans+C[A[i-1]-1]
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<functional>
#include<utility>
#include<vector>
#define INF 1145141919
#define SIZE1 131072
#define SIZE2 262144
using namespace std;

class segtree{
	int score[SIZE1];
	int tree[SIZE2];//not use 0;
public:
	void reset(int n){
		for (int i = 0; i < n; i++){
			score[i] = 0;
		}
		for (int i = n; i < SIZE1; i++){
			score[i] = -INF;
		}
		for (int i = SIZE2 - 1; i >= SIZE1; i--){
			tree[i] = i - SIZE1;
		}
		for (int i = SIZE1 - 1; i >= 1; i--){
			tree[i] = tree[i * 2];
		}
		return;
	}
	void setting(int team, int up){
		score[team] += up;
		int now = team + SIZE1;
		while (now != 1){
			now /= 2;
			tree[now] = (score[tree[now * 2]] < score[tree[now * 2 + 1]]) ? tree[now * 2 + 1] : tree[now * 2];
		}
		return;
	}
	int top(){
		return tree[1];
	}
};

int n, r, l;
int tim[100000];
vector<pair<int, int> > per;
int d[1000002], t[1000002], x[1000002];
segtree s;
int main()
{
	cin >> n >> r >> l;
	s.reset(n);
	for (int i = 1; i <= r; i++){
		cin >> d[i] >> t[i] >> x[i];
	}
	t[r + 1] = l;
	int nowtop = 0;
	for (int i = 1; i <= r + 1; i++){
		s.setting(d[i] - 1, x[i]);
		tim[nowtop] += t[i] - t[i - 1];
		nowtop = s.top();
	}
	for (int i = 0; i < n; i++){
		per.push_back(make_pair(tim[i], i));
	}
	sort(per.begin(), per.end(), greater<pair<int, int> >());
	cout << per[0].second + 1 << endl;
	return 0;
}

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

int main() {
  int k;
  int a;
  int b;
  cin >> k;
  cin >> a;
  cin >> b;
  bool vane =false;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      vane=true;
    }
  }
  
  if(vane==true){
    cout << "OK";
  }else{
    cout << "NG";
  }
	return 0;
}


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

using namespace std;

int main(void)
{
  string S;
  cin >> S;
  int red = 0;
  int blu = 0;
  for(int i = 0; i < S.size(); i++){
    if(S[i] == '0')
      red++;
    else
      blu++;
  }
  cout << min(red, blu) * 2 << endl;
  return 0;
}


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

#define ll long long int
#define Mod 1000000007

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,l; cin>>n>>l;
    int sum=0,rem,m=INT_MAX;
    for(int i=0;i<n;i++)
    {
        sum+=l+i;
        if(abs(l+i)<m)
        {
            m=abs(l+i);
            rem=l+i;
        }
    }
    cout<<(sum-rem);
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
INF = 10**18


def input():
    return sys.stdin.readline().rstrip()


def main():
    H, W = map(int, input().split())
    A = [[] for _ in range(H)]
    B = [[] for _ in range(H)]
    C = [[0] * W for _ in range(H)]
    minusdigit = 80 * 80 * 2
    for i in range(H):
        A[i] = list(map(int, input().split()))
    for i in range(H):
        B[i] = list(map(int, input().split()))
    for i in range(H):
        for j in range(W):
            C[i][j] = abs(A[i][j] - B[i][j])
    dp = [[0] * W for _ in range(H)]
    dp[0][0] = ((1 << minusdigit) << C[0][0]) | ((1 << minusdigit) >> C[0][0])
    for i in range(1, H):
        dp[i][0] = (dp[i - 1][0] << C[i][0]) | (dp[i - 1][0] >> C[i][0])
    for j in range(1, W):
        dp[0][j] = (dp[0][j - 1] << C[0][j]) | (dp[0][j - 1] >> C[0][j])

    for i in range(1, H):
        for j in range(1, W):
            dp[i][j] = (dp[i - 1][j] << C[i][j]) | (dp[i - 1][j] >> C[i][j]) | (dp[i][j - 1] << C[i][j]) | (dp[i][j - 1] >> C[i][j])
    ans = dp[H - 1][W - 1]
    for i in range(len(bin(ans)) - (2 + minusdigit)):
        if (ans >> (i + minusdigit)) & 0b1 == 1 or (-i + minusdigit >= 0 and (ans >> (-i + minusdigit)) & 0b1 == 1):
            print(i)
            exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 56540
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
#define MOD 1000000007
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

  ll A,B,C,D; cin>>A>>B>>C>>D;

  while(A>0 && C>0) {
    C-=B;
    A-=D;
  }
  if(C<=0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


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

using namespace std;

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

	int cnt = 0, Max = 0;
	for (int i = 0; i < n; i++) {
		int a, b;	cin >> a >> b;
		if (a == b) cnt++;
		else {
			Max = max(Max, cnt);
			cnt = 0;
		}
	}
	Max = max(Max, cnt);

	cout << (Max >= 3 ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 3588
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int n = scan.nextInt();
        int[] x = new int[n];
        int a = 0;
        int min = Integer.MAX_VALUE;
        for(int i = 0; i < n; i++){
            x[i] = scan.nextInt();
        }
        System.out.println();
        for(int p = 1; p <= 100; p++){
            a = 0;
            for(int i = 0; i < n; i++){
                a += Math.pow(x[i] - p, 2);
            }
            if(a < min){
                min = a;
            }
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 23380
// class point	の練習（クラスの高度な実装）
#include <iostream>
using namespace std;



int main() {
	int x,y;

	do {
		cin >> x >> y;
		if (x == 0 && y == 0)break;
		else {
			if (x > y)cout << y << " " << x << endl;
			else cout << x << " " << y << endl;
		}
	} while (1);
	
	return 0;
}



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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll a,b;
  cin >> a >> b;
  ll ans = max(0ll,a-b*2);
  cout << ans<< endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int euclid(int a, int b){
  if(a < b){
    int tmp = a;
    a = b;
    b = tmp;
  }
  int r = a % b;
  if(r < 0){
    r += b;
  }
  while(r != 0){
    a = b;
    b = r;
    r = a % b;
    if(r < 0){
      r += b;
    }
  }
  return b;
}

int main(){
  int N, X;
  int x[100010] = {};

  scanf("%d %d", &N, &X);
  for(int i = 0; i < N; i++){
    scanf("%d", &x[i]);
  }

  int D = abs(x[0] - X);
  for(int i = 1; i < N; i++){
    D = euclid(D, abs(x[i] - X));
  }
  printf("%d\n", D);

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return 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; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, c;
    cin >> n >> m >> c;
    V<> b(m);
    VV<> a(n, V<>(m));
    rep(i, m) cin >> b[i];
    rep(i, n) rep(j, m) cin >> a[i][j];
    int ans = 0;
    rep(i, n) {
        int now = c;
        rep(j, m) now += a[i][j] * b[j];
        ans += now > 0;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 3716
while(1):
    [n,m,a]=[int(x) for x in raw_input().split()]
    if n==0:
        break
    else:
        currenth=9999999
        amidadict={}
        for i in range(n):
            amidadict[i+1]=[] #amidadict[i]=[(height,direction)]
        for i in range(m): 
            [h,p,q]=[int(x) for x in raw_input().split()]
            amidadict[p].append((h,q))
            amidadict[q].append((h,p))
        for i in range(n):
            amidadict[i+1].sort(key=lambda x:x[0])
        while(len(amidadict[a])>0):
            topamida=amidadict[a].pop()
            if topamida[0]<currenth:
                a=topamida[1]
                currenth=topamida[0]
        print a

Measured memory_bytes: 4380
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <string>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int n,c,k; cin >> n >> c >> k;
    int times[n]; for(int i = 0; i<n; ++i) cin >> times[i];
    sort(times, times+n);
    int ans = 0;
    for(int i = 0; i<n;){
        int l_time = times[i] + k;
        for(int j = 1; j<=c && i<n && times[i] <= l_time; ++j){
            ++i;
        }
        ++ans;
    }
    cout << ans << endl; return 0;
}

Measured memory_bytes: 640
# Problem D - Div Game

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# input
N = int(input())

# initialization
fact_arr = factorization(N)
count = 0

# count
for f in fact_arr:
    c = f[1]
    tmp_count = 0
    i = 1
    while c-i>=0:
        c -= i
        tmp_count += 1
        i += 1
    count += tmp_count

# output
if N==1:
    count = 0
print(count)


Measured memory_bytes: 9448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    ll N;
    cin>>N;
    vector<ll> A(N,0);

    ll max = pow(10,18);

    for(int i=0;i<N;i++){
        cin>>A[i];
        if(A[i]==0){
            cout << 0;
            return 0;
        }
    }

    ll res = 1;
    for(int i=0;i<N;i++){
        if(A[i]<=max/res){
            res*=A[i];
        }
        else{
            cout << -1;
            return 0;
        } 
    }

    cout << res;
}

Measured memory_bytes: 4048
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
const int N=100;
int root,par[N],chl[N][2];
void pre(int v){
	if (v==-1) return;
	printf(" %d",v);
	pre(chl[v][0]);
	pre(chl[v][1]);
}
void in(int v){
	if (v==-1) return;
	in(chl[v][0]);
	printf(" %d",v);
	in(chl[v][1]);
}
void post(int v){
	if (v==-1) return;
	post(chl[v][0]);
	post(chl[v][1]);
	printf(" %d",v);
}
main(){
	int n,node,r,l;
	scanf("%d",&n);
	for (int i=0;i<n;i++) par[i]=-1;
	for (int i=0;i<n;i++){
		scanf("%d%d%d",&node,&l,&r);
		chl[node][0]=l;chl[node][1]=r;
		par[l]=par[r]=node;
	}
	for (int i=0;i<n;i++) if (par[i]==-1){root=i;break;}
	printf("Preorder\n");pre(root);printf("\n");
	printf("Inorder\n");in(root);printf("\n");
	printf("Postorder\n");post(root);printf("\n");
}


Measured memory_bytes: 3212
n = int(input())
list_a = []
list_b = []
su = 0
for i in range(n):
  a,b = map(int,input().split())
  list_a.append(a)
  list_b.append(b)
list_a = list_a[::-1]
list_b = list_b[::-1]
for i in range(n):
  list_a[i] += su
  if list_a[i]%list_b[i]==0:
    continue
  else:
    x = list_b[i]-(list_a[i]%list_b[i])
    su += x
#  print(list_a)
print(su)


Measured memory_bytes: 14900
ABC=list(map(int,input().split()))
ABC=sorted(ABC)

ans=0
if ABC[0]!=ABC[2]:    
    if ABC[0]%2==ABC[1]%2:
        ans+=(ABC[2]-ABC[0])//2
        ans+=(ABC[2]-ABC[1])//2
        ans+=(ABC[2]-ABC[0])%2
    else:
        ans+=(ABC[2]-ABC[0])//2
        ans+=(ABC[2]-ABC[1])//2
        ans+=2
print(ans)

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

using namespace std;

int main() {
  int a, b;

  while (cin >> a >> b) {
    a += b;
    int dig_num = 1;
    while ((a /= 10) != 0) {
      ++dig_num;
    }
    cout << dig_num << "\n";
  }
}


Measured memory_bytes: 3060
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, P = map(int, rl().split())
    S = input()
    
    ans = 0
    if P == 2 or P == 5:
        for i in range(N - 1, -1, -1):
            si = int(S[i])
            if si % P == 0:
                ans += i + 1
    else:
        cum = [0]
        t = 1
        for i in range(N - 1, -1, -1):
            cum.append(int(S[i]) * t % P)
            t = t * 10 % P
        for i in range(N):
            cum[i + 1] = (cum[i + 1] + cum[i]) % P
        
        counter = defaultdict(int)
        for val in cum:
            ans += counter[val]
            counter[val] += 1
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 48588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC114A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            if (x == 7 || x == 5 || x == 3)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
def calc_surface(l)
    return ((l[0] - l[4]) * (l[3] - l[5]) - (l[2] - l[4]) * (l[1] - l[5])).abs / 2.0
end
 
while l=gets
    x1, y1, x2, y2, x3, y3, px, py = l.split.map(&:to_f)
     
    abc = calc_surface([x1, y1, x2, y2, x3, y3])
    pab = calc_surface([x1, y1, x2, y2, px, py])
    pbc = calc_surface([x2, y2, x3, y3, px, py])
    pca = calc_surface([x3, y3, x1, y1, px, py])
     
    if abc >= pab + pbc + pca
        puts "YES"
    else
        puts "NO"
    end
end


Measured memory_bytes: 6872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

using ld = long double;
ld EPS = 1e-12;
const int GETA = 2010;
const int MAX = 4200;
int n;

typedef pair<ld, ld> Pdd;
ld X[100], Y[100];

ld f(ld a, ld b, ld y){
	return (y - b) / a;
}

ld g(int p, int q, int i){
	if(Y[p] < Y[q]) swap(p, q);
	double a = Y[p] - i, b = i - Y[q];
	return (b * X[p] + a * X[q]) / (a + b);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	while(cin >> n, n){
		for(int i = 0; i < n; i++){
			cin >> X[i] >> Y[i];
		}
		int ans = 0;
		for(int y = -2010; y <= 2010; y++){
			// y??????(y+1)
			vector<Pdd> v;
			for(int i = 0; i < n; i++){
				int ni = (i + 1) % n;
				if(Y[i] == Y[ni] || y < min(Y[i], Y[ni]) || y + 1 > max(Y[i], Y[ni])) continue;
				ld x1 = g(i, ni, y), x2 = g(i, ni, y + 1);
				if(x1 > x2) swap(x1, x2);
				v.push_back({ x1, x2 });
			}
			if(v.size() == 0) continue;
			sort(v.begin(), v.end());
			int xr = -5000;
			for(int i = 0; i < v.size(); i += 2){
				Pdd d1 = v[i], d2 = v[i + 1];
				int l = max(int(floor(d1.first)), xr);
				int r = ceil(d2.second);
				//cout << y << " " << r - l << endl;
				ans += r - l;
				xr = r;
			}
		}
		cout << ans << endl;
	}
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;
    string a = "Yes";
    REP(i, A)
    {
        if (S[i] - '0' >= 0 && S[i] - '0' <= 9)
            continue;
        a = "No";
    }
    REP(i, B)
    {
        if (S[i + A + 1] - '0' >= 0 && S[i + A + 1] - '0' <= 9)
            continue;
        a = "No";
    }
    if (S[A] != '-')
        a = "No";
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	long long int N,M;
	scanf("%lld %lld",&N,&M);
	if(N==2||M==2){
		printf("0");
	return 0;
	}
	if(N==1&&M==1){
		printf("1");
		return 0;
	}
	if(N==1){
		printf("%lld",M-2);
	return 0;
	}
	
	if(M==1){
	printf("%lld",N-2);
	return 0;
	}
	
	
	
	printf("%lld",(N-2)*(M-2));
	
		
	}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  repr(i, 1, n + 1) {
    double sq = sqrt(i);
    if (ceil(sq) == sq) {
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

ll N, M, P;
ll dist[3000];
vector<vector<ll>>Eli;
vector<ll>E[3000];
set<ll>vis;
void dfs(int now){

	fore(x, E[now]) {
		if (vis.count(x))continue;
		vis.insert(x);
		dfs(x);
	}
}

ll Bellman_Ford(){
	//init
	for (int i = 0; i < N; i++)dist[i] = inf;
	dist[0] = 0;
	for (int i = 0; i < N - 1; i++) {
		for (int j = 0; j < M; j++) {
			ll u = Eli[j][0];
			ll v = Eli[j][1];
			ll c = Eli[j][2];
			if (!vis.count(u) || !vis.count(v))continue;
			if (dist[u] == inf)continue;
			if (dist[v] > dist[u] + c)dist[v] = dist[u] + c;
		}
	}

	
	//check
	for (int j = 0; j < M; j++) {
		ll u = Eli[j][0];
		ll v = Eli[j][1];
		ll c = Eli[j][2];
		if (!vis.count(u) || !vis.count(v))continue;
		if (dist[u] == inf)continue;
		if (dist[v] > dist[u] + c)return inf;
	}
	return max(0LL,-dist[N - 1]);
}

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

	cin >> N >> M >> P;
	for (int i = 0; i < M; i++) {
		ll A, B, C;
		cin >> A >> B >> C;
		A--, B--;
		Eli.pb({A,B,-(C-P)});
		E[B].pb(A);
	}
	vis.insert(N - 1);
	dfs(N - 1);


	ll ans = Bellman_Ford();
	if (ans == inf)puts(-1);
	else puts(ans);

	return 0;
}

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

using namespace std;

//#define debug

#ifdef debug
#define mode cout << "--- debug mode ---" << endl
#define dump(i) cout << "[*] " #i ": " << i << " (line: " << __LINE__ << ")" << endl
#else
#define mode
#define dump(i)
#endif

struct Station {
  int c;
  int s;
  int f;
};

int func(const vector<Station>& stations, int n, const int max) {
  int ret = stations[n].s + stations[n].c;
  if (n == max) {
    return ret;
  } else {
    while(n < max) {
      ++n;
      dump(ret);
      dump(n);
      dump(stations[n].f);
      const int tmp = ret % stations[n].f;
      if (tmp > 0) {
        ret -= tmp;
        ret += stations[n].f;
      }
      if (ret < stations[n].s) {
        while (ret < stations[n].s) {
          ret += stations[n].f;
        }
      }
      ret += stations[n].c;
    }
    return ret;
  }
}
int main() {
  mode;

  int n;
  cin >> n;
  vector<Station> station(n);
  vector<int> ans(n);
  for (int i = 0; i < n - 1; ++i) {
    int c, s, f;
    cin >> c >> s >> f;
    station[i].c = c;
    station[i].s = s;
    station[i].f = f;
  }

  --n;
  const int max = n;
  dump(max);
  ans[n] = 0;
  --n;
  while (n >= 0) {
    dump(n);
    ans[n] = func(station, n, max-1);
    --n;
  }

  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
      solve();
  }
}


void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<int> table(n);
  for (int i = n; i >= 1; --i) {
    int tmp = 0;
    for (int j = 2 * i; j <= n; j += i) { // 出た, 調和級数
      (tmp += table[j - 1]) %= 2;
    }
    if (tmp != a[i - 1]) table[i - 1] = 1;
  }
  cout << accumulate(all(table), 0) << endl;
  rep(i, n) if (table[i]) cout << i + 1 << " "; cout << endl;
}


Measured memory_bytes: 2560
#include <iostream>
const int N = 100;
const int INF = 0x7fffffff;
#define min(a, b) a > b ? b : a
using namespace std;

int a[N];

int main () {
	int n, T, sum = 0, cnt = 0, mn = INF;
	cin >> n >> T;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		mn = min (mn, a[i]);
		sum += a[i];
	}
	T -= sum;
	cnt = cnt + n + T / mn;
	cout << cnt << "\n";
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

n, k = map(int, input().split())

d = Counter()
for _ in range(n):
    a, b = map(int, input().split())
    d[a] += b

x = sorted(d.items(), key=lambda x: x[0])
cnt = 0
for a, b in x:
    cnt += b
    if cnt >= k:
        print(a)
        exit()

Measured memory_bytes: 21308
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a;
    scanf("%d",&a);
    int i,b[4];
    for(i=3;i>=0;i--)
    {
        b[i]=a%10;
        a/=10;
    }
    if(b[0]+b[1]+b[2]+b[3]==7){printf("%d+%d+%d+%d=7",b[0],b[1],b[2],b[3]);}
    else if(b[0]+b[1]+b[2]-b[3]==7){printf("%d+%d+%d-%d=7",b[0],b[1],b[2],b[3]);}
    else if(b[0]+b[1]-b[2]+b[3]==7){printf("%d+%d-%d+%d=7",b[0],b[1],b[2],b[3]);}
    else if(b[0]+b[1]-b[2]-b[3]==7){printf("%d+%d-%d-%d=7",b[0],b[1],b[2],b[3]);}
    else if(b[0]-b[1]+b[2]+b[3]==7){printf("%d-%d+%d+%d=7",b[0],b[1],b[2],b[3]);}
    else if(b[0]-b[1]+b[2]-b[3]==7){printf("%d-%d+%d-%d=7",b[0],b[1],b[2],b[3]);}
    else if(b[0]-b[1]-b[2]+b[3]==7){printf("%d-%d-%d+%d=7",b[0],b[1],b[2],b[3]);}
    else if(b[0]-b[1]-b[2]-b[3]==7){printf("%d-%d-%d-%d=7",b[0],b[1],b[2],b[3]);}
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n, k, x int
	fmt.Scan(&n, &k)
	ans := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		if k-x < x {
			ans += k - x
		} else {
			ans += x
		}
	}
	fmt.Println(ans * 2)
}

Measured memory_bytes: 512