akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;


//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;




/*
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
*/
/*
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
*/

const ll mod = 1e9 + 7;
const ll modl=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/
/*
const int N=100001;
ll fact_inverse[N];
ll num_inverse[N];
ll fact[N];
void number_inverse(int m){
   num_inverse[0]=1;
   num_inverse[1]=1;
   for(int i=2;i<=N;i++){
     num_inverse[i]=num_inverse[m%i]*(m - m/i)%m;
   }
}

void factorial_inverse(int m){
   fact_inverse[0]=1;
   fact_inverse[1]=1;
   for(int i=2;i<=N;i++){
      fact_inverse[i]=(num_inverse[i]*fact_inverse[i-1])%m;
   }
}

void factorial(int m){
  fact[0]=1;
  for(int i=1;i<=N;i++)fact[i]=(i*fact[i-1])%m;
}

int modular_nCr(int n,int r,int m){
   ll res=((fact[n]*fact_inverse[r])%m *  fact_inverse[n-r])%m;
   return res;
}
*/
int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
       ll k,n;
       cin>>k>>n;
       vll v(n);
       for(int i=0;i<n;i++)cin>>v[i];
       ll ans=0,mx=0;
       for(int i=1;i<n;i++){
         ans+=v[i]-v[i-1];
         mx=max(mx,v[i]-v[i-1]);
       }
       ans+=k-v[n-1];
       ans+=v[0];
       mx=max(mx,k-v[n-1]+v[0]);
       ans-=mx;
       cout<<ans<<endl;
  }
}









Measured memory_bytes: 4752
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int main()
{
	int n;

	int tm = 0;
	int px = 0, py = 0;
	bool ans = true;
	for (cin >> n; n--; )
	{
		int t, x, y;
		cin >> t >> x >> y;

		int  t0 = t - tm;
		tm = t;

		int x0 = abs(x - px);
		int y0 = abs(y - py);

		px = x;
		py = y;

		if (t0 % 2 != (x0 + y0) % 2 || t0 < x0 + y0)
		{
			ans = false;
			break;
		}
	}

	cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
const int inf=1145141919;
const int dd[]={0,-1,0,1,0};
using namespace std;
int keta(int n){
	int i;
	for(i=0;n;i++)
		n/=10;
	return i;
}
signed main(){
	int n,ans=inf;
	int i;
	cin>>n;
	for(i=1;i*i<=n;i++)
		if(n%i==0){
			int x=keta(n/i);
			if(x<ans)
				ans=x;
		}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io;
use std::str::FromStr;
use std::iter::FromIterator;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::mem::{replace, swap};


// abcde
fn read_string() -> String {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    line
}

// -3.2
fn read_as_primitive<T: FromStr>() -> T {
    let s = read_string();
    s.trim().parse().ok().expect("failed to parse input")
}

// 1 -3 0 999
fn read_as_collection<U: FromStr, T: FromIterator<U>>() -> T {
    let s = read_string();
    s.trim().split_whitespace().map(|s| s.parse().ok().expect("failed to parse")).collect()
}

// #.#.###..
fn read_as_chars<T: FromIterator<char>>() -> T {
    let s = read_string();
    s.trim().chars().collect()
}

// 1 abc
fn read_as_pair<T: FromStr, U: FromStr>() -> (T, U) {
    let s = read_string();
    let elems: Vec<_> = s.trim().split_whitespace().collect();
    (
        elems[0].parse().ok().expect("failed to parse"),
        elems[1].parse().ok().expect("failed to parse"),
    )
}

// 1.5 -2 abc
fn read_as_triple<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let s = read_string();
    let elems: Vec<_> = s.trim().split_whitespace().collect();
    (
        elems[0].parse().ok().expect("failed to parse"),
        elems[1].parse().ok().expect("failed to parse"),
        elems[2].parse().ok().expect("failed to parse"),
    )
}

fn main() {
    let n: i32 = read_as_primitive();
    let ans = match n {
        25 => "Christmas",
        24 => "Christmas Eve",
        23 => "Christmas Eve Eve",
        22 => "Christmas Eve Eve Eve",
        _  => "",
    };
    println!("{}", ans);

}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

const int INF = 1001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, t, a;
    cin >> n >> t >> a;
    vi h(n);
    rep(i, n) cin >> h[i];
    int ans;
    int mn = INF;
    rep(i, n) {
        if (chmin(mn, abs(1000*t - 6*h[i] - 1000*a))) ans = i+1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import bisect
from collections import deque
n=int(input())
a=[int(input()) for _ in range(n)]

q=[]
def bisect_desc(a,x):
    r = len(a)
    if r == 0:
        return 0
    l = 0
    while l != r:
        f = (l+r)//2
        if a[f] >= x:
            l = f+1
        else:
            r = f
    return l

for sa in a:
    t = bisect_desc(q,sa)
    if t ==len(q):
        q.append(sa)
    else:
        q[t] = sa

print(len(q))

Measured memory_bytes: 54744
#include <stdio.h>

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    int a[n][m];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            scanf("%d", &a[i][j]);
        }
    }
    int b[m];
    for (int i = 0; i < m; i++)
    {
        scanf("%d", &b[i]);
    }
    int v=0;
    for (int i = 0; i < n; i++)
    {
        v=0;
        for (int j = 0; j < m; j++)
        {
            v+=b[j]*a[i][j];
        }
        printf("%d\n", v);
    }
    
    
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#include <cstdlib>
#define ll long long
#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define MX 100010
using namespace std;

