akhauriyash/Code-Regression huggingface dataset:
from sys import exit

N, M = map(int, input().split())

L = []
R = []

for i in range(M):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

l_max = max(L)
r_min = min(R)

if (r_min - l_max) < 0:
    print(0)
else:
    print(r_min - l_max + 1)


Measured memory_bytes: 10996
#include <stdio.h>

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main() {
    int N;
    string S, T;
    cin >> N;
    cin >> S >> T;

    string res;
    for (int i = 0; i < N*2; i++) {
        if (i % 2 == 0) {
            res = res + S[i / 2];
        } else {
            res = res + T[i / 2];
        }
    }
    cout << res << endl;

    return 0;
}


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

int main(){
    int n,k,ct = 0;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        ct += (x >= k);
    }
    cout<<ct;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    
     
    public static void main(String[] args) {
    	Main app = new Main();
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int n = sc.nextInt(),left = 0,ans = 0,end,sta; 
            if(n == 0)break;
            double[][] p = new double[n][2];
            
            for(int i=0;i<n;i++){
                String[] s = sc.next().split(",");
                p[i][0] = Double.parseDouble(s[0]);
                p[i][1] = Double.parseDouble(s[1]);
            }
            
            
            
            
            boolean[] judge1 = new boolean[n];
            for(int i=1;i<n;i++){
            	if(p[i][0]<p[left][0])left=i;
            }
            judge1[left]=true;
            end = left;
            sta = left;
            
            
            
            
            
            while(true){
                for(int i = 0;i < n;i++){
                    if(sta == i)continue;
                    boolean judge2 = true;
                    for(int j  =0;j  < n;j++){
                        if(j == sta||j == i)continue;
                        if(app.doing(p[sta][0], p[sta][1], p[i][0], p[i][1], p[j][0], p[j][1]) <= 0){
                            judge2 = false;
                            break;
                        }
                    }
                    if(judge2){
                        judge1[i] = true;
                        sta = i;
                        break;
                    }
                }
                if(sta == end)break;
            }
            for(int i = 0;i < n;i++){
            	if(!judge1[i])ans++;
            }
            System.out.println(ans);
        }
    }

    double doing(double x1, double y1, double x2, double y2, double x3, double y3){
        double dx1 = x2-x1,
        	   dy1 = y2-y1,
        	   dx2 = x3-x1,
        	   dy2 = y3-y1;
        return (dx1*dy2)-(dx2*dy1);
    }

}

Measured memory_bytes: 26368
#include <iostream>
#include <cstdio>
int main(){std::string s;while(std::cin>>s){int c[91]={0};for(int i=0;i+2<s.size();i++)s[i+1]==79&&s[i+2]==73&&c[s[i]]++;printf("%d\n%d\n",c[74],c[73]);}}

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

