akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define _u(i,a,b) for(int i=a;i<=b;++i)
#define _d(i,a,b) for(int i=a;i>=b;--i)
#define endl "\n"
#define ii pair<int,int>
#define fi first
#define se second
#define ll long long
#define FIO() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FI(task) freopen(task".inp","r",stdin)
#define FO(task) freopen(task".out","w",stdout)

using namespace std;

const int N = 1e5+7;
const int M = 1e9+7;

int f[N][4];
int a[N], b[N], c[N];
int n;

#define task "test"

int main(){
    FIO();
    //FI(task);
    ///FO(task);

    cin >> n;
    _u(i,1,n) cin >> a[i] >> b[i] >> c[i];
    _u(i,1,n){
        f[i][1] = max(f[i-1][2], f[i-1][3]) + a[i];
        f[i][2] = max(f[i-1][1], f[i-1][3]) + b[i];
        f[i][3] = max(f[i-1][1], f[i-1][2]) + c[i];
    }
    cout << max(max(f[n][1], f[n][2]),f[n][3]);
    return 0;
}


Measured memory_bytes: 2944
K = input().split(" ")
k = [int(n) for n in K]
t =k[0]//k[3]
a = k[2]//k[1]
t1 = k[0]%k[3]
a1 = k[2]%k[1]
if t1 != 0:
    t = t+1
if a1 != 0:
    a = a+1
if t>=a:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9080
import sys
sys.setrecursionlimit(10**6)

def MI(): return map(int, input().split())

N,Q=MI()
Edge=[[] for _ in range(N)]
Point=[0]*(N)
for _ in range(N-1):
  a,b=MI()
  Edge[a-1].append(b-1)
  Edge[b-1].append(a-1)
for _ in range(Q):
  p,x=MI()
  Point[p-1]+=x
  #print(p,Point[p-1])
  
def dfs(now,pre=-1):
  for nxt in Edge[now]:
    if nxt==pre:
      continue
    Point[nxt]+=Point[now]
    #print(*Point)
    dfs(nxt,now)
dfs(0)
print(*Point)

Measured memory_bytes: 283024
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(a+b)*(c/2)<<endl;

    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
double f[302][302][302];
int main()
{
        int n,i,j,k,i1=0,j1=0,k1=0,tmp;
        double a,b,c;
        scanf("%d",&n);
        f[0][0][0]=0;
        for(i=1;i<=n;i++)
        {
                scanf("%d",&tmp);
                if(tmp==1)
                        i1++;
                else if(tmp==2)
                        j1++;
                else
                        k1++;
        }
        for(k=0;k<=n;k++)
        {
                for(j=0;j<=n;j++)
                {
                        for(i=0;i<=n;i++)
                        {
                                a=b=c=0;
                                if(i==0&&j==0&&k==0)
                                        continue;
                                if(i!=0)
                                        a=i*f[i-1][j][k]/(i+j+k);
                                if(j!=0)
                                        b=j*f[i+1][j-1][k]/(i+j+k);
                                if(k!=0)
                                        c=k*f[i][j+1][k-1]/(i+j+k);
                                f[i][j][k]=a+b+c+(double)n/(i+j+k);
                        }
                }
        }
        printf("%.10lf",f[i1][j1][k1]);
        return 0;
}


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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for(int i = m; i < (n); ++i)

struct Info { int turn, x, y; };

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

int main()
{
    int t, n, x, y, c[140][140];
    
    while(cin >> t >> n && t)
    {
        int ans = 1;
        fill_n(*c, 140*140, 0);
        rep(i, n) cin >> x >> y, c[x+70][y+70] = -1;
        
        cin >> x >> y;
        c[x+70][y+70] = 1;
        queue<Info> que;
        que.push((Info){ 0, x+70, y+70 });
        
        while(!que.empty())
        {
            Info a = que.front(); que.pop();
            if(a.turn == t) continue;
            rep(i, 6) {
                if(c[a.x+dx[i]][a.y+dy[i]] == 0) {
                    ++ans;
                    c[a.x+dx[i]][a.y+dy[i]] = 1;
                    que.push((Info){ a.turn+1, a.x+dx[i], a.y+dy[i] });
                }
            }
        }
        
        cout << ans << endl;
    }
}

Measured memory_bytes: 1000
import java.util.Scanner

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)

    val n = sc.nextInt()
    val s = sc.next()

    val ans =
      (1 until n)
        .map(i => {
          val a = s.take(i).toCharArray.distinct
          val b = s.drop(i).toCharArray.distinct
          a.count(b.contains(_))
        })
        .max

    println(ans)
  }

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }

  def printExecTime(process: => Unit): Unit = {
    val start = System.currentTimeMillis
    process
    debug("処理時間： " + (System.currentTimeMillis - start) + " ミリ秒")
  }

  def bitSearch[T](n: Int, choice: Vector[T]): Vector[Vector[T]] = {
    @tailrec
    def bitSearchLogic(n: Int,
                       choice: Vector[T],
                       acc: Vector[Vector[T]]): Vector[Vector[T]] = {
      if (n == 0) acc
      else {
        val newAcc =
          acc.flatMap(vec => {
            choice.map(c => vec :+ c)
          })
        bitSearchLogic(n - 1, choice, newAcc)
      }
    }

    val firstAcc = choice.map(i => Vector(i))
    bitSearchLogic(n - 1, choice, firstAcc)
  }
}


