akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int a[110];
int boje[10];

int main () {
	
	int n;
	cin>>n;
	int dod=0;
	for (int i=0; i<n; i++) {
		cin>>a[i];
		if (a[i]>=1 && a[i]<=399) {boje[0]++;}
		if (a[i]>=400 && a[i]<=799) {boje[1]++;}
		if (a[i]>=800 && a[i]<=1199) {boje[2]++;}
		if (a[i]>=1200 && a[i]<=1599) {boje[3]++;}
		if (a[i]>=1600 && a[i]<=1999) {boje[4]++;}
		if (a[i]>=2000 && a[i]<=2399) {boje[5]++;}
		if (a[i]>=2400 && a[i]<=2799) {boje[6]++;}
		if (a[i]>=2800 && a[i]<=3199) {boje[7]++;}
		if (a[i]>=3200) {dod++;}
	}
	int prazan=0;
	for (int i=0; i<8; i++) {
		if (boje[i]==0) {
			prazan++;
		}
	}
	int maxi=0,mini=0;
	maxi=(8-prazan)+dod;
	if (prazan<8) {mini=(8-prazan);} else if (dod>0) {mini=1;} else {mini=0;}
	cout<<mini<<" "<<maxi<<endl;
	
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
                using namespace std;
                 
                int main() {
                  int X, A; 
                  cin>> X >> A; 
                  if(X<A){
                    cout<< 0 <<endl;
                  }else{
                    cout<< 10 <<endl; 
                  }
                }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a, b;
	cin>>a>>b;
	string one, two;
	for(int i =0; i<a;i++)
		one.push_back(char(b + '0'));
	for(int i =0;i<b;i++)
		two.push_back(char(a + '0'));
		
	if(one > two)
		cout<<two<<endl;
	else
		cout<<one<<endl;
		
	return 0;
}

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

#define MODADD(x, y) ((x) = ((x) + (y)) % MOD)

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

string K;
int D, n;
ll dp0[2][100], dp1[2][100];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> K >> D;
    n = K.size();
    dp0[0][0] = 1;
    for (int i = 0; i < n; i++) {
        memset(dp1, 0, sizeof dp1);
        for (int m = 0; m < D; m++) {
            for (int d = 0; d <= 9; d++)
                MODADD(dp1[1][(m + d) % D], dp0[1][m]);
            for (int d = 0; d < K[i] - '0'; d++)
                MODADD(dp1[1][(m + d) % D], dp0[0][m]);
            MODADD(dp1[0][(m + K[i] - '0') % D], dp0[0][m]);
        }
        memcpy(dp0, dp1, sizeof dp1);
    }
    cout << (dp1[0][0] + dp1[1][0] + MOD - 1) % MOD << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

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

using namespace std;

typedef long long ll;

int main(){
	int n; scanf("%d",&n);
	static int a[100000];
	rep(i,n) scanf("%d",a+i);

	sort(a,a+n);

	ll sum=0;
	rep(i,n){
		if(a[i]>sum+1) break;
		sum+=a[i];
	}
	printf("%lld\n",sum+1);

	return 0;
}

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

typedef long long int int64;

#define POS(i,j) ((i)*W+(j))

void run(void){
  int H,W,h,w;
  scanf("%d%d%d%d",&H,&W,&h,&w);
  if(H%h==0 && W%w==0){
    printf("No\n");
    return;
  }
  int *b=(int *)calloc(H*W,sizeof(int));
  const int m=(1000000000-1)/(h*w-1);
  int64 sum=0;
  int i,j;
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      b[POS(i,j)]=(i%h==h-1 && j%w==w-1?-m*(h*w-1)-1:m);
      sum+=b[POS(i,j)];
    }
  }
  if(sum<=0){
    printf("No\n");
    return;
  }
  printf("Yes\n");
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      printf("%d ",b[POS(i,j)]);
    }
    printf("\n");
  }
}

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


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

double log2(double a,double b){
  double cnt=1;
  while(a<b){
    a*=2;
    cnt/=2;
  }
  return cnt;
}

int main(){
  int N,K;
  cin>>N>>K;
  double n=N;
  double ans=0;
  for(int i=1;i<=N;i++){
    ans+=1/n*log2(i,K);
  }
  printf("%.10lf",ans);
}

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

#print(s.count('0'))

if len(s) == 1:
    print(0)
    exit(0)

if s.count('0') == s.count('1'):
    print(len(s))

else:
    n = abs(s.count('0') - s.count('1'))
    print(len(s) - n)


Measured memory_bytes: 3956
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
N = INT()
a = LIST()[::-1]

ans = [[0]*W for _ in range(H)]
tmp = a.pop()
color = 1
cnt = 0
for i in range(H):
    for j in range(W):
        if i%2:
            j = W-j-1
        ans[i][j] = color
        cnt += 1
        if cnt == tmp and a:
            cnt = 0
            tmp = a.pop()
            color += 1

