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

const int N = 3e5 + 5;
int h=0,k=0,m=0,x=0,y=0,ans=0;
map<pair<int,int>,int> mpp;
int row[N];
int col[N];

int main()
{  
   #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
   #endif
   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

   cin>>h>>k>>m;
   vector<int> p,q;
  for(int i=0;i<m;i++)
    { 
      cin>>x>>y;
      row[x]++;
      col[y]++;
      mpp[{x,y}]=1;
    }
   
   x = *max_element(row+1,row+h+1);
   y = *max_element(col+1,col+k+1);
   
   for(int i=1;i<=h;i++)
    {if(row[i]==x)
      p.push_back(i);
    }

   for(int i=1;i<=k;i++)
    {if(col[i]==y)
      q.push_back(i);
    }
   
   for(auto i : p)
     {
      for(auto j : q)
       {
          if(mpp[{i,j}])
          {
            ans = max(ans,x+y-1);
          }
          else {
            ans = max(ans,x+y);
            cout<<ans;
            return 0;
          }
       }
     }
    cout<<ans;
return 0;
}


Measured memory_bytes: 28528
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int cnt = 0;
  while(A >= B){
    B *= 2;
    cnt++;
  }
  while(B >= C){
    C*= 2;
    cnt++;
  }
  if(cnt <= K){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

#define ll long long
#define mod 1000000007

int main()
{
  ll n,d;
  cin>>n>>d;
  ll cnt=0;
  ll xi,yi;
  for(int i=0;i<n;++i){
  	cin>>xi>>yi;
  	if(sqrt(xi*xi + yi*yi) <= d){
  		++cnt;
	  }
  }
 cout<<cnt<<endl;
return 0;
}



Measured memory_bytes: 3672
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int i;
	int a,x;
	int ans=2000000000;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a);
		x=0;
		while(a%2==0)
		{
			x++;
			a/=2;
		}
		if(ans>x)
		  ans=x;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N,M=map(int,readline().split())
    H=list(map(int,readline().split()))
    A=[]
    B=[]
    for i in range(M):
        a,b=map(int,readline().split())
        A.append(a)
        B.append(b)

    flags=[True]*N
    for i in range(M):
        a=A[i]-1
        b=B[i]-1
        if H[a]<H[b]:
            flags[a]=False
        elif H[a]>H[b]:
            flags[b]=False
        else:
            flags[a]=False
            flags[b]=False

    res=0
    for i in range(N):
        if flags[i]:
            res+=1
    print(res)
if __name__=="__main__":
    main()

Measured memory_bytes: 22400
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")



#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include <ext/rope>
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define Find order_of_key
// #define at find_by_order
#define x first
#define y second
#define ll long long
#define lll __int128
#define ull unsigned long long
#define ulll unsigned __int128
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define gu getchar_unlocked()
#define pu putchar_unlocked()
#define all(x) x.begin(),x.end()
#define endl '\n'

const int mod=1000000007;

int main()
{
	int n,a,s=0,c=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		s=(s+(c*1LL*a)%mod)%mod;
		c=(c+a)%mod;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3624
s = gets.chomp
t = s.to_s.size - 1
sum = 0

(2 ** t).times do |i|
  temp = s.dup
  t.times do |j|
    k = s.size - temp.size
    if i[j] == 1
      sum += temp.slice!(0, j - k + 1).to_i
    end
  end
  sum += temp.to_i
end
puts sum

Measured memory_bytes: 1788
N,T=map(int,input().split())
C=[0]*N
NG=float('inf')
for i in range(N):
  c,t=map(int,input().split())
  if t <= T:
    C[i]=c
  else:
    C[i]=NG
if C.count(NG)==N:
  print('TLE')
else:
  print(min(C))

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

const ll MOD = 1000000007;

long long int mpow(long long int x, int n)
{
    if(n == 0)
        return 1;

    long long int k = 1;
    while(n > 1)
    {
        if(n % 2 == 1)
        {
            k *= x;
            k %= MOD;
        }
        x *= x;
        x %= MOD;
        n /= 2;

    }
    return (k * x) % MOD;
}

int n;
ll a[303030];
int as[303030][66];

int main()
{
    cin >> n;
    rep(i, n)
    {
        cin >> a[i];
        rep(j, 60)
        {
            as[i][j] = (a[i] >> j) & 1;
        }
    }
    for(int i = n - 1; i > 0; i--)
    {
        rep(j, 60)
        {
            as[i - 1][j] += as[i][j];
        }
    }

    ll res = 0;
    for(int i = 0; i < n - 1; i++)
    {
        rep(j, 60)
        {
            if((a[i] >> j) & 1)
            {
                res += ((n - i - 1 - as[i + 1][j]) * mpow(2, j)) % MOD;
            }
            else
            {
                res += (as[i + 1][j] * mpow(2, j)) % MOD;
            }
            res %= MOD;
        }
    }
    cout << res << endl;
    
    return 0;
}

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

using namespace std;

const int maxn = 1e5+100;

int n, h[maxn], dp[maxn];

int solve(int x){
    if(dp[x]!=0x3f3f3f3f)return dp[x];
    if(x>n)return 0x3f3f3f3f;
    if(x==n)return 0;
    for(int i=1; i<=2; i++){
        dp[x]=min(dp[x], abs(h[x]-h[x+i]) + solve(x+i));
    }
    return dp[x];
}

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

    cin >> n;

    for(int i=1; i<=n; i++)cin >> h[i];

    memset(dp, 0x3f3f3f3f, sizeof dp);

    cout << solve(1) << endl;
}


