akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main() {
    string s; cin >> s;
    long long K; cin >> K;
    long long ans = 0;
    bool alleq = true;
    for (int i = 1; i < s.size(); i++)
        if (s[0] != s[i]) { alleq = false; break; }
    if (alleq) {
        cout << (K * s.size()) / 2 << endl;
    } else {
        const int n = s.size();
        int i = 0, j = n-1;
        while (s[0] == s[i]) i++;
        while (s[j] == s[n-1]) j--;
        for (int k = i, c = 1; k <= j; k++) {
            if (k == j || s[k] != s[k+1]) { ans += (long long)c/2 * K; c = 1; }
            else c++;
        }
        if (s[0] == s[n-1]) ans += i/2 + (n-j-1)/2 + (long long)(i+n-j-1)/2*(K-1);
        else ans += K * (i/2 + (n-j-1)/2);
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
    int n, m, p, sum;
    while(std::cin >> n >> m){
        std::vector<int> price_list = {};
        if(n == 0 && m == 0){
            break;
        }
        sum = 0;
        for(int i = 0;i < n;++i){
            std::cin >> p;
            price_list.push_back(p);
            sum += p;
        }
        std::sort(price_list.begin(), price_list.end(), std::greater<int>());
       for(int i = 1;i <= n/m;++i){
            sum -= price_list.at(i * m - 1);
        }
        std::cout << sum << std::endl;
    }
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  string S;
  cin>>N>>S>>K;
  char X=S.at(K-1);
  for(int Y=0;Y<N;Y++){
    if(S.at(Y)==X){
      cout<<X;
    }
    else{
      cout<<'*';
    }
  }
}

Measured memory_bytes: 3628
#include <cmath>
#include <cstdio>
#include <algorithm>

typedef long long ll;

struct Point {
    ll x, y;
    int id;
};

Point p[104];
Point q[104];
double result[104];

ll ccw(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
    return x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
}
ll sqrdist(ll x1, ll y1, ll x2, ll y2) {
    return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
ll ccw(Point a, Point b, Point c) {
    return ccw(a.x, a.y, b.x, b.y, c.x, c.y);
}
ll sqrdist(Point a, Point b) {
    return sqrdist(a.x, a.y, b.x, b.y);
}

int main(void) {
    int N, pivot = 0;
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) {
        scanf("%lld%lld", &p[i].x, &p[i].y);
        p[i].id = i;
        if (p[i].y < p[pivot].y || (p[i].y == p[pivot].y && p[i].x < p[pivot].x))
            pivot = i;
    }

    std::swap(p[pivot], p[0]);

    std::sort(p + 1, p + N, [](Point a, Point b) {
        ll ccw = ::ccw(p[0], a, b);
        if (ccw != 0)
            return ccw > 0;
        else
            return sqrdist(p[0], a) < sqrdist(p[0], b);
    });

    // for (int i = 0; i < N; ++i)
    //     printf("%lld %lld\n", p[i].x, p[i].y);
    // printf("\n");

    int K = 2;
    q[0] = p[0];
    q[1] = p[1];
    for (int i = 2; i < N; ++i) {
        // printf("\n");
        while (K >= 2 && ccw(q[K - 2], q[K - 1], p[i]) <= 0)
            --K;
        q[K] = p[i];
        ++K;
    }
    
    // for (int i = 0; i < K; ++i)
    //     printf("%lld %lld\n", q[i].x, q[i].y);

    for (int i = 0; i < N; ++i)
        result[i] = 0.0;

    double sum = 0;
    for (int i = 0; i < K; ++i) {
        Point a = q[(i - 1 + K) % K];
        Point b = q[i];
        Point c = q[(i + 1) % K];
        double dot = (b.x - a.x) * (b.x - c.x) + (b.y - a.y) * (b.y - c.y);
        double ab = std::sqrt(sqrdist(a, b));
        double bc = std::sqrt(sqrdist(b, c));
        double cos = dot / (ab * bc);
        if (cos < -1) cos = -1;
        if (cos > 1) cos = 1;
        double angle = std::acos(-cos);
        sum += result[b.id] = angle / (M_PI * 2);
        // printf("  %lld %lld %.15lf  %.15lf\n", b.x, b.y, cos, result[b.id]);
    }
    if (std::fabs(sum - 1.0) > 1e-5)
        abort();

    for (int i = 0; i < N; ++i)
        printf("%.15lf\n", result[i]);

    return 0;
}





Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
   
int main(){
    ll n;
    cin >> n;
    ll k=0;
    int m=0;
    while(k<n){
        m++;
        k+=pow(26,m);
    }
    ll a,ans,b;
    char x;
    for(int i=1;i<=m;i++){
        a=pow(26,m-i);
        b=n-(k-pow(26,m));
        ans=(b-1)/a;
        x=char(ans+'a');
        cout << x;
        n-=a*ans;
    }
    cout << endl;

} 
    

Measured memory_bytes: 4064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 500;
const int MAX_C = 1000000;

const string ans[] = { "USAGI", "NEKO", "DRAW" };

/* typedef */

typedef vector<int> vi;
typedef map<int,int> mi;

struct Bingo {
  int n, nn;
  int d0, d1;
  vi hs, vs;
  mi cs;

  Bingo(int _n): n(_n), nn(_n * _n), d0(_n), d1(_n), hs(_n, _n), vs(_n, _n) {}

  void set(int d, int x, int y) { cs[d] = y * n + x; }

  int draw(int c) {
    mi::iterator mit = cs.find(c);
    if (mit == cs.end()) return 0;

    int x = mit->second % n, y = mit->second / n;
    cs.erase(mit);

    if (n == 1) return 1;

    int count = 0;
    if (! --hs[y]) count++;
    if (! --vs[x]) count++;
    if (x == y && ! --d0) count++;
    if (x + y == n - 1 && ! --d1) count++;
    
    return count;
  }
};

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, u, v, m;
  cin >> n >> u >> v >> m;

  Bingo bu(n), bv(n);

  for (int y = 0; y < n; y++)
    for (int x = 0; x < n; x++) {
      int d;
      cin >> d;
      bu.set(d, x, y);
    }

  for (int y = 0; y < n; y++)
    for (int x = 0; x < n; x++) {
      int d;
      cin >> d;
      bv.set(d, x, y);
    }

  int ul = 0, vl = 0;
  int st = 2;
  
  while (m--) {
    int c;
    cin >> c;

    ul += bu.draw(c);
    vl += bv.draw(c);
    //printf("ul=%d, vl=%d\n", ul, vl);

    int fin = 0;
    if (ul >= u) fin += 1;
    if (vl >= v) fin += 2;

    if (fin) {
      st = fin - 1;
      break;
    }
  }

  cout << ans[st] << endl;
  return 0;
}

