akhauriyash/Code-Regression huggingface dataset:
from collections import deque
from typing import List


def main():
    h, w = map(int, input().split())
    g = []
    for _ in range(h):
        r = list(input())
        g.append(r)
    print(mm(h, w, g))


def mm(h: int, w: int, g: List[List[str]]) -> int:
    ret = 0
    for i in range(h):
        for j in range(w):
            if (g[i][j] == '#'):
                continue
            q = deque([(i, j, 0)])
            v = [[0] * w for _ in range(h)]
            v[i][j] = 1
            while q:
                ii, jj, cnt = q.popleft()
                ret = max(ret, cnt)
                # ↓
                if ii < h - 1 and g[ii + 1][jj] == '.' and v[ii + 1][jj] == 0:
                    v[ii + 1][jj] = 1
                    q.append((ii + 1, jj, cnt + 1))
                # →
                if jj < w - 1 and g[ii][jj + 1] == '.' and v[ii][jj + 1] == 0:
                    v[ii][jj + 1] = 1
                    q.append((ii, jj + 1, cnt + 1))
                # ↑
                if ii > 0 and g[ii - 1][jj] == '.' and v[ii - 1][jj] == 0:
                    v[ii - 1][jj] = 1
                    q.append((ii - 1, jj, cnt + 1))
                # ←
                if jj > 0 and g[ii][jj - 1] == '.' and v[ii][jj - 1] == 0:
                    v[ii][jj - 1] = 1
                    q.append((ii, jj - 1, cnt + 1))
    return ret


if __name__ == '__main__':
    main()


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e3 + 5);
const int MAX_SIZE = (int)(MAX_N * MAX_N);

/////////////////////////////////////////////////////////////
// node in { 0, ... }
class TopologicalSort {
  using ts_graph = vector<vector<int>>;

 public:
  static const int MAX_N = (int)(8e5 + 100);

  int n;
  ts_graph graph;
  vector<int> topological_sorted;
  vector<int> flg;  // 0: not-visited, 1: done, -1, temporary

  bool no_loop;

  TopologicalSort(ts_graph graph, int n) {
    this->flg = vector<int>(n, 0);
    this->graph = graph;
    this->n = n;
    init();
  }

  void init() {
    topological_sort();
  }

  bool visit(int i) {
    if (flg[i] == -1) {
      return false;
    }

    if (flg[i] == 0) {
      flg[i] = -1;

      for (auto &e : graph[i]) {
        if (!visit(e)) {
          return false;
        }
      }

      flg[i] = 1;

      topological_sorted.push_back(i);

      return true;
    }

    return true;
  }

  void topological_sort() {
    for (int i = 0; i < n; ++i) {
      flg[i] = 0;
    }

    for (int i = 0; i < n; ++i) {
      if (flg[i] == 0) {
        if (!visit(i)) {
          no_loop = false;
          return;
        }
      }
    }

    reverse(topological_sorted.begin(), topological_sorted.end());

    no_loop = true;
    return;
  }

  bool contains_loop() {
    return !no_loop;
  }

  vector<int> &get_sorted() {
    return topological_sorted;
  }
};
/////////////////////////////////////////////////////////////

int n;

int tmp[MAX_N];
vector<vector<int>> graph(MAX_SIZE);
unordered_map<int, int> memo;

int make_key(int a, int b) {
  return min(a, b) * n + max(a, b);
}

