akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    using namespace std;
    char s[55];
    int a[10];
    map<char,int> m;
    int main()
    {
    	cin>>s;
    	int n=strlen(s);
    	if (n>9) {
    		puts("NO");
    		return 0;
    	}
    	int cnt=0,cnt2=0,cnt3=0;
    	for (int i=0;i<n;i++)
    	{	
		if (s[i]!='A' && s[i]!='K' && s[i]!='B' )
		  if (s[i]!='H' && s[i]!='R' && s[i]!='I')
    		{
			puts("NO");
			return 0;
		}
		if (s[i]=='A') cnt++;else
    		if (s[i]=='K' && (cnt>1 || cnt2))
    		{
    			puts("NO");
    			return 0;
    		}else if (s[i]=='K') {
    			cnt2++;
    			a[1]=cnt;
    		}
    		if (s[i]=='I' && (cnt>1 || cnt2!=1))
    		{
    			puts("NO");
    			return 0;
    		}
    		else if (s[i]=='I'){
    			if (cnt>=1 && a[1]==0){
    				puts("NO");
    				return 0;
    			}
    			else {
    				cnt2++;
    				a[2]=cnt;
    			}
    		}
    	       if (s[i]=='H' && (cnt>1 || cnt2!=2)) 
    		{
    			puts("NO");
    			return 0;
    		}
    		else if (s[i]=='H'){
    			if (cnt>=1 && a[1]==0)
    			{
    				puts("NO");
    				return 0;
    			}
    			else{
    				cnt2++;
    				a[3]=cnt;
    			}
    		}
    		else if (s[i]=='B' && (cnt>2 || cnt2!=3))
    		{
    			puts("NO");
    			return 0;
    		}
    		else if (s[i]=='B') {
    			if (cnt-a[3]>1) {
    				puts("NO");
    				return 0;
    			}
    			cnt2++;
    			a[4]=cnt;
    		}
    		if (s[i]=='R' && (cnt>3|| cnt2!=4))
    		{
    			puts("NO");
    			return 0;
    		}
    		else if (s[i]=='R') {
    			if (cnt-a[4]>1)
    			{
    				puts("NO");
    				return 0;
    			}
    			cnt2++;
    			a[5]=cnt;
    		}
    	}
	if (cnt-a[5]>1)
	{
		puts("NO");
		return 0;
	}
    	if (cnt>4 || cnt2!=5) puts("NO");
    	else puts("YES");
     
    }

Measured memory_bytes: 256
for i in range(int(input())):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
    if abs((y1 - y2) * (x3 - x4) - (y3 - y4) * (x1 - x2)) < 1.e-10:
        print('YES')
    else:
        print('NO')

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

constexpr int MAX_LEN = 1e5;
constexpr int DIVISOR = 13;
constexpr int MOD = 1e9 + 7;

long dp[MAX_LEN + 1][DIVISOR];

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

  int mul{1};
  dp[S.length()][0] = 1;
  for (int i = S.length() - 1; i >= 0; --i) {
    if (S[i] == '?') {
      for (int v{}; v < 10; ++v) {
        for (int j{}; j < DIVISOR; ++j) {
          dp[i][(v * mul + j) % DIVISOR] += dp[i + 1][j];
          dp[i][(v * mul + j) % DIVISOR] %= MOD;
        }
      }
    } else {
      int v = S[i] & 0xF;
      for (int j{}; j < DIVISOR; ++j) {
        dp[i][(v * mul + j) % DIVISOR] += dp[i + 1][j];
        dp[i][(v * mul + j) % DIVISOR] %= MOD;
      }
    }
    mul *= 10;
    mul %= DIVISOR;
  }

  cout << dp[0][5] << endl;
  return 0;
}


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

#define endl "\n"
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

void solve() {
	char ch;
	cin >> ch;
	printf("%c\n", ch + 1);
}

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count = scanner.nextInt();
        int pileSize = scanner.nextInt();
        int[] arr = new int[count];
        for (int i = 0; i < count; ++i) {
            arr[i] = scanner.nextInt();
        }

        boolean[] canWin = new boolean[pileSize + 1];

        for (int i = 1; i <= pileSize; ++i) {
            for (int move : arr) {
                if (move <= i) {
                    if (!canWin[i - move]) {
                        canWin[i] = true;
                    }
                }
            }
        }

        System.out.println(canWin[pileSize] ? "First" : "Second");
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N; cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    ll money = 1000;
    rep(i, N){
        int tmp = A[i];
        for(int j = i + 1; j < N; j++){
            if(tmp > A[j])break;
            if(tmp < A[j]){
                ll k = money / tmp;
                money %= tmp;
                money += k * A[j];
                i = j - 1;
                break;
            }
        }
    }
    cout << money << endl;
} 

