akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

// 移動元と行先と辺のコストを記録する構造体
template <typename T>
struct Edge {
    int from, to;
    T cost;
    Edge(int s, T d) : to(s), cost(d) {}
    Edge(int f, int s, T d) : from(f), to(s), cost(d) {}

    bool operator<(const Edge &e) const {
        return cost < e.cost;
    }
    bool operator>(const Edge &e) const {
        return cost > e.cost;
    }
};

// 木に対するDFS (対象となる頂点から最も遠い頂点の情報を返す)
// n := (頂点番号, その頂点までのコスト)
// Verified: AtCoder Regular Contest 022 C (ロミオとジュリエット)

template <typename T>
void getDeepest(pair<int, T> &n, vector< vector< Edge<T> > > &G, int p, int prev, T cost) {
    int ok = true;
    for(auto x : G[p]) {
        if(x.to != prev) {
            ok = false;
            getDeepest(n, G, x.to, p, cost+x.cost);
        }
    }
    if(ok && n.second < cost) {
        n.first = p;
        n.second = cost;
    }
}

// 補足: これを使用すると木の直径が求められる。
// 1. 適当な頂点を選びDFSを適用する
// 2. 1 で返ってきた頂点に対してDFSを適用する
// 3. 1 で返った頂点と 2 で返った頂点が直径の候補の一つになる。


template <typename T>
using Graph = vector< vector< Edge<T> > >;

signed main() {
    int N; cin >> N;
    vector< vector< Edge<int> > > G(N);
    for(int i=0; i<N-1; i++) {
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].emplace_back(b, 1);
        G[b].emplace_back(a, 1);
    }

// 使用例
// この場合は p.fr と r.fr が直径の候補の一つであり、その大きさは r.sc である。
    pii p = pii(0, 0), r = pii(0, 0);
    getDeepest<int>(p, G, 0, -1, 0);
    getDeepest<int>(r, G, p.first, -1, 0);

    cout << (r.second % 3 == 1 ? "Second" : "First") << endl;
    return 0;
}


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

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



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

  int result = 0;
  for (int a = 1; a <= K; a++) {
    for (int b = 1; b <= K; b++) {
      for (int c = 1; c <= K; c++) {
        result += gcd(gcd(a, b), c);
      }
    }
  }
  cout << result;
}

Measured memory_bytes: 3636
N = int(input())
cnt_f = 0
cnt_t = 0
for a in map(int, input().split()):
    if a % 4 == 0:
        cnt_f += 1
    elif a % 2 == 0:
        cnt_t += 1
if N // 2 <= cnt_f or N <= cnt_f * 2 + cnt_t:
    print('Yes')
else:
    print('No')

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

int vector_finder(std::vector<int> vec, int number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

int main()
{
	int H, W, K;
	cin >> H >> W >> K;
	vector<vector<char>> c(H,vector<char>(W));

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> c.at(i).at(j);
		}
	}

	int count = 0;
	int sum_count = 0;
	for (int bit = 0; bit < (1 << H); bit++) {
		vector<int> S;

		for (int i = 0; i < H; i++) {
			if (bit & (1 << i)) {
				S.push_back(i);
			}
		}

		for (int bit2 = 0; bit2 < (1 << W); bit2++) {
			vector<int> T;
			for (int j = 0; j < W; j++) {
				if (bit2 & (1 << j)) {
					T.push_back(j);
				}
			}

			count = 0;

			for (int k = 0; k < H; k++) {
				for (int l = 0; l < W; l++) {
					if (vector_finder(S, k) || vector_finder(T, l)) {
						continue;
					}
					else if (c.at(k).at(l) == '#') {
						count++;
					}
				}
			}

			if (count == K) {
				sum_count++;
			}

		}
	}
	cout << sum_count << endl;
	return 0;
}

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

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

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

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

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

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  init();
  ll N, M, X;
  cin >> N >> M >> X;
  ll a = 0;
  ll b = 0;
  rep(i, M) {
    ll aa;
    cin >> aa;
    if (aa > X) {
      a++;
    } else {
      b++;
    }
  }
  ll ans = min(a, b);
  COUT(ans);
  return 0;
}

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

#define int long long
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>
int const N = 2e5 + 10;
bool b[N];
int a[N];
vi ans;
int n, k;

void dfs(int i) {
    k--;
    if(k == 0) {
        cout << i << endl;
        exit(0);
    }
    b[i] = 1;
    ans.pb(i);
    if(!b[a[i]]) {
        dfs(a[i]);
    }
    else {
        int cycle = 0;
        for(int j = 0; j < ans.size(); j++) {
            if(a[i] == ans[j]) {
                cycle = ans.size() - j;
                k--;
                k %= cycle;
                cout << ans[j + k] << endl;
                exit(0);
            }
        }
    }
}
signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    k++;
    dfs(1);

    return 0;
}



