akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long int llint;
llint arr[3005],dp[3005][3005][2];
llint rek(int l,int r,llint x,llint y,int a) {
	if(l>r) return 0;
	if(dp[l][r][a]!=-1) return dp[l][r][a];
	llint ret;
	if(a==0) ret=max(rek(l+1,r,x+arr[l],y,1)+arr[l],rek(l,r-1,x+arr[r],y,1)+arr[r]);
	else ret=min(rek(l+1,r,x,y+arr[l],0)-arr[l],rek(l,r-1,x,y+arr[r],0)-arr[r]);
	dp[l][r][a]=ret;
	//cout <<l<<" "<<r<<" "<<a<<" "<<x<<" "<<y<<" "<<ret<<endl;
	return ret;
}
int main()
{
	int n;
	cin >> n;
	for(int i=0;i<n;i++) {
		cin >> arr[i];
	}
	memset(dp,-1,sizeof(dp));
	/*for(int i=0;i<n;i++) {
		for(int j=i;j<n;j++) {
			if(i==j) dp[i][j]=
		}
	}*/
	cout <<rek(0,n-1,0,0,0);
	return 0;
}


Measured memory_bytes: 141568
<?php
$que=[];
$head=0;
$tail=0;
list($length,$Q)=explode(' ',trim(fgets(STDIN)));

for($i=0;$i<$length;$i++) {
    $que[$tail++]=explode(' ',trim(fgets(STDIN)));
}

$result='';
$TIME=0;
while($head!=$tail){
  //task[0]:name, task[1]:time
  $task=$que[$head++];
  if($task[1]<=$Q){
    // プロセス完了
    $result.=$task[0].' '.($TIME+$task[1]).PHP_EOL;
    $TIME+=$task[1];
  }
  else{
    // プロセス未完了
    $task[1]-=$Q;
    $que[$tail++]=$task;
    $TIME+=$Q;
  }
}
echo $result;



Measured memory_bytes: 116864
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

template <typename T>
bool chmin(T& x, T& y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T& y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(std::string S){
    vector<string> t = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    cout << distance(find(t.begin(), t.end(), S), t.end()) << endl;
}


signed main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
  {
   string s1,s2,s3;
   cin>>s1>>s2>>s3;
   int l1 = s1.length();
   int l2 = s2.length();
   int l3 = s3.length();
   
   if((s1[l1-1]==s2[0])&&(s2[l2-1]==s3[0]))
   cout<<"YES"<<endl;
   else 
   cout<<"NO"<<endl;
  }

Measured memory_bytes: 3620
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
A=tuple(map(int,input().split()))


if N==0:
    if A[0]==1:
        print(1)
        exit()
    else:
        print(-1)
        exit()

right=1
for i,x in enumerate(A):
    if x>right:
        print(-1)
        exit()
    right-=x
    right*=2
    right=min(right,10**10)

ans=1
tmp=0
M=[1]


if A[0]>0:
    print(-1)
    exit()

for i,x in enumerate(A[1:],1):
    if i>=65:
        n=2**65
    else:
        n=2**i
    M.append(min(n-x,M[i-1]*2-x))
    if (i!=N and M[i]<=0) or (i==N and M[i]<0):
        print(-1)
        exit()
for i,(x,y) in enumerate(zip(A[1:][::-1],M[1:][::-1])):
    tmp+=x
    tmp=min(tmp,n,y+x)
    ans+=tmp
if A[0]+M[0]>1:
    print(-1)
    exit()
print(ans)

Measured memory_bytes: 101100
n = int(input())
h_list = list(map(int, input().split()))
h_list = h_list[:n]
count = 0
last_h = 0
for index,h in enumerate(h_list):
	if last_h <= h:
		count += 1
	
	if last_h <= h:
		last_h = h

print(count)
		
	
	

Measured memory_bytes: 2940
H, W, K = [int(_) for _ in input().split()]

MOD = 1000000007

P = [""]
for i in range(W - 1):
    Q = []
    for p in P:
        Q.append(p + "0")
        if len(p) == 0 or p[-1] == "0":
            Q.append(p + "1")
    P = Q

rs = [1] + [0] * (W - 1)

for j in range(H):
    nrs = [0] * W
    for p in P:
        drs = rs[:]
        for i, c in enumerate(p):
            if c == "1":
                drs[i], drs[i + 1] = drs[i + 1], drs[i]
        for i in range(W):
            nrs[i] = (nrs[i] + drs[i]) % MOD
    rs = nrs

print(rs[K - 1])


Measured memory_bytes: 3064
# coding: utf-8
n = int(input())
cards = [[True for i in range(13)] for j in range(4)] #j = 0 S, j = 1 H, j = 2 C, j = 3 D
for i in range(n):
    line = input().rstrip().split()
    if line[0] == "S":
        mark = 0
    elif line[0] == "H":
        mark = 1
    elif line[0] == "C":
        mark = 2
    else:
        mark = 3
    cards[mark][int(line[1]) - 1] = False

for i in range(4):
    for j in range(13):
        if cards[i][j] == True:
            if i == 0:
                print("S", end=" ")
            elif i == 1:
                print("H", end=" ")
            elif i == 2:
                print("C", end=" ")
            else:
                print("D", end=" ")
            print(j+1)


Measured memory_bytes: 5616
import sys


# input = sys.stdin.readline

def main():
    A,B,K =map(int,input().split())

    if A>=K:
        print(A-K,B)
    elif A+B >=K:
        print(0,A+B-K)
    else:
        print(0,0)
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 9156
use proconio::input;

// use std::f64::consts::PI;
// use std::cmp::*;
// use std::collections::*;
// use proconio::marker::Chars;
const MOD: u64 = 1000000007;

fn main() {
    input! {
        n: u32,
        k: u32,
    }
    println!("{}", k * (k - 1).pow(n - 1));
}


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

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

Measured memory_bytes: 3620
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){

    vector<string> v;
    int N,L;

    cin>>N>>L;
    for(int i=0;i<N;i++){
        string s;
        cin>>s;
        v.push_back(s);
    }

    sort(v.begin(),v.end());

    for(int i=0;i<v.size();i++){
        cout<<v[i];
    }
    cout<<endl;
}



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

