akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <cassert>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using ld = long double;

#define st first
#define nd second

const int MAXN = 1e6 + 5, inf = 1e9;
const ll INF = 1e18;
const ld PI = 3.1415926535897932384626433832795;

int cnt[MAXN];
ll dp[MAXN], tab[MAXN];
bool vis[MAXN], used[MAXN];

vector<int> G[MAXN];
vector<ll> V;
set<ll> S;
map<ll, int> M;
stack<ll> St;
queue<ll> Q;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(13) << fixed;

    //////////////////////////////////////////
    //////////////////////////////////////////

    ll n;
    cin >> n;
    ll res = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> tab[i];

    }

    for (int i = 1; i <= n + 1; i++)
    {
        res += abs(tab[i] - tab[i - 1]);
    }

    for (int i = 1; i <= n; i++)
    {
        //res = min(res, res - abs(tab[i] - tab[i - 1]) - abs(tab[i] - tab[i + 1]) + abs(tab[i - 1] - tab[i + 1]));
        cout << res - abs(tab[i] - tab[i - 1]) - abs(tab[i] - tab[i + 1]) + abs(tab[i - 1] - tab[i + 1]) << "\n";
    }
}


Measured memory_bytes: 27904
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <limits>
#include <sstream>
#include <typeinfo>