Measured memory_bytes: 27548
#include <bits/stdc++.h>
using namespace std; int a[1000]; int main() {
  while (true) {
    int n, m; cin >> n >> m;
    if (n == 0 && m == 0)
        break;
    for (int i = 0; i < n; i++)
        cin >> a[i];
        sort(a, a + n);
    int ans = 0;
    if (a[n - 1] + a[n - 2] < m) {
      cout << a[n - 1] + a[n - 2] << endl;
      continue;
      }
    for (int i = 0; i < n; i++) {
      int p = lower_bound(a, a + n, m - a[i]) - a;
      if (a[i] + a[p] > m)
        p--;
      if (i == p)
        p--;
      if (p < 0) continue;
      if (a[i] + a[p] > ans)
        ans = a[i] + a[p];
    }
    if (ans)
        cout << ans << endl;
    else
        cout << "NONE" << endl;
  }
}


Measured memory_bytes: 3124
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
int main()
{
    //freopen("in.txt","r",stdin);
    int a,b;
    while(scanf("%d%d",&a,&b)!=-1)
    {
    	if(a>=10||b>=10)
    	{
    		cout<<-1<<endl;
    	}
    	else
    		cout<<a*b<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

n, m = map(int, input().split())
s = list(map(int, input()))


def solve(x):
    if x <= m + 1:
        return [x - 1]
    for i in range(m, 0, -1):
        if s[x - 1 - i] == 0:
            cand = solve(x - i)
            if len(cand) != 0:
                cand.append(i)
                return cand

    return []


cnt1_continuous = 0
cnt = 0
for i in range(n + 1):
    if s[i] == 1:
        cnt += 1
        if i == n:
            cnt1_continuous = max(cnt1_continuous, cnt)
    else:
        cnt1_continuous = max(cnt1_continuous, cnt)
        cnt = 0

if cnt1_continuous >= m:
    print(-1)
else:
    print(*solve(len(s)))


Measured memory_bytes: 94528
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    REP(i, 0, 5) {
        ll a;
        cin >> a;
        if (a == 0) {
            cout << i + 1 << endl;
            break;
        }
    }
}


Measured memory_bytes: 3636
N=int(input())
HP=list(map(int,input().split()))

a=HP[0]
b=HP[1]

(x, lastx) = (0, 1)
(y, lasty) = (1, 0)
while b != 0:
    q = a // b
    (a, b) = (b, a % b)
    (x, lastx) = (lastx - q * x, x)
    (y, lasty) = (lasty - q * y, y)
        
tmp=a

for i in range(1,N-1):
    a=tmp
    b=HP[i+1]
    
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
        
    tmp=a
    
print(tmp)

Measured memory_bytes: 14480
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(i64 i = 0; i < N; i++)
#define Rep(i, k, N) for(i64 i = k; i < N; i++)
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
    rep(i, 5){
        int x;
        cin >> x;
        if(x == 0) {
            cout << i+1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3632
#include<stdio.h>
int main ()
{
    int f,a,k;
    scanf("%d %d",&f,&a);
    k=-32767;
    if(k<f+a)
    k=f+a;
    if(k<f-a)
    k=f-a;
    if(k<f*a)
    k=f*a;
    printf("%d\n",k);


    return 0;
}


Measured memory_bytes: 128
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const ll INF = 10000000000;//INFinity
using namespace std;//namespace

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}//transform
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//#define int long long // yabai

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout

#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    int n;
    cin>>n;
    vector<int> d(n);
    REP(i,n)cin>>d[i];
    sort(ALL(d));
    d.erase(unique(ALL(d)),d.end());
    cout<<d.size()<<endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
)

func main() {
	var s string
	fmt.Scan(&s)
	for r, i := range s {
		if (r+1)%2 == 0 && string(i) == "R" {
			fmt.Println("No")
			os.Exit(0)
		}
		if (r+1)%2 == 1 && string(i) == "L" {
			fmt.Println("No")
			os.Exit(0)
		}
	}
	fmt.Println("Yes")

}


Measured memory_bytes: 512
import sys
import numpy as np

n = int(sys.stdin.readline().rstrip())
a = np.array(sys.stdin.read().split(), dtype=np.int32)
b = np.sort(a.copy())[::-1]

def main():
    bl = a == b[0]
    a[bl], a[~bl] = b[1], b[0]
    print(*a, sep='\n')

if __name__ ==  '__main__':
    main()

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

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			int n = Integer.parseInt(str);
			long ans = 1;
			for(int i = 0; i < n;i++) {
				str = br.readLine();
				long x;
				long y;
				long tmp;
				long t = Long.parseLong(str);
				if(i == 0) {
					ans = t;
				}else {
					if(ans > t) {
						x = ans;
						y = t;
					}else {
						x = t;
						y = ans;
					}

					while((tmp = x % y) != 0) {
						x = y;
						y = tmp;
					}
					ans = (ans / y)* t;
				}
			}
			System.out.println(ans);

//			long max  = 1000000007;
		}catch (Exception e) {
			System.exit(0);
		}
	}

}


