akhauriyash/Code-Regression huggingface dataset:
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    vector<ll> L, R;
    rep (i, M) {
        ll l, r;
        cin >> l >> r;
        L.pb(l);
        R.pb(r);
    }
    sort(rall(L));
    sort(all(R));
    cout << max(0ll, R[0] - L[0] + 1ll) << endl;
}


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

auto chmin = [](auto&& a, auto b) { return b < a ? a = b, 1 : 0; };

template <class T> struct dijkstra {
  struct edge {
    int to;
    T w;
  };
  vector<vector<edge>> g;
  const T inf;
  dijkstra(int n, T _inf = numeric_limits<T>::max()) : g(n), inf(_inf) {}
  void add_edge(int from, int to, T w) { g[from].push_back({to, w}); }
  void add_undirected_edge(int u, int v, T w) {
    add_edge(u, v, w), add_edge(v, u, w);
  }
  vector<T> run(int s) const {
    vector<T> dist(g.size(), inf);
    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<>> pq;
    pq.emplace(dist[s] = 0, s);
    while (not pq.empty()) {
      T d;
      int v;
      tie(d, v) = pq.top(), pq.pop();
      if (d > dist[v]) continue;
      for (auto e : g[v])
        if (chmin(dist[e.to], dist[v] + e.w)) pq.emplace(dist[e.to], e.to);
    }
    return dist;
  }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (auto&& e : s) {
    cin >> e;
  }
  dijkstra<int> g(h * w);
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (i + 1 < h) {
        g.add_edge(i * w + j, (i + 1) * w + j, s[i][j] == '.' and s[i + 1][j] == '#');
      } 
      if (j + 1 < w) {
        g.add_edge(i * w + j, i * w + (j + 1), s[i][j] == '.' and s[i][j + 1] == '#');
      }
    }
  }
  int res = (s[0][0] == '#') + g.run(0).back();
  cout << res << '\n';
}


