akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int  ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

bool cmp(LL a, LL b) {
	LL wa = (10 - (a%10))%10;
	LL wb = (10 - (b%10))%10;
	return wa < wb;
}

int main() {
	LL times[5];
	rep(i, 0, 5)	times[i] = scanLong();
	sort(times, times+5, cmp);
	LL total = 0;
	rep(i, 0, 5) {
		total += times[i];
		if(i != 4 && times[i]%10 != 0)
			total += (10 - (times[i]%10));
	}
	pll(total); nl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    string T;
    cin >> T;
    bool N = false, W = false, S = false, E = false;
    for (int i = 0; i < T.size(); i++){
        if (T.at(i) == 'N'){
            N = true;
        }
        if (T.at(i) == 'E'){
            E = true;
        }
        if (T.at(i) == 'W'){
            W = true;
        }
        if (T.at(i) == 'S'){
            S = true;
        }
    }
    if ((N == S) && (E == W)){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

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

	int n, d;
	cin >> n >> d;
	vector<vector<int>> x(n, vector<int>(d));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> x[i][j];
		}
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			double len = 0;
			for (int k = 0; k < d; k++) {
				len += pow(x[i][k] - x[j][k], 2);
			}
			len = pow(len, 0.5);
			if (len == (double)(int)len) ans++;
		}
	}


	cout << ans << endl;

}

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

using namespace std;