Measured memory_bytes: 14668
#include <stdio.h>

int main(void){
  int W,H,x,y,r,xmin,xmax,ymin,ymax;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  xmin=x-r;
  xmax=x+r;
  ymin=y-r;
  ymax=y+r;
  if(0<=W && W<=100 && 0<=H && H<=100 && -100<=x && x<=100 && -100<=y && y<=100 && 0<=r && r<=100){
      if(0<=xmin && xmax<=W && 0<=ymin && ymax<=H){
          printf("Yes\n");
      }else{
          printf("No\n");
      }
  }
  return 0;
}

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


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

    string n;
    cin >> n;
    int num = stoi(n);
    int sum = 0;
    rep(i, n.size()) {
        int t = n[i] - '0';
        sum += t;
    }
    if (num % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

using ll =  long long;

constexpr ll INF = 1LL<<60;

struct Edge{
    int from, to; ll cost;
    Edge(int from, int to, ll  cost): from(from), to(to), cost(cost) {}
};

vector<ll> d(1001, INF);
vector<bool> in_loop(1001, false);

// 負のサイクルがあるかどうかを返す
bool bellman_ford(int start, int n, vector<Edge> edges){
    d[start] = 0LL;
    bool updated = true;
    for(int i=0;i<2*n;++i) {
        updated = false;
        for(Edge e: edges){
            if(d[e.from] != INF && d[e.from] + e.cost < d[e.to]){
                d[e.to] = d[e.from] + e.cost;
                updated = true;
                if(i == n-1) {
                    in_loop[e.from] = true;
                    in_loop[e.to] = true;
                } else if(i > n-1 && in_loop[e.from]) {
                    in_loop[e.to] = true;
                }
            }
        }

        if(!updated) return false;
    }
    return true;
}

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n, m, a, b; ll c;
    cin >> n >> m;
    vector<Edge> edges;
    for(int i=0;i<m;++i){
        cin >> a >> b >> c;
        edges.push_back(Edge(a-1, b-1, -c));
    }

    if(bellman_ford(0, n, edges) && in_loop[n-1]) {
        cout << "inf" << endl;
    } else  {
        cout << -d[n-1] << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >>s;
    int n=s.size();
    string ans ;
    for(int i= 0;i<n;i++){
        if(ans.size()==0 && s.at(i) == 'B')continue;
        else if(s.at(i)=='B') ans.pop_back();
        else ans += s.at(i);
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

std::map<int, int> prime_factorize(int d) {
  std::map<int, int> primes;

  if (d % 2 == 0) {
    primes.insert(std::make_pair(2, 0));
    while(d % 2 == 0) {
      d /= 2;
      primes[2]++;
    }
  }

  int factor = 3;
  while(d > 1) {
    if (d % factor == 0) {
      primes.insert(std::make_pair(factor, 0));
      while(d % factor == 0) {
        d /= factor;
        primes[factor]++;
      }
    }
    factor += 2;
  }
  return primes;
}

int main() {
  int N; std::cin >> N;
  std::map<int, int> m;
  for (int i = 2; i <= N; ++i) {
    for (auto pair : prime_factorize(i)) {
      m[pair.first]+=pair.second;
    }
  }

  LL ans = 1;
  for (auto pair : m) {
    ans *= pair.second + 1;
    ans %= kMod;
  }
  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <functional>
using namespace std;

int main() {
	int N, M, a, b, c, d;
	cin >> N >> M;
	vector<pair<int, int>> ab(N), cd(M), manhattan(M);
	
	for (int i = 0; i < N; i++) {
		cin >> a >> b;
		ab[i] = make_pair(a, b);
	}
	for (int i = 0; i < M; i++) {
		cin >> c >> d;
		cd[i] = make_pair(c, d);
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			manhattan[j] = make_pair(abs(ab[i].first - cd[j].first) + abs(ab[i].second - cd[j].second), j + 1);
		}
		sort(manhattan.begin(), manhattan.end());
		cout << manhattan[0].second << endl;
	}	
	return 0;
}

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

typedef long long ll;typedef long double lf;typedef double fl;typedef string str;
typedef vector<int> vi;typedef vector<vector<int>> vvi;typedef vector<fl> vf;typedef vector<ll> vl;typedef vector<lf> vlf;typedef vector<char> vc;typedef vector<str> vs;

#define bre(a,b) if(a==b)break
#define ts to_string
#define con cout<<"\n"
#define w(a) while(a--)
#define wt while(true)
#define f(i,a,b,c) for(ll i=a;i<b;i+=c)
#define fd(i,a,b,c) for(ll i=a;i>=b;i-=c)
#define pb push_back
#define mp make_pair
#define len(a) a.size()
#define lenv(a) int(a.size())
#define be(a) a.begin(),a.end()
#define eb(a) a.rbegin(),a.rend()
#define ft first
#define se second
#define ctoi(a) (a-'0')
#define rei rd<int>
#define indexc index<char>
#define indexi index<int>

//NÃO ESQUEÇA DE ATRIBUIR O VETOR AO VETOR RESULTANTE DE RD()
template<class T>vector<T> rd(vector<T> ns, int n){f(i,0,n,1){T nn;cin>>nn;ns.push_back(nn);}return ns;}
template<class T>vector<vector<T>> rdm(vector<vector<T>> ns,int l,int c){f(i,0,l,1){vector<T> auau;f(j,0,c,1){T nn;cin>>nn;auau.push_back(nn);}ns.push_back(auau);}return ns;}
template<class T>int index(vector<T> ns,T n){f(i,0,lenv(ns),1){if(ns[i]==n)return i;}return -1;}
int isalf(char p){return (toupper(p)>='A' and toupper(p)<='Z') ? 1 : 0;}
vc tasc(vc ns){f(i,32,255,1)ns.push_back(i);return ns;}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.precision(2);cout.setf(ios::fixed);

    vi ns;
    ns=rei(ns,5);
    cout<<index(ns,0)+1<<"\n";

}
//SE O PROBLEMA EXIGIR MATEMÁTICA OU GEOMETRIA, VERIFIQUE SE NÃO EXISTE A FUNÇÃO NA REFERÊNCIA C++
/*CASO ESTIVER DANDO ERRO:
    -REVEJA SINTAXE;
    -VERIFIQUE ERROS MATEMÁTICOS;
    -TENTE NÃO USAR O RD;
    -SITES AJUDANTES: CPLUSPLUS, GEEK FOR GEEKS, CURSOS DO NEPS;
    -REVEJA FUNÇÕES AJUDANTES;
    -MANTENHA O CÓDIGO ORGANIZADO PARA MELHOR ENTENDIMENTO;
    -CASOS DE TESTE EXTRAS: 1 OU 0; OU ATÉ MESMO LIMITES DE MATRIZES, VETORES E CASOS DE TESTE COM ESTOURO EX.:64BITS PARA UM INT;
    -MANTENHA A CALMA E NUNCA DESISTA DE UM PROBLEMA ATOA, OLHE-O POR OUTRA PERSPECTIVA, VEJA SE EXISTEM PADRÕES OU FÓRMULAS E VÊ SE VOCÊ PODE IMPLEMENTÁ-LOS;
*/


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		String s = "Sunny";
		String c = "Cloudy";
		String r = "Rainy";
		Scanner sc = new Scanner(System.in);
		
		String today = sc.nextLine();
		if(today.equals(s)) System.out.println(c);
		if(today.equals(c)) System.out.println(r);
		if(today.equals(r)) System.out.println(s);
		
	}

}

