akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

map<int, ll> mp;
ll pw[18];

//n:=桁数、k:=注目している桁、rem:=残り
ll dfs(int n, int k, ll rem){
    ll ret = 0;
    if(k == n/2){
        if(rem == 0){
            if(n & 1) return 10;
            return 1;
        }
        return 0;
    }
    ll x = (pw[n-2*k-1]-1)/9;
    ll a = abs(rem)%10;
    if(a == 0){
        if(k == 0) ret += (mp[0]-1)*dfs(n, k+1, rem/10);
        else ret += mp[0]*dfs(n, k+1, rem/10);
    }
    elif(rem > 0){
        if(k == 0) ret += (mp[a]-1)*dfs(n, k+1, (rem-a*x)/10);
        else ret += mp[a]*dfs(n, k+1, (rem-a*x)/10);
        ret += mp[a-10]*dfs(n, k+1, (rem-(a-10)*x)/10);
    }
    else{
        if(k == 0) ret += (mp[10-a]-1)*dfs(n, k+1, (rem-(10-a)*x)/10);
        else ret += mp[10-a]*dfs(n, k+1, (rem-(10-a)*x)/10);
        ret += mp[-a]*dfs(n, k+1, (rem+a*x)/10);
    }
    return ret;
}

int main(){
    rep(i, 10) rep(j, 10) mp[i-j]++;
    ll D; cin >> D;
    if(D%9 != 0) {cout << 0 << endl; return 0;}
    D /= 9;
    pw[0] = 1;
    rep2(i, 1, 17) pw[i] = pw[i-1]*10;
    ll ans = 0;
    rep2(i, 1, 18){
        ans += dfs(i, 0, D);
    }
    cout << ans << endl;
}

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

