akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#define MAX 20000  // スタックの最大値

typedef struct{
  int top;         // スタックポインタ(一番上の位置)
  int S[MAX];
}Stack;


// スタック st の初期化
void initialize(Stack *st)
{
  st->top = 0;
  st->S[st->top] = 0;
}

// スタック st が空かどうかを確認
int isEmpty(Stack *st)
{
  return st->top == 0;
}

// スタック st が一杯かどうかを確認
int isFull(Stack *st)
{  
  return st->top >= MAX - 1;
}

// スタック st に要素 x をフラッシュ(一番上に要素を追加)
void push(int x, Stack *st)
{
  if (isFull(st)) 
    exit(1);

  st->top++;
  st->S[st->top] = x;
}

// スタック st から要素をポップ(一番上の要素を取り出す)
int pop(Stack *st) {
  if (isEmpty(st)) 
    exit(1);

  st->top--;
  return st->S[st->top+1];
}


int main(void)
{
  Stack st1;     // '\' の開始位置を格納するスタック
  Stack st2_j;   // 各水たまりの最も左の'\' の位置を格納するスタック
  Stack st2_a;   // 各水たまりの水量を格納するスタック

  // スタック初期化
  initialize(&st1);
  initialize(&st2_j);
  initialize(&st2_a);

  char c;
  int sum = 0;  // 水たまりの総水量

  // 地形を読み込み，各水たまりの水量を計算
  for (int i = 0; (c = getchar()) != EOF; i++) {
    if (c == '\\') {                                 // '\' が出た時の処理
      // 位置 i を st1 にプッシュ(write your code)
    	push(i, &st1);
       
    }else if (!isEmpty(&st1) && c == '/') {          // '/' が出た時の処理
      // 水たまりの総水量 sum を更新(write your code)
    	int j = pop(&st1);
    	sum = sum + i - j;
      
      // st2_j と st2_a を用いて水たまりの水量を更新 
      int a = i - j;   // 更新する水たまりの水量を a に格納していく
      while (!isEmpty(&st2_j) && st2_j.S[st2_j.top] > j) {  // 最も左の '\' の位置が j よりも大きい場合，以下を繰り返す
        // 水たまりの水量を求めていく (write your code)
      	a = a + pop(&st2_a);
      	pop(&st2_j);
      }
      // 更新した水たまりの「最も左の'\' の位置」および「水量」を更新 (write your code)
    	push(j, &st2_j);
    	push(a, &st2_a);
    }
  }

  printf("%d\n", sum);       // 水たまりの総水量を出力
  printf("%d", st2_a.top);   // 水たまりの個数を出力

  // 各水たまりの水量を断面図の左から出力(スタックの底から出力)
  for (int i = 1; i <= st2_a.top; i++) 
    printf(" %d", st2_a.S[i]);  
  printf("\n");

  return 0;
}


Measured memory_bytes: 2144
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  int N, K;
  ci(N, K);
  if(N % K == 0){
    co(0);
  }
  else{
    co(1);
  }
}

Measured memory_bytes: 256
N = int(input())
S = {}
for i in range(N):
    s = input()
    if s in S:
        S[s] += 1
    else:
        S[s] = 1

m = max(S.values())

ans = [k for k, v in S.items() if v == m]
ans.sort()



for i in ans:
    print(i)


Measured memory_bytes: 32096
#include <stdio.h>
int main(){
	int i,a[26]={};
	char w;
	while (scanf("%c",&w)!=EOF){
		if (w>='a'&&w<='z')
			a[w-'a']++;
		else if (w>='A'&&w<='Z')
			a[w-'A']++;
	}
	for (i=0;i<26;i++)
		printf("%c : %d\n",i+'a',a[i]);	
	return 0;
}

Measured memory_bytes: 540
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

int main(){
  ll dp[55][6000];
  int N, A;
  cin >> N >> A;
  int x[N];
  rep(i, N){
    cin >> x[i];
    x[i] -= A;
  }
  dp[0][A*N]=1;
  rep(i, N){
    rep(j, 5590){
       dp[i+1][j+x[i]] += dp[i][j];
       dp[i+1][j] += dp[i][j];
    }
  }
  ll ans = dp[N][A*N];
  ans--;
  cout << ans << endl;
}


