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

int N;

//出力する関数
void trace(int A[]){
  int i;
  for(i = 0;i<N;i++){
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}

//並べ替える関数
void insert(int A[]){
  int i,j,tmp;
  for(i=1;i<N;i++){
    j=i-1;
    tmp=A[i];
    while(tmp<A[j] && j>=0){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=tmp;
    trace(A);
  }

}
int main(){
  int A[100];
  int i;
  scanf("%d",&N);

  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  trace(A);
  insert(A);

return 0;
}


Measured memory_bytes: 2052
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        
//        int n=sc.nextInt();
        char c[]=sc.getCharSet();
        for (int i = 0; i < c.length; i++) {
    		if(c[i]=='?') {
    	        out.print("D");				
			} else 
    	        out.print(c[i]);				
		}
        out.println();
     	out.flush();
    }
    
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x,c;long s;
//	P(int  x, int c, long s) {
//	  this.x=x;
//	  this.c=c;
//	  this.s=s;
//	}
//}


class P implements Comparable<P>{
	int x,c;long s;
	P(int  x, int c, long s) {
	  this.x=x;
	  this.c=c;
	  this.s=s;
	}

    public int compareTo(P p){
        return Long.signum(s-p.s);
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 36856
#include<bits/stdc++.h>
using namespace std;
char s[51],b[51];
int main() {
	scanf("%s",s);
	scanf("%s",b);
	int len1=strlen(s);
	int len2=strlen(b);
	for(int i=0; i<len2; i++) {
		printf("%c%c",s[i],b[i]);
	}
	if(len1>len2) {
		printf("%c\n",s[len2]);
	} else {
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int n,t;
vi a;

int main(){
	cin>>n>>t;
	a=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	int M=0,MAX=0,num;
	for(int i=n-2;i>=0;i--){
		M=max(M,a[i+1]);
		if(MAX<M-a[i]){
			MAX=M-a[i];
			num=1;
		}
		else if(MAX==M-a[i]) num++;
	}
	cout<<num<<endl;
}

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

#define ll long long
#define endl "\n"
#define deb(x) cerr << #x << ":" << x << "\n"

void solve()
{
	ll n, k;
	cin >> n >> k;
	vector<ll> v(n + 1);
	for (int i = 1; i <= n;i++)
		cin >> v[i];
	if (k < n){
		int cur = 1;
		while (k--)
		{
			cur = v[cur];
		}
		cout << cur << endl;
		return;
	}
	set<ll> s;
	ll cur = 1;
	ll moves = 1;
	vector<int> d;
	vector<int> a;
	int cnt = 0;
	while (1)
	{
		if(s.count(cur)){
			for (int i = 0; i < d.size();i++){
				if(d[i]==cur){
					k -= i;
					for (int j = i; j < d.size();j++)
						a.emplace_back(d[j]);
				}
			}
			break;
		}
		s.insert(cur);
		d.emplace_back(cur);
		cur = v[cur];
	}
	// deb(k);
	// for (auto x : d)
	// 	cerr << x << " ";
	// cerr << endl;
	// for (auto x : a)
	// 	cerr << x << " ";
	// cerr << endl;
	cout << a[k % a.size()] << endl;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	while (t--)
		solve();
	return 0;
}
/*
1 6 2 5 3 2
 */

Measured memory_bytes: 12824
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  string w;
  cin >> w;
  
  map<char,int> mp;
  
  rep(i,w.size()){
    mp[w[i]]++;
  }
  
  for(auto m:mp){
    if(m.second%2){
      cout << "No";
      return 0;
    }
  }
  
  cout << "Yes";
  return 0;
}

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


int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, k; cin>>n>>k;
	cout<<(500*n >= k ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>//////////AOJ0037
                               int
i,j,w[5][5];char*p,b[1<<7];;   int
F(int(v)){scanf("%s",b);for(   p=b
;*p;++p                 ){w[   p-b
+1-v][j   +v]|=((w[p-   b][j   ]|=
(*p==49   )<<3-v)&8>>   v)>>   2;}
return(   j+=v          );/*   */}
main(){   for(   ;4-F   (0);   F(1
));for(   p=b,   i=j=   (*b=   3)^
3;i+=""   "BA"          "BC"   [*b
]-66,j=   (*b)["ABCB"]-66+j,   *++
p="ULDR   "[*b],i+j;)for((*    b+=
1)&=~4;                        !(w
[i][j]&(1<<*b));(*b+=3)&=3);return
!puts(b+1);}///////05-2018,@siikya



Measured memory_bytes: 2492
n = int(input())
sp = []
for i in range(n):
    s,p = map(str, input().split())
    sp.append((s,int(p)))
sp1 = tuple(sp)
sp = sorted(sp, key=lambda x:(x[0],-x[1]))
for h in sp:
    print(sp1.index(h)+1)

Measured memory_bytes: 9128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
#include <cstdlib>
using namespace std;

int main()
{
    vector<long long> abc(3);
    cin >> abc[0] >> abc[1] >> abc[2];
    sort(abc.begin(), abc.end());
    if (abc[2] & 1)
    {
        cout << abc[0] * abc[1] << endl;
    }
    else
    {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from sys import stdin
from collections import deque


def get_result(data):
    K = data[0]
    lunlun_num_q = deque([str(i+1) for i in range(9)])
    cnt = 9
    while cnt < K:
        tmp_num = lunlun_num_q.popleft()
        if tmp_num[-1] == '0':
            lunlun_num_q.extend([tmp_num + '0', tmp_num + '1'])
            cnt += 2
        elif tmp_num[-1] == '9':
            lunlun_num_q.extend([tmp_num + '8', tmp_num + '9'])
            cnt += 2
        else:
            last_digit = int(tmp_num[-1])
            lunlun_num_q.extend(
                [tmp_num + str(last_digit-1), tmp_num + str(last_digit),
                 tmp_num + str(last_digit+1)])
            cnt += 3

    return lunlun_num_q[-1+K-cnt]


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip().split(' ')))
    result = get_result(data)
    print(result)


Measured memory_bytes: 7924
def cin():  return list(map(int,input().split()))

N, K = cin()
A = cin()

dp = [[-1 for _ in range(2)] for _ in range(100)]
dp[0][0] = 0
MAX_DIGIT = 50

for i in range(1, MAX_DIGIT):
    mask = (1 << (MAX_DIGIT - i - 1))
    cnt = 0
    for j in range(N):  cnt += bool(A[j] & mask)
    cost0 = mask * cnt
    cost1 = mask * (N - cnt)
    if(dp[i - 1][1] != -1):  dp[i][1] = max(dp[i][1], dp[i - 1][1] + max(cost0, cost1))
    if(dp[i - 1][0] != -1):
        if(K & mask):  dp[i][1] = max(dp[i][1], dp[i - 1][0] + cost0)
        if(K & mask):  dp[i][0] = max(dp[i][0], dp[i - 1][0] + cost1)
        else:  dp[i][0] = max(dp[i][0], dp[i - 1][0] + cost0)
        
ans = max(dp[MAX_DIGIT - 1][0], dp[MAX_DIGIT - 1][1])
print(ans)

Measured memory_bytes: 86488
#include<stdio.h>
int inputi(){
	char c='0';
	int ans=0;
	signed char flg=1;
	do{
		c=getchar();
	}while(c<=32);
	if(c=='-'){
		flg=-1;
		c=getchar();
	}
	do{
		ans*=10;
		ans+=(c-'0');
		c=getchar();
	}while(c>32);
	return ans*flg;
}
int main(void){
	int n,j=0;
	unsigned o=0;
	n=inputi();
  	if(n==0) printf("0");
	while(n){
		if(n%2) o|=1<<j;
		if(n>0)n=(n-n%2)/-2;else n=(n+n%2)/-2;
		j++;
	}
	while(j){
		j--;
		printf("%d",(o&1<<j)>>j);
	}
	puts("");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
int main()
{
    int N, M;
    std::cin >> N;
    std::vector<std::string> s(N);
    std::map<std::string, int> st;
    for (int i = 0; i < N; i++) {
        std::cin >> s[i];
        if(st.find(s[i]) == std::end(st)) {
            st.insert(std::make_pair(s[i], 1));
        }
        else {
            st[s[i]]++;
        }
    }

    std::cin >> M;
    std::vector<std::string> t(M);
    for (int i = 0; i < M; i++) {
        std::cin >> t[i];
        if(st.find(t[i]) == std::end(st)) {
            st.insert(std::make_pair(t[i], -1));
        }
        else {
            st[t[i]]--;
        }
    }

    int ans = -10000000;
    for (auto & a : st) {
        if (a.second > ans) {
            ans = a.second;
        }
    }

    if (ans < 0) ans = 0;

    std::cout << ans << std::endl;

    return 0;
}

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


def solve(s: int):
    memo = [-1] * 1000001
    for i in range(1000001):
        if memo[s] >= 0:
            ret = i + 1
            break
        memo[s] = i
        if s % 2 == 0:
            s //= 2
        else:
            s = 3 * s + 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = int(next(tokens))  # type: int
    solve(s)

if __name__ == '__main__':
    main()


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

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll c = n / (a + b);
    ll d = n % (a + b);
    
    ll ans = a * c;
    ans += min(d, a);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
s = list(input())
K = int(input())

for i in range(len(s)):
    need = (123-ord(s[i]))%26
    if need <= K:
        s[i] = "a"
        K -= need
if 0 < K:
    tmp = ord(s[-1]) + K%26
    tmp -= 26 if 123 <= tmp else 0
    s[-1] = chr(tmp)
print("".join(s))

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

bool solve() {
    ll N, a;
    cin >> N;
    set<ll> s;
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        s.insert(a);
    }
    
    return s.size() == N;
}

int main() {
    string ans = solve() ? "YES" : "NO";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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; }



int main() {
    int N,M,R; cin >> N >> M >> R;
    vei r(R); rep(i,R) {cin >> r[i]; r[i]--;}
    sort(all(r));

    ll dp[205][205];
    rep(i,N) rep(j,N) {
        if(i == j) dp[i][j] = 0;
        else dp[i][j] = INF;
    }

    rep(i,M) {
        ll a,b,c; cin >> a >> b >> c;
        a--; b--;
        dp[a][b] = dp[b][a] = c;
    }

    rep(k,N) rep(i,N) rep(j,N) dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
    
    ll ans = INF;
    do{
        ll sum = 0;
        rep1(i,R) sum += dp[ r[i-1] ][ r[i] ];
        ans = min(ans, sum);
    }while( next_permutation( all(r) ) );

    cout << ans << endl;
    return 0;
}



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

int main() {
  int N, M; cin >> N >> M;
  vector<bool> has(N);
  while (M--) {
    int a,b; cin >> a >> b; a--, b--;
    int c;
    if (a == 0) c = b;
    else if (b == N-1) c = a;
    else continue;
    if (has[c]) {
      cout << "POSSIBLE" << '\n';
      exit(0);
    }
    has[c] = true;
  }
  cout << "IMPOSSIBLE" << '\n';
}

Measured memory_bytes: 256
import itertools
import math
import fractions
import functools
import copy

a, b, c, d = map(int, input().split())

a -= 1
sum = (b - (b//c + b//d - b//(c*d // fractions.gcd(c, d))))-(a-(a//c + a//d - a//(c*d // fractions.gcd(c, d))))
print(sum)

Measured memory_bytes: 63980
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int c[500];
int s[500];
int f[500];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  REP(i, n - 1) {
    cin >> c[i] >> s[i] >> f[i];
  }

  REP(i, n - 1) {
    int sum = s[i] + c[i];
    FOR(j, i + 1, n - 1) {
      if(sum < s[j]) sum += s[j] - sum;
      else sum += sum % f[j] != 0 ? f[j] - sum % f[j] : 0;
      sum += c[j];
    }
    cout << sum << endl;
  }

  cout << 0 << endl;
}


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
    int H,M,S;
    while(cin>>H>>M>>S){
        if(H==-1 && M==-1 && S==-1)break;
        int sec=2*60*60  -  (H*60*60 + M*60 +S);
        
        int h=sec/3600;
        sec-=h*3600;
        
        int m=sec/60;
        sec-=m*60;
        
        int s=sec;
        
        printf("%02d:%02d:%02d\n",h,m,s);
        
        
        sec=2*60*60  -  (H*60*60 + M*60 +S);
        sec*=3;
        
        h=sec/3600;
        sec-=h*3600;
        
        m=sec/60;
        sec-=m*60;
        
        s=sec;
        
        printf("%02d:%02d:%02d\n",h,m,s);
    }

    return 0;
}

Measured memory_bytes: 1160
def sub():
    N, K = [int(e) for e in input().split(" ")]
    ss = [int(e) for e in input()]
    # if len(set(ss)) == 1:
    #     print(len(ss))
    #     return

    dd = [ss[i+1] - ss[i] for i in range(N-1)]
    idd = [0] + [i+1 for i, d in enumerate(dd) if d != 0]
    # print(idd)
    maxScore = 0
    for i in range(len(idd)):
        if ss[idd[i]] == 0:
            ni = i + 2*K
            if ni < len(idd):
                score = idd[ni] - idd[i]
            else:
                score = N - idd[i]
            if score > maxScore:
                maxScore = score
        else:
            ni = i + 2*K + 1
            if ni < len(idd):
                score = idd[ni] - idd[i]
            else:
                score = N - idd[i]
            if score > maxScore:
                maxScore = score
        
    print(maxScore)

sub()


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

long long N, K;
long long x[55];
long long y[55];
long long ans;


long long func(long long x1, long long y1, long long x2, long long y2){
	long long tmp = 0;
	long long minix = min(x1, x2);
	long long maxix = max(x1, x2);
	long long miniy = min(y1, y2);
	long long maxiy = max(y1, y2);

	for(long long i = 0; i < N; i++){
		if(minix <= x[i] && x[i] <= maxix)
			if(miniy <= y[i] && y[i] <= maxiy)
				tmp++;
	}
	if(tmp >= K)
		ans = min(ans, (maxix - minix) * (maxiy - miniy));
}

int main(){
	cin >> N >> K;
	for(long long i = 0; i < N; i++){
		cin >> x[i] >> y[i];
	}

	ans = LONG_MAX;
	for(long long i = 0; i < N; i++)
		for(long long j = 0; j < N; j++)
			for(long long k = 0; k < N; k++)
				for(long long l = 0; l < N; l++)
					func(x[i], y[j], x[k], y[l]);
	cout << ans << endl;
}

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

list = [0]*61206

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            n = x*x + y*y + z*z + x*y + y*z + z*x
            list[n-1] += 1
            
ans = list[:N]

for n in ans:
    print(n)

Measured memory_bytes: 69012
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

ll lcm(ll a, ll b)
{
    if (a < b) {
        ll t = a;
        a = b;
        b = t;
    }
    ll aa = a;
    ll bb = b;
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    ll gcd = b;
    a = aa;
    b = bb;
    return a * b / gcd;
}

int main(int argc, char **argv)
{
    ll N, M;
    string S, T;
    cin >> N >> M >> S >> T;

    ll L = lcm(N, M);
    map<ll, char> X;
    REP(i, N) {
        X.insert(make_pair((L / N) * i, S[i]));
    }
    bool f = true;
    REP(i, M) {
        if (X.find((L / M) * i) != X.end()) {
            if (X[(L / M) * i] != T[i]) {
                f = false;
                break;
            }
        }
    }
    if (f) cout << L << endl;
    else cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 6144
#d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#import numpy as np
#import math
#n=int(input())
#li=input().split()
#n=int(input())
#lis=list(map(int,input().split()))

S=input()
l=len(S)

a,b=0,0
#01010...という文字列との比較
for i in range(l):
    if i%2==1 and S[i]=="0":
        a+=1
    elif i%2==0 and S[i]=="1":
        a+=1

#10101...という文字列との比較
for i in range(l):
    if i%2==1 and S[i]=="1":
        b+=1
    elif i%2==0 and S[i]=="0":
        b+=1
c=max(a,b)

ans=l-c

print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {

    int N;
    cin >> N;

    vector<int> AS;
    vector<int> BS;
    vector<int> CS;

    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        AS.push_back(A);
    }
    for (int i = 0; i < N; ++i) {
        int B;
        cin >> B;
        BS.push_back(B);
    }
    for (int i = 0; i < N - 1; ++i) {
        int C;
        cin >> C;
        CS.push_back(C);
    }

    int pre = AS[0];
    int s = BS[AS[0] - 1];

    for (int i = 1; i < N; ++i) {
        s = s + BS[AS[i] - 1];
        if (pre == (AS[i] - 1)) {
            s += CS[pre - 1];
        }
        pre = AS[i];
    }

    cout << s << "\n";
    return 0;
}


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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long
#define ld long double

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    if (s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes";
    else cout << "No";
    return 0;
}



Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <deque>
#include <thread>

using namespace std;

int main()
{
    int n, k;
    long long int a[200010];
    long long int ans = 0;
    long long int max = -1;

    cin >> k >> n;

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

    for (int i = 1; i < n; i++) {
        ans += a[i] - a[i-1];
        if (max < a[i] - a[i-1]) {
            max = a[i] - a[i-1];
        }
    }
    ans += k - a[n-1] + a[0];
    if (max < k - a[n-1] + a[0]) {
        max = k - a[n-1] + a[0];
    }

    cout << ans - max << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int main(int argc, const char *argv[]) {
  int N;
  cin >> N;
  string S;
  map<string, long long> A;
  long int ans = 0;

  for (int i = 0; i < N; i++) {
    cin >> S;
    sort(S.begin(), S.end());
    A[S]++;
  }

  for(auto x : A){
    ans += (x.second * (x.second - 1)) / 2;
  }
  cout << ans << endl;

  return 0;
}


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

int main(void){
    double k;int n;cin>>k>>n;
    double tmp, before;
    double a0, last;
    double max=-1;
    for(int i=0;i<n;i++){
        if(i==0){cin>>before;a0=before;continue;}
        cin>>tmp;
        if(tmp-before>=k/2){cout<<before+k-tmp<<endl;return 0;}
        if(tmp-before>max)max=tmp-before;
        before = tmp;
    }
    if(max<a0+k-tmp)max=a0+k-tmp;
    cout<<k-max<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      String W = sc.nextLine();
      int Wtotal = 0;
      while (sc.hasNext()) {
        String T = sc.next();
        if (T != "END_OF_TEXT") {
          T = T.toLowerCase();
          char line[] = T.toCharArray();
          if (line.length == W.length()) {
            int total = 0;
            for (int i = 0; i< W.length(); i++) {
              char Wj = W.charAt(i);
              char Tj = T.charAt(i);
              if (Wj == Tj) total++;
              }
              if (total == W.length()) Wtotal++;
          }
        }
      }
      System.out.println(Wtotal);
    }
}


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

int main(void)
{
    int number[3],k;
    for(int i = 0;i < 3;i++){cin >> number[i];}
    cin >> k;
    sort(number,number + 3);
    for(int i = 0;i < k;i++){number[2] *= 2;}
    cout << number[0] + number[1] + number[2] << endl;
    return 0;
}

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

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

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


def main():
    n,m = LI()
    a = sorted(LI())
    aa = sorted([LI() for _ in range(m)], key=lambda x: -x[1])
    ai = 0
    for b,c in aa:
        for j in range(b):
            if ai >= n:
                break
            if a[ai] < c:
                a[ai] = c
                ai += 1
            else:
                break
        if ai >= n:
            break

    return sum(a)


print(main())



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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


int N, K;
const int MAX_N = 100005;
ll dp[MAX_N];
int h[MAX_N];

void solve() {
    cin >> N >> K;
    rep(i, N) cin >> h[i];

    rep(i, MAX_N) dp[i] = 1e+9;
    dp[0] = 0;
    rep(i, N){
        rep1(j, K){
            if(i+j >= N) continue;
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i] - h[i+j]));
        }
    }

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

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 5504
//#include "stdc++.h"
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
    ll n;
    cin>>n;
    ll sum=0;
    ll a[n+1];
    ll i,j;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    i=1;
    ll sum1=0;
    ll temp,temp1=INT_MAX;
    ll ans;
    while(i<=n)
    {
        sum1+=a[i];
        temp=sum-sum1;
        ans=abs(temp-sum1);
        temp1=min(temp1,ans);
        i++;
    }
    cout<<temp1<<endl;
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
	int x, a[30];
	for(int i = 0;i < 30;i++)a[i] = 0;
	for(int i = 0;i < 28;i++)scanf("%d", &x), a[x-1] = 1;
	for(int i = 0;i < 30;i++)if(!a[i])printf("%d\n", i+1);
	return 0;
}

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

static const int MAX=100;
static const long long INF=(1LL<<32);

int n;
long long d[MAX][MAX];

void floyd(){
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      if(d[i][k]==INF) continue;
      for(int j=0;j<n;j++){
        if(d[k][j]==INF) continue;
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
}

int main(){
  int e,u,v,c;
  cin>>n>>e;
  
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      d[i][j]=((i==j)? 0:INF);
    }
  }
  for(int i=0;i<e;i++){
    cin>>u>>v>>c;
    d[u][v]=c;
  }
  
  floyd();
  
  bool negative =false;
  for(int i=0;i<n;i++) if(d[i][i]<0) negative=true;
  
  if(negative){
    cout<<"NEGATIVE CYCLE"<<endl;
  }else{
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        
      if(j) cout<<" ";
      if(d[i][j]==INF) cout<<"INF";
      else cout<<d[i][j];
    }
    cout<<endl;
  }
}
return 0;
}

                            
    
     