for i in ans:
    print(" ".join([str(x) for x in i]))


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

#define PAUSE system("pause")
#define LLI long long int
#define LD long double
#define PB push_back
#define PF push_front
#define MP make_pair
#define FORi(i, a, b) for(int i = a; i < b ; ++i)
#define FORd(i, a, b) for(int i = a; i > b ; --i)

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	FORi(i,0,n){
		cin >> s[i];
	}
	string t;
	cin >> t;
	int before=0, after=0;
	FORi(i,0,n){
		bool prefix = 1, before_added=0, after_added=0;
		FORi(j,0,min(t.size(), s[i].size())){
			if (s[i][j]!='?' && t[j]!='?'){
				if (s[i][j] < t[j]){
					before_added = 1;
					prefix = 0;
					break;
				}
				if (s[i][j] > t[j]){
					after_added = 1;
					prefix = 0;
					break;
				}
				continue;
			}
			if (t[j] == 'a'){
				after_added = 1;
				continue;
			}
			if (s[i][j] == 'a'){
				before_added = 1;
				continue;
			}
			if (t[j] == 'z'){
				before_added = 1;
				continue;
			}
			if (s[i][j] == 'z'){
				after_added = 1;
				continue;
			}
			before_added = 1;
			after_added = 1;
			prefix = 0;
			break;
		}
		if (prefix){
			if (t.size() < s[i].size()){
				after_added = 1;
			}
			if (t.size() > s[i].size()){
				before_added = 1;
			}
			if (t.size() == s[i].size()){
				before_added = 1;
				after_added = 1;
			}
		}
		before += before_added;
		after += after_added;
	}
	//cout << before << ' ' << after << endl;
	FORi(i,n+1-after,before+2){
		if (i > n+1-after){
			cout <<  ' ';
		}
		cout << i;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
 
using namespace std;
 
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.10lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
const int mod = 1000 * 1000 * 1000 + 7;
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;
 
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;
 
int dx[6] = {-1,-1,0,0,1,1};
int dy[6] = {-1,0,-1,1,0,1};

const int N=2e5+5;
int a[N];
int main(){
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    ll sum=0;
    sort(a,a+n);
    for(int i=0;i<k;++i){
        sum+=a[i];
    }
    cout<<sum<<endl;
    return 0;
}







Measured memory_bytes: 3576
#include<stdio.h>
int main(){
  int a[5],k=10,i,x[5],s,sum=0;
  for(i=0;i<5;i++){
  	scanf("%d",&a[i]);
    x[i]=a[i]%10;
  }
  for(i=0;i<5;i++){
    if(x[i]<k){
      if(x[i]==0){}else{
      s=i;
        k=x[i];
      }
    }else{}
  }
  for(i=0;i<5;i++){
    if(x[i]==0){
    sum=sum+a[i];}else{
  	sum=sum+a[i]+10-x[i];
    }
  }
  if(x[s]==0){
  }else{
  sum=sum-(10-x[s]);
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())

o = ''
for j in range(k):
    o += (''.join(t[j::k])).replace('rr', 'r').replace(
        'pp', 'p').replace('ss', 's')

x = 0
for i, h in enumerate(o):
    if h == 'r':
        x += p
    elif h == 's':
        x += r
    else:
        x += s

print(x)


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

    int N;
    cin >> N;

    vector<int> P;
    int temp = 0;
    for(int i=0; i<N; i++){
        cin >> temp;
        P.emplace_back(temp);
    }

    int ans=1;
    int now = P[0];
    FOR(i,1,N){
        if(now > P[i]){
            now = P[i];
            ans++;
        }
    }

    cout << ans << "\n";


return 0;
}

Measured memory_bytes: 1400
import sys
input = sys.stdin.readline
ri = lambda: int(input())
#rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

N = ri()
XY = []
for i in range(N):
    x,y=rl()
    XY.append((x,y))
XY.sort()
XYD = []
for i in range(N):
    x,y = XY[i]
    ret = []
    for j in range(i+1,N):
        ret.append((XY[j][0] - x, XY[j][1] - y))
    XYD.extend(ret)

import collections
c = collections.Counter(XYD).most_common()
if N == 1:
    print(1)
else:
    print(N-c[0][1])


Measured memory_bytes: 3700
#include<bits/stdc++.h>
#include<string.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1<<29;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

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

	int t=0;
	t=(b-1)/(a-1);
	if((b-1)%(a-1)>0)t++;
	cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 256
/*

0566: soccer

*/

#include <stdio.h>

#define N 101

int getMax(int array[], int n, int limit, int min);
int getMin(int array[], int n);

int main(void){
	
	int n;
	int a, b, c, d;
	int i, max, min, limit;
	int score[N] = {0};
	int ranks[N] = {0};
	int rank = 1;
	int count = 0;
	
	scanf("%d", &n);
	
	for(i=0; i<n*(n-1)/2; i++){
		
		scanf("%d %d %d %d", &a, &b, &c, &d);
		
		//aの勝ち
		if(c > d){
			
			score[a] += 3;
			
		}
		
		//bの勝ち
		else if(c < d){
			
			score[b] += 3;
			
		}
		
		//引き分け
		else{
			
			score[a] += 1;
			score[b] += 1;
			
		}
		
	}
	
	min = getMin(score, n);
	max = getMax(score, n, 500, min);
	
	i = 1;
	
	while(1){
		
		if(score[i] == max){
			
			ranks[i] = rank;
			count++;
			
		}
		
		i++;
		
		if(i > n){
			
			i = 1;
			max = getMax(score, n, max, min);
			
			if(max == -1){
				
				break;
				
			}
			
			rank += count;
			count = 0;
			
		}
		
	}
	
	for(i=1; i<=n; i++){
		
		printf("%d\n", ranks[i]);
		
	}
	
	return 0;
	
}


int getMax(int array[], int n, int limit, int min){
	
	int max = min;
	int i;
	
	if(limit == min){
		
		return -1;
		
	}
	
	for(i=1; i<=n; i++){
		
		if(limit <= array[i]){
			
			continue;
			
		}
		else if(max < array[i]){
			
			max = array[i];
			
		}
		
	}
	
	return max;
	
}


int getMin(int array[], int n){
	
	int i;
	int min = array[1];
	
	for(i=1; i<=n; i++){
		
		if(min > array[i]){
			
			min = array[i];
			
		}
		
	}
	
	return min;
	
}

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

int main() {
	char a,b,c;
	cin >> a >> b >> c;
	if(b == 'B')
	{
		b = 'R';
	}
	else
	{
		b = 'B';
	}
	cout << a << b << c;
	return 0;
}


Measured memory_bytes: 3592
from math import gcd
N = int(input())
A = [0]+list(map(int, input().split()))+[0]
L = [0]*(N+1)
R = [0]*(N+1)
for i in range(1, N+1):
    L[i] = gcd(L[i-1], A[i])
    R[N-i] = gcd(R[N+1-i], A[N+1-i])
# print(L)
# print(R)

ans = 0
for i in range(1, N+1):
    ans = max(ans, gcd(L[i-1], R[i]))
print(ans)


Measured memory_bytes: 88668
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
N = ri()
A = ri_()
ans = INF
for a in A:
    tmp = 0
    while a % 2 == 0:
        tmp += 1
        a = a // 2
    ans = min(tmp, ans)
print(ans)

Measured memory_bytes: 65388
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  vector<string> c(3);
  cin >> c[0] >> c[1] >> c[2];
  cout << c[0][0] << c[1][1] << c[2][2] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 2000000
#define INFTY (1<<30)
#define SWAP(a,b) (a^=b,b=a^b,a^=b)
int H, A[MAX+1];
void maxHeapify(int i){
  int l,r,largest;
  l=2*i;
  r=2*i+1;
  if(l<=H&&A[l]>A[i]) largest=l;
  else largest=i;
  if(r<=H&&A[r]>A[largest]) largest=r;
  if(largest!=i){
    SWAP(A[i],A[largest]);
    maxHeapify(largest);
  }
}
int extract(){
  int maxv;
  if(H<1) return -INFTY;
  maxv=A[1];
  A[1]=A[H--];
  maxHeapify(1);
  return maxv;
}
void kansuu(int i,int key){
  if(key<A[i]) return;
  A[i]=key;
  while(i>1&&A[i/2]<A[i]){
    SWAP(A[i],A[i/2]);
    i=i/2;
  }
}
void insert(int key){
  H++;
  A[H]=-INFTY;
  kansuu(H,key);
}
int main(void){
  int key;
  char com[10];

  while(1){
    scanf("%s",com);
    if(com[0]=='e'&&com[1]=='n') break;
    if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }else{
      printf("%d\n",extract());
    }
  }
  return 0;
}