int main() {
  string S;
  cin >> S;
  int first=0, last, middle;
  for (int i=0;i<S.length();i++) {
    if (i==S.length()-1 || S[i]=='L' && S[i+1] == 'R') {
      last = i+1;
      int l=last-first;
      int half[2];
      if (l%2) {
        half[first%2] = l/2+1;
        half[1-first%2] = l/2;
      } else {
        half[0] = half[1] = l/2;
      }
      for (int j=first;j<last;j++) {
        if (j<middle || j>middle+1) cout << "0 ";
        else cout << half[j%2] << " ";
      }
      first = i+1;
    }
    else if (S[i]=='R' && S[i+1] == 'L') middle = i;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 640
r, c = map(int, input().split())
cc = [input() for i in range(r)]

from collections import deque


# 縦がｙ 横がx　だから座標はy,xて書く


# 保留スタックtodoにスタートの位置情報を入れる
todo=deque([[0,0]])
# 検知済みリストseenを-1で初期化 (何も検知してないてこと)
seen=[[-1 for i in range(c)] for j in range(r)]

# 黒を数える
bcount=0
for i in range(r):
    bcount+=cc[i].count("#")

# seenにはどんだけの手数でそこに到達できるかを入れる
# 例えばスタート地点は手数0でいけるから0を入れる
seen[0][0]=0

# 4方向の移動リスト これ使って移動していく
ido=[[1,0],[0,1],[-1,0],[0,-1]]

f=0
# 保留リストtodoが空になるまでやる
while todo:
    y, x=todo.popleft() # 現在地は保留からの先頭とりだす
    for i in range(4): # 現在地から4方向を見る
        ny, nx=y+ido[i][0], x+ido[i][1] # 現在地から隣の座標
        # 隣の座標が区画をはみ出さないかつ、検知してないときに
        if 0<=ny<r and 0<=nx<c and seen[ny][nx]==-1 and cc[ny][nx]!="#":
            # 隣に行けるということなので検知してその手数を格納
            seen[ny][nx]=seen[y][x]+1 # 手数＝前の地点の手数+1
            todo.append([ny,nx]) # 保留リストにも入れとく
    if seen[r-1][c-1]!=-1:
        f=1
        break
if f==1: #到達可能
    # 面積-ゴールまでの最短手数-1(スタートのマス分)-元々あった黒のマス
    print(r*c-seen[r-1][c-1]-1-bcount)
else:
    print(-1)

Measured memory_bytes: 3316
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

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

	lint a, b, x;
	cin >> a >> b >> x;

	cout << b / x - (a / x + (lint)(a % x != 0)) + 1;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
using namespace std;
const int N=1e5+1;
const int M=999999937;
const int K=1e9;
const double eps=1e-6;
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){return x?BIT[x]+sum(x-(x&-x)):0;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//LL pw(LL a, LL b,LL M) { return b ? b & 1 ? a*pw(a, b - 1,M) % M : pw(a*a%M, b>>1,M) : 1; }
vector<PII>v;
map<int,int>m;
bool cmp(PII a,PII b){
	return a.S<b.S;
}
int main(){
	int n,k;
	
	cin>>n>>k;
	int x;
	REP(i,n){
		cin>>x;
		m[x]++;
	}
	if(m.size()<=k)return cout<<"0\n",0;
	for(auto x:m){
		v.PB({x.S,x.F});
	}
	sort(ALL(v));
	
	//for(auto x:v)cout<<x.F<<" "<<x.S<<endl;
	
	int ans=0;
	REP(i,m.size()-k)ans+=v[i].F;
	cout<<ans<<endl;
}

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

int main() {
	//input
	int64_t N, K;
	cin >> N >> K;

	vector<int64_t> A(N);
	for (int64_t i = 0; i < N; i++) {
		cin >> A[i];
		A[i]--;
	}

	//calculation
	vector<int64_t> went_city(N, -1);
	went_city[0] = 0;
	int64_t city = 0;
	int64_t start_count, end_count;
	int64_t start_city;
	int64_t count = 1;
	while (1) {
		city = A[city];
		if (went_city[city] == -1) {
			went_city[city] = count;
			city = city;
			count++;
		} else {
			start_count = went_city[city];
			end_count = count;
			start_city = city;
			break;
		}
	}


	//cout << start_count << " " << end_count << " " << start_city << endl;

	//output
	
	if (K < start_count) {
		int64_t out = 0;
		for (int64_t i = 0; i < K; i++) {
			out = A[out];
		}
		out++;
		cout << out << endl;
		return 0;
	}

	int64_t output = start_city;
	int64_t rem = (K - start_count) % (end_count - start_count);
	for (int64_t i = 0; i < rem; i++) {
		output = A[output];
	}
	output++;
	cout << output << endl;


	return 0;
}


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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int N=1010;

int a[N];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    string ans;
    while(n)
        n--,
        ans+='a'+n%26,
        n/=26;
    reverse(ans.begin(),ans.end());
    cout<<ans;
}


Measured memory_bytes: 3648
h,w,k = map(int,input().split())
c = [list(input()) for _ in range(h)]
cnt = 0
for p_h in range(2**h):
    for p_w in range(2**w):
        black = 0
        for i in range(h):
            for j in range(w):
                if (p_h>>i)&1==0 and (p_w >> j)&1==0:
                        if c[i][j]=='#':
                            black += 1
        if black == k:
            cnt += 1
print(cnt)


Measured memory_bytes: 8956
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int x,y;
	int a,b;
	cin>>x>>y;
	if(x==1||x==3||x==5||x==7||x==8||x==10||x==12){
		a = 1;
	}	
	else if(x==4||x==6||x==9||x==11){
		a=2;
	}
	else{
		a=3;
	}
	if(y==1||y==3||y==5||y==7||y==8||y==10||y==12){
		b = 1;
	}	
	else if(y==4||y==6||y==9||y==11){
		b=2;
	}
	else{
		b=3;
	}
	if(a==b){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include <list>
#include <queue>
#include <vector>
#include <iostream>
using namespace std;
// ------ Class ------ //
class Graph1 {
public:
	// ------ Variables ------ //
	static const int INF = 1000000000;
	int V; vector<vector<int> > G;

	// ------ Constructors ------ //
	Graph1() : V(0), G(vector<vector<int> >()) {}
	Graph1(int v) : V(v), G(vector<vector<int> >(v)) {}
	Graph1(vector<vector<int> > g) : V(g.size()), G(g) {}

	// ------ Basic Functions ------ //
	void add1(int v1, int v2) { G[v1].push_back(v2); }
	void add2(int v1, int v2) { add1(v1, v2); add1(v2, v1); }

	// ------ Algorithms ------ //
	vector<int> dist(int s) {
		queue<int> que; que.push(s);
		vector<int> d(V, INF); d[s] = 0;
		while (!que.empty()) {
			int u = que.front(); que.pop();
			for (int i = 0; i < G[u].size(); i++) {
				if (d[G[u][i]] == INF) {
					d[G[u][i]] = d[u] + 1;
					que.push(G[u][i]);
				}
			}
		}
		return d;
	}
};
int N, Q, c, u, v; Graph1 G;
int main() {
	cin >> N; G = Graph1(N);
	for (int i = 0; i < N; i++) {
		cin >> u >> c;
		for (int j = 0; j < c; j++) {
			cin >> v; G.add1(u - 1, v - 1);
		}
	}
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		cin >> u >> v >> c;
		int d = G.dist(u - 1)[v - 1] + 1;
		if (d > c) cout << "NA" << endl;
		else cout << d << endl;
	}
	return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}






int main() {
   string s,t,u;
   int a,b;
   cin >> s >> t;
   cin >> a >> b;
   cin >> u;

   if (s==u) cout << a-1 << " " << b << endl;
   else cout << a << " " << b-1 << endl;
}

Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,k;
  cin>>n>>k;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  vector<ll> tmp(n+1);
  tmp[0]=0;
  rep(i,n) tmp[i+1]=tmp[i]+v[i];
  vector<ll> ans(n-k+1);
  rep(i,n-k+1) ans[i]=tmp[i+k]-tmp[i];
  ll ans2=0;
  rep(i,n-k+1) chmax(ans2,ans[i]);
  cout<<setprecision(10)<<(double)(0.5*k+ans2*0.5)<<endl;
}

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

int main() {
	int n; cin >> n;
	map<int, int>a; for (int i = 0, tmp; i < n; i++)cin >> tmp, a[tmp]++;
	
	long long ans = 0;
	for (auto&& x : a) {
		if (x.first < x.second)ans += (x.second - x.first);
		else if (x.first > x.second) ans += x.second;
	}
	cout << ans << endl;

	return 0;
}

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

