akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {  
  int num = 0;
  cin >> num;
  vector<long long> lucas(num+1) ;

  // 再帰厳しい
  lucas[0] = 2;
  lucas[1] = 1;
  for (int i = 2; i <= num; i++) {
    lucas[i] = lucas[i-2] + lucas[i-1];
  }

  cout << lucas[num] << endl;
}

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

int max(int *L);

int main(void) {
	int N, temp = 0;
	int *L;
	scanf("%d,", &N);
	L = (int *)malloc(sizeof(int) * N );
	for (int i = 0; i < N; ++i) {
		scanf("%d", &L[i]);
		if (L[i] > temp) temp = L[i];
	}
	int sum = 0;
	int flag = 0;
	for (int i = 0; i < N; ++i) {
		if (L[i] < temp || (L[i] == temp && flag == 1)) {
			sum += L[i];
		}else if(L[i] == temp){
		    flag = 1;
		}
	}
	//printf("%d %d\n",temp,sum);
	sum > temp ? printf("Yes\n") : printf("No\n");

	free(L);

}

Measured memory_bytes: 128
s=input()
l=list(s.split('LR'))
if len(l)>1:
  l[0]+='L'
  l[-1]='R'+l[-1]
  for i in range(1,len(l)-1):
    l[i]='R'+l[i]+'L'