Measured memory_bytes: 5704
data class AB(val a: Int, val b: Int) {
    constructor(pc: List<Int>): this(pc[0], pc[1])
}
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    val ab = Array(M) { AB(listOfInt(-1)) }.sortedBy { it.b }
    var now = ab[0].b
    var ans = 1
    for (m in 1 until M) {
        if (ab[m].a >= now || now > ab[m].b) {
            ans += 1
            now = ab[m].b
        }
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun nextInt(offset: Int = 0) = nextInt() + offset
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }






Measured memory_bytes: 76072
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N,K;
  cin>>N>>K;
  vector<int> A(N),B(N,1000000000);
  for(int &i:A)
    cin>>i;
  B[0]=0;
  for(int i=1;i<N;i++)
    for(int j=1;j<=K;j++)
      if(i-j>=0)
        B[i]=min(B[i],B[i-j]+abs(A[i-j]-A[i]));
  cout<<B[N-1]<<endl;
}

Measured memory_bytes: 4716
#include <iostream>
using namespace std;
int main() {
	int N,p[50],o[50],i,d=0;
  cin >> N;
  for(i = 0;i < N;i++)
  {
  cin >> p[i]; 
  }
  for(i = 0;i < N;i++){
  o[i] = i+1;
    if(p[i] != o[i]){
    d += 1;
    }
  }
  if(d == 2 || d == 0){
  cout << "YES" << endl;
  }else{
  cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
 
int main(void){
  std::string input = "";
  std::cin >> input;
  if (input.find("A") != std::string::npos && input.find("B") != std::string::npos)
    std::cout << "Yes";
  else
    std::cout << "No";
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define int long long int
using namespace std;

void desperate_optimization(bool submitting=true,int precision=10)
{
  if(!submitting) return;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(precision);
}
int heights[100005];
int n;
int memo[100005];
int k;
int dpfunction(int startingindex)
{
  if(memo[startingindex]!=-1) return memo[startingindex];
  if(startingindex==n-1) {memo[startingindex]=0; return memo[startingindex];}
  int answer=(abs(heights[startingindex]-heights[startingindex+1])+dpfunction(startingindex+1));
  for(int i=1;i<=k;i++)
  {
    if(startingindex+i<=n-1)
    {
      answer=min(answer,abs(heights[startingindex]-heights[startingindex+i])+dpfunction(startingindex+i));
    }
  }
  return memo[startingindex]=answer;
}
int32_t main()
{
  desperate_optimization(false);
  //freopen("input.txt","r",stdin);
  memset(memo,-1,sizeof(memo));
  cin>>n>>k;
  for(int i=0;i<n;i++) cin>>heights[i];
  cout<<dpfunction(0);

  return 0;
}

Measured memory_bytes: 26752
#include <iostream>

using namespace std;


int mod(int x){
	return (x >= 0 ? x : -x);
}
int main(){
	int n; cin >> n;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	int d[n];
	d[0] = 0;
	d[1] = mod(a[0] - a[1]);
	for (int i = 2; i < n; ++i)
	{
		d[i] = min(d[i-2] + mod(a[i]- a[i-2]), d[i-1] + mod(a[i] - a[i-1]));
	}
	cout << d[n-1];
}

Measured memory_bytes: 4348
#include <iostream>

using namespace std;

int a[100];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=n-1; i>=0; i--) cin>>a[i];
    cout<<a[0];
    for(int i=1; i<n; i++) cout<<' '<<a[i];
    cout<<'\n';
    return 0;
}

Measured memory_bytes: 1196
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long nn = sc.nextLong();
		for (int h = 1; h <= 3500; h++) {
		    for (int n = h; n <= 3500; n++) {
		        if ((4 * h * n - nn * n - nn * h != 0) && ((nn * h * n) % (4 * h * n - nn * n - nn * h)== 0)) {
		            long w = (nn * h * n) / (4 * h * n - nn * n - nn * h);
		            if (w <= 0) {
		                continue;
		            }
	                System.out.println(h + " " + n + " " + w);
	                return;
		        }
		    }
		}
	}
}
	


