akhauriyash/Code-Regression huggingface dataset:
def f_single_dot():
    # https://atcoder.jp/contests/abc168/submissions/13368489
    import sys
    from collections import deque
    input = sys.stdin.readline
    N, M = [int(i) for i in input().split()]

    X, Y = set([0]), set([0])
    vertical_lines = []
    for _ in range(N):
        a, b, grid = map(int, input().split())
        vertical_lines.append((a, b, grid))
        X |= {a, b}
        Y |= {grid}
    horizontal_lines = []
    for _ in range(M):
        d, e, f = map(int, input().split())
        horizontal_lines.append((d, e, f))
        X |= {d}
        Y |= {e, f}
    X = sorted(X)
    Y = sorted(Y)
    dictx, dicty = {n: i * 2 for i, n in enumerate(X)}, {n: i * 2 for i, n in enumerate(Y)}
    LX = [X[i // 2 + 1] - X[i // 2] if i % 2 else 0 for i in range(len(X) * 2 - 1)]
    LY = [Y[i // 2 + 1] - Y[i // 2] if i % 2 else 0 for i in range(len(Y) * 2 - 1)]
    grid = [[0] * (len(X) * 2 - 1) for _ in range(len(Y) * 2 - 1)]
    for a, b, c in vertical_lines:
        a, b, c = dictx[a], dictx[b], dicty[c]
        for x in range(a, b + 1):
            grid[c][x] = 1
    for d, e, f in horizontal_lines:
        d, e, f = dictx[d], dicty[e], dicty[f]
        for y in range(e, f + 1):
            grid[y][d] = 1
    que = deque()
    used = [[0] * len(X) * 2 for _ in range(len(Y) * 2)]
    dy = [1, 1, -1, -1]
    dx = [1, -1, 1, -1]
    for k in range(4):
        nny, nnx = dicty[0] + dy[k], dictx[0] + dx[k]
        if 1 <= nny < len(Y) * 2 - 1 and 1 <= nnx < len(X) * 2 - 1:
            que.append((nny, nnx))
            used[nny][nnx] = 1
    ans = 0
    dy = [1, 0, -1, 0]
    dx = [0, 1, 0, -1]
    while que:
        y, x = que.popleft()
        if y % 2 and x % 2:
            ans += LY[y] * LX[x]
        for k in range(4):
            ny, nx = y + dy[k], x + dx[k]
            nny, nnx = ny + dy[k], nx + dx[k]
            if grid[ny][nx] == 0:
                if nny < 0 or nny >= len(Y) * 2 - 1 or nnx < 0 or nnx >= len(X) * 2 - 1:
                    return 'INF'
                if not used[nny][nnx]:
                    que.append((nny, nnx))
                    used[nny][nnx] = 1
    return ans

print(f_single_dot())

Measured memory_bytes: 713656
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	double ans = 0, x;
	string u;
	
	cin>>N;
	
	for(int i = 0; i < N; i++){
		cin>>x>>u;
		
		if(u == "JPY") ans += x;
		else ans += 380000.0*x;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
import numpy as np
#https://yottagin.com/?p=1650

N,K=map(int,input().split())
h=list(map(int,input().split()))

#dp=[float("inf")]*N
#dp[0]=0
#dp=[0]
dp=np.zeros(N,dtype=int)
h=np.array(h)

for i in range(1,N):
  start=max(0,i-K)
  #start~i-1
  dp[i]=min(dp[start:i]+np.abs(h[i]-h[start:i]))
  #tmp=float("inf")
  #for k in range(1,K+1):
    #if i-k<0: break
    #dp[i]=min(dp[i],dp[i-k]+abs(h[i]-h[i-k]))
    #tmp=min(tmp,dp[i-k]+abs(h[i]-h[i-k]))
  #dp[i]=tmp
  #dp+=[tmp]

print(dp[N-1])

Measured memory_bytes: 22808
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n);(i)>=0;(i)--)
typedef long long lint;

int main(){
   int N,ans;
   string s;
    cin >>s;
   if(s=="Sunny") cout<<"Cloudy";
else if(s=="Cloudy")cout <<"Rainy";
else cout <<"Sunny";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#define int long long
using namespace std;
signed main(){
    string s;
    cin>>s;
    int n=s.size();
    int count=0;
    for(int i=0;i<n;i++){
        if(s[i]=='o')count++;
    }
    if(count+15-n>=8)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;

ll mpow(ll a, ll b) {
	ll res = 1;
	a %= mod;
	while (b) {
		if (b & 1) res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}
vector<int> fac, finv;
void factor(int N) {
	fac.resize(N); finv.resize(N);
	fac[0] = finv[0] = 1;
	rep(i, 1, N)fac[i] = 1LL * fac[i - 1] * i % mod;
	finv[N - 1] = mpow(fac[N - 1], mod - 2);
	for (int i = N - 2; i; --i) finv[i] = 1LL * finv[i + 1] * (i + 1) % mod;
}
int nCr(int n, int m) {
	if (m < 0 || n < m) return 0;
	return 1LL * (1LL * fac[n] * finv[m] % mod) * finv[n - m] % mod;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, k; cin >> n >> m >> k;
	factor(200010);
	ll ans = (1LL*(m * m)%mod * (n - 1) * n * (n + 1) / 6) % mod;
	ans = (ans+1LL * (n * n) % mod * (m - 1) * m * (m + 1) / 6) % mod;
	ans = (1LL * ans * nCr(n * m - 2, k - 2)) % mod;
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1792
a, b, c = map(int, input().split())
if a == 5:
  if b == 5:
    if c == 7:
      print("YES")
    else:
      print("NO")
  elif b == 7:
    if c == 5:
      print("YES")
    else:
      print("NO")
  else:
    print("NO")
elif a == 7:
  if b == 5:
    if c == 5:
      print("YES")
    else:
      print("NO")
  elif b == 5:
    if c == 5:
      print("YES")
    else:
      print("NO")
  else:
    print("NO")
else:
  print("NO")

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int t[4], n[4];
	int i;
	
	for (i = 0; i < 4; i++){
		scanf("%d %d", &t[i], &n[i]);
	}
	
	for (i = 0; i < 4; i++){
		if (t[i] == 1){
			printf("%d\n", n[i] * 6000);
		}
		else if (t[i] == 2){
			printf("%d\n", n[i] * 4000);
		}
		else if (t[i] == 3){
			printf("%d\n", n[i] * 3000);
		}
		else if (t[i] == 4){
			printf("%d\n", n[i] * 2000);
		}
	}
	
	return (0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define all(a) a.begin(),a.end()
#define dbg_v(v) cout<<#v<<":";for(auto x:v) cout<<" "<<x; cout<<endl;
ll power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int n;
	cin>>n;
	int a[n][2];
	int f=0;
	for (int i = 0; i < n; i++)
	{
		cin>>a[i][0]>>a[i][1];
	}
	
	for(int i=0;i<n-2;i++){
		if(a[i][0]==a[i][1]&&a[i+1][0]==a[i+1][1]&&a[i+2][0]==a[i+2][1])
			f=1;
	}
	if(f)
	cout<<"Yes\n";
	else
		cout<<"No\n";
}


Measured memory_bytes: 3636
IDENTIFICATION DIVISION.
PROGRAM-ID. 162C.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 K          PIC  9(3) COMP.
01 A          PIC  9(3) COMP.
01 B          PIC  9(3) COMP.
01 C          PIC  9(3) COMP.
01 X          PIC  9(3) COMP.
01 Y          PIC  9(3) COMP.
01 Z          PIC  9(3) COMP.
01 S          PIC  9(3) COMP.
01 R          PIC  9(3) COMP.
01 GK         PIC  9(9) COMP.
01 OUT        PIC  Z(8)9.
01 GCD-TBL.
   03 G-T1    OCCURS 200.
      05 G    PIC 9(3) OCCURS 200. 
*>
PROCEDURE DIVISION.
  ACCEPT K.
*>
  MOVE ZERO TO GK GCD-TBL.
  PERFORM VARYING A FROM 1 BY 1 UNTIL A > K
    PERFORM VARYING B FROM 1 BY 1 UNTIL B > K
      EVALUATE TRUE
        WHEN G(A, B) > 0
          MOVE G(A, B) TO Z
        WHEN G(B, A) > 0
          MOVE G(B, A) TO Z
        WHEN OTHER
          MOVE A TO X
          MOVE B TO Y  
          PERFORM GCD
          MOVE X TO Z G(A, B)
      END-EVALUATE  
*>      
      PERFORM VARYING C FROM 1 BY 1 UNTIL C > K
        EVALUATE TRUE 
          WHEN G(Z, C) > 0
            MOVE G(Z, C) TO X
          WHEN G(C, Z) > 0
            MOVE G(C, Z) TO X
          WHEN OTHER
            MOVE Z TO X  
            MOVE C TO Y  
            PERFORM GCD
            MOVE X TO G(Z, C) 
        END-EVALUATE
*>         
        ADD X TO GK
      END-PERFORM
    END-PERFORM
  END-PERFORM.
*>
  MOVE GK TO OUT.
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.
*>---------------------------------------------<*
GCD SECTION.
  PERFORM UNTIL Y = 0
    DIVIDE X BY Y GIVING S REMAINDER R
    MOVE Y TO X
    MOVE R TO Y  
  END-PERFORM.
*>
  EXIT.

Measured memory_bytes: 4040
N, K = map(int, input().split())
S = list(input())
Y = 0
if N == 1:
    print(0)
    exit(0)

if S[0] == 'L':
    Y += 1
if S[N-1] == 'R':
    Y += 1

count = 0
X = 0
for i in range(N-1):
    if S[i] == 'R' and S[i+1] == 'L':
        X += 1
    if S[i] == S[i+1]:
        count += 1

count += K*2
print(min(N-1, count))


Measured memory_bytes: 49520
N = int(input())
A = [int(n) for n in input().split()]

result = True
for a in A:
    if a % 2 == 0:
        if a % 3 != 0 and a % 5 != 0:
            result = False
            break

if result:
    print("APPROVED")
else:
    print("DENIED")

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int w;
    scanf(" %d", &w);
    vector<int> a(w);
    rep(i,w) scanf(" %d", &a[i]);

    vector<int> ev(w,0);

    int now=0;
    int state=0;

    rep(i,w)
    {
        if(a[i]==0)
        {
            now=10000;
            state=0;
        }
        if(a[i]<0)
        {
            now=min(now,-a[i]);
            state=1;
        }

        ev[i]=max(ev[i],now);
        if(state) --now;
    }

    now=0;
    state=0;
    for(int i=w-1; i>=0; --i)
    {
        if(a[i]==0)
        {
            now=10000;
            state=0;
        }
        if(a[i]<0)
        {
            now=min(now,-a[i]);
            state=1;
        }

        ev[i]=max(ev[i],now);
        if(state) --now;
    }

    int ans=0;
    rep(i,w)
    {
        if(a[i]>0) ans+=min(a[i],ev[i]);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3608
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define MP make_pair
#define fs first
#define sc second
#define F first
#define S second
#define nl "\n"
#define asche cerr<<"Ekhane asche\n";
#define pf printf
#define sf scanf
#define mem(a,x) memset(a,x,sizeof(a))
#define SZ(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define one(x) __builtin_popcount(x)
#define fout(x) fixed<<setprecision(x)
#define BeatMeScanf ios_base::sync_with_stdio(false)
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); deb(_it, args); }
void deb(istream_iterator<string> it) {}
template<typename T, typename... Args>
void deb(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    deb(++it, args...);
}
//template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
namespace IO
{
    #define in() ( { int a ; scanf("%d",&a); a; } )
    #define LL() ( { ll a ; scanf("%lld",&a); a; } )
    #define ULL() ( { ull a ; scanf("%llu",&a); a; } )
    #define DD() ({ double a; scanf("%lf", &a); a;})
    #define CC() ( { char a ; scanf("%c",&a); a; } )
    #define pf1(a) printf("%d\n",a)
    #define pf1ll(a) printf("%lld\n",a)
}
using namespace IO;

const int mod=1e9+7;
const int N=3e5+9;
const double eps=1e-9;
const double PI=acos(-1.0);
ll qpow(ll n,ll k) {ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}


int32_t main()
{
    ///BeatMeScanf;
    int n=in();
    pf1ll(1LL*n*(n-1)/2);
    return 0;
}
///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static int N;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();

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

    static String solve() {
        String s = String.valueOf(N);
        String t = "";
        for (int i = 0; i < s.length(); i++) {
            if( s.charAt(i) == '1' ) {
                t += "9";
            } else {
                t += "1";
            }
        }
        return t;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 21076
import java.util.Scanner;

public class Main {
    private int n;
    private int[] num;

    public Main(int n, int[] num) {
        this.n = n;
        this.num = num;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] num = new int[n];
        for (int i = 0; i < n; i++) {
            num[i] = in.nextInt();
        }
        Main test = new Main(n, num);
        int count = test.bubbleSort();
        for(int i = 0; i < n; i++) {
            System.out.print(num[i]);
            if(i < n - 1){
                System.out.print(" ");
            }
            else{
                System.out.println();
            }
        }
        System.out.println(count);
    }

    private int bubbleSort() {
        int count = 0;
        boolean flag = true;
        for (int i = 0; flag; i++) {
            flag = false;
            for (int j = n - 1; j >= i + 1; j--) {
                if (num[j] < num[j - 1]) {
                    swap(j, j-1);
                    flag = true;
                    count++;
                }
            }
        }
        return count;
    }

    private void swap(int a, int b) {
        int temp = num[a];
        num[a] = num[b];
        num[b] = temp;
    }
}


Measured memory_bytes: 26372
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
#include <queue>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

ll power(ll a, ll x, ll mod){
    ll ans = 1;
    while(x > 0){
        if((x & 1) == 1){
            ans = ans * a % mod;
        }
        a = a * a % mod;
        x >>= 1;
    }
    return ans;
}

ll combination(ll n, ll k, ll mod){
    ll x = 1, y = 1;
    for(ll i = 0; i < k; i++){
        x = x * (n-i) % mod;
    }

    for(ll i = 1; i <= k; i++){
        y = y * power(i, mod-2, mod) % mod;
    }

    return x* y % mod;
}

ll solve_145D(){
    int x, y;
    cin >> x >> y;

    if((x + y) % 3 != 0) return 0;
    
    ll a = (2*y - x) / 3, b = (2*x - y) / 3;
    if(a < 0 || b < 0) return 0;

    return combination(a+b, a, MOD);
}

int main(void){
    cout << solve_145D() << endl;

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
main(){

  int a[5000],n,i,j;
  int sum=0,ans=-100000000;

  while(1){
    
    scanf("%d",&n);

    ans=-100000000;

    if(n==0){
      break;
    }
    
    for(i=0;i<n;i++){
      scanf("%d",&a[i]);
    }
    
    for(i=0;i<=n;i++){
      
      sum=0;
      
      for(j=i;j<n;j++){
	sum += a[j];
	if(sum>ans){
	  ans=sum;
	}
      }
    }
  
  printf("%d\n",ans);
  ans=0;
  
  }

  return 0;
}

Measured memory_bytes: 620
n = int(input())
s = input()

if n % 2 == 1:
    print('No')
    exit()

flg = True
n2 = n // 2
for i in range(n2):
    if s[i] != s[n2+i]:
        flg = False
        break
print('Yes') if flg else print('No')

Measured memory_bytes: 9120
#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 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 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;
 
  int dp[2][3];
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
}
  int func(int *a,int *b,int *c,int n)
  {
      int dp[n][3];
      dp[0][0]=a[0];
      dp[0][1]=b[0];
      dp[0][2]=c[0];
      for(int i=1;i<n;i++)
      {
          dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
          dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
          dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
      }
      return max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
  }
int32_t main()
{
    c_p_c();
     int n;
     cin>>n;
     int c=0;
     int A[n];
     int B[n];
     int C[n];
     for(int i=0;i<n;i++)
     {
         int a,b,c;
         cin>>a>>b>>c;
         A[i]=a;
         B[i]=b;
         C[i]=c;
     }
     cout<<func(A,B,C,n);
   // cout<<dp[0][0];
    return 0;
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp std::make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

const LL MOD = 1000000007;
int N;
std::string S1, S2;
int main() {
    std::cin >> N;
    std::cin >> S1;
    std::cin >> S2;

    LL ans = 1;
    int x = 0;
    int prev = -1;
    while(x < N) {
        if (S1[x] == S2[x]) {
            if (prev == -1) {
                ans = 3;
            }
            else if(prev == 0) {
                ans *= 2;
            }
            else {
                ans *= 1;
            }
            x++;
            prev = 0;
        } else {
            if(prev == -1) {
                ans = 6;
            } else if(prev == 0) {
                ans *= 2;
            } else {
                ans *= 3;
            }
            x += 2;
            prev = 1;
        }
        ans %= MOD;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const int INF = 1001001001;

int main(){
    int n, k; cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    vector<int> dp(n+k+1,INF);
    dp[0] = 0;
    for(int i = 0; i < n; ++i){
        for(int j = 1; j <= k; ++j){
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    string S;
    cin >> S;

    string before = "";
    int ans = 0;
    int index = 0;

    for(int i = 0; i < (int)S.size(); i++){
        char temp = S[i];
        if(before == ""){
            ans++;
            before = temp;
        }
        else{
            if((int)before.size() >= 2){
                ans++;
                before = temp;
                index = 0;
            }
            else{
                if(before[0] == temp){
                    if(i != (int)S.size() - 1){
                        ans++;
                        before = temp;
                        before += S[i + 1];
                        i++;
                    }
                }
                else{
                    ans++;
                    before = temp;
                    index = 0;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  for (int i = 0; i < ty - sy; i ++){
    cout << 'U';
  }
  for (int i = 0; i < tx - sx; i ++){
    cout << 'R';
  }
  for (int i = 0; i < ty - sy; i ++){
    cout << 'D';
  }
  for (int i = 0; i < tx - sx; i ++){
    cout << 'L';
  }
  cout << 'L';
  for (int i = 0; i <= ty - sy; i ++){
    cout << 'U';
  }
  for (int i = 0; i <= tx - sx; i ++){
    cout << 'R';
  }
  cout  << 'D' << 'R';
  for (int i = 0; i <= ty - sy; i ++){
    cout << 'D';
  }
  for (int i = 0; i <= tx - sx; i ++){
    cout << 'L';
  }
  cout << 'U' << '\n';
}

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

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  if(a>=b)
    cout << "delicious" << endl;
  else if(x+a<b)
    cout << "dangerous" << endl;
  else
    cout << "safe" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
#include <numeric>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	double sum = 0.0;
	for(int i = 1;i <= n; ++i)
	{
		int x;
		scanf("%d",&x);
		sum += (1.0 / (x + 0.0));
	}
	printf("%.10lf\n",(1.0 / sum));
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {

	int a, b, c,i,count=0;

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

	for (i = a; i <= b; i++) {
		if (c % i == 0) count++;
	}

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

	return 0;

}


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

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

	int a = 0, b = 0;
	for (int i = 0; i < S.size(); i++) {
		if (i % 2) {
			if (S[i] != '0') a++;
		}
		else {
			if (S[i] != '1') a++;
		}
	}
	for (int i = 0; i < S.size(); i++) {
		if (i % 2) {
			if (S[i] != '1') b++;
		}
		else {
			if (S[i] != '0') b++;
		}
	}

	cout << min(a, b) << endl;
}

Measured memory_bytes: 3700
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,k;
    int ans=0;
    while(1){
        int lis[100001]={0};
        ans=0;
        cin>>n>>k;
        if(n==0&&k==0)break;
        for(int i=0;i<k;i++){
            int a;
            cin>>a;
            lis[a]=1;
        }
        int bef=0;
        int kuuhaku=0,befkuuhaku=0;
        int cou=0;
        for(int i=1;i<=100000;i++){
            if(lis[i]){
                cou++;
                if(kuuhaku)befkuuhaku=kuuhaku,kuuhaku=0;
            }
            else bef=cou,cou=0,kuuhaku++;
            if(lis[0]&&befkuuhaku==1)ans=max(ans,cou+bef+1);
            else if(lis[0]&&befkuuhaku!=0)ans=max(ans,cou+1);
            else ans=max(ans,cou);

            //printf("[%d][%d][%d][%d][%d]\n",kuuhaku,befkuuhaku,cou,bef,ans);

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

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n{0};
	cin>>n;
	int *arr=new int[n];
	for(int i=0;i<n;++i)
	{
		cin>>arr[i];
	}
	int seq=0;
	for(int i=0;i<n;++i)
	{
		if(arr[i]==seq+1)
		++seq;
	}
	if(seq==0)
	cout<<"-1\n";
	else
	cout<<n-seq<<"\n";
	return 0;
}

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

int main(void){
  int N;
  scanf("%d\n",&N);
  if(N%2==1){
    printf("%d\n",(int)(N-1)/2);
  }else if(N%2==0){
    printf("%d\n",(int)((N-1)-1)/2);
  }
  return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    int x[111000];
    for(int i=0; i<m; i++){
        cin >> x[i];
    }
    sort(x, x+m);
    vector<int> v;
    for(int i=0; i<m-1; i++){
        v.push_back(x[i+1]-x[i]);
    }
    sort(v.begin(), v.end());
    int ans = 0;

    for(int i=0; i<m-n; i++){
        ans += v[i];
    }
  
  	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1276
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<numeric>
#include<set>
#include<math.h>
using namespace std;

int main(){
    int X, A;
    cin >> X >> A;

    if(X < A) cout << 0 << endl;
    else cout << 10 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<map>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define mset(s,_) memset(s,_,sizeof s)
using namespace std;
ll a[200010];
int main(){
	ll n,k;
	cin>>n>>k;
	rep(i,0,n-1) cin>>a[i];
	ll l=-1e18,r=1e18;
	sort(a,a+n);
	while(l<r){
		ll mid=(l+r)>>1,cnt=0;
		rep(i,0,n-1){
			if(a[i]>0){
				cnt+=upper_bound(a,a+n,(long double)mid/a[i])-a;
		  }
		  else if(a[i]<0){
		  	cnt+=n-(lower_bound(a,a+n,(long double)mid/a[i])-a);
		  }
		  else if(mid>=0){
		  	cnt+=n;
		  }
		  if(a[i]*a[i]<=mid) cnt--;
		}
		if(cnt>=2*k) r=mid;
    else l=mid+1;
   //cout<<mid<<'\n';
	}
	cout<<l<<'\n';
}
			
	

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int k;cin>>k;
    rep(i,k)cout<<"ACL";
    cout<<endl;
}

Measured memory_bytes: 3524
#include <stdio.h>
int main(void){
  int x,i,n;
  scanf("%d\n",&n);

  for(i = 1; i<=n ; i++){
    x = i;
    if(x % 3 == 0){
      printf(" %d",i);
    }else if(x % 10 == 3){
      printf(" %d",i);
    }else{
      while( x != 0){
        x /= 10;
        if(x % 10 == 3){
          printf(" %d",i);
          break;
        }
      }
    }
  }

  printf("\n");
  return 0;
}


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

using namespace std;

using int64 = long long;

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

  int n, m;
  cin >> n >> m;
  // pair<value, count>
  vector<pair<int64, int>> pairs;
  for (int i = 0; i < n; i++) {
    int64 x;
    cin >> x;
    pairs.push_back(make_pair(x, 1));
  }
  for (int i = 0; i < m; i++) {
    int count;
    int64 value;
    cin >> count >> value;
    pairs.push_back(make_pair(value, count));
  }
  sort(pairs.begin(), pairs.end(),
       [](auto& p1, auto& p2) {
         return p1.first > p2.first;
       });
  
  int used_count = 0;
  int64 answer = 0;
  for (const auto& pair : pairs) {
    if (used_count + pair.second <= n) {
      used_count += pair.second;
      answer += pair.first * pair.second;
    } else if (used_count < n) {
      int use = n - used_count;
      used_count = n;
      answer += pair.first * use;
    }
  }
  cout << answer << endl;
}


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

int main(){
    int n, m, l;
    int A[100][100];
    int B[100][100];
    long C[100][100];

    scanf("%d %d %d", &n, &m, &l);

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

    for(int j=0; j<m; j++){
        for(int i=0; i<l; i++){
            scanf("%d", &B[j][i]);
        }
    }

    for(int j=0; j<n; j++){
        for(int i=0; i<l; i++){
            C[j][i] = 0;
            for(int k=0; k<m; k++){
                C[j][i] += A[j][k] * B[k][i];
            }
            printf("%ld", C[j][i]);
            if(i < l-1){
                printf(" ");
            }
        }
        printf("\n");
    }



    return 0;
}


Measured memory_bytes: 2092
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int minv = INF;
	for(int i = 1;i * i <= n;++i){
		if(n % i == 0){
			string s = to_string(i);
			string t = to_string(n / i);
			chmin(minv,max(s.size(),t.size()));
		}
	}
	cout << minv << '\n';
	return 0;
}


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

int main(){
  int H, W, i, j;

  while(1){

  scanf("%d %d", &H, &W);
  if(H==0 && W==0) break;

  for(i=0;i<H;i++) {
    for(j=0;j<W;j++) {
      if(i%2!=0) {
        if(j%2!=0) printf("#");
        else printf(".");
      } else {
        if (j%2!=0) printf(".");
        else printf("#");
      }
    }
    printf("\n");
  }
  printf("\n");
}





}



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

typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin >> a[i];

    for(int i=0;i<n;i++){
        for(int j=i-1;j>=0;j--){
            if(a[j]>a[j+1])swap(a[j],a[j+1]);
        }
        for(int j=0;j<n;j++){
            cout << a[j];
            cout << (j!=n-1?" ":"\n");
        }
    }
}



Measured memory_bytes: 3140
// AOJ 2932 Divisor Game
// 2018.3.12 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int power[15], sz;

int ptbl[] = {
		 3,   5,   7,  11,  13,  17,  19,  23,  29,
   31,  37,  41,  43,  47,  53,  59,  61,  67,  71,
   73,  79,  83,  89,  97, 101, 103, 107, 109, 113,
  127, 131, 137, 139, 149, 151, 157, 163, 167, 173,
  179, 181, 191, 193, 197, 199, 211, 223, 227, 229,
  233, 239, 241, 251, 257, 263, 269, 271, 277, 281,
  283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
  353, 359, 367, 373, 379, 383, 389, 397, 401, 409,
  419, 421, 431, 433, 439, 443, 449, 457, 461, 463,
  467, 479, 487, 491, 499, 503, 509, 521, 523, 541,
  547, 557, 563, 569, 571, 577, 587, 593, 599, 601,
  607, 613, 617, 619, 631, 641, 643, 647, 653, 659,
  661, 673, 677, 683, 691, 701, 709, 719, 727, 733,
  739, 743, 751, 757, 761, 769, 773, 787, 797, 809,
  811, 821, 823, 827, 829, 839, 853, 857, 859, 863,
  877, 881, 883, 887, 907, 911, 919, 929, 937, 941,
  947, 953, 967, 971, 977, 983, 991, 997, 0 };

int prime_factor(long long n)
{
	int i, b;
	int *pp, *p;

	pp = power;
	if ((n & 1) == 0) {
		do n >>= 1LL, (*pp)++;
		while ((n & 1) == 0);
		pp++;
	}
	for (p = ptbl; n > 1 && *p > 0; p++) {
		if (n % *p) continue;
		b = *p;
		do n /= b, (*pp)++;
		while (n % b == 0);
		pp++;
	}
	if (n > 1) {
		b = (int)sqrt((double)n);
		for (i = 1009; n > 1; i += 2) {
			if (i > b) { *pp++ = 1; break; }
			if (n % i == 0) {
				do n /= i, (*pp)++;
				while (n % i == 0);
				pp++;
			}
		}
	}
	return pp - power;
}

int main()
{
	int i, ans;
	long long N;

	scanf("%lld", &N);
	sz = prime_factor(N);
	ans = 1;
	for (i = 0; i < sz; i++) ans *= power[i] + 1;
	printf("%d %d\n", sz, ans - 1);
	return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,sa=0,i;
    cin >>N;
    vector <int> a(N);
    for(i=0;i<N;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for(i=0;i<N;i++){
        if(i%2==0) sa+=a[i];
        else sa-=a[i];
    }
    cout <<sa <<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

static inline void MainTask() {
  uint32_t N;
  cin >> N;
  vector<uint32_t> A(N), B(N - 1);
  ArrayInput(B);
  A[0] = B[0];
  A[1] = B[0];
  for (uint32_t i = 1; i < N - 1; ++i) {
    if (B[i] < B[i - 1]) {
      A[i] = B[i];
    }
    A[i + 1] = B[i];
  }
  uint64_t res = 0;
  for (uint32_t i = 0; i < N; ++i) res += A[i];
  cout << res << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
/* #pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/
typedef long long ll;
const ll MAXN = 1e5 + 2;
const ll MAXK = 5e2 + 2;
const ll MOD = 1e9 + 7;
const ll MODH = 1e9 + 9;
const int MAXLG = 20;
const long double PI = acos(-1);
const ll p = 41;
const long double EPS = 1e-4;
#define x first
#define y second
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll rand(ll a, ll b) {ll c = rng(); return a+((ll)abs(c))%(b-a+1);}
ll binpow(ll a, ll b, ll m) {a %= m;ll res = 1;while (b > 0) {if (b & 1){res = res * a % m;}a = a * a % m;b >>= 1;
}return res;}



int main() {
  
 
 ios::sync_with_stdio(0);
 cin.tie(0);
 cout.tie(0);
  int n,x,t;
 cin >> n >> x >> t;
  int ans = 0;
  int tans = 0;
  while(ans < n)
  {
  	tans+=t;
  	ans+=x;
  }

  cout << tans << '\n';
  

  }

Measured memory_bytes: 3656
N, M, Q = map(int, input().split())
ts = [tuple(map(int, input().split())) for _ in range(Q)]

As = [1] * N

def next(ls):
    if ls[-1] < M:
        ls[-1] += 1
    else:
        for i, elem in reversed(list(enumerate(ls))):
            if elem < M:
                for j in range(i, N):
                    ls[j] = elem + 1
                break
        else:
            return False
    return True

cond = True
max_score = 0
while cond:
    score = 0
    for a, b, c, d in ts:
        if As[b-1] - As[a-1] == c:
            score += d
    max_score = max(max_score, score)
    cond = next(As)

print(max_score)


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

import static java.lang.Integer.parseInt;

/**
 * Japanese Calendar
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		line = br.readLine();

		int E, Y;
		E = parseInt(line.substring(0, line.indexOf(' ')));
		Y = parseInt(line.substring(line.indexOf(' ') + 1));

		switch (E) {
			case 0:
				if (Y < 1912) {
					System.out.printf("M%d%n", Y - 1868 + 1);
				} else if (Y < 1926) {
					System.out.printf("T%d%n", Y - 1912 + 1);
				} else if (Y < 1989) {
					System.out.printf("S%d%n", Y - 1926 + 1);
				} else {
					System.out.printf("H%d%n", Y - 1989 + 1);
				}
				break;
			case 1:
				System.out.println(1868 + Y - 1);
				break;
			case 2:
				System.out.println(1912 + Y - 1);
				break;
			case 3:
				System.out.println(1926 + Y - 1);
				break;
			case 4:
				System.out.println(1989 + Y - 1);
				break;
		}
	}
}

Measured memory_bytes: 24448
#include <bits/stdc++.h>
using namespace std;
#define int long long
 main() {
	int n,q,a[100500],l,r,x;
	long long sum=0;
	cin >> n;
	for(int i=0; i<n; i++) 
	{
		cin>>x;
		sum+=x;
		a[x]++;
	}
	cin >> q;
	for(int i=0; i<q; i++)
	{
		cin >> l>>r;
		int v = a[l];
		sum = sum - (1ll*v*l) + (1ll*v*r);
		a[l]=0;
		a[r]+=v;
		cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 4416
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/
#include <assert.h> /*確認*/
#include <ctype.h>  /*文字操作*/
#include <stdbool.h>/*bool型*/
#include <limits.h>/*限界*/

//---------------------------------------------------

// c
#define rep(i, n) for(int  i = 0; i < (n); i++)
#define max(a,b) ((a>b)?a:b)
#define ABS(a) (((a)>(0))?a:-(a))
#define LL long long
#define MOD 1000000007//10^9+7(素数)

int main(void)
{
  LL a;
  double b;
  scanf("%lld %lf", &a, &b);
  printf("%lld\n", (long long)((double)a * b));
  return 0;
}


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

int main(){
    int n;
    string s;
    cin >> n >> s;

    vector<int> white(n+1);
    for(int i=0; i<n; i++){
        if(s[i] == '.') white[i+1] = 1;
    }
    for(int i=0; i<n; i++){
        white[i+1] += white[i];
    }

    int ans = 1e6;// INF
    for(int i=0; i<=n; i++){
        int flip = (i - white[i]) + (white[n] - white[i]);
        ans = min(ans, flip);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4428
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    string S;
    cin >> S;
    string vs[] = {"eraser", "erase", "dreamer", "dream"};

    for (auto ss : vs) {
        std::string::size_type pos = 0;
        while ((pos = S.find(ss, pos)) != std::string::npos) {
            S.replace(pos, ss.length(), "0");
            pos += 1;
        }
    }

    REP(i, SIZE(S)) {
        if (S[i] != '0') {
            cout << "NO";
            return;
        }
    }
    cout << "YES";
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3776
UF=Hash.new{-1}
def u a,b;UF[f b]=f a;end
def f c;UF[c]<0?c:UF[c]=f(UF[c])end

cities=(1..n=gets.to_i).map{|i|gets.split.map(&:to_i)+[i]}

road = cities.sort_by{|x,y,i|x}.each_cons(2).map{|(x1,y1,i),(x2,y2,j)|[x2-x1,i,j]}+
       cities.sort_by{|x,y,i|y}.each_cons(2).map{|(x1,y1,i),(x2,y2,j)|[y2-y1,i,j]}

p road.sort.inject(0){|s,(cost,i,j)|
  if f(i)!=f(j)
    u(i,j)
    s+cost
  else
    s
  end
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> d(n, 0);
    for (int i = 1; i <= n; ++i) {
        for (int j = i+1; j <= n; ++j) {
            int p = j-i;
            int q = abs(x-i)+1+abs(y-j);
            ++d[min(p, q)];
        }
    }
    for (int i = 1; i < n; ++i) {
        cout << d[i] << endl;
    }
}



Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        System.out.println(solve() ? "Yes" : "No");
    }

    private static boolean solve() {

        Scanner sc = new Scanner(System.in);

        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        BigDecimal A = BigDecimal.valueOf(a);
        BigDecimal B = BigDecimal.valueOf(b);
        BigDecimal C = BigDecimal.valueOf(c);
        BigDecimal right = C.subtract(A).subtract(B);

        if (c - a - b <= 0) {
            return false;
        }

        right = right.multiply(right);
        BigDecimal left = BigDecimal.valueOf(4).multiply(A).multiply(B);
        if (left.compareTo(right) < 0) {
            return true;
        }
        return false;
    }
}


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



int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

long long int dp[200002];
long long int num[200002];

long long int dp2[200002];



int main(){

ios::sync_with_stdio(false);
cin.tie(0);

fill(dp,dp+200002,0);
fill(dp2,dp2+200002,-1);

int n;
cin>>n;

int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
num[a[i]]++;
}

long long int sums=0;

for(int i=0;i<200002;i++){
if(num[i]>1){
dp[i]=num[i]*(num[i]-1)/2;
sums+=dp[i];
}

}

//cout <<sums<<"\n"<<endl;


for(int i=1;i<=n;i++){

long long int temp=sums;
temp-=dp[a[i-1]];


if(dp2[i]>=0){
temp+=dp2[i];
}else{

if(num[a[i-1]]-1>1){
temp+=(num[a[i-1]]-1)*(num[a[i-1]]-2)/2;
dp2[i]=(num[a[i-1]]-1)*(num[a[i-1]]-2)/2;
}else{
temp+=0;
dp2[i]=0;
}

}
/*
for(int i=0;i<=6;i++){
cout << num[i]<<" ";
} 
cout << endl;
for(int i=0;i<=6;i++){
cout << dp[i]<<" ";
} 
cout << endl;
for(int i=0;i<=6;i++){
cout << dp2[i]<<" ";
} 
cout << endl;
*/

cout <<temp<<endl;
}


//cout << setprecision(12) << fixed<<l<< endl;

}


Measured memory_bytes: 7680
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    int K,N,A[1000000],max = -1,i;
    
    scanf("%d",&K);
    scanf("%d",&N);
    
    for(i = 0;i < N;i++){
        scanf("%d",&A[i]);
    }
    max = K-A[N-1] + A[0];
    for(i = N-1;i >= 0;i--){
        if(max < A[i]-A[i-1]){
            max = A[i]-A[i-1];
        }
    }
    printf("%d\n",K - max);
    
    return 0;
}


Measured memory_bytes: 3072
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
B = [int(input()) for i in range(N)]

flag = True
for i in range(3):
    if (A1[0] in B) and (A1[1] in B) and (A1[2] in B):
        print('Yes')
        flag = False
        break
    elif (A2[0] in B) and (A2[1] in B) and (A2[2] in B):
        print('Yes')
        flag = False
        break
    elif (A3[0] in B) and (A3[1] in B) and (A3[2] in B):
        print('Yes')
        flag = False
        break
    elif (A1[i] in B) and (A2[i] in B) and (A3[i] in B):
        print('Yes')
        flag = False
        break 
    elif (A1[0] in B) and (A2[1] in B) and (A3[2] in B):
        print('Yes')
        flag = False
        break 
    elif (A1[2] in B) and (A2[1] in B) and (A3[0] in B):
        print('Yes')
        flag = False
        break 
if flag == True:
    print('No')

Measured memory_bytes: 3064