ans=[]
for i in range(len(l)):
  p=l[i].find('RL')
  q=len(l[i])-p-2
  ans.extend([0]*p)
  ans.append(1+p//2+q//2+q%2)
  ans.append(1+p//2+q//2+p%2)
  ans.extend([0]*q)
print(' '.join(map(str,ans)))

Measured memory_bytes: 13932
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Ti4 tuple<int, int, int, int>
#define Tlll tuple<ll, ll, ll>
#define PI 3.141592653589793

int main() {
    int n, m, p;
    while (cin >> n >> m >> p) {
        if (n == 0) return 0;
        int x[105], s = 0;
        for (int i = 0; i < n; i++) {
            cin >> x[i];
            s += 100*x[i];
        }
        if (x[m - 1] == 0) cout << 0 << endl;
        else cout << s * (100 - p) / 100 / x[m - 1] << endl;
    }
}



Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll X, Y;
    cin >> X >> Y;

    ll ans = 1;
    while(X * 2 <= Y){
        ans++;
        X *= 2;
    }

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

Measured memory_bytes: 3508
N, C = map(int, input().split())
sushi = [tuple(map(int, input().split())) for _ in [0]*N]
normal = [sushi[0][1] - sushi[0][0]]
n_append = normal.append
cur = normal[0]
n_max = max(0, normal[0])
for (s1_pos, s1_cal), (s2_pos, s2_cal) in zip(sushi, sushi[1:]):
    cur = cur + s2_cal - (s2_pos-s1_pos)
    if n_max < cur:
        n_max = cur
    n_append(n_max)
     
reverse = [sushi[-1][1] - (C-sushi[-1][0])]
r_append = reverse.append
cur = reverse[0]
r_max = max(0, reverse[0])
for (s1_pos, s1_cal), (s2_pos, s2_cal) in zip(sushi[::-1], sushi[-2::-1]):
    cur = cur + s2_cal - (s1_pos-s2_pos)
    if r_max < cur:
        r_max = cur
    r_append(r_max)
     
result = 0
for i, (pos, cal) in enumerate(sushi[:-1]):
    result = max(result, normal[i], normal[i]-pos+reverse[N-2-i])
for i, (pos, cal) in enumerate(sushi[:0:-1]):
    result = max(result, reverse[i], reverse[i]-(C-pos)+normal[N-2-i])
result = max(result, normal[-1], reverse[-1])
     
print(result)

Measured memory_bytes: 25940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, S;
  cin >> N >> M;
  
  vector<int> roads(M * 2);
  for(int i=0; i<M*2; i++){
    cin >> roads.at(i);
  }
  
  for(int i=1; i<=N; i++){
    S = 0;
    for(int j=0; j<M*2; j++){
      if(roads.at(j) == i){
        S++;
      }
    }
    cout << S << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 305
#define lint long long
#define trace(x) cout<<#x<<" = "<<x<<'\n'
#define trace2(x, y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<'\n'
#define tracea(arr, i) cout<<#arr<<"["<<i<<"]"<<" = "<<arr[i]<<'\n'
#define print(arr, n) for (int iDx = 0; iDx < (n); iDx++) cout << arr[iDx] << " \n"[iDx == (n)-1]
#define sz(x) (int)(x).size()
using namespace std;
struct ii {
	int a, b;
	bool operator < (ii o) const { return make_tuple(a, b) < make_tuple(o.a, o.b); }
};
struct iii {
	int a, b, c;
	bool operator < (iii o) const { return make_tuple(a, b, c) < make_tuple(o.a, o.b, o.c); }
};
int TC, N, M, K, Q, x, y, z;

int arr[MAXN][MAXN], cnt[MAXN], ptr[MAXN];
bitset<MAXN> anulir;

int main() {
	#ifdef FAIRUZI10
	freopen("/home/fairuzi/Documents/CP/input.in", "r", stdin);
	#endif
	
	scanf("%d%d", &N, &M);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			scanf("%d", &arr[i][j]);
		}
	}
	
	for (int i = 0; i < N; i++) cnt[arr[i][0]]++;
	int maks = 1;
	for (int i = 2; i <= M; i++) {
		if (cnt[i] > cnt[maks]) maks = i;
	}
	int ans = cnt[maks];
	anulir[maks] = 1;
	cnt[maks] = 0;
	for (int i = 1; i < M; i++) {
		for (int j = 0; j < N; j++) {
			if (anulir[arr[j][ptr[j]]]) {
				while (anulir[arr[j][ptr[j]]]) ptr[j]++;
				cnt[arr[j][ptr[j]]]++;
			}
		}
		maks = 1;
		for (int j = 2; j <= M; j++) {
			if (cnt[j] > cnt[maks]) maks = j;
		}
		ans = min(ans, cnt[maks]);
		anulir[maks] = 1;
		cnt[maks] = 0;
	}
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int hi[20];
int SA (int n,int i,int m);
int main()
{
  int i,n,q,m;
 
  scanf ("%d",&n);
  for (i=0;i<n;i++)
    scanf ("%d",&hi[i]);
  scanf ("%d",&q);
  for (i=0;i<q;i++){
    scanf ("%d",&m);
    if ( SA(n,0,m) )
      printf ("yes\n");

    else
      printf ("no\n");
  }
  return 0;
}

int SA (int n,int i,int m){
  int p;
  if (m==0)
    return 1;
  if (i>=n)
    return 0;
  p= SA(n,i+1,m) || SA(n,i+1,m-hi[i]);
  return p;
}



Measured memory_bytes: 2052
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

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

llint a, b, v, w, t;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> a >> v;
	cin >> b >> w;
	cin >> t;
	
	if(v <= w){
		cout << "NO" << endl;
		return 0;
	}
	
	if(abs(a-b) <= t*(v-w)) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	
	return 0;
}

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

struct cell{int D,P;};
bool operator<(cell a, cell b){return a.P!=b.P?a.P>b.P:a.D>b.D;};

int main()
{
  int N,M,D,P,p,i;
  vector<cell> v;
  while(cin>>N>>M,N||M){
    v.resize(N);
    for(i=0;i<N;i++){
      cin>>D>>P;
      v[i].D=D;
      v[i].P=P;
    }
    sort(v.begin(),v.end());
    for(i=0;M>0&&i<N;i++){
      while(M>0&&v[i].D>0){
	v[i].D--;
	M--;
      }
    }
    for(p=i=0;i<N;i++){
      p+=v[i].D*v[i].P;
    }
    cout<<p<<endl;
  }
}

Measured memory_bytes: 1076
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define repp(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define popcnt __builtin_popcount
#define all(v) v.begin(),v.end()
#define _Pi 3.1415926535
#define _MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?GCD(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/GCD(a,b);}

int main(){
    string s; cin >> s;
    int ans=0,tmp=0;
    rep(i,10){
        if(s[i] != 'A' 
        && s[i] != 'C' 
        && s[i] != 'G' 
        && s[i] != 'T'){
            chmax(ans,tmp);
            tmp = 0;
        }
        else{
            ++tmp;
        }
    }
    chmax(ans,tmp);
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
use proconio::*;

fn run() {
    input! {
        n: usize,
        a: [u64; n],
    }
    let mut ans = 0;
    let mut x = a[0];
    for a in a.iter().skip(1) {
        if *a < x {
            ans += x - *a;
        }
        if *a > x {
            x = *a;
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 5504
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        c: [[i64; 3]; 3]
    }

    let mut a = vec![0i64;3];
    let mut b = vec![0i64;3];
    b[0] = c[0][0];
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];
    b[1] = c[0][1];
    b[2] = c[0][2];
    let mut is_ok = true;
    for y in 0..3 {
        for x in 0..3 {
            if c[y][x] != a[y] + b[x] {
                is_ok = false;
            }
        }
    }
    println!("{}", if is_ok {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    if min(A) == 0:
        print(0)
        return
    ret = 1
    for a in A:
        ret *= a
        if ret > 10**18:
            ret = -1
            break
    print(ret)


if __name__ == '__main__':
    main()

Measured memory_bytes: 21780
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        long mod=1_000_000_007;
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        long[] x=new long[n];
        long[] border=new long[n];
        int put=0;
        for(int i=0;i<n;i++){
            x[i]=fsc.nextLong();
            if(i>0 && (long)(i-put)*2l>=x[i]){
                border[put++]=i+1;
            }
        }
        border[put]=n;
        fsc.close();
        long ans=1;
        for(int i=0;i<n;i++){
            if(i<=put){
                ans*=(border[i]-i);
            } else{
                ans*=(n-i);
            }
            ans%=mod;
        }
        System.out.println(ans);
    }
    

    static 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 static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; 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() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


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

using namespace std;
#define ll long long
int main()
{
    ll h,w,st[102][102],nb=0,x[]={1,0},y[]={0,1};
    char grid[102][102];
    cin>>h>>w;
    for(ll i=0;i<h;i++)
    {
        for(ll j=0;j<w;j++)
        {
            cin>>grid[i][j];
            st[i][j]= -1;
        }
    }
    queue<pair<ll,ll> > que;
    que.push({0,0});
    if(grid[0][0]=='#')st[0][0]=1;
    else st[0][0]=0;
    while(!que.empty())
    {
        ll nx=que.front().first,ny=que.front().second;
        que.pop();
        for(ll i=0;i<2;i++)
        {
            ll cx=nx+x[i],cy=ny+y[i],cs;
            if(cx>=h || cy>=w)continue;
            if(grid[cx][cy]=='#' && grid[nx][ny]!='#')cs=st[nx][ny]+1;
            else cs=st[nx][ny];
            if(st[cx][cy]==-1 || cs<st[cx][cy]){que.push({cx,cy});st[cx][cy]=cs;}
        }
    }
    cout<<st[h-1][w-1]<<endl;

    return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;

const int MXN = (int)2e5 + 7;

typedef long long llong;

llong a, b;

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  cin >> a >> b;
  cout << (a * b) / __gcd(a, b);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pii;
#define sf(x) scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define lli long long int
#define ll64 int64_t
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define frr(i,a) for(int i=0;i<a;i++)
#define frl(i,a) for(lli i=0;i<a;i++)
int main()
{
    lli n;
    cin>>n;
    lli a[n];
    for(lli i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    lli c=1,f=0,ans=1;
    for(lli i=n-2;i>=0;i--)
    {
        if(a[i]==a[i+1])
        {
            c++;
        }
        else
        {
            if(c>=4 and f==0)
            {
                ans*=a[i+1]*a[i+1];
                f=2;
                break;
            }
            else if(c>=2 and f<2)
            {
                ans*=a[i+1];
                f++;
                if(f==3)
                {
                    break;
                }
            }
            c=1;
        }
    }
    if(c>=4)
    {
        if(f==0)
        {
            ans*=a[0]*a[0];
            f=2;
        }
        else if(f==1)
        {
            ans*=a[0];
            f=2;
        }
    }
    else if(c>=2)
    {
        if(f==1)
        {
            ans*=a[0];
        }
        f=2;
    }
    if(f>=2)
    {
        cout<<ans<<endl;
    }
    else
    {
        cout<<0<<endl;
    }
}


Measured memory_bytes: 4352
/* 
 * Project: AtCoder Beginners Contest 167 B - Easy Linear Programming
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/05/11
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cmath>
using namespace std;

int a, b, c, k;

void solve() {
    if (k < a) {
        printf("%d\n", k);
        return;
    } else if (k <= a + b) {
        printf("%d\n", a);
        return;
    } else {
        printf("%d\n", 2*a+b-k);
        return;
    }
}

int main() {

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &k);

    solve();

}

Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
using namespace std;
const int INF = 1e9;
typedef long long lint;
const lint LINF = 1e18;
const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}
 
int main(){
	int n,k; cin>>n>>k;
	lint ans = 0;
	ans += pow(n/k,3);
	if (k%2==0){
		ans += pow(n/(k/2) - n/k,3);
	}
	cout << ans << endl;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)


int n, indeg[26], outdeg[26];
bool vis[26];
vector< int > adj[26];

void dfs(int v) {
	vis[v] = true;
	for (int u : adj[v]) if (!vis[u]) dfs(u);
}

bool connected() {
	int cnt = 0;
	
	for_(v,0,26) {
		if (vis[v]) continue;
		++cnt; dfs(v);
	}
	
	return cnt == 1;
}

void solve() {
	memset(indeg, 0, sizeof(indeg));
	memset(outdeg, 0, sizeof(outdeg));
	
	for_(i,0,26) {
		adj[i].clear();
		vis[i] = true;
	}
	
	for_(i,0,n) {
		string s;
		cin >> s;
		int a = s[s.size() - 1] - 'a', b = s[0] - 'a';
		++indeg[a];
		++outdeg[b];
		adj[b].push_back(a);
		vis[b] = vis[a] = false;
	}
	
	bool ok = connected();
	for_(i,0,26) ok &= (indeg[i] == outdeg[i]);
	cout << (ok ? "OK" : "NG") << endl;
}

int main() { while (cin >> n, n) { solve(); } }

Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<time.h>
#include<vector>
using namespace std;
long long a[105];
int ans;
int main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int n;
    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&&i!=j; j++){
            for(int k=j+1; k<=n&&i!=k&&j!=k&&i!=j; k++){
                if(a[i]==a[j]||a[i]==a[k]||a[j]==a[k])
                    continue;
                if(abs(a[i]-a[j])<a[k]&&abs(a[i]-a[k])<a[j]&&abs(a[j]-a[k])<a[i]){
                    ans++;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3620
package main

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

var buf = bufio.NewScanner(os.Stdin)

func scanInt() int {
	buf.Scan()
	i, _ := strconv.Atoi(buf.Text())
	return i
}

func scanInts(n int) []int {
	a := make([]int, n)
	for k, _ := range a {
		a[k] = scanInt()
	}
	return a
}

func scanString() string {
	buf.Scan()
	return buf.Text()
}

func scanStrings(n int) []string {
	a := make([]string, n)
	for k, _ := range a {
		a[k] = scanString()
	}
	return a
}

func main() {
	buf.Split(bufio.ScanWords)

	n := scanInt()
	s := scanStrings(n)

	m := make(map[string]int)
	for _, v := range s {
		m[v] += 1
	}

	largest := 0
	for _, v := range m {
		if largest < v {
			largest = v
		}
	}

	result := []string{}
	for k, v := range m {
		if v == largest {
			result = append(result, k)
		}
	}

	sort.Strings(result)

	for _, v := range result {
		fmt.Printf("%s\n", v)
	}
}


Measured memory_bytes: 30976
package main

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

func main() {
	N, M := nextInt(), nextInt()
	As := nextInts(N)

	BCs := make([][]int, M)
	for i := 0; i < M; i++ {
		BCs[i] = nextInts(2)
	}

	sort.Ints(As)
	sort.Sort(BCS(BCs))

	i := 0
	for j := 0; i < len(As) && j < M; j++ {
		B, C := BCs[j][0], BCs[j][1]
		if C <= As[i] {
			break
		}
		for B > 0 && i < len(As) && C > As[i] {
			As[i] = C
			B--
			i++
		}
	}

	fmt.Println(Sum(As...))
}

type BCS [][]int

func (bcs BCS) Len() int {
	return len(bcs)
}

func (bcs BCS) Less(i, j int) bool {
	return bcs[i][1] > bcs[j][1]
}

func (bcs BCS) Swap(i, j int) {
	bcs[i], bcs[j] = bcs[j], bcs[i]
}

func Sum(slice ...int) int {
	sum := 0
	for _, v := range slice {
		sum += v
	}
	return sum
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}


Measured memory_bytes: 6912
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

  public static void main (String[] args) {
    String[] nq = new String[2];
    char[] s = null;
    List<String[]> lr = new ArrayList<>();
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
      nq = br.readLine().split("\\s");
      s = br.readLine().toCharArray();
      for (int i = 0; i < Integer.parseInt(nq[1]); i++) {
        lr.add(br.readLine().split("\\s"));
      }
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    }

    int[] sum = new int[s.length + 1];
    for (int i = 1; i < s.length; i++) {
      if (s[i-1] == 'A' && s[i] == 'C') {
        sum[i+1] = sum[i] + 1;
      } else {
        sum[i+1] = sum[i];
      }
    }

    for (String[] array : lr) {
      final int start = Integer.parseInt(array[0]);
      final int end = Integer.parseInt(array[1]);
      System.out.println(sum[end] - sum[start]);
    }
  }
}


Measured memory_bytes: 85640
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
p = 10**9+7
from math import gcd
from collections import Counter
from collections import defaultdict
used = defaultdict(list)

n = int(input())

ctr = Counter()
az = bz = zz = 0
for i in range(n):
    a, b = map(int, input().split())
    if a==b==0:
        zz+=1
    elif a==0:
        az+=1
    elif b==0:
        bz+=1
    else:
        g = gcd(a,b)
        a,b = a//g, b//g
        if b < 0:
            a*=-1
            b*=-1
        ctr[(a,b)]+=1
        used[(a,b)]=False

ans = 1

# 仲の悪いグループ対ごとに処理する
for (a1,b1),v1 in ctr.items():
    if used[(a1,b1)]:
        continue
    a2,b2=-b1,a1
    if b2 < 0:
        b2*=-1
        a2*=-1
    v2 = ctr[(a2,b2)]

    r = (pow(2,v1,p)+pow(2,v2,p)-1)%p
    ans*=r
    ans%=p
    used[(a1,b1)]=True
    used[(a2,b2)]=True

# 片方が0のクループ対
r = (pow(2,az,p)+pow(2,bz,p)-1)%p
ans*=r
ans%=p

ans+=zz # 0匹のケースは禁止されている
ans-=1 # 0匹のケースは禁止されている
ans%=p
print(ans)



Measured memory_bytes: 110468
import java.util.*;
class Main {
	public static void main(String []args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(),l;
		int a[][]=new int[2][n],c=0,d=0;
		for (int i=0;i<2;i++)
		{
			for (int j=0;j<n;j++)
			{
				a[i][j]=sc.nextInt();
			}
		}
		int s[]=new int[n];
		for (int k=0;k<n;k++)
		{
			for (int i=0;i<n-k;i++) 
			{
				s[k]=s[k]+a[0][i];
			}
			for (int i=n-k-1;i<n;i++)
			{
				s[k]=s[k]+a[1][i];
			}
		}
		Arrays.sort(s);
		System.out.println(s[n-1]);
	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//turn on extra precision
//#pragma GCC target("fpmath=387")

using namespace std;
using namespace __gnu_pbds;

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

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define watch(x) cout << (#x) << " is : " << (x) << newl

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
vi dirx = {0,0,1,-1};
vi diry = {1,-1,0,0};
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122) return char(x-32);
    if( 65 <= int(x) && int(x) <= 90) return x;
    return -1;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122) return x;
    if( 65 <= int(x) && int(x) <= 90) return char(x+32);
    return -1;
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57) return int(x-'0');
    if(97 <= int(x) && int(x) <= 122) return int(x-96);
    if(65 <= int(x) && int(x) <= 90) return int(x-64);
    return -1;
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1 = {l1,r1};
    pii p2 = {l2,r2};
    if(p1>p2)swap(p1,p2);
    return (p2.fi <= p1.se);
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1%MOD;
    else if(num2==1)return num1%MOD;
    else{
        ll temp = quickpow (num1,num2>>1LL,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2&1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template

int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int a[6];
    for(int i = 1; i <= 5; ++i) cin >> a[i];
    for(int i = 1; i <= 5; ++i){
        if(a[i] == 0) {cout << i << newl; return 0;}
    }

    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000007

int main(){
    int N;
    int64_t result=0,sum=0;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
        sum+=A.at(i);
    }
    for(int i=0;i<N;i++){
        sum-=A.at(i);
        result+=(sum%INF)*A.at(i);
        result%=INF;
    }
    cout<<result<<endl;
}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


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

    if ( n/10 == 9 || n%10 == 9 ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  string s;
  cin >> s;
  rep(i,s.size()-8) cout << s[i];
  cout << endl;
}


Measured memory_bytes: 256
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
use std::cmp; // cmp::max,cmp::min

// Rust memo: https://hackmd.io/i0lQY1OKTDW1t66TECOmiw?both

#[allow(dead_code)]
fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn read_charvec() -> Vec<char>{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

#[allow(dead_code)]
fn read_int() -> i64{
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String{
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n:i64) -> Vec<String>{
    let mut xs = Vec::new();

    for _i in 0..n{
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n:i64) -> Vec<i64>{
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn arange(start:i64,end:i64,step:i64) -> Vec<i64>{
    let mut ret = Vec::new();
    let mut i = start;

    while i < end{
        ret.push(i);
        i += step;
    }

    ret
}

#[allow(dead_code)]
const DXS : [i64; 4] = [0,0,1,-1];
#[allow(dead_code)]
const DYS : [i64; 4]  = [1,-1,0,0];
#[allow(dead_code)]
const INF : i64 = 999999999;

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

fn main(){
    let xs = read_ints();
    let (h,w) = (xs[0] as usize,xs[1] as usize);
    
    let mut mat = (0..h).map(|_| read_ints()).collect::<Vec<Vec<i64>>>();
    //let mut checked = vec![vec![false;w];h];
    
    let mut ans = Vec::new();
    
    let mut cnt = 0;
    for i in 0..h{
        for j in 0..w{
            if mat[i][j] % 2 == 1{
                if j == w-1{
                    if i == h-1{
                        // もうむり
                    }else{
                        // した
                        mat[i][j]-=1;
                        mat[i+1][j]+=1;
                        ans.push((i+1,j+1,i+2,j+1));
                        cnt+=1;
                    }
                }else{
                    // となり
                    mat[i][j]-=1;
                    mat[i][j+1]+=1;
                    ans.push((i+1,j+1,i+1,j+2));
                    cnt+=1;
                }
            }
            
        }
    }
    
    println!("{}",cnt);
    for x in ans{
        println!("{} {} {} {}",x.0,x.1,x.2,x.3);
    }
}   

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

int main() {
  int n,q;
  long t = 0;
  cin >> n >> q;
  queue<int>time;
  queue<string>name;
  for(int i = 0;i < n;i++){
    string s;
    int qi;
    cin >> s >> qi;
    name.push(s);
    time.push(qi);
  }
  while(time.empty() == false){
    if(time.front()-q <= 0){
      t += time.front();
      time.pop();
      cout << name.front() << " " << t << endl;
      name.pop();
    }
    else{
      t += q;
      long topt = time.front()-q;
      string ntop = name.front();
      time.pop();
      name.pop();
      time.push(topt);
      name.push(ntop);
    }
  }
}



Measured memory_bytes: 5704
_ = gets.to_i
cards = gets.split.map(&:to_i)
cards = cards.sort.reverse
alice = []
bob = []
cards.each.with_index do |card, i|
  if i.even?
    alice << card
  else
    bob << card
  end
end
puts alice.inject(:+) - bob.inject(:+)


Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int t[2][6]={
  {1,-1,1,4,5,2},
  {2,3,-1,5,2,1}
};
string str;
int n,pos;
int main(){
  while(1){
    cin>>str;
    n=str.size();
    pos=0;
    if(str=="#")break;
    for(int i=0;i<n;i++){
      pos=t[str[i]-'0'][pos];
      if(pos==-1)break;
    }
    if(pos!=5)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    int n;
    string st;
    cin >> st;
    for (int i = st.size()-1; i >= 0; --i) {
        if(st[i] == 'Z'){
            st.erase(i+1);
            break;
        }
    }
    int ar[st.size()] ={};
    int mx =0;
    for(int i=0; i<st.size(); i++){
        if(st[i]=='A'){
            if(ar-1 < 0 || ar[i-1] == 0)  ar[i] = 1;
            else ar[i] = ar[i-1]+1;
        }else if(st[i] == 'Z'){
            if(ar[i-1] !=0)
                ar[i] = ar[i-1]+1;
            mx = max(ar[i],mx);
        }else{
            if(i-1 >= 0 && ar[i-1] != 0)
                ar[i] = ar[i-1]+1;
        }
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 1300
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
 
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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


int main()
{
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	cout << min(a, b) + min(c, d) << endl;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

int main(){
	string s;
	bool flg1,flg2;
	flg1=flg2=false;
	cin>>s;
	REP(i,(int)s.length()){
		if (s[i]=='C'){
			flg1=true;
		}else if (s[i]=='F' && flg1){
			flg2=true;
		}
	}
	if (flg2){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
        int int1 = Integer.parseInt(scan.next());
//        int int2 = Integer.parseInt(scan.next());
//        int int3 = Integer.parseInt(scan.next());
//        int int4 = Integer.parseInt(scan.next());
//        double db = Double.parseDouble(scan.next());
        int ans_int = 0;
        String ans = "No\n";
//        String temp_str1 = "";
//        String temp_str2 = "";
        int temp_int1 = 0;
//        String str1 = scan.next();
//        String str2 = scan.next();
//        String str3 = scan.next();
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 1;i<10;i++){
            for (int h = 1;h<10;h++){
                if(i*h == int1){
                    ans = "Yes\n";
                    break;
                }
            }
            if(ans.equals("Yes\n")){
                break;
            }
        }
        PrintWriter out = new PrintWriter(System.out);
        out.println(ans);
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
int main(void){
  char a[100],b[100],c[100];
  scanf("%s%s%s",a,b,c);
  char index='a';
  int A=0,B=0,C=0,ans='A';
  while(1){
    if(index=='a'){
      index=a[A];
      ans='A';
      if(a[A]=='\0') break;
      A++;
    }
    else if(index=='b'){
      index=b[B];
      ans='B';
      if(b[B]=='\0') break;
      B++;
    }
    else if(index=='c'){
      index=c[C];
      ans='C';
      if(c[C]=='\0') break;
      C++;
    }
  }
  printf("%c",ans);
  return 0;
}

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

struct EulerTourOnVertex {
    vector<int> posL, posR;
    vector<vector<int>> g;
    int pos;
    EulerTourOnVertex(int n) : posL(n), posR(n), g(n) { }
    void add_edge(int u, int v) {
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }
    void dfs(int u, int p) {
        posL[u] = pos++;
        for (int v: g[u]) if (v != p) {
            dfs(v, u);
            pos++;
        }
        posR[u] = pos;
    }
    void build(int r = 0) {
        pos = 0;
        dfs(r, -1);
    }
};

int main() {
    int n, q; cin >> n >> q;
    EulerTourOnVertex et(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b; cin >> a >> b; a--, b--;
        et.add_edge(a, b);
    }
    et.build();
    vector<int> v(n * 2);
    while (q--) {
        int p, x; cin >> p >> x; p--;
        v[et.posL[p]] += x;
        v[et.posR[p]] -= x;
    }
    for (int i = 1; i < n * 2; i++) v[i] += v[i - 1];
    for (int i = 0; i < n; i++) cout << v[et.posL[i]] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 22656
import heapq

def main():
    pq = []
    heapq.heapify(pq)
    while True:
        com = list(input().split())
        if com[0]=='end':break
        if com[0]=='insert':
            heapq.heappush(pq,-int(com[1]))
        else :
            print(-heapq.heappop(pq))



if __name__ == '__main__':
    main()




Measured memory_bytes: 45312
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
vector<string>ans; 
int n;
void dg(string s)
{
	if(s.size()>n)return;
	if(s.size()==n)
	{
		ans.pb(s);
		return;
	}
	for(int i=s.size();i>=0;i--)
	{
		string pp=s;
		bool flag=0;
		for(int j=s.size()-1;j>=0;j--)
			if(s[j]=='a'+i-1)flag=1;
		if(flag==0&&i!=0)continue;
		s+=i+'a';
		dg(s);
		s=pp; 
	}
}
int main()
{
	cin>>n;
	string s="";
	dg(s);
	sort(ans.begin(),ans.end());
	REP(i,ans.size())	
		cout<<ans[i]<<endl;
	return 0;
}



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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> mp(h);
    rep(i, h) cin >> mp.at(i);

    vector<vector<int>> bomb(h, vector<int>(w));
    vector<pair<int, int>> dif = {
        make_pair(-1, -1), make_pair(-1, 0),
        make_pair(-1, 1), make_pair(0, -1),
        make_pair(0, 1), make_pair(1, -1),
        make_pair(1, 0), make_pair(1, 1)
    };
    rep(i, h) {
        rep(j, w) {
            if(mp.at(i).at(j) == '#') {
                bomb.at(i).at(j) = -1;
                for(auto d : dif) {
                    int di = i + d.first;
                    int dj = j + d.second;
                    if(0 <= di && di < h && 0 <= dj && dj < w && bomb.at(di).at(dj) != -1) {
                        bomb.at(di).at(dj)++;
                    }
                }
            }
        }
    }

    rep(i, h) {
        rep(j, w) {
            if(bomb.at(i).at(j) == -1) {
                cout << '#';
            }
            else cout << bomb.at(i).at(j);
        }
        cout << endl;
    }

    return 0;
}

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

#define MAX 100001

int isPossibleToBuy(int idx, int Value, const std::vector<int>& goods){
    if(idx >= 6) return 0;

    if((Value % goods[idx]) == 0) return 1;
    
    int idx_max_buy = Value/goods[idx];

    for(int items = 0; items <= idx_max_buy; ++items){
        if(isPossibleToBuy(idx+1, Value - goods[idx]*items, goods)) return 1;
    }

    return 0;
}

int main(void){
    std::vector<int> goods({100, 101, 102, 103, 104, 105});

    int X;
    std::cin >> X;

    std::cout << isPossibleToBuy(0, X, goods);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll a,b,c;cin>>a>>b>>c;
    ll k;cin>>k;
    ll ans=0;
    if(a>=k){
        ans+=k;
        k=0;
    }else{
        k-=a;
        ans+=a;
    }
    if(k==0){
        cout<<ans<<endl;
        return 0;
    }
    if(b>=k){
        k=0;
    }else{
        k-=b;
    }
    if(k==0){
        cout<<ans<<endl;
        return 0;
    }
    ans-=k;
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
S = input()

if S == "SUN":
    print("7")

elif S == "MON":
    print("6")

elif S == "TUE":
    print("5")

elif S == "WED":
    print("4")

elif S == "THU":
    print("3")

elif S == "FRI":
    print("2")

else:
    print("1")

Measured memory_bytes: 38256
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
using namespace std;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
#define pb push_back
template<class T> void print(const T& x){cout << x << endl;}
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;

int main(){
    int s; cin >> s;
    unordered_set<int> se;
    rep(i, 0, 1e7){
        if(se.find(s) != se.end()){
            cout << i + 1 << endl;
            return 0;
        } else {
            se.insert(s);
        }
        if(s % 2 == 0) s /= 2;
        else s = 3*s + 1;

        
    }

    return 0;
}




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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int s=a+b+c;
    Yes((s==2*a)||(s==2*b)||(s==2*c));
    return 0;
}

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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

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

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x << " "; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


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


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

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


auto solve() {
    int A, B;
    cin >> A >> B;

    if (B % A == 0) return A + B;
    else return B - A;
}


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

//    cout << (solve() ? "First" : "Second") << endl;
//    cout << (solve() ? "YES" : "NO") << endl;
    cout << solve() << endl;
//    solve();

    return 0;
}


Measured memory_bytes: 256