akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T1, class T2>bool chmax(T1& a, const T2& b) { return a < b ? a = b, 1 : 0; }
template<class T1, class T2>bool chmin(T1& a, const T2& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i, N) cin >> H[i];

    bool ans = true;
    for (int i = N - 2; i >= 0; --i) {
        if (H[i] - H[i + 1] > 1) {
            ans = false;
        }
        else if (H[i] == H[i + 1] + 1) {
            H[i]--;
        }
        else {

        }
    }

    write(ans ? "Yes" : "No");
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, y; cin >> x >> y;
  if(x == 2 || y == 2){
    cout << "No" << endl;
  }else{
    if((x == 4 || x == 6 || x == 9 || x == 12) && (y == 4 || y == 6 || y == 9 || y == 12)){
      cout << "Yes" << endl;
    }else if((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 3552
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}
	
	final long MOD=(long)1e9+7;

	void run() {
		FastScanner sc=new FastScanner();
		int N=sc.nextInt();
		long D=sc.nextLong();
		int ans=0;
		for (int i=0;i<N;++i) {
			long x=sc.nextLong();
			long y=sc.nextLong();
			if (x*x+y*y<=D*D) ++ans;
		}
		System.out.println(ans);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
	
	
	class FastScanner {
	    private final InputStream in = System.in;
	    private final byte[] buffer = new byte[1024];
	    private int ptr = 0;
	    private int buflen = 0;
	    private boolean hasNextByte() {
	        if (ptr < buflen) {
	            return true;
	        }else{
	            ptr = 0;
	            try {
	                buflen = in.read(buffer);
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            if (buflen <= 0) {
	                return false;
	            }
	        }
	        return true;
	    }
	    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	    private boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
	    public String next() {
	        if (!hasNext()) throw new NoSuchElementException();
	        StringBuilder sb = new StringBuilder();
	        int b = readByte();
	        while(isPrintableChar(b)) {
	            sb.appendCodePoint(b);
	            b = readByte();
	        }
	        return sb.toString();
	    }
	    public long nextLong() {
	        if (!hasNext()) throw new NoSuchElementException();
	        long n = 0;
	        boolean minus = false;
	        int b = readByte();
	        if (b == '-') {
	            minus = true;
	            b = readByte();
	        }
	        if (b < '0' || '9' < b) {
	            throw new NumberFormatException();
	        }
	        while(true){
	            if ('0' <= b && b <= '9') {
	                n *= 10;
	                n += b - '0';
	            }else if(b == -1 || !isPrintableChar(b)){
	                return minus ? -n : n;
	            }else{
	                throw new NumberFormatException();
	            }
	            b = readByte();
	        }
	    }
	    public int nextInt() {
	    	return (int)nextLong();
	    }
	}
}



Measured memory_bytes: 37024
#include<bits/stdc++.h>
using namespace std;
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define pa pair<int,int>
#define mod 998244353
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define cl(x) memset(x,0,sizeof x)
#ifdef Devil_Gary
#define bug(x) cout<<(#x)<<" "<<(x)<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define bug(x)
#define debug(...)
#endif

const int INF = 0x7fffffff;
const int N=1e5+5;
/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int read(){
    int x=0,rev=0,ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')rev=1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    return rev?-x:x;
}

int main(){
#ifdef Devil_Gary
    freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
#endif
	ll x=read(),y=read(),z=read();
	int k=read();
	while(k--){
		if(y<=x) y*=2;
		else z*=2;
	}
	if(x<y&&y<z) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
vector<pair<char, int>> run_length_compress(string S)
{
    vector<pair<char, int>> res;
    int n = S.size(),cnt=1;
    for (int i = 0; i < n-1; i++)
    {
        if(S[i]==S[i+1])
        {
            cnt++;
        }
        else
        {
            res.push_back({S[i],cnt});
            cnt=1;
        }
        
    }
    res.push_back({S.back(),cnt});
    return res;
}
int main()
{
    string s;
    cin>>s;
    int n = s.size();
    auto com = run_length_compress(s);
    int cnt = 0;
    string ans="";
    for (size_t i = 0; i < n;i++)
    {
//        if((i == 0 and s[i] == 'R' and s[i+1] == 'L') or (i == n-1 and s[i-1] != s[i]) or (i != 0 and i != n-1 and (s[i-1] != s[i] or s[i] != s[i+1])))
        if(s[i] == 'R' and s[i+1] == 'L')
        {
                ans += to_string((com[cnt].second+1)/2 + (com[cnt+1].second)/2) + " ";
                ans += to_string((com[cnt].second)/2 + (com[cnt+1].second+1)/2) + " ";
                cnt+=2; 
                i++;                   
        }
        else
        ans += to_string(0) + " ";
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4636
# encoding:utf-8

while True:
	a, op, b = raw_input().split()
	if op == "?":
		break
	a, b = map(int, (a,b))
	if op == "+":
		print(a+b)
	elif op == "-":
		print(a-b)
	elif op == "*":
		print(a*b)
	else:
		print(a/b)

Measured memory_bytes: 6432
import java.awt.Point;
import java.util.*;
public class Main {

        public static int [] t ={0,1,2,3,5,7,8,9};
        public static void main(String[] args) throws java.io.IOException{
            Scanner scan = new Scanner(System.in);
            while(true){
                int n = scan.nextInt();
                if(n==0)break;
                Point [] p =new Point[n];
                for(int i=0;i<n;i++){
                    p[i] = new Point(scan.nextInt(),scan.nextInt());
                }
                Arrays.sort(p,new DataComparator());
                
                long sum=0;
                boolean flag = true;
                for(int i=0;i<n;i++){
                    if(sum+p[i].x<=p[i].y){
                        sum+=p[i].x;
                    }
                    else flag=false;
                    
                }
                System.out.println(flag?"Yes":"No");
                
            }
        }
        
}
 class DataComparator implements java.util.Comparator<Point>{
    public int compare(Point o1, Point o2) {
        Point p1 = (Point) o1;
        Point p2 = (Point) o2;
        return p1.y - p2.y;
      }
     }

Measured memory_bytes: 12000
#include<iostream>
#include<map>
#include<algorithm>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <vector>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>

using namespace std;

int main() {
	int n; cin >> n;
	int a[n];
	int ans[100000 + 2];
	memset(ans, 0, sizeof(ans));

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] != 0) {
			ans[a[i]] += 1;
			ans[a[i] - 1] += 1;
			ans[a[i] + 1] += 1;
		}
		else {
			ans[a[i]] += 1;
			ans[a[i] + 1] += 1;
		}
	}

	int A = 0;

	for (int i = 0; i < 100000 + 2; i++) {
		A = max(A, ans[i]);
	}

	cout << A << endl;


}

Measured memory_bytes: 1024
from collections import deque
n = int(input())
a = list(map(int, input().split()))

b = deque()

for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])

if n % 2 == 1:
    b.reverse()

print(" ".join(map(str, b)))

Measured memory_bytes: 35976
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MAXN=1e5;

priority_queue<ll> pq;
ll x,y,a,b,c,ans;
ll p[MAXN+5],q[MAXN+5],r[MAXN+5];

int main(){
    cin>>x>>y>>a>>b>>c;
    for(int i=0; i<a; ++i){
        cin>>p[i];
    }
    for(int i=0; i<b; ++i){
        cin>>q[i];
    }
    for(int i=0; i<c; ++i){
        cin>>r[i];
    }
    sort(p,p+a);
    sort(q,q+b);
    sort(r,r+c);
    for(int i=0; i<x; ++i){
        ans+=p[a-1-i];
        pq.push(-p[a-1-i]);
    }
    for(int i=0; i<y; ++i){
        ans+=q[b-1-i];
        pq.push(-q[b-1-i]);
    }
    for(int i=0; !pq.empty() && i<c; ++i){
        if(pq.top()+r[c-1-i]>0){
            ans+=pq.top()+r[c-1-i];
            pq.pop();
        }
        else break;
    }
    cout<<ans;
    return 0;
}


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

using namespace std;

int n, d, x, a[102], ans;
int main()
{
	scanf("%d%d%d", &n, &d, &x);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	ans = x;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= d; j += a[i]) ans++;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<vector>
#include<iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>a(N);
  int i,j,k,sum;
  for(i=0;i<N;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  j=k=0;
  for(i=N-1;i>=0;i-=2){
    j+=a[i];
  }
  
  for(i=N-2;i>=0;i-=2){
    k+=a[i];
  }
  cout<<j-k<<endl;
  return 0;
}


Measured memory_bytes: 256
//2019.12.16
//s1270188 momoka murakami
//alds1_04b Binary Search

#include<stdio.h>
#include<stdlib.h>

int main(){
  int *data, num;
  int s_num, cnt=0, search, left, mid, right;
  int i;


  //input
  scanf("%d",&num);
  data=(int *)malloc(sizeof(int)*num);
  for(i=0;i<num;i++) scanf("%d",&data[i]);


  //search
  scanf("%d",&s_num);
  for(i=0;i<s_num;i++){
    scanf("%d",&search);
    
    left=0;
    right=num;
    while(left<right){
      mid=(left+right)/2;

      if(search==data[mid]){
	cnt++;
	break;
      }
      
      if(search>data[mid]) left=mid+1;
      else right=mid;
    }

    
  }
  

  
  //output cnt
  printf("%d\n",cnt);
  

  free(data);
  return 0;
}



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

using namespace std;

typedef long long 		ll;
typedef vector<ll> 		vll;
typedef pair<ll,ll> 	pll;
typedef vector<pll> 	vpll;
typedef vector<int> 	vi;
typedef pair<int,int> 	pii;
typedef vector<pii> 	vpii;

#define fi				first
#define se 				second
#define pb 				push_back
#define mp 				make_pair
#define all(v)			v.begin(),v.end()
#define sz(v)			s.size()
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define per(i,a,b) 		for(int i=a;i>=b;i--)
#define fill(a,v)		memset(a,v,sizeof(a))
#define tc				int T;cin>>T;while(T--)
#define nl				printf("\n")
#define aya				printf("yaha aya\n")
#define debug(x,y)		printf("%d %d\n",x,y)
#define fast_io			ios_base::sync_with_stdio(false);cin.tie(NULL);
#define grt				greater<int>()

const int mod = 1e9+7;
const int mod2= 1e9+9;

inline int pow_(ll a, int n, int p=mod){
	int r=1;while(n){if(n&1)r=r*a%p;n>>=1;a=a*a%p;}return r;
}
const int mx = 1e2+1;

ll w[mx],v[mx];
int N,W;
const int inf = 1e9+1;

int main(void)
{
	cin>>N>>W;
	int V = 1e5;
	ll dp[V+1];
	// fill(dp,inf);
	rep(i,0,V) dp[i] = inf;
	dp[0] = 0;
	rep(i,0,N-1){
		cin>>w[i]>>v[i];
		per(j,V,v[i]) dp[j] = min(dp[j],dp[j-v[i]] + w[i]);
	}
	int ans = 0;
	rep(i,1,V) if(dp[i] <= W) ans = i;
	cout<<ans<<"\n";
}

Measured memory_bytes: 1152
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

INF = 1 << 60

def main():
  N = read()
  rs = []; bs = []
  for i in range(N):
    a, b = reads()
    rs.append((a, b))
  for i in range(N):
    a, b = reads()
    bs.append((a, b))
  
  bi = bipmatch(2 * N)
  for i, j in product(range(N), range(N)):
    if rs[i][0] < bs[j][0] and rs[i][1] < bs[j][1]:
      bi.add_edge(i, N+j)
  ans = bi.count_match()
  print(ans)

class bipmatch:
  def __init__(self, N):
    self.size = N
    self.edges = [[] for _ in range(N)]

  def add_edge(self, u, v):
    self.edges[u].append(v)
    self.edges[v].append(u)

  def dfs(self, match, used, u):
    N = self.size; edges = self.edges
    used[u] = True
    for v in edges[u]:
      w = match[v]
      if w < 0 or not used[w] and self.dfs(match, used, w):
        match[u], match[v] = v, u
        return True
    return False

  def count_match(self):
    N = self.size; edges = self.edges
    res = 0; match = [-1] * N
    for v in range(N):
      if match[v] < 0:
        used = [0] * N
        if self.dfs(match, used, v):
          res += 1
    return res

main()

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

int main(){
    int numMinus = 0;
    int N;
    cin >> N;
    vector<long long> v(N);
    for(int i =0; i < N; i++){
        long long a;
        cin >> a;
        if(a<0){
            numMinus++;
            v[i] = -a;
        }
        else{
            v[i] = a;
        }
    }
    sort(v.begin(),v.end());
    long long ans = 0;
    for(int i =0; i < N; i++){
        ans+= v[i];
    }
    if(numMinus%2 == 1){
        ans -= 2*v[0];
    }
    cout << ans << endl;
}

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

int main() {
    int L, R, d;
    cin >> L >> R >>d;
    int ans = 0;
    for (int i = L; i <= R; i++)
    {
        if (i % d == 0)
        {
            ans++;
        }
        
    }
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3564
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

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

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

template <typename T>
bool uax(T& a, const T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T>
bool uin(T& a, const T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 30;
const int N = (int)3e5 + 7;
const int MAXN = (int)3e6 + 7;
const int MOD = (int)998244353;
const int INF = (int)1e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e17;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

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

void solve() {
	int n, m;
	cin >> n >> m;
	if (n % 2 == 1) {
		for (int i = 1; i <= m; i++)
			cout << i << ' ' << n - i + 1 << endl;
		return;
	}
	vector <int> diff;
	for (int i = 1; size(diff) != m; i++) {
		if (i % 2 == 1)
			diff.push_back(i);
		else
			diff.push_back(n - i);
	}
	sort(rall(diff));
	for (int i = 0; i < size(diff); i++) 
		cout << i + 1 << ' ' << i + 1 + diff[i] << endl;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

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

  int sum = accumulate(vl.begin() + 1, vl.end(), 0);
  if (vl.front() < sum) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
mod = 10**9+7
a = [1,1,2,3,5,8,13,21,34,55,1]
H,W,K = map(int,input().split())
dp = [[0]*W for i in range(H)]

if W == 1:
    print(1)
else:
    dp[0][0]=a[W-1]
    dp[0][1]=a[W-2]
    for i in range(H-1):
        for j in range(W):
            dp[i+1][j]=dp[i][j]
            dp[i+1][j]*=a[j]
            dp[i+1][j]*=a[W-j-1]
            if j > 0:
                dp[i+1][j]+=dp[i][j-1]*a[W-j-1]*a[j-1]
            if j < W-1:
                dp[i+1][j]+=dp[i][j+1]*a[W-j-2]*a[j]
            dp[i+1][j]%=mod
    print(dp[H-1][K-1])

Measured memory_bytes: 3064
INF = 10 ** 9

n, k = gets.chomp.split(" ").map(&:to_i)
candles = gets.chomp.split(" ").map(&:to_i)

if candles.include?(0)
  k -= 1
  candles.delete(0)
end

if k == 0
  puts 0
  exit
end

minus_candles = []
plus_candles = []

candles.each do |candle|
  if candle < 0
    minus_candles << candle.abs
  else
    plus_candles << candle
  end
end

minus_candles.reverse!

([k - minus_candles.length, 0].max).times do
  minus_candles << INF
end

([k - plus_candles.length, 0].max).times do
  plus_candles << INF
end

costs = []

minus_candles.each_with_index do |minus_candle, index|
  if k - index - 2 >= 0
    costs << minus_candle + plus_candles[k - index - 2] * 2
    costs << minus_candle * 2 + plus_candles[k - index - 2]
  end
end

costs << plus_candles[k - 1]
costs << minus_candles[k - 1]

puts costs.min

Measured memory_bytes: 12692
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
  int n,m;
  bool ans=1;
  cin >> n>> m;
  const ll inf=-100000000000000000;
  vector<ll> iti(n,inf);
  vector<vector<pair<int,int>>> g(n);
  rep(i,m){
    int a,b,c;
    cin >> a >> b >> c;
    a--;
    b--;
    g.at(a).push_back(make_pair(b,c));
    g.at(b).push_back(make_pair(a,-c));
  }
  rep(i,n){
    if(iti.at(i)!=inf)continue;
    if(!ans)break;
    iti.at(i)=0;
    stack<int> s;
    s.push(i);
    while(!s.empty()){
      auto t=s.top();
      s.pop();
      for(auto nt:g.at(t)){
        if(iti.at(nt.first)==inf){
          s.push(nt.first);
          iti.at(nt.first)=iti.at(t)+nt.second;
        }
        else if(iti.at(nt.first)!=iti.at(t)+nt.second){
          ans=0;
          break;
        }
      }
      if(!ans)break;
    }
  }
  if(ans)cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
        
    

Measured memory_bytes: 9728
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

int main()
{
	FAST;
	ll a, b;
	cin >> a >> b;
	cout << 6 - a - b;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right


def main():
    N = int(input())
    S = input()
    B = 0
    W = S.count('.')
    ans = B+W
    for i in range(N):
        if S[i] == '#':
            B += 1
        else:
            W -= 1
        ans = min(ans, B+W)
    print(ans)

if __name__ == "__main__":
    main()


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


int main(){
    int a,b,c=0,i,j,k,m,n,r,x,y,z;
    char s[15];
    scanf("%s",s);
    for(i=0;i<strlen(s);i++){
       if(s[i]=='x')c++;
    }
    if(c>7)printf("NO\n");
    else printf("YES\n");



    return 0;
}

Measured memory_bytes: 128
#include <iostream>

int main(){
  int A,B;
  std::cin>>A>>B;
  if(B<0){
    if((B-A)%2){
      std::cout<<"Positive"<<std::endl;
    }else{
      std::cout<<"Negative"<<std::endl;
    }
  }else if(A>0){
    std::cout<<"Positive"<<std::endl;
  }else{
    std::cout<<"Zero"<<std::endl;
  }
  return 0;
}


Measured memory_bytes: 764
li = list(input())
front = int(li[0]+li[1])
back = int(li[2]+li[3])

if front > 0 and front < 13:
    if back > 0 and back < 13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
        
else:
    if back > 0 and back < 13:
        print('YYMM')
    else:
        print('NA')

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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

const long long MOD = 1000000007;


void solve(long long N, std::string S) {
    int c[128] = {};
    long long ans = 1;
    for (auto x : S) {
        c[x]++;
    }
    for (int i = 0; i < 128; i++) {
        ans *= c[i] + 1;
        ans %= MOD;
    }
    cout << (ans - 1 + MOD) % MOD  << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n;
  cin >> n;
  if(n%10==9 || n/10==9) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int ans = 0;
		int count = 0;
		for(int i=0;i<n;i++) {
			if(s.substring(i,i+1).equals("I")) {
				count += 1;
			}else {
				count -= 1;
			}
			ans = Math.max(ans, count);
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 23252
#include <stdio.h>
int main(void){
  int W,a,b;
  int result;
  scanf("%d",&W);
  scanf("%d",&a);
  scanf("%d",&b);
  if(a>b){
    if(b+W>=a){
      result=0;
    }else{
      result=a-(b+W);
    }
  }else{
    if(a+W>=b){
      result=0;
    }else{
      result=b-(a+W);
    }
  }
  printf("%d\n",result);
  return 0;
}

Measured memory_bytes: 128
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

void solve() {
    cini(n);
    cinai(a,n);

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

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


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

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

  string ans;

  while(n>0){
    n--;
    char c = 'a' + n % 26;
    n /= 26;
    ans = c + ans;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string input;
	bool ccheck=false,fcheck=false;
	
	int i;
	cin>>input;
	for(i=0;i<input.length();i++)
	{
		if(input.at(i)=='C')
		{
			ccheck=true;
			break;
		}
	}
	for(;i<input.length();i++)
	{
		if(input.at(i)=='F')
		{
			fcheck=true;
			break;
		}
	}
	if(ccheck==true&&fcheck==true)cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

int main(){
    long long n,k;
    cin>>n>>k;
    int a[n],b[n];
    vector<pair<int,int>> v;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        v.push_back(make_pair(a[i],b[i]));
    }
    sort(v.begin(),v.end());
    long long cnt=0;
    for(auto i:v){
        cnt+=i.second;
        if(cnt>=k){
            cout<<i.first<<endl;
            return 0;
        }
    }




}

Measured memory_bytes: 1912
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    
    int a,b;
    cin>>a>>b;
    
    if(a>=13){
        cout<<b<<endl;
    }else if(6<=a && a<=12){
        cout<<b/2<<endl;
    }else if(a<=5){
        cout<<"0"<<endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int ans = 0;
        for (int n = 0; n <= 999; n++) {
            int n1 = n/100;
            int n2 = (n-n1*100)/10;
            int n3 = n%10;
            // n1
            int n1i = -1;
            for (int i = 0; i < N; i++) {
                if (S.charAt(i) == (char)('0' + n1)) {
                    n1i = i;
                    break;
                }
            }
            if (n1i == -1) {
                continue;
            }
            // n2
            int n2i = -1;
            for (int i = n1i+1; i < N; i++) {
                if (S.charAt(i) == (char)('0' + n2)) {
                    n2i = i;
                    break;
                }
            }
            if (n2i == -1) {
                continue;
            }
            // n3
            int n3i = -1;
            for (int i = n2i+1; i < N; i++) {
                if (S.charAt(i) == (char)('0' + n3)) {
                    n3i = i;
                    break;
                }
            }
            if (n3i == -1) {
                continue;
            }

            ans++;
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
import fractions
A,B = map(int,input().split())
GCD = fractions.gcd(A,B)
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
c = prime_factorize(GCD)
C = set(c)
print(len(C)+1)

Measured memory_bytes: 5048
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
	int a[3];
	scanf("%d%d%d", &a[0], &a[1], &a[2]);
	swap(a[0], a[1]);
	swap(a[0], a[2]);

	for (int i = 0; i < 3; ++i)
		printf("%d ", a[i]);

	return 0;
}

Measured memory_bytes: 256
/**************************************
 * Au: Hany01
 * Prob: agc003a
 * Date: Oct 20th, 2018
 * Email: hany01@foxmail.com
**************************************/

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)
#define Rep(i, j) for (register int i = 0, i##_end_ = j; i < i##_end_; ++ i)
#define For(i, j ,k) for (register int i = (j), i##_end_ = (k); i <= i##_end_; ++ i)
#define Fordown(i, j, k) for (register int i = (j), i##_end_ = (k); i >= i##_end_; -- i)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define SZ(a) ((int)(a.size()))
#define ALL(a) a.begin(), a.end()
#define PB(a) push_back(a)
#define MP(a, b) make_pair(a, b)
#define X first
#define Y second
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define y1 wozenmezhemecaia 
#ifdef hany01
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline T read() {
    register char c_; register T _, __;
    for (_ = 0, __ = 1, c_ = getchar(); !isdigit(c_); c_ = getchar()) if (c_ == '-')  __ = -1;
    for ( ; isdigit(c_); c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}
//EOT


char str[1024];
int cnt[256];

int main()
{
#ifdef hany01
    File("agc003a");
#endif

	scanf("%s", str);
	Rep(i, strlen(str)) cnt[str[i]] = 1;
	puts((cnt['E'] ^ cnt['W']) || (cnt['S'] ^ cnt['N']) ? "No" : "Yes");

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"

int main() {
  int N, a;
  if (scanf("%d", &N));

  int sum_top[N+1];
  int sum_bottom[N+1];
  sum_top[0] = 0, sum_bottom[0] = 0;
  REP(i, N) {
    if (scanf("%d", &a));
    sum_top[i+1] = sum_top[i] + a;
  }
  REP(i, N) {
    if (scanf("%d", &a));
    sum_bottom[i+1] = sum_bottom[i] + a;
  }

  int ans = 0;
  REP(i, N)
    ans = max(ans, sum_top[i+1] + (sum_bottom[N] - sum_bottom[i]));
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

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

ll LCM(ll a, ll b)
{
    return a * b / GCD(a, b);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    ll len = LCM(n, m);
    vector<ll> si, ti;
    for (ll i = 0; i < n; i++)
    {
        si.push_back(i * (len / n));
    }
    for (ll i = 0; i < m; i++)
    {
        ti.push_back(i * (len / m));
    }
    sort(ALL(si));
    sort(ALL(ti));
    vector<ll> rec;
    set_intersection(ALL(si), ALL(ti), back_inserter(rec));
    for (auto i : rec)
    {
        if (s[i / (len / n)] != t[i / (len / m)])
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << len << endl;
}

Measured memory_bytes: 2804
-module('Main').
-export([main/1]).

main(_) -> 
    {ok, [A, B, C, D, E]} = io:fread("", "~d ~d ~d ~d ~d"),
    Ans = find_zero([A, B, C, D, E]),
    io:format("~p~n", [Ans]),
    halt().

find_zero(L) ->
    find_zero(L, 1).
find_zero([0|_T], Index) ->
    Index;
find_zero([_H|T], Index) ->
    find_zero(T, Index + 1).


Measured memory_bytes: 22016
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        String t = sc.next();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(s.charAt(i));
            sb.append(t.charAt(i));
        }
        System.out.println(sb);
    }
}


Measured memory_bytes: 22996
import java.util.Scanner;
import java.util.Random;
import java.util.Arrays;
import java.util.Comparator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.HashMap;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<String> list = new ArrayList<String>();
		int n = sc.nextInt();
		String[] s = new String[n];
		
		for (int i = 0; i < n; i++) {
			s[i] = sc.next();
			if (!(list.contains(s[i]))) {
				list.add(s[i]);
			}
		}
		
		if (list.size() == 3) {
			System.out.println("Three");
		} else {
			System.out.println("Four");
		}
		
	
	}
		
}
	
	


Measured memory_bytes: 23892
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
using namespace std;

#define M 100000

vector<int> G[M];
int N;
bool visited[M];
int prenum[M], parent[M], lowest[M], timer;

void dfs(int current, int prev){
  //?????????current????¨???????????????¨?????????
  prenum[current] = lowest[current] = timer;
  timer++;

  visited[current] = true;

  int next;
  for(int i=0; i<G[current].size(); ++i){
    next = G[current][i];

    if( !visited[next] ){
      //?????????current???????????????next????¨????????????´????????????
      parent[next] = current;

      dfs(next, current);

      //?????????next?????¢?´¢????????????????????¨?????????
      lowest[current] = min(lowest[current], lowest[next]);
    }
    else if( next != prev){ //??¨??????current --> next ???Back-Edge?????´???
      lowest[current] = min(lowest[current], prenum[next]);
    }

  }
  //?????????current ?????¢?´¢????????????????????¨?????????
}

void art_points(){
  for(int i=0; i<N; ++i) visited[i] = false;
  timer=1;

  //lowest????¨????
  dfs(0, -1); //0 == root

  set<int> ap;
  int np=0;
  for(int i=1; i<N; ++i){
    int p = parent[i];
    if(p==0) np++;
    else if(prenum[p] <= lowest[i]) ap.insert(p);
  }

  if(np>1) ap.insert(0);
  for(set<int>::iterator it = ap.begin(); it!=ap.end(); ++it) cout << *it << endl;
}

int main(){
  int m;
  scanf(" %d %d", &N, &m);

  for(int i=0; i<m; ++i){
    int s, t;
    scanf(" %d %d", &s, &t);
    G[s].push_back(t);
    G[t].push_back(s);
  }

  art_points();

}

Measured memory_bytes: 5124
#include <iostream>
#include <algorithm>

using namespace std;

int find_max(int n, int a[]) {
    int max = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] > max)
            max = a[i];
    }

    return max;
}

int find_min(int n, int a[]) {
    int min = 1000;
    for (int i = 0; i < n; i++) {
        if (a[i] < min)
            min = a[i];
    }

    return min;
}

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

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

    int len = find_max(n, a) - find_min(n, a);

    cout << len << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
c = 0
r = 'No'
for i in range(n):
  d1, d2 = input().split(' ')
  d1 = int(d1)
  d2 = int(d2)
  if d1 == d2:
    c += 1
  else:
    c = 0
  if c == 3:
    r = 'Yes'
    break
print(r)

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  S.push_back('#');
  int ans = 0;
  for(size_t i = 0; i + 1 < S.size(); i++) {
      // 数えるのは境界線の数だけでいい
      if(S[i] != S[i+1]) ans++;
  }
  cout << ans << endl;
}


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

using namespace std;

#define ll long long

int main()
{

	ll n;
	cin>>n;

	ll a[n];

	ll sum = 0;

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

	ll pre[n];

	pre[0] = a[0];

	for(ll i = 1 ; i < n ; i++)
	{
		pre[i] = pre[i-1] + a[i];
		// cout<<pre[i]<<" ";
	}

	ll ans = LONG_LONG_MAX;

	for(ll i = 0 ; i < n - 1; i++)
	{
		ans = min(ans,abs(sum - pre[i] - pre[i]));
	}

	cout<<ans<<endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

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

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

	for (int i = 0; i < n; i++) {
		cout << (x ^ a[i]) << endl;
	}
	return 0;
}


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

typedef long long ll;

int cell[MAX][MAX];

int main()
{
    int row, col;

    scanf("%d %d", &row, &col);

    for(int i = 0; i < row; i++){
        char str[105];
        scanf("%s", str);
        for(int j = 0; j < col; j++){
            if(str[j] == '.')
                cell[i][j] = 0;
            else if(str[j] == '#')
                cell[i][j] = 1;
        }
    }

    for(int i = 0; i < row; i++){
        for(int j = 0; j < col; j++){
            if(cell[i][j] == 0){
                int flag1 = 1, flag2 = 1;
                for(int k = 0; k < row; k++){
                    if(cell[k][j] == 1){
                        flag1 = 0;
                        break;
                    }
                }
                if(flag1){
                    for(int k = 0; k < row; k++){
                        cell[k][j] = -1;
                    }
                }
                for(int k = 0; k < col; k++){
                    if(cell[i][k] == 1){
                        flag2 = 0;
                        break;
                    }
                }
                if(flag2){
                    for(int k = 0; k < col; k++){
                        cell[i][k] = -1;
                    }
                }
            }
        }
    }

    for(int i = 0; i < row; i++){
        int cnt = 0;
        for(int j = 0; j < col; j++){
            if(cell[i][j] == 0)
                printf("."), cnt++;
            else if(cell[i][j] == 1)
                printf("#"), cnt++;
        }
        if(cnt)
            printf("\n");
    }

    //printf("\n");

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int M=1e5;
int n;
struct pt { 
  double x, y; 
  pt() {}
  pt(double x, double y) : x(x), y(y) {}
  pt(const pt &p) : x(p.x), y(p.y)    {}
  pt operator - (const pt &p)  const { return pt(x-p.x, y-p.y); }
};
pt arr[M];
double cross(pt p,pt q){return p.x*q.y-p.y*q.x;}
void inp()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>arr[i].x>>arr[i].y;
}
double polygonarea()
{
	double area=0;
	pt o=arr[0];
	for(int i=1;i<n-1;i++)
	{
		area+=cross(arr[i]-o,arr[i+1]-o);
		area+=cross(arr[i]-o,arr[i+1]-arr[i]);
	}
	return abs(area/4);
}
int main()
{
	inp();
	cout<<fixed<<setprecision(1)<<polygonarea()<<endl;
    return 0;
}

Measured memory_bytes: 1296
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
int n , k ; 
int get(int c){
    if ( n - c < 0 ) return 0 ;
    int ans = (n - c) / k ;
    if ( c == 0 ) return ans ;
    return ans + 1 ;
}
signed main(){
    fastio
    cin >> n >> k ; 
    int ans = 0 ;
    for(int i = 0; i < k; i++){
        if ( i == (k - i) % k ){
            int first = get(i) ;
            ans += first * first * first ;
        }
    }
    cout << ans << endl;
    return 0; 
}

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

int main() {
  string a, b;
  cin >> a >> b;
  int n = stoi(a+b);
  for (int i = 0; i < 500; i++) {
    if (i*i == n) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int gcd(int x, int y)
{
	if(x == 0)
	{
		return y;
	}
	else
	{
		return gcd(y%x, x);
	}
}
 
int main()
{
	int n, x;
	cin >> n >> x;
	int a[100000];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		a[i] = abs(a[i] - x);
	}
	int ans = a[0];
	for (int i = 1; i < n; ++i)
	{
		ans = gcd(ans, a[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	int ans = inf;
	for (char c = 'a'; c <= 'z'; ++c) {
		vector<int> a(n);
		rep(i, n) a[i] = s[i] == c;
		while (a != vector<int>(a.size(), 1)) {
			vector<int> p(a.size() - 1);
			swap(a, p);
			rep(i, a.size()) a[i] = p[i] | p[i + 1];
		}
		mins(ans, n - (int)a.size());
	}
	cout << ans << endl;
	return 0;
}

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

const ll INFF = 1e18;

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<ll> a(n); rep(i, n) cin >> a[i];

	ll mina = INFF;
	rep(i, n) mina = min(mina, abs(a[i]));

	int mcnt = 0;
	rep(i, n) mcnt += (a[i] < 0) ? 1 : 0;

	ll sum = 0;
	rep(i, n) sum += abs(a[i]);

	cout << sum - ((mcnt % 2) ? 2 * mina : 0ll) << endl;
	return 0;
}


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

int main(){
	int N=0,Y=0,man=0,go=0,sen=0;
	bool flag = false;
	cin>>N>>Y;
	for(int i =0;i<=N/*&flag==false*/;++i)
	{
		for(int j=0;j<=N-i/*&&flag==false*/;++j)
		{
				if(i*10000+j*5000+(N-j-i)*1000==Y)
				{
					flag =true;
					man =i;
					go=j;
					sen=N-i-j;				}
		}
	}if(flag)cout<<man<<" "<<go<<" "<<sen;
	else cout<<"-1 -1 -1";
	return 0;
	}


Measured memory_bytes: 256