int depth(int cur) {
  if (memo.find(cur) != memo.end()) return memo[cur];

  if (graph[cur].size() == 0) {
    return memo[cur] = 1;
  }

  int ret = -1;

  for (auto &e : graph[cur]) {
    ret = max(ret, depth(e));
  }

  ret += 1;

  return memo[cur] = ret;
}

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= n - 1; ++j) {
      scanf("%d", &(tmp[j]));
      tmp[j] -= 1;
    }

    int last = make_key(i, tmp[1]);

    for (int j = 2; j <= n - 1; ++j) {
      int cur = make_key(i, tmp[j]);
      graph[last].push_back(cur);
      last = cur;
    }
  }

  TopologicalSort ts(graph, MAX_SIZE);

  if (ts.contains_loop()) {
    printf("-1\n");
    return 0;
  }

  int ans = -1;

  for (int i = 0; i < MAX_SIZE; ++i) {
    ans = max(ans, depth(i));
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 127604
using System;
using System.Linq;

class TestClass {
	static void Main(string[] args) {
		int[] num = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
		if(num[0] < num[1] && num[1] < num[2]) {
			Console.WriteLine("Yes");
		}else{
			Console.WriteLine("No");
		}
	}
}


Measured memory_bytes: 9308
s=input()
N=int(input())
#s="atcoderandatcodeera"
#N=5
D={}

if(len(s)<=1):
    for i in range(1,len(s)+1):
        for j in range(len(s)):
            if D.get(s[j:j+i],None) == None:
                D[s[j:j+i]]=1
    D=sorted(D)
    print(D[N-1])
    exit()
else:
    t=sorted(s)
    i=0
    k=0
    for c in t:
        if(c!=k):
            i=0
            if(len(D)>=5):
                break
        k=c
        while(i<len(s)):
            if(s[i]==c):
                break
            i+=1
        j=i+1
        while(j<=min(len(s),i+5)):
            D[s[i:j]]=1
            j+=1
        i+=1
    
    D=sorted(D)
    print(D[N-1])
    exit()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

map<ll,ll>lst;

ll pref[N];

main()
{
    //cout<< (9999999212)/786;
    ll n,x,m;
    cin>>n>>x>>m;

    pref[1]=x;
    lst[x]=1;

    for(ll i=2;i<=n;i++)
    {
        x=(x*x)%m;

        if(lst[x]!=0)
        {
//            cout<<endl;
//            cout<<"in"<<endl;
            ll len=i-lst[x];
            ll cycsum=pref[i-1]-pref[lst[x]-1];
            ll baki=n-i+1;

            ll cyc=baki/len,ex=baki%len;
            ll ans=pref[i-1]+cyc*cycsum;
            //cout<<cyc<<' '<<ex<<' '<<cycsum<<' '<<len<<' '<<baki<<endl;
            if(ex)
            {
                ans+=pref[lst[x]+ex-1]-pref[lst[x]-1];
            }
            cout<<ans;
            return 0;
        }
        lst[x]=i;
        pref[i]=pref[i-1]+x;
    }
    cout<<pref[n];
}
/*
786 9999999212
*/


Measured memory_bytes: 7036
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }


void solve(long long N, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c){
    vector<vll> dp(N+1, vll(3, 0));
    REP(i, N){
        chmax(dp[i+1][0], dp[i][1]+a[i]); chmax(dp[i+1][0], dp[i][2]+a[i]); 
        chmax(dp[i+1][1], dp[i][0]+b[i]); chmax(dp[i+1][1], dp[i][2]+b[i]); 
        chmax(dp[i+1][2], dp[i][1]+c[i]); chmax(dp[i+1][2], dp[i][0]+c[i]); 
    }
    ll ans = 0;
    REP(i, 3) chmax(ans, dp[N][i]);
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    std::vector<long long> b(N);
    std::vector<long long> c(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
    }
    solve(N, std::move(a), std::move(b), std::move(c));
    return 0;
}


Measured memory_bytes: 8064
//#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <queue>
#include <set>
#include <string>
#include <stdbool.h>
#include<ctime>

#include <cstring>

#define pb push_back


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ll long long
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) < (b) ? (a) : (b))

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfb(a) printf("%.10lf\n",a);
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.12lf ",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"

#define MOD  ( int)(1e9 + 7)
#define MAXN (ll) ((1e5+5))
#define K 25
#define  ALPHABET_SIZE  26
//#define N (int)(1e5+10)
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define INF (ll )1e18
#define int ll
using namespace std;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int, int>>> vvpi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph;


signed main(){
	ll n;
	cin >> n;
	if (n >= 30)cout << "Yes";
	else cout << "No";








	return 0;



}




/*


10 567
300 150 460 518 426 181 393 70 129 742
*/


Measured memory_bytes: 3516
/*
 *  Created on: 2017/06/27
 *      Author: LitMc
 */
#define MYDEBUG
#include <bits/stdc++.h>
#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
using std::vector;
using std::cout;
using std::cin;
using std::endl;
using std::max;
using std::min;
using std::swap;
using std::string;
using std::fill;
using std::pair;
using std::sort;
using std::reverse;
using std::pair;
using std::greater;
using std::priority_queue;
using std::ostream;
using std::unique;

template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i] << endl;
	}
	return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last) {
			out << ",";
		}
	}
	out << "]";
	return out;
}

struct edge {
	int from, to, cost;
	edge() {
		*this = edge(-1, -1, -1);
	}
	edge(int from_, int to_, int cost_) {
		from = from_;
		to = to_;
		cost = cost_;
	}
	bool operator<(const edge& e) const {
		return cost < e.cost;
	}
	bool operator==(const edge& e) const {
		return (from == e.from && to == e.to && cost == e.cost)
				|| (from == e.to && to == e.from && cost == e.cost);
	}
};
static const double EPS = 1e-14;
typedef std::complex<double> P;
int n, size;
vector<P> p;