Measured memory_bytes: 2816
#include <iostream>
#include <cstdio>
#include <set>
#include <algorithm>
using namespace std;
int N;
int a[200001],b[200001];
int main(){
  cin >> N;
  long long int ans=0;
  set<int> s,t;
  for(int i=1;i<=N;i++){
    cin >> a[i];
    b[a[i]]=i;
  }
  //for(int i=1;i<=N;i++)printf("%d ",b[i]);
  //printf("\n");
  s.insert(0);
  s.insert(N+1);
 
  for(int i=1;i<=N;i++){
    /*
     for( set<int>::iterator ite=s.begin();ite!=s.end();ite++){
    cout << *ite << " ";
  }
    */
    set<int>::iterator it=s.lower_bound(b[i]);
    //cout << "b[" << i << "]= " << b[i] << " *it= " << *it << endl;
    long long r=(*it)-b[i];
    it--;
    long long l=b[i]-(*it);
    ans+=r*l*i;
    s.insert(b[i]);
    //printf("i=%d l=%d r=%d %d\n\n",i,l,r,ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
#include <set>

using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
ll a, b;
	cin >> a >> b;
	ll diff = b - a;
	ll sum = 0;
	for (ll i = 1; i <= (diff - 1); i++) {
		sum += i;
	}
	cout << sum - a << endl;
	return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int64_t GCD(int64_t a, int64_t b) {
	if (!b) return a;
	else return GCD(b, a % b);
}

int64_t LCM(int64_t a, int64_t b) {
	int64_t gcd = GCD(a, b);
	int64_t n, m;
	n = a / gcd;
	m = b / gcd;
	return gcd * n * m;
}

int main() {
	int64_t A, B, C, D;
	cin >> A >> B >> C >> D;

	vector<int64_t> a(3), b(3);
	int64_t g = LCM(C, D);
	a[0] = B / C;	a[1] = B / D;	a[2] = B / g;
	b[0] = (A-1) / C;	b[1] = (A - 1) / D;	b[2] = (A - 1) / g;

	int64_t ret = B - A + 1;
	int64_t n = (a[0] - b[0]) + (a[1] - b[1]) - (a[2] - b[2]);
	ret -= n;

	cout << ret << endl;
}

Measured memory_bytes: 3628
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


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

	ll temp = stoi(a+b);

	int ans = sqrt(temp);
	if(ans*ans == temp)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {
		Scanner scan = new Scanner(System.in);
		String c = scan.next();
		ArrayList<String> v = new ArrayList<String>();
		v.add("a"); v.add("i");v.add("u");v.add("e");v.add("o");
		System.out.println((v.contains(c))? "vowel":"consonant");
	}

}

Measured memory_bytes: 21716
#include<iostream>

using namespace std;

int main(){

	int h, w;

	while (true){

		cin >> h >> w;

		if (h == 0 && w == 0)break;

		for (int i = 0; i <= h - 1; i++){

			for (int j = 0; j <= w - 1; j++){

				if ((i % 2 == 0 && j % 2 == 0) || (i % 2 != 0 && j % 2 != 0)){
					cout << '#';
				}
				else{
					cout << '.';
				}

			}

			cout << endl;
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K, cnt=0;
  cin >> N >> K;
  vector<int> h(N);
  REP(i,N) {
    cin >> h[i];
    if(h[i]>=K) cnt++;
  }
  cout << cnt << endl;
}

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

using namespace std;


int main(void){
	int N; cin >> N;
	vector<string> s(N);
	string t;
	int i;
	bool flag = true;

	for (i = 0; i < N; i++) {
		cin >> t;
		s[i] = t;
	}

	for (i = 0; i < N - 1; i++) {
		if (s[i].back() != s[i + 1].front()) {
			flag = false;
		}
	}


	for (i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i>=j) {
				continue;
			}
			if (s[i] == s[j]) {
				flag = false;
			}
		}
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else { cout << "No" << endl; }

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define  rep(i,a,b) for(i=a;i<b;i++)
#define endl "\n"
#define ll long long int
#define ld long double
using namespace std;
int main()
{
IOS;
ll n,i;
cin>>n;
ll a[n],b[n],c[n-1];
rep(i,0,n)
cin>>a[i];
rep(i,0,n)
cin>>b[i];
rep(i,0,n-1)
cin>>c[i];
ll sum=0;
rep(i,0,n)
{
    sum=sum+b[a[i]-1];
    if(a[i+1]==a[i]+1)
        sum=sum+c[a[i]-1];
}
cout<<sum;
return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val heroCount = readLine()!!.toInt()
    val monsterCountParTown = readLine()!!.split(" ").map { it.toInt() }
    val maxKillCountParHero = readLine()!!.split(" ").map { it.toInt() }

    print(abc135c(heroCount, monsterCountParTown, maxKillCountParHero))
}

fun abc135c(heroCount: Int, monsterCountParTown: List<Int>, maxKillCountParHero: List<Int>): Long {
    var ans:Long = 0
    val monsterCount = mutableMapOf<Int, Int>()
    for(i in monsterCountParTown.indices){
        monsterCount[i] = monsterCountParTown[i]
    }

    //協力が出来ていない？
    // 必ず前の街を全力で潰す。二つ目の全力にするパターンもある？
    for (i in 1..heroCount) {
        val target: Pair<Int, Int> = Pair(monsterCount[i - 1]!!, monsterCount[i]!!)
        val attackResult = attackMonster(target, maxKillCountParHero[i - 1])
        ans += attackResult.first
        monsterCount[i - 1] = attackResult.second
        monsterCount[i] = attackResult.third
    }
    return ans
}

fun attackMonster(target: Pair<Int, Int>, maxKillCount: Int): Triple<Long, Int, Int> {

    var firstTownMonsterCount = target.first
    var secondTownMonsterCount = target.second
    var killCount:Int

    //最初の街を攻撃
    when {
        firstTownMonsterCount > maxKillCount -> { //全部殺せない場合
            killCount = maxKillCount
            firstTownMonsterCount -= killCount

            return Triple(killCount.toLong(), firstTownMonsterCount, secondTownMonsterCount)
        }
        else -> {
            killCount = firstTownMonsterCount
            firstTownMonsterCount = 0
        }
    }

    //次の街を攻撃
    return when {
        secondTownMonsterCount > (maxKillCount - killCount) -> { //全部殺せない場合
            secondTownMonsterCount -= (maxKillCount - killCount)
            killCount = maxKillCount
            Triple(killCount.toLong(), firstTownMonsterCount, secondTownMonsterCount)
        }
        else ->{
            killCount += secondTownMonsterCount
            secondTownMonsterCount = 0
            Triple(killCount.toLong(), firstTownMonsterCount, secondTownMonsterCount)
        }
    }
}

Measured memory_bytes: 96500
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;
	cin>>a>>b;
	cout<<(6-(a+b));
    return 0;
}


//252908XL

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int N,M;
	cin >> N >> M;
	int L[100000],R[100000];
	int ansL = 0;
	int ansR = N+1;	
	for (int i = 0; i < M; ++i)
	{
		cin >> L[i] >> R[i];

		ansL = max(ansL,L[i]);
		ansR = min(ansR,R[i]);
	}

	if (ansL > ansR)
	{
		cout << "0" << endl;
	}
	else
	{
		cout << ansR - ansL + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL n;
    cin >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    VVLL dp(n, VLL(5));
    dp[0][0] = dp[0][4] = a[0];
    dp[0][1] = dp[0][3] = a[0] % 2;
    if (a[0] < 1) {
        dp[0][1] += 2;
        dp[0][3] += 2;
    }
    dp[0][2] = (a[0] + 1) % 2; 
    REP(i,1,n) {
        dp[i][0] = dp[i-1][0] + a[i];
        dp[i][1] = a[i] % 2 + min(dp[i-1][0], dp[i-1][1]);
        dp[i][2] = (a[i]+1) % 2 + min({dp[i-1][0], dp[i-1][1], dp[i-1][2]});
        dp[i][3] = a[i] % 2 + min({dp[i-1][0], dp[i-1][1], dp[i-1][2], dp[i-1][3]});
        dp[i][4] = a[i] + min({dp[i-1][0], dp[i-1][1], dp[i-1][2], dp[i-1][3], dp[i-1][4]});
        if (a[i] < 1) {
            dp[i][1] += 2;
            dp[i][3] += 2;
        }
    }
    cout << *min_element(all(dp[n-1])) << endl;
    /*
    REP(i,0,n) {
        REP(j,0,5) cout << (dp[i][j] == (1LL << 60) ? -1LL : dp[i][j]) << " ";
        cout << endl;
    }
    */
}

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

Measured memory_bytes: 15872
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
vector<pair<int, int>>X[1 << 17], Y[1 << 17]; int dist[1 << 17], N, A, B, C, root; queue<int>Q;
int main() {
	cin >> N;
	for (int i = 0; i < N - 1; i++) { cin >> A >> B >> C; X[A].push_back(make_pair(B, C)); Y[B].push_back(make_pair(A, C)); }
	for (int i = 0; i < N; i++) { if (Y[i].size() == 0) { root = i; } }
	for (int i = 0; i < N; i++) { dist[i] = 1145141919; }Q.push(root); dist[root] = 0;
	while (!Q.empty()) {
		int a1 = Q.front(); Q.pop();
		for (int i = 0; i < X[a1].size(); i++) {
			int to = X[a1][i].first, a2 = X[a1][i].second;
			if (dist[to] == 1145141919) { dist[to] = dist[a1] + a2; Q.push(to); }
		}
	}
	int maxn = 0, maxid = 0;
	for (int i = 0; i < N; i++) { if (maxn < dist[i]) { maxn = dist[i]; maxid = i; } }Q.push(maxid);
	for (int i = 0; i < N; i++) { dist[i] = 1145141919; }dist[maxid] = 0;
	while (!Q.empty()) {
		int a1 = Q.front(); Q.pop(); maxn = 0; maxid = 0;
		for (int i = 0; i < X[a1].size(); i++) {
			int to = X[a1][i].first, a2 = X[a1][i].second;
			if (dist[to] > dist[a1] + a2) { dist[to] = dist[a1] + a2; Q.push(to); }
		}
		for (int i = 0; i < Y[a1].size(); i++) {
			int to = Y[a1][i].first, a2 = Y[a1][i].second;
			if (dist[to] > dist[a1] + a2) { dist[to] = dist[a1] + a2; Q.push(to); }
		}
	}
	for (int i = 0; i < N; i++) { if (maxn < dist[i]) { maxn = dist[i]; maxid = i; } }
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 15844
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 110000
#define MAX_V 900010
#define vec vector<int>
using namespace std;

main(){
    int n,k;
    cin>>n>>k;
    int x[N],y[N];
    rep(i,n){
        cin>>x[i]>>y[i];
        char c;cin>>c;
        if(c=='W')y[i]+=k;
        x[i]%=(2*k);
        y[i]%=(2*k);
    }
    int s[4020][4020]={};
    rep(i,n){
        s[x[i]][y[i]]++;
        s[x[i]+k][y[i]]--;
        s[x[i]][y[i]+k]--;
        s[x[i]+k][y[i]+k]++;
    }
    
    rep(i,4010)rep(j,4010){
        s[i][j+1]+=s[i][j];
    }
    rep(i,4010)rep(j,4010){
        s[j+1][i]+=s[j][i];
    }
    int ans=0;
    rep(i,2*k)rep(j,2*k){
        ans=max(ans,s[i][j]+s[i+k][j+k]+s[i+2*k][j+2*k]+s[i+2*k][j]+s[i][j+2*k]);
        if(i>=k)ans=max(ans,s[i-k][j+k]+s[i][j]+s[i+k][j+k]+s[i+2*k][j+2*k]+s[i+2*k][j]+s[i][j+2*k]);
        if(j>=k)ans=max(ans,s[i+k][j-k]+s[i][j]+s[i+k][j+k]+s[i+2*k][j+2*k]+s[i+2*k][j]+s[i][j+2*k]);
        if(i>=k&&j>=k)ans=max(ans,s[i-k][j+k]+s[i+k][j-k]+s[i][j]+s[i+k][j+k]+s[i+2*k][j+2*k]+s[i+2*k][j]+s[i][j+2*k]);

    }
    cout<<ans;
}

Measured memory_bytes: 64256
#include <stdio.h>
#include <string.h>

typedef struct Process
{
    char name[100];
    int time;
}Process;

class ProcessQueue
{
private:
    int m_Tail;
    int m_Head;
    int m_Size;
    Process* m_Queue;
    
public:
    ProcessQueue(int size):
    m_Size(size + 1),
    m_Head(0),
    m_Tail(0)
    {
        m_Queue = new Process[m_Size];
    };

    ~ProcessQueue()
    {
        delete[] m_Queue;
    };

    bool enqueue(Process val)
    {
        m_Queue[m_Tail] = val;
        m_Tail++;
        if(m_Tail == m_Size)
        {
            m_Tail = 0;
        }
        return true;
    }

    bool dequeue(Process* val)
    {
        if(isEmpty())
        {
            return false;
        }
        *val = m_Queue[m_Head];
        m_Head++;
        if(m_Head == m_Size)
        {
            m_Head = 0;
        }
        return true;

    }

private:
    bool isEmpty()
    {
        if(m_Head == m_Tail)
        {
            return true;
        }
        else
        {
            return false;
        }
    };

    bool isFull()
    {
        if( (m_Tail+1) % m_Size == m_Head)
        {
            return true;
        }
        else
        {
            return false;
        }
        
    }
};

int main()
{
    int numProcess, quantum, elapsed;

    scanf("%d %d", &numProcess, &quantum);
    ProcessQueue queue(numProcess);


    Process temp;
    for(int i= 0; i < numProcess; i++)
    {
        scanf("%s", temp.name);
        scanf("%d", &temp.time);
        queue.enqueue(temp);
    }
    elapsed = 0;

    while(queue.dequeue(&temp))
    {
        if(temp.time > quantum)
        {
            temp.time -= quantum;
            queue.enqueue(temp);
            elapsed += quantum;
        }
        else
        {
            elapsed += temp.time;
            printf("%s %d\n", temp.name, elapsed);
        }
    }

}



Measured memory_bytes: 7324
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int mod = 1_000_000_007;
		int n = sc.nextInt();
		long ans = 1;
		for (int i = 1; i <= n; i++) {
			ans = ans * i % mod;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23380
#https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d
#2019-02-11

#DP

L = int(input())

DP = [0 for i in range(5)]

def cost(a):
    if a:
        return [a, a%2, (a+1)%2, a%2, a]
    else:
        return [0, 2, 1, 2, 0]

for i in range(L):
    n = [min(DP[:i+1]) for i in range(5)]
    a = int(input())
    cos = cost(a)
    DP[0] = n[0] + cos[0]
    DP[1] = n[1] + cos[1]
    DP[2] = n[2] + cos[2]
    DP[3] = n[3] + cos[3]
    DP[4] = n[4] + cos[4]



print(min(DP))

Measured memory_bytes: 3188
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayDeque<Integer> ans = new ArrayDeque<Integer>();
		ArrayDeque<Integer> sta = new ArrayDeque<Integer>();

		while(sc.hasNext()){
			int n = sc.nextInt();
			if(n==0){
				ans.push(sta.pop());
			}else{
				sta.push(n);
			}
		}
		int num = ans.size();
		for(int i=0;i<num;i++){
			System.out.println(ans.pollLast());
		}
	}
}

Measured memory_bytes: 17212
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define oo (int)1e9
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

char s[N];
int main(){
    int n;
    scanf("%d%s", &n, &s);
    int cnt = 0;
    for(int i = 0 ; i < n ; ){
        int j = i;
        while(j < n && s[i] == s[j])++j;
        ++cnt;
        i = j;
    }
    printf("%d\n", cnt);
}

Measured memory_bytes: 384
N=int(input())
A=list(map(int, input().split()))
L=[0]*(100001)
#何回その数字が出てきたかのリスト
ans=0
for a in A:
  L[a]+=1
  #aが出てきた数（2回出てきたら2になる）
  ans+=a
Q=int(input())
for i in range(Q):
  B,C=map(int, input().split())
  key=L[B]
  L[C]+=key
  ans+=key*(C-B)
  L[B]=0
  print(ans)

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

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];

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

    Arrays.sort(a);
    System.out.println(a[n - 1] - a[0]);

  }
}

