akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>

#define PREC 1e-12

#define max(a, b) ((a)>(b)?(a):(b))
#define min(a, b) ((a)<(b)?(a):(b))

int main() {
    int x, y, x0, y0, x1, y1, x2, y2, x3, y3;
    int q;
    double s, t, num1, num2, denom;
    int judge;

    scanf("%d", &q);
    
    while (q--) {
        scanf("%d %d %d %d %d %d %d %d",
              &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3);
        num1 = (y3-y2)*(x2-x0)-(x3-x2)*(y2-y0);
        num2 = (y1-y0)*(x2-x0)-(x1-x0)*(y2-y0);
        denom = (x1-x0)*(y3-y2) - (y1-y0)*(x3-x2);
        if (fabs(denom) < PREC) {
            if (fabs(num1) < PREC && fabs(num2) < PREC ) {
                if ((max(x0, x1) >= min(x2, x3) && min(x0, x1) <= max(x2, x3)) &&
                    (max(y0, y1) >= min(y2, y3) && min(y0, y1) <= max(y2, y3)))
                    judge = 1;
                else
                    judge = 0;
            }
            else
                judge = 0;
        }
        else {
            s = num1 / denom;
            t = num2 / denom;
            if (s < 0 || s > 1 || t < 0 || t > 1) {
                judge = 0;
            }
            else {
                judge = 1;
            }
        }
        printf("%d\n", judge);
    }

    return 0;
}

Measured memory_bytes: 600
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const ll MAX_B = 1e6, INF = 1e18;
ll n, s;

ll base_exchange(ll n, ll b) {
  if (n == 0) return 0;
  return base_exchange(n/b, b) + (n % b);
}

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


  for (ll b = 2; b <= min(n+1, MAX_B); ++b) {
    if (s == base_exchange(n, b)) {
      cout << b << endl;
      return 0;
    }
  }

  ll ans = INF;
  if (n+1 > MAX_B) {
    for (ll p = 1; p < MAX_B; ++p) {
      ll q = s-p;
      if (q >= 0 && (n-q)%p == 0 && (n-q)/p > q) {
        ans = min(ans, (n-q)/p);
      }
    }
  }

  if (ans < INF) {
    cout << ans << endl;
    return 0;
  }

  if (n == s) {
    cout << n+1 << endl;
    return 0;
  }
  
  cout << -1 << endl;

  return 0;
}




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

using namespace std;


int main()
{
  	int n,ans=0;
	cin>>n;
	vector<int> v(n);
	for(int &i:v)
		cin>>i;
	sort(v.begin(),v.end());

	for(int i=0;i<n;i++)
	{
		int f=1;
		for(int j=1;j*j<=v[i];j++)
		{
			if(v[i]%j==0)
			{
			if(binary_search(v.begin(),v.end(),j))
			{
				if(j==v[i])
				{
					if(upper_bound(v.begin(),v.end(),j)-lower_bound(v.begin(),v.end(),j)>1)
					{
						f=0;
						break;
					}	
				}
				else
				{
					f=0;
					break;
				}
			}
			if(binary_search(v.begin(),v.end(),v[i]/j))
			{
				if(j==1)
				{
					if(upper_bound(v.begin(),v.end(),v[i])-lower_bound(v.begin(),v.end(),v[i])>1)
					{
						f=0;
						break;
					}	
				}
				else
				{
					f=0;
					break;
				}
			}
		}
		}
		if(f)
			ans++;
	}
	cout<<ans<<"\n";
}

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

typedef long long  LL;
struct node{int x,y;}a[200010];
int n;
LL ans;
multiset <int> S1,S2;

bool cmp(node x,node y){return x.x<y.x;}