Measured memory_bytes: 21844
#include <stdio.h>
int main(void) {
    int m1, m2, d1, d2, a;
    scanf("%d", &m1);
    scanf("%d", &d1);
    scanf("%d", &m2);
    scanf("%d", &d2);
    a = m1+1;
    if (a == 13) {
        a = 1;
    }
    if (a == m2) {
        printf("1");
        return 0;
    } else {
        printf("0");
        return 0;
    }
}

Measured memory_bytes: 128
# coding: utf-8
H, W = list(map(int, input().split()))
S = []
for _ in range(H):
    S.append(list(input()))

grid = [[0 for _ in range(W)] for _ in range(H)]

for h in range(1,H):
  if S[h-1][0] == '#' and S[h][0] == '.':
    grid[h][0] = grid[h-1][0] + 1
  else:
    grid[h][0] = grid[h-1][0]
    
for w in range(1,W):
  if S[0][w-1] == '#' and S[0][w] == '.':
    grid[0][w] = grid[0][w-1] + 1
  else:
    grid[0][w] = grid[0][w-1]
for w in range(1,W):
  for h in range(1,H):
    if S[h-1][w] == '#' and S[h][w] == '.':
      next_h = grid[h-1][w] + 1
    else:
      next_h = grid[h-1][w]      
    if S[h][w-1] == '#' and S[h][w] == '.':
      next_w = grid[h][w-1] + 1
    else:
      next_w = grid[h][w-1]
    grid[h][w] = min([next_w, next_h])
if S[H-1][W-1] == '#':
  grid[H-1][W-1] += 1
print(grid[H-1][W-1])

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(){
char a, b;
  cin >> a >> b;
  if (a - 'A' > b - 'A'){
    cout << ">";
  }
  else if (a - 'A' == b - 'A'){
    cout << "=";
  }
  else cout << "<";
}

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

def main():
    N = int(input())
    H = list(map(int, input().split()))
    dp = [10**4]*N
    dp[0] = 0

    for i in range(N-1):
        dp[i+1] = min(dp[i+1], abs(H[i+1] - H[i]) + dp[i])
        if i == N-2:
            break
        dp[i+2] = abs(H[i+2] - H[i]) + dp[i]

    print(dp.pop())


main()