Measured memory_bytes: 22484
pub fn get_str() -> String {
    use std::io;
    let mut input = String::new();
    io::stdin().read_line(&mut input);
    input.as_str().trim().to_string()
}
fn split_by_space(ss:&str) -> Vec<&str> {
    ss.split_whitespace().collect()
}
fn str_to_int(ss:&str) -> i64 {
    ss.parse().unwrap()
}
pub fn get_ints() -> Vec<i64> {
    split_by_space(&get_str()).iter().map(|s:&&str| str_to_int(s)).collect()
}


fn get_image(h : &i64) -> Vec<String> {
    let mut image : Vec<String> = Vec::with_capacity(*h as usize);
    for _ in 1..(h+1).abs() {
        image.push(get_str());
    }
    image
}

fn main() {
    let (h, w) = { let v = get_ints(); (v[0], v[1]) };
    let mut image = get_image(&h);
    let t : String = { let mut tmp = String::new(); for _ in 1..(w+3).abs() { tmp.push('#') }; tmp };
    for mut s in &mut image {
        s.insert(0, '#');
        s.push('#');
    }
    image.insert(0, t.clone());
    image.push(t);
    for s in image {
        println!("{}", s);
    }
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	char a[200];
	int k, b;
	scanf("%d", &k);
	scanf("%s", a);
	b=strlen(a);
	if(k>=b) puts(a);
	else
	{
		for(int i=0;i<k;i++)
		putchar(a[i]);
		printf("...");
	}
	return 0;
}

Measured memory_bytes: 1724
import java.util.Scanner;

public class Main {
	int dx[] = {0, -1, 1, 0};
	int dy[] = {-1, 0, 0, 1};
	int w, h;

	int solve(int sx, int sy, int gx, int gy, int f[][], int depth) {
		if (depth == 11)
			return 11;
		if (sx == gx && sy == gy)
			return depth;
		int min = 11;
		for (int i = 0; i < 4; i++) {
			int nx, ny;
			nx = sx;
			ny = sy;
			while (0 <= nx && nx < w && 0 <= ny && ny < h && f[ny][nx] != 1) {
				nx += dx[i];
				ny += dy[i];
				if (nx == gx && ny == gy) {
					return depth + 1;
				}
			}
			int desx = nx;
			int desy = ny;
			nx -= dx[i];
			ny -= dy[i];
			if (nx != sx || ny != sy) {
				if (0 <= desx && desx < w && 0 <= desy && desy < h) {
					f[desy][desx] = 0;
				} else {
					continue;
				}
				min = Math.min(min, solve(nx, ny, gx, gy, f, depth + 1));
				if (0 <= desx && desx < w && 0 <= desy && desy < h) {
					f[desy][desx] = 1;
				}
			}
		}
		return min;
	}

	void run () {
		Scanner sc = new Scanner(System.in);

		while (true) {
			w = sc.nextInt();
			h = sc.nextInt();
			if ((w | h) == 0) {
				break;
			}

			int f[][] = new int[h][w];
			int sx, sy, gx, gy;
			sx = sy = gx = gy = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					f[i][j] = sc.nextInt();
					if (f[i][j] == 2) {
						sx = j;
						sy = i;
						f[i][j] = 0;
					}
					if (f[i][j] == 3) {
						gx = j;
						gy = i;
						f[i][j] = 0;
					}
				}
			}
			int tmp = solve(sx, sy, gx, gy, f, 0);
			if (11 <= tmp) tmp = -1;
			System.out.println(tmp);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 38816
#include<cstdio>
using namespace std;
long long n,k,tmp,ans;
long long calc(long long k){return k*k*k;}
int main(){
	scanf("%d%d",&n,&k);
	ans=calc(n/k);
	if(!(k&1))ans+=calc((n+(k>>1))/k);
	printf("%lld",ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 200010
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n,a,b;
    cin>>n>>a>>b;
    n%=12;
    ll x,y;
    if(n==0||n==11)x=a;
    else if(n<=2)x=a-b;
    else if(n<=4)x=-b;
    else if(n<=6)x=-a;
    else if(n<=8)x=b-a;
    else if(n<=10)x=b;
    
    if(n<2)y=b;
    else if(n<4)y=a;
    else if(n<6)y=a-b;
    else if(n<8)y=-b;
    else if(n<10)y=-a;
    else if(n<12)y=b-a;
    cout<<x<<" "<<y<<endl;
}





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

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<map>
#include<stack>
#include<queue>
#include<math.h>


using namespace std;


long long int arr[10050];

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	long long int n;
	cin >> n;

	for (long long int i = 1; i < 105; i++)
	{
		for (long long int j = 1; j < 105; j++)
		{
			for (long long int k = 1; k < 105; k++)
			{
				long long int b = (i * i + j * j + k * k + i * j + j * k + k * i);
				if (b < 10050)
					arr[b] += 1;
			}
		}
	}
	for (long long int i = 1; i <= n; i++)
	{
		cout << arr[i] << endl;
	}




	return 0;


}


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

    typedef long long int ll;

    #define MOD (ll)(1e9+7)
    #define endl "\n"
    #define pb push_back
    #define TEST_CASES  ll t;cin>>t;while(t--)
    #define forn(i,a,n) for (int i = a; i < n; ++i)
    #define f first
    #define s second
    #define all(x) x.begin(), x.end()
    
    ll powD(ll x,ll y){
      ll res = 1;
      while(y > 0){
        if(y & 1)
          res = (res*x)%MOD;
        x = (x*x)%MOD;
        y = y>>1;
      }
      return res;
    }


