akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <bool Directed, typename TEdge, bool Index> struct graph {
    using EType = TEdge;
    vector<TEdge> edges;
    vector<vector<int>> adj;
    graph(int n) : adj(n + Index) {}
    graph(int n, int m) : graph(n) { edges.reserve(m << not Directed); }
    TEdge& operator()(int e) { return edges[e]; }
    vector<int>& operator[](int u) { return adj[u]; }
    int size() { return adj.size() - Index; }
    void add_edge(const TEdge& e) {
        adj[e.u].push_back(edges.size());
        edges.push_back(e);
        if(not Directed) {
            adj[e.v].push_back(edges.size());
            edges.push_back(e.reverse());
        }
    }
};
struct edge {
    int u, v;
    edge reverse() const { return {v, u}; }
    friend ostream& operator<<(ostream& os, const edge& e) {
        return os << "(" << e.u << ", " << e.v << ")";
    }
};
template <bool Index> pair<vector<int>, vector<vector<int>>> find_2eccs(graph<0, edge, Index>& g) {
    vector<int> vis(g.adj.size()), low(g.adj.size()), cut_edge(g.edges.size()), s;
    vector<vector<int>> _2eccs = {};
    int timer = 1;
    function<void(int, int)> dfs = [&](int u, int from) {
        vis[u] = low[u] = timer++;
        s.push_back(u);
        for(int e : g[u]) {
            if(not vis[g(e).v]) {
                dfs(g(e).v, e & ~1);
                if(vis[u] < low[g(e).v]) {
                    cut_edge[e] = cut_edge[e ^ 1] = true;
                    _2eccs.push_back(vector<int>());
                    do {
                        _2eccs.back().push_back(s.back()), s.pop_back();
                    } while(_2eccs.back().back() != g(e).v);
                }
                low[u] = min(low[u], low[g(e).v]);
            } else if((e & ~1) != from and vis[u] > vis[g(e).v]) {
                low[u] = min(low[u], vis[g(e).v]);
            }
        }
    };
    for(int u = Index; u < g.adj.size(); u++) if(not vis[u]) {
        dfs(u, -1);
        _2eccs.push_back(vector<int>());
        while(not s.empty()) {
            _2eccs.back().push_back(s.back()), s.pop_back();
        }
    }
    return {cut_edge, _2eccs};
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    graph<0, edge, 1> g(n, m);
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        g.add_edge({u, v});
    }
    auto p = find_2eccs(g);
    cout << count(p.first.begin(), p.first.end(), 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
A=[int(i) for i in input().split()]
S=[0 for i in range(N+1)]
for i in range(N):
  S[i+1]=(S[i]+A[i])%M
D=dict()
ans=0
for i in range(N+1):
  if S[i] in D:
    D[S[i]]+=1
  else:
    D[S[i]]=1
  ans+=D[S[i]]-1
print(ans)


Measured memory_bytes: 16184
#include <stdio.h>

int main(void)
{
    int n;

    scanf("%d", &n);

        if (n > 0 && n < 1000)
    {
        printf("ABC\n");
    }

    else if (n > 999 && n < 1999)
    {
        printf("ABD\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <sys/timeb.h>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll LINF = 1e18;
const int INF = 1e9;
const int mod = 1e9+7;

int main(){
    int n, k, sum =0, ans;
    int mina = INF;
    cin >> n >> k;
    vector<int> a(n);
    
    REP(i, n){
        a[i] = k+i;
        sum+=a[i];
        if(abs(a[i]) < mina){
            mina = abs(a[i]);
            ans = a[i];
        }
    }
    
    cout << sum - ans<< endl;
}


Measured memory_bytes: 256
v = [int(d) for d in input().split()]

LM = []
for d in range(v[1]):
   LM.append([int(d) for d in input().split()])

L = [d[0] for d in LM]
M = [d[1] for d in LM]
L.sort()
M.sort()
if L[-1] <= M[0]:
    if M[0] <= v[0]:
        print(M[0]-L[-1]+1)
        exit()
    else:
        print(v[0]-L[-1]+1)
        exit()
else:
    print('0')

Measured memory_bytes: 23244
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
long const M=1000000007;
ll po(ll x, ll y) {
    ll t; 
    if( y == 0) 
        return 1; 
    t = po(x, y/2); 
    if (y%2 == 0) 
        return t*t; 
    else
        return x*t*t; 
} 

int main() {
    ll a , b ,c,d,numc,numl,numd ;
    cin >> a >>b >> c >>d;
    ll l = (c*d)/__gcd(c,d) ;
    if(a % c ==0)
        numc = b/c-a/c+1 ;
    else
        numc = b/c-a/c ;
    if(a%d ==0)
        numd = b/d-a/d+1 ;
    else
        numd = b/d-a/d ;
    if(a%l==0)
        numl = b/l-a/l +1;
    else
        numl = b/l-a/l ;
    cout << b-a + 1-(numc+numd-numl )<< endl ;
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?n=0,false:(n=in<T>(c),true);}
_SCAN(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

int main() {
	for (int m; (m = in());) {
		int n {in()};
		vector<bool> v(min(7368792, m + n * 15));
		int i {m};
		for (int j {}; j < n; j++) {
			while (v[i])
				i++;
			for (int k = i; k < (int) v.size(); k += i)
				v[k] = true;
		}
		while (v[i])
			i++;
		outl(i);
	}
}


Measured memory_bytes: 3440
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
int mod = 998244353;
// int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
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; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int T;
  T = 1;
  while (T--) solve();
}

// https://www.youtube.com/watch?v=WhDtakdCPg4
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;

  vector<vector<ll> > dp(n + 1, vector<ll>(5, INF));
  dp[0][0] = 0;
  rep(i, n) {
    // 0 to 2 (1 をとばす) とかもありうる
    rep(j, 5) rep(k, j + 1) { // k to j
      ll add = a[i]; // j = 0, 4
      if (j == 1 || j == 3) { if (a[i] == 0) add = 2; else if (a[i] % 2) add = 1; else add = 0; } // debuged, かっこ大事
      else if (j == 2) { if (a[i] % 2) add = 0; else add = 1; }

      chmin(dp[i + 1][j], dp[i][k] + add);
    }
  }
  cout << *min_element(all(dp[n])) << endl;
  // rep(i, n + 1) { rep(j, 5) cout << dp[i][j] << " "; cout << endl; }
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define fr(i, n) for (i = 0; i < n; i++)
#define rep(i, n) for (i = 1; i <= n; i++)
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout << "----------------------------------\n";
#include <iostream>

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}; // trick to explore an implicit 2D grid
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; // S,SE,E,NE,N,NW,W,SW neighbors  //GO FOR EVEN FOR 4 moves

#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

set<int> red_pos, white_pos;
int c1()
{
    //red-<last
    auto ptr = red_pos.end();
    advance(ptr, -1);
    int pos_r = *ptr;
    debug(pos_r);
    return pos_r;
}

int c2()
{
    auto ptr2 = white_pos.begin();
    int pos_w = *ptr2;
    return pos_w;
    debug(pos_w);
}

bool check()
{
    if(c2()<c1())
    {
        return true;
    }
    else
    {
        false;
    }
    
}
int main()
{
    fastinput;
    LL n, i, j, k, t, temp, tc;
    LL cnt = 0;
    priority_queue<int> q1,q2;
    LL len;
    cin >> len;
    n = len;
    string s;
    cin >> s;
    for (i = 0; i < n; i++)
    {
        if (s[i] == 'R')
        {
            q1.push(i);
        }
        else
        {
            q2.push(-i);
        }
    }
    if (q1.size() == 0 || q2.size() == 0)
    {
        cout << 0 << endl;
        return 0;
    }

    while(true)
    {
        int r_last=q1.top();
        int w_first=-q2.top();
        if(w_first<r_last)
        {
            q1.pop();
            q2.pop();
            cnt++;
            q1.push(w_first);
            q2.push(-r_last);
        }
        else
        {
            break;
        }
        
    }
    cout<<cnt<<endl;
    
    return 0;
}


Measured memory_bytes: 4764
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 2005000000
#define MOD 1000000007
#define N 100005
#define M 100000000
#define LOG 20
#define KOK 4000000
using namespace std;

int n,x,y;
int ata[N];
unordered_multiset<int> s[N];
unordered_map<int,int> cnt[N];
queue<ii> q;

int bul(int node) {

	if(node==ata[node]) return node;

	return ata[node]=bul(ata[node]);

}

void merge(int x,int y) {

	if(x==y) return ;

	if(sz(s[x])<sz(s[y])) swap(x,y);

	ata[y]=x;

	for(auto go:s[y]) {

		s[go].erase(s[go].find(y));
		
		if(x!=go) {
		
			s[x].insert(go);
			s[go].insert(x);

		}

		int val=--cnt[min(y,go)][max(y,go)];

		if(!val) cnt[min(y,go)].erase(cnt[min(y,go)].find(max(y,go)));

		if(x!=go) {
		
			val=++cnt[min(x,go)][max(x,go)];

			if(val==2) q.push({x,go});

		}

	}

	s[y].clear();

}

int main() {

	//freopen("input.txt","r",stdin);

	scanf("%d",&n);

	for(int i=1;i<2*n-1;i++) {

		scanf("%d %d",&x,&y);

		if(x>y) swap(x,y);

		s[x].insert(y);
		s[y].insert(x);

		cnt[x][y]++;

	}

	for(int i=1;i<=n;i++) {

		for(auto x:cnt[i]) {

			if(x.nd==2) {

				q.push({i,x.st});

			}

		}

		ata[i]=i;

	}

	while(!q.empty()) {

		ii p=q.front();

		q.pop();

		merge(bul(p.st),bul(p.nd));

	}

	int tot=0;

	for(int i=1;i<=n;i++) {

		tot+=(bul(i)==i);

	}

	printf(tot==1?"YES":"NO");

}

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

int main(void){
  int W,H,c=0;
  while(c==0){
  cin >> H >> W;
  if(H+W==0)break;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      if(i%2==0 && j%2==0)cout << '#';
      else if(i%2!=0 && j%2!=0)cout << '#';
      else cout << '.';
    }
    cout << endl;
  }
  cout << endl;
}

  return 0;
}

Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {

    private static int H;
    private static int W;
    private static int A;
    private static int B;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        H = sc.nextInt();
        W = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();
        System.out.println( solve() );
    }

    private static int solve() {
        Comb comb = new Comb(H + W);

        // first
        // (0, 0) to [(B, H-A-1)..(W-1, H-A-1)]
        // second
        // [(B, H-A)..(W-1, H-A)] to (W-1, H-1)
        int ans = 0;
        for (int i = 0; i < W-B; i++) {
            int x = B + i;
            int y_first = H-A-1;
            int first = calcWay(x, y_first, comb);

            int y_second = y_first+1;
            int second = calcWay(W-1 - x, H-1 - y_second, comb);

            ans = sum(ans, mul(first, second));
        }
        return ans;
    }

    private static int calcWay(int dw, int dh, Comb comb) {
        if( dw < 0 || dh < 0 ) throw new IllegalArgumentException("wtf : " + dw + " " + dh);
        if( dw == 0 || dh == 0 ) return 1;
        return comb.get(sum(dw, dh), dw);
    }

    private static final int MOD = 1_000_000_007;

    private static int mul(int a, int b) {
        long ab = (long)a * b;
        return (int)(ab % MOD);
    }

    private static int sum(int a, int b) {
        long ab = (long)a + b;
        return (int)(ab % MOD);
    }

    private static int pow(int base, int exp) {
        if( exp == 0 ) return 1;

        int ans = 1;
        base %= MOD;
        while( exp > 0 ) {
            if( (exp & 1) == 1 ) {
                ans = mul(ans, base);
            }

            base = mul(base, base);
            exp = exp >> 1;
        }
        return ans;
    }

    private static class Comb {

        private int[] factorial;
        private int[] factorialInverse;

        Comb(int size) {
            factorial = new int[size + 1];
            factorialInverse = new int[size + 1];
            factorial[1] = 1;
            factorialInverse[1] = 1;
            for (int i = 2; i <= size; i++) {
                factorial[i] = mul(factorial[i-1], i);
                factorialInverse[i] = pow(factorial[i], MOD-2);
            }
        }


        int get(int n, int k) {
            return mul(mul(factorial[n], factorialInverse[k]), factorialInverse[n - k]);
        }
    }
}

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