Measured memory_bytes: 3608
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
    int n,j,i;
    int q[100];
    int kaisu=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>q[i];
    }
    int flag=1;
    
    while(flag){
        flag=0;
        for(i=n-1;i>0;i--){
            if(q[i]<q[i-1]){
                j=q[i];
                q[i]=q[i-1];
                q[i-1]=j;
                kaisu++;
                flag=1;
            }
        }
    }
    for(i=0;i<n;i++){
        if(i<n-1)cout<<q[i]<<' ';
        else cout<<q[i]<<endl;
        
    }
    cout<<kaisu<<endl;
    return 0;
}





Measured memory_bytes: 3104
def dijkstra(n):
    distance_list[0] = 0
    while True:
        min_distance = 10**9
        u = -1
        for i in range(n):
            distance = distance_list[i]
            if flag_list[i] < 2 and distance < min_distance:
                min_distance = distance
                u = i
        if u == -1:
            break
        flag_list[u] = 2
        for v in range(n):
            edge = m_list[u][v]
            if flag_list[v] < 2 and -1 < edge:
                if distance_list[u] + edge < distance_list[v]:
                    distance_list[v] = distance_list[u] + edge
                    p[v] = u
                    flag_list[v] = 1


if __name__ == "__main__":
    n = int(input())
    m_list = [[-1]*n  for _ in range(n)]
    for i in range(n):
        in_list = list(map(int, input().split()))
        adj_num = in_list[1]
        tmp = []
        if adj_num > 0:
            for j in range(adj_num):
                m_list[i][in_list[j*2+2]] = in_list[j*2+3]

    flag_list = [0]*n # 0: 未到達, 1: 処理中, 2: 完了
    distance_list = [10**9]*n
    p = [-1]*n
    dijkstra(n)
    for i, d in enumerate(distance_list):
        print(i, d)



Measured memory_bytes: 5816
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
#include <string>
#include <limits>
using namespace std;
int gcd(int a, int b)//最大公約数
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int mod = 1000000000 + 7;
vector<int> v;
class Calc
{
    // 宣言
    long long a;

    public:
        // 素因数分解
        void decompositPrime(long long a);
};

/*
 * 素因数分解
 */
void Calc::decompositPrime(long long n)
{
    // 割る数の初期値
    a = 2;
    // √n ≧ a ( n ≧ a * a ) の間ループ処理
    while (n >= a * a) {
        // a で割り切れたら、a は素因数
        // そして、割られる数を a で割る
        // a で割り切れなかったら、 a を 1 増加させる
        if (n % a == 0) {
            //printf("%d * ", a);
             v.push_back(a);
            n /= a;
        } else {
            a++;
        }
    }
    // 最後に残った n は素因数
    v.push_back(n);
    //printf("%d\n", n);
}
vector<int> divisor(int n) {//約数発見
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    std::sort(ret.begin(), ret.end());
    return ret;
}
long nc2(long n){
    return n*(n-1)/2;
}
int main(){
    //std::stack<int> stack;
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < k; i++){
        vector<int> b(n,0);
        for(int j = 0; j < n; j++){
            b[max(0, j-a[j])] ++;
            if(j+a[j]+1 <= n-1){
                b[j+a[j]+1] --;
            }
        }
        // for(int i = 0; i < n-1; i++){
        //     cout << b[i] << " ";
        // }
        // cout << b[n-1] << endl;
        for(int j = 1; j < n; j++){
            b[j] += b[j-1];
        }
        if(a == b){
            break;
        }
        a = b;
    }
    for(int i = 0; i < n-1; i++){
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
    //cout << ans << endl;
    return 0;
}






