akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, k;
int ans;

signed main() {
	cin >> n >> k;
	for (int i = k; i <= n + 1; i++) {
		int ma = i * (2 * n - i + 1) / 2;
		int mi = i * (i - 1) / 2;
		ans += ma - mi + 1;
		ans %= mod;
	}
	cout << ans << endl;
}

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

int main()
{
    int x,y,size,count=0,max=0;
    int dots[14][14]={{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}};
    while(scanf("%d,%d,%d",&x,&y,&size)!=EOF){
        x += 2;
        y += 2;
        dots[y][x]++;
        switch(size){
            case 1 :
                dots[y-1][x]++;
                dots[y][x+1]++;
                dots[y+1][x]++;
                dots[y][x-1]++;
                break;
            case 2 :
                dots[y-1][x]++;
                dots[y-1][x+1]++;
                dots[y][x+1]++;
                dots[y+1][x+1]++;
                dots[y+1][x]++;
                dots[y+1][x-1]++;
                dots[y][x-1]++;
                dots[y-1][x-1]++;
                break;
            case 3 :
                dots[y-1][x]++;
                dots[y-1][x+1]++;
                dots[y][x+1]++;
                dots[y+1][x+1]++;
                dots[y+1][x]++;
                dots[y+1][x-1]++;
                dots[y][x-1]++;
                dots[y-1][x-1]++;
                dots[y-2][x]++;
                dots[y][x+2]++;
                dots[y+2][x]++;
                dots[y][x-2]++;
                break;
        }
    }
    for(int i=2;i<12;i++){
        for(int j=2;j<12;j++){
            if(dots[i][j]==0){
                count++;
            }
            if(max<dots[i][j]){
                max=dots[i][j];
            }
        }
    }
    cout<<count<<endl<<max<<endl;
    return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	int n;
	std::cin >> n;
	int x = (n+1000-1)/1000;
	print(x*1000-n);
}


Measured memory_bytes: 3648
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
H, W = map(int, input().split())
S = [input() for _ in range(H)]
R = [[0] * W for _ in range(H)]
L = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]

for i in range(H):
	for j in range(W):
		if S[i][j] == '.':
			if j > 0:
				L[i][j] = L[i][j - 1] + 1
			elif j == 0:
				L[i][j] = 1
				
			if i > 0:
				U[i][j] = U[i - 1][j] + 1
			elif i == 0:
				U[i][j] = 1
		
		if S[i][W - j - 1] == '.':
			if j > 0:
				R[i][W - j - 1] = R[i][W - j] + 1
			elif j == 0:
				R[i][W - j - 1] = 1
		
		if S[H - i - 1][j] == '.':
			if i > 0:
				D[H - i - 1][j] = D[H - i][j] + 1
			elif i == 0:
				D[H - i - 1][j] = 1
			
ans = 0
for i in range(H):
	for j in range(W):
		tmp = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
		if tmp > ans:
			ans = tmp
			
print(ans)


Measured memory_bytes: 178056
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL gcd(LL a, LL b) {
	if (b == 0)return a;

	return gcd(b, a%b);
}

LL lcm(LL a,LL b) {
	return (a / gcd(a, b))*b;
}

int main() {
	LL n; cin >> n;

	LL lc = 1;
	
	for (int i = 0; i < n; i++) {
		LL t; cin >> t;

		lc = lcm(t, lc);
		
	}

	cout << lc << endl;
	
	return 0;
}

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

using namespace std;

#define IOO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl '\n'

typedef long long ll;

int n, m;
double xc1[200], yc1[200], xc2[200], zc2[200];
double max1, max2, min1, min2;

bool ok(double x) {
	return max(min1, min2) <= x && x <= min(max1, max2);
}

double width(int k, double x, double a[], double b[]) {
	double up = -200.0, down = 200.0;
	for (int i = 1; i <= k; i++) {
		double x1 = a[i], x2 = a[i % k + 1];
		if (min(x1, x2) <= x && x <= max(x1, x2)) {
			double temp = b[i] + (b[i] - b[i % k + 1]) / (x1 - x2) * (x - x1);
			up = max(up, temp);
			down = min(down, temp);
		}
	}
	return max(0.0, up - down);
}

const double eps = 1e-6; // 注意复合精度误差
double f(double x) {
	return width(m, x, xc1, yc1) * width(n, x, xc2, zc2);
} 
double simpson(double l, double r) {
	return (f(l) + 4.0 * f((l + r) / 2.0) + f(r)) / 6.0 * (r - l);
}
double integral(double l, double r) {
	double mid = (l + r) / 2.0;
	double res = simpson(l, r);
	if (fabs(res - simpson(l, mid) - simpson(mid, r)) < eps) return res;
	else return integral(l, mid) + integral(mid, r);
}