Measured memory_bytes: 5760
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

vector<ll> frac(1000010);

ll modinv(ll a) {
  ll M = MOD, b = M, u = 1, v = 0;
  while (b)
    u -= a / b * v, swap(u, v), a %= b, swap(a, b);
  return (u % M + M) % M;
}

ll nCr(ll n, ll r) {
  ll ret = 1;
  ret *= frac[n];
  ret *= modinv(frac[n-r]);
  ret %= MOD;
  ret *= modinv(frac[r]);
  ret %= MOD;
  return ret;
}

void solve() {
  ll n, k;
  cin >> n >> k;

  frac[0] = 1;
  for (ll i = 1; i < 1000010; i++) {
    frac[i] = frac[i-1] * i;
    frac[i] %= MOD;
  }

  ll ans = 0;
  k = min(k, n-1);
  for (ll i = 0; i <= k; i++) {
    ll zero_room = i;
    ll non_zero_room = n - i;
    ll a = nCr(non_zero_room + zero_room - 1, non_zero_room - 1);
    ll b = nCr(n, zero_room);
    ll tmp = a * b;
    tmp %= MOD;
    // cerr << "zero_room: " << zero_room << ", a: " << a << ", b: " << b << ", tmp: " << tmp << endl;
    ans += tmp;
    ans %= MOD;
  }

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


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

int main()
{
    int d;
    cin>>d;
    for(int h=0;h<d;h++)
    {
        if(h)cout<<endl;
        int n;cin>>n;
        int a[150][150]={};
        for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)a[i][j]=1;
        for(int i=1;i<=n;i++)a[1][i]=a[n][i]=a[i][1]=a[i][n]=0;
        a[2][n]=1;
        int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
        int x=3,y=n;

        for(int k=0;k<1000;k++)
        {
            while(1)
            {
                int X=x+dx[k%4];
                int Y=y+dy[k%4];
                int s=0;
                for(int j=0;j<4;j++)
                {
                    if(a[X+dx[j]][Y+dy[j]]==0)s++;
                }
                if(s!=1)break;

                a[X][Y]=0;
                x=X;
                y=Y;
            }
        }

        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=n;j++)
            {
                cout<<(a[j][i]?' ':'#');
            }
            cout<<endl;
        }
    }
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

char poll[120];
int sum[30];

int main(){
	int n;
	while(1){
		cin >> n;
		if(n == 0) break;
		for(int i = 0;i < n;i++){
			cin >> poll[i];
		}

		for(int i = 0;i < 30;i++) sum[i] = 0;
		int fi = 0,se = 0;
		int numfi = -1,numse = -1;
		int ans = -1;
		for(int i = 0;i < n;i++){
			int num = poll[i]-65;
			sum[num]++;
			if(sum[num] > fi){
				if(num != numfi){
					se = fi;
					numse = numfi;
				}
				fi = sum[num];
				numfi = num;
			}else if(sum[num] > se){
				se = sum[num];
				numse = num;
			}
			if(se + n-i-1 < fi){
				ans = i+1;
				break;
			}
		}
		if(ans == -1){
			cout << "TIE" << endl;
		}else{
			printf("%c ",numfi+65);
			cout << ans << endl;
		}
	}




}
	


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;


using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(int)(n);i++)
#define foi(i,k,n) for(int i=(k); i<(int)(n); i+=1)
#define fod(i,n,k) for(int i=k; i>=(int)n; i-=1)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define endl "\n"

#define int long long
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef long long llint;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<llint> VL;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
llint toint(string s) {stringstream ss(s); llint x; ss >> x; return x;}
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//gp_hash_table<string, llint> table;


//int mpow(llint base, llint exp) {
  //base %= MOD;
  //llint result = 1;
  //while (exp > 0) {
    //if (exp & 1) result = ((llint)result * base) % MOD;
    //base = ((llint)base * base) % MOD;
    //exp >>= 1;
  //}
  //return result;
//}


//void makegraph(int n, int m){
	//int i, u, v;
	//while(m--){
		//cin>>u>>v;
		//u--, v--;
		//g[u].pb(v);
		//g[v].pb(u);
	//}
//}

//void dfs(int u, int par){
	//for(int v:g[u]){
		//if (v == par) continue;
		//dfs(v, u);
	//}
//}


// ------------------------------------------------------------------ILB----------------------------------------------------------------  //



void solve(){
	loop(i, 5){
		int t;
		cin >> t;
		if(t == 0) cout << i + 1;
	}
}