using namespace std;
typedef long long ll;
int main() {
	vector<ll> x(3);
	for (int i = 0; i < 3; i++) {
		cin >> x[i];
	}
	sort(x.begin(), x.end());
	ll n = x[2] / 2;
	ll m = x[2] - n;
	ll ans = (m - n) * (x[0] * x[1]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import math

N = int(input())

dig = int(math.log10(N))

num = 0
if dig == 0:
    num = N
elif dig == 1:
    num = 9
elif dig == 2:
    num = 9 + (N - 100 + 1)
elif dig == 3:
    num = 9 + 900
elif dig == 4:
    num = 9 + 900 + (N - 10000 + 1)
elif dig == 5:
    num = 9 + 900 + 90000
print(num)


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

using namespace std;

typedef long long ll;
const ll mx = 10000007;
const ll MOD = 1e9 + 7;
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
int main() {
    ll n;
    cin >> n;

    vector<ll>v;
    for (ll i = 0; i < n; i++) {
        ll x;
        cin >> x;
        v.push_back(x);
    }

    ll ans = v[0];

    for (ll i = 0; i < n; i++) {
        ans = lcm(ans, v[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 100000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    ll n, a, b, i, j;
    cin >> a >> b >> n;

    ll x = n;
    if (n >= b -1) x = b - 1;
    ll ans = a*x/b - a*(x/b);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3592
A=input()
if A[0] != "A":
  print("WA")
  quit()
if A[2:-1].count("C") != 1:
  print("WA")
  quit()
for i in range(1,len(A)):
  if A[i] !="C" and not A[i].islower():
    print("WA")
    break
else:
  print("AC")

Measured memory_bytes: 9036
/*  
	If they say
    Who cares if one more light goes out?
    In a sky of a million stars
    It flickers, flickers
    Who cares when someone's time runs out?
    If a moment is all we are
    We're quicker, quicker
    Who cares if one more light goes out?
    Well I do
*/

#include<bits/stdc++.h>
using namespace std;

#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) ((a) / gcd(a,b)) * (b)
#define all(x)  x.begin(),x.end()

#define ll long long
#define ull unsigned long long
#define VI vector<int>
#define VLL vector<ll>
#define VS vector<string>
#define MPII map<int, int>
#define SET set<int>
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
#define fast_io   ios_base::sync_with_stdio(false);cin.tie(0),cout.tie(0);

ll MOD = 1e9+7;

ll add(ll a, ll b){a+=b; a%=MOD;if(a<0) a+=MOD;return a;}
//doesn't work for neg numbers

ll mult(ll a, ll b){if(a>MOD) a%=MOD;if(b>MOD) b%=MOD;ll ans=(a*b)%MOD;if(ans<0) ans+=MOD;return ans;}
//doesn't work for neg numbers

ll pw(ull a, ull b){ll r=1;while(b){if(b&1) r=mult(r,a);a=mult(a,a);b>>=1;}return r;}
//doesn't work for neg numbers

void solve(){
	int a,b;
	cin>>a>>b;
	int arr[a];
	for(int i = 0 ; i < a ; i++){
		cin>>arr[i];
	}
	sort(arr, arr+a);
	int ans=0;
	for(int i = 0 ; i < b ; i++)ans+=arr[i];
	cout<<ans<<endl;

}

int main(){
/*	#if ONLINE_JUDGE
	  freopen("inputf.in", "r", stdin);
	  freopen("outputf.in", "w", stdout);
	#endif
*/
    fast_io;
    ll t, k=0;
    t=1;
    while(t--){
        //k++;        
        //cout<<"Case "<<k<<": ";
        solve();
    }
}


Measured memory_bytes: 3652
#include <stdio.h>

int main()
{
	int x, y, tmp;
	while (1) {
		scanf("%d %d", &x, &y);
		if (x == 0 & y == 0) {
			return 0;
		}
		if (x > y) {
			tmp = x;
			x = y;
			y = tmp;
		}
		printf("%d %d\n", x, y);
	}
}

Measured memory_bytes: 600
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;

const int mod = 1e9+7;
const int inf = 1e17+21;


int32_t main(){
    FAST;
    int n;  cin >> n;
    int f1 = 0 , f2  = 0 , f3 = 0 , f4 = 0  , f5 = 0;
    for(int x=0;x<n;x++){
        string s;   cin >> s;
        char ch = s[0];
        if(ch == 'M'){
            f1++;
        }else if(ch == 'A'){
            f2++;
        }else if(ch == 'R'){
            f3++;
        }else if(ch == 'C'){
            f4++;
        }else if(ch == 'H'){
            f5++;
        }


    }

    int ans = f1*f2*(f3 + f4 + f5);
    ans += f1*f3*(f4 + f5) + f1*f4*f5;
    ans += f2*f3*(f4 + f5) + f2*f4*f5 + f3*f4*f5;

    cout << ans;




    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
N = [list(list(input())) for _ in range(n)]
M = [list(list(input())) for _ in range(m)]

for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            if N[i+k][j:j+m] != M[k]:
                break
        else:
            print('Yes')
            exit()
else:
    print('No')


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<chrono>
#include<random>
#include<cstdio>
#include<set>
#include<map>
#define MAX_N 10
#define MAX_M 100
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;



int main(){
    int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int b;
    cin>>b;
    cout<<a[b-1];
}

Measured memory_bytes: 888
n,m = map(int,input().split())
#a = [input() for _ in [0]*n]
#b = [input() for _ in [0]*m]
#print(a,b)

ba = []
for i in range(n):
    ba.append(input())
bb = []
for i in range(m):
    bb.append(input())
    
#print(ba,bb)  
 
for i in range(n-m+1):
    for j in range(n-m+1):
        ok = True
        for k in range(m):
            #ba[]
            if ba[i+k][j:j+m] != bb[k]:
                ok = False
                break
        if ok:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3064
n = int(input())
N = list(map(int,input().split()))

for i in range(n):
    if N[i]%2 == 0:
        if N[i]%3 == 0 or N[i]%5 == 0:
            pass
        else:
            print('DENIED')
            break
else:
    print('APPROVED')


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

int main()
{
	int n,t,x,y,F=0;
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>t>>x>>y;
		if (x+y<=t && (t-x-y)%2==0) continue;
		else F=1;
		
	}
	if (F==0) cout<<"Yes";
	else	  cout<<"No";
	
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	c := make([][]int, 10)
	for i := 1; i <= 9; i++ {
		c[i] = make([]int, 10)
	}
	for i := 1; i <= N; i++ {
		x := top(i)
		y := i % 10
		c[x][y]++
	}
	ans := 0
	for i := 1; i <= 9; i++ {
		for j := 1; j <= 9; j++ {
			ans += c[i][j] * c[j][i]
		}
	}
	fmt.Println(ans)
}

func top(n int) int {
	for n >= 10 {
		n /= 10
	}
	return n
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

int findmax(int *a,int len){
	int maxn = 0;
	int pos = -1;
	for (int i = 0;i<len;i++){
		if (a[i]>maxn){
			maxn = a[i];
			pos = i;
		}
	}
	return pos;
}


int main() {
	int k,t,tt;
	cin>>k>>t;
	tt = 0;
	int *a = new int[t];
	while(tt<t){
		cin>>a[tt];
		tt++;
	}
	int pos = findmax(a,t); 
	int sum = 0;
	for (int i = 0;i<t;i++){
		if (i == pos)
			continue;
		sum +=a[i];
	}
	if (sum>=a[pos]){
		cout<<"0"<<endl;
	}else{
		cout<<a[pos]-sum-1<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s;
   int c=0;
   cin>>s;
   int f=0,l=s.size()-1;
  while(f<=l)
  {
      if(s[f]==s[l])
      {
          f+=1;
          l-=1;
      }
      else
      {
          c+=1;
          f+=1;
          l-=1;
      }
  }
  cout<<c;
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Maxn 4000007
const int INF = 1e9 + 5;
const int  N = 2e5 + 314;
void foo(){
    double n;
    cin>>n;
    cout<<fixed<<setprecision(10)<<(n/3)*(n/3)*(n/3);
}
int main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)foo();
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		
		boolean judge = false;
		
		while(true) {
			c -= b;
			if(c <= 0 ) {
				judge = true;
				break;
			}
			
			a -= d;
			if(a <= 0 ) {
				judge = false;
				break;
			}
		}
		
		if( judge == true) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 35768
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a>b)
	{
		if(a>c)
		printf("%d",(c+b));
		else
		printf("%d",(a+b));
	}
	else
	{
		if(b>c)
		printf("%d",a+c);
		else
		printf("%d",a+b);
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>

using namespace std;

int main(){
  int n, s1, s2, d, rect = 0, dia = 0;
  while (scanf("%d,%d,%d", &s1, &s2, &d) != EOF) {
    if (s1 * s1 + s2 * s2 == d * d) rect++;
    if (s1 == s2) dia++;
  }
  printf("%d\n%d\n", rect, dia);
  return 0;
}

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

using namespace std;

const long long MOD = 1000000007;
const int MAX = 2147483647;
const double PI = 3.14159265358979323846;

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


Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;

    int s1[100], s2[100];

    cin >>n>>m;
    for(int i = 0;i<n;i++)
        cin >> s1[i];
    for(int i = 0;i<m;i++)
        cin >>s2[i];
        int c1= 0,c2=0;
        int count=0;
while(n && m)
{
    for(int i = 0;i<n;i++)
        for(int j= 0;j<m;j++)
    {
        int t = s1[i];
        s1[i] = s2[j];
        s2[j] = t;
        count++;
        int sum1 = 0;
        int sum2 = 0;
        for(int p = 0;p<n;p++)
            sum1 +=s1[p];
        for(int p = 0;p<m;p++)
            sum2 +=s2[p];
        if(sum1 == sum2)
            if(c1==0&&c2==0)
        {
            c1 = s2[j];
            c2 = s1[i];
        }

         else if(c1!=0 &&c2!=0 && c1+c2>s2[j]+s1[i])
        {
            c1 = s2[j];
            c2 = s1[i];
        }
        int a = s1[i];
        s1[i] = s2[j];
        s2[j] = a;

    }
    if(c1 !=0 &&c2!=0)
        cout <<c1<<" "<<c2<<endl;
    else
        cout <<-1<<endl;
cin >>n>>m;
    for(int i = 0;i<n;i++)
        cin >> s1[i];
    for(int i = 0;i<m;i++)
        cin >>s2[i];
         c1= 0,c2=0;
         count=0;
}
}



Measured memory_bytes: 3076
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long LL;
const int MaxN = 1e5 + 4;
 
int main() {
	int q;
	scanf("%d", &q);
	while(q--) {
		LL a, b;
		scanf("%lld %lld", &a, &b);
		LL pro = a * b;
		LL sq = sqrt(pro);
		LL ans = sq * 2;
		if(sq * sq == pro) ans -= 2;
		if((pro - 1) / sq == sq) ans--;
		if(!(a == sq && b == sq)) ans--;
		printf("%lld\n", ans);
	}
	return 0;
}

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

int main(){
    int a,b,x=0;
    string s;
    cin >> a;
    cin >> s;
    b=s.size();
    for(int i=0;i<b-2;i++){
        if(s.at(i)=='A'&&s.at(i+1)=='B'&&s.at(i+2)=='C'){
            x++;
        }
    }
    cout << x << endl;

} 
 

Measured memory_bytes: 256
n,m,l = map(int, input().split())

A = [[0 for i in range(m)] for j in range(n) ]

B = [[0 for i in range(l)] for j in range(m) ]

C = [[0 for i in range(l)] for j in range(n) ]

for i in range(n):
  data = input().split()
  for j in range(m):
    A[i][j] = int(data[j])
    
for i in range(m):
  data = input().split()
  for j in range(l):
    B[i][j] = int(data[j])

for i in range(n):
  for j in range(l):
    for k in range(m):
      C[i][j] += A[i][k] * B[k][j]

for i in range(n):
  print(*C[i])


Measured memory_bytes: 7064
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
int N, M, K, H, W, L, R;



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

	cin >> N;
	vector<vector<pair<int,int>>>edge(N+10);
	for (int i = 0; i < N; i++) {
		cin >> M;
		if (!M) {
			for (int j = 1; j <= 6; j++) {
				edge[i].push_back({ i + j,1 });
			}
		}
		else {
			edge[i].push_back({ i + M,0 });
		}
	}
	vector<int>dis(N + 10, MOD);
	vector<int>ddis(N + 10, MOD);
	dis[0] = 0;
	deque<int>Q;
	Q.push_back(0);
	while (!Q.empty()) {
		int cn = Q.front();
	//	cout << cn << endl;
		Q.pop_front();
		if (ddis[cn] == dis[cn])continue;
		ddis[cn] = dis[cn];
		for (auto i : edge[cn]) {
			if (dis[i.first] > dis[cn] + i.second) {
				dis[i.first] = dis[cn] + i.second;
				if (i.second)Q.push_back(i.first);
				else Q.push_front(i.first);
			}
		}
	}
	cout << dis[N - 1] << endl;
}



Measured memory_bytes: 10740
# シンプルに左から探索するだけ
N = int(input())
A = [int(i) for i in input().split()]

L = [i+1 for i in range(N)]

cnt = 0
k = 0
for j in A:
  if j == L[k]:
    k += 1
  else:
    cnt += 1 

if k == 0:
  print(-1)
else:
  print(cnt)

Measured memory_bytes: 25768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N+1);
  rep1(i, N) {
    cin >> A[i];
  }
  ll ans = 0;
  map<int, int> mp;
  rep1(i, N) {
    mp[i+A[i]]++;
  }
  rep1(i, N) {
    ans += mp[i-A[i]];
  }
  cout << ans << endl;
}

Measured memory_bytes: 20952
#include<stdio.h>
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define N 1001

int main(){
	int n,m,i,j;
	int a[N];
	int b[N];
	int flg=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	
	scanf("%d",&m);
	for(i=0;i<m;i++)scanf("%d",&b[i]);
		
	for(i=0;i<MIN(n,m);i++){
		if(a[i]==b[i])continue;
		else if(b[i] > a[i]){
			printf("1\n");
			break;
		}
		else if(b[i] < a[i]){
			printf("0\n");
			break;
		}
	}
	
	if(i==MIN(n,m)){
		if(n == m)printf("0\n");
		else if(n < m)printf("1\n");
		else printf("0\n");
	}
	
	
	return 0;
	
}


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

int main() {
    int n, a, b;
    cin >> n >> a >> b;

    int r = 0;
    for (int i = 1; i <= n; i++) {
        int k = 0, t = i;
        for (int j = 0; j < 5; j++) {
            k += t % 10;
            t /= 10;
        }
        if (a <= k && k <= b) r += i;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int atinclease_count=0,h,w,i,j,atcount=0;
    char table[21][21];
    while (1) {
        
        scanf("%d %d ",&w,&h);
        
        if (h==0 && w==0) {
            break;
        }
        
        for (i=0; i<h; i++) {
                //table[i][j] = getchar();
                scanf("%s",table[i]);
        }
        
        while (1) {
            
            for (i=0; i<h; i++) {
                for (j=0; j<w; j++) {
                    if (table[i][j] == '@') {
                        if (table[i-1][j]=='.') {
                            table[i-1][j] = '@';
                            atinclease_count++;
                        }
                        
                        if (table[i+1][j]=='.') {
                            table[i+1][j] = '@';
                            atinclease_count++;
                        }
                        
                        if (table[i][j-1]=='.') {
                            table[i][j-1] = '@';
                            atinclease_count++;
                        }
                        
                        if (table[i][j+1]=='.') {
                            table[i][j+1] = '@';
                            atinclease_count++;
                        }
                    }
                }
            }
            
            if(atinclease_count == 0){
                break;
            }
            
            atinclease_count=0;
            
        }
        
        for (i=0; i<h; i++) {
            for (j=0; j<w; j++) {
                if (table[i][j]=='@') {
                    atcount++;
                }
            }
        }
        
        printf("%d\n",atcount);
        atcount=0;
    }
    return 0;
}

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

int a[100005], b[100005], psa[100005], bit[200005];
int n;

void update(int i) {
	for (; i < 200005; i += (i & -i))
		bit[i]++;
}

int query(int i) {
	int ans = 0;
	for (; i > 0; i -= (i & -i))
		ans += bit[i];
	return ans;
}

bool test(int m) {
	memset(bit, 0, sizeof bit);
	update(n + 1);
	psa[0] = 0;
	ll cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i-1] >= m)
			b[i] = 1;
		else
			b[i] = -1;
		psa[i] = psa[i - 1] + b[i];
		cnt += query(psa[i] + n + 1);
		update(psa[i] + n + 1);
	}
	return cnt >= (1LL * n * (n + 1) / 2 + 1) / 2;
}

int main() {
	scanf("%d", &n);
	int lo = 1, hi = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		hi = max(hi, a[i]);
	}
	while (lo < hi) {
		// printf("lo = %d, hi = %d\n", lo, hi);
		int mid = (lo + hi + 1) / 2;
		// printf("test(%d) = %d\n", mid, test(mid));
		if (test(mid))
			lo = mid;
		else
			hi = mid - 1;
	}
	printf("%d", lo);
}

Measured memory_bytes: 2176
K, N = list(map(int, input().split()))
A = list(map(int, input().split()))

max_diff = 0
for i in range(N):
    if i == 0:
        diff = K+A[0]-A[-1]
    else:
        diff = A[i] - A[i-1]
    max_diff = max(max_diff, diff)


print(K-max_diff)


Measured memory_bytes: 26444
#include<stdio.h>
#include<stdlib.h>
int D(int d,int dd);
typedef struct pp{
  int id;
  double k;
  int parent;
  int depth;
  int C[100];
  int J;
}P;
P *A;
int main(){
  int n,*S,i,j,N,count=0;
  
  scanf("%d\n",&n);
  
  A=(P*)malloc((n*n)*sizeof(P));
  for(i=0;i<n*n;i++) A[i].k=3.14;
  for(i=1;i<=n;i++) scanf("%lf",&A[i].k);
  
  printf("node 1: key = %.0f, left key = %.0f, right key = %.0f, \n",A[1].k,A[2].k,A[3].k);
  for(i=2;i<=n;i++){
    if(A[i*2].k==3.14) printf("node %d: key = %.0f, parent key = %.0f, \n",i,A[i].k,A[i/2].k);
    else if(A[i*2].k!=3.14&&A[i*2+1].k==3.14) printf("node %d: key = %.0f, parent key = %.0f, left key = %.0f, \n",i,A[i].k,A[i/2].k,A[i*2].k);
    else printf("node %d: key = %.0f, parent key = %.0f, left key = %.0f, right key = %.0f, \n",i,A[i].k,A[i/2].k,A[i*2].k,A[i*2+1].k);
  }
 
  return 0;
}



Measured memory_bytes: 27632
using System;
using System.Collections.Generic;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Io.Read<int>();

            var output = 0L;
            for (var i = 1; i < N; i++)
            {
                output += i;
            }

            Console.WriteLine(output);
        }
    }

    class Io
    {
        public static string Read()
        {
            return Console.ReadLine();
        }

        public static IEnumerable<string> ReadRepeat(int count)
        {
            return Enumerable.Range(0, count).Select(_ => Read());
        }

        public static T Read<T>()
        {
            return (T)Convert.ChangeType(Read(), typeof(T));
        }

        public static IEnumerable<T> ReadRepeat<T>(int count)
        {
            return Enumerable.Range(0, count).Select(_ => Read<T>());
        }

        public static string[] ReadSplit(char devide = ' ')
        {
            return Read().Split(devide);
        }

        public static T[] ReadSplit<T>(char devide = ' ')
        {
            return ReadSplit(devide)
                .Select(s => (T)Convert.ChangeType(s, typeof(T)))
                .ToArray();
        }

        public static IEnumerable<T[]> ReadSplitRepeat<T>(int count, char devide = ' ')
        {
            return Enumerable.Range(0, count).Select(_ => ReadSplit<T>(devide));
        }
    }
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=998244353;

