akhauriyash/Code-Regression huggingface dataset:
#define Bobyama
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll W, H, x, y;

int main() {

  cin >> W >> H >> x >> y;

  printf("%.14lf ", (double)W*(double)H/2.0);
  if (2*x == W && 2*y == H) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

}


Measured memory_bytes: 888
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val bList = readLine()!!.split(' ').map(String::toLong)
    val aList = Array(n) { 0L }
    aList[n - 1] = bList.last()
    aList[0] = bList.first()
    (n - 2 downTo 1).forEach {
        aList[it]=Math.min(bList[it],bList[it-1])
    }
    println(aList.sum())
}

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

int main()
{
	char str[15];
	char pass[15];
	scanf("%s", &str);
	
	int len = strlen(str);
	
	for(int i = 0, j = 0; i < len; i++){
		if(str[i] == '0'){
			pass[j] = '0';
			++j;
			pass[j] = '\0';
		}else if(str[i] == '1'){
			pass[j] = '1';
			++j;
			pass[j] = '\0';
		}else{
			if(pass[j-1] != '\0'){
				--j;
				pass[j] = '\0';
			}
		}
	}
	//1
	printf("%s\n", pass);
}

Measured memory_bytes: 1628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main(String args[]) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();
		int i=1;
		while(true){
			int data= Integer.parseInt(reader.readLine());
			if(data==0)
				break;
			
			builder.append("Case ").append(Integer.toString(i++)).append(": ").append(Integer.toString(data)).append("\n");
		}
		System.out.print(builder);
	}
}

Measured memory_bytes: 26756
import java.util.*;

public class Main {
    static int n, s, count;

    static void dfs(int i, int j, int sum) {
        if(j == n && sum == s) {
            count++;
            return;
        }
        else if(j == n || i == 10) return;

        dfs(i + 1, j + 1, sum + i);
        dfs(i + 1, j, sum);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            n = sc.nextInt();
            s = sc.nextInt();
            if(n == 0 && s == 0) break;

            count = 0;
            dfs(0, 0, 0);

            System.out.println(count);
        }
    }
}


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

def f(N,S,A):
    MOD=998244353
    dp=[0]*(S+1)
    dp[0]=pow(2,N,MOD)
    div=pow(2,MOD-2,MOD)
    m=0
    for a in A:
        m+=a
        for i in range(min(m,S),a-1,-1):
            dp[i]=(dp[i]+dp[i-a]*div)%MOD
    return dp[S]

print(f(N,S,A))
    

Measured memory_bytes: 9384
#include <stdio.h>

int main(void){

	int n,m;
	int i,j,k;
	int ans=0;
	
	scanf("%d",&n);
	scanf("%d",&m);
	
	int a[n][m];
	int b[m];
	
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	
	for(i=0;i<m;i++){
		scanf("%d",&b[i]);
	}
	
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			ans=ans+a[i][j]*b[j];
		}
		printf("%d\n",ans);
		ans=0;
	}
	
	return 0;
}

Measured memory_bytes: 2756
N, K = map(int, input().split())
wds = [tuple(map(int, input().split())) for _ in range(N)]