Measured memory_bytes: 13808
#include<iostream>
#include<algorithm>
#include<string>
#include<list>


using namespace std;


int main()
{
	int n, a[6] = {0};
	double h;

	ios::sync_with_stdio(false);

	cin >>n;

	for (int i = 0; i != n; ++i)
	{
		cin >> h;
		if (h < 165.0)
		{
			++a[0];
		}
		else if (h < 170.0)
		{
			++a[1];
		}
		else if (h < 175.0)
		{
			++a[2];
		}
		else if (h < 180.0)
		{
			++a[3];
		}
		else if (h < 185.0)
		{
			++a[4];
		}
		else
		{
			++a[5];
		}
	}

	for (int i = 0; i != 6; ++i)
	{
		cout << i + 1<<":";
		for (int j = 0; j != a[i]; ++j)
		{
			cout << "*";
		}
		cout << endl;
	}

	return 0;

}


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


#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

ll mod = 1e9 + 7ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll inf = 1ll << 60;


int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> work(101010);
    rp(i, 0, n){
        int a, b;
        scanf("%d%d", &a, &b);
        work.at(a).push_back(b);
    }
    priority_queue<int> pq;
    ll ans = 0ll;
    rp(i, 1, m+1){
        rp(j, 0, work.at(i).size()) pq.push(work.at(i).at(j));
        if(pq.size() != 0){
            ans += pq.top();
            pq.pop();
        }
        
    }
    printf("%lld", ans);
    return 0;
}



Measured memory_bytes: 5632
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve() {
  int a; cin >> a;
  string s; cin >> s;
  if (a >= 3200) cout << s << endl;
  else cout << "red" << endl;
}

int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Measured memory_bytes: 256
import numpy as np
L,R = (int(x) for x in input().split())

if R - L > 3000:
  print(0)
  exit()
  
x = np.arange(L,R+1,dtype=np.int64)
y = x[:,None] * x[None,:] % 2019
for i in range(len(x)):
  y[i,i] = 3000
answer = y.min()
print(answer)

Measured memory_bytes: 76128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> x(N);
    vector<int> y(N);
    vector<int> h(N);
    for(int k=0; k<N; k++) {
        cin >> x.at(k) >> y.at(k) >> h.at(k);
    }

    for(int i=0; i<=100; i++) {
        for(int j=0; j<=100; j++) {
            int max_height = INT32_MAX;
            vector<int> H;
            for(int k=0; k<N; k++) {
                if(h.at(k) != 0) {
                    H.push_back(h.at(k) + abs(i-x.at(k)) + abs(j-y.at(k)));
                } else {
                    max_height = min(max_height, h.at(k) + abs(i-x.at(k)) + abs(j-y.at(k)));
                }
            }
            if(*min_element(H.begin(), H.end()) == *max_element(H.begin(), H.end()) && H.at(0) <= max_height) {
                cout << i << " " << j << " " << H.at(0) << endl;
                return 0;
            }
        }
    }
    return 0;
}


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

int main() {
	
	int s1s2s3, s1, s2,s3;
	cin >> s1s2s3;
	s1=s1s2s3/100;
    s2=(s1s2s3-s1*100)/10;
  	s3=s1s2s3-s1*100-s2*10;
	cout << s1+s2+s3 << endl;
}

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

vector<int> v(200005);

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

    sort(v.rbegin(), v.rend());

    int ans = 0;
    for(int i=k;i<n;++i) ans += v[i];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define MAX 100006
using namespace std;


int UF[MAX],cou[MAX];

int search(int x){
    return UF[x] == x ? x: (UF[x] = search(UF[x]));
}

bool connected(int x, int y){
    return search(x) == search(y);
}

void connect(int x, int y){
    int dadX = search(x), dadY = search(y);
    if(dadX != dadY){
        UF[dadX] = dadY;
        cou[dadY] += cou[dadX];
    }
}

int main(){
    for(int i = 0; i < MAX;++i){
        UF[i] = i;
        cou[i] = 1;
    }
    int n,m,k;
    scanf(" %d %d %d",&n,&m,&k);
    vector<int> ans(n,0);
    vector<int> fr(n,0);
    vector<set<int>> enemies(n);
    while(m--){
        int a,b;
        scanf(" %d %d",&a,&b);
        --a,--b;
        connect(a,b);
        ++fr[a];
        ++fr[b];
    }
    while(k--){
        int a,b;
        scanf(" %d %d",&a,&b);
        --a,--b;
        enemies[a].insert(b);
        enemies[b].insert(a);
    }
    for(int i = 0; i < n;++i){
        ans[i] += cou[search(i)];
        for(auto ve:enemies[i]){
            if(connected(i,ve)){
                --ans[i];
                --ans[ve];
            }
            enemies[ve].erase(i);
        }
        if(i == 0) printf("%d",ans[i]-fr[i]-1);
        else printf(" %d",ans[i]-fr[i]-1);
    }
    puts("");
    return 0;
}