Measured memory_bytes: 3176
/*

1000 以下の３つの正の整数を入力し、
それぞれの長さを３辺とする三角形が直角三角形である場合には YES を、
違う場合には NO と出力して終了するプログラムを作成して下さい。

手順：
・データセット数nを入力
・x,y,rを入力
	・x,y,rのいずれかが1以上1000以下の範囲になければ、その入力はカウントしない。（i--）
・r^2==(x^2+y^2)なら、YES
	そうでなければ、NOを表示する。
・データセット数（n）回繰り返して終了。

・結果：Wrong answer

なぜか不正解。
3つの入力の内、x,y,rを切り替えられるようにしてみたが、やはり不正解。（x^2==(y^2+r^2)とか、y^2==(x^2+r^2)とか。)

*/

#include <stdio.h>

int main()
{
	int x[1000],y[1000],r[1000];
	int i,count=0;
	int n;
	while(1){
		scanf("%d",&n);
		if(n<=1000){
			break;
		}
	}
	for(i=0; i<n; i++){
		scanf("%d %d %d",&x[i],&y[i],&r[i]);
		if(x[i]<1||x[i]>1000||y[i]<1||y[i]>1000||r[i]<1||r[i]>1000){
			i--;
		}
	}
	for(i=0; i<n; i++){
		if(r[i]*r[i]==(x[i]*x[i])+(y[i]*y[i])){
			printf("YES\n");
		}
		else if(x[i]*x[i]==(y[i]*y[i])+(r[i]*r[i])){
			printf("YES\n");
		}
		else if(y[i]*y[i]==(x[i]*x[i])+(r[i]*r[i])){
			printf("YES\n");
		}
		
		else{
			printf("NO\n");
		}
	}
    return 0;
}