void dfs(int rest, P p1, P p2) {
	P s = (p2 - p1) / 3.0 + p1;
	P t = (p2 - p1) * (2.0 / 3.0) + p1;
	P u = (t - s) * P(0.5, sqrt(3) / 2.0) + s;
	if (rest > 1) {
		dfs(rest - 1, p1, s);
		p.push_back(s);
		dfs(rest - 1, s, u);
		p.push_back(u);
		dfs(rest - 1, u, t);
		p.push_back(t);
		dfs(rest - 1, t, p2);
	} else if (rest == 1) {
		p.push_back(s);
		p.push_back(u);
		p.push_back(t);
	}
}

void solve() {
	cin >> n;
	P p1 = P(0, 0), p2 = P(100, 0);
	p.push_back(p1);
	dfs(n, p1, p2);
	p.push_back(p2);
	rep(i,0,(int)p.size())
	{
		printf("%.8f %.8f\n", p[i].real(), p[i].imag());
	}
}

int main() {
	solve();
}

Measured memory_bytes: 3212
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int mod = 1000000007;
 
//足したり引いたりすると勝手にmodをとってくれる
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
 
//コンビネーションのライブラリ
struct combination {
    //factのなかに階乗を求めている
    //ifactのなかに階乗逆元を求めている
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

//移動距離が３の倍数でなければ移動不可能である
//x - (x+y)/3, y - (x+y)/3 により有名問題へ帰着させる
// x < 0 or y < 0の場合は不適であることに注意せよ

int main(){
    int x, y;
    cin >> x >> y;
    
    //移動距離が３の倍数でなければ移動不可能である
    if ((x+y) % 3) {
        cout << 0 << endl;
        return 0;
    }
    
    int n = (x+y) / 3;
    x -= n, y -= n;
    
    if (x < 0 || y < 0){
        cout << 0 << endl;
        return 0;
    }
    
    combination c(x+y);
    mint ans = c(x+y, x);
    cout << ans.x << endl;
}




Measured memory_bytes: 10624
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector< lli > h(N);
  REP(i, N) { cin >> h[i]; }
  sort(ALL(h));
  lli ans = INF;
  REP(i, N - (K - 1)) { ans = min(ans, h[i + K - 1] - h[i]); }
  cout << ans << "\n";
}

Measured memory_bytes: 1024
S = input()

if S[0] != "A":
    print("WA")
    exit()

if S[2:-1].count("C") != 1:
    print("WA")
    exit()

if (S[1:S.find("C")] + S[S.find("C")+1:]).islower() == False:
    print("WA")
    exit()

print("AC")

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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



int main(void)
{
  ll s;
  cin >> s;
  ll v = 1000000000;
  ll x = (v - s%v)%v;
  ll y = (s+x)/v;
  printf("0 0 1000000000 1 %lld %lld\n", x, y);
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<Integer,Integer> low = new HashMap<>();
		int[] arr = new int[n + 1];
		for(int i = 1; i <= n; i++) {
			int val = sc.nextInt();
			arr[i] = val;
			low.put(i - val, low.getOrDefault(i - val , 0) + 1);
		}
		long res = 0;
		for(int i = 1; i <= n; i++) {
			if(low.containsKey(arr[i] + i))
				res += low.get(arr[i] + i);
			if(arr[i] == 0)
				res--;
		}
		System.out.println(res);
    }
}

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

using namespace std;
using ll = long long;