//status unsolved

int main(){
    
    int N,S;
    cin>>N>>S;
    vector<int>A(N);

    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    //dp[i][k]:=最初のi個の数のみについて考えた時の、
    //総和がkであるように選んでできる部分集合全てについての
    //それを含むような集合の個数の総和

    vector<vector<long long>>dp(N+1,vector<long long>(S+1,0));

    dp[0][0]=1;

    for(int i=0;i<N;i++){
        for(int k=0;k<=S;k++){
            //A[i]を選ばない時、和がkになる部分集合自体は変化しないが
            //それを含む集合の個数はA[i]を含むか含まないかの2通りになる
            dp[i+1][k]+=dp[i][k]*2%mod;
            
            //和がk-A[i]のものをたす
            if(k-A[i]>=0)dp[i+1][k]+=dp[i][k-A[i]];
            dp[i+1][k]%=mod;
        }
    }
    cout<<dp[N][S]<<endl;

    return 0;

}
/*


*/


Measured memory_bytes: 73756
N,K = list(map(int,input().split()))
p = list(map(int,input().split()))

value = [0]*N
k_list = []

for i in range(N):
    value[i] = (p[i]+1)*0.5
    
value_list = [0]*N

for i in range(N):
    value_list[i] = value_list[i-1] + value[i]

