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

using namespace std;

const int N=1e6+3;

const double eps=0.000000001;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9,mod=1e9+7;

int n,m,a[N],b[N],k,q,u,v,x,y,tc,l,r,c,ans,cnt[100005],p;

char s[N];

void IO(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("test.txt","r",stdin);
	#endif
}

char grid[105][105];

int dp[105][105][2];

int solve(int x,int y,bool blocked){
	if (x<0 || x>=r || y<0 || y>=c)
		return 1e9;
	if (x==r-1 && y==c-1){
		blocked|=grid[x][y]=='#';
		return blocked;
	}
	int &ret=dp[x][y][blocked];
	if (~ret)
		return ret;
	int add=0;
	if (blocked && grid[x][y]=='.')
		blocked=false,add=1;
	blocked|=grid[x][y]=='#';
	int wa=solve(x+1,y,blocked);
	wa=min(wa,solve(x,y+1,blocked));
	ret=add+wa;
	return ret;
}

int main(){
	//IO();
	memset(dp,-1,sizeof dp);
	scanf("%d%d",&r,&c);
	for(int i=0;i<r;i++)
		scanf("%s",grid[i]);
	printf("%d\n",solve(0,0,0));
}

Measured memory_bytes: 384
fun main(args: Array<String>) {
  val first = readLine()!!.split(" ")
  val n = Integer.parseInt(first[0])
  val k = Integer.parseInt(first[1])
  val s = readLine()!!
  val t = s.get(k - 1)
  var after = ""
  
  when (t) {
    'A' -> {
        after = "a"
    }
    'B' -> {
        after = "b"
    }
    'C' -> {
        after = "c"
    }
  }
  
  var a1 = s.substring(0, k - 1)
  val a2 = s.substring(k)
  val result = a1 + after + a2
  println(result)
}

Measured memory_bytes: 36120
import java.text.DecimalFormat;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        long[] a = IntStream.range(0, 3).mapToLong(i -> sc.nextLong()).sorted().toArray();
        
        out.println(a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0 ? "0" : a[0] * a[1]);
        
        out.flush();
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
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());
    }
}


Measured memory_bytes: 26580
#include<stdio.h>

int main(void){
  long long n , k;
  scanf("%lld %lld",&n ,&k);

  long long ans = n%k;
  if(n%k > k - n%k){
    ans = k - n%k;
  }

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

  return 0;
}

Measured memory_bytes: 1700
#[allow(dead_code)]
fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

#[allow(unused_macros)]
macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

#[allow(unused_macros)]
macro_rules! debug { ($x: expr) => { println!("{}: {:?}", stringify!($x), $x) } }
// macro_rules! debug { ($x: expr) => () }