Measured memory_bytes: 14012
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    ll n,m;
    cin >> n >> m;

    vector<int> a(n);
    vector<int> sum(n + 1,0);
    map<int,ll> r;
    ll ans = 0;

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

    sum[0] = 0;
    for(int i = 0;i < n;i++){
        sum[i + 1] = (sum[i] + a[i]) % m;
    }

    for(int i = 0;i <= n;i++){
        ans += r[sum[i]];
        r[sum[i]]++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  double x1,y1,x2,y2,xq,yq;

  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&xq,&yq)!=EOF){

    double ux=x2-x1;
    double uy=y2-y1;
    double vx=xq-x1;
    double vy=yq-y1;
    double v=sqrt(vx*vx+vy*vy);
    double u=sqrt(ux*ux+uy*uy);
    double len=(ux*vx+uy*vy)/u;

    // printf("\nux=%f,uy=%f\nvx=%f,vy=%f\n",ux,uy,vx,vy);
    // printf("len=%f\n",len);

    double x=x1+ux*len/u;
    double y=y1+uy*len/u;
    //printf("x=%f,y=%f\n",x,y);

    printf("%f %f\n",2*x-xq,2*y-yq);

  }
}

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

int main() {
    int n;
    cin >> n;
    int rooms[4][3][10];
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                rooms[i][j][k] = 0;
            }
        }
    }
    int b, f, r, v;
    for (int i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;
        rooms[b-1][f-1][r-1] += v;
    }

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                cout << " " << rooms[i][j][k];
            }
            cout << endl;
        }
        if (i != 3) cout << "####################" << endl;
    }
}


Measured memory_bytes: 3100
//agc009_a.cpp
//Sat Oct 27 11:43:32 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll count = 0;
	for (int i=n-1;i>=0;i--){
		if ((a[i]+count)%b[i] != 0){
			count += b[i]-(a[i]+count)%b[i];
		}
	}

	cout << count << endl;

}

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

int a,b,c;

