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


const int mod = 1000000007;

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};


const int MOD = 1000000007;
using mint = Fp<MOD>;

long myPow(long x, long n, long m ){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main(){
    int N , a , b ;
    cin >> N >> a >> b  ;
    mint ansa = 1 ;
    mint ansb = 1 ;
    for(int i = 0 ; i < a ; i++ ){
        ansa *= (mint) N - i ;
        ansa /= (mint) a - i ;
    }
    for(int i = 0 ; i < b ; i++ ){
        ansb *= (mint) N - i ;
        ansb /= (mint) b - i ;
    }
    int answer =  myPow(2,N,mod) ;
    mint ans = answer ;
    cout << ans - ansa - ansb - 1 << endl; 
}


Measured memory_bytes: 3520
#include <stdio.h>
#include <string.h>
#define ll long long int
#define e 2.7182818
#define pi 3.14159
ll res = 0;
ll rest = 1;
ll oof = 1000000007;

ll pow (ll num, ll x){
	rest = 1;
	for (int i=0; i<num; i++){
		 rest *= x;
		 rest = rest % oof;
	}
	return rest;
}

int main (){
	ll num;
	scanf ("%lld", &num);
	res += (pow(num, 10));
	res -= (pow(num, 9));
	res -= (pow(num, 9));
	res += (pow(num, 8));
	res %= oof;
	res = (res+oof)%oof;
	printf ("%lld\n", res);
	
return 0;
}


Measured memory_bytes: 1724
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
#include<vector>

using namespace std;


int main() {
	string N;
	cin >> N;
	bool can = false;
	for (int i = 0; i < 3; i++) {
		if (N[i] == '7') can = true;
	}
	if (can) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}




Measured memory_bytes: 3624
import java.util.Arrays;
import java.util.Scanner;

/**
 * http://abc071.contest.atcoder.jp/tasks/arc081_a
 */
public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		long[] a = new long[N];
		for(int i=0; i<N; i++){
			a[i] = sc.nextLong();
		}
		sc.close();
		
		Arrays.sort(a);
		long max = 0;
		for(int i=N-1; i>0; i--){
			if(a[i]==a[i-1]){
				max = a[i];
				a[i]= -1;
				a[i-1] = -1;
				break;
			}
		}
		
		Arrays.sort(a);
		long max2 = 0;
		for(int i=N-1; i>0; i--){
			if(a[i]==a[i-1]){
				max2 = a[i];
				break;
			}
		}
		
		System.out.println(max*max2);

	}

}

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