Measured memory_bytes: 23252
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	string s;
	cin>>s;
	ll ans=0;
	REP(i,s.size()){
		if(s[i]!=s[s.size()-1-i]){
			ans++;
		}
	}
	cout<<ans/2<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

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

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

		long[] S=new long[N+1];
		S[0]=0;
		for (int i = 1; i <= N; i++) {

			S[i]=S[i-1]+sc.nextLong();

		}

		Arrays.sort(S);

		long cnt=0;
		long ans=0;
		for (int i = 0; i < N; i++) {

			if(S[i]==S[i+1]) {
				cnt++;
			}else {
				ans+=(cnt)*(cnt+1)/2;
				cnt=0;
			}

		}

		if(cnt!=0) {
			ans+=(cnt)*(cnt+1)/2;
		}

		System.out.println(ans);
	}

	//以下テンプレート

	public static int[] extgcd(int a, int b) {

		int x0 = 1;
		int x1 = 0;

		int y0 = 0;
		int y1 = 1;

		while (b != 0) {
			int q = a / b;
			int r = a % b;

			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;

			a = b;
			b = r;

			x0 = x1;
			x1 = x2;

			y0 = y1;
			y1 = y2;
		}

		return new int[] { a, x0, y0 };

	}

	static int gcd(int a, int b) {

		if (b == 0)
			return a;

		if (a < b) {
			int t = a;
			a = b;
			b = t;
		}

		return gcd(b, a % b);

	}

	static int lcm(int a, int b) {
		return a * b / gcd(a, b);
	}

	static void swap(int[] a) {
		int t;

		t = a[0];
		a[0] = a[1];
		a[1] = t;

		return;
	}

	static <T> void output(List<T> list) {

		for (int i = 0; i < list.size(); i++) {
			System.out.print(list.get(i));

			if (i != list.size() - 1) {
				System.out.print(" ");
			} else {
				nl();
			}
		}

	}

	static void output(String[][] str) {

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				print(str[i][j]);
			}

			nl();
		}

	}

	static void output(boolean flg, String Yes, String No) {

		if (flg) {
			pln(Yes);
		} else {
			pln(No);
		}

	}

	static void output(String[][] str, int digit) {

		String dig = "%" + String.valueOf(digit) + "s";

		for (int i = 0; i < str.length; i++) {
			for (int j = 0; j < str[i].length; j++) {
				System.out.printf(dig, str[i][j]);
			}
			nl();
		}

	}

	static void pln(String str) {
		System.out.println(str);
	}

	static void pln(int x) {
		System.out.println(x);
	}

	static void print(String str) {
		System.out.print(str);
	}

	static void print(int x) {
		System.out.print(x);
	}

	static void print(String str, int times) {
		for (int i = 0; i < times; i++) {
			print(str);
		}
	}

	static void print(int x, int times) {
		for (int i = 0; i < times; i++) {
			print(x);
		}
	}

	static void nl() {
		System.out.println();
	}

}


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

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
  bool judge=true;
  long long N;
  cin>>N;
  long long a,b;
  vector<pair <long long,long long>> pairs(N);
  for(int i=0;i<N;++i){
    cin>>a>>b;
    pairs[i]=make_pair(a,b);
  }
  sort(pairs.begin(),pairs.end(), compare_by_b);
  long long duty=0;
  long long work=0;
  for(int i=0;i<N;++i){
    duty=pairs[i].second;
    work+=pairs[i].first;
    if(duty<work){
      judge=false;
    }
  }
  if(judge){
    cout<<"Yes"<<"\n";
  }
  else{
    cout<<"No"<<"\n";
  }
