akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n,m; cin >> n >> m;
  vector<int> l(m),r(m); rep(i,m) cin >> l[i] >> r[i];

  int left = 1,right = n;

  rep(i,m){
    left = max(left,l[i]);
    right = min(right,r[i]);
  }
  int ans = left>right ? 0:right-left+1;

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


Measured memory_bytes: 4056
import numpy as np
N, A = map(int, input().split())
X = [int(c) for c in input().split()]
dp = np.zeros((51,51,2501))
dp[:,0,0] = 1
for i in range(1,N+1):
  c = X[i-1]
  for k in range(1,N+1):
    dp[i,k,:c] = dp[i-1,k,:c]
    dp[i,k,c:] = dp[i-1,k,c:]+dp[i-1,k-1,:2501-c]
ans = 0
for i in range(1,N+1):
  ans += dp[N,i,i*A]
print(int(ans))
  


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/08  Problem: ABC 093 B / Link: http://abc093.contest.atcoder.jp/tasks/abc093_b  ----- */


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

	LL A, B, K; cin >> A >> B >> K;
	set<LL>ans;
	FOR(i, 0, K) {
		if (A + i <= B)
		ans.insert(A + i);
	}
	FORR(i, K - 1, 0 - 1) {
		if (A <= B - i)
		ans.insert(B - i);
	}
	for (auto it : ans) {
		cout << it << endl;
	}


	return 0;
}


Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())

    if N & 1:
        gen = ((i+1, N-i) for i in range(M))
    else:
        gen = ((i+1, N-i) if 2*i < N/2-1 else (i+1, N-i-1) for i in range(M))

    [print(*s) for s in gen]


if __name__ == "__main__":
    main()


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

