akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
using ll=long long;

int main(){
    int N, tmph;
    cin >> N;
    vector<int> x(N), y(N);
    vector<ll> h(N);
    bool hh = false;
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] != 0) tmph = i;
    }
    int cx, cy, H;
    for(cx = 0; cx <= 100; cx++){
        for(cy = 0; cy <= 100; cy++){
            bool flag = true;
            int height = h[tmph] + abs(x[tmph]-cx) + abs(y[tmph]-cy);
            for(int k = 0; k < N; k++){
                int tmp_height = max(height-abs(x[k]-cx)-abs(y[k]-cy),0);
                if(tmp_height != h[k]){
                    flag = false;
                    break;
                }
            }
            if(flag){
                H = height;
                hh = true;
                break;
            }
        }
        if(hh) break;
    }
    cout << cx << " " << cy << " " << H << endl;
    return 0;
}

Measured memory_bytes: 256
local mmi, mma = math.min, math.max
local mod = 998244353
local mfl = math.floor
local function bmul(x, y)
  local x0, y0 = x % 31596, y % 31596
  local x1, y1 = mfl(x / 31596), mfl(y / 31596)
  return (x1 * y1 * 62863 + (x1 * y0 + x0 * y1) * 31596 + x0 * y0) % mod
end
local function badd(x, y)
  return (x + y) % mod
end