int main()
{
    int a,b;
    cin >> a >> b;
    for(int i = 1; i <= 100000; i++){
        int t = i * 0.08;
        int k = i * 0.10;
        if(t == a && k == b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

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

using namespace std;

#define INF 1e9
#define MAXN 10005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll sumA = 0, sumB = 0, ans = 0;
int N, A[MAXN], B[MAXN];

void solve(){
    rep(i, N){
        if(A[i] < B[i]){
            ans += (B[i] - A[i])/2;
        } else if(A[i] > B[i]) {
            ans -= A[i] - B[i];
        }
    }

    if(ans < 0)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}

int main(){
    cin >> N;

    rep(i, N){
        cin >> A[i];
        sumA += A[i];
    }

    rep(i, N){
        cin >> B[i];
        sumB += B[i];
    }

    solve();
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <list>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <vector>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
// const ll MOD = 1000000009;


int main() {
    string s;
    ll q;
    cin >> s >> q;
    vector<char> lst[2];
    bool rev = false;
    int front = 0;
    for (ll i = 0; i < q; ++i) {
        int t;
        cin >> t;
        if (t == 1) {
            rev = !rev;
            front = 1 - front;
        } else {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1) {
                lst[front].push_back(c);
            } else {
                lst[1-front].push_back(c);
            }
        }
    }
    for (ll i = lst[front].size() - 1; i >= 0; --i) {
        cout << lst[front][i];
    }
    if (!rev) {
        cout << s;
    } else {
        for (ll i = s.size() - 1; i >= 0; --i) {
            cout << s[i];
        }
    }
    for (ll i = 0; i < lst[1-front].size(); ++i) {
        cout << lst[1-front][i];
    }
    cout << endl;
}


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

int main(){
    int a[3];
    for(int i=0;i<3;i++){
        cin>>a[i];
    }
    if(a[0]+a[1]+a[2]>=22){
    cout<<"bust"<<endl;
    }else{
    cout<<"win"<<endl;
    }
    return 0;
}

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


#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}

void solve(){


}
string s[1009];
int vis[1009][1009];
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	int n;cin>>n;
	int m;cin>>m;
	rep(i,n) cin>>s[i];
	queue<pii> q;
	rep(i,n) rep(j,m){
		if(s[i][j]=='#') {
			vis[i][j] = 1;
			q.push({0,i*m+j});
		}
	}
	int ans = 0;
	while(!q.empty()){
		pii z = q.front();
		q.pop();
		int x = z.snd/m,y = z.snd%m;
		if(x&&!vis[x-1][y]) {
			ans = z.fst+1;
			q.push({z.fst+1,(x-1)*m+y});
			vis[x-1][y]=1;
		}
		if(x+1<n&&!vis[x+1][y]) {
			ans = z.fst+1;
			q.push({z.fst+1,(x+1)*m+y});
			vis[x+1][y]=1;
		}
		if(y&&!vis[x][y-1]) {
			ans = z.fst+1;
			q.push({z.fst+1,(x)*m+y-1});
			vis[x][y-1]=1;
		}
		if(y+1<m&&!vis[x][y+1]) {
			ans = z.fst+1;
			q.push({z.fst+1,(x)*m+y+1});
			vis[x][y+1]=1;
		}
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 13456
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int N;
map<char, int>m;
string M = "RB";
int ask(int k) {
	cout << '?';
	for (int i = 0; i < N; ++i) {
		cout << ' ' << (k + i) % (N + N) + 1;
	}
	cout << endl;
	string res;
	cin >> res;
	return m[res[0]];
}
int ask2(int L, int x) {
	cout << '?';
	for (int i = 0; i <= N; ++i) {
		int now = (L + i) % (N + N);
		if (now != x) {
			cout << ' ' << now + 1;
		}
	}
	cout << endl;
	string res;
	cin >> res;
	return m[res[0]];
}

int main() {
	cin >> N;
	string ans;
	ans.resize(N + N, ' ');
	m['R'] = 0;
	m['B'] = 1;
	int lo = 0, hi = N;
	int t = ask(0);
	while (hi - lo > 1) {
		int mid = (hi + lo) / 2;
		if (t == ask(mid)) {
			lo = mid;
		}
		else {
			hi = mid;
		}
	}
	ans[lo] = M[t];
	ans[(lo + N) % (N + N)] = M[1 - t];
	for (int i = 1; i < N; ++i) {
		ans[(lo + i) % (N + N)] = M[1 - ask2(lo, lo + i)];
	}
	for (int i = 1; i < N; ++i) {
		ans[(lo + i + N) % (N + N)] = M[1 - ask2((lo + N) % (N + N), (lo + N + i) % (N + N))];
	}
	cout << "! " << ans << endl;
}

Measured memory_bytes: 724
#ARC076
import math

n,m=map(int,raw_input().split())
res=((math.factorial(m)%(10**9+7))*math.factorial(n)%(10**9+7))%(10**9+7)
if abs(n-m)==1:
 print res
elif n==m:
 print (res*2)%(10**9+7)
else:
 print 0


Measured memory_bytes: 40348
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i, n)
    {
        cin >> b[i];
    }

    int result = 0;
    rep(i, n - 1)
    {
        for (int j = i + 1; j < n; j++) {
            result += b[i] * b[j];
        }
    }
    cout << result << endl;
    return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  if ((a + b) >= c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

 

def main():
    N, K = map(int, input().split())
    print(len(Base_10_to_n(N,K)))



if __name__ == "__main__":
    main()

Measured memory_bytes: 38256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC081_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int s = int.Parse(Console.ReadLine());

            int count = 0;

            for (int i = 0; i < 3; ++i)
            {
                if (s % 10 == 1)
                {
                    ++count;
                }

                s /= 10;
            }

            Console.WriteLine($"{count}");
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<stdio.h>
using namespace std;
using ll=long long;
#include<algorithm>
#include<set>
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using P=pair<int,int>;

//auto

int main(){
int n;
string s,t;
cin>>n>>s>>t;
rep(i,n){
  cout<<s[i]<<t[i];
}
cout<<endl;
}



Measured memory_bytes: 3116
package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func solve(a, b, h, m float64) float64 {
    x := float64(360) / float64(12 * 60) * (h * 60 + m)
    y := float64(360 / 60 * m)
    delta := math.Abs(x - y)
    degrees := delta
    if delta == 180 {
        return a + b
    } else if delta > 180 {
        degrees = 360 - delta
    }
    return math.Sqrt(a * a + b * b - 2.00 * a * b * math.Cos(degrees * math.Pi/180))
}

func main() {
    var a, b, m, h float64
    fmt.Scanf("%v %v %v %v", &a, &b, &h, &m)
    ans := solve(a, b, h, m)
    fmt.Println(ans)
}

Measured memory_bytes: 1824
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n; i++)
#define ll long long
const ll MOD=1000000007;
using namespace std;
ll n;
ll a[100000];
ll modpow(ll x,ll y){
    if (y==0){
        return 1;
    }else if (y==1){
        return x%MOD;
    }else if (y%2==0){
        ll z=modpow(x,y/2);
        return z*z%MOD;
    }else{
        ll z=modpow(x,y/2);
        return (z*z%MOD)*x%MOD;
    }
}
int main(){
    cin>>n;
    rep(i,n) cin>>a[i];
    sort(a,a+n);
    if (n%2==0){
        rep(i,n/2){
            if (a[i*2]!=i*2+1 || a[i*2+1]!=i*2+1){
                cout<<0<<endl;
                return 0;
            }
        }
    }else{
        if (a[0]!=0){
            cout<<0<<endl;
            return 0;
        }
        rep(i,n/2){
            if (a[i*2+1]!=(i+1)*2 || a[i*2+2]!=(i+1)*2){
                cout<<0<<endl;
                return 0;
            }
        }
    }
    ll ans=modpow(2,n/2)%MOD;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n, m = sc.nextInt
    val x = new Array[Long](n)
    val y = new Array[Long](n)
    val z = new Array[Long](n)
    for (i <- 0 until n) {
      x(i) = sc.nextLong
      y(i) = sc.nextLong
      z(i) = sc.nextLong
    }

    var ans = 0L
    val sign = Array[Int](-1, 1)
    for (xs <- sign; ys <- sign; zs <- sign) {
      val sums = (0 until n).map(
        i =>
          xs * x(i) + ys * y(i) + zs * z(i)
      )

      val mx = sums.sorted.reverse.slice(0, m).sum

      ans = math.max(ans, mx)
    }

    println(ans)
  }
}


Measured memory_bytes: 32868
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOJ_ITP_1_2_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);
            //a < b < cの関係が成り立つか
            if(a < b && b < c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}



Measured memory_bytes: 17928
#include <stdio.h>

int main(void)
{
    int a, b;
    scanf("%d %d", &a, &b);
    if (a > b)
    {
        printf("a > b\n");     
    }
    else if (a < b)
    {
         printf("a < b\n");
    }
    else
    {
        printf("a == b\n");    
    }
    return 0;    
} 



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

using namespace std;

const int N = 1001;

main(){
  int data[N+1], a, b;
  data[0] = 1;
  data[1] = 2;
  for(int i=2;i<=N;i++) data[i] = (data[i-1] + data[i-2]) % N;
  while(cin >> a >> b){
    int ans = 1;
    int tmp[N+1];
    for(int i=0;i<a;i++) tmp[i] = data[i+1];
    sort(tmp, tmp+a);
    for(int i=1;i<a;i++){
      if(tmp[i] - tmp[i-1] >= b) ans++;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h,m,s;
	cin >> s;
	h=s/3600;
	s=s-3600*h;
	m=s/60;
	s=s-60*m;
	cout << h << ":" << m << ":" << s <<endl;
}


Measured memory_bytes: 3100
#include <iostream>
#include <cstring>
#include <cstdio>
#define INF 0x3f3f3f3f
using namespace std;

const int MAXN=100010;

int main()
{
    int n;
    while (scanf("%d",&n)!=EOF) {
        cout<<n/3<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
def make_divisors(n: int) -> list:
    """自然数nの約数を列挙したリストを出力する
    計算量: O(sqrt(N))
    入出力例: 12 -> [1, 2, 3, 4, 6, 12]
    """
    divisors = []
    for k in range(1, int(n ** 0.5) + 1):
        if n % k == 0:
            divisors.append(k)
            if k != n // k:
                divisors.append(n // k)
    divisors = sorted(divisors)
    return divisors


n = int(input())
ans = 0
for num in make_divisors(n):
    if num == 1:
        continue
    res = n
    while res >= num:
        if res % num == 0:
            res = res // num
        else:
            res = res - (res // num) * num
    if res == 1:
        ans += 1
print(ans + len(make_divisors(n - 1)) - 1)

Measured memory_bytes: 39280
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#define ll long long int
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define PI 3.141592653589793
using namespace std;

bool IsPrime(int num)
{
    if (num <= 1) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
    int x;

    cin >> x;
    int p = x;
    while(!IsPrime(p)) p++;

    cout<< p << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
b = list(map(int, input().split()))
ans = b[0]
if(n == 2):
  ans = b[0] * 2
else:
  for i in range(1, len(b)):
    ans += min(b[i-1], b[i])
  ans += b[len(b)-1]
print(ans)

Measured memory_bytes: 3060
N=int(input())
b=list(map(int,input().split()))
kari=[]
flag = 0
while len(b) > 0:
    blen=len(b)
    for i in range(blen):
        if b[blen-i-1] == blen-i:
            kari.append(blen-i)
            del b[blen-i-1]
            break
        else:
            pass
    if blen==len(b):
        print(-1)
        flag = 1
        break
ans=kari[::-1]
if flag == 0:
    for i in range(N):
        print(ans[i])

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

using namespace std;

int main() {
    // Input
    vector<vector<int>> A = vector<vector<int>>(3, vector<int>(3));
    int N;
    vector<int> b;

    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++) cin >> A[i][j];
    }
    cin >> N;
    b = vector<int>(N);
    for (int i = 0; i < N; i++) cin >> b[i];

    // Process
    vector<vector<bool>> check = vector<vector<bool>>(3, vector<bool>(3, false));
    for (int n : b){
        for (int i = 0; i < 3; i++){
            for (int j = 0; j < 3; j++){
                if (A[i][j] == n) check[i][j] = true;
            }
        }
    }

    bool judge = false;
    for (int i = 0; i < 3; i++){
        if (check[i][0] && check[i][1] && check[i][2]) judge = true;
        if (check[0][i] && check[1][i] && check[2][i]) judge = true;
    }
    if (check[0][0] && check[1][1] && check[2][2]) judge = true;
    if (check[2][0] && check[1][1] && check[0][2]) judge = true;

    // Output
    cout << (judge ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#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 PB push_back
#define EB emplace_back
#define MP make_pair
#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)--)
#define debug(x) cerr << #x << ": " << x << endl
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 };

/* -----  2018/01/29  Problem: ABC 087 A / Link: http://abc087.contest.atcoder.jp/tasks/abc087_a  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	int X, A, B;
	cin >> X >> A >> B;
	X -= A;
	while (X - B >= 0) {
		X -= B;
	}
	ans = X;
	cout << ans << "\n";

	return 0;
}


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

d = {}
for a in A:
    d.setdefault(a, 0)
    d[a] += 1

A = sorted(set(A))
t = [True] * (10 ** 6 + 1)
for a in A:
    if d[a] > 1:
        t[a] = False
    for i in range(a + a, 10 ** 6 + 1, a):
        t[i] = False
print(sum(1 for a in A if t[a]))


Measured memory_bytes: 44212
#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000000;
vector<long long> dijkstra(vector<vector<pair<int, int>>> &E, int s){
    int V = E.size();
    vector<long long> d(V, INF);
    priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> Q;
    Q.push(make_pair(0, s));
    while (!Q.empty()){
        long long c = Q.top().first;
        int v = Q.top().second;
        Q.pop();
        if (d[v] == INF){
            d[v] = c;
            for (int i = 0; i < E[v].size(); i++){
                Q.push(make_pair(c + E[v][i].first, E[v][i].second));
            }
        }
    }
    return d;
}
int main(){
  int V, E, r;
  cin >> V >> E >> r;
  vector<vector<pair<int, int>>> e(V);
  for (int i = 0; i < E; i++){
    int s, t, d;
    cin >> s >> t >> d;
    e[s].push_back(make_pair(d, t));
  }
  vector<long long> d = dijkstra(e, r);
  for (int i = 0; i < V; i++){
    if (d[i] != INF){
      cout << d[i] << endl;
    } else {
      cout << "INF" << endl;
    }
  }
}


Measured memory_bytes: 16508
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define per(i,n) for(int i=(n)-1; i>=0; i--)
#define chmin(a,b) a = min(a,b)
#define chmax(a,b) a = max(a,b)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;
const int MOD = 1000000007;

int main(){
    int a;cin>>a;
    int ans = 0;
    cout << a*a*a + a*a + a <<endl;
    return 0;
}

Measured memory_bytes: 3588
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int a,b,c;
	scan(a);scan(b);scan(c);
	prin(min(c,b/a));

	return 0;
}


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

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

    int n;
    cin >> n;

    vector<int> h(n, 0);
    REP(i, n) cin >> h[i];

    int count = 0;
    int sum = accumulate(h.begin(), h.end(), 0);
    // REP(z, 5) {
    while (sum) {
        int l = 0;
        REP(i, n) {
            if (h[i] > 0) {
                l = i;
                break ;
            }
        }

        int r = l;
        for (int i = l + 1; i < n; i++) {
            if (h[i] != 0) r = i;
            else break ;
        }

        // cout << l << ' ' << r << '\n';
        for (int i = l; i <= r; i++)
            h[i]--;
        // for (auto i : h) cout << i;
        // cout << '\n';
        count++;
        sum = accumulate(h.begin(), h.end(), 0);
    }

    cout << count << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

char M(char x, char y){
  if(x == 'T' && y == 'F') return 'F';
  else return 'T';
}

int main(){
  int N;
  char ans, p;
  cin >> N >> ans;
  for(int i = 0; i < N - 1; i++){
    cin >> p;
    ans = M(ans, p);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3136
using System;
using System.Linq;

namespace AtCoder20190629
{
	class ProgramA
	{
		static void Main(string[] args)
		{
			var S = Console.ReadLine().Trim();
			A(S);
		}
		static bool JudgeA(string S)
		{
			char[] array = S.ToCharArray();
			char[] uniqueChars = array.Distinct().ToArray();
			if (uniqueChars.Length != 2) return false;
			foreach(char uc in uniqueChars)
			{
				int n = array.Count(c => c == uc);
				if (n != 2) return false;
			}
			return true;
		}
		static void A(string S)
		{
			Console.WriteLine(JudgeA(S) ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 13276
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#include<iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<double,double>;
using vvi = vector<vector<int> >;
using vvll =  vector<vector<ll> >;
const ll mod = 1e9 + 7;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
    int N; cin >> N;
    vector<ll> A(N),ruiseki(N+1,0);
    REP(i,N){
        cin >> A[i];
        ruiseki[i+1] = ruiseki[i] + A[i];
        ruiseki[i+1] %= mod;
    }
    ll ans = 0;
    for(int i = 1; i < N; i++){
        ans += ruiseki[i] * A[i];
        ans %= mod;
    }

    cout << ans << endl;
}



Measured memory_bytes: 6344
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  char c = s[s.size()-1];
  if(c == '2' || c == '4' || c == '5' || c == '7' || c == '9') cout << "hon\n";
  else if(c == '3') cout << "bon\n";
  else cout << "pon\n";
}


Measured memory_bytes: 3616
import scipy
n, a, b = map(int, input().split())
mod = 10**9 + 7
ans = pow(2, n, mod) - 1

cax = 1
cay = 1
for i in range(a):
    cax *= (n-i) % mod
    cax %= mod
    cay *= (i+1) % mod
    cay %= mod

cbx = 1
cby = 1
for i in range(b):
    cbx *= (n-i) % mod
    cby *= (i+1) % mod
    cbx %= mod
    cby %= mod

ans -= cax * pow(cay, mod - 2, mod)
ans -= cbx * pow(cby, mod - 2, mod)
print(ans % mod)

Measured memory_bytes: 12456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
const int inf = 1000000000; // 10 ^ 9

bool isPrime(int x); 
int gcd(int a, int b); 
vector<int> primeFactorization(int x); 
void printVector(vector<long> list, string str); 
void setPrecision(int n);

int hoge(int count, int num, int div) {
  if (num == 0) return count;

  return hoge(count+1, num/div, div);
}

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];
  
  int ans = inf;
  for (int i = 1; i <= 100; i++) {
    int cost = 0;
    rep(j, n) cost += (x[j] - i) * (x[j] - i);
    ans = min(cost, ans);
  }

  cout << ans << endl;
} 

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

bool isPrime(int x) {
  if (x < 2) return false;
  if (x == 2) return true;
  if (x % 2 == 0) return false;

  double num = sqrt(x);
  for (int i = 3; i <= num; i+=2) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

// 素因数分解
// example: primeFactorization(12) = vector<int>{2, 2, 3}
vector<int> primeFactorization(int x) {
  vector<int> ans;
  int i = 2;
  while (i*i <= x) {
    if (x % i == 0) {
      ans.push_back(i);
      x /= i;
    } else {
      i++;
    }
  }
  ans.push_back(x);
  return ans;
}

void printVector(vector<long> list, string str) {
  for (int i = 0; i < list.size(); i++) {
    cout << str << ": " << list[i] << endl;
  }
}

void setPrecision(int n) {
  cout << fixed << setprecision(n);
}

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

int main() {
	int i = 1;
	int n;
	cin >> n;
	for (; i <= n; i++) {
		if (i % 3 == 0) {
			cout << " " << i;
		}else if (i / 10 != 0 ) {
			for (int k = i; k != 0; k /= 10) {
				if (k % 10 == 3){
				    cout << " " << i;
				    break;
				}
			}
		}
	}
	cout << endl;
}


Measured memory_bytes: 3088
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
 
int main(void)
{
    int n,ans = 1;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++)
        cin >> a[i];

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

    for(int i = 1;i < n;i++){
        if(a[i] > a[i-1])
            ans++;
    }     
    cout << ans << endl;                                                       
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,l,r) for(int (i)=(l);(i)<(r);i++)
#define erep(i,l,r) for(int (i)=(l);(i)<=(r);i++)
using namespace std;
int main(){
    ll n,ans=0;
    cin>>n;
    ll num[10][10]={};
    erep(i,1,n){
        ll buf=i;
        while(buf>=10)buf/=10;
        num[buf][i%10]++;
    }
    rep(i,0,10)rep(j,0,10)ans+=num[i][j]*num[j][i];
    cout<<ans<<endl;
}


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

using namespace std;

uint64_t facctorialMethod(uint64_t k);

int main()
{
    uint64_t nn;
    uint64_t nn_ans = 0;
    uint64_t mm;
    uint64_t mm_ans = 0;
    cin >> nn >> mm;

    nn_ans = (nn * (nn - 1)) / 2;
    mm_ans = (mm * (mm - 1)) / 2;
    
    cout << nn_ans + mm_ans << endl;

    return 0;
}

uint64_t facctorialMethod(uint64_t k){
    uint64_t sum = 1;
    for (uint64_t i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

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

int main() {
  string s;
  while(getline(cin, s)) {
    replace(s.begin(), s.end(), '.', ' ');
    replace(s.begin(), s.end(), ',', ' ');
    stringstream ss(s);
    bool first = true;
    while(ss >> s) {
      if(s.size() >= 3 && s.size() <= 6) {
        if(first) first = false;
        else cout << " ";
        cout << s;
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S; cin >> S;
  string ans_S;
  ans_S += S.at(0);
  for(int i = 1; i < S.size(); i++){
    if(ans_S.at(i - 1) == '1')
      ans_S += '0';
    else
      ans_S += '1';
  }
  int cnt = 0;
  for(int i = 0; i < S.size(); i++){
    if(ans_S.at(i) != S.at(i)) cnt++;
  }
  
  cout << cnt << endl;
}
      

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
struct UnionFind{
    vi data;
    UnionFind(int size):data(size,-1){}
    bool unite(int x,int y){
        x=root(x);y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];data[y]=x;
        }
        return x!=y;
    }
    bool find(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};
int main(){
    int V,E;
    cin>>V>>E;
    vl vec(V);
    REP(i,V){
        cin>>vec[i];
    }
    UnionFind uf(V);
    REP(i,E){
        int a,b;
        cin>>a>>b;
        uf.unite(a,b);
    }
    int F=0;
    vector<priority_queue<ll,vl,greater<ll>>> d(V);
    REP(i,V){
        if(uf.root(i)==i){
            F++;
        }
        d[uf.root(i)].push(vec[i]);
    }
    if(F==1){
        cout<<0<<endl;
        return 0;
    }
    ll ans=0;
    priority_queue<ll,vl,greater<ll>>que;
    REP(i,V){
        if(d[i].size()){
            ans+=d[i].top();d[i].pop();
        }
        while(d[i].size()){
            que.push(d[i].top());d[i].pop();
        }
    }
    if(que.size()<F-2){
        cout<<"Impossible"<<endl;
        return 0;
    }
    REP(i,F-2){
        ans+=que.top();que.pop();
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7680