void work()
{
	scanf("%d",&n);
	if (n==1)  {puts("0");  return;}
	for (int i=1; i<=n; i++)
		{
			scanf("%d %d",&a[i].x,&a[i].y);
			if (a[i].x>a[i].y)  swap(a[i].x,a[i].y);
			S1.insert(a[i].x),S2.insert(a[i].y);			
		}
	ans=1LL*(*S1.rbegin()-*S1.begin())*(*S2.rbegin()-*S2.begin());
	sort(a+1,a+n+1,cmp);
	for (int i=1; i<=n; i++)
		{
			S1.erase(S1.find(a[i].x)),S1.insert(a[i].y);
			S2.erase(S2.find(a[i].y)),S2.insert(a[i].x);
			ans=min(ans,1LL*(*S1.rbegin()-*S1.begin())*(*S2.rbegin()-*S2.begin()));
		}
	printf("%lld",ans);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 20608
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        char[] cArray = s.toCharArray();
        Arrays.sort(cArray);

        if(cArray[0] == cArray[1] && cArray[2] == cArray[3] && cArray[1] != cArray[2]){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n; cin >> n;
	ll backa=0, topb=0, ba=0;
	ll ans=0;

	rep(i, n){
		string s; cin >> s;
		if (s.front()=='B' && s.back()!='A') topb++;
		if (s.back()=='A' && s.front()!='B') backa++;
		if (s.front()=='B' && s.back()=='A') ba++;
		char c1 = s.front(), c2;
		rep(j, s.size()-1){
			c2 = s[j+1];
			if (c1=='A' && c2=='B') ans++;
			c1 = c2;
		}
	}

	if (ba>0){
		ans += ba-1;
		if (topb>0) topb--, ans++;
		if (backa>0) backa--, ans++;
		ans += min(backa, topb);
	}else{
		ans += min(backa, topb);
	}

	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	bool ok = true;
	ll a, b, c;
	cin >> a >> b >> c;
	ll t = c - a - b;
	if (t < 0)ok = false;
	if (4 * a * b >= t * t)ok = false;
	cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
//Om Sree Sai Ram
#include "bits/stdc++.h"
using namespace std;

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

vector<int> dp;
vector<int> vis;

int main() 
{
int mod = 1e9+7;

int m,n;
cin>>m>>n;
vector<string> ar(m);
for(int i=0;i<m;i++)
{
  cin>>ar[i];
}
//cout<<" input "<<endl;
vector<vector<int>>dp(m,vector<int>(n));
dp[0][0] = 1;
for(int i=0;i<m;i++)
{
  for(int j=0;j<n;j++)
  {
    //cout<<" i = "<<i<<" j = "<<j<<endl;
    if(ar[i][j]!='.')
    {
      continue;
    }
      if(i+1<m && ar[i+1][j]=='.')
      {
       // cout<<" one "<<endl;
     dp[i+1][j] += (dp[i][j]);
     dp[i+1][j] %= mod;
      }
     if(j+1<n && ar[i][j+1]=='.')
     {
      //cout<<" two "<<endl;
     dp[i][j+1] += (dp[i][j]);
     dp[i][j+1] %=mod;
     }
  }
}
cout<<dp[m-1][n-1]<<endl;

}


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

using Weight = int;
using Vertex = int;
struct Edge {Vertex from, to;};
using Graph = std::vector<std::vector<Edge>>;

// ???????????£?????????????§£ O(|V| + |E|)
std::pair<Graph, std::vector<Weight>> bridge(const Graph& G) {
  std::stack<Vertex> roots, S;
  std::vector<bool> inS(G.size());
  std::vector<int> num(G.size()), group(G.size());
  std::vector<Edge> bridge;
  std::vector<std::vector<Vertex>> bcc;
  int timer = 0;
  // Tarjan
  std::function<void(const Edge&)> dfs = [&](const Edge& cur){
    num[cur.to] = ++timer;
    S.push(cur.to); inS[cur.to] = true;
    roots.push(cur.to);
    for(const auto& nex: G[cur.to]) {
      if(!num[nex.to]) dfs(nex);
      else if(nex.to != cur.from && inS[nex.to]) while(num[roots.top()] > num[nex.to]) roots.pop();
    }
    if(roots.top() == cur.to) {
      bridge.push_back(cur);
      bcc.push_back(std::vector<Vertex>());
      while(true) {
        auto v = S.top(); S.pop(); inS[v] = false;
        bcc.back().push_back(v);
        group[v] = bcc.size() - 1;
        if(v == cur.to) break;
      }
      roots.pop();
    }
  };
  for(auto v = 0; v < G.size(); ++v) if(!num[v]) {
    dfs({v, v});
    bridge.pop_back();
  }
  // Forrest
  Graph F(bcc.size());
  for(auto e: bridge) {
    auto s = group[e.from];
    auto t = group[e.to];
    F[s].push_back({s, t});
    F[t].push_back({t, s});
  }
  std::vector<Weight> W;
  for(auto i: bcc) W.emplace_back(i.size());
  return std::make_pair(F, W);
}

#include<bits/stdc++.h>
using namespace std;

Weight solve(const Graph& G) {
  Graph F; vector<Weight> W;
  tie(F, W) = bridge(G);

  vector<bool> used(F.size());
  vector<vector<Weight>> dp(2, vector<Weight>(F.size(), -1));
  function<Weight(Vertex, Vertex)> ignore, opt;

  ignore = [&](Vertex cur, Vertex pre) {
    if(~dp[0][cur]) return dp[0][cur];
    dp[0][cur] = 0;
    used[cur] = true;
    for(auto e: F[cur]) if(e.to != pre) dp[0][cur] += max(ignore(e.to, cur), opt(e.to, cur));
    return dp[0][cur];
  };

  opt = [&](Vertex cur, Vertex pre) {
    if(~dp[1][cur]) return dp[1][cur];
    dp[1][cur] = W[cur];
    used[cur] = true;
    for(auto e: F[cur]) if(e.to != pre) dp[1][cur] += ignore(e.to, cur);
    return dp[1][cur];
  };

  auto res = 0;
  for(auto v = 0; v < F.size(); ++v) if(!used[v]) {
    res += max(ignore(v, v), opt(v, v));
  }
  return res;
}

int main() {
  int N, M;
  cin >> N >> M;
  Graph G(N);
  for(auto i = 0; i < M; ++i) {
    Vertex s, t;
    cin >> s >> t;
    G[s].push_back({s, t});
    G[t].push_back({t, s});
  }

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

Measured memory_bytes: 28412
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()


int main() {
	ll k;
	cin >> k;
	cout << (k / 2) * ((k + 1) / 2) << endl;
}


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

using namespace std;

void success () {
  cout << "Yes" << endl;
  exit(0);
}

void failure () {
  cout << "No" << endl;
  exit(0);
}

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

  int n;
  cin >> n;

  vector<int> arr (n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }

  sort(arr.begin(), arr.end());

  vector<pair<int, int>> blocks;
  for (int i = 0; i < n; i++) {
    if (i == 0 || arr[i] != arr[i - 1]) {
      blocks.push_back(make_pair(arr[i], 0));
    }
    blocks.back().second++;
  }

  if (n % 3 == 0) {
    if ((int) blocks.size() > 3) {
      failure();
    } else if ((int) blocks.size() == 3) {
      for (int k = 0; k < 3; k++) {
	if (blocks[k].second != n / 3) {
	  failure();
	}
      }

      if ((blocks[0].first ^ blocks[1].first) != blocks[2].first) {
	failure();
      }
      success();
    } else if ((int) blocks.size() == 2) {
      if (blocks[0].first != 0) {
	failure();
      }

      if (blocks[0].second != n / 3) {
	failure();
      }
      success();
    } else if ((int) blocks.size() == 1) {
      if (blocks[0].first != 0) {
	failure();
      }
      success();
    }
  } else {
    if (blocks[0].first == 0 && (int) blocks.size() == 1) {
      success();
    } else {
      failure();
    }
  }
}


Measured memory_bytes: 1784
#include<iostream>
#include<map>
#include<vector>
using namespace std;
typedef long long int ll;
vector<pair<ll,ll>>datados;
vector<vector<ll>>alm;
ll m(ll w,ll i){
    if(w<0){
        return -1e9;
    }
    if(w==0 || i<0){
        return 0;
    }
    if(alm[w][i]!=-1){
        return alm[w][i];
    }

    alm[w][i]= max(m(w-datados[i].first,i-1)+datados[i].second,m(w,i-1));
    return alm[w][i];
}
int main(){
    ll a,b,c,d;
    cin>>a>>b;
    vector<int>ava(a,1);
    vector<ll>aux(a,-1);
    alm=vector<vector<ll>>(b+1,aux);
    for(int i=0;i<a;i++){
        cin>>c>>d;
        datados.push_back({c,d});
    }
    cout<<m(b,a-1)<<endl;
return 0;
}


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

int a[2][100], b[2][100], d[2][100];

int main() {
	int n;
	while (scanf("%d", &n), n) {
		rep(j, 2)rep(i, n) {
			scanf("%d", &a[j][i]);
			b[j][i] = i;
		}
		rep(j, 2) {
			int back = -1;
			rep(i, n) {
				if (a[j][i] != 1) {
					if (back != -1) {
						for (int k = back; k < i; k++)b[j][k] = i - 1; back = -1;
					}
				}
				if (a[j][i] == 1) {
					if (back == -1)back = i;
				}
			}
			if (back != -1) {
				for (int k = back; k < n; k++)b[j][k] = n - 1;
			}
		}
		rep(j, 2) {
			int back = -1;
			for (int i = n - 1; i >= 0; i--) {
				if (a[j][i] != 2) {
					if (back != -1) {
						for (int k = back; k > i; k--)b[j][k] = i; back = -1;
					}
				}
				if (a[j][i] == 2) {
					if (back == -1)back = i;
				}
			}
		}
		queue<P>que;
		memset(d, 0x3f, sizeof(d));
		d[0][b[0][0]] = 0; que.push(P(0, b[0][0]));
		d[1][b[1][0]] = 0; que.push(P(1, b[1][0]));
		while (!que.empty()) {
			P p = que.front(); que.pop();
			for (int i = 0; i <= 2; i++) {
				if (p.second + i >= n)break;
				int k = !p.first;
				int t = b[k][p.second + i];
				if (d[k][t] == INF) {
					d[k][t] = d[p.first][p.second] + 1;
					que.push(P(k, t));
				}
			}
		}
		int ans = min(d[0][n - 1], d[1][n - 1]);
		if (ans == INF)puts("NA");
		else printf("%d\n", ans);
	}
}

Measured memory_bytes: 3136
#ABC129B
N = int(input())
W = list(map(int,input().split()))
W_sum = sum(W)
ans = W_sum
s1 = 0
for i in range(0,N-1):
    s1 += W[i]
    if abs(s1- (W_sum - s1)) < ans:
        ans = abs(s1- (W_sum - s1))
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define int long long
#define mod 1000000007
#define fi first
#define se second
#define be begin()
#define en end()
#define re reverse
#define Set setprecision
#define NO cout<<"NO\n"
#define YES cout<<"YES\n"
#define No cout<<"No\n"
#define Yes cout<<"Yes\n" 
const int INFi=2147483647;
const long long INFl=9223372036854775807LL;
template<typename T> T abs(T a,T b){
    return max(a,b)-min(a,b);
}
template<typename T> T lcm(T a,T b){//最小公倍数
  return (a*b)/gcd(a,b);
}
int  gcd(int a,int b){//最大公約数
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for(int i=3;i<=sqrtNum;i+=2){
	if(num%i==0){
	    return false;
	}
    }
  return true;
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c=0;
    //string a,b;
    cin>>a>>b;
    while(true){
	if(a==0) break;
	a/=b;
	c++;
    }
    cout<<c<<"\n";
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var s = ReadText();
            var l = new List<char>();
            for (int i = 0; i < s.Length; i++)
            {
                if (i % 2 == 0)
                {
                    l.Add(s[i]);
                }
            }
            return new string(l.ToArray());
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 26988
#include <bits/stdc++.h>
#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(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const double eps = 1e-9;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int main () {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  vi water, sugar;
  REP(i,f+1) {
    REP(j,f+1) {
      int x = 100*a*i + 100*b*j;
      int y = c*i + d*j;
      if (x <= f) water.push_back(x);
      if (y <= f) sugar.push_back(y);
    }
  }

  SORT(water);
  SORT(sugar);

  water.erase(unique(ALL(water)),water.end());
  sugar.erase(unique(ALL(sugar)),sugar.end());

  //DEBUG(cnct_e);
  double cnct_max = -1.0;
  int xm, ym;
  for (auto x : water) {
    for (auto y : sugar) {
      //DEBUG(x);
      //DEBUG(y);
      if (x == 0 && y == 0) continue;
      if (y*100 > x*e || x+y > f) {
        continue;
      }
      else {
        double cnct = 100*(double)y/(x+y);
        //DEBUG(cnct);
        if (cnct_max + eps < cnct) {
          cnct_max = cnct;
          xm = x;
          ym = y;
        }
      }
    }
  }

  cout << xm+ym << " " << ym << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x) cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YN(x) cout << ((x) ? "YES" : "NO") << endl
#define Yn(x) cout << ((x) ? "Yes" : "No") << endl
#define yn(x) cout << ((x) ? "yes" : "no") << endl
#define absi(x) (((x) >= 0) ? (x) : (-(x)))
#define debugvec(v)                                                            \
    rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i         \
                          << "] = " << v[i] << endl;
#define debugvec2(v)                                                           \
    cerr << "L" << __LINE__ << ": " << #v << " = { ";                          \
    rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", ");          \
    cerr << " }" << endl;
typedef long long ll; // 10^18 くらいまでいける

// for DP
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;

double calc_dist(double a[], double b[]) {
    return sqrt(pow(a[0] - b[0], 2) + pow(a[1] - b[1], 2));
}

int main() {
    int n;
    cin >> n;
    double x[10][2];
    rep(i, n) cin >> x[i][0] >> x[i][1];

    double val = 0;
    double cnt = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if(i == j)
                continue;
            val += calc_dist(x[i], x[j]);
        }
        cnt++;
    }

    cout << std::setprecision(10) << val / cnt << endl;

    return 0;
}