int main() {
	IOO;
	while (cin >> m >> n && (n + m)) {
		vector<double> x(n + m + 1, 0);
		for (int i = 1; i <= m; i++) {
			cin >> xc1[i] >> yc1[i];
			x.push_back(xc1[i]);
		}
		for (int i = 1; i <= n; i++) {
			cin >> xc2[i] >> zc2[i];
			x.push_back(xc2[i]);
		}
		sort(x.begin(), x.end());
		max1 = *max_element(xc1 + 1, xc1 + m + 1);
		min1 = *min_element(xc1 + 1, xc1 + m + 1);
		max2 = *max_element(xc2 + 1, xc2 + n + 1);
		min2 = *min_element(xc2 + 1, xc2 + n + 1);
		double ans = 0.0;
		for (int i = 1; i < x.size(); i++) {
			if (ok(x[i - 1]) && ok(x[i])) {
				ans += simpson(x[i - 1], x[i]);
			}
		}
		cout << fixed << setprecision(10) << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

constexpr ll INF = 1LL << 62;
constexpr ll MOD = 1e9 + 7;
constexpr ll MAX = 2 * 1e5;

ll fact[MAX + 1];
ll inv[MAX + 1];

ll doubling(ll n) {
    ll ret = 1;
    ll a = n;
    bitset<32> bs(MOD - 2);
    for (ll i = 0; i < bs.size(); i++) {
        if (bs[i]) {
            ret *= a;
            ret %= MOD;
        }

        a *= a;
        a %= MOD;
    }

    return ret;
}

ll invert(ll n) {
    return doubling(n);
}

void init() {
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= MAX; i++) {
        fact[i] = fact[i - 1] * i;
        fact[i] %= MOD;
        inv[i] = invert(fact[i]);
    }
}

ll C(ll n, ll r) {
    return (fact[n] * inv[n - r] % MOD) * inv[r] % MOD;
}

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

    init();

    ll H, W, A, B;
    cin >> H >> W >> A >> B;

    ll ans = 0;
    for (ll i = B; i < W; i++) {
        ans += C(H - A - 1 + i, i) * C(A - 1 + W - i - 1, A - 1) % MOD;
    }
    cout << ans % MOD << endl;

    return 0;
}



Measured memory_bytes: 3328
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;


void solve(long long N, std::vector<long long> s){
	LL ret=0;
	for(int i=1;i<N;i++){
		int x=0;
		int y=N-1;
		LL sum=0;
		while(x+i<N){
			if(x+i==y){
				break;
			}
			x+=i;
			y-=i;
			if(x==y){
				break;
			}
			if(y<i){
				break;
			}
			sum+=s[x]+s[y];
			ret=max(ret,sum);
		}
	}
	cout << ret << endl;
}

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


Measured memory_bytes: 1024
Alpha = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
N = int(input())
S = list(input())

for i in range(len(S)):
    
    n = Alpha.index(S[i])


    S[i] = Alpha[(n + N)%26]

print(*S,sep="")



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

string s,t;
ll f[10005][10005],m,n;
vector <char> trace;

 main()
{
    cin>>s>>t;
    s=' '+s;
    t=' '+t;
    for (long long  i=1;i<s.size();i++)
        for (long long  j=1;j<t.size();j++)
    {
        f[0][j]=0;
        f[i][0]=0;
        if (s[i]==t[j]) f[i][j]=f[i-1][j-1]+1;
        else f[i][j]=max(f[i-1][j],f[i][j-1]);
    }
    m=s.size()-1;
    n=t.size()-1;
    if (f[m][n]==0) return 0;
    while (m>0&&n>0)
    {
        if (s[m]==t[n])
        {
            trace.push_back(s[m]);
            m--;
            n--;
        }
        else if (f[m][n]==f[m-1][n]) m--;
        else if (f[m][n]==f[m][n-1]) n--;
    }
    for (long long  i=trace.size()-1;i>=0;i--) cout<<trace[i];
}


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



Measured memory_bytes: 6528
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
int main()
{
	ll n, m;
    string w;
    vector<ll> v(26,0);
    cin>>w;
    REP(i,0,w.size()-1)
    {
        m=w[i]-'a';
        v[m]++;
    }
    REP(i,0,v.size()-1)
    {
        if(v[i]%2!=0)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

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

using namespace std;

#define int long long

const int N=1e5+5;
int n,pset[N],lazy[N],ans[N];
vector<int> child[N];
vector< pair<int, pair<int,int> > > edge;

void joinset(int u, int v, int w){
    if(child[ pset[u] ].size() > child[ pset[v] ].size()) swap(u, v);
    int pau = pset[u];
    lazy[ pset[v] ] += w * (child[ pset[u] ].size());
    for(int cu : child[ pset[u] ]){
        ans[cu] += lazy[ pset[u] ] + w * child[ pset[v] ].size() - lazy[ pset[v] ];
    }
    for(int cu : child[ pset[u] ]) child[ pset[v] ].push_back(cu), pset[cu] = pset[v];
    child[ pau ].clear();
}

signed main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<n;++i){
        int u,v,w; cin>>u>>v>>w;
        edge.push_back(make_pair(w,make_pair(u,v)));
    }
    sort(edge.begin(), edge.end());

    for(int i=1;i<=n; ++i) pset[i] = i, child[i].push_back(i);

    for(int i = edge.size()-1; i >= 0; --i){
        joinset(edge[i].second.first, edge[i].second.second, edge[i].first);
    }

    for(int i = 1; i <= n; ++i) cout << ans[i] + lazy[ pset[i] ] << "\n";

    return 0;
}


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