int main(){
    int n;
    string s;
    cin >> n >> s;
    for(int i=0;i<s.size();i++){
        s[i] = (s[i]-'A'+n)%26 + 'A';
    }
    cout << s << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

string S;

int main () {
  cin >> S;

  int N = S.size();
  int ans = N / 2;
  char c = S[N/2];
  while(ans <= N && S[ans] == S[N-1-ans] && S[ans] == c) ans++;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
fig = []
h,w  = map(int,input().split())
for i in range(h):
    fig.append(list(str(input())))
    
fig_2 = []

for i in range(h):
    fig_2.append(fig[i])
    fig_2.append(fig[i])
    
for i in range(len(fig_2)):
    onetime = ''
    for j in range(len(fig_2[i])):
        onetime = onetime + fig_2[i][j]
    print(onetime)
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <atcoder/fenwicktree>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
//#define _GLIBCXX_DEBUG

using ll = long long;
using ull = unsigned long long;
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; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
using namespace atcoder;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
int main()
{
    int N, Q;
    cin >> N >> Q;
    fenwick_tree<ll> fw(N);
    rep(i, N) {
        ll a;
        cin >> a;
        fw.add(i, a);
    }
    rep(i, Q) {
        ll a, b, c;
        cin >> a >> b >> c;
        //1点加算
        if (a == 0) { 
            fw.add(b, c);
        }
        //区間和
        if (a == 1) {
            fw.sum(b, c);
            cout << fw.sum(b, c) << "\n";
        }
    }
  
}


Measured memory_bytes: 8220
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<u64>()[0];
    println!("{}", (n-2)*180);
}


Measured memory_bytes: 4352
H, W = map(int, input().split())

S = [list(input()) for i in range(H)]
ans = [["#"] * W for i in range(H)]

dx = [1, 0, -1, 0, 1, -1, -1, 1]
dy = [0, 1, 0, -1, 1, 1, -1, -1]

for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            continue

        num = 0
        for d in range(8):
            ni = i + dy[d]
            nj = j + dx[d]

            if ni < 0 or H <= ni:
                continue

            if nj < 0 or W <= nj:
                continue

            if S[ni][nj] == "#":
                num += 1

        ans[i][j] = str(num)

for i in range(H):
    print("".join(ans[i]))


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
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; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

int main() {
	int N, M; cin >> N >> M;
	vector<vint> cost(N, vint(N, 0));
	int bsize = 1 << N;
	vint cm(bsize, 0);
	while (M--) {
		int a, b, c;
		cin >> a >> b >> c; --a, --b;
		cost[a][b] = cost[b][a] = c;
	}
	for (int b = 0; b < bsize; b++) {
		for (int i = 0; i < N; i++) {
			for (int j = i + 1; j < N; j++) {
				if (((b>>i)&1) && ((b>>j)&1)) cm[b] += cost[i][j];
			}
		}
	}
	
	vector<vint> dp(bsize, vint(N, -INF));
	for (int b = 1; b < (bsize>>1); b += 2) dp[b][0] = cm[b];

	for (int b = 1; b < bsize; b++) {
		for (int v = 0; v < N; v++) {
			if (dp[b][v] == -INF) continue;
			int rev = (~b) & (bsize-1);
			for (int u = 0; u < N; u++) {
				if ((b>>u)&1) continue;
				for (int nb = rev; nb > 0; nb = (nb-1)&rev) {
					if ((nb >> u) & 1 && cost[v][u] > 0) {
						chmax(dp[b|nb][u], dp[b][v] + cm[nb] + cost[v][u]);
					}
				}
			}
		}
	}
	cout << cm[bsize-1] - dp[bsize-1][N - 1] << endl;

	return (0);
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void A(){
    int x;
    cin>>x;
    if(x>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
void B(){
    ll n,d;
    cin>>n>>d;
    int res=0;
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        if(x*x+y*y<=d*d) res++;
    }
    cout<<res<<endl;
}
void C(){
    int k;
    cin>>k;
    int num=7;
    for(int i=0;i<1e7;i++){
        if(num%k==0) {
            cout<<i+1<<endl;
            return;
        }
        num=(num*10+7)%k;
    }
    cout<<-1<<endl;
}
void D(){
    int n;
    string s;
    cin>>n;
    cin>>s;
    stack<int>st;
    for(int i=0;i<n;i++){
        if(s[i]=='R') st.push(i);
    }
    int l=0,r=n-1;
    int res=0;
    for(int i=0;i<n&&!st.empty();i++){
        if(i>=st.top()) break;
        if(s[i]=='W'){
            st.pop();
            res++;
        }
    }
    cout<<res<<endl;
}
void E(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n,0);
    ll ma=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        ma=max(ma,a[i]);
    }
    if(k==0) {
        cout<<ma<<endl;
        return;
    }
    ll l=0,r=ma;//*1.0;
    ll ans=0;
    while(l<r){
        //cout<<l<<" "<<r<<endl;
        ll mid=l+(r-l)/2;
        if(mid==0) {
            l=1;
            break;
        }
        ll cnt=0;
        for(ll i:a){
            cnt+=(i-1)/mid;
        }
        if(cnt<=k) {
            ans=mid;
            r=mid;
        }
        else l=mid+1;
    }
    cout<<l<<endl;
}
void F(){

}
void helper(){
    ll r=1;
    while(r<LONG_LONG_MAX/100){
        vector<ll> res;
        for(ll i=1;i*i<=r;i++){
            if(r%i==0){
                res.push_back(i);
                if(r/i!=i) res.push_back(r/i);
            }
        }
        sort(res.begin(),res.end());
        for(ll i:res) cout<<i<<" ";
        cout<<endl;
        r=r*10+1;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    helper();
    C();
    return 0;
}


Measured memory_bytes: 3564
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int dx[]={0,0,-1,1};
int dy[]={-1,1,0,0};
typedef struct{
	int x,y;
} q;
int n,m,a;
int main(){
	cin>>m>>n;
	vector<vector<char> >in(n+2,vector<char>(m+2));
	rep(i,n+2)rep(j,m+2){
		if(!i||!j||i==n+1||j==m+1)in[i][j]='#';
		else cin>>in[i][j];
	}
	cin>>a;
	vector<q>s(a+1);
	rep(i,a){
		cin>>s[i+1].y>>s[i+1].x;
		s[i+1].x++;s[i+1].y++;
	}
	bool h=false;
	rep(i,a+1){
		vector<q>tmp;
		if(!i){q qq={1,1};tmp.pb(qq);in[1][1]='!';}
		else{
			bool h1=false;
			rep(j,4)if(in[s[i].x+dx[j]][s[i].y+dy[j]]=='!')h1=true;
			if(h1){tmp.pb(s[i]);in[s[i].x][s[i].y]='!';}
			else in[s[i].x][s[i].y]='.';
		}
		while(tmp.size()){
			//cout<<tmp[0].x<<" "<<tmp[0].y<<endl;
			rep(j,4){
				int nx=tmp[0].x+dx[j];
				int ny=tmp[0].y+dy[j];
				if(in[nx][ny]=='t'){h=true;break;}
				if(in[nx][ny]=='.'){
					q qq={nx,ny};
					tmp.pb(qq);
					in[nx][ny]='!';
				}
			}
			tmp.erase(tmp.begin());
			if(h){cout<<i<<endl;return 0;}
		}
	/*rep(j,n+2){
			rep(k,m+2)cout<<in[j][k];
			cout<<endl;
		}
		cout<<endl;*/
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 2060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define fcout cout << fixed << setprecision(10)
ll digsum(ll n){ //各桁の和
    ll a=0;
    while (n) {
        a+=n%10;
        n/=10;
    }
    return a;
}
int main(){
    ll n;
    cin>>n;
    ll dis=1;
    ll cnt=1;
    while (n) {
        if(cnt*digsum(cnt+dis)<=(cnt+dis)*digsum(cnt)){ //次の数よりn/S(n)が低いなら
            cout<<cnt<<endl; //出力
            n--;
            cnt+=dis;
        }
        else{ //そうでなければ
            dis*=10; //増加幅を1桁増やし
            cnt=(cnt/dis+1)*dis-1; //下*桁が9の数まで進む
        }
    }
}

Measured memory_bytes: 256
var sample_input = require('fs').readFileSync('/dev/stdin', 'utf8');
var coefficient_sets = (sample_input.trim()).split("\n");
coefficient_sets.forEach(function(coefficient_set){
  var coefficients = coefficient_set.split(" ").map(Number);
  var a = coefficients[0];
  var b = coefficients[1];
  var c = coefficients[2];
  var d = coefficients[3];
  var e = coefficients[4];
  var f = coefficients[5];
  var x;
  var y;
  var x = (c*e - f*b )/(e*a - d*b);
  var y = (c-a*x)/b;
  console.log([x.toFixed(3),y.toFixed(3)].join(" "));
});

Measured memory_bytes: 15388
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define eb emplace_back
#define mp make_pair
using namespace std;
const int MAX_N=510;
int a[MAX_N][MAX_N],n;
void solve(int l,int r,int level){
    if(l==r){
        return;
    }
    int mid=(l+r)>>1;
    for(int i=l;i<=mid;i++){
        for(int j=mid+1;j<=r;j++){
            a[i][j]=level;
        }
    }
    solve(l,mid,level+1);
    solve(mid+1,r,level+1);
}
int main(){
    scanf("%d",&n);
    solve(1,n,1);
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++){
            printf("%d ",a[i][j]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int w, h, x, y;
int32_t main(){_

   cout << fixed << setprecision(15);

   cin>>w>>h>>x>>y;

   L area = (h*w) / 2.0;

   int ans = 0;
   if ((x*h) == (w-x)*h){
      ans++;
   }

   if ((y*w) == (h-y)*w){
      ans++;
   }



   if (ans > 1){
      cout<<area<<' '<<1;
      exit(0);
   }

   bool a = (w*y == x*h);
   bool b = (-w*(y-h) == x*h);

   if (a and b){
      cout<<area<<' '<<1;
      exit(0);
   }


   cout<<area<<' '<<0;
   exit(0);   

   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me give it a try.
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e3+5;
ll x,y;
int main()
{
	cin>>x>>y;
	ll cnt=1;
	while(y/2>=x)
		cnt++,y/=2;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000

void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin>>n;
  std::vector<char> s(n);
  rep(i,n) cin>>s[i];
  ll flg= 0;
  rep(i,n) if(s[i]=='Y') flg=1;
  if(flg) cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
s = gets.chomp.split("/")

if s[0].to_i < 2019
	str = "Heisei"
elsif s[0].to_i > 2020
	str = "TBD"
elsif s[1].to_i <= 4
	str = "Heisei"
else
	str = "TBD"
end

puts str

Measured memory_bytes: 1788
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	string s;
	cin>>s;
	int a=(s[5]-48)*10+s[6]-48;
	int b=(s[8]-48)*10+s[9]-48;
	//cout<<a<<endl;
	if(a>=5)
		cout<<"TBD"<<endl;
	else
		cout<<"Heisei"<<endl;
	return 0;
}




















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

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

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    int cost = 1e9;
    int mn = a[0];
    int mx = a[n - 1];
    for (int i = mn; i <= mx; i++) {
        int total = 0;
        for(int j = 0; j < n; j++) {
            total += (i - a[j]) * (i - a[j]);
        }
        cost = min(cost, total);
    }
    
    cout << cost << endl;
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
// abc173_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    REP(i, H) cin >> S[i];

    int ans = 0;
    REP(x, 1 << H) REP(y, 1 << W){

        auto T = S;
        REP(i, H) REP(j, W){
            if ((x >> i) & 1 || (y >> j) & 1){
                T[i][j] = 'x';
            }
        }

        int cnt = 0;
        REP(i, H) REP(j, W) {
            cnt += (T[i][j] == '#');
        }

        if (cnt == K){
            ans++;
        }
//        print(x, y, cnt);
    }

    print(ans);


    return 0;
}


Measured memory_bytes: 3604
N, M = map(int, input().split())
lefts = []
rights = []

for _ in range(M):
    L, R = map(int, input().split())
    lefts.append(L)
    rights.append(R)

lefts.sort()
rights.sort()

if lefts[-1] > rights[0]:
    print(0)
else:
    print(rights[0] - lefts[-1] + 1)


Measured memory_bytes: 86652
#include<iostream>
#include<string>
#include<vector>
#include<queue>

using namespace std;

int main() {

	int n, q, P = 0;
	cin >> n >> q;
	vector<int> TIME(n);
	vector<string> NAME(n);
	queue<int> time, Atime;
	queue<string> name, Aname;
	for (int i = 0; i < n; i++) {
		cin >> NAME[i] >> TIME[i];
		name.push(NAME[i]);
		time.push(TIME[i]);
	}

	while (name.empty()==0) {
		if (time.front() > q) {
			P += q;
			time.push(time.front() - q);
			time.pop();
			name.push(name.front());
			name.pop();
		}
		else {
			P += time.front();
			Atime.push(P);
			time.pop();
			Aname.push(name.front());
			name.pop();
		}
	}

	for (int i = 0; i < n; i++) {
		cout << Aname.front() << " " << Atime.front() << endl;
		Aname.pop();
		Atime.pop();
	}

	return 0;
}


Measured memory_bytes: 6512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int inputN = scanner.nextInt();
		int[] inputAs = new int[inputN];
		for (int i = 0; i < inputN; i++) {
			inputAs[i] = scanner.nextInt();
		}
		scanner.close();

		int base = 0;
		int current = 0;
		for (int targetNum = 1; targetNum <= inputN; targetNum++) {
			int target = inputAs[targetNum - 1];
			base += Math.abs(target - current);
			current = target;
		}
		base += Math.abs(0 - current);

		for (int targetNum = 1; targetNum <= inputN; targetNum++) {
			int sum = base;
			if (targetNum == 1) {
				sum -= Math.abs(inputAs[0]);
				sum -= Math.abs(inputAs[1] - inputAs[0]);
				sum += Math.abs(inputAs[1]);
			} else if (targetNum == inputN) {
				sum -= Math.abs(inputAs[inputN - 1] - inputAs[inputN - 2]);
				sum -= Math.abs(inputAs[inputN - 1]);
				sum += Math.abs(inputAs[inputN - 2]);
			} else {
				sum -= Math.abs(inputAs[targetNum - 2] - inputAs[targetNum - 1]);
				sum -= Math.abs(inputAs[targetNum - 1] - inputAs[targetNum]);
				sum += Math.abs(inputAs[targetNum] - inputAs[targetNum - 2]);
			}
			System.out.println(sum);
		}

	}
}


Measured memory_bytes: 66796
import heapq
import sys
from collections import defaultdict

def dijkstra(graph, size, start):
    d = [float('inf')] * size
    d[start] = 0
    q = [(0, start)]
    while len(q):
        du, u = heapq.heappop(q)
        for length, v in graph[u]:
            if d[v] > du + length:
                d[v] = du + length
                heapq.heappush(q, (d[v], v))
    return d

f = sys.stdin

while True:
    n, m = map(int, f.readline().split())
    if n == 0:
        break
    abct = [map(int, f.readline().split()) for _ in range(n)]
    d = [defaultdict(list), defaultdict(list)]
    
    for ai, bi, ci, ti in abct:
        ai -= 1
        bi -= 1
        d[0][ai].append((ci, bi))
        d[0][bi].append((ci, ai))
        d[1][ai].append((ti, bi))
        d[1][bi].append((ti, ai))
    
    dist = {}
    for i in range(int(f.readline())):
        p, q, r = map(int, f.readline().split())
        p -= 1
        q -= 1
        try:
            print(dist[(q,r)][p])
        except KeyError:
            try:
                print(dist[(p,r)][q])
            except:
                dist[(p,r)] = dijkstra(d[r], m, p)
                print(dist[(p,r)][q])

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

int main() {
  
  string n;
  cin >> n;
  
  int sum = 0;
  int length = n.size();
  
  for (int i = 0; i < length; i++) {
    sum += (int)n.at(i)-(int)'0';
    sum %= 9;
  }
  
  if (sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
return 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <vector>
using namespace std;
using ll = long long int;

int main()
{
	int n;
	ll k;
	cin >> n >> k;
	auto a = vector<int>(n + 1);
	for(int i = 1; i <= n; ++i){
		cin >> a[i];
	}
	auto b = vector<int>(n + 1);
	ll p = a[1], c = 1, q;
	b[1] = c;
	while(c < k + 1 && b[p] == 0){
		b[p] = ++c;
		q = p;
		p = a[p];
	}
	k -= c;
	if(k < 0){
		p = q;
	}else if(k > 0){
		int r = c - b[p] + 1;
		k %= r;
		while(k > 0){
			p = a[p];
			--k;
		}
	}
	cout << p << endl;
	return 0;
}

Measured memory_bytes: 4828
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a) for(ll i=ll(a-1);i>=0;--i)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll EPS = 1e-10;
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
typedef complex<double> Point;
const ll MAX = 30000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
map<ll,ll> app;
ll a,b,c,d;
ll dfs(ll n){
    if (n == 0) return app[n] = 0;
    if (n == 1) return app[n] = d;
    if (n == 2) return app[n] = min(2*d,a+d);
    if (app[n]) return app[n];
    ll res;
    if (n*d > 0) res = n*d;
    else res = INF;
    ll k = n/2;
    chmin(res,min(abs(n-k*2)*d+dfs(k)+a,abs(n-(k+1)*2)*d+dfs(k+1)+a));
    k = n/3;
    chmin(res,min(abs(n-k*3)*d+dfs(k)+b,abs(n-(k+1)*3)*d+dfs(k+1)+b));
    k = n/5;
    chmin(res,min(abs(n-k*5)*d+dfs(k)+c,abs(n-(k+1)*5)*d+dfs(k+1)+c));
    return app[n] = res;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll t;
    cin >> t;
    rep(_,t){
        ll n;
        cin >> n >> a >> b >> c >> d;
        PRINT(dfs(n));
        app.clear();
    }
}



Measured memory_bytes: 4872
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
typedef long long int ll;
const int MAXN=1e5+1;
const ll mod=1e9+7;
char s[MAXN];
int len,cnt[MAXN];
ll pw[MAXN],dp[3][MAXN];
int main(){
	scanf("%s",s+1);len=strlen(s+1);
	pw[0]=1;
	for(int i=1;i<=len;++i){
		cnt[i]=cnt[i-1]+(s[i]=='?');
		pw[i]=pw[i-1]*3%mod;
	}
	for(int i=1;i<=len;++i){
		if(s[i]=='A') dp[0][i]=(dp[0][i-1]+pw[cnt[i-1]])%mod;
		else dp[0][i]=dp[0][i-1]; 
		if(s[i]=='B') dp[1][i]=(dp[1][i-1]+dp[0][i-1])%mod;
		else dp[1][i]=dp[1][i-1];
		if(s[i]=='C') dp[2][i]=(dp[2][i-1]+dp[1][i-1])%mod;
		else dp[2][i]=dp[2][i-1];
		if(s[i]=='?'){
			dp[0][i]=(3*dp[0][i-1]+pw[cnt[i-1]])%mod;
			dp[1][i]=(3*dp[1][i-1]+dp[0][i-1])%mod;
			dp[2][i]=(3*dp[2][i-1]+dp[1][i-1])%mod;
		}
	}
	printf("%lld",dp[2][len]);
	return 0;
}

Measured memory_bytes: 3840
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <vector>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

const int maxn = 305, mod = 1000000007;
ll f[maxn][maxn][maxn];
std::vector<int> lim[maxn];

int main() {
	int n = read, m = read;

	for(int i = 1; i <= m; i ++) {
		int l = read, r = read, x = read;
		lim[r].push_back(l * 10 + x);
	}

	f[0][0][0] = 1;
	ll ans = 0;

	for(int i = 0; i <= n; i ++) {
		for(int j = 0; j <= n; j ++) {
			for(int k = 0; k <= n; k ++) {
				int r = std::max(i, std::max(j, k));
				f[i][j][k] %= mod;

				bool ok = 1;
				for(int li : lim[r]) {
					int l = li / 10, x = li % 10;
					int y = (i >= l) + (j >= l) + (k >= l);
					if(x != y) {
						ok = 0;
						break;
					}
				}

				if(ok) {
					if(r == n) ans += f[i][j][k];
					else {
						f[r + 1][j][k] += f[i][j][k];
						f[i][r + 1][k] += f[i][j][k];
						f[i][j][r + 1] += f[i][j][k];
					}
				}
				else
					f[i][j][k] = 0;
			}
		}
	}

	ans %= mod;
	printf("%lld\n", ans);
}


Measured memory_bytes: 219392
N = int(input())
P, Q = [], [0]*(N+1)
for i in range(1,N+1):
    p = int(input())
    P.append(p)
    Q[p] = i
Q.append(0)
cnt = 1
res = []
for i in range(1,N+1):
    if Q[i] < Q[i+1]:
        cnt += 1
    else:
        res.append(cnt)
        cnt = 1
if res:
    print(N-max(res))
else:
    print(N)

Measured memory_bytes: 103852
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for a in range(0, n-2):
    for b in range(a+1, n-1):
        for c in range(b+1, n):
            if l[a] + l[b] > l[c] and l[b] + l[c] > l[a] and l[c] + l[a] > l[b] and l[a] != l[b] and l[a] != l[c] and l[b] != l[c]:
                cnt += 1
print(cnt)

Measured memory_bytes: 73916
#include <bits/stdc++.h>
    using namespace std;
    signed main(){
    int x,ans=0;
    cin>>x;
    while(x != 0){
    if(x%10 == 2){
    ans++;
    }
    x/=10;
    }
    cout<<ans<<endl;
    return(0);
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<long long>a(n);
  long long lsum=0,rsum=0,ans=0;
  
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    if(i<n/2)lsum+=a[i];
    else rsum+=a[i];
  }
  if(lsum==rsum)cout<<0<<endl;
  else
  {
    if(lsum>rsum)
    {
      int i=n/2-1;
      ans=lsum-rsum;
    	while(i>=0)
    	{
      		lsum-=a[i];
          	rsum+=a[i];
            ans=min(ans,abs(lsum-rsum));
          	i--;
    	}
    }
    else
    {
      int j=n/2;
      ans=rsum-lsum;
    	while(j<n)
    	{
      		rsum-=a[j];
          	lsum+=a[j];
            ans=min(ans,abs(lsum-rsum));
          	j++;
    	}
    }
    cout<<ans<<endl;
   }
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
    int n;
    cin >> n;
    vector<pair<int,pair<int,int> > > v(n);
    rep(i,n){
        int t,x,y;
        cin >> t >> x >> y;
        v[i] = make_pair(t, make_pair(x,y));
    }
    sort(v.begin(), v.end());

    bool answer = true;
    int t(0), x(0), y(0);
    rep(i, n){
        int dt = v[i].first - t;
        int dist = abs(v[i].second.first - x) + abs(v[i].second.second - y);
        if(dt < dist){
            answer = false;
        }else if((dt - dist) % 2 == 1){
            answer = false;
        }
        t = v[i].first;
        x = v[i].second.first;
        y = v[i].second.second;
    }
    cout << (answer ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>


using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(a>0&&c>0){
    c-=b;
    if(c<=0){
      cout<<"Yes";
      break;
    }
        a-=d;
    if(a<=0){
      cout<<"No";
      break;
    }
  }

}

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

#define Bye return 0
#define ll long long
const ll MAX = 1e2;

void solve(){
    int n, m; cin>>n>>m;
    ll a[n+1], b[n+1], c[m+1], d[m+1];

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

    for (int i=1; i<=m; i++)
        cin>>c[i]>>d[i];

    for (int i=1; i<=n; i++){
        ll x1 = a[i]; ll y1 = b[i];

        ll mini = LONG_MAX;
        ll point = 1;
        for (int j=1; j<=m; j++){
            ll x2 = c[j];  ll y2 = d[j];

            ll x = abs(x1-x2) + abs(y1-y2);

            if(x<mini){
                mini = x; point = j;
            }
        }

        cout<<point<<endl;
    }
}

int main(){
    solve();
    Bye;
}

Measured memory_bytes: 3472
// d-not-divisible.yml
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pii = pair<int, int>;
template <typename V> using uset = unordered_set<V>;
template <typename K, typename V> using umap = unordered_map<K, V>;
template <typename C> int sz(C &v) { return v.size(); }

const int MN = 2e5 + 1, MV = 1e6 + 1;
int N,
    val[MN], cnt[MV];
bool bad[MV], seen[MV];

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

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> val[i];
        cnt[val[i]]++;
    }

    for (int i = 0; i < N; i++) {
        if (cnt[val[i]] > 1) {
            bad[val[i]] = true;
        }
        if (seen[val[i]]) continue;
        seen[val[i]] = true;
        for (int j = val[i] + val[i]; j < MV; j += val[i]) {
            bad[j] = true;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
        ans += !bad[val[i]];
    cout << ans << '\n';

    return 0;
}



Measured memory_bytes: 10280
n = int(input())
s = input()
ans = []

for i in range(0,1000):
    v = str(i).zfill(3)
    p1 = s.find(v[0],0)
    p2 = s.find(v[1],p1+1)
    p3 = s.find(v[2],p2+1)
    if p1 != -1 and p2 != -1 and p3 != -1:
        ans.append(v)

print(len(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define N 100007
using namespace std;
int n,m,a[N*2],l[N*2],r[N*2];
bool check(int k){
	int t=0;
	for(int i=n*2;i;--i)
		if(a[i]<=k){t=i;break;}
	for(int i=1,j=t;i<=t;++i){
		while(i<j && a[i]+a[j]>k)--j;
		if(i>=j){t=i-1;break;}
		else --j;
	}
	for(int i=n*2,j=1;i;--i){
		while(j<=n*2 && (a[i]+a[j])%m>k)++j;
		l[i]=j,r[i]=max(j,r[i+1]);
		if(j>n*2)break;
		while(r[i]<n*2 && (a[i]+a[r[i]+1])%m<=k)++r[i];
	}
	int L=0,R=n*2-1;
	for(int i=n*2;i;--i){
		L=max(L+1,l[i]),R=min(R+1,r[i]);
		if(L>R)return 0;
		if(i-1>=L && i-1<=R && (t+n*2-i+1)>=n)return 1;
	}
	return 0;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n*2;++i)scanf("%d",&a[i]);
	sort(a+1,a+n*2+1);
	int ans=m-1,l=0,r=m-1;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid))ans=mid,r=mid-1;
		else l=mid+1;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <math.h>
#include <stdbool.h>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

class Point {
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (Point p) { return Point(x+p.x, y+p.y); }
    Point operator - (Point p) { return Point(x-p.x, y-p.y); }
    Point operator * (double a) { return Point(a*x, a*y); }
    Point operator / (double a) { return Point(x/a, y/a); }

    double abs() {return sqrt(norm()); }
    double norm() {return x*x + y*y; }
};

class Circle {
    public:
    double r;
    Point c;

    Circle(double r = 0, Point c = Point()): r(r) {}
};

int main(){
    #if 0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
    #endif

    Circle c1, c2;
    cin >> c1.c.x >> c1.c.y >> c1.r;
    cin >> c2.c.x >> c2.c.y >> c2.r;

    double d = ( c1.c - c2.c ).abs();
    double r1 = c1.r;
    double r2 = c2.r;
    if ( r1 < r2 ) swap(r1,r2);

    if ( d > r1 + r2 ) cout << 4 << endl;
    else if ( d == r1 + r2 ) cout << 3 << endl;
    else if ( d  > r1 - r2 ) cout << 2 << endl;
    else if ( d == r1 - r2 ) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 3216
# coding: euc-jp
S = gets.chomp!

# 両端から１文字ずつ比較していって、一致しない文字数を出力する
ri = S.size - 1
li = 0
mi = (S.size / 2) - 1
ans = 0

(0..mi).each do |i|
  ans += 1 if S[i] != S[ri - i]
end

puts ans



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

#define MaxNUM 100

int main( void )
{
    char tmp;
    char i,j,k = 0;
    unsigned char Num = 0;
    
    unsigned short Array[MaxNUM];
    unsigned short v = 0;

    // ??\??? 1?????????????????°?????????
    // ????????????????????\????????§??£?¶???????
    while( (tmp = getchar()) != '\n' )
    {
        Num = (Num * 10) + (tmp - '0'); // ??????????????°???????????????????¶?????????????
    };
    
    // ??\??? 2??????????????????????????????????????????
    for(k=0; k<Num; k++ )
    {
        // ??????????????????
        Array[k]=0;
    
        do{
            tmp = getchar();
            printf("%c",tmp);
            
            if(tmp == '\n') //???????????????????????????
            {
                break;
            }
            
            if( tmp != ' ' )
            {
                Array[k] = Array[k] * 10 + (tmp - '0');
            }
        }while(tmp != ' ' && tmp != '\n'); // ???????????£???????¬???????????????????
    }

    // ?????????
    for( i=1; i<Num; i++ )
    {
        v = Array[i];
        j = i - 1;
    
        // ??????????????????????????§????????¨??????1??????????????¨??\????????????
        while( j >= 0 && Array[j] > v )
        {
            Array[j+1] = Array[j];
            Array[j] = v;
            j--;
        }
    
        // ???????????????????????????????????????????????????????????????
        for(k=0; k<Num; k++ )
        {
            printf("%d",Array[k]);
            if( k == Num-1 )
            {
               printf("\n");    // ???????????????
            }
            else
            {
               printf(" ");
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 1788
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

import numpy as np

MOD = 998244353

N = int(readline())
A = np.array(readline().split(),np.int32)

U = 10**6+100
counter = np.bincount(A,minlength=U)

def cumprod(arr):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

x = np.arange(U,dtype=np.int64); x[0] = 1
fact = cumprod(x)
x = np.arange(U,0,-1,dtype=np.int64); x[0] = pow(int(fact[-1]),MOD-2,MOD)
fact_inv = cumprod(x)[::-1]

inv = np.zeros(U,dtype=np.int64)
inv[1:] = fact[:-1] * fact_inv[1:] % MOD

"""
・f(n) = sum_{gcd(a,b) == 1}ab
・g(n) = sum_{n|gcd(a,b)}ab
"""

"""
・S(n) = sum_{n|a} a
・T(n) = sum_{n|a} a^2
"""

x = np.arange(U,dtype=np.int64)*counter%MOD
y = np.arange(U,dtype=np.int64)**2%MOD*counter%MOD
S = np.zeros(U,dtype=np.int64)
T = np.zeros(U,dtype=np.int64)
M = int(U**.5+1)+10
for d in range(1,M):
    S[d] = (x[d::d]).sum()
    T[d] = (y[d::d]).sum()
for d in range(1,M):
    S[M:(U-1)//d+1] += x[M*d:U:d]
    T[M:(U-1)//d+1] += y[M*d:U:d]
S%=MOD
T%=MOD

G = (S*S-T)%MOD*inv[2]%MOD

coef = np.ones(U,dtype=np.int64)
for p in range(2,U):
    if coef[p] == 1:
        coef[p::p] *= (1-p)

answer = (G*coef%MOD*inv%MOD).sum()%MOD
print(answer)



Measured memory_bytes: 122904
object Main {
  import java.util.Scanner

  def readStrings(n: Int)(implicit sc: Scanner): Array[String] = Array.fill(n) { sc.next() }
  def readInts(n: Int)(implicit sc: Scanner): Array[Int] = Array.fill(n) { sc.nextInt() }
  def readLongs(n: Int)(implicit sc: Scanner): Array[Long] = Array.fill(n) { sc.nextLong() }
  def readLineStrings(implicit sc: Scanner): Array[String] = sc.nextLine().split(' ')
  def readLineInts(implicit sc: Scanner): Array[Int] = readLineStrings.map(_.toInt)
  def readLineLongs(implicit sc: Scanner): Array[Long] = readLineStrings.map(_.toLong)

  def main(args: Array[String]): Unit = solve(new Scanner(System.in))

  def solve(implicit sc: Scanner): Unit = {
    val s = sc.nextLong
    def f(n: Long): Long = n match { case ev if ev % 2 == 0 => ev / 2; case _ => 3 * n + 1 }
    val accum = scala.collection.mutable.Set(s)
    var a = 1
    var last = s
    while (true) {
      val next = f(last)
      if (accum.contains(next)) return println(a + 1)
      accum.add(next)
      last = next
      a += 1
    }
  }
}


Measured memory_bytes: 27192
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int h, w, n;
  cin >> h >> w >> n;
  int ans[105][105];
  int color[10005];
  REP(i, n) { cin >> color[i]; }
  int now_color = 0;
  REP(i, h) {
    if (i % 2 == 0) {
      REP(j, w) {
        ans[i][j] = now_color + 1;
        if (--color[now_color] == 0) {
          now_color += 1;
        }
      }
    } else {
      for (int j = w - 1; j >= 0; j--) {
        ans[i][j] = now_color + 1;
        if (--color[now_color] == 0) {
          now_color += 1;
        }
      }
    }
  }

  REP(i, h) {
    REP(j, w) {
      if (j == w - 1) {
        cout << ans[i][j] << endl;
      } else {
        cout << ans[i][j] << " ";
      }
    }
  }
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
  int w,h,x,y,r;
  cin >> w >> h >> x >> y >> r;
  if (x>=0&&x<=w-r&&y>=0&&y<=h-r) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3108
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target ("avx")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


int main() {
	ll K;
	cin >> K;
	if (K < 50 * 0) {
		ll a = 1, b = 1;
		for (int i = 0; i < K; i++) {
			if (a <= b) {
				a += 2;
				b -= 1;
			}
			else {
				a -= 1;
				b += 2;
			}
		}
		cout << 2 << endl;
		cout << a << " " << b << endl;
		return 0;
	}
	ll d1 = K / 50, d2 = K % 50;
	ll k_ = d1 * 50;
	vector<ll> ans(50, d1 + 49);
	for (ll i = d1 * 50; i < K; i++) {
		ll max_index = 0, max_n = INF_LL;
		for (int j = 0; j < 50; j++) {
			if (max_n > ans[j]) {
				max_index = j;
				max_n = ans[j];
			}
		}
		for (int j = 0; j < 50; j++) {
			if (j == max_index) {
				ans[j] += 50;
			}
			else {
				ans[j] -= 1;
			}
		}
	}
	
	cout << 50 << endl;
	for (int i = 0; i < 50; i++) {
		cout << ans[i] << " ";
	}
	cout << endl;
}

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

#ifdef LOCAL
	#define D(a) cerr << #a << " = " << a << endl
#else
	#define D(a)
	#define cerr false && cerr
#endif
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) dforsn(i,0,n)
#define forn(i,n) forsn(i,0,n)
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first
#define endl '\n'
using pii = pair<int,int>;
using vi = vector<int>;
using ll = long long;

const int N = 1e5, K = 2;

int n;
vi adj[N];

int color[N], n_color[K]; 
int s, t;
void paint(int u = 0, int p = -1, int cur_color = 1) {
    color[u] = cur_color;
    n_color[cur_color==1]++;

    int next_color = -1 * cur_color;
    for (int v : adj[u]) if (v != p) {
        if (!color[v]) paint(v, u, next_color);
        else s = u, t = v;
    }
}

int need[N];
int calc_needs(int u = 0, int p = -1) {
    need[u] = color[u];

    for (int v : adj[u]) if (v != p) {
        if ((u == s && v == t) || (u == t && v == s)) continue;

        need[u] += calc_needs(v, u);
    } 

    return need[u];
}

bool in_cycle[N];
bool find_cycle(int u = s, int p = -1) {
    if (u == t) in_cycle[u] = true;

    for (int v : adj[u]) if (v != p) {
        if ((u == s && v == t) || (u == t && v == s)) continue;
        
        if (find_cycle(v, u)) in_cycle[u] = true;
    }

    return in_cycle[u];
}

ll calc_cost() {
    ll cost = 0;
    forn(u, n) cost += abs(need[u]);
    return cost;
}

void no() {
    cout << -1 << endl;
    exit(0);
}

int main() {
	fastio;

    int m; cin >> n >> m;
    forn(_, m) {
        int u, v; cin >> u >> v; u--, v--; 
        adj[u].pb(v), adj[v].pb(u); 
    }

    paint();
    int dif_colors = n_color[1] - n_color[0];

    ll ans;
    if (m == n - 1) { // árbol
        if (dif_colors != 0) no();

        calc_needs();

        ans = calc_cost();
    }
    else if (color[s] == color[t]) { // ciclo impar
        if (abs(dif_colors) % 2 == 1) no();

        int need_add = dif_colors / 2;
        color[s] -= need_add, color[t] -= need_add;
        calc_needs();

        ans = abs(need_add) + calc_cost();
    }
    else { // ciclo par
        if (dif_colors != 0) no();

        calc_needs();

        find_cycle();
        vi sorted_needs; sorted_needs.pb(0);
        forn(u, n) if (in_cycle[u] && u != s) sorted_needs.pb(need[u]);

        sort(all(sorted_needs)); 
        int opt_move = sorted_needs[si(sorted_needs) / 2];

        color[s] += opt_move, color[t] -= opt_move;
        calc_needs();

        ans = abs(opt_move) + calc_cost();
    }

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


Measured memory_bytes: 16316
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b;
    cin >> a >> b;
    if( a + b >= 10 ) cout << "error";
    else cout << a + b;
    cout << endl;
    return 0;
}



Measured memory_bytes: 256