int main(int argc, char **argv)
{
	ll n, m; cin >> n >> m;
	vector<ll> p(m), y(m); for (ll i = 0; i < m; ++i) cin >> p[i] >> y[i], --p[i];

	vector<vector<ll>> vals(n);
	for (ll i = 0; i < m; ++i) vals[p[i]].push_back(y[i]);

	for (ll v = 0; v < n; ++v)
	{
		sort(vals[v].begin(), vals[v].end());
		vals[v].erase(unique(vals[v].begin(), vals[v].end()), vals[v].end());
	}

	for (ll mi = 0; mi < m; ++mi)
	{
		ll city = p[mi];
		std::cout << setw(6) << setfill('0') << city + 1;
		std::cout << setw(6) << setfill('0') <<
			lower_bound(vals[city].begin(), vals[city].end(), y[mi]) - vals[city].begin() + 1
				  << std::endl;
	}
}

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

// Type alias
using ll=long long;
using ld=double;

using pi=pair<int,int>;
using pll=pair<ll,ll>;
using pld=pair<ld,ld>;
using ti3=tuple<int, int, int>;

using vi=vector<int>;
using vll=vector<ll>;
using vld=vector<ld>;
using vpi=vector<pi>;
using vpll=vector<ll>;
using vpld=vector<ld>;
using vti3=vector<ti3>;

// Constants
const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

// Macro
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

#define ALL(a) a.begin(),a.end()

// Funtcions
ll pow(ll base, ll i, ll mod){
  ll a = 1;
  while(i){
    if (i & 1) {
      a *= base;
      a %= mod;
    }
    base *= base;
    base %= mod;
    i >>= 1;
  }
  return a;
}
ll gcd(ll a, ll b){
  while(b){
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}
ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}
template<typename T> bool chmin(T& a, const T& b) {
  if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
  if (a < b) return a = b, true; else return false;
}


void solve(){
  int N, X, Y;
  cin >> N >> X >> Y;

  int count[2*1000 + 5] = {};

  X--;
  Y--;

  rep(i, N){
    int dist[2*1000 + 5];
    memset(dist, -1, (2 * 1000 + 5) * sizeof(int));
    dist[i] = 0;

    queue<int> que;
    que.push(i);
    while(!que.empty()){
      int p = que.front(); que.pop();

      if(p-1 >= 0 && dist[p-1] == -1){
        dist[p-1] = dist[p] + 1;
        que.push(p-1);
      }
      if(p+1 < N && dist[p+1] == -1){
        dist[p+1] = dist[p] + 1;
        que.push(p+1);
      }
      if(p == X && dist[Y] == -1){
        dist[Y] = dist[p] + 1;
        que.push(Y);
      }
      if(p == Y && dist[X] == -1){
        dist[X] = dist[p] + 1;
        que.push(X);
      }
    }

    rep(j, N){
      count[dist[j]]++;
    }
  }

  REP(i, 1, N){
    cout << count[i] / 2 << endl;
  }
}

int main(){
// FastIO
//ios_base::sync_with_stdio(false);
cin.tie(NULL);
  solve();
  return 0;
}

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

using namespace std;
typedef long long LL;
int _max(int x, int y) {return x > y ? x : y;}
const int N = 200001;
const int mod = 924844033;
int read() {
	int s = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
	return s * f;
}
void put(int x) {
	if(x < 0) putchar('-'), x = -x;
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

struct edge {
	int x, y, next;
} e[2 * N]; int len, last[N];
int id, ll[N], rr[N], dep[N];
int xx[N], yy[N], fa[N];
bool v1[N], v2[N];

void ins(int x, int y) {
	e[++len].x = x, e[len].y = y;
	e[len].next = last[x], last[x] = len;
}

void dfs1(int x) {
	ll[x] = ++id;
	for(int k = last[x]; k; k = e[k].next) {
		int y = e[k].y;
		if(y != fa[x]) fa[y] = x, dep[y] = dep[x] + 1, dfs1(y);
	} rr[x] = ++id;
}

void dfs2(int x, int fa, int d) {
	if(d >= dep[x]) return ;
	v2[x] = 1;
	for(int k = last[x]; k; k = e[k].next) {
		int y = e[k].y;
		if(y != fa) {
			dfs2(y, x, d + 1);
		}
	}
}

bool check(int x, int y) {
	if(ll[x] > ll[y]) swap(x, y);
	if(ll[x] < ll[y] && rr[y] < rr[x]) return dep[y]- dep[x] > 2;
	return fa[x] != fa[y];
}

int main() {
	int n = read(), x = read(), y = read();
	for(int i = 1; i < n; i++) xx[i] = read(), yy[i] = read();
	for(int i = 1; i < n; i++) {
		int x = read(), y = read();
		ins(x, y), ins(y, x);
	} dfs1(y);
	len = 0; memset(last, 0, sizeof(last));
	for(int i = 1; i < n; i++) {
		if(check(xx[i], yy[i])) v1[xx[i]] = v1[yy[i]] = 1;
		ins(xx[i], yy[i]), ins(yy[i], xx[i]);
	} dfs2(x, 0, 0);
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		if(v1[i] && v2[i]) {puts("-1"); return 0;}
		if(v2[i]) ans = _max(ans, dep[i] * 2);
	} put(ans), puts("");
	return 0;
}