value_list.append(0)

for i in range(N-K+1):
    k_list.append(value_list[i+K-1]-value_list[i+K-(K+1)])
    
print(max(k_list))

Measured memory_bytes: 28232
//insertion sort
#include <iostream>
#define max_n 101

using namespace std;

void trace(int* a, int n)
{
	for(int i = 0; i < n; ++i)
	{
		if(i > 0)
			cout << " ";
		cout << a[i];	
	}
	cout << endl;	
}

//in ascending order
void insertionSort(int* a, int n) 
{
	int key;
	for(int i = 1; i < n; i++)
    {
    	key = a[i];
    	int j = i - 1;
    	while(j >= 0 && a[j] > key)
    	{
    		a[j + 1] = a[j];
    		--j;      //j = 1 is possible
		}
		a[j + 1] = key;
		trace(a, n);
	}
}

int main(void)
{
	int n, a[max_n];
	
	cin >> n;
	for(int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	
	trace(a, n);
	insertionSort(a, n);
	
	return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n, d;
	cin >> n >> d;

	int view = 2 * d + 1, ans = 0;
	while (n > 0) {
		n -= view;
		ans++;
	}

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


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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<double,int> p;

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

#define MAX_N 1010
#define MAX_V MAX_N+2
struct edge {int to;double cost;};
int V;
vector<edge> G[MAX_V];
double d[MAX_V];

void dijkstra(int s){
    priority_queue<p,vector<p>, greater<p> > que;
    fill(d,d+V, INF*INF);
    d[s]=0;
    que.push(p(0,s));
    while(!que.empty()){
        p pi = que.top(); que.pop();
        int v = pi.second;
        if(d[v] < pi.first) continue;
        REP(i,G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(p(d[e.to],e.to));
            }
        }
    }
}

// 円と円の距離
double caldis(double x1, double y1, double r1, double x2, double y2, double r2){
    double ret = sqrt( (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2) );
    ret = max(0.0, ret-r1-r2);
    return ret;
}


double xs,ys,xt,yt;
int N;
double cx[MAX_V];
double cy[MAX_V];
double cr[MAX_V];
int main(){
    ios::sync_with_stdio(false);
    cin >> cx[0] >> cy[0] >> xt >> yt >> N;
    V=N+2;
    cr[0]=0;
    REP(i,N) {
        cin >> cx[i+1] >> cy[i+1] >> cr[i+1];
    }
    cx[N+1]=xt;cy[N+1]=yt;cr[N+1]=0;
    
    double mindis = INF*INF;
    REP(i,N+2)REP(j,N+2)if(i!=j){
        double tmp = caldis(cx[i],cy[i],cr[i],cx[j],cy[j],cr[j]);
        G[i].pb((edge){(int)j,tmp});
        G[j].pb((edge){(int)i,tmp});
    }
    
    dijkstra(0);
    
    cout << fixed << setprecision(15) << d[N+1] << endl;
    
    return 0;
}

Measured memory_bytes: 37044
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Console;
using static System.Math;
class Simple
{
    int N;
    int[] p;
    void Solve() {
        //input
        N = io.Int;
        p = new int[N];
        for (int i = 0; i < N; ++i) {
            p[i] = io.Int;
        }
        //cal
        var isToSwap = p.Select((v, i) => v == i + 1).ToArray();
        var cnt = 0;
        for (int i = 0; i < N - 1; ++i) {
            if (isToSwap[i] && isToSwap[i + 1]) {
                cnt++;
                isToSwap[i] = false;
                isToSwap[i + 1] = false;
            } else if (isToSwap[i]) {
                cnt++;
                isToSwap[i] = false;
            }
        }
        if (isToSwap[N - 1]) cnt++;
        //ret
        WriteLine(cnt);
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}
class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] { ' ', '"', ',' };
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
        AutoFlush = false
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if (_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == "")
            st = ReadLine();
        if (st != null)
            _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else
            st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


Measured memory_bytes: 19424
# -*- coding: utf-8 -*-
import math

import math
#試し割法
def trial_division(n):
    #素因数を格納するリスト
    factor = [0]
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            if(num != 1):
                factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        return n
    else:
        factor.append(n)
        return factor

def main():
    N = int(input())
    result = 1
    divisor = []

    for i in range(1, N+1):
        divisor.extend(trial_division(i))

    for i in range(2,N+1):
        result = result*(divisor.count(i)+1)

    print(result % (10 ** 9 + 7))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int N=cin.nextInt();
		int[][]a=new int[N][3];
		int[] score=new int[N];
		for(int i=0;i<N;i++){
			for(int j=0;j<3;j++){
				a[i][j]=cin.nextInt();
			}
		}
		for(int j=0;j<3;j++){
			for(int i=0;i<N;i++){
				boolean f=true;
				for(int k=0;k<N;k++){
					if(i==k)continue;
					if(a[i][j]==a[k][j])f=false;
				}
				if(f)score[i]+=a[i][j];
			}
		}
		for(int i=0;i<N;i++){
			System.out.println(score[i]);
		}
	}

}