int32_t main() {
	fast_io;
    int t = 1;
    //cin >> t;
    //int xx = 0
    while(t--) {
		//xx++;
		//cout << "Case ";
      solve();
    }
    return 0;
}



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

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  char c[H][W];

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> c[i][j];
    }
  }

  // w_bits, h_bits && 1 << iなら赤
  int ans = 0;

  for (unsigned short int h_bits = 0; h_bits < (1 << H); h_bits++) {
    for (unsigned short int w_bits = 0; w_bits < (1 << W); w_bits++) {
      int count = 0;
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (!((h_bits & (1 << i)) || (w_bits & (1 << j))) && c[i][j] == '#') count++;
        }
      }
      if (count == K) ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N, K; cin >> N >> K;
	vector<int>A(N);
	rep(i, 0, N)cin >> A[i];
	ll l = 0, r = 1e9 + 7;
	while (r - l > 1) {
		ll mid = (l + r) / 2;
		ll cnt = 0;
		if (mid == 0)break;
		rep(i, 0, N) {
			if (A[i] <= mid)continue;
			cnt += A[i] / mid;
		}
		if (cnt <= K)r = mid;
		else l = mid;
	}
	cout << r << "\n";

	return 0;
}

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

int s[2][105];


int main()
{
    int n,cur=0,ans=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",s[0]+i);
    for(int i=0;i<n;i++)
    {
        scanf("%d",s[1]+i);
        cur += s[1][i];
    }
    for(int i=0;i<n;i++)
    {
        cur += s[0][i];
        if(cur > ans) ans = cur;
        cur -= s[1][i];
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    int ans=inf;
    for(int i=1;i*i<=n;i++){
        if(n%i)continue;
        int j=n/i;
        ans=min(ans,i+j-2);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>

typedef long long int ll;

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

const ll MOD = 1000000007;

using namespace std;

int A[200005];

int main()
{
	int N, x;
	cin >> N >> x;
	if (x == 1 || x == 2 * N - 1)
	{
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;

	A[N - 2] = 1;
	A[N - 1] = x;
	A[N] = 2 * N - 1;

	int index = 0;
	FOR(i, 2 * N, 1)
	{
		if (index == N - 2)
		{
			index = N + 1;
		}
		if (i == 1 || i == x || i == 2 * N - 1)
		{
			continue;
		}
		A[index++] = i;
	}

	REP(i, 2 * N - 1)
	{
		cout << A[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 2304
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(b - a == c - b) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 21972
#include<iostream>
#include<queue>
#include<vector>
#include<set>

using namespace std;
using ll = long long;

const int INF = 1001001001;
const int MOD = 1000000007;



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

	int r = 0;
	int g = 0;
	int b = 0;

	for (int i = 0;i < n;i++){
		if (s[i] == 'R'){
			++r;
		}else if (s[i] == 'G'){
			++g;
		}else{
			++b;
		}
	}

	ll R = r;ll G = g;ll B = b;
	const ll total = R * G * B;
	ll total_wrong = 0;
	for (int i = 0;i < n - 2;i++){
		for (int j = 1;i+2*j < n;j++){
			bool is_false = s[i] == s[i+j] || s[i] == s[i+2*j] || s[i+j] == s[i+2*j];
			if (!is_false){
				total_wrong++;
			}
		}
	}
	const ll ans = total - total_wrong;
	cout << ans << endl;

	return 0;
}


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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;
using Real = double;
using Point = complex< Real >;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
//constexpr ll INF = 1001001001001001001LL;
constexpr double INF = 1e10;
constexpr Real EPS = 1e-10;
const Real PI = acos(-1);
using number = double;


struct edge {
    int to; number cost;
    edge(int a, number b) : to(a), cost(b) {}
};
using wgraph = vector<vector<edge>>;

vector<number> dijkstra(int s, int V, const wgraph &G) {
    minPQ<pair<number, int>> q;
    vector<number> dist(V, INF);
    dist[s] = 0;
    q.push(mp(0, s));

    while (!q.empty()) {
        auto p = q.top(); q.pop();
        int v = p.second;
        if (dist[v] > p.first) continue;
        for (auto e : G[v]) {
            if (dist[e.to] > dist[v] + e.cost) {
                dist[e.to] = dist[v] + e.cost;
                q.push(mp(dist[e.to], e.to));
            }
        }
    }
    return dist;
}

inline double ABS(double x, double y) {
    return sqrt(x * x + y * y);
}


int main() {
    double xs, ys, xt, yt; cin >> xs >> ys >> xt >> yt;
    int n; cin >> n;

    vector<double> x(n + 2), y(n + 2), r(n + 2);
    rep(i, n) cin >> x[i + 1] >> y[i + 1] >> r[i + 1];
    x[0] = xs; y[0] = ys; r[0] = 0;
    x[n + 1] = xt; y[n + 1] = yt; r[n + 1] = 0;

    wgraph G(n + 2);
    for (int i = 0; i < n + 1; i++) {
        for (int j = i + 1; j < n + 2; j++) {
            double d = max((double)0, ABS(x[i] - x[j], y[i] - y[j]) - r[i] - r[j]);
            G[i].pb(edge(j, d));
            G[j].pb(edge(i, d));
        }
    }

    auto dist = dijkstra(0, n + 2, G);

    cout << dist[n+1] << endl;

}

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

int main() {
  int N,M,sum=0;cin>>N>>M;
  vector<int> A(M);
  for (int i=0;i<M;i++) {
    cin>>A.at(i);
    sum += A.at(i);}
  if (N >= sum) cout<<N-sum<<endl;
  else cout<<"-1"<<endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
	int n; cin >> n;
	ll ans = 0;
	for (ll i = 1; i <=n; i++) {
		if (i%3 && i%5) ans += i;
	}
	cout << ans;
}

Measured memory_bytes: 3624
#include<cstdio>

int main(){
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d = a / b;
    r = a % b;
    f = (double)a / (double)b;

    printf("%d %d %f",d,r,f);

return 0;
}



Measured memory_bytes: 2756
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    rep(i,n)v[i]--;
    
    static vector<vector<int>> r(m,vector<int>(n+1,0));
    vector<int> num(20,0);
    rep(i,v.size()){
        num[v[i]]++;
        r[v[i]][i+1] = 1;
    }
    rep(i,m){
        rep(j,n){
            r[i][j+1] += r[i][j];
        }
    }
    
    static int dp[1<<20];
    static int len[1<<20];
    rep(i,1<<20)dp[i] = INF;
    rep(i,1<<20)len[i] = INF;
    dp[0] = 0;
    len[0] = 0;
    
    rep(bit,1<<m){
        rep(piv,m){
            if( (bit&(1<<piv))==0 ){
                int left = len[bit], right = left + num[piv];
                
                int add = 0;
                rep(i,m){
                    if( ((bit|1<<piv) & 1<<i)==0 ){
                        add += r[i][right] - r[i][left];
                    }
                }
                add += num[piv] - r[piv][len[bit]+num[piv]];
                
                dp[bit|(1<<piv)] = min(dp[bit|(1<<piv)], dp[bit] + add);
                len[bit|(1<<piv)] = len[bit] + num[piv];
            }
        }
    }
    cout<<dp[(1<<m)-1]<<endl;
}



Measured memory_bytes: 19312
import java.util.*;

public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main(){
		new AOJ1179().doIt();
	}
	
	class AOJ1179{
		
		int calc(int y,int m,int d){
			int result = 0;
			for(int i=1;i<y;i++){
				for(int s=1;s<=10;s++){
					if(i%3==0)result+=20;
					else if(s%2==0)result+=19;
					else result += 20;
				}
			}
			for(int i=1;i<m;i++){
				if(y%3==0)result += 20;
				else if(i%2==0)result += 19;
				else result += 20;
			}
			result += d;
			return result;
		}
		
		void doIt(){
			int n = in.nextInt();
			int a = calc(1000, 1, 1);
//			System.out.println(a);
			for(int i=0;i<n;i++){
				int b = calc(in.nextInt(), in.nextInt(), in.nextInt());
//				System.out.println(b);
				System.out.println(a-b);
			}
		}
	}
	
}

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

int main() {
  int A , B , C , K;
  cin >> A >> B >> C >> K;
  
  if (K <= A) {
    cout << K << endl;
  }
  else if (K - A <= B) {
    cout << A << endl;
  }
  else {
    cout << 2 * A + B - K << endl;
  }
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <stdlib.h>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		string s[n][2];
		for(int i=0;i<n;i++){
			cin>>s[i][0]>>s[i][1];
		}
		int t;
		cin>>t;
		for(int i=0;i<t;i++){
			string a;
			cin>>a;
			for(int j=0;j<n;j++){
				if(s[j][0]==a){
					cout<<s[j][1];
					goto end;
				}
			}
			cout<<a;
			end:;
		}
		cout<<endl;
	}
    return 0;
}

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

int main()
{
  int c[4] = {10, 50, 100, 500};
  vector<int> num; //所持している硬貨の枚数
  int pay; //支払金額
  bool flag = true;

  while(1) {
    cin >> pay;
    if(pay == 0)
      break;

    for(int i = 0; i < 4; i++) {
      int C;
      cin >> C;
      num.push_back(C);
    }

    int sum = 0;
    for(int i = 0; i < 4; i++) {
      sum += c[i] * num[i];
    }
    pay = sum - pay;

    int k[4] = {}; //余った硬貨の枚数

    for(int i = 3; i >= 0; i--){
      k[i] = pay / c[i];
      pay = pay - (k[i] * c[i]);
    }

    if(flag) flag = false;
    else {
      cout << endl;
    }
    for (int i = 0; i < 4; i++) {
      if(num[i] > k[i]) {
        cout << c[i] << ' ' << num[i] - k[i] << endl;
        }
    }

    num.clear();
  }
}


Measured memory_bytes: 3140
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;

//#define int ll


const int N = 1e3 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

string a, b, c;
int A, B;
main() {
    file("threesum");
    ios;
    cin >> a >> b >> A >> B >> c;
    map <string, int> cnt;
    cnt[a] = A;
    cnt[b] = B;
    --cnt[c];
    cout << cnt[a] << ' ' << cnt[b];
    cerr << "\nTime elapsed: " << (clock() + 0.0) / CLOCKS_PER_SEC;
    return 0;
}
/**

*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1000000007, INF = 1e9;

int main()
{
    ll n, r, ans = 0;
    cin >> n;
    pair<ll, ll> p[n];
    vector<ll> x(n), l(n);
    rep(i, n){
        cin >> x[i] >> l[i];
        p[i] = pair<ll, ll>(x[i]+l[i], x[i]-l[i]);
    }
    sort(p, p+n);
    r = -1e10;
    for(ll i = 0; i < n; i++){
        if(r <= p[i].second){
            ans++;
            r = p[i].first;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 入力
		char[] s = (sc.next()).toCharArray();
		int[] result = new int[s.length];
		float r = 1;
		int l_i = 0;
		float l = 0;
		for(int i = 0; i < s.length; i++){
		    if(i > 0 && s[i - 1] == 'R' && s[i] == 'R'){
		        result[i - 1] = 0;
		        r = r + 1;
		    }else if(i > 0 && s[i - 1] == 'R' && s[i] == 'L'){
		        result[i - 1] = (int)ceil(r/2);
		        result[i] = 1 + (int)floor(r/2);
		        r = 0;
		        l_i = i;
		    }else if(i > 0 && s[i - 1] == 'L' && s[i] == 'R'){
		        result[l_i - 1] = result[l_i - 1] + (int)ceil(l/2);
		        result[l_i] = result[l_i] + (int)floor(l/2);
		        r = 1;
		        l = 0;
		    }else if(i > 0 && s[i - 1] == 'L' && s[i] == 'L'){
		        result[i] = 0;
		        l = l + 1;
		    }
		}
		result[l_i - 1] = result[l_i - 1] + (int)ceil(l/2);
		result[l_i] = result[l_i] + (int)floor(l/2);
		
		// 計算

		// 出力
		for(int i = 0; i < result.length; i++){
            System.out.print(result[i] + " ");
		}
		
	}
}


Measured memory_bytes: 41844
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
int p[610];
short dp[2][610][180010];
short rev[2][610][180010];
int dist[180100];
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	for(int i=0;i<a;i++)scanf("%d",p+i);
	for(int i=0;i<2;i++)for(int j=0;j<=a;j++)for(int k=0;k<180010;k++)
		dp[i][j][k]=999;
	int tmp=0;
	for(int i=0;i<b;i++)tmp+=p[i];
	dp[0][b][tmp]=0;
	for(int i=b;i<=a;i++){
		for(int j=1;j>=0;j--){
			for(int k=180000;k>=0;k--){
				if(dp[j][i][k]>900)continue;
				if(a==i&&j==0)continue;
				if(j==0){
					if(dp[0][i+1][k]>dp[j][i][k]){
						dp[0][i+1][k]=dp[j][i][k];
						rev[0][i+1][k]=-1;
					}
					if(dp[1][i+1][k+p[i]]>dp[j][i][k]){
						dp[1][i+1][k+p[i]]=dp[j][i][k];
						rev[1][i+1][k+p[i]]=-2;
					}
				}else{
					for(int l=dp[1][i][k];l<=min(b-1,(int)dp[1][i-1][k]);l++){
						if(dp[0][i][k-p[l]]>l+1){
						//	printf("%d %d %d: %d\n",0,i,k-p[l],l+1);
							dp[0][i][k-p[l]]=l+1;
							rev[0][i][k-p[l]]=l;
						}
					}
				}
			}
		}
	}
	for(int i=0;i<180010;i++)dist[i]=999999999;
	for(int i=0;i<=180000;i++)if(dp[0][a][i]<=b)dist[i]=0;
	for(int i=1;i<=180000;i++)dist[i]=min(dist[i],dist[i-1]+1);
	for(int i=179999;i>=0;i--)dist[i]=min(dist[i],dist[i+1]+1);
	int ret=c;
	int ans=0;
	for(int i=c;i<=d;i++){
		if(dist[i]>ans){
			ans=dist[i];ret=i;
		}
	}
	printf("%d\n",ret);
	vector<int>ind;
	
	int A=0;
	int B=a;
	int C=ret;
	if(ret-ans>=0&&dp[0][a][ret-ans]<=b)C=ret-ans;
	else C=ret+ans;
	
	for(int i=dp[0][a][C];i<b;i++)ind.push_back(i+1);
	while(A!=0||B!=b||C!=tmp){
	
	//	printf("%d %d %d\n",A,B,C);
	//	if(C>180000)break;
		if(rev[A][B][C]==-1)B--;
		else if(rev[A][B][C]==-2){
			ind.push_back(B);
			B--;
			A=0;
			C-=p[B];
		}else{
			int to=dp[A][B][C];
			A=1;
			C+=p[to-1];
			for(int i=dp[A][B][C];i<to-1;i++)ind.push_back(i+1);
		}
	}
	std::sort(ind.begin(),ind.end());
	for(int i=0;i<ind.size();i++){
		if(i)printf(" ");
		printf("%d",ind[i]);
	}
	printf("\n");
}

Measured memory_bytes: 831204
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a, b;
    cin >> a >> b;

    for (int i = 0; i < 10000; i++) {
        int aa = i * 0.08;
        int bb = i * 0.1;
        if (aa == a && bb == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;  
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long


int main()
{
	int n;
	while (cin >> n)
	{
		int cnt = 0;
		REP(i, 10)REP(j, 10)REP(k, 10)REP(l, 10)
		{
			if (i + j + k + l == n)
			{
				cnt++;
			//	cout << i << " " << j << " " << k << " " << l << endl;
			}
		}
		cout << cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int a, b;
	cin >> a >> b;
	cout << a + (b / 2) << endl;
	getchar();getchar();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
typedef long long ll;
#define MOD 1000000007

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 main(){
  ll n,m;
  cin >> n >> m;
  ll x[10000],y[10000],z[10000];
  FOR(i,n){
    cin >> x[i] >> y[i] >> z[i];
  }

  ll sum=0,ans=0,a[100],v[10000];
  FOR(i,8){
    sum=0;
    FOR(j,3){
      if(i & 1 << j){a[j]=1;}else{a[j]=-1;}
    }
    FOR(j,n){
      v[j]=x[j]*a[0]+y[j]*a[1]+z[j]*a[2];
    }
    sort(v,v+n);
    reverse(v,v+n);
    FOR(j,m){

        sum+=v[j];
    }
    chmax(ans,sum);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
 
const ll MOD = 1000000007;
 
map< pair<ll,ll> , int > m;
ll p2[202020];
 
ll GCD(ll a, ll b) {
  if ( a%b==0 ) return b;
  return GCD(b, a%b);
}
 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
 
int main(){
  p2[0] = 1;
  REP(i,202020) p2[i+1] = (p2[i] * 2) % MOD;
  
  int N;
  cin >> N;
  ll ans = 1;
  int z = 0;
  REP(i,N) {
    ll a,b;
    cin >> a >> b;
    if (a==0 && b==0) {
      z++;
    } else if (a==0) {
      m[{0,-1}]++;
    } else if (b==0) {
      m[{1,0}]++;
    } else {
      ll gcd = GCD(abs(a),abs(b));
      a /= gcd;
      b /= gcd;
      if (a<0) {
        a = -a;
        b = -b;
      }
      m[{a,b}]++;
    }
  }
  for ( auto m0 : m ) {
//    cout << m0.first.first << " " << m0.first.second << " " << m0.second << " " << ans << endl;
    ll a0 = m0.first.first;
    ll b0 = m0.first.second;
    ll a1,b1, t = 1;
    if ( m[{a0,b0}] != 0 ) {
      if ( b0<0 ) {
        a1 = -b0;
        b1 = a0;
      } else {
        a1 = b0;
        b1 = -a0;
      }
//      t = (modpow(2, m[{a0,b0}], MOD) + modpow(2, m[{a1,b1}], MOD) - 1) % MOD;
      t = (p2[m[{a0,b0}] ] + p2[m[{a1,b1}]]- 1) % MOD;
      m[{a1,b1}] = 0;
    }
    m[{a0,b0}] = 0;
    ans = (ans * t)% MOD;
  }
  cout << ((ans+z+MOD-1)%MOD) << endl;
}

Measured memory_bytes: 30080
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    REP(i, 0, n) cin >> a[i];
    REP(i, 0, n) cin >> b[i];
    REP(i, 0, n) cin >> c[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    long long ans = 0;
    REP(j, 0, n) {
        long long ca = 0, cc = 0;
        ca = lower_bound(a.begin(), a.end(), b[j]) - a.begin();
        cc = upper_bound(c.begin(), c.end(), b[j]) - c.begin();
        ans += ca * (n - cc);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#define INF INT_MAX
using namespace std;

int N;

int main(){
	cin >> N;
	if (N < 1000){
		cout << "ABC" << endl;
	}
	else{
		cout << "ABD" << endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL x[100001];
LL y[100001];
typedef pair<LL,LL> P;
vector<P>vx;
vector<P>vy;
vector<P>edge;
vector<P>que;

int par1[200001];
int rank1[200001];
//n要素で初期化
void init(int n){
   for(int i=0;i<n;i++){
       par1[i]=i;
       rank1[i]=0;
   }
}
//木の根を求める
int find(int x){
    if(par1[x] ==x){
         return x;
    }else{
         return par1[x]=find(par1[x]);
    }
}
//xとyの属する集合を併合
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y) return;

    if(rank1[x]<rank1[y]){
         par1[x]=y;
    }else{
         par1[y]=x;
         rank1[x]++;
    }
}
//xとyが同じ集合に属するか否か
bool same(int x,int y){
     return find(x)==find(y);
}

int main(){
    cin>>N;
    REP(i,N){
        LL a,b;
        cin>>a>>b;
        vx.push_back(P(a,i));
        vy.push_back(P(b,i));
    }
    sort(vx.begin(),vx.end());
    sort(vy.begin(),vy.end());
    REP(i,N-1){
        {
           LL a=vx[i].second;
           LL b=vx[i+1].second;
           edge.push_back(P(a,b));
           que.push_back(P(vx[i+1].first-vx[i].first,2*i));
        }
        {
           LL a=vy[i].second;
           LL b=vy[i+1].second;
           edge.push_back(P(a,b));
           que.push_back(P(vy[i+1].first-vy[i].first,2*i+1));
        }
    }
    sort(que.begin(),que.end());
    init(N+10);
    LL ans=0;
    REP(i,que.size()){
        //cout<<"edge"<<
        int num=que[i].second;
        if(same(edge[num].first,edge[num].second)==false){
           unite(edge[num].first,edge[num].second);
           ans+=que[i].first;
        }
    }
    cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 15456
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;typedef vector<ll> vll;
ll mod = 1000000007, INF = 10000000000000000;
int main(){
  ll n;
  cin >> n;
  vll a(n);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (ll i = -100; i <= 100; i++) {
    ll f = 0;
    for (ll j = 0; j < n; j++) {
      f += (a[j]-i)*(a[j]-i);
    }
    if (INF > f) INF = f;
  }
  
  cout << INF << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int A[4];
	int B[4];
	int scoa = 0;
	int scob = 0;
	int i;
	
	for(i = 0;i < 4;i++){
		scanf("%d",&A[i]);
		scoa += A[i];
	}
	
	for(i = 0;i < 4;i++){
		scanf("%d",&B[i]);
		scob += B[i];
	}
	
	if(scob > scoa){
		printf("%d\n",scob);
	}
	else if(scoa > scob){
		printf("%d\n",scoa);
	}
	else {
		printf("%d\n",scoa);
	}
	
	return(0);
}

Measured memory_bytes: 592
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto i:v)output(i);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define sum(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
int main(){
    input(a,n);
    lint ans=LINF;
    repi(i,-100,101){
        lint x=0;
        rep(j,n){
            x+=(a[j]-i)*(a[j]-i);
        }
        ans=min(ans,x);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
        int H,W;
        string s;
        cin >> H >> W;
        for(int i=0;i<H;i++){
                cin >> s;
                cout << s <<endl;
                cout << s << endl;
        }
        return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        long n = Long.parseLong(sc.next());
        
        //String s = sc.next();
        
        int a = (int)Math.sqrt(n);
        long b=0;
        int M=0;
        while(M==0){
            if(n%a==0){
                b=n/a;
                M=get_digit(b);
            }
            a--;
        }
        System.out.println(M);
    }
    private static int get_digit(long num){
        if(num<10){
            return 1;
        }else if(num<100){
            return 2;
        }else if(num<1000){
            return 3;
        }else if(num<10000){
            return 4;
        }else if(num<100000){
            return 5;
        }else if(num<1000000){
            return 6;
        }else if(num<10000000){
            return 7;
        }else if(num<100000000){
            return 8;
        }else if(num<1000000000){
            return 9;
        }else{
            return 10;
        }
    }
}

Measured memory_bytes: 23764
# 1 軒のホテルがあります。 このホテルの宿泊費は、次のようになっています。
# 最初の K 泊までは、 1 泊あたり X 円 K + 1 泊目以降は、 1 泊あたり Y 円 高橋君は、このホテルに N 泊連続で宿泊することにしました。
# 高橋君の宿泊費は合計で何円になるか求めてください。

N = int(input())
K = int(input())
X = int(input())
Y = int(input())

if N - K >= 1:
    print((X * K) + (Y * (N - K)))

else:
    print(X * N)

Measured memory_bytes: 9096
x,n = map(int,input().split())
if n == 0:
    print(x)
    exit()
P = [*map(int,input().split())]

ans = 100000000 # inf
for d in range(100+10):
    now_diff = abs(ans - x)
    min_x, max_x = x - d, x + d
    if min_x not in P:
        if now_diff > abs(min_x - x): ans = x-d
    elif max_x not in P:
        if now_diff > abs(max_x - x): ans = x+d
print(ans)


Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MAX 2000005
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define t1(x)             cerr<<#x<<"="<<x<<endl
#define t2(x, y)          cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl
#define t3(x, y, z)       cerr<<#x<<"=" <<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl
#define t4(a,b,c,d)       cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<endl
#define t5(a,b,c,d,e)     cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<endl
#define t6(a,b,c,d,e,f)   cerr<<#a<<"="<<a<<" "<<#b<<"="<<b<<" "<<#c<<"="<<c<<" "<<#d<<"="<<d<<" "<<#e<<"="<<e<<" "<<#f<<"="<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define tr(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
 
 
ll n, m, i, j, k, t,r, a, b, c, d, l, w, tmp, g, ans, sum, cnt, neg1, flag, mn, mx, neg2;
ll arr[MAX], fact[MAX], ifact[MAX];
vector<ll> v[MAX];
vector<ll> centroid;

ll power(ll x, ll y){
    ll res = 1;
    x = x % MOD; 
    if (x == 0) return 0; 
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % MOD;  
        y = y>>1; // y = y/2  
        x = (x*x) % MOD;  
    }  
    return res;  
}
ll nCr(ll n, ll r){
    if(r > n)return 0;
    return ((fact[n] * ifact[r])%MOD * ifact[n-r])%MOD;
}
int main()
{
    
    ios_base::sync_with_stdio(false);cin.tie(NULL);

        cin>>n;
        fact[0]=1;
        for(i=1;i<=MAX;i++){
            fact[i] = (fact[i-1]*i)%MOD;
        }
        ifact[MAX] = power(fact[MAX], MOD-2);
        for(i=MAX-1;i>=0;i--){
            ifact[i] = ((i+1)*ifact[i+1])%MOD;
        }
        for(i=1;i<=700;i++){
            if(3*i > n)break;
            m = n-3*i;
            ans += nCr(m+i-1, m);
            ans%=MOD;
        }
        cout<<ans;

    return 0;   
}

Measured memory_bytes: 81716
#pragma GCC optimize(3)
#pragma GCC optimize("inline")
#pragma once
#include<bits/stdc++.h>
#define q register
typedef long long ll;
using namespace std;
string s;
ll tag1,tag2,tot;
bool ans;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>s;
    for(q ll i=0;i<s.length();i++){
        if((s[i]=='C')&&(!ans)){
            //tot=tag1=i;
			ans=true;  
        }
        if(s[i]=='F'){
            //tag2=i;   
            if(ans){
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    sort(h.begin(), h.end());

    int64_t ans = 0;
    for (int i = 0; i < N - K; ++i) {
        ans += h[i];
    }

    cout << ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
int n,m,nun;
map<int,int> ax[1000005];
map<int,int> bx[1000005];
list<int> edg[400005];
list<int> poi[100005];
int res[100005];
set<pair<int,int> > q;

void ins(int x,int y,int j){
    int a,b;
    if(ax[j][x]==0){
        ax[j][x]=++nun;
        a = nun;
    }
    else a=ax[j][x];
    edg[a].push_back(y);
    poi[x].push_back(j);
}

void play(int x,int val,int j){
    if(res[x]==-1){
        res[x]=val;
        q.insert(make_pair(val,x));
    }
    if(ax[j][x]==0)return;
    list<int>::iterator p;
    int a = ax[j][x];
    ax[j][x]=0;
    for(p=edg[a].begin();p!=edg[a].end();p++){
        play(*p,val,j);
    }
}

int main()
{
    scanf("%d%d",&n,&m);
    int i,j,b,c;
    pair<int,int> a;
    for(i=1;i<=m;i++){
        scanf("%d%d%d",&c,&b,&j);
        ins(c,b,j);
        ins(b,c,j);
    }
    memset(res,-1,sizeof(res));
    q.insert(make_pair(0,1));
    res[1]=0;
    while(!q.empty()){
        a = *(q.begin());
        q.erase(q.begin());
        list<int>::iterator p,p2;
        for(p=poi[a.second].begin();p!=poi[a.second].end();p++){
            b = ax[*p][a.second];
            if(b==0)continue;
            for(p2=edg[b].begin();p2!=edg[b].end();p2++){
                play(*p2,a.first+1,*p);
            }
        }
    }
    printf("%d",res[n]);
}


Measured memory_bytes: 148224
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
const long double Pi=acos(-1);
int main(){
  ll N,ans=0;
  cin>>N;
  vector<ll> vec(N);
  for(ll i=0;i<N;i++){
    cin>>vec.at(i);
  }
  for(ll i=0;i<N-1;i++){
    for(ll j=i+1;j<N;j++){
      ans+=vec.at(i)*vec.at(j);
    }
  }
  cout<<ans<<endl;
} 

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

const string YES = "YES";
const string NO = "NO";

void solve(long long X){
if(X==3 || X==5 || X==7){
	cout<<YES<<endl;
}else{
cout<<NO<<endl;
}
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<endl
#define AA(i) cout<<i<<endl
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
  int N; cin >> N;
  vector<ll> A(N);
  vector<ll> B(N);
  int i;
  rep(i,N){
    cin>> A[i];
    cin>> B[i];
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());

  ll ans = 0;

  if(N%2!=0){
    int K = (N-1)/2;
    ans = B[K] - A[K] + 1;
  }
  else{
    int K = N / 2 - 1;
    ans = B[K] + B[K+1] - A[K] - A[K+1] + 1;
    
  }
  AA(ans);
  return 0;
}

Measured memory_bytes: 6424