akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class SearchIsland
    {
        struct Position { internal int x, y; }

        readonly int[] moveX = new int[] { -1, 0, 1, 0 };
        readonly int[] moveY = new int[] { 0, -1, 0, 1 };

        bool[,] map;

        public void MakeMap(string[] source)
        {
            map = new bool[12, 12];

            for (int i = 0; i < 12; i++)
            {
                for (int j = 0; j < 12; j++)
                {
                    map[i, j] = source[i][j] == '1' ? true : false;
                }
            }
        }

        public int Count()
        {
            int count = 0;

            for (int i = 0; i < 12; i++)
            {
                for (int j = 0; j < 12; j++)
                {
                    if (map[i, j])
                    {
                        CheckIsland(i, j);
                        count++;
                    }
                }
            }
            return count;
        }

        private void CheckIsland(int i, int j)
        {
            Stack<Position> stk = new Stack<Position>();

            Position willPush;
            willPush.x = j;
            willPush.y = i;
            stk.Push(willPush);

            while (stk.Count > 0)
            {
                Position temp = stk.Pop();
                int posX = temp.x;
                int posY = temp.y;

                map[posY, posX] = false;

                for (int n = 0; n < 4; n++)
                {
                    willPush.x = posX + moveX[n];
                    willPush.y = posY + moveY[n];

                    if (isValid(willPush.x, willPush.y) && map[willPush.y, willPush.x])
                    {
                        stk.Push(willPush);
                    }
                }
            }
        }

        private bool isValid(int x, int y)
        {
            if (x < 0 || x > 11) return false;
            if (y < 0 || y > 11) return false;
            return true;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();
            SearchIsland SI = new SearchIsland();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                string[] map = new string[12];
                map[0] = input;

                for (int i = 1; i < 12; i++)
                {
                    map[i] = Console.ReadLine();
                }

                SI.MakeMap(map);

                sb.AppendLine(SI.Count().ToString());

                Console.ReadLine();
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 10060
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
int main(){
 int n;
  cin>>n;
  int d[n];
  rep(i, n){
    cin>>d[i];}
  
  sort(d,d+n,greater<int>());
  int p=(n-2)/2;
  cout<<d[p]-d[p+1]<<endl;
  
 
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll n,k;
  cin >> n >> k;
  vl a;
  inputv(a,n);
  ll num=0;
  rep(i,n){
    for(ll j=i+1; j<n; j++){
      if(a[i] > a[j]) num++;
    }
  }
  vl b(n,0);
  rep(i,n){
    rep(j,n){
      if(a[i] < a[j]) b[i]++;
    }
  }
  
  ll sum = 0;
  rep(i,n){
    sum += b[i];
  }
  ll x = ((k*(k-1))/2)%MOD;

  ll ans = ((k*num)+(x*sum))%MOD;
  
  
  cout << ans;
 return 0;
}


Measured memory_bytes: 256
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main() {
	int L, R, d;
	sci(L), sci(R), sci(d);
	int ans = 0;
	for (int i = L; i <= R; ++i) {
		ans += i % d == 0;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3816
n=int(input())
a=[]
while n:
    a+=n%26+96,
    n//=26
for i in range(len(a)-1):
    f=a[i]<97
    a[i]+=f*26
    a[i+1]-=f
print(*map(chr,a[::-1][a[-1]<97:]),sep='')

Measured memory_bytes: 9068
#include<iostream>
#include<cstdio>
using namespace std;
const int inf=1010101010;
struct Edge{
	int to,next,val;
}e[2020202];
int head[1010101],cnt=0;
void add(int u,int v,int w)
{
	cnt++;
	e[cnt].to=v;
	e[cnt].next=head[u];
	e[cnt].val=w;
	head[u]=cnt;
}
int cal[22];
int dfs(int x,int fa)
{
	int ret=0;
	for(int i=head[x];i!=0;i=e[i].next)
	{
		int to=e[i].to;
		if(to!=fa)
		{
			int tmp=dfs(to,x);
			cal[e[i].val^tmp]++;
			ret^=e[i].val;
		}
	}
	return ret;
}
int dp[1010101],p[33];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		u++;
		v++;
		add(u,v,w);
		add(v,u,w);
	}
	dfs(1,0);
	int ans=0;
	for(int i=1;i<=15;i++)
	{
		ans+=cal[i]/2;
		cal[i]%=2;
	}
	int nn=0;
	for(int i=1;i<=15;i++)
	if(cal[i]==1)
	{
		nn++;
		p[nn]=i;
	}
	for(int i=0;i<(1<<nn);i++)
		dp[i]=inf;
	dp[0]=0;
	for(int i=0;i<(1<<nn);i++)
	{
		int tmp=0;
		for(int j=1;j<=nn;j++)
		if((i&(1<<(j-1)))!=0)
			tmp^=p[j];
		for(int j=1;j<=nn;j++)
		if((i&(1<<(j-1)))==0)
		{
			if((tmp^p[j])==0)
				dp[(i|(1<<(j-1)))]=min(dp[(i|(1<<(j-1)))],dp[i]);
			else
				dp[(i|(1<<(j-1)))]=min(dp[(i|(1<<(j-1)))],dp[i]+1);
		}
	}
	printf("%d\n",ans+dp[(1<<nn)-1]);
	return 0;
}

Measured memory_bytes: 12928
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n = I()
    a = Intl()
    for i in range(n):
        if a[i]%2 == 0:
            if a[i]%3 == 0 or a[i]%5 == 0:pass
            else:
                print("DENIED")
                exit()
    print("APPROVED")

Measured memory_bytes: 9096
#include <bits/stdc++.h>
 
using namespace std;
 
const int SZ = 1000000;
const int INF = 1 << 30;
 
int N, M, S[100000];
int latte[SZ + 1], malta[SZ + 1];
 
bool check(int X)
{
  int curr = 1, ret = 1;
  while(curr + X <= S[N - 1]) {
    int sub = INF;
    if(curr + X > latte[curr]) sub = min(sub, latte[curr] - curr);
    sub = min(sub, curr - malta[curr]);
    curr += max(1, X - sub);
    ++ret;
  }
  return (ret >= M);
}
 
int main()
{
  while(cin >> N >> M, N) {
    for(int i = 0; i < N; i++) cin >> S[i];
    fill(begin(latte), end(latte), INF);
    fill(begin(malta), end(malta), -INF);
    for(int i = 0; i < N; i++) latte[S[i]] = S[i];
    for(int i = 0; i < N; i++) malta[S[i]] = S[i];
    for(int i = SZ - 1; i >= 0; i--) latte[i] = min(latte[i], latte[i + 1]);
    for(int i = 1; i <= SZ; i++) malta[i] = max(malta[i], malta[i - 1]);
    int ok = S[0], ng = SZ + 5;
    if(!check(ok)) {
      cout << -1 << endl;
    } else {
      while(ng - ok > 1) {
        int mid = (ok + ng) >> 1;
        if(check(mid)) ok = mid;
        else ng = mid;
      }
      cout << ok << endl;
    }
  }
}

Measured memory_bytes: 11292
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

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

	int cnt = 0;
	for(int i = 1; i <= N; i++)
	{
		string s = to_string(i);
		if(s.size() % 2 != 0) cnt++;
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N, W;
	cin >> N >> W;
	int w[110], v[110];
	for (int i = 0; i < N; ++i)cin >> w[i] >> v[i];
	ll dp[110][100100] = {};
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 100100; ++j) {
			if (j >= w[i]) {
				dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
			}
			else {
				dp[i + 1][j] = dp[i][j];
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i <= W; ++i) {
		ans = max(ans, dp[N][i]);
	}
	cout << ans << endl;
	return 0;
}



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

int main() {
  long long K;
  cin >> K;
  long long p = 7;
  long long cnt = 1;
  bool b = false;
  long long q;
  for(int i = 0; i < 5000000; i++) {
    if(p % K == 0) {
      q = cnt;
      b = true;
      break;
    }
    else {
      p = 10*(p%K)+7;
      cnt++;
    }
  }
  if(b) {
    cout << q << endl;
  }
  else  {
    cout << "-1" << endl;
  }
}


Measured memory_bytes: 3632
n,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
ans=0
for i in range(n):
    if x>=a[i]:
        ans+=1
        x-=a[i]
    else:
        break
if ans == n:
    if x!=0:
        ans-=1
print(ans)

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

int dp[1 << 20], pd[1 << 26], state[1 << 20];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	string s; cin >> s;
	for (int i = 0; i < s.length(); i++) s[i] -= 'a';
	for (int i = 0; i < s.length(); i++) {
		if (i) state[i] = state[i - 1];
		state[i] ^= (1 << s[i]);
	}
	for (int i = 0; i < 1 << 26; i++) pd[i] = 1 << 20;
	pd[0] = 0;
	for (int i = 0; i < s.length(); i++) {
		if (i == 0) {
			dp[i] = 1;
			pd[state[i]] = 1;
			continue;
		}
		int now = state[i - 1];
		dp[i] = min(pd[now], pd[now ^ (1 << s[i])]) + 1;
		for (int j = 0; j < 26; j++) dp[i] = min(dp[i], pd[now ^ (1 << s[i]) ^ (1 << j)] + 1);
		pd[state[i]] = min(dp[i], pd[state[i]]);
	}
	cout << dp[s.length() - 1] << endl;
	return 0;
}



Measured memory_bytes: 267452
import itertools
from collections import Counter

L=['M','A','R','C','H']
N=int(input())
a =[input()[0] for i in range(N)]
A=dict(Counter([x for x in a if x in L]))

res = list(map(dict, itertools.combinations(A.items(), 3)))

ans=0
for r in res:
	tmp=1
	for k in r.values():
		tmp*=k
	ans+=tmp
print(ans)	


Measured memory_bytes: 4992
# -*- coding: utf-8 -*-

a_b_c = list(map(int, input().split()))
tmp = [5, 7, 5]
flag = True

for i in a_b_c:
    if i in tmp:
        tmp.remove(i)
    else:
        print('NO')
        flag = False
        break

if flag:
    print('YES')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >> S;
    
    for(int i=0;i<S.size()-1;i++){
        if(S[i]==S[i+1]){
            cout << "Bad";
            return 0;
        }
    }
    
    cout << "Good";
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

using namespace std;

int main() {

    int n; cin >> n;
    int ans;
    int m = 1;
    int a[101]; rep(i,n) cin >> a[i];

    ans = pow(3,n);

    rep(i,n){
        if(a[i]%2 == 0) m *= 2;
    }
    cout << (ans - m);
    return 0;
}











Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main() {
    int n;
    cin >> n;
    int ans = 9999999;
    for(int i = 1; i < n/2+1; i++){
        int a = i;
        int b = n-i;
        string sa = to_string(a);
        string sb = to_string(b);
        int dsum = 0;
        for(auto ch : sa){
            dsum += int(ch-'0');
        }
        for(auto ch : sb){
            dsum += int(ch-'0');
        }
        ans = min(ans, dsum);

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k;
	string s;
	cin>>k>>s;
	int len=s.size();
	if(len<=k)
		cout<<s<<endl;

	else
	{
		for(int i=0;i<k;i++)
			cout<<s[i];
		cout<<"..."<<endl;
	}
		


	return 0;

}

Measured memory_bytes: 3620
#include<map>
#include<cstdio>
#include<string>
#include<algorithm>

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

using namespace std;

struct Interval{
	int a,b;
	Interval(){}
	Interval(int A,int B):a(A),b(B){}
	bool operator<(const Interval &I)const{ return b<I.b; }
};

bool intersect(const Interval &I,const Interval &J){
	return I.a<J.b && J.a<I.b;
}

int solve(int n,Interval *I){
	sort(I,I+n);

	int ans=0,r=-1;
	rep(i,n) if(r<=I[i].a) r=I[i].b, ans++;

	return ans;
}

int main(){
	for(int n;scanf("%d",&n),n;){
		map<string,int> f;
		Interval I[500];
		rep(i,n){
			char name[33];
			int week,start; scanf("%s%d%d",name,&week,&start);
			f[name]=i;

			int h=start/100,m=start%100;
			start=week*24*60+h*60+m;
			I[i]=Interval(start,start+30);
		}

		int nf; scanf("%d",&nf);
		Interval fav[500];
		rep(i,nf){
			char name[33]; scanf("%s",name);
			fav[i]=I[f[name]];
		}

		bool ok=true;
		rep(j,nf) rep(i,j) if(intersect(fav[i],fav[j])) ok=false;
		if(!ok){ puts("-1"); continue; }

		int n2=0;
		Interval J[500];
		rep(i,n){
			bool ok=true;
			rep(j,nf) if(intersect(I[i],fav[j])) ok=false;
			if(ok) J[n2++]=I[i];
		}

		printf("%d\n",nf+solve(n2,J));
	}

	return 0;
}

Measured memory_bytes: 900
void main()
{
    long n = readln.chomp.to!long;
    long[] a = new long[n];
    foreach (i; 0 .. n)
    {
        a[i] = readln.chomp.to!long;
    }

    auto rbt = new RedBlackTree!(long, "a < b", true);
    foreach (x; a)
    {
        auto l = rbt.lowerBound(x);
        if (!l.empty) rbt.removeKey(l.back);
        rbt.insert(x);
    }

    rbt.length.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

int main(){
	int a;
	cin >> a;
	if(a<1200){
		cout << "ABC" ;
	}else if(a<2800){
		cout << "ARC" ;
	}else{
		cout << "AGC" ;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define ll long long
#define hii cout << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first 
#define ss second
#define all(s) s.begin(), s.end()
#define fuck_you_scanf ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define si size()
 
const int N = 1e6 + 5;
vector<int> v[N];
int DP[N];

int dfs(int sv)
{
    if(DP[sv] != -1) return DP[sv];
    int ret = 0;
    for(int x : v[sv])
    {
        int ans = 1 + dfs(x);
        ret = max(ans, ret);
    }
    return DP[sv] = ret;
}

int32_t main()
{
    memset(DP, -1, sizeof(DP));
    int n, m;
    cin >> n >> m;
    while(m--)
    {
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
    }
    for(int i = 1; i <= n; i++)
    {
        dfs(i);
    }
    cout << *max_element(DP + 1, DP + n + 1);
}

Measured memory_bytes: 36608
import itertools as it
while 1:
  n = input()
  if n==0: break
  A = sorted(set([pow(i, 2, n) for i in range(1, n)]))[::-1]
  C=[0]*n
  for a,b in it.combinations(A, 2):
    C[a-b] += 2
  D = C[::-1]
  for i in range(n/2):
    print C[i+1] + D[i]

Measured memory_bytes: 5536
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int main() {
    int A,B,X;
    cin >> A >> B >> X;
    if(X >= A && A + B >= X){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}



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

int waru(int N, int k){
	int ans = 0;
	while(N % k == 0){
		ans++;
		N /= k;
	}
	return ans;
}

signed main(){
	int N, i, j, k, l, ans = 0;
	int M = 18;
	scanf("%lld", &N);
	vector<vector<int>> s(M + 1, vector<int>(M + 1, 0));
	for(i = 0; i < N; i++){
		double A;
		scanf("%lf", &A);
		int B = (int)(A * 1e9 + 1e-1);
		int a = waru(B, 2);
		int b = waru(B, 5);
//		printf("(B, a, b) = (%lld, %lld, %lld)\n", B, a, b);
		s[min(M, a)][min(M, b)]++;
	}
/*	printf("s:\n");
	for(i = 0; i <= M; i++){
		for(j = 0; j <= M; j++){
			printf("%lld ", s[i][j]);
		}
		printf("\n");
	}
	printf("\n");
*/	for(i = 0; i <= M; i++){
		for(j = 0; j <= M; j++){
			for(k = 0; k <= M; k++){
				for(l = 0; l <= M; l++){
					if(i + k >= M && j + l >= M){
						ans += s[i][j] * s[k][l];
						if(i == k && j == l){
							ans -= s[i][j];
						}
					}
				}
			}
		}
	}
	printf("%lld\n", ans / 2);
	return 0;
}

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

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

    if (0 < t.size() <= 10 && (t.erase(t.size() - 1, 1) == s))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<queue>
#include<math.h>
#include<ctime>
#include<deque>
#include<set>
#include<string.h>
#include<algorithm>
#include<map>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ls rt<<1
#define rs rt<<1|1
#define mmm(a,b) memset(a,b,sizeof(a))
#define sc(x) scanf("%d",&x)
using namespace std;
const ll mod = 1e9+7;
const ll inf = 1e17;
const double pi = acos(-1.0);
const int maxn = 1e6+5;
int kase;
ll n,m,p,k,cnt;
ll dp[maxn][4];
void run(){
    cin>>n;
    dp[0][2]=1;
    for(int i=1;i<=n;i++){
        dp[i][0]=(dp[i-1][2]+dp[i-1][0]*9)%mod;
        dp[i][1]=(dp[i-1][2]+dp[i-1][1]*9)%mod;
        dp[i][2]=(dp[i-1][2]*8)%mod;
        dp[i][3]=(dp[i-1][0]+dp[i-1][1]+dp[i-1][3]*10)%mod;
    }
    cout<<dp[n][3]<<'\n';
}
int main(){
#ifdef haosao
freopen("main.h", "r", stdin);
//freopen("out.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);
//    cin>>kase;
//    while(kase--)
        run();
    return 0;
}


Measured memory_bytes: 34444
h,w,m=map(int,input().split())
row=[0]*h
col=[0]*w
s=[]
for _ in range(m):
	x,y=map(int,input().split())
	row[x-1]+=1
	col[y-1]+=1
	s.append([x-1,y-1])
a,b=max(row),max(col)
aa=row.count(a)
bb=col.count(b)
c=0
for x,y in s:
	if row[x]==a and col[y]==b:c+=1
if c<aa*bb:print(a+b)
else:print(a+b-1)

Measured memory_bytes: 126196
#include<bits/stdc++.h>//万能头万岁！
using namespace std;
string a;
bool lk=false;
int main(){
	ios::sync_with_stdio(false);
	cin>>a;
	for(int i=0;i<a.length();i++){
		if(a[i]=='C') lk=true;
		if(a[i]=='F'&&lk){
			cout<<"Yes";return 0;
		} 
	}
	cout<<"No";
	return 0;
}
//木有钱233 NO_MANEY 奉上

Measured memory_bytes: 256
#include <stdio.h>

int cps(int w1,int h1,int w2,int h2) {
	int t1=w1*w1+h1*h1;
	int t2=w2*w2+h2*h2;
	if(t1<t2)return -1;
	if(t1>t2)return 1;
	if(h1<h2)return -1;
	if(h1>h2)return 1;
	return 0;
}

int main(void) {
	int h,w;
	int hh,ww;
	int mh,mw;
	while(scanf("%d%d",&h,&w)==2 && (h|w)!=0) {
		mh=mw=200;
		for(hh=1;hh<=150;hh++) {
			for(ww=hh+1;ww<=150;ww++) {
				if(cps(w,h,ww,hh)<0 && cps(ww,hh,mw,mh)<0) {
					mw=ww;mh=hh;
				}
			}
		}
		printf("%d %d\n",mh,mw);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>

using ll = long long;

ll solv(size_t N, ll X,
        std::vector<ll> const& Height,
        std::vector<ll> const& Patties) {
  if (X == 0) return 0;

  if (X == Height[N]) return Patties[N];

  if (X-1 <= Height[N-1]) return solv(N-1, X-1, Height, Patties);

  return Patties[N-1] + 1 + solv(N-1, X-Height[N-1]-2, Height, Patties);
}

int main() {
  size_t N;
  ll X;

  std::cin >> N >> X;

  std::vector<ll> Height(N+1);
  std::vector<ll> Patties(N+1);

  Height[0] = 1;
  Patties[0] = 1;

  for (size_t l=1; l<N+1; l++) {
    Height[l] = Height[l-1] * 2 + 3;
    Patties[l] = Patties[l-1] * 2 + 1;
  }

  std::cout << solv(N, X, Height, Patties) << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    long double a, b, c;
    cin >> a >> b >> c;
    long double sa = sqrt(a/c);
    long double sb = sqrt(b/c);
    //long double sc = sqrt(c);

    ATYN(sa + sb < 1)
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
    int y, m, d;
    scanf("%d/%d/%d", &y, &m, &d);
    if(y <= 2019 && m <= 4 && d < 31)
        printf("Heisei\n");
    else
        printf("TBD\n");
    return 0;
}


Measured memory_bytes: 128
class segment_tree_dual:
    def __init__(self, N, compose, funcval, ID_M=None):
        self.compose = compose
        self.ID_M = ID_M
        self.funcval = funcval

        self.height = (N-1).bit_length() #木の段数
        self.N0 = 1<<self.height #木の横幅 >= N
        self.laz = [self.ID_M]*(2*self.N0) #作用素の木
        self.val = None #値の配列

    #初期値の配列を作る
    def build(self,initial):
        self.val = initial[:]

    #laz[k] を子に伝える、k が一番下の場合は laz[k] を val に反映する
    def propagate(self,k):
        if self.laz[k] == self.ID_M: return;
        if self.N0 <= k:
            self.val[k-self.N0] = self.funcval(self.val[k-self.N0], self.laz[k])
            self.laz[k] = self.ID_M
        else:
            self.laz[(k<<1)  ] = self.compose(self.laz[(k<<1)  ],self.laz[k]);
            self.laz[(k<<1)+1] = self.compose(self.laz[(k<<1)+1],self.laz[k]);
            self.laz[k] = self.ID_M;
    
    # 遅延をすべて解消する
    def propagate_all(self):
        upto = self.N0 + len(self.val)
        for i in range(1,upto): self.propagate(i)

    # laz[k]およびその上に位置する作用素をすべて伝播
    def thrust(self,k):
        for i in range(self.height,-1,-1): self.propagate(k>>i)

    # 区間[l,r]に関数 f を作用
    def update(self, L,R,f):
        L += self.N0; R += self.N0+1
        """まず伝播させる（オペレータが可換なら必要ない）"""
        #self.thrust(L)
        #self.thrust(R-1)
        #登りながら関数 f を合成
        while L < R:
            if R & 1:
                R -= 1
                self.laz[R] = self.compose(self.laz[R],f)
            if L & 1:
                self.laz[L] = self.compose(self.laz[L],f)
                L += 1
            L >>= 1; R >>= 1
    
    # values[k] を取得。
    def point_get(self, k):
        res = self.val[k]
        k += self.N0
        while k:
            if self.laz[k] != self.ID_M:
                res = self.funcval(res, self.laz[k])
            k //= 2
        return res
    
    # values[k] = x 代入する
    def point_set(self, k): 
        self.thrust(k+self.N0)
        self.val[k] = x

###########################################################################
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
 
n,m = [int(i) for i in readline().split()]
s = input()[::-1]

if n == 1:
    print(1)
    exit()

compose = min
funcval = min
ID_M = INF = 10**18

seg = segment_tree_dual(n, compose, funcval, ID_M)
seg.build([0]+[INF]*(n))

for i in range(n):
    if s[i] == "1": seg.val[i] = -1
    else:
        v = seg.point_get(i)
        #print(v,i)
        seg.update(i+1,min(n,i+m),v+1)
        #print(seg.laz)

seg.propagate_all()
#print(s)
#print(seg.val)

val = seg.val
if val[-1] == -1 or val[-1] == INF:
    print(-1)
    exit()

ans = []

now = n
time = val[-1]
while now:
    n2 = now-1
    time -= 1
    while s[n2] == "1" or val[n2] != time:
        n2 -= 1
    ans.append(now-n2)
    now = n2
    
print(*ans)    
    
    
    












Measured memory_bytes: 56412
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>

using namespace std;

int main(){
	int N;
	double d[505], x[505]={0.0}, ans=0.0;
	
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> d[i];
		x[i] = d[i];
		for(int j=0; j<i; j++){
			double h = abs( d[i]-d[j] );
			double r = d[i] + d[j];
			double w = sqrt( r*r - h*h );
			x[i] = max(x[i], x[j]+w);
		}
		ans = max(ans, x[i] + d[i]);
	}
	printf("%0.6f\n", ans);

	return 0;
}

Measured memory_bytes: 1252
#include<cstdio>
#include<algorithm>
int main() {
	int a[3], k;
	scanf("%d%d%d%d", &a[0], &a[1], &a[2], &k);
	std::sort(a, a + 3);
	printf("%d", a[0] + a[1] + (a[2] << k));
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int c[1000006];
vector<int> V;
set<int> S;
multiset<int> T;

int N, A[200005];

int dp[200005];

int num[1000006];

int main(void) {
	cin >> N;
	int Am = 0;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		V.push_back(A[i]);
		S.insert(A[i]);
		T.insert(A[i]);
		Am = max(Am, A[i]);
		num[A[i]]++;
	}

	//sort(V.begin(), V.end());

	

	for(auto y: V){
		if (c[y] >= 1) { c[y] = 2; }
		else if (c[y] >= 0) { c[y]++;
		for (long long int j = y*2; j <= Am; j+=y) {
			c[(int) j] = -1;
		}
		}
	}

	for (int i = 1; i <= N;i++) {
		T.count(A[i]);
	}

	int ans = 0;

	for (int i = 1; i <= N; i++) {
		//if (T.count(A[i]) >= 2) { continue; }
		if (c[A[i]] == 1) { ans++; }
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 30352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 1;
const ll mo = 1000000007;
vector<ll> factorial(ll n){
  vector<ll> fac;
  fac.push_back(1);
  for(ll i = 1; i < n; i++){
      fac.push_back((fac[i-1]*i)%mo);
  }
  return fac;
}
int main()
{
ll n ;
string  s ;
cin >> n >> s ;
bool a[2*n]={};
if(!(s[0]=='B'&&s[2*n-1]=='B')){
  cout << 0 << endl;
  return 0;
}
ll aa=0;
rep(i,n*2){
  if(i%2==1&&s[i]=='B'){a[i]=1;aa++;}
  if(i%2==0&&s[i]=='W'){a[i]=1;aa++;}
}
if(aa!=n){
  cout << 0 << endl;
  return 0;
}

ll te=0;
rep(i,2*n){
  if(a[2*n-1-i]==1)te++;
  else{
    ans*=te;
    te--;
    ans%=mo;
  }
}
vector<ll> fac=factorial(100100);
ans*=fac[n];
ans%=mo;
cout << ans << endl;
return 0;
}


Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int A,B,C,K;
int ans=0;

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


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline int rd() {
	char ch=getchar(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=getchar();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=getchar();}
	return i*f; 
}
const int N=1e5+50;
int n,l[N],r[N];
LL ans,tl,tr,lq,rq;
priority_queue < LL,vector<LL>,less<LL> > L; 
priority_queue < LL,vector<LL>,greater<LL> > R;
int main() {
	n=rd();
	for(int i=1;i<=n;i++) l[i]=rd(), r[i]=rd(), l[i]=r[i]-l[i];
	L.push(r[1]); R.push(r[1]);
	for(int i=2;i<=n;i++) {
		tl-=l[i-1], tr+=l[i];
		lq=L.top()+tl; rq=R.top()+tr;
		if(r[i]>=lq&&r[i]<=rq) L.push(r[i]-tl), R.push(r[i]-tr);
		else if(r[i]>=lq) {
			ans+=r[i]-rq; R.pop(); L.push(rq-tl);
			R.push(r[i]-tr); R.push(r[i]-tr);
		} else {
			ans+=lq-r[i]; L.pop(); R.push(lq-tr);
			L.push(r[i]-tl); L.push(r[i]-tl);
		}
	} cout<<ans;
}

Measured memory_bytes: 2804
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()


int main(){
  ll N,ans=0;
  cin >> N;
  rep(i,N){
    ans+=((N/(i+1))*(N/(i+1)+1)*(i+1))/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
import std.stdio, std.string, std.conv;
import std.algorithm, std.array, std.range;
import std.typecons;
auto solve(string s_){
    immutable N = s_.chomp.to!int();
    auto x = new int[N];
    auto y = new int[N];
    foreach(i;0..N){
        immutable xy=readln.split.map!(to!int).array();
        x[i]=xy[0];
        y[i]=xy[1];
    }
    alias T = Tuple!(int, "c", int, "a", int, "b");
    T[] es; es.reserve(2*(N-1));
    {
        auto xd = iota(N).array().sort!((a,b)=>x[a]<x[b]);
        auto yd = iota(N).array().sort!((a,b)=>y[a]<y[b]);
        foreach(i;1..N){
            immutable x1=xd[i-1], x2=xd[i];
            es ~= T(x[x2]-x[x1],x1,x2);
            immutable y1=yd[i-1], y2=yd[i];
            es ~= T(y[y2]-y[y1],y1,y2);
        }
    }
    es.sort;
    auto p=iota(N).array();
    auto r=new int[N];
    int find(int x){
        if(x==p[x]) return x;
        return p[x]=find(p[x]);
    }
    void unite(int x, int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(r[x]>r[y]) swap(x,y);
        else if(r[x]==r[y]) ++r[y];
        p[x]=y;
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
    int c=0;
    foreach(ref e;es) if(!same(e.a,e.b)){
        unite(e.a,e.b);
        c+=e.c;
    }
    return c;
}
void main(){ for(string s; (s=readln.chomp()).length;) writeln(solve(s)); }

Measured memory_bytes: 8016
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int N; cin >> N;
    vector<double> ps(N);
    REP(i, N) cin >> ps[i];

    // dp[i][m]: i番目までのコインを投げたとき表がちょうどm個出る確率
    vector dp(N, vector(N+1, double()));
    dp[0][0] = 1.0 - ps[0];
    dp[0][1] = ps[0];
    FOR(i, 1, N) REP(m, N+1) {
        dp[i][m] = dp[i-1][m] * (1.0 - ps[i]);
        if (m > 0) dp[i][m] += dp[i-1][m-1] * ps[i];
    }

    double ans = 0;
    FOR(m, N/2+1, N+1) ans += dp[N-1][m];
    cout << fixed << setprecision(15) << ans << '\n';
}


Measured memory_bytes: 73784
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x)
#define printl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;

int main(){
    ll A, B, C, K; cin >> A >> B >> C >> K;
    if(K%2 == 0){
        if(abs(A - B) > pow(10,18)){
            print("unfair");
        }else{
            print(A - B);
        }
    }else{
        if(abs(B - A) > pow(10,18)){
            print("unfair");
        }else{
            print(B - A);
        }
    }
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
    int n;
    cin>>n;
    vector<int> a(n+1);
    rep(i,1,n+1)cin>>a[i];
    int ans=0;
    rep(i,1,n+1){
        if(i%2&&a[i]%2)ans++;
    }
    cout<<ans<<endl;
}

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

int main() {
  int N;
  cin >> N;
  float tax = 1.08;
  queue<int> ans;
  for (int i = 0; i <= 50000; i++) {
    int money = i * tax;
    if (money == N) {
      ans.push(i);
      break;
    }
  }
  if (ans.empty()) cout << ":(" << endl;

  while (!ans.empty()) {
    cout << ans.front() << endl;
    ans.pop();
  }

  return 0;
}

Measured memory_bytes: 256
# スペース区切りの整数の入力
a, b = map(int, input().split())

a0 = a
a1 = a-1

b0 = b
b1 = b-1

l = [a0, a1, b0, b1]

l.sort(reverse=True)

#print(l[:2])

ans = l[0]+l[1]

print (ans)


Measured memory_bytes: 3060
// A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{

	long long a, b, c, d, m, x;

	cin >> a >> b >> c >> d;

	x = a * c;
	m = x;

	x = a * d;

	m = max(m, x);

	x = b * c;

	m = max(m, x);

	x = b * d;


	m = max(m, x);

	cout << m << endl;

	return 0;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
// 配列中の重複削除
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong a,b,c,d;
    cin >> a >> b >> c >> d;
    while(1){
        c -= b;
        if(c<=0){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a<=0){
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3608
//#define _CRT_SECURE_NO_WARNINGS
//#include <bits/stdc++.h>
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define int long long

#define PI (3.14159265358979323)
#define MOD (1000000007LL)
#define INF (1LL<<60LL)
#define MAX_N (100001)

using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	double a, b, x, y; cin >> a >> b >> x >> y;
	double ans;
	x += y / 60;
	x = x / 12 * 360;
	y = y / 60 * 360;
	x = x / 180 * PI;
	y = y / 180 * PI;
	ans = sqrt(a * a + b * b - 2 * a * b * cos(x - y));
	cout <<fixed<<setprecision(10)<< ans << endl;
}


Measured memory_bytes: 4244
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cstdint>
using namespace std;

void solve() {
	int n;
	cin >> n;
	int m = 0x7fffffff;
	int c = 0;
	for (int i = 0; i < n; ++i) {
		int pi;
		cin >> pi;
		c +=  pi <= m;
		m = std::min(pi, m);
	}
	cout << c << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct node
{
    int x,y,id;
} a[100005];
bool cmp(node p1,node p2)
{
    if(p1.x==p2.x)
        return p1.y<p2.y;
    else
        return p1.x<p2.x;
}
string ans[100005];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1; i<=m; i++)
        scanf("%d%d",&a[i].x,&a[i].y),a[i].id=i;

    sort(a+1,a+1+m,cmp);
    int p=0,x=a[1].x;

    for(int i=1; i<=m; i++)
    {
        if(x==a[i].x)
            ++p;
        else
            p=1,x=a[i].x;
        string s="";
        int t=a[i].x,l=0;
        while(t)
            s=(char)(t%10+'0')+s,t/=10,l++;
        string k="";
        for(int j=1; j<=6-l; j++)
            k+='0';
        k+=s;
        s="";
        t=p,l=0;
        while(t)
            s=(char)('0'+t%10)+s,t/=10,l++;
        for(int j=1; j<=6-l; j++)
            k+='0';
        k+=s;
        ans[a[i].id]=k;
    }
    for(int i=1; i<=m; i++)
        cout<<ans[i]<<'\n';
}


Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

int app() {
  int a,b,c,k;
  cin>>a>>b>>c>>k;

  int ans=0;

  int a_=min(a,k);
  ans+=a_;
  k-=a_;

  int b_=min(b,k);
  k-=b_;

  int c_=min(c,k);
  ans-=c_;
  k-=c_;

  return ans;
}

int main(){cout<<app()<<endl;return 0;}


Measured memory_bytes: 3636
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string.h>
#include <cmath>

using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<int,int> P;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);++(i))

int h,w;

int fie[2020][2020];
vector<vector<int>> xs(2020,vector<int>(2020,0));
int main(){
	cin >> h >> w;
	rep(i,1,h){
		string s;
		cin >> s;
		rep(j,1,w){
			if(s[j - 1] == '#'){
				fie[i][j] = 1;
			}
		}
	}
	rep(i,1,h - 1)rep(j,1,w - 1){
		int cou = 0;
		rep(dx,0,1)rep(dy,0,1) cou += fie[i + dx][j + dy];
		if(cou != 3 && cou != 1){
			if(i == 1) xs[i][j] = 1;
			else xs[i][j] = xs[i - 1][j] + 1;
		}
	}

	int ans = max(h,w);
	rep(i,1,h - 1){
		stack<P> s;
		rep(j,1,w - 1){
			int lj = j;
			while(!s.empty() && s.top().first > xs[i][j]){
				ans = max(ans , (s.top().first + 1) * (j - s.top().second + 1));
				lj = s.top().second;
				s.pop();
			}
			if(xs[i][j]) s.emplace(xs[i][j],lj);
		}
		while(!s.empty()){
			ans = max(ans, (s.top().first + 1) * (w - s.top().second + 1));
			s.pop();
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 32128
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

const int CMax = 100002;


int n, A[CMax], ats, p = 1, q = 1;

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

    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
        q *= 3;
        if (A[i] % 2 == 0) p *= 2;
    }

    printf("%d\n", q - p);
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#include<fstream>
#define ld long double
#define ull unsigned long long 
#define ll long long 
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define MAXN 100060
using namespace std;

int a[MAXN],n,res;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",a+i);
		
	for(int i=1;i<=n-1;i++)
		if(a[i]==i&&a[i+1]==i+1)
			res++,swap(a[i],a[i+1]);
			
	for(int i=1;i<=n;i++)
		if(a[i]==i)res++;
		
	printf("%d\n",res);				
				
	
	return 0;	
} 

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int A[2 * M];
  for (int i = 0; i < 2 * M; i++) cin >> A[i];
  
  int ans[N] = {0};
  for (int i = 0; i < 2 * M; i++) {
    for (int j = 1; j <= N; j++) {
      if (A[i] == j) ans[j-1]++;
    }
  }
  for (int i = 0; i < N; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<cctype>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main(){
int box[6];
string Moji ,x;
int ans = 1;
int ans0 = 1;
for(int i = 0; i < 6; i++){
  cin >> box[i];
}
//while(cin >> x){
cin >> Moji;
//cin >> x;
//Moji.push_back('x');

for(int i = 0; i < Moji.size(); i++){

switch(Moji[i]){
            case 'N':{
                ans0 = box[0];
                box[0] = box[1];
                box[1] = box[5];
                box[5] = box[4];
                box[4] = ans0;
                ans = box[0];
                break;
            }
            case 'E':{
                ans0 = box[0];
                box[0] = box[3];
                box[3] = box[5];
                box[5] = box[2];
                box[2] = ans0;
                ans = box[0];
                break;
            }
            case 'W':{
                ans0 = box[0];
                box[0] = box[2];
                box[2] = box[5];
                box[5] = box[3];
                box[3] = ans0;
                ans = box[0];
                break;
            }
            case 'S':{
                ans0 = box[0];
                box[0] = box[4];
                box[4] = box[5];
                box[5] = box[1];
                box[1] = ans0;
                ans = box[0];
                break;
            }
}//switch
}//for
printf("%d\n", ans );
return 0;
}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    int N, K;
    cin >> N >> K;
    ll a[N];
    rep(i, N) cin >> a[i];
    ll sum[N-K+1], mx[N-K+1], ans[N-K+1];
    ll zero = 0, M = 0;
    sum[0] = 0, mx[0] = 0;
    rep(i, N) M += max(zero, a[i]);
    rep(i, K){
        sum[0] += a[i];
        mx[0] += max(zero, a[i]);
    }
    rep(i, N-K){
        sum[i+1] = sum[i] + a[i+K]-a[i];
        mx[i+1] = mx[i] + max(zero,a[i+K]) - max(zero,a[i]);
    }
    ll res = 0;
    rep(i, N-K+1){
        ans[i] = M-mx[i] + max(zero, sum[i]);
        res = max(res, ans[i]);
    }
    cout << res << endl;
}

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

#define lli long long int
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define INF 1000000007
#define endl "\n"

lli n,m;
string a,a2,a3;

int main(){
	cin>>a;
	for(int i=0;i<a.size();i++){
		if(a[i]!=a[a.size()-i-1]) {
			cout<<"No";
			return 0;
		}
	}
	for(int i=0;i<(a.size()-1)/2;i++){
		a2.pb(a[i]);
	}
	for(int i=(a.size()+3)/2-1;i<a.size();i++){
		a3.pb(a[i]);
	}
	for(int i=0;i<a2.size();i++){
		if(a2[i]!=a2[a2.size()-i-1]) {
			cout<<"No";
			return 0;
		}
	}
	for(int i=0;i<a3.size();i++){
		if(a3[i]!=a3[a3.size()-i-1]) {
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 256
#!/usr/bin/env python3

N = int(input())

AB = {} # 締め切り: かかる時間


for i in range(N):
    a, b = map(int, input().split())
    if b in AB: AB[b].append(a)
    else: AB[b] = [a]


time = 0
for s, t in sorted(AB.items(), key=lambda x:x[0]):
    for ti in t:
        time += ti
        if time > s:
            print('No')
            exit()
print('Yes')



Measured memory_bytes: 62736
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <stack>
#include <queue>
typedef long long ll;
using namespace std;

int main(){
  ll i,j,k,n,m;
  cin >> n >> m;
  ll cnt=n*3;
  cout << (cnt+m)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
#define REP3(i,x,n) for(ll i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = 1001001001;
struct Item{
    ll cost;vector<ll>A;
};
Item items[13];
ll C[13][13],G[13][13];

int main(){
    ll N,M,X,a;
   
    cin >> N >> M >> X;
    vector<ll> c(N);
    //vector<ll> sum_rikaido_MAX(M,0)
    ll A[N][M];
    for (ll i = 0; i < N; i++){
        cin >> c[i];
        for (ll j = 0; j < M; j++){
            cin >> A[i][j];
            //sum_rikaido_MAX[j]+=a;
        }
    }
    int ans = INF;
    REP(s,1<<N){
        int cost = 0;
        vector<ll>d(M);
        for(int i = 0;i < N;i++){
            if(s>>i&1){
                cost +=c[i];
                REP(j,M){
                    d[j]+=A[i][j];
                }
            }
        }
        bool ok = true;
        REP(j,M)if(d[j]<X)ok = false;
        if(ok) ans = min(ans,cost);
    }
    if(ans == INF){cout << -1 << endl;}
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <ios>
#include <iomanip>
#include <cmath>
#include <regex>
using namespace std;

int main(){
  int y, m, d;
  scanf("%d/%d/%d", &y, &m, &d);
  if (y==2017) {
    printf("%d/%02d/%02d\n", 2018, m, d);
  } else {
    printf("%d/%02d/%02d\n", y, m, d);
  }
  return 0;
}

Measured memory_bytes: 256