return 0;
}


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

#define nl '\n'

using namespace std;

typedef long long ll;

void solve() {
  int n, k;
  cin >> n >> k;
  int p[n];
  for (int& i: p) cin >> i;

  sort(p, p + n);
  int price = 0;
  for (int i = 0; i < k; i++) {
    price += p[i];
  }

  cout << price;
}

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

  // int t;
  // cin >> t;
  // while (t--) {
    solve();
  // }

  return 0;
}

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

using namespace std;

int main()
{
  int N, D;
  cin >> N >> D;
  int ret = 0;
  for(int i = 0; i < N; i++) {
    int P;
    cin >> P;
    ret += max(P - D, 0);
  }
  if(ret == 0) {
    cout << "kusoge" << endl;
  } else {
    cout << ret << endl;
  }
}

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

int main(){
  string w; cin >> w;
  int count =0; 
  bool flag = false;
  sort(w.rbegin(),w.rend());
  for(int i = 0; i < w.size();i++){
    if(w[i] == w[i+1]){
      count++;
    }
    else{
      if(count %2 == 0){
        flag =true;
      }
      count = 0;
    }
  }
  if(flag)
  cout << "No" << endl;
  else
  {
    cout << "Yes" << endl;
  }
  

}

Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#define min(x, y) (x < y ? x : y)
#define ll long long int 

int main()
{

 int A , B;
 scanf("%d %d",&A,&B);

 printf("%d",A*B);

  return 0;
}


Measured memory_bytes: 1736
#include <stdio.h>

int x[200010];
long long int check[200010];
int main()
{
	int a;
	scanf("%d",&a);
	for(int i=1;i<=a;i++) scanf("%d",&x[i]);
	for(int i=1;i<=a;i++) check[x[i]]++;
	
	long long int sum = 0;
	for(int i=1;i<=a;i++) sum += check[i]*(check[i]-1)/2;
	for(int i=1;i<=a;i++)
	{
		printf("%lld\n",sum-(check[x[i]]*(check[x[i]]-1)/2)+((check[x[i]]-1)*(check[x[i]]-2)/2));
	}
}