int main() {
    string s;
    int k;
    cin>>k>>s;
    int a = s.size();
    if(a<=k){
        cout<<s<<endl;
    }else{
        rep(i,k){
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }
}

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    ll N, K;
    cin >> N >> K;
    vector<pll> A(N);
    for (int i = 0; i < N; i++) {
        ll t, d;
        cin >> t >> d;
        t--;
        A[i] = {d, t};
    }
    sort(all(A));
    reverse(all(A));

    vector<ll> cnt(N);
    priority_queue<pll, vector<pll>, greater<pll>> P;
    ll sum = 0;
    ll kind = 0;

    for(int i = 0; i < K; i++) {
        if (!cnt[A[i].second]) kind++;
        cnt[A[i].second]++;
        sum += A[i].first;
        P.push(A[i]);
    }

    ll ans = sum + kind * kind;
    pll out = P.top();
    for(ll i = K; i < N; i++) {
        if (!cnt[A[i].second]) {
            cnt[A[i].second]++;
            kind++;
            sum += A[i].first;

            while(cnt[out.second] <= 1) {
                P.pop();
                if (P.empty()) {
                    cout << ans << endl;
                    return;
                }
                out = P.top();
            }
            cnt[out.second]--;
            sum -= out.first;
            ans = max(ans, sum + kind * kind);
            if (P.empty()) {
                cout << ans << endl;
                return;
            }
            P.pop(); out = P.top(); 
        }
    }

    cout << ans << endl;

}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();

    #ifdef LOCAL_ENV
    assert(cin.rdstate() & ios_base::eofbit);
    #endif
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
	ll cost;
};
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
ll n, m;
vl a, b;
/******* define variable end *******/
int solve() {
	cin >> n >> m;
	a.resize(m);
	b.resize(m);
	REP(i, m){
		cin >> a[i] >> b[i];
	}
	vl edges(n-1);
	vl tables(n, 0);
	vl one(n-1);
	REP(i, m){
		if(max(a[i],b[i])-min(a[i],b[i]) > 1){
			tables[min(a[i],b[i])-1]++;
			tables[max(a[i],b[i])-1]--;
		}else{
			one[min(a[i],b[i])-1]++;
		}
	}
	bool flag = true;
	vl ans(n-1);
	ans[0] = tables[0] + one[0];
	REP(i, n-1){
		if(i > 0){
			tables[i] += tables[i-1];
			ans[i] = tables[i] + one[i];
		}
		flag = flag && (ans[i] % 2 == 0);
	}
	if(flag) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


Measured memory_bytes: 4992
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007
//P pa(114,514);   ,vector<P>vec(N,0);
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}
int kaijou(int n){
    int a=1;
  if(n==0){
    return 1;
  }
    REP(i,n){
        a*=i+1;
    }
    return a;
}
int ncr(int n,int r){
  int a;
  if(n<0||r<0||n<r){
    return 0;
  }
  a=kaijou(n)/kaijou(r)/kaijou(n-r);
  return a;
}
//cout << setprecision(123);
int main(){
  bool ok=false;
  string S;
  cin>>S;
  if(S[0]==S[1] || S[1]==S[2] || S[2]==S[3])ok=true;
  
  if(ok)cout<<"Bad"<<endl;
  else cout<<"Good"<<endl;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int M, GRE, GEO, DP, GRA, O;
    while (cin >> M >> GRE >> GEO >> DP >> GRA >> O) {
        if (!M && !GRE && !GEO && !DP && !GRA && !O) break;

        int G1 = M + DP;
        int G2 = GRE + GRA;
        int G3 = GEO + O;

        int ans = 0;
        int mn = min({G1, G2, G3});

        /*
        {
            int tmp = mn;
            tmp += (G1 - mn) / 3;
            tmp += (G2 - mn) / 3;
            tmp += (G3 - mn) / 3;
            tmp += min({(G1 - mn)%3, (G2 - mn)%3, (G3 - mn)%3});
            ans = max(ans, tmp);
        }

        {
            int tmp = 0;
            tmp += G1/3; G1%=3;
            tmp += G2/3; G2%=3;
            tmp += G3/3; G3%=3;
            tmp += min({G1, G2, G3});
            ans = max(ans, tmp);
        }
        */

        // cerr << "------------" << endl;
        for (int m=max(0, mn-100); m<=mn; m++) {
            int tmp = m;
            tmp += (G1 - m) / 3;
            tmp += (G2 - m) / 3;
            tmp += (G3 - m) / 3;
            ans = max(ans, tmp);
            // DUMP(tmp);
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 3228
def sub():
    N, W = [int(e) for e in input().split()]
    ww = []
    vv = []
    for _ in range(N):
        w, v = [int(e) for e in input().split()]
        ww.append(w)
        vv.append(v)
    
    V = sum(vv)
    INF = 10**12
    dp_table = [[INF for _ in range(V+1)] for _ in range(N+1)]
    dp_table[0][0] = 0
    for i in range(N):
        for j in range(V):
            v_next = vv[i] + j
            w_next = ww[i]
            d = dp_table[i][j]
            if v_next <= V:
                dp_table[i+1][v_next] = min(dp_table[i+1][v_next], d + w_next)
            dp_table[i+1][j] = min(dp_table[i+1][j], d)
    
    # for r in dp_table:
    #     print(r)
    idxx = [i for i, w in enumerate(dp_table[-1]) if w <= W]
    print(idxx[-1])
sub()



Measured memory_bytes: 171500
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define F first
#define S second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int Inf = 1e9;
const double EPS = 1e-9;



int main()
{
  int n, m ;
  cin >> n >> m ;
  vector<pair<int,int>> stu(n) ;
  vector<pair<int,int>> poi(m) ;
  ll min = MOD ;
  ll tmp = min ;
  int ans ;
  int dis ;
  
  REP(i,n){
    int a, b ;
    cin >> a >> b ;
    stu.at(i) = make_pair(a,b) ;
  }
  REP(i,m){
    int a, b ;
    cin >> a >> b ;
    poi.at(i) = make_pair(a,b) ;
  }
  REP(i,n){
    REP(j,m){
      int a, b, c, d ;
      a = stu.at(i).F ;
      b = stu.at(i).S ;
      c = poi.at(j).F ;
      d = poi.at(j).S ;
      dis = abs(a-c)+abs(b-d) ;
      if(dis<min){
        min = dis ;
        ans = j ;
      }
      if(j==m-1){
        cout << ans+1 <<endl ;
        min = tmp ;
        ans = tmp ;
      }
    }
  }

  return 0 ;
}




Measured memory_bytes: 256
import java.io.*;
import java.util.*;
//import java.util.stream.*;
//import java.math.*;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        String s = br.readLine();
        int count = 0, i = 0;
        char c = s.charAt(0);
        while (i < s.length() - 1) {
            if (s.charAt(i + 1) == c) {
            } else {
                c = s.charAt(i + 1);
                count++;
            }
            i++;
        }
        System.out.println(count);
        bw.flush();
    }
}


Measured memory_bytes: 24660
#include <iostream>
#include <string>

using namespace std;

int main()

{
    string str;

    int len, res(0);

    cin >> str;

    len = str.size();

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

        if (str.substr(0, i) == str.substr(i, i))

            res = 2 * i;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
// #define INF 9223372036854775807
# define INF 1e9
using namespace std;

int main(){

  int A, B;
  cin >> A >> B;
  if(B % A == 0){
    cout << A + B << endl;
  } else {
    cout << B - A << endl;
  }

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main() {
    class union_find{
            vector<long> parent, tree_size;
        public:
            union_find(unsigned long _n) : parent(_n), tree_size(_n, 1){
                for(unsigned long i = 0; i < _n; ++i)parent[i] = i;
            }
            ll find(ll x){
                while(parent[x] != x)x = parent[x] = parent[parent[x]];
                return x;
            }
            void merge(ll a, ll b){
                a = find(a);
                b = find(b);
    	    if(a==b) return;
                if(tree_size[a] < tree_size[b])swap(a, b);
                tree_size[a] += tree_size[b];
                parent[b] = a;
                return;
            }
    	bool same(ll a, ll b){
    	    a = find(a);
    	    b = find(b);
    	    return a == b;
    	}
    	int size(int a){
                return tree_size[find(a)];
            }
        };
    //uf.mergeのように使う
    //ufはMAX_N+1でとるか、代入時に0-indexedにする
    cin>>N>>M>>K;
    mat blo(N, vec(0));
    vec fnum(N, 0);
    union_find uf(N + 10);
    rep(i,M){
        int a, b;
        cin>>a>>b;
        --a;
        --b;
        ++fnum[a];
        ++fnum[b];
        uf.merge(a, b);
    }
    rep(i,K){
        int c, d;
        cin>>c>>d;
        --c;
        --d;
        blo[c].push_back(d);
        blo[d].push_back(c);
    }
    rep(i,N){
        ll ans = uf.size(i) - fnum[i] - 1;
        for(int to : blo[i]) ans -= uf.same(i, to);
        cout<<ans;
        i != N - 1 ? cout<<' ' : cout<<endl;
    }
}

Measured memory_bytes: 9088
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        int w = input.nextInt();
        int h = input.nextInt();
        while(input.hasNext()){
            if(w != 0 && h != 0)
                draw(h, w);
            w = input.nextInt();
            h = input.nextInt();
        }
    }
    
    public static void draw(int w, int h){
        for(int i = 0; i < h; i ++ ){
            if(i % 2 == 0){
                for(int j = 0; j < w; j ++){
                    if(j % 2 == 0)
                        System.out.print("#");
                    else
                        System.out.print(".");
                }
            }
            else{
                for(int j = 0; j < w; j ++){
                    if(j % 2 == 0)
                        System.out.print(".");
                    else 
                        System.out.print("#");
                }
            }
            System.out.println();
        }
        System.out.println();
    }
}


Measured memory_bytes: 34212
# -*- coding: utf-8 -*-
"""
http://abc062.contest.atcoder.jp/tasks/abc062_b

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    H, W = map(int, input().split())
    data = []
    for _ in range(H):
        data.append(input().strip())

    frame = ['#' * (W+2)]

    for d in data:
        frame.append('#' + d + '#')
    frame.append('#' * (W+2))

    for line in frame:
        print(line)


if __name__ == '__main__':
    main(sys.argv[1:])

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

typedef long long ll;
typedef long double ld;
typedef pair<ll,pair<ll,ll>> pii;
typedef pair<ll,ll> pi;
typedef vector<ll> vl;

#define matrix vector<vector<ll>>
#define llmax LLONG_MAX
#define llmin LLONG_MIN
#define rep(i,n) for(ll (i)=0;(i)<n;++(i))
#define crep(i,m,n) for(ll (i)=m;(i)<n;++(i))
#define zero(a) memset((a),0,sizeof((a)))
#define minus(a) memset((a),-1,sizeof((a)));
#define sq(a) ((a)*(a))
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define ff first
#define ss second

ll global=0;

// return nCr value
long long C(int n, int r) {
	if(r>n) return 0;
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    long long ans = 1;
    int i;
    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }
    return ans;
}

// return whether number is prime or not
vector<ll> sieve(ll n){
    vector<ll> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++) {
        if (is_prime[i] && (long long)i * i <= n) {
            for (int j = i * i; j <= n; j += i)
                is_prime[j] = false;
        }
    }
    return is_prime;
}


void test_case();
int main(){
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    ll t=1;
    // cin >> t;
    for(ll T=0;T<t;T++){
        test_case();
    }
    //**************************************************************************//
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

vector<ll>dp(100005,0);
vector<bool>used(100005,false);

void dfs(ll u, vector<vector<ll>>&adj){
    used[u] = true;
    for(auto v:adj[u]){
        if(!used[v])dfs(v,adj);
        dp[u] = max(dp[v]+1, dp[u]);
    }

}

void test_case(){
    ll n,m,u,v,ans=-1;cin>>n>>m;
    vector<vector<ll>> adj(n+1);
    rep(i,m){
        cin>>u>>v;
        adj[u].pb(v);
    }
    
    crep(i,1,n+1){
        if(!used[i]) dfs(i,adj);
    }
    rep(i,n+1)ans=max(ans,dp[i]);
    cout<<ans;
}


Measured memory_bytes: 12972
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=998244353;
const int MAX=300001;
int fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

int COM(int n,int k){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int powMOD(int n,int r){
    if(r==0)return 1;
    if(r%2==0)return powMOD(n,r/2)*powMOD(n,r/2)%MOD;
    if(r%2==1)return powMOD(n,r-1)*n%MOD;
}

signed main(){
    COMinit();
    int n,a,b,k;cin>>n>>a>>b>>k;
    int ans=0;
    for(int e=0;e<=n;e++){
        int f=(k-a*e)/b;
        if(f<0||f>n||e*a+f*b!=k)continue;
        ans+=COM(n,e)*COM(n,f)%MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7296
N = int(input())
arr_V = input().split()
arr_C = input().split()

loss = [0] * N
ans = 0

for i in range(N):
    if int(arr_V[i]) - int(arr_C[i]) > 0:
        ans += int(arr_V[i]) - int(arr_C[i])
        
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;
class Graph{
public:
    Graph(llint n):g_size(n),edges(n,vector<llint>(n,linf/100)),dp(1<<n,vector<llint>(n,-1)){
        REP(i,n){
          //  edges[i][i] = 0;
        }

    }
    void add_edge(llint a,llint b,llint cost){
        edges[a][b] = cost;
    }
    llint search(llint bit,llint v){
        if(dp[bit][v]>=0){
            return dp[bit][v];
        }
        if(bit==((1<<g_size)-1)&&v==0){
            return dp[bit][v]=0;
        }
        llint result = linf/100;
        llint prevbit = bit & (~(1 << v));
        REP(i,g_size){
            if(!(bit>>i&1)){     
                result = min(result, search(bit|1<<i, i) + edges[v][i]);
            }
        }
        return dp[bit][v] = result;
    }

private:
    vector<vector<llint>> edges;
    llint g_size;
    vector<vector<llint>> dp;
};


int main(){
    llint v, e;
    cin >> v >> e;
    Graph graph(v);
    llint tmpa, tmpb, tmpc;
    REP(i,e){
        cin >> tmpa >> tmpb >> tmpc;
        graph.add_edge(tmpa, tmpb, tmpc);

    }
    llint result = linf;
    result = min(result,graph.search(0, 0));
    if(result>inf){
        result = -1;
    }
    cout << result << endl;
}



Measured memory_bytes: 7564
//
//  main.swift
//
//  Created by sun-yryr
//  Copyright © 2019 sun-yryr. All rights reserved.
//

import Foundation

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}


func readInt(separator s: Character = " ") -> [Int] {return readLine()!.split(separator: s).map({Int($0)!})}
func readDouble(separator s: Character = " ") -> [Double] {return readLine()!.split(separator: s).map({Double($0)!})}
func readElement(separator s: Character = " ") -> [String] {return readLine()!.split(separator: s).map({String($0)})}

extension String {
    func at(_ i: Int) -> Character {
        precondition(0 <= i && i < self.count)
        return self[self.index(self.startIndex, offsetBy: i)]
    }
}

func main() {
    let N = readInt()[0]
    var ans = 0
    for i in 1...N {
        let m = Int(floor(Double(N)/Double(i)))
        ans += (m * i * (m + 1)) / 2
    }
    print(ans)
}
main()


Measured memory_bytes: 13668
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;

public class Main{
  static int n;
  static int[] a, b;

  static List< List< Integer > > graph;

  static final boolean DEBUG = false;

  static int[] color;

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

    n = sc.nextInt();
    a = new int[n - 1];
    b = new int[n - 1];
    for(int i = 0; i < n - 1; i++){
      a[i] = sc.nextInt() - 1;
      b[i] = sc.nextInt() - 1;
    }

    graph = new ArrayList< >(n);
    for(int i = 0; i < n; i++){
      graph.add(new ArrayList< >());
    }
    for(int i = 0; i < n - 1; i++){
      graph.get(a[i]).add(b[i]);
      graph.get(b[i]).add(a[i]);
    }

    int[] parent = new int[n];
    dfs(0, n - 1, -1, parent);

    List< Integer > path = new ArrayList< >();
    int v = n - 1;
    while(parent[v] != -1){
      path.add(v);
      if(DEBUG){
        System.out.println("v = " + v);
      }
      v = parent[v];
    }
    path.add(0);

    color = new int[n];
    int s = path.size() - 1, t = 0;
    for(int i = 0; i < path.size() / 2; i++){
      color[path.get(s)] = 1;
      if(s == t){
        continue;
      }
      color[path.get(t)] = 2;
      --s; ++t;
    }

    int count0 = dfsCount(0, -1, 1);
    int count1 = n - count0;
    if(count0 - 1 > count1 - 1){
      System.out.println("Fennec");
    }
    else{
      System.out.println("Snuke");
    }
  }

  static void dfs(int v, int t, int p, int[] parent){
    parent[v] = p;
    if(v == t){
      return;
    }
    for(int w : graph.get(v)){
      if(w != p){
        dfs(w, t, v, parent);
      }
    }
  }

  static int dfsCount(int v, int p, int c){
    int sum = 0;
    for(int w : graph.get(v)){
      if(w != p && (color[w] == 0 || color[w] == c)){
        sum += dfsCount(w, v, c);
      }
    }
    return sum + 1;
  }
}

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

#define io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pii pair<ll, ll>
#define piii pair<ll, pair<ll, ll>>
#define debug(x) cout<<#x<<" = "<<x<<endl

using namespace std;
const int N = 100005;
ll t, n, m, k, q, a, b, x, y, ans, arr[N];
ll mod = 998244353;
string s;
bool vis[N];

ll moduloMultiplication(ll a, ll b, ll mod) {
    ll res = 0;
    a %= mod;
    while (b) {
        if (b & 1)
            res = (res + a) % mod;
        a = (2 * a) % mod;
        b >>= 1;
    }
    return res;
}

int main() {
    io;
    t = 1;
//    cin >> t;
    while (t--) {
        cin >> n;
        ans = 1;
        y = 1000000000000000001ll;
        for (int i = 0; i < n; ++i) {
            cin >> arr[i];
            if (!arr[i])
                return cout << 0 << endl, 0;
        }
        for (int i = 0; i < n; ++i) {
            ll cur = moduloMultiplication(ans, arr[i], y);
            if (ans == cur / arr[i])
                ans = cur;
            else
                return cout << -1 << endl, 0;
        }
        cout << ans << endl;
    }
    return 0;
}
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);


Measured memory_bytes: 4436
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;
int n, k;
llong T[MAX];

// 最大積載量Pのk台のトラックで何個の荷物を積めるか？
int check(llong P){
    int i=0;
    for (int j=0; j < k; j++){
        llong s = 0;
        while (s + T[i] <= P){
            s += T[i];
            i++;
            if (i == n) return n;
        }
    }
    return i;
}

int solve(){
    llong left = 0;
    llong right = 100000 * 10000; // 荷物の個数×1個あたりの最大重量
    llong mid;
    while (right - left > 1){
        mid = (left + right) / 2;
        int v = check(mid); // mid == P を決めて何個積めるかチェック
        if (v >= n) right = mid;
        else left = mid;
    }
    return right;
}
main () {
    cin >> n >> k;
    for (int i=0; i<n; i++) cin >> T[i];
    llong ans = solve();
    cout << ans << endl;
}


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

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

  int count = 0;
  for (int i = 0; i < n; i ++) {
    if (a.at(i) % 2 == 0) {
      while (a.at(i) > 1 && a.at(i) % 2 == 0) {
        count ++;
        a.at(i) /= 2;
      }
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
ll N,L,T;
vector<pair<ll, int>> ants;
vector<ll> res;
int main() {
  cin >> N >> L >> T;
  ants.resize(N);
  for (auto &ant : ants){
    cin >> ant.first >> ant.second;
    if (ant.second == 1){
      res.push_back((ant.first + T) % L);
    }else{
      res.push_back(((ant.first - T)% L + L) %L);
    }
  }
  ll cnt = 0;
  for (int i = 0; i < ants.size(); i++){
    if (ants[i].second == 1){
      cnt += (ants[i].first + T) / L;
    }else{
      cnt -= (T - ants[i].first + (L - 1)) / L;
    }
  }
  cnt %= N;
  sort(res.begin(), res.end());
  cerr << cnt << endl;
  for (int i = 0; i < N; i++){
      cout << res[(i + cnt + N) % N] << endl;
  }
  return 0;
}


Measured memory_bytes: 3700
N, M = map(int, input().split(" "))
Shops = [()]*N

for i in range(N):
    A,B = map(int, input().split(" "))
    Shops[i] = (A,B)

Drinks_Fee = 0
Drinks = 0

for shop in sorted(Shops):
    if Drinks+shop[1]>=M:
        Drinks_Fee+=shop[0]*(M-Drinks)
        break
    else:
        Drinks_Fee+=shop[0]*shop[1]
        Drinks+=shop[1]
print(Drinks_Fee)

Measured memory_bytes: 17748
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u){
  int v;
  color[u] = GRAY;
  d[u] = ++tt;
  for(v=0;v<n;v++){
    if(M[u][v] == 0) continue;
    if(color[v] == WHITE){
      dfs_visit(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs(){
  int u;

  for(u = 0; u < n; u++) color[u] = WHITE;
  tt = 0;

  for(u = 0; u < n; u++){
    if(color[u] == WHITE) dfs_visit(u);
  }
  for(u = 0; u < n; u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int u,v,k,i,j;

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

  for(i = 0; i < n; i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }
  dfs();

  return 0;
}



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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
typedef pair<ll, ll> P;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}


class Conv {
    ll cursor = 0;
    map<ll, ll> to_short; // <original, small >
    map<ll, ll> to_long; // <small, original>
    std::set<ll> tmp;


public:
    void set(ll original) {
        if (to_short.find(original) != to_short.end()) {
            return;
        }
        to_long[cursor] = original;
        to_short[original] = cursor;
        cursor++;
    }

    ll revert(ll after) {
        assert(to_long.find(after) != to_long.end());
        return to_long[after];
    }

    ll convert(ll original) {
        assert(to_short.find(original) != to_short.end());
        return to_short[original];
    }

    ll next() {
        return cursor;
    }

    // 前計算省略のため
    void cache(ll t) {
        tmp.insert(t);
    }

    void build() {
        for (ll t : tmp) {
            set(t);
        }
    }

};

int main() {
    ll n, a, b;
    cin >> n >> a >> b;

    if (a + b > n + 1) {
        cout << -1 << endl;
        ret();
    }
    if (a * b < n) {
        cout << -1 << endl;
        ret();
    }

    vector<vector<int>> boxes(a);
    rep(i, b) boxes[0].push_back(i);

    ll sub = n - b;
    if (sub > 0) {
        ll par = sub / (a - 1);
        ll md = sub % (a - 1);
        rep(i, sub) {
            if (md * (par + 1) >= i) {
                ll j = i / (par + 1);
                boxes[j + 1].push_back(b + i);
            } else {
                ll p = md * (par + 1);
                ll j = i - p;
                ll k = j / par;
                ll f = md + 1 + k;
                boxes[f].push_back(b + i);
            }
        }
    }
    rep(i, a) reverse(boxes[i].begin(), boxes[i].end());

    for (vector<int> &v: boxes) {
        for (int i : v) cout << i + 1 << ' ';
    }
    cout << endl;

}



Measured memory_bytes: 16512
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
	int k;cin>>k;
    bool v[100005];
    memset(v,0,sizeof v);
    v[100]=v[101]=v[102]=v[103]=v[104]=v[105]=1;
    for(int i=106;i<1e5+1;i++){
        if(v[i-105]||v[i-104]||v[i-103]||v[i-102]||v[i-101]||v[i-100]) v[i]=1;
    }
  	cout<<v[k];
}

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

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

    int tmp = 0, ans = 1000000000;
   for (int i=1; i<=100; i++) {
       for (int j=0; j<n; j++) {
           tmp += pow((x[j] - i), 2);
       }
       ans = min(tmp, ans);
     	tmp = 0;
   }

   cout << ans << endl;
}

Measured memory_bytes: 256
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    string ans;
    if(a+b == 15){
        ans = '+';
    }else if (a*b == 15){
        ans = '*';
    }else{
        ans = 'x';
    }

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

Measured memory_bytes: 256
len = int(input())

dict = {}

for i in range(len):
    result = input()

    if result in dict:
        dict[result] += 1
    else:
        dict[result] = 1

keys = ['AC', 'WA', 'TLE', 'RE']
for k in keys:
    cnt = 0
    if k in dict:
        cnt = dict[k]
    print("{0} x {1}".format(k, cnt))

Measured memory_bytes: 9188
typedef long unsigned int size_t;
extern int printf (const char *__restrict __format, ...);
extern int scanf (const char *__restrict __format, ...) ;
extern int getchar (void);
extern int putchar (int __c);
int nextInt(){int f=0;char s=0;char c=getchar();while((c<48)||(57<c)){if(c==45){s=1;c=getchar();break;}c=getchar();}while((48<=c)&&(c<=57)){f=f*10+(c-48);c=getchar();}return s?-f:f;}
short int nextShort(){short f=0;char s=0;char c=getchar();while((c<48)||(57<c)){if(c==45){s=1;c=getchar();break;}c=getchar();}while((48<=c)&&(c<=57)){f=f*10+(c-48);c=getchar();}return s?-f:f;}
long long int nextLong(){long long int f=0;char s=0;char c=getchar();while((c<48)||(57<c)){if(c==45){s=1;c=getchar();break;}c=getchar();}while((48<=c)&&(c<=57)){f=f*10+(c-48);c=getchar();}return s?-f:f;}
void println(){putchar(10);}
void print(char *f){while(*f){putchar(*f);f++;}}
void printInt(int f){char c[10];if(!f){putchar(48);return;}if(f<0){f=-f;putchar(45);}char i=0;while(f){c[++i]=(f%10)+48;f/=10;}while(i){putchar(c[i--]);}}
void printLong(long long int f){char c[19];if(!f){putchar(48);return;}if(f<0){f=-f;putchar(45);}char i=0;while(f){c[++i]=(f%10)+48;f/=10;}while(i){putchar(c[i--]);}}
typedef int (*__compar_fn_t) (const void *, const void *);
extern void *bsearch (const void *__key, const void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar)__attribute__ ((__nonnull__ (1, 2, 5))) ;
extern void qsort (void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar) __attribute__ ((__nonnull__ (1, 4)));
int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
int compare_long(const void *a, const void *b){if(*(long long int*)a - *(long long int*)b < 0){return -1;}else if(*(long long int*)a - *(long long int*)b > 0){return 1;}else{return 0;}}
short n, ans, d, i;
short a, p;
int main(){
 n = nextShort();
 for(i=0; i<n; i++){
  a = nextShort();
  if(a==p){d++;}
  else{ans+=(d>>1); d=1;}
  p = a;
 }
 ans+=(d>>1);
 printInt(ans);
 println();
}


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

int main()
{
    int x,y,z,sum=0,ans=0;
    cin>>x>>y>>z;
    for(int i=2;i<x;i++){
        sum = i*y+(i+1)*z;
        if(sum>x){
            ans=i-1;break;
        }
        else if(sum==x){
            ans= i;break;
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;

int main()
{
   string str ;
   cin>>str;
   int n;
   cin>>n;
    for(int i=0; i<=str.size()-1; ++i){
        if(i%n == 0) cout<<str[i];
    }
    return 0;
}


Measured memory_bytes: 256
# ABC078 B - ISU

# Y*[人数]+Z*[人数]+1 <=X
# 3*q+1*q+1<=13
# Y*q+(Z+1)*q<=X
## Y*q+Z*(q+1)<=X
## q<=(X-Z)/(Y+Z) 
# q<=(X)/(Y+Z+1)

import math
x,y,z = map(int,input().split())
t = (x-z)/(y+z)
print(math.floor(t))




Measured memory_bytes: 9060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int main(void){
    int sum=0;
int n,t[100005],m,p[105],x[105];
scanf("%d",&n);
for(int i=0;i<n;i++){
    scanf("%d",&t[i]);
}
scanf("%d",&m);
for(int i=0;i<m;i++){
    scanf("%d",&p[i]);
    scanf("%d",&x[i]);
}

for(int i=0;i<n;i++){
    sum=sum+t[i];
}

for(int i=0;i<m;i++){
    printf("%d\n",sum-(t[p[i]-1]-x[i]));
}


}

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <tuple>

using namespace std;

typedef vector<vector<char> > Field;
typedef vector<vector<bool> > LocationMap;
typedef pair<int, int> Location;
typedef pair<Location, int> LocationLevel;
typedef queue<LocationLevel> LocationQueue;

inline int solve(int h, int w, Field &field, LocationQueue &que, LocationMap& visited) {
  /*
  cout << h << " " <<  w << " " << endl;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cout << field[i][j];
    }
    cout << endl;
  }
  */
  LocationLevel loc_lev;
  Location loc;
  Location nloc;
  int i,j,level;
  int n = 0, max_level = 0;

  while(que.size()){
    loc_lev = que.front(); que.pop();
    loc = loc_lev.first;
    i = loc.first; j = loc.second;
    level = loc_lev.second;

    visited[i][j] = true;

    if (i > 0) {
      nloc = make_pair(i-1,j);
      if( !visited[i-1][j] && (field[i - 1][j] == '.') ){
        field[i - 1][j] = '#';
        visited[i-1][j] = true;
        que.push(make_pair(nloc, level + 1));
        if( level + 1 > max_level ){ max_level = level + 1; }
      }
    }
    if (i < h - 1) {
      nloc = make_pair(i+1,j);
      if( !visited[i+1][j] && (field[i + 1][j] == '.') ){
        field[i + 1][j] = '#';
        visited[i+1][j] = true;
        que.push(make_pair(nloc, level + 1));
        if( level + 1 > max_level ){ max_level = level + 1; }
      }
    }
    if (j > 0) {
      nloc = make_pair(i,j-1);
      if( !visited[i][j-1] && (field[i][j-1] == '.') ){
        field[i][j-1] = '#';
        visited[i][j-1] = true;
        que.push(make_pair(nloc, level + 1));
        if( level + 1 > max_level ){ max_level = level + 1; }
      }
    }
    if (j < w - 1) {
      nloc = make_pair(i,j+1);
      if( !visited[i][j+1] && (field[i][j+1] == '.') ){
        field[i][j+1] = '#';
        visited[i][j+1] = true;
        que.push(make_pair(nloc, level + 1));
        if( level + 1 > max_level ){ max_level = level + 1; }
      }
    }
  }

  return max_level;
}

int main(int argc, char const *argv[]) {
  int h, w;
  char c;
  Field field;
  LocationQueue que;
  LocationMap visited;

  cin >> h;
  cin >> w;

  for (int i = 0; i < h; i++) {
    vector<char> row;
    vector<bool> brow;
    for (int j = 0; j < w; j++) {
      cin >> c;
      row.push_back(c);
      brow.push_back(false);
      if (c == '#') {
        que.push(make_pair(make_pair(i, j), 0));
      }
    }
    field.push_back(row);
    visited.push_back(brow);
  }

  cout << solve(h, w, field, que, visited);

  return 0;
}


Measured memory_bytes: 13712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
const ll MOD=1e9+7;

int main(){
	// 分かりやすい
	// http://fluffyowl.hatenablog.com/entry/2019/01/08/114131
	// dp[i][j]:i番目まで決めていて、最後に置いた値が「残っている未使用の値のうちj番目に小さい値」であるような場合の数


	/*
	前回までの残り
	OOOOOOOOO
	012345678

	OOOOOOXOO
	012345 67
	       j

	前回までの残りでj番目だったやつを置くとすると
	'>'のとき,(0<=j<N-i)のすべてのjについて
		dp[i][j] += dp[i-1][k];(k>j and k<=N-i)
	'<'のとき,(0<=j<N-i)のすべてのjについて
		dp[i][j] += dp[i-1][k];(k<j and k<=N-i)

	全てのjについて計算するが累積和を用いてO(N)でできる
	これをN回やって全体でO(N^2)
	*/


	ll N;
	string s;
	cin >> N >> s;
	vector<ll> from(N,1),to(N,0),zero(N,0);
	FOR(i,1,N){
		to = zero;
		if(s[i-1]=='>'){
			ll sum = from[N-i];
			FORR(j,0,N-i){
				(to[j] += sum) %= MOD;
				(sum += from[j] ) %= MOD;
			}
		}else{
			ll sum = from[0];
			FOR(j,0,N-i){
				(to[j] += sum) %= MOD;
				(sum += from[j+1]) %= MOD;
			}
		}
		from = to;
	}

	ll ans = 0;
	FOR(i,0,N){
		(ans += from[i]) %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
import std.stdio, std.conv, std.string, std.regex, std.math, std.array, std.algorithm;

void main(){
	auto ip = readln.split;
	int A = ip[0].to!int;
	int B = ip[2].to!int;
	char op = ip[1].to!char;
	if(op == '+'){
		writeln(A + B);
	} else if(op == '-'){
		writeln(A - B);
	}
}

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

using namespace std;

int main(int argc, char const* argv[])
{
	string str;
	string hoge;

	int count = 0;
	while( cin >> str ){
		hoge = str;
		reverse( hoge.begin(), hoge.end() );
		if( hoge == str ) count++;
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 100011

struct pct {
    ll x, y, id;
};

int n, i;
pct P[maxN];
vector< pair<ll, pair<int, int> > > ord;
int dad[maxN];
ll ans;

int Find(int x) {
    if (dad[x] == x) return x;
    dad[x] = Find(dad[x]);
    return dad[x];
}

bool Merge(int x, int y) {
    x = Find(x);
    y = Find(y);

    if (x == y) return false;
    dad[x] = y;
    return true;
}

int main()
{
  //  freopen("test.in","r",stdin);

    cin >> n;
    for (i = 1; i <= n; i++) cin >> P[i].x >> P[i].y, P[i].id = i;

    sort(P + 1, P + n + 1, [](const pct& a, const pct& b)->bool const {
        return a.x < b.x;
    });

    for (i = 2; i <= n; i++) ord.pb(mp(P[i].x - P[i - 1].x, mp(P[i - 1].id, P[i].id)));

    sort(P + 1, P + n + 1, [](const pct& a, const pct& b)->bool const {
        return a.y < b.y;
    });

    for (i = 2; i <= n; i++) ord.pb(mp(P[i].y - P[i - 1].y, mp(P[i - 1].id, P[i].id)));

    sort(ord.begin(), ord.end());
    for (i = 1; i <= n; i++) dad[i] = i;

    for (auto e : ord) {
        if (Merge(e.second.first, e.second.second))
            ans += e.first;
    }

    cout << ans;


    return 0;
}


Measured memory_bytes: 8816
from queue import Queue


def main():
    n, q = map(int, input().split(' '))
    process_time = Queue()
    process_name = Queue()
    for _ in range(n):
        name, time = input().split(' ')
        process_name.put(name)
        process_time.put(int(time))
    cnt_time = 0
    while not (process_time.empty()):
        time = process_time.get()
        if time <= q:
            cnt_time += time
            print(process_name.get(), cnt_time)
        else:
            cnt_time += q
            process_time.put(time - q)
            process_name.put(process_name.get())


if __name__ == '__main__':
    main()



Measured memory_bytes: 10824
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);
	public static void main(String[] args){
		int S = scan.nextInt();
		int h = S / (60 * 60);
		int m = (S - 60 * 60 * h) / 60;
		int s = (S - 60 * 60 * h ) % 60;
		System.out.printf("%d:%d:%d\n", h, m, s);
	}
}

Measured memory_bytes: 26440
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<pair<int, int> > > vvp;
typedef vector<pair<int, int> > vp;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<vector<ll> > vvl;
typedef vector<ll> vl;
typedef vector<vector<bool> > vvb;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define mod 1000000007
#define nil -1
int main() {
	int v, e;
	cin >> v >> e;
	vvl A(v, vl(v, 1e18));
	for (int i = 0; i < v; i++)A[i][i] = 0;
	for (int i = 0; i < e; i++)
	{
		int s, t, d;
		cin >> s >> t >> d;
		A[s][t] = d;
	}
	bool f = false;
	for (int k = 0; k < v; k++)
	{
		for (int i = 0; i < v; i++)
		{
			for (int j = 0; j < v; j++)
			{
				if (A[i][k]==1e18||A[k][j]==1e18)continue;
				A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
				if (i == j && A[i][j] < 0)f = true;
			}
		}
	}
	if (f) {
		cout << "NEGATIVE CYCLE" << endl;
	}
	else {
		for (int i = 0; i < v; i++)
		{
			for (int j = 0; j < v; j++)
			{
				if (A[i][j] == 1e18)cout<<"INF";
				else cout << A[i][j];
				if (j != v - 1)cout << " ";
			}
			cout << endl;
		}
	}

}


Measured memory_bytes: 3252
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define ARRAY_SIZE 100001

int m, n, num[10] = {0,1,2,3,4,5,6,7,8,9}, p[8], ksum, uk;
char a[11];

int dfs(int k,int sum){
	int i, j, ret = 0, plus;
	if(k == uk){
		if((sum + ksum) % 10 == 0)
			return 1;
		return 0;
	}
	for(i = 0;i < m;i++){
		if((n - 1 - p[k]) % 2 == 0) plus = num[a[i] - '0'];
		else plus = (num[a[i] - '0'] * 2) / 10 + (num[a[i] - '0'] * 2) % 10;
		ret += dfs(k + 1,sum + plus);
	}
	return ret;
}

int main(void){
	int i, j;
	char s[ARRAY_SIZE];
	scanf("%d%*c",&n);
	for(i = 0;i < n;i++)
		s[i] = getchar();
	scanf("%d%*c",&m);
	for(i = 0;i < m;i++){
		a[i] = getchar();
		getchar();
	}
	ksum = uk = 0;
	for(i = 0;i < n;i++){
		if(s[i] == '*'){
			p[uk] = i;
			uk++;
		}
		else{
			if((n - 1 - i) % 2 == 0) ksum += num[s[i] - '0'];
			else ksum += (num[s[i] - '0'] * 2) / 10 + (num[s[i] - '0'] * 2) % 10;
		}
	}
	printf("%d\n",dfs(0,0));
	return 0;
}

Measured memory_bytes: 1124