akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main()
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if (a == b && a == c) {
        printf("No\n");
        
    } else if (a != b && a != c && b != c) {
        printf("No\n");
    }else {
        printf("Yes\n");
    }

}

Measured memory_bytes: 128
l = str(int(input()))
n = []

for i in range(len(l)):
    n.append((l)[i])
    
if n[-1] == '2' or n[-1] == '4' or  n[-1] == '5' or n[-1] == '7' or  n[-1] == '9':
    print("hon")
elif  n[-1] == '3':
    print("bon")
else:
    print("pon")

Measured memory_bytes: 61660
#include<bits/stdc++.h>
using namespace std;
int a[1000001],b[1000001];
int main() {
	int n,m,i;
	scanf("%d%d",&n,&m);
	for(i=1; i<=m; i++) {
		int st,ed;
		scanf("%d%d",&st,&ed);
		if(st==1)a[ed]=1;
		if(ed==n)b[st]=1;
	}
	for(i=1; i<=m; i++)
		if(a[i]&&b[i]) {
			printf("POSSIBLE\n");
			return 0;
		}
	printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 5120
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int MOD = 1e+7;

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

  int n;
  cin >> n;
  int res = 0;
  int mini = inf;
  rep(i,n) {
    int p;
    cin >> p;
    if(p <= mini) {
      res++;
      mini = p;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	if a <= 5 {
		fmt.Println(0)
	} else if a >= 6 && a <= 12 {
		fmt.Println(b/2)
	} else {
		fmt.Println(b)
	}
}


Measured memory_bytes: 512
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	public static void main(String[] args) {
		String SS=sc.next();
		String T=sc.next();
		StringBuffer S = new StringBuffer(SS);
		boolean x=false;
		for(int i=0;i<S.length();i++) {
			char X=S.charAt(S.length()-1);
			S.deleteCharAt(S.length()-1);
			S.insert(0, X);
			if(S.toString().equals(T)) {
				x=true;
				break;
			}
		}
		
		if(x)p("Yes");
		else p("No");
	}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 22996
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Tue Dec 25 03:18:53 2018
//
package main

import "fmt"

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var N int
	var S string
	fmt.Scan(&N, &S)

	totalE, totalW := 0, 0
	arrE := make([]int, len(S))
	arrW := make([]int, len(S))
	for i := range S {
		if S[i] == 'E' {
			arrE[i]++
			totalE++
		} else {
			arrW[i]++
			totalW++
		}
	}
	for i := range arrE {
		if i+1 < len(arrE) {
			arrE[i+1] += arrE[i]
		}
		if len(arrW)-i-2 >= 0 {
			arrW[len(arrW)-i-2] += arrW[len(arrW)-i-1]
		}
	}

	ans := 1 << 60
	for i := range S {
		ans = min(ans, totalE-arrE[i]+totalW-arrW[i])
	}
	fmt.Println(ans)
}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;cin>>n>>m;
    int sum = 0;
    vector<int> a(n);rep(i,n){cin>>a[i];sum+=a[i];}
    int cnt = 0;
    rep(i,n){
        if(a[i]*4*m>=sum)cnt++;
    }
    if(cnt>=m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
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; }


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

    const ll INF=1LL<<60;
    vector<ll> dp(100010,INF);

    dp[0] = 0;

    vector<ll> h(N);
    REP(i,N) cin>>h[i];

    REP(i,N){
        REP2(j,1,K+1){
            if(i+j<N) chmin(dp[i+j], dp[i]+abs(h[i+j]-h[i]));
        }
    }

    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1920
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto r = readln.chomp.to!int;
  auto g = readln.chomp.to!int;

  writeln(2 * g - r);
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	map<string,pii>ma;
	string w="+-*/";
	cin>>n;
	while(n--){
		string s;
		int a,b;cin>>s>>a>>b;
		ma[s]={a,b+1};
	}
	cin>>n;
	bool h=true;
	vvi in;
	rep(i,n){
		string s;cin>>s;
		if(w.find(s[0])!=string::npos){
			int m=in.size();
			vi ne(256);
			rep(j,256)rep(k,256)if(in[m-2][j]&&in[m-1][k]){
				if(s=="+")ne[(j+k)%256]=true;
				if(s=="-")ne[(j-k+256)%256]=true;
				if(s=="*")ne[(j*k)%256]=true;
				if(s=="/"){
					if(k==0)h=false;
					else ne[j/k]=true;
				}
			}
			in.erase(in.begin()+m-1);
			in[m-2]=ne;
		}else{
			vi t(256);
			if(ma.count(s)){
				pii a=ma[s];
				loop(j,a.first,a.second)t[j]=true;
			}else{
				t[stoi(s)]=true;
			}
			in.pb(t);
		}
	}
	if(h)cout<<"correct"<<endl;
	else cout<<"error"<<endl;
}