#[allow(dead_code)]
fn show<T>(iter: T) -> String
where
    T: Iterator,
    T::Item: std::fmt::Display
{
    let mut res = iter.fold(String::new(), |sum, e| sum + &format!("{} ", e));
    res.pop();
    res
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::collections::btree_map::Entry::{Occupied, Vacant};

fn main() {
    use std::io::Write;
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    macro_rules! printf { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); }
    macro_rules! printfln { () => (writeln!(out).unwrap()); ($($arg:tt)*) => (writeln!(out, $($arg)*).unwrap()); }
    
    let (a, b, c) = readl!(i32, i32, i32);
    let k = readl!(i32);
    let ma = max(a, max(b, c));
    printfln!("{}", 2_i32.pow(k as u32) * ma + a + b + c - ma);
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int sum = 0;
    int N; cin >> N;
    int d[10010];
    rep(i, N) cin >> d[i];
    rep(i, N) {
        REP(j, i + 1, N - 1) {
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

typedef pair <int, int> pii;

const int Inf = 100000;
const int mod = 1000000007;
const double Pi = acos(-1);

void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n;
int sum = 0;
bool dp[2005][100000];

int main()
{
	cin >> n;
	dp[0][0] = true;
	for(int i = 1; i <= n; i++)
	{
		int temp;
		cin >> temp;
		sum += temp;
		for(int j = 99999; j >= 0; j--)
		{
			if(j + temp <= 99999)
				dp[i][j + temp] |= dp[i - 1][j];
			if(j - temp >= 0)
				dp[i][j - temp] |= dp[i - 1][j];
			else
				dp[i][temp - j] |= dp[i - 1][j];
		}
	}
	for(int i = 0; i <= 99999; i++)
	{
		if(dp[n][i])
		{
			cout << (sum + i) / 2;
			return 0;
		}
	}
}

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

int n,k,a[10];
string s;

int main() {
  rep(i,4){
  cin >> n; a[n]++;
  }
  if(a[1]==1&&a[9]==1&&a[7]==1&&a[4]==1)
  cout << "YES" << endl;
  else 
  cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main(){
  int N;
  cin>>N;
  bool can[105];
  memset(can,1,sizeof(can));
  can[1] = can[2] = can[3] = can[5] = can[6] = can[9] = can[10] = can[13] = can[17] = 0;
  puts(can[N] ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

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

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

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

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int main() {
	for(int n, s; cin >> n >> s && (n || s);) {
		int ret = 0;
		for(int i = 0; i < (1<<10); i++) {
			int sum = 0;
			if(__builtin_popcount(i) != n) continue;
			for(int j = 0; j < 10; j++) {
				if((1 << j) & i) sum += j;
			}
			if(sum == s) ret++;
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
    cout << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    string s, t;
    cin >> s >> t;
    int n = s.size();
    vector<int> a[26];
    for (int i = 0; i < n; i++) {
        a[s[i] - 'a'].pb(i);
    }

    int p = -1;
    ll ans = 0;
    for (char c : t) {
        int ind = c - 'a';
        if (a[ind].empty()) {
            cout << -1;
            return 0;
        }

        auto it = upper_bound(a[ind].begin(), a[ind].end(), p);
        if (it == a[ind].end()) {
            ans += n - 1 - p + a[ind][0] + 1;
            p = a[ind][0];
        }

        else {
            ans += *it - p;
            p = *it;
        }

    }

    cout << ans;




}



Measured memory_bytes: 1228
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	// int n;
	// cin >>n;
    // vector<pair<int,int>> p(n);
    // rep(i,n){
    //     int x,l;
    //     cin >> x >> l;
    //     p[i] = MP(x,l);
    // }
    // SORT(p);

    int n,k,s;
    cin >> n >> k >> s;
    int X = 1000000000;
    if(s == 1000000000){
        rep(i,k)cout << s << " ";
        rep(i,n-k)cout << 1 << " ";
        cout << endl;
    }else{
        rep(i,k)cout << s << " ";
        rep(i,n-k)cout << X << " ";
        cout << endl;
    }






    
 	
	
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2020-qual.contest.atcoder.jp/tasks/ddcc2020_qual_b
// rm -r -f test;oj dl https://keyence2020.contest.atcoder.jp/tasks/keyence2020_b

Measured memory_bytes: 1280
#include <stdio.h>
#include <math.h>

int isprime(int n)
{
  for(int i = 2; i < n; i++)
    {
      if(!(n%i))return 0;
    }
  return 1;
}
int main()
{
  int N;
  int n=0;
  scanf("%d%*c", &N);

  for(int i = 0; i < N; i++)
    {
      printf(i?" ":"");
      for (n++;; n++)
	{
	  if(isprime(n*10+1))
	    {
	      printf("%d",n*10+1);
	      break;
	    }
	}
    }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <vector>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
 
int main(){
  ll S;
  cin >> S;
  ll sq[5];
  ll point=0;
  
  sq[0]=10;
  sq[1]=100;
  sq[2]=10000;
  sq[3]=100000000;
  sq[4]=1000000000;
  
  rep(i, 5){
    if(pow(sq[i],2)>=S){
      point=i;
      break;
    }
  }
  if(S%sq[point]==0) cout << 0 << " " << 0 << " " << sq[point] << " " << 0 << " " << sq[point] << " " << S/sq[point] << endl;
  else cout << 0 << " " << 0 << " " << sq[point] << " " << 1 << " " << (sq[point]-(S%sq[point])) << " " << (S/sq[point]+1) << endl;
}

Measured memory_bytes: 256
n,q = map(int, input().split())
s = input()
af = False
AClist = [0 for i in range(10**5)]
for i,c in enumerate(s):
    if af:
        if c == 'C':
            AClist[i-1]+=1
            af = False
        elif c != 'A':
            af = False
    else:
        if c == 'A':
            af = True

a2=[0]
for i in AClist:a2.append(a2[-1]+i)
def SumArea(l, r):
    return a2[r]-a2[l]

ans = []
for i in range(q):
    l,r = map(int, input().split())
    print(SumArea(l-1, r-1))

Measured memory_bytes: 53700
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define pr pair<int,int>
signed main()
{
    SPEED;
    int a,ans;
    double b;
    cin>>a>>b;
    ans=round(b*100);
    cout<<(ans*a)/100;
}

Measured memory_bytes: 3772
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

vector<int> E[601];
double memo[601];
double dfs(int v) {
	if (memo[v] != -1) return memo[v];
	int kazu = E[v].size();
	double ret = 0;
	for (int p : E[v]) {
		ret += dfs(p);
	}
	return memo[v] = 1 + ret / kazu;
}

vector<int> IE[601];
double K[601] = {};
double omomi(int v) {
	if (K[v] != -1) return K[v];
	double ret = 0;
	for (int p : IE[v]) {
		ret += omomi(p) / E[p].size();
	}
	return K[v] = ret;
}

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


	int N, M;
	cin >> N >> M;
	rep(i, M) {
		int s, t;
		cin >> s >> t;
		E[s].pb(t);
		IE[t].pb(s);
	}

	rep1(i, N) memo[i] = -1;
	memo[N] = 0;

	double kotae = dfs(1);

	rep1(i, N) K[i] = -1;
	K[1] = 1;

	double saishou = 0;
	rep1(i, N) {
		if (E[i].size() > 1) {
			int kazu = E[i].size();
			double saidai = 0;
			double kei = 0;
			for (int p : E[i]) {
				kei += dfs(p);
				chmax(saidai, dfs(p));
			}
			double are = (kei - saidai) / (kazu - 1) - kei / kazu;
			are *= omomi(i);
			chmin(saishou, are);
		}
	}

	cout << setprecision(12) << kotae + saishou << endl;

	Would you please return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int a, b, x;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

void solve() {
    cin >> a >> b >> x;
    if (a > x) {
        cout << "NO" << endl;
    } else {
        if ((x - a) <= b) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  ll ans = (N % 2 == 0) ? (N / 2) : (N / 2 + 1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  int id;
  for (int i = 0; i < n; i++)
    if (a[i] == 1)
      id = i;
  cout << (n - 1 + k - 2) / (k - 1) << endl;
  return 0;
}


Measured memory_bytes: 640
/**
 * author: said_v15
 * created with web_programmer
**/
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int q;
    int n;
   
    string s;

    cin >> n >> q >> s;
	vector<int> v(n);
	for(int i=0; i<n; ++i)
		if(s.substr(i, 2) == "AC")
			v[i+1] = 1;
	for(int i=1; i<n; ++i)
		v[i] += v[i-1];
	while(q--){
		int l, r;
		cin >> l >> r;
		cout << v[r-1] - v[l-1] << "\n";
	}
    
}

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

int n, a[100005];

int abs(int p) {return p > 0 ? p : -p;}

int main()
{
	int i;
	cin >> n >> a[0] >> a[0];
	for (i = 1; i <= n; i++) scanf("%d", &a[i]);
    cout << max(abs(a[n] - a[0]), abs(a[n] - a[n - 1])) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cstdlib>
#define N 1005
using namespace std;

int n, x[N], y[N];
vector<int> a[N];

void f(int p) {
	int i, t, s = 0;
	bitset<5005> bs;
	bs = 1;
	for (i = 0; i < a[p].size(); i++) {
		t = a[p][i];
		f(t);
		bs = bs << x[t] | bs << y[t];
		s += x[t] + y[t];
	}
	for (i = x[p]; i >= 0; i--) if (bs[i]) break;
	if (i < 0) {cout << "IMPOSSIBLE"; exit(0);}
	y[p] = s - i;
}

int main()
{
	int i, t;
	cin >> n;
	for (i = 2; i <= n; i++) {
		scanf("%d", &t);
		a[t].push_back(i);
	}
	for (i = 1; i <= n; i++) scanf("%d", &x[i]);
	f(1);
	cout << "POSSIBLE";
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, x, y;
  cin >> a >> b;
  x=(a+b)/2;
  y=(a+b)%2; 
  if (y > 0) {
    cout << x+1 << endl;
  }
  else{
    cout << x << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;
 
int main(int argc, char *argv[])
{
    int A, B, C;
    std::cin >> A >> B >> C;

    if (B / A > C) {
        std::cout << C << std::endl;
    } else {
        std::cout << B/A << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
int main(){
    vector<int> abc(3);
    REP(i, 3) cin >> abc[i];
    sort(abc.begin(), abc.end());
    cout << (abc[0] + abc[1] == abc[2] ? "Yes" : "No") << endl; 
    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
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()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> A(N+2);
    A[0] = 0;
    A[N+1] = 0;

    ll sumdis = 0;

    for(ll i=1; i<=N; i++){
        cin >> A[i];
        sumdis += abs(A[i] - A[i-1]);
    }
    sumdis += abs(A[N+1] - A[N]);
    // cout << sumdis << endl;

    for(ll i=1; i<=N; i++){
        cout << sumdis - abs(A[i]-A[i-1]) - abs(A[i+1]-A[i]) + abs(A[i+1]-A[i-1]) << endl;
    }
    return 0;
}

Measured memory_bytes: 2048
N = gets.to_i
A = gets.split.map(&:to_i).select{|a|a.even?}
ans = A.inject(true) do |q, a|
  q &= (a % 3).zero? || (a % 5).zero?
end
if ans
  puts 'APPROVED'
else
  puts 'DENIED'
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,i,j,k,ct;
	cin>>n;
	string ans="";
	while(n>0)
	{
		ct=n%26;
		if(ct==0) 
		{
			ans += 'z';
			n=(n/26)-1;
		}
		else
		{
			ans +=  (ct-1)+'a';
			n /= 26;
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int n, m;
  cin >> n >> m;
  int s[m][n];
  REP(i,m)REP(j,n) s[i][j] = 0;

  REP(i,m){
    int k;
    cin >> k;
    REP(j,k){
      int x; cin >> x;
      --x;
      s[i][x] = 1;
    }
  }
  // REP(i,m){
  //   REP(j,n){
  //     cout << s[i][j] << " ";
  //   }
  //   cout << endl;
  // }

  vector<int> p(m); //電球ONの条件
  REP(i,m) cin >> p[i];

  //デバック
  // REP(i,m){
  //   for(auto x : s[i]) cout << x << endl;
  // }
  // for(auto x: p) cout << x << endl;

  int cnt = 0;
  REP(bi, 1 << n){
    vector<int> sum(n);
    //cout << "switch" << endl;
      REP(j, n) if( bi >> j &1){
        //cout << j << " ";
        REP(i,m) if( s[i][j] == 1) sum[i]++;
      }
      bool ok = true;
      REP(i,m){
        if(sum[i]%2 !=  p[i]) ok = false;
      }
      if(ok) ++cnt;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)
#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pii pair<int,int>
#define pLL pair<long long,long long>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
typedef long long ll;
typedef long long int lln;
ll INF=1<<28;
//typedef long long lld;
const double pi=acos(-1.0);
int fx[]={1,-1,0,0}; //direction array
int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
const long double EPS=1e-7;
//#define INF 10000
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    return a/gcd(a,b)*b;
}

bool cmp(int a, int b)
{
    return a<b;
}

struct compare
{
  bool operator()(const int& l, const int& r)
  {
      return l>r;
  }
};
ll inf=1e18;
ll dp[200][100005];
int W[200],V[200],C[200];
int n;
ll fun(int pos,int val)
{
    if(pos==n){
        if(val==0)
            return 0;
        return inf;
    }
    if(dp[pos][val]!=-1)
        return dp[pos][val];
    ll ans=inf;
    ans=min(ans,W[pos]+fun(pos+1,val-V[pos]));
    ans=min(ans,fun(pos+1,val));
    return dp[pos][val]=ans;
}
int main()
{
//    READ;
    int w;
    sf2(n,w);
    mem(dp,-1);
    ll tot=0;
    for(int i=0;i<n;i++)
    {
        sf2(W[i],V[i]);
        tot+=V[i];
    }
    ll x;
    for(int i=tot;i>=0;i--)
    {
        x=fun(0,i);
        if(x<=w){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 156544
from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime


#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
			


s=str(input())
t=str(input())
count=0
for i in range(3):
	if s[i]==t[i]:
		count+=1
print(count)




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

using namespace std;

double eps=1e-9;

int main()
{
    /*
    freopen("flat.in", "r", stdin);
    freopen("flat.out", "w", stdout);
    */
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int ar[3];
    cin>>ar[0]>>ar[1]>>ar[2];
    sort(ar,ar+3);
    cout<<ar[2]-ar[0]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, x;
vector<i64> a;
int main() {
  cin >> n >> x;
  read_n(a, n);

  i64 ans = 0;
  for (i64 i = 1; i < n - 1; ++i) {
    i64 c = max(i64(0), min({a[i], a[i - 1] + a[i] - x, a[i] + a[i + 1] - x}));
    a[i] -= c;
    ans += c;
  }

  for (i64 i = 0; i < n - 1; ++i) {
    ans += max(i64(0), a[i] + a[i + 1] - x);
  }

  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		if(N==2) {
			int A=sc.nextInt();
			int B=sc.nextInt();
			System.out.println(A+B);
		}
		else if(N==1) {
			System.out.println("Hello World");
		}
	}
}


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

int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i=0; i<N; i++) cin >> H.at(i);
  int cnt=0;
  int ans=0;
  for(int i=0; i<N-1; i++){
    if(H.at(i)>=H.at(i+1)) cnt++;
    else cnt=0;
    ans=max(ans, cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
	
	int n, a, b;
	string str;
	
	cin >> n >> a >> b;
	
	cin >> str;
	
	int count_ab = 0;
	int count_b = 0;
	
	for(int i = 0; i < n; i++){
		if(str[i] == 'a'){
			if(count_ab < a + b){
				cout << "Yes" << endl;
				count_ab++;
			}else{
				cout << "No" << endl;
			}
		}else if(str[i] == 'b'){
			if(count_ab < a + b && count_b < b){
				cout << "Yes" << endl;
				count_ab++;
				count_b++;
			}else{
				cout << "No" << endl;
			}
		}else{
			cout << "No" << endl;
		}
	}
	
	return 0;
}



Measured memory_bytes: 896
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

s = input()
ans = 'No'
n = len(s)
def isPalindrome(s):
    return s == s[::-1]

if isPalindrome(s) and isPalindrome(s[: n // 2]) and isPalindrome(s[(n // 2 + 1): ]):
    ans = "Yes"
print(ans)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int a =0, b = 0, c = 0, d = 0;
  vector<string> S(N);
  for(int i = 0; i < N; i++){
    cin >> S[i];
  }
  for(int i = 0; i < N; i++){
    if(S[i] == "AC"){
      a++;
    }else if(S[i] == "WA"){
      b++;
    }else if(S[i] == "TLE"){
      c++;
    }else if(S[i]=="RE"){
      d++;
    }
  }
  cout << "AC x " << a << endl;
  cout << "WA x " << b << endl;
  cout << "TLE x " << c << endl;
  cout << "RE x " << d << endl;
}

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

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

bool used[1000];

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

	int ans = 0;

	int N; cin >> N;

	for (int i = 0;i < N;i++){
		int d; cin >> d;
		if(!used[d]){
			ans++;
			used[d] = true;
		}
	}

	cout <<ans << endl;

	return 0;

}


Measured memory_bytes: 256
def f(x,y):
    if y>0:return x
    elif x<0:return -y
    elif x > -y:return x-2*y
    else: return 2*x-y
a,b=map(int,input().split())
c=list(map(int,input().split()))
d=f(c[-1],c[-b])
for i in range(a-b):
    if d > f(c[i+b-1],c[i]):
        d=f(c[i+b-1],c[i])
print(d)

Measured memory_bytes: 14664
n = int(input())
first_row = [int(x) for x in input().split()]
sec_row = [int(x) for x in input().split()]
first_row_d = [0 for i in range(n)]
sec_row_d = [0 for i in range(n)]
first_row_d[0] = first_row[0]
for i in range(1, n):
    first_row_d[i] = first_row_d[i - 1] + first_row[i]

sec_row_d[0] = first_row_d[0] + sec_row[0]
for i in range(1, n):
    sec_row_d[i] = max(sec_row_d[i - 1], first_row_d[i])
    sec_row_d[i] += sec_row[i]
print(sec_row_d[-1])


Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;

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

		int N = sc.nextInt();
		ArrayList<Dish> dish = new ArrayList<Dish>();

		long A_point = 0;
		long B_point = 0;

		for (int i = 0; i < N; i++) {
			int A =sc.nextInt();
			int B =sc.nextInt();
			dish.add(new Dish(A,B,i));
		}
		
		Comparator<Dish> comp = new Comparator<Dish>() {
			@Override
			public int compare(Dish o1, Dish o2) {
				return o2.A + o2.B - (o1.A + o1.B);
			}
		};
		
		dish.sort(comp);
		
		for(int i = 0;i<N;i++) {
			if(i % 2 == 0) {
				A_point += dish.get(i).A;
			}else {
				B_point += dish.get(i).B;
			}
		}
		
		System.out.println(A_point - B_point);

	}

	static class Dish{
		int A;
		int B;
		int index;
		Dish(int a,int b,int in){
			A=a;
			B=b;
			index=in;
		}
	}
	
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, k, n) for (int i = k; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

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

    int N, K;
    cin >> N >> K;
    vector<llong> X(N), Y(N);
    rep(i, N) {
        cin >> X[i] >> Y[i];
    }

    llong ans = INF;
    rep(i, N) {
        rep(j, N) {
            rep(k, N) {
                rep(l, N) {
                    if (i == j || k == l) continue;

                    int cnt = 0;
                    llong left = X[i], right = X[j];
                    llong up = Y[k], down = Y[l];
                    //if (right < left) swap(right, left);
                    //if (up < down) swap(down, up);
                    rep(m, N) {
                        if ((left <= X[m] && X[m] <= right) && (down <= Y[m] && Y[m] <= up)) ++cnt;
                    }

                    llong s = (right - left) * (up - down);
                    if (cnt >= K) ans = min(ans, s);
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication51
{
    class Program
    {
        static void Main()
        {
            while (true)
            {   string a = Console.ReadLine();
                if (a == null) break;
                if ((a[0] == a[4] && a[4] == a[8] || a[2] == a[4] && a[4] == a[6])&&a[4]!='s') { Console.WriteLine(a[4]); goto d; }
                for (int b = 0; b < 7; b++)
                {   if (a[b] == 's') continue;
                    if (b < 3)
                    {
                        if (a[b] == a[b + 3] && a[b + 6] == a[b]) { Console.WriteLine(a[b]);goto d; }
                    }
                    if (b % 3 == 0)
                    {
                        if (a[b] == a[b + 1] && a[b + 1] == a[b + 2]) { Console.WriteLine(a[b]); goto d; }
                    }
                }
                Console.WriteLine("d");
            d:;
            }
        }
    }
}

Measured memory_bytes: 8824
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int a[100005];

vii c,nc;
vector<pii> v;

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
rep(i,0,n-1)cin>>a[i];
sort(a,a+n);

c.pb(a[0]);

rep(i,1,n-2)
{
	if(a[i]>0)nc.pb(a[i]);
	else c.pb(a[i]);
}
nc.pb(a[n-1]);

int szc=c.size(),szn=nc.size();

int mn=min(c.size(),nc.size());

int ans=0;

if(szc>=szn)
{
	ans=nc[0]-c[0];
	v.pb(mp(nc[0],c[0]));
}
else
{
	if(szc==1)
	{
		ans=c[0]-nc[0];
		v.pb(mp(c[0],nc[0]));
	}
	else
	{
		ans=nc[0]-c[0];
		v.pb(mp(nc[0],c[0]));
	}
}

rep(i,1,mn-1)
{
	v.pb(mp(c[i],ans));
	ans=c[i]-ans;
	if(i==mn-1&&szc<szn)
	{
		v.pb(mp(ans,nc[i]));
		ans=ans-nc[i];
	}
	else
	{
		v.pb(mp(nc[i],ans));
		ans=nc[i]-ans;
	}
}

if(szc>=szn)
{
	rep(i,mn,szc-1)
	{
		v.pb(mp(ans,c[i]));
		ans-=c[i];
	}
}
else
{
	rep(i,mn,szn-2)
	{
		v.pb(mp(ans,nc[i]));
		ans-=nc[i];
	}
	v.pb(mp(nc[szn-1],ans));
	ans=nc[szn-1]-ans;
}
ol(ans);on;
tr(v,it)
{
	o2(it->ff,it->ss);on;
}

return 0;
}



Measured memory_bytes: 3828
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define fi first
#define se second
//#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
typedef pair<int,int> P;
#define REP(i,x,y) for(int i=x;i<=y;i++)
#define abs(x) ((x)>0?(x):-(x))
#define y1 qjc
const int maxn = 3e5+10;
int main(){
	int a,b,c,n;
	cin>>a>>b>>c>>n;
	int cnt=0;
	for(int i=0;a*i<=n;i++){
		for(int j=0;a*i+j*b<=n;j++){
			if((n-i*a-j*b)%c==0) cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,m;
    int i,j,k;
    int mat[100][100]={{}};
    int ve[100]={};
    cin>>n>>m;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin>>mat[i][j];
        }
    }
    for(j=0;j<m;j++)
    cin>>ve[j];
    for(i=0;i<n;i++){
        int x=0;
    for(j=0;j<m;j++)
    x+=mat[i][j]*ve[j];
    cout<<x<<endl;
    }
    return 0;
    
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define int int64_t
#define pr(x) cout << x << endl;
#define vi vector<int>
#define vii vector< int , vector<int> >
#define mp make_pair
#define f(i,n) for(i =0 ; i< n ; i++)
#define pb push_back
#define INF 1e9
#define SIZE 200001
#define mod 1000000007
#define int int64_t
void solve();
// class dsu
// {
//     vi rank,parents;
// public:
//     dsu(int n)
//     {
//         rank.assign(n+10,0);
//         parents.assign(n+10,0);
//         for(int i=0;i<=n;i++)
//         {
//             parents[i]=i;
//         }
//     }
//     int findparent(int a)
//     {
//         return parents[a]==a ? a : parents[a]=findparent(parents[a]);
//     }
//     bool isSameParent(int x,int y)
//     {
//         return findparent(x)==findparent(y);
//     }
//     void joindsu(int x,int y)
//     {
//         int a=findparent(x);
//         int b=findparent(y);
//         if(a!=b)
//         {
//             if(rank[a]>rank[b])
//             {
//                 parents[b]=a;
//             }
//             else
//             {
//                 parents[a]=b;
//                 if(rank[a]==rank[b])
//                     rank[b]++;
//             }
//         }
//     }
// };


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}
int32_t  k=0, l=0, i, j, n, m, a, t=0, b, w ;
void solve()
{
    // cin >> t;while(t--)
    {
        cin >> n ;
        vi v(n);
        f(i,n) cin >> v[i];
        f(i,n-1)
            {
                if(v[i]>v[i+1]) v[i]--;
                else if(i-1>0)
                {
                    if(v[i-1]<v[i]) v[i]--;
                }
                else if(i==0) v[0]--;
            } 

        // f(i,n) cout << v[i];

        bool b = true;
        f(i,n-1) if(v[i] > v[i+1]) b=false;

        if(b) pr("Yes")
        else pr("No")
        
            
    }
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
    unsigned long int i, n, m, l, r, tempL, tempR, count;

    count = 0;
    l = 0;
    r = 100000;

    scanf("%lu %lu", &n, &m);

    for ( i = 0; i < m; i++)
    {
        scanf("%lu %lu", &tempL, &tempR);
        if (tempL > l)
        {
            l = tempL;
        }
        if (tempR < r)
        {
            r = tempR;
        }
    }

    for ( i = l; i <= n; i++)
    {
        if (i >= l && i <= r)
        {
            count++;
        }
    }
    
    printf("%lu", count);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, n, a) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, n, 0)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int Pow(int a, int b)
{
    int res = 1;
    rep(i, b) res *= a;
    return res;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, p;
    cin >> n >> p;
    vector<int> prime = {};
    map<int, int> mp = {};
    for (int i = 2; i <= 10000000; i++)
    {
        if (p % i == 0)
        {
            prime.push_back(i);
            while (p % i == 0)
            {
                p /= i;
                mp[i]++;
            }
        }
        if (p == 1)
            break;
    }
    if (p != 1)
    {
        prime.push_back(p);
        mp[p]++;
    }
    int ans = 1;
    rep(i, prime.size()) ans *= Pow(prime[i], mp[prime[i]] / n);
    cout << ans << endl;
}

Measured memory_bytes: 256
#[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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        d: [usize; n],
    }
    let mut result = 0;
    for i in 0..n {
        for j in 0..i {
            result += d[i] * d[j];
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 4352
#!/usr/bin/python

from sys import stdin

def count(S, i, j):
  c = 0
  for y in range(i - 1, i + 2):
    for x in range(j - 1, j + 2):
      if 0 <= y < len(S) and 0 <= x < len(S[y]) and S[y][x] == '#':
        c += 1
  return str(c)

def solve(S):
  return [[count(S, i, j) if S[i][j] == '.' else '#'
          for j in range(len(S[i]))] for i in range(len(S))]

H, W = [int(w) for w in stdin.readline().split()]
S = []
for i in range(H):
  S.append(stdin.readline().strip())
R = solve(S)
R = '\n'.join([''.join(r) for r in R])
print(R)


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

typedef long long int ll;
using namespace std;

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

    ll res = 1e10;
    for (int i = 0; i <= N-K;i++){
        ll sum = h[i] - h[i + K-1];
        res = min(res, sum);
    }
    cout << res;
}

Measured memory_bytes: 1024
#[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! {
        n: usize,
        y: u64
    }

    let mut p = -1i64;
    let mut q = -1i64;
    let mut r = -1i64;
    'outer: for i in 0..n+1 {
        for j in (0..).take_while(|&j| i + j <= n) {
            let k = n - i - j;
            if 10000 * i as u64 + 5000 * j as u64 + 1000 * k as u64 == y {
                p = i as i64;
                q = j as i64;
                r = k as i64;
                break 'outer;
            }
        }
    }
    println!("{} {} {}", p, q, r);
}

Measured memory_bytes: 4352