Measured memory_bytes: 20848
A,B = map(int,(input().split()))


tasu = A+B
hiku = A-B
kakeru = A*B

"""
print('tashizan',tasu)
print('hiki',hiku)
print('kake',kakeru)
"""


if tasu >= hiku and tasu >= kakeru:
    print(tasu)
elif hiku >= tasu and hiku >= kakeru:
    print(hiku)
else:
    print(kakeru)


"""
for i in range(3):
    if tasu > hiku:
        if tasu > kakeru:
            print(tasu)
    elif hiku > tasu:
        if hiku > kakeru:
            print(hiku)
    elif kakeru > tasu:
        if kakeru > hiku:
"""

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int k,a,b;
  cin >> k >> a >> b;
  bool f = false;

  FOR(i, a, b + 1){
    f |= i % k == 0;
  }

  cout << ( f ? "OK" : "NG" ) << endl;

  return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int n, t, h;
	int sum = 0, speed = 0;
	pair<int,int> bef, ans;
	
	cin>>n>>t;
	
	for(int i = 0; i < n; i++){
		cin>>h;
		if(sum >= t) ans.first = 1;
		else {
			if(speed <= h){
				ans.first = (t - sum)/h + 1;
				ans.second = ((t - sum)/h)*h + sum;
				speed = h;
			} else {
				if(t - bef.second < h){
					ans.first = bef.first-1;
					ans.second = bef.second - speed + h;
				} else {
					ans.first = bef.first;
					ans.second = bef.second + h;
				}
			}
		}
		sum += h;
		bef = ans;
		cout<<ans.first<<endl;
	}
	return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N; cin >> N;
  string S; cin >> S;
  int ans = 0;
  for (int i = 0; i + 1 < N; i++) {
    int on[256] = {0};
    for (int j = 0; j < i; j++) on[S[j]] |= 1;
    for (int j = i; j < N; j++) on[S[j]] |= 2;

    int cur = 0;
    REP(i, 256) if (on[i] == 3) cur++;
    chmax(ans, cur);
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};



