akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define mp make_pair
#define pb push_back
#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n - 1); i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
const int MOD = 1e9+7;
const int inf = 1e9+9;
const long long INF = 1e18+3;
const ld eps = 1e-9;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    char ch;
    bool x[26]={};
    cin>>s;
    forn(i,0,s.size()){
        x[s[i]-'a']=1;
    }
    forn(i,0,26)
        if(!x[i]) {
            ch='a'+i;
            cout<<ch<<endl;
            return 0;
        }
    cout<<"None"<<endl;

 return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.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; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    if (s == "RRR") cout << 3 << '\n';
    else if ((s[0] == 'R' && s[1] == 'R') || (s[2] == 'R' && s[1] == 'R')) {
        cout << 2 << '\n';
    }
    else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') cout << 1 << '\n';
    else cout << 0 << '\n';
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int n;
	string a, b, c;
	cin >> n >> a >> b >> c;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == b[i] && b[i] == c[i]) {
			//
		} else if (a[i] == b[i] || a[i] == c[i] || b[i] == c[i]) {
			ans++;
		} else {
			ans += 2;
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3192
H,W,D = map(int,input().split())
A = [[-1,-1] for _ in range(H*W)]
for i in range(H):
    A_tmp = [int(x)-1 for x in input().split()]
    for j in range(W):
        A[A_tmp[j]] = [i,j]
        
Q = int(input())
LR = [[int(i) for i in input().split()] for _ in range(Q)]

M_sum = [] 
for i in range(H*W):
    if i<D:
        M_sum.append(0)
    else:
        M_sum.append(M_sum[i-D]+abs(A[i][0]-A[i-D][0])+abs(A[i][1]-A[i-D][1]))
        
for L,R in LR:
    print(M_sum[R-1]-M_sum[L-1])


Measured memory_bytes: 91372
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from collections import defaultdict
import sys
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a/b の切り上げ


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def main():
    k = int(input())
    a, b = wi()
    for i in range(a, b+1):
        if i % k == 0:
            print('OK')
            sys.exit()
    print('NG')


if __name__ == '__main__':
    main()


Measured memory_bytes: 65416
N = int(input())
L = list(map(int, input().split()))
len_l = len(L)
ans = 0

for i in range(len_l):
    for j in range(i+1, len_l):
        for k in range(j+1, len_l):
            if abs(L[i]-L[j]) < L[k] < L[i] + L[j] and L[i] != L[j] != L[k] != L[i]:
                ans += 1

print(ans)


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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll h, w, d;
    cin >> h >> w >> d;

    ll posx[d][h*w/d + 1];
    ll posy[d][h*w/d + 1];

    rep(i, h)rep(j, w){
        ll a;
        cin >> a;
        posx[a%d][a/d] = i;
        posy[a%d][a/d] = j;
    }

    ll dist[d][h*w/d + 1];

    rep(i, d){
        ll start = 1;
        if(i == 0)start++;
        dist[i][start-1] = 0;
        for(ll j = start; j < h*w / d + 1; ++j){
            dist[i][j] = dist[i][j-1] + abs(posx[i][j] - posx[i][j-1]) + abs(posy[i][j] - posy[i][j-1]);
        }
    }

    ll q;
    cin >> q;

    ll ans[100010];

    rep(i, q){
        ll l, r;
        cin >> l >> r;
        ans[i] = dist[r%d][r/d] - dist[l%d][l/d];
    }

    rep(i, q)cout << ans[i] << endl;
}

Measured memory_bytes: 5376
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//数値計算 個数以外はdouble
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

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

	if (A >= K) {
		cout << K << endl;
		return 0;
	}
	else if (A + B >= K) {
		cout << A << endl;
		return 0;
	}
	else{
		cout << A - (K - A - B) << endl;
	}
}