int main(int argc, char const *argv[]) {
  int a,b,c,d,e,k;
  std::cin >> a >> b >> c >> d >> e >> k;

  if (e - a <= k) std::cout << "Yay!" << '\n';
  else std::cout << ":(" << '\n';
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Convert;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }


        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;
            var x = cin.ReadInt;
            double box = a * a * b;
            double ans = 0;
            var plate = (double)x / a;
            if(x > box / 2)
            {
                double tate = 2 * b - 2 * plate / a;
                double c = Sqrt(a * a + tate * tate);
                var sin = a * tate / (a * c);
                ans = Asin(sin)  * 360 / (2 *PI);
            }
            else if(x < box / 2)
            {
                var tate = 2 * plate / b;
                var c = Sqrt(b * b + tate * tate);
                var sin = 2 * plate / (c * tate);
                ans = Asin(sin) * 360 / (2*PI);
            }
            else
            {
                var c = Sqrt(a * a + b * b);
                var sin = 2 * plate / (a * c);
                ans = Asin(sin) * 360 / (2*PI);
            }
            WriteLine(ans);
        }


        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    vector<int> xi(n);
    vector<int> yi(m);
    rep(i,n) cin >> xi[i];
    rep(i,m) cin >> yi[i];

    int x_max = *max_element(xi.begin(),xi.end());
    int y_min = *min_element(yi.begin(),yi.end());
    if(x_max >= y_min)
        cout << "War" << endl;
    else if(x_max >= y)
        cout << "War" << endl;
    else if(y_min <= x)
        cout << "War" << endl;
    else
        cout << "No War" << endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      abs: [(i64, i64); n],
    }
    let mut vals = vec![];
    for i in 0..n {
        let a = abs[i].0;
        let b = abs[i].1;
        vals.push((a+b, i));
    }
    vals.sort();
    vals.reverse();

    let mut ans = 0i64;
    for i in 0..n {
        let j = vals[i].1;
        if i%2 == 0 {
            ans += abs[j].0;
        } else {
            ans -= abs[j].1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
a, b, m = map(int, input().split())
a_l = list(map(int, input().split()))
b_l =  list(map(int, input().split()))
x_y_c = [ list(map(int, input().split())) for _ in range(m) ]

ans = min(a_l) + min(b_l)
for x,y,c in x_y_c:
   ans = min(a_l[x-1]+b_l[y-1]-c, ans)
print(ans) 

Measured memory_bytes: 38544
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

const int maxn = 2e6+5;
const LL MOD = 1e9+7;
LL inv[maxn], f[maxn], invf[maxn];

void init() {
    inv[1] = 1;
    for(int i = 2; i < maxn; ++i)
        inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;
    f[0] = invf[0] = 1;
    for(int i = 1; i < maxn; ++i) {
        f[i] = f[i-1] * 1LL * i % MOD;
        invf[i] = invf[i-1] * inv[i] % MOD;
    }
}

LL comb(int a, int b) {
    if(b < 0 || b > a) return 0;
    return f[a]*invf[a-b]%MOD*invf[b]%MOD;
}

void run_case() {
    LL n, m;
    init();
    cin >> n >> m;
    if((n+m)%3) cout << "0\n";
    else {
        
        cout << (comb((n+m)/3, (2*n-m)/3) + MOD) % MOD;
    }
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}


Measured memory_bytes: 50504
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		char[] s = sc.next().toCharArray();
		int[] acumL = new int[N+1], acumR = new int[N+1];
		for (int i = 1; i < N + 1; i++) {
			acumL[i] = acumL[i-1] + (s[i-1] == '#'? 1 : 0);
		}
		for (int i = 1; i < N + 1; i++) {
			acumR[i] = acumR[i-1] + (s[N - i] == '.'? 1 : 0);
		}
		int ans = N;
		for (int i = 0; i < N + 1; i++) {
			ans = Math.min(ans, acumL[i] + acumR[N-i]);
		}
		out.println(ans);
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


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

int check(long long int P, vector<long long int> T, int k, int n){
    int i = 0;
    for (int j = 0; j < k; j++) {
        long long int s = 0;
        while (s + T[i] <= P) {
            s += T[i];
            i++;
            if (i == n) return n;
        }
    }
    return i;
}

int solve(vector<long long int> T, int k, int n) {
    long long int left = 0;
    long long int right = 100000 * 10000;
    long long int mid;
    while (right - left > 1) {
        mid = (right + left) / 2;
        int v = check(mid, T, k, n);
        if (v >= n) right = mid;
        else left = mid;
    }
    return right;
}

int main(void){
    int n, k;
    vector<long long int> T(100000);
    cin >> n >> k;
    for (int m = 0; m < n; m++) cin >> T[m];
    int ans = solve(T, k, n);
    cout << ans << endl;
    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

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

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> a;
map<ll,ll> m;

int main()
{
	ll n, m;
	int tmp;
	double ans;

	cin >> n >> m;

	ans = ((1900 * m) + 100 * (n - m)) * pow(2, m);
	
	cout << ans << endl;
	
	return 0;
}



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

int main() {
  ll n,m,c=0;

  cin >> n >> m;
  vector<ll> h(n);
  vector<vector<ll>> t(n);

  rep(i,n) {
    cin >> h[i];
  }
  rep(j,m){
    ll a,b;
    cin >> a >> b;
    a--;
    b--;
    t.at(a).push_back(b);
    t.at(b).push_back(a);
  }
  rep(i,n){
    int ts = t.at(i).size();
    if (ts == 0){
      c++;
      continue;
    }
    bool tr = true;
    for (ll j=0;j<ts;++j){
      if (h[i]<=h[t.at(i).at(j)]) tr = false;
    }
    if (tr) c++;
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 9864
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    ULL A,B; cin>>A>>B;
    ULL a1,a2,b1,b2;
    if(A%2==0){
        if(B%2==0){
            if(((B-A+1)/2)%2==0){
                c(B);
            }else{
                c(B^1);
            }
        }else{
            if(((B-A+1)/2)%2==0){
                c(0);
            }else{
                c(1);
            }
        }
    }else{
        if(B%2==0){
            if(((B-A-1)/2)%2==0){
                c(A^B);
            }else{
                c(A^1^B);
            }
        }else{
            if(((B-A)/2)%2==0){
                c(A);
            }else{
                c(A^1);
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define INF (1LL << 60)
using namespace std;
typedef long long ll;

struct edge { ll v, dist; };
struct state {
  ll v, cost;
  bool operator>(const state s) const { return cost > s.cost; }
};

vector<ll> dijkstra(vector< vector<edge> > &E, ll S) {
  vector<ll> dp(E.size(), INF);
  priority_queue<state, vector<state>, greater<state> > q;
  q.push((state) { S, 0 });
  while(!q.empty()) {
    ll v = q.top().v, cost = q.top().cost;
    q.pop();
    if(dp[v] <= cost) continue;
    dp[v] = cost;
    REP(i, 0, E[v].size()) {
      ll nv = E[v][i].v, ncost = cost + E[v][i].dist;
      if(dp[nv] > ncost) q.push((state) { nv, ncost });
    }
  }
  return dp;
}

int main(void) {
  ll H, W;
  char S, T;
  cin >> H >> W >> S >> T;
  char A[H][W];
  REP(i, 0, H) REP(j, 0, W) cin >> A[i][j];

  vector< vector<edge> > E(256);
  REP(i, 0, H) REP(j, 0, W) {
    if('A' <= A[i][j] && A[i][j] <= 'Z') {
      ll dd[5] = { 0, 1, 0, -1, 0 };
      REP(k, 0, 4) {
        ll pi = i + dd[k];
        ll pj = j + dd[k + 1];
        while(1) {
          pi += dd[k];
          pj += dd[k + 1];
          if(!(0 <= pi && pi < H && 0 <= pj && pj < W)) break;
          if(A[pi][pj] == 'o') {
            E[A[i][j]].push_back((edge) { A[pi + dd[k]][pj + dd[k + 1]], 1 });
            // cout << A[i][j] << " " << A[pi + dd[k]][pj + dd[k + 1]] << endl;
            break;
          }
          if(dd[k] != 0 && A[pi][pj] != '|') break;
          if(dd[k + 1] != 0 && A[pi][pj] != '-') break;
          if(A[pi][pj] == '.') break;
        }
      }
    }
  }

  cout << dijkstra(E, S)[T] << endl;
}



Measured memory_bytes: 3172
#include <iostream>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cassert>
#include <tuple>
using namespace std;
using ll = long long int;

ll A, B, D;
const ll INF = 1LL << 50;
const ll MAX = 1LL << 21;
pair<ll, ll> NIL(INF, INF);

pair<ll, ll> compare_pair(pair<ll, ll> L, pair<ll, ll> R) {
  ll XL, XR, YL, YR;
  tie(XL, YL) = L; tie(XR, YR) = R;
  if(XL + YL != XR + YR) {
    if(XL + YL < XR + YR) return L;
    else                  return R;
  }
  else {
    ll massL = XL * A + YL * B;
    ll massR = XR * A + YR * B;
    if(massL < massR) return L;
    else              return R;
  }
}

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

pair<ll, ll> solve(ll a, ll b, ll d, bool rev) {
  ll g = gcd(a, b);
  if(d % g != 0) return NIL;
  ll na = a/g, nb=b/g, nd=d/g;

  // if(gcd(na, nb) != 1) return NIL;
  ll x; for(x=0; x<nb; x++) if(na*x % nb == nd % nb) break;

  if(x == nb) return NIL;
  // fprintf(stderr, "na = %lld, nb = %lld, nd = %lld, x = %lld\n", na, nb, nd, x);
  // x *= g;

  pair<ll, ll> ans = NIL;
  for(; x<MAX; x += nb) {
    // fprintf(stderr, "a = %lld, x = %lld, b = %lld, d = %lld\n", a, x, b, d);
    if(ans.first + ans.second < x) break;
    assert(a*x % b == d % b);
    ll val = a*x - d;
    if(val < 0 or val % b != 0) continue;
    ll y = val / b;
    // if(x < 10 or y < 10) fprintf(stderr, "x = %lld, y = %lld\n", x, y);
    if(rev) {
      ans = compare_pair(ans, make_pair(y, x));
    }
    else {
      ans = compare_pair(ans, make_pair(x, y));
    }
  }

  return ans;
}

int main() {
  while(cin >> A >> B >> D, A) {
    pair<ll, ll> ans = NIL;
    ans = compare_pair(ans, solve(A, B, D, false));
    ans = compare_pair(ans, solve(B, A, D, true));

    for(ll x=0; x<MAX; x++) {
      ll rest = D - A*x;
      if(rest < 0 or rest % B != 0) continue;
      ll y = rest / B;
      ans = compare_pair(ans, make_pair(x, y));
    }
    printf("%lld %lld\n", ans.first, ans.second);
  }
  return 0;
}



Measured memory_bytes: 3124
N,D=map(int,input().split())
X=[]
for n in range(N):
    X.append(list(map(int,input().split())))
count=0
for i in range(N):
    for j in range(i+1,N):
        distance=sum([(X[i][d]-X[j][d])**2 for d in range(D)])**0.5
        if distance==int(distance):
            count+=1
print(count)

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

#define int             long long int
#define ld              long double
#define ff              first
#define ss              second
#define mp              make_pair
#define pb              push_back
#define endl            "\n"

#define si              set <int>
#define vi              vector <int>
#define pii             pair <int, int>
#define vpii            vector <pii>
#define mii             map <int, int>
#define que_max         priority_queue <int>
#define que_min         priority_queue <int, vi, greater<int>>

#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))


#define M               1000000007
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 3e5 + 7;
vector <vi > adj;
bool vis[N];
int dp[1003][1003];
char a[1003][1003];
int n, m;
int ways(int i, int j)
{
	int &ans = dp[i][j];
	//cout << a[i][j] << " ";
	if ( ans != -1 )
		return ans;
	if ( i >= n or j >= m )
		return 0;
	if ( a[i][j] == '#' )
		return 0;
	if ( i == n - 1 and j == m - 1 )
		return 1;

	return dp[i][j] = (ways(i + 1, j) + ways(i, j + 1)) % M;
}
void solve()
{

	cin >> n >> m;
	loop(i, 0, n)
	{
		loop(j, 0, m)
		{
			cin >> a[i][j];
		}
	}

	mset(dp, -1);

	cout << ways(0, 0) << endl;
	/*loop(i, 0, n)
	{
		loop(j, 0, m)
		{
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/
	return;
}

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

	cout << setprecision(9) << fixed;

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}


	return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

int n;
char str[100100];
vector<pii> ans;

int main() {
	scanf("%s",str+1);
	n=strlen(str+1);

	if(str[n]=='1' || str[1]=='0') {
		puts("-1");
		return 0;
	}

	int cur=1,c=2;
	for(int i=1;i<=n/2;i++) {
		if(str[n-i]!=str[i]) {
			puts("-1");
			return 0;
		}
		ans.push_back(pii(cur,c));
		if(str[i]=='1') cur=c;
		c++;
	}
	for(;c<=n;c++) ans.push_back(pii(cur,c));

	for(auto &it:ans)
		printf("%d %d\n",it.first,it.second);

	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1000000000; //10^9

int main(){
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A);
    vector<int> b(B);
    for (int i = 0; i < A; i++) cin >> a.at(i);
    for (int i = 0; i < B; i++) cin >> b.at(i);
    int minA = *min_element(a.begin(), a.end());
    int minB = *min_element(b.begin(), b.end());
    int ans = minA + minB;
    for(int i = 0; i < M; i++){
        int x, y, c;
        cin >> x >> y >> c;
        x--;
        y--;
        ans = min(ans, a.at(x) + b.at(y) - c);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main() {
    string S;
    int Q;
    bool flag=true;
    cin >> S;
    cin >> Q;
    vector<int> a(Q), b(Q);
    vector<char> c(Q);
    deque<char> ans;

    for(int i=0; i<S.size(); i++){
	ans.push_back(S[i]);
    }
    for(int i=0; i<Q; i++){
	cin >> a[i];
	if(a[i] == 2)
	    cin >> b[i] >> c[i];
    }
 
    for(int i=0; i<Q; i++){
	if(a[i]==1)
	    flag = !flag;
	else if(b[i]==1)
	    if(flag)
		ans.push_front(c[i]);
	    else
		ans.push_back(c[i]);
	else if(b[i]==2)
	    if(flag)
		ans.push_back(c[i]);
	    else
		ans.push_front(c[i]);
    }
    
    if(!flag)
	reverse(ans.begin(), ans.end());

    for(char tmp: ans){
	cout << tmp ;
    }
    cout  << endl;
}



Measured memory_bytes: 2688
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;

using namespace std;

int main() 
{
    double R, G;
    cin >> R >> G;

    cout << 2*G - R << endl;
    return 0;
}
    



Measured memory_bytes: 256
#include <iostream>


using namespace std;


int main()
{
	int n;
	int* a = new int[n];

	cin >> n;

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

	int temp = 0;

	for (int i = 0 ; i < n ; i++){
		for (int j = i+1 ; j < n ; j++){
			if (a[i] - a[j] < 0 && temp < a[j] -a[i])	temp = a[j] - a[i];
			if (a[i] - a[j] >= 0 && temp < a[i] - a[j])	temp = a[i] -a[j];
		}
	}
	cout << temp << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point{
public:
  double x, y;

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

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

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return equals(x, p.x) && equals(y, p.y);
  }

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

typedef Point Vector;

struct Segment{
  Point p1, p2;
};

typedef Segment Line;

double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }

bool isOrthogonal(Vector a, Vector b){
  return equals(dot(a, b), 0.0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2){
  return equals(dot(a1 - a2, b1 - b2), 0.0);
}

bool isOrthogonal(Segment s1, Segment s2){
  return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

bool isParallel(Vector a, Vector b){
  return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2){
  return equals(cross(a1 - a2, b1 - b2), 0.0);
}

bool isParallel(Segment s1, Segment s2){
  return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

Point project(Segment s, Point p){
  Vector base = s.p2 - s.p1;
  double r = dot(p - s.p1, base) / base.norm();
  return s.p1 + base * r;
}

int main(void){
  int q;
  double x0, y0, x1, y1, x2, y2, x3, y3;
  
  cin >> x1 >> y1 >> x2 >> y2;
  
  Segment s;
  Point *p1 = new Point(x1, y1);
  Point *p2 = new Point(x2, y2);
  s.p1 = *p1, s.p2 = *p2;
  
  cin >> q;
  for(int i = 0; i < q; i++){
    cin >> x0 >> y0;
    Point *p0 = new Point(x0, y0);
    Point projection = project(s, *p0);
    printf("%.10f %.10f\n", projection.x, projection.y);
  }
  return 0;
}

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

int n;
int d[300000];

bool solve()
{
	int reachablePoint = 0;
	for (int i = 0; i < n; i++)
	{
		if (i > reachablePoint) return false;
		reachablePoint = max(reachablePoint, d[i] + i);
	}

	reverse(d, d + n);

	reachablePoint = 0;
	for (int i = 0; i < n; i++)
	{
		if (i > reachablePoint) return false;
		reachablePoint = max(reachablePoint, d[i] + i);
	}

	return true;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int distance;
		cin >> distance;
		d[i] = distance / 10;
	}
	if (solve()) cout << "yes" << endl;
	else cout << "no" << endl;

	return 0;
}

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

int main() {
	string a, b, c;
	cin >> a >> b >> c;

	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	
	return 0;
}

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

int main(){
	int N, c=0, i;
	cin >> N;
	int a[N];
	for(i=0; i<N; i++){
		cin >> a[i];
	}
	sort(a, a+N);
	for(i=1; i<N; i++){
		c += a[i] - a[i-1];
	}
	cout << c << endl;
}

Measured memory_bytes: 256
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  a,b,c:Integer;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Read(a);
    Read(b);
    Readln(c);

    if a=b and c then
      Writeln('1')
    else if (a=b) or (b=c) or (a=c) then
      Writeln('2')
    else
      Writeln('3');
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABC = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine(Math.Max(ABC[2] - (ABC[0] - ABC[1]), 0));
        }
    }
}


Measured memory_bytes: 13268
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	string x;
	cin >> x;
	int res = 0, d = 0;
	REP(i, x.length()) {
		if (x[i] == 'S') ++d;
		else if (d > 0) --d;
		else ++res;
	}
	cout << (res * 2) << endl;
	return 0;
}


Measured memory_bytes: 640
#pragma GCC optimze("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll inf=1e18, N=100005;
ll dp[3005][3005];
inline ll mult(ll x,ll y){x%=hell;y%=hell;return (1LL*x*y)%hell;}
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll powMod(ll base,ll expo){
	if(base==0)return 0;
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base); 
		expo>>=1;
	}
	return ans;
}
void solve(){
	string a, b;
	cin>>a>>b;
	memset(dp,0,sizeof dp);
	rep(i,1,sz(a)+1){
		rep(j,1,sz(b)+1){
			if(a[i-1]==b[j-1])dp[i][j]=max(dp[i][j],dp[i-1][j-1]+1);
			dp[i][j]=max(dp[i][j],dp[i-1][j]);
			dp[i][j]=max(dp[i][j],dp[i][j-1]);
		}
	}
	ll pa=sz(a),pb=sz(b);
	//trace(dp[pa][pb]);
	string ans="";
	while(sz(ans)<dp[sz(a)][sz(b)]){
		if(a[pa-1]==b[pb-1] and dp[pa][pb]==dp[pa-1][pb-1]+1){
			ans+=a[pa-1];
			pa--;
			pb--;
		}
		else{
			if(dp[pa-1][pb]==dp[pa][pb])pa--;
			else
				pb--;
		}
	}
	reverse(all(ans));
	cout<<ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


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

#define fi first
#define se second
#define pb push_back
#define fio ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;



int main() {	
	vector<int> v;
	v.resize(3);
	cin >> v[0] >> v[1] >> v[2];
	int t = 0;
	while(true) {
		if(v[0] == v[1] && v[1] == v[2]) break;
		++t;
		sort(v.begin(),v.end());
		if(v[1] < v[2]) {
			++v[0];
			++v[1];
		} else {
			v[0] += 2;
		}
	}
	cout << t << "\n";
}

Measured memory_bytes: 256
from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)

n = int(input())
seen = [-1]*(n+1)
path = defaultdict(dict)

for _ in range(n-1):
    u, v, w = map(int, input().split())
    path[u][v] = w
    path[v][u] = w


def dfs(seen, pos, color):
    if seen[pos] != -1:
        return
    else:
        seen[pos] = color
        change_color = 1 - color
        for nx in path[pos].keys():
            check = path[pos][nx]
            if check % 2 == 1:
                dfs(seen, nx, change_color)
            dfs(seen, nx, color)


dfs(seen, 1, 0)
for i in range(1, n+1):
    print(seen[i])


Measured memory_bytes: 91960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<long long, long long> > vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

struct que {
    int a;
    int b;
    int c;
    ll d;
};

int N, M, Q;

vector<que> q;
ll ans;

ll check(vector<int> x, vector<que> q)
{
    ll tmp = 0;

    rep(i, Q)
    {
        if (x[q[i].b] - x[q[i].a] == q[i].c) {
            tmp += q[i].d;
        }
    }

    return tmp;
}

int cnt = 0;
void dfs(vector<int> x, int j)
{
    /*rep(i, N)
    {
        cout << x[i] << ' ';
    }
    cout << endl;*/
    cnt++;
    // rep (i, N) {
    //   cout << x[i] << ' ';
    // }
    // cout << endl;
    bool flag = true;
    rep(i, N)
    {
        if (x[i] < M) {
            flag = false;
        }
    }
    if (flag) {
        ll tmp = check(x, q);

        chmax(ans, tmp);
        return;
    }

    ll tmp = check(x, q);

    chmax(ans, tmp);

    if (j >= 0) {
        if (j < N - 1) {
            for (int i = 2; i <= x[j + 1]; i++) {
                x[j] = i;
                dfs(x, j - 1);
            }
        } else {
            for (int i = 2; i <= M; i++) {
                x[N - 1] = i;
                dfs(x, N - 2);
            }
        }
    }
}


int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N >> M >> Q;

    vector<int> pos(N, 1);

    ans = 0;

    q.resize(Q);
    rep(i, Q)
    {
        cin >> q[i].a >> q[i].b >> q[i].c >> q[i].d;
        --q[i].a;
        --q[i].b;
    }


    dfs(pos, N - 1);
    // cout << cnt << endl;

    cout << ans << endl;
}


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

int main()
{
  int H,N,i;
  int A,totalA=0;

  scanf("%d%d",&H,&N );

  for(i=0; i<N; i++){
    scanf("%d", &A);
    totalA += A;
  }

  if(totalA >= H)
    printf("Yes");
  else
    printf("No");

  return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }

bool isprime(long long int val) {
 if (val <= 1)return false;
 for (long long int i = 2; i*i <= val; i++) {
   if (val%i == 0LL)return false;
 }
 return true;//素数
}

int main(int argc, char const *argv[]) {
  int q;
  cin >> q;
  vector<int> l(q),r(q);
  rep(i,q) cin >> l[i] >> r[i];
  vector<int> f(100010,0);
  rep(i,100010){
    if(i%2==0) continue;
    if(isprime(i) && isprime((i+1)/2)) f[i]=1;
  }

  vector<int> cnt(100010,0);
  rep(i,100010){
    cnt[i+1]=cnt[i]+f[i];
  }

  rep(i,q){
    cout << cnt[r[i]+1]-cnt[l[i]] << endl;
  }
  return 0;
}


Measured memory_bytes: 2176
#include <algorithm>	//sort, binary_search等々
#include <functional>	//greaterなど
#include <iomanip>		//各種マニピュレータ
#include <iostream>		//基本入出力
#include <string>		//文字列処理
#include <vector>		//STLの花形vector
using namespace std;

int today(int y, int m, int d){
	int day = 0, uruu;
	uruu = static_cast<int>((y - 1) / 3);
	day += ((y - 1) - uruu) * (20 * 5 + 19 * 5);
	day += uruu * 20 * 10;
	if((y % 3) == 0){
		day += (m - 1) * 20;
		day += d;
	}else{
		for(int i = 1; i < m; i++){
			if(i % 2 == 1){
				day += 20;
			}else{
				day += 19;
			}
		}
		day += d;
	}
	return day;
}

int main(){
	int n, y, m, d, day = today(1000, 1, 1);

	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> y >> m >> d;
		cout << (day - today(y, m, d)) << "\n";
	}
	cout << flush;

/*	nums_n = new int[n];
	for(int i = 0; i < n; i++){
		cin >> tmp;
		nums_n[i] = tmp;
		nums_v.push_back(tmp);
	}
	cout << nums_n[0] << nums_n[n - 1] << "\n";
	cout << *nums_v.begin() << *nums_v.end() << "\n";
	cout << flush;

	while(1){
		cin >> n;
		if(n == 0)
			break;
		
	}

	delete [] nums_n;*/

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
using namespace std;
    
int main(){
    unsigned long long a,b,x,num;
    cin >> a >> b >> x;
    num = b/x+1;
    if(a>=1)   num -= ((a-1)/x+1);
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int start, end;
  if (a < c) {
    start = c;
  } else {
    start = a;
  }
  if (b < d) {
    end = b;
  } else {
    end = d;
  }
  int ans = end - start;
  if (ans < 0) {
    cout << 0 << endl;
  } else {
    cout << ans << endl;
  }
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(void)
{
    string day[7] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
    int eotm[] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
    int m, d;
    
    while(true)
    {
        cin >> m >> d;
        if(m == 0) break;
        for (int i=0; i<m; i++) {
            d += eotm[i];
        }
        cout << day[d%7] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1192
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,c,k,a[100005],o,ans;
int main(){
    scanf("%d%d%d",&n,&c,&k);
    for(int i=1;i<=n;++i)scanf("%d",a+i);
    sort(a+1,a+n+1);
    o=1,ans=1;
    for(int i=2;i<=n;++i)if(i-o>=c||a[o]+k<a[i])o=i,++ans;
    printf("%d\n",ans);  
    //system("pause");
    return 0;
}


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

int main()
{
	int arr[100],n,cnt=0,min_i;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> arr[i];
	for (int i = 0; i < n; i++)
	{
		min_i = i;
		for (int j = i + 1; j < n; j++)
		{
			if (arr[min_i] > arr[j])min_i = j;
		}
		if (min_i != i)
		{
			swap(arr[min_i], arr[i]);
			cnt++;
		}
	}
	for (int i = 0; i < n; i++)
	{
		cout << arr[i];
		if (i != n - 1)cout << " ";
	}
	cout << endl << cnt << endl;
	return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define sz(a) int(a.size())
#define pb(x) push_back(x);
#define ll long long
#define ii pair<ll,ll>
#define Long long long
#define MAX_N 3
#define MOD 1000000007

int main() {
    int n;cin>>n;
    vector<ii>a(n);
    for(int i = 0;i <n;i++){
        cin>>a[i].first>>a[i].second;
    }
    sort(a.begin(),a.end());
    long double total = 0;
    ll c = 0;
    do{
        for(int i = 0;i <n-1;i++){
            ll dx = a[i].first-a[i+1].first;
            ll dy = a[i].second-a[i+1].second;
            total += sqrt(dx*dx+dy*dy);
        }
        c++;
    }while(next_permutation(a.begin(),a.end()));
    printf("%.8Lf\n",total/c);
}

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

#define ll long long
#define vl vector<ll>
#define fo(i,a,b) for(ll i=a; i<b; i++)
#define PI 3.14159265359

int main(){
    ll R;
    cin >> R;

    cout << 2*R*PI << endl;
}

/*
　 ◇　　　　 ミ ◇
　◇◇　 /￣|　 ◇◇
◇◇＼　 L＿| ◇◇
　　彡Ｏ(・＿・)/
　 　　ヽ Ｐ`Ｏ
　　 ／彡#_|ミ＼
　　　 </LL凵>
　　　　∪ ∪
pass system test !!
*/

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ll n;
	cin>>n;
	ll A[n],B[n],C[n-1];
	for(ll i=0;i<n;++i){
		cin>>A[i];
	}
	for(ll i=0;i<n;++i){
		cin>>B[i];
	}
	for(ll i=0;i<n-1;++i){
		cin>>C[i];
	}
	ll ans=B[A[0]-1];
	for(ll i=1;i<n;++i){
		ans+=B[A[i]-1];
		if(A[i]==A[i-1]+1)
			ans+=C[A[i-1]-1];
		// cout<<ans<<endl;
	}
	cout<<ans<<endl;
}

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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll = V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define INF 1e16
#define mod 1e9+7


int main(){
  ll n;
  cin>>n;
  ll ans;
  for(ll i=1;i<(n-i)/i;i++){
    // i/ikesi
    if((n-i)%i==0){
      ans+=(n-i)/i;
    }
  }
  co(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
const unsigned long long int MAX_ans = 1e+18;
int main() {
    int N;
    cin >> N;
    unsigned long long int ans = 1;
    bool T = false;
    for (int i = 0; i < N; ++i) {
        unsigned long long int input = 0;
        cin >> input;
        if (input == 0) {
            cout << 0 << endl;
            return 0;
        }
        if (T || __int128(ans) * input > MAX_ans) {
            T = true;
        }
        ans *= input;
    }
    if (T) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007

#A
a = input()
b = input()
if a[2] == b[0] and a[1] == b[1] and a[0] == b[2]:
    print("YES")
else:
    print("NO")

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

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

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N, L, Q;
  cin >> N;
  vector<int> x(N);
  REP(i,N) cin >> x[i];
  cin >> L >> Q;

  vector<vector<int>> r(20, vector<int> (N));
  REP(i,N) {
    r[0][i] = upper_bound(ALL(x), x[i] + L) - x.begin() - 1;
  }
  REP(k,19)REP(i,N) r[k + 1][i] = r[k][r[k][i]];

  REP(i,Q) {
    int a, b;
    cin >> a >> b; --a; --b;
    if(a > b) swap(a, b);
    int res = 0;
    for(int j = 19; j >= 0; --j) {
      if(r[j][a] < b) {
        a = r[j][a];
        res += (1 << j);
      }
    }
    cout << res + 1 << endl;
  }
  return 0;
}



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

int main() {
  int H, W, n, m;
  cin >> H >> W;
  vector<string> a(H);
  for(n = 0; n < H; n++){
    cin >> a.at(n);
  }
  for(m = 0; m < W + 2 ; m++){
    cout << '#';
  }
  cout << endl;
  for(n = 0; n < H; n++){
    cout << '#' << a.at(n) << '#' << endl;
  }
  for(m = 0; m < W + 2; m++){
    cout << '#';
  }
  cout << endl;
}

Measured memory_bytes: 256