    int main()
    {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int h,w,k;
      cin>>h>>w>>k;
      vector<string> board(h),boardt(h);
      forn(i,0,h){
        cin>>board[i];
      }
      ll ans = 0;
      forn(i,0,(1<<h)){
        bitset<6> r(i);
        forn(j,0,(1<<w)){
          boardt = board;
          bitset<6> c(j);
          //cout<<r.to_string()<<" "<<c.to_string()<<endl;
          forn(k,0,h){
            if(r[k]){
              forn(m,0,w){
                boardt[k][m] = '.';
              }
            }
          }
          forn(k,0,w){
            if(c[k]){
              forn(m,0,h){
                boardt[m][k] = '.';
              }
            }
          }
          int cnt = 0;
          /*forn(p,0,h){
            cout<<boardt[p]<<endl;
          }
          cout<<endl;*/
          forn(p,0,h){
            forn(q,0,w){
              if(boardt[p][q] == '#')
                cnt++;
            }
          }
          if(cnt == k){
            ans++;
          }
        }
      }
      cout<<ans<<endl;

    } 
    

Measured memory_bytes: 3660
/*
 
 Author : Bisma
 @ copy from bisma template 1.0
 */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <iomanip>
#include <fstream>
#include <cstdio>
using namespace std;
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define repn(a,b,c) for(int a=b; a>=c; a--)
#define ll long long
#define mem(a, b) memset(a, (b), sizeof(a))
#define loop(a,b,c) for(int a = b ;a<c;a++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;

ll max(ll a, ll b){
    if(a>b) return a;
    return b;
}

ll min(ll a, ll b){
    if(a>b) return b;
    return a;
}

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



int main(){
    fast();

    
    string s;

    cin>>s;

    ll size = s.size()-1;

    ll dif1 = 0;
    ll dif2 = 0;

    rep(i,0,size){
        char p ;

        if(i % 2 == 0){
            p = '1';
        }else{
            p = '0';
        }

        if(p != s[i]) dif1++;

    }


    rep(i,0,size){
        char p;

        if(i % 2 == 0){
            p = '0';
        }else{
            p = '1';
        }

        if(p != s[i]) dif2++;
    }


    cout<<min(dif1 , dif2)<<endl;

    return 0;
    
}
 






Measured memory_bytes: 512
N=int(input())
ls=[int(s) for s in input().split()]
dic={}
for e in ls:
  if (e in dic):
    dic[e]+=1
  else:
    dic[e]=1
Sum=0
for key,value in dic.items():
  Sum+=value*(value-1)//2

for i in range(N):
  print(Sum-dic[ls[i]]+1)
  

Measured memory_bytes: 25764
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int,int>

#define MOD 1000000007
#define INF 2147483647
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std;


int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    int d, e;
    d = e = 0;
    for (int i = 0; i < 3; i++)
    {
        if (a[i] == 5) {
            d++;
        }
        else if (a[i] == 7) {
            e++;
        }
    }
    if (d == 2 && e == 1) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(n) for n in input().split()]
lst = [0 for _ in range(2 * 100000)]
ans = 0
for i in a:
    lst[i] = lst[i] + 1
for i in lst:
    if i != 0:
        ans = ans + (i * (i - 1) / 2)
for i in a:
    x = lst[i]
    if x != 0 or x != 1:
        print((ans - (x * (x - 1) / 2) + ((x - 1) * (x - 2) / 2)).__int__())

Measured memory_bytes: 26268
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <climits>
#include <iomanip>
#include <sstream>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

template <typename T>
T gcd(T a, T b) {
	while (b != 0) {
		T temp = a;
		a = b;
		b = temp % b;
	}

	return a;
}

// cout << setfill('0') << setw(5) << number < endl;
// while(getline(cin, s)) { .. } | `s` is a string

void solve() {
	int n;
	cin >> n;
	vector<int> prev(3, 0), curr(3, 0), dp(3, 0);

	while(n--) {
		for (auto &it : curr) {
			cin >> it;
		}

		for (int i = 0; i < 3; ++i) {
			for (int j = 0; j < 3; ++j) {
				if (i == j)
					continue;
				dp[i] = max(dp[i], curr[i] + prev[j]);
			}
		}
		prev = dp;
	}

	cout << max(dp[0], max(dp[1], dp[2]));
}


int main(){
	IOS;
	int t = 1;
	// cin >> t;
	while(t--)
		solve();

	return 0;
}



























 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>

#define div 1000000000+7

typedef long long ll;

using namespace std;