typedef long long ll;

const ll MOD = 1000000007;

ll mod_pow(ll n,ll m,ll mod){
  ll res = 1;
  while(m>0){
    if(m&1) res =(res* n) %mod;
    n = n * n % mod;
    m>>=1;
  }
  return res;
}


ll solve(int n,int m){
  return mod_pow(n,m,MOD);
}


int main(){
  ll n,m;
  cin>>n>>m;
  cout<<solve(n,m)<<endl;
}

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
  int k;
  string s;
  cin >> k >> s;
  if (s.length() <= k)
    cout << s << endl;
  else
  {
    cout << s.substr(0, k) + "..." << endl;
  }
}

Measured memory_bytes: 3632
//
//  main.cpp
//  3
//
//  Created by RISHAV SINGH MEHTA on 31/01/20.
//  Copyright © 2020 RISHAV SINGH MEHTA. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <vector>
#define ll long long
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    ll int T,i,j,k,l,N,K;
    vector<ll int> H;
    cin>>N>>K;
    for (i=0; i<N; i++) {
        cin>>j;
        H.push_back(j);
    }
    
    sort(H.begin(), H.end(), greater<>());
    ll int sum=0;
    for (i=K; i<N; i++) {
        sum += H[i];
    }
    
    cout<<sum<<endl;
    
    return 0;
}


Measured memory_bytes: 3444
#include <stdio.h>

int n = 0;