Measured memory_bytes: 16512
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long;

int main()
{
    int D,T,S;
    cin >> D >> T >> S;
    if(S*T >= D){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
int main(){
  int i,j,multiplication;
  i=1;
  j=1;
  multiplication=0;
  while(i<=9){
    multiplication=i*j;
    printf("%dx%d=%d\n",i,j,multiplication);
    j+=1;
    if(j == 10) {
      i+=1;
      j=1;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int d1[10]={0,0,-1,-1,-1,1,1,1};
int d2[10]={1,-1,0,1,-1,0,1,-1};
char mp[59][59];
int n,m,a[59][59],ans[59][59];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%s",mp[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			a[i][j]=mp[i][j]=='#'?1:0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			for(int k=0;k<8;k++){
				int x=i+d1[k],y=j+d2[k];
				if(a[x][y])ans[i][j]++;
			}		
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)
			if(mp[i][j]!='#')printf("%d",ans[i][j]);
			else printf("#");
		printf("\n");		
	}
	return 0;
}


Measured memory_bytes: 256
//Dragan Andrei Gabriel
//    (-_-)


#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

int n;

int main()
{
    scanf("%d", &n);
    printf("%lld\n", 1LL * n * n);

    return 0;
}


Measured memory_bytes: 128
from collections import deque
class UnionFind:
    """
        n : 要素数
        root : 親ノード
        size : グループのサイズ
    """
    
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.size = [1]*(n+1)
    
    """ノードxのrootノードを見つける"""
    def Find_Root(self, x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    
    """木の合併"""
    def Union(self, x, y):
        #入力ノードの親を探索
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        
        #既に同じ木に所属する場合
        if x==y:
            return 
        
        #異なる木に所属する場合 -> sizeが小さい方から大きい方に合併する
        elif self.size[x] > self.size[y]:
            self.size[x] += self.size[y]
            self.root[y] = x
        
        else:
            self.size[y] += self.size[x]
            self.root[x] = y

n = int(input())
uf = UnionFind(n)
G = [[] for _ in range(n+1)]
for _ in range(n-1):
    a,b = map(int,input().split())
    uf.Union(a,b)
    G[a].append(b)
    G[b].append(a)
rt = uf.root.index(-1)
for idx in range(1, n+1):
    if uf.root[idx] == -1:
        rt = idx-1
        break

c = list(map(int,input().split()))
c.sort(reverse=True)
c = [0] + c
ans = [0]*(n+1)
que = deque([rt])
idx = 1

while que:
    node = que.popleft()
    if ans[node]!=0:
        continue
    else:
        ans[node] = c[idx]
        idx += 1
        for g in G[node]:
            que.append(g)
print(sum(c)-max(c))
print(*ans[1:])

Measured memory_bytes: 62040
#include <iostream>
#include <string>
#define MOD 998244353
using namespace std;

int main() {
  long long N, K; cin >> N >> K;
  long long L[K], R[K];
  for (int i = 0; i < K; i++) cin >> L[i] >> R[i];
  long long dp[N];
  for (int i = 0; i < N; i++) dp[i] = 0;
  dp[0] = 1;
  long long sum[K];
  for (int i = 0; i < K; i++) sum[i] = 0;
  
  for (long long i = 0; i < N; i++){
    if (i != 0){
      for (int j = 0; j < K; j++) dp[i] += sum[j];
      dp[i] %= MOD;
    }
    for (long long j = 0; j < K; j++){
      if (i - L[j] + 1 >= 0) sum[j] = sum[j] + dp[i - L[j] + 1];
      if (i - R[j] >= 0) sum[j] = sum[j] - dp[i - R[j]];
      sum[j] = ((sum[j] % MOD) + MOD) % MOD;
    }
  }
  
  cout << dp[N - 1] << endl;
}

Measured memory_bytes: 5184
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 && i % 5) ans += i;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3188
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    int ans = Integer.MAX_VALUE;
    for(long i = 1; i * i <= N; i++) {
      if(N % i == 0) {
        long b = N / i;
        int digit = 0;
        for(int j = 0; j <= 11; j++) {
          if(b < (long)Math.pow(10, j)) {
            digit = j;
            break;
          }
        }
        ans = Math.min(ans, digit);
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstdlib>
using namespace std;
const int max_n=100;
int main()
{
    int n,h[max_n],tmp,num;
    cin>>n;
    for (int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    tmp = h[0];
    num= 1;
    for (int i=1;i<n ;i++ )
    {
        if(h[i]>=tmp)
            num++;
        if(h[i]>tmp)
            tmp = h[i];
    }
    cout<<num;


    //system("pause");


}


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

int main(void){

  int a, b, c;
  cin >> a >> b >> c;

  if(a > b){
    if(a > c){
      if(a == b+c){
        cout << "Yes" << endl;
        return 0;
      }
    }else{
      if(c == a+b){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }else{
    if(b > c){
      if(b == a+c){
        cout << "Yes" << endl;
        return 0;
      }
    }else{
      if(c == a+b){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner (System.in);
	String str = scan.nextLine();
	StringBuilder sb = new StringBuilder();
	for (int i = str.length()-1; i >= 0; i--) {
	    sb.append(str.charAt(i));
	}
	System.out.println(sb);
    }
}

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

int main(){
    int n;
    string s,t;
    int dp[26]={0};
    cin >> n;
    cin >> s;
    cin >> t;
    dp[s[0]-'a']=1;
    for (int i=1;i<n-1;i++){
        dp[s[i]-'a'] = (dp[s[i]-'a']+dp[t[i]-'a'])%1000000007;
    }
    cout << dp[t[n-1]-'a'] << endl;
    return 0;
}




Measured memory_bytes: 3340
#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 n; cin >> n;
    ll l[n];
    rep(i, n){
        cin >> l[i];
    }

    sort(l, l+n);
    map<ll, ll> lmp;
    rep(i, n){
        lmp[l[i]]++;
    }

    // for(auto x : lmp){
    //     cout << x.first << endl;
    // }

    vector<ll> lunique, lcnt;
    for(auto x : lmp){
        // cout << x.first << endl;
        lunique.push_back(x.first);
        lcnt.push_back(x.second);
    }

    int m = lunique.size();
 
    ll ans = 0;
    rep(i, m){
        reps(j, i, m){
            if(i == j && lcnt[i] < 2) continue;
            reps(k, j, m){
                if(j == k && lcnt[j] < 2) continue;
                if(i == j && j == k && lcnt[i] < 3) continue;

                if(lunique[i] + lunique[j] > lunique[k]){
                    if(i == j && j == k){
                        ans += lcnt[i]*(lcnt[j]-1)/2*(lcnt[k]-2)/3;
                    }
                    else if(i == j){
                        ans += lcnt[i]*(lcnt[j]-1)/2*lcnt[k];
                    }
                    else if(j == k){
                        ans += lcnt[j]*(lcnt[k]-1)/2*lcnt[i];
                    }
                    else{
                        ans += lcnt[i] * lcnt[j] * lcnt[k];
                    } 
                }
                else{
                    break;
                }
            }
        }
    }

    cout << ans;

    return 0;
}

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

using namespace std;

#define PB push_bavck
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

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

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin >> n;
    ll res = (n+2)*(n+1)*n/6;
    for(ll i=0; i<n-1; i++)
    {
        ll u, v;
        cin >> u >> v;
        if(u > v)
            swap(u, v);
        res -= u * (n-v+1);
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 3652
import java.util.*;

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

    long ans = 10000000000l;
    if(H == 2 && W == 2){
      ans = 1;
    }
    for(int i = 1; i <= H-2; i++){
      long h1, h2;
      if((H-i) % 2 == 0){
        h1 = h2 = (H-i)/2;
      }else{
        h1 = (H-i)/2;
        h2 = h1 + 1;
      }
      
      long a1 = Math.max(i*W, Math.max(h1*W, h2*W));
      long a2 = Math.min(i*W, Math.min(h1*W, h2*W));
      
      if(a1-a2 < ans){
        ans = a1 - a2;
      }
    }

    for(int i = 1; i <= W-2; i++){
      long w1, w2;
      if((W-i) % 2 == 0){
        w1 = w2 = (W-i)/2;
      }else{
        w1 = (W-i)/2;
        w2 = w1 + 1;
      }
      long a1 = Math.max(i*H, Math.max(w1*H, w2*H));
      long a2 = Math.min(i*H, Math.min(w1*H, w2*H));
      if(a1-a2 < ans){
        ans = a1 - a2;
      }
    }
    
    for(int i = 1; i <= H-2; i++){
      long w1, w2;
      if(W % 2 == 0){
        w1 = w2 = W/2;
      }else{
        w1 = W/2;
        w2 = w1 + 1;
      }
      long a1 = Math.max(i*W, Math.max(w1*(H-i), w2*(H-i)));
      long a2 = Math.min(i*W, Math.min(w1*(H-i), w2*(H-i)));
      
      if(a1-a2 < ans){
        ans = a1 - a2;
      }
    }
    
    for(int i = 1; i <= W-2; i++){
      long h1, h2;
      if(H % 2 == 0){
        h1 = h2 = H/2;
      }else{
        h1 = H/2;
        h2 = h1 + 1;
      }
      long a1 = Math.max(i*H, Math.max(h1*(W-i), h2*(W-i)));
      long a2 = Math.min(i*H, Math.min(h1*(W-i), h2*(W-i)));
      if(a1-a2 < ans){
        ans = a1 - a2;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22228
#include <stdio.h>
#define mod 1000000007
typedef long long ll;

int main(void) {
  ll i, n, cnt[26];
  scanf("%lld", &n);
  for(i = 0; i < 26; ++i) cnt[i] = 0;
  char s[n + 10], t[n + 10];
  scanf("%s%s", s, t);
  cnt[t[n - 1] - 'a'] = 1;
  for(i = n - 2; i > 0; --i) {
    cnt[t[i] - 'a'] += cnt[s[i] - 'a'];
    cnt[t[i] - 'a'] %= mod;
  }
  printf("%lld\n", cnt[s[i] - 'a']);
  return 0;
}


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

 int main(){
while(1){
int H,W;
cin>>H>>W;
 if(H == 0 && W == 0) break;

  for (int i=0;i<H;i++){
   for (int j=0;j<W;j++){
    cout<<"#";
   } 
   cout<<endl;
  }
  cout<<endl;
 }
 return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;

int main()
{
	string s;
	ll ans=0;
	cin>>s;
	if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3])
		cout<<"Bad"<<endl;
	else
		cout<<"Good"<<endl;
	//cout<<ans<<endl;
	return 0;
}

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

using namespace std;

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

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

    int a_max = *max_element(a.begin(), a.end());

    vector<long long> b(2 * a_max + 1, 0);
    for (int i = 0; i < n; i++) {
        b[a[i]]++;
    }
    for (int i = a_max; i > 0; i--) {
        b[i - 1] += b[i];
    }

    vector<long long> c(2 * a_max + 1, 0);
    for (int i = 0; i < n; i++) {
        c[a[i]] += a[i];
    }
    for (int i = a_max; i > 0; i--) {
        c[i - 1] += c[i];
    }

    int left = 0, right = 2 * a_max;
    while (left < right) {
        int mid = (left + right + 1) / 2;

        long long cnt = 0;
        for (int i = 0; i < n; i++) {
            cnt += b[max(mid - a[i], 0)];
        }

        if (cnt >= m) {
            left = mid;
        } else {
            right = mid - 1;
        }
    }

    long long res = 0, cnt = 0;
    for (int i = 0; i < n; i++) {
        res += a[i] * b[max(left - a[i], 0)] + c[max(left - a[i], 0)];
        cnt += b[max(left - a[i], 0)];
    }
    res += left * (m - cnt);

    cout << res << endl;
}


Measured memory_bytes: 3712
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)

from collections import defaultdict

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

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

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

    return arr

N = ii()
d = defaultdict(int)
for i in range(2, N+1):
    for l in factorization(i):
        d[l[0]] += l[1]
#print(d)
ans = 1
INF = 10**9+7

for key in d:
    #ans = (ans * (d[key]+1))%INF
    ans = (ans * (d[key]+1))

ans = ans%INF
          
print(ans)


Measured memory_bytes: 3548
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
using namespace std;

int main() {
    int n;
    cin >> n;
    deque<int>ans;
    vector<int>a(n+1);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (n % 2 == i % 2)ans.push_back(a);
        else ans.push_front(a);
    }

    for (int i = 0; i < n; i++) {
        cout << ans[i] << " ";
    }
    
    
    return 0;

}

Measured memory_bytes: 3840
s=input()
q=int(input())
head=''
foot=''

a=0
for i in range(q):
  t=input()
  if t=='1':
    a=a^1
  else:
    t, f, c = map(str, t.split())
    f=int(f)
    if (f^a)&1==0:
      foot+=c
    else:
      head=c+head
s=head+s+foot
if a==1:
  s=s[::-1]
print(s)

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

int main() {
    long long h, m, s;
    cin >> s;
    h = s / 3600;
    s -= h * 3600;
    m = s / 60;
    s -= m * 60;
    cout << h << ":" << m << ":" << s << "\n";
    return 0;
}


Measured memory_bytes: 3088
N,H=map(int,input().split())
B=[]
A=0
for _ in range(N):
    a,b=map(int,input().split())
    A=max(A,a)
    B.append(b)
B.sort(reverse=True)
ans=(H-1)//A+1
for i in range(N):
    H-=B[i]
    if H<=0:
        ans=min(ans,i+1)
        break
    ans=min(ans,(H-1)//A+1+i+1)
print(ans)


Measured memory_bytes: 13132
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main(void){
    int N; cin >> N;
    int pay = (N / 1000 + (N % 1000 ? 1 : 0)) * 1000;
    cout << (pay - N) << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define pii pair<int, int>
#define forr(i,a,n) for (int i = (a); i < (n); ++i)
#define rforr(i,a,n) for (int i = (a); i > (n); --i)
#define ALL(x) x.begin(),x.end()
#define LEN(X) ((int)(X).size())
#define CASET int _T; cin >> _T; forr(caset,0,_T)
#define int ll

int mod = 1000000000+7;

signed main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    //freopen("input.txt","w",stdout);
    int n,k; cin >> n >> k;
    int ans = 0;
    // 0,1,..,n
    forr(i,k,n+2) {
        // choose i
        int lo = i*(i-1)/2;
        int hi = (2*n-i+1)*i/2;
        ans += hi-lo+1;
        ans = ans % mod;
    }

    cout << ans << '\n';
}

Measured memory_bytes: 3640
# include <bits/stdc++.h>
 
/*
// ordered_set 
# 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> 
*/
 
using namespace std;
 
typedef long long                                        ll;
typedef long double                                      ld;
typedef pair <int, int>                                  pii;
typedef pair <pii, int>                                  ppi;
typedef pair <int, pii>                                  pip;
typedef pair <pii, pii>                                  ppp;
typedef pair <ll, ll>                                    pll;
 
# define A                                               first
# define B                                               second
# define endl                                            '\n'
# define sep                                             ' '
# define all(x)                                          x.begin(), x.end()
# define kill(x)                                         return cout << x << endl, 0
# define SZ(x)                                           int(x.size())
# define Sort(x)                                         sort(all(x))
# define InTheNameOfGod                                  ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
 
ll power(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));}
 
const int xn = 1e6 + 10;
const int xm = - 20 + 10;
const int SQ = 320;
const int sq = 320 + 10;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const int mod = 998244353;
const int TM = 3;
const int base = 257;

ll n, a[xn], b[xn], c[xn], cnt[xn], ans, inv = power(2, mod - 2, mod);
vector <int> magh[xn], vec[xn];

int main(){
    InTheNameOfGod;
    
	cin >> n;
	for (int i = 1; i <= n; ++ i){
		cin >> a[i];
		++ cnt[a[i]];
	}
	for (int i = 1; i < xn; ++ i){
		for (int j = i; j < xn; j += i){
			b[i] = (b[i] + c[i] * j % mod * cnt[j] % mod) % mod;
			b[i] = (b[i] + (cnt[j] * (cnt[j] - 1) / 2) * j % mod * j % mod) % mod;
			c[i] = (c[i] + j * cnt[j] % mod) % mod;
		}
	}
	for (int i = xn - 1; i >= 1; -- i){
		for (int j = i + i; j < xn; j += i) b[i] = (b[i] - b[j] + mod) % mod;
		ans = (ans + ll(b[i]) * power(i, mod - 2, mod) % mod) % mod;
	}
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 75512
package main

import (
	"fmt"
)

func main() {
	var d, n int
	fmt.Scan(&d, &n)
	if d == 0 {
		fmt.Println(n + n/100)
		return
	}
	if d == 1 {
		fmt.Println(100*n + n/100*100)
		return
	}
	fmt.Println(10000*n + n/100*10000)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll n,smn=10000000000,mn;
  vector<ll> a(n);
  cin>>n;
  for(ll i=0;i<n;i++){
    scanf("%lld",&a[i]);
  }for(ll p=1;p<101;p++){
    mn=0;
    for(ll i=0;i<n;i++){
      mn+=pow(a[i]-p,2);
    }
    smn=min(smn,mn);
  }
  cout<<smn<<endl;
}

Measured memory_bytes: 33024
while True:
    H,W=map(int,input().split())
    if  H==0 and  W==0:
        break
    else:
        for i in range(1,H+1):
            
            if i==1 or i==H:
                for l in range(1,W+1):
                    print("#",end="")
                print()
            else:    
                for l in range(1,W+1):
                    if l==1 or l==W:
                        print("#",end="")
                    else:
                        print(".",end="")
                print()
        print()
        


Measured memory_bytes: 7004
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;cin>>a>>b>>c>>d;
  string ans = "No";
  if (abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)) ans = "Yes";
  cout << ans << endl;
      
}

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

#define ll long long
using namespace std;

int k, N, ans, ara[200000+3], hi;

int main()
{
  cin >> k >> N >> ara[ 0 ];
  
  for (int i=1; i<N; i++){
    cin >> ara[ i ];
    hi = max( hi, abs( ara[ i ] - ara[ i - 1 ] ) );
  }
  
  hi = max( hi, k - ara[ N - 1 ] + ara[ 0 ] );
 
  cout << k - hi << "\n";
  
  return 0;
}

Measured memory_bytes: 1024
N = int(input())
a = list(map(int, input().split()))

b = [0] * N

for i in range(N//2, N) :
    b[i] = a[i]

for i in range(0, N//2)[::-1] :
    buf = 0
    for j in range(1, N//(i+1)) :
        buf += b[(i+1)*(j+1) - 1]
    buf += a[i]
#    if i == 0 :
#        print(i, buf, a[i])
    if buf % 2 == a[i] :
        b[i] = a[i]
    else :
        if a[i] == 1 :
            b[i] = 0
        if a[i] == 0 :
            b[i] = 1
#        if i == 0 :
#            print(a[i], b[i])
#print(b)
ans = []
cnt = 0

for i in range(N) :
    if b[i] == 1 :
        ans.append(i+1)
        cnt += 1

print(cnt)
for i in range(len(ans)) :
    print(ans[i], end=" ")
if len(ans) > 0 :
    print()


Measured memory_bytes: 12084
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n; cin>>n;
  string s; cin>>s;
  string s1,s2;
  s1=s.substr(0,n/2);
  s2=s.substr(n/2,n/2);

  if(n%2==1){
      cout<<"No"<<endl;
  }
  else if(s1==s2){
      cout<<"Yes"<<endl;
  }
  else{
      cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
	int n,ans=0;
	cin>>n;
	int a[n];
	for (int i=0;i<n;i++) {
		cin>>a[i];
	}
	for (int i=0;i<n-1;i++) {
		for (int j=i+1;j<n;j++) {
			ans+=a[i]*a[j];
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
from collections import deque
import copy

def main():
    h, w = map(int, input().split())
    a = [[j == "#" for j in input()] for _ in range(h)]


    # スタート地点をqueueに追加
    que = deque([(i, j) for i in range(h) for j in range(w) if a[i][j]])

    count = 0
    while True:
        count += 1
        nque = deque()
        while que:
            y, x = que.popleft()
            if x > 0 and not a[y][x-1]:
                a[y][x-1] = True
                nque.append((y,x-1))
            if x < w-1 and not a[y][x+1]:
                a[y][x+1] = True
                nque.append((y,x+1))
            if y > 0 and not a[y-1][x]:
                a[y-1][x] = True
                nque.append((y-1,x))
            if y < h-1 and not a[y+1][x]:
                a[y+1][x] = True
                nque.append((y+1,x))

        if nque:
            que = copy.copy(nque)
        else:
            break

    print(count - 1)

if __name__ == "__main__":
    main()

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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  sort(S.begin(), S.end());
  for (int i = 0; i < N; i++) {
    cout << S.at(i);
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T = ll> constexpr T TEN(int n) {return (n==0)?1:10*TEN<T>(n-1);}

ll f(ll b, ll n) {
    ll ans = 0;
    while (n) {
        ans += n%b;
        n /= b;
    }
    return ans;
}

int main() {
    ll n, s;
    cin >> n >> s;
    for (ll b = 2; b <= TEN(6); b++) {
        if (f(b, n) == s) {
            cout << b << endl;
            return 0;
        }
    }
    ll ans = TEN(18);
    if (n == s) ans = n+1;
    for (ll u = 1; u <= TEN(6); u++) {
        // u, s-u
        // u * b + (s-u) = n
        // b = (n-s)/u + 1
        ll b = (n-s)/u + 1;
        if (b < 2) continue;
        if (f(b, n) != s) continue;
        ans = min(ans, b);
    }
    if (ans == TEN(18)) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
count = 0
ans = 0
sum_h = 0

for i in range(1,n):
    for j in range(i):
        if h[j] > h[i]:
            break
        if j == i - 1:
            ans += 1
print(ans+1)
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define debug(x) cout << #x " = " << (x) << '\n';
#define P(x) cout << #x << '\n';    
#define int long long
typedef pair<int, int> pii;
const int mod = 1000000007;
 
int modpow(int x, int y, int p = mod) 
{ 
    int res = 1;       
	x %= p;   
	while (y > 0) 
    { 
        if (y & 1) 
            res = (res * x) % p; 
		y >>= 1;
        x = (x * x) % p;   
    } 
    return res; 
} 
int add(int x, int y) {
	return (x + y) % mod;
}
int sub(int x, int y) {
	x -= y;
	if (x < 0) return x + mod;
	return x;
}
int inv(int a, int m = mod)
{
	return modpow(a, m - 2, m);
}
int mul(int a, int b) 
{
	a %= mod;
	b %= mod;
	return (long long) a * b % mod;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
	
	int n;
	cin >> n;
	vector<int> a(n + 10);
	for(int i = 0; i < n; ++ i)
	{
		cin >> a[i];
	}
	int ans = 0;
	for(int i = 0; i <= 60; ++ i)
	{
		vector<int> cnt = {0, 0};
		for(int j = 0; j < n; ++ j)
		{
			if(a[j] & (1LL << i))
				++ cnt[1];
			else
				++ cnt[0];
		}
		ans = add(ans, mul(cnt[0], mul(cnt[1], (1LL << i))));
	}
	cout << ans << '\n';
}
 

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int w,h;
char ma[30][30];
int b[30][30];
int cnt;
int dfs(int sy,int sx){
    for(int i=0;i<4;i++){
        int ny=sy+dy[i],nx=sx+dx[i];
        if(ny < 0 || ny > h - 1 || nx < 0 || nx > w - 1 || b[ny][nx]==1 || ma[ny][nx]=='#'){continue;}
        b[ny][nx]=1;
        cnt++;
        dfs(ny,nx);
    }
    return cnt;
}
int main(){
    while(1){
        cin>>w>>h;
        if(w==0 && h==0){
            break;
        }
        int sx,sy;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>ma[i][j];
                if(ma[i][j]=='@'){
                    sy=i;
                    sx=j;
                }
            }
        }
        cnt=1;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                b[i][j]=0;
            }
        }
        b[sy][sx]=1;
        cout<<dfs(sy,sx)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3004
/*
	Name: Various Sushi
	Author: Jerryjiang090210
	Date: 30/06/19 16:20
	Description: Jerryjiang090210's code <Various Sushi>
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=(1e5+10);
struct st
{
	int kt,d;
}a[maxn];
bool cmp(st x,st y)
{
	return (x.d>y.d);
}
ll n,k,ans=0,now=0,tp=0,cnt=0;
stack<ll> s;
bool vis[maxn];
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i].kt>>a[i].d;
	sort(a,a+n,cmp);
	for(int i=0;i<n;i++)
	{
		if(cnt<k)
		{
			if(!vis[a[i].kt])
			{
				vis[a[i].kt]=true;
				++tp;
			}
			else
			{
				s.push(a[i].d);
			}
			++cnt;
			now+=a[i].d;
			ans=max(ans,now+tp*tp);
		}
		else
		{
			if(s.empty())
				break;
			if(vis[a[i].kt])
				continue;
			vis[a[i].kt]=true;
			++cnt;
			now-=s.top();
			s.pop();
			now+=a[i].d;
			++tp;
			ans=max(ans,now+tp*tp);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int a,b,h; cin>>a>>b>>h;
    cout<<(a+b)*h/2<<endl;
}


Measured memory_bytes: 764