Measured memory_bytes: 256
using AtCoderBeginnerContest144.Questions;
using AtCoderBeginnerContest144.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest144.Questions
{
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();

            for (int i = 1; i < 10; i++)
            {
                for (int j = 1; j < 10; j++)
                {
                    if (i * j == n)
                    {
                        yield return "Yes";
                        yield break;
                    }
                }
            }
            yield return "No";
        }
    }
}


namespace AtCoderBeginnerContest144
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest144.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest144.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

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

int main() {
    int n, t, a, h, num;
    cin >> n;
    cin >> t >> a;
    double minimum = 100000000;
    for (auto i=0; i<n; i++) {
        cin >> h;
        double dt = abs(a - (t - h * 0.006));
        if (min(dt, minimum) == dt) {
            num = i + 1;
            minimum = dt;
        }
    }

    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,ans=0,a[500010];
int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=3*n;i++) scanf("%lld",&a[i]);
    sort(a+1,a+1+3*n);
    long long mid=n;
    for(int i=3*n-1;i>mid;i-=2)
        ans+=a[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
using namespace std;

int main()
{
    int n, m, k; cin>>n>>m>>k;
    vector<string> a(n);
    for(auto& s: a) cin>>s;
    
    vector<vector<int>> v(n, vector<int>(m, -1));
    queue<pair<int, int>> q;
    for(int i=0; i<n; ++i) {
        for(int j=0; j<m; ++j) {
            if (a[i][j]=='S') {
                q.emplace(i, j);
                v[i][j]=0;
            }
        }
    }

    int dr[4]={-1, 0, 1, 0};
    int dc[4]={0, -1, 0, 1};
    int res=1<<30;
    while (q.size()) {
        int r, c;
        tie(r, c)=q.front();
        q.pop();
        if (r==0 or c==0 or r==n-1 or c==m-1) {
            cout<<1<<endl;
            return 0;
        }
        res=min({res, r, c, n-1-r, m-1-c});
        if (v[r][c]==k) continue;

        for(int i=0; i<4; ++i) {
            int nr=r+dr[i];
            int nc=c+dc[i];
            if (nr<0 or nr>=n or nc<0 or nc>=m) continue;
            if (a[nr][nc]=='#') continue;
            if (~v[nr][nc]) continue;
            q.emplace(nr, nc);
            v[nr][nc]=v[r][c]+1;
        }
    }
    cout<<(res+k-1)/k+1<<endl;
}


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

int main(){
  const int bnum = 4, fnum = 3, rnum = 10;
  vector<vector<vector<int>>> count{
    {{0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0}},
    {{0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0}},
    {{0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0}},
    {{0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0},
     {0,0,0,0,0,0,0,0,0,0}}};

  int n, b, f, r, v;
  cin >> n;
  if (n < 1) { return 0; }
  for(int i = 0; i < n; i++){
    cin >> b; cin >> f; cin >> r; cin >> v;
    count[b-1][f-1][r-1] += v;
  }
  for(int bb = 0; bb < bnum; bb++){
    for(int ff = 0; ff < fnum; ff++){
      for(int rr = 0; rr < rnum; rr++){
	cout << " " << count[bb][ff][rr];
      }
      cout << endl;
    }
    if(bb + 1 != bnum){
      cout << "####################" << endl;
    }
  }
  return 0;
}

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

int main() {
  int N, A;
  cin >> N >> A;
  if(1 <= N <= 10000 && 0 <= A <= 1000){ //Nが1以上100001以下で、Aが0以上1000以下
    if(N % 500 <= A){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
/***************************************** START OF TEMPLATE *********************************************/

#include<bits/stdc++.h>

using namespace std;

#define  SPEED          ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  newl           cout<<"\n";
#define  f              first
#define  s              second
#define  pb             push_back
#define  mp             make_pair
#define  sym(s)         s="#"+s+"#";   
#define  all(x)         (x).begin(),(x).end()
#define  alll(x, n)     x+1, x+n+1
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  mset1d(a,n,v)  foo(i,0,n+5)a[i]=v;
#define  mset2d(a,n,m,v)foo(i,0,n+5)foo(j,0,m+5)a[i][j]=v;
#define  INP(a,n)       foo(i,1,n) cin>>a[i];
#define  deb1d(a,n)     foo(i,1,n)cout<<a[i]<<" ";newl;
#define  deb2d(a,n,m)   foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}    
#define  debm(a)        for(auto it: a)cout<<"{"<<it.f<<","<<it.s<<"}, ";newl;
#define  debp(a,n)      foo(i,1,n)cout<<"{"<<a[i].f<<","<<a[i].s<<"}, ";newl;
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<" ";newl;
#define  deb2(a,b)      cout<<a<<" "<<b<<" ";newl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<" ";newl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d;newl;
#define  ll             long long
#define  ld             long double
#define  pll            pair<ll,ll>
#define  vll            vector<ll>
#define  vpll           vector<pll>

const ld   PI    =  3.14159265358979323846; 
const ll   MOD   =  1e+9+7;
const ll   INF   =  LLONG_MAX;
const int  INFi  =  INT_MAX;
const ll   N     =  2e+5+8;

vll adj[N]; ll vis[N];
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

ll test_cases = 1; randomINIT;

/*********************************************************************************************************/
/***************************************** VARIABLE DECLARATIONS *****************************************/



/***************************************** FUNCTION IMPLEMENTATIONS **************************************/



/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN(ll tc){
    ll a, b, c, d, e;
    cin>>a>>b>>c>>d>>e;
    if(a==0)cout<<1;
    if(b==0)cout<<2;
    if(c==0)cout<<3;
    if(d==0)cout<<4;
    if(e==0)cout<<5;

}

int main(){
    SPEED;

    //cin>>test_cases;
    foo(i,1,test_cases){
        MAIN(i);
    }
}

Measured memory_bytes: 8352
#include <bits/stdc++.h>
#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(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int main () {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  vvi tx(h,vi(w,-1)), ty(h,vi(w,-1));
  rep(y,h) {
    rep(x,w) {
      if (s[y][x] == '.') {
        int cnt = 0;
        for (int i = x; i < w && s[y][i] == '.'; ++i) {
          cnt++;
        }
        for (int i = x; i < x+cnt; ++i) {
          tx[y][i] = cnt;
        }
        x += cnt-1;
      }
    }
  }
  rep(x,w) {
    rep(y,h) {
      if (s[y][x] == '.') {
        int cnt = 0;
        for (int i = y; i < h && s[i][x] == '.'; ++i) {
          cnt++;
        }
        for (int i = y; i < y+cnt; ++i) {
          ty[i][x] = cnt;
        }
        y += cnt-1;
      }
    }
  }

  /*
  puts("\n");
  rep(i,tx.size()) {
    rep(j,tx[i].size()) {
      printf("%d%c", tx[i][j], j==tx[i].size()-1?'\n':' ');
    }
  }
  puts("\n");
  rep(i,ty.size()) {
    rep(j,ty[i].size()) {
      printf("%d%c", ty[i][j], j==ty[i].size()-1?'\n':' ');
    }
  }
  */

  int ans = 0;
  rep(y,h) {
    rep(x,w) {
      if (s[y][x] == '#') continue;
      ans = max(ans,tx[y][x]+ty[y][x]-1);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 35712
//============================================================================
// Name        : AOJ.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;
typedef long long ll;
int main(){

	string s;

	cin>>s;

	s[5]=' ';
	s[13]=' ';

	cout<<s<<endl;
	return 0;


}


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


int main(void){
    int a, b;
    cin >> a >> b;
    string ans;
    if(a <= 8 && b <= 8){
        ans = "Yay!";
    }else{
        ans = ":(";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	int H,W;
	void solve(){
		Scanner sc=new Scanner(System.in);
		H=sc.nextInt();
		W=sc.nextInt();
		
		if(H%3==0 ||  W%3==0)System.out.println(0);
		else{
			int h1,h2,h3;
			long min;
			//1通りめ
			if(H%3==1){
			h1=H/3;
			h2=H/3;
			h3=H-h1-h2;
			}else{
				h1=H/3+1;
				h2=H/3+1;
				h3=H-h1-h2;
			}
			min=Math.abs(h3*W-h1*W);
			//2通り目
			int w1,w2,w3;
			if(W%3==1){
			w1=W/3;
			w2=W/3;
			w3=W-w1-w2;
			}else{
				w1=W/3+1;
				w2=W/3+1;
				w3=W-w1-w2;
			}
			min=Math.min(min, Math.abs(w3*H-w1*H));
			
			//3通り目:横を分割
			int a1,b1,b2,a2,a3;
			long S1,S2,S3;
			a1=W;
			b1=H/2;
			b2=H-b1;
			a2=W/2;
			a3=W-a2;
			S1=a1*b1;
			S2=a2*b2;
			S3=a3*b2;
			min=Math.min(min, calc(S1,S2,S3));
			
			a1=W;
			b1=H/3;
			b2=H-b1;
			a2=W/2;
			a3=W-a2;
			S1=a1*b1;
			S2=a2*b2;
			S3=a3*b2;
			min=Math.min(min, calc(S1,S2,S3));
			
			a1=W;
			b1=H/3+1;
			b2=H-b1;
			a2=W/2;
			a3=W-a2;
			S1=a1*b1;
			S2=a2*b2;
			S3=a3*b2;
			min=Math.min(min, calc(S1,S2,S3));
			
			//5通り目:たてを分割
			int c1,d1,d2,c2,c3;
			long T1,T2,T3;
			
			c1=H;
			d1=W/2;
			d2=W-d1;
			c2=H/2;
			c3=H-c2;
			T1=c1*d1;
			T2=c2*d2;
			T3=c3*d2;
			min=Math.min(min, calc(T1,T2,T3));
			
			c1=H;
			d1=W/3;
			d2=W-d1;
			c2=H/2;
			c3=H-c2;
			T1=c1*d1;
			T2=c2*d2;
			T3=c3*d2;
			min=Math.min(min, calc(T1,T2,T3));
			
			c1=H;
			d1=W/3+1;
			d2=W-d1;
			c2=H/2;
			c3=H-c2;
			T1=c1*d1;
			T2=c2*d2;
			T3=c3*d2;
			min=Math.min(min, calc(T1,T2,T3));
			
			System.out.println(min);
		}
		
	}
	long calc(long a,long b,long c){
		long Max=Math.max(a, b);
		Max=Math.max(Max, c);
		long Min=Math.min(a, b);
		Min=Math.min(Min, c);
		
		return Max-Min;
	}
	
}

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

int n,k;
void decl(vector<int> &res,int cnt){
    int idx=n-1;
    while(cnt--){
        res[idx]--;
        if(res[idx]==0){
            idx--;
        }
        else{
            for(int j=idx+1;j<n;j++){
                res[j]=k;
            }
            idx=n-1;
        }
    }
}

int main(){
    cin>>k>>n;
    vector<int> res(n,0);
    if(k%2==1){
        for(int i=0;i<n;i++) res[i]=(k+1)/2;
        decl(res,n/2);
        for(int i=0;i<n;i++){
            if(res[i]==0){
                res.resize(i);
                break;
            }
        }
    }
    else{
        res[0]=k/2;
        for(int i=1;i<n;i++){
            res[i]=k;
        }
    }
    for(int i=0;i+1<res.size();i++){
        printf("%d ",res[i]);
    }
    printf("%d\n",res.back());
    return 0;
}

Measured memory_bytes: 3456
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'


void solve(){ 
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  forn(i, 10){
    forn(j, 10){
      forn(k, 10){
        auto x = s.find('0'+ i, 0);
        if (x != s.npos){
          x = s.find('0'+ j, x + 1);
          if (x != s.npos){
            x = s.find('0'+ k, x + 1);
            if (x != -1){
              ans++;
            }
          } 
        }
      }
    }
  }

  cout << ans;
}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 



9 8 7 10 5 6 3 4 2 1 * 9 8 7 10 5 6 3 4 2 1 * 9 8 7 10 5 6 3 4 2 1

 */

Measured memory_bytes: 384
import sys
import heapq
from collections import deque

# sys.setrecursionlimit(100001)
INF = sys.maxsize


# ===CODE===
def main():
    s, w = map(int, input().split())
    if s>w:
        print("safe")
    else:
        print("unsafe")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9472
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    int mod = 1000000007;
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
        sum %= mod;
    }
 
    long ans = 0;
 
    //Search for all i
    for (int i = 0; i < N; i++)
    {
        //Update the values of A[i+1] ... A[N]
        sum -= A[i];
        if (sum < 0) sum += mod;
 
        ans += A[i] * sum;
        ans %= mod;
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 4052
#include<iostream>
int main () {
int a , b;
std::cin >> a >> b;
if(a<b){
std::cout<<"a < b"<<std::endl;
}
else if (a>b){
std::cout<<"a > b"<<std::endl;
}
else{
std::cout<<"a == b"<<std::endl;
}
return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int x,y,s,ans,sa,a,maxn;
int main(){
	while(1){
		cin >> x>>y >>s;
		if(!(x||y||s))break;
		maxn=0;
		sa=s*100/(100+x);
		for(int i=1;i<sa;i++){
			a=s-i*(100+x)/100;
			if(a*100%(100+x)==0){
				a=a*100/(100+x);
			}else{
				a=(a*100/(100+x))+1;
			}
			if(a*(100+x)/100+i*(100+x)/100!=s)continue;
			if(a*(100+y)/100+i*(100+y)/100>maxn){
				maxn=a*(100+y)/100+i*(100+y)/100;
				//ans=i;
			}
		}
		//cout << ans<<endl;
		cout << maxn <<endl;
	}
	return 0;
}

Measured memory_bytes: 2996
#include<iostream>
#include<vector>
#include<map>
#include<tuple>
#include<set>
#include<cmath>
#include<numeric>
#define ll long long
#define MOD = 1e9+7
 
using namespace std;

int main(){
  int N;
  cin >> N;
  cout << N * N * N << endl;
}


Measured memory_bytes: 888
n=int(input())
a = [0]+list(map(int,input().split()))+[0,0]
x = abs(a[1])
z = abs(a[2])
aa = list()
p=x#sum
for i in range(1,n+1):
    k = a[i]
    y=abs(a[i+1]-k)
    aa.append(x+y-z)
    x = y
    z = abs(a[i+2]-k)
    p+=y
print('\n'.join([str(p-i) for i in aa]))

Measured memory_bytes: 19008
from operator import itemgetter

N = int(input())
S = []
for i in range(N):
    S.append(list(map(int,input().split())))
    

S = sorted(S, key=itemgetter(1))

t = 0
flag = True
for i in S:
    if t+ i[0] > i[1]:
        print("No")
        flag = False
        break

    t += i[0]

if flag:    
    print("Yes")


Measured memory_bytes: 55256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=200005;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 


ll int power(ll int a,ll int b)
{
    ll int ans=1,f=a;
    while(b)
    {
        if(b&1ll) ans=(ans*f)%mod;
        b=b>>1ll;
        f=(f*f)%mod;
    }
    return ans;
}

vector<int> v[mex];
int vis[mex],cnt=0;
void dfs(int n)
{
    vis[n]=1;
    cnt++;
    fo(i,0,sz(v[n]))
    if(vis[v[n][i]]==0) dfs(v[n][i]);

}
int main()
{
  
   int n,m;
   cin>>n>>m;
   fo(i,0,m)
   {
       int a,b;
       cin>>a>>b;
       v[a].pb(b);
       v[b].pb(a);
   }
   int ans=0;
   fo(i,1,n+1)
   {
       if(vis[i]==0)
       {
           dfs(i);
           ans=max(ans,cnt);
           cnt=0;
       }
   }
   cout<<ans<<endl;

}

Measured memory_bytes: 21560
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll k; cin >> k;

    queue<ll> que;

    rep(i, 9){
        que.push(i + 1);
    }

    ll x;
    rep(i, k){
        x = que.front();
        // cout << x << endl;
        que.pop();

        ll xshift = 10 * x + x % 10;

        if(x % 10 != 0){
            que.push(xshift - 1);
        }

        que.push(xshift);

        if(x % 10 != 9){
            que.push(xshift + 1);
        }
    }

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 4772
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from string import ascii_uppercase

    N = int(readline())
    S = input()
    res = ""

    for char in S:
        idx = ascii_uppercase.index(char)
        res += ascii_uppercase[(idx + N) % 26]

    print(res)

if __name__ == '__main__':
    main()


Measured memory_bytes: 74308
#import <stdio.h>
#import <stdlib.h>

int compare_int(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

// 昇順に並んだ values の中で searchValue を 左から探したときに初めて上回る(order>0) / 右から探したときに初めて下回る(order<0) ような index を探す（ない場合は -1 を返す）
int binary_search(int searchValue, int *values, int minIndex, int maxIndex, int order) {
    int midIndex = (minIndex + maxIndex)/2;
    int midValue = values[midIndex];
    int maxValue = values[maxIndex];
    if (minIndex == midIndex) { // 区間の長さが2になったとき
        if (order > 0) {
            if (searchValue < midValue) { // 左がサーチ値を上回るなら左
                return midIndex;
            }
            if (searchValue < maxValue) { // 左がサーチ値以下かつ右がサーチ値を上回るなら右
                return maxIndex;
            }
        } else {
            if (searchValue > maxValue) { // 右がサーチ値を下回るなら右
                return maxIndex;
            }
            if (searchValue > midValue) { // 右がサーチ値以上かつ左がサーチ値を下回るなら左
                return midIndex;
            }
        }
        return -1; // 区間の長さが2のとき両端とも条件を満たさないなら存在しない
    }
    if (order > 0) {
        if (midValue <= searchValue) { // 中央での値がまだ上回っていないなら右半分
            return binary_search(searchValue, values, midIndex, maxIndex, order);
        } else {
            return binary_search(searchValue, values, minIndex, midIndex, order);
        }
    } else {
        if (midValue >= searchValue) { // 中央での値がまだ下回っていないなら左半分
            return binary_search(searchValue, values, minIndex, midIndex, order);
        } else {
            return binary_search(searchValue, values, midIndex, maxIndex, order);
        }
    }
}

int main(){
    int N;
    scanf("%d", &N);
    int A[200000] = {0};
    int B[200000] = {0};
    int C[200000] = {0};
    for(int i=0;i<N;i++){
        int a;
        scanf("%d", &a);
        A[i] = a;
    }
    for(int i=0;i<N;i++){
        int b;
        scanf("%d", &b);
        B[i] = b;
    }
    for(int i=0;i<N;i++){
        int c;
        scanf("%d", &c);
        C[i] = c;
    }
    qsort(A, N, sizeof(int), compare_int);
    qsort(C, N, sizeof(int), compare_int);
    if (N==1) {
        puts((A[0]<B[0] && B[0]<C[0]) ? "1" : "0");
        return 0;
    }
    unsigned long long count = 0;
    for(int j=0;j<N;j++){
        int b = B[j];
        int i = binary_search(b,A,0,N-1,-1);
        int k = binary_search(b,C,0,N-1,1);
        if (i>=0 && k>=0) {
            count += (unsigned long long)(i+1)*(N-k);
        }
    }
    printf("%lld",count);
}


Measured memory_bytes: 4976
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }
    vvi ans(h, vi(w));

    int now = 0;
    rep(i, h) {
        if (i % 2 == 0) {
            rep(j, w) {
                if (a[now] == 0) now++;
                ans[i][j] = now+1;
                a[now]--;
            }
        } else {
            for (int j = w-1; j >= 0; j--) {
                if (a[now] == 0) now++;
                ans[i][j] = now+1;
                a[now]--;
            }
        }
    }
    rep(i, h) {
        rep(j, w) {
            if (j != 0) cout << " ";
            cout << ans[i][j];
        }
        cout << endl;
    }
}

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

using namespace std;

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

    int cnt = 0;
    for (int i = 0; i < n.size(); i++)
    {
        if (n[i] == '2')
            cnt++;
    }

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

    return 0;
}

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

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<int> a(n+1, 0);
	vector<int> b(n+1, 0);

	int maxx = 0;
	for (int i =1; i <= n; i++) {
		cin >> a[i];
		maxx = max(maxx, a[i]);
	}

	vector<int> c(maxx+1, 0);
	for (int i = 1; i <= n; i++) {
		c[a[i]]++;
	}

	for (int i = 1; i <= maxx; i++) {
		c[i]+=c[i-1];
	}

	for (int i = n ; i > 0; i--) {
		b[c[a[i]]] = a[i];
		c[a[i]]--;
	}

	for (int i = 1; i <= n; i++) {
		cout << b[i] << (i == n  ? "\n" : " ");
	}

}


Measured memory_bytes: 18292