local n, s = io.read("*n", "*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
local dp = {}
for i = 1, s + 1 do
  dp[i] = 0
end
dp[1] = 1
for i = 1, n do
  local v = a[i]
  for j = s + 1, mma(1, s + 2 - v), -1 do
    dp[j] = bmul(dp[j], 2)
  end
  for j = s + 1 - v, 1, -1 do
    dp[j + v] = badd(dp[j + v], dp[j])
    dp[j] = bmul(dp[j], 2)
  end
end
print(dp[s + 1])


Measured memory_bytes: 2728
H, W = map(int, input().split())

if H % 3 == 0:
    ans = 0
else:
    ans = W
    h_small = max(1, H // 3)
    a = W * h_small
    b = (H - h_small) * (W // 2)
    c = (H - h_small) * ((W + 1) // 2)
    ans_new = max(a, b, c) - min(a, b, c)
    ans = min(ans_new, ans)
    h_big = H // 3 + 1
    a = W * h_big
    b = (H - h_big) * (W // 2)
    c = (H - h_big) * ((W + 1) // 2)
    ans_new = max(a, b, c) - min(a, b, c)
    ans = min(ans_new, ans)
if W % 3 == 0:
    ans = 0
else:
    ans = min(H, ans)
    w_small = max(1, W // 3)
    a = H * w_small
    b = (W - w_small) * (H // 2)
    c = (W - w_small) * ((H + 1) // 2)
    ans_new = max(a, b, c) - min(a, b, c)
    ans = min(ans_new, ans)
    w_big = W // 3 + 1
    a = H * w_big
    b = (W - w_big) * (H // 2)
    c = (W - w_big) * ((H + 1) // 2)
    ans_new = max(a, b, c) - min(a, b, c)
    ans = min(ans_new, ans)

print(ans)


Measured memory_bytes: 38384
#include <iostream>
#include <set>
#include <algorithm>

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
//    sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート


using namespace std;
using ll = long long;

int
main(void){
  int n, k;
  cin >> n >> k;
  int x[n];
  REP(i, n) cin >> x[i];  

  ll sum = 0L;

  REP(i, n){
    int l = x[i];
    int r = k-x[i];
    if(l > r) sum = sum + 2*r;
    else sum = sum + 2*l;
  }
  
  cout << sum << endl;
  return 0;
}


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

vector<vector<int>> T(100000);

int N, rd, md = -1, fen, snu, cnt = 0;

void fdfs(int c, int p, int dis) {
	if (c == N - 1) {
		rd = dis;
		md = rd / 2;
	}
	else if (md < 0) {
		int C = T[c].size();
		for (int i = 0;i < C;i++) {
			if (T[c][i] == p)
				continue;
			fdfs(T[c][i], c, dis + 1);
			if (md >= 0) break;
		}
	}
	if (dis == md + 1) {
		fen = p;
		snu = c;
	}
}

void sdfs(int c, int p) {
	cnt++;
	int C = T[c].size();
	for (int i = 0;i < C;i++) {
		if (T[c][i] == p)
			continue;
		sdfs(T[c][i], c);
	}
}

int main() {
	int a, b;
	cin >> N;
	for (int i = 0;i < N - 1;i++) {
		cin >> a >> b;
		a--;b--;
		T[a].push_back(b);
		T[b].push_back(a);
	}
	fdfs(0, 512411, 0);
	sdfs(fen, snu);
	int fc = cnt;
	cnt = 0;
	sdfs(snu, fen);
	int sc = cnt;
	//cout << fc << "," << sc << endl;
	if (sc < fc)
		cout << "Fennec" << endl;
	else
		cout << "Snuke" << endl;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 10005
 
#define PI   3.14159265358979323846264338327950
 
#define F first
#define S second
 
#define ll 	 long long int
 
#define mod  1000000007



int main()
{
	FAST;
	ll n;
	cin >> n;
	string s;
	cin >> s;
	if(n % 2){
		cout << "No";
		return 0;
	}
	for(ll i = 0; i < n / 2; i ++){
		if(s[i] != s[i+  n/2]){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int n, m;
int r;
vector<int> e[100010];
vector<int> topo;
bool used[100010];
int parent[100010];

void init() {

}

void dfs(int i) {
  if (used[i]) return;
  used[i] = true;
  REP(j, SZ(e[i])) dfs(e[i][j]);
  topo.push_back(i);
}

void makeTopo() {
  topo.clear();
  REP(i, n) dfs(i);
  reverse(ALL(topo));
}

void input() {
  REP(i, 100010) {
    // e[i].clear();
    parent[i] = -1;
  }
  cin >> n >> m;
  REP(i, n+m-1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    e[a].push_back(b);
  }
  makeTopo();
  REP(i, n) {;
    REP(j, SZ(e[topo[i]])) {
      parent[e[topo[i]][j]] = topo[i];
    }
  }
  REP(i, n) cout << parent[i] + 1 << endl;
}

void solve() {

}

int main() {
	init();
	input();
	solve();
	return 0;
}


Measured memory_bytes: 10484
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N, K;
    cin >> N >> K;
    cout << N-K+1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799;

int n, d;

int main(){
  int x[10][10];
  cin >> n >> d;
  int ans = 0;
  rep(i, n) rep(j, d) cin >> x[i][j];
  for(int i = 0; i < n-1; i++){
    for(int j = i+1; j < n; j++){
      int dist = 0;
      for(int k = 0; k < d; k++){
        dist += pow(x[i][k] - x[j][k], 2);
      }
      for(int k = 1; k <= dist; k++){
        if(k*k == dist){
          ans++;
          break;
        }
      }
    }
  }
  cout <<ans <<endl;
}
      

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <iomanip>
#include <cstdlib>
using namespace std;

//関数getinputdata宣言
vector<vector<string>> getinputdata();
vector<vector<int>> getinputdata2();
vector<vector<double>> getinputdata3();

void abc122_1(vector<vector<string>> v) {

    string btemp = v[0][0];

    const char *b = btemp.c_str();

    switch (*b) {

        case 'A':
            cout << "T" << endl;

            break;
            
        case 'C':
            cout << "G" << endl;

            break;
            
        case 'G':

            cout << "C" << endl;
            break;
            
        case 'T':
            cout << "A" << endl;

            break;


    }

}

int main() {

    vector<vector < string>> vec_arr_result;
    //    vector<vector<int>> vec_arr_result;
    vec_arr_result = getinputdata();

    abc122_1(vec_arr_result);

    return 0;
}

//関数getinputdata実装

vector<vector<double>> getinputdata3() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<double>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<double> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atof(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;
}

//関数getinputdata実装

vector<vector<int>> getinputdata2() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<int>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<int> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atoi(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;


}

//関数getinputdata実装

vector<vector < string >> getinputdata() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector < string>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<string> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(ret);
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;

}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	int ret=0;
	for (char &ch : s)
		if(ch=='2') ret++;
	cout<<ret<<"\n";
	return 0;
}

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();
    int L[] = new int[N+1];
    int R[] = new int[N+1];
    for (int i=0; i<N; i++) {
      L[i] = sc.nextInt();
      R[i] = sc.nextInt();
    }
    Arrays.sort(L);
    Arrays.sort(R);
    long ans = 0;
    for (int i=0; i<=N; i++) {
      ans += 2 * Math.max(0, L[N-i] - R[i]);
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 83396
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

LL modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}

void Main()
{
    int n,k; cin >> n >>k;

    VI p(n);
    REP(i, n) cin >> p[i];

    vector<double> q(n);
    REP(i,n){
        q[i] = (1.0+p[i]) * p[i] / 2.0;
        q[i] /= p[i];
    }

    double result = 0;

    REP(i,k){
        result += q[i];
    }

    double sum = result;

    FOR(i,k,n){
        sum -= q[i-k];
        sum += q[i];
        result = max(result, sum);
    }

    cout << result << endl;




    

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <map>
#include <numeric>
#include <queue>

using namespace std;
typedef long long ll;

int main(){
    int n;
    string s;
    cin >> n >> s;
    if(n%2==0){
        for(int i=0; i<n/2; i++){
            if(s[i]!=s[n/2+i]){
                cout << "No" << endl;
                exit(0);
            }
        }
    }else{
        cout << "No" << endl;
        exit(0);
    }
    cout << "Yes" << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n;
  cin >> n;
  if(n <= 999) cout << "ABC" << endl;
  else cout << "ABD" << endl;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let v: Vec<i64> = read_vec();
    let n = v[0];
    let m = v[1];
    let x: Vec<i64> = read_vec();
    let y: Vec<i64> = read_vec();

    let mut tmp1: i64 = 0;
    for i in 1..n {
        tmp1 = (tmp1 + i*(n-i)*(x[i as usize] - x[(i-1) as usize]))%1000000007;
    }
    let mut tmp2: i64 = 0;
    for i in 1..m {
        tmp2 = (tmp2 + i*(m-i)*(y[i as usize] - y[(i-1) as usize]))%1000000007;
    }

    println!("{}", (tmp1*tmp2)%1000000007);
}


Measured memory_bytes: 11512
#include <bits/stdc++.h>
using namespace std;
#define repx(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
const int MAX = 101010;
vector<int> member[MAX];
set<int> graph[MAX];
int memo[MAX];

// https://ja.wikipedia.org/wiki/幅優先探索
// ※bfsの動作確認用.
// @param m: 参加者.
// @param l: 連結成分番号.
// @param: 特に無し.
void bfs(int m, int l){
    
    // 1. 終了条件設定.
    if(memo[m] >= 1) return;
    
    // 2. 空のキュー.
    queue<int> q;
    
    // 3. 参加者 m をキュー q に追加.
    memo[m] = l;
    q.push(m);
    while(!q.empty()){
        
        // 4. キューから取り出す.
        int u = q.front();
        q.pop();
        
        // 5. 取り出した要素を処理.
        for(auto &e : graph[u]){
             // 6. 訪問済であれば, 処理をスキップ.
            if(memo[e] > 0)            continue;
            if(memo[e] == 0 && e != m) memo[e] = l, q.push(e);
        }
    }
    return;
}

int main(){
    
    // 1. 入力情報.
    int N, M;
    scanf("%d %d", &N, &M);
    
    // 2. 言語ごとに, 参加者情報を保存.
    rep(i, N){
        int K, L;
        scanf("%d", &K);
        rep(j, K) scanf("%d", &L), L--, member[L].pb(i);
    
    }
    rep(i, M){
        for(auto &p : member[i]){
            int f = member[i].front();
            if(f != p) graph[f].insert(p), graph[p].insert(f);
        }
    }
    // rep(i, N){
    //     for(auto &p : graph[i]) printf("i=%d p=%d\n", i, p);
    // }
    
    // 4. 連結成分の個数をカウント.
    int ans = 1;
    rep(i, N) if(memo[i] == 0) bfs(i, ans), ans++;
    // rep(i, N) printf("%d ", memo[i]);
    // printf("\n");
    
    // 5. 出力.
    printf("%s\n", (ans == 2) ? "YES" : "NO");
    return 0;
    
}

Measured memory_bytes: 17912
N, foot = map(int,input().split())


q, mod = divmod(foot, 4)

if foot % 2 ==1:
  print("No")
elif q > N :
  print("No")
elif  q == N and mod >= 2:
  print("No")
elif foot < N*2:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 9184
// cities to vapori-
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define REP(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N = 2550, INF = 1e9;

ll ans;
vector<ii> adj[N], rev[N];
bool reach[2][N];

void bfs(int n){
	fill(reach,0);
	queue<int> q;
	vector<int> dist(n+1,INF);
	dist[1] = 0;
	q.push(1);
	while(sz(q)){
		int u = q.front();
		q.pop();
		reach[0][u] = 1;
		for(ii par : adj[u]){
			int v = par.fst;
			if(dist[v] == INF){
				dist[v] = dist[u] + 1;
				q.push(v);
			}
		}
	}
	REP(i,0,n+1) dist[i] = INF;
	dist[n] = 0;
	q.push(n);
	while(sz(q)){
		int u = q.front();
		q.pop();
		reach[1][u] = 1;
		for(ii par : rev[u]){
			int v = par.fst;
			if(dist[v] == INF){
				dist[v] = dist[u] + 1;
				q.push(v);
			}
		}
	}
}

bool bford(int n){
	vector<ll> dist(n+1,ll(1e18));
	dist[1] = 0;
	for(int t = 0; t < n; ++t){
		for(int u = 1; u <= n; ++u){
			for(ii par : adj[u]){
				int v = par.fst, w = par.snd;
				dist[v] = min(dist[v], dist[u] + w);
			}
		}
	}
	ans = dist[n];
	for(int u = 1; u <= n; ++u){
		for(ii par : adj[u]){
			int v = par.fst, w = par.snd;
			if(dist[u] + w < dist[v] && reach[0][u] && reach[1][v]){
				return true;
			}
		}
	}
	return false;
}

int main(){

	fastio;
	int n,m,p;
	cin >> n >> m >> p;
	for(int i = 0; i < m; ++i){
		int a,b,c;
		cin >> a >> b >> c;
		adj[a].pb(ii(b,-(c-p)));
		rev[b].pb(ii(a,0));
	}

	bfs(n);

	if(bford(n)){
		cout << -1 << endl;
	}else{
		cout << max(-ans,0LL) << endl;
	}

	return 0;
}


Measured memory_bytes: 3992
#include<iostream>
#include<queue>
using namespace std ;
int main()
	{
	bool odd=1 ;
	bool c=1 ;
	string s ;
	s.clear() ;
	cin>>s ;
	for(int i=0 ;i<s.length() ;i++)
		{
		//cout<<"odd=="<<odd<<endl ;
		if(odd==1&&s[i]=='L')
			{
			//cout<<s[i] ;
			//cout<<"odd"<<odd ;
			cout<<"No"<<endl ;
			c=!c ;
			break ;
			}
		else if(odd==0&&s[i]=='R')
			{
			//cout<<s[i] ;
			//cout<<"odd"<<odd ;
			cout<<"No"<<endl ;
			c=!c ;
			break ;
			}
		odd=!odd ;
		}
	if(c==1)
		cout<<"Yes"<<endl ;
	}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	string str;
	cin >> str;
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		string cmd;
		cin >> cmd;
		int a, b;
		cin >> a >> b;
		if (cmd == "print") { cout << str.substr(a, b-a+1) << endl; }
		if (cmd == "reverse") {
			string chg;
			chg.resize(b - a + 1);
			for (int i = a; i <= b; i++) { chg[i-a] = str[i]; }
			for (int i = a; i <= b; i++) { str[i] = chg[b-i]; }
		}
		if (cmd == "replace") {
			string p;
			cin >> p;
			str.replace(a, b - a + 1, p);
		}
	}
	return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

int main() {
  int A, B, K;
  cin >> A >> B >> K;

  if(A>B) {
    int tmp = B;
    B = A;
    A = tmp;
  }

  vector<ll> div = divisor(A);
  reverse(div.begin(), div.end());

  int cnt = 0;
  rep(i, div.size()) {
    //cout << "div " << div[i] << endl;
    if(B%div[i]==0) {
      cnt++;
      if(cnt==K) {
        cout << div[i] << endl;
        break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <vector>
#include <cmath>
using namespace std;
          
vector<int> A;
vector<int> g;

int n, m;
int cnt;

auto prn=[=](){
    for(auto a : A)
        cout<<a<<"\n";
};

void _insSort(int g){
    for(int i=g-1;i<n;i++){
        int maxi=i;
        for(int j=i+g;j<n;j+=g){
            if(A[j] < A[maxi]){
                maxi=j;
            }
        }
        if(i!=maxi){
            swap(A[i],A[maxi]);
            cnt++;
        }
    }
 //   cout<<"----"<<g<<"-----\n";
 //   prn();
}

void insSort(int g){
    for(int i=g;i<n;i++){
        int v = A[i];
        int j = i - g;
        while(j>=0 && A[j] > v){
            A[j+g] = A[j];
            j -= g;
            cnt++;
        }
        A[j+g] = v;
    }
}

void  ShellSort(){
    int i;    
    cnt=0;
    m = n;
    if(m>100)
	m=100;
    g.push_back(1);
    for(i=1;pow(4,i)+3*pow(2,i-1)+1<n&&i<=m;i++){
        g.push_back(pow(4,i)+3*pow(2,i-1)+1);
    }
    if(i!=m)
	m=i;
    for(i=g.size()-1;i>=0;i--)
        insSort(g[i]);
}

int main(){
    ios::sync_with_stdio(false);
    int  t;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>t;
        A.push_back(t);
    }
    ShellSort();    
    cout<<m<<"\n";
    for(int i=g.size()-1;i>0;i--)
        cout<<g[i]<<" ";
    cout<<g[0]<<"\n";
    cout<<cnt<<endl;
    prn();
    return 0;
}

Measured memory_bytes: 5420
h, w = gets.split.map(&:to_i)
ss = h.times.map { gets.chomp }

ans = Array.new(h) { Array.new(w, 0) }

h.times do |i|
  w.times do |j|
    if ss[i][j] == "#"
      ans[i][j] = ss[i][j]
      next
    end

    l = j - 1 < 0 ? j : j - 1
    r = j + 1 > w ? j : j + 1
    count = 0

    if i - 1 >= 0
      count += ss[i - 1][l..r].count("#")
    end

    count += ss[i][l..r].count("#")

    if i + 1 <= h - 1
      count += ss[i + 1][l..r].count("#")
    end

    ans[i][j] = count
  end
end

ans.each { |a| puts a.join }


Measured memory_bytes: 2044
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<utility>
#include<map>


using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  int n, k;cin>>n>>k;
  map<int, int> count;
  for(int i=0;i<n;i++){
    int a;cin>>a;
    count[a]++;
  }
  if(k>=(int)count.size())cout<<0<<endl;
  else{
    vector<int> t;
    for(auto itr=count.begin();itr!=count.end();itr++){
      t.push_back(itr->second);
    }
    sort(t.begin(), t.end());
    int ans=0;
    for(int i=0;i<(int)count.size()-k;i++){
      ans+=t[i];
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 10748
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x=a*b;
  int y=c*d;
  if(x>y)cout<<x<<endl;
  else cout<<y<<endl;
  return(0);
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

const double eps = 1e-12;

int main() {
    ll N;
    cin >> N;
    for (int i=N; i >= 1; --i) {
        double t = sqrt(i);
        if (t - (int)t <= eps) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())
ans = (-1, -1, -1)
for x in range(N + 1):
    xm = 10000 * x
    if xm > Y:
        break
    for y in range(N - x + 1):
        z = N - x - y
        if xm + 5000 * y + 1000 * z == Y:
            ans = (x, y, z)
            break
    else:
        continue
    break

print(*ans)


Measured memory_bytes: 3060
#include <stdio.h>

long a1045(long *a,long p,long g,int n){
  long x,y;
  if(n==0) return (p>g)?(p-g):(g-p);

  if((x=a1045(a+1,p+a[0],g,n-1))==0) return 0;
  if((y=a1045(a+1,p,g+a[0],n-1))==0) return 0;
  return (x<y)?x:y;
}
int main(){
  long a[20];
  int i,n;
  while(scanf("%d",&n)){
    if(n==0) break;
    for(i=0;i<n;i++) scanf("%ld",&a[i]);
    printf("%ld\n",a1045(&a[0],0,0,n));
  }
  return 0;
}

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

using namespace std;

struct Edge{
    int dst, cost;
};

typedef vector<Edge> Node;
typedef vector<Node> Graph;

Graph G;
int C[1001];

const int INF = 1000000000;

int dfs(int u, int p) {
    if(C[u] > 0) return INF;
    int res = 0;
    for(Edge e : G[u]) if(e.dst != p) {
        res += min(e.cost, dfs(e.dst, u));
    }
    return res;
}

int main(){
    int N;
    while(cin >> N) {
        REP(i, N - 1) cin >> C[i + 1];
        G.assign(N, Node());
        REP(i, N - 1) {
            int u, v, c;
            cin >> u >> v >> c;
            G[u].push_back({v, c});
            G[v].push_back({u, c});
        }
        cout << dfs(0, -1) << endl;
    }
    return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n , k;
    scanf("%d%d",&n,&k);
    if(k % 2){
        int c = n / k;
        long long ans = (1LL * c * c * c);
        cout<<ans<<endl;
    }
    else{
        long long ans = 0;
        int c;
        if(n >= k/2){
            c = (n - k/2) / k + 1;
            ans = (1LL * c * c * c);
        }
        c = n / k;
        ans += (1LL * c * c * c);
        cout<<ans<<endl;
    }
    return 0;
}


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

al, ar = [A[0]], [A[-1]]
for n in range(1, N):
	al += [al[-1] + A[n]]
	ar += [ar[-1] + A[-(n + 1)]]
ar = ar[::-1]

ad = []
for n in range(N - 1):
	ad += [abs(al[n] - ar[n + 1])]

#print(al)
#print(ar)
#print(ad)
print(min(ad))


Measured memory_bytes: 37648
// 2020-09-01 22:35:00
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
void answer() {
  int n;
  cin >> n;
  deque<int> as(n);
  rep(i, n) cin >> as[i];
  sort(RALL(as));
  int cur1 = as.front();
  as.pop_front();
  int cur2 = as.back();
  as.pop_back();
  vector<P> ans;
  for (auto a : as) {
    if (a < 0) {
      ans.emplace_back(cur1, a);
      cur1 -= a;
    } else {
      ans.emplace_back(cur2, a);
      cur2 -= a;
    }
  }
  ans.emplace_back(cur1, cur2);
  cout << cur1 - cur2 << '\n';
  for (auto [x, y] : ans) {
    cout << x << ' ' << y << '\n';
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 4684
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int N_MAX = 100;
ll L[N_MAX];

ll Lucas(int n){
  if(L[n] != 0) return L[n];
  return L[n] = Lucas(n-1) + Lucas(n-2);
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  L[0] = 2;
  L[1] = 1;
  int n;cin >> n;
  cout << Lucas(n) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
using namespace std;

int main(){
  ll N;
  cin>>N;
  ll A[N+1];
  REP(i,N+1) A[i]=0;
  
  for(int i=2; i<=N; ++i){
    ll a;
    cin>>a;
    A[a]++;
  }
  
  for(int i=1; i<=N; ++i) cout<<A[i]<<endl;
}

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

  int n, A[2000001], i, C[10001], B[2000001], max=0;

int main(){


  for(i=0;i<=10000;i++){
    C[i]=0;
  }
    
  scanf("%d", &n);
  for(i=1;i<=n;i++){
    scanf("%d", &A[i]);
    if(max < A[i]) max = A[i];
    C[A[i]]++;
  }

  for(i=1;i<=max;i++){
    C[i] = C[i-1] + C[i];
  }

  for(i=n;i>0;i--){
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }

  for(i=1;i<=n;i++){
    printf("%d", B[i]);
    if(i != n) printf(" ");
  }

  printf("\n");

  return 0;
}
    
    



Measured memory_bytes: 17372
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
int n;
int main()
{
	cin>>n;
	if (n<1200) cout<<"ABC";
	else if (n<2800) cout<<"ARC";
	else if (n>=2800) cout<<"AGC";
    return 0;
}

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

int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double a_th, b_th, res;
    double ax, ay, bx, by;

    cout << fixed << setprecision(20);

    a_th = (M_PI / 2) - (h + m/60) * M_PI / 6;
    b_th = (M_PI / 2) - m / 60 * 2 * M_PI;

    ax = a * cos(a_th); ay = a * sin(a_th);
    bx = b * cos(b_th); by = b * sin(b_th);

    res = pow(pow(ax - bx, 2) + pow(ay - by, 2), 0.5);
    cout << res << endl;
}

Measured memory_bytes: 4300
from queue import Queue
H, W = map(int, input().split())
S=[input() for _ in range(H)]

def bfs(sy, sx):
    mx=0
    q=Queue()
    dist=[[-1]*W for _ in range(H)]
    q.put((sy,sx))
    dist[sy][sx]=0
    while not q.empty():
        y, x=q.get()
        y_nxt=[y+1, y-1, y, y]
        x_nxt=[x, x, x+1, x-1]
        for Y,X in zip(y_nxt, x_nxt):
            if not (0 <= Y < H) or not (0 <= X < W) or S[Y][X]=="#":
                continue
            if dist[Y][X]==-1:
                dist[Y][X]=dist[y][x]+1
                q.put((Y, X))
                mx=max(mx, dist[Y][X])
    return mx

mx=0
for y in range(H):
    for x in range(W):
        if S[y][x]=="#":
            continue
        else:
            mx=max(bfs(y,x),mx)

print(mx)

Measured memory_bytes: 9672
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n+1][3];
  for(int i=1;i<=n;i++)
  	cin>>a[i][0]>>a[i][1]>>a[i][2];
  int dp[n+1][3];
  dp[0][0]=0;dp[0][1]=0;dp[0][2]=0;
  dp[1][0]=a[1][0];dp[1][1]=a[1][1],dp[1][2]=a[1][2];
  for(int i=2;i<=n;i++)
  {
     dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
     dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
     dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
  }
  cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
  return 0;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = N;
    rep(i, N + 1) {
        int a = i;
        int b = N - i;
        int cnt = 0;
        int c = 6*6*6*6*6*6;
        int d = 9*9*9*9*9;
        while(a > 0) {
            while(a < c) c /= 6;
            a -= c;
            cnt++;
        }
        while(b > 0) {
            while(b < d) d /= 9;
            b -= d;
            cnt++;
        }
        //cout << i << " " << N - i << " " << cnt << endl;
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i=0; i<(int64_t)(n); i++)
#define all(v) v.begin(), v.end()
//c
int main(){
  
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double rad, ans, pai=3.1415926535897;
  rad=pai*2*m/60-pai*2*(h*60+m)/720;
  cout << fixed << setprecision(10);
  ans=(double)a*a+b*b-2*a*b*cos(rad);
  ans=sqrt(ans);
  //cout << cos(rad) << endl;
  cout << ans << endl;
  
}

Measured memory_bytes: 4228
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  string s;
  cin >> s;
  int t = 0;
  for (auto ss : s) {
    if (ss == 'o') t+=1;
  }
  int p = 15 - s.size();
  // debug(p);
  if (s.size() < 8 or p + t >= 8) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


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

using namespace std;

int main(void)
{
    int k, n, i, in;
    long sum = 0;

    cin >> k >> n;

    int ar[n], dist[n];

    for(i = 0; i < n; i++)
    {
        cin >> in;
        ar[i] = in%k;
    }

    sort(ar,ar+n);

    sum = dist[0] = ar[0]+k-ar[n-1];

    for(i = 1; i < n; i++)
    {
        dist[i] = ar[i]-ar[i-1];
        sum+= ar[i]-ar[i-1];
    }

    sort(dist,dist+n);

    cout << sum - dist[n-1];

    return 0;
}


Measured memory_bytes: 1920
N = int(input())
Alist = [int(x) for x in input().split()]
M = max(Alist)
A0 = ['NotUse']
Abool = A0 + [0 for x in range(M)]
Alist.sort()
ans = 0

for i in Alist:
    for j in range(i,M+1,i):
        if Abool[j] >= 2:
            None
        else:
            Abool[j] += 1
    
for i in Alist:
    if Abool[i] == 1:
        ans += 1
print(ans)

Measured memory_bytes: 35012
n, m, l = STDIN.gets.split(' ').map(&:to_i)

mat1 = []
n.times do |i|
  mat1 << STDIN.gets.split(' ').map(&:to_i)
end

mat2 = []
m.times do |i|
  mat2 << STDIN.gets.split(' ').map(&:to_i)
end

n.times do |i|
  row = []
  l.times do |j|
    # mat1 ??? i ?????? * mat2 ??? j ??????
    sum = 0
    m.times do |k|
      sum += mat1[i][k] * mat2[k][j]
    end
    row << sum
  end
  puts row.join(' ')
end

Measured memory_bytes: 9320
import java.util.Scanner;

/**
 * Created by enpingkuang on 2020/9/13 9:29 下午
 */
public class Main {
    private static long MOD = 1000000007;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long[][] dp = new long[2001][2001];
        long ans = 0;
        //dp[i][j]   j的i划分
        dp[0][0] = 1;
        for(int i = 1;i<=n/3;i++){
            for(int j = 1;j<=n;j++){
                if(j - 3 >= 0){
                    dp[i][j] = (dp[i][j-1] + dp[i-1][j-3])%MOD;
                }else{
                    dp[i][j] = dp[i][j-1];
                }
            }
            ans = (ans + dp[i][n])%MOD;
        }
        System.out.println(ans);
    }
}


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

int main(){
	int A,B,ans;
	cin>>A>>B;
	
	if(A>=13){
		ans=B;
	}
	else if(6<=A&&A<=12){
		ans=B/2;
	}
	else
		ans=0;
	
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono> 
 
using namespace std;
using namespace std::chrono; 
 
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma optimization_level 3
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define f0r(a, b) for (long long a = 0; a < (b); ++a)
#define f1r(a, b, c) for (long long a = (b); a < (c); ++a)
#define f0rd(a, b) for (long long a = (b); a >= 0; --a)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); --a)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL); cout.tie(NULL);}
#define fix(prec) {cout << setprecision(prec) << fixed;}
#define mp make_pair
#define f first
#define s second
#define presum(p, a, n) {p[0] = a[0]; for (int i = 1; i < (n); i++) p[i] = a[i] + p[i-1];}
#define all(v) v.begin(), v.end()
#define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());}
#define readgraph(list, edges) for (int i = 0; i < edges; i++) {int a, b; cin >> a >> b; a--; b--; list[a].pb(b); list[b].pb(a);}
#define ai(a, n) for (int ele = 0; ele < n; ele++) cin >> a[ele];
#define ain(a, lb, rb) for (int ele = lb; ele <= rb; ele++) cin >> a[ele];
#define ao(a, n) {for (int ele = 0; ele < (n); ele++) { if (ele) cout << " "; cout << a[ele]; } cout << '\n';}
#define aout(a, lb, rb) {for (int ele = (lb); ele <= (rb); ele++) { if (ele > (lb)) cout << " "; cout << a[ele]; } cout << '\n';}
typedef long long ll;
typedef double ld;
typedef long double lld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
 
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
  cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
  cin >> p.first;
  return cin >> p.second;
}
 
// mt19937 rng(steady_clock::now().time_since_epoch().count());
mt19937 rng(61378913);
/* usage - just do rng() */
 
void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}
 
const lld pi = 3.14159265358979323846;
const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;
 


ll n, m, k, q, l, r, x, y, z;
ll a[1000005];
ll b[1000005];
ll c[1000005];
string s, t;
ll ans = 0;



void solve(int tc) {
  cin >> n >> m; cout << n * m;
}
 
int main() {
  send help
 
  // usaco("file");


  int tc = 1;
  // cin >> tc;
  for (int t = 0; t < tc; t++) solve(t);
} 

Measured memory_bytes: 3644
#include<algorithm> 
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cstdio>
#include<ctime>

using namespace std;

inline int read() {
	int res=0,fh=1;
	char ch=getchar();
	while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
	if(ch=='-')fh=-1,ch=getchar();
	while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar();
	return fh*res;
}

const int maxn=100010;
int n,a[maxn];
int main()
{
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=2;i<=n;i++){
		if(a[i]-1>=a[i-1]) a[i]--;
	}
	for(int i=2;i<=n;i++) if(a[i]<a[i-1]) return puts("No"),0;
	return printf("Yes\n"),0;
}

Measured memory_bytes: 640
function main(input) {
  input=input.trim();
  const a = parseInt(input.split(" ")[0], 10);
  const b = parseInt(input.split(" ")[1], 10);
  const c = parseInt(input.split(" ")[2], 10);
  var arr=[a,b,c]
  arr.sort()
  if(arr[0]==5&&arr[1]==5&&arr[2]==7){
    console.log("YES");
  }else{
    console.log("NO");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
  int K;
  string S;
  cin >> K >> S;
  if (S.size() <= K) cout << S << endl;
  else {
    rep(i,K) cout << S[i];
    cout << "..." << endl;
  }
  return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n;

int32_t main(){_
   

   vector<int> a(3);
   cin >> a[0] >> a[1] >> a[2];
      
   int k;
   cin >> k;
   vector<int> b = a;

   for (int i = 0; i <= k; ++i)
   {
      for (int j = 0; j <= k; ++j)
      {
         for (int l = 0; l <= k; ++l)
         {
            if (i + j + l > k){
               continue;
            }
            a = b;
            a[0] *= pow(2, i);
            a[1] *= pow(2, j);
            a[2] *= pow(2, l);
      if (a[1] > a[0] and a[2] > a[1]){
         cout<<"Yes";
         exit(0);
      }

         }
      }
   }

   cout<<"No";

   return 0;
}

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

int main() {
  int r,g,b;
  int x;
  
  cin >> r >> g >> b ;
  x = 100*r + 10*g + b;
  if ( x % 4 == 0 ){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

typedef struct {
    bool L, R;
} p_t;

int main() {
    vector<int> res;
    int w, d;
    while (cin >> w >> d and w) {
        vector<int> a(w), b(d);
        for (int i = 0; i < w; i++) {
            cin >> a[i];
        }
        for (int i = 0; i < d; i++) {
            cin >> b[i];
        }
        map<int, int> mp;
        for (int i = 0; i < w; i++) {
            mp[a[i]]++;
        }
        int sum = 0;
        map<int, int> mp2;
        for (int i = 0; i < d; i++) {
            if (mp[b[i]] > 0) {
                sum += b[i];
                mp[b[i]]--;
            }
            else {
                mp2[b[i]]++;
            }
        }
        for (auto i : mp) {
            if (i.se > 0) {
                sum += i.fi * i.se;
            }
        }
        for (auto i : mp2) {
            if (i.se > 0) {
                sum += i.fi * i.se;
            }
        }
        res.push_back(sum);
    }
    for (int i = 0; i < (int)res.size(); i++) {
        dump(res[i]);
    }
    return 0;
}



Measured memory_bytes: 3144
import collections
n = int(input())
a = list(map(int,input().split()))

c = sorted(collections.Counter(a).items(),reverse = True)

tmp = 0
ans=[]

for k in c:
  if k[1]>=4:
    tmp = max(tmp,k[0]*k[0])
  if k[1]>=2:
    ans.append(k[0])
  else:
    continue

if len(ans)>=2:
  print(max(ans[0]*ans[1],tmp))
else:
  print(tmp) 

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

int main() {
  int n,t;
  cin>>n>>t;
  int ans=1001;
  for(int i=0;i<n;i++){
    int c,T;
    cin>>c>>T;
    if(T<=t){
      ans=min(ans,c);
    }
  }
  if(ans==1001) cout<<"TLE"<<endl;
  else cout<<ans<<endl;
}


Measured memory_bytes: 3636
n, m, d = map(int, input().strip().split())

c = "RYGB"

if d % 2 == 1:
    for i in range(n):
        print("".join([c[(i + j) % 2] for j in range(m)]))
else:
    for i in range(n):
        result = []
        for j in range(m):
            b1 = ((i + j) // d) % 2
            b2 = ((i - j) // d) % 2
            result += c[b1 * 2 + b2]
        print("".join(result))

Measured memory_bytes: 3316