using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

/* [💭] [💡] [🎈] */

int h[100000];
bitset<100000> flags;

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

    int n, m;
    cin >> n >> m;
    flags.flip();

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

    while (m--) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        if (h[u] > h[v]) flags[v] = false;
        if (h[u] < h[v]) flags[u] = false;
        if (h[u] == h[v]) {
            flags[u] = flags[v] = false;
        }
    }

    int c = 0;
    for (int i = 0; i < n; i++) c += flags[i];
    cout << c;

    return 0;
}

Measured memory_bytes: 4056
#include <iostream>

using namespace std;

int main()
{
  int n, k; cin >> n >> k;
  int a[n]; for (int i = 0; i < n; ++i) cin >> a[i];
  
  bool dp[200200] = {};
  for (int i = 0; i <= k; ++i)
    if (!dp[i]) for (int ch: a) dp[i+ch] = true;
  
  if (dp[k]) cout << "First" << endl;
  else cout << "Second" << endl;
  return 0;
}

Measured memory_bytes: 384
n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(len(l)):
  for j in range(i+1, len(l)):
    for k in range(j+1, len(l)):
      if l[k] < l[i]+l[j] and l[i]!=l[j] and l[j]!=l[k]:
        ans += 1

print(ans)

Measured memory_bytes: 9172
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  vector<ll> x,y;
  ll Rmax=0,mi=1e10;
  int mat=0;
  for(int i=0;i<n;i++){
    ll a,b;
    cin>>a>>b;
    if(a>b) swap(a,b);
    x.push_back(a);
    y.push_back(b);
    if(Rmax<b){
      Rmax=b;
      mat=i;
    }
    mi=min(mi,a);
  }

  ll ansDif=0;
  ll Rmin=Rmax,Bmin=mi,Bmax=x[mat];
  for(int i=0;i<n;i++){
    Bmin=min(Bmin,x[i]);
    Rmin=min(Rmin,y[i]);
    Bmax=max(Bmax,x[i]);
  }
  ansDif=(Rmax-Rmin)*(Bmax-Bmin);
  //cout<<ansDif<<endl;

  ll ansSame=ansDif;
  Rmin=mi;Bmin=1e10;
  vector<pair<ll,ll>> v;
  for(int i=0;i<n;i++){
    v.push_back(make_pair(x[i],y[i]));
  }
  sort(v.begin(),v.end());
  for(int i=0;i<n;i++){
    Bmin=min(Bmin,v[i].second);
    Bmax=max(Bmax,v[i].second);
    if(i==n-1) ansSame=min(ansSame,(Rmax-Rmin)*(Bmax-Bmin));
    else{
      ansSame=min(ansSame,(Rmax-Rmin)*(Bmax-(min(Bmin,v[i+1].first))));
    }
  }

  cout<<min(ansSame,ansDif)<<endl;
  return 0;
}