Measured memory_bytes: 588
N = int(input())
alist = list(map(int,input().split()))
ans = 10 ** 10
cnt = 0
asum = sum(alist)
for a in alist[:-1]:
    cnt += a
    diff = abs(asum - 2 * cnt)
    if ans > diff:
        ans = diff
print(ans)
    

Measured memory_bytes: 24816
dp = [0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0]
X=int(input())
rem = X%100
div = int(X/100)
if div>=dp[rem]:
  print('1')
else:
  print('0')

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int a, b, c, x, y;
  ll ans = 0;
  
  cin >> a >> b >> c >> x >> y;

  if(a + b > c*2){
    ans += min(x,y) * c * 2;
    int t = min(x,y);
    x -= t;
    y -= t;
  }

  
  if(a > c*2){
    ans += x * 2 * c;
  }else{
    ans += x * a;
  }

  if(b > c*2){
    ans += y * 2 * c;
  }else{
    ans += y * b;
  }

  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 256
n,m=map(int,input().split())
#n人が参加<=300
#m個のスポーツ<=300
#最も多くの人が参加しているスポーツの最小

aa=[list(map(int, input().split())) for _ in range(n)]

a=[[-1]*m for _ in range(n)]

for y in range(n):
    for x in range(m):
        a[y][aa[y][x]-1]=x