Measured memory_bytes: 17024
package main

import (
	"fmt"
)

func main() {

	var N int
	fmt.Scanf("%d\n", &N)

	var a bool = true
	for i := 0; i < N; i ++ {
		var A int
		fmt.Scanf("%d", &A)
		if A % 2 != 0 {
			continue
		}
		if A % 3 != 0 && A % 5  != 0 {
			a = false
			break
		}
	}
	if a {
		fmt.Println("APPROVED")
	} else {
		fmt.Println("DENIED")
	}
	
}

Measured memory_bytes: 512
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


//abc163D
int main(void) {
  //int n, k, i, a, cou=0, tmp;
  long long n, k, i, a, cou=0, tmp;
  long long mod=1000000007,sum=0;
  scanf(" %lld %lld", &n,&k);


  for(i=k; i <=n+1; i++){
    sum=(sum+(n+1-i)*i+1)%mod;
  }

  printf("%lld",sum);
  return 0;
}

Measured memory_bytes: 1736
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  int N;
  cin >> N;
  vector<int> L;
  rep(i, N) {
    int l;
    cin >> l;
    L.push_back(l);
  }

  int max_l = *max_element(L.begin(), L.end());

  int sum = 0;
  rep(i, N) { sum += L[i]; }
  sum -= max_l;
  if (max_l < sum) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <functional>
#include <string.h>

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


void solve()
{
	string S;
	cin >> S;
	int size = S.size();
	int a1 = 0;   // 0101
	int a2 = 0;   // 1010
	for (int i = 0; i < size; ++i)
	{
		if (i % 2 == 0)
		{
			if (S[i] == '0')
			{
				++a2;
			}
			if (S[i] == '1')
			{
				++a1;
			}
		}
		else
		{
			if (S[i] == '0')
			{
				++a1;
			}
			if (S[i] == '1')
			{
				++a2;
			}
		}
	}
	cout << min(a1, a2) << endl;
}

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int a[111111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1); reverse(a+1,a+n+1);
	int cur=1;
	for(int i=1;i<=n;i++)
	{
		if(a[i]>=i)
		{
			cur=i;
		}
		else break;
	}
	int res=0;
	int cntr=0;
	for(int i = cur + 1; i <= n; i++)
	{
		if(a[i]==cur)
		{
			cntr++;
		}
		else break;
	}
	if(cntr&1) res=1;
	if((a[cur]-cur)&1) res=1;
	cout<<(res?"First":"Second")<<'\n';
}


Measured memory_bytes: 768
if __name__ == '__main__':
	h,w = map(int, input().split())
	while h+w!=0:
		for i in range(h):
			if i == 0 or i == h-1:
				print("#"*w)
			else:
				print("#"+"."*(w-2)+"#")
		print()
		h,w = map(int, input().split())