def isOK(mid):
    num = sum([(mid-w)//d+1 if w <= mid else 0 for w, d in wds])
    return num >= K

ng, ok = 0, 2 * 10**18
while abs(ok-ng) > 1:
    mid = (ng+ok) // 2
    if isOK(mid):
        ok = mid
    else:
        ng = mid

print(ok)


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

int main(){
  int a,b,t;
  char s[55];
  cin>>a>>b;
  if(a==b)cout<<a*2;
  else if(a<b)cout<<b*2-1;
  else if(a>b)cout<<a*2-1;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

string s,rev;
int n,z1[500010],z2[500010];
vector<int> v[500010];

inline void Z(int z[],string &x){
	int l=0,r=0;
    for(int i=1;i<n;i++)
    {
        if(i<=r) z[i]=min(z[i-l],r-i);
        while(i+z[i]<n&&x[z[i]]==x[i+z[i]]) z[i]++;
        if(i+z[i]>r)
        {
            l=i;
            r=i+z[i];
        }
    }
}

inline bool ok(int l,int r)
{
	int len=r-l+1;
	if(len==1) return true;
	for(int i=0;i<v[len].size();i++){
		if(l==0&&z1[v[len][i]]>=len-v[len][i]) return false;
		if(r==n-1&&z2[v[len][i]]>=len-v[len][i]) return false;
	}
	return true;
}

signed main()
{
	ios::sync_with_stdio(false);
	cin>>s;n=s.size();
	for(int i=1;i<=n;i++){
		for(int j=2*i;j<=n;j+=i){
			v[j].push_back(i);
		}
	}
	for(int i=s.size()-1;i>=0;i--) rev+=s[i];
	Z(z1,s);
	Z(z2,rev);
	int cnt=0;
	for(int i=0;i<n;i++){
		if(s[i]!=s[0]) cnt++;
	}
	if(cnt==0){
		cout<<n<<endl<<1<<endl;
		return 0;
	}
	if(ok(0,n-1)){
		cout<<1<<endl<<1<<endl;
		return 0;
	}
	int tot=0;
	for(int i=0;i<n-1;i++){
		if(ok(0,i)&&ok(i+1,n-1)) tot++;
	}
	cout<<2<<endl<<tot<<endl;
	return 0;
}

Measured memory_bytes: 61340
#include<iostream>
using namespace std;
long long  num[100003]={0,1,2,3,4,5,6,7,8,9};
int main()
{
	int k;
	cin>>k;
	int p=1,q=9,j=10;
	if(k<=9)
	{
		cout<<num[k]<<endl;
		return 0;
	}
	while(j<=k)
	{
		for(int i=p;i<=q;i++)
		{
			if(num[i]%10>=1)
			{
				num[j++]=num[i]%10-1+num[i]*10;
				//cout<<j-1<<"="<<num[j-1]<<endl;
				if(k==j-1) {
					cout<<num[k]<<endl;
					return 0;
				}
			}
			num[j++]=num[i]%10+num[i]*10;
			//cout<<j-1<<"="<<num[j-1]<<endl;
			if(k==j-1) 
			{
				cout<<num[k]<<endl;
				return 0;
			}
			if(num[i]%10==9) continue;
			num[j++]=num[i]%10+1+num[i]*10;
			//cout<<j-1<<"="<<num[j-1]<<endl;	
			if(k==j-1) 
			{
				cout<<num[k]<<endl;
				return 0;
			}
		}
		p=q+1;
		q=j-1;
	}
	//cout<<num[k]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int MAXN=2e5+100;
int a[110],b[110];
int main(){
	ios;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
	for(int i=1;i<=n-2;i++){
		if(a[i]==b[i]){
			if(a[i+1]==b[i+1] && a[i+2]==b[i+2]){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<'\n';
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long int lli;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli x,y,i,a,flag;
    cin>>x>>y;
    for(i=0;i<=101;i++)
    {
        a=x-i;
        if(a>=0)
        {
            if(i*2+a*4==y)
            {
                flag=0;
                break;
            }
        }
        else
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
        cout<<"No";
    else
        cout<<"Yes";
}

Measured memory_bytes: 3604
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static long process(TestCase testCase) {
        int N = testCase.N;
        List<Integer> A = testCase.A;

        List<Integer> differences = new ArrayList<>();

        for (int i = 0; i < N; ++i) {
            int target = (i + 1);
            final int diff = target - A.get(i);
            differences.add(diff);
        }

        differences.sort(Integer::compareTo);

//        int mid = N / 2;
        int mid = (N - 1) / 2;

        final int midDiff = differences.get(mid);

        return sadness(differences, midDiff);
    }

    private static long sadness(Collection<Integer> differences, int midDiff) {
        return differences.stream()
                .mapToLong(i -> Math.abs(i - midDiff))
                .sum();
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final long result = process(testCase);

        output(result);
    }

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

        int N = sc.nextInt();

        List<Integer> A = new ArrayList<>();
        for (int i = 0; i < N; ++i) {
            A.add(sc.nextInt());
        }

        sc.close();
        return new TestCase(N, A);
    }

    private static void output(long result) {
        System.out.println(result);
    }

    public static class TestCase {
        final int N;
        final List<Integer> A;

        public TestCase(int N, List<Integer> A) {
            this.N = N;
            this.A = A;
        }
    }

}


Measured memory_bytes: 93732
def f_small_products(N, K, MOD=10**9 + 7):
    # 参考: https://atcoder.jp/contests/abc132/submissions/6187073
    sqrt_n = int(N**0.5)

    # num: 0 <= i <= Nについて、N // i の値で同一視できるものの個数が前から格納される
    num = [0 for i in range(2 * sqrt_n + 1)]
    # 1から√N までは、同一視できるものの個数は1つ
    for i in range(1, sqrt_n + 1):
        num[i] = 1
    # √NからN までは、複数の整数が同一視されることがある
    for i in range(1, sqrt_n + 1):
        lo = max(sqrt_n + 1, (N + i + 1) // (i + 1))
        hi = N // i
        num[2 * sqrt_n + 1 - i] = hi - lo + 1

    # dp[n][m]: 最後の整数が m であるような n 個の整数を
    # 並べて条件を満たすようにする場合の数
    dp = [[0 for j in range(2 * sqrt_n + 2)] for i in range(K + 1)]
    dp[0][1] = 1  # 数列の先頭のさらに1個前に1があるとみなす(置き方1通り)
    for i in range(K):
        # 累積和を用いたdpテーブルの更新(imos法)
        for j in range(1, 2 * sqrt_n + 1):
            ways = (dp[i][j] * num[j]) % MOD
            dp[i + 1][1] += ways
            dp[i + 1][2 * sqrt_n + 2 - j] -= ways
        for j in range(1, 2 * sqrt_n + 1):
            dp[i + 1][j] += dp[i + 1][j - 1]

    return sum(a * b for a, b in zip(dp[K], num)) % MOD

N, K = [int(i) for i in input().split()]
print(f_small_products(N, K))

Measured memory_bytes: 121628
from operator import itemgetter

n = int(input())
XL = []
for _ in range(n):
    x, l = map(int, input().split())
    XL.append([x-l, x+l])

XL = sorted(XL, key=itemgetter(1))
i = 1
while i != len(XL):
    if XL[i][0] < XL[i-1][1]:
        XL.pop(i)
    else:
        i += 1

print(len(XL))

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


int main() {
    string S;
    cin >> S;

    int ans = 1000;
    int char_int[30] = {};

    for (char c='a'; c <='z'; c++) {
        int idx = c - 'a';
        int prev = 0, now = 0;

        rep(i, S.size()) {
            if (S[i] == c) {
                now = i;
                char_int[idx] = max(char_int[idx], now - prev);
                prev = now + 1;
            }
        }
        if (prev != 0) char_int[idx] = max(char_int[idx], ((int) S.size()) - prev);
    }

    rep(i, 'z'-'a'+1) {
        if (char_int[i] != 0) ans = min(ans, char_int[i]);
    }

    if (ans == 1000) ans = 0;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
int n,h[100];

int dfs(int l, int r){
  int mi=h[l],ma=h[l];
  for(int i=l;i<=r;i++){
    mi=min(mi,h[i]);
    ma=max(ma,h[i]);
  }
  if(mi==ma){
    for(int i=l;i<=r;i++) h[i]-=mi;
    return mi;
  }
  if(mi>0){
    for(int i=l;i<=r;i++) h[i]-=mi;
    return dfs(l,r)+mi;
  }
  int ll=l,rr=l,ttl=0;
  while(!h[ll]&&ll<n){
    ll++; 
    rr++;
  }
  while(rr<n){
    while(rr+1<n&&h[rr+1]) rr++;
    ttl+=dfs(ll,rr);
    rr++;
    while(!h[rr]&&rr<n) rr++;
    ll=rr;
  }
  return ttl;
}

int main(){
  cin>>n; REP(i,n) cin>>h[i];
  cout<<dfs(0,n-1);
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n,k;
    while (cin >> n >> k) {
        VI A(n);
        FOR(i,0,n)
            cin >> A[i];
        VI dp(k+1);
        FOR(i,0,k+1) if (!dp[i]) {
            FOR(j,0,n) if (i+A[j] <= k)
                dp[i+A[j]] = 1;
        }
        if (dp[k])
            cout << "First" << endl;
        else
            cout << "Second" << endl;
    }
    return 0;
}


Measured memory_bytes: 640
// 'By Anki'

#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define wr(i) cout<<#i<<" = "<<i<<",  ";
#define wre(i) cout<<#i<<"  =  "<<i<<endl;
#define all(v) v.begin(),v.end()
typedef long long ll;
#define lim 1000000007LL
// #define lim 10LL
#define M 1000006
 
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
 
ll fact(ll n)
{
    ll ans=1LL;
    while(n)
    ans*=(n--);
    return ans;

}

ll func(ll val,ll n,ll a,ll b,ll c,vector<ll>v){
    ll ans=0LL;
    if(a+b<=c){
        for(auto x:v){
            if(x>val)ans+=(x-val)*b;
            else ans+=(val-x)*a;
        }
    }
    else
    {
        int i=0,j=n-1;
        while(i<j){
            if(v[i]>val)break;
            if(v[j]<val)break;
            ll tmp=min(val-v[i],v[j]-val);
            v[j]-=tmp;
            v[i]+=tmp;
            ans+=tmp*c;
            if(v[j]==val)j--;
            if(v[i]==val)i++;
        }
        if(v[i]>val){
            for(;i<=j;i++)ans+=(v[i]-val)*b;
        }
        else if(v[j]<val){
            for(;j>=i;j--)ans+=(val-v[j])*a;
        }
    }
    // wr(ans);
    return ans;
}

ll ternary(ll l,ll r, vector<ll>v,ll n, ll a, ll b,ll c){
    while(r-l>2){
        ll m1=l+(r-l)/3;
        ll m2=r-(r-l)/3;
        // wr(m1)wre(m2)
        if(func(m1,n,a,b,c,v)<func(m2,n,a,b,c,v))r=m2;
        else l=m1;
    }
    ll ans=func(l,n,a,b,c,v);
    for(int i=l;i<=r;i++)ans=min(ans,func(i,n,a,b,c,v));
    return ans;
}

int main()
{
fast
ll t=1;
// cin>>t;
while(t--)
{
    ll n;
    cin>>n;
    ll tmp=n%10;
    if(tmp==2||tmp==4||tmp==5||tmp==7||tmp==9)cout<<"hon\n";
    else if(tmp==3)cout<<"bon\n";
    else cout<<"pon\n";
    
}
} 

Measured memory_bytes: 3640
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static boolean is_not_covered(final int n, final int purpos, int[] x_array, int[] y_array, int[] r_array, int bit){	
		for(int j = 0; j < n; j++){
			if((bit & (1 << j)) == 0){
				continue;
			}else if(purpos == j){
				continue;
			}
		
			final int diff_x = (x_array[purpos] - x_array[j]) * (x_array[purpos] - x_array[j]);
			final int diff_y = (y_array[purpos] - y_array[j]) * (y_array[purpos] - y_array[j]);
			final int diff_r = (r_array[purpos] + r_array[j]) * (r_array[purpos] + r_array[j]);
				
			if(diff_x + diff_y < diff_r && purpos > j){
				//System.out.println(purpos + " " + j);
				return false;
			}
		}
		
		//System.out.println("ok");
		
		return true;
	}
	
	public static int dfs(int bit, final int n, int[] x_array, int[] y_array, int[] r_array, int[] c_array, int[] memo){
		if(memo[bit] >= 0){
			return memo[bit];
		}
		
		//System.out.println(Integer.toBinaryString(bit));
		
		int max = 0;
		
		for(int i = 0; i < n; i++){
			if((bit & (1 << i)) == 0){
				continue;
			}
			
			for(int j = i + 1; j < n; j++){
				if((bit & (1 << j)) == 0){
					continue;
				}else if(c_array[i] != c_array[j]){
					continue;
				}else if(is_not_covered(n, i, x_array, y_array, r_array, bit) && is_not_covered(n, j, x_array, y_array, r_array, bit)){
					final int next_bit = (bit & (~(1 << i))) & (~(1 << j));
					
					//System.out.println(bit + " => " + next_bit);
					
					max = Math.max(max, dfs(next_bit, n, x_array, y_array, r_array, c_array, memo) + 2);
				}
			}
		}
		
		return memo[bit] = max;
	}
	
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);

		while (true) {
			final int n = sc.nextInt();
			
			System.gc();
			
			if(n == 0){
				break;
			}
			
			int[] x_array = new int[n];
			int[] y_array = new int[n];
			int[] r_array = new int[n];
			int[] c_array = new int[n];
			
			for(int i = 0; i < n; i++){
				x_array[i] = sc.nextInt();
				y_array[i] = sc.nextInt();
				r_array[i] = sc.nextInt();
				c_array[i] = sc.nextInt();
			}
			
			int[] memo = new int[1 << n];
			Arrays.fill(memo, -1);
			
			System.out.println(dfs((1 << n) - 1, n, x_array, y_array, r_array, c_array, memo));
		}
	}

}

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

int main(void){
    string st;
    int q;
    cin>>st>>q;
    string order;
    int r,l;
    string print,rev,rep;
    for(int i=0;i<q;i++){
        cin>>order>>r>>l;
        if(order=="print"){
            print=st.substr(r,l-r+1);
            cout<<print<<endl;
        }
        else if(order=="reverse"){
            rev=st.substr(r,l-r+1);
            for(int j=0;j<l-r+1;j++){
                st.at(r+j)=rev.at(l-r-j);
            }
        }
        else if(order=="replace"){
            cin>>rep;
            st=st.substr(0,r)+rep+st.substr(l+1,st.size()-l-1);
        }
    }
}



Measured memory_bytes: 3232
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;
using lint = int64_t;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
#define All(vec) vec.begin(), vec.end()

constexpr lint mod = 998'244'353LL;
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& rhs) { return is >> rhs.first >> rhs.second; }
template<class InputIterator> void arrin(InputIterator first, InputIterator last) { for (; first != last; ++first) cin >> (*first); }

void coordinate_compression(vector<P>& vec) {
	int m = vec.size();
	vector<lint>x(m), y(m);
	rep(i, m) x[i] = vec[i].first, y[i] = vec[i].second;
	sort(All(x)); sort(All(y));
	rep(i, m) {
		lint a = lower_bound(All(x), vec[i].first) - x.begin();
		lint b = lower_bound(All(y), vec[i].second) - y.begin();
		vec[i] = make_pair(a, b);
	}
	sort(All(vec));
}

template<class T>
class binary_indexed_tree {
private:

	int m_size;
	vector<T>m_vec;

public:

	binary_indexed_tree(int size)
		:m_size(size)
	{
		m_vec.resize(m_size);
	}

	void add(int a, const T& w) { for (int x = a; x <= m_size; x += (x & -x)) m_vec[x] += w; }

	T sum(int a) const {
		T res{};
		for (int x = a; x > 0; x -= (x & -x)) res += m_vec[x];
		return res;
	}

};

int n, mem[2 * 100010][4];
lint ans, pow2[2 * 100010];
int main() {

	cin >> n;

	pow2[0] = 1;
	rep1(i, n + 1) {
		pow2[i] = pow2[i - 1] * 2 % mod;
	}

	vector<P>v(n);
	arrin(All(v));

	coordinate_compression(v);

	rep(t, 2) {
		binary_indexed_tree<int>bit(n + 10);
		rep(i, n) {
			int y = v[i].second;
			int a = bit.sum(y), b = i - bit.sum(y + 1);
			if (t == 0) {
				mem[i][0] = a;
				mem[i][1] = b;
			}
			else {
				mem[n - i - 1][2] = a;
				mem[n - i - 1][3] = b;
			}
			bit.add(y + 1, 1);
		}
		if (t == 0) reverse(All(v));
	}
	rep(i, n) {
		lint a = (pow2[mem[i][0]] + pow2[mem[i][3]] - 1) % mod;
		lint b = (pow2[mem[i][1]] + pow2[mem[i][2]] - 1) % mod;
		lint add = (pow2[n] - a * b) % mod;
		if (add < 0) add += mod;
		ans = (ans + add) % mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 10144
#include<algorithm>
#include<vector>
#include<stack>
#include<deque>
#include<iostream>
#include<cstdio>
#define F first
#define S second
#define LIM 1000000010
#define pb push_back
#define all(n) n.begin(),n.end()
using namespace std;
typedef pair<int,int> P;
int dp[5002][5002];
int main(){
  int n,m;
 
  vector<int> X,Y;
  
  while(cin >> n >> m){
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)dp[j][i] = 0;
    for(int i=0;i<n;i++){
      int x,y;
      cin >> x >> y;
      X.pb(x); Y.pb(y);
    }
    vector<int> x,y;
    x = X;
    y = Y;
    X.pb(-LIM); X.pb(LIM); Y.pb(-LIM); Y.pb(LIM);
    sort(all(X)); sort(all(Y));
    X.erase(unique(all(X)),X.end());
    Y.erase(unique(all(Y)),Y.end());
    for(int i=0;i<n;i++){
      x[i] = find(all(X),x[i])-X.begin();
      y[i] = find(all(Y),y[i])-Y.begin();
      dp[y[i]][x[i]]++;
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	dp[i+1][j+1] += dp[i+1][j]+dp[i][j+1]-dp[i][j];

      }

    }
    for(int i=0;i<m;i++){
      int sx,sy,gx,gy;
      cin >> sx >> sy >> gx >> gy;
      sx = lower_bound(all(X),sx)-X.begin();
      sy = lower_bound(all(Y),sy)-Y.begin();
      gx = upper_bound(all(X),gx)-X.begin()-1;
      gy = upper_bound(all(Y),gy)-Y.begin()-1;
      cout << dp[gy][gx]-dp[gy][sx-1]-dp[sy-1][gx]+dp[sy-1][sx-1] << endl;

    }



  }
  return 0;
}

Measured memory_bytes: 99036
#ifdef __GNUC__
#include <bits/stdc++.h>
#else
#include "bits/stdc++.h"
#define scanf scanf_s
#endif
#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define WHL(i) while(i)
#define putn printf("\n")
using namespace std;


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

	if (!(tmp % 2)) {
		printf ("%d\n", tmp);
	}
	else {
		printf ("%d\n", tmp * 2);
	}
}



Measured memory_bytes: 256
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, K = getlist()
	A = getlist()
	if K == 0:
		print(sum(A))
		sys.exit()	
	dp = [0] * 41
	j = 0
	while True:
		if K % 2 == 1:
			dp[-1 - j] = 1
		K = K // 2
		if K == 0:
			break
		j += 1
	#print(dp)

	p1 = [0] * 41
	p0 = [N] * 41
	for i in range(N):
		a = A[i]
		j = 0
		while True:
			if a % 2 == 1:
				p1[-1 - j] += 1
			a = a // 2
			if a == 0:
				break
			j += 1
	for i in range(41):
		p0[i] -= p1[i]
	#print(p1)
	#print(p0)

	#DP
	DP0 = [0] * 41
	DP1 = [0] * 41
	s = dp.index(1)
	DP0[0] = (2 ** 40) * p1[0]
	DP1[0] = (2 ** 40) * p1[0]
	for i in range(1, s):
		DP0[i] += DP0[i - 1] + (2 ** (40 - i)) * p1[i]
		DP1[i] += DP1[i - 1] + (2 ** (40 - i)) * p1[i]
	if s != 0:
		DP0[s] = DP0[s - 1] + (2 ** (40 - s)) * p0[s]
		DP1[s] = DP1[s - 1] + (2 ** (40 - s)) * p1[s]
	else:
		DP0[s] = (2 ** (40 - s)) * p0[s]
		DP1[s] = (2 ** (40 - s)) * p1[s]
	for i in range(s + 1, 41):
		if dp[i] == 1:
			DP0[i] = DP0[i - 1] + (2 ** (40 - i)) * p0[i]
			DP1[i] = max(DP1[i - 1] + (2 ** (40 - i)) * max(p0[i], p1[i]), DP0[i - 1] + (2 ** (40 - i)) * p1[i])
		else:
			DP0[i] = DP0[i - 1] + (2 ** (40 - i)) * p1[i]
			DP1[i] = DP1[i - 1] + (2 ** (40 - i)) * max(p0[i], p1[i])
	# print(DP0)
	# print(DP1)
	print(max(DP0[-1], DP1[-1]))

if __name__ == '__main__':
	main()

Measured memory_bytes: 61168
#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 main(void){
	string s;
	ll a[100001]={},b=-1,c=-1;
	cin>>s;
	rep(i,26){
		if(s.size()==2){
			if(s[0]==s[1]){
				b=1;
				c=2;
				break;
			}
		}else{
			a[0]=0;
			// cout<<char('a'+i)<<endl;
			rep(j,s.size()){
				if(s[j]==char('a'+i)){
					a[j+1]=a[j]+1;
				}else{
					a[j+1]=a[j];
				}
			}
			rep(j,s.size()-2){
				if(a[j+3]-a[j]>=2){
					b=j+1;
					c=j+3;
					break;
				}
			}
		}
		if(c!=-1)break;
	}
	cout<<b<<" "<<c<<endl;
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll R, G;
    cin >> R >> G;

    cout << G * 2 - R << endl;

}

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

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll>p(n),c(n);
    rep(i,n){
        cin>>p[i];
        p[i]--;
    }
    rep(i,n)cin>>c[i];
    vector<ll>t(n);
    ll ans=-LONG_LONG_MAX;
    //周期調べる、1周目全探索
    rep(i,n){
        vector<bool>seen(n,false);
        ll now=i,T=0;
        ll cnt=0;
        while(1){
            now=p[now];
            if(seen[now])break;
            T++;
            cnt+=c[now];
            seen[now]=true;
            if(T<=k)ans=max(ans,cnt);
        }
        t[i]=T;
    }
    //最後の周期全探索(1回前から)
    rep(i,n){
        //周期する回数
        ll z=(k/t[i])-1;
        //1周目で終わるならcontinue
        if(z==-1)continue;
        vector<bool>seen(n,false);
        ll now=i;
        ll cnt=0;
        while(1){
            now=p[now];
            if(seen[now])break;
            cnt+=c[now]*z;
            seen[now]=true;
        }
        //最終周期(1回前から)
        now=i;
        ll modcnt=(k%t[i])+t[i];
        while(1){
            now=p[now];
            if(modcnt==0)break;
            modcnt--;
            cnt+=c[now];
            ans=max(ans,cnt);
        }
    }
    cout<<ans<<endl;
}

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

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


#define F first
#define S second
#define pob pop_back
#define pb push_back
#define Time()	cerr << clock() * 1000 / CLOCKS_PER_SEC << "ms\n"
#define show(x)	cerr << #x << " = " << (x) << '\n'
#define inf 1e14
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define invec(v) for(auto& x : v)cin>>x;
#define Test int T;cin>>T;while(T--)
#define vec vector<ll> 
#define REP(i,j,k) for(int i=(j);(i)<(k);(i)++)

int main(){
	
	int a,b,c;
	cin>>a>>b>>c;
	swap(a,b);swap(a,c);
	cout<<a<<" "<<b<<" "<<c;
	

}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int tanka,kosu,i,j,k;
	double ave;
	tanka=kosu=k=0;
	while(scanf("%d,%d",&i,&j)!=EOF){
       tanka+=i*j;
	   kosu+=j;
	   k++;
	}
	ave=(kosu*1.0/k +0.5);
	printf("%d\n",tanka);
	printf("%d\n",(int)ave);
	return 0;
}