def pri(x):
    for item in x:
        print(item)

ans=301
for _ in range(m):
    score=[0]*m
    #print("###########")
    #pri(a)
    for y in range(n):
        mini=-1
        miniscore=501
        for x in range(m):
            if miniscore>a[y][x]:
                mini=x
                miniscore=a[y][x]
        score[mini]+=1
    tmp=max(score)
    ans=min(tmp,ans)
    #print(score)
    for x in range(m):
        if score[x]==tmp:
            for y in range(n):
                a[y][x]=501

print(ans)







Measured memory_bytes: 46684
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


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


int main() {
	
	string s;
	cin >> s;
	int n = s.size();
	int p1, p2;

	REP(i, n) {
		if (s[i] == 'A') {
			p1 = i;
			break;
		}
	}

	REP(i, n) {
		if (s[n-1-i] == 'Z') {
			p2 = n-1-i;
			break;
		}
	}

	ANS(p2 - p1 + 1);

	return 0;
}



Measured memory_bytes: 640
n, m = map(int, input().split())
a_set = set()

for i in range(m):
    a = int(input())
    a_set.add(a)

ret_list = [0] * (n + 1)

ret_list[0] = 1
ret_list[1] = 0 if 1 in a_set else 1

for i in range(2, n + 1):
    if i in a_set:
        ret_list[i] = 0
    else:
        ret_list[i] = (ret_list[i-1] + ret_list[i-2]) % 1000000007