void solve() {
    int h, w;
    string a[100];
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        cin >> a[i];
    }

    for (int i = 0; i < w+2; i++) {
        cout << "#";
    }
    cout << endl;
    for (int i = 0; i < h; i++) {
        cout << "#" << a[i] << "#" << endl;
    }
    for(int i = 0; i < w+2; i++){
        cout << "#";
    }
    cout << endl;
}

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


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main() {
	int amt=0,qut=0,cnt=0,a,b;
	while (scanf("%d,%d",&a,&b)!=EOF) {
		amt += a*b;
		qut += b;
		cnt++;
	}
	int res = qut/cnt;
	double dec = (double)qut/(double)cnt-res;
	if (dec>=0.5) res+=1;
	printf("%d\n%d\n",amt,res);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
typedef long long ll;
int main() {
  ll N; cin >> N;
  cout << N*(N-1)/2 << endl;
}


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

#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define abs(x) (((x)<0)?(-(x)):(x))

using namespace std;

int qsort_long_compare_descend(const void *a,const void *b){
    long c = *(long*)b - *(long*)a;
    if(c<0){
        return -1;
    }
    else if(c==0){
        return 0;
    }
    return 1;
}
void descendOrder(long size,long *array){//ko-jun
    qsort(array,size,sizeof(long),qsort_long_compare_descend);
}

int main(){
    int N;
    long A[100000],B[100000],K[100000];
    cin >> N;
    long Asum=0,Bsum=0;
    int Anum=0;//Aの方が小さくなるパターンの個数
    long Dsum=0;//足りない量の総和
    long Knum=0;//余剰パターンの個数
    for(int i=0;i<N;i++){
        cin >> A[i];
        Asum += A[i];
    }
    for(int i=0;i<N;i++){
        cin >> B[i];
        Bsum += B[i];
    }
    if(Asum<Bsum){
        cout << -1;
        return 0;
    }
    for(int i=0;i<N;i++){
        if(A[i]<B[i]){
            Dsum+=B[i]-A[i];
            Anum++;
        }
        else if(A[i]>B[i]){
            K[Knum]=A[i]-B[i];
            Knum++;
        }
    }
    if(Dsum==0){
        cout << 0;
        return 0;
    }
    descendOrder(Knum,K);
    for(int i=0;i<Knum;i++){
        Dsum -= K[i];
        Anum++;
        if(Dsum<=0){
            cout << Anum;
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 2684
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 1e5 + 10;
string S;
LL dp[MAX][13];

int main(void) {
    cin >> S;
    const int L = S.length();

    dp[0][0] = 1;
    REP(i, L) {
        if (S[i] == '?') {

            REP(j, 13) {
                REP(k, 10) {
                    const int nxt = (j * 10 + k) % 13;
                    (dp[i + 1][nxt] += dp[i][j]) %= MOD;
                }
            }

        } else {

            const int cur = S[i] - '0';
            REP(j, 13) {
                const int nxt = (j * 10 + cur) % 13;
                (dp[i + 1][nxt] += dp[i][j]) %= MOD;
            }

        }
    }

    cout << dp[L][5] << endl;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

    int ans = 0;
    if(A > B) {
        ans += A;
        A--;
    }
    else{
        ans += B;
        B--;
    }

    ans += max(A, B);
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include <stdio.h>
int main()
{
  char s[11];
  scanf("%s",&s);
  int i;
  i = 1;
  while (s[i])
  {
    if (s[i] != 'i' && s[i] != 'h')
      break;
    else if (s[i] == 'h' && s[i + 1] != 'i')
      break;
    else if (s[i] == 'i' && (s[i + 1] != 'h' && s[i + 1] != '\0'))
      break;
    if (s[i] == 'i' && s[i - 1] == 'h' && i % 2 != 0 && s[i+1] == '\0')
    {
      printf("Yes");
      return (0);
    }
    i++;
  }
  printf("No");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
const int mod=1e9+7;

int main(){
    int n;cin>>n;
    vector<string> s(n);
    int ans=0;
    rep(i,n)cin>>s[i];
    rep(i,n){
        bool flag=1;
        rep(j,n){
            if(!flag)break;
            rep(k,n){
                if(s[j][k]!=s[k][j]){
                    flag=0;break;
                }
            }
        }
        if(flag)ans+=n;
        string tmp=s[0];
        s.erase(s.begin());
        s.push_back(tmp);
    }
    cout<<ans<<endl;
}

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

int main(){
  string S;
  cin >> S;
  
  int count = 0;
  for(int i=0; i<3; i++){
    if(S.at(i) == 'o'){
      count++;
    }
  }
  
  int price = 700 + count * 100;
  cout << price << endl;
  
}


Measured memory_bytes: 3472
#include<stdio.h>
int main()
{
    int n,i,p=0,count=0,k;
    scanf("%d",&n);

        
    for(i=n;i>0;i--)
    {
        k=i;
        count=0;
       while(k!=0)
        {
        k=k/10;
        count++;
    }
    if(count%2!=0)
    {
        p++;
    }
        }
    printf("%d",p);
    return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_B&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    x = int(input())
    print(x**3)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7772
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n;
  cin>>n;
  int input[n][3];
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<3;j++)
      cin>>input[i][j];
  }
  int last=-1;
  int dp[n][3];
  memset(dp,0,sizeof(dp));
  dp[n-1][0]=input[n-1][0];
    dp[n-1][1]=input[n-1][1];
    dp[n-1][2]=input[n-1][2];
  for(int i=n-2;i>=0;i--)
  {
   for(int j=0;j<3;j++)
   {
   if(j==0)
   {
    dp[i][j]=input[i][j]+max(dp[i+1][1],dp[i+1][2]); 
   }
     else if(j==1)
     {
         dp[i][j]=input[i][j]+max(dp[i+1][0],dp[i+1][2]); 
       
     }
     else
     {
         dp[i][j]=input[i][j]+max(dp[i+1][1],dp[i+1][0]); 
       
     }
     
     
   }
    
    
  }
 cout<<max(dp[0][0],max(dp[0][1],dp[0][2]))<<endl;
  
  
}

Measured memory_bytes: 5916
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    if(n*a>b)
        cout<<b<<endl;
    else if(n*a<b)
        cout<<n*a<<endl;
    else if(n*a==b)
        cout<<b<<endl;

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;


int main(){
  ll x, y;
  cin >> x >> y;
  int ans = 1;
  while (x <= y){
    x *= 2;
    ans++;
  }
  ans--;
  cout << ans << endl;
}

Measured memory_bytes: 256
require 'set'
n,m = gets.split.map(&:to_i)
as = gets.split.map(&:to_i).sort.reverse
CONSUMES = [nil,2,5,5,4,5,6,3,7,6]
uses = as.map{|i| CONSUMES[i] }.to_set.sort

dp = [0]
1.upto(n) do |i|
  dp[i] = uses.map{|use| (i-use>=0 ? dp[i-use] : -100)+1 }.max
end

result = 0
i = n
while i > 0
  as.each do |a|
    if i-CONSUMES[a] >= 0 && dp[i-CONSUMES[a]]+1 == dp[i]
      result = result*10 + a
      i -= CONSUMES[a]
      break
    end
  end
end
puts result


Measured memory_bytes: 6012
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
std::string s,pre,aft;
cin>>s;
long long Q;
cin>>Q;
long long query,f;
bool direction=true;
pre="";
aft="";
std::string s1;
for(int i=0;i<Q;++i){
  cin>>query;
  if(query==1){
    if(direction){
      direction=false;
    }
    else{
      direction=true;
    }
  }
  if(query==2){
    cin>>f>>s1;
    if(direction){
      if(f==2){
        aft+=s1;
      }
      else{
        pre+=s1;
      }
    }
    else{
      if(f==1){
        aft+=s1;
      }
      else{
        pre+=s1;
      }
    }
  }

}
if(direction==true){
  std::reverse( pre.begin(), pre.end() );
  cout<<pre+s+aft<<"\n";
}
if(direction==false){
  std::reverse( aft.begin(), aft.end() );
  std::reverse( s.begin(), s.end() );
  cout<<aft+s+pre<<"\n";
}

return 0;
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
using namespace std;
static const int MAX=50;
int H,W,cunt[MAX+2][MAX+2];
int dx[8]={-1,-1,-1,0,1,1,1,0};
int dy[8]={-1,0,1,1,1,0,-1,-1};
int main(){
    cin>>H>>W;
    string s[H];
    for(int i=0;i<H;i++){
        cin>>s[i];
        for(int j=0;j<W;j++){
            if(s[i][j]=='#'){
                for(int k=0;k<8;k++)
                    cunt[i+1+dx[k]][j+1+dy[k]]++;
            }
        }
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(s[i][j]=='#')cout<<'#';
            else
                cout<<cunt[i+1][j+1];
        }
        cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define debug(var) std::cout << #var << " : " << var << std::endl;
using ll = long long;
using ull = unsigned long long;
ll mod = 1e9 + 7;

int main(){


	int N; std::cin >> N;
	std::vector<ll> A(N);
	rep(i, N)std::cin >> A[i];

	ll x = 0;
	rep(i, N){
		if(i % 2 == 0)x += A[i];
		else x -= A[i];
	}

	std::vector<ll> ans(N);
	ans[0] = x / 2;

	rep(i, N - 1){
		ans[i + 1] = A[i] - ans[i];
	}

	rep(i, N)ans[i] *= 2;
	rep(i, N)std::cout << ans[i] << " ";

	
	return 0;
}

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

int main()
{
  int N,M;
  cin >> N;
  vector<int> T(N);
  for(int i=0; i<N; ++i)
    cin >> T[i];
  cin >> M;
  vector<int> P(M);
  vector<int> X(M);
  for(int i=0; i<M; ++i)
    cin >> P[i] >> X[i];

  for(int n=0; n<M; ++n)
  {
    int ans = 0;
    for(int i=0; i<N; ++i)
    {
      if(i==P[n]-1)
        ans += X[n];
      else
        ans += T[i];
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val rowC1 = readLine.split(" ").map(_.toInt)
    val rowC2 = readLine.split(" ").map(_.toInt)
    val rowC3 = readLine.split(" ").map(_.toInt)

    val maxN = 100

    def checkRow(row:Array[Int], a1: Int, a2: Int, a3:Int): Boolean ={
      ((row(0) - a1) == (row(1) - a2)) && ((row(1) - a2) == (row(2) - a3))
    }
    val checklist =
      for(a1 <- 0 to maxN; a2 <- 0 to maxN; a3 <- 0 to maxN) yield {
        val a = checkRow(rowC1, a1, a2, a3) && checkRow(rowC2, a1, a2, a3) && checkRow(rowC3, a1, a2, a3)
        //println("DEBUG" + a)
        a
      }
    val ans = checklist.exists(x => x)

    println(if(ans) "Yes" else "No")
  }

}


Measured memory_bytes: 44964
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  ll n; cin>>n;
  std::vector<ll> a(n),b(n);
  for(ll i=0;i<n;++i) cin>>a[i];
  bool valid = true;
  for(ll j=n-1;j>=0;--j){
    if(j>n/2){
      b[j] = a[j];
    } else if(j==0) {
      continue;
    } else {
      ll tmp=j+j+1;
      ll cnt_ball =0;
      while(tmp<n){
        cnt_ball += b[tmp];
        tmp += j+1;
      }
      if(cnt_ball%2==a[j]){
        b[j] = 0;
      } else {
        b[j] = 1;
      }
    }
  }
  ll cnt_ball = accumulate(b.begin()+1,b.end(),0);
  if(cnt_ball%2==a[0]){
    b[0] = 0;
  } else {
    b[0] = 1;
    ++cnt_ball;
  }
  cout << cnt_ball << endl;
  for(ll i=0;i<n;++i){
    if(b[i]==1) cout << i+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3968
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int main(){
    int an,A[10000],bn,count=0;
    cin >> an;
    for (int i = 0; i < an; i++) {
        scanf("%d",&A[i]);
    }
    cin >> bn;
    for (int i = 0; i < bn; i++) {
        int k;
        scanf("%d",&k);
        for (int j = 0; j < an; j++) {
            if (k == A[j]) {
                count++;
                break;
            }
        }
    }
    
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 1280
s = input()

even_list = [s[i] for i in range(len(s)) if i % 2 == 0]
odd_list = [s[i] for i in range(len(s)) if i % 2 != 0]

a = set(["R", "U", "D"])
b = set(["L", "U", "D"])

if set(even_list) | a == a and set(odd_list) | b == b:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
x, k, d = map(int, input().split())

if x >= 0:
    cnt = x // d
    if cnt >= k:
        pos = x - k * d
        print(pos)
    else:
        pos1 = x - cnt * d # cnt-kai
        nokori = k - cnt
        if nokori % 2 == 0:
            print(pos1)
        else:
            pos2 = abs(pos1 - d)
            print(pos2)
else:
    x = -x
    cnt = x // d
    if cnt >= k:
        pos = x - k * d
        print(pos)
    else:
        pos1 = x - cnt * d # cnt-kai
        nokori = k - cnt
        if nokori % 2 == 0:
            print(pos1)
        else:
            pos2 = abs(pos1 - d)
            print(pos2)


Measured memory_bytes: 61864
#include <iostream>
using namespace std;
int n,m;
char a[110][110]={0};
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
			if(a[i][j]=='.')
			{
				int sum=0;
				for(int k=i-1;k<=i+1;k++)
					for(int q=j-1;q<=j+1;q++)
						if(a[k][q]=='#') sum++;
				cout<<sum;
			} 
			else if(a[i][j]=='#') cout<<"#";
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
As, Bs = readlines.map{|l| l.split.map(&:to_i)}
B, M = 1007, 10**9 + 7

def mpow(x, n)
  ret = 1
  while n > 0
    if n.even?
      x = x * x % M
      n >>= 1
    else
      ret = ret * x % M
      n -= 1
    end
  end
  ret
end

P, N2 = mpow(B, N), 2*N
as, bs = [As, Bs].map{|a| a.cycle.each_cons(2).take(2*N).map{|x, y| x^y}}
ha, hb = [as, bs].map{|a| a.each_with_object([0]){|v, o| o << (o.last*B + v) % M}}
f = ->(h, i){(h[i + N] - h[i]*P) % M}
(0 ... N).each{|k| puts "#{k} #{As[k]^Bs[0]}" if f[ha, k] == f[hb, 0]}

Measured memory_bytes: 99668
#include<bits/stdc++.h>
using namespace std; 
int a[50]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
	int k;scanf("%d",&k);
	printf("%d",a[k]);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;

#define x first
#define y second
#define NMAX 100005
#define INF 1000000007

int v[NMAX], n, wrong;

int main (){
    
    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
        scanf("%d",&v[i]);
    }
    sort(v + 1, v + n + 1);
    for(int i = 1; i < n; i++){
        if(v[i] == v[i + 1])
            wrong++;
    }
    
    printf("%d\n", n - (wrong + (wrong&1)));
    
    
    return 0;
}

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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int N;
using ll = long long;
vector<ll> A(N);
ll f(ll b) {
    ll sum = 0;
    rep(i, N) sum += abs(A[i] - b);
    return sum;
}
int main() {
    cin >> N;
    A.resize(N);
    rep(i, N) cin >> A[i];
    rep(i, N) A[i] = (A[i] - i - 1);
    map<ll, int> cnt;
    rep(i, N) cnt[A[i]]++;

    int maxi = 0;
    ll b = 0;
    rep(i, N) {
        if (maxi < cnt[A[i]]) {
            maxi = cnt[A[i]];
            b = A[i];
        }
    }

    ll lb = -1e9, ub = 1e9;
    while (ub - lb > 1) {
        ll mid = (lb + ub) / 2;
        if (f(mid) - f(mid - 1) < 0) {
            lb = mid;
        } else {
            ub = mid;
        }
    }

    b = lb;
    // cout << "b = " << b << endl;
    cout << f(b) << endl;
    // for (int i = -10; i < 10; i++) {
    //     cout << i << ", " << f(i) << endl;
    // }

    return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
vector<ll>thick(51);
ll thickness(int L){//レベルLの厚さ
    if(L==0)return thick[0]=1;
    if(thick[L]!=0)return thick[L];
    return thick[L]=thickness(L-1)*2+3;
}
ll num_of_P(int L,ll n){//レベルL,下からn番目まで食べる時のパティの数
    if(L==0)return 1;
    if(n==1)return 0;
    else if(n<=1+thickness(L-1))return num_of_P(L-1,n-1);
    else if(n==2+thickness(L-1))return num_of_P(L-1,thickness(L-1))+1;
    else if(n<=2+2*thickness(L-1))return num_of_P(L-1,thickness(L-1))+1+num_of_P(L-1,n-2-thickness(L-1));
    else return 2*num_of_P(L-1,thickness(L-1))+1;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    ll X;
    cin>>N>>X;
    cout<<num_of_P(N,X)<<endl;
}

Measured memory_bytes: 256
class BIT:
    # 1-indexed
    def __init__(self, n):
        self.size = n + 1
        self.bit = [0] * self.size

    def add(self, i, x):
        # Add x to a[i]
        while i < self.size:
            self.bit[i] += x
            i += i & -i

    def sumup(self, i):
        # Sum a[1]~a[i]
        res = 0
        while i > 0:
            res += self.bit[i]
            i -= i & -i
        return res

    def query(self, i, j):
        # Sum a[i]~a[j]
        return self.sumup(j) - self.sumup(i - 1)


N, Q = map(int, input().split())
C = list(map(int, input().split()))

X = []
for i in range(Q):
    l, r = map(int, input().split())
    X.append((i, l, r))
X.sort(key=lambda x: x[2])

ans = [0] * Q
bit = BIT(N + 1)
last = [0] * (N + 1)
k = 0
for i, l, r in X:
    for j in range(k + 1, r + 1):
        if last[C[j - 1]] > 0:
            bit.add(last[C[j - 1]], -1)

        bit.add(j, 1)
        last[C[j - 1]] = j

    k = r
    ans[i] = bit.query(l, r)

print(*ans, sep="\n")


Measured memory_bytes: 239788
import java.util.*;
import java.io.*;

/*
   AtCoder contests
   coder : yoichion
 */

public class Main {
    public static long total(int level){
        if (level<=0) return 1;
        return 3 + 2 * total(level-1);
    }
    public static long patty(int level){
        if (level<=0) return 1;
        return 1 + 2 * patty(level-1);
    }
    public static long eat(int level, long layer){
        if(layer<=0) return 0;
        if(level==0) return 1;
        if(layer >= total(level)) return patty(level);

        if(layer <= 1 + total(level-1)){
            return eat(level-1, layer-1);
        }
        if(layer == 2 + total(level-1)){
            return 1 + patty(level-1);
        }
        return patty(level-1) + 1 + eat(level-1, layer-total(level-1)-2);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long X = sc.nextLong();
        System.out.println(eat(N,X));
    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <set>

int main()
{
	int n;
	std::cin >> n;

	std::set<int> s;
	for( int i = 0; i < n; i++ ) {
		int x;
		std::cin >> x;
		s.insert( x );
	}

	std::cout << s.size() << std::endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	public static void solver() {

		int W = cin.nextInt();
		int H = cin.nextInt();
		int x = cin.nextInt();
		int y = cin.nextInt();
		int r = cin.nextInt();
		
		if ( (x-r >= 0) && (x+r <= W) && (y-r >=0) && (y+r <=H) ) {
			cout.println("Yes");
		} else {
			cout.println("No");
		}
		
	}
		
	public static void main(String[] args) throws IOException {

		cin = new Scanner(System.in);
		Main.solver();
	}

	static Scanner     cin;
	static PrintStream cout = System.out;//標準出力
}

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

A=list(map(int,input().split()))

count=0
i=N-1

while i>0:
	j=0
	while j<i:
		if A[N-1-j]<A[N-2-j]:
			(A[N-1-j],A[N-2-j])=(A[N-2-j],A[N-1-j])
			count+=1
			#print(' '.join(map(str,A)))
		j+=1
	i-=1


print(' '.join(map(str,A)))
print(count)

Measured memory_bytes: 7704
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	vector<int> P(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> P[i];
	}
	vector<int> Q(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> Q[i];
	}

	vector<int> index;
	for (auto i = 1; i <= N; ++i)
	{
		index.push_back(i);
	}

	auto a = 0;
	auto b = 0;
	auto num = 0;
	do
	{
		++num;
		auto isP = true;
		auto isQ = true;
		for (auto i = 0; i < N; ++i)
		{
			if (index[i] != P[i])
			{
				isP = false;
			}
			if (index[i] != Q[i])
			{
				isQ = false;
			}
		}
		if (isP)
		{
			a = num;
		}
		if (isQ)
		{
			b = num;
		}
	} while (next_permutation(index.begin(), index.end()) != false);

	cout << abs(a - b) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=3e3+10;
const double pi=acos(-1);

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n;
long long l,t[N];
double x,y,tt;

int main() {
	cin>>n>>l;tt=1.0*n*(n-1)*(n-2)/6;
	for(int i=1;i<=n;i++) t[i]=gi();
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++) {
			x+=cos(pi*(t[i]+t[j])/l)*(n-(j-i+1));
			y+=sin(pi*(t[i]+t[j])/l)*(n-(j-i+1));
			x+=cos(pi*(t[i]+t[j]+l)/l)*(j-i-1);
			y+=sin(pi*(t[i]+t[j]+l)/l)*(j-i-1);
		}
	x/=tt,y/=tt;
	cout<<setprecision(10)<<fixed<<x<<' '<<y<<endl;
	return 0;
}


Measured memory_bytes: 256