akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	T res(1),now(a);
	while(b){
		if(b&1)res*=now;
		b>>=1;
		now*=now;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int D,c[27],s[365][27],ans[365];
int main() {
	std::random_device rd;
	std::mt19937 mt(rd());
	scanf("%d",&D);
	REP(i,26)scanf("%d",c+i);
	rep(i,D){
		REP(j,26)scanf("%d",&s[i][j]);
	}
	int score=0,last[27]={};
	rep(i,D){
		int max=-INF,cand;
		REP(j,26){
			int cnt=s[i][j];
			REP(k,26){
				if(j!=k)cnt-=c[k]*(i-last[k]);
			}
			if(chmax(max,cnt))cand=j;
		}
		score+=max;
		last[cand]=i;
		std::cout<<cand<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 3296
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int H,W,h,w;
        H=s.nextInt();
        W=s.nextInt();
        h=s.nextInt();
        w=s.nextInt();
        
        System.out.println((W-w)*(H-h));

    }  
}


Measured memory_bytes: 23252
#include <stdio.h> 
 #include <ctype.h> 
 #include <string.h> 
 
 
 int main(){ 
     char search[21], word[21]; 
     int count=0; 
     int i; 
      
     scanf("%s", search); 
     while(1){ 
         scanf(" %s", word); 
         if(strcmp(word, "END_OF_TEXT")==0)break; 
         for(i=0;word[i]!='\0';i++){ 
             word[i]=tolower(word[i]); 
         } 
         if(strcmp(word, search)==0){ 
             count++; 
         } 
     } 
     printf("%d\n", count); 
 
 
     return 0; 
 } 



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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int a, b;
	
	cin >> a >> b;
	
	
	cout << max(0, a - 2 * b) << endl;
		
	return 0;
} 

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int yono = Math.min(b , c) * 2;
		b -= yono / 2;
		c -= yono / 2;
		if(a < c) yono += a + 1;
		else yono += c;
		yono += b;
		ou.println(yono);
		ou.flush();
	}
}

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

bool cmp(int a, int b)
{
	return a > b;
}

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

	sort(b, b + n, cmp);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (a[i] == b[j])
			{
				cout << b[j + 1] << endl;
				break;
			}
			if (a[i] != b[j])
			{
				cout << b[j] << endl;
				break;
			}
		}





	}
	delete[]a;
	return 0;
}

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

const int N = 510;

char ans1[N][N], ans2[N][N];