print(ret_list[-1])


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

int main(){
	int n,cur = 100000;
	cin >> n;
	for(int i=0;i<n;i++){
		cur *= 1.05;
		if(cur%1000){
			cur += 1000-cur%1000;
		}
	}
	cout << cur << endl;
	
}

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    string s;
    cin >> s;

    int a_idx = s.size(), z_idx = -1;
    rep(i, s.size()){
        if(s[i] == 'A') a_idx = min(a_idx, i);
        else if(s[i] == 'Z') z_idx = max(z_idx, i);
    }

    cout << z_idx - a_idx + 1<< endl;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

template<typename T> class RPQ : public priority_queue<T, vector<T>, greater<T>> { };
template<typename C> void dijkstra(int s, vector<pair<int, C>> g[], C d[]) {
	RPQ<pair<C, int>> q;
	d[s] = 0;
	q.emplace(d[s], s);
	while(! q.empty()) {
		C   c = q.top().FI;
		int v = q.top().SE;
		q.pop();
		if(d[v] != c) { continue; }
		for(auto & e : g[v]) {
			int ev = e.FI;
			C   ec = e.SE;
			if(setmin(d[ev], d[v] + ec)) { q.emplace(d[ev], ev); }
		}
	}
}

const int M = 1001 * 1001 + 1;
int h, w, d[M];
vector<pair<int, int>> g[M];
string s[1000];