int a[5];
int k;
bool ans;

int main(){
        FOR(i,0,5){
                cin >> a[i];
        }
        cin >> k;
        ans = false;
        FOR(i,0,5){
                FOR(j,i,5){
                  if(a[j] - a[i] > k){
                        ans=true;
                  }
                }
        }

        if(!ans) cout << "Yay!" << endl;
        else cout << ":(" << endl;
        return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<ll> a(N),b(N),c(N);
  for(int i = 0; i < N; ++i){
    cin >> a[i];
  }
  for(int i = 0; i < N; ++i){
    cin >> b[i];
  }
  for(int i = 0; i < N; ++i){
    cin >> c[i];
  }
  sort(a.begin(), a.end());
  sort(c.begin(), c.end());

  ll ans = 0;
  for(int i = 0; i < N; ++i){
    ll up = upper_bound(c.begin(), c.end(), b[i]) - c.begin();
    up = N - up;
    ll down = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    ans += up * down;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2688
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons;
import std.math, std.numeric;


void main() {
    int n; scan(n);
    char[][] ban = new char[][](n, n);
    iota(n).each!(i => ban[i] = readln.chomp.to!(char[]));

    long ans;

    foreach (i ; 0 .. n) {
        if (isSym(n, ban, 0, i)) {
            ans += n;
        }
    }

    writeln(ans);
}

bool isSym(int n, char[][] ban, int a, int b) {
    auto cop = new char[][](n, n);

    foreach (i ; 0 .. n) {
        foreach (j ; 0 .. n) {
            cop[i][j] = ban[(i + a) % n][(j + b) % n];
        }
    }

    debug {
        writefln("(a, b) = (%d, %d)", a, b);
        writefln("%-(%s\n%)", cop);
    }

    foreach (i ; 0 .. n) {
        foreach (j ; 0 .. n) {
            if (cop[i][j] != cop[j][i]) {
                return false;
            }
        }
    }

    return true;
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 11132
def insertionSort(A, n, g):
  ret=0
  for i in range(g,n):
    v = A[i]
    j = i - g
    while j >= 0 and A[j] > v:
      A[j+g] = A[j]
      j = j - g
      ret+=1
      A[j+g] = v
  return ret

n=int(input())
arr=[int(input()) for _ in range(n)]
cnt=0
g=[]
h=1
while h<=n:
  g.append(h)
  h=h*3+1
g=sorted(g,reverse=True)
m=len(g)
for i in range(m):
  cnt+=insertionSort(arr, n, g[i])
print(m)
print(' '.join(map(str,g)))
print(cnt)
for i in range(n):
  print(arr[i])


Measured memory_bytes: 45508
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c,count,x;
    cin >> a >>b >> c;
    count=b/c;
    x=a/c;
    if(a%c==0){
        count ++;
    }
    cout << count-x << endl;
    return 0;

}


Measured memory_bytes: 256
while True:
    s = input()
    if s == '#':
        break
    else:
        a, b, c, d = map(int, input().split())
        s_list = s.split('/')
        a_str = ''
        if a == c:
            for i in s_list[a-1]:
                if i == 'b':
                    a_str += 'b'
                else:
                    a_str += '.' * int(i)
            a_tmp = a_str[min(b, d)-1]
            c_tmp = a_str[max(b, d)-1]
            a_rep = a_str[:min(b, d)-1] + c_tmp + a_str[min(b, d):max(b, d)-1] + a_tmp + a_str[max(b, d):]
            a_s = ''
            count = 0
            flag = 0
            for i in a_rep:
                if i == '.':
                    flag = 1
                    count += 1
                elif flag == 1:
                    a_s += str(count)
                    a_s += str('b')
                    flag = 0
                    count = 0
                else:
                    a_s += str('b')
                    flag = 0
                    count = 0
            if flag == 1:
                a_s += str(count)
                flag = 0
            s_list[a-1] = a_s
        else:
            for i in s_list[a-1]:
                if i == 'b':
                    a_str += 'b'
                else:
                    a_str += '.' * int(i)
            a_tmp = a_str[b-1]
            c_str = ''
            for i in s_list[c-1]:
                if i == 'b':
                    c_str += 'b'
                else:
                    c_str += '.' * int(i)
            c_tmp = c_str[d-1]
            a_rep = a_str[:b-1] + c_tmp + a_str[b:]
            c_rep = c_str[:d-1] + a_tmp + c_str[d:]
            flag = 0
            count = 0
            a_s = ''
            for i in a_rep:
                if i == '.':
                    flag = 1
                    count += 1
                elif flag == 1:
                    a_s += str(count)
                    a_s += str('b')
                    flag = 0
                    count = 0
                else:
                    a_s += str('b')
                    flag = 0
                    count = 0
            if flag == 1:
                a_s += str(count)
                flag = 0
            count = 0
            c_s = ''
            for i in c_rep:
                if i == '.':
                    flag = 1
                    count += 1
                elif flag == 1:
                    c_s += str(count)
                    c_s += str('b')
                    flag = 0
                    count = 0
                else:
                    c_s += str('b')
                    flag = 0
                    count = 0
            if flag == 1:
                c_s += str(count)
            s_list[a-1] = a_s
            s_list[c-1] = c_s
        out = ''
        for i in range(len(s_list)):
            out += s_list[i]
            if i < len(s_list) - 1:
                out += '/'
        print(out)



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


def main():
    h, w = map(int, input().split())
    ch, cw = map(int, input().split())
    dh, dw = map(int, input().split())
    
    ch += 1
    cw += 1
    dh += 1
    dw += 1
    
    
    s = ["#"*(w+4)]
    s.append("#"*(w+4))
    for i in range(h):
        s.append("##" + input()[:-1] + "##")
    s.append("#"*(w+4))
    s.append("#"*(w+4))
    
    
    ans = [[-1]*(w+4) for _ in range(h+4)]
    for i in range(h+4):
        for j in range(w+4):
            if s[i][j] == "#":
                ans[i][j] = -2
    ans[ch][cw] = 0
    
    move = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    move2 = [(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), \
             (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), \
             (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), \
             (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), \
             (2, -2), (2, -1), (2, 0), (2, 1), (2, 2)]
        
    not_yet = [(ch, cw)]
    one_time = []
    
    while len(not_yet) > 0:
        x, y = not_yet.pop()
        one_time.append((x, y))
        for (p, q) in move:
            v1, v2 = x+p, y+q
            if ans[v1][v2] == -1:
                not_yet.append((v1, v2))
                ans[v1][v2] = ans[x][y]
                
        if len(not_yet) == 0:
            while len(one_time) > 0:
                x2, y2 = one_time.pop()
                for (v1, v2) in move2:
                    i, j = x2+v1, y2+v2
                    if ans[i][j] == -1:
                        ans[i][j] = ans[x2][y2]+1
                        not_yet.append((i, j))
          
    print(ans[dh][dw])
    
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 23196
fun main(args: Array<String>) {
    val (n, d) = readLine()!!.split(" ").map { it.toInt() }
    val xList = Array(n) {
        readLine()!!.split(" ").map { it.toDouble() }.toTypedArray()
    }

    var sum = 0
    for (i in 0 until n) {
        for (j in i + 1 until n) {
            val current = xList[i]
            val target = xList[j]

            val sumDiff = current.mapIndexed { index, l -> Math.pow(l - target[index], 2.toDouble()) }.sum()

            val num: Double = Math.sqrt(sumDiff)

            val isInteger = (num - num.toInt()) == 0.toDouble()
            if (isInteger) sum++
        }
    }
    println(sum)
}


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

template<typename T> T changeMax(T& a, T b){
    if(a < b)a = b;
    return 0;
}
int n;
ll w[110], v[110];
ll W, dp[110][100010] = {0}; 
int main()
{
    
    cin >> n >> W;
    rep(i, n) cin >> w[i] >> v[i];
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= W; j++){
            if(j - w[i] >= 0){
                changeMax(dp[i+1][j], dp[i][j-w[i]]+v[i]);
            }
            changeMax(dp[i+1][j], dp[i][j]);
        }
    }
    cout << dp[n][W] << endl;
}

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