int main() {
  cin >> a >> b >> c;
  if(a == b && b!=c) cout << "Yes";
  else if(b == c && a!=c) cout << "Yes";
  else if(a == c && b!=c) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 256
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    unused_imports,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::{fastout, input, marker::*};
use std::collections::*;
//use std::cmp::*;
//use std::num;
//use petgraph::unionfind::UnionFind;

#[fastout()]
fn main() {
    input! {
        N:i64
    }
    if N < 357 {
        println!("0");
        return;
    }

    let l = N.to_string();

    let ans = dfs(0, N);
    println!("{}", ans);
}
fn dfs(x: i64, N: i64) -> i64 {
    let mut t = 0;
    if x > N {
        return 0;
    } else if is753(x) {
        t += 1;
    }
    t += dfs(x * 10 + 3, N);
    t += dfs(x * 10 + 5, N);
    t += dfs(x * 10 + 7, N);
    t
}
fn is753(x: i64) -> bool {
    let s = x.to_string();
    if s.find('3') == None || s.find('5') == None || s.find('7') == None {
        false
    } else {
        true
    }
}


Measured memory_bytes: 2208
#include<iostream>
#include<vector>
#include<stack>
#include<climits>
using namespace std;

enum{WALL,BLANK};
struct Data{int height,pos;};
int getRectangleArea(vector<int>buf)
{
  int ans=0;
  stack<Data>S;
  buf.push_back(INT_MIN);
  for(int i=0;i<buf.size();i++){
    Data next={buf[i],i},pre;
    if(S.empty()){
      S.push(next);
    }else if(S.top().height < next.height){
      S.push(next);
    }else if(S.top().height == next.height){
    }else if(S.top().height > next.height){
      pre=next;
      while(!S.empty() && S.top().height >= next.height){
        pre=S.top();
        S.pop();
        ans = max(ans, (next.pos-pre.pos)*pre.height);
      }
    next.pos=pre.pos;
    S.push(next);
    }
  }
  return ans;
}

int main()
{
  int n,ans;
  vector< vector<int> >field(5,vector<int>(5,0));
  vector< vector<int> >dp(5,vector<int>(5,0));
  cin>>n;
  while(n-->0){
    for(int i=0;i<5;i++)for(int j=0;j<5;j++)cin>>field[i][j];
    ans=0;
    for(int j=0;j<5;j++)dp[0][j] = (field[0][j]==WALL)?0:1;
    for(int i=1;i<5;i++)for(int j=0;j<5;j++)dp[i][j] = (field[i][j]==WALL)?0:dp[i-1][j]+1;
    for(int i=0;i<5;i++)ans=max(ans,getRectangleArea(dp[i]));
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 0
#include <iostream>

unsigned long int N, K;

unsigned long int A( unsigned long int n ) {
    return 2*n;
}

unsigned long int B( unsigned long int n ) {
    return n+K;
}

unsigned long int solve() {
    unsigned long int res = 1;

    for (int i=0; i<N; ++i) {
        res = std::min( A(res), B(res) );
    }

    return res;
}

int main() {
    std::cin >> N >> K;

    std::cout << solve() << std::endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

count_list = []

black = 0
white = s.count('.')

count_list.append(white)

for i in range(n):
    if s[i] == '#':
        black += 1
    if s[i] == '.':
        white -= 1
    count_list.append(black + white)

print(min(count_list))

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

// セグメント木
// ref:https://ei1333.github.io/luzhiled/snippets/structure/segment-tree.html
template <typename Mnd>
struct segment_tree {
    int sz;
    vector<Mnd> data;
    function<Mnd(Mnd, Mnd)> f;
    Mnd e;
    //サイズだけ指定して初期化
    segment_tree(int _sz, function<Mnd(Mnd, Mnd)> _f, Mnd _e) : f(_f), e(_e) {
        sz = 1;
        while (sz < _sz) sz <<= 1;
        data.assign(sz * 2, e);
    }
    //参照渡しなので代入とかもできる
    Mnd& operator[](const int& k) {
        return data[k + sz];
    }
    //木を構築 O(n)
    void build() {
        for (int i = sz - 1; i > 0; i--) data[i] = f(data[2 * i], data[2 * i + 1]);
    }
    //更新しつつ木を再構築 O(log n)
    void update(int k, Mnd x) {
        data[k += sz] = x;
        while (k >>= 1) data[k] = f(data[2 * k], data[2 * k + 1]);
    }
    //[a,b)でのクエリに答える　O(log n)
    Mnd query(int a, int b) const {
        Mnd l = e, r = e;
        for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if (a & 1) l = f(l, data[a++]);
            if (b & 1) r = f(r, data[--b]);
        }
        return f(l, r);
    }
};

int n, k;
vector<int> l, r;
lint mod = 998244353;

int main() {
    cin >> n >> k;
    l.resize(k);
    r.resize(k);
    for (int i = 0; i < k; i++) {
        cin >> l[i] >> r[i];
        l[i]--;
    }
    auto add = [](lint x, lint y) { return (x + y) % mod; };
    segment_tree<lint> seg(n, add, 0);
    seg.update(0, 1);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < k; j++) {
            int left = max(0, i - r[j]);
            int right = max(0, i - l[j]);
            lint add = seg.query(left, right);
            lint now = seg.query(i, i + 1);
            seg.update(i, now + add);
        }
    }
    cout << seg.query(n - 1, n) << endl;
}

Measured memory_bytes: 7460
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    cin>>a;
    int Z1=a%10;
    a=a/10;
    int Z=a%10;
    a=a/10;
    int Y=a%10;
    a=a/10;
    int X=a%10;
    if(X+Y+Z+Z1==7)
    {
        cout<<X<<"+"<<Y<<"+"<<Z<<"+"<<Z1<<"=7";

    }
    else  if(X-Y+Z+Z1==7)
    {
        cout<<X<<"-"<<Y<<"+"<<Z<<"+"<<Z1<<"=7";;

    }
    else  if(X+Y-Z+Z1==7)
    {
        cout<<X<<"+"<<Y<<"-"<<Z<<"+"<<Z1<<"=7";;

    }
     else  if(X+Y+Z-Z1==7)
    {
        cout<<X<<"+"<<Y<<"+"<<Z<<"-"<<Z1<<"=7";;

    }
     else if(X-Y-Z+Z1==7)
    {
        cout<<X<<"-"<<Y<<"-"<<Z<<"+"<<Z1<<"=7";;
    }
      else if(X-Y+Z-Z1==7)
    {
        cout<<X<<"-"<<Y<<"+"<<Z<<"-"<<Z1<<"=7";;

    }
      else if(X+Y-Z-Z1==7)
    {
        cout<<X<<"+"<<Y<<"-"<<Z<<"-"<<Z1<<"=7";;

    }
      else if(X-Y-Z-Z1==7)
    {
        cout<<X<<"-"<<Y<<"-"<<Z<<"-"<<Z1<<"=7";;
    }
     /* else if(X+Y+Z+Z1)
    {
        cout<<X<<"+"<<Y<<"+"<<Z<<"+"<<Z1;
        break;
    }
      else if(X+Y+Z+Z1)
    {
        cout<<X<<"+"<<Y<<"+"<<Z<<"+"<<Z1;
        break;
    }
      else if(X+Y+Z+Z1)
    {
        cout<<X<<"+"<<Y<<"+"<<Z<<"+"<<Z1;
        break;
    }
      else if(X+Y+Z+Z1)
    {
        cout<<X<<"+"<<Y<<"+"<<Z<<"+"<<Z1;
        break;
    }
      else if(X+Y+Z+Z1)
    {
        cout<<X<<"+"<<Y<<"+"<<Z<<"+"<<Z1;
        break;
    }
      else if(X+Y+Z+Z1)
    {
        cout<<X<<"+"<<Y<<"+"<<Z<<"+"<<Z1;
        break;
    }
      else if(X+Y+Z+Z1)
    {
        cout<<X<<"+"<<Y<<"+"<<Z<<"+"<<Z1;
        break;
    }
      else if(X+Y+Z+Z1)
    {
        cout<<X<<"+"<<Y<<"+"<<Z<<"+"<<Z1;
        break;
    }
      else if(X+Y+Z+Z1)
    {
        cout<<X<<"+"<<Y<<"+"<<Z<<"+"<<Z1;
        break;
    }*/
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <cassert>
#include <string.h>
#include <tuple>

using namespace std;
#define  rep(i,n) for(int i=0;i<n;i++)
#define  rrep(i,n) for(int i=n-1;i>=0;i--)///n-1番目からn回
#define  REP(i,a,b) for(int i=a;i<=b;i++) ///a番目からb回
#define  RREP(i,a,b) for(int i=a;i<b;i--)
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pair_t;
#define MOD 1000003

//int arr[N]
////sort(arr,arr +N)

//vector <int> hoge
////sort(hoge.begin(),hoge.end());
///*min_element(hoge.begin(),hoge.end();　最小値　　　最大値はmax_element();
///(10-(n%10))%10  10-(1桁目)取得 12->8 20->0

#define Ru(n)  ( ((n)+9)/10*10  ) //切りあげ
#define Rd(n)  ( ((n)-10)/10*10 +10 )	切り捨て


int gcd(int a,int b);
size_t length(const std::string& str) {
	return str.length();
}
bool comp(const pair_t &a, const pair_t &b) {
	return a.first < b.first;
}

int main() {
	int n,x;
	vi L(1000);
	cin>>n>>x;
	rep(i,n)
		cin>>L[i] ;
	int sum=0,flag=1;
	rep(i,n){
		sum+=L[i];
		if(sum<=x)
			flag++;

	}
	cout<<flag<<endl;
}





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


Measured memory_bytes: 256
program abc142b
	implicit none
    integer :: N, K, counter, i
    integer, allocatable :: h(:)
    
    read(*,*) N, K
    allocate( h(N))
    read(*,*) h(:)
    counter = 0
    do i = 1, N
    	if(h(i)>=K) then 
        	counter = counter + 1
        end if
    end do
    
    print *, counter
end program abc142b
    

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n,m,k;
  cin >> n >> m >> k;
  if(k==0 || k%m==0){
    cout << "Yes" << endl;
    return 0;
  }
  rep(i,n+1){
    int x=k-i*m,y=n-2*i;
    if(x*y>0 && x%y==0 && x/y<=m){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
return 0;}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979323846264338327950
 
int main() {
	int a, b, h, m, min = 0;
	long double rad = 0.0;
	scanf("%d%d%d%d", &a, &b, &h, &m);
	min = h * 60 + m;
	rad = fabs((long double)min * 0.5 - (long double)min * 6.0);
	rad = rad * PI / 180.0;
	long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *b) * cosl(rad);
	printf("%20.20Lf\n", sqrtl(rsq));
	return 0;
}

Measured memory_bytes: 2580
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h1 = sc.nextInt();
		int m1 = sc.nextInt();
		int h2 = sc.nextInt();
		int m2 = sc.nextInt();
		if(h2==0) {
			h2=24;
		}
		int k = sc.nextInt();
		int H = h2-h1;
		int M = m2-m1;
		System.out.println(H*60+M-k);
	 }
}