Measured memory_bytes: 4788
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n = sc.nextInt();
		int[] a=new int[n];
		int count=0;
		for(int i = 0; i<n; i++){
			a[i]= sc.nextInt();
		}
		for(int i = 0; i<n-1; i++){
			if(a[i]==i+1){
				if(a[i+1]==i+2){
					count++;
					a[i+1]=a[i];
				}else{
					count++;
				}
			}
		}
		if(a[n-1]==n){
			count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 49528
while line = gets
    a,b,c,d,e,f = line.split.map(&:to_f)
    x = (c * e - b * f)/(a * e - b * d) + 0.000
    y = (c * d - a * f)/(b * d - a * e) + 0.000
    printf("%.3f %.3f\n", x, y)
end

Measured memory_bytes: 6132
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<ctime>
#include<climits>
#include<vector>
//#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    //ios::sync_with_stdio(0);
    cin>>s;
    int len=s.length();
    for(int i=0;i<len;i++)
    {
        if(s[i]=='C')
        {
            for(int j=i+1;j<len;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]






use std::cmp::{max, min};
use std::ops::Range;

const MAXDIGIT: usize = 15;

fn neighbor(i: usize) -> Range<usize> {
    let start = i.saturating_sub(1);
    let end = min(i + 2, 10);
    start..end
}

fn make_dp(mut n: usize) -> (Vec<Vec<usize>>, usize, usize, usize) {
    let mut dp = vec![vec![0; MAXDIGIT]; 10];

    for d in 1..MAXDIGIT {
        for i in 0..10 {
            if d == 1 {
                dp[i][d] = 1;
            } else {
                for l in neighbor(i) {
                    dp[i][d] += dp[l][d - 1];
                }
            }

            if i != 0 {
                if n <= dp[i][d] {
                    return (dp, n, i, d);
                }

                n -= dp[i][d];
            }
        }
    }

    unreachable!("too large query");
}


fn get_nth(dp: &Vec<Vec<usize>>, mut n: usize, i: usize, d: usize) -> String {
    
    if d == 1 {
        assert_eq!(n, 1);
        return i.to_string();
    }

    assert!(n <= dp[i][d]);

    for l in neighbor(i) {
        if dp[l][d - 1] >= n {
            return format!("{}{}", i, get_nth(dp, n, l, d - 1));
        }
        n -= dp[l][d - 1];
    }

    unreachable!("bug");
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n = s.trim().parse::<usize>().unwrap();

    let (dp, n, i, d) = make_dp(n);
    

    println!("{}", get_nth(&dp, n, i, d));
}


Measured memory_bytes: 4352
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int A, B, N; cin >> A >> B >> N;

	cout << floor(A*min(N,B-1) / B) << endl;

	return 0;
}



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

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

    double count = 0;

    for (size_t i = 1; i <= N; i++)
    {
        if (i%2 != 0)
        {
            count++;
        }
        
    }
    
    cout << count / N << endl;
}

Measured memory_bytes: 256
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1, 105):
    for j in range(1, 105):
        for k in range(1, 105):
            v = i*i+j*j+k*k+i*j+j*k+k*i
            if v < 10050:
                ans[v] += 1
for i in range(n):
    print(ans[i+1])

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

using namespace std;

int main(){
        int N;
        cin>>N;
        int res=1e9;
        for(int i=0;i<N;i++){
                int a;
                cin>>a;
                int cnt=0;
                while(a%2==0){
                        cnt++;
                        a/=2;
                }
                res=min(cnt, res);
        }
        cout<<res<<endl;
        return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;


int main()
{
    ll n,m;cin >>n>>m;
    vector<V>g(n,V());
    rep(i,m){
        ll a,b;cin >>a >>b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    bool flg=false;
    for(ll v:g[0]){
        for(ll k:g[v]){
            if(k==n-1){
                flg=true;
            }
        }
    }
    if(flg)puts("POSSIBLE");
    if(!flg)puts("IMPOSSIBLE");
    return 0;
}


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

int main() {
    int n, q, c, t, x, v_size;
    cin >> n >> q;
    vector<vector<int>> v(n);
    for(int j = 0; j < q; ++j) {
        cin >> c;
        if(c == 0) {
            cin >> t >> x;
            v[t].push_back(x);
        } else if(c == 1) {
            cin >> t;
            v_size = v[t].size();
            if(v_size) {
                for(int i = 0; i < v_size; ++i) {
                    cout << v[t][i];
                    if(i != v_size - 1) cout << " ";
                    else cout << '\n';
                }
            } else {
                cout << '\n';
            }
        } else {
            cin >> t;
            v[t] = {};
        }
    }
}



Measured memory_bytes: 5764
#include <bits/stdc++.h>
using namespace std;
const int N=2e4+5;

int n,a[N],b[N],p;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i=1;i<=n;i++){
		a[i]=i;
		b[i]=-i;
	}
	for (int i=1;i<=n;i++){
		cin >> p;
		a[p]+=i;
		b[p]=i-a[p];
		for (int j=p+1;j<=n;j++){
			int now=max(a[j-1]+1-a[j],
			b[j]-(b[j-1]-1));
			a[j]+=now;
			b[j]-=now;
		}
	}
	int mn=INT_MAX;
	for (int i=1;i<=n;i++){
		mn=min(mn,a[i]);
	}
	for (int i=1;i<=n;i++){
		cout << a[i]+1-mn << (i==n?"\n":" ");
	}
	mn=INT_MAX;
	for (int i=1;i<=n;i++){
		mn=min(mn,b[i]);
	}
	for (int i=1;i<=n;i++){
		cout << b[i]+1-mn << (i==n?"\n":" ");
	}
}