Measured memory_bytes: 11028
#include <bits/stdc++.h>
#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 n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  //a.push_back(a[0]+k); //2 syuu me no saisyo dake tasu
  //sort(a.begin(),a.end(),greater<int>());
  //double sum = 0;
  int sum = 0;
  rep(i,n) {
    sum += a[i];
  }
  int cnt = 0;
  //sort(a.begin(),a.end(),greater<int>());
  int ans = 0;
  //int toku = 0;
  //toku = 4*m;
  //ll toku = 0;
  //toku = sum*4*m;
  //ans = sum *(1.0/toku);
  rep(i,n){
      //if(sum * (1/(4*m)) <= a[i]) {
          if(sum <= a[i]*4*m) {
          //cout << "No" << endl;
        cnt++;
      }
      /*else {
          cout << "Yes" << endl;
      }*/
  }
  if (cnt < m) {
      cout << "No" << endl; 
      //cout << ans << endl;
      //cout << cnt << endl;
      /*rep(i,n) {
          cout << a[i] << endl;
      }*/
  }
  else {
      cout << "Yes" << endl;
      //cout << cnt << ans << endl;
      //cout << ans << endl;
      /*rep(i,n) {
          cout << a[i] << endl;
      }*/
  }  
    return 0;
}

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

using namespace std;

const int MAXN = 100010;

int n;
int ans;

int v[MAXN];

void compress()
{
	vector< int > aux;

	aux.push_back( v[1] );

	for(int i = 2 ; i <= n ; i++)
		if( v[i] != aux.back() ) aux.push_back( v[i] );

	n = aux.size();

	for(int i = 1 ; i <= n ; i++)
		v[i] = aux[i - 1];
}

int main()
{
	scanf("%d",&n);

	for(int i = 1 ; i <= n ; i++)
		scanf("%d",&v[i]);

	compress();

	int L = 1;
	int ans = 0;

	while( L < n )
	{
		bool isIncreasing = ( v[L] <= v[L + 1] );

		int R = L + 2;

		while( R <= n )
		{
			if( isIncreasing && v[R - 1] > v[R] ) break;
			if( !isIncreasing && v[R - 1] < v[R] ) break;

			R++;
		}

		ans++;
		L = R;
	}

	if( L == n ) ans++;

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

Measured memory_bytes: 1276
N = int(input())
P = [int(p) for p in input().split()]

A = [30000 * i for i in range(1, N+1)]
R = [0 for i in range(N)]
for i in range(N):
    R[P[i]-1] = i+1
B = [30000 * (N-i) + R[i-1] for i in range(1, N+1)]

print(" ".join(map(str, A)))
print(" ".join(map(str, B)))


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

using namespace std;

int n;
double num[110],sum,item;

int main()
{
	scanf("%d",&n);
	sum=1.0;
	for(int i=1;i<=n;i++)
	{
		scanf("%lf",&num[i]);
		sum=sum*num[i];
	}
	for(int i=1;i<=n;i++)  
	    item=item+sum/num[i]; 
	double ans=sum/item;
	printf("%.14lf\n",ans); 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) cerr <<"at line "<< __LINE__ <<", " << #x << " = " << x << "\n"
using namespace std;

int main()
{
    // freopen("../io/in.txt", "r", stdin);
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;

    int red[a];
    int green[b];
    int white[c];

    for(int i=0; i<a; i++) cin>>red[i];
    for(int i=0; i<b; i++) cin >> green[i];
    for(int i=0; i<c; i++) cin >> white[i];

    sort(red, red+a, greater<int>());
    sort(green, green+b, greater<int>());
    sort(white, white+c, greater<int>());

    priority_queue <int, vector<int>, greater<int> > pq;

    for(int i=0; i<x; i++) pq.push(red[i]);
    for(int i=0; i<y; i++) pq.push(green[i]);
    int first = 0;
    int i=0;
    while(i<c) {
        first = pq.top();
        if(white[i] > first) {
            pq.pop();
            pq.push(white[i]);
            i++;
        }
        else break;
    }

    long long ans = 0LL;
    while(!pq.empty()) {
        ans += pq.top();
        // watch(pq.top());
        pq.pop();
    }

    cout<<ans<<"\n";

    return 0;
}



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

const int MAXN = 1e5 + 5;

int n, m;
vector<int> adj[MAXN];
bool visited[MAXN];
int ans;

void dfs(int pos){
	visited[pos] = true;
	for(int i : adj[pos]){
		if(visited[i])
			continue;
		dfs(i);
	}
}

int main(){
	scanf("%d %d", &n, &m);
	for(int i = 0; i < m; ++i){
		int u, v, w;
		scanf("%d %d %d", &u, &v, &w);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for(int i = 1; i <= n; ++i){
		if(!visited[i])
			ans++;
		dfs(i);
	}
	printf("%d\n", ans);
}

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

using namespace std;

int n, m;
int arr[111];
int cnt, resultcnt;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	cin >> n >> m;
	
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		cnt += arr[i];
	}

	for (int i = 0; i < n; i++) {
		if (arr[i] >= ((double)cnt * (double)(1 / (double)(4 * m)))) resultcnt++;
	}

	if (resultcnt >= m) cout << "Yes";
	else cout << "No";

	return 0;

}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	//iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
void solve() {
	while (true) {
		int n;
		cin >> n;
		vector<pair<int, int>> inputs;
		REP(i, n) {
			int a, b;
			cin >> a >> b;
			inputs.push_back(mp(a, b));
		}
		sort(ALL(inputs));
		int ans = 0;
		priority_queue<int,vector<int>,greater<int>> next;
		next.push(1e9);
		REP(i, inputs.size()) {
			next.push(inputs[i].second);
			while (next.size() > next.top()) {
				next.pop();
			}
			if (next.size() >= inputs[i].first) {
				ans = max(ans, (long long)next.size() - 1LL);
			}
		}
		cout << ans << endl;
		return;
	}
}
#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 6172
#include <bits/stdc++.h>
#include <unordered_map>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
# define INF 0x3f3f3f3f 
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
ll gcd(ll a , ll b){if(b==0) return a; a%=b; return gcd(b,a);}
const int N=500023;
bool vis[N];
vector <int> adj[N];