int main()
{
    int a[5], b[5];
    char c[5] = {'A','B','C','D','E'};


    while( cin >> a[0] >> b[0] )
    {
        if( a[0] + b[0] == 0 )
            break;
        int max = a[0] + b[0], j = 0;
        for( int i = 1; i < 5; i++ )
        {
            cin >> a[i] >> b[i];
            if( max < a[i] + b[i] )
            {
                max = a[i] + b[i];
                j = i;
            }
        }
        cout << c[j] << " " << max << endl;
    }

    return 0;
}


Measured memory_bytes: 3076
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n;
    cin  >> n;
    string s;
    cin >> s;
    int num = 0;
    rep(i, n) {
        if(s[i] == '#') {
            num = i;
            break;
        }
    }
    s = s.substr(num);
    n = s.size();
    vi sumd(n+1), sums(n+1);
    rep(i, n) {
        if(s[i] == '.') {
            sumd[0]++;
        }
    }
    rep(i, n) {
        sumd[i+1] = sumd[i];
        sums[i+1] = sums[i];
        if(s[i] == '.') {
            sumd[i+1]--;
        } else {
            sums[i+1]++;
        }
    }
    
    int ans = 100000000;
    rep(i, n+1) {
        ans = min(ans, sumd[i]+sums[i]);
    }

    cout << ans << endl;
}

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

int main(){
  int A,B;
  cin >> A>>B;
  
  int total=1;
  int count =0;
  
  if (B==1){
    cout << 0 <<endl;
    return 0;
  }
  
  while(1){
    total --;
    total +=A;
    count++;
    
    if (total>=B){
      break;
    }
  }
  
  cout << count << endl;
  return 0;
}

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

using namespace std;
 
static inline int left(int i) {
  return 2 * i;
}

static inline int right(int i) {
    return 2 * i + 1;
}

static inline void maxHeapify(vector<int>& A, int i) {
  const int l = left(i);
  const int r = right(i);

  const int H = A.size() - 1;
  int largest = 0;
  if (l <= H && A[l] > A[i]) {
     largest = l;
    } else {
      largest = i;
    }

    if (r <= H && A[r] > A[largest]) {
      largest = r;
    }
    
    if (largest != i) {
      swap(A[i], A[largest]);  
      maxHeapify(A, largest);
    }    
}

static void buildMaxHeap(vector<int>& A) {
  const int H = A.size() - 1;
  for (int i = H / 2; i > 0; i--) {
    maxHeapify(A, i);
  }
}

static vector<int> A;

int main() {
  int H;
  cin >> H;

  A.resize(H + 1);

  int k;
  for (int i = 1; i <= H; i++) {
    cin >> k;
    A[i] = k;
  }
  
  buildMaxHeap(A);
  
  for (int i = 1; i <= H; i++) {
    cout << " " << A[i];
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 4552
#include <stdio.h>

int main(void) {

	long long int a, b, c, d, max;
	long long int sum[4];

	scanf("%lld %lld %lld %lld", &a,&b,&c,&d);

	sum[0] = a * c;
	sum[1] = a * d;
	sum[2] = b * c;
	sum[3] = b * d;

	max = sum[0];

	for (int i = 1; i < 4; i++) {
		if (max < sum[i]) {
			max = sum[i];
		}
	}

	printf("%lld\n", max);

	return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    string s;
    cin >> s;
    if(s == "SUN") {
        cout << 7 << endl;
    }
    if(s == "MON") {
        cout << 6 << endl;
    }
    if(s == "TUE") {
        cout << 5 << endl;
    }
    if(s == "WED") {
        cout << 4 << endl;
    }
    if(s == "THU") {
        cout << 3 << endl;
    }
    if(s == "FRI") {
        cout << 2 << endl;
    }
    if(s == "SAT") {
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 200000
int main()
{
  int i,j,maxv,minv,R[MAX],n;

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

for(j=1;j<=n-1;j++){
  for(i=0;i<=j-1;i++){
    if(maxv>R[j]-R[i]){
      maxv=maxv;
    }
    if(maxv<R[j]-R[i]){
      maxv=R[j]-R[i];
    }
  }
 }

  minv=R[0];
  maxv=R[1]-R[0];
  for(j=1;j<=n-1;j++){
    if(maxv>R[j]-minv){
      maxv=maxv;
    }
    if(maxv<R[j]-minv){
      maxv=R[j]-minv;
    }
    if(minv>R[j]){
      minv=R[j];
    }
    if(minv<R[j]){
      minv=minv;
    }
  }
  printf("%d\n",maxv);

  return 0;
}

Measured memory_bytes: 1376
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

int N=3;
vi A;
vb used;
int ans;

void dfs(int n, int i, int ret) {
    if (n >= N) {
        ans = min(ans, ret);
        return;
    }

    REP(j,N) {
        if (used[j]) continue;
        used[j] = true;

        int cost = abs(A[j] - A[i]);
        dfs(n + 1, j, ret+cost);

        used[j] = false;
    }
}

int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    A =vi(N); REP(i, N) cin >> A[i];
    used =vb(N, false);
    
    ans = INF;
    REP(i,N) {
        used[i] = true;
        dfs(1, i, 0);
        used[i] = false;
    }
    
    cout << ans << endl;

    return 0;
}


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

int main() {
    int A1, A2, A3; 

    cin >> A1 >> A2 >> A3; 

    if (A1 + A2 + A3 >= 22) {
        cout << "bust" << endl; 
    } else {
        cout << "win" << endl; 
    }
    
}

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

int main() {
	int N,M;
	cin >> N>>M;
	map<int, int>mp;
	for (int n = 0;n<N;++n) {
		int A, B;
		cin >> A >> B;
		mp[A] += B;
	}
	long long ans = 0;
	for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
		if (M >= itr->second) {
			ans += (long long)itr->first * itr->second;
			M -= itr->second;
		}
		else {
			ans += (long long)itr->first * M;
			M = 0;
		}
		if (0 == M) {
			break;
		}

	}
	cout << ans <<  endl;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int W = in.nextInt();
		int[] w = new int[n];
		int[] p = new int[n];
		for (int i = 0; i < n; i++) {
			w[i] = in.nextInt();
			p[i] = in.nextInt();
		}
		//前n个物品能得到j价值的最小重量
		long[]dp = new long[100001];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 100000; j >= p[i]; j--) {
				dp[j] = Math.min(dp[j], dp[j-p[i]] + w[i]);
			}
		}
		for(int i = 100000; i >= 0; i--){
			if(dp[i] <= W){
				System.out.println(i);
				return;
			}
		}
	}
}