int main(int argc, char const *argv[])
{
    scanf("%d", &n);

    int a[n];
    int check = 0;
    int count = 0;
    int i = 0;

    for (i = 0; i < n; i++)
    {
        a[i] = 0;
    }

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

    for (i = 0; i < n; i++)
    {
        if (a[i] % 2 == 0)
        {
            count++;
            if (a[i] % 3 == 0 || a[i] % 5 == 0)
            {
                check++;
            }
        }
    }

    if (check == count)
    {
        printf("APPROVED\n");
    }
    else
    {
        printf("DENIED\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{

        int n;
        int h[100];
        int i, j, k = 0, res = 0;

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

        for(i = 0; i < n; i++) {
                k = 0;
                for(j = 0; j <= i; j++) {
                        if(h[i] >= h[j]) {
                                k++;
                        }
                }
                if(k == i+1) {
                        res++;
                }
        }
        printf("%d", res);
        return 0;
}


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

long long ans,n,a,b,k,mod=998244353ll,invfact[300005],fact;

long long fastp(long long base,int exp){
    if(exp==1)return base;
    long long val=fastp(base,exp/2);
    val=(val*val)%mod;
    if(exp%2)val*=base;
    return val%mod;
}

long long binom(long long num){
    return ((fact*invfact[num])%mod*invfact[n-num])%mod;
}

int main(){

	cin>>n>>a>>b>>k;
	
	long long num=1;
	for(int i=1;i<=n;i++)num=(num*i)%mod;
	fact=num;
	num=fastp(num,mod-2);
	invfact[n]=num;
	for(int i=n-1;i>=0;i--)invfact[i]=(invfact[i+1]*(i+1))%mod;
    
    for(long long i=0;i<=n;i++)
        if((k-(i*a))%b==0 && (k-(i*a))/b<=n && (k-(i*a))/b>=0){
            ans+=(binom(i)*binom((k-(i*a))/b))%mod;
            ans%=mod;
        }
    
    cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 2560
S = input()

ret = 0

cnt = 0

# t
for s in S:
    if s == 'S':
        cnt += 1
    else:
        if cnt > 0:
            cnt -= 1
        else:
            ret += 1

cnt = 0
# s
for s in S[::-1]:
    if s == 'T':
        cnt += 1
    else:
        if cnt > 0:
            cnt -= 1
        else:
            ret += 1

print(ret)


Measured memory_bytes: 3500
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main() {
  long long n;
  cin >> n;
  vector <vector<char>> rjeci(n);
  for (long long i = 0; i < n; i++){
    vector <char> tmp(10);
    for (long long j = 0; j < 10; j++) cin >> tmp[j];
    sort(tmp.begin(), tmp.end());
    rjeci[i] = tmp;
  }
  sort(rjeci.begin(),rjeci.end());
  long long bp = 0;
  for (long long i = 0; i < n; i++){
    vector <char> tren = rjeci[i];
    long long brojac = 0;
    while (tren == rjeci[i]){
      brojac++;
      i++;
    }
    if (brojac != 0) i--;
    bp += (brojac*(brojac-1))/2;
  }
  cout << bp;
}

Measured memory_bytes: 5760
h, w = map(int, input().split())

s = [input() for i in range(h)]

for i in range(1,h-1):
    for j in range(1, w-1):
        if s[i][j]=="#" and s[i+1][j]=="." and s[i][j+1]=="." and s[i-1][j]=="." and s[i][j-1]==".":
            print("No")
            exit()

for j in range(1,w-1):
    if s[0][j] == "#" and s[1][j] == "." and s[0][j + 1] == "." and s[0][j - 1] == ".":
        print("No")
        exit()
    if s[h-1][j] == "#" and s[h-2][j] == "." and s[h-1][j + 1] == "." and s[h-1][j - 1] == ".":
        print("No")
        exit()


for i in range(1,h-1):
    if s[i][0] == "#" and s[i + 1][0] == "." and s[i][1] == "." and s[i - 1][0] == ".":
        print("No")
        exit()
    if s[i][w-1] == "#" and s[i + 1][w-1] == "." and s[i][w-2] == "." and s[i - 1][w-1] == ".":
        print("No")
        exit()

if s[0][0]=="#" and s[1][0]=="." and s[0][1]==".":
    print("No")
    exit()

if s[h-1][0]=="#" and s[h-1][1]=="." and s[h-2][0]==".":
    print("No")
    exit()

if s[0][w-1]=="#" and s[1][w-1]=="." and s[0][w-2]==".":
    print("No")
    exit()

if s[h-1][w-1]=="#" and s[h-1][w-2]=="." and s[h-2][w-1]==".":
    print("No")
    exit()

print("Yes")

Measured memory_bytes: 3192
#!/usr/bin/env python3

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    # N = II()
    # S = input()

    # ans = []
    # for i in range(2**N, 2**(N+1)):
    #     if bin(i)[3:].count('1') == N - 3:
    #         t = ''
    #         for s, b in zip(S, bin(i)[3:]):
    #             if b != '1':
    #                 t += s
    #         ans.append(t)
        
    # print(len(set(ans)))

    N = II()
    S = input()

    ans = 0
    for i in range(10):
        a = S.find(str(i))
        if a != -1:
            for j in range(10):
                b = S.find(str(j), a+1)
                if b != -1:
                    for k in range(10):
                        c = S.find(str(k), b+1)
                        if c != -1:
                            ans += 1

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9296
#include <bits/stdc++.h>
using namespace std;
int read(){
	int x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)&&ch!='-')
		ch=getchar();
	if (ch=='-')
		f=-1,ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x;
}
const int N=100005;
int n,v[N];
struct color{
	int t,c;
}a[2][N];
bool cmp(color a,color b){
	return a.t>b.t;
}
int main(){
	n=read();
	memset(a,0,sizeof a);
	for (int i=1;i<N;i++)
		a[0][i].c=a[1][i].c=i;
	for (int i=1;i<=n;i++){
		v[i]=read();
		a[i&1][v[i]].t++;
	}
	sort(a[0]+1,a[0]+100001,cmp);
	sort(a[1]+1,a[1]+100001,cmp);
	int ans;
	if (a[0][1].c!=a[1][1].c)
		ans=n-a[0][1].t-a[1][1].t;
	else
		ans=min(n-a[0][1].t-a[1][2].t,n-a[0][2].t-a[1][1].t);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a  =sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a+b >= c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}


Measured memory_bytes: 23636
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int main()
{
	int N, K;
	char s[11];
	scanf("%d%s%d", &N, s, &K);
	int i = 0;
	while (s[i] != '\0') {
		if (s[i] != s[K - 1]) {
			s[i] = '*';
		}
		printf("%c", s[i]);
		i++;
	}
	return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(1000000)


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


def main():
    N = int(input())
    X = list(map(int, input().split()))
    ans = float('inf')
    for p in range(1, 101):
        total = 0
        for x in X:
            total += (x - p) ** 2
        ans = min(total, ans)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;

const lint mod = 1e9 + 7;

int main(){
    int n;
    scanf("%d", &n);
    map<int, int> mp;
    int L = 0;
    rep(i, n){
        int a;
        scanf("%d", &a);
        ++mp[a];
        L = max(L, a);
    }
    
    rep(i, L+1){
        int d = max(i, L-i);
        if(mp[d] == 0){
            printf("Impossible\n");
            return 0;
        }
        else --mp[d];
    }
    
    int m = (L-1)/2 + 2;
    for(auto itr=mp.begin(); itr!=mp.end(); ++itr){
        if(itr->se && itr->fi < m){
            printf("Impossible\n");
            return 0;
        }
    }
    
    printf("Possible\n");
}

Measured memory_bytes: 256
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ======================================================================
    //　素数チェック（２，３も大丈夫）					
    boolean isPrime(long n) {					
    	if(n <= 1)		return false;		
        	for(int i = 2; i * i <= n; i++){				
        		if(n % i == 0)		return false;	
    	}				
    	return true;				
    }					
	public void solve() {
		int N = ni();
		int M = ni();
		if(isPrime(M)) {
			out.println(1);
			return;
		}
		for (int i = N; i <= M; i++) {
			if(M % i == 0) {
				out.println(M/i);
				return;
			}
		}
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

//	LLONG_MAX 9.2*1e18	9223372036854775807LL = (2^63)-1
//	INT_MAX 2.1*1e9 2147483647 = (2^31)-1
//	O(1e8) 1.2sec

void Main()
{
	ll X,K,D;
	cin>>X>>K>>D;
	X = abs(X);
	if(K<=abs(X/D)){
		//dout<<"flag"<<'1'<<_n;
		if(X>0) cout<<abs(X-D*K)<<_n;
		else cout<<abs(X+D*K)<<_n;
		return;
	}

	else if(((X/D)%2)==(K%2)){
		//dout<<"flag"<<'2'<<_n;
		cout<<abs(X%D)<<_n;
		return;
	}

	else{
		//dout<<"flag"<<'3'<<_n;
		if(X%D<0)cout<<abs((X%D)+D)<<_n;
		else cout<<abs((X%D)-D)<<_n;
		return;
	}

}


void Test();
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define max(x,y) ((x)>(y)?(x):(y))
using namespace std;
char s1[10000],s2[10000];
int l,f[10000],z[10000],ans,kk,d;
bool f1,f2;
bool cmp1(const int &x,const int &y){return f[x]<f[y];}
bool cmp2(const int &x,const int &y){return f[x+l]<f[y+l];}
int main(){
	//freopen("flip.in","r",stdin);freopen("flip.out","w",stdout);
	scanf("%s%s",&s1,&s2);l=strlen(s1);f1=f2=0;
	for (int i=0;i<l;i++)s1[i]-='0',f1|=s1[i];
	for (int i=0;i<l;i++)s2[i]-='0',f2|=s2[i];
	if (!f2)return (cout<<(f1?-1:0)<<endl),0;
	for (int i=l;i<2*l;i++)s1[i]=s1[i-l],s2[i]=s2[i-l];
	for (int j=0;j<5;j++)
		for (int i=l-1;i>=0;i--)
			if (s2[i])f[i]=0;else f[i]=f[(i+1)%l]+1;
	for (int j=0;j<5;j++)
		for (int i=0;i<l;i++)
			if (s2[i])f[i]=0;else f[i+l]=f[(i-1+l)%l+l]+1;
	ans=1e9;z[0]=9999;for (int i=1;i<=l;i++)z[i]=i-1;sort(z+1,z+1+l,cmp1);
	for (int i=0;i<l;i++){
		if (ans<=i)break;
		d=0;kk=0;f[9999]=i;for (int j=0;j<l;j++)if (s1[j]!=s2[j+i])d++;
		for (int j=l;j>=0;j--){
			ans=min(ans,i+kk+max((f[z[j]]-i)*2,0)+d);
			if (s1[z[j]]!=s2[z[j]+i])kk=max(kk,f[z[j]+l]*2);
		}
	}sort(z+1,z+1+l,cmp2);
	for (int i=0;i<l;i++){
		if (ans<=i)break;
		d=0;kk=0;f[9999]=i;for (int j=0;j<l;j++)if (s1[j+i]!=s2[j])d++; 
		for (int j=l;j>=0;j--){
			ans=min(ans,i+kk+max((f[z[j]+l]-i)*2,0)+d);
			if (s1[z[j]]!=s2[z[j]+l-i])kk=max(kk,f[z[j]]*2);
		}
	}cout<<ans<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

class Dinic:
    """ 最大流(Dinic) """

    INF = 10 ** 18

    def __init__(self, n):
        self.n = n
        self.links = [[] for _ in range(n)]
        self.depth = None
        self.progress = None
 
    def add_link(self, _from, to, cap):
        self.links[_from].append([cap, to, len(self.links[to])])
        self.links[to].append([0, _from, len(self.links[_from]) - 1])
 
    def bfs(self, s):
        from collections import deque

        depth = [-1] * self.n
        depth[s] = 0
        q = deque([s])
        while q:
            v = q.popleft()
            for cap, to, _ in self.links[v]:
                if cap > 0 and depth[to] < 0:
                    depth[to] = depth[v] + 1
                    q.append(to)
        self.depth = depth
 
    def dfs(self, v, t, flow):
        if v == t:
            return flow
        links_v = self.links[v]
        for i in range(self.progress[v], len(links_v)):
            self.progress[v] = i
            cap, to, rev = link = links_v[i]
            if cap == 0 or self.depth[v] >= self.depth[to]:
                continue
            d = self.dfs(to, t, min(flow, cap))
            if d == 0:
                continue
            link[0] -= d
            self.links[to][rev][0] += d
            return d
        return 0
 
    def max_flow(self, s, t):
        INF = Dinic.INF
        flow = 0
        while True:
            self.bfs(s)
            if self.depth[t] < 0:
                return flow
            self.progress = [0] * self.n
            current_flow = self.dfs(s, t, INF)
            while current_flow > 0:
                flow += current_flow
                current_flow = self.dfs(s, t, INF)

N = INT()
A = LIST()

# 最大流を最小カットに使用、流量がコストとみなせる
dinic = Dinic(N+2)
s = N
t = N + 1
total = 0
for i, a in enumerate(A):
    if a < 0:
        # 元々損失の部分はそのままコストとして扱う
        dinic.add_link(s, i, -a)
    elif a > 0:
        # 利益については、予め利益を得られるとして、得られなくなる方の選択肢にコストとして足す
        dinic.add_link(i, t, a)
        total += a

for i in range(1, N+1):
    j = i
    while j <= N:
        # 制約で異なる選択肢を選べない組にコストINFの辺を張る
        dinic.add_link(i-1, j-1, INF)
        j += i

res = dinic.max_flow(s, t)
# 最大利益 = 調整分 - 最小カット
print(total - res)


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

bool isPrime(int n)
{
	if (n <= 1) return false;
	if (n == 2) return true;
	bool res = true;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			res = false;
			break;
		}
	}
	return res;
}

int main()
{
	int N;
	cin >> N;
	vector<int> nums(N);
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		cin >> nums[i];
		if (isPrime(nums[i]))
			cnt++;
	}
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 3088
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#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 REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll N,K;
    cin>>N>>K;
    vector<ll> A(N);
    REP(i,N) cin>>A[i];
    REP2(i,K,N){
        if(A[i]>A[i-K]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

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

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

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

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

int main() {
    int k,x;
    cin >> k >> x ;

    for(int i=x-k+1;i<x+k-1;i++){
        cout << i << " ";
    }

    cout << x+k-1 << endl;

}



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

int main()
{
	int a, b;
	cin >> a >> b;
	if (a + b == 15) cout << '+' << endl;
	else if (a * b == 15) cout << '*' << endl;
	else cout << 'x' << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


string a, b, ans;
ll dp[3100][3100];
int main() {
	cin >> a >> b;
	REP(i, a.size()) {
		REP(j, b.size()) {
			if (a[i] == b[j])dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
			else dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
		}
	}
	ll na = a.size(), nb = b.size();
	REP(i, INF) {
		bool ok = false;
		if (na <= 0 and nb <= 0)break;
		if (na != 0) {
			if (dp[na][nb] == dp[na - 1][nb]) {
				na--;
				ok = true;
			}
		}
		if(nb != 0 and !ok){
			if (dp[na][nb] == dp[na][nb - 1]) {
				nb--;
				ok = true;
			}
		}
		if(!ok) {
			ans.push_back(a[na - 1]);
			na--;
			nb--;
		}
	}
	reverse(ALL(ans));
	cout << ans << endl;
}

Measured memory_bytes: 73984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;


int main() {
    int n,k,ans = 0; cin >> n >> k;
    for(int i = 0;i < n;i++){
        int x; cin >> x;
        ans += min(abs(x*2),abs(k-x)*2);
    }
    cout << ans;
}




Measured memory_bytes: 256
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

d, t, s = input_a

if d > t * s
  puts "No"
else
  puts "Yes"
end


Measured memory_bytes: 14384
#include <stdio.h>

int main()
{
  int i, n, rank;
  int s[13] = {}, h[13] = {}, c[13] = {}, d[13] = {};
  char mark;
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf(" %c %d", &mark, &rank);
    switch(mark) {
      case 'S':
      s[rank-1] = 1;
      break;
      case 'H':
      h[rank-1] = 1;
      break;
      case 'C':
      c[rank-1] = 1;
      break;
      case 'D':
      d[rank-1] = 1;
      break;
    }
  }
  for(i = 0; i < 13; i++) {
    if(s[i] == 0) {
      printf("S %d\n", i + 1);
    }
  }
  for(i = 0; i < 13; i++) {
    if(h[i] == 0) {
      printf("H %d\n", i + 1);
    }
  }
  for(i = 0; i < 13; i++) {
    if(c[i] == 0) {
      printf("C %d\n", i + 1);
    }
  }
  for(i = 0; i < 13; i++) {
    if(d[i] == 0) {
      printf("D %d\n", i + 1);
    }
  }
  return 0;
}

Measured memory_bytes: 596
// ITP_1_9_B
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
  std::string to_string(char val) {
    return std::string(1, val);
    // return std::string{val};
  }
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    bool flag=true;
    string s;
    int kai,num;
    while(flag){
        cin>>s;
        if(s=="-") break;
        cin>>kai;
        int total=0;
        for(int i=0;i<kai;i++){
            cin>>num;
            total+=num;
        }
        int hanten=total%s.size();
        string ans;
        for(int i=0+hanten;i<s.size();i++){
            ans+=you::to_string(s[i]);
        }
        for(int i=0;i<hanten;i++){
            ans+=you::to_string(s[i]);
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3200
N = int(input())
X,Y = [],[]
for i in range(N):
    x,y = map(int,input().split())
    X.append(x)
    Y.append(y)

# パリティが同一かチェック
p = set()
for i in range(N):
    p.add((X[i]+Y[i])%2)

# もし0,1の2種類あるなら不可能
if len(p)>1:
    print(-1)
    exit()

# パリティが0の場合 → X座標を-1して 1の場合に帰着する(あとでX+1する)
if 0 in p:
    for i in range(N):
        X[i] -= 1

# アームを準備
D = []
for i in range(35):
    D.append(2**i)
D.sort(reverse=True)

Ans = []
# 順番に計算
for i in range(N):
    x,y = X[i],Y[i]
    x0,y0 = 0,0
    ans = ""
    for d in D:
        tx,ty = x-x0,y-y0
        if ty<tx and ty>-tx:
            ans += "R"
            x0 += d
        elif ty<tx and ty<-tx:
            ans += "D"
            y0 -= d
        elif ty>tx and ty<-tx:
            ans += "L"
            x0 -= d
        else:
            ans += "U"
            y0 += d
    Ans.append(ans)

# パリティが0の場合 → 1のアームを追加、最後にRで調整
if 0 in p:
    D.append(1)
    print(len(D))
    print(" ".join(map(str,D)))
    for ans in Ans:
        print(ans + "R")
else:
    print(len(D))
    print(" ".join(map(str,D)))
    for ans in Ans:
        print(ans)





Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ABC081 C - Not so Diverse
// 2020.06.24

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K; cin >> N >> K;
  map<int, int> mp; 
  set<int> s;
  REP(i, N){
    int a; cin >> a;
    mp[a]++;
    s.insert(a);
  }
  int n = s.size();
  if(n <= K){
    cout << 0 << endl;
    return 0;
  }
  priority_queue<int, vector<int>, greater<int> > pq;
  int ans = 0;
  for(auto i : mp){
    pq.push(i.second);
  }
  REP(i, n-K){
    ans += pq.top(); pq.pop();
  }
  cout << ans << endl;
}

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

int main(){
    int n,d;
    cin >> n >> d;
    int see_n = 2*d+1;
    int ans = n % see_n == 0 ? n / see_n : n / see_n + 1;
    cout << ans << endl;
}

Measured memory_bytes: 3568
n = int(input())
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))

diff = abs(a -(t- 0.006*h[0]))
ans = 0
for i in range(1,n):
	diff2 = abs(a - (t - 0.006*h[i]))
	if diff2 < diff:
		ans = i
		diff = diff2
print(ans+1)




Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

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

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n;
    cin >> n;
    if(n == 0) return 0;

    vector<string> vs(n);
    rep(i, 0, n) cin >> vs[i];

    int l = 0, r = 0;
    int state = 0;
    int ans = 0;

    for (int i = 0; i < n; ++i) {
        int nl = l, nr = r, nstate = state;
        if (vs[i] == "lu") {
            nl = 1;
        }
        if (vs[i] == "ld") {
            nl = 0;
        }
        if (vs[i] == "ru") {
            nr = 1;
        }
        if (vs[i] == "rd") {
            nr = 0;
        }
        if(nr == nl){
            nstate = nr;
        }
        if(nstate != state){
            ans++;
        }
        l = nl;
        r = nr;
        state = nstate;
    }
    cout << ans << endl;

    main();
    return 0;
}



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

using namespace std;

const int N = 123456;

int n,a[N];

int main()
{
	int ans = 0;
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%d",&a[n]);
		a[n]%=2;
		if(a[n]==1) ans++;
	}
	if(ans%2==0) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

#define vi vector<int>
#define p pair<int, int>
#define REP(i, n) for(int i = 0;i < n; i++)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define BR cout << endl;
#define INF  2000000000

int main(){
    int c[10][10], h, w, a[200][200];
    cin >> h >> w;
    REP(i, 10) REP(j, 10){
        cin >> c[i][j];
    }
    REP(i, h) REP(j, w){
        cin >> a[i][j];
    }
    REP(k, 10) REP(i, 10) REP(j, 10){
        if(i == j) continue;
        c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    }
    int ans = 0;
    REP(i, h) REP(j, w) if(a[i][j] != -1) ans += c[a[i][j]][1];
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  int sum_vote = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    sum_vote += A.at(i);
  }
  sort(A.begin(), A.end(), greater<int>());
  bool ok = true;
  for (int i = 0; i < M; i++) {
    if (A.at(i) * (4 * M) < sum_vote) ok = false;
  }
  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	int N;
	cin >> N;
	cout << 180 * (N - 2) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

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

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};



int main(){
    int s = 0;
    int ins = 0;
    int sum = 0;
    while(cin >> ins){
        if(s%10 == 0){
            if(s!= 0)COUT(sum);
            sum = ins;
        }else{
            sum -= ins;
        }
        s++;
        if(ins == 0)rt 0;
    }
    COUT(sum);
    return 0;
}



Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[][] p = new int[n][3];
        for(int i = 0; i < n; i++){
            int[] aux = p[i];
            aux[0] = scanner.nextInt();
            aux[1] = scanner.nextInt();
            aux[2] = scanner.nextInt();
        }
        int c0 = 0;
        int c1 = 0;
        int c2 = 0;
        for(int i = 0; i < n; i++){
            int[] aux = p[i];
            int a0 = aux[0] + Math.max(c1,c2);
            int a1 = aux[1] + Math.max(c0,c2);
            int a2 = aux[2] + Math.max(c1,c0);
            c0 = a0;
            c1 = a1;
            c2 = a2;
//            System.out.println(c0+" "+c1+" "+c2);
        }
        System.out.println((int)Math.max(Math.max(c0,c1),c2));
    }
}