Measured memory_bytes: 3840
#include<stdio.h>
#pragma GCC optimize("O2")
#define rep(i,N) for(int i=0;i<(int)N;i++)
int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
void OUT(long x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
void Radix32(int A[],const int sz)
{
  int temp[200001];const int bit=0b1000,mask=0b11111111;
  rep(k,0b100)
  {
    int u[0x100]={},v[0x100]={};
    rep(i,sz)u[A[i]>>bit*k&mask]++;
    rep(i,mask)u[i+1]+=u[i];
    rep(i,sz){temp[--u[A[sz-1-i]>>bit*k&mask]]=A[sz-1-i];}k++;
    rep(i,sz)v[temp[i]>>bit*k&mask]++;
    rep(i,mask)v[i+1]+=v[i];
    rep(i,sz)A[--v[temp[sz-1-i]>>bit*k&mask]]=temp[sz-1-i];
  }
}
int main(void)
{
  int N=IN(),x,p=0,m=0,z=0,minus=0,A[200000];
  long K,count=0,l=-2e18,r=-l,mid;x=scanf("%ld",&K);
  rep(i,N){x=IN();if(x>0)A[m+p++]=x;else if(x<0)A[p+m++]=x;else z++;}
  Radix32(A,m+p);
  if(K>1l*m*p&&K<1l*m*p+1l*z*(N-1)/2)return puts("0"),0;
  if(K<=1l*m*p)r=1l;else l=-1l;
  while(l<=r)
  {
    mid=(l+r)/2;count=0;
    if(mid>=0)
    {
      int plus=p-1,minus=m-1;count+=1l*z*(p+m)+1l*z*(z-1)/2+1l*p*m;
      rep(i,plus){while(1l*A[i]*A[plus]>mid){plus--;}if(i>=plus){break;}count+=1l*plus-i;}
      rep(i,minus){while(1l*A[m+p-1-i]*A[m+p-1-minus]>mid){minus--;}if(i>=minus){break;}count+=1l*minus-i;}
    }
    else{minus=1;int low=0;rep(i,m){while(1l*A[low]*A[p+i]>mid&&low<p){low++;}count+=1l*p-low;}}
    if(count>=K)r=mid-1l;else l=mid+1l;
  }
  return OUT(l),0;
}

Measured memory_bytes: 3084
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int main()
{
	int n;cin>>n;
	cout<<(n+1)/2<<endl; 
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n;
    cin >> n;
    int d, x;
    cin >> d >> x;

    int a[n];
    rep(i, n) { cin >> a[i]; }

    int b[n] = {};
    rep(i, n) {
        int num = 1;
        while (num <= d) {
            b[i]++;
            num += a[i];
        }
    }

    int sum = 0;
    rep(i, n) { sum += b[i]; }
    int ans = sum + x;

    cout << ans << endl;

    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

void prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

struct P { double x, y; };
double dist2(P A, P B) {
	return (A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y);
}

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


	int N;
	cin >> N;

	P XY[50];
	rep(i, N) cin >> XY[i].x >> XY[i].y;
	P O = { 0,0 };

	double kotae = 1e18;

	rep(i, N) rep(j, i) {
		P pi = XY[i];
		P pj = XY[j];

		if (pi.y != pj.y) {

			double L = 0;
			double R = 1000;
			rep(p, 100) {
				double x = L + (R - L) / 3;
				double tmp = dist2(O, pi) - dist2(O, pj) + 2 * x * (pj.x - pi.x);
				double y = tmp / (pi.y - pj.y) / 2;
				P p1 = { x,y };
				double d1 = 0;
				rep(k, N) chmax(d1, dist2(p1, XY[k]));

				x = L + (R - L) * 2 / 3;
				tmp = dist2(O, pi) - dist2(O, pj) + 2 * x * (pj.x - pi.x);
				y = tmp / (pi.y - pj.y) / 2;
				P p2 = { x,y };
				double d2 = 0;
				rep(k, N) chmax(d2, dist2(p2, XY[k]));

				chmin(kotae, min(d1, d2));

				if (d1 < d2) R = p2.x;
				else L = p1.x;
			}

		}
		else {
			double L = 0;
			double R = 1000;
			rep(p, 100) {
				double x = (pi.x + pj.x) / 2;
				double y = L + (R - L) / 3;
				P p1 = { x,y };
				double d1 = 0;
				rep(k, N) chmax(d1, dist2(p1, XY[k]));

				y = L + (R - L) * 2 / 3;
				P p2 = { x,y };
				double d2 = 0;
				rep(k, N) chmax(d2, dist2(p2, XY[k]));

				chmin(kotae, min(d1, d2));

				if (d1 < d2) R = p2.y;
				else L = p1.y;
			}
		}
	}

	cout << setprecision(12) << sqrt(kotae) << endl;

	Would you please return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int a[1000],x[1000];



int main() {

	int n;
	int y = 0;
	cin >> n;

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

		cin >> a[i];

		 x[i] = a[i];
		
    }
	for (int i = nn; i > 0; i--) {

		cout << x[i]<<" ";

	}

	int i = 0;
	cout << x[i] << endl;
	
	

	return 0;
}



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

int read()
{
	int ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10+ch-'0';
	if(flag)ans=-ans;
	return ans;
}

long long rell()
{
	long long ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10ll+(long long)(ch-'0');
	if(flag)ans=-ans;
	return ans;
}

void writ(int n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}

void wrll(long long n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10ll)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}

const int N=1<<9;
long long a[N];
int n;

bool check(long long k)
{
	if(k<0)return true;
	long long sum=0;
	for(int i=0;i<n;i++)
	{
		sum+=(a[i]+k)/(long long)(n+1);
	}
	return sum>=k;
}