Measured memory_bytes: 23508
package main

import "fmt"

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

	d := 0
	cnt := 0
	if d <= x {
		cnt++
	}

	var l int
	for i := 0; i < n; i++ {
		fmt.Scan(&l)
		d = d + l
		if d <= x {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b){
    return *(int*)b - *(int*)a;
}
int main(void){
    int n, k, num[200000+5]={0};
    scanf("%d %d", &n, &k);
    for(int i=0; i<n; i++){
        int a;
        scanf("%d", &a);
        num[a-1]++;
    }
    
    int cnt=0;
    for(int i=0; i<200000; i++)if(num[i]>0)cnt++;
    
    int ans=0;
    qsort(num, 200000, sizeof(int), compare_int);
    for(int i=k; i<cnt; i++)ans+=num[i];
    
    printf("%d\n", ans);
    return 0;
}


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


#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
int main(void){
	int a,b;
	rep(i,7){
		cin>>a>>b;
		cout<<(a+100)-(b+100)<<endl;
	}
}

Measured memory_bytes: 1160
n=int(input())
ac=0
wa=0
tle=0
re=0
for _ in range(n):
    buf=input()
    if buf=="AC":
        ac+=1
    elif buf=="WA":
        wa+=1
    elif buf=="RE":
        re+=1
    elif buf=="TLE":
        tle+=1
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

Measured memory_bytes: 69772
#include <stdio.h>
#include <math.h>
int main() {
    int a, b, n;
    scanf("%d%d", &a, &b);
    int a1, a2, b1, b2;
    a1 = ceil(12.5 * a);
    a2 = floor(12.5 * (a+0.9));
    b1 = ceil(10 * b);
    b2 = floor(10 * (b+0.9));
    if(a2 < b1 || b2 < a1) {
        printf("-1");
        return 0;
    }
    if(b1 >= a1 && b1 <= a2) {
        printf("%d\n", b1);
        return 0;
    }
    if(b1 <= a1 && b2 >= a1) {
        printf("%d\n", a1);
        return 0;
    }
}

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

#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ldb long double 
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int MOD = 1e9+7;
const int MX = 2e5+5;
const ll INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n)
{
 ll res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a*=a;
  n/=2;
}
return res;
}

ll abst(ll a)
{
 return ((a<0)?(-1*a):(a));
}