Measured memory_bytes: 9572
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n) for(i=0;i<n;i++)
#define ll long long
#define ull unsigned long long int
#define fast  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            int t; cin>>t; while(t--)
const int MOD = 1000000007;
ll mod(ll x){
    return (x%MOD + MOD)%MOD;
}
ll mul(ll a , ll b){
    return mod(mod(a)*mod(b));
}
bool comp(pair<ll,ll>& a, pair<ll,ll>& b)
{
    if(a.second == b.second)
    return a.first > b.first;
    else
    return b.second < a.second;
}
static int rowNbr[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
static int colNbr[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
int main()
{
    fast


        ll n,d;
        cin>>n>>d;
        int cnt=0;
        int i=0;
        fo(i,n)
        {
            ll x,y;
            cin>>x>>y;
            if((x*x+y*y) <= d*d)
            {
                cnt++;
            }

        }
        cout<<cnt<<endl;


    return 0;
}





Measured memory_bytes: 3620
#include <bits/stdc++.h>
// using namespace std;
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace edamat {
template <class T>
struct CumulativeSum {
    ::std::vector<T> data;

    CumulativeSum(){};
    CumulativeSum(int sz) : data(sz, 0){};
    CumulativeSum(::std::vector<T> v) { build(v); }

    void add(int k, T x) { data[k] += x; }
    void build() {
        for(int i = 1; i < data.size(); i++) data[i] += data[i - 1];
    }
    void build(::std::vector<T> &v) {
        data = v;
        for(int i = 1; i < data.size(); i++) data[i] += data[i - 1];
    }
    T query(int k) {
        if(k < 0) return (0);
        return (data[::std::min(k, (int)data.size() - 1)]);
    }
    T query(int l, int r) {
        if(l < 0 || r > data.size()) return (0);
        return query(r - 1) - query(l - 1);
    }
    T operator[](int k) { return query(k - 1); }
};
}  // namespace edamat

void AGC023_A() {
    int N;
    std::cin >> N;
    std::vector<i64> a(N);
    rep(i, N) std::cin >> a[i];

    // 累積和と連想配列
    std::map<i64, i64> nums;
    edamat::CumulativeSum<i64> s(a);
    for(int i = 0; i < N + 1; ++i) nums[s[i]]++;

    // 集計処理
    i64 res = 0;
    for(auto it : nums) {
        i64 num = it.second;  // it.first が it.second 個ある
        res += num * (num - 1) / 2;
    }
    std::cout << res << std::endl;
}

int main() {
    AGC023_A();
    return 0;
}

Measured memory_bytes: 15844
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int count = 0;

		ArrayList<Integer> array_number = new ArrayList<>();


		//入力
		int first_input = sc.nextInt();
		array_number.add(first_input);

		int second_input = sc.nextInt();
		array_number.add( second_input);

		int third_input = sc.nextInt();
		array_number.add(third_input);

		//入力された文字を昇順に並べる
		Collections.sort(array_number);

		int a = array_number.get(0);
		int b = array_number.get(1);
		int c = array_number.get(2);

		while (a+2 <= c) {
			a = a + 2;
			count ++;
		}

		while (b+2 <= c) {
			b = b + 2;
			count ++;
		}


		if (a + 1== c && b + 1 == c) {
			count ++;
		}

		else if (a + 1 == c || b + 1 == c){
			count = count + 2;
		}

		else {
			count = count + 0;
		}

		System.out.println(count);

	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < n; ++i)
using namespace std;
const int INF = 2147483647;
using ll = long long;
// cout << typeid('変数').name() << endl;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0;i<n;++i){
        cin >> a.at(i);
    }
    map<int,int> mp;
    for(int i=0;i<n;++i){
        mp[a.at(i)]++;
    }
    int cnt=0;
    for (auto i:mp){
        if(i.second>i.first)   
            cnt+=i.second-i.first;
        else if(i.first>i.second)
            cnt+=i.second;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 5120
from math import ceil

def main():
    S = list(input())
    num_r = 0
    num_l = 0
    agg = []
    pos = [0 for _ in range(len(S))]
    for i in range(len(S)-1):

        if S[i] == "R":
            num_r += 1

        elif S[i] == "L":
            num_l += 1

        if S[i] == "R" and S[i+1] == "L":
            agg.append((i, num_r))
            num_r = 0
        elif S[i] == "L" and S[i+1] == "R":
            agg.append((i, num_l))
            num_l = 0

        if i == len(S) - 2:
            num_l += 1
            agg.append((i, num_l))
            num_l = 0

    # length of agg is always even number
    for i in range(0, len(agg)-1, 2):
        idx = agg[i][0]
        r_num = ceil(agg[i][1] / 2) + agg[i+1][1] // 2
        l_num = agg[i][1] - ceil(agg[i][1] / 2) + agg[i+1][1] - agg[i+1][1] // 2
        pos[idx] = r_num
        pos[idx+1] = l_num
    print(*pos)


if __name__ == '__main__':
    main()


Measured memory_bytes: 17296
# -*- coding: utf-8 -*-
import time
import numpy as np

start = time.time()
limit_time = 1.8

# 整数の入力
d = int(input())
c = [int(i) for i in input().split()]
s = [[int(i) for i in input().split()] for j in range(d)]

def point(t):
    result = 0
    map = {
        0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0,
        10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0, 18: 0, 19: 0,
        20: 0, 21: 0, 22: 0, 23: 0, 24: 0, 25: 0
    }
    for i in range(d):
        comp = t[i] - 1
        day = i + 1
        map[comp] = day
        result = result + s[i][comp]
        for cc in range(26):
            result = result - c[cc] * (day - map[cc])
        print(result)
    return result

t = [int(input()) for i in range(d)]

point(t)

Measured memory_bytes: 27608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  int s;
  s = 0;
  
  if(a > b){
    s = 2 * a - 1;
  }
  else if (a == b){
    s = 2 * a;
  }
  else{
    s = 2 * b - 1;
  }
  cout << s << endl;
}

  

Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
 
  /* 数値（整数） */
  int a;
 
  /* 変数 */
  int reverse = 0;
  int remaind;
  int tmp;
 
  /* 数値（整数）の入力 */
  printf("");
  scanf("%d", &a);