int main(){
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; i++) cin >> H[i];
    vector<int> dp(N);
    dp[0] = 0;
    for(int i = 1; i < N; i++){
        if(i == 1) dp[i] = dp[i - 1] + abs(H[i] - H[i - 1]);
        else{
            dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2]));
        }
    }
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 4036
r=raw_input
N,M=r().split()
c=[0,2,5,5,4,5,6,3,7,6]
A=sorted(r().split())
N=int(N)
D,a=[0]+[-1]*N*9,[0,0]*N
for i in range(1, N + 1):
 for j in A:
  p=i-c[int(j)]
  if min(p,D[p],D[p]+1-D[i])>=0:D[i],a[i]=D[p]+1,j
S=""
while N:S,N=S+a[N],N-c[int(a[N])]
print S

Measured memory_bytes: 4100
#include<iostream>
using namespace std;
int main(){
  int n[101];
  int i;
  int num;
  cin >> num;
  for(i=0;i<num;i++) cin >> n[i];
  cout << n[num-1];
  for(i=1;i<num;i++) cout <<" "<< n[num-i-1];
  cout << endl;
  return 0;
}



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

ll knap(ll n, ll w, vector<pair<ll, ll>> &in, vector<vector<ll>> &dp){
    if(n == -1){
        return 0;
    }
    ll it = dp[n][w];
    if(it != -1){
        return it;
    }
    

    ll a = knap(n - 1, w, in, dp);

    ll b = w >= in[n].first ? in[n].second + knap(n - 1, w - in[n].first, in, dp) : 0;
    dp[n][w] = max(a, b);
    return dp[n][w];
}