Measured memory_bytes: 95080
#include<bits/stdc++.h>
using namespace std;
int main(){
    long k;
    cin>>k;
    int cnt=0;

for(int i=0;i<k;i++){
    int x;
    cin>>x;
  if(x!=(i+1)){
      cnt++;
  }
}
if(cnt>2){
    cout<<"NO";
}else if(cnt<=2){
    cout<<"YES";
}


    
}
  

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
using namespace std;
int main(){
	int N;
	string S;
	cin>>N>>S;
	int answer=114514334;
	int Wnum[300001]={},Enum[300001]={};
	for(int i=0;i<N;i++){
		if(S[i]=='W') Wnum[i+1]=Wnum[i]+1;
		else Wnum[i+1]=Wnum[i];
	}
	for(int i=0;i<N;i++){
		if(S[i]=='E') Enum[i+1]=Enum[i]+1;
		else Enum[i+1]=Enum[i];
	}
	for(int i=0;i<N;i++){
		int leader=i;
		int changenum=Wnum[leader]+(Enum[N]-Enum[leader+1]);
		answer=min(answer,changenum);
	}
	cout<<answer<<endl;
	return 0;
}


Measured memory_bytes: 3076
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int64 ans=a[0]/2;
  a[0]%=2;
  for(i=1;i<n;i++){
    if(a[i-1]>0 && a[i]>0){
      ans++;
      a[i]--;
    }
    ans+=a[i]/2;
    a[i]%=2;
  }
  printf("%lld\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

template<typename T>
void print_vector(vector<T>& a){
    REP(i, a.size()){
        cout << a.at(i);
        if(i + 1 < a.size()){
            cout << ' ';
        }
    }
    cout << endl;
}

void insertion_sort(vector<ll>& a, ll g, ll& cnt){
    for(ll i = g; i < a.size(); ++i){
        const ll v = a.at(i);
        ll j;
        for(j = i - g; j >= 0 && a.at(j) > v; j -= g, cnt++){
            a.at(j + g) = a.at(j);
        }
        a.at(j + g) = v;
    }
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n){
        cin >> a.at(i);
    }

    // shell sort
    ll count = 0;
    vector<ll> gs;
    gs.push_back(1);
    while(gs.back() * 3 + 1 < a.size()){
        gs.push_back(gs.back() * 3 + 1);
    }
    reverse(gs.begin(), gs.end());
    cout << gs.size() << endl;
    print_vector(gs);
    for(ll g : gs){
        insertion_sort(a, g, count);
    }
    cout << count << endl;
    for(ll x : a){
        cout << x << endl;
    }
    return 0;
}