int main()
{
	n=read();
	for(int i=0;i<n;i++)
	{
		a[i]=rell();
	}
	long long h=0,t=1e18;
	for(;h<=t;)
	{
		long long mid=(h+t)>>1;
		bool flag=true;
		for(long long i=0;i<=n;i++)
		{
			flag&=check(mid-i);
		}
		if(flag)h=mid+1ll;else t=mid-1ll;
	}
	wrll(t);puts("");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i;
    string s1;
    cin >> s1;
    if( s1[2] == s1[3] && s1[4] == s1[5])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = []
B = []
for i in range(N):
    A.append(input())
for i in range(M):
    B.append(input())

for i in range(N-M+1):
    if B[0] in A[i]:
        k = A[i].index(B[0])
        points = 1
        for j in range(1,M):
            if B[j] == A[i+j][k:k+M]:
                points += 1
        if points == M:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 9200
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if ( a > b){
        cout << a - 1 << endl;
    } else {
        cout << a  << endl;
    }
}

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

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

int x[200010], s[200010], dp[200010];

template<class T>
class segmentTree {
public:
  int size_;
  vector<T> dat;
  T init__ = -LLONG_MAX; // 単位元

  segmentTree() {}
  segmentTree(int n) {
    for(size_ = 1; size_ < n; size_ *= 2);
    dat.assign(2*size_-1, init__);
  }

  T calc(T d1, T d2) {
    // return min(d1, d2);     // minnimum
    return max(d1, d2);  // maximum
    // return d1+d2;        // sum
  }
  T query(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return init__;
    if(a <= l && r <= b) return dat[k];
    return calc(query(a, b, 2*k+1, l, (l+r)/2),
                query(a, b, 2*k+2, (l+r)/2, r));
  }
  // [a, b)
  T query(int a, int b) {return query(a, b, 0, 0, size_);}
  void update(int k, T a) {
    k += size_ - 1;
    dat[k] = a;      // max or min
    // dat[k] += a;  // sum
    while(k > 0) {
      k = (k-1) / 2;
      dat[k] = calc(dat[k*2+1], dat[k*2+2]);
    }
  }
};

signed main(void)
{
  int n;
  cin >> n;
  segmentTree<int> seg(n);
  REP(i, n) cin >> x[i] >> s[i];

  FOR(i, 1, n) {
    dp[i] = s[i] - (x[i]-x[i-1]);
    dp[i] += dp[i-1];
  }

  REP(i, n) {
    seg.update(i, dp[i]);
  }

  int ret = 0;
  REP(i, n) {
    chmax(ret, s[i] + seg.query(i, n) - dp[i]);
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <iomanip>
using namespace std;

int main()
{
  long long N,K,nowx;
  cin>>N>>K;
  long double ans=0;
  for(int i=0;(1<<i)<K;i++){
    nowx=i+1;
  }
  int maxx=nowx;
  for(int i=1;i<=N;i++){
    while(nowx>-1 && (1<<nowx)*i>=K){
      nowx--;
    }
    ans+=(1<<(maxx-nowx));
  }
  cout << setprecision(20);
  cout<<ans/N/(1<<(maxx+1))<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
#define inf 9000000000000000000LL
using namespace std;

lli ar[105][5];
lli dp[102][100005];


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n,w;
    cin >> n >> w ;

    lli sum=0;
    for(int i=1; i<=n; i++)
    {
        cin >> ar[i][1] >> ar[i][2];
        sum+=ar[i][2];
    }
    for(int i=0; i<=n; i++)
    {
        for(int j=1; j<=sum; j++)
        {
            if(j==0 )
                dp[i][j] = 0;
            else
                dp[i][j] = INT_MAX;
        }
    }

    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=sum; j++)
        {
             lli a = dp[i-1][j];

            if(j-ar[i][2]>=0)
                dp[i][j] = min(ar[i][1] + dp[i-1][j-ar[i][2]],a);
            else
                dp[i][j]=a;

        }
    }
    lli ans = 0;

    for(int j=0; j<=sum; j++)
    {
        if(dp[n][j]<=w)
            ans = j;
    }

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 82340
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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;
}

signed main() {
  init();
  ll N, M;
  cin >> N >> M;

  vector<string> A(N);
  vector<string> B(M);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];

  rep(i, N) {
    rep(j, N) {
      if (i + M - 1 >= N) continue;
      if (j + M - 1 >= N) continue;
      bool ok = true;
      rep(p, M) {
        rep(q, M) {
          if (A[i + p][j + q] == B[p][q]) {
            continue;
          }
          ok = false;
          break;
        }
        if (!ok) break;
      }
      if (ok) {
        RETURN("Yes");
      }
    }
  }
  COUT("No");
  return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N;