Measured memory_bytes: 35720
a, b, c, d = (int(x) for x in input().split())

while 0 <= c or 0 <= c :
    
    c = c - b
    if c <= 0 : 
        ans = 'Yes'
        break

    a = a - d
    if a <= 0 :
        ans = 'No'
        break


print(ans)
    

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

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++){
        cin >> d[i];
    }
    sort(d.begin(), d.end());

    int idx = n / 2;

    cout << d[idx] - d[idx - 1] << endl;
}

Measured memory_bytes: 640
/*
AUTHOR: Aman Raj
LANG: C++
*/

using namespace std;

typedef   long long  int ll;
#include <bits/stdc++.h>


//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
#define fast  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define all(a) a.begin(),a.end()
//#define mod 998244353


#define mod   1000000007

#define inf 1e18
//#define mod 3
#define flush fflush(stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<ll, ll, hash< ll > > ht;

// find_by_order()  // order_of_key
typedef tree<
    ll,
    null_type,
    less<ll>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;






ll power1(ll a, ll b)//a raised to power b
   {  if(b<=0) return 1; if(b==1) return a;
       ll c=power1(a,b/2);
        c*=c;if(b%2==1) c*=a;
        return c;
   }
   ll mi(ll a,ll m)
   { ll c= power1(a,m-2);

     return c;
   }



 struct less_then_greater {
    template<typename T, typename U>
    bool operator()(T const& lhs, U const& rhs) const {
        if (lhs.first < rhs.first) return true;
        if (rhs.first < lhs.first) return false;
        return lhs.second > rhs.second;
    }
};
 /*std::priority_queue<std::pair<int, int>,
                    std::vector<std::pair<int, int>>,
                    less_then_greater
                   > pq;*/
  /*   #define MAXN 1000001
ll spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)

        // marking smallest prime factor for every
        // number to be itself.
        spf[i] = i;

    // separately marking spf for every even
    // number as 2
    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {
        // checking if i is prime
        if (spf[i] == i)
        {
            // marking SPF for all numbers divisible by i
            for (int j=i*i; j<MAXN; j+=i)

                // marking spf[j] if it is not
                // previously marked
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}
vector<ll> getFactorization(ll x)
{
    vector<ll> ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}
*/
// take multiset of all edges
// meanwhile for all cc keep record of all edges in multiset too which can be used to digest
// one line or two lines
//


  int main()
{    fast;
      ll a;cin>>a;
       cout<<a+ (a*a) + (a*a*a)<<endl;
      return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cstdlib>
#include <cstdio>
using namespace std;

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

void print_hms(int sec){
	int h, m, s;
	s = sec % 60;
	m = (sec/60) % 60;
	h = sec/3600;

	printf("%02d:%02d:%02d\n", h, m, s);
}

int main(){
	int h, m, s;
	while(cin >> h >> m >> s, s != -1 ){
		const int twh = 7200;
		int sec;
		sec = h*60*60+m*60+s;
		print_hms(twh - sec);
		print_hms((twh - sec)*3);
	}

	return 0;
}

Measured memory_bytes: 1160
class UnionFind
    def initialize
        @obj_to_node = {}
    end

    def add(obj)
        @obj_to_node[obj] ||= Node.new(obj)
    end

    class Node
        def initialize(obj)
            @obj = obj
            @parent = self
            @size = 1
            @rank = 0
        end

        def root
            return self if @parent == self
            @parent = @parent.root
        end

        attr_accessor :parent, :size, :rank, :obj
    end

    def union(x, y)
        u = (@obj_to_node[x] ||= Node.new(x)).root
        v = (@obj_to_node[y] ||= Node.new(y)).root
        return u.obj if u == v
        if u.rank > v.rank
            v.parent = u
            u.size += v.size
            return u.obj
        elsif v.rank > u.rank
            u.parent = v
            v.size += u.size
            return v.obj
        else
            u.parent = v
            v.rank += 1
            v.size += u.size
            return v.obj
        end
    end

    def groups
        @obj_to_node.keys.group_by {|x| @obj_to_node[x].root.obj}
    end
end

n, m = gets.split.map(&:to_i)

machines = (1..m).map { gets.split.map(&:to_i) }.sort_by(&:first).reverse.map(&:last)

h = {}
l = {}
hg = UnionFind.new
lg = UnionFind.new
(1..n).each do |i|
    h[i] = i
    hg.add(i)
    l[i] = i
    lg.add(i)
end

machines.each do |y|
    if h[y] and h[y + 1]
        h[y + 1] = hg.union(h[y], h[y + 1])
    elsif h[y]
        h[y + 1] = h[y]
    end
    h[y] = nil

    if l[y + 1] and l[y]
        l[y] = lg.union(l[y + 1], l[y])
    elsif l[y + 1]
        l[y] = l[y + 1]
    end
    l[y + 1] = nil
end

hl = Hash.new(1)
gh = hg.groups
gl = lg.groups
h.each do |i, r|
    (gh[r] || []).each do |k|
        hl[k] += i
    end
end
l.each do |i, r|
    (gl[r] || []).each do |k|
        hl[k] -= i
    end
end
puts (1..n).map {|i| hl[i]} * ' '



Measured memory_bytes: 121352
#include<stdio.h>

#define modn 1000000007


static inline int mod_multi(long long a,long long b){
    unsigned long long ans;
    ans = (long long)a * b;
    if(ans > modn)ans %= modn;
    return ans; 
}

static inline int modpow(int number,int index){
    int ret = 1;
    while(index > 0){
        if(index & 1)ret = mod_multi(ret,number);
        number = mod_multi(number,number);
        index>>=1;
    }
    return ret;
}


static inline int inv(int n){
  return modpow(n,modn - 2);
}

int modcomb(long long n,int k){
  int ret = 1;
  if(k > n/2)k = n - k;
  for(long long i = n;n - i < k;i--)ret = mod_multi(i,ret);
  for(int i = 1;i <= k;i++)ret = mod_multi(ret,inv(i));
  return ret;
}

int main(void){
    int n,ans,a,b;
    scanf("%d %d %d",&n,&a,&b);
    ans = modpow(2,n);
    ans--;
    ans -= modcomb(n,a);
    if(ans < 0)ans += modn;
    ans -= modcomb(n,b);
    if(ans < 0)ans += modn;
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
import java.util.Set;

public class Main {

	@SuppressWarnings("unchecked")
	private static final Set<Integer>[] SETS = new Set[] { Set.of(1, 3, 5, 7, 8, 10, 12), Set.of(4, 6, 9, 11),
			Set.of(12) };

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int x = scanner.nextInt(), y = scanner.nextInt();
			System.out.println((getSet(x) == getSet(y)) ? "Yes" : "No");
		}
	}

	/**
	 * @param n 入力数字
	 * @return 入力数字を含まれるセット
	 */
	private static Set<Integer> getSet(int n) {
		for (Set<Integer> set : SETS) {
			if (set.contains(n)) {
				return set;
			}
		}
		return null;
	}
}