int main(){
	int h, w;
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; ++ i){
		scanf("%s", ans1[i]);
	}
	for (int i = 0; i < h; ++ i){
		for (int j = 0; j < w; ++ j){
			ans2[i][j] = ans1[i][j];
		}
	}
	for (int i = 0; i < h; ++ i){
		for (int j = 1; j < w - 1; ++ j){
			(i & 1 ? ans2[i][j] : ans1[i][j]) = '#';
		}
	}
	for (int i = 0; i < h; ++ i){
		ans1[i][0] = '#';
		ans2[i][w - 1] = '#';
	}
	for (int i = 0; i < h; ++ i){
		for (int j = 0; j < w; ++ j){
			putchar(ans1[i][j]);
		}
		putchar('\n');
	}
	putchar('\n');
	for (int i = 0; i < h; ++ i){
		for (int j = 0; j < w; ++ j){
			putchar(ans2[i][j]);
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  string s,t;cin>>s>>t;

  int place = -1;
  bool exist = true;
  rep(i,s.size()){
    bool can = false;
    rep(j,t.size()){
      if(s.size() <= i+j){
        can = false;
        break;
      }
      can = s[i+j] == t[j] || s[i+j] == '?';
      if(!can)break;
    }
    if(can){
      place = i;
      //test(place);
    }
  }

  if(place == -1){
    print("UNRESTORABLE");
  }else{
    rep(i,s.size())if(s[i] == '?')s[i] = 'a';
    rep(i,s.size()){
      if(i == place){
        rep(j,t.size()){
          s[i+j] = t[j];
        }
        break;
      }
    }
    print(s);
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char s1[15];
char s2[15];
char s3[15];
int main(){
	scanf("%s",s1);
	getchar();
	scanf("%s",s2);
	getchar();
	scanf("%s",s3);
	printf("%c%c%c",s1[0]-('a'-'A'),s2[0]-('a'-'A'),s3[0]-('a'-'A'));
}

Measured memory_bytes: 128
#include <cstdio>
#include <queue>
#include <utility>
#include <algorithm>

using namespace std;
typedef pair<int,int> P;
int n,l,d[100003],s[100003];
int ans = 0;

int main(){
  scanf("%d%d",&n,&l);
  priority_queue<P> que;
  for(int i = 1;i <= n;i++){
    scanf("%d",&d[i]);
    que.push(P(d[i],i));
  }
  
  while(que.size()){
    P q = que.top(); que.pop();
    s[q.second] = max(s[q.second-1],s[q.second+1]) + l - q.first;
    ans = max(ans,s[q.second]);
  }
  printf("%d\n",ans);
  
  return 0;
}
  
    
  
  


Measured memory_bytes: 2616
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;

int main() {
    int x;
    cin >> x;
    if(x == 0) cout << 1 << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n - 1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{	
	int r, c; cin >> r >> c;
	vector<vector<int>> t(r,vector<int>(c));
	rep(i, r)rep(j, c) cin >> t[i][j];
	rep(i, r)
	{
		int sum = 0;
		rep(j, c)sum += t[i][j];
		t[i].push_back(sum);
	}
	vector<int> s;
	rep(j, c+1)
	{
		int sum = 0;
		rep(i, r)sum += t[i][j];
		s.push_back(sum);
	}
	t.push_back(s);
	rep(i,r+1)
	{
		rep(j,c+1)
		{
			cout << t[i][j];
			if(j != c)cout << " ";	
		}
		cout << endl;
	}
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}



Measured memory_bytes: 3200
#include <stdio.h>
int main(int argc, char const *argv[]) {

  int num_baggages; // ???????????°
  int num_trucks;   // ?????????????????°
  int p = 0;        // ?????????
  int i;
  int sum_w;        // ???????????????????????§????????????????????????????¨?
  int count_trucks;

  scanf("%d %d",&num_baggages,&num_trucks);
  int baggages[num_baggages]; // ??????????????????

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

  int min = 1;
  int max = 1000000000;

  while( 1 ){

    // ?????????????????????1??°??????
    count_trucks = 1;
    sum_w = 0;
    p = (min+max)/2;

    for( i = 0 ; i < num_baggages ; i++ ){

      // ??????????????????????????????
      // ??????????????£????????\????????????????????????

      if( baggages[i] > p ){
        count_trucks = num_trucks + 1;
        break;
      }else if( sum_w + baggages[i] > p ){
        sum_w = baggages[i];
        count_trucks++;
      }else{
        sum_w += baggages[i];
      }

    }

    // ???????????????????????????????????°???????????????????????????????????°??¨?????£??????
    // ????????????????????????????¢???????????????????????????????????????´

    if( min == max ){
      p = min;
      break;
    }else if( count_trucks > num_trucks ){
      min = p+1;
    }else{
      max = p;
    }

    //printf("p2:%d\n",p);

  }

  printf("%d\n",p);

  return 0;
}

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

int V(int d[10],int c[10][10]);
int main()
{
    int m, n, i, j, temp, sum=0;
    int a[11]={0},c[10][10],d[10];
    scanf("%d%d",&m,&n);
    for(i=0;i<10;i++)
    {
        for(j=0;j<10;j++)
        {
            scanf("%d",&c[i][j]);
        }
    }
    for(i=0;i<m;i++)
    {
        for(j=0;j<n;j++)
        {
            scanf("%d",&temp);
            a[1+temp]++;
        }
    }
    for(i=0;i<10;i++) d[i]=c[i][1];
    while(V(d,c));
    for(i=0;i<10;i++)
    {
        sum+=a[i+1]*d[i];
    }printf("%d",sum);
    return 0;
}
int V(int d[10],int c[10][10])
{
    int count =0,i,j,temp;
    for(i=0;i<10;i++)
    {
        for(j=0;j<10;j++)
        {
            if(d[i]>d[j]+c[i][j])
            {
                d[i]=d[j]+c[i][j];
                count++;
            }
        }
    }
    return count;
}


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

int main() {
    int r;
    cin >> r;
    if(r < 1200){
        cout << "ABC" << endl;
    } else if(r < 2800){
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
}

Measured memory_bytes: 256
import math
import sys
import collections 
N=int(input())
D = list(map(int, input().split()))
M=int(input())
T = list(map(int, input().split()))
new_D=sorted(D)
new_T=sorted(T)
a=collections.Counter(new_D)
b=collections.Counter(new_T)
#print(a[10])
#print(new_D[0])
for i in new_T:
    if a[i]<b[i]:
        print("NO")
        sys.exit()
    
    
print("YES")

Measured memory_bytes: 60376
n, h = map(int, input().split())

a = [0 for _ in range(n)]
b = [0 for _ in range(n)]
s = [[] for _ in range(n)]
for i in range(n):
    s[i] =list(map(int, input().split()))

temp = s[0][0]
for i in range(1, n):
    temp = max(s[i][0], temp)

b = []
for x in s:
    if x[1] > temp:
        b.append(x[1])

b = list(reversed(sorted(b)))

d = 0
ans = 0
while d < h and len(b) > 0:
    d += b[0]
    b.pop(0)
    ans += 1

if d < h:
    ans += (h - d) // temp
    if (h - d) % temp != 0:
        ans += 1

print(ans)

Measured memory_bytes: 30752
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for (int i = 0; i < r; i++)
#define repeq(i,r) for (int i = 0; i <= r; i++)

int main() {
  int N, R;
  cin >> N >> R;
  
  cout << R + (N < 10 ? 100 * (10 - N) : 0) << endl;
  return 0;
}


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


int MOD=1000000007;

int main(void){
    string S;
    cin >> S;
    if(S=="Sunny") cout << "Cloudy" << endl;
    if(S=="Rainy") cout << "Sunny" << endl;
    if(S=="Cloudy") cout << "Rainy" << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define vll vector<long long>
#define pb push_back
typedef  long long ll;
typedef long double ld;
long double pi=3.14159265358979323846;

vll al[500005];
ll vis[500005],color[500005],I[101][101];

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

bool isPrime(int n)
{
    if (n<=1) return false; 
    if (n<=3) return true; 
    if (n%2==0||n%3==0) return false; 
    for (int i=5;i*i<=n;i=i+6) if (n%i==0||n%(i+2)==0) return false; 
    return true; 
}

ll binpow(ll n, ll po)
{
	ll res=1;
	while(po>0)
	{
		if(po%2)
		{
			res*=n;
			po--;
		}
		else
		{
			n*=n;
			po/=2;
		}
	}
	return res;
}

ll swap(ll a, ll b)
{
	a=a+b;
	b=a-b;
	a=a-b;
}

ll fact(ll n) { 
   if ((n==0)||(n==1))
      return 1;
   else
      return n*fact(n-1);
}

//bool bipartite_dfs(ll node, ll flag)
//{
//	vis[node]=1;
//	ll cflag=flag;
//	color[node]=cflag;
//	for(ll child : al[node])
//	{
//		if(!vis[child])
//		{
//			bool n=bipartite_dfs(child,1-cflag);
//			if(n==false) return false;
//		}
//		else if(color[child]==color[node]) return false;
//	}
//	return true;
//}

void mmul(ll A[][101], ll B[][101], ll dim)
{
	ll res[dim][dim];
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++)
	{
		res[i][j]=0;
		for(ll k=0;k<dim;k++) res[i][j]=(res[i][j]+A[i][k]*B[k][j])%1000000007;
	}
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++) A[i][j]=res[i][j];
}

void mpow(ll A[][101],ll dim, ll po)
{
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++)
	{
		if(i==j) I[i][j]=1;
		else I[i][j]=0;
	}
	while(po>0)
	{
		if(po%2==1)
		{
			mmul(I,A,dim);
			po--;
		}
		else
		{
			mmul(A,A,dim);
			po/=2;
		}
	}
	
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++) A[i][j]=I[i][j];
}


int main()
{
	ll n;
	cin>>n;
	ll a[n],sum=0,ans=0;
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	if(sum%n==0)
	{
		ll g=sum/n;
		for(ll i=0;i<n;i++) ans+=(g-a[i])*(g-a[i]);
	}
	else
	{
		ll g=sum/n;
		for(ll i=0;i<n;i++) ans+=(g-a[i])*(g-a[i]);
		g++;
		ll ansa=0;
		for(ll i=0;i<n;i++) ansa+=(g-a[i])*(g-a[i]);
		ans=min(ans,ansa);
	}
	cout<<ans;
}


Measured memory_bytes: 13696
#include<stdio.h>
int main()
{
    char ch[5];
    int i,a,b,c,d;
    scanf("%s",ch);
    a=ch[0]-48;
    b=ch[1]-48;
    c=ch[2]-48;
    d=ch[3]-48;
    if(a+b+c+d==7)
        printf("%d+%d+%d+%d=7",a,b,c,d);
    else if(a+b+c-d==7)
        printf("%d+%d+%d-%d=7",a,b,c,d);
    else if(a+b-c+d==7)
        printf("%d+%d-%d+%d=7",a,b,c,d);
    else if(a+b-c-d==7)
        printf("%d+%d-%d-%d=7",a,b,c,d);
    else if(a-b+c+d==7)
        printf("%d-%d+%d+%d=7",a,b,c,d);
    else if(a-b+c-d==7)
        printf("%d-%d+%d-%d=7",a,b,c,d);
    else if(a-b-c+d==7)
        printf("%d-%d-%d+%d=7",a,b,c,d);
    else
        printf("%d-%d-%d-%d=7",a,b,c,d);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main { 
    public static void main(String[] args) {
      Scanner sc=new Scanner(System.in);
      double a=sc.nextDouble();
      double b=sc.nextDouble();
      double x=sc.nextDouble();
      double o;
      if(x>a*a*b/2){
        double k=x/Math.pow(a,2);
        double l=2/a;
      	double tan=l*(b-k);
        o=Math.toDegrees(Math.atan(tan));
      }else{
      	double tan=a*Math.pow(b,2)/(2*x);
        o=Math.toDegrees(Math.atan(tan));
      }
      
      System.out.println(o);
    }
}

Measured memory_bytes: 22612
fun main(args: Array<String>) {
    val s = readLine()!!
    val k = readLine()!!.toLong()
    var oneLength = 0
    for (c in s) {
        if (c == '1') {
            oneLength++
        } else {
            break
        }
    }

    if (k == 1L) {
        println(s[0])
    } else if (k <= oneLength) {
        println(1)
    } else {
        println(s[oneLength])
    }
}

Measured memory_bytes: 33516
import itertools
H, W, K = map(int, input().split())

S = [0]*H
for i in range(H):
  S[i] = input()
Sdivs = []
mcnt = 1100
for b in itertools.product([0, 1], repeat=H-1):
  start = 0
  end = 1
  Sdivs=[]
  for a in b:
    if a==1:
      Sdivs.append(S[start:end])
      start = end
    end += 1
  Sdivs.append(S[start:end])
  cnt = sum(b)
  #print(b,cnt,Sdivs)
  ones_cum = [0]*len(Sdivs)
  mark1,mark2 = True,True
  ws = [0]
  w = 1
  while w<W+1 and mark2:
    for i,Sdiv in enumerate(Sdivs):
      #print(w,ws)
      for s in Sdiv:
        ones_cum[i] += s[w-1]=='1'
      if ones_cum[i] > K:
        #print(i,w,ones_cum[i])
        mark1 = False
        if w-1 == ws[-1]:
          #print(w-1)
          mark2 = False
          break
        ws.append(w-1)
        w -= 1
        break
    if mark1 == False:
      mark1 = True
      ones_cum = [0]*len(Sdivs)
    w+=1
  #print(cnt,mark2)
  if mark2 == False:
    continue
  cnt += len(ws)-1
  #print(cnt)
  mcnt = min(mcnt,cnt)
print(mcnt)

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

using namespace std;

typedef long long ll;

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

        int a, b;
        cin >> a >> b;
        cout << max(0, a - 2 * b) << "\n";

        return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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 ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    ll x;
    cin>>n>>x;
    V<ll> a(n);
    cinf(n,a);
    sort(all(a));
    int ans=0;
    rep(i,n){
        if(x<a[i]) break;
        if(i==n-1){
            if(x==a[i]) ans++;
        }else{
            ans++;
            x-=a[i];
        }
    }
    cout<<ans<<endl;
}

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

int main()
{
  int n;
  cin>>n;
  std::vector<int> a(n);
  set<int> st;
  for (int i = 0; i < n; ++i)
  {
    cin>>a[i];
    st.insert(a[i]);
  }
  sort(a.begin(), a.end());
  int ans=a.size();
  for(auto &&e: st) {
    auto u=upper_bound(a.begin(), a.end(),e);
    auto l=lower_bound(a.begin(), a.end(),e);
    ans-=u-l;
    if((u-l)%2!=0){
      ans++;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 5376
#include<stdio.h>
#include<string.h>

char field[8][10];
void input(int *x0,int *y0);
void bomb(int x,int y);
void output(int count);

int main()
{
	int datanum,datacount;
	int x,y,x0,y0;
	char buffer[12];

	fgets(buffer,12,stdin);
	sscanf(buffer,"%d",&datanum);

	for(datacount=1;datacount<=datanum;datacount++)
	{
		input(&x0,&y0);
		x0--;y0--;
		bomb(x0,y0);
		output(datacount);
	}
	return 0;
}

void input(int *x0,int *y0)
{
	int y;
	char buffer[12];
	for(y=0;y<8;y++)
	{
		fgets(buffer,10,stdin);
		if(strcmp(buffer,"\n")==0)
		{
			y--;
			continue;
		}
		*(buffer+8)='\0';
		strcpy(&field[y][0],buffer);
	}
	
	fgets(buffer,12,stdin);
	sscanf(buffer,"%d",x0);
	fgets(buffer,12,stdin);
	sscanf(buffer,"%d",y0);	
}

void output(int count)
{
	int y;
	printf("Data %d:\n",count);
	for(y=0;y<8;y++)
	{
		puts(&field[y][0]);
	}
}

void bomb(int x,int y)
{
	if(field[y][x]=='1')
	{
		field[y][x]='0';
		if(x-1>=0)bomb(x-1,y);
		if(x-2>=0)bomb(x-2,y);
		if(x-3>=0)bomb(x-3,y);
		if(x+1<8)bomb(x+1,y);
		if(x+2<8)bomb(x+2,y);
		if(x+3<8)bomb(x+3,y);
		if(y-1>=0)bomb(x,y-1);
		if(y-2>=0)bomb(x,y-2);
		if(y-3>=0)bomb(x,y-3);
		if(y+1<8)bomb(x,y+1);
		if(y+2<8)bomb(x,y+2);
		if(y+3<8)bomb(x,y+3);
	}
}

Measured memory_bytes: 0
N = int(input())
x = list(input())[::-1]
num = 0
nump = 0
numm = 0
pop_num = 0
for i in range(N):
        if x[i] == "1":
            pop_num += 1
for i in range(N):
    if x[i] == "1":
        num += pow(2,i,pop_num)
        num %= pop_num 
        nump += pow(2,i,pop_num+1)
        nump %= pop_num  + 1
        if pop_num-1 != 0:
            numm += pow(2,i,pop_num - 1)
            numm %= pop_num - 1



def popcnt(n):
    c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff)
    return c

x = x[::-1]
def calc(i,depth,n):
    if depth == 0:
        if x[i] == "1":
            tmp = numm
            if pop_num - 1 != 0:
                tmp -= pow(2,N-i-1,pop_num-1)
                tmp %= (pop_num - 1)
            else:
                return 0
            return calc(i,depth+1,tmp)
        else:
            tmp = nump
            tmp += pow(2,N-i-1,pop_num+1)
            tmp %= (pop_num + 1)
            return calc(i,depth+1,tmp)
    else:
        if n == 0: return depth
        return calc(i,depth+1, n % popcnt(n))
        

for i in range(N):
    print(calc(i,0,0))



Measured memory_bytes: 87536
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  while (cin >> N) {
    vec<int, 2> G(N);
    for (int i = 0; i < N - 1; i++) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      G[a].push_back(b);
      G[b].push_back(a);
    }
    vector<ll> C(N);
    for (ll& x : C) cin >> x;
    sort(C.rbegin(), C.rend());
    int ptr = 0;
    vector<ll> res(N);
    function<void(int, int)> dfs = [&](int v, int p) {
      res[v] = C[ptr++];
      for (int u : G[v]) {
        if (u == p) continue;
        dfs(u, v);
      }
    };
    dfs(0, -1);
    ll M = accumulate(C.begin() + 1, C.end(), 0ll);
    cout << M << endl;
    for (ll x : res) cout << x << " ";
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 1664
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod.m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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


int main(){
    string s;
    cin >> s;
    int tmp=0;
    rep(i, s.size()){
        tmp += (int)(s[i] - '0');
    }
    if(tmp%9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3756
import           Control.Exception           (assert)
import           Control.Monad
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  [n, k] <- getIntList

  let p = 10^9 + 7 :: Int

      sm l r =
        let res = ((r - l + 1) * (l + r) `div` 2 )
        in {- trace ("sm " ++ show (l, r, res))-} res

      f m =
        let res = (sm (n - m + 1) n - sm 0 (m-1) + 1)
        in {- trace ("f " ++ show (m, res))-} res

      as = map f [k..(n+1)]

      ans = foldr (\x a -> (x + a) `mod` p) 0 as

  -- print as
  print ans

Measured memory_bytes: 11932
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/abc108/tasks/arc102_b

//参考：
//https://misteer.hatenablog.com/entry/ARC102-D
//「0~Xまでの整数を全部作る」系はp進法を使うと相場が決まっている
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL L;

int N = 20;
vector<LL> U,V,W;
void add(LL u,LL v,LL w){
	U.push_back(u);
	V.push_back(v);
	W.push_back(w);
}

void solve(){
	for(int i=1;i<=19;i++) add(i,i+1,0);
	LL now_root = 1;
	LL last_vertex = -1;
	for(int i=1;;i++){
		LL next_root = now_root<<1;
		if(next_root>L || i==20){
			last_vertex = i-1;
			break;
		}
		add(i,i+1,now_root);
		now_root = next_root;
	}

	//点iから点20に辺をはる
	for(int i=last_vertex;i>=1;i--){
		LL diff = (1LL<<(i-1));
		if(now_root+diff<=L){
			add(i,20,now_root);
			now_root += diff;
		}
	}
}
 
int main(){
   	cin >> L;
 
    solve();

    cout << N << " " << U.size() << endl;
    for(int i=0;i<U.size();i++) cout << U[i] << " " << V[i] << " " << W[i] << endl;
    return 0;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main()
{
    lli n;
    cin>>n;
    if(n<=599)
    {
        cout<<8<<"\n";
    }else if(n<=799 && n>=600)
    {
        cout<<7<<"\n";
    }else if(n<=999 && n>=800)
    {
        cout<<6<<"\n";
    }else if(n<=1199 && n>=1000)
    {
        cout<<5<<"\n";
    }else if(n<=1399 && n>=1200)
    {
        cout<<4<<"\n";
    }else if(n<=1599 && n>=1400)
    {
        cout<<3<<"\n";
    }else if(n<=1799 && n>=1600)
    {
        cout<<2<<"\n";
    }else if(n<=1999 && n>=1800)
    {
        cout<<1<<"\n";
    }
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int n, a;
	cin >> n;

	set<int> st;
	for(int i = 0; i < n; ++i)
	{
		cin >> a;
		st.insert(a);
	}

	cout << (st.size() == n ? "YES" : "NO");
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 9600
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

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

  string s;
  cin >> s;

  size_t n = s.size();
  if (n % 2 == 1)
    n--;
  else
    n -= 2;
  ll ans;
  for (ll l = n / 2; l >= 1; l--) {
    bool ok = true;
    rep(i, l) if (s[i] != s[i + l]) {
      ok = false;
      break;
    }
    if (ok) {
      ans = l;
      break;
    }
  }

  cout << ans * 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

template<typename T>
T gcd(T a, T b) {
	if( a < b ) swap(a, b);
	
	T r;
	while( r = a % b ) {
		a = b;
		b = r;
	}
	
	return b;
}

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

int main(void) {
	int n;
	cin >> n;
	
	vector<ll> t(n);
	for(int i = 0; i < n; ++i) {
		cin >> t[i];
	}
			
	ll ans = t[0];
	for(int i = 1; i < n; ++i) {
		ans = lcm(ans, t[i]);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

count = 0
while not all([x <= 0 for x in h]):
    while h[0] == 0:
        del h[0]
    subcount = 0
    for i in range(len(h)-1):
        if (h[i] > 0 or h[i+1] > 0) and h[i]*h[i+1] == 0:
            subcount += 1
    h = [x - 1 if x - 1 >= 0 else 0 for x in h]
    subcount = subcount // 2 + 1
    count += subcount

print(count)


Measured memory_bytes: 9164
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;
string st;
int ans,len;
int main()
{
	cin>>st;
	len=st.size();
	for(int i=0;i<len;i++)
	{
		if(i==0)cout<<st[i];
		else 
		{
			if(i!=len-1)ans++;
			else cout<<ans<<st[i];
		}
	}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    char a;

    while(true){
        scanf("%c", &a);

        if(a >= 'A' && a <= 'Z')
            printf("%c", (char)(a + 32));
        else if(a >= 'a' && a <= 'z')
            printf("%c", (char)(a - 32));
        else
            cout << a;
        
        if(a == '\n') break;
    }
    return 0;
}


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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//const int md = 998244353;

/*int power(int a,int n)
{
    if(n == 1)return a%mod;
    if(n == 0)return 1;
    if(n&1)return ((a%mod)*(power((a*a)%mod,n/2))%mod)%mod;
    return power((a*a)%mod,n/2)%mod;
}*/
//int n,m,k;

signed main()
{
    showoff;
    //cin >> n >> m >> k;
    int c = 0;
    int n,h,w,a[maxn],b[maxn];
    cin >> n >> h >> w;
    FOR(i,1,n+1){
    cin >> a[i] >> b[i];
    }
    FOR(i,1,n+1){
    if(a[i] >= h && b[i] >= w )
    ++c;
    }
    cout << c;
    return 0;
}


Measured memory_bytes: 2304
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
const int maxn=100000;
struct Edge
{
	int to,next;
}e[2*maxn+10];
int head[maxn+10];
void addEdge(int a,int b)
{
	static int c=0;
	e[++c]=(Edge){b,head[a]};
	head[a]=c;
	e[++c]=(Edge){a,head[b]};
	head[b]=c;
}
int du[maxn+10];
bool vis[maxn+10];
vector<int> ans;
void dfs(int now)
{
	vis[now]=false;
	ans.push_back(now);
	int mn=0;
	for(int i=head[now]; i!=0; i=e[i].next) {
		if (vis[e[i].to]) {
			du[e[i].to]--;
			if (du[e[i].to]<du[mn]) {
				mn=e[i].to;
			}
		}
	}
	if (mn!=0)
		dfs(mn);
}
void solve(long long N, long long M, vector<long long> A, vector<long long> B){
	du[0]=999999;
	for(int i=0; i<M; ++i) {
		addEdge(A[i],B[i]);
		du[A[i]]++;
		du[B[i]]++;
	}	
	int mn=1;
	for(int i=2; i<=N; ++i) {
		if (du[i]<du[mn] || (du[i]==du[mn] && rand()%50==0)) {
			mn=i;
		}
	}
	debug(du[mn]);
	memset(vis,true,sizeof(vis));
	dfs(mn);
	printf("%zu\n",ans.size());
	for(auto i:ans) {
		printf("%d ",i);
	}
	puts("");
}

int main(){	
#ifdef WAAUTOMATON
	freopen("in.txt","r",stdin);
#endif
	long long M;
	long long N;
	scanf("%lld",&N);
	scanf("%lld",&M);
	vector<long long> A(M-1+1);
	vector<long long> B(M-1+1);
	for(int i = 0 ; i <= M-1 ; i++){
		scanf("%lld",&A[i]);
		scanf("%lld",&B[i]);
	}
	solve(N, M, A, B);
	return 0;
}



Measured memory_bytes: 9976
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c)cout<<"Yes";else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,k;
vector<long long>altura;
vector<long long>dp;
int rec(int i){
    if(dp[i]!=INT_MAX/2)return dp[i];
    if(i==n-1){
        return 0;
    }
    long long mm=INT_MAX;
    for(int j=1;j<=k;j++){
        if(i+j<=n-1)mm=min(rec(i+j)+abs(altura[i]-altura[i+j]),mm);
    }
    dp[i]=mm;
    return dp[i];


}
int main(){
    cin>>n>>k;
    dp.assign(n,INT_MAX/2);
    altura.resize(n);
    for(int i=0;i<n;i++)cin>>altura[i];
    cout<<rec(0);
}




Measured memory_bytes: 8064
n, w = map(int, input().split())
wv = [tuple(map(int, input().split())) for _ in range(n)]
vMax = 10**5
dp = [[10**9+1 for i in range(vMax + 1)] for j in range(n + 1)]
dp[0][0] = 0
for i in range(1, n + 1):
    wi, vi = wv[i-1]
    for j in range(vMax + 1):
        if vi > j:
            dp[i][j] = min(dp[i][j], dp[i - 1][j])
        else:
            dp[i][j] = min(dp[i- 1][j], dp[i - 1][j - vi] + wi)
for i in range(vMax, -1, -1):
    if dp[n][i] <= w:
        ans = i
        break
print(ans)

Measured memory_bytes: 171912
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> As(N);
    REP(n, N) cin >> As[n];

    ll ans = 0;
    int start = 0;
    int end = 0;
    ll sum_res = 0;
    ll xor_res = 0;
    while(start < N && end < N) {
        sum_res += As[end];
        xor_res ^= As[end];
        if (sum_res == xor_res) {
            ++end;
        }
        else {
            auto len = end - start;
            ans += len;
            //cout << "from " << start << " to " << end << endl;
            sum_res -= As[start];
            xor_res ^= As[start];
            sum_res -= As[end];
            xor_res ^= As[end];
            ++start;
        }
    }
    // 最後?
    while (start < end) {
        ans += end - start;
        ++start;
    }
    ans += end - start;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
/*input
4 8
7 9 8 9
*/
#include <bits/stdc++.h>
using namespace std;
#define TEMPLATE

#ifdef TEMPLATE
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;

#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

const int MOD = 1000000007;
const ll INF = std::numeric_limits<ll>::max();
const int MX = 100101;
const ld PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270L;

template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }
#endif

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int N, A;
	cin >> N >> A;
	vi sk(N);
	for (int i = 0; i < N; ++i)
		cin >> sk[i];

	vll dp(N + 1, vl(50 * 100, 0));
	// dp[i][j] kiek budu i skaiciu suma = j
	dp[0][0] = 1;

	for (int k = 0; k < N; k++)
		for (int i = N - 1; i >= 0; --i)
			for (int j = 50 * 50; j >= 0; --j)
					dp[i + 1][j + sk[k]] += dp[i][j];
	ll ats = 0;
	for (int i = 1; i <= N; ++i)
		ats += dp[i][A * i];
	printf("%lld\n", ats);
}

/* Look for:
* special cases (n=1?)
* overflow (ll vs int?)
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* array bounds
*/


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

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int n=gi();
	    int a=gi();
	    int b=gi();
	   
	    System.out.print(Math.min(n*a, b));

//        if ((x.charAt(0)==x.charAt(1) && x.charAt(2)==x.charAt(3) && x.charAt(0)!=x.charAt(2))
//        || (x.charAt(0)==x.charAt(2) && x.charAt(1)==x.charAt(3) && x.charAt(0)!=x.charAt(1))
//        || (x.charAt(0)==x.charAt(3) && x.charAt(2)==x.charAt(1) && x.charAt(0)!=x.charAt(2))) {
//        	System.out.print("Yes");
//        }else {
//        	System.out.print("No");
//        }


	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

int main(void) {
    std::map<int, int> cnt;
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int a;
        scanf("%d", &a);
        ++cnt[a];
        ++cnt[a - 1];
        ++cnt[a + 1];
    }
    int max = 0;
    for (auto i: cnt) {
        max = std::max(max, i.second);
    }
    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 4736
#include<cstdio>
#include<iostream>
#define RI register int
using namespace std;
const int N=200005;
int n,k,a[N],q[N],cur,ans; bool ismi[N],ismx[N];
int main()
{
	RI i,j,H,T; scanf("%d%d",&n,&k);
	for (i=1;i<=n;++i) scanf("%d",&a[i]);
	for (T=0,q[H=1]=n+1,i=n;i;--i)
	{
		while (H<=T&&q[H]-i>=k) ++H; while (H<=T&&a[i]<a[q[T]]) --T;
		q[++T]=i; if (H==T) ismi[i]=1;
	}
	for (T=0,H=i=1;i<=n;++i)
	{
		while (H<=T&&i-q[H]>=k) ++H; while (H<=T&&a[i]>a[q[T]]) --T;
		q[++T]=i; if (H==T) ismx[i]=1;
	}
	for (i=1;i<=n;i=j+1)
	{
		for (j=i;a[j+1]>a[j];++j); cur+=(j-i+1>=k);
	}
	for (ans=n-k+1-max(cur-1,0),i=k+1;i<=n;++i)
	ans-=ismi[i-k]&&ismx[i]; return printf("%d",ans),0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#include<atcoder/all>
#define int long long
using namespace std;
using namespace atcoder;
using mint=modint998244353;
using P=pair<pair<int,int>,int>;
signed main(){
  int N,Q;
  cin>>N>>Q;
  vector<mint> A(N+1);
  A[N-1]=1;
  for(int i=N-1;i>0;i--)A[i-1]=A[i]*10;
  for(int i=N;i>0;i--)A[i-1]+=A[i];
  mint ans=1;
  for(int i=1;i<N;i++)ans=ans*10+1;
  set<P> S;
  S.insert({{0,N},1});
  while(Q--){
    int a,b,c;
    cin>>a>>b>>c;
    a--;
    for(auto it=prev(S.lower_bound({{b,0},0}));(*it).first.second>a;it=prev(S.erase(it))){
      int r=(*it).first.second,l=(*it).first.first,k=(*it).second;
      if(b<r && a>l){
        ans+=(A[a]-A[b])*(c-k);
        S.insert({{l,a},k});
        S.insert({{b,r},k});
      }else if(a>l){
        ans+=(A[a]-A[r])*(c-k);
        S.insert({{l,a},k});
      }else if(b<r){
        ans+=(A[l]-A[b])*(c-k);
        S.insert({{b,r},k});
      }else{
        ans+=(A[l]-A[r])*(c-k);
      }
      if(it==S.begin()){
        S.erase(it);
        break;
      }
    }
    S.insert({{a,b},c});
    cout<<ans.val()<<endl;
  }
}

Measured memory_bytes: 16396
import java.util.Scanner;

//Clock Short Hand and Long Hand
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t--!=0){
			String[] s = sc.next().split(":");
			int h = Integer.parseInt(s[0]);
			int m = Integer.parseInt(s[1]);
			double x = h*30.0 + 30.0*m/60.0;
			double y = m*6;
			double d = Math.min(Math.abs(x-y), Math.abs(y-x));
//			System.out.println("DD:" + d);
			if(d>=180)d = 360-d;
//			System.out.println("D:" + d);
			System.out.println(0<=d&&d<30?"alert":90<=d&&d<=180?"safe":"warning");
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>

using namespace std;

int main(void) {
  string s;
  int a,b;
  cin>>a>>b;
  int sum = 0;
  while(a <= b) {
    s = to_string(a);
    if(s[0] == s[4] && s[1] == s[3]) {
    sum++;
  }
    a++;
  }

  cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 888