Measured memory_bytes: 5608
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INF = 1e17+7;
const long long MOD = 1e9+7;
const double PI=acos(-1);

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> memo(101010,0);
	for(int i=0;i<n;i++){
		int temp;
		cin >> temp;
		memo[temp]++;
	}
	int ans=-1;
	for(int i=0;i<memo.size()-3;i++){
		int cnt=0;
		for(int j=i;j<=i+2;j++){
			cnt+=memo[j];
		}
		ans=max(ans,cnt);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
int main() {
	long n,k,i,j,ans=0;
	cin>>n>>k;
	vector<long> a(n), path;
	vector<bool>visited(n,false);
	for (i=0;i<n;++i)
		cin>>a[i];
	path.push_back(0);
	visited[0]=true;
	for (i=1;i<=k;++i)
	{
		ans=a[ans]-1;
		if (visited[ans])
			break;
		path.push_back(ans);
		visited[ans]=true;
	}
	int l=path.size();
	for (j=0;j<l;++j)
		if (path[j]==ans)
			break;
	l-=j;
	k-=i;
	k%=l;
	ans=path[j+k]+1;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 6960
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

const double PI = 3.1415926535;

signed main(){
    double x = 0, y = 0;
    int d, a, next = 90;
    while(1){
        char c;
        cin >> d >> c >> a;
        if(d == 0 && a == 0) break;
        x += (double)d * cos(next * PI / 180.0);
        y += (double)d * sin(next * PI / 180.0);
        next -= a;
    }
    cout << (int)x << endl;
    cout << (int)y << endl;
}

Measured memory_bytes: 3396
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

int main()
{
    vector<int> v(3);
    for (int i = 0; i < 3; i++)
    {
        cin >> v[i];
    }

    sort(v.begin(), v.end());
    int ans = v[0] + v[1];

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

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
int dyy[]={0,-1,0,1};
int dxx[]={-1,0,1,0};
vector<ll> p,c;
int main(){
    ll d,g;
    cin>>d>>g;
    p.resize(d);
    c.resize(d);
    rep(i,0,d)cin>>p[i]>>c[i];
    
    ll ans=1<<29;
    rep(bit,0,(1<<d)){
        ll sum=0;
        ll num=0;
        rep(i,0,d){
            if(bit&(1<<i))sum+=c[i]+p[i]*100*(i+1),
            num+=p[i];
        }
        if(sum>=g)ans=min(ans,num);
        else{
            for(int i=d-1;i>=0;--i){
                if(bit&(1<<i))continue;
                rep(j,0,p[i]){
                    if(sum>=g)break;
                    sum+=100*(i+1);
                    ++num;
                }
            }
            ans=min(ans,num);
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

p = s.count("E")
q = 0
ans = float("Inf")

for i in range(n):
    if s[i] == "E":
        p -= 1
        
    c = p + q
    ans = min(ans, c)
    
    if s[i] == "W":
        q += 1
print(ans)

Measured memory_bytes: 11552
n, m = map(int, input().split())
arr = [map(int, input().split()) for _ in range(m)]
d = {i:0 for i in range(1, n+1)}
for a, b in arr:
    d[a] += 1
    d[b] += 1
for v in sorted(d.items(), key=lambda x: x[0]):
    print(v[1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define endl "\n" 
#define pi acos(-1)
#define ll long long 
using namespace std;
ll power(ll a,ll b){
	ll k=1;
	for(int i=0;i<b;i++)
		k*=a;
	return k;
}
void solve();
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	int q=1;//cin>>q;
	while(q--){
		solve();
	}
}
void solve(){
	int x,k;
	for(int i=1;i<=5;i++){
		cin>>x;
		if(x==0)
			k=i;
	}
	cout<<k<<endl;
}

Measured memory_bytes: 3660
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

count = 0

for i in range(N):
    count += B[i]

    if  i >= 1 and A[i] == A[i - 1] + 1:
        count += C[A[i - 1] - 1]

print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int ans, n;
int a[110];
int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= n; ++i)
        for (int j = i + 1; j <= n; ++j)
            ans += a[i] * a[j];
    cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>

using namespace std;
int n,m,cnt,ans;
char s[333333];
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=2;i<=n;i++)
	{
		if(s[i]=='E')cnt++;
	}
	ans=cnt;
	for(int i=2;i<=n;i++)
	{
		if(s[i]=='E')cnt--;
		if(s[i-1]=='W') cnt++;
		ans=min(ans,cnt);
	}
	printf("%d\n",ans);
	return 0;
}

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

int main()
{
  string s[3];
  cin >> s[0] >> s[1] >> s[2];
  int nn = 0;
  while(1){
    if(s[nn].size() == 0){
      char ans = 'A' + nn;
      cout << ans << endl;
      break;
    }
    char nc = s[nn][0];
    s[nn].erase(s[nn].begin());
    nn = nc - 'a';
  }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.math.BigInteger;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Kenji
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC109C solver = new ABC109C();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC109C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int X = in.nextInt();
            long[] arr = new long[N + 1];
            for (int i = 0; i < N; i++) {
                arr[i] = in.nextLong();
            }
            arr[N] = X;
            Arrays.sort(arr);
            long ans = 0;
            for (int i = 0; i < N; i++) {
                long a = arr[i];
                long b = arr[i + 1];
                if (i == 0) {
                    ans = b - a;
                } else {
                    ans = gcd(ans, b - a);
                }
            }
            out.println(ans);
        }

        public static long gcd(long m, long n) {
            return BigInteger.valueOf(m).gcd(BigInteger.valueOf(n)).longValue();
        }

    }
}



Measured memory_bytes: 60296
"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/),
    cid = 0;

// number一個取得
// eslint-disable-next-line no-unused-vars
const next = () => +cin[cid++];

// 文字列一個取得
// eslint-disable-next-line no-unused-vars
const nextstr = () => cin[cid++];

// BigInteger一個取得
// eslint-disable-next-line no-unused-vars
const nextbig = () => BigInt(cin[cid++]);

// 長さnの配列として取得。aは文字列フラグ
// eslint-disable-next-line no-unused-vars
const nexts = (n, a) =>
    a ? cin.slice(cid, (cid += n)) : cin.slice(cid, (cid += n)).map((a) => +a);

// w個ずつを組にして長さhの配列。aは文字列フラグ。
// eslint-disable-next-line no-unused-vars
const nextm = (h, w, a) => {
    var r = [],
        i = 0;
    if (a) for (; i < h; i++) r.push(cin.slice(cid, (cid += w)));
    else for (; i < h; i++) r.push(cin.slice(cid, (cid += w)).map((a) => +a));
    return r;
};
// 多次元配列。v,a1,a2,a3 なら、3次元。[[値vで長さa3の配列]をa2個並べた配列]をa1個並べた配列。
// eslint-disable-next-line no-unused-vars
const xArray = (...args) => {
    var a = args,
        l = a.length,
        r = "Array(a[" + --l + "]).fill().map(x=>{return " + a[0] + ";})";
    while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")";
    return eval(r);
};

console.log(main().toString());

function main() {
    let x = nexts(5);
    for (let i = 0; i < 5; i++) {
        if (x[i] == 0) return i + 1;
    }
}


Measured memory_bytes: 29624
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int count = 0;
		for (int i = 0; i < s.length() - 1; i++) {
			if (s.charAt(i) != s.charAt(i + 1)) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 24124
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  s[0]++;
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

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

  cout << a-b+1 <<endl;
  
}


Measured memory_bytes: 256
import Control.Monad
allcards = [s++" "++show n|s<-["S","H","C","D"], n<-[1..13]]
main = do
  n <- readLn :: IO Int
  cards <- return . lines =<< getContents
  forM_ [0..51] $ \i -> do
    if not $ elem (allcards !! i) cards then putStrLn $ allcards!!i
    else return ()


Measured memory_bytes: 3716
import java.util.Scanner;
import java.util.HashSet;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        String s = sc.nextLine();
        int[] ans= new int[n-1];
        HashSet<Character> st = new HashSet<Character>();

        sc.close();
        for(int i=1; i<s.length()-1; i++) {
            st.clear();
            ans[i-1] = 0;
            for(int j=0; j<i; j++) {
                for(int k=i; k<s.length(); k++) {
                    if(!(st.contains(s.charAt(j))) && s.charAt(j)==s.charAt(k)) {
                        ans[i-1]++;
                        st.add(s.charAt(j));
                        break;
                    }
                }
            }
        }
        int max = 0;
        for(int i: ans) {
            if(i>max) max=i;
        }
        System.out.println(max);
    }
}

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


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N; cin >> N;
  vector<double> x(N), y(N);
  for (int i = 0; i < N; i++) cin >> x.at(i) >> y.at(i);
  double t = 0.0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < i; j++) {
      double xd = x.at(i) - x.at(j);
      double yd = y.at(i) - y.at(j);
      double d = sqrt(xd*xd + yd*yd);
      t += d;
    }
  }
  cout << t * 2 / N << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>