Measured memory_bytes: 35764
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<functional>

using namespace std;

int main()
{
	long long h;

	scanf("%lld", &h);

	long long sol;

	sol = (long long)pow(2.0, (long long)log2(h) + 1) - 1;

	printf("%lld\n", sol);

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define x first
#define y second
int n,k,i;
const int N=1005;
int a[N];
ll ans;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //assert(freopen("input.txt","r",stdin));
    //assert(freopen("output.txt","w",stdout));
    cin>>n>>k;
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(i=0;i<k;i++)
        ans+=a[i];
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdint>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <cassert>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

using namespace std;

int main() {

  long long N = 0, M = 0;
  cin >> N >> M;

  std::vector<LL> A(N);
  for(size_t i=0; i<N; i++) {
    cin >> A[i];
  }

  typedef std::pair<LL,LL> P;
  std::vector<P> BC(M);
  for(size_t i=0; i<M; i++) {
    LL b,c;
    cin >> b >> c;
    BC[i] = std::make_pair(b,c);
  }

  std::sort(A.begin(), A.end());
  std::reverse( A.begin(), A.end() );

  std::sort(BC.begin(), BC.end(), [&](const P& lhs, const P& rhs) {
    return (lhs.second > rhs.second);
  });

  LL sum = 0;
  LL num_card = 0;
  size_t a_idx = 0, bc_idx = 0;
  while( num_card < N ) {
    LL amax = A[a_idx];
    LL cmax = BC[bc_idx].second;
    if(amax > cmax) {
      sum += amax;
      num_card++;
      a_idx++;
    }
    else {
      LL b = min(N-num_card, BC[bc_idx].first);
      sum += cmax * b;
      num_card += b;
      bc_idx++;
    }
  }

  std::cout << sum << std::endl;

  return 0;
}



Measured memory_bytes: 2560
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int main(){
  long ii,jj,kk;
  vector<int> a,b;

  int n,m;
  cin >> n;
  a.resize(n);
  for(ii=0;ii<n;ii++){
    cin >> a[ii];
  }
  cin >> m;
  b.resize(m);
  for(ii=0;ii<m;ii++){
    cin >> b[ii];
  }

  int pos=0;
  for(ii=0;ii<m;ii++){
    while(a[pos] != b[ii] && pos < n){
      pos++;
    }
  }
  if(pos != n){
    cout << "1" << endl;
  }
  else{
    cout << "0" << endl;
  }
  return 0;
}



Measured memory_bytes: 4308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

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


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	char mj[1200];
	int t, i = 0;

	while ((mj[i] = getchar()) != EOF) {
		i++;
	}
	
	for (t = 0; t < i; t++) {
		if (mj[t] >= 'A' && mj[t] <= 'Z') {
			mj[t] += 0x20;
		}
		else if (mj[t] >= 'a' && mj[t] <= 'z') {
			mj[t] -= 0x20;
		}

		printf("%c", mj[t]);
	}

	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
using namespace std;
const int N = 310000, mod = 1e9 + 7;

int n, ans;
ll a[N];

template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}