Measured memory_bytes: 3244
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





ll N, A[5];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, 5) cin >> A[i];
	
	ll mi = infl;
	rep(i, 0, 5) chmin(mi, A[i]);

	ll ans = 4 + (N + mi - 1) / mi;
	cout << ans << endl;
}

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

int main()
{
    /*A
    int a[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
    int k;
    cin>>k;
    cout<<a[k-1]<<endl;
    */
    
    ll h,w;
    cin>>h>>w;
    ll countOdd;
    if(w%2==0)
    {
        countOdd=w/2;
    }
    else
    {
        countOdd = w/2+1;
    }
    ll countEven =w-countOdd;
    ll count;
    if(w==1 || h==1)
    {
        cout<<1<<endl;
        return 0;
    }
    if(h%2==0)
    {
        count = (countEven+countOdd)*(h/2);
    }
    else
    {
        count = (countEven+countOdd)*(h/2)+countOdd;
    }

    cout<<count<<endl;
    
    return 0;
}

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

using namespace std;

void Main() {
    long long X, K, D;
    cin >> X >> K >> D;

    X = abs(X);
    long long k = X / D;
    if (K < k) {
        cout << X - K * D << endl;
        return;
    }

    X -= k * D;
    K -= k;
    long long a = X % D;
    if (K % 2 == 0) {
        cout << a << endl;
    }
    else {
        cout << D - a << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3632
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    aa = sorted([LI() for _ in range(n)], key=lambda x: x[1])
    t = 0
    for a,b in aa:
        t += a
        if t > b:
            return 'No'

    return 'Yes'


print(main())



Measured memory_bytes: 58508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

vp divisor(ll m){
    vp ret;
    for(ll i = 2; i*i <= m; i++){
        if(m%i==0){
            ret.emplace_back(i, 0);
            while(m%i==0){
                m /= i;
                ret.back().second++;
            }
        }
    }
    if(m>1){
        ret.emplace_back(m, 1);
    }
    sort(ALL(ret));
    return ret;
}

ll fac[200010], facinv[200010];
void cominit(){
    fac[0] = facinv[0] = 1;
    ll c = 1;
    repr(i, 1, 200010){
        c *= i;
        c %= MOD;
        fac[i] = c;
        facinv[i] = powmod(c, MOD-2);
    }
}
ll comb(ll a, ll b){
    ll ret = 1;
    ret *= fac[a];
    ret *= facinv[b];
    ret %= MOD;
    ret *= facinv[a-b];
    ret %= MOD;
    return ret;    
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, m;
    cin >> n >> m;
    vp div = divisor(m);
    cominit();
    ll ans = 1;
    for(auto&& e: div){
        ans *= comb(e.second+n-1, e.second);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
int par[100000], r[100000], club[100001];
 
void makeset(int n);
int findset(int x);
void joinclub(int x, int y);
void link(int x, int y);
bool paradox1(int x, int y);
bool paradox2(int x,int y);
 
signed main()
{
    int n, m, k, rec, a, b, ans;
    cin >> n >> m >> k;
     
    makeset(n);
    ans = 0;
     
    for(int i=0 ;i<k ;i++ ){
 
        cin >> rec >> a >> b;
 
        if(ans == 0){
            if(rec == 1){
                if( paradox1(a-1, b-1) ){
                    ans = i+1;
                }
            } else {
                if( paradox2(a-1, b) ){
                    ans = i+1;
                }
            }
        }
    }
 
    cout << ans << endl;
 
    return (0);
}
 
void makeset(int n)
{
   for(int i=0 ;i<n ;i++ ){
       par[i] = i;
       r[i] = 0;
       club[i] = 0; // 虚無に所属
   } 
 
   return ;
}
 
int findset(int x)
{
    if(x != par[x]){
        par[x] = findset(par[x]);
    }
    return(par[x]);
}
 
void joinclub(int x, int y)
{
    club[x] = y;
 
    return ;
}
 
void link(int x, int y)
{    
    int X, Y;
    X = findset(x);
    Y = findset(y);
 
    if(r[X] > r[Y]){
        par[X] = Y;
    } else if(r[X] > r[Y]) {
        par[Y] = X;
    } else {
        par[Y] = X;
        r[X]++;        
    }
 
    if(club[X] == 0){
        joinclub(X, club[Y]);
    } else if (club[Y] == 0){
        joinclub(Y, club[X]);
    }
 
    return ;
}
 
bool paradox1(int x, int y){
    int X, Y;
    X = findset(x);
    Y = findset(y);
 
    if(club[X] != 0 && club[Y] != 0 && club[X] != club[Y]){
        return (true);
    } else {
        link(X, Y);
 
        return (false);
    }
}
 
bool paradox2(int x, int y){
    int X;
 
    if(club[x] != 0 && club[x] != y){
        return (true);
    } else {
        joinclub(x, y);
        X = findset(x);
 
        if(club[X] != 0 && club[X] != y){
            return (true);
        } else {
            joinclub(X, y);
 
            return(false);
        }
    }
}


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

int main(){
    int n,x,i,ans=0;
    cin >> n >> x;
    vector<int> a(n);
    long long int sum=0;
    for(i=0;i<n;i++){ 
        cin >> a.at(i);
        sum += a.at(i);
    }
    if(sum == x) ans = n;
    else{
        sort(a.begin(),a.end());
        sum = 0;
        for(i=0;i<n;i++){
            sum += a.at(i);
            if(sum > x) break;
        }
        if(i==n) i--;
        ans = i; 
    }
    cout << ans << endl;
    return 0;
}

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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    int ans = 0;
    for (int i=1;i<=N;i++){
        int a;
        cin >> a;
        if (i%2==1 && a%2==1) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3632
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	int D, N;
	cin >> D >> N;
	if (N != 100) {
		cout << N * pow(100, D) << endl;
	}
	else if  (D != 2) cout << 101 * pow(100, D) << endl;
	else cout << 1010000 << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long LL;
const int SIZEN = 200010;
int A[SIZEN] = {0};
LL ans = 0;
int main(){
    int N;
    scanf("%d",&N);
    for(int i = 1;i <= N;i++){
        scanf("%d",&A[i]);
    }
    int pre = A[1];
    for(int i = 2;i <= N;i++){
        if(A[i] >= pre)pre = A[i];
        else   {
            ans += pre - A[i];
        }
    }
    printf("%lld\n",ans);
    return 0;
}

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

#define vi vector<int>
#define vl vector<long long>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define INF 1e18
#define INFTY 1e9
#define MOD 1e9+7
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

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

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

struct edge {int to, cost;};
vector< vector<edge> > es;
const int MAX_N = 10010;

struct UnionFind {

    vector<int> par;
    vector<int> rank;
    vector<int> size;

    UnionFind(int N) : par(N), rank(N), size(N) {
        REP(i, N) {
            par[i] = i;
            rank[i] = 0;
            size[i] = 1;
        }
    }
    
    int find(int x) {
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (rank[x] > rank[y]) {
            par[y] = x;
            size[x] += size[y];
        } else {
            par[x] = y;
            size[y] += size[x];
            if (rank[x] == rank[y]) rank[y]++;
        }
    }

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

    int ret_size(int x) {
        return size[find(x)];
    }
};

bool comp(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
}

int main() {
    int N, M;
    cin >> N >> M;
    vi A, B;
    A.resize(M);
    B.resize(M);
    REP(i, M) {
        cin >> A[i] >> B[i];
        --A[i]; --B[i];
    }
    int res = 0;
    REP(i, M) {
        UnionFind uf(N);
        REP(j, M) {
            if (i == j) continue;
            uf.unite(A[j], B[j]);
        }
        if (!uf.same(A[i], B[i])) res += 1;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import collections

s = input()

x_num = collections.deque()
x_num.append(0)
others = collections.deque()
for s_i in s:
    if s_i == 'x':
        x_num[-1] += 1
    else:
        others.append(s_i)
        x_num.append(0)
possible = 1
while len(others) > 1:
    if others.pop() != others.popleft():
        possible = 0
        break
if possible:
    ans = 0
    while len(x_num) > 1:
        ans += abs(x_num.pop() - x_num.popleft())
    print(ans)
else:
    print(-1)

Measured memory_bytes: 48368
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoderCS
{
	public interface IReader
	{
		string ReadLine();
		int ReadInt();
		long ReadLong();
		string[] ReadStringArray();
		int[] ReadIntArray();
		long[] ReadLongArray();
	}
	public class ConsoleReader : IReader
	{
		public string ReadLine() => Console.ReadLine();
		public int ReadInt() => int.Parse(ReadLine());
		public long ReadLong() => long.Parse(ReadLine());
		public string[] ReadStringArray() => ReadLine().Split(' ');
		public int[] ReadIntArray() => ReadLine().Split(' ').Select<string, int>(s => int.Parse(s)).ToArray();
		public long[] ReadLongArray() => ReadLine().Split(' ').Select<string, long>(s => long.Parse(s)).ToArray();
	}

	public interface IWriter
	{
		void WriteLine(string line);
		void WriteLine(int value);
		void WriteLine(ulong value);
	}
	public class ConsoleWriter : IWriter
	{
		public void WriteLine(string line) => Console.WriteLine(line);
		public void WriteLine(ulong value) => Console.WriteLine(value);
		public void WriteLine(int value) => Console.WriteLine(value);
	}

	public partial class Solver
	{
		readonly IReader _reader;
		readonly IWriter _writer;

		public Solver(IReader reader = null, IWriter writer = null) {
			_reader = reader ?? new ConsoleReader();
			_writer = writer ?? new ConsoleWriter();
		}

		partial void Dump<T>(IEnumerable<T> array);

		public void Run() {
			var N = _reader.ReadInt();
			//Console.WriteLine(N);

			var S = _reader.ReadLine();

			// D/M数, DM組数を累積和で保持する ★i番目の前までの和 を格納する
			ulong[] accumD = new ulong[S.Length];
			ulong[] accumM = new ulong[S.Length];
			ulong[] accumDM = new ulong[S.Length];
			ulong sumD = 0, sumM = 0, sumDM = 0;
			for (int i = 0; i < S.Length; i++) {
				accumD[i] = sumD;
				accumM[i] = sumM;
				accumDM[i] = sumDM;
				switch (S[i]) {
					case 'D': ++sumD; break;
					case 'M':
						sumDM += sumD;
						++sumM;
						break;
				}
			}
			_reader.ReadInt();

			int[] k_ary = _reader.ReadIntArray();
			//k_ary.Dump();

			foreach (var k in k_ary) {
				int sect_len = k - 1;
				int l = 0;
				ulong ans = 0;

				// 右端のindexをインクリメントしていく
				for (int r = 2; r < N; r++) {
					// 左端
					if (S[r] == 'C') {
						if (0 <= r - sect_len) l = r - sect_len;
						ans += accumDM[r] - accumDM[l] - accumD[l] * (accumM[r] - accumM[l]);
					}
				}
				_writer.WriteLine(ans);
			}
		}
	}

	class MainClass
	{
		public static void Main(string[] args) {
			new Solver().Run();
		}
	}
}


Measured memory_bytes: 38528
"""AtCoder."""

import math

a, b, h, m = [int(v) for v in input().split(' ')]


class Point:

    def __init__(self, r, v):
        self.r = r
        self.w = (2 * math.pi) / v

    def get_pos(self, t):
        wt = self.w * t
        return self.r * math.cos(wt), self.r * math.sin(wt)


p1 = Point(a, 12 * 60)
p2 = Point(b, 60)

minute = (h * 60) + m
x1, y1 = p1.get_pos(minute)
x2, y2 = p2.get_pos(minute)

print(math.sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)))


Measured memory_bytes: 9312
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	d = Dict{Int,Int}()
	for i in 1:n
		if haskey(d,a[i])
			d[a[i]] += 1
		else
			d[a[i]] = 1
		end
	end
	k = 0
	for i in keys(d)
		if d[i]>i
			k += d[i]-i
		elseif d[i]<i
			k += d[i]
		end
	end
	println(k)
end

main()

Measured memory_bytes: 168940
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const int N = 300006;

int main() { 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll>a(n);
    map<ll,ll>h;
    ll sum = 0;
    for(ll&x:a) {
        cin >> x;
        h[x] += 1;
        sum += x;
    }
    int q;
    cin >> q;
    while(q--) {
        ll x, y;
        cin >> x >> y;
        sum -= x * h[x];
        sum += y * h[x];
        h[y] += h[x];
        h[x] = 0;
        cout << sum << '\n';
    }
    return 0; 
}
 

Measured memory_bytes: 9996
int a[200010];
int ans[200010];
int main(){
int n;
scanf("%d",&n);
for(int i=2;i<=n;i++)scanf("%d",&a[i]);
for(int i=2;i<=n;i++)ans[a[i]]++;
for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
}


Measured memory_bytes: 3236
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

//HEADER FILES AND NAMESPACES
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp>   
using namespace std;
using namespace __gnu_pbds;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy

const int MAX = 1000001; 

int factor[MAX]; 
  
void generatePrimeFactors() 
{ 
    factor[1] = 1; 
  
    for (int i = 2; i < MAX; i++) 
        factor[i] = i; 
  
    for (int i = 4; i < MAX; i += 2) 
        factor[i] = 2; 
  
    for (int i = 3; i * i < MAX; i++) { 
        if (factor[i] == i) {  
            for (int j = i * i; j < MAX; j += i) { 
                if (factor[j] == j) 
                    factor[j] = i; 
            } 
        } 
    } 
} 

int calculateNoOFactors(int n) 
{ 
    if (n == 1) 
        return 1; 
  
    int ans = 1; 

    int dup = factor[n]; 
  

    int c = 1; 

    int j = n / factor[n]; 

    while (j != 1) { 

        if (factor[j] == dup) 
            c += 1; 
  
        else { 
            dup = factor[j]; 
            ans = ans * (c + 1); 
            c = 1; 
        } 
  
        j = j / factor[j]; 
    } 
    ans = ans * (c + 1); 
  
    return ans; 
} 
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);  

#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r+", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w+", stdout);
#endif  
	generatePrimeFactors();
    int n;
    cin >> n;
    ll ans = 0;
    for(int i=1;i<n;i++) {
    	ans += calculateNoOFactors(n-i);
    }
    cout << ans << '\n';
}
 
// read the question correctly (ll vs int)
// template by bqi343

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

using namespace std;

struct UnionFind {
    vector<int> par;
    vector<int> gn;
    
    UnionFind(int N) : par(N+1, 0), gn(N+1, 1) {
        for(int n=1; n<=N; n++) {
            par[n] = n;
        }
    }
    
    int root(int x) {
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    
    void unite(int x, int y) {
        int rx=root(x);
        int ry=root(y);
        
        if(rx==ry) return;
        par[rx] = ry;
        gn[ry] += gn[rx];
    }
    
    bool same(int x, int y) {
        int rx=root(x);
        int ry=root(y);
        return rx==ry;
    }

    int group_num(int x) {
        int rx=root(x);
        return gn[rx];
    }
};

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    
    UnionFind uf(N);
    vector<vector<int> > f(N+1);
    vector<vector<int> > b(N+1);
    for(int m=0; m<M; m++) {
        int a, b;
        cin >> a >> b;
        f[a].push_back(b);
        f[b].push_back(a);
        uf.unite(a, b);
    }

    for(int k=0; k<K; k++) {
        int c, d;
        cin >> c >> d;
        b[c].push_back(d);
        b[d].push_back(c);
    }

    for(int n=1; n<=N; n++) {
        int ans=uf.group_num(n)-1-f[n].size();
        for(int i=0; i<b[n].size(); i++) {
            if(uf.same(b[n][i], n)) {
                ans--;
            }
        }
        cout << ans << " ";
    }
    cout << endl;


    return 0;
    
}

Measured memory_bytes: 12920
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<pair<string,int>,int>> list(n);
  for(int i=0; i<n; i++) {
    string s;
    int p;
    cin >> s >> p;
    list[i].first.first = s;
    list[i].first.second = p*-1;
    list[i].second = i+1;
  }
  sort(list.begin(),list.end());
  for(int i=0; i<n; i++) {
    cout << list[i].second << endl;
  }
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

long long n;
long long ta = 810, mu = 1919, rin = 364364;

signed main() {
	cin >> n;
	for (long long i = 1; i <= sqrt(n); i++) {
		if (n%i == 0) {
			mu = 1;
			rin = n / i;
			while (rin >= 10) {
				mu++;
				rin /= 10;
			}
			if (ta > mu)ta = mu;
		}
	}
	cout << ta << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;
  if(A >= 13){
    cout << B << endl;
  } else if(A >= 6 && A <= 12 ){
    cout << B / 2 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())

MOD = 10 ** 9 + 7

DP = [[[[0 for i in range(4)] for j in range(4)] for k in range(4)] for l in range(N + 1)]
DP[0][3][3][3] = 1

for len in range(N):
  for i in range(4):
    for j in range(4):
      for k in range(4):
        if DP[len][i][j][k] == 0: continue
        for a in range(4):
          if (a, i, j) == (2, 1, 0): continue
          if (a, i, j) == (2, 0, 1): continue
          if (a, i, j) == (1, 2, 0): continue
          if (a, i, k) == (2, 1, 0): continue
          if (a, j, k) == (2, 1, 0): continue

          DP[len + 1][a][i][j] += DP[len][i][j][k]
          DP[len + 1][a][i][j] % MOD

Ans = 0
for i in range(4):
  for j in range(4):
    for k in range(4):
      Ans += DP[N][i][j][k]
      Ans %= MOD
                         
print(Ans)

Measured memory_bytes: 3440
#include<stdio.h>

int main(void)
{
  int x , i;
 
  for(i = 0 ; i < 10000; i++){
    scanf("%d", &x);
    if(x == 0){
      break;
    }
    printf("Case %d: %d\n",i+1,x);
  }

  return 0;
}



Measured memory_bytes: 2044
#include<cstdio>
#include<algorithm>
#include<queue>
#define inf 1000000
#define max 1010
using namespace std;
int H,W,N,x0,y0;
char map[max][max];
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int d[max][max]; 
typedef pair<int,int>P;
struct position
{
	int rx,ry,e;
}ed[9];
bool comp(const position a,const position b)
{
	return a.e<b.e;
}
int bfs(int sx,int sy,int gx,int gy)
{
	int tx,ty;
	queue<P>q;
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		d[i][j]=inf;
	}
	q.push(P(sx,sy));
	d[sx][sy]=0;
	while(!q.empty())
	{
		P p=q.front();
		if(p.first==gx&&p.second==gy)
		return d[p.first][p.second];
		q.pop();
		for(int i=0;i<4;i++)
		{
			tx=p.first+dx[i];
			ty=p.second+dy[i];
			if(tx>=0&&tx<H&&ty>=0&&ty<W&&map[tx][ty]!='X'&&d[tx][ty]==inf)
			{
				d[tx][ty]=d[p.first][p.second]+1;
				q.push(P(tx,ty));
			}
		}
	}
}
int main(void)
{
	while(scanf("%d%d%d",&H,&W,&N)==3)
	{
		int x1[9],y1[9];
		for(int i=0;i<H;i++)
		scanf("%s",&map[i]);
		int t=0;
		for(int i=0;i<H;i++)
		{
			for(int j=0;j<W;j++)
			{
				if(map[i][j]=='S')
				{
					x0=i;
					y0=j;
				}
				if(map[i][j]-'0'>0&&map[i][j]-'0'<=9)
				{
					ed[t].rx=i;
					ed[t].ry=j;
					ed[t].e=map[i][j]-'0';
					t++;
				}
			}
		}
		sort(ed,ed+N,comp);
		int ans=bfs(x0,y0,ed[0].rx,ed[0].ry);
		for(int i=0;i<N-1;i++)
		ans+=bfs(ed[i].rx,ed[i].ry,ed[i+1].rx,ed[i+1].ry);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 6032
# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))  # 整数
count = 0
## 同一なら次と入れ替える
for i in range(n-1):
    if a[i] == i + 1:
        a[i], a[i + 1] = a[i + 1], a[i]
        count += 1
##ラストが同一だったら先に入れ替えておく
if a[n - 1] == n:
    count += 1

print(count)


Measured memory_bytes: 14004
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)






int main() {
	int n,m;
	cin >> n>>m;
	string s = "Yes";
	if (n == 2 || m == 2) {
		s = "No";
	}
	cout << s << endl;
}

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

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 K = 0;
	SINT64 ANS;

	cin >> N;
	cin >> K;

	if ((K%2) == 1) {
		ANS = pow(N/K,3);

	} else {
		ANS = pow(N/K,3);
		SINT32 cnt = 0;
		for (SINT32 i = 1; i < N+1; i++) {
			if ((i % K) == K/2) {
				cnt++;
			}
		} 
		ANS += pow(cnt,3);
	}

	cout << ANS << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var h, w int
	fmt.Scanf("%d %d", &h, &w)
	s := make([][]int, h)
	for i := 0; i < h; i++ {
		s[i] = make([]int, w)
		for j := 0; j < w+1; j++ {
			var tmp int
			fmt.Scanf("%c", &tmp)
			if j < w {
				s[i][j] = tmp
			}
		}
	}
	answer := findRoute(s, h, w)
	fmt.Println(answer)
}

type RouteInfo struct {
	minBlack  int // continually black counts 1
	prevBlack bool
}

func isBlack(i int) bool {
	return i == 35
}

func findRoute(s [][]int, h, w int) int {
	dp := make([][]RouteInfo, h)
	for i := 0; i < h; i++ {
		dp[i] = make([]RouteInfo, w)
	}
	startMinBlack := 0
	startPrevBlack := false
	if isBlack(s[0][0]) {
		startMinBlack++
		startPrevBlack = true
	}
	dp[0][0] = RouteInfo{startMinBlack, startPrevBlack}
	for i := 1; i < h; i++ {
		if isBlack(s[i][0]) {
			if dp[i-1][0].prevBlack {
				dp[i][0] = RouteInfo{
					dp[i-1][0].minBlack,
					true,
				}
			} else {
				dp[i][0] = RouteInfo{
					dp[i-1][0].minBlack + 1,
					true,
				}
			}
		} else {
			dp[i][0] = RouteInfo{
				dp[i-1][0].minBlack,
				false,
			}
		}
	}

	for i := 1; i < w; i++ {
		if isBlack(s[0][i]) {
			if dp[0][i-1].prevBlack {
				dp[0][i] = RouteInfo{
					dp[0][i-1].minBlack,
					true,
				}
			} else {
				dp[0][i] = RouteInfo{
					dp[0][i-1].minBlack + 1,
					true,
				}
			}
		} else {
			dp[0][i] = RouteInfo{
				dp[0][i-1].minBlack,
				false,
			}
		}
	}

	for i := 1; i < h; i++ {
		for j := 1; j < w; j++ {
			var smaller RouteInfo
			if dp[i-1][j].minBlack < dp[i][j-1].minBlack {
				smaller = dp[i-1][j]
			} else if dp[i-1][j].minBlack > dp[i][j-1].minBlack {
				smaller = dp[i][j-1]
			} else if dp[i-1][j].prevBlack { // prefer prevBlack
				smaller = dp[i-1][j]
			} else {
				smaller = dp[i][j-1]
			}
			if isBlack(s[i][j]) {
				if smaller.prevBlack {
					dp[i][j] = RouteInfo{
						smaller.minBlack,
						true,
					}
				} else {
					dp[i][j] = RouteInfo{
						smaller.minBlack + 1,
						true,
					}
				}
			} else {
				dp[i][j] = RouteInfo{
					smaller.minBlack,
					false,
				}
			}

		}
	}

	return dp[h-1][w-1].minBlack
}


Measured memory_bytes: 1408
S = gets.chomp

b = 0
w = 0
(S.length).times do |i|
  if i.even?
    if S[i] == '0'
      b += 1
    else
      w += 1
    end
  else
    if S[i] == '0'
      w += 1
    else
      b += 1
    end
  end
end
puts [w,b].min

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
typedef long long L;
const int N=2e5+11,M=N<<2,oo=~0u>>2;
int n,m,mn[M],z[M],t[M],g[M];
int ql,qr,qx;
void pu(int x){
	z[x]=z[x*2];
	t[x]=t[x*2+1];
	mn[x]=min(mn[x*2],mn[x*2+1]);
}
void build(int x,int l,int r){
	if(l==r){
		z[x]=l;
		t[x]=l;
		return;
	}
	int m=l+r>>1;
	build(x*2,l,m);
	build(x*2+1,m+1,r);
	pu(x);
}
void pt(int x,int w,int r){
	assert(g[x]<=w);
	assert(t[x]<=w);
	g[x]=w;
	t[x]=w;
	z[x]=w;
	if(w<=m)mn[x]=w-r;
	else mn[x]=oo;
}
/*int ask(int x,int l,int r){
	if(l==r)return l;
	int m=l+r>>1;
	if(g[x]){
		pt(x*2,g[x],m);
		pt(x*2+1,g[x],r);
		g[x]=0;
	}
	if(t[x*2]>=qx) return ask(x*2,l,m);
	else return ask(x*2+1,m+1,r);
}
int qry(int x,int l,int r){
	if(l==r)return l;
	int m=l+r>>1;
	if(g[x]){
		pt(x*2,g[x],m);
		pt(x*2+1,g[x],r);
		g[x]=0;
	}
	if(z[x*2+1]>=qx) return qry(x*2,l,m);
	else return qry(x*2+1,m+1,r);
}*/
void upd(int x,int l,int r){
	if(z[x]>qr||t[x]<ql)return;

	if(/*ql<=l&&r<=qr&&*/z[x]>=ql&&t[x]<=qr){
		pt(x,qr+1,r);
		return;
	}
	int m=l+r>>1;
	if(g[x]){
		pt(x*2,g[x],m);
		pt(x*2+1,g[x],r);
		g[x]=0;
	}
	//if(ql<=m)
	upd(x*2,l,m);
	//if(qr>m)
	upd(x*2+1,m+1,r);
	pu(x);
}
int main(){
	cin>>n>>m;
	int i;
	build(1,1,m);
	int p=1;
	for(i=1;i<=n;++i){
		cin>>ql>>qr;
		/*qx=ql;
		ql=ask(1,1,m);
		qx=qr+1;
		if(qr!=m) {
			qr=qry(1,1,m);
		}
		//cerr<<ql<<" "<<qr<<endl;
		if(ql<=qr)*/upd(1,1,m);
		if(mn[1]>m)puts("-1");
		else printf("%d\n",mn[1]+i);
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n,c;

ll solve(vector<P> vp){
    ll res = 0;
    vector<ll> sr(n+1,0),ml(n+1,0);
    rep(i,n)sr[i+1] = sr[i] + vp[i].second;
    rep(i,n)sr[i+1] -= vp[i].first;
    rep(i,n)ml[i+1] = ml[i] + vp[n-1-i].second;
    rep(i,n)ml[i+1] -= 2*(c-vp[n-1-i].first);
    rep(i,n){
        ml[i+1] = max(ml[i],ml[i+1]);
        sr[i+1] = max(sr[i],sr[i+1]);
    }

    // rep(i,n+1)cout << sr[i] << " ";
    // cout << endl;
    // rep(i,n+1)cout << ml[i] << " ";
    // cout << endl;

    rep(i,n+1){
        res = max(res,sr[i]);
        // cout << "!" << sr[i] << " " << ml[n-i] << endl;
        res = max(res,sr[i] + ml[n-i]);
    }

    return res;
}

int main(){
    cin >> n >> c;
    vector<P> vp(n);
    vector<ll> sr(n+1,0),sl(n+1,0);
    vector<ll> mr(n+1,0),ml(n+1,0);
    ll ans = 0;
    rep(i,n)cin >> vp[i].first >> vp[i].second;
    // cout << "!" << endl;
    // rep(i,n)cout << vp[i].first << " " << vp[i].second << endl;
    // cout << "!" << endl;

    ans = max(ans,solve(vp));
    reverse(ALL(vp));
    rep(i,n)vp[i].first = c - vp[i].first;
    ans = max(ans,solve(vp));
    cout << ans << endl;

}

Measured memory_bytes: 8064
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
long long gcd(long x,long y){
    if(y == 0){
        return x;
    }
    return gcd(y,x%y);
}

int main(){
    long long n,k;
    cin >> n >> k;
    long long maxn = 0;
    vector<long long> num(n);
    for(long long i=0;i<n;i++){
        cin >> num[i];
        if(num[i]>maxn){
            maxn = num[i];
        }
    }
    long long g = num[0];
    for(long long i=0;i<n;i++){
        g = gcd(g,num[i]);
    }
    if(k<=maxn&&k%g==0){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 1024
x,k,d = map(int,input().split())
if x < 0:
    x = -x
if x - k*d > 0:
    print(x-k*d)
    quit()

t = x//d
y = x-d*t
if t%2 == 1:
    if k%2 == 0:
        print(abs(y-d))
    else:
        print(abs(y))
else:
    if k%2 == 0:
        print(abs(y))
    else:
        print(abs(y-d))


Measured memory_bytes: 9176
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

void prts(V<char> ss) {
  REP(i, ss.size()) {
    cout << ss[i];
  }
  cout << endl;
}

int main() {
  char a, b; cin >> a >> b;
  if (a=='H') {
    cout << b << endl;
  } else {
    if (b=='H') cout << 'D' << endl;
    else cout << 'H' << endl;
  }
  return 0;
}


Measured memory_bytes: 256
# AGC034A - Kenken Race
def main():
    n, a, b, c, d = tuple(map(int, input().rstrip().split()))
    S = input().rstrip()
    if "##" in S[a - 1 : c] or "##" in S[b - 1 : d]:
        flg = 0
    else:
        if c < d:
            flg = 1
        else:
            flg = "..." in S[b - 2 : d + 1]
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

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

int main(){
    ll n, a;
    cin >> n;
    vll x;
    for(ll i=0; i<n; i++){
        cin >> a;
        x.push_back(a);
    }
    
    ll ans = 0;
    for(ll i=0; i<n-1; i++){
        if(x[i] > x[i+1]){
            ans += x[i] - x[i+1];
            //cout << ans << endl;
            x[i+1] = x[i];
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    using namespace std;
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int N, K; cin >> N >> K;
    vector<int> P(N);
    for (auto &p : P) cin >> p;
    sort(P.begin(), P.end());
    int ans = 0;
    for (int i = 0; i < K; ++i) ans += P[i];
    cout << ans << '\n';
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <cmath>
#include <stack>
#include <climits>
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;

ll N,M;
ll l[364364],r[364364];
vector<P> vec;
ll data[700200];
ll datb[700200];
ll pos = 0;
ll MM;
void add(ll a , ll b, ll x, ll k, ll l, ll r){
  if(a <= l && r<= b){
    data[k] += x;
  }
  else if(l < b && a < r){
    datb[k] += (min(b,r) - max(a,l))*x;
    add(a,b,x,k*2+1,l,(l+r)/2);
    add(a,b,x,k*2+2,(l+r)/2,r);
  }
}
int sum(ll a , ll b , ll k , ll l , ll r){
  if(b <= l || r<= a){
    return 0;
  }
  else if(a <= l && r <= b){
    return data[k] * (r-l) + datb[k];
  }
  else{
    ll res = (min(b,r) - max(a,l)) * data[k];
    res += sum(a,b, k*2+1 ,l,(l+r)/2);
    res += sum(a,b, k*2+2 ,(l+r)/2,r);
    return res;
  }
}
int main(){
  cin >> N >> M;
  MM = 1;
  while(MM < M) MM *= 2;
  MM*= 2;
  for(int i=0;i<N;i++){
    cin >> l[i] >> r[i];
    vec.push_back(make_pair(r[i]-l[i]+1,i));
  }
  sort(vec.begin(),vec.end());
  for(int i=1;i<=M;i++){
    while(vec[pos].first < i && pos < N){
      ll tmp = vec[pos].second;
      add(l[tmp],r[tmp]+1,1,0,0,MM);
      /*
      cout << l[tmp] << "  " << r[tmp] << endl;
      for(int i=0;i<MM*2;i++){
        cout << " " << data[i] << " " << datb[i] << endl;
      }
      */
      pos++;
    }
    ll cnt = 0;
    for(int j=0;j<=M;j+=i){
      cnt += sum(j,j+1,0,0,MM);
    }
    cout << cnt + N-pos << endl;
  }
}

Measured memory_bytes: 20584