int main()
{
    cin >> N;

    int ans[101][101];
    lint hmax[101][101];
    memset(ans, -1, sizeof(ans));
    REP(l, 101) REP(w, 101) hmax[l][w] = 10000000000;

    REP(i, N)
    {
        lint x, y, h;
        cin >> x >> y >> h;

        REP(l, 101) REP(w, 101)
        {
            lint estimated_top = h + abs(l - x) + abs(w - y);
            if (h > 0)
            {
                if (ans[l][w] == -2) continue;
                else if (ans[l][w] == -1) ans[l][w] = estimated_top;
                else if (ans[l][w] != estimated_top) ans[l][w] = -2;
            }
            else
            {
                hmax[l][w] = min(hmax[l][w], estimated_top);
            }
        }
    }

    REP(l, 101) REP(w, 101) if (ans[l][w] > 0 && hmax[l][w] >= ans[l][w]) cout << l << " " << w << " " << ans[l][w] << endl;
}


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

int main() {
int n,a,b;
cin >> n >> a >> b;
if(n==1) cout << "Hello World" << endl;
else cout << a+b << endl;
}
  


Measured memory_bytes: 256
// Aizu Vol-1 0174: Badminton
// 2017.8.9

#include <stdio.h>
#include <ctype.h>

char *gets(char *);
char buf[150], *p;

int main()
{
	int a, b, k;

	while (1) {
		for (k = 3; k-- > 0; k--) {
			gets(p = buf); while (isspace(*p)) p++;
			if (*p == '0') return 0;
			a = b = 0;
			while (*++p) if (*p == 'A') a++; else b++;
			if (a > b) a++; else b++;
			printf("%d %d\n", a, b);
		}
	}
	return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int n,W;
ll w[110],v[110];
ll dp[110][101000];
ll ans;

void input(){
	cin>>n>>W;
	for(int i=0;i<n;i++)cin>>w[i]>>v[i];
	return;
}

void solve(){
	for(int i=0;i<=n;i++){
		for(int j=0;j<100005;j++){
			dp[i][j]=INF;
		}
	}
	dp[0][0]=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<100010;j++){
			if(dp[i][j]==INF)continue;
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
			if(dp[i][j]+w[i]>W)continue;
			dp[i+1][j+v[i]]=min(dp[i+1][j+v[i]],dp[i][j]+w[i]);
		}
	}
	for(int i=0;i<100001;i++){
		if(dp[n][i]!=INF)ans=i;
	}
	cout<<ans<<endl;
	return;
}

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


Measured memory_bytes: 80128
#include<stdio.h>

int main(){
  int A[100], n, i, j, t, sw = 0;

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

  for ( i = 0; i < n; i++ ){
    for ( j = n-1; j >= i+1; j-- ){
      if ( A[j] < A[j-1] ){
	t = A[j]; A[j] = A[j-1]; A[j-1] = t;
	sw++;
      }
    }
  }

  for ( i = 0; i < n; i++ ){
    if (i) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", sw);

  return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
const int inf = pow(10,9);
const int nil = -1;
int i, j, n, m, ans, t;
int s[10][10];
int k[10];
int p[10];

bool check(int a[10]) {
    bool result = true;
    rep(0, m) {
        int sum = 0;
        for(j=0;j<k[i];j++) sum += a[s[i][j]-1];
        if (sum % 2 != p[i]) result = false;
    }
    return result;
}

void search(int i, int a[10]) {
    if (i == n) {
        if (check(a)) ans++;
        return;
    } else {
        a[i] = 0;search(i+1, a);
        a[i] = 1;search(i+1, a);
    }
}

int main() {
    scanf(" %d %d", &n, &m);
    rep(0,m) {
        scanf(" %d", &k[i]);
        for(j=0;j<k[i];j++) {
            scanf(" %d", &t);
            s[i][j] = t;
        }
    }
    rep(0,m) scanf(" %d", &p[i]);

    ans = 0;
    int a[10]; 
    search(0, a);
    printf("%d\n", ans);
}

Measured memory_bytes: 256
//Sourav Mondal

#include <bits/stdc++.h>
using namespace std;
#define llt long long int

int main() {
	int n,k;
	cin>>n>>k;
	int arr[n];
	
	int ans=0;
	for(int i=0;i<n;i++)
	cin>>arr[i];
	sort(arr,arr+n);
	for(int i=0;i<k;i++)
	ans+=arr[i];
	cout<<ans<<endl;
}


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

void b_sort(int a[],int n){
    int count = 0;

    for(int i=0;i<n;i++){
        for(int j=0;j<n-i-1;j++){
            if(a[j]>a[j+1]){
                int tmp = a[j];
                a[j] = a[j+1];
                a[j+1] = tmp;
                count++;
            }
        }
    }


    for(int i=0;i<n;i++){
        cout << a[i] ;
        if(i<n-1){
            cout << " ";
        }
    }
    cout << endl;

    cout << count << endl;
}

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

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

    b_sort(a,n);

    return 0;
}


Measured memory_bytes: 3092