if(100<=a&&a<=999){
  tmp = a;
  while(tmp!=0)
  {
    /* 1桁ずつ数値を切り出す */
    remaind = tmp % 10;
 
    /* 数値を反転 */
    reverse = reverse * 10 + remaind;
 
    /* 次の桁へシフト */
    tmp /= 10;
  }
 
  /* 反転した数値と元の数値を比較 */
    if( reverse == a ){
        printf("Yes\n", a);
    }
    else
    {
        printf("No\n", a);
    }
}
else
{
    printf("error");
}
    
    
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)

using namespace std;
typedef long long ll;
ll s(ll x) {
  ll re = 0;
  while (x > 0) {
    re += x % 10;
    x /= 10;
  }
  return re;
}

bool cmp(ll x, ll y) {
  return x*s(y) <= y * s(x);
}

void solve(int K) {
  ll d = 1, cur = 0;
  rep(i, K) {
    ll x = cur + d;
    ll y = cur + d * 10;
    if (cmp(x, y)) {
      cur = x;
    } else {
      cur = y;
      d *= 10;
    }
    cout << cur << endl;
  }
}

int main() {
  int K;
  cin >> K;
  solve(K);
  return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
List = list(map(int, input().split()))
 
def imosu(x,k):
  data = [0]*k
  for i in range(k):
    first = i-x[i]
    last = i+x[i]
    if first < 0:
      first = 0
    data[first] += 1
    if last+1 < k:
      data[last+1] +=-1
  ruiseki = [0]*k
  ruiseki[0] = data[0]
  for i in range(k-1):
    ruiseki[i+1] = ruiseki[i] + data[i+1]
  return ruiseki
 
for i in range(K):
  List = imosu(List,N)
  if List.count(N) == N:
    break
print(*List)


Measured memory_bytes: 141816
N = int(input())
h = list(map(int,input().split()))
 
dp = [float('inf')]*N
 
dp[0] = 0
dp[1] = abs(h[1]-h[0])
 
for i in range(2,N):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
 
print(dp[N-1])

Measured memory_bytes: 85576
#include <stdio.h>
#include <math.h>

double area(double a, double b, double c) {
  double z = (a + b + c) / 2;
  double s = sqrt(z * (z-a) * (z-b) * (z-c));
  return s;
}

int main(void) {
  double x[20], y[20], s[18], ans = 0;
  int i = 0, n, t1, t2;

  while (scanf("%lf,%lf", &x[i], &y[i]) != EOF) {
    i++;
  }
  n = i - 2;
  t1 = 1;
  t2 = 2;

  for (i = 0; i < n; i++) {
    s[i] = area(sqrt((x[t2]-x[t1])*(x[t2]-x[t1])+(y[t2]-y[t1])*(y[t2]-y[t1]))
		, sqrt((x[t1]-x[0])*(x[t1]-x[0])+(y[t1]-y[0])*(y[t1]-y[0]))
		, sqrt((x[t2]-x[0])*(x[t2]-x[0])+(y[t2]-y[0])*(y[t2]-y[0])));
    t1++;
    t2++;
  }
  for (i = 0; i < n; i++)
    ans += s[i];
  printf("%lf\n", ans);

  return 0;
}

Measured memory_bytes: 652
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <boost/format.hpp>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;

  const regex re((boost::format("^\\d{%d}-\\d{%d}$") % A % B).str());
  cout << (regex_match(S, re) ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3876
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

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

long long com(long long n,long long k){
	
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	string t;
	int a,b;
	cin>>s;
	if(s.length()==2){
		cout<<s<<endl;
	}else{
		reverse(s.begin(),s.end());
		cout<<s<<endl;
	}
}

	


Measured memory_bytes: 256
n = int(input())
ans=[0]*4
for _ in range(n):
    s=str(input())
    if s == 'AC':
        ans[0] +=1
    elif s == 'WA':
        ans[1] += 1
    elif s == 'TLE':
        ans[2] += 1
    else:
        ans[3] += 1
print('AC x '+ str(ans[0]))
print('WA x '+ str(ans[1]))
print('TLE x '+ str(ans[2]))
print('RE x '+ str(ans[3]))

Measured memory_bytes: 9216
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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


int n, ans;
int a[200005];

int main() {

	cin >> n;
	rep(i, n) {
		cin >> a[i];
		ans = ans ^ a[i];
	}

	rep(i, n) {
		cout << (ans ^ a[i]) << " ";
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 4420
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

ll cnt(ll n){
  if (n <= 0) return 1;
  else if (n == 1) return 2;
  else if (n == 2) return 3;
  else return cnt(n-1) + cnt(n-2);
}

int main() {
  ll h, w, k;
  cin >> h >> w >> k;
  ll A[h+1][w+2];
  A[0][1] = 1;
  for (int i=2;i<=w;i++) A[0][i] = 0;
  for (int i=0;i<=h;i++) {
    A[i][0] = 0; 
    A[i][w+1] = 0;
  }
  
  //for (int i=0;i<=8;i++) cout << cnt(i) << endl;
  
  for (int i=1;i<=h;i++){
    for (int j=1;j<=w;j++){
      ll le = (A[i-1][j-1]*cnt(j-3)*cnt(w-j-1)) % MOD;
      ll st = (A[i-1][j]*cnt(j-2)*cnt(w-j-1)) % MOD;
      ll ri = (A[i-1][j+1]*cnt(j-2)*cnt(w-j-2)) % MOD;
      A[i][j] = (le+st+ri)%MOD;
      //cout << i << " " << j << " " << A[i][j] << endl;
    }
  }
  
  cout << A[h][k] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
/*
	BubbleSort(A)
	for i = 1 to length[A]
		do for j = length[A] downto i+1
			do if A[j] < A[j-1]
				then swap A[j] and A[j-1]
*/
int main()
{
//	cut here before submit 
//	freopen ("testcase.bubble_sort", "r", stdin );
	int n, m;
	scanf ("%d", &n );
	vector<int> A(n, 0 );
	rep (i, n ){
		scanf (" %d", &A[i] );
	} // end rep

	int res = 0;
	rep (i, n ){
		for (int j = n - 1; j >= i+1; j-- ){
			if (A[j] < A[j-1] ){
				swap (A[j], A[j-1] );
				res++;
			} // end if
		} // end for
	} // end rep

	rep (i, n ){
		cout << A[i] << (i != n - 1 ? ' ' : '\n' );
	} // end rep
	cout << res << endl;
		
	return 0;
}

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

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

    if (n >= 100) {
        n = n % 100;
        n = n % 10;
    } else if (n >= 10) {
        n = n % 10;
    } else {
        ;
    }

    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
        cout << "hon" << endl;
    else if (n == 0 || n == 1 || n == 6 || n == 8)
        cout << "pon" << endl;
    else 
        cout << "bon" << endl;

    return 0;
}

Measured memory_bytes: 3620
#list全要素にadd 1
def add_list(LIST):
    return LIST +1
####################################
def flatten(nested_list):
    """2重のリストをフラットにする関数"""
    return [e for inner_list in nested_list for e in inner_list]
####################################

N, K = (int(x) for x in input().split())
List_1 = []
List_2 = []
for  i in range(K):
    List_1.append([int(input())])
    List_2.append([int(y) for y in input().split()])

men = list(range(N))
men_add = list(map(lambda z: z + 1, men))

flatten_list = flatten(List_2)

#人のlistの中から、お菓子を持っている人を削除。listに値がないとエラーになるので、例外処理も追加
for j in range(len(set(flatten_list))):
    try:
        men_add.remove(j+1)
    except ValueError:
        pass

print(len(men_add))



Measured memory_bytes: 9388
main:: IO ()
main = do
    [n,a,b,c,d] <- (map read . words) <$> getLine
    putStrLn $ if solve (n-1) (b-a) (c,d) then "YES" else "NO"

solve :: Int -> Int -> (Int, Int) -> Bool
solve n' k (c,d) = any f [n'*d, n'*d-(c+d) .. 0]
  where f x = x-(d-c)*n' <= abs k && abs k <= x

Measured memory_bytes: 1020
using System;
class uneven{
  public static void Main(){
    String str = Console.ReadLine();
    int count=0;
    if(str.Length%2==0){
      for(int i=1; i<str.Length; i+=2){
        count+=9*(int)Math.Pow(10,i-1);
      }
    }
    else{
      for(int i=1; i<str.Length-1; i+=2){
        count+=9*(int)Math.Pow(10,i-1);
      }
      count+=int.Parse(str)+1-(int)Math.Pow(10,str.Length-1);
    }
    Console.WriteLine(count);
  }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld,lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer(x) cout<<endl<<"answer : "<<x<<endl<<endl;
#define op(x) cout<<x<<endl;
#define maxn 500005
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {messi lld t=1;//cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0,l=0,r=0,mid=0,lo=0,hi=0;string s;bool flag=false;
        cin>>n; lld a[n]; for(i=0;i<n;i++) cin>>a[i];
        for(i=1;i<n;i++)
            if(a[i-1]>a[i])
                cnt+=a[i-1]-a[i],a[i]=a[i-1];
        op(cnt);
    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|

*/


Measured memory_bytes: 5196
N = int(input())

hatsugen = [[] for _ in range(N)]
#print(hatsugen)
A = -1
while True:
  try:
  	s = input()
  except EOFError:
    break  
  a = tuple(map(int,s.rstrip().split()))
  #print(a)
  if len(a) == 1:
    A += 1
  else:
    hatsugen[A].append(a)
#print(hatsugen)

ans = 0
for i in range(2**N):
  
  bit = i
  flag = [0]*N
  idx = 0
  while bit:
    if (bit&1):
      flag[idx] = 1
    bit >>= 1
    idx+=1
  
  flag2=0
  #print(flag)
  for i in range(N):
    if flag[i]:
      hatsu = hatsugen[i]
    else:
      continue
    for word in hatsu:
      #print(*word)
      if flag[word[0]-1] != word[1]:
        flag2 = 1
        #print("false")
        break
    if flag2:
      break
  if flag2==0:
    ans = max(ans, sum(flag))

print(ans)
    
  
      
  

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

int main(){
    int64_t a, b, x;
    cin >> a >> b >> x;
    int64_t ans;
    if (a % x == 0) ans ++;
    ans += b / x - a / x;
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
    using namespace std;
    int main()
    {
    	long long m[2][2019] = {};
    	int cur = 0, nxt;
    	long long ans = 0;
    	char c;
    	int dig;
    	while (cin >> c) {
    		if (c == 'i')break;
    		dig = c - '0';
    		nxt = cur ^ 1;
    		for (int i = 0; i < 2019; i++) {
    			m[nxt][i] = 0;
    		}
    		m[cur][0] += 1;
    		for (int i = 0; i < 2019; i++) {
    			m[nxt][(i*10+dig)%2019] += m[cur][i];
    		}
    		cur = nxt;
    		ans += m[cur][0];
    	}
    	cout << ans;
    }

Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
int t[100001];

int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d %d",&a,&b);
    t[a-1]++;
    t[b]--;
  }
  int ans=0;
  for(int i=1;i<=100000;i++){
    t[i]+=t[i-1];
    if(i<=t[i])ans=i;
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

template<class T> inline bool in_range(T y, T x, T H, T W) { return 0<=y&&y<H&&0<=x&&x<W; }

int H, W, D, N;
vector<string> G;
vector<int> R;

int F[55][55];

bool in_square(int y, int x, int i, int j, int s) {
  return x - R[s] <= j && j <= x + R[s] && y - R[s] <= i && i <= y + R[s];
}

void dowsing(int y, int x, int s) {
  rep(i, H) rep(j, W) {
    if(s == D - 1 || in_square(y, x, i, j, s + 1)) {
      F[i][j]++;
    }
    if(s > -1 && in_square(y, x, i, j, s)) {
      F[i][j]--;
    }
  }
}

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

bool broken() {
  rep(i, H) rep(j, W) if(F[i][j] == N) return false;
  return true;
}

bool no() {
  int sy, sx;
  rep(i, H) rep(j, W) if(G[i][j] == 'D') sy = i, sx = j;
  queue<pair<int, int>> q;
  q.emplace(sy, sx);
  vector<vector<bool>> vis(H, vector<bool>(W));
  vis[sy][sx] = 1;
  while(!q.empty()) {
    int y, x; tie(y, x) = q.front(); q.pop();
    if(F[y][x] == N) return false;
    rep(k, 4) {
      int ny = y + dy[k], nx = x + dx[k];
      if(!in_range(ny, nx, H, W)) continue;
      if(G[ny][nx] == '#') continue;
      if(vis[ny][nx]) continue;
      vis[ny][nx] = 1;
      q.emplace(ny, nx);
    }
  }
  return true;
}

bool yes() {
  int sy, sx;
  rep(i, H) rep(j, W) if(G[i][j] == 'D') sy = i, sx = j;
  queue<pair<int, int>> q;
  q.emplace(sy, sx);
  vector<vector<bool>> vis(H, vector<bool>(W));
  vis[sy][sx] = 1;
  while(!q.empty()) {
    int y, x; tie(y, x) = q.front(); q.pop();
    rep(k, 4) {
      int ny = y + dy[k], nx = x + dx[k];
      if(!in_range(ny, nx, H, W)) continue;
      if(G[ny][nx] == '#') continue;
      if(vis[ny][nx]) continue;
      vis[ny][nx] = 1;
      q.emplace(ny, nx);
    }
  }

  rep(i, H) rep(j, W) {
    if(F[i][j] == N && G[i][j] != '#' && !vis[i][j]) return false;
  }
  return true;
}

int main() {

  cin >> H >> W >> D >> N;
  G.resize(H);
  rep(i, H) cin >> G[i];
  rep(i, H) rep(j, W) F[i][j] = 0;
  R.resize(D);
  rep(i, D) cin >> R[i];
  rep(i, N) {
    int y, x, s; cin >> x >> y >> s; s--;
    dowsing(y, x, s);
  }

  if(broken()) {
    cout << "Broken" << endl;
    exit(0);
  } else if(no()) {
    cout << "No" << endl;
  } else {
    cout << (yes() ? "Yes" : "Unknown") << endl;
  }
  
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  long long L[87];
  L[0] = 2;
  L[1] = 1;
  for(int i=2; i<=N; i++){
    L[i] = L[i-1] + L[i-2];
  }
  cout << L[N] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n;
  cin >> n;
  int maxval =0;
  int tmp =0;
  int count = 0;
  REP(i,n ){
    cin >> tmp;
    maxval = max(tmp, maxval);
    if(max(tmp, maxval) == tmp){
      count ++;
    }

  }  
  cout << count << endl;

}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct UnionFind
{
    void init(int n)
    {
        mN = n;
        mNodeTbl.resize(mN);
        mRankTbl.resize(mN);
        REP(i, mN)
        {
            mNodeTbl[i] = i;
            mRankTbl[i] = 0;
        }
    }
    int find(int x)
    {
        if (x == mNodeTbl[x])
            return x;
        return mNodeTbl[x] = find(mNodeTbl[x]);
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
    void unit(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (mRankTbl[x] < mRankTbl[y])
        {
            mNodeTbl[x] = y;
        }
        else
        {
            mNodeTbl[y] = x;
            if (mRankTbl[x] == mRankTbl[y])
                mRankTbl[x]++;
        }
    }

    int mN;
    vector<int> mNodeTbl;
    vector<int> mRankTbl;
};

pll E[60];

int main()
{
    int N, M;
    cin >> N >> M;
    REP(i, M)
    {
        cin >> E[i].first >> E[i].second;
        E[i].first--;
        E[i].second--;
    }

    int n = 0;
    REP(i, M)
    {
        //! 橋iを取り除いた時に連結になるか調べる
        UnionFind uf;
        uf.init(N);
        REP(j, M)
        {
            if (i == j)
                continue;
            uf.unit(E[j].first, E[j].second);
        }

        REP(j, N - 1)
        {
            if (!uf.same(j, j + 1))
            {
                n++;
                break;
            }
        }
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
        string s;
        int A_pos, Z_pos;
        cin >> s;
        int len = s.length();
        for (int i = 0; i < len - 1; i++) {
                if(s[i] == 'A') {
                        A_pos = i;
                        break;
                }
        }
        for (int i = len - 1; i > 0; i--) {
                if(s[i] == 'Z') {
                        Z_pos = i;
                        break;
                }
        }
        cout << Z_pos - A_pos + 1 << endl;
        return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int n,c=0;
  cin>>n;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  rep(i,n){
    reps(j,i+1,n){
      reps(k,j+1,n){
        if(a[i]+a[j]>a[k])c++;
      }
    }
  }
  cout<<c;
}

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

int main(void){
 int n;
 cin>>n;
 int x_now=0,y_now=0,t_now=0;
 bool ok=true;
 vector<int>t(n);
 vector<int>x(n);
 vector<int>y(n);
 for(int i=0;i<n;i++){
     cin>>t[i]>>x[i]>>y[i];
 }
 for(int i=0;i<n;i++){
     int t_next,x_next,y_next,dist,tm;
     t_next=t[i],x_next=x[i],y_next=y[i];
     tm=t_next-t_now;
     dist=abs(x_next-x_now)+abs(y_next-y_now);
     bool oddt,oddd;
     oddt=tm%2;
     oddd=dist%2;
     if(dist>tm||(oddt!=oddd)){
         cout<<"No"<<endl;
         ok=false;
         break;
     }
     x_now=x_next;
     y_now=y_next;
     t_now=t_next;
 }
 if(ok){cout<<"Yes"<<endl;}
 return 0;
}

Measured memory_bytes: 1408