Measured memory_bytes: 36116
S=gets.chomp

l = 0
r = S.length-1
ret = 0
while l < r
    if S[l] == S[r]
        l += 1
        r -= 1
    elsif S[l] == 'x'
        ret += 1
        l += 1
    elsif S[r] == 'x'
        ret += 1
        r -= 1
    else
        puts -1
        exit 0
    end
end

puts ret

Measured memory_bytes: 3964
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():

    def make_divisors(n):
        divisors = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n//i)
        divisors.sort(reverse=True)
        return divisors

    n, m = nm()

    for divisor in make_divisors(m):
        if divisor <= m / n:
            print(divisor)
            exit()

if __name__ == '__main__':
    main()

Measured memory_bytes: 3788
N, M = map(int, input().split())
A = [ int(_) for _ in input().split()]
S = 0
G =0
for i in range(N):
    S += A[i]
L = S/(4*M)
for i in range(N):
    if A[i] >= L:
        G += 1
if G < M:
    print("No")
else:
    print("Yes")

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

class D
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var s = Console.ReadLine().Select(x => x == 'R' ? 0 : x == 'G' ? 1 : 2).ToArray();

		var dp = new int[n + 1, 3];
		for (int i = n - 1; i >= 0; i--)
			for (int j = 0; j < 3; j++)
				dp[i, j] = dp[i + 1, j] + (s[i] == j ? 1 : 0);

		var r = 0L;
		for (int i = 0; i < n; i++)
			for (int j = i + 1; j < n; j++)
			{
				if (s[i] == s[j]) continue;
				var sk = 3 - s[i] - s[j];
				r += dp[j, sk];
				if (2 * j - i < n && s[2 * j - i] == sk) r--;
			}
		Console.WriteLine(r);
	}
}