Measured memory_bytes: 768
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] num = new int[n];
		String[] str = (br.readLine()).split(" ");
		for (int i = 0; i<n ; i++ ) {
			num[i] = Integer.parseInt(str[i]);
		}
		int count = 0;
		for (int i = 0 ; i<num.length ; i++  ) {
			for (int j = num.length-1; j>=i+1 ; j-- ) {
				if ( num[j] < num[j-1]) {
					int work = num[j];
					num[j] = num[j-1];
					num[j-1] = work;
					count++; 
				}
			}
		}
		for (int i = 0; i<num.length ; i++ ) {
			if ( i == num.length-1) {
				System.out.println(num[i]);
			}else{
				System.out.print(num[i] + " ");
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 24496
# coding: utf-8
# Your code here!
N, K = map(int, input().split())

########関数部分##############
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
############################
 
 
#####関数をつかってみる．#####
######今回は二進数に変換######
x10 = N
x2 = Base_10_to_n(x10, K)
print( len(str(x2)) )#"100011"が表示される．

Measured memory_bytes: 3060
#168b
#値を受け取る
K = int(input())
S = str(input())

#Kになるまで文字を取り、K以降の文字列は'…'で表す
def answer(K: int, S: str) -> str:
    if len(S) <= K:
        return S
    else:
        return S[:K] + '...'


print(answer(K, S))

Measured memory_bytes: 9192
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
#include<string>
#include<iostream>
#include<tuple>
#include<utility>
#include<set>
using namespace std;
typedef long long int llint;
const llint big=((llint)1<<(llint)30);
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define pub push_back
#define res resize
//JOI 2017 ho-3 kingdom
//5:20???
//????????¢?´¢
//JII
//JJI
//JJI?????????
int main(void){
	int H,W,i,j,maxh=0,minh=big,maxb,minb,gen;
	vector<vector<int>>high[4];
	cin>>H>>W;
	high[0].res(H);
	high[1].res(H);
	high[2].res(H);
	high[3].res(H);
	for(i=0;i<H;i++){
		high[0][i].res(W);
		high[1][i].res(W);
		high[2][i].res(W);
		high[3][i].res(W);
	}
	for(i=0;i<H;i++){
		
		for(j=0;j<W;j++){
			cin>>high[0][i][j];
			maxh=max(maxh,high[0][i][j]);
			minh=min(minh,high[0][i][j]);
			high[1][i][W-j-1]=high[0][i][j];
			high[2][H-i-1][j]=high[0][i][j];
			high[3][H-i-1][W-j-1]=high[0][i][j];
		}
	}
	maxb=(maxh-minh);
	minb=0;
	while(maxb-minb!=1){
		gen=(maxb+minb)/2;
		
		bool can=false;
		//printf("de%d\n",gen);
		for(int k=0;k<4;k++){
			int y=0,x=0;
			while(y<H&&x<W){
				//J????????????
				for(i=y;i<H;i++){
					if(high[k][i][x]<maxh-gen){break;}
				}
				
				if(i==H){x++;continue;}
				for(j=x;j<W;j++){
					if(high[k][y][j]>minh+gen){break;}
				}
				if(j==W){y++;continue;}
				else{break;}//??????
			}
			if(y==H||x==W){can=true;break;}
		}
		if(!can){minb=gen;}
		else{maxb=gen;}
	}
	cout<<maxb<<endl;
	return 0;
}

Measured memory_bytes: 65640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;


int main() {
  int n,m;
  cin >> n >> m;
  vector<pair<ll, int>> v(n);
  rep(i,n){
    cin >> v[i].first >> v[i].second;
  }
  sort(rng(v));
  
  ll count=0;
  ll ans=0;
  rep(i,n){
    if(v[i].second+count<=m){
      ans += v[i].first*v[i].second;
      count += v[i].second;
      if(count == m){
        cout << ans << endl;
        return 0;
      }
    }
    else{
      ans+=v[i].first*(m-count);
      cout << ans << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Graph{
	private:
	int n;
	vvp g;
	public:
	vl DIJ(int s){
		priority_queue<pll> q;
		vl d(n,INF);
		d[s]=0;
		q.push({0,s});
		while(!q.empty()){
			pll p=q.top();
			q.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(auto i:g[v]){
				ll u=i.first,D=d[v]+i.second;
				if(d[u]>D){
					d[u]=D;
					q.push({-D,u});
				}
			}
		}
		return d;
	}
	Graph(int v){
		n=v;
		g=vvp(v);
	}
	void add_edge(int s,int t,int c){
		g[s].push_back({t,c});
		g[t].push_back({s,c});
	}
};

int n,m,s,t;

int main(){
	cin>>n>>m>>s>>t;
	s--;t--;
	Graph g(n),G(n);
	for(int i=0;i<m;i++){
		int u,v,A,B;
		cin>>u>>v>>A>>B;
		g.add_edge(u-1,v-1,A);
		G.add_edge(u-1,v-1,B);
	}
	vl d=g.DIJ(s),D=G.DIJ(t),a(n);
	for(int i=0;i<n;i++) a[i]=d[i]+D[i];
	for(int i=n-2;i>=0;i--) a[i]=min(a[i],a[i+1]);
	for(auto i:a) cout<<1000000000000000-i<<endl;
}

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

int main()
{
  ll h,w,n;
  cin >> h >> w >> n;
  ll tmph = n/h;
  if(n%h!=0) tmph++;
  ll tmpw = n/w;
  if(n%w!=0) tmpw++;
  cout << min(tmph,tmpw) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include<bits/stdc++.h>
#define mod 100002
#define ll long long int
#define pb push_back
#define mk make_pair

using namespace std;


int main(){
   int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int b[mod];
    for(int i=0;i<mod;i++)b[i]=0;
    for(int i=0;i<n;i++){
       b[a[i]-1]++;
        b[a[i]]++;
        b[a[i]+1]++;
    }
    int ans=0;
    for(int i=0;i<mod;i++){
        ans=max(ans,b[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    static int A;
    static int B;

    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        A = scanner.nextInt();
        B = scanner.nextInt();
        scanner.close();

        long ans = (A + B) / 2;
        if((A + B) % 2 == 0) {
            System.out.println(ans);
        } else {
            System.out.println("IMPOSSIBLE");
        }
    }
}

Measured memory_bytes: 23764
f = lambda :[int(i) for i in input().split()]
from sys import stderr
from functools import reduce
from operator import add
debug = lambda *x:stderr.write(reduce(add,repr(x))+'\n')

n = int(input())
x = f()
y = sorted(x)
med = (y[int(n/2)]+y[int(n/2)-1])/2
lmed = y[int(n/2)]
smed = y[int(n/2)-1]

for po in x:
    if po < med:
        print(lmed)
    else:
        print(smed)
        

Measured memory_bytes: 25716
#安定なソート
#ようわからん
#バブルソートはどうやっても安定的なことが言いたい？

#バブルソート
def bubble_sort(list, length):
    flag = 1
    while(flag):
        flag = 0
        for j in reversed(range(1, length)):
            if list[j][1] < list[j-1][1]:
                list[j], list[j-1] = list[j-1], list[j]
                flag = 1

    return list

#選択ソート
def selection_sort(list, length):
    for i in range(length):
        minpos = i
        for j in range(i, length):
            if list[minpos][1] > list[j][1]:
                minpos = j

        list[i], list[minpos] = list[minpos], list[i]

    return list

#安定かどうかを判定するために常に安定なソートであるバブルソートと比較する

length = int(input())
cards_ = input().split()
cards = []
cards2 = []

for c in cards_:
    cards.append([c[0], int(c[1:])])
for c in cards_:
    cards2.append([c[0], int(c[1:])])

b_list = bubble_sort(cards, length)
s_list = selection_sort(cards2, length)

result = ''
for b in b_list:
    result += b[0]+str(b[1]) + ' '
print(result[:-1])
print('Stable')

result = ''
for s in s_list:
    result += s[0]+str(s[1]) + ' '
print(result[:-1])

flag = 0
for i in range(len(b_list)):
    if b_list[i] != s_list[i]:
        print('Not stable')
        flag = 1
        break
if flag == 0:
    print('Stable')


Measured memory_bytes: 5616
import heapq
hq=[]
X, Y, Z, K= map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
B=list(map(int,input().split()))
B.sort(reverse=True)
C=list(map(int,input().split()))
C.sort(reverse=True)
searched={(0,0,0)}
heapq.heappush(hq,(-(A[0]+B[0]+C[0]),0,0,0))
D=[[1,0,0],[0,1,0],[0,0,1]]

for _ in range(K):
    abc,x,y,z=heapq.heappop(hq)
    print(-abc)
    for dx,dy,dz in D:
        if x+dx<X and y+dy < Y and z+dz < Z and (x+dx,y+dy,z+dz) not in searched:
            heapq.heappush(hq,(-(A[x+dx]+B[y+dy]+C[z+dz]),x+dx,y+dy,z+dz))
            searched.add((x+dx,y+dy,z+dz))

Measured memory_bytes: 5224
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	int n;
	int a[105];
	scanf("%d",&n);
	for (int i=1; i<=n; i++){
		scanf("%d",&a[i]);
	}
	int res=1000000;
	for (int i=1; i<=100; i++){
		int sum=0;
		for (int j=1; j<=n; j++){
			sum+=(i-a[j])*(i-a[j]);
		}
		res=min(res,sum);
	}
	printf("%d",res);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
int main() {
 int n;
 cin >> n;
 vector <tuple<string,int,int>> rs(n);
 for (int i=0;i < n;++i){
   cin >> get<0>(rs[i]) >> get<1>(rs[i]);
   get<1>(rs[i])*=-1;
   get<2>(rs[i]) = i+1;
 }
 sort(begin(rs),end(rs));

 for (auto r : rs){
   cout << get<2>(r) << endl;
 }


 
 



}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const ll MOD = 1e9+7;

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

//********************************template END****************************************//

void solve(void){

	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	vec xs(N), ys(M);

	rep(N, i) {cin >> xs[i];}
	rep(M, i) {cin >> ys[i];}

	Rep(X+1, Y, z)
	{
		int f = 1;
		rep(N, i)
		{
			f &= xs[i] < z;
		}
		rep(M, i)
		{
			f &= ys[i] >= z;
		}
		if (f)
		{
			cout << "No War" << endl;
			return;
		}
	}

	cout << "War" << endl;

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
from bisect import*
class BTreeNode:
    def __init__(self):self.key,self.child=[],[]
class BTree:
    def __init__(self):self.root=BTreeNode()
    def search_higher(self,key):
        ptr=self.root
        ret=None
        while ptr.child:
            i=bisect(ptr.key,key)
            if i!=len(ptr.key):ret=ptr.key[i]
            ptr=ptr.child[i]
        i=bisect(ptr.key,key)
        if i!=len(ptr.key):ret=ptr.key[i]
        return ret
    def search_lower(self,key):
        ptr=self.root
        ret=None
        while ptr.child:
            i=bisect_left(ptr.key,key)
            if i:ret=ptr.key[i-1]
            ptr=ptr.child[i]
        i=bisect_left(ptr.key,key)
        if i:ret=ptr.key[i-1]
        return ret
    def insert(self,key):
        def insert_rec(ptr):
            b_size=256
            if not ptr.child:
                insort(ptr.key,key)
                if len(ptr.key)==b_size*2-1:
                    ret=BTreeNode()
                    ret.key=ptr.key[:b_size]
                    ptr.key=ptr.key[b_size:]
                    return ret
            else:
                i=bisect(ptr.key,key)
                tmp=insert_rec(ptr.child[i])
                if tmp:
                    ptr.key.insert(i,tmp.key.pop())
                    ptr.child.insert(i,tmp)
                    if len(ptr.child)==b_size*2:
                        ret=BTreeNode()
                        ret.child=ptr.child[:b_size]
                        ptr.child=ptr.child[b_size:]
                        ret.key=ptr.key[:b_size]
                        ptr.key=ptr.key[b_size:]
                        return ret
        tmp=insert_rec(self.root)
        if tmp:
            root=BTreeNode()
            root.key=[tmp.key.pop()]
            root.child=[tmp,self.root]
            self.root=root
def main():
    n,*a=map(int,open(0).read().split())
    l=[0]*n
    for i,v in enumerate(a,1):l[v-1]=i
    t=BTree()
    insert,search_higher,search_lower=t.insert,t.search_higher,t.search_lower
    insert(0)
    insert(n+1)
    c=0
    for i,v in enumerate(l,1):
        c+=(search_higher(v)-v)*(v-search_lower(v))*i
        insert(v)
    print(c)
main()

Measured memory_bytes: 25884
#include<iostream>
#include<algorithm>
using namespace std;
int h,w;
int gx,gy;
int map[10][10];
int ans;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
int t;
void DFS(int x,int y,int len){
	for(int i=0;i<4;i++){
		int xx=x+dx[i],yy=y+dy[i];
		while(true){
			if(xx>=0&&xx<w&&yy>=0&&yy<h){
				if(map[yy][xx]==1){
					map[yy][xx]=0;
					DFS(xx,yy,len+1);
					map[yy][xx]=1;
					break;
				}
				if(map[yy][xx]==2&&len==t){
					ans++;
					break;
				}
			}
			else break;
			xx+=dx[i],yy+=dy[i];
		}
	}
}
int main(){
	while(true){
	cin>>w>>h;
	if(w==0&&h==0)break;
	t=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>map[i][j];
			if(map[i][j]==2){
				gy=i,gx=j;
			}
			if(map[i][j]==1)t++;
		}
	}
	ans=0;
	DFS(gx,gy,0);
	cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

bool ok(char a, char b) {
	return (a-'0') ^ (b-'0');
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	while(cin>>s) {
		stack<ll> st;
		ll N = s.size();
		REP(i, N) {
			if(st.size() && ok(st.top(), s[i])) st.pop();
			else st.push(s[i]);
		}
		
		cout<<N - st.size()<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1232
from itertools import product, permutations, combinations, combinations_with_replacement

c = [list(map(int, input().split())) for i in range(3)]

result = [c[i][j] - c[i+1][j] - c[i][j+1] + c[i+1][j+1]  for i,j in product(range(2),repeat=2)]
for i in result:
    if i!=0:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	int n, m;
	
	char a, b;
	string ans, str;
	
	char change[50000];
	
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}
		for(int i = 0; i < 50000; i++){
			change[i] = i;
		}
		for(int i = 0; i < n; i++){
			cin >> a >> b;
			change[a] = b;
		}
		cin >> m;
		ans = "";
		for(int i = 0; i < m; i++){
			cin >> a;
			str = "D";
			str[0] = change[a];
			ans = ans + str;
		}
		cout << ans << endl;
	}
	
	return 0;
}

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

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


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

using namespace std;
typedef long long LL;

inline LL read(){LL x; scanf("%lld", &x); return x;}
inline void read(char *s){scanf("%s", s);}
inline void no(){printf("-1");exit(0);}

#define maxn 120000
char s[maxn];
int main(){
	read(s + 1);
	int n = strlen(s + 1);
	if(s[n] == '1' || s[1] == '0') no();
	for(int i = 1; i < n; i += 1) if(s[i] != s[n - i]) no();
	int num = 1, k = n;
	while(k > 1){
		int x = k - 1;
		while(s[x] == '0') x -= 1;
		for(int j = 1; j < k - x; j += 1) printf("%d %d\n", num, num + j);
		printf("%d %d\n", num, num + k - x);
		num = num + k - x;
		k = x;
	}
}

Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;

int main(){
    long long  n,k;
    cin >> n >> k;
    long long in[100001];
    memset(in,0,sizeof in);
    for(int i=0;i<n;i++){
        long long  a,b;
        cin >> a >> b;
        in[a] += b;
    }
    long long sum = 0;
    long long  ans;
    for(int i=1;i<=100000;i++){
        sum +=in[i];
        if(sum >= k){
            ans = i;
            break;
        } 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=s;i<t;i++)
#define MAXNUM 111
vector<int> e[MAXNUM];
bool isusedl[MAXNUM],isusedr[MAXNUM];
int matchx[MAXNUM], matchy[MAXNUM];
int n;
bool rematch(int now)
{
    isusedl[now]=1;
    for(int k:e[now])
        if(!isusedr[k])
        {
            isusedr[k] = 1;
            int g = matchy[k];
            if (!g || (rematch(g)))
            {
                matchx[now] = k;
                matchy[k] = now;
                return 1;
            }
        }
    return 0;
}
int getmatch()
{
    int res = 0;
    memset(matchx, 0, sizeof(matchx));
    memset(matchy, 0, sizeof(matchy));
    for (int i = 1; i <= n; i++)
    {
        if (matchx[i])
            continue;
        memset(isusedr, 0, sizeof(isusedr));
        res += rematch(i);
    }
    return res;
}
int mat[111][111];
int main()
{
    int m;scanf("%d%d",&n,&m);
    rep(i,1,n+1)rep(j,1,m+1)scanf("%d",&mat[i][j]);
    rep(i,1,m+1)
    {
        rep(j,1,n+1)e[j].clear();
        rep(j,1,n+1)rep(k,i,m+1)
        e[(mat[j][k]-1)/m+1].push_back(j);
        getmatch();
        rep(j,1,n+1)
        {
            int k=matchx[j];
            rep(x,i,m+1)
            if((mat[k][x]-1)/m+1==j)
            {
                swap(mat[k][i],mat[k][x]);
                break;
            }
        }
    }
    rep(i,1,n+1){
        rep(j,1,m+1)printf("%d ",mat[i][j]);
        puts("");
    }
    rep(i,1,n+1)rep(j,1,m+1)
    {
        rep(k,i,n+1)
        if((mat[k][j]-1)/m+1==i)
        {
            swap(mat[k][j],mat[i][j]);
            break;
        }
    }
    rep(i,1,n+1){
        rep(j,1,m+1)printf("%d ",mat[i][j]);
        puts("");
    }
}

Measured memory_bytes: 512
#!/usr/bin/env python3
import sys


def solve(S: int):

    if 1 <= int(S[2:]) <= 12:
        if 1 <= int(S[:2]) <= 12:
            print("AMBIGUOUS")
        else:
            print("YYMM")
    else:
        if 1 <= int(S[:2]) <= 12:
            print("MMYY")
        else:
            print("NA")

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    solve(S)


if __name__ == "__main__":
    main()


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

int main() {
    int c[4][4]={0};
    for(int i=1;i<4;++i){
        for(int j=1;j<4;++j){
            cin>>c[i][j];
        }
    }
    int i,j,k,l;
    i=c[2][1]-c[1][1]+c[1][2]-c[2][2];
    j=c[2][1]-c[1][1]+c[1][3]-c[2][3];
    k=c[3][1]-c[1][1]+c[1][2]-c[3][2];
    l=c[3][1]-c[1][1]+c[1][3]-c[3][3];
    if(i==0&&j==0&&k==0&&l==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define set_zero(a) memset(a,0,sizeof(a));
#define ll long long
#define PI 2 * acos(0.0)
#define MAX 1000000000
#define INF 1000000 
#define M 1000000007
using namespace std;
bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{ 
       return (a.first > b.first); 
} 
int main(){
   fast_io
   string s;
   cin>>s;
   ll i = 0;
   ll j = s.length()-1;
   ll ans = 0;
   while(i <= j){
      if(s[i] != s[j]) ans++;
      j--;
      i++;
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 3628
using System;

public class Program
{
    private long H, W;

    public void Solve()
    {
        var sc = new Scanner();
        H = sc.NextInt();
        W = sc.NextInt();
        if (H % 3 == 0 || W % 3 == 0)
        {
            Console.WriteLine(0);
            return;
        }
        Console.WriteLine(Math.Min(Calc(H,W),Calc(W,H)));
    }

    private long Calc(long h, long w)
    {
        return Math.Min(Calc(h, w, h / 3), Calc(h, w, h / 3 + 1));
    }

    private long Calc(long h, long w, long h1)
    {
        long h2 = h - h1;
        long a = h1 * w;
        long b, c;
        long bc = w * h2;
        if (h2 % 2 == 0 || w % 2 == 0)
        {
            b = bc / 2;
        }
        else
        {
            b = (bc + Math.Min(w, h2)) / 2;
        }

        c = bc - b;

        long min = Math.Min(Math.Min(a, b), c);
        long max = Math.Max(Math.Max(a, b), c);
        return max - min;
    }


    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 13140
/*
      author : Nishikawa
      created: 09.08.2020 17:04:46
*/

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


int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if(a>=k) cout << k << endl;
    else if(k<=a+b) cout << a << endl;
    else{
        cout << a-(k-a-b) << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    string s;
    cin>>s;
    vector<ll> ans(s.size()+1);
    ll nowl=0;
    rep(i, s.size()){
        if(s[i] == '<'){
            ans[i]=nowl;
            nowl++;
            ans[i+1]=nowl;
        }
        else nowl=0;
    }
    reverse(s.begin(), s.end());
    ll nowr=0;
    rep(i, s.size()){
        if(s[i] == '>'){
            ans[s.size()-i]=max(nowr, ans[s.size()-i]);
            nowr++;
            ans[s.size()-i-1]=max(nowr, ans[s.size()-i-1]);
        }
        else nowr=0;
    }
    ll sum = accumulate(ans.begin(), ans.end(), 0LL);
    cout<<sum<<endl;
    return 0;
}

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

int main(){
  string s,t;
  cin>>s>>t;
  int n=s.size();
  int a=0;
  rep(i,0,n){
    if(s[i]!=t[i]) a++;
  }
  cout<<a<<endl;
}

Measured memory_bytes: 3832
// sky kaafi neeche aa gaya hai, sab choo rahe hain
// let's raise the bar now :P
#include<bits/stdc++.h>
#define ll long long
#define F f
#define S se
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const int N = 2e3 + 5;
ll dist[N];
bool vis[N];
vector<pair<ll, ll> > v[N];
ll ans[N];
int n;
void dj(int source){
    fill(dist, dist + N, LLONG_MAX);
    memset(vis, 0, sizeof(vis));
    dist[source] = 0;
    multiset<pair<ll, ll> > ms;
    ms.insert({0, source});
    while(!ms.empty()){
        pair<ll, ll> p = *ms.begin();
        ms.erase(ms.begin());
        ll x = p.second, we = p.first;
        if(vis[x]) continue;
        vis[x] = 1;
        for(auto i : v[x]){
            ll e = i.first, w = i.second;
            if(dist[x] + w < dist[e]){
                dist[e] = dist[x] + w;
                ms.insert({dist[e], e});
            }
        }
    }
    for(int i = 1; i <= n; i++)
        ans[dist[i]]++;
}
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int x, y;
    cin >> n >> x >> y;
    v[x].push_back({y, 1});
    v[y].push_back({x, 1});
    for(int i = 1; i < n; i++)
        v[i].push_back({i + 1, 1}), v[i + 1].push_back({i, 1});

    for(int i = 1; i <= n; i++)
        dj(i);
    for(int i = 1; i < n; i++)
        cout << (ans[i] / 2) << "\n";
return 0;
}


Measured memory_bytes: 512