int id(int i, int j) { return (w + 1) * i + j; }

int main() {
	cin >> h >> w;
	inc(i, h) { cin >> s[i]; }
	
	inc(i, h) {
	inc(j, w) {
		g[id(i, j)].EB(id(i + 1, j), 1);
		g[id(i, j)].EB(id(i, j + 1), 1);
		g[id(i + 1, j)].EB(id(i, j), 1);
		g[id(i, j + 1)].EB(id(i, j), 1);
		if(s[i][j] == '#') { g[M - 1].EB(id(i, j), 0); }
	}
	}
	
	inc(i, M) { d[i] = M + 1; }
	dijkstra(M - 1, g, d);
	
	int ans = 0;
	inc(i, h) {
	inc(j, w) {
		setmax(ans, d[id(i, j)]);
	}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 97256
import sys
t='X'
for e in sys.stdin:
 for i in'0123456789'[(e[0]==t)*('+'!=e[1])or('+X'in e)*('+X='not in e)or('=X'in e)*(e[-1]==t):]:
  l,r=e.replace(t,i).split('=')
  if sum(map(int,l.split('+')))==int(r):print(i);break
 else:print('NA')


Measured memory_bytes: 5616
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
 ll n;
  cin >> n;
 vll a(n);
  map<ll,ll> mp;
  rep(i,0,n) {
    cin >> a[i];
    mp[a[i]]++;
  }
    sort(all(a));
  
  ll ans=0;
  
  repr(i,n,0){
    if(mp[a[i]]>1) continue;
   vll prime;
    for(int j=1;j*j<=a[i];j++){
     if(a[i]%j==0){
      prime.eb(j);
      if(j!=a[i]/j) prime.eb(a[i]/j); 
     }
    }
    ll f=1;
    for(auto x:prime) {
      auto it=a.begin();
      it+=i;
      if(upper_bound(a.begin(),it,x)-lower_bound(a.begin(),it,x)!=0) f=0;
    }
    ans+=f;
  }
  
  cout << ans << endl;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 17176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define in freopen("in.txt","r",stdin)
//#define out freopen("out.txt","w",stdout) 

const ll mod=998244353;
ll njie[200005];

ll qupow(ll a,ll b)
{
	if(b==0) return 1;
	ll c=qupow(a,b/2);
	if(b%2==1) return c*c%mod*a%mod;
	else return c*c%mod;
}

ll cnm(ll n,ll m)
{
	ll ans=njie[n]%mod;
	ll b=njie[n-m]*njie[m]%mod;
	return ans*qupow(b,mod-2)%mod;
}

int main()
{
	ll i,j;
	ll n,m,k;
	scanf("%lld%lld%lld",&n,&m,&k);
	njie[0]=1;
	for(i=1;i<=n;i++) njie[i]=njie[i-1]*i%mod;
	ll sum=0;
	for(i=0;i<=k;i++)
	{
		sum+=cnm(n-1,n-1-i)*m%mod*qupow(m-1,n-1-i)%mod;
	}
	sum%=mod;
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 5320
# -*- coding: utf-8 -*-
def main():
    S = list(input())
    Bcnt = 0
    ans = 0
    for i in range(len(S)):
        if S[i] == 'B':
            Bcnt += 1
        else:
            ans += Bcnt
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 82200
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val N = input.nextInt()
    val H = IntArray(N)
    
    for (i in H.indices) {
      H[i] = input.nextInt()
    }
    
    for (i in H.lastIndex - 1 downTo 1) {
      if (H[i] > H[i - 1] || H[i] > H[i + 1] ) {
        --H[i]
      }
    }
    
    var isNonDecreasing = true
    for (i in 1..H.lastIndex) {
      if (H[i] < H[i - 1]) {
        isNonDecreasing = false
        break
      }
    }
    --H[0]
    
    if (isNonDecreasing) {
      println("Yes")
    } else {
      println("No")
    }
  }
}

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

typedef long long int ll;
ll n, k, d, x;
bool ans[107];

int main() {
    cin >> n >> k;
    for(ll i = 0; i < k; ++i) {
        cin >> d;
        for(ll j = 0; j < d; ++j) {
            cin >> x;
            ans[x] = 1;
        }
    }

    ll cnt = 0;
    for(ll i = 1; i <= n; ++i) {
        if(!ans[i]) cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#define ll long long
#define Max(x,y) ((x)>(y)?(x):(y))
#define Min(x,y) ((x)<(y)?(x):(y))
#define Abs(x)   ((x)<0?(-(x)):(x))
using namespace std;
char s1[100000+5];
char s2[100000+5];
int s1a[100000+5];
int s1b[100000+5];
int s2a[100000+5];
int s2b[100000+5];
int main(){
        while(scanf("%s%s",s1+1,s2+1) != EOF){
                s1a[0] = s2a[0] = s1b[0] = s2b[0] = 0;
                for(int i = 1;s1[i];++i){
                        s1a[i] = s1a[i-1];
                        if(s1[i] == 'A')s1a[i] ++;
                }
                for(int i = 1;s1[i];++i){
                        s1b[i] = s1b[i-1];
                        if(s1[i] == 'B')s1b[i] ++;
                }

                for(int i = 1;s2[i];++i){
                        s2a[i] = s2a[i-1];
                        if(s2[i] == 'A')s2a[i] ++;
                }

                for(int i = 1;s2[i];++i){
                        s2b[i] = s2b[i-1];
                        if(s2[i] == 'B')s2b[i] ++;
                }
                int T;scanf("%d",&T);
                while(T --){
                        int x1,x2,y1,y2;
                        scanf("%d%d%d%d",&x1,&x2,&y1,&y2);
                        //printf("%d %d\n%d %d\n",s1a[x2] - s1a[x1-1],s1b[x2] - s1b[x1-1],s2a[x2] - s2a[x1-1],s2b[x2] - s2b[x1-1]);
                        int ans1 = s1a[x2] - s1a[x1-1] + (s1b[x2] - s1b[x1-1])*2;
                        int ans2 = s2a[y2] - s2a[y1-1] + (s2b[y2] - s2b[y1-1])*2;
                        if(ans1%3 == ans2%3) printf("YES\n");
                        else printf("NO\n");
                }
        }
        return 0;
}


Measured memory_bytes: 2304
import java.util.Arrays;
import java.util.Scanner;

import javax.net.ssl.SSLContext;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		int[] obuget = new int[100010];
		int[] ebuget = new int[100010];
		int[] o = new int[100010];
		int[] e = new int[100010];
		int E = 0;
		int O = 0;
		int E2 = 0;
		int O2 = 0;
		int m = n/2;
		boolean f  = true;
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}

		for (int i = 0; i < n; i++) {
			if (i % 2 == 0) {
				ebuget[a[i]]++;
			} else {
				obuget[a[i]]++;
			}
		}
		System.arraycopy(ebuget, 0, e, 0, 100010);
		System.arraycopy(obuget, 0, o, 0, 100010);
		Arrays.sort(ebuget);
		Arrays.sort(obuget);
		E = ebuget[100009];
		O = obuget[100009];
		E2 = ebuget[100008];
		O2 = obuget[100008];
		
		for (int i = 0; i < 100010; i++) {
			if (e[i] == E && o[i] == O) {
				f = false;
			}
		}
		if (f) {
			int ans = (m-E)+(m-O);
			System.out.println(ans);
			return;
		} else {
			int ans1 = (m-E2)+(m-O);
			int ans2 = (m-E)+(m-O2);
			System.out.println(Math.min(ans1, ans2));
		}
	}
}