Measured memory_bytes: 28008
#include<cstdio>

int main(void){
int i,n,x,a;
scanf("%d",&n);
for(i=1;i<=n;i++){
if(i%3==0){printf(" %d",i);
}else {
x=i;
do {
a=0;
if(x%10==3){printf(" %d",i);a=1;}
x=x/10;

} while(x!=0&&a==0);
;}
}printf("\n");
return 0;
}

Measured memory_bytes: 2704
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


int main(){
    LL n, m, s, t;
    cin >> n >> m;
    vector<vector<LL>> edge(n);
    for(LL i = 0; i < m; ++i){
        LL v1, v2;
        cin >> v1 >> v2;
        --v1; --v2;
        edge[v1].push_back(v2);
    }
    cin >> s >> t;
    --s; --t;
    vector<vector<LL>> memo(n, vector<LL>(3));
    LL ans = -1;
    set<LL> cur_set, next_set;
    cur_set.insert(s);
    for(LL e = 0; ; ++e){
        if(cur_set.empty()) break;
        if(e % 3 == 0 && cur_set.count(t) > 0){
            ans = e/3;
            break;
        }
        for(LL v: cur_set){
            if(memo[v][e%3]) continue;
            memo[v][e%3] = 1;
            for(LL v2: edge[v]){
                next_set.insert(v2);
            }
        }
        cur_set.swap(next_set);
        next_set.clear();
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

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

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {


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

        if(s.charAt(0)==s.charAt(1) ||
                s.charAt(1)==s.charAt(2)||
                s.charAt(2)==s.charAt(3)){
            System.out.println("Bad");
        }else{
            System.out.println("Good");

        }

    }

}


Measured memory_bytes: 21844
from itertools import product


def read():
    N, W = list(map(int, input().split()))
    pairs = list()
    for i in range(N):
        w, v = list(map(int, input().split()))
        pairs.append((w, v))
    return N, W, pairs

def solve(N, W, pairs):
    dp = [[0 for j in range(W+1)] for i in range(N+1)]
    for i, j in product(range(N), range(W+1)):
        u = dp[i][j]
        if j - pairs[i][0] >= 0:
            u = max(u, dp[i][j-pairs[i][0]]+pairs[i][1])
        dp[i+1][j] = u
    return max(dp[N])

if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 171912
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    set<int> s;
    FOR(i, 0, n)
    {
        int x;
        cin >> x;
        s.insert(x);
    }
    if (SZ(s) == n)
        cout << "YES\n";
    else
        cout << "NO\n";
    return 0;
}