Measured memory_bytes: 1020
n = int(input())
arr = list(map(int, input().split()))
zetArr = list(map(abs, arr))
minusNum = 0
minZ = min(zetArr)
for e in arr:
    if e < 0:
        minusNum += 1

if minusNum % 2 == 0:
    print(sum(zetArr))
else:
    print(sum(zetArr) - 2 * minZ)


Measured memory_bytes: 14332
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,M;
  cin>>A>>B>>M;
  vector<int>a(A),b(B);
  for(int i=0;i<A;i++)cin>>a[i];
  for(int i=0;i<B;i++)cin>>b[i];
  int ans=*min_element(a.begin(),a.end())+*min_element(b.begin(),b.end());
  int x,y,c;
  while(M--){
    cin>>x>>y>>c;
    x--;y--;
    ans=min(ans,a[x]+b[y]-c);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define umii            unordered_map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define rep(i,st,end)   for(int i=st;i<end;i++)
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void s_g_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	s_g_c();
	int n;
	cin >> n;
	int a[200005];
	vector<int> freq(1000005,0);
	int max = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		freq[a[i]]++;
		if (max < a[i])
			max = a[i];
	}
	bool b[1000005];
	memset(b, false, sizeof(b));
	int count = 0;
	for (int i = 0; i <= 1000000; i++)
	{
		if (freq[i] == 0 || b[i])
			continue;
		if (freq[i] == 1 && !b[i])
			count++;
		for (int j = i; j <= 1000000 ; j += i)
		    b[j] = true;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 13472
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
   ll m,n ;cin>>m>>n ;
   map<ll,ll> ord;  //素因数とオーダーをマップで管理
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            ll res=0;
            while(n%i==0){
                n/=i;
                res++;
            }
            ord[i]=res;
        }
    }