using namespace std;

int n, a, x[51];
unsigned long long dp[51][2501];

int main() {
  int i, j, k;
  while (~scanf("%d%d", &n, &a)) {
    for (i = 1; i <= n; ++i) scanf("%d", x+i);
    memset(dp, 0, sizeof dp);
    dp[0][0] = 1;

    for (k = 1; k <= n; ++k)
      for (i = k-1; i >= 0; --i)
        for (j = 0; j <= i*50; ++j)
          dp[i+1][j+x[k]] += dp[i][j];

    unsigned long long ans = 0;
    for (i = 1; i <= n; ++i) ans += dp[i][a*i];
    cout << ans << "\n";
  }
}


Measured memory_bytes: 1280
function Main(input) {
  var args = input.split("\n");
  var n = parseInt(args[0], 10);
  var times = args[1].split(" ");
  var m = parseInt(args[2], 10);
  var drink_set = [];
  for(var i = 3; i < args.length; i++) {
    drink_set.push(args[i].split(" "));
  }

  for(var i = 0; i < m; i++) {
    var times_tmp = times.concat();
    times_tmp[parseInt(drink_set[i][0], 10)-1] = parseInt(drink_set[i][1], 10);
    var sum = 0;
    for(var j = 0; j < n; j++) {
      sum += parseInt(times_tmp[j], 10);
    }
    console.log(sum);
  }

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 6904
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n;
    cin >> n;
    cout << (1<<(31-__builtin_clz(n))) << endl;
}


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

