akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

struct UnionFind{
    vector<ll> par;
    vector<ll> siz;

    void init(ll n){
        for(ll i=0;i<n;i++){
            par.push_back(i);
            siz.push_back(1);
        }
    }
    ll root(ll x){
        //根を返す
        if(par[x]==x){
            return x;
        }
        else{
            return (par[x]=root(par[x]));
        }
    }
    bool sameParent(ll x,ll y){
        return(root(x)==root(y));
    }
    void unite(ll x, ll y){
        x=root(x);y=root(y);
        if(x==y)    return;
        //データ構造->小を大にくっつける
        if(siz[x]<siz[y]) swap(x,y);
        siz[x] += siz[y];
        par[y]=x;
    }

    ll size(ll x){
        return siz[root(x)];
    }
};
//もう一回ワーシャルフロイドして一回でも更新が起きたら正しくない？

int main(){
    int n;cin>>n;
    ll a[n][n];
    rep(i,n)rep(j,n) cin>>a[i][j];
    bool update=false;
    rep(k,n){
        rep(i,n){
            rep(j,n){
                if(a[i][j]>a[i][k]+a[k][j]) update=true;
            }
        }
    }
    if(update){
        cout<<-1<<endl;return 0;
    }
    ll ans=0;

    //最短経路構築
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ll cost=a[i][j];
            //このコストの辺がグラフに要るかどうか
            bool f=false;
            for(int k=0;k<n;k++){
                //kは経由地
                if(k==i) continue;
                if(k==j) continue;
                f=(f||(cost==a[i][k]+a[k][j]));
            }
            if(!f) ans+=cost;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
int a[500000], n, i;
int count = 0;

void  merge(int ar[], int left, int mid, int right){
    int n1, n2, L[500000], R[500000], i, j, k;
    n1 = mid - left;
    n2 = right - mid;
    for(i = 0; i < n1; i++)
        L[i] = ar[left + i];
    for(i = 0; i < n2; i++)
        R[i] = ar[mid + i];
    L[n1] = 1000000001;
    R[n2] = 1000000001;
    i = j = 0;
    for(k = left; k < right  ; k++){
        if( L[i] <= R[j]){
            ar[k] = L[i];
            i++;
            count++;
        } else {
            ar[k] = R[j];
            j++;
            count++;
        }
        
    }
  }
    
void mergesort (int ar[], int left, int right){
    int mid;
    if(left + 1 < right){
           mid = (left + right) / 2;
           mergesort(ar, left, mid);
           mergesort(ar, mid, right);
           merge(ar, left, mid, right);
        }
 }
    
int main(){
   
   scanf("%d", &n);
   for (i = 0; i < n; i++){
      scanf("%d", &a[i]);
   }
        
    mergesort(a, 0, n);
    
    for(i = 0; i < n; i++){
        if(i != 0){
            printf(" ");
        }
        printf("%d", a[i]);
    }
    
    printf("\n%d\n", count);
       
    return 0;
}



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

int change[10] = {0, 1, 2, 3, 5, 7, 8, 9};

void solve(int x) {
  if( x/8 > 0 ) solve( x/8 );
  cout << change[x%8];
}

int main()
{
  int n;
  while( cin >> n, n ) {
    solve( n );
    cout << endl;
  }
}

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

int main() {
	int n;
	cin >> n;
	int ac = 0, tle = 0, wa = 0, re = 0;
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		if(s == "AC") ac++;
		else if(s == "TLE") tle++;
		else if(s == "WA") wa++;
		else re++;
	}
	cout << "AC" << " " << "x" << " " << ac << "\n";
	cout << "WA" << " " << "x" << " " << wa << "\n";
	cout << "TLE" << " " << "x" << " " << tle << "\n";
	cout << "RE" << " " << "x" << " " << re << "\n";
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for(int i=0;i<n;++i)
#define EPS 1e-9
typedef complex<double> Point;
typedef vector<Point> VP;
typedef pair<Point, Point> Line;
#define X real()
#define Y imag()

#define EQ(n,m) (abs((n)-(m)) < EPS)

namespace std {
  bool operator<(const Point a, const Point b) {
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
  // bool operator==(const Point a, const Point b) {
  //   return abs(a-b)<EPS;
  // }
}

double dot(Point a, Point b) {
  return a.X*b.X + a.Y*b.Y;
}

// ?????????cross(a,b) = |a||b|sin??
double cross(Point a, Point b) {
  return a.X*b.Y - a.Y*b.X;
}

int ccw(Point a, Point b, Point c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

bool isecSS(Point a1, Point a2, Point b1, Point b2) {
  return ccw(a1, a2, b1)*ccw(a1, a2, b2) <= 0 &&
  ccw(b1, b2, a1)*ccw(b1, b2, a2) <= 0;
}

Point crosspointLL(Point a1, Point a2, Point b1, Point b2) {
  double d1 = cross(b2-b1, b1-a1);
  double d2 = cross(b2-b1, a2-a1);
  if (EQ(d1, 0) && EQ(d2, 0)) return a1;  // same line
  assert(!EQ(d2, 0)); // ???????????????
  return a1 + d1/d2 * (a2-a1);
}


int main(void){
    int n;
    while(cin>>n,n){
        vector<Line> ls(n);
        int crosscnt=0;
        rep(i,n){
            double p1x,p1y,p2x,p2y;
            cin>>p1x>>p1y>>p2x>>p2y;
            ls[i] = {{p1x,p1y},{p2x,p2y}};
            set<Point> cp;
            rep(j,i){
                if(isecSS(ls[i].first,ls[i].second,ls[j].first,ls[j].second)){
                    Point p = crosspointLL(ls[i].first,ls[i].second,ls[j].first,ls[j].second);
                    if(p.X>-100 && p.X<100 && p.Y>-100 && p.Y<100) cp.insert(p);
                }
            }
            crosscnt += (int)cp.size();
        }
        cout<<n+crosscnt+1<<endl;
    }

    return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int main(){
int a,b,c,x,ans;
  cin>>a>>b>>c>>x;
  REP(i,a+1){
    REP(j,b+1){
      REP(k,c+1){
        if(500*i+100*j+50*k==x)ans++;
      }
    }
  }
  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>
#include <bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
//constexpr long long MOD = 1000000007;

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

int main()
{
  int N, R;
  std::cin >> N >> R;
  int ans = 0;
  if(N <= 10)
    ans = R + 100 * (10 - N);
  else
    ans = R;
  std::cout << ans << std::endl;
  return 0;
}



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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
    int N, K;
    cin >> N >> K;
    double ans = 0.;
    for (int i = 1; i <= N; i++)
    {
        int num = i;
        int cnt = 0;
        while (num < K)
        {
            num *= 2;
            cnt++;
        }
        ans += 1.0 / N * pow(0.5, cnt);
    }
    cout << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::input;
fn main() {
	input!(n: usize);

	let mut ans: usize = 0;
//	let mut count: [usize; 10000] = [0; 10000];
	let mut count: Vec<usize> = vec![0; 10000010];
	for i in 2..n+1 {
		let mut j = 1;
		loop {
			if i * j > 10000000 {
				break;
			}
			count[i*j] += 1;
			j += 1;
		}
	}
	for k in 1..n+1 {
		ans += k * (count[k] + 1);
	}
	println!("{}", ans);
}


Measured memory_bytes: 80164
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#define re register
const int MAXN=2e5+10;
int n,K,s[MAXN],a[MAXN],timee;
char fin[10010],*p1=fin,*p2=fin;
char getc()
{
	return p1==p2&&(p2=(p1=fin)+fread(fin,1,10000,stdin),p1==p2)?EOF:*p1++;
}
int read()
{
	re int x=0;
	re char ch=0;
	while(ch<'0'||ch>'9') ch=getc();
	while('0'<=ch&&ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getc();
	return x;
}
inline void insert(int x,int w)
{
	for(;x<=n;x+=x&-x) s[x]+=w;
}
inline int query(int x)
{
	re int res=0;
	for(;x;x-=x&-x) res+=s[x];
	return res;
}
int main()
{
	//freopen("t2.out","w",stdout);
	n=read();
	K=read();
	for(re int i=1;i<=n;i++) a[i]=read();
	while(K--)
	{
		re bool flag=1;
		memset(s,0,(n+5)*sizeof(int));
		for(re int i=1;i<=n;i++) insert(std::max(1,i-a[i]),1),insert(std::min(n,i+a[i])+1,-1);
		for(re int i=1;i<=n;i++) a[i]=query(i),flag&=(a[i]==n);
		if(flag) break;
	}
	for(re int i=1;i<=n;i++) printf("%d ",a[i]);
	printf("\n");
	return 0;
}
/*
5 1
1 0 0 1 0
*/

Measured memory_bytes: 5284
/*
 * 2×N のマス目があります。上から i 行目、左から j 列目 (1≤i≤2, 1≤j≤N) のマスをマス (i,j) と表すことにします。
 * 
 * あなたははじめ、左上のマス (1,1) にいます。 あなたは、右方向または下方向への移動を繰り返し、右下のマス (2,N) に移動しようとしています。
 * 
 * マス (i,j) には Ai,j 個のアメが置かれています。 あなたは移動中に通ったマスに置いてあるアメをすべて回収します。 
 * 左上および右下のマスにもアメが置かれており、あなたはこれらのマスに置かれているアメも回収します。
 * 
 * 移動方法をうまく選んだとき、最大で何個のアメを回収できるでしょうか。
 */

import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int n = Integer.parseInt(sc.next());
            int[][] candies = new int[2][n];
            int[][] dp = new int[2][n];
            
            for(int i=0; i<2*n; i++){
            	candies[i/n][i%n] = Integer.parseInt(sc.next());
            }
            dp[0][0] = candies[0][0];
            dp[1][0] = dp[0][0] + candies[1][0];
            for(int i=1; i<n; i++){
            	dp[0][i] = dp[0][i-1] + candies[0][i];
            	dp[1][i] = candies[1][i] + Math.max(dp[0][i], dp[1][i-1]);
            }
            
            //出力
            System.out.println(dp[1][n-1]);
            sc.close();
        }
    }
	

Measured memory_bytes: 23636
import java.util.Scanner;

class Main{
   public static void main(String args[]) {
      Scanner stdIn = new Scanner(System.in);
      int n = stdIn.nextInt();
      int sum = 1;
      for(int i = 0; i < 3; i++){
         sum *= n;
      }
      System.out.println(sum);
   }
}

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

long long f(long long b, long long n){
    if(n < b){
        return n;
    }else{
        return f(b, n/b) + n%b;
    }
}

int main(){
    long long n, s;
    scanf("%lld%lld", &n, &s);
    //printf("n=%lld\ns=%lld\n", n, s);

    if(s > n){
        printf("-1");
        return 0;
    }

    if(s == n){
        printf("%lld\n", n+1);
        return 0;
    }

    for(int b = 2; b <= 10000000; b ++){
        if(f(b, n) == s){
            printf("%d", b);
            return 0;
        }
    }

    for(long long a = 1000000LL; a >= 1; a --){
        // (a-1)*b = n-s
        if( (n-s)%a == 0 ){
            long long b = 1+(n-s)/a;
            //printf("a=%lld n-s=%lld b=%lld\n", a, n-s, b);
            if(a >= b || s-a >= b){continue;}
            if(f(b, n) != s){continue;}
            printf("%lld\n", b);
            return 0;
        }
    }

    printf("-1");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	long long e; string s;
	cin >> s;
	cout << "2018/" << s[5] << s[6] << s[7] << s[8] << s[9] << endl;
	cin >> e;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
 
int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	
	string t;
	cin >> t;
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	
	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void doIt() {
		long n = sc.nextLong();
		long p = sc.nextLong();
		if(n == 1) {
			System.out.println(p);
			return;
		}
		int len = (int)Math.ceil(Math.pow(p, 1.0/n));
		//System.out.println(Math.pow(p, 1.0/n)+ " "+pp);
		boolean[] prime = makePrime(len);
		long ans = 1;
		long[] f = new long[len + 1];
		Arrays.fill(f, 0);
		for(int i = 2; i <= len; i++) {
			if(prime[i]) {
				while(p % i == 0) {
					f[i]++;
					p /= i;
					//System.out.println(p);
				}
				//System.out.println(ans + " " + Arrays.toString(f));
				ans *= Math.pow(i, f[i] / n);
			}
			//if(p == 1)break;
		}
		System.out.println(ans);
	}
	boolean[] makePrime(int n) {
		boolean[] p = new boolean[n + 1];
		Arrays.fill(p, true);
		p[0] = false; p[1] = false;
		for(int i = 2; i <= n; i++) {
			if(p[i]) {
				for(int j = i + i; j <= n; j += i) {
					p[j] = false;
				}
			}
		}
		//System.out.println(n + " " +Arrays.toString(p));
		return p;
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 29268
#include <stdio.h>
 
int main(void){
    int n, m, target[100], i, j, num, friend[100] = {0}, x = 0;
    scanf("%d %d", &n, &m);
    for (i = 0; i < m; i++){
        scanf("%d", &target[i]);
    }
    for (i = 0; i < m; i++){
        for (j = 0; j < n; j++){
            scanf("%d", &num);
            if (num == target[i])
                friend[j] += 1;
            else friend[target[i]-1]++;
        }
    }
    for (i = 0; i < n; i++)
        printf("%d\n", friend[i]);
    return 0;
}

Measured memory_bytes: 1828
n=int(input())
s=list(input())
ans=[0]*n
ans[0]+=list(s[1:]).count("E")
for i in range(1,n):
    if s[i]=="E" and s[i-1]=="E":
        ans[i]=ans[i-1]-1
    elif (s[i]=="E" and s[i-1]=="W") or (s[i-1]=="E" and s[i]=="W"):
        ans[i]=ans[i-1]    
    else:
        ans[i]=ans[i-1]+1
print(min(ans))

Measured memory_bytes: 23156
#include <stdio.h>

int main(void)
{
	int x, s = 0, t = 0;
	int i;

	for (i = 0; i < 4; i++) {
		scanf("%d", &x);
		s += x;
	}
	for (i = 0; i < 4; i++) {
		scanf("%d", &x);
		t += x;
	}

	printf("%d\n", s >= t ? s :t);

	return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min, std::next_permutation
#include <iomanip> // std::setprecision
#include <cmath> // std::ceil
#include <numeric> // std::gcd
#include <limits> // std::numeric_limits<long int>::max()

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 

template<typename T>
T powint (const T& x, const T& y) {
  T ret = 1;
  for(int i=0; i<y; ++i) ret *= x;
  return ret;
}

ll factorial(ll X) {
  ll ans = 1;
  for(int i=1; i<X+1 ; ++i) ans *= i;
  return ans;
}

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

  vector<vector<int> > perms;
  vector<int> numbers;
  for(int i=0; i<N; ++i) numbers.push_back(i+1);
  do{
    perms.push_back(numbers);
  } while ( next_permutation(numbers.begin(), numbers.end()) );
  
  ll a = 0;
  ll b = 0;
  for(const auto perm : perms) {
    for(int i=0; i<N; ++i) {
      if(P[i] > perm[i]) {
        a++;
        break;
      }
      else if(P[i] < perm[i]) {
        break;
      }
    }
  } 
  for(const auto perm : perms) {
    for(int i=0; i<N; ++i) {
      if(Q[i] > perm[i]) {
        b++;
        break;
      }
      else if(Q[i] < perm[i]) {
        break;
      }
    }
  } 

  cout << abs(a-b) << endl;
  return 0;
}


Measured memory_bytes: 3256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<sys/time.h>
#include<cstring>
#include<cmath>
using namespace std;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(int x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n=ri();
	wi(n/3);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
int main(){
    string n;
    cin >> n;
    
    for(int i=0;i<3;i++){
        if(n[i]=='1'){
            n.replace(i,1,"9");
        }else{
            n.replace(i,1,"1");
            
        }
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		long a = sc.nextInt();
		long b = sc.nextInt();
		long ans = 0;
		if (a > b) {
		} else if (n == 1) {
			if (a == b) {
				ans = 1;
			}
		} else if (n == 2) {
			if (a <= b) {
				ans = 1;
			}
		} else {
			ans = b * (n - 2) - a * (n - 2) + 1;
		}
		System.out.println(ans);

	}
}


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

int a,b; //変数を宣言

cin >> a >> b ; //外部入力を変数を2つ読み込む

//面積・空白スペース・周の長さ・改行を出力
cout<<a * b  <<" "<< 2 * (a + b )<< endl;
return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define rep(i,n,k) for(long long int i=k; i<n; ++i)
#define drep(i,n,k) for(long long int i=n-1; i>=k; --i)
using namespace std;

int main(){
  int n;
  long long int ans = 0;
  cin >> n;
  vector<int> s(n);
  rep(i,n,0){
    cin >> s[i];
    ans += s[i]*s[i];
  }
  sort(s.begin(),s.end());
  
  if(s[0] == s[n-1]) ans = 0;
  rep(i,s[n-1],s[0]){
    long long int sum = 0;
    rep(j,n,0){
      sum += (s[j] - i) * (s[j] - i);
    }
    if(ans > sum) ans = sum;
  }
  cout << ans << endl;
}

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

int main()
{
	int a1, a2, a3, b1, b2, b3;
	int x[4][4];
	
	for(int i=1; i<=3; i++)
	{
		for(int j=1; j<=3; j++)
		{
			cin >> x[i][j];
		}
	}
	a1 = 0;
	b1 = x[1][1] - a1;	
	b2 = x[1][2] - a1;
	b3 = x[1][3] - a1;
	
	a2 = x[2][1] - b1;
	a3 = x[3][1] - b1;
	
	if(a2+b2==x[2][2] && a2+b3==x[2][3] && a3+b2==x[3][2] && a3+b3== x[3][3])
	{
		cout << "Yes" << endl;
		return 0;
	}
	
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ma1,ma2,ma3,a[9],i,j,c;
int main(){
	for(i=0;i<10;i++){
		cin>>a[i];
	}
	while(c<=9){
	     for(j=9;j>=1;j--){
		     if(a[j]<a[j-1]){
			    swap(a[j],a[j-1]);
		      }
		 }
		  c++;
		  j=9;
	 }
	 cout<<a[9]<<endl;
	 cout<<a[8]<<endl;
	 cout<<a[7]<<endl;
 }
		  
		  



Measured memory_bytes: 3068
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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 int INF = 1<<30;
const int mod = 1000000007;

int main(){
	int n;
	cin >> n;
	map<int, int> mp, used;
	vector<int> A;
	rep(i,n){
		int a;
		cin >> a;
		mp[a]++;
		used[a] = 0;
		A.push_back(a);
	}
	int cnt = 0;
	rep(i,n){
		if(!used[A[i]] && mp[A[i]]%2 == 1){
			cnt++;
			used[A[i]]++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 9976
#include <iostream>
#include <cmath>
using namespace std;
const int N = 2e5 + 500, INF = 1e9 + 500;
int a[N], b[N], c[N], n, dp[N][3];
int main(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	for(int i = 1; i <= n; i++){
		dp[i][1] = max(dp[i - 1][2] + b[i], dp[i - 1][3] + c[i]);
		dp[i][2] = max(dp[i - 1][1] + a[i], dp[i - 1][3] + c[i]);
		dp[i][3] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + b[i]);
	}
	cout << max(dp[n][1], max(dp[n][2], dp[n][3])) << endl;
}
/*
7
6 7 8
8 8 3
2 5 2
7 8 6
4 6 8
2 3 4
7 5 1
*/

Measured memory_bytes: 3712
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <algorithm>
#define MAX 50000
#define INF 100000000
using namespace std;
typedef long long ll;
int t[MAX+1],c[21];
struct bags{
	int value;
	int weight;
};
vector<bags> B;
int main()
{	
	int n,m; 
	struct bags tian;
	int dp[10002];
	cin>>n>>m;
	B.push_back(tian);
	for(int i=1;i<=n;i++)
	{
		struct bags tmp;
		cin>>tmp.value>>tmp.weight;
		B.push_back(tmp);
	}
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++)
		for(int j=m;j>=B[i].weight;j--)
		{
			dp[j]=max(dp[j],dp[j-B[i].weight]+B[i].value);
		}
	cout<<dp[m]<<endl;
}


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

int cnt=0;
long long half(long h){
  long long x=h/2;
  if(h==1)return cnt;
  cnt++;
  if(x>1){
    half(x);
  }else return cnt;
}
int main(){
  long h;
  cin>>h;
  int n=half(h);
  long long attack=0;
  for(long long i=0;i<=n;i++){
    attack+=pow(2,i);
    
  }
  cout<<attack<<endl;
  
}

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

void swap(int *a,int *b)
{
	int temp=0;
	temp=*a;
	*a=*b;
	*b=temp;
	
	return;
}

int main(){
	int a,b,c;
	
	cin >> a >> b >> c;
	if(a>b) swap(a,b);
	if(b>c) swap(b,c);
	if(a>b) swap(a,b);
	
	cout << a << " " << b << " " << c <<endl;
		
	return 0;
}

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

#define FOR(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)

int n, a[100005], b[100005], c[100005], A[100005], B[100005], C[100005];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("VACATION.inp", "r", stdin);
    //freopen("FROG1.out", "w", stdout);
    cin >> n;
    FOR(i,1,n) cin >> a[i] >> b[i] >> c[i];
    FOR(i,1,n)
    {
        A[i]=max(B[i-1], C[i-1])+a[i];
        B[i]=max(A[i-1], C[i-1])+b[i];
        C[i]=max(A[i-1], B[i-1])+c[i];
    }
    cout << max(A[n], max(B[n], C[n]));
    return 0;
}


Measured memory_bytes: 2560
<?php
$abcd = fgets(STDIN);
//a,b,c,dに分ける
for($i=0;$i<4;$i++){
	$array[$i] = substr($abcd, $i,1);
}
//op1,op2,op3の全パターンを探索
for ($i=0;$i<8;$i++) {
	$sum = 0;
	$temp;
	//op1からop3までのループ
	for ($j=0;$j<3;$j++){
		//op1から判定
		if (($i&1<<$j)==(1<<$j)){
			if ($j==0){
				$sum += $array[$j] + $array[$j+1];
				$temp= $array[$j] . "+" . $array[$j+1];
			}else {
				$sum += $array[$j+1];
				$temp= $temp. "+" . $array[$j+1];
			}
		}else {
			if ($j==0){
				$sum += $array[$j] - $array[$j+1];
				$temp= $array[$j] . "-" . $array[$j+1];
			}else {
				$sum -= $array[$j+1];
				$temp= $temp. "-" . $array[$j+1];
			}
		}
		//op3までいって7だったら出力
		if ($j==2 && $sum == 7){
			$ans = $temp . "=7";
		}
	}
}
echo $ans . "\n";

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

#ifdef LOCAL
#define debug(_) cerr << #_ << ": " << (_) << '\n'
#define _GLIBCXX_DEBUG
#else
#define debug(_) (void(0))
#endif  // LOCAL

int main(){
    int N, M, tmp;
    multiset<int> Ds, Ts;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        Ds.insert(tmp);
    }
    cin >> M;
    for (int i = 0; i < M; i++) {
        cin >> tmp;
        Ts.insert(tmp);
    }
    for (auto T: Ts) {
        debug(T);
        auto it = Ds.find(T);
        if (it == Ds.end()) {
            cout << "NO\n";
            return 0;
        }
        Ds.erase(it);
    }

    cout << "YES\n";

    return 0;
}

Measured memory_bytes: 22344
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        String s = sc.next();
        int n = s.length();
        long a = 0;
        long ans = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == 'A') {
                a++;
                continue;
            }
            if (i + 1 >= n) {
                break;
            }
            if (s.charAt(i) == 'B' && s.charAt(i + 1) == 'C') {
                ans += a;
                i++;
                continue;
            }
            a = 0;
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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


Measured memory_bytes: 23636
#include<iostream>
using namespace std;
int main(){
	int N;
	cin>>N;
	for(int i=1;i<=9;i++){
		if(N%i==0){
			if(N/i<10){
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
	return 0;
}

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

#define MAX 81

int get_line(char str[]);
int judge(char word[]);
void shift_word(char word[]);
void shift_line(int n, char line[]);

int main(void)
{
    char tmp[MAX], line[MAX];
    char *word;
    int shift_num;

    while(get_line(tmp) != 0) {
        strcpy(line, tmp);
        word = strtok(tmp, " ");
        if ((shift_num = judge(word)) != -1) {
            shift_line(shift_num, line);
        } else {
            while((word = strtok(NULL, " ")) != NULL) {
                if ((shift_num = judge(word)) != -1) {
                    shift_line(shift_num, line);
                    break;
                }
            }
        }
        printf("%s\n", line);
    }

    return 0;
}

int get_line(char str[])
{
    int i = 0;
    char c;

    while ((c = getchar()) != '\n' && c != EOF) {
        str[i++] = c;
    }
    str[i] = '\0';

    return i;
}

int judge(char word[])
{
    int i;

    for (i = 0; i < 26; i++) {
        if (strcmp(word, "the") == 0 ||
                strcmp(word, "this") == 0 || strcmp(word, "that") == 0) {
            return i;
        }
        shift_word(word);
    }
    return -1;
}

void shift_word(char word[])
{
    int i;
    int len = strlen(word);

    for (i = 0; i < len; i++) {
        if ('a' <= word[i] && word[i] <= 'z') {
            word[i] = (word[i] - 'a' + 1) % 26 + 'a';
        }
    }

    if (word[len - 1] == '.') {
        word[len - 1] = '\0';
    }
}

void shift_line(int n, char line[])
{
    int i;

    for (i = 0; i < (int)strlen(line); i++) {
        if ('a' <= line[i] && line[i] <= 'z') {
            line[i] = (line[i] - 'a' + n) % 26 + 'a';
        }
    }
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

using ll = long long;

const int N = 1e5+23;
const ll inf = 1e15;

vector<pair<int, int>> S[N], Y[N];
long long costS[N], costY[N];
long long ans[N];

void solve() {
  int n, m, s, t; scanf("%d%d%d%d", &n, &m, &s, &t);
  --s, --t;
  for (int u, v, a, b, i = 0; i < m; ++i) {
    scanf("%d%d%d%d", &u, &v, &a, &b);
    Y[--u].emplace_back(--v, a);
    Y[v].emplace_back(u, a);
    S[u].emplace_back(v, b);
    S[v].emplace_back(u, b);
  }
  for (int i = 0; i < n; ++i) {
    costS[i] = costY[i] = inf;
  }
  priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
  pq.emplace(0, s);
  costY[s] = 0;
  while (!pq.empty()) {
    ll d = pq.top().first, u = pq.top().second;
    pq.pop();
    if (d != costY[u]) continue;
    costY[u] = d;
    for (const auto &v: Y[u]) {
      if (costY[v.first] <= d+v.second) continue;
      costY[v.first] = d+v.second;
      pq.emplace(d+v.second, v.first);
    }
  }
  pq.emplace(0, t);
  costS[t] = 0;
  while (!pq.empty()) {
    ll d = pq.top().first, u = pq.top().second;
    pq.pop();
    if (costS[u] != d) continue;
    costS[u] = d;
    for (const auto &v: S[u]) {
      if (costS[v.first] <= d+v.second) continue;
      costS[v.first] = d+v.second;
      pq.emplace(d+v.second, v.first);
    }
  }
  ans[n] = inf;
  for (int i = n-1; i >= 0; --i) {
    ans[i] = min(ans[i+1], costY[i]+costS[i]);
  }
  for (int i = 0; i < n; ++i) printf("%lld\n", inf-ans[i]);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 18200
#include <iostream>
#include <string>
#define rep(n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  string N;
  cin >> N;
  
  int total = 0;
  rep(N.length()){
    total += (int)(N[i] - '0');
  }
  
  if(stoi(N) % total == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main() {
    string s;
    cin >> s;
    vector<string> a = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    int i = 0;
    for (i = 0; i < 7; ++i) {
        if (a[i] == s) break;
    }
    cout << 7 - i << endl;
}


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

int main() {
  int N, M; cin >> N >> M;
  vector<pair<int, int>> war(M);
  for (int i = 0; i < M; i++) cin >> war[i].second >> war[i].first;
  
  sort(war.begin(), war.end());
  
  int ans = 0;
  int cur = -1;
  for (int i = 0; i < M; i++) {
    if (cur <= war[i].second) {
      ans++;
      cur = war[i].first;
    }
  }
  cout << ans << endl;  
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, a, b, c, d;

int main()
{
	scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	if(c == 0 && d == 0) {puts(a==b?"YES":"NO"); return 0;}
	b -= a;
	ll S = (n-1) * c, E = (n-1) * d;
	if(b > E) {puts("NO"); return 0;}
	if(S <= b && b <= E) {puts("YES"); return 0;}
	ll SS = 0, SE = 1e9;
	while(SS<SE) {
		ll M = (SS+SE)/2;
		S - M*(c+d) <= b ? SE = M : SS = M+1;
	}
	S -= SS*(c+d); E -= SE*(c+d);
	puts(S <= b && b <= E ? "YES" : "NO");
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    multiset<double> a;
    double v;
    REP(i, n) {
        cin >> v;
        a.insert(v);
    }
    while (a.size() > 1) {
        auto fi = a.begin();
        auto se = fi;
        se++;
        double c = (*fi + *se) / 2;
        a.erase(fi);
        a.erase(se);
        a.insert(c);
    }
    cout << fixed << setprecision(10) << *(a.begin()) << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main(void) {
	int N,M;
	cin >> N >> M;

	int ans = 0;
	// 偶数＋偶数
	for (int i = 0; i < N-1; i++) {
		for (int j = i + 1; j < N; j++) ans++;
	}
	// 奇数＋奇数
	for (int i = 0; i < M-1; i++) {
		for (int j = i+1; j < M; j++) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	for a%b != 0 {
		a, b = b, a%b
	}
	return b
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	a := make([]int, n)
	max := 0
	var g int
	for i := range a {
		fmt.Scan(&a[i])
		if max < a[i] {
			max = a[i]
		}
		if i > 0 {
			g = gcd(g, a[i])
		} else {
			g = a[i]
		}
	}

	if k > max {
		fmt.Println("IMPOSSIBLE")
	} else if k%g == 0 {
		fmt.Println("POSSIBLE")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}


Measured memory_bytes: 5504
n,k,*a=map(int,open(0).read().split())
s,m=sum(a),1
for i in sum([[s//i,i]for i in range(1,int(s**.5)+1)if s%i<1],[]):
  p=[0]+sorted(j%i for j in a)
  for j in range(n):p[j+1]+=p[j]
  f=t=0
  for j in range(n):
    f|=t==p[~j]<=k
    t+=i-p[~j]+p[-j-2]
  m=max(m,i*f)
print(m)

Measured memory_bytes: 42716
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T & a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T & a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<class T> void getVector(vector<T> & v) {
	for (int i = 0; i < v.size(); ++i)
		cin >> v[i];
}

int main() {
	makei(x);
	say(x * x * x);
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    vector<ll> sum_pos_l(N+1), sum_pos_r(N+1), sum_all(N+1);
    rep(i, N) {
        sum_pos_l[i+1] = sum_pos_l[i] + max(A[i], 0LL);
        sum_pos_r[i+1] = sum_pos_r[i] + max(A[N-i-1], 0LL);
        sum_all[i+1] = sum_all[i] + A[i];
    }

    ll ans = 0;
    rep(i, N-K+1) {
        int l = i, r = N - K - i;
        ll tmp = sum_pos_l[l] + sum_pos_r[r] + max(0LL, sum_all[N-r] - sum_all[l]);
        ans = max(ans, tmp);
        // DUMP2(i, tmp);
    }
    cout << ans << endl;
}



Measured memory_bytes: 3456
#include <stdio.h>

int main(void)
{
    int a, b, c, i, count;
    count = 0;

    scanf("%d %d %d", &a, &b, &c); //３つの整数を読み込む

    for (i = a; i <= b; i++)
    {
        if (c % i == 0) //iがcの約数でa以上b以下の時のiを求める
        {
            count++; //該当するiの数をカウントして出力したい
        }
    }

    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(i) sort((i).begin(),(i).end())
#define INF 2000000000
constexpr ll mod = 1000000007;

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	x -= z;
	y += z;
	cout << x / y << "\n";

	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    N = int(input())
    A = list(map(int,input().split()))

    a = max(A)
    if not all(0 <= a - b <= 1 for b in A):
        print('No')
        return
    
    cnt = sum(0 if a == b else 1 for b in A)
    if cnt == 0 and (2*a <= N or a + 1 == N):
        print('Yes')
    elif a == cnt == N:
        print('Yes')
    elif a - cnt > 0 and (a - cnt)*2 <= N - cnt:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 20720
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  long long N;

  std::cin >> N;

  long long dm = N - 1;

  for (int i = 1; 1LL * i * i <= N; i ++)
    if (N % i == 0)
      dm = std::min(i + N / i - 2, dm);

  std::cout << dm << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	unordered_set<string> st;
	int n;
	cin>>n;
	string s;
	while(n--)
	{
		cin>>s;
		if(st.find(s)==st.end())
			st.insert(s);
	}
	cout<<st.size();
}

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

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

  for(i=1;i<=n;i++)
  {
    x = i;
    if( x%3 == 0 ) 
        cout << " " << i;
    else
    {   
      while( x != 0 ) 
      {   
        if( x%10 == 3 ) 
        {   
          cout << " " << i;
          break;
        }   
        x /= 10; 
      }   
    }   
  }

  cout << endl;

  return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<pii>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}




struct point{
    int y, x, n;
};

int grid[3000][3000];
ll dp[3000][3000][4];


int main() {
    int r, c, l;
    cin >> r >> c >> l;
    rep(i, l) {
        int ri, ci, vi;
        cin >> ri >> ci >> vi;
        grid[ri-1][ci-1] = vi;
    }

    rep(i, r) {
        rep(j, c) {
            if (i) rep(x, 4) chmax(dp[i][j][0], dp[i - 1][j][x]);
            if (j) {
                rep(kk, 4){
                    chmax(dp[i][j][kk], dp[i][j-1][kk]);
                }
            }
            REPR(ki, 3, 0){
                chmax(dp[i][j][ki], dp[i][j][ki - 1] + grid[i][j]);
            }
        }

    }
    ll ans = 0;
    rep(i, 4){
        ans = max(ans, dp[r - 1][c - 1][i]);
    }
    co(ans);
}


Measured memory_bytes: 319752
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string.h>
#include<string>
#include<set>
#include<limits.h>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<functional>
#include<stack>
#include<deque>
#include<queue>
using namespace std;

signed main() {
	int n; cin >> n;
	int MIN = 1 << 29;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		int sum = 0;
		while (a % 2 == 0) {
			sum++;
			a /= 2;
		}
		MIN = min(MIN, sum);
	}
	cout << MIN << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);

int main(){
	int n,m;cin>>n>>m;
	ll x[n],y[n],z[n];
	rep(i,n)cin>>x[i]>>y[i]>>z[i];
	ll ans =-INFL;
	rep(a,2)rep(b,2)rep(c,2){
		vl su(n,0);
		rep(i,n){
			if(a==0)su[i]+=x[i];
			else su[i]-=x[i];
			if(b==0)su[i]+=y[i];
			else su[i]-=y[i];
			if(c==0)su[i]+=z[i];
			else su[i]-=z[i];
		}
		ll res =0;
		sort(been(su),greater<ll>());
		rep(i,m)res+=su[i];
		ans=max(ans,res);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int k,a,b;
int main(){
	scanf("%d%d%d",&k,&a,&b);
	if(b - a <= 2 || k <= a - 1){
		printf("%d\n",k + 1);
	}else{
		k -= a - 1;
		ll ans = a + ll(b - a) * (k >> 1);
		if(k & 1) ans++;
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 256
import math

x = y = 0
# 初めは90から
totalAngle = 90
while(1):
    try:
        num,angle = (int(x) for x in input().split(","))
        if num == 0:break
        rad = math.radians(totalAngle)
        y += math.sin(rad) * num
        x += math.cos(rad) * num
        # 右周り+だから-になる
        totalAngle -= angle
    except EOFError:
        break
print(int(x))
print(int(y))


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

int main(){
	string s, t;
	cin>>s;
	cin>>t;
	ll n=s.size(), m=t.size();
	ll i, j;
	vector<vector<ll>> dp(n+1, vector<ll>(m+1));
	for(i=0;i<=n;i++){
		for(j=0;j<=m;j++){
			if(i==0 || j==0)
				dp[i][j] = 0;
			else if(s[i-1]==t[j-1])
				dp[i][j] = 1+dp[i-1][j-1];
			else
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}
	i = n, j = m;
	string ans;
	while(i>0 && j>0){
		if(s[i-1]==t[j-1]){
			ans.push_back(s[i-1]);
			i--;
			j--;
		}
		else{
			if(dp[i-1][j]>dp[i][j-1])
				i--;
			else
				j--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 73664
#define scanf_s scanf
#include <string>
#include <stdio.h>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <iostream>
using namespace std;

#define MAX 100000
//#define MAX_ 1000

int n;
int partition(int A[], int p,int r)
{
	int x = A[r], work;
	int i, j;
	i = p - 1;
	for (j = p; j <= r - 1; j++) {
		if (A[j] <= x) {
			i = i + 1;
			work = A[i]; A[i] = A[j]; A[j] = work;
		}
	}
	work = A[i + 1]; A[i + 1] = A[r]; A[r] = work;
	return i + 1;
}
int main(void)
{
	int S[MAX], a, cou = 0;
	scanf_s("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf_s("%d", &S[i]);
	}
	a = partition(S, 0, n - 1);
	for (int i = 0; i < n; i++) {
		if (i != 0) printf(" ");
		if (a == i) {
			printf("[%d]", S[i]);
		}
		else printf("%d", S[i]);
	}
	printf("\n");
}

Measured memory_bytes: 1584
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        long a = sc.nextInt(), b = sc.nextInt(), x = sc.nextInt();
        if (a * a * b / 2 >= x) {
            double angle = Math.PI / 2 - Math.atan(1.0 * x / a / b / b * 2);
            out.println(angle * 180 / Math.PI);

        } else {
            double angle = Math.atan(2.0 * (a * a * b - x) / (a * a * a));
            out.println(angle * 180 / Math.PI);
        }


        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define AC ios::sync_with_stdio(0),cin.tie(0);

int main()
{
    AC
    int n,w,r=0;
    cin>>n>>w;
    vector<ll> dp(100001,1e10);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        int wei,val;
        cin>>wei>>val;
        for(int j=100000;j>=val;j--)
            dp[j]=min(dp[j],dp[j-val]+wei);
    }
    for(int i=1;i<dp.size();i++)
        if(dp[i]<=w) r=i;
    cout<<r<<'\n';
}


Measured memory_bytes: 1024