if(n!=1) ord[n]++;
  ll ans=1 ;
  for(auto p :ord){
    ans*=pow(p.first,(p.second/m)) ;
  } 
  cout<<ans<<endl ;
  return 0;
}

Measured memory_bytes: 512
#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>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, a, b;
	cin>>n>>a>>b;
	string s;
	cin>>s;
	int ct=0, ct2=0;
	for(int i=0; i<n; i++){
		if(s[i]=='c'){
			cout<<"No"<<endl;
			continue;
		}
		if(s[i]=='a'){
			if(ct<a+b){
				cout<<"Yes"<<endl;
				ct++;
			}else{
				cout<<"No"<<endl;
			}
		}else{
			if(ct<a+b && ct2<b){
				cout<<"Yes"<<endl;
				ct++;
				ct2++;
			}else{
				cout<<"No"<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1280
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
	int n, m, c;
	cin >> n >> m >> c;
	if(n <= c && c <= m) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


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

using namespace std;

#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair

int n, m;
char c[55][55];
bool used[55][55];
int white, black;
int x[] = {-1, 1, 0, 0};
int y[] = {0, 0, 1, -1};
int d[55][55];

bool check (int i, int j) {
	return i >= 1 && j >= 1 && i <= n && j <= m && c[i][j] == '.';
}

void bfs() {       
	queue < pii > q;
	q.push(mk(1, 1));
	d[1][1] = 1;
	while (!q.empty()) {
		pii v = q.front();
		q.pop();
		if (v.fr == n && v.sc == m) {
			continue;
		}
		for (int i = 0; i < 4; i++) {
			int xto = v.fr + x[i];
			int yto = v.sc + y[i];
			if (check(xto, yto) && d[v.fr][v.sc] + 1 < d[xto][yto]) {
				d[xto][yto] = d[v.fr][v.sc] + 1;
				q.push(mk(xto, yto));
			}
		}
	}
}

main() {         
	scanf("%d %d", &n, &m);	
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> c[i][j];
			if (c[i][j] == '.') {
				white++;
			}
			d[i][j] = 1e9;
		}
	}
	bfs();
	if (d[n][m] != (int)1e9) {
		cout << white - d[n][m];
	} else {
		puts("-1");
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	int years = scan.nextInt();
      	int money = scan.nextInt();
      	if(years >= 13){
        	System.out.print(money);
        }
      else if(years >= 6){
      		System.out.print(money / 2);
      }
      else if(years >= 0){
      		System.out.print(0);
      }
    }

}

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

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;
int f[4000 * 4000];

void prework(){

}

void read(){

}

void solve(int casi){
//	cout << "Case #" << casi << ": ";
	ll n;
	cin >> n;
	for (ll a = 1; a <= 3500; a++)
		for (ll b = 1; b <= 3500; b++){
			ll p = n * a * b;
			ll q = 4 * a * b - n * (a + b);
			if (q > 0 && p % q == 0){
				cout << a << ' ' << b << ' ' << p / q << endl;
				return ;
			}
		}
}

void printans(){

}


int main(){
	std::ios::sync_with_stdio(false);
	prework();
	int T = 1;
//	cin>>T;
	for(int i = 1; i <= T; i++){
		read();
		solve(i);
		printans();
	}
	return 0;
}

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

using namespace std;

int main()
{
    vector<int> H, W;
    for(;;){
        int h, w;
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        H.push_back(h);
        W.push_back(w);
    }
    
    for(int i = 0; i < H.size(); i++){
        for(int h = 0; h < H.at(i); h++){
            for(int w = 0; w < W.at(i); w++){
                if(h % 2 == 0){
                    if(w % 2 == 0) cout << "#";
                    else cout << ".";
                }else{
                    if(w % 2 == 0) cout << ".";
                    else cout << "#";
                }
            }
            cout << endl;
        }
        cout << endl;
    }

}


Measured memory_bytes: 3124
def getsum(bit, i):

    s = 0
    i = i + 1

    while i > 0:

        s += bit[i]

        i -= i & (-i)
    return s

def interval_sum(bit, a, b):
    if a == 0:
        return getsum(bit, b)
    else:
        return getsum(bit, b) - getsum(bit, a - 1)

def updatebit(bit , n , i ,v):

    i += 1

    while i <= n:

        bit[i] += v

        i += i & (-i)


def construct(arr, n):

    bit = [0]*(n+1)

    for i in range(n):
        updatebit(bit, n, i, arr[i])

    return bit


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

intervals = []
for _ in range(k):
    a, b = map(int, input().split())
    intervals.append((a, b))
intervals.sort()


data = [0] * n
data[0] = 1
bit = construct(data, n)

mod = 998244353

for i in range(1, n):
    cnt = 0
    for a, b in intervals:
        if i - a < 0:
            break
        cnt += interval_sum(bit, max(i - b, 0), max(i - a, 0))
    cnt %= mod
    updatebit(bit, n, i, cnt)

print(interval_sum(bit, n - 1, n - 1) % mod)


Measured memory_bytes: 76944
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    ll h, w;
    cin >> h >> w;
    ll ans = min((h % 3 != 0) * w, (w % 3 != 0) * h);
    for (ll i = 1; i <= h - 1; ++i) {
        ll s = i * w;
        ll t = (h - i) * (w / 2);
        ll u = (h - i) * ((w + 1) / 2);
        ans = min(max({s, t, u}) - min({s, t, u}), ans);
    }

    for (ll i = 1; i <= w - 1; ++i) {
        ll s = i * h;
        ll t = (w - i) * (h / 2);
        ll u = (w - i) * ((h + 1) / 2);
        ans = min(max({s, t, u}) - min({s, t, u}), ans);
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int H,W;
  cin >> H >> W;
  vector<string> A(H);
  REP(i, H) cin >> A[i];
  vector<vector<int>> ans(H,vector<int> (W,0));
  REP(i,H){
    vector<int> X;
    int cnt = 0;
    REP(j,W){
      if(A.at(i).at(j)=='.'){
        cnt++;
      }else{
        X.push_back(cnt);
        cnt=0;
      }
    }
    X.push_back(cnt);
    int cnt2 = 0;
    REP(j,W){
      if(A.at(i).at(j)=='#'){
        cnt2++;
      }else{
        ans.at(i).at(j)+=X.at(cnt2);
      }
    }
  }
  REP(i,W){
    vector<int> X;
    int cnt = 0;
    REP(j,H){
      if(A.at(j).at(i)=='.'){
        cnt++;
      }else{
        X.push_back(cnt);
        cnt=0;
      }
    }
    X.push_back(cnt);
    int cnt2 = 0;
    REP(j,H){
      if(A.at(j).at(i)=='#'){
        cnt2++;
      }else{
        ans.at(j).at(i)+=X.at(cnt2);
      }
    }
  }

  int MAX=0;
  REP(i,H){
    REP(j,W){
      MAX=max(MAX,ans.at(i).at(j));
    }
  }

  cout << MAX-1 << endl;
}

Measured memory_bytes: 20096
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<functional>
#include<cstring>

using namespace std;

int main()
{
	//freopen("input.txt", "r", stdin);

	int n;

	scanf("%d", &n);

	printf("%d\n", !n);

	return 0;
}

Measured memory_bytes: 1736
//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

struct Dijkstra {
    struct Edge {
        ll to;
        ll c;
    };

    int V;
    vector<vector<Edge>> e;
    vector<ll> d;

    Dijkstra(int V): V(V) {
        e.resize(V);
        d.resize(V);
    }

    void add_edge(int from, int to, ll cost) {
        e[from].pb({to, cost});
    }

    ll query(ll dest) {
        return d[dest];
    }

    void operator()(ll s) {
        priority_queue<Pll, vector<Pll>, greater<>> q;

        REP(i, V) d[i] = INF;
        d[s] = 0;
        q.push({0, s});

        while(!q.empty()) {
            Pll n = q.top(); q.pop();
            ll v = n.se;
            if (d[v] < n.fi) continue;

            REP(i, e[v].size()) {
                Edge cur = e[v][i];
                ll cost = d[v] + cur.c;
                if (d[cur.to] > cost) {
                    d[cur.to] = cost;
                    q.push({cost, cur.to});
                }
            }
        }
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    --s; --t;

    Dijkstra gy(n), gs(n);

    REP(i, m) {
        int u, v; ll a, b;
        cin >> u >> v >> a >> b;
        u--; v--;

        gy.add_edge(u, v, a);
        gy.add_edge(v, u, a);
        gs.add_edge(u, v, b);
        gs.add_edge(v, u, b);
    }

    gy(s);
    gs(t);

    ll hajime = 1e15;
    vector<ll> ans(n);
    ll cur = gy.query(n - 1) + gs.query(n - 1);
    ans[n - 1] = hajime - cur;
    REVREP(i, n - 1) {
        cur = min(cur, gy.query(i) + gs.query(i));
        ans[i] = hajime - cur;
    }

    REP(i, n) print(ans[i]);
}


Measured memory_bytes: 21148
#include <iostream>
#include <math.h>
#include <string>


using namespace std;

int main(){
	long long int H;
	long long int W;
	long long int s;
	long long int count = 0;
 
	cin >> H;
	cin >> W;
 
	s = H * W;
	if (s % 2 == 1) {
		s = s + 1;
	}
 	if(W == 1||H == 1){
      	count = 1;
    }else{
		count = s / 2;
    }
 
	cout << count;
 
	return 0;
}

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

double dist(vector<int> x,vector<int> y){
  double res=0;
  for(int i=0;i<x.size();i++){
    res += (x[i]-y[i])*(x[i]-y[i]);
  }
  return sqrt(res);
}

bool isD(double x){
  return abs(x-int(x))<=1e-9;
}

int main(){
  int n,d; cin >> n >> d;
  vector<vector<int>> X(n,vector<int>(d,0));
  int ans=0;
  for(int i=0;i<n;i++) for(int j=0;j<d;j++) cin >> X[i][j];
  for(int i=0;i<n-1;i++) for(int j=i+1;j<n;j++) if(isD(dist(X[i],X[j]))) ans++;
  cout << ans << endl;
}

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


int main(){
  int n;
  cin >> n;
  vector<int> score;
  int ans = 0;
  int ten = 0;
  rep(i, n) {
    int x;
    cin >> x;
    score.push_back(x);
    ans += score[i];
    if(score[i] %10 == 0) ten++;
  }

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

  
  int count = 0;
  int f = 0;
  if (ten == n){
    f = 1;
    ans = 0;
  
  }
  
  else{
  while(f == 0 && count < n){
    if(ans % 10 != 0){
      f = 1;
    }
    else{
      if (score[count]%10 != 0){
      ans -= score[count];
      count++;
      }
      else{
      count++ ;
    }
    }
  }
}

  cout << ans << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INTINF = 1<<30;
const int MOD = 1000000007;

void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N,M;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    vector<ll> a[3];
    rep(i,N){
      rep(j,3){
        ll num; cin >> num;
        a[j].push_back(num);
      }
    }
    ll ans = 0;
    for(int bit = 0; bit < (1 << 3); ++bit){
      vector<ll> b;
      rep(i,N){
        ll tmp = 0;
        rep(j,3){
          if(bit & (1 << j)) tmp += a[j][i];
          else tmp -= a[j][i];
        }
        b.push_back(tmp);
      }
      sort(all(b), greater<ll>());
      ll sum = 0;
      rep(i,M) sum += b[i];
      chmax(ans,sum);
    }
    cout << ans << endl;
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<pi> vpi;
typedef vector<bool> vbool;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define forall(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define F0(i,n) for(ll i = 0; i < n; i++)
#define F1(i,n) for(ll i = 1; i <= n; i++)
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define per(i,a,b) for(int i = b-1; i >= a; i--)
#define FIN ios::sync_with_stdio(false);cin.tie(0);
#define db(x) cout<<#x<<" = "<<x<<"\n"
#define all(v) v.begin(),v.end()
#define modulo(a,b) ((a%b)+b)%b
#define F first
#define S second
#define INF 1000000010
#define INFLL 1000000000000000000
#define eps 0.000000000001
#define mod 1000000007
template<class C> void mini(C&a, C b){ a=min(a, b);}
template<class C> void maxi(C&a, C b){a=max(a,b);}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

//=======================//
const int maxn = 3002;
ll dp[maxn][maxn];
bool visited[maxn][maxn];
int n;
vll a;

ll hacerDP(int i, int j, int turno) {
	//Turno=0 : quiero maximizar. Turno=1 : quiero minimizar.
	if (i > j) return 0;
	if (visited[i][j]) return dp[i][j];
	ll r1 = hacerDP(i+1, j, 1-turno);
	ll r2 = hacerDP(i, j-1, 1-turno);
	if (turno==0) {r1+=a[i]; r2+=a[j]; dp[i][j] = max(r1,r2);}
	else {r1-=a[i]; r2-=a[j]; dp[i][j] = min(r1, r2);}
	visited[i][j] = true;
	return dp[i][j];
}

int main () {
	//FIN

	cin >> n;
	a = vll(n);
	F0(i,n) cin >>a[i];
	F0(i,n) F0(j,n) visited[i][j] = false;
	cout << hacerDP(0,n-1,0) << "\n";


	return 0;
}










Measured memory_bytes: 58568
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	N, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	scanner.Scan()
	R, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	if N >= 10 {
		fmt.Println(R)
	} else {
		fmt.Println(R + (100 * (10 - N)))
	}
}


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

typedef long long ll;

int main(void)
{
    int i;
    string s1, s2;
    cin >> s1 >> s2;

    int cnt = 0;
    for(i = 0; i < s1.size(); i++)
    {
        if(s1[i] != s2[i])
            cnt++;
    }
    cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 3916