Measured memory_bytes: 9600
while True:
    a,op,b = input().split()
    a,b = map(int,[a,b])
    if op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    elif op=="/":
        print(a//b)
    elif op=="?":
        exit()


Measured memory_bytes: 5600
n,m = list(map(int,input().split()))

ab = [list(map(int,input().split())) for i in range(m)]
#逆順にしたもの追加
ab += [[b,a] for a,b in ab]

#辺id付きで、idがfrom,abi[from]=[to1,to2,...] のリスト
abi = [[] for _ in range(n+1)]
for i,(a,b) in enumerate(ab):
    abi[a].append(b)
    abi[b].append(a)


#再起のlimitを上げる
import sys
sys.setrecursionlimit(4100000)

from collections import deque



def dfs(i):
    visitted.append(i)
    flg = False
    for x in abi[i]:
        if x not in visitted and (i,x) != blocked and (x,i) != blocked:
            dfs(x)
            flg = True
    return len(visitted)==n

ret = 0
for i in range(m):
    blocked = (ab[i][0],ab[i][1])
    visitted = deque([])
    if not dfs(1):
        ret+=1

print(ret)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
typedef long long ll;
const ll mod = 1e9 + 7;
const ll N = 3e5 + 7;



int main() {
	fastIO;
	int grid[3][3] = {};
	map<int, pair<int, int>> pos;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			int x;
			cin >> x;
			pos[x] = { i, j };
		}
	}
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (!pos.count(x))
			continue;
		grid[pos[x].first][pos[x].second] = 1;
	}

	bool valid = false;
	for (int i = 0; i < 3; i++) {
		valid |= grid[i][0] + grid[i][1] + grid[i][2] == 3 || grid[0][i] + grid[1][i] + grid[2][i] == 3;
	}
	valid |= grid[0][0] + grid[1][1] + grid[2][2] == 3 || grid[0][2] + grid[1][1] + grid[2][0] == 3;

	if (valid) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 3612