int main()
{
  int n,m;
  cin>>n>>m;
  int arr[n+2];
  for(int i=0;i<=n+1;i++)
   arr[i]=0;
   for(int i=0;i<m;i++)
   {
       int x,y;
       cin>>x>>y;
       arr[x]+=1;
       arr[y+1]-=1;
   }
   int sum[n+2];
   sum[0]=arr[0];
   int count=0;
   for(int i=1;i<=n;i++)
{
    sum[i]=sum[i-1]+arr[i];
    if(sum[i]==m)
     count++;
}
cout<<count<<"\n";
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int d, t, s;
    cin >> d >> t >> s;

    if (d <= s * t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3620
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

N = int(input())
a = list(map(int, input().split()))

one = a.count(1)
two = a.count(2)
three = a.count(3)

dp = [[[0.0] * (N + 1) for _ in range((N + 1))] for _ in range((N + 1))]

max_one = one + two + three
max_two = two + three
max_three = three

for k in range(max_three + 1):
    for j in range(max_two + 1 - k):
        for i in range(max_one + 1 - j - k):
            if i + j + k == 0:
                continue
            else:
                r = N

            if i > 0:
                r += dp[i - 1][j][k] * i
            if j > 0:
                r += dp[i + 1][j - 1][k] * j
            if k > 0:
                r += dp[i][j + 1][k - 1] * k

            dp[i][j][k] = r / (i + j + k)

print(dp[one][two][three])


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

using namespace std;

int main() {
	int X;
	cin >> X;
	if (400 <= X && X <= 599) {
		cout << 8;
		return 0;
	}
	if (600 <= X && X <= 799) {
		cout << 7;
		return 0;
	}
	if (800 <= X && X <= 999) {
		cout << 6;
		return 0;
	}
	if (1000 <= X && X <= 1199) {
		cout << 5;
		return 0;
	}
	if (1200 <= X && X <= 1399) {
		cout << 4;
		return 0;
	}
	if (1400 <= X && X <= 1599) {
		cout << 3;
		return 0;
	}
	if (1600 <= X && X <= 1799) {
		cout << 2;
		return 0;
	}
	if (1800 <= X && X <= 1999) {
		cout << 1;
		return 0;
	}
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;

const int MAXN = 100010;
const int LOGN = 18;
ll x[MAXN], nxt[MAXN][LOGN];

int main() {
    int N; cin >> N;
    for(int i=0; i<N; i++) {
        cin >> x[i];
    }

    ll L; cin >> L;
    for(int i=0; i<N; i++) {
        int idx = upper_bound(x, x+N, x[i] + L) - x - 1;
        nxt[i][0] = idx;
    }
    for(int k=1; k<LOGN; k++) {
        for(int i=0; i<N; i++) {
            nxt[i][k] = nxt[ nxt[i][k-1] ][k-1];
        }
    }

    int Q; cin >> Q;
    while(Q--) {
        int a, b; cin >> a >> b;
        a--; b--;
        if(a > b) swap(a, b);

        int idx = a, ans = 0;
        for(int k=LOGN-1; k>=0; k--) {
            if(nxt[idx][k] < b) {
                ans += (1 << k);
                idx = nxt[idx][k];
            }
        }

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


Measured memory_bytes: 15616
#include <stdio.h>
#include <math.h>

int cnt;

void shellSort(int *A, int n);
void insertionSort(int *A, int n, int g);

int main(void)
{
	int n;
	int i;

	cnt = 0;
	scanf("%d", &n);

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

	shellSort(A, n);
	
	printf("%d\n", cnt);	
	for(i = 0; i < n; i++){
		printf("%d\n", A[i]);	
	}
	
}

void shellSort(int *A, int n)
{
	int i, m;

	int G_rev[100], G_rev_cnt = 0;	

	G_rev[0] = 1;
	i = 1;
	while(1){
		G_rev[i] = G_rev[i - 1] + pow(3, i);
		if(G_rev[i] > n) break;
		//printf("G_rev[%d] = %d\n", i, G_rev[i]);
		i++;
	}
	m = i;
	printf("%d\n", m);

	int G[m];
	for(i = 0; i < m - 1; i++){
		G[i] = G_rev[m - i - 1];
		printf("%d ", G[i]);
		//printf("G[%d] = %d\n", i, G[i]);
	}
	G[i] = G_rev[m - i - 1];
	printf("%d\n", G[i]);

	for(i = 0; i <= m - 1; i++){
		insertionSort(A, n, G[i]);
	}
}

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




Measured memory_bytes: 5772
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int x; cin>>x;
	cout<<10-x/200<<endl;
	return 0;
}

Measured memory_bytes: 3604
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

int pt[100001],visited[100001]={};
vector<vector<int> >child(100001);
int DFS(int u){
	// cout<<"訪問："<<u<<endl;
	pt[u]=1;
	rep(i,child[u].size()){
		if(visited[child[u][i]]==0){
			visited[child[u][i]]=1;
			pt[u]+=DFS(child[u][i]);
		}
	}
	return pt[u];
}

int main(void){
	int N,a,b;
	cin>>N;
	rep(i,N-1){
		cin>>a>>b;
		child[a].push_back(b);
		child[b].push_back(a);
	}
	//DFSでパスを見つける。真ん中の点以降の部分木の頂点個数を考える。
	visited[1]=1;
	DFS(1);
	//大をたどる。
	vector<int>path;
	int u=N;
	path.push_back(N);//一応
	while(u!=1){
		rep(i,child[u].size()){
			if(pt[child[u][i]]>pt[u]){
				path.push_back(child[u][i]);
				u=child[u][i];
				break;//１個しかないから
			}
		}
	}
	//pathには１が含まれている
	int snuke;
	snuke = pt[path[path.size()/2-1]];
	// cout<<snuke<<endl;
	if(snuke>=N-snuke){
		cout<<"Snuke"<<endl;
	}else{
		cout<<"Fennec"<<endl;
	}
	return 0;
}

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

#define lld long long
#define pp pair<int,int>
#define pb push_back
#define MOD 1000000007
#define left lleft
#define right rright
#define INF 2000000000
#define Linf 1000000000000000000LL
#define next nnext
#define minus mminus

using namespace std;

lld N;
lld d[1000002],sum[1000002];

int main(){
	scanf("%lld",&N);
	d[1] = sum[1] = N;
	for(int i=2; i<=N; i++){
		d[i] = d[i-1];
		lld t = max(2,i-1);
		d[i] += (N-t+1)*N;
		if(t > 2){
			d[i] += sum[i-3];
			d[i] += (t-2)*(N-1);
		}
		sum[i] = sum[i-1]+d[i];
		d[i] %= MOD; sum[i] %= MOD;
	}
	printf("%lld\n",d[N]);

	return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

void solve()
{
    int n,k;
    cin>>n>>k;
    vi a(n);
    for(int i=0;i<n;i++) cin>>a[i];

    sort(all(a));
    int ans=0;
    for(int i=0;i<k;i++) {
        ans+=a[i];
    }
    cout<<ans;
}

int main()
{
    fastio;
    int t;

    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        //cout << newl;
    }

    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[51], b[51];
bool graph[51][51];
bool visited[51];

void dfs(int v) {
    visited[v] = true;
    for(int v2 = 0; v2 < n; ++v2) {
        if(graph[v][v2] == false) continue;
        if(visited[v2] == true) continue;
        dfs(v2);
    }
}

int main() {
    cin >> n >> m;
    for(int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }
    int ans = 0;
    for(int i = 0; i < m; ++i) {
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
        for(int j = 0; j < n; ++j) visited[j] = false;
        dfs(0);
        bool bridge = false;
        for(int j = 0; j < n; ++j) if(visited[j] == false) bridge = true;
        if(bridge) ans += 1;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N,  K = map(int, input().split())
candles = list(map(int, input().split()))
ans = float('inf')
for i in range(N - K + 1):
    if candles[i] * candles[i + K - 1] >= 0:
        t = max(abs(candles[i]), abs(candles[i + K - 1]))
    else:
        t = candles[i + K - 1] - candles[i] + min(abs(candles[i]), abs(candles[i + K - 1]))
    ans = min(ans, t)
print(ans)


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

int N, a, b;

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a;
    b |= a;
  }

  int count = 0;
  while (b % 2 == 0) {
    b /= 2;
    ++count;
  }
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 3636
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String yymm = sc.next();
    StringBuilder sb = new StringBuilder();
    sb.append(yymm);
    String yy = sb.substring(0,2);
    String mm = sb.substring(2,4);
    boolean isYYMM = false;
    boolean isMMYY = false;
    String answer = "";
    int month = Integer.parseInt(mm);
    int year = Integer.parseInt(yy);
    if(month>=1&&month<=12){
      isYYMM = true;
    }
    if(year>=1&&year<=12){
      isMMYY = true;
    }
    if(!isYYMM&&!isMMYY){
      answer = "NA";
    }else if(isYYMM&&!isMMYY){
      answer = "YYMM";
    }else if(!isYYMM&&isMMYY){
      answer = "MMYY";
    }else{
      answer = "AMBIGUOUS";
    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 22996
o,x,b;
main(a){
  for(scanf("%*d");~scanf("%s",&a);o==3?o=b=x=!printf("%d\n",x):0){
    a%=6;
    !a?x+=b+1,b=0:a-5?x+=++b/4,b>3?b=3:0:o++;
  }
}

Measured memory_bytes: 0
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

ll N, M, V, P;

bool isOK(vector<ll> A, ll key) {
    if (key < P)
        return true;
    A[key] += M;
    ll tmp = A[key];
    if (A[P - 1] > tmp)
        return false;
    ll score = 0;
    score += (P - 1) * M;  // p-1まで
    score += (N - key) * M; // keyより下
    for (int i = P - 1; i < key; i++) {
        score += min(M, max(0LL, tmp - A[i])); // p-1からkeyまで
    }

    return score >= M * V;
}

int main() {
    cin >> N >> M >> V >> P;
    vector<ll> A(N);
    rep(i, N) { cin >> A[i]; }

    sort(all(A), greater<ll>());
    ll ok = -1, ng = N;
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (isOK(A, mid))
            ok = mid;
        else
            ng = mid;
    }

    cout << ok + 1 << endl;
    return 0;
}

Measured memory_bytes: 4932
first = input().split(' ')
second = input().split(' ')

name_1 = first[0]
count_1 = int(second[0])
name_2 = first[1]
count_2 = int(second[1])

name = input()

if name_1 == name:
    count_1 -= 1
else:
    count_2 -= 1

print(count_1, count_2)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007; 
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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

class UnionFind{
    std::vector<int> par;
    std::vector<int> rank;
    std::vector<int> membnum;

public:
    UnionFind(){}
    UnionFind(int n): par(n), rank(n), membnum(n){
        for(int i(0); i < n; ++i){
            par[i] = i;
            rank[i] = 0;
            membnum[i] = 1;
        }
    }

    void resize(int n){
        int m(par.size());
        par.resize(n);
        rank.resize(n, 0);
        membnum.resize(n, 1);
        for(int i(m); i < n; ++i) par[i] = i;
    }

    int find(int x){
        if(x == par[x]) return x;
        else return par[x] = find(par[x]);
    }

    bool unit(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;

        if(rank[x] < rank[y]){
            par[x] = y;
            membnum[y] += membnum[x];
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) ++rank[x];
            membnum[x] += membnum[y];
        }
        return true;
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    int howmany(int x){ //同じグループに属すものの個数(自分を含む)
        return membnum[find(x)];
    }
};





int main(){
    int N, M; std::cin >> N >> M;
    // i=0,...,N-1: i+1が1, i=N,..,2n-1: i-n+1が0
    UnionFind uf(2 * N);
    {
        int X, Y, Z;
        for(int i(0); i < M; ++i){
            std::cin >> X >> Y >> Z;
            if(Z % 2){
                uf.unit(X, N+Y); uf.unit(N+X, Y);
            }else{
                uf.unit(X, Y); uf.unit(N+X, N+Y);
            }
        }
    }
    int cnt(0);
    for(int i(0); i < N; ++i){
        /* 矛盾があるとき
        if(uf.same(i, N+i)){
            std::cout << -1 << std::endl;
            return 0;
        }
        */
       if(uf.find(i) == i) ++cnt;
    }
    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>

using namespace std;
using ll = long long;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<int>;

const int MOD = 1000000007;

int H, W;

bool check(int i,int j,mat & room)
{
	if (i < 0 || j < 0)return false;
	if (i >= H)return false;
	if (j >= W)return false;
	return room[i][j]==0;
}

int main()
{
	cin >> H >> W;
	mat room(H, vec(W, 0));

	for (int i = 0; i < H; ++i)
	{
		string S; cin >> S;
		for (int j = 0; j < W; ++j)
		{
			if(S[j]=='#')
			{
				room[i][j] = 1;
			}
		}
	}

	int ans = 0;
	mat right(H, vec(W, 0));
	mat left(H, vec(W, 0));
	mat up(H, vec(W, 0));
	mat down(H, vec(W, 0));
	for (int i = 0; i < H; ++i)
	{
		for (int j = 1; j < W; ++j)
		{
			if (room[i][j] != 0)
			{
				continue;
			}
			right[i][j] = (room[i][j-1] == 0) + right[i][j - 1];
		}

		for (int j = W-2; j >= 0; --j)
		{
			if (room[i][j] != 0)
			{
				continue;
			}
			left[i][j] = (room[i][j + 1] == 0) + left[i][j + 1];
		}
	}

	for (int j = 0; j < W; ++j)
	{
		for (int i = 1; i < H; ++i)
		{
			if (room[i][j] != 0)
			{
				continue;
			}
			up[i][j] = (room[i-1][j] == 0) + up[i - 1][j];
		}
		for (int i = H-2; i >= 0; --i)
		{
			if (room[i][j] != 0)
			{
				continue;
			}
			down[i][j] = (room[i+1][j] == 0) + down[i + 1][j];
		}
	}

	for (int j = 0; j < W; ++j)
	{
		for (int i = 0; i < H; ++i)
		{
			if (room[i][j] == 1)continue;
			ans = max(ans, 1 + up[i][j] + down[i][j] + right[i][j] + left[i][j]);
		}
	}

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

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll V, E;
    cin >> V >> E;
    vector<pair<ll, P>> info(E);
    rep(i, E) {
        ll s, t, d;
        cin >> s >> t >> d;
        info[i] = make_pair(s, make_pair(t, d));
    }
    vector<vector<ll>> dp(V, vector<ll>(1 << V, INF));
    dp[0][0] = 0;
    rep(i, 1 << V) {
        rep(j, E) {
            ll s = info[j].first;
            ll t = info[j].second.first;
            ll d = info[j].second.second;
            if (!(i & (1 << t))) {
                dp[t][i | (1 << t)] = min(dp[t][i | (1 << t)], dp[s][i] + d);
            }
        }
    }
    ll ans = dp[0][(1 << V) - 1];
    if (ans == INF) {
        cout << -1 << '\n';
    } else {
        cout << ans << '\n';
    }
}

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



Measured memory_bytes: 7080
import sys

h,w=map(int,input().split())

ans=10**10

S=[]

if h%3==0 or w%3==0:
  print(0)
  sys.exit()


for h1 in [h//3,(h//3)+1]:
  if ((h-h1)*w)%2==0:
    S.append([h1*w,((h-h1)*w)//2,((h-h1)*w)//2])
  else:
    S.append([h1*w,((h-h1)//2)*w,((h-h1)//2+1)*w])
    S.append([h1*w,(w//2)*(h-h1),(w//2+1)*(h-h1)])

for w1 in [w//3,(w//3)+1]:
  if ((w-w1)*h)%2==0:
    S.append([w1*h,((w-w1)*h)//2,((w-w1)*h)//2])
  else:
    S.append([w1*h,((w-w1)//2)*h,((w-w1)//2+1)*h])
    S.append([w1*h,(h//2)*(w-w1),(h//2+1)*(w-w1)])

for si in S:
  ans=min(ans,max(si)-min(si))

print(ans)

Measured memory_bytes: 9168
S = input()
T = input()

num_list = []

for i in range(len(S)-len(T)+1):
    num = len(T)
    for j, target in enumerate(S[i:i+len(T)]):
        if target == T[j]:
            num -= 1
    num_list.append(num)
print(min(num_list))


Measured memory_bytes: 9032
from itertools import accumulate

n, k = map(int, input().split())
p = list(map(int, input().split()))


def f(x):
    return (1 + x) / 2


kitai = [0] + [f(e) for e in p]
acm = list(accumulate(kitai))

ans = 0
for e1, e2 in zip(acm, acm[k:]):
    ans = max(ans, e2 - e1)

print(ans)


Measured memory_bytes: 25504
#include <stdio.h>
#include<math.h>
#include <string.h>
#include <ctype.h>

int main(){
int a[1001],i,n,m,f,t;

while(1){
scanf("%d %d",&n,&m);
if(n==0&&m==0)break;
for(i=1;i<=n;i++)a[i]=i;
i=1;
f=0;
t=0;
while(1){
if(t==n-1)break;
if(a[i]!=0)f++;
if(f==m){
a[i]=0;
t++;
f=0;
}
i++;
if(i==n+1)i=1;
}
for(i=1;i<=n;i++){
if(a[i]!=0){
printf("%d\n",a[i]);
}
}
}
return 0;
}

Measured memory_bytes: 1032
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <random>
#include <cassert>
#include <limits>

using namespace std;

#define mp make_pair
#define pb push_back
#define repi(i, p, q) for (long i = p; i < q; i++)
#define repd(i, p, q) for (long i = p; i >= q; i--)
#define sz(x) x.size()
#define INF 2000000000
#define MOD 1000000007

typedef map<int, int> MI;
typedef pair<int, int> PI;
typedef long long int LLI;
typedef long int LI;
typedef int I;

char a[103][103];
int row[103] = {0};
int col[103] = {0};

int main()
{
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < h; i++)
    {
        int flag = 0;
        for (int j = 0; j < w; j++)
        {
            if (a[i][j] == '#')
            {
                flag = 1;
            }
        }
        if (flag == 0)
        {
            row[i] = 1;
        }
    }
    for (int i = 0; i < w; i++)
    {
        int flag = 0;
        for (int j = 0; j < h; j++)
        {
            if (a[j][i] == '#')
            {
                flag = 1;
            }
        }
        if (flag == 0)
        {
            col[i] = 1;
        }
    }
    for (int i = 0; i < h; i++)
    {
        int flag = 0;
        for (int j = 0; j < w; j++)
        {
            if (row[i] == 1 || col[j] == 1)
            {
            }
            else
            {
                flag = 1;
                cout << a[i][j];
            }
        }
        if (flag == 1)
            cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::collections::BinaryHeap;


const INF: i64 = std::i64::MAX;

struct Graph {
    num_node: usize,
    edges: Vec<(usize, usize, i64)>,
}

impl Graph {
    fn new(num_of_node: usize) -> Self {
        Graph { num_node: num_of_node, edges: Vec::new() }
    }

    fn add_edge(&mut self, start_node: usize, end_node: usize, edge_cost: i64, directed: bool) -> () {
        self.edges.push((start_node, end_node, edge_cost));
        if !directed { self.edges.push((end_node, start_node, edge_cost)); }
    }

    fn bellman_ford(&self, start_node: usize) -> i64 {
        let node = self.num_node;
        let mut distance: Vec<i64> = vec![INF; node];
        distance[start_node] = 0;
        for i in 0..node {
            for &(u, v, c) in &self.edges {
                if distance[u] != INF && distance[u] + c < distance[v] {
                    distance[v] = distance[u] + c;
                    if i == (node - 1) && v == (node - 1) {
                        return -INF;
                    }
                }
            }
        }
        -distance[node - 1]
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn readc() -> char {
    let s: String = read();
    return s.chars().nth(0).unwrap();
}

fn read_vec<T: FromStr>(n: usize) -> Vec<T> {
    return (0..n).map(|_| read()).collect();
}

fn main() {
    let n: usize = read();
    let m: usize = read();

    let mut g = Graph::new(n+1);
    for i in 0..m {
        let a: usize = read();
        let b: usize = read();
        let c: i64 = read();
        g.add_edge(a, b, -c, true);
    }

    let ans = g.bellman_ford(1);
    if ans == -INF {
        println!("inf");
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 4352