int main(){
    ll n, w;
    cin>>n>>w;
    vector <pair<ll, ll>> in(n);
    for(int i = 0; i< n; i++){
        cin>>in[i].first>>in[i].second;
    }
    ll p = w + 1;
    vector<vector<ll>> dp(n, vector<ll>(p, -1));
    ll ans = knap(n - 1, w, in, dp);
    cout<<ans<<endl;
}


Measured memory_bytes: 79360
#include <iostream>
#include <string>

int compare(std::string a, std::string b)
{
    for(int i = 0; i < a.size() && b.size(); ++i){
        if(a[i] > b[i]) return 1;
        if(a[i] < b[i]) return -1;
    }
    if(a.size() == b.size()) return 0;
    if(a.size() >  b.size()) return 1;
    return -1;
}

int main()
{
    int taro = 0;
    int hana = 0;
    int n;
    std::cin >> n;
    for(int i = 0; i < n; i++){
        std::string t;
        std::string h;
        std::cin >> t >> h;
        if(compare(t,h) < 0){
            hana += 3;
        }else
        if(compare(t,h) > 0){
            taro += 3;
        }else{
            hana += 1;
            taro += 1;
        }
    }
    std::cout << taro << " " << hana << std::endl;
    return 0;
}

Measured memory_bytes: 3164
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a,b,c,x;
    cin >> a >> b >> c >> x;
    int answer=0;
    REP(i,a+1){
        REP(j,b+1){
            REP(k,c+1){
                if(i*500+j*100+k*50==x)answer++;
            }
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
n,m,xm = map(int,input().split())

c = []

ans = 10**9

for i in range(n):
    c.append(list(map(int,input().split())))

for i in range(2**n):
    t = []
    r = [0]*m
    cost = 0
    for s in range(n):
        if i >> s & 1:
            t.append(s)
    
    for tx in t:
        cost += c[tx][0]
        for x in range(m):
            r[x] += c[tx][x+1]

    if min(r)>xm-1:
        ans = min(ans,cost)

if ans == 10**9:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9064
#include<cstdio>
#include<set>
using namespace std;
struct le{
bool operator()(int x,int y){
return x>y;
}
};
multiset<int,le> l;
multiset<int,le>::iterator p;

int a[100005];
int n;
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
p=l.upper_bound(a[i]);
if(p!=l.end())l.erase(p);
l.insert(a[i]);
}
printf("%d",l.size());
}

Measured memory_bytes: 5376
use proconio::*;

#[fastout]
fn run() {
    input! {
        n: usize,
        m: usize,
        mut e: [(usize, usize); m],
    }
    let mut cnt = vec![0; n];
    for e in e.iter_mut() {
        e.0 -= 1;
        e.1 -= 1;
        cnt[e.0] += 1;
        cnt[e.1] += 1;
    }
    let mut g: Vec<_> = cnt.into_iter().map(|c| Vec::with_capacity(c)).collect();
    for (a, b) in e {
        g[a].push(b);
        g[b].push(a);
    }
    let mut prev = vec![n; n];
    prev[0] = 0;
    let mut q = std::collections::VecDeque::new();
    q.push_back(0);
    while let Some(v) = q.pop_front() {
        for &u in g[v].iter() {
            if prev[u] == n {
                prev[u] = v;
                q.push_back(u);
            }
        }
    }
    println!("Yes");
    for p in prev.iter().skip(1) {
        println!("{}", *p + 1);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 14244
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

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

    cout << a*b/2 << endl;

}



Measured memory_bytes: 3636
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            check(sc.nextLine());
        }
    }

    private static void check(String s) {
        for (int i = 0; i <= 9; i++) {
            String[] lines = s.replaceAll("X", String.valueOf(i)).split("[+=]");
            if((lines[0].length()>1 && lines[0].charAt(0)=='0') || (lines[1].length()>1 && lines[1].charAt(0)=='0') || (lines[2].length()>1 && lines[2].charAt(0)=='0'))
                continue;
            if (new BigInteger(lines[0]).add(new BigInteger(lines[1])).equals(new BigInteger(lines[2]))) {
                System.out.println(i);
                return;
            }
        }
        System.out.println("NA");
    }
}