int main(){
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 0;i < s.size();i++){
		if(s[i] == '2')ans++; 
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
inline int in(){int a;scanf("%d",&a);return a;}
inline ll lin(){ll a;scanf("%lld",&a);return a;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

vi G[100010];

int depth[100010];
int par[100010][22];

void lca_dfs(int v, int p, int d)
{
    depth[v] = d;
    par[v][0] = p;

    for (int ch : G[v]) {
        if (ch == p) continue;
        lca_dfs(ch, v, d + 1);
    }
}

void lca_init(int root = 0)
{
    lca_dfs(root, -1, 0);

    rep(i, 20) {
        rep(j, 100010) {
            par[j][i + 1] = par[j][i] == -1 ? -1 : par[par[j][i]][i];
        }
    }
}

int lca(int u, int v)
{
    if (depth[u] > depth[v]) swap(u, v);

    int diff = depth[v] - depth[u];

    rep(i, 20) {
        if (diff >> i & 1) v = par[v][i];
    }

    if (u == v) return u;

    rrep(i, 20) {
        if (par[u][i] != par[v][i]) {
            u = par[u][i];
            v = par[v][i];
        }
    }

    return par[u][0];
}

int main()
{
    int n = in();

    rep(i, n) {
        int k = in();

        rep(j, k) {
            int c = in();

            G[i].PB(c);
            G[c].PB(i);
        }
    }

    lca_init();

    int q = in();

    rep(_, q) {
        int u = in(), v = in();

        printf("%d\n", lca(u, v));
    }
}

Measured memory_bytes: 22340
#include <bits/stdc++.h>
using namespace std;
#define COUT(x) cout<<(x)<<"\n"
#define REP(i,n) for(int i=0;i<n;i++)

int a,b;
const int h=100,w=100;
char g[h][w];

int main() {
  cin >> a >> b;
  a--; b--;

  REP(i,h) REP(j,w) g[i][j] = i<h/2 ? '#' : '.';

  for (int i = 0; i < h; i+=2) {
    if (h/2+2 == i) swap(a,b);
    for (int j = 0; j < w; j+=2) {
      if (a==0) break;
      g[i][j] = g[i][j] == '.' ? '#' : '.';
      a--;
    }
  }

  cout << h << " " << w << endl;
  REP(i,h) REP(j,w) {
    cout << g[i][j];
    j == w-1 && cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

struct edge{
	int from,to,cost;
	edge(int f,int t,int c){from=f,to=t,cost=c;};
};

int main()
{
	int n,m;
	cin>>n>>m;
	vector<vector<int>> g(n,vector<int>(n,1e9+10));
	for (int i = 0; i < n; i++){
		g[i][i] = 0;
	}
	for (int i = 0; i < m; i++){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		g[a][b] = c;
		g[b][a] = c;
	}

	vector<vector<int> >  dist(n,vector<int>(n,1e9+10));
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			dist[i][j] = g[i][j];
		}
	}
	for (int k = 0; k < n; k++){
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < n; i++){
		for (int j = i+1; j < n; j++){
			if(dist[i][j] < g[i][j] && g[i][j]<1e9+10) ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long double PI = 3.14159265358979323846;

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

    int n;
    cin >> n;
    if (n % 10 == 7 || n / 10 % 10 == 7 || n / 100 % 10 == 7) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 3560
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 998244353
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  ll B = 0, G = 0, R = 0, BG = 0, GR = 0, RB = 0;
  ll ans = 1;
  FOR(i, N) { ans = ans * (i + 1) % MOD; }
  FOR(i, 3 * N) {
    char c = S[i];
    if (c == 'R') {
      if (BG > 0) {
        ans = ans * BG % MOD;
        BG--;
      } else {
        if (G > 0) {
          ans = ans * G % MOD;
          G--;
          GR++;
        } else if (B > 0) {
          ans = ans * B % MOD;
          B--;
          RB++;
        } else {
          R++;
        }
      }
    } else if (c == 'G') {
      if (RB > 0) {
        ans = ans * RB % MOD;
        RB--;
      } else {
        if (R > 0) {
          ans = ans * R % MOD;
          R--;
          GR++;
        } else if (B > 0) {
          ans = ans * B % MOD;
          B--;
          BG++;
        } else {
          G++;
        }
      }
    } else {
      if (GR > 0) {
        ans = ans * GR % MOD;
        GR--;
      } else {
        if (R > 0) {
          ans = ans * R % MOD;
          R--;
          RB++;
        } else if (G > 0) {
          ans = ans * G % MOD;
          G--;
          BG++;
        } else {
          B++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
#include <algorithm>


Measured memory_bytes: 900
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int 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;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	ll cost;
	edge(int _t, ll _cost) : t(_t)
		, cost(_cost) {
	}
};


void Solve() {
	int n,k;
	cin >> n >> k;
	ll h[100010];
	for (size_t i = 0; i < n; i++)
	{
		cin >> h[i];
	}
	ll dp[100010];
	for (size_t i = 0; i <= n; i++)
	{
		dp[i] = INF;
	}
	dp[0] = 0;
	for (size_t i = 0; i < n; i++)
	{
		for (size_t j = 1; j <= k; j++)
		{
			if (i + j >= n) break;
			dp[i + j] = min(dp[i + j],dp[i] + abs(h[i + j] - h[i]));
		}
	}
	cout << dp[n - 1] << endl;
}
int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b;
    cin >> a >> b;
    int cnt = 0;
    for (int i = a; i<=b; i++)
    {
	    string x = to_string(i);
	    string y = x;
	    reverse(y.begin(), y.end());
	    if (x == y) cnt ++;
    }
    cout << cnt << endl;

}


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

#define ll long long

typedef pair< int, int > ii;
typedef vector< ii > vii;

void solve(){
	int n, m, c; cin>>n>>m>>c;
	vector< int > b(m);
	for(int &i : b) cin>>i;

	int a[n][m], cnt = 0;
	for(int i = 0; i<n; i++){
		for(int j = 0; j<m; j++){
			cin>>a[i][j];
		}
		int ans = c;
		for(int j = 0; j<m; j++){
			ans += a[i][j] * b[j];
		}
		if(ans > 0){
			cnt++;
		}
	}
	cout<<cnt<<endl;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
         
        using namespace std;
        typedef long long ll;
		vector<vector<ll > > dp(108,vector<ll >(100009,-1));
		ll ans(ll a[][2],ll w,ll i){
         
          if(dp[i][w]!=-1)return dp[i][w];
          if(i==0 || w==0){dp[i][w]=0;return dp[i][w];}
          if(w-a[i-1][0]>=0){dp[i][w]=max(ans(a,w-a[i-1][0],i-1)+a[i-1][1],ans(a,w,i-1));return dp[i][w];}
          else{dp[i][w]=ans(a,w,i-1);return dp[i][w];}
        }
        int main(){
          ll n,w;
          cin>>n>>w;
          ll a[n][2];
          ll sum=0;
          for(int i=0;i<n;i++){cin>>a[i][0]>>a[i][1];}
          ll x=ans(a,w,n);
          cout<<x<<endl;
          }

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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); }
template<class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream& operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto& vv : V) os << vv << ","; os << "]";
  return os;
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int n;
vector<int> t;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
  R(i,n*2){
    int pom;
    cin >> pom;
    t.PB(pom);
  }
  sort(ALL(t));
  int res = 0;
  R(i,n){
    res += t[i*2];
  }
  cout << res << "\n";
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    
    int a,b,c,d;
    cin >>a>>b>>c;
    
    if(a >= c){
        cout<<"0"<<endl;
    }else if(a + b >= c){
        d = c - a;
        cout <<d<<endl;
    }else{
        cout <<"NA"<<endl;
    }
    
}



Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>
#include <functional>
#include <sstream>
#include <cstdio>

using namespace std;

#define ERROR_ID		0

#define PROCESS_ERROR(Condition)    \
{                                   \
		if (!(Condition))           \
		{                           \
			goto Exit0;             \
		}                           \
}

typedef unsigned char			BYTE;
typedef int						BOOL;
typedef unsigned long			DWORD;
typedef unsigned long long		ULLONG;

inline int read() {
	int ret = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-') f = -f;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') ret = ret * 10 + ch - '0', ch = getchar();
	return ret * f;
}//快读优化

int main(int argc, char* argv[])
{
	string			szWordStr;
	int				nLength;

	cin >> szWordStr;

	nLength = szWordStr.size();

	if (szWordStr[0] == szWordStr[nLength - 1])
	{
		if (nLength % 2 == 1)
		{
			cout << "Second" << endl;
		}
		else
		{
			cout << "First" << endl;
		}
	}
	else
	{
		if (nLength % 2 == 1)
		{
			cout << "First" << endl;
		}
		else
		{
			cout << "Second" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 512
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
 
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD=1e9+7;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;

int main(){
	int K,N;
	cin >> K >> N;
	if(K==1){
		rep(i,(N+1)/2)cout<<1<<" ";
		cout<<endl;
		return 0;
	}
	if(K%2==0){
		cout<<K/2<<" ";
		rep(i,N-1){
			cout<<K<<" ";
		}
		cout<<endl;
	}else{
		int a[15];
		rep(i,15)a[i]=(K+1)/2;
		rep(i,N/2){
			int j=0;
			while(a[j]==0)j++;
			if(a[j]==1){
				a[j]--;
			}else{
				a[j]--;
				for(int k=0;k<j;k++){
					a[k]=K;
				}
			}
		}
		vector<int> ans;
		rep(i,N){
			if(i<15)ans.pb(a[i]);
			else ans.pb((K+1)/2);
		}
		reverse(all(ans));
		rep(i,N){
			if(ans[i]!=0)cout<<ans[i]<<" ";
		}
		cout<<endl;
	}

}


Measured memory_bytes: 3568
#include "bits/stdc++.h"

using namespace std;

void solve()
{
	int T;
	cin >> T;
	while(T--)
	{
		long A, B, C, D;
		cin >> A >> B >> C >> D;
		if (A < B || D < B)
		{
			cout << "No" << endl;
			continue;
		}
		long g = __gcd(B, D);
		A = (C+g-A%g)/g*g+A%g;
		//cout << A << ' ';
		cout << (A >= B ? "Yes" : "No") << endl;
	}
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

#define rep(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define repn(i, m, n) for (ll (i) = (m) ; (i) < (ll)(n) ; ++(i))
#define rep_rev(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define repn_rev(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= (m) ; --(i))

#define INF 2e9
#define ll long long
#define MOD 1e9+7

int main(){
    int n;
    cin>>n;
    if(n%2==0){
        cout<<"0.5000000"<<endl;
    } else {
        double ans = (double)((n+1)/2)/n;
        printf("%.7f\n", ans);
    }

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
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 (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール
string jfenize(const string &row) {
    string result = "";
    ll stack = 0;
    REP(i, row.size()) {
        if (row[i] == 'b') {
            if (stack) result += to_string(stack);
            result += 'b';
            stack = 0;
        } else {
            stack++;
        }
    }
    if (stack) result += to_string(stack);
    return result;
}
string parse(const string &jfen) {
    string result = "";
    REP(i, jfen.size()) {
        if ('1' <= jfen[i] && jfen[i] <= '9') {
            result += string(jfen[i] - '0', '.');
        } else if (jfen[i] == 'b') {
            result += 'b';
        }
    }
    return result;
}
vector<string> split(const string &s) {
    vector<string> result;
    string stack = "";
    REP(i, s.size()) {
        if (s[i] != '/') {
            stack += s[i];
        } else {
            result.emplace_back(stack);
            stack.clear();
        }
    }
    if (!stack.empty()) result.emplace_back(stack);
    return result;
}

// 処理内容
int main() {

    string s;
    while (cin >> s, s != "#") {
        
        ll a, b, c, d;
        cin >> a >> b >> c >> d;

        vector<string> tbl = split(s);
        REP(i, tbl.size()) tbl[i] = parse(tbl[i]);

        tbl[a-1][b-1] = '.';
        tbl[c-1][d-1] = 'b';

        REP(i, tbl.size()) tbl[i] = jfenize(tbl[i]);

        ll h = tbl.size();
        REP(i, h) cout << tbl[i] << "/\n"[i == h-1];

    }
    
}


Measured memory_bytes: 3224
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var seqA = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        var ts = new (int L, int R)[seqA.Length];
        for (int i = 0; i < ts.Length; ++i)
        {
            ts[i] = (i + seqA[i], i - seqA[i]);
        }

        var k = 0L;
        var map = new Dictionary<int, int>();
        for (int i = 0; i < ts.Length; ++i)
        {
            k += map.ExistValueOrDefault(ts[i].R);
            map.ModifyExistOrCreateFromDefault(ts[i].L, x => ++x);
        }

        Console.WriteLine(k);
    }
}

static class DictionaryExtension
{
    public static TValue ExistValueOrDefault<TKey, TValue>(this Dictionary<TKey, TValue> dic, TKey key)
    {
        dic.TryGetValue(key, out var x);
        return x;
    }

    public static TValue ModifyExistOrCreateFromDefault<TKey, TValue>(this Dictionary<TKey, TValue> dic, TKey key, Func<TValue, TValue> modification)
    {
        dic.TryGetValue(key, out var x);
        return dic[key] = modification(x);
    }
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> d(K);
    vector<int> ans;
    rep(i, K){
        cin >> d.at(i);
        vector<int> s(d.at(i));
        rep(j, d.at(i)){
            cin >> s.at(j);
            ans.push_back(s.at(j));
        }
    }
    
    //rep(i,ans.size()) cout << ans.at(i);
    //cout << endl;
    int cnt = 0;
    rep(i, N+1){
        rep(j, ans.size()){
            if(i == ans[j]){
                cnt++;
                break;
            }
        }
    }
    
    cout << N - cnt << endl;
}


Measured memory_bytes: 3680
#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>
#include<math.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
int  main(){
  ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	cout.tie(0);
 ull n,i;
  cin>>n;
  ull a[n],b[n+1]={0};
  for(i=0;i<n;i++){
    cin>>a[i];
    b[a[i]]++;
}
   ull sum=0,x;
      for(i=0;i<=n;i++){
        if(b[i]>=2)
          sum=sum+b[i]*(b[i]-1)/2;
      }
      for(i=0;i<n;i++){
        if(b[a[i]]==1||b[a[i]]==0){
          cout<<sum<<endl;}
        else if(b[a[i]]>=2){
          x=sum-b[a[i]]*(b[a[i]]-1)/2+(b[a[i]]-1)*(b[a[i]]-2)/2;
        cout<<x<<endl;}
      }
}


Measured memory_bytes: 5760
//ABC137.cpp
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main(){
	int A,B;
	cin>>A>>B;
	int sum=A+B;
	int dif=A-B;
	int tim=A*B;
	int max=-11000;
	if(max<sum)max=sum;
	if(max<dif)max=dif;
	if(max<tim)max=tim;
	cout<<max<<endl;
	return 0;	
}

Measured memory_bytes: 256
n = int(input())
d = [0]*n
f = [0]*n
G = [[] for _ in range(n)]
for _ in range(n):
    l = list(map(int, input().split()))
    u, k = l[:2]
    l = list(map(lambda x: x-1, l[2:]))
    G[u-1] = l

timestamp = [i+1 for i in range(2*n)]
def dfs(node):
    global d,f,G,timestamp
    if d[node]>0:
        return False
    d[node] = timestamp.pop(0)
    for v in G[node]:
        dfs(v)
    if f[node]==0:
        f[node] = timestamp.pop(0)
    return True
for i in range(n):
    dfs(i)
    
for i in range(n):
    print(i+1, d[i], f[i])


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

using namespace std;

int main() {
	int n, x;
	cin >> n >> x;
	vector<int> m(n);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> m[i];
		sum += m[i];
	}
	sort(m.begin(), m.end());
	int a = x - sum, b = 0;
	while (m[0] <= a) {
		a -= m[0];
		b++;
	}

	cout << n + b << endl;

	return 0;
}

Measured memory_bytes: 256
-module('Main').
-export([main/1]).

solve() ->
    [S] = input("~s"),
    Len = length(lists:filter(fun (Elem) -> Elem =:= $1 end, S)),
    io:format("~B~n", [Len]),
    ok.

main(_) ->
    solve(),
    halt().

input(Pat) ->
    {ok, L} = io:fread("", Pat),
    L.


Measured memory_bytes: 21724
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<vector>
using namespace std;
string sss[12500000];
int main() {

	string s;
	cin >> s;
	int k;
	cin >> k;
	int i, j;
	string ss;
	int l = 0;
	//priority_queue<string, vector<string>, greater<string>> que;
	for (i = 0; i < s.size(); i++) {
		ss = "";
		for (j = i; j < s.size(); j++) {
			ss = ss + s[j];
			sss[l] = ss;
			l++;
			if (j > i + 6)break;
		}
	}
	ss = "";
	sort(sss, sss + l);
	for(i = 0;i<l;i++){
		if (ss != sss[i]) {
			ss = sss[i];
			k--;
			//cout << ss << endl;
		}
		if (k == 0) {
			cout << ss << endl;
			return 0;
		}
	}

}

Measured memory_bytes: 394256
#!/usr/bin/env python3

# N = int(input())
# S = input()
N, T = map(int, input().split())
# A = list(map(int, input().split()))

def main():
    ans = 10000
    for _ in range(N):
        c, t = map(int, input().split())
        if t <= T:
            ans = min(ans, c)
    
    if ans != 10000:
        print(ans)
    else:
        print("TLE")

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <stdio.h>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORa(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define FORs(i,st) for(auto i : st)
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    while(cin>>n, n){
      vector<ll> satisfy(n);
      vector<ll> mask(n);
      FOR(i,0,n){
        ll date;
        cin>>date>>satisfy[i];
        FOR(j,0,date){
          ll s,e;
          cin>>s>>e;
          s-=6;
          e-=6;
          FOR(k,s,e){
            mask[i] |= 1<<k;
          }
        }
      }

      vector<ll> dp(1<<20,0);
      FOR(i,0,n){
        FOR(j,0,1<<16){
          if((mask[i] & j) == 0){
            dp[mask[i]|j] = max(dp[mask[i]|j], satisfy[i] + dp[j]);
          }
        }
      }
      ll res=0;
      FOR(i,0,1<<16){
        res = max(res,dp[i]);
      }
      cout<<res<<endl;
    }
}



Measured memory_bytes: 11312
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	int n;
	cin >> n;
	vector<pair<int,int>> x(n);
	REP(i,n){
		cin >> x[i].first >> x[i].second;
	}
	
	map<pair<int,int>,int> m;
	REP(i,n){
		REP(j,n){
			if(i==j) continue;
			
			int dx = x[i].first - x[j].first;
			int dy = x[i].second - x[j].second;
			m[make_pair(dx,dy)]++;
			
		}
	}
	if(n==1){
		cout << 1 << endl;
		return 0;
	}
	
	int ans=50;
	for(auto l:m){
		// i -> j 
		int res = 0;
		//vector<vector<int>> ok(n,vector<int>(n,0));
		vector<pair<int,int>> check(n,{0,0});
		REP(i,n){
			REP(j,n){
				if(i==j) continue;
				
				if(check[i].second == 1 || check[j].first == 1) continue;
				
				int dx = x[i].first - x[j].first;
				int dy = x[i].second - x[j].second;
				if(dx==l.first.first && dy==l.first.second){
					check[i].second =1;
					check[j].first = 1;
					res++;
				}
				
			}
		}
		
		chmin(ans, n-res);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main()

{
    int x1, x2, y1, y2;
    int x3, y3, x4, y4;
    int sides;
    cin >> x1 >> y1 >> x2 >> y2;

    sides = abs(x1 * x1 + y1 + y1 - x2 * x2 - y2 * y2);
    int yy = y2 - y1;
    int xx = x2 - x1;
    x3 = x2 - yy;
    y3 = y2 + xx;
    x4 = x3 - xx;
    y4 = y3 - yy;
    cout << x3 << " " << y3 << " " << x4 << " " << y4;
}


Measured memory_bytes: 888
#include<iostream>
#include<bits/stdc++.h>
#include<climits>

#define forn(x,n,s) for(int i = x; i < n; i += s )
#define forr(x,n,s) for(int i = x; i>=n; i -= s)

using namespace std;

void go(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
  #endif
}

int main(){
    go();

    // code here
    int n,m,k;cin>>n>>m>>k;
    char arr[n][m];
    for(int i = 0; i < n;i++) for(int j = 0; j < m;j++) cin>>arr[i][j];
    int ans = 0;
    for(int i = 0;i < (1<<n);i++){
        for(int j = 0; j < (1<<m);j++){
            int b = 0;
            for(int row = 0; row < n;row++){
                for(int col = 0; col < m;col++){
                    if((i>>row&1)==0 and (j>>col&1)==0 and arr[row][col]=='#') b++;
                }
            }
            if(b==k) ans++;
        }
    }
    cout<<ans;
}






Measured memory_bytes: 3648
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			BigDecimal a = BigDecimal.valueOf(scanner.nextLong());
			BigDecimal b = new BigDecimal(scanner.next());
			System.out.println(a.multiply(b).setScale(0, RoundingMode.FLOOR));
		}
	}
}


Measured memory_bytes: 36008
// Author: Jashan Bansal
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second	
#define mp make_pair
#define int long long
#define ll long long
#define pii pair<int,int>
#define all(arr) arr.begin(), arr.end()
#define sz(arr) ((long long)arr.size())
// const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
#define log1(x) cout << x << '\n'
#define log2(x,y) cout << x << " " << y <<'\n'
#define log3(x,y,z) cout << x <<" " << y <<" " << z << '\n'
#define logarr(arr,n) for(int __=0; __ < n; __++)	cout << arr[__] << " "; cout << '\n'

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}


void solve(){
	int n; cin >> n;
	vi arr(n);
	for(auto &x: arr) cin >> x;

	vi dp(n+1,0);
	dp[2] = abs(arr[1] - arr[0]);

	for(int i=3; i<=n; i++){
		dp[i] = min(dp[i-1] + abs(arr[i-1] - arr[i-2]), dp[i-2] + abs(arr[i-1] - arr[i-3]));
	}
	cout << dp[n] << "\n";
}
signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t=1;
	// cin>>t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 1792
/*
    title: C.cpp
    author: Akhil
    date: 2020-09-19
    time: 17:38:38
*/

#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <climits>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <numeric>
#include <cmath>
#include <stdio.h>

using namespace std;

int pairs(int n)
{
    int ans = 0; 
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            if (n/i != i) ans += 2;
            else ans += 1;
        }
    }
    return ans;
}

int main()
{
    int n; 
    cin >> n;
    long long ans = 0;
    for (int i = 1; i < n; i++)
    {
        ans += pairs(i); 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
# D - Disjoint Set of Common Divisors
from math import sqrt

def get_gcd(a, b):
    if b == 0:
        return a
    else:
        return get_gcd(b, a % b)

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, K = map(int, input().split())
gcd = get_gcd(N, K)
print(len(factorization(gcd)) + 1) if gcd > 1 else print(1)

Measured memory_bytes: 3064
#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)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
using ll = long long;

int main() {
  char c[2][6];
  rep(i,2)rep(j,3)cin>>c[i][j];
  if(c[0][0]==c[1][2]&&c[0][2]==c[1][0]&&c[0][1]==c[1][1]){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b; cin>>a>>b;
    string s; cin>>s;
    s.at(b-1)=s.at(b-1)-'A'+'a';
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace std;
#define endl '\n'
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define _ <<' '<<
using ll = long long;


signed main(){
	FAST
	ll X;
	cin >> X;
	ll ans;
	while(true){
		bool flag = true;
		for(int i = 2; i<=sqrt(X); i++){
			if(X % i == 0) flag = false;
		}
		if(flag){
			ans = X;
			break;
		}else X++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
typedef long int li;

int main(){
  int order,lim; cin >>order >>lim;
  vector<int> d(order);
  for(int& x: d) cin >>x;
  rep(_,lim){
    int n,x,m; cin >>n >>x >>m;
    li sum=0,ans=0;
    vector<int> dm(order);
    rep(j,order) {
      dm[j]=d[j]%m;
      sum+=dm[j];
      if(df) printf("%d ",dm[j]);
      if(not dm[j]) ans++;
    }
    int q=(n-1)/order,r=(n-1)%order;
    if(df)printf("n-1=%d=%d*%d+%d\n",n-1,order,q,r);
    ans*=q;
    li s=q*sum;
    rep(j,r){
      s+=dm[j];
      if(not dm[j]) ans++;
    }
    s+=x%m;
    if(df) printf("total jump:%ld\n",s);
    ans+=s/m;
    printf("%ld\n",n-1-ans);
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

using Graph = vector<vector<int>>;

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

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

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

    ll ans = INF;
    rep(i,N){
        if (i+K-1 >= N) break;
        ans = min(ans, h[i+K-1]-h[i]);
    }    
    cout << ans << endl;
}



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

int main(){
    int N;
    cin >> N;
    vector<int> x(N),y(N),h(N);
    rep(i,N){
        cin >> x[i] >> y[i] >> h[i];
    }
    for(int cx=0;cx<=100;cx++){
        for(int cy=0;cy<=100;cy++){
            int H;
            for(int i=0;i<N;i++){
                if(h[i]!=0){
                    H = h[i] + abs(x[i]-cx)+abs(y[i]-cy);
                }
            }
            bool flg = true;
            for(int i=0;i<N;i++){
                if(H-abs(x[i]-cx)-abs(y[i]-cy)<=0&&h[i]==0) continue;
                if(h[i] + abs(x[i]-cx)+abs(y[i]-cy)!=H){
                    flg = false;
                }
            }
            if(flg){
                cout << cx << " " << cy << " " << H << endl;
                return 0;
            }
        }
    }
    cout << "ERROR" << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from itertools import permutations
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    mx=[1,1,-1,-1]
    my=[1,-1,1,-1]
    def check(tmp_board):
        for y,x in enumerate(tmp_board):
            d=[1,1]
            for j in range(7):
                for k in range(4):
                    c=[y+d[0]*my[k],x+d[1]*mx[k]]
                    if 0<=c[0]<=7 and 0<=c[1]<=7 and tmp_board[c[0]]==c[1]:
                        return False
                d[0]+=1
                d[1]+=1
        return True
    
    
    k=int(input())
    c=[['.']*8 for _ in range(8)]
    for i in range(k):
        R,C=map(int,input().split())
        c[R][C]='Q'
    yoko=list(range(8))
    tate=list(range(8))
    board=[-1]*8
    try:
        for y,l in enumerate(c):
            for x,s in enumerate(l):
                if s=='Q':
                    tate.remove(y)
                    yoko.remove(x)
                    board[y]=x
        for p in permutations(yoko):
            tmp_board=board[:]
            for i,x in enumerate(tate):
                tmp_board[x]=p[i]
            if check(tmp_board):
                for x in tmp_board:
                    ans=['.']*8
                    ans[x]='Q'
                    print(''.join(ans))
                break
        else:
            raise Exception
    except:
        print('No Answer')

if __name__ == '__main__':
    main()



Measured memory_bytes: 5668
N, Q = map(int, input().split())
route = [[] for _ in range(N)]
count = [0 for i in range(N)]
for i in range(N - 1):
    a, b = map(int,input().split())
    route[a - 1].append(b - 1)
    route[b - 1].append(a - 1)
for i in range(Q):
    p, x = map(int, input().split())
    count[p - 1] += x
check = [(0,-1)]#(now, From)
while check:
    for _ in range(len(check)):
        now, From = check.pop()
        for next in route[now]:
            if next == From:
                continue
            else:
                count[next] += count[now]
                check.append((next, now))
print(' '.join(list(map(str, count))))

Measured memory_bytes: 65308
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = n; i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
	int a;cin >> a;
	cout << a + a*a+a*a*a<<endl;
	return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>

long long int gcd(long long int a, long long int b){
    long long int m,n,r;
    if(a > b){
        m = a;
        n = b;
    }else{
        m = b;
        n = a;
    }
    
    while(n != 0){
        r = m % n;
        m = n;
        n = r;
    }
    
    return m;
}

int main(void){
    long long int a,b,c,d;
    long long int l;
    long long int count;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    
    count = b - a + 1;
    
    //count -= b / c - (a + (c - a) % c) + 1;
    count -= b / c - (a / c + (a % c ? 1 : 0)) + 1;
    //count -= b / d - (a + (d - a) % d) + 1;
    count -= b / d - (a / d + (a % d ? 1 : 0)) + 1;
    l = c / gcd(c,d) * d;
    
    //count += b / l - (a + (l - a) % l) + 1;
    count += b / l - (a / l + (a % l ? 1 : 0)) + 1;
    
    //printf("%lld %lld %lld\n", b / c - (a + (c - a) % c) + 1, b / d - (a + (d - a) % d) + 1, count -= b / l - (a / l + (a % l ? 1 : 0)));
    printf("%lld", count);
    
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;
class Main {

public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
  	int contests = sc.nextInt();
  	int display = sc.nextInt();
  	int inner = 0;
  	if (contests < 10) { 
    	System.out.println((100 * (10 - contests)) + display);
    }
  else System.out.println(display);
}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h> 
using namespace std;
 
bitset<2000007> dp;
int main()
{
    int n;
    cin >> n;
    vector <int> arr(n);
    int sum=0;
    dp[0]=1;
  	for(int i=1;i<=n;i++)
    {
      int x;
      cin>>x;
      sum=sum+x;
      dp=(dp|dp<<x);
    }
  
  int target= (sum+1)/2;
  
  for(int i=target;i<=sum;i++)
  {
    if(dp[i])
    {
      cout<<i;
      break;
    }
  }
  return 0;
}
  	


Measured memory_bytes: 1280
#include<iostream>
#include<math.h>
#include<iomanip>
#include<string.h>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<algorithm>

using namespace std;
int main(){

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

  int sum = 0;
  for(int i = 0; i < 10000; i++){
    sum += c[i];
    c[i] = sum;
  }

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

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



}



Measured memory_bytes: 18776
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
pl P[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N) {
		ll a; cin >> a;
		P[i] = pl(a, 1);
	}
	rep(i, 0, N) {
		ll a; cin >> a;
		P[i + N] = pl(a, -1);
	}
	sort(P, P + 2 * N);
	ll ans = 1, t = 0;
	rep(i, 0, 2 * N) {
		// debug(t);
		if(P[i].sec == 1) {
			if(t < 0) {
				MUL(ans, abs(t));
			}
			t += 1;
		}
		else {
			if(t > 0) {
				MUL(ans, abs(t));
			}
			t -= 1;
		}
	}
	cout << ans << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);

		//入力表示
		String  a = scanner.next();
		String  b = scanner.next();
		
		//文字の繰り返し表示
		String c = "";
		for(int i =0; i<Integer.parseInt(b); i++) {
			c=c+a;
		}
		
		String d = "";
		for (int i =0; i<Integer.parseInt(a); i++) {
			d=d+b;
		}
		
		if (c.compareTo(d) == 0) {
			System.out.println(c);
	
		}
		if (c.compareTo(d) < 0) {
			System.out.println(c);
		}
		
		if (c.compareTo(d) > 0) {
			System.out.println(d);
		}

		scanner.close();
	}
}


Measured memory_bytes: 21076