Measured memory_bytes: 64656
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 53;

long long N, K;
vector<long long> meat;
vector<long long> num;

void input() {
    cin >> N >> K;
    meat.resize(MAX_N); meat[0] = 1;
    num.resize(MAX_N);  num[0] = 1;
    for (int i = 1; i < MAX_N; i++) {
        meat[i] = 1 + meat[i-1] * 2;
        num[i] = 3 + num[i-1] * 2;
    }
    return;
}

long long func(long long Lv, long long X) {
    if (X == 0) return 0LL;
    if (Lv == 0) return meat[0];
    if (X == 1) return 0LL;
    if (X == num[Lv]) return meat[Lv];
    long long half = num[Lv-1]+2;
    if (half <= X) return meat[Lv-1] + 1 + func(Lv-1, X-half);
    return func(Lv-1, X-1);
}

int main() {
    input();
    long long ans = func(N, K);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  double r;
  cin >> r;
  const double pi = acos(-1);
  double area = pi * r * r;
  double perimeter = 2 * pi * r;
  cout << fixed << setprecision(5) << area << " " << perimeter << endl;
  return 0;
}


Measured memory_bytes: 3300
N=parse(Int,readline())
cnt=zeros(Int,N)
for a=map(x->parse(Int,x),split(readline()))
	cnt[a+1]+=1
end
flag=true
for i=N:-2:2
	flag&=cnt[i]==2
end
println(flag ? powermod(2,div(N,2),10^9+7) : 0)

Measured memory_bytes: 128280