Measured memory_bytes: 30792
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define gcd __gcd
bool compare(ll x, ll y){
    return x>y;
}
ll isprime(ll n){
    if(n==1) return 0;
    else if(n==2) return 1;
    else{
        for(ll i=2;i<=sqrt(n);i++){
            if(n%i==0) return 0;
        }
    return 1;   
    }
}
vector<ll> get_prime_less(ll n){
    ll array[n];
    vector<ll> factor;
    for(ll i=1;i<=n;i++) array[i]=i;
    ll prime[n];
    for(ll i=0;i<n;i++) prime[i]=1;
    for(ll i=2;i<=sqrt(n);i++){
        if(prime[i]==1){
            for(ll j=i*i;j<=n;j=j+i) prime[j]=0; 
            factor.push_back(i);
        }
    }
    return factor;
}
vector<ll> retain_index(ll arr[], ll n){ 
    vector<pair<ll, ll> > vp; 
    for (ll i = 0; i < n; ++i) { 
        vp.push_back(make_pair(arr[i], i)); 
    } 
    sort(vp.begin(), vp.end());
    vector<ll> retain;
    for (ll i = 0; i < vp.size(); i++) { 
        ll a = vp[i].second;
        retain.pb(a);
    }
    return retain;
}
int main(){
    string s;
    cin>>s;
    if(s[0]==s[1] && s[1]==s[2]) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


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

int L[N][N], R[N][N], U[N][N], D[N][N], ans;

char mat[N][N];

int32_t main()
{
	cin>>n>>m;

	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			cin>>mat[i][j];

	for(int i = 1; i <= n; i++)
	{
		int cara = 0;

		for(int j = 1; j <= m; j++)
		{
			if(mat[i][j] == '#') cara = j;

			L[i][j] = cara;
		}

		cara = m + 1;

		for(int j = m; j >= 1; j--)
		{
			if(mat[i][j] == '#') cara = j;

			R[i][j] = cara;
		}
	}

	for(int j = 1; j <= m; j++)
	{
		int cara = 0;

		for(int i = 1; i <= n; i++)
		{
			if(mat[i][j] == '#') cara = i;

			U[i][j] = cara;
		}

		cara = n + 1;

		for(int i = n; i >= 1; i--)
		{
			if(mat[i][j] == '#') cara = i;

			D[i][j] = cara;
		}
	}

	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			int tot = abs(R[i][j] - j) + abs(L[i][j] - j) + abs(U[i][j] - i) + abs(D[i][j] - i);

			ans = max(ans, tot);
		}
	}

	cout<<max(0LL, ans-3)<<"\n";
}

Measured memory_bytes: 131456
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll m;cin>>m;
  ll ans=0;
  vi A;
  for(int i=0;i<m;i++){
    ll a,b;cin>>a>>b;
    // ll nnum=a*b;
    if(a==0)ans+=b;
    // else if(a==9){ans+=2*b-2;A.pb(9);}
    else{
      vi hogg;
      for(ll i=BITLE(50);i>0;i/=2){
	if(b>=i){
	  ll num=a;
	  ll cnt=i;
	  ll plus=0;

	  while(cnt>1){
	    num*=2;
	    if(num>=10){
	      num=num/10+num%10;
	      plus+=cnt;
	      cnt/=2;
	    }else{
	      plus+=cnt/2;
	      cnt/=2;

	    }
	  }
	  hogg.pb(num);
	  // cout<<cnt<<endl;
	  ans+=plus;
	  // cout<<plus<<endl;
	  b-=i;
	}
      }
      if(hogg.size() == 0){
	A.pb(a);
      }else{
	ll noww=hogg[0];
	for(ll ii=1;ii<hogg.size();ii++){
	  noww+=hogg[ii];
	  if(noww>=10){
	    noww=noww/10+noww%10;
	    ans+=2;
	  }else{
	    ans++;
	  }
	}
	A.pb(noww);
      }
    }
  }
  if(A.size() != 0){
    ll now=A[0];
    for(int i=1;i<A.size();i++){
      now+=A[i];
      if(now>=10){
	now=now/10+now%10;
	ans+=2;
      }else{
	ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2420
import sys
input = sys.stdin.readline

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

def main():
    mod=10**9+7
    N,M=MI()
    L=[0]*(N+1)
    for _ in range(M):
        l,r=MI()
        l-=1
        r-=1
        L[l]+=1
        L[r+1]-=1
        
    for i in range(N):
        L[i+1]+=L[i]
        
    ans=0
    
    for i in range(N):
        if L[i]>=M:
            ans+=1
            
    print(ans)
    

main()


Measured memory_bytes: 74600
s = input()
cnt = 1
t = s[0]
i = 1
while i<len(s)-1:
    if len(t) == 2:
        t = s[i]
        i += 1
    elif t == s[i]:
        t = s[i:i+2]
        i += 2
    else:
        t = s[i]
        i += 1
    cnt += 1
if i==len(s)-1 and t!=s[-1]:
    print(cnt+1)
else:
    print(cnt)


Measured memory_bytes: 3500
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
string S;
bool ch(int a,int b)
{
	return S[a]==S[b];
}

int main()
{
	cin>>S;
	if((ch(0,1)&&ch(2,3)&&!ch(0,2))||(ch(0,2)&&ch(1,3)&&!ch(0,1))||(ch(0,3)&&ch(1,2)&&!ch(0,1)))
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    int a, b, c;
    cin >> a >> b >> c;

    set<int> color;
    color.insert(a);
    color.insert(b);
    color.insert(c);

    cout << color.size() << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

int H,W;
int i,j;
while(1){
scanf("%d %d",&H,&W);
if(H==0 && W==0){break;}
for(i=0;i<H;i++){
	for(j=0;j<W;j++){
		printf("#");
	}
	printf("\n");
}
printf("\n");
}

	return 0;
}

Measured memory_bytes: 572