int main(){
    int N,K;
    int tmp;
    cin >> N >> K;
    int l[51];
    for(int i=0;i<N;i++){
        cin >> l[i];
    }
    int ans=0;
    for(int k=0;k<K;k++){
        for(int s=k+1;s<N;s++){
            if(l[k]<=l[s]) {
            tmp = l[s];
            l[s] = l[k];
            l[k] = tmp;
            }
        }
    ans+=l[k];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// skip until line 65
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)
#define MIN(V, T) V=min(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
struct Vec;
//set<int, Comparator> S;

// solution below
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
ll mod=1000*1000*1000+7;

int main() {
    cout.precision(10);
    cout<<fixed;
    int A,B,C,D;
    cin >> A >> B>>C>>D;
    while(true) {
        C-=B;
        if (C<=0) {
            cout<<"Yes"<<endl;
           exit(0);
        }
        A-=D;
        if (A<=0) {
            cout<<"No"<<endl;
            exit(0);
        }

    }
}

struct Vec{
    double v[2];
    string to_s(){
        return "("+to_string(v[0])+","+to_string(v[1])+")";
    }
    double& operator[](int t){
        return v[t];
    }
    Vec operator+(Vec t) {
        return {v[0]+t[0],v[1]+t[1]};
    }
    Vec& operator+=(Vec t) {
        v[0]+=t[0];v[1]+=t[1];
        return *this;
    }
    Vec operator-(Vec t) {
        return {v[0]-t[0],v[1]-t[1]};
    }
    Vec& operator-=(Vec t) {
        v[0]-=t[0];v[1]-=t[1];
        return *this;
    }
    Vec operator*(double t) {
        return {v[0]*t,v[1]*t};
    }
    Vec& operator*=(double t) {
        v[0]*=t;v[1]*=t;
        return *this;
    }
    double operator*(Vec t) {
        return v[0]*t[0]+v[1]*t[1];
    }
    Vec operator-(){
        return {-v[0],-v[1]};
    }
    static Vec Z;
};
Vec Vec::Z={0,0};


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(){
 int w,h,n;
 cin >> w >> h >> n;
 int sx = 0, sy = 0;
 for(int i = 0;i < n;i++){
  int x, y, a;
  cin >> x >> y >> a;
  /*
  ai=1 のときは長方形の x<xi をみたす領域
  ai=2 のときは長方形の x>xi をみたす領域
  ai=3 のときは長方形の y<yi をみたす領域
  ai=4 のときは長方形の y>yi をみたす領域
  */
  if(a == 1){
   sx = max(sx, x);
  }else
  if(a == 2){
   w = min(w, x);
  }else
  if(a == 3){
   sy = max(sy, y);
  }else
  if(a == 4){
   h = min(h, y);
  }
 }
 if(w-sx<=0)cout << 0 << endl;else
 if(h-sy<=0)cout << 0 << endl;else
 cout << (w - sx) * (h - sy) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int main(){
    string s,t;
    cin>>s>>t;
    s+=s;
    for(int i=0;i<t.length();i++){
        bool f=true;
        for(int j=i;j<i+t.length();j++){
            if(t[j-i]==s[j]);
            else f=false;
        }
        if(f){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    As = list(map(int, input().split()))
    fours = 0
    evens = 0
    odds = 0
    for A in As:
        if A % 4 == 0:
            fours += 1
        elif A % 2 == 0:
            evens += 1
        else:
            odds += 1

    if fours+(evens)//2 >= n//2:
        ans = 'Yes'
    else:
        ans = 'No'
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 20080
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
const int INF = 10e9 + 5;
int main()
{
	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(3));
	vector<vector<int>> dp(n, vector<int>(3,0));
	for (int i = 0; i < n; i++) cin >> a[i][0] >> a[i][1] >> a[i][2];
	for (int i = 0; i < n-1; i++) {
		for (int j = 0; j < 3; j++) {
			
			dp[i + 1][j] = max(dp[i][(j + 1) % 3] + a[i][(j + 1) % 3], dp[i][(j + 2) % 3] + a[i][(j + 2) % 3]);
			
		}
	}
	cout << max(dp[n - 1][0]+a[n-1][0], max(dp[n - 1][1]+a[n-1][1], dp[n - 1][2]+a[n-1][2]));
}


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

int main(){
	string str;
	cin >> str;
	int length = str.length();
	if(length < 2){
		cout << "-1 -1" << endl;
		return 0;
	}else{
		for(int i=0;i<length-1;i++){
			if(str[i] == str[i+1]){
				cout << i+1 << " " << i+2 << endl;
				return 0;
			}
			else if(i+2 < length && str[i] == str[i+2]){
				cout << i+1 << " "<< i+3 <<endl;
				return 0;
			}
		}
	}
	cout << "-1 -1" << endl;
}

int prev(){
	string str;
	cin >> str;
	long** cnt=(long**)malloc(sizeof(long*)*100000);
	for(int i=0;i<100000;i++){
		cnt[i] = (long*)malloc(sizeof(long)*26);
		for(int j=0;j<26;j++){
			cnt[i][j] = 0;
		}
	}
	// cout << "OK" << endl;
	long long total_cnt[26]={};
	char res_word='0';
	int start_index,fin_index;
	int length=str.length();
	long thr;

	if(length < 2){
		cout << "-1 -1" <<endl;
	}else{
		for(int i=0;i<length;i++){
			total_cnt[str[i]-'a']++;
			for(int a=0;a<26;a++){
				cnt[i][a]=total_cnt[a];
			}
		}
		// cout << "OK" << endl;
		for(int a=0;a<26;a++){
			for(int i=length-1;i>=1;i--){
				thr = (i+1)/2;
				if(cnt[i][a] > thr){
					cout << 1 << " " << i+1 << endl;
					return 0;
				}
			}
		}
		// cout << "OK" << endl;
		for(int a=0;a<26;a++){
			for(int i=length-1;i>=1;i--){
				for(int j=0;j<=i-1;j++){
					thr = (i-j+1)/2;
					if(cnt[i][a]-cnt[j][a]>thr){
						// cout << (char)('a'+a)<<endl;
						// cout << thr << endl;
						cout << j+1 << " " << i+1 << endl;
						return 0;
					}
				}
			}
		}
		cout << "-1 -1" << endl;
	}
}

Measured memory_bytes: 512
#include<stdio.h>

typedef struct{
  int a;
  int b;
  int c;
}order;

char check[300];

int main(){
  int a,b,c,i,n,oa,j,ob,oc,sf,on;
  order od[1000];
  do{
    scanf("%d %d %d",&a,&b,&c);
    if(!a&&!b&&!c) break;
    scanf("%d",&n);
    for(i=0,on=0;i<n;i++){
      scanf("%d %d %d %d",&oa,&ob,&oc,&sf);
      if(sf){
	check[oa-1]=1;
	check[ob-1]=1;
	check[oc-1]=1;
      }else{
	od[on].a=oa-1;
	od[on].b=ob-1;
	od[on++].c=oc-1;
      }
      for(j=0;j<on;j++){
	if(check[od[j].a]==1&&check[od[j].b]==1){
	  check[od[j].c]=2;
	}else if(check[od[j].a]==1&&check[od[j].c]==1){
	  check[od[j].b]=2;
	}else if(check[od[j].b]==1&&check[od[j].c]==1){
	  check[od[j].a]=2;
	}
      }
    }
    n=a+b+c;
    for(i=0;i<n;i++){
      printf("%d\n",check[i]==0?2:check[i]==1?1:0);
    }
    for(i=0;i<n;i++) check[i]=0;
  }while(1);
  return 0;
}
      

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>

const long long INF = 1LL<<60;
const int inf = 1 << 30;
const int mod = 1e9+7;


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  string s;
  cin >> s;
  int n = s.size();
  reverse(all(s)); 

  int x = 1;
  int t = 0;
  vector<int> cnts(2019);
  cnts[0]  = 1;
  ll ans = 0;
  rep(i, 0, n){
    int num = (s[i] - '0') * x + t;
    num %= 2019;
    t = num;
    cnts[num]++;
    x = (x * 10) % 2019;
  }

  for (int cnt: cnts){
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
}


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

int main() { // claudio van
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int h, n; cin >> h >> n;
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    int a; cin >> a;
    sum += a;
  }
  if (sum >= h) {
    cout << "Yes" << "\n";
  } else {
    cout << "No" << "\n";
  }
  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;

int main(void) {
	int h, w;
	cin >> h >> w;
	
	vector<string> a(h);
	for(int i = 0; i < h; ++i) {
		cin >> a[i];
	}
	
	vector<bool> row(h, false);
	vector<bool> colum(w, false);
	for(int i = 0; i < h; ++i) {
		for(int j = 0; j < w; ++j) {
			if( a[i][j] == '#' ) {
				row[i] = true;
				colum[j] = true;
			}
		}
	}
	
	for(int i = 0; i < h; ++i) {
		if( row[i] ) {
			for(int j = 0; j < w; ++j) {
				if( colum[j] ) cout << a[i][j];
			}
			
			cout << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007ll
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    n++;
    ll i;
    ll ans(0);
    xrep(i, k, n + 1) {
        ll a = ((n - i + 1) + n) * i / 2 ;
        ll b = (1 + i) * i / 2;
        // cout << i << ' ' << a << ' ' << b << endl;
        ans += a - b + 1;
        ans %= mod;
    }
    cout << ans << endl;
}


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

using namespace::std;

int main(){
    long long a,b,c,d,out;
    cin >> a >> b >> c >> d;
    out = a*c;
    out = max(out,a*d);
    out = max(out,b*c);
    out = max(out,b*d);
    cout << out;
}


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

bool cmp(string &s, string &t)
{
  if (s.size()!=t.size())
    return s.size()>t.size();
  return s>t;
}

int main()
{
  string s,t; cin>>s>>t;
  if (s==t){
    cout<<"EQUAL"<<endl;
    return 0;
  }
  if (cmp(s,t)) cout<<"GREATER"<<endl;
  else cout<<"LESS"<<endl;
  return 0;
}


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

int main(){
    int h, w, d;
    cin >> h >> w >> d;
    vector<vector<int>> A(h, vector<int>(w));
    for (auto &a: A)
        copy_n(istream_iterator<int>(cin), w, a.begin());
    vector<array<int, 2>> P(h * w + 1);
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            P[A[i][j]] = {i, j};
        }
    }

    vector<int> S(h * w + 1);
    for (int i = 1; i <= d; i++){
        int x = P[i][0];
        int y = P[i][1];
        int s = 0;
        for (int j = i + d; j <= h * w; j += d){
            auto nx = P[j][0];
            auto ny = P[j][1];
            s += abs(nx - x) + abs(ny - y);
            S[j] = s;
            x = nx; y = ny;
        }
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        cout << S[r] - S[l] << endl;
    }
}

Measured memory_bytes: 2560
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
using namespace std;
// clang-format on

main {
  int n;
  cin >> n;
  vi a(n);
  cin >> a;
  int mini = a.front(), maxDiff = -INF;
  for_each(a.begin() + 1, a.end(), [&](int x) {
    cmax(maxDiff, x - mini);
    cmin(mini, x);
  });
  cout << maxDiff << endl;
}

Measured memory_bytes: 4376
#include<bits/stdc++.h>
using namespace std;
int i,j,n,m,ans,a[3][105];
int main(){
    cin>>n;
    for(i=1;i<=2;i++)
        for(j=1;j<=n;j++)
            cin>>m,a[i][j]=a[i][j-1]+m;
    for(i=1;i<=n;i++)
        ans=max(ans,a[1][i]+a[2][n]-a[2][i-1]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
H, W, d = map(int, input().split())
if d%2 == 1:
	for i in range(H):
		print(*["R" if (i+j)%2 == 0 else "Y" for j in range(W)], sep="")
else:
	for i in range(H):
		ans = ""
		for j in range(W):
			if (i+j) % (2*d) < d and (i-j) % (2*d) < d:
				ans += "R"
			elif (i+j) % (2*d) >= d and (i-j) % (2*d) < d:
				ans += "Y"
			elif (i+j) % (2*d) < d and (i-j) % (2*d) >= d:
				ans += "G"
			else:
				ans += "B"
		print(ans)

Measured memory_bytes: 4724
#include <iostream>
using namespace std;
int main() {
    int odd[200];
    int n = 0;
    int count = 0;
    int yakucount =0;
    int ans = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        if (i == 1){
            odd[count] = i;
            count++;
        } else if (i % 2 != 0){
            odd[count] = i;
            count++;
        }
    }
    for (int k = 0; k < count; ++k) {
        for (int i = 1; i <= odd[k]; ++i) {
            if (odd[k] % i == 0){
                yakucount++;
            }
            if (yakucount == 8){
                ans++;
            }
        }
        yakucount = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int a,b;
int main(){
	cin>>a>>b;
	if(a>=13)
		cout<<b;
	else if(a>=6)
		cout<<b/2;
	else
		cout<<0;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,t;
  double a;
  cin >> n >> t >> a;
  double c[n];
  a=(t-a)*500/3;
  int b=99999999,e;
  for(int i=0;i<n;i++){
    cin >> c[i];
    if(abs(c[i]-a)<b){
      b=abs(c[i]-a);
      e=i+1;
    }
  }
  cout << e;
}


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    string S;
    cin >> S;
    ll s = 0;
    ll a=0;
    REP(i, S.length())
    {
        if (S[i] == 'A')
        {
            a++;
            continue;
        }
        if (S[i] == 'B')
        {
            if (i + 1 < S.length() && S[i + 1] == 'C')
            {
                s += a;
                i++;
                continue;
            }
        }
        a = 0;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 640