using namespace std;

typedef long long ll;

int f(ll x) {
	int r = 1;
	x /= 10;
	while(x > 0) {
		r++;
		x /= 10;
	}
	return r;
}

int main() {
	ll n;
	scanf("%lld", &n);
	int ret = 100;
	for(int i = 1; i <= 100000; i++) {
		if(n%i==0) {
			ret = min(ret, max(f(i), f(n/i)));
		}
	}
	printf("%d\n", ret);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,a,b;
  	int c = 0;
  	bool f = false;
    cin >> n;
  	for (int i = 0; i < n; i++){
  		cin >> a >> b;
    	if(a == b){c++;} 
     	else{c = 0;}
    	if (c == 3){
    		f = true;
			break;
    	}      		
  	}
     	if(f)cout << "Yes" <<endl;
  		else cout << "No" << endl;

}

Measured memory_bytes: 3600
h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(list(input()))
c = 0
inds = [[-1] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            inds[i][j] = c
            c += 1
inf = 10**10
graph = [[inf] * c for _ in range(c)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            d = inds[i][j]
            graph[d][d] = 0
            if j > 0 and s[i][j-1] == '.':
                graph[d][inds[i][j-1]] = 1
            if j < w-1 and s[i][j+1] == '.':
                graph[d][inds[i][j+1]] = 1
            if i >0 and s[i-1][j] == '.':
                graph[d][inds[i-1][j]] = 1
            if i < h-1 and s[i+1][j] == '.':
                graph[d][inds[i+1][j]] = 1
for k in range(c):
    for i in range(c):
        for j in range(c):
            graph[i][j] = min(graph[i][j],graph[i][k] + graph[k][j])
mins = 0
for i in range(c):
    for j in range(c):
        if graph[i][j] > mins:
            mins = graph[i][j]
print(mins)


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

int main()
{
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            cout << i << 'x' << j << '=' << i*j << endl;
        }
    }

	getchar();
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=1e5;
int N;
vector<int> G[MAX_N];
int cnt[2],dis[2][MAX_N];

void bfs(int f){
	int s=(f==0 ? 0 : N-1);
	memset(dis[f],-1,sizeof(dis[f]));
	dis[f][s]=0;
	queue<int> que;
	que.push(s);
	while(!que.empty()){
		int v=que.front();
		que.pop();
		for(auto e:G[v]){
			if (dis[f][e]==-1){
				dis[f][e]=dis[f][v]+1;
				que.push(e);
			}
		}
	}
}
int main(){
	cin>>N;
	REP(i,N-1){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	bfs(0);
	bfs(1);
	REP(i,N){
		if (dis[0][i]<=dis[1][i]){
			cnt[0]++;
		}else{
			cnt[1]++;
		}
	}
	cout<<(cnt[0]>cnt[1] ? "Fennec" : "Snuke")<<endl;
	return 0;
}

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

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

for(int b=-118;b<120;b++)
for(int a = -118;a<120;a++)
if(x==(a*a*a*a*a)-(b*b*b*b*b))
{
    cout<<a<<" "<<b<<endl;
    return 0;
}
    return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
int main(void){
    int i,x,y;
    char S[3];
    x=700;

    for(i=0; i<3; i++){
        scanf("%c",&S[i]);

        if(S[i]=='o'){
            y+=100;
        }

        else{
            x=x;
        }   
    }
    printf("%d\n",x+y);
    return 0;
}

Measured memory_bytes: 128
function main(input) {
  input = input.trim();
  const [a, b] = input.split(" ").map(n => Number(n));
  let result = "Yes";
  if (a === 2 || b === 2) {
    result = "No";
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int simple_interest(int initial_fund, int years, double interest_rate, int operation_charge);
int compound_interest(int initial_fund, int years, double interest_rate, int operation_charge);

int main(int argc, char const* argv[])
{
  int m;
  std::cin >> m;
  for (int case_num = 0; case_num < m; ++case_num) {
    int initial_fund, n_years, n;
    std::cin >> initial_fund >> n_years >> n;
    std::vector<int> results(n);
    for (int n_op = 0; n_op < n; ++n_op) {
      int simple_or_compound;
      double annual_interest_rate;
      int annual_operation_charge;
      std::cin >> simple_or_compound >> annual_interest_rate >> annual_operation_charge;
      results[n_op] = simple_or_compound
        ? compound_interest(initial_fund, n_years, annual_interest_rate, annual_operation_charge)
        : simple_interest(initial_fund, n_years, annual_interest_rate, annual_operation_charge);
    }
    std::cout << *std::max_element(results.begin(), results.end()) << std::endl;
  }
  return 0;
}

int simple_interest(int initial_fund, int years, double interest_rate, int operation_charge) {
  int cumulative_interest = 0;
  int fund = initial_fund;
  for (int y = 0; y < years; ++y) {
    cumulative_interest += fund * interest_rate;
    fund -= operation_charge;
  }
  return fund + cumulative_interest;
}

int compound_interest(int initial_fund, int years, double interest_rate, int operation_charge) {
  int fund = initial_fund;
  for (int y = 0; y < years; ++y) {
    int interest = fund * interest_rate;
    fund = fund + interest - operation_charge;
  }
  return fund;
}

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

int main()
{
  int max = 0;
  int c, t;
  t = 0;
  cin >> c;
  for ( int i = 0; i < c; i++ ) {
    int x;
    cin >> x;
    t += x;
    if ( x > max ) { max = x; }
  }
  t -= max;
  if ( max < t )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    ll x=100;
    ll cnt =0;
    while(x<n){
        x+=x/100;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
# input
n = int(input())
value = [int(a) for a in input().split()]
cost = [int(a) for a in input().split()]

profit = 0
for i in range(n):
    tmp = value[i] - cost[i]
    if tmp > 0:
        profit += tmp

print(profit)


Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
	int H,W,i,j;

	while(1){
		scanf("%d %d",&H,&W);
		
		if(H==0 && W==0){
		break;
		}else{
			for(i=0;i<H;i++){
				for(j=0;j<W;j++){
					if((i%2==1 &&j%2==0) || (i%2==0 &&j%2==1)){
						printf(".");
					}else{
						printf("#");
					}
				}
				printf("\n");
			}
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 2056
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
          string input_line = Console.ReadLine();
          if(input_line[0] == input_line[1] && input_line[1] == input_line[2])
          {
            Console.WriteLine("No");
          }else
          {
            Console.WriteLine("Yes");
          }
        }
    }
}


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

main()
{
    int n; cin>>n;
    int acc=0;
    vector<pair<int,int>> v1,v2;
    for(int i=0; i<n; ++i)
    {
        string s; cin>>s;
        int now=0;
        int mi=0;
        for(char c: s)
        {
            if(c=='(') now++;
            else now--;
            mi=min(mi,now);
        }
        if(mi<0)
        {
            if(now>0)
            {
                v1.emplace_back(mi,now);
            }
            else
            {
                v2.emplace_back(mi-now,now);
            }
        }
        else
        {
            acc+=now;
        }
    }
    sort(rbegin(v1),rend(v1));
    sort(begin(v2),end(v2));
    for(auto [b,a]: v1)
    {
        if(acc+b<0)
        {
            cout << "No" << "\n";
            return 0;
        }
        acc+=a;
    }
    for(auto [b,a]: v2)
    {
        b+=a;
        if(acc+b<0)
        {
            cout << "No" << "\n";
            return 0;
        }
        acc+=a;
    }
    if(acc)
    {
        cout << "No" << "\n";
    }
    else
    {
        cout << "Yes" << "\n";
    }

}

Measured memory_bytes: 7464
import java.util.Scanner;
import java.util.*;

public class Main {

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

		int N = sc.nextInt();
		int W = sc.nextInt();
		int[] weight = new int[N+1];
		long[] value = new long[N+1];
		weight[0] = 0;
		value[0] = 0;
		for(int i=1;i<=N;i++){
			weight[i] = sc.nextInt();
			value[i] = sc.nextInt();
		}

		long[][] dp = new long[N+1][W+1];
		for(int j=0;j<=W;j++){
			dp[0][j] = 0;
		}

		for(int i=1;i<=N;i++){
			for(int j=0;j<=W;j++){
				if(j-weight[i]<0){
					dp[i][j] = dp[i-1][j];
				}else{
					long dp1 = dp[i-1][j];
					long dp2 = dp[i-1][j-weight[i]]+value[i];
					if(dp1>dp2){
						dp[i][j] = dp1;
					}else{
						dp[i][j] = dp2;
					}
				}
			}
		}
		System.out.println(dp[N][W]);
	}
}


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

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

  vector<int> A(N), B(N), C(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> B[i];
  for (int i = 0; i < N; i++) cin >> C[i];

  // 昇順
  sort(A.begin(), A.end());
  sort(C.begin(), C.end());

  ll ans = 0;

  for (int i = 0; i < N; i++) {
    // lower_bound は指定した値以上の要素の一番左のイテレータを返す
    ll a = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
    // upper_bound は指定した値より大きいの要素の一番左のイテレータを返す
    ll c = upper_bound(C.begin(), C.end(), B[i]) - C.begin();
    ans += a * (N - c);
  }

  cout << ans << endl;
}

Measured memory_bytes: 4588
#include <iostream>

using namespace std;

int main()
{
    char a[4][4];
    for (int i=0;i<3;i++)
        for (int j=0;j<3;j++)
        cin>>a[i][j];
        cout<<a[0][0]<<a[1][1]<<a[2][2]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll A, B; cin >> A >> B;
  cout << max(A+B, max(A-B, A*B)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
using namespace std;

bool HaveNeighbor(int i, int j, const vector<string>& sm){
    if(j-1 >= 0           && sm[i][j-1]=='#') return true;
    if(j+1 < sm[i].size() && sm[i][j+1]=='#') return true;
    if(i-1 >= 0           && sm[i-1][j]=='#') return true;
    if(i+1 < sm.size()    && sm[i+1][j]=='#') return true;
    return false;
}

bool IsPossible(vector<string> sm){
    for(int w=0; w<sm.size(); w++){
        for(int h=0; h<sm.front().size(); h++){
            if(sm[w][h]=='#' && !HaveNeighbor(w,h,sm)) return false;
        }
    }
    return true;
}

int main()
{
    size_t H, W;
    cin >> H >> W;
    string s;
    vector<string> sm;
    for(size_t i=0;i<H;i++){
        cin >> s;
        sm.push_back(s);
    }
    auto possible = IsPossible(sm);
    if(possible) cout << "Yes" << endl;
    else         cout << "No" <<endl;
    return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k%2){
    cout<<b-a<<endl;
  }else
    cout<<a-b<<endl;
 
  return 0;
}


Measured memory_bytes: 256
n = int(input())
d_array = [int(x) for x in input().split()]
counter = {x: 0 for x in range(-1, 10 ** 5 + 1)}
for i in d_array:
    counter[i] += 1
MOD = 998244353
if d_array[0] != 0 or counter[0] != 1:
    print(0)
    exit()
ans = 1
for num in set(d_array):
    if num == 0:
        continue
    if counter[num-1] == 0:
        print(0)
        exit()
    ans *= (counter[num-1])**counter[num]
    ans = ans % MOD
else:
    print(ans)

Measured memory_bytes: 65072
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<map>
#include<set>
#include<stdio.h>
using namespace std;
const int INF = 100000000;
#define MAX_N 7368792
bool flower[MAX_N];
bool prime[MAX_N];
/*
void eratos(){
  for(int i = 0; i < MAX_N; i++){
    prime[i] =true;
  }
  prime[0]=false, prime[i] = false;
  for(int i = 2; i < MAX_N; i++){
    if(prime[i] == true){
      for(int k = i + i; k < MAX_N; k++){
        prime[k] = false;
      }
    }
  }
}
*/
void flower_times(int M){
  for(int i = 0; i < MAX_N; i++){
    flower[i] =false;
  }
  for(int i = M; i <= 2*M - 1; i++){
    flower[i] =true;
    for(int k = i + i; k < MAX_N; k = k + i){
      flower[k] = true;
    }
  }
}
int main(){
  int m, n;
  while(true){
    cin >> m >> n;
    if(m == 0 && n == 0){
      break;
    }
    int ans = 0;
    flower_times(m);
    if(n < m){
      ans = n + m;
    }else{
      int count = m ;
      for(int i = m; i < MAX_N; i++){
        if(!flower[i]){
          if(count == n){
            ans = i;
            i = MAX_N;
          }else{
            count++;
            flower[i] = true;
            for(int k = i + i; k < MAX_N; k = k + i){
              flower[k] = true;
            }
          }
        }
      }
      if(count < n){
        ans = 7368791;
      }
    }
    cout << ans << endl;
  }
  return 0;
}



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

int main()
{

    int n, k, l;
    cin >> n >> k >> l;

    int count = 0;

    int d = k - n;

    count = d / l;

    if (k % l == 0)
    {

        count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 3168
s = str(input())
Acount = 3000000
Zcount = 0
for i in range (len(s)):
    if (s[i] == 'A' and i < Acount):
        Acount = i

for j in range (len(s)):
    if (s[j] == 'Z' and j > Zcount):
        Zcount = j

print(Zcount - Acount +1)

Measured memory_bytes: 3516
#include <bits/stdc++.h>
#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

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

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

using namespace std;

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

int n,m,ans;
int main() {
    cin>>n>>m;
    int x[m],diff[m-1];
    REP(i,m){
        cin>>x[i];
    }
    sort(x,x+m);
    ans=x[m-1]-x[0];
    REP(i,m-1){
        diff[i]=x[i+1]-x[i];
    }
    sort(diff,diff+m-1,greater<int>());
    if(n>=m){cout<<0<<endl;return 0;}
    REP(i,n-1){
        ans-=diff[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int N;
  scanf("%d", &N);
  int ans = N;
  rep(i, 0, N + 1) {
    int cnt = 0;
    int num = i;
    while ( num > 0 ) cnt += num % 6, num /= 6;
    num = N - i;
    while ( num > 0 ) cnt += num % 9, num /= 9;  
    ans = min(ans, cnt);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[101];
bool cmp(int x,int y)
{
	return x>y; 
}
int main()
{
	int n,m;cin>>n>>m;
	int s=0;
	for(int i=1;i<=n;s+=a[i++])
		cin>>a[i];
	sort(a+1,a+n+1,cmp);
	if(a[m]<s/4.0/m)cout<<"No";
	else		  cout<<"Yes";
}

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

int take()
{
    int n;
    scanf("%d",&n);
    return n;

}

ll takes()
{
    ll n;
    scanf("%lld",&n);
    return n;

}
#define M 200005
#define Int take()
#define LL takes()

#define fr(n) for(int i=1;i<=n;i++)
#define rfr(n) for(int i=n;i>=1;i--)
int cas;
#define print printf("Case %d:",++cas)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mk  make_pair
#define fill(x,v) memset(x,v,sizeof x)
using namespace std;

int C[11][11],dp[11][11];

int main(){

    int r=Int,c=Int;

    for(int i=0;i<=9;i++){
        for(int k=0;k<10;k++)
            dp[i][k]=Int;
    }

    for(int i=0;i<10;i++){
        for(int k=0;k<10;k++){
            for(int j=0;j<10;j++){
                if( dp[k][j]>=dp[k][i]+dp[i][j])
                    dp[k][j]=dp[k][i]+dp[i][j];
            }
        }
    }
    int ans=0,v;
    fr(r){
        for(int k=1;k<=c;k++){
            v=Int;
            if(v>=0)
                ans+=dp[v][1];
        }
    }
    printf("%d\n",ans);
    return 0;
}


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

int main()
{
    int a, b, i;
    char op;
    cin >> a >> op >> b;
    for (i=1;op!='?';i++)
    {
            if (op== '+')
            {
              cout << (a+b) << endl;
                cin >> a >> op >> b;
            }
            else if (op=='-')
              {
                  cout << (a-b) << endl;
                cin >> a >> op >> b;
              }
            else if (op=='*')
              {
                  cout << (a*b) << endl;
                cin >> a >> op >> b;
              }
            else if (op=='/')
            {
              cout << (a/b) << endl;
                cin >> a >> op >> b;
            }
           
            
    }

   return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> s;
	string t[] = {"SUN","MON","TUE","WED","THU", "FRI", "SAT"};
	rep(i, 0, 6){
		if(s == t[i]){
			print(7-i)
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

int main() {
    int r;
    cin >> r;
    int ans = (r*r);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int,input().split())
res = []
for i in range(M):
  if i%2==0:
    j = i//2
    #res.append(M-2*j)
    print("{} {}".format(1+j,M+1-j))
  else:
    j = i//2
    #res.append(M-1-2*j)
    print("{} {}".format(M+2+j,2*M+1-j))

Measured memory_bytes: 9224
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


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

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


int main(){
    FIN;
    ll n; cin >> n;
    ll a; cin >> a;
    ll ans = a;
    for(ll i=1;i<n;i++){
        cin >> a;
        ans = gcd(ans,a);
    }

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



Measured memory_bytes: 3636
N = int(input())
S = input()

cnt_b = [0 for i in range(N)]    # i番目を含んでにそれまでにb，wが何個あるか
cnt_w = [0 for i in range(N)]

if S[0] == "#":
    cnt_b[0] = 1
else:
    cnt_w[0] = 1

for i in range(1, N):
    if S[i] == "#":
        cnt_b[i] = cnt_b[i-1] + 1
        cnt_w[i] = cnt_w[i-1]
    else:
        cnt_b[i] = cnt_b[i-1]
        cnt_w[i] = cnt_w[i-1] + 1

cnt_change_to_w = [0 for i in range(N)]
cnt_change_to_b = [0 for i in range(N)]
for i in range(N):
    cnt_change_to_b[i] = cnt_b[i] + cnt_w[N - 1] - cnt_w[i]

for i in range(N):
    cnt_change_to_w[i] = cnt_b[i] + cnt_w[N - 1] - cnt_w[i]
    if S[i] == "#":
        cnt_change_to_w[i] -= 1

min1 = min(cnt_change_to_b)
min2 = min(cnt_change_to_w)
print(min(min1, min2))

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

int main() {
  string s;
  cin >> s;
  vector<string> day;
  int n;
  day = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  for(int i=0; i<7; i++){
    if(s == day.at(i)){
      n = i;
      break;
    }
  }
  if(s == "SUN"){
    cout << 7 << endl;
  }
  else{
    cout << 7-n << endl;
  }
}

Measured memory_bytes: 256
M = gets.chop.to_i
nums = gets.chop.split.map(&:to_i)

nums.sort!

max_num = nums.pop
min_num = nums.shift

process = []
while !nums.empty? && nums[0] <= 0
  num = nums.shift
  process << "#{max_num} #{num}"
  max_num -= num
end

nums.each do |n|
  process << "#{min_num} #{n}"
  min_num	-= n
end

process << "#{max_num} #{min_num}"
max_num -= min_num

puts max_num
puts process.join("\n")

Measured memory_bytes: 21240
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<map>
using namespace std;
typedef long long int ll;
 
ll gcd(ll a, ll b){
    if (b == 0) return a;

    return gcd(b, a % b);
}

int main(){
    ll N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;

    string T;
    cin >> T;

    ll sum = 0;
    for (int i = 0; i < N; i++){
        if (T[i] == 'r') sum += P;
        else if (T[i] == 's') sum += R;
        else sum += S;
    }

    for (int i = 0; i < K; i++){
        int num = 0;
        int tmp = 0;
        while(i + (tmp + 1) * K <= N - 1){
            if (T[i + tmp * K] == T[i + (tmp + 1) * K]) {
                if (num % 2 == 0){
                    if (T[i + tmp * K] == 'r') sum -= P;
                    else if (T[i + tmp * K] == 's') sum -= R;
                    else sum -= S;
                }
                num++;
            }
            else num = 0;

            tmp++;
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 512
#include <stdio.h>

#define MAX_SIZE 100002

#define OK  0
#define NG  1

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))


int Col[MAX_SIZE];
int Row[MAX_SIZE];

/* いもす準備された配列とサイズを受け取り、いもす展開しながら全て1以上であればOKを返す */
int check(int list[],int list_size){
    int i,ret;

    ret = OK;
    /* いもす展開 ＆ 判定 */
    for(i=0;i<list_size;i++){
        if(list[i]<=0){
            ret = NG;
            break;
        }
        list[i+1]+=list[i];
    }
    return ret;
}

int main(){
    int n,w,h;
    int xi,yi,wi;
    int i,ans;

    /* 初期化 */
    for(i=0;i<MAX_SIZE;i++){
        Col[i]=0;
        Row[i]=0;
    }

    /* いもす準備 */
    scanf("%d %d %d",&n,&w,&h);
    for(i=0;i<n;i++){
        scanf("%d %d %d",&xi,&yi,&wi);
        Col[MAX(xi-wi,0)]++;
        Col[MIN(xi+wi,w)]--;
        Row[MAX(yi-wi,0)]++;
        Row[MIN(yi+wi,h)]--;
    }

    /* いもす展開 ＆ 判定 */
    /* 縦か横のどちらかが全範囲を網羅できていればよい */
    if( (check(Col,w)==OK) || (check(Row,h)==OK) ){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;

}



Measured memory_bytes: 2504
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
const int maxn=1e3+5;
char maze[maxn][maxn];
int h,w;
int ch,cw,dh,dw;
int vis[maxn][maxn];
int drow[4]={0,0,1,-1};
int dcol[4]={1,-1,0,0};
bool inboard(int row,int col)
{
    if(row>=0&&row<h&&col>=0&&col<w)
        return true;
    return false;
}
void dfs(int row,int col,int id)
{
    vis[row][col]=id;
    for(int i=0;i<4;++i)
    {
        int nextrow=row+drow[i];
        int nextcol=col+dcol[i];
        if(inboard(nextrow,nextcol)&&maze[nextrow][nextcol]=='.'&&vis[nextrow][nextcol]==-1)
            dfs(nextrow,nextcol,id);
    }
}
int main(void)
{
    cin>>h>>w>>ch>>cw>>dh>>dw;
    for(int i=0;i<h;++i)
        for(int j=0;j<w;++j)
            cin>>maze[i][j];
    memset(vis,-1,sizeof(vis));
    int id=0;
    for(int i=0;i<h;++i)
        for(int j=0;j<w;++j)
            if(maze[i][j]=='.'&&vis[i][j]==-1)
                dfs(i,j,id),id++;
    unordered_set<int> edge[id+1];
    for(int i=0;i<h;++i)
        for(int j=0;j<w;++j)
        {
            if(maze[i][j]=='#') continue;
            for(int p=i-2;p<=i+2;++p)
                for(int q=j-2;q<=j+2;++q)
                    if(inboard(p,q)&&maze[p][q]=='.'&&vis[p][q]!=vis[i][j])
                        edge[vis[p][q]].insert(vis[i][j]),edge[vis[i][j]].insert(vis[p][q]);
        }
    int start=vis[ch-1][cw-1];
    int end=vis[dh-1][dw-1];

    queue<int> q;
    int dis[id+1];
    bool visi[id+1];
    memset(visi,0,sizeof(visi));
    q.push(start);
    dis[start]=0;
    visi[start]=true;
    while(!q.empty())
    {
        int now=q.front();
        q.pop();
        for(auto it=edge[now].begin();it!=edge[now].end();++it)
            if(visi[*it]==false)
                visi[*it]=true,q.push(*it),dis[*it]=dis[now]+1;
    }
    if(visi[end]==false)
        cout<<-1<<endl;
    else
        cout<<dis[end]<<endl;
    return 0;
}

Measured memory_bytes: 34172
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;cin>>n;
	rep(i, n){
		int a;cin>>a;
		if(a%2==0){
			if(a%3==0||a%5==0){

			}else{
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1005;
const int MAXM=10005;
int fa[MAXN];
pair< int, pair<int, int> > E[MAXM];
int find(int x){
    return fa[x]=fa[x]==x?x:find(fa[x]);
}
int main(){
    int n, m;
    while(cin>>n>>m&&(n||m)){
        for(int i=1; i<=n; i++){
            fa[i]=i;
        }
        for(int i=0, x, y, w; i<m; i++){
            scanf("%d%d%d",&x,&y,&w);
            E[i]=make_pair(w,make_pair(x,y));
        }
        sort(E,E+m);
        for(int i=0, cnt=0; i<m; i++){
            int u=find(E[i].second.first);
            int v=find(E[i].second.second);
            int w=E[i].first;
            if(u!=v){
                fa[u]=v;
                cnt++;
                if(cnt*2>=n-1){
                    printf("%d\n",w);
                    break;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1336
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s,t;
  cin >> s >> t;
  s += t;
  int n = atoi(s.c_str());
  for(int i=1; i<=320; i++) {
    if(n == i*i) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(num) scanf("%d",&num)
#define sff(num1,num2) scanf("%d %d",&num1,&num2)
#define sfff(num1,num2,num3) scanf("%d %d %d",&num1,&num2,&num3);
#define sl(num) scanf("%lld",&num)
#define sll(num1,num2) scanf("%lld %lld",&num1,&num2)
#define slll(num1,num2,num3) scanf("%lld %lld %lld",&num1,&num2,&num3);
#define rep(i,n) for(i=1;i<=n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define pb push_back
#define mpp make_pair
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
#define TIME cerr<<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<"s\n";
typedef long long int ll;
using namespace std;
int main()
{
    int x,a;
    cin>>x>>a;
    if(x<a)
        pf("0");
    else
        pf("10");
}


Measured memory_bytes: 256