Measured memory_bytes: 896
str_in = input()
num = [int(n) for n in str_in.split()]
num = num =list(map(int, str_in.strip().split()))
# X,T,N
#(N/X)*T
N = num[0]
X = num[1]
T = num[2]
if N%X == 0:
    print((N//X)*T)
else:
    print((N//X+1)*T)

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

#define int long long

int N;
int a[200010];
multiset<int> st;

main()
{
	ios::sync_with_stdio(false);
	
	cin>>N;
	for(int i=1;i<=N;i++)
	{
		cin>>a[i];
		st.insert(a[i]);
	}
	
	int ans=0;
	while(!st.empty())
	{
		auto it=st.end(); it--;
		int x=*it;
		st.erase(it);
		int t=1;
		while(t<=x) t*=2;
		if(st.find(t-x)!=st.end())
		{
			st.erase(st.find(t-x));
			ans++;
		}
	}
	cout<<ans;
}








Measured memory_bytes: 11264
#include<cstdio>

int comparedice(void);
class dice{
private:
	int a,b,c,d,e,f;
public:
	void setnumber(void);
	void E(void);
	void W(void);
	void S(void);
	void N(void);
	void R(void);
	void V(void);
	int frontside(int x,int y);
	int putme(char me);
};

void dice::setnumber(void){
scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
}


void dice::E(void){
int a1=a,c1=c,d1=d,f1=f;
a=d1;
c=a1;
d=f1;
f=c1;
}

void dice::W(void){
int a1=a,c1=c,d1=d,f1=f;
a=c1;
c=f1;
d=a1;
f=d1;
}

void dice::S(void){
int a1=a,b1=b,e1=e,f1=f;
a=e1;
b=a1;
e=f1;
f=b1;
}

void dice::N(void){
int a1=a,b1=b,e1=e,f1=f;
a=b1;
b=f1;
e=a1;
f=e1;
}

int dice::frontside(int x,int y){
int i=0,a1,b1,c1,d1,e1,f1;
while(1){
	a1=a;
	b1=b;
	c1=c;
	d1=d;
	e1=e;
	f1=f;
	a=b1;
	b=c1;
	c=a1;
	d=f1;
	e=d1;
	f=e1;
	i++;
	if(i==4)break;
}

if (b!=x){
	a=e1;
	b=f1;
	c=d1;
	d=c1;
	e=a1;
	f=b1;
}
//printf("%d %d %d %d %d %d\n",a,b,c,d,e,f);
i=0;
while (b!=x){
	a1=a;
	b1=b;
	c1=c;
	d1=d;
	e1=e;
	f1=f;
	a=b1;
	b=c1;
	c=a1;
	d=f1;
	e=d1;
	f=e1;
	i++;
	if(i==4)break;
}
if(i==4){ return 0;}
i=0;
while(c!=y){
	a1=a;
	c1=c;
	d1=d;
	f1=f;
	a=d1;
	c=a1;
	d=f1;
	f=c1;
	i++;
	if(i==5) break;
}
if(i==5) {return 0;}
return 1;
}

int dice::putme(char me){
if(me=='a'){
return a;
}else if(me=='b'){
return b;
}else if(me=='c'){
return c;
}else if(me=='d'){
return d;
}else if(me=='e'){
return e;
}else {
return f;
}
}

dice koro1,koro2;

int main(void){

char ch[101];
int i,j;
koro1.setnumber();
koro2.setnumber();
for(i=0;i<3;i++){
	for(j=0;j<4;j++){
		if (comparedice()==0){
			printf("Yes\n");
			return 0;
		}
		koro2.E();
	}
koro2.E();
koro2.N();
}
koro2.N();
koro2.E();
koro2.E();
for(i=0;i<3;i++){
	for(j=0;j<4;j++){
		if (comparedice()==0){
			printf("Yes\n");
			return 0;
		}
		koro2.E();
	}
koro2.E();
koro2.N();
}
printf("No\n");
return 0;
}

int comparedice(){
if(
	(koro1.putme('a')==koro2.putme('a'))
	&&(koro1.putme('b')==koro2.putme('b'))
	&&(koro1.putme('c')==koro2.putme('c'))
	&&(koro1.putme('d')==koro2.putme('d'))
	&&(koro1.putme('e')==koro2.putme('e'))
	&&(koro1.putme('f')==koro2.putme('f'))
	){
return 0;
}else {return 1;}
}
		

Measured memory_bytes: 2620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> g[200005];
ll col[200005];
ll son[200005];
ll colson[200005];
ll ans[200005];
ll n;
ll f(ll n)
{
	return n*(n+1)/2;
}
void dfs(ll u,ll par)
{
	ll temp=colson[col[u]];
	for(ll i=0;i<g[u].size();i++)
	{
		ll v=g[u][i];
		if(v==par) continue;
		colson[col[u]]=0;
		dfs(v,u);
		son[u]+=son[v];
		ans[col[u]]-=f(son[v]-colson[col[u]]);
	}
	colson[col[u]]=temp+son[u];
}
int main(void)
{
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++)
	{
		scanf("%lld",&col[i]);
		son[i]=1;
		ans[i]=f(n);
	}
	for(ll i=0;i<n-1;i++)
	{
		ll u,v;
		scanf("%lld%lld",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1,0);
	for(ll i=1;i<=n;i++)
	{
		printf("%lld\n",ans[i]-f(n-colson[i]));
	}
}

Measured memory_bytes: 39696
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
const double pi = 3.141592653589793;
int main(){
    int64_t a;
    string b;
    cin>>a;
    cin>>b;
    int64_t sei = b[0]-'0';
    int64_t sho = (b[2]-'0')*10+(b[3]-'0');
    //cout<<b-sei<<endl;
    //cout<<sei<<" "<<sho<<endl;
    cout<<(a*sei)+(a*sho/100)<<endl;
    //cout<<int64_t(a*b)<<endl;
    //cout<<a*b<<endl;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int len, target;
    cin >> len >> target;
    vector<int> arr(len);
    for(int i = 0; i < len; i++) {
        cin >> arr[i];
    }
    int ans = INT_MAX;
    for(int i = 0; i <= len - target; i++) {
        int small = arr[i], big = arr[i + target - 1];
        if(small < 0 && big > 0) {
            small = abs(small);
            big = abs(big);
            int curr = (2 * min(big, small)) + max(big, small);
            ans = min(ans, curr);
        } else {
            ans = min(ans, max(abs(big), abs(small)));
        }
    }
    cout << ans;
}


Measured memory_bytes: 3724
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		
		int ans = 0;
		for (int i = 0; i <= A; i++){
			for (int j = 0; j <= B; j++){
				for (int k = 0; k <= C; k++){
					if(X == i*500+j*100+k*50){
						ans++;
					}
				}
			}
		}
		System.out.println(ans);
	}
}

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

int main(){
    int n;
    cin>>n;
    int a[n];
    int maxv=0;
    for(int i=0;i<n;i++)cin>>a[i];
    long long ans=0;
    for(int i=0;i<n;i++){
        if(maxv<=a[i]){
            maxv=max(maxv,a[i]);
        }else {
            ans+=maxv-a[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(void){
    int n, tmp;
    vector<int> s;
    cin >> n;
    for (int i=0; i<n; i++){
        cin >> tmp;
        s.emplace_back(tmp);
    }
    int sum = accumulate(s.begin(), s.end(), 0);
    if (sum % 10 != 0){
        cout << sum << endl;
    } else{
        sort(s.begin(), s.end());
        bool flag = true;
        for (int i=0; i<s.size(); i++){
            if ((sum - s[i]) % 10 != 0){
                sum -= s[i];
                flag = false;
                break;
            }
        }
        cout << (flag ? 0 : sum) << endl;
    }
    return 0;
}

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

using namespace std;

int main() {

	int n,m,c;
	cin >> n >> m >> c;

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

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

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

int n;
const int maxn = 1e5 + 5;
int a[maxn], k;

int gcd(int x, int y){
    return y == 0 ? x : gcd(y, x % y);
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    int g = 0;
    int mx = 0;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
        g = gcd(g, a[i]);
        mx = max(mx, a[i]);
    }
    if(mx < k){
        cout << "IMPOSSIBLE" << endl;
    }else{
        if((mx - k) % g == 0){
            cout << "POSSIBLE" << endl;
        }else{
            cout << "IMPOSSIBLE" << endl;
        }
    }
    return 0;
}


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

const long long MOD = 1000000007;
const long long MAX = 2000000;

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

int main()
{
    string N;
    cin>>N;
    if(N[N.size()-1]=='2'||N[N.size()-1]=='4'||N[N.size()-1]=='5'||N[N.size()-1]=='7'||N[N.size()-1]=='9'){
        cout<<"hon"<<endl;
    }else if(N[N.size()-1]=='0'||N[N.size()-1]=='1'||N[N.size()-1]=='6'||N[N.size()-1]=='8'){
        cout<<"pon"<<endl;
    }else{
        cout<<"bon"<<endl;
    }

}


Measured memory_bytes: 3596
// dp[i][j] := (i-1)番目(i は 0-indexed)までの魔法を行使してj体力を削った時の最小消費MP
// 初期値 dp[i][j] = INF ただし、 dp[0][0] = 0
// (i >= 1) 
//      (j <= A[i-1]) dp[i][j] = min(dp[i-1][j], B[i-1])
//      (j >  A[i-1]) dp[i][j] = min(dp[i-1][j], dp[i][j-A[i-1]] + B[i-1])
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

const int INF = 1000000100;
const int MAX_N = 1100;
const int MAX_H = 10100;
int A[MAX_N], B[MAX_N];
int H, N;
int dp[MAX_N][MAX_H];

int main()
{
    scanf("%d %d", &H, &N);
    for(int i = 0; i < N; ++i) scanf("%d %d", &A[i], &B[i]);
    
    for(int i = 0; i <= N; ++i) for(int j = 0; j <= H; ++j) dp[i][j] = INF;
    dp[0][0] = 0;
    for(int i = 1; i <= N; ++i) {
        for(int j = 0; j <= H; ++j) {
            if(j < A[i-1]) dp[i][j] = min(dp[i-1][j], B[i-1]);
            else dp[i][j] = min(dp[i-1][j], dp[i][j-A[i-1]] + B[i-1]);
        }
    }
    printf("%d\n", dp[N][H]);
    return 0;
}

Measured memory_bytes: 41216
N,M = gets.split.map(&:to_i)

z = Array.new(N+1)

1.upto(N) do |i|
	z[i] = gets.to_i
end

1.upto(M) do |k|
	1.upto(N-1) do |i|
		if z[i]%k>z[i+1]%k
			tmp = z[i]
			z[i] = z[i+1]
			z[i+1] = tmp
		end
	end
end

1.upto(N) do |i|
	puts z[i]
end

Measured memory_bytes: 8640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

int main(int argc, char *argv[]){
    int h, w; cin >> h >> w;
    vector<string> S(h); rep(i, h) cin >> S[i];
    bool flag = true;
    rep(i, h){
        rep(j, w){
            if(S[i][j] == '#'){
                bool flag2 = false;
                rep(d, 4){
                    if(i + dy[d] < 0 || j + dx[d] < 0 || i + dy[d] >= h || j + dx[d] >= w) continue;
                    if(S[i + dy[d]][j + dx[d]] == '#') flag2 = true;
                }
                if(!flag2) flag = false;
            }
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
grade :: Int -> Int -> Int -> String
grade m f r
  | m == -1 || f == -1 = "F"
  | 80 <= t            = "A"
  | 65 <= t            = "B"
  | 50 <= t            = "C"
  | 30 <= t            = if 50 <= r then "C" else "D"
  | otherwise          = "F"
  where
    t = m + f

main :: IO ()
main = do
    [m, f, r] <- getLine >>= return.(map $ \n -> read n :: Int).words
    if m == -1 && f == -1 && r == -1 then
        return ()
    else
        (putStrLn $ grade m f r) >> main



Measured memory_bytes: 4068
#include<stdio.h>
#define M 100

main() {

  int n;//グラフGの頂点の数
  int i, j;//counter
  int number, k, v;//number...要素番号　k...何個隣接しているか v...指向グラフが向いている要素番号
  int Adj[M][M];//Gの隣接行列

  scanf("%d", &n);

  for(i = 0; i < n; i++) {
    for(j = 0; j < n; j++) {
      Adj[i][j]  = 0;//隣接行列の初期化
    }  
  }

  for(i = 0; i < n; i++) {
    scanf("%d %d", &number, &k);
      for(j = 0; j < k; j++) {//kの数だけ入力可能
	scanf("%d", &v);
	Adj[number-1][v-1] = 1;//A[要素番号][指向グラフの向く方向]に１代入
      }
  }

  //結果表示
  for(i = 0; i < n; i++) {
    //  printf(" ");
    for(j = 0; j < n; j++) {

      if(j != 0) {
	printf(" ");//最初のループの場合、空白は入れない
      }
   printf("%d", Adj[i][j]);
    }
    printf("\n");
  }    

  return 0;
}

Measured memory_bytes: 640
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}
int main()
{
    ios;
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c-min(c,(a-b))<<endl;



}
//Alhamdulillah

















Measured memory_bytes: 3520
from bisect import bisect_right
a, b, c, d, e, f = map(int, input().split())
suger = [0] * ((f // c + 1) * (f // d + 1))
idx = 0
for i in range(f // c + 1):
    for j in range(f // d + 1):
        suger[idx] = c * i + d * j
        idx += 1
suger.sort()
ans1, ans2 = 0, 0
ma = -1
for i in range(f // (100 * a) + 1):
    for j in range(f // (100 * b) + 1):
        w = a * i + b * j
        if f < 100 * w:
            continue
        s = suger[bisect_right(suger, min(w * e, f - 100 * w)) - 1]
        if w != 0 and ma < s / (100 * w + s):
            ma = s / (100 * w + s)
            ans1 = w
            ans2 = s
print(ans1 * 100 + ans2, ans2)


Measured memory_bytes: 23868
def func(a, b)
  a[0] * b[1] - a[1] * b[0]
end

cas = 1
while (n = gets.to_i) != 0
  arr = Array.new
  n.times do
    x, y = gets.split
    x = x.to_f
    y = y.to_f
    arr.push([x, y])
  end
  area = 0
  for i in (0...n) do
    area += func(arr[i-1], arr[i])
  end
  area = area.abs / 2
  puts "#{cas} #{area}"
  cas += 1
  gets
end



Measured memory_bytes: 6864
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	vector<vector<int>> ans(h, vector<int>(w));
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				for (int k = i - 1; k <= i + 1; k++) {
					for (int l = j - 1; l <= j + 1; l++) {
						if (k >= 0 && k < h && l >= 0 && l < w && s[k][l] != '#') {
							ans[k][l]++;
						}
					}
				}
			}
		}
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				cout << '#';
			}
			else {
				cout << ans[i][j];
			}
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
#include <sstream>
#include <queue>
using namespace std;
typedef long long ll;

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

int main() {
  int n, x;
  cin >> n >> x;

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

  vector<int> diff(n);
  for (int i = 0; i < n; i++) {
    diff[i] = abs(x - a[i]);
  }

  int ans = diff[0];
  for (int i = 0; i < n; i++) {
    ans = gcd(diff[i], ans);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3528
import java.util.Scanner;


class Main{
    public static void main(String args[]){
	//	print();
	int x ;
	Scanner scan = new Scanner(System.in);

	x = scan.nextInt();

	if(x>100){
	    return;
	}

	int sum = 0;
	for(int n=1;1 <= n &&n <= x;n++){
	    sum = sum + n;
	}
	System.out.println(sum);

    }
    static void print(){
	System.out.println("hello world");
	return;
    }
}//1からnまで足す

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

int main()
{
	int x,y;
	
	while(1)
	{		
		cin>>x>>y;
		
		if(x==0 and y==0)break;
		
		if(x<y)
		{
			cout<<x<<" "<<y<<endl;
		}
		else
		{
			cout<<y<<" "<<x<<endl;
		}
	}
	return 0;
}




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

int main(){
    int n,y;
    cin >> n >> y;
    int res10 = -1,res5 = -1, res1 = -1;
    for(int a = 0; a<=n; a++){
        for(int b=0; b+a<=n; b++){
            int c = n-a-b;
            int total = 10000*a + 5000*b + 1000*c;
            if(total == y){
                res10 = a;
                res5 = b;
                res1 = c;
            }
        }
    }
    cout << res10 << " " << res5 << " " << res1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI acos(-1)
using namespace std;
int main(){
    long double  a, b, x;
    cin >> a >> b >> x;
    long double ans;
    if(a*a*b/2 <=x){//less than a half of the cube
        ans = atan(2*(a*a*b-x)/(a*a*a));
    }else{ //more than a half og the cube
        ans = PI/2-atan(2*x/(a*b*b));
    } 
    cout << fixed << setprecision(10) << ans*180.0/PI << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int A, B;
    read(A, B);
    B--;
    if(B % (A - 1) != 0) B += (A - 1) - (B % (A - 1));
    write(B / (A - 1));
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 256
using System;

namespace code_festival_2017_qualc_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            int e = 0;
            for(int i = 0; i < N; i ++){
                if(A[i]%2==0){
                    e++;
                }
            }
            Console.WriteLine(Math.Pow(3,N)-Math.Pow(2,e));
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n;
    cin >> n;
    cout << n*n << endl;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,d;
  cin>>n>>d;
  long long int ans=0;
  while(n--)
  {
    long long int x,y;
    cin>>x>>y;
    long long int j=(x*x)+(y*y);
    if(j<=(d*d))
      ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <queue>
#include <string>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int main(void){
  initialize();
  ll h,w,i,j,k,result=0,x[2],y[2];
  int a[LIMIT2]={0};
  int xx,yy,ww;
  queue<int> xQue,yQue,wQue;
  string s;
  
  cin >> h >> w >> k;
  cin >> x[0] >> y[0] >> x[1] >> y[1];
  rep(i,2){
    x[i]--;
    y[i]--;
  }
  vector<string> ss;

  rep(i,h){
    cin >> s;
    ss.push_back(s);
  }
  vector<vector<int>> data(h,vector<int>(w,-1));
  
  xQue.push(x[0]);
  yQue.push(y[0]);
  data.at(x[0]).at(y[0]) = 0;
  while(!xQue.empty()){
    xx = xQue.front();
    xQue.pop();
    yy = yQue.front();
    yQue.pop();
    ww = data.at(xx).at(yy);
    
    for(i=0;i<4;i++){
      for(j=1;j<=k;j++){
        int tx = xx+dx[i]*j;
        int ty = yy+dy[i]*j;
        if(tx<0||tx>=h) break;
        else if(ty<0||ty>=w) break;
        else if(ss[tx][ty]=='@') break;
        else if(data.at(tx).at(ty)!=-1 && data.at(tx).at(ty)<=data.at(xx).at(yy)) break;
        else if(data.at(tx).at(ty)!=-1) continue;
        
        data.at(tx).at(ty) = ww+1;
        xQue.push(tx);
        yQue.push(ty);
      }
    }
  }
  rep(i,h){
    break;
    rep(j,w){
      cout << data.at(i).at(j) << (j==w-1 ? "\n" : " ");
    }
  }
  cout << data.at(x[1]).at(y[1]) << endl;
  
  return 0;
}

Measured memory_bytes: 13204
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const llint INF = 9999999999999999;

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

    int N, T;
    cin >> N >> T;
    vector<llint> A(N);
    REP(i, N) cin >> A[i];
    llint maxv = -INF;
    llint minv = A[0];
    int ans = 1;
    FOR(i, 1, N){
        if(maxv < A[i]-minv){
            maxv = A[i]-minv;
            ans = 1;
        }
        else if(maxv == A[i]-minv) ans++;
        minv = min(minv, A[i]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

func nextInt() int {
	if !sc.Scan() {
		panic("failed scan int")
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	if n == 1 {
		fmt.Println("Hello World")
	} else if n == 2 {
		a := nextInt()
		b := nextInt()
		fmt.Println(a + b)
	}
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  REP(i, n) {
    cin >> v[i];
  }
  int total = accumulate(ALL(v), 0);
  int m;
  cin >> m;
  //vector<pair<int, int>> vp(m);
  int p, x;
  REP(i, m) {
    cin >> p >> x;
    int diff = v[p-1] - x;
    cout << total - diff << endl;
  }

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	mod int = 1e9 + 7
)

func main() {
	N := getInt()

	flag := false
	for i := 1; i <= 9; i++ {
		if N % i == 0 && N / i <= 9 {
			flag = true
			break
		}
	}

	if flag {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray) - 1])
}

func calcMod(x int) int {
	return x % mod
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define yzh 2333333
#define bql 2147483647
using namespace std;
int n,k;
int main()
{
	fast;
	cin>>n>>k;
	cout<<n-k+1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
 
//gcd(a,b)が1前提のしか作ってない
ll ex_Euclid(ll a,ll b){
	ll q,r,x0,x1,x2,y0,y1,y2;
	x0=1;y0=0;
	x1=0;y1=1;
	while(b>0){
		r=a%b;
		q=a/b;
		x2=x0-x1*q;
		y2=y0-y1*q;
		a=b;b=r;
		x0=x1;x1=x2;
		y0=y1;y1=y2;
	}
	return y0;
}
 
ll comb(ll N,ll k,ll mod){
	ll i,j;
	vector<ll> fact(N+1);
	fact[0]=1;
	for(i=1;i<=N;i++){
		fact[i]=(fact[i-1]*i)%mod;
	}
	vector<ll> invfact(N+1);
	invfact[N]=ex_Euclid(mod,fact[N])%mod;
	for(i=1;i<=N;i++){
		invfact[N-i]=invfact[N-i+1]*(N-i+1)%mod;
	}
	return fact[N]*invfact[N-k]%mod*invfact[k]%mod;
}
 
 
int main(){
	ll MOD=1000000007;
	ll X,Y;
	cin >> X >> Y;
	if(X<Y)swap(X,Y);
	if((X+Y)%3==0 && X<=2*Y){
		cout << comb((X+Y)/3,(2*Y-X)/3,MOD)<<endl;
	}else{
		cout << 0;
	}
    return 0;
}

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

import itertools

tmp = list(itertools.permutations(N))

ans = "NO"

for i, j, k, l in tmp:
    val = 1000 * i + 100 * j + 10 * k + l
    if val == 1974:
        ans = "YES"

print(ans)


Measured memory_bytes: 3060
import sys


def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    D = [0] * (1 + 10 ** 5)
    sA = sum(A)
    for a in A: D[a] += 1
    Q = int(input())
    Ans = [-1] * Q
    for i in range(Q):
        B, C = map(int, input().split())
        sA += (C - B) * D[B]
        D[C] += D[B]
        D[B] = 0
        Ans[i] = sA
    print(*Ans, sep="\n")

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 21252
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int calc(int y,int m,int d){
    int cnt=0;
    for(int i=1;i<y;i++){
        cnt+=(i%3)?195:200;
    }
    for(int i=1;i<m;i++){
        if(y%3!=0&&i%2==0)cnt+=19;
        else cnt+=20;
    }
    cnt+=d;
    return cnt;
}
int main(){
    int n;
    scanf("%d",&n);
    while(n--){
        int y,m,d;
        scanf("%d%d%d",&y,&m,&d);
        printf("%d\n",calc(1000,1,1)-calc(y,m,d));
    }
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>

#include<queue>

using namespace std;

struct NODE
{

};

int main() {

	int N, M;
	cin >> N >> M;

	struct CUT
	{
		int under;
		int over;
		CUT()
		{
			under = 0;
			over = 0;
		}
	};
	vector<CUT> info(M);
	for (int i = 0; i < M; i++)
	{
		cin >> info[i].under >> info[i].over;
		--info[i].under;
		--info[i].over;
	}


	int under = info[0].under;
	int over = info[0].over;
	for (int i = 1; i < M; i++)
	{
		if (under < info[i].under)
		{
			under = info[i].under;
		}
		if (over > info[i].over)
		{
			over = info[i].over;
		}
	}

	int result = 0;
	if (over >= under)
	{
		result = over - under + 1;
	}
	cout << result << endl;

	return 0;
}




Measured memory_bytes: 1024
input=gets.chomp.to_i
waters=gets.chomp.split.map(&:to_i)
start=0
waters.each_with_index do|val, ind|
  if (ind+1)%2 == 1
    start = start+val
  else
    start = start-val
  end  
end  
answer= [start]
waters.each do|val|
  answer.push(2*(val-answer.last/2))
end  
puts answer.slice(0..-2)

Measured memory_bytes: 14340
#include<iostream>

int main()
{
	int n,max,min,mins;
	std::cin >> n;
	int R[n];
	for(int t=0;t<=n-1;t++){
		std::cin >> R[t];
	}
	
	min=R[0];
	mins=0;
	for(int j=1;j<=n-1;j++){
		for(int i=j-1;i<j;i++){
			if(R[i]<=min){
				min=R[i];
				mins=i;
			}
			if(j==1){
				max=R[j]-min;
			}
			
			if(R[j]-min>max){
				max=R[j]-min;
			}
/*			if(R[j]<R[j-1]){
				break;
			}
			if( R[i]<=min && R[j]-R[i]>max){
				max=R[j]-R[i];
				min=R[i];
				
			}*/
		}
	}
	std::cout << max << "\n";
	
	return 0;
}


Measured memory_bytes: 3860
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;

int main() {
  string n;
  cin >> n;
  ll m = n.size();
  ll cnt = 0;
  rep(i,m)
    cnt += n[i] - '0';
  if (cnt%9==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
int a, b, c;

int main() {
  	cin>>a>>b>>c;
    if(a == b && a != c || a == c && a != b || b == c && b != a) {
    	printf("Yes\n");
    }else {
    	printf("No\n");
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(3)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ld, ld> point;
typedef pair<ld, pii> P;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

ld dist(point l, point r)
{
	ld x = l.first - r.first;
	ld y = l.second - r.second;
	return sqrt(x*x + y*y);
}


int main()
{
	int n;
	while (cin >> n, n)
	{
		vector<point> v;
		vi h;
		REP(i, n)
		{
			int a, b; cin >> a >> b;
			v.emplace_back(a, b);
			h.push_back(b);
		}
		sort(ALL(h));
		h.erase(unique(ALL(h)), h.end());
		vector<point> eve;
		REP(i, n - 1)
		{
			ld lh = v[i].second, rh = v[i+1].second;
			ld slo = (rh - lh) / (v[i + 1].first - v[i].first);
			eve.emplace_back(v[i]);
			REP(j, h.size())
			{
				if ((lh < rh && h[j] > lh && h[j] < rh) || 
					(lh > rh && h[j] < lh && h[j] > rh))
				{
					eve.emplace_back(v[i].first + (h[j] - lh) / slo, h[j]);
				}
			}
		}
		eve.emplace_back(v.back());
		sort(ALL(eve));
		int m = eve.size();

		int d[] = { -1, 0, 1 };
		priority_queue<P, vector<P>, greater<P>> que;
		map<pii, ld> mp;
		mp[pii(0, m - 1)] = 0;
		que.push(P(0, pii(0, m - 1)));
		while (que.size())
		{
			P p = que.top();
			que.pop();
			int l = p.second.first, r = p.second.second;
			ld cost = p.first;
			if (mp[pii(l, r)] < cost) continue;
			if (l == r)
			{
				cout << D10 << cost << endl;
				break;
			}
			REP(i, 3)REP(j, 3)
			{
				int nl = l + d[i], nr = r + d[j];
				if (nl < 0 || nl >= m || nr < 0 || nr >= m) continue;
				if (eve[nl].second != eve[nr].second) continue;
				pii nx(nl, nr);
				ld ncost = cost;
				ncost += dist(eve[nl], eve[l]) + dist(eve[nr], eve[r]);
				if (mp.count(nx) == 0 || mp[nx] > ncost)
				{
					mp[nx] = ncost;
					que.push(P(ncost, nx));
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 5772
//Krunal_Mathukiya
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define li long int
#define pb push_back
#define mkp make_pair
#define nikalL return
#define umap unordered_map
#define fr(i,s,n) for(int i=s;i<=n;++i)
#define frr(i,s,n) for(int i=s;i>=n;--i)
#define jaldiKarNe ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
int arr[100007][4];
int dp[100007][4];
int vis[100007][4];
int n,k;
lli fn(int i,int last) {
	if (i > n) return 0;
	if(vis[i][last]) return dp[i][last];
	vis[i][last]=1;
	lli ans=0;
	fr(j,0,2) {
		if(j==last) continue;
		lli tmp=arr[i][j]+fn(i+1,j);
		ans=max(ans,tmp);
	}
	return dp[i][last]=ans;
}
void TestingChaluKarEyy() {
	cin >> n;
	fr(i, 1, n) {
		cin>>arr[i][0];
		cin>>arr[i][1];
		cin>>arr[i][2];
		vis[i][0]=0;
		vis[i][1]=0;
		vis[i][2]=0;
		vis[i][3]=0;
	}
	cout << fn(1,3);
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	jaldiKarNe;
	int TestingKaravvuChhe = 1;
	// cin >> TestingKaravvuChhe;
	while (TestingKaravvuChhe--) {
		TestingChaluKarEyy();
	}
}


Measured memory_bytes: 16012
#include<cstdio>
#include<cstring>
#define N 190
inline int min(int x,int y){return x<y?x:y;}
inline int max(int x,int y){return x<y?y:x;}
int a[N][N][N],b[N],d[N][N],e[N],f[N][N][N],i,j,k,l,m,n,r,s;char c[N][N];
int main()
{
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)scanf("%s",c[e[i]=i]+1);
	for(i=1;i<=n;i++)for(j=1;j<=m;j++)d[i][j]=d[i][j-1]+(c[i][j]=='.');
	for(i=1;i<=m;i++)for(j=i;j<=m;j++)for(k=1,l=0,a[i][j][n+1]=n;k<=n;a[i][j][k++]=l)while(l<n&&(l+1<k||l+1==k&&(d[l+1][j]-d[l+1][i-1]==j-i+1||d[l+1][j]==d[l+1][i-1])||k<=l&&d[l+1][j]-d[l+1][i-1]==d[l][j]-d[l][i-1]))l++;
	for(s=0;a[1][m][1]<n;s++)
	{
		for(k=1;k<=n;k++)for(memcpy(b+1,e+1,m<<2),j=0;j<m;j++)for(i=1;i+j<=m;f[i][i+j][k]=max(a[i][i+j][a[i][i+j][k]+1],min(a[i][b[i]][k],a[b[i]+1][i+j][k])),i++)while(b[i]<i+j&&min(a[i][b[i]+1][k],a[b[i]+2][i+j][k])>=min(a[i][b[i]][k],a[b[i]+1][i+j][k]))b[i]++;
		for(i=1;i<=m;i++)for(j=i;j<=m;j++)for(k=1;k<=n;k++)a[i][j][k]=f[i][j][k];
	}
	return 0*printf("%d\n",s);
}

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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

signed main() {
	int n, a, b, c, d;
	string s;
	cin >> n >> a >> b >> c >> d;
	a--, b--, c--, d--;
	cin >> s;
	if (c < d) {
		for (int i = a; i <=c - 1; i++) {
			if (s[i] == '#' && s[i + 1] == '#') {
				cout << "No" << endl;
				return 0;
			}
		}
		for (int i = b; i <=d - 1; i++) {
			if (s[i] == '#' && s[i + 1] == '#') {
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}
	else {
		for (int i = a; i <=c - 1; i++) {
			if (s[i] == '#' && s[i + 1] == '#') {
				cout << "No" << endl;
				return 0;
			}
		}
		for (int i = b; i <=d - 1; i++) {
			if (s[i] == '#' && s[i + 1] == '#') {
				cout << "No" << endl;
				return 0;
			}
		}
		bool bou = false;
		for (int i = b - 1; i <= d - 1; i++) {
			if (i + 2 < n && s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
				bou = true;
			}
		}
		if (!bou) cout << "No" << endl;
		else cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 640
s = list(input())
k = int(input())
i = 0
flag = 0
while s[i] == "1":
    i += 1
    if i == len(s):
        flag = 1
        break
onelength = i
if flag == 1:
    print(1)
else :
    onenext = s[i]
    if onelength < k:
        print(s[i])
    else:
        print(1)

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

int main()
{
    int N;
    cin >> N;
    vector<int> as(N);
    for (int i = 0; i < N; i++)
    {
        cin >> as.at(i);
    }

    vector<int> dijk(N); // １からの最短距離を各ボタンについて計算

    dijk.at(0) = 0;
    vector<bool> closed(N, false); // 格納済み頂点集合

    int next_button = 1;
    while (true)
    {
        if (closed.at(next_button - 1))
        {
            cout << -1 << endl;
            exit(0);
        }
        closed[next_button - 1] = true;

        // cout << next_button << endl;

        int kokomedenokyori = dijk.at(next_button - 1);
        next_button = as.at(next_button - 1);
        dijk.at(next_button - 1) = kokomedenokyori + 1;

        // 終了判定処理
        if (next_button == 2)
        {
            break;
        }
    }

    cout << dijk[1] << endl;
}


Measured memory_bytes: 1152
# Binary search tree I 二分探索木：挿入


class Node():

    def __init__(self, k):
        self.k = k
        self.p = None
        self.l = None
        self.r = None
    
    def __repr__(self):
        return str(self.k)


def insert(z):
    if z == T[0]:
        return
    y = None
    x = T[0]
    while x != None:
        y = x 
        if z.k < y.k:
            x = y.l
        else:
            x = y.r
    z.p = y

    if z.k < y.k:
        y.l = z
    else:
        y.r = z


def preparse(u):
    print(" ", u.k, sep="", end="")
    if u.l != None:
        preparse(u.l)
    if u.r != None:
        preparse(u.r)


def inparse(u):
    if u.l != None:
        inparse(u.l)
    print(" ", u.k, sep="", end="")
    if u.r != None:
        inparse(u.r)


m = int(input())
T = [None for i in range(m)]
for id in range(m):
    cmd = input().split()
    if cmd[0] == "insert":
        T[id] = Node(int(cmd[1]))
        insert(T[id])
    elif cmd[0] == "print":
        inparse(T[0])
        print()
        preparse(T[0])
        print()



Measured memory_bytes: 109264
//https://atcoder.jp/contests/arc068/tasks/arc068_d

#include<bits/stdc++.h>
const int N = 2005;
const int mod = 1e9 + 7;
using namespace std;

int n, k, sum[N][N];

void add(int&a, int b){
    a += b; if (a >= mod) a -= mod;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> k; k = n - k;
    sum[0][0] = 1; for (int i = 1; i < k; i++) add(sum[0][0], sum[0][0]);
    for (int i = 1; i <= n; i++) for (int j = i; j >= 0; j--) sum[i][j] = sum[i-1][j-1], add(sum[i][j], sum[i][j+1]);
    cout << sum[n-1][k];
}


Measured memory_bytes: 15104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    string t;
    cin >> t;
    For(i,0,t.size()){
        if(t[i]=='?') t[i]='D';
    }
    cout << t << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3728
def main():
    n = int(input())
    
    res = [0]*(n+1)

    for i in range(1,100):
        for j in range(1,100):
            for k in range(1,100):
                tmp = i**2 + j**2 + k**2 + i*j + j*k + k*i
                if(tmp<=n):
                    res[tmp]+=1



    for i in range(1,n+1):
        print(res[i])
if __name__ == '__main__':
    main()


Measured memory_bytes: 9424
#include <bits/stdc++.h>
int read(){
	int x=0,f=1;
	char ch=getchar();
	while (ch<'0' || ch>'9'){
		if (ch=='-') f=-1;
		ch=getchar();
	}
	while (ch>='0' && ch<='9'){
		x=x*10+ch-'0';ch=getchar();
	}
	return x*f;
}
const int N=600;
int n,d1,d2,col[2][N*N];
std::vector< std::pair<int,int> > v[2];
inline int id(const int &x,const int &y) {
    return x*N+y;
}
inline bool check(const int &x) {
    return 0<=x && x<n*2;
}
void dfs(const int &x,const int &t) {
    const int i=x/N,j=x%N;
    for (auto &d:v[t]) {
        const int nx=i+d.first,ny=j+d.second;
        if (!check(nx)||!check(ny)) continue;
        const int y=id(i+d.first,j+d.second);
        if (!col[t][y]) {
            col[t][y]=col[t][x]==1?2:1;
            dfs(y,t);
        }
    }
}
int main() {
    n=read(),d1=read(),d2=read();
    for (register int i=0;i<=d1;i++) {
        const int j=sqrt(d1-i*i);
        if (i*i+j*j!=d1) continue;
        v[0].emplace_back(std::make_pair(i,j));
        v[0].emplace_back(std::make_pair(-i,j));
        v[0].emplace_back(std::make_pair(i,-j));
        v[0].emplace_back(std::make_pair(-i,-j));
    }
    for (register int i=0;i<=d2;i++) {
        const int j=sqrt(d2-i*i);
        if (i*i+j*j!=d2) continue;
        v[1].emplace_back(std::make_pair(i,j));
        v[1].emplace_back(std::make_pair(-i,j));
        v[1].emplace_back(std::make_pair(i,-j));
        v[1].emplace_back(std::make_pair(-i,-j));
    }
    for (register int i=0;i<n*2;i++) {
        for (register int j=0;j<n*2;j++) {
            if (!col[0][id(i,j)]) {
                col[0][id(i,j)]=1;
                dfs(id(i,j),0);
            }
            if (!col[1][id(i,j)]) {
                col[1][id(i,j)]=1;
                dfs(id(i,j),1);
            }
        }
    }
    for (register int i=0,cnt=0;i<n*2;i++){
        for (register int j=0;j<n*2;j++) {
            if (col[0][id(i,j)]==1 && col[1][id(i,j)]==1) {
                printf("%d %d\n",i,j);
                if (++cnt==n*n) return 0;
            }
        }
    }
}


Measured memory_bytes: 31872
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

static int gcd(int a, int b)
{
	int tmp = 0;

	//   絶対値をとることで、a, b のいずれか、または
	//   両方が負であっても通用するようになる
	a = abs(a);
	b = abs(b);

	while (b != 0) {
		if (b < a) {
			// swap (abs(b) is always bigger than abs(a)
			tmp = a;
			a = b;
			b = tmp;
		}
		//
		// s/%/-/ は正しいが、b と a の値の差が圧倒的に大きい
		// ときにずっと同じ値 a を引きつづけるため、非常に遅い
		//
		// b の方が大きい限り a を引き続けるということは、いず
		// れは a で割った余りを求めることと同義になる。よって
		// b % a の方が圧倒的に速い
		//
		// ※  % 演算子のオペランドが負であったときの結果は処理系
		//     定義であることに注意。だが、ここでは a, b は常に
		//     正になるように補正しているので無問題
		//
		b = b % a;
		//printf("a:%d b:%d\n", a, b);
	}
	return a;
}


signed main() {
	ll N, sum = 0;

	cin >> N;

	for (int i = 1; i <= N; i++) {
		for (int i2 = 1; i2 <= N; i2++) {
			for (int i3 = 1; i3 <= N; i3++) {
				sum += gcd(i, gcd(i2, i3));
			}
		}
	}

	cout << sum << endl;


	return 0;
}

Measured memory_bytes: 3644