#include<stdio.h>

int main(void){
	int n,c[100],i,f;
	
	for(i=0;i<100;i++)c[i]=0;
	
	f=0;
	
	while(scanf("%d",&n)!=EOF){
		c[n-1]++;
		if(f<c[n-1])f=c[n-1];
	}
	
	for(i=0;i<100;i++){
		if(c[i]==f)printf("%d\n",i+1);
	}
	
	return 0;
}
	
	

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

int main(){
    int n,m,c;
    cin >> n >> m >> c;
    int A[m], B[m];
    int sum;
    int ans = 0;
    for(int i=0; i<m; i++) cin >> B[i];
    for(int i=0; i<n; i++){
        sum = 0;
        for(int j=0; j<m; j++){
            cin >> A[j];
            sum += A[j]*B[j];
        }
        if(sum+c > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  int m,d;
  cin>>m>>d;
  int ans=0;
  for(int i=1;i<=m;i++){
    for(int j=1;j<=d;j++){
      int d1=j%10;
      int d2=j/10;
      if(d1>1&&d2>1&&i==d1*d2)ans++;
    }
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
 
public class Main {
  public static void main(String [] args) {
    System.out.println(solve());
  }
  
  public static long solve() {
    FastReader fr = new FastReader();
    int N = fr.nextInt();
    int[] d = new int[N];
    long sum = 0;
    long result = 0;
    for (int i = 0; i < N; i++) {
      d[i] = fr.nextInt();
      sum += d[i];
    }
    
    for (int i = 0; i < N-1; i++) {
      sum -= d[i];
      result += d[i] * sum;
    }
    
	return result;
  }
}
 
class FastReader {
  BufferedReader br;
  StringTokenizer st;
 
  public FastReader() {
    br = new BufferedReader(new
        InputStreamReader(System.in));
  }
 
  String next() {
    while (st == null || !st.hasMoreElements())
    {
      try
      {
        st = new StringTokenizer(br.readLine());
      }
      catch (IOException e)
      {
        e.printStackTrace();
      }
    }
    return st.nextToken();
  }
 
  int nextInt() {
    return Integer.parseInt(next());
  }
 
  long nextLong() {
    return Long.parseLong(next());
  }
 
  double nextDouble() {
    return Double.parseDouble(next());
  }
 
  String nextLine() {
    String str = "";
    try {
      str = br.readLine();
    }
    catch (IOException e) {
      e.printStackTrace();
    }
    return str;
  }
}

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

#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fst first
#define snd second

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i < 10 && i <= n; i++)
        ans++;
    for (int i = 100; i < 1000 && i <= n; i++)
        ans++;
    for (int i = 10000; i < 100000 && i <= n; i++)
        ans++;
    for (int i = 1000000; i < 10000000 && i <= n; i++)
        ans++;
    cout << ans;
    return 0;
}

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

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;
bool F[100][10];
int P[100][11];

int main()
{
	int N;
	cin >> N;
	REP(i, N)
	{
		REP(j, 10)
		{
			int f = 0;
			cin >> f;
			F[i][j] = (bool)f;
		}
	}
	REP(i, N)
	{
		REP(j, 11)
		{
			cin >> P[i][j];
		}
	}

	ll max = -1000000005;
	FOR(i, 1 << 10, 1)
	{
		ll m = 0;
		REP(j, N)
		{
			int on = 0;
			REP(k, 10)
			{
				if ((i >> k & 1) == 1 && F[j][k])
				{
					on++;
				}
			}
			m += P[j][on];
		}
		max = std::max(max, m);
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
const int mod = 1e9+7;
const int INF = 1e9;
const int MAX = 1e6;

struct cusum {
    int n;
    vector<ll> s;
    cusum(vector<int> &a) {
        n = (int)a.size();
        s.resize(n+1);
        s[0] = 0;
        for (int i = 1; i <= n; i++) {
            s[i] = s[i-1] + a[i-1];
        }
    }
    ll sum(int a, int b) { // 閉区間[a,b]の和
        return s[b+1] - s[a];
    }
};

int main() {
    int n;
    cin >> n;
    vector<int> a1(n), a2(n);
    rep(i, n) {
        cin >> a1[i];
    }
    rep(i, n) {
        cin >> a2[i];
    }
    // vector<int> s1(n+1), s2(n+1);
    // rep(i, n+1) {
    //     if (i == 0) {
    //         s1[i] = s2[i] = 0;
    //     } else {
    //         s1[i] = s1[i-1] + a1[i-1];
    //         s2[i] = s2[i-1] + a2[i-1];
    //     }
    // }
    cusum s1(a1), s2(a2);
    int ans = 0;
    rep(i, n) {
        int cnt = 0;
        // cnt += s1[i] - s2[0];
        // cnt += s2[n] - s2[i-1];
        cnt += s1.sum(0, i);
        cnt += s2.sum(i, n-1);
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;

            int N = int.Parse(Console.ReadLine());

            string[] a = Console.ReadLine().Split(' ');
            string[] b = Console.ReadLine().Split(' ');

            for(int i=0;i<N;i++)
            {
                int A = int.Parse(a[i]);
                int B = int.Parse(b[i]);

                if (A > B)
                    ans += A - B;

            }

            Console.WriteLine(ans.ToString());
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main(){
	int a, b, c, d;
	string ans;
	cin >> a >> b >> c >> d;
	if((abs(a-b)<=d && abs(b-c)<=d) || abs(a-c)<=d){
		ans = "Yes";
	}else{
		ans = "No";
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(int _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxl 3000
#define maxn 100000

using namespace std;

const ll mod = 1000000007;
pii v[maxl+5];
ll d[maxl+5], fact[2*maxn+5], pre[2*maxn+5];

ll lgput (ll a, ll b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  ll c = lgput(a, b/2); c = c * c % mod;
  if (b % 2 == 1) c = c * a % mod;
  return c;
}

ll inv (int x) { return lgput(x, mod-2); }

ll comb (int n, int k) {
  ll ans = fact[n];
  ans = ans * pre[k] % mod;
  ans = ans * pre[n-k] % mod;
  return ans;
}

ll cai (pii a, pii b) {
  return comb(b.fi-a.fi + b.se-a.se, b.fi-a.fi);
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n, m, l; cin >> n >> m >> l;
  int i, j, z;
  for (fact[0] = 1, i = 1; i <= 2*max(n,m)+1; i++) fact[i] = (fact[i-1] * i) % mod;
  for (i = 0; i <= 2*max(n,m)+1; i++) pre[i] = inv(fact[i]);
  for (i = 0; i < l; i++) cin >> v[i].fi >> v[i].se;
  v[l] = {n, m};
  sort(v, v+l+1, [](pii a, pii b){
       if (a.fi != b.fi) return a.fi < b.fi;
       return a.se < b.se; });
  for (i = 0; i <= l; i++) d[i] = cai({1,1}, v[i]);
  for (i = 0; i < l; i++)
    for (j = i+1; j <= l; j++)
      if (v[j].se >= v[i].se) d[j] = (d[j] - d[i]*cai(v[i], v[j])%mod + mod) % mod;
  cout << d[l];
  return 0;
}


Measured memory_bytes: 3456
#include <iostream>
using namespace std;
typedef long long ll;
ll n,k,s[51],t[51];
ll f(ll a,ll b){
    if(a==1)return 0;
    if(a<(s[b]+1)/2-1)return f(a-1,b-1);
    if(a==(s[b]+1)/2-1)return t[b-1];
    if(a==(s[b]+1)/2)return t[b-1]+1;
    if(a<s[b]-1)return f(a-(s[b]+1)/2,b-1)+t[b-1]+1;
    else return 2*t[b-1]+1;
}
int main(void){
    cin>>n>>k;
    s[0]=1;
    t[0]=1;
    for(int i=1;i<=50;i++){
       s[i]=s[i-1]*2+3;
       t[i]=t[i-1]*2+1;
    }
    //for(int i=0;i<51;i++)cout<<t[i]<<endl;
    cout<<f(k,n)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<string.h>

using namespace std;

int main() {
	int N, X, L[101],D = 0,counter=0;
	cin >> N >> X;
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	for (int i = 1; i < N + 1; i++) {
		D += L[i - 1];
		if (D <= X)counter++;
	}
	cout << counter+1 << endl;
		return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;

template<typename T>
struct BellmanFord {
    struct Edge {
        int from, to; LL cost;
        Edge() {}
        Edge(int from, int to, LL cost): from(from), to(to), cost(cost) {}
    };

    int n;
    vector<vector<int>> graph;
    vector<int> used, reach;
    BellmanFord(int n): n(n), graph(n), used(n, 0), reach(n, 0) {}

    vector<Edge> edges;
    void add_edge(int from, int to, LL cost) {
        edges.push_back(Edge(from, to, cost));
        graph[from].push_back(to);
    }

    void dfs(int v) {
        if (used[v]) return;

        used[v] = 1;
        for (int u : graph[v]) {
            dfs(u);
        }
    }
    LL build(int from, int to, bool &neg_loop) {
        rep(i, n) {
            fill(used.begin(), used.end(), 0);
            dfs(i);
            reach[i] = used[to];
        }

        vector<LL> dist(n, 1e18);
        dist[from] = 0;

        rep(i, n) {
            bool updated = false;

            for (auto e : edges) {
                if (not reach[e.from]
                    or not reach[e.to]
                    or dist[e.from] == 1e18) continue;

                if (dist[e.to] > dist[e.from] + e.cost) {
                    dist[e.to] = dist[e.from] + e.cost;
                    updated = true;
                }
            }

            if (not updated) break;
            if (i == n - 1) {
                neg_loop = true;
                return 1e18;
            }
        }
        neg_loop = false;
        return dist[to];
    }
};
int main() {
    int n, m, p;
    cin >> n >> m >> p;
    BellmanFord<int> graph(n);
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        graph.add_edge(a, b, p - c);
    }

    bool neg_loop;
    int res = graph.build(0, n - 1, neg_loop);
    if (neg_loop) {
        cout << -1 << endl;
        return 0;
    } else {
        cout << max((LL)0, (LL)-res) << endl;
        return 0;
    }
}


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

#define	S_MAX 100000			/*  */

/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  main
 *  Description:  
 * =====================================================================================
 */
	int
main ( int argc, char *argv[] )
{
	char S[S_MAX+1]; /* 盤面 */
	long i, count=0;

	scanf ( "%s", S );

	for ( i=1 ;S[i]!=NULL ;i++ ){

		if ( S[i]!=S[i-1] ) ++count;
	}
	printf ( "%ld\n", count );
	return EXIT_SUCCESS;
}				/* ----------  end of function main  ---------- */


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
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; }


int main() {
    vec x={1,1,2,3,4,5};
    vec a(6);
    rep1(i,5) cin>>a[i];
    rep1(i,5){
        if(a[i]==0) cout<<x[i]<<endl;
    }

}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <string>
using namespace std;
int intinput() {
	int x;
	cin >> x;
	return x;
}
vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	int a,b,c;
	a = intinput();
	b = intinput();
	c = intinput();
	if(c < b){
		cout << c + b << endl;
	}else if(c <= a + b){
		cout << c + b << endl;
	}else{
		cout << a + b*2 + 1 << endl;
	}
}

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

int main(){
  int N;
  cin >> N;
  bool flag = false;
  if(N%10 == 7)
    flag = true;
  else if((N/10)%10 == 7)
    flag = true;
  else if((N/100) == 7)
    flag = true;
  if(flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3576
V,E,r=map(int,input().split())
W=[tuple(map(int,input().split())) for _ in range(E)]
dis=[float('inf')]*V
dis[r]=0
for _ in range(V-1):
    update=False
    for s,t,d in W:
        if dis[t] > dis[s] + d:
            dis[t] = dis[s] + d
            update = True
    if not update: break
for i in dis:
    print(i if i!=float('inf') else 'INF')



Measured memory_bytes: 94804
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n, -1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    a = root(a);
    return -Parent[a];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(a < b) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

int main(){
  int n,m; cin >> n >> m;
  vi a(m), b(m);
  rep(i,m){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
  }

  int ans = 0;
  rep(i,m) {
    UnionFind Uni(n);
    rep(j,m) {
      if(i == j) continue;
      Uni.merge(a[j], b[j]);
    }
    //cout << Uni.size(0) << endl;
    if(Uni.size(0) < n) ans++;
  }
  cout << ans << endl;
}

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

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

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

const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;

           
int n;
double a[N];
int main()
{                   
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	sort(a,a + n);
	for(int i = 1; i < n; i++)
		a[i] = (a[i] + a[i - 1]) / 2.0;
	cout << fixed << setprecision(10) << a[n - 1];
	return 0;
}


Measured memory_bytes: 256