inline int addMod(int a, int b) {
    return (a += b) >= mod ? a - mod : a;
}

int main() {
    read(n);
    for (R int i = 1; i <= n; ++i) read(a[i]);
    for (R int i = 59; ~i; --i) {
        int num0 = 0, num1 = 0, sum = 0;
        for (R int j = 1; j <= n; ++j) {
            if (a[j] & (1ll << i)) sum = addMod(sum, num0), ++num1;
            else sum = addMod(sum, num1), ++num0;
        }
        ans = (ans + (1ll << i) % mod * sum) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> ipair;
typedef tuple<int, int, int> ituple;

// const int INF = INT_MAX;
// const ll INF = LLONG_MAX;
const int MOD = ((int)1e9 + 7);
// const ld EPS = (1e-10);
#define PI acosl(-1)
#define MAX_N (100000 + 2)

string k;
int d;
// dp[大きい方からn桁まで][どの数字を使ってもいいか][mod D]
ll dp[MAX_N][2][102];

ll rec(int digit, int can_use_any_number, int remain){
  if (digit == -1){
    if (can_use_any_number){
      return 0;
    }
    else{
      return remain == 0 ? 1 : 0;
    }
  }
  if (dp[digit][can_use_any_number][remain] != -1){
    return dp[digit][can_use_any_number][remain];
  }

  ll result = 0;
  int number = k[digit] - '0';
  if (can_use_any_number){
    for (int i = 0; i <= 9; i++){
    // printf("1: 10 * %d + %d - %d mod %d = %d\n", d, remain, i, d, (10 * d + remain - i) % d);
      result += rec(digit - 1, 1, (10 * d + remain - i) % d);
      result %= MOD;
    }

    for (int i = 0; i <= number - 1; i++){
    // printf("2: 10 * %d + %d - %d mod %d = %d\n", d, remain, i, d, (10 * d + remain - i) % d);
      result += rec(digit - 1, 0, (10 * d + remain - i) % d);
      result %= MOD;
    }
  }
  else{
    result += rec(digit - 1, 0, (10 * d + remain - number) % d);
    result %= MOD;
  }
  // printf("dp[%d][%d][%d] = %lld\n", digit, can_use_any_number, remain, result);
  dp[digit][can_use_any_number][remain] = result;

  return result;
}

void exec(){
  cin >> k >> d;

  for (int i = 0; i < MAX_N; i++){
    for (int j = 0; j < 2; j++){
      for (int k = 0; k < 102; k++){
        dp[i][j][k] = -1;
      }
    }
  }

  ll result = rec(k.length()-1, 1, 0) + rec(k.length()-1, 0, 0);
  result %= MOD;
  result = (result + MOD - 1) % MOD;

  cout << result << endl;

}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

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


Measured memory_bytes: 160384
#include <bits/stdc++.h>
using namespace std ;
typedef long long int ll ; 
int inf = -1e9;
const ll w = 1e9 ;



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

     return 0 ;
   }

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int x = 0, y, size, max = 0, cnt = 0;
		int[][] paper = new int[10][10];
		String[] strings;
		for(int i = 0; i < 10; i++){
			for(int j = 0; j < 10; j++){
				paper[i][j] = 0;
			}
		}
		
		while(sc.hasNext()){
			strings = sc.next().split(",");
			x = Integer.parseInt(strings[0]);
			y = Integer.parseInt(strings[1]);
			size = Integer.parseInt(strings[2]);
			
			if(size == 1){
				if(y - 1 >= 0) paper[x][y - 1]++;
				for(int i = 0; i < 3; i++){
					if(x - 1 + i >= 0 && x - 1 + i < 10) paper[x - 1 + i][y]++;
				}
				if(y + 1 >= 0) paper[x][y + 1]++;
			}else if(size == 2){
				for(int i = 0; i < 3; i++){
					for(int j = 0; j < 3; j++){
						if((x - 1 + j >= 0  && x - 1 + j < 10) && (y - 1 + i >= 0 && y - 1 + i < 10)) paper[x - 1 + j][y - 1 + i]++;
					}
				}
			}else{
				for(int i = 0; i < 3; i++){
					for(int j = 0; j < 3; j++){
						if((x - 1 + j >= 0  && x - 1 + j < 10) && (y - 1 + i >= 0 && y - 1 + i < 10)) paper[x - 1 + j][y - 1 + i]++;
					}
				}
				if(y - 2 >= 0) paper[x][y - 2]++;
				if(x - 2 >= 0) paper[x - 2][y]++;
				if(x + 2 < 10) paper[x + 2][y]++;
				if(y + 2 < 10) paper[x][y + 2]++;
			}
		}
		
		for(int i = 0; i < 10; i++){
			for(int j = 0; j < 10; j++){
				if(paper[j][i] == 0){
					cnt++;
				}
				else if(paper[j][i] > max){
					max = paper[j][i];
				}
			}
		}
		System.out.println(cnt);
		System.out.println(max);
	}
}

Measured memory_bytes: 12000
package main

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

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	K := nextInt(sc)
	N := nextInt(sc)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt(sc)
	}
	maxi := 0
	for i := 1; i < N; i++ {
		maxi = max(maxi, A[i]-A[i-1])
	}
	maxi = max(maxi, K+A[0]-A[N-1])
	fmt.Println(K - maxi)
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
const ll INF=1000000000000001;
int main() {
	ll n;
	string s,st;
	cin >>s;
	n=s.length();
	if (s[n-1]=='s'){
		st ="es";
	}
	else{
		st="s";
	}
	cout << s + st <<endl;
	return 0;
}


Measured memory_bytes: 3624