akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <cstring>
#include <iomanip>
using namespace std;

#define double long double
#define int long long
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << '\n';
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; };
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; };

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}

signed main() {
	int k;
	cin >> k;
	int c = 1;
	for (int i = 1; true; i++, c *= 3) {
		for (int j = 1; j <= 9; j++) {
			for (int Msk = 0; Msk < c; Msk++) {
				int tmp = Msk;
				int msk = 0;
				for (int z = 0; z < i - 1; z++) {
					msk *= 3;
					msk += tmp % 3;
					tmp /= 3;
				}
				int num = j;
				bool fl = true;
				int prev = j;
				for (int z = i - 2; z >= 0; z--, msk /= 3) {
					int cur = prev + msk % 3 - 1;
					if (cur < 0 || cur >= 10) {
						fl = false;
						break;
					}
					num *= 10;
					num += cur;
					prev = cur;
				}
				if (!fl) continue;
				k--;
				if (k == 0) {
					cout << num << '\n';
					return 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a, b = map(int, input().split())
p = [int(_) for _ in input().split()]

num1, num2, num3 = 0, 0, 0
for i in p:
    if i <= a:
        num1 += 1
    elif b+1 <= i:
        num3 += 1
    else:
        num2 += 1
print(min(num1, num2, num3))

Measured memory_bytes: 3064
N, M = map(int, input().split())
cake = [list(map(int, input().split())) for i in range(N)]
ans = 0
score = []
p = [-1, 1]

for i in p:
    for j in p:
        for k in p:
            for x, y, z in cake:
                score.append(x * i + y * j + z * k)
            score.sort(reverse=True)
            ans = max(ans, sum(score[:M]))
            score.clear()
print(ans)

Measured memory_bytes: 3316
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Wed Jan  9 00:36:47 2019
//
package main

import "fmt"

func scanSlice(slice []int) {
	for i := range slice {
		fmt.Scan(&slice[i])
	}
}

func main() {
	var N int
	fmt.Scan(&N)
	arr := make([]int, N)
	scanSlice(arr)

	ans := 0
	for i := range arr {
		if i < len(arr)-1 {
			if arr[i] == i+1 {
				arr[i], arr[i+1] = arr[i+1], arr[i]
				ans++
			}
		} else {
			if arr[i] == i+1 {
				arr[i], arr[i-1] = arr[i-1], arr[i]
				ans++
			}
		}
	}
	fmt.Println(ans)
}


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

int n,q,sumv=0;
int a[100005],visited[100005];

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
		visited[a[i]]++;
		sumv+=a[i];
	}
	cin>>q;
	for (int i=1;i<=q;i++)
	{
		int b,c;
		cin>>b>>c;
		sumv+=(c-b)*visited[b];
		cout<<sumv<<endl;
		
		visited[c]+=visited[b];
		visited[b]=0;
	}
	return 0;
}

Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
int main(){
  string N;
  cin>>N;
  int sum=0;
  for(int i=0; i<N.size(); i++){
    sum+=N.at(i)-48;
  }
  if(sum%9==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3696
n,m=map(int,input().split())
h=list(map(int,input().split()))
k=[]
for i in [0]*m:
    a,b=map(int,input().split())
    a-=1
    b-=1
    if h[a]==h[b]:
        k+=[a]+[b]
    if h[a]>h[b]:
        k+=[b]
    if h[a]<h[b]:
        k+=[a]
print(n-len(set(k)))

Measured memory_bytes: 20116
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
#[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn main() {
    println!("{}", solve(&stdin!()));
}
fn solve(src: &str) -> String {
    input! {
        source = src,
        n:usize,
        m:usize,
        q:usize,
        abcd_s:[(usize1,usize1,usize,usize);q],
    }
    dfs(vec![], &abcd_s, n, m).to_string()
}

fn dfs(mut A: Vec<isize>, abcd_s: &[(usize, usize, usize, usize)], n: usize, m: usize) -> usize {
    if A.len() == n + 1 {
        let sum = abcd_s
            .iter()
            .filter(|&&(a, b, c, _)| A[b] - A[a] == c as isize)
            .fold(0, |s, (_, _, _, d)| s + d);
        return sum;
    }
    A.push(*A.last().unwrap_or(&1));

    let mut ans = 0;
    while *A.last().unwrap() <= m as isize {
        ans = max(ans, dfs(A.clone(), abcd_s, n, m));
        let l = A.last_mut().unwrap();
        *l += 1;
    }
    ans
}
test! {
    include_str!("c1_in.txt") => "110",
    include_str!("c2_in.txt") => "357500",
    include_str!("c3_in.txt") => "1",
}


Measured memory_bytes: 2192
#include <iostream>

using namespace std;

const u_int64_t R = 1'000'000'007LL;
u_int64_t perm[200'001];

u_int64_t dpow(const u_int64_t &x, const u_int64_t &y)
{
    if (y == 0)
    {
        return 1;
    }
    if (y % 2 == 0)
    {
        return dpow(x * x % R, y / 2);
    }
    return x * dpow(x, y - 1) % R;
}

u_int64_t inv(const u_int64_t &x)
{
    return dpow(x, R - 2);
}

u_int64_t ways(const u_int64_t &h, const u_int64_t &w)
{
    return perm[h + w - 2] * inv(perm[h - 1]) % R * inv(perm[w - 1]) % R;
}

int main()
{
    u_int64_t h, w, a, b;
    cin >> h >> w >> a >> b;

    perm[0] = 1;
    for (u_int64_t i = 1; i <= h + w; i++)
    {
        perm[i] = i * perm[i - 1] % R;
    }

    u_int64_t result = 0;
    for (u_int64_t i = 1; i <= h - a; i++)
    {
        result += ways(i, b) * ways(h - i + 1, w - b) % R;
        result %= R;
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 1792
program colorful_leaderboard
  implicit none
  integer :: n, a(100), i, c(0:8), r, m
  a = 0
  c = 0
  read(*,*) n
  read(*,*) a(1:n)
  do i = 1, n
    r = a(i)/400
    if (r.gt.8) r = 8
    c(r) = c(r) + 1
  end do
  m = 0
  do i = 0, 7
    if (c(i).gt.0) m = m + 1
  end do
  if (m.eq.0) then
    write(*,'(i0,x,i0)') 1, c(8)
  else
    write(*,'(i0,x,i0)') m, m+c(8)
  end if
  stop
end program colorful_leaderboard

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def main():
    O = input()
    E = input()
    password = ""
    for o, e in zip(O, E):
        password += o + e
    if len(O) > len(E): password += O[-1]
    print(password)
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 61884
#include <stdio.h>

int mygetline(char s[], int size)
{
    int c, i;

    for ( i = 0;  (c = getchar()) != EOF && c != '\n' && i < size - 1; i++ ) {
        s[i] = c;
    }

    s[i] = '\0';

    if ( c == EOF && i == 0 ){
        return -1;
    }

    return i;
}

int main()
{
  char s[256];
  mygetline(s,256);
  int i=0;
  while (s[i]!='\0') {
    i++;
  }
  for (int j=0;j<i;j++) {
    printf("x");
  }
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int a,b=0,c,i;
	scanf("%d",&a);
	c=a;
	for(i=0;i<10;i++){
		b=b+a%10;
		a=a/10;
	}
	if(c%b==0){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include<vector>
#include<iostream>
#include<algorithm>
typedef long long ll;
using namespace std;

int main(){
    int n,m; cin>>n>>m;
    vector<pair<int,int>> v(n);
    for(int i=0;i<n;i++){
        int a,b; cin>>a>>b;
        v[i]=make_pair(a,b);
    }
    sort(v.begin(),v.end());

    ll ans=0;
    for(int i=0;i<n;i++){
        if(v[i].second>=m){
            ans+=1LL*v[i].first*m;
            break;
        }else{
            ans+=1LL*v[i].first*v[i].second;
            m-=v[i].second;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(500000)
def input():
    return sys.stdin.readline()[:-1]

class BIT:
            
    def __init__(self, L):
        self.N = len(L)
        self.bit = [0]*self.N
        #for i,l in enumerate(L):
        #    self.add(i,l)
        self.N0 = 1
        while self.N0*2 <= self.N:
            self.N0 *= 2

    def add(self, a, w):
        x = a + 1
        for i in range(1000):
            self.bit[x-1] += w
            x += x & -x
            if x > self.N:
                break

    def sum(self, a):
        x = a+1
        ret = 0
        for i in range(1000):
            ret += self.bit[x-1]
            x -= x & -x
            if x <= 0:
                break        
        return ret

    #you can use this function when the BIT has only non-negative values.
    def lower_bound(self, w):
        if w<=0:
            return 0
        x = 0
        k = self.N0
        while k>0:
            if x+k<=self.N:
                if self.bit[x+k-1]<w:
                    w-=self.bit[x+k-1]
                    x+=k
            k//=2
        return x+1


def main():
    #da=BIT([1,2,3])
    #print(da.bit)
    #print(da.sum(0))
    N = int(input())

    B = [BIT([0]*N) for i in range(26)]

    S = list(input())

    for i in range(N):
        B[ord(S[i]) - ord("a")].add(i, 1)

    Q = int(input())

    for i in range(Q):
        a,b,c = input().split()
        if a=="1":
            #print(B[0].bit)
            index = int(b)-1
            c = c
            if not S[index]==c:
                old = ord(S[index]) - ord("a")
                num = ord(c) - ord("a")
                B[num].add(index, 1)
                B[old].add(index, -1)
                S[index] = c
        else:
            #print(B[0].bit)
            #print(B[0].sum(1))
            l = int(b)-1
            r = int(c)-1
            ans = 0
            for j in range(26):
                if l==0:
                    if B[j].sum(r)>0:
                        ans+=1
                else:
                    if B[j].sum(r)-B[j].sum(l-1)>0:
                        ans+=1

            print(ans)

if __name__ == '__main__':
    main()



Measured memory_bytes: 184308
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n;
    cin>>n;
    int c[300030]={};
    for(int i=0; i<n; i++){
        int a; cin>>a;
        c[a-1]++;
    }
    sort(c, c+n);
    int m=0;
    for(int i=0; i<n; i++){
        if(c[i]!=0){
            m=n-i;
            break;
        }
    }
    int s[300030];
    s[0]=0;
    for(int i=0; i<n; i++) s[i+1]=s[i]+c[i];
    int t[300030];
    for(int i=1; i<=n; i++){
        int k=lower_bound(c, c+n, i)-c;
        t[i]=s[k]+(n-k)*i;
    }
    for(int k=1; k<=n; k++){
        if(k>m){
            cout<<0<<endl;
            continue;
        }
        int l=1, r=n+1;
        while(r-l>1){
            int mid=(l+r)/2;
            if(t[mid]>=(ll)mid*k) l=mid;
            else r=mid;
        }
        cout<<l<<endl;
    }
    return 0;
}

Measured memory_bytes: 4352
let fs = require('fs');

const yourAnswerFunctionComesHere = data => {
  const splitedData = data.split(" ");
  const sortedData = splitedData.sort((x, y) => y - x);
  let answerString = "";
  for(let i = 0; i < sortedData.length; i++) {
    answerString += sortedData[i];
    if(i < sortedData.length - 1) {
      answerString += " ";
    }
  }
  console.log(answerString);
}

const readFile = path => {
  fs.readFile(path, 'utf8', (err, data) => {
    yourAnswerFunctionComesHere(data);
  });
}

const readFileWithoutArg = () => {
  const input = require('fs').readFileSync('/dev/stdin', 'utf8');
  var Arr=(input.trim()).split(" ").map(Number);
  Arr.sort(function(a,b){return b-a;});
  console.log(Arr.join(" "));
}

let sampleInputPath = "";

if(process.argv.length > 2) {
  sampleInputPath = process.argv[2];
  readFile(sampleInputPath);
} else {
  readFileWithoutArg();
}



Measured memory_bytes: 15144
#include<bits/stdc++.h>
int main()
{
	int n ,i ,j ,s=0 ,ans=0 ,t=0;
	scanf("%d",&n);
	int a[3][n+1];
	for(i = 1; i <= 2; i++)
		for(j = 1; j<=n; j++)
			scanf("%d",&a[i][j]);
	for(i = 1; i <= n; i++)
	{
		t += a[1][i];
		s = t;
		for(j = i ; j <= n;j++)
			s += a[2][j];
		ans = std::max(ans,s);
	}
	printf("%d",ans);
	return 0;
 } 

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

int n, m;
int l, r;
 
int main()
{
	cin >> n >> m;
	int maxv = -100, minv = 99999999;
	
	for(int i = 0; i < m; i++)
	{
		cin >> l >> r;
		maxv = max(maxv, l);
		minv = min(minv, r);
	}
	
	int ans = minv - maxv + 1;
	
	if(ans < 0)
		ans = 0;
	
	cout << ans << endl;
}

Measured memory_bytes: 384
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=998244353
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,a,b,k=map(int,input().split())
# MOD combination
def cmb(n, r, mod=998244353):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans=0
for i in range(n+1):
    aka=i
    if k-aka*a>=0 and (k-aka*a)%b==0:
        ao=(k-aka*a)//b
    else:
        continue
    ans+=cmb(n,aka)*cmb(n,ao)
    ans%=mod
print(ans)

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

int main()
{
	int N, M, x, y;
	cin >> N >> M;
	vector<int> box(N+1,1);
	vector<bool> sus(N+1,false);
	sus[1] = true;
	for (int i = 0; i < M; i++) {
		cin >> x >> y;
		if (sus[x]) {
			if (box[x] == 1) {
				sus[x] = false;
				sus[y] = true;
			}
			else {
				sus[y] = true;
			}
		}
		box[x]--;
		box[y]++;
	}
	int res = 0;
	for (int i = 1; i <= N; i++)
		if (sus[i])
			res++;
	cout << res << endl;
	return 0;
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MN = 100010;
const ll INF = 1e18;
const ll MOD = 1000000007;

int N, M;
int S, T;
vector<pii> g[MN];
ll d[2][MN];
ll dp[MN];
ll dpr[MN];

int main() {
	cin >> N >> M;
	cin >> S >> T;
	--S; --T;

	rep(i, M) {
		int u, v, d;
		cin >> u >> v >> d;
		--u; --v; 
		g[u].eb(v, d);
		g[v].eb(u, d);
	}

	using Data = pair<ll, int>;

	vector<int> vec[2];

	rep(tt, 2) {
		priority_queue<Data, vector<Data>, greater<Data>> que;

		int s = (tt == 0 ? S : T);
		que.push(mp(0LL, s));

		rep(i, N) {
			d[tt][i] = INF;
		}
		d[tt][s] = 0;

		while (!que.empty()) {
			Data p = que.top(); que.pop();
			int v = p.se;
			if (d[tt][v] < p.fi) continue;

			vec[tt].pb(v);

			for (auto e : g[v]) {
				ll nd = d[tt][v] + e.se;
				if (d[tt][e.fi] > nd) {
					d[tt][e.fi] = nd;
					que.push(mp(nd, e.fi));
				}
			}
		}
	}

	dp[S] = 1;
	rep(i, N) {
		int v = vec[0][i];
		for (auto e : g[v]) {
			if (d[0][e.fi] == d[0][v] + e.se) {
				dp[e.fi] = (dp[e.fi] + dp[v]) % MOD;
			}
		}
	}

	dpr[T] = 1;
	rep(i, N) {
		int v = vec[1][i];
		for (auto e : g[v]) {
			if (d[1][e.fi] == d[1][v] + e.se) {
				dpr[e.fi] = (dpr[e.fi] + dpr[v]) % MOD;
			}
		}
	}

	ll ret = dp[T] * dpr[S] % MOD;
//	cerr << ret << endl;
	ll dT = d[0][T];

	rep(v, N) {
		if (d[0][v] == d[1][v] && d[0][v] + d[1][v] == dT) {
			ll dec = dp[v] * dpr[v] % MOD;
			dec = dec * dec % MOD;
		//	cout << "dec = " << dec << endl;
			ret -= dec;
			if (ret < 0) ret += MOD;
		}

		for (auto e : g[v]) {
			if (d[0][e.fi] == d[0][v] + e.se && d[1][v] == d[1][e.fi] + e.se && d[0][v] + d[1][e.fi] + e.se == dT) {
				ll D = e.se;
				ll m1 = d[0][v];
				ll m2 = d[1][e.fi];
				if (m1 > m2) {
					swap(m1, m2);
				}
				if (m1 + D > m2) {
					ll dec = dp[v] * dpr[e.fi] % MOD;
					dec = dec * dec % MOD;
					ret -= dec;
					if (ret < 0) ret += MOD;
				//	cout << "edge = " << dec << endl;
				}
			}
		}
	}
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 15444
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();
        int[] a = new int[q];
        for (int i = 0 ; i < q ; i++) {
            a[i] = sc.nextInt();
        }
        int[] b = new int[n];
        for (int i = 0 ; i < q ; i++) {
            b[a[i] - 1]++;
        }
        for (int i = 0 ; i < n ; i++) {
            System.out.println(k - q + b[i] > 0 ? "Yes" : "No");
        }
    }

}

Measured memory_bytes: 56440
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
typedef pair<int,int> pii;
typedef long long ll;

int k,a,b;

int bisa(){
	for (int i=a;i<=b;i++){
		if (i % k == 0) return true;
	}
	return false;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	
	cin >> k >> a >> b;
	if (bisa()) cout << "OK" << "\n";
	else cout << "NG" << "\n";
	return 0;
}

Measured memory_bytes: 3620
import java.util.*;

public class Main {
    public static void main(String[] args ) throws Exception {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        if(S.equals(T)){
            System.out.println(0);
        } else {
            String[] sArray = new String[S.length()];
            String[] tArray = new String[T.length()];
            int count = 0;
            for(int i = 0;i < S.length();i++){
                sArray[i] = S.substring(i, i+1);
            }
            for(int i = 0;i < T.length();i++){
                tArray[i] = T.substring(i, i+1);
            }
            for(int i = 0;i < T.length();i++){
                if(!sArray[i].equals(tArray[i])){
                    count++;
                }
            }
            System.out.println(count);
        }

    }
}


Measured memory_bytes: 57872
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

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

int t, n, sx, sy, ans, diff = 200;
bool visited[300][300][31];  //(a, b) -> visited[a+30][b+30]
bool obj[300][300];

void dfs(int y, int x, int turn){
  if(visited[y+diff][x+diff][turn]) return;
  if(turn > t) return;

  bool flag = true;
  REP(i,0,31){
    if(visited[y+diff][x+diff][i]) flag = false;  /*??\????????¨?????????*/
  }
  if(flag) ans++;

  visited[y+diff][x+diff][turn] = true;

  REP(k,0,6){
    int nx = x + dx[k], ny = y + dy[k];
    //if(!CH(ny+100, 0, 61) || !CH(nx+100, 0, 61)) continue;
    if(obj[ny+diff][nx+diff]) continue;
    dfs(ny, nx, turn + 1);
  }
  return;
}

int main() {
  //test
  //vector<int> v;

  while(1){
    cin>>t>>n;
    if(t==0 && n==0) break;
    REP(i,0,300)REP(j,0,300) obj[i][j] = false;
    REP(i, 0, n){
      int x, y;
      cin>>x>>y;
      obj[y+diff][x+diff] = true;
    }
    cin>>sx>>sy;

    REP(i,0,300)REP(j,0,300)REP(k,0,31) visited[i][j][k] = false;
    ans = 0;

    dfs(sy, sx, 0);

    cout<<ans<<endl;
    //v.push_back(ans);
  }

  //REP(i,0,v.size()) cout<<v[i]<<" ";
  //cout<<endl;

  return 0;
}

Measured memory_bytes: 5924
// 2006à\IA fBNÌZpè

#include <iostream>
#include <cstring>

using namespace std;

const int maxP = 1000000;

int main(){
	bool isPrime[maxP];
	isPrime[1] = false;
	for(int i=2;i<maxP;i++) isPrime[i] = true;
	for(int i=2;i<maxP;i++){
		if(!isPrime[i]) continue;
		for(int j=2;i*j<maxP;j++) isPrime[i*j] = false;
	}
	int a, d, n;
	while(cin >> a >> d >> n){
		if(!a) break;
		int count = 1;
		for(int i=a;;i+=d){
			if(isPrime[i]){
				if(count == n) { cout << i << endl; break; }
				else count++;
			}
		}
	}
}

Measured memory_bytes: 0
function Main(input) {
	input = input.split(" ").map(a => parseInt(a));
	var A = input[0];
	var B = input[1];
	
	var ans = 0;
	for(;A<=B;A++){
		if(Math.floor(A / 10000) === A % 10 && Math.floor(A/1000) % 10 === Math.floor(A % 100 / 10)) ans++;
	}
	
	console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
#define ll long long
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> //lower_bound , upper_bound
// using namespace __gnu_pbds;//kth smallest : *pd.find_by_order(k-1) , no. of elem < X : pd.order_of_key(X) , delete X : pd.erase(X).
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define nl '\n'
#define pl pair<ll,ll>
#define all(v) v.begin(),v.end()
#define tc ll tc;cin>>tc;while(tc--)
const ll mod=(1e+9)+7;
const ll sz = 2e5+9;
ll gcd(ll a,ll b) {if(b==0)return a;return gcd(b,a%b);}
ll power(ll a,ll b,ll m = mod) {ll res = 1;while(b>0){if(b&1)res = (res*a)%m;b = b>>1;a = (a*a)%m;}return res;}



void solve()
{
   ll n;
   cin>>n;
   vector<ll> a(n),b(n),c(n);
   vector<vector<ll>> dp(n,vector<ll>(3,0));
   f(i,0,n) {
       cin>>a[i];
       cin>>b[i];
       cin>>c[i];
   }
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
   f(i,1,n){
     
    dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
    dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
    dp[i][2]=max(dp[i-1][1]+c[i],dp[i-1][0]+c[i]);

   }
    cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2])<<nl;
}
 
int main()
{
    #ifdef JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    clock_t beg = clock();
    solve();
    clock_t end = clock();
    fprintf(stderr, "%.3f sec, Copyright %c 2019 PyThor. \n", double(end - beg) / CLOCKS_PER_SEC , 184);
    return 0;
}

Measured memory_bytes: 8064
# coding: utf-8
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

total = sum(A)
border = total / (4 * M)
ret = 0
for a in A:
    if a >= border:
        ret += 1
if ret >= M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <math.h>

using namespace std;

int main(){

  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double ans = 0;

  double pi = acos(-1);

  double a = 2*pi * double(H*60+M)/720;
  double b = 2*pi * double(M)/60;
  double r = 0;

  r = a - b;

  ans = sqrt(A*A + B*B - 2*A*B*cos(r));
  printf("%.10f\n", ans);

  return 0;
}

Measured memory_bytes: 4140
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N; ++i) {
        chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }

    // 答え
    cout << dp[N-1] << endl;
}

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

#define int long long

const int N = 50 + 5, M = N * N;
int n, A, ar[N], dp[2][N][M];

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> A;
	for (int i = 1; i <= n; i++)
		cin >> ar[i];
	
	dp[0][0][0] = 1;
	for (int i = 1; i <= n; i++) {
		int now = (i & 1), prv = (now ^ 1);
		dp[now][0][0] = dp[prv][0][0];
		
		for (int j = 1; j <= i; j++)
			for (int x = 0; x < M; x++) {			
				dp[now][j][x] = dp[prv][j][x];
				if (ar[i] <= x)
					dp[now][j][x] += dp[prv][j - 1][x - ar[i]];
			}	
	}
	
	int ans = 0;
	for (int j = 1; j <= n; j++) {
		int x = A * j;
		ans += dp[n & 1][j][x];
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cmath>

using namespace std;

int main(void) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
	int N;
	int A, B;
	int ans = 0;

	cin >> N >> A >> B;

	for(int i = 1; i<=N; i++)
	{
		int i_root = 0;
		int i_copy = i;
		while(i_copy > 0)
		{
			i_root += i_copy %10;
			i_copy /= 10;
		}

		if(i_root >= A && i_root <= B)
			ans += i;
	}

	cout << ans;

	return 0;
}

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

int main(){
  string S;
  cin >> S;
  if(S.at(2) == S.at(3) && S.at(4) == S.at(5)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS                \
  ios::sync_with_stdio(0); \
  cin.tie(0);              \
  cout.tie(0);
#define int long long
const unsigned int M = 1000000007;
using namespace std;
int32_t main()
{
  IOS int n, m, k;
  cin >> n >> m >> k;
  int a[n + 1] = {0}, b[m + 1] = {0};
  for (int i = 1; i <= n; i++)
  {
    cin >> a[i];
    a[i] += a[i - 1];
  }
  for (int i = 1; i <= m; i++)
  {
    cin >> b[i];
    b[i] += b[i - 1];
  }
  int ans = 0;
  for (int i = 0; i <= n; i++)
  {
    if (a[i] > k)
      break;
    int l = 1, r = m;
    int idx = -1;
    while (l <= r)
    {
      int mid = (l + r) / 2;
      if (k - a[i] == b[mid])
      {
        idx = mid;
        break;
      }
      else if (k - a[i] > b[mid])
      {
        l = mid + 1;
      }
      else
      {
        idx = mid - 1;
        r = mid - 1;
      }
    }
    ans = max(ans, i + idx);
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int>kane(n);
  for(int i=0;i<n;i++)
    cin >> kane.at(i);
  sort(kane.begin(),kane.end(),greater());
  int ans=kane.at(0)/2;
  for(int i=1;i<n;i++)
    ans+=kane.at(i);
  cout << ans << endl;
  return 0;
}

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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanLLInt(A);
    scanLLInt(B);
    scanLLInt(C);
    scanLLInt(X);
    scanLLInt(Y);
    ll result = LLONG_MAX;
    for (ll abh = 0; abh <= max(X, Y); ++abh){
        ll a = max(0ll, X - abh);
        ll b = max(0ll, Y - abh);
        result = min(result, A * a + B * b + C * abh * 2);
    }
    cout << result << endl;
}


Measured memory_bytes: 256
import heapq

"""
https://juppy.hatenablog.com/entry/2019/02/18/%E8%9F%BB%E6%9C%AC_python_%E3%83%97%E3%83%A9%E3%82%A4%E3%82%AA%E3%83%AA%E3%83%86%E3%82%A3%E3%82%AD%E3%83%A5%E3%83%BC%28heapq%29%E3%82%92%E7%94%A8%E3%81%84%E3%81%9F%E3%83%97%E3%83%AA%E3%83%A0%E6%B3%95
"""

def dijkstra_heap(s,edge):
    #始点sから各頂点への最短距離
    d = [10**10]*n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d
 
################################
N = int(input())
n = N
w = N
 
edge = tuple([] for i in range(n))
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(w-1):
    a,b,c = map(int,input().split())
    edge[a-1].append([c,b-1])
    edge[b-1].append([c,a-1])


Q,K = map(int,input().split())
dist = dijkstra_heap(K-1,edge)
 
for i in range(Q):
    x,y = map(int,input().split())
    print(int(dist[x-1]+dist[y-1]))

Measured memory_bytes: 50804
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	string s,t; cin >> s >> t;
	int n = s.size();
	int m = t.size();
	s += s;
	vector<vector<int>> id(26);
	rep(i,2*n){
		id[s[i]-'a'].push_back(i);
	}
	int now = -1;
	ll ans = 0;
	rep(i,m){
		if(id[t[i]-'a'].size() == 0){
			cout << -1 << endl;
			return 0;
		}
		now = *upper_bound(id[t[i]-'a'].begin(),id[t[i]-'a'].end(),now);
		if(now >= n){
			ans += n;
			now -= n;
		}
	}
	ans += now+1;
	cout << ans << endl;
}

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<stdio.h>
using namespace std;
int main(){
  int n; double tmp,s; int count;
  vector<double> px,py; count = 1;
  while(cin >> n){
    if(n ==0){
      return 0;
    }
    s = 0; px.clear(); py.clear();
    for(int i=0;i<n;i++){
      cin >> tmp;
      px.push_back(tmp);
      cin >> tmp;
      py.push_back(tmp);
    }
    for(int i = 0;i<n-1;i++){
      s = s + (px[i] - px[i+1])*(py[i] + py[i+1]);
    }
    s = s + (px[n-1] -px[0])*(py[n-1]+py[0]);
    if(s < 0){s = -s;}
    
    printf("%d %.1f\n",count,s/2);
    count += 1;
  }
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	T res(1),now(a);
	while(b){
		if(b&1)res*=now;
		b>>=1;
		now*=now;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
bool a[30],b[30];
int main() {
	int N,ans=0;
	std::string S;
	std::cin>>N>>S;
	for(int i=1;i<N;i++){
		for(int j=0;j<26;j++){
			a[j]=b[j]=false;
		}
		for(int j=0;j<i;j++){
			a[S[j]-'a']=true;
		}
		for(int j=i;j<N;j++){
			b[S[j]-'a']=true;
		}
		int cnt=0;
		for(int j=0;j<26;j++){
			if(a[j]&&b[j])cnt++;
		}
		ans=std::max(ans,cnt);
	}
	std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;


int gcd (int a, int b) {
	if (b == 0) return a;
	return gcd(b, a%b);	
}

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


	int K,N; cin >> K >> N;
	int m = 0;
	int old = 0;
	int start; cin >> start;
	int goal;
	old = start;
	for (int i = 1; i < N; i++) {
		int a; cin >> a;
		m = max(m, a - old);
		old = a;
		goal = a;
	}
	m = max(m,start + (K - goal));
	cout << K - m << endl;



	return 0;
}


Measured memory_bytes: 3600
L = 6
table = 165.0.step(185.0, 5.0).each_cons(2).to_a 
table = [[0, 165.0]] + table + [[185.0, Float::INFINITY]]
count = Array.new(L, 0)

$<.gets.to_i.times do
  h = $<.gets.to_f
  count[table.index {|a, b| a <= h and h < b}] += 1
end

L.times do |i|
  puts "#{i + 1}:" + "*" * count[i]
end


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

signed main() {
  int A, B;
  cin >> A >> B;
  
  if( A == 1 ) A = 14;
  if( B == 1 ) B = 14;
  
  if( A < B ) cout << "Bob" << endl;
  else if( A > B ) cout << "Alice" << endl;
  else if( A == B ) cout << "Draw" << endl;
  
}

Measured memory_bytes: 256
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    A_arr = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    A_arr_bin = list(map(bin,A_arr))
    cnt = -1
    for A_bin in A_arr_bin:
        _ = len(A_bin.rsplit('1',1)[-1])
        if cnt > _ or cnt==-1:
            cnt = _
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 38256
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <vector>
#include <array>
#include <set>
#include <climits>
#include <sstream>
#include <iomanip>
#include <cassert>
#include <bitset>
#include <numeric>
using namespace std;
using namespace __gnu_pbds;
typedef tree< // find_by_order & order_of_key
        int ,
        null_type ,
        less<int> ,
        rb_tree_tag ,
        tree_order_statistics_node_update 
> new_set;
#define MOD 1000000007
#define MAXN (int)1e5+10
array<int,MAXN>arr;
array<int64_t,MAXN>dp;
int main(void){
#ifdef HELL_JUDGE
    freopen("input","r",stdin);
    freopen("output","w",stdout);
    freopen("error","w",stderr);
#endif 
    int n; scanf("%d",&n);
    for(int i=0;i<n;++i){
        cin>>arr[i];
    }
    fill(dp.begin() , dp.begin()+n , INT_MAX);
    dp[0] = 0;
    for(int i=0;i<n;++i){
        for(int j:{1,2}){
            if(i+j>n){
                continue;
            }
            dp[i+j] = min(dp[i+j] , dp[i]+(int64_t)abs(arr[i]-arr[i+j]));
        }
    }
    cout<<dp[n-1]<<'\n';
    return 0;
}


Measured memory_bytes: 1408
gets
t, a = gets.chomp.split.map(&:to_i)

const = (a - t)/0.006

errors = gets.chomp.split.map(&:to_i).map{|x| (const + x)**2}
min = errors.min
errors.each_with_index do |e, i|
  if e == min
    puts i+1
    break
  end
end

Measured memory_bytes: 1916
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<typename Monoid>
struct SegmentTree{
	using F=function<Monoid(Monoid, Monoid)>;
	int sz;
	vector<Monoid> seg;
	const F f;
	const Monoid e;

	SegmentTree(int n, const F f, const Monoid &e): f(f), e(e){
		sz=1;
		while(sz<n) sz<<=1;
		seg.resize(2*sz, e);
	}

	SegmentTree(int n, const F f, const Monoid &e, vector<Monoid> v): f(f), e(e){
		sz=1;
		while(sz<n) sz<<=1;
		seg.resize(2*sz, e);
		for(int i=0; i<n; i++) seg[i+sz]=v[i];
		for(int i=sz-1; i>=1; i--){
			seg[i]=f(seg[2*i], seg[2*i+1]);
		}
	}

	void update(int k, const Monoid &x){
		k+=sz;
		seg[k]=x;
		while(k>1){
			k>>=1;
			seg[k]=f(seg[2*k], seg[2*k+1]);
		}
	}

	Monoid query(int a, int b){
		a+=sz, b+=sz;
		Monoid ret=e;
		for(;a<b; a>>=1, b>>=1){
			if(b&1) ret=f(ret, seg[--b]);
			if(a&1) ret=f(ret, seg[a++]);
		}
		return ret;
	}

	Monoid operator[](const int &k) const{
		return seg[k+sz];
	}
};
int main()
{
    int n;
	cin>>n;
	ll x[200020], d[200020], y[200020];
	vector<ll> v;
	for(int i=0; i<n; i++){
		cin>>x[i]>>d[i];
		v.push_back(x[i]); v.push_back(x[i]+d[i]);
	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	int m=v.size();
	int l[400040];
	fill(l, l+m, -1);
	for(int i=0; i<n; i++){
		y[i]=lower_bound(v.begin(), v.end(), x[i]+d[i])-v.begin();
		x[i]=lower_bound(v.begin(), v.end(), x[i])-v.begin();
		l[x[i]]=i;
	}
	const ll MOD=998244353;
	const int INF=1e9+7;
	int r[200020];
	SegmentTree<int> seg(m, [](int a, int b){ return max(a, b);}, -1);
	for(int i=m-1; i>=0; i--){
		if(l[i]==-1) continue;
		int k=l[i];
		int t=seg.query(x[k], y[k]);
		r[k]=max(t, (int)y[k]);
		seg.update(i, r[k]);
	}
	vector<int> vr[400040];
	for(int i=0; i<n; i++) vr[r[i]].push_back(x[i]);
	ll dp[400040]={};
	dp[0]=1;
	for(int i=1; i<m; i++){
		(dp[i]+=dp[i-1])%=MOD;
		for(auto j:vr[i]){
			(dp[i]+=dp[j])%=MOD;
		}
	}
	cout<<dp[m-1]<<endl;
	return 0;
}


Measured memory_bytes: 30956
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int x = 0;

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

        System.out.println(x);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int x,y;

void func(){

	x = abs(x);
	y = abs(y);

	if(x > y){

		swap(x,y);
	}

	if(x == 0 && y%2 == 1){

		if(y == 1){

			printf("1\n");
		}else{

			printf("%d\n",y+1);
		}

	}else{

		if(x%2 == 0 && y%2 == 0){

			printf("%d\n",x+y);
		}else{

			printf("%d\n",(x/2)*2+(y/2)*2+1);
		}
	}
}


int main(){

	while(scanf("%d %d",&x,&y) != EOF){

		func();
	}

	return 0;
}



Measured memory_bytes: 3164
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    ll n,m; cin>>n>>m;
    if(n==1 && m==1)
    cout<<1<<endl;
    else if(n==1 || m==1)
    cout<<max(n,m)-2<<endl;
    else
    cout<<(n-2)*(m-2)<<endl;
    
}

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

int main() {
    long long n, k;
    cin >> n >> k;
    long long result = (n / k) * (n / k) * (n / k);
    if (k % 2 == 0 && n >= k / 2) {
        auto t = (n - k / 2) / k + 1;
        result += t * t * t;
    }
    cout << result;
    return 0;
}

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

struct S{
    int r, c, s, cnt;
};

signed main(){
    while(1){
        int p, q;
        cin >> p >> q;
        if(p + q == 0) break;
        vector<S> d(p); 
        int r = 0, c = 0, s = 0;
        rep(i, 0, p){
            string st;
            cin >> st;
            bool f = true;
            int cnt = 0;
            rep(j, 0, st.size()){
                if(f){
                    if(st[j] == '.') cnt++;
                    else f = false;
                }
                if(st[j] == '(') r++;
                if(st[j] == ')') r--;
                if(st[j] == '[') c++;
                if(st[j] == ']') c--;
                if(st[j] == '{') s++;
                if(st[j] == '}') s--;
            }
            d[i] = {r, c, s};
            if(i) d[i - 1].cnt = cnt;
        }
        vector<S> cand;
        rep(i, 1, 21){
            rep(j, 1, 21){
                rep(k, 1, 21){
                    bool f = true;
                    rep(l, 0, p - 1){
                        int tmp = i * d[l].r + j * d[l].c + k * d[l].s;
                        if(tmp != d[l].cnt){
                            f = false;
                            break;
                        }
                    }
                    if(f){
                        cand.push_back({i, j, k});
                    }
                }
            }
        }
        vector<int> res(q);
        vector<S> d2(q); 
        r = 0; c = 0; s = 0;
        rep(i, 0, q){
            string st;
            cin >> st;
            rep(j, 0, st.size()){
                if(st[j] == '(') r++;
                if(st[j] == ')') r--;
                if(st[j] == '[') c++;
                if(st[j] == ']') c--;
                if(st[j] == '{') s++;
                if(st[j] == '}') s--;
            }
            d2[i] = {r, c, s};
        }
        res[0] = 0;
        rep(i, 0, q - 1){
            set<int> st;
            rep(j, 0, cand.size()){
                int tmp = cand[j].r * d2[i].r + cand[j].c * d2[i].c + cand[j].s * d2[i].s;
                st.insert(tmp);
            }
            if(st.size() == 1){
                res[i + 1] = *st.begin();
            }else{
                res[i + 1] = -1;
            }
        }
        for(int ii = 0; ii < res.size(); ii++){
            if(ii) cout << ' ';
            cout << res[ii];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3336
L, R = map(int, input().split(' '))

min_value = 2018
for i in range(L, R):
    for j in range(i + 1, R + 1):
        min_value = min(min_value, i * j % 2019)
        if min_value == 0:
            break
    else:
        continue
    break
    
print(min_value)


Measured memory_bytes: 2940
#include <stdio.h>

int n, data[100001], tmp;

int main(void)
{
    int i, j;
    long long int ans;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &data[i]);
    }
    tmp = 0;
    for (i = 0; i < n; i++) {
        if (data[i] != 0) {
            data[i] += tmp;
            ans += data[i] / 2;
            tmp = data[i] % 2;
        } else {
            tmp = 0;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector <int> b;
    b = a;
    sort(b.begin(), b.end());
    map <int, int> c;
    for (int i = 0; i < n; i++) {
        c[b[i]] = i % 2;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 != c[a[i]]) {
            ans++;
        }
    }
    cout << ans / 2 << '\n';
    return 0;
}


Measured memory_bytes: 8732
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
const long long INF = 1LL << 60;

int main() {
	int N;
	cin >> N;
	vector<ll> x(N), y(N);
	REP(i, N) {
		cin >> x[i] >> y[i];
	}

	if (N == 1) {
		cout << 1 << endl;
		return 0;
	}

	int ans = 100;
	REP(i, N - 1) {
		FOR(j, i + 1, N) {
			ll now_p = x[j] - x[i];
			ll now_q = y[j] - y[i];
			int now_ans = 0;
			REP(k, N) {
				bool match = false;
				REP(l,N) {
					ll dis_x = x[l] - x[k];
					ll dis_y = y[l] - y[k];
					if (dis_x == now_p && dis_y == now_q) {
						match = true;
					}
				}
				if (!match) {
					now_ans++;
				}
			}
			ans = min(ans, now_ans);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256