Measured memory_bytes: 10692
N,M = map(int,input().split())
H = list(map(int,input().split()))
AB = [list(map(int,input().split())) for _ in range(M)]
load = [[] for _ in range(N)]
ans = 0

for a,b in AB:
  a-=1
  b-=1
  load[a].append(b)
  load[b].append(a)
  
for i,lis in enumerate(load):
  if len(lis)==0:
    ans+=1
  else:
    judge = True
    for j in lis:
      if H[i]<=H[j]:
        judge = False
        break
    if judge:
      ans+=1
      
print(ans)

Measured memory_bytes: 47516
while True:
    round = lambda x:(x*2+1)/2
    H,W=[int(x) for x in input().split()]
    f = W//2
    u = round(W/2 - W//2)//1
    if H == 0 and W == 0:
        break
    for a in range (H):
        if a % 2 == 0:
            print(("#" + ".")*f+("#")*int(u))
        else:
            print(("." + "#")*f+(".")*int(u))
    print('')


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


int main()
{
	int h, n;
	cin >> h >> n;
	vector<pair<int, int>> magic(n);
	for (int i = 0; i < n; i++) {
		int a_in, b_in;
		cin >> a_in >> b_in;
		magic.at(i) = make_pair(a_in, b_in);
	}

	vector<int> dp(h + 1, 100000000);
	for (int i = 1; i <= h; i++) {
		for (auto magic_ele : magic) {
			int temp = 0;
			if (magic_ele.first >= i) {
				temp = magic_ele.second;
			} else {
				temp = dp.at(i - magic_ele.first) + magic_ele.second;
			}
			dp.at(i) = min(dp.at(i), temp);
		}
	}

	cout << dp.at(h) << endl;
}


Measured memory_bytes: 256
// G - Longest Path
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define chmax(x,y) x=max(x,y)
int in(){int x;cin>>x;return x;}

vvi edges;
vi dp(100'000, -1);

int dfs(int p){
	if(0 <= dp[p]) return dp[p];
	dp[p] = 0;
	for(int c:edges[p]) chmax(dp[p], dfs(c)+1);
	return dp[p];
}

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

	edges.resize(N);
	while(M--) edges[in()-1].push_back(in()-1);

	int ans = 0;
	while(N--) chmax(ans, dfs(N));
	cout<< ans <<endl;
}


Measured memory_bytes: 9472
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputNumbers = Arrays.asList(br.readLine().split(" "));
            int X = Integer.parseInt(inputNumbers.get(0));
            int Y = Integer.parseInt(inputNumbers.get(1));
            int Z = Integer.parseInt(inputNumbers.get(2));
            
            int ans = 0;
            while (X >= Y + Z) {
                X = X - (Y + Z);
                ans++;
            }

            if (X < Z) {
                ans--;
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 22740
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

	static void exec(Scanner in, PrintStream out) {
		String b = in.next();
		if (b.equals("A")) {
			out.println("T");
		} else if (b.equals("C")) {
			out.println("G");
		} else if (b.equals("G")) {
			out.println("C");
		} else if (b.equals("T")) {
			out.println("A");
		}
	}

	public static void main(String[] args) {
		exec(new Scanner(System.in), System.out);
	}

}


Measured memory_bytes: 23124
#include<cstdio>
using namespace std;
int main(void)
{
	double a,b,s,x,t;
	scanf("%lf %lf",&a,&b);
	x=a*b;
	t=3.305785;
	s=x/t;
	printf("%lf\n",s);
	return 0;
}

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

int main(){
  int H,W;

  while(1){
    cin >> H >> W;
    
    if(H==0 && W==0){
      break;
    }

    for(int j=0; j<H; j++){
      for(int i=0; i<W; i++){
        if((j%2==0 && i%2==0) || (j%2==1 && i%2==1)){
            cout << "#";
        }else{
            cout << ".";
        }
      }
      cout << endl;
    }
    

    cout << endl;
  }
  
  return(0);
}

Measured memory_bytes: 1152
#include <iostream>

using namespace std;

int main()
{
	int cnt[4] = {};
	int a, b;
	for (int i = 0; i < 3; i++) {
		cin >> a >> b;

		cnt[a - 1]++;
		cnt[b - 1]++;
	}

	for (int i = 0; i < 4; i++) {
		if (cnt[i] != 1 && cnt[i] != 2) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;

	return 0;
}

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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    long n, a, b;
    cin >> n >> a >> b;
    if (a % 2 == b % 2) {
        cout << (b - a) / 2;
    } else {
        cout << (b - a + 1) / 2 + min(n - b, a - 1);
    }

    return 0;
}

Measured memory_bytes: 256