void solve() 
{
    int x, y;
    cin>>x>>y;

    if(y%2 != 0)
    {
        cout<<"No"<<endl;

        return;
    }

    if(y >= 2*x && y <= 4*x)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }



}

int main()
{   

    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 15520
#include <iostream>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#define N 100
using namespace std;

typedef pair<int,int> pii;
int mat[N][N];
bool color[N];
int n;
int sum=0;
priority_queue<pii> pq;

int mini(int k){
	
	color[k]=true;
	for(int i=0;i<n;i++){
		if(mat[k][i]!=-1)pq.push(make_pair(-mat[k][i],i));
	}
	while(!pq.empty()){
		pii temp=pq.top();pq.pop();
		temp.first=-temp.first;
	//	cout<<"popping:"<<temp.first<<" "<<temp.second<<endl;
		if(color[temp.second])continue;
		color[temp.second]=true;
		sum+=temp.first;
	//	for(int i=0;i<n;i++) cout<<i<<":"<<((color[temp.second])?"t ":"f ");
//		cout<<endl;
		for(int i=0;i<n;i++){
			if(mat[temp.second][i]!=-1 && !color[i])pq.push(make_pair(-mat[temp.second][i],i));
		}
	}
	cout<<sum<<endl;
	return 0;
}
int main(void){
	cin>>n;
	for(int i=0;i<n;i++)color[i]=false;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>mat[i][j];
		}
	}
	mini(0);
	return 0;
}

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

#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}
int power(long long x, long long y, long long p) {
    long long res = 1;  // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1) res = (res * x) % p;

        // y must be even now
        y = y >> 1;  // y = y/2
        x = (x * x) % p;
    }
    return res;
}

long long modInverse(long long n, long long p) { return power(n, p - 2, p); }

long long nCrModPFermat(long long n, long long r, long long p) {
    if (r == 0) return 1;
    long long fac[n + 1];
    fac[0] = 1;
    for (long long i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p;

    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p;
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

signed main() {
    long long ans = 0;
    int n;
    cin >> n;
    if (n < 1200){
        cout << "ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
ll dpD[2010][2010],dpU[2010][2010],dpL[2010][2010],dpR[2010][2010];
int main(){
  int h,w;
  cin >> h >> w;
  vector<string>v(h);
  rep(i,h)cin >> v[i];
  for(int i = 1; i < h; i++){
    rep(j,w){
      if(v[i][j] == '#')continue;
      if(v[i - 1][j] == '#')dpD[i][j] = 0;
      else dpD[i][j] += dpD[i - 1][j] + 1;
    }
  }
  for(int i = h - 2; i >= 0; i--){
    rep(j,w){
      if(v[i][j] == '#')continue;
      if(v[i + 1][j] == '#')dpU[i][j] = 0;
      else dpU[i][j] += dpU[i + 1][j] + 1;
    }
  }
  rep(i,h){
    for(int j = 1; j < w; j++){
      if(v[i][j] == '#')continue;
      if(v[i][j - 1] == '#')dpL[i][j] = 0;
      else dpL[i][j] += dpL[i][j - 1] + 1;
    }
  }
  rep(i,h){
    for(int j = w - 2; j >= 0; j--){
      if(v[i][j] == '#')continue;
      if(v[i][j + 1] == '#')dpR[i][j] = 0;
      else dpR[i][j] += dpR[i][j + 1] + 1;
    }
  }
  ll ans = 0;
  rep(i,h)rep(j,w){
    ans = max(ans,dpR[i][j] + dpL[i][j] + dpU[i][j] + dpD[i][j]);
  }
  cout << ans + 1 << endl;
  return 0;
}


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

int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)

int main () {
    
    int n; cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] -= (i+1);
    }

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

    ll res = 0;
    ll b;
    if(n % 2 == 1) {
        b = a[n/2];
        REP(i,n) {
            res += abs(a[i] - b);
        }
    } else {
        b = (a[n/2] + a[n/2-1])/2;
        REP(i,n) {
            res += abs(a[i] - b);
        }
        b = b + 1;
        ll res1;
        REP(i,n) {
            res1 += abs(a[i] - b);
        }
        res = min(res, res1);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    int n;
    cin >> n;
    if(n%10 == 7){
        cout << "Yes" << endl;
        return 0;
    }
    n /= 10;
    if(n%10 == 7){
        cout << "Yes" << endl;
        return 0;
    }
    n /= 10;
    if(n%10 == 7){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main(){
long long int H;
long long int W;
 cin >> H >> W;
 if(H==1 || W==1)cout << 1 <<endl;
 else if((H*W)%2==0)cout << H*W/2 << endl;
 else{cout << (H*W/2)+1 << endl;}
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn= 999999+5;
ll prime[maxn];
int main()
{
	ll cnt=0;
	for(ll i=2;i<maxn;++i)
	{
		if(!prime[i])
		{
			prime[i]=++cnt;
			for(ll j=i*i;j<maxn;j+=i)
			{
				prime[j]=1;
			}
		}
		else
		{
			prime[i]=prime[i-1];
		}
	}
	ll n;
	while(~scanf("%lld",&n))
	{
		printf("%lld\n",prime[n]);
	}
	return 0;
}

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

using namespace std;

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

  int n;
  cin >> n;

  int arr[n];

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

  int res = ~(1 << 31);

  for (int x = -100; x <= 100; ++x) {
    int tmp = 0;
    for (int y: arr) {
      tmp += static_cast<int>(pow(x - y, 2));
    }
    res = min(res, tmp);
  }

  cout << res << "\n";
}


Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		int m = fs.nextInt();
		
		HashMap<Integer, Integer> modMMap = new HashMap<>();
		long ans = 0;
		long cumulative = 0;
		for(int i = 1; i <= n; i++) {
			long nextLong = fs.nextLong();
			cumulative = cumulative + nextLong;
			int modM = (int)(cumulative%m);
			
//			System.out.println(modM);
			
			if(modM == 0) {
				ans++;
			}
			
//			int zeroSum = (m - modM)%m;
			if(modMMap.containsKey(modM)) {
				ans += modMMap.get(modM);
			}
			
			if(modMMap.containsKey(modM)) {
				int numOfModM = modMMap.get(modM);
				modMMap.put(modM, numOfModM+1);
			}else {
				modMMap.put(modM, 1);
			}
		}
		
//		System.out.println(modMMap);
		
		System.out.println(ans);
		
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 45788
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int w, h, n;
    cin >> w >> h >> n;
    int A = w * h;
    int lmx = 0, rmx = w, umy = h, dmy = 0;
    for(int i = 0; i < n; i++){
        int x, y, a;
        cin >> x >> y >> a;
        if(a == 1){
            // x < xi
            lmx = max(lmx, x);
        }else if(a == 2){
            // x > xi
            rmx = min(rmx, x);
        }else if(a == 3){
            // y < yi
            dmy = max(dmy, y);
        }else{
            // y > yi
            umy = min(umy, y);
        }
    }
    if(lmx >= rmx || umy <= dmy){
        cout << 0;
    }else{
        cout << (rmx - lmx) * (umy - dmy);
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	vector<int> a(n);
	for(int i =0; i<n; ++i)
		cin>>a[i];
	sort(a.begin(), a.end());
	int right = n / 2;
	int left = n / 2 - 1;
	if(left == right){
		cout<<0;
	}
	else{
		cout<<a[right] - a[left];
	}
  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <string>
#include <functional>
#include <cassert>
#include <cmath>
#define SIZE 2005
#define MOD 1000000007
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int A[SIZE];

int main()
{
    int n;
    scanf("%d", &n);
    ll K;
    scanf("%lld", &K);
    for (int i=0; i<n; i++) scanf("%d", &A[i]);

    ll ans = 0;
    for (int i=0; i<n; i++)
    {
        for (int j=i+1; j<n; j++)
        {
            if (A[i] > A[j])
            {
                ans += ((K + 1) * K / 2LL) % MOD;
            }
            else if (A[i] < A[j])
            {
                ans += (K * (K - 1) / 2LL) % MOD;
            }
            if (ans >= MOD) ans -= MOD;
        }
    }

    printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>

using namespace std;


/** ワーシャル・フロイド法による全点対最短路探索

    経路を逐次最小化していく。

    知らないパスにはコスト大きめを設定しておくこと。
    O(|V|^3)

    @param[in] V  頂点数
    @param[in, out] distance[i][j]: 頂点i -> jのコスト
*/
template<typename T, typename M>
void warshall_floyd(T V, M& distance)
{
    for (T k = 0; k < V; ++k) {
        for (T i = 0; i < V; ++i) {
            for (T j = 0; j < V; ++j) {
                distance[i][j] = std::min(distance[i][j],
                                          distance[i][k] + distance[k][j]);
            }
        }
    }
}

/* 2倍しても桁溢れしない最大数

   almost_max<uint64_t>() とか
*/
template<typename T>
constexpr T almost_max() {
    return std::numeric_limits<T>::max() / 2 - 1;
}

int main()
{
    int N, M, R;
    std::cin >> N >> M >> R;

    boost::multi_array<int64_t, 2> mat(boost::extents[N][N]);
    std::fill(mat.data(), mat.data() + mat.num_elements(), almost_max<int>());

    std::vector<int> route;
    for (int i = 0; i < R; ++i) {
        int r;
        std::cin >> r;
        r--;
        route.push_back(r);
    }

    for (int i = 0; i < M; ++i) {
        int a, b;
        int64_t c;
        std::cin >> a >> b >> c;
        a--;
        b--;
        mat[a][b] = c;
        mat[b][a] = c;
    }

    // 距離計算
    warshall_floyd(N, mat);

    // 順列で全部試す
    int64_t dist = INT64_MAX;
    std::sort(route.begin(), route.end());
    do {
        int64_t d = 0;
        for (int i = 1; i < R; ++i) {
            d += mat[route[i-1]][route[i]];
        }
        dist = std::min(dist, d);
    } while (std::next_permutation(route.begin(), route.end()));

    std::cout << dist << std::endl;

    return 0;
}


Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <stack>

typedef long long ll;
typedef std::vector< int > VI;

const double EPS = 1e-10;
const double PI  = acos(-1);
const ll     INF = 1 << 30;

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

ll gdb(ll a, ll b) {
  if (a < b) std::swap(a, b);
  if (a == 0 || b == 0) return -999999999;
  return gdb_exec(a, b);
}

ll lcm(ll a, ll b) {
  ll gdb_val = gdb(a, b);
  if (a % gdb_val == 0) {
    return (a / gdb_val) * b;
  }
  return (b / gdb_val) * a;
}

int main(int argc, char* argv[])
{
  ll val;
  std::string s;
  std::string::iterator it;

  std::cin >> s;
  sscanf(s.c_str(), "%lld", &val);

  ll sum = 0;
  for (it = s.begin(); it != s.end(); it++) {
    sum += *it - '0';
  }

  if (val % sum == 0) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int A[100000];
int prec[100001];
int prec2[100001];
int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    prec[0] = 0;
    prec2[n] = 0;
    for(int i=0;i<n;i++){
        prec[i+1] = __gcd(prec[i], A[i]);
        prec2[n-1-i] = __gcd(prec2[n-i], A[n-i-1]);
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        ans = max(ans, __gcd(prec[i], prec2[i+1]));
    }
    cout << ans;
    return 0;
}


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

int main(int argc, char **argv) {
    int K;
    int N;
    std::vector<int> A;

    std::cin >> K >> N;
    for (int i = 0; i < N; i++) {
        int ai;
        std::cin >> ai;
        A.push_back(ai);
    }

    // A is sorted per constraints .. < ..

    // find biggest gap
    int biggestGap = A[0] + (K - A.back()); // this one crosses the 0-Line
    for (int i = 1; i < N; i++) {
        int diff = abs(A[i] - A[i - 1]);
        biggestGap = std::max(biggestGap, diff);
    }

    std::cout << (K - biggestGap) << std::endl;
    return 0;
}


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

int s[5];
int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    int a1=a+k,b1=b-k;
    if(a1>b1)
      for(int i=a;i<=b;i++)
         cout<<i<<endl;
    else{
        for(int i=a;i<a+k;i++)
            cout<<i<<endl;
        for(int i=b-k+1;i<=b;i++)
            cout<<i<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
import sys


def main() -> None:
    n = int(next_str())
    s = next_str()
    t = next_str()

    overlap = 0
    for i in range(n, 0, -1):
        if s[-i:] == t[:i]:
            overlap = i
            break

    print(2 * n - overlap)


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
s = input()
key = 'keyence'

pre = 0
for c,t in zip(s[:7], key):
    if c == t:
        pre += 1
back = 0
for c,t in zip(s[-7:], key):
    if c == t:
        back += 1
        
print('YES' if pre + back >= len(key) else 'NO')


Measured memory_bytes: 2940
package main

import (
	"fmt"
)

func charConv(buf byte, times int) string {
	for i := 0; i < times; i++ {
		if buf == byte(90) {
			// Z → A
			buf = byte(65)
		} else {
			buf += 1
		}
	}
	return string(buf)
}

func main() {
	var (
		n   int
		str string
	)
	fmt.Scan(&n, &str)

	ans := ""
	for i := 0; i < len(str); i++ {
		ans += charConv(str[i], n)
	}

	fmt.Println(ans)
}


Measured memory_bytes: 6656
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

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

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

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

int main() {
  ll K, A, B;
  cin >> K >> A >> B;
  if (B - A <= 2) {
    cout << K + 1 << endl;
  } else {
    ll biscuits = A;
    K -= A - 1;

    biscuits += (B - A) * (K / 2);
    biscuits += K % 2;
    cout << biscuits << endl;
  }
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define pb push_back             
#define se second                
#define fi first  
#define be begin()
#define en end()
#define all(v) v.be, v.en
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }
template<typename... T> void po(T... args) { ((cout << args << " "), ...); cout<<""; }

 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
     int test=1;
     //cin>>test;
     for(int tt=1; tt<=test; tt++){
       ll n;
       cin>>n;
       ll a[n];
       for(ll i=0; i<n; i++){
           cin>>a[i];
       }
       ll k=a[0];
       for(ll i=1; i<n; i++){
           k=k^a[i];
       }
       
       ll ans[n];
       ans[0]=k^a[0];
       //pp(17^19^2);
       //k = k^a[0];
       for(ll i=1; i<n; i++){
           ans[i]=a[i]^k;

       }
       for(ll i=0; i<n; i++){
           po(ans[i]);
       }
     //cout<<"Case #"<<tt<<": ";  
     }
 
    return 0;
}

Measured memory_bytes: 6736
#define N 105
#include <stdio.h>

void showArray(int a[], int n) {
    for (int i = 0; i < n; i++) {
        if (i > 0) {
            printf(" ");
        }
        printf("%d", a[i]);
    }
    printf("\n");
}

void InsertionSort(int a[], int n) {
    showArray(a, n);
    for (int i = 1; i < n; i++) {
        int val = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > val) {
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = val;
        showArray(a, n);
    }
}

int main() {
    int a[N];
    int n = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    InsertionSort(a, n);
    return 0;
}



Measured memory_bytes: 2044
n,k = map(int,input().split())
X = list(map(int,input().split()))
from bisect import bisect_left as bl
zero = bl(X,0)

temp = []
for i in range(max(zero,k-1),min(zero+k,n)):
    if X[i-k+1] >= 0:
        temp.append(X[i])
    elif X[i] <= 0:
        temp.append(abs(X[i-k+1]))
    else:
        temp.append(min(abs(X[i]),abs(X[i-k+1]))*2+max(abs(X[i]),abs(X[i-k+1])))
try:
        print(min(temp))
except:
        print(abs(X[-k]))

Measured memory_bytes: 14564
#include <stdio.h>
int main(){
    int a[5],i,c,d,an;
    for(i=0;i<5;i++){
    scanf("%d\n",&a[i]);}

    c=a[0]*a[4];
    if(a[2]-a[4]>=0){d=a[1];}
    else d=a[1]+(a[4]-a[2])*a[3];

    if(c>d){an=d;}
    else an=c;

printf("%d\n",an);
return 0;
}

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

int main(){
  int k;
  string s;
  
  cin >> k >> s;
  
  if(s.size() <= k) cout << s << endl;
  else{
    for(int i = 0; i < k; i++){
      cout << s[i];
    }
    cout << "..." << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

ll dp[100010][3];

int main(){
    int N; cin >> N;
    vector<int> a(N),b(N),c(N);
    rep(i,N)cin >> a[i] >> b[i] >>c[i];
    for(int i=1;i<=N;i++){
        dp[i][0]=max(dp[i-1][1]+a[i-1],dp[i-1][2]+a[i-1]);
        dp[i][1]=max(dp[i-1][0]+b[i-1],dp[i-1][2]+b[i-1]);
        dp[i][2]=max(dp[i-1][0]+c[i-1],dp[i-1][1]+c[i-1]);
    }

    cout << max(dp[N][0],max(dp[N][1],dp[N][2])) << endl;

    return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>
int main(){
    int n,t,i;
    while(1){
        scanf("%d",&n);
        if(n==0)return 0;
        int data[n][n];
        int tate[n];
        int allsum=0;
        for(i=0;i<n;i++){
            tate[i]=0;
        }
        for(i=0;i<n;i++){
            for(t=0;t<n;t++){
                scanf("%d",&data[i][t]);
            }
        }
        for(i=0;i<n;i++){
            int sum=0;
            for(t=0;t<n;t++){
                printf("%5d",data[i][t]);
                sum+=data[i][t];
                tate[t]+=data[i][t];
            }
            allsum+=sum;
            printf("%5d",sum);
            puts("");
        }
        for(i=0;i<n;i++){
            printf("%5d",tate[i]);
        }
        printf("%5d\n",allsum);
    }
    return 0;
}

Measured memory_bytes: 620
H, W, K = map(int, input().split())
C = []
for i in range(H):
    c = list(input().strip())
    C.append(c)

ans = 0
for h in range(1 << H):
    for w in range(1 << W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if h >> i & 1:
                    continue
                if w >> j & 1:
                    continue
                if C[i][j] == "#":
                    cnt += 1
        if cnt == K:
            ans += 1

print(ans)


Measured memory_bytes: 9104
import numpy as np
import sys

input = sys.stdin.readline

n, k = [int(x) for x in input().split()]
A = np.array([int(a) for a in input().split()], dtype="int64")

A = np.sort(A)

A_pos = A[A > 0]
A_neg = A[A < 0]
A_zero = A[A == 0]

# 積がc以下となる組み合わせの数を求める
def n_comb_lt(c):
    n_comb = 0
    # A[i] > 0であるA[i]について
    target = c // A_pos  # target以下の値がA[i]の相方
    n_comb += np.searchsorted(A, target, side="right").sum()

    # A[i] == 0であるA[i]について
    n_comb += n * len(A_zero) if c >= 0 else 0

    # A[i] < 0であるA[i]について
    target = -(-c // A_neg)
    n_comb += (n - np.searchsorted(A, target, side="left")).sum()

    # 組み合わせのうち、A[i]*A[i]となっているものを引いて、2で割る
    n_comb -= A[A * A <= c].size
    n_comb //= 2

    return n_comb

ok = -10 ** 18 - 1
ng = 10 ** 18 + 1

# k番目の積は、積がm未満となる組み合わせがk個未満となる最大のm
# ←→積が(m-1)以下となる組み合わせがk個未満となる最大のm
while ng - ok > 1:
    mid = (ng + ok) // 2
    if n_comb_lt(mid - 1) < k:
        ok = mid
    else:
        ng = mid

print(ok)


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

int main(){

    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2; 


    int x3, y3, x4, y4;
    vector<int> vec = { x2-x1, y2-y1 };

    x3 = x2 - vec[1];
    y3 = y2 + vec[0];

    x4 = x3 - vec[0];
    y4 = y3 - vec[1];

    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

    return 0;

}

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

int main() {
  ll h,a;
  cin >> h >> a;
  
  ll count = 0;
  rep(i, 100000){
    h -= a;
    count++;
    if(h <= 0)
      break;
  }
  cout << count << endl;
}

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

int main(void){
    int n,a,b;
    cin >> n >> a >> b;
    
    int ans(0);
    for(int i=1;i<=n;i++){
        string s = to_string(i);
        int sum(0);
        for(int i=0;i<s.size();i++){
            sum += s[i]-'0';
        }
        if(sum>=a && sum<=b)
            ans += i;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3772
using System;
using System.Collections.Generic;
class Program
    {
    	static void Main(string[] args)
    	{
            string[] s1 = Console.ReadLine().Split(' ');
            int n = int.Parse(s1[0]), l = int.Parse(s1[1]);

            int sum = (n + 2 * l - 1) * n / 2;
            if (l > 0) sum -= l;
            else if (n + l - 1 < 0) sum -= n + l - 1;
            Console.WriteLine(sum);
            
            
        }
    }
    //mcs Main.cs
    //mono Main.exe

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

inc = 0
res = 0
for i in range(N - 1):
    if A[i] < A[i + 1]:
        if inc == 1:
            continue
        elif inc == 0:
            inc = 1
        else:
            res += 1
            inc = 0
    elif A[i] > A[i + 1]:
        if inc == -1:
            continue
        elif inc == 0:
            inc = -1
        else:
            res += 1
            inc = 0
print(res + 1)

Measured memory_bytes: 14228
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskA {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int[] a = new int[3 * n];
			for (int i = 0; i < a.length; i++) {
				a[i] = in.nextInt();
			}
			Arrays.sort(a);
			long ans = 0;
			for (int i = a.length - 2, j = 0; j < n; i -= 2, j++) {
				ans += a[i];
			}
			out.println(ans);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 56752
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

const int M=405;
ll n,C[M][M];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	int sum=0;
	vector<vvl> dp(2,vvl(M,vl(M)));
	dp[0][0][0]=C[0][0]=1;
	for(int i=0;i<M-1;i++) for(int j=0;j<=i;j++){
		(C[i+1][j]+=C[i][j])%=mod;
		(C[i+1][j+1]+=C[i][j])%=mod;
	}
	for(int i=0;i<n;i++){
		vector<vvl> DP=dp;
		int a,b;
		cin>>a>>b;
		sum+=a;
		for(int x=0;x<2;x++) for(int j=0;j<M;j++) for(int k=0;k<M-a;k++) if(dp[x][j][k]){
			ll t=1;
			for(int l=0;l<b&&j+l<M;l++){
				(DP[1-x][j+l][k+a]+=dp[x][j][k]*C[j+l][j]%mod*t)%=mod;
				(t*=a)%=mod;
			}
		}
		dp=DP;
	}
	ll res=0;
	for(int i=0;i<2;i++) for(int j=0;j<M;j++) for(int k=0;k<M;k++) if(j||k){
		ll t=Div(dp[i][j][k],Pow(k,j+1))*sum%mod;
		if(i==1) (res+=t)%=mod;
		else (res+=mod-t)%=mod;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 6876
#include <bits/stdc++.h>
using namespace std;
map < string , int > mp;
map < string , int > :: iterator itr;
int m = -2;
int main()
{
    int n , i = 0;
    string s;
    cin >> n;
    while(i < n)
    {
        cin >> s;
        mp[s]++;
        m = max(mp[s] , m);
        i++;
    }
    for(itr = mp.begin() ; itr != mp.end() ; itr++)
        if(itr->second == m)
        cout << itr->first << endl;
    return 0;
}


Measured memory_bytes: 25216
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int i,out;
    i=a;
    out=0;
    while(i<=b){
        if(i%c==0){
            i=i+c;
            out++;
        }
        else{i++;}
    }
    cout<<out;}


Measured memory_bytes: 3628