akhauriyash/Code-Regression huggingface dataset:
fn main() {
    let k: usize = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_end().to_owned().parse().unwrap()
    };

    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_end().to_owned()
    };

    if s.chars().count() > k {
        let mut str1 = "".to_string();
        for (i, c) in s.chars().enumerate() {
            if i < k {
                str1.push(c);
            }
        }
        println!("{}...", str1);
    } else {
        println!("{}", s);
    }
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s; cin >> s;
  	for (int i = 0; i < s.length(); i++) {
    	if (s[i] == '?') cout << 'D';
      	else cout << s[i];
    }
  	cout << endl;
}

Measured memory_bytes: 3720
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int x;
        for(int i = 1; i <= 10000; i++){
            x = scan.nextInt();
            if(x == 0){
                break;
            }
            System.out.println("Case " + i + ": " + x);
        }
    }
}

Measured memory_bytes: 42264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef string str;
const long long INF = INT64_MAX / 2;

#define REP(i, n) for(ll i=0;i<n;i++)
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);

void solve() {
    vector<str> valids = {
        "maerd",
        "remaerd",
        "esare",
        "resare"
    };
    str s;
    cin >> s;
    reverse(s.begin(), s.end());
    ll pos = 0;
    bool ismatch = false;
    while(pos < s.size()) {
        ismatch = false;
        for(auto &valid:valids) {
            if(valid==s.substr(pos, valid.size())) {
                ismatch = true;
                pos += valid.size();
                break;
            }
        }
        if(!ismatch) {
            cout << "NO\n";
            return;
        }
    }
    if(pos == s.size()) {
        cout << "YES\n";
    }else {
        cout << "NO\n";
    }
}

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

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = Integer.parseInt(sc.next());
		sc.close();

		int odd = 0;
		int even = 0;
		if(K % 2 == 0) {
			odd = even = K / 2;
		}else {
			odd = K / 2 + 1;
			even = K / 2;
		}
		System.out.println(odd * even);
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define rlp(i,n) for(int i = int(n);i >= 0;i--)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
void _run(){
   ll x,k,d;
   cin>>x>>k>>d;
   ll ans =0;
   x = abs(x);
   if(x/d>k){
       cout<<x-(k*d)<<endl;
    return;
   }
   ll rem = x/d;
   k-=rem;
   x-=rem*d;
   if(k&1)x=abs(x-d);
   ans = x;
   cout<<x<<endl;
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int t=1;
    // scanf("%d",&t);
    while(t--)_run();
    
    return 0;
}

Measured memory_bytes: 3632
//2:50 start
//3:08 writing done


#include <stdio.h>
#include <string.h>

//#define DEBUG
#define MAX_N 10

int cmb[MAX_N];
int n_cmb;

//when reached maximum, return 1. else 0
int increase(void)
{
    int i;
    for(i=n_cmb-1;i>=0;i--){
        if(cmb[i]<9){
            cmb[i]++;
            int j;
            for(j=i+1;j<n_cmb;j++){
                cmb[j]=cmb[i]; 
            }
            return 0;
        }
    }
    return 1;
}
int sum(void)
{
    int i,sum=0;
    for(i=0;i<n_cmb;i++){
        sum+=cmb[i];
#if 0
        printf("%d ",cmb[i]);
#endif
    }
#if 0
    printf("\n");
#endif
    return sum;
}
int anysame(void)
{
    int exist[MAX_N];
    memset(exist,0,sizeof(int)*MAX_N);
    int i;
    for(i=0;i<n_cmb;i++){
        if(exist[cmb[i]]){ return 1; }
        else{ exist[cmb[i]]=1; }
    }
    return 0;
}

int count(int s)
{
    memset(cmb,0,sizeof(int)*MAX_N);
    int cnt=0;
    while(1){
        if(sum()==s && (!anysame())){ cnt++; } 
        if(increase()){ break; }
    }
    return cnt;
}

int main(void)
{
    FILE *fp;
#ifdef DEBUG
    fp=fopen("input.txt","r");
#else
    fp=stdin;
#endif

    while(1){
        int n,s;
        fscanf(fp,"%d %d\n",&n,&s);
        if(n==0 && s==0){ break; }
        n_cmb=n;
        printf("%d\n",count(s));
    }
    return 0;
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#define TASK "C-large"
#pragma comment(linker, "/STACK:171088640")
#include <stdio.h>
#include <iostream>
#include <iomanip> 
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#include <assert.h>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <random>
#include <complex>
using namespace std;

const int MOD = 1000000007;
const int INF = 1000000007;
const long double EPS = 1e-6;
const int HASH_POW = 29;
const long double PI = acos(-1.0);
mt19937_64 rnd(1);

long long rndNext(long long l, long long r) {
	uniform_int_distribution <long long> foo(l, r);
	return foo(rnd);
}

double workTime() {
	return double(clock()) / CLOCKS_PER_SEC;
}

void my_return(int code) {
#ifdef MYDEBUG
	cout << "\nTime = " << fixed << setprecision(3) << workTime() << endl;
#endif
	exit(code);
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef MYDEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	/*freopen(TASK".in", "r", stdin);
	freopen(TASK".out", "w", stdout);*/
#endif

	string s;
	cin >> s;
	int cnt[26];
	memset(cnt, 0, sizeof cnt);
	long long ans = 1;
	for (int i = 0; i < s.length(); ++i) {
		ans += i - cnt[s[i] - 'a'];
		++cnt[s[i] - 'a'];
	}
	cout << ans << endl;

	my_return(0);
}

Measured memory_bytes: 720
import itertools
import numpy as np

H,W,K=map(int,input().split())
m=[]
for i in range(H):
    m.append(list(input()))

ans=0
for i in range(2**H):
     for j in range(2**W):
            i_s=format(i, "0{0}b".format(H))
            j_s=format(j, "0{0}b".format(W))
            M=[[[] for _ in range(W)] for _ in range(H)]
            for h in range(H):
                for w in range(W):
                    if i_s[h]=="1" or j_s[w]=="1":
                        M[h][w]="$"
                    else:
                        M[h][w]=m[h][w]
            M_1=list(itertools.chain.from_iterable(M))
            if M_1.count("#")==K:
                ans+=1
            
print(ans)

Measured memory_bytes: 27188
import java.util.Arrays;
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        int[] num = new int[N];
        for(int i = 0;i < N;i++){
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int j = 0;
        num[0] = 1;
        for(int i = 1;i < N;i++){
            if(a[i-1] == a[i]){
                num[j]++;
                continue;
            }
            j++;
            num[j]++;
        }
        int count = 0;
        for(int i = 0;i < N;i++){
            if(num[i] % 2 == 1){
                count++;
            }
        }
        System.out.println(count);
    }
}


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

int val[10000001];

int main(void) {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
        for(int j=i;j<=n;j+=i) {
            val[j]++;
        }
    }
    long long ret=0;
    for(int i=1;i<=n;i++) {
        ret+=1LL*i*val[i];
    }
    printf("%lld",ret);
}

Measured memory_bytes: 42924
#include <stdio.h>
int main(){
	for(;;){
		int max=0,set[100000],n,m,a,b,c;
		scanf("%d%d",&n,&m);
		if(n==0&&m==0)
		break;
		for(a=0;a<n;a++){
			scanf("%d",&set[a]);
		}
		for(a=0;a<n-m;a++){
			c=0;
			for(b=0;b<m;b++){
				c+=set[a+b];
			}
			if(max<c)
			max=c;
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 2964
#include<bits/stdc++.h>
using namespace std;
int n;
long long int ans=0;

int dist[500][500],vis[500][500];
bool in(int x,int y){
	return x>=0&&x<n&&y>=0&&y<n;
}
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

void dfs(int x,int y){
	for(int i=0;i<4;i++){
		int nx=x+dx[i],ny=y+dy[i];
		if(in(nx,ny)){
			if(!vis[x][y]){
				if(dist[nx][ny]>dist[x][y]+1)
					dist[nx][ny]=dist[x][y]+1,dfs(nx,ny);
			}
			else{
				if(dist[nx][ny]>dist[x][y])
					dist[nx][ny]=dist[x][y],dfs(nx,ny);
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n*n;i++){
		int x=i/n,y=i%n;
		dist[x][y]=min({x,n-1-x,y,n-1-y});
	}
	for(int i=1,x;i<=n*n;i++){
		cin>>x;
		x--;
		ans+=dist[x/n][x%n];
		vis[x/n][x%n]=true;
		dfs(x/n,x%n);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 20740
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)
//string s = to_string(i);
int a = 0, b = 0, x = 0, y = 0, z = 0, n = 0, sum = 0;
string s = ""; asas; cncn;

int main(void) {
	cin >> x >> a;
	sec(0, 10, x < a);
	please AC;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define mod 998244353
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll ,ll> pii;

void solve()
{
	int n;
	cin>>n;
	cout<<(n==0)<<endl;
}

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
	solve();
    return 0;
}


Measured memory_bytes: 3600
n = int(input())
c = [[0]*(10) for i in  range(10)]
for k in range(1,n+1):
    leng = len(str(k))-1 
    i = k//(10**leng)
    j = k%10
    c[i][j] +=1
ans = 0
for i in range(10):
    for j in range(10):
        ans+=c[i][j] *c[j][i]
print(ans)


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

int gcd(int x, int y){
  if(y%x==0){
    return x;
  }
  else if(x%y==0){
    return y;
  }
  else{
    if(x<y){
      return gcd(x, y%x);
    }
    if(x>y){
      return gcd(y, x%y);
    }
  }
}

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  if(C%(gcd(A, B))==0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <stack>
#include <unordered_set>
using namespace std;

int main(){
    int n;
    cin >> n;
    long long res = 0;
    for(int a = 1; a <= n; a++){
        for(int b = 1; b <= n; b++){
            for(int c = 1; c <= n; c++){
                res += __gcd(__gcd(a, b), c);
            }
        }
    }
    cout << res << '\n';
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int A,B,C,D;
int main(){
    cin>>A>>B>>C>>D;
    while(1){
        C-=B;
        if(C<=0){cout<<"Yes"<<endl;return 0;}
        A-=D;
        if(A<=0){cout<<"No"<<endl;return 0;}
    }
    return 0;
}

Measured memory_bytes: 3636
n,m=map(int,input().split())
dp=[0]*(n+3)
a=[int(input()) for i in range(m)]
mod=10**9+7
for i in range(m):
    dp[a[i]]=-1

dp[0]=1
if dp[1]!=-1:
    dp[1]+=dp[0]

for i in range(n+1):
    if dp[i+2]==-1:
        continue
    if dp[i]!=-1:
        dp[i+2]+=dp[i]
    if dp[i+1]!=-1:
        dp[i+2]+=dp[i+1]
    dp[i+2]%=mod
print(dp[n]%mod)

Measured memory_bytes: 7848
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef LOCAL
    #define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define debug(...) 42
    #define eprintf(...) 42
#endif

#define PI 3.1415926535897932384626433832795
#define INF 2e9
#define SINV(t) greater<t>()
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define FOREACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define SIGN(x) (((x)>0)?1:(((x)<0)?-1:0))

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; }

typedef long long ll;
#define vv(t) vector< t > 

#define CHC(mp, x) if(mp.end() != mp.find(x))
#define CHCV(mp, x) if(mp.end() != find(ALL(mp), x))

template<typename T>
inline T lcm(T a, T b) {return a / __gcd(a, b) * b;}

#define fi first
#define se second

#pragma endregion

template<typename T>
void SV(vector<T> v){
    #ifdef LOCAL
        REP(i,v.size()){
                cout << i << " : " << v[i] << endl;
        }
    #endif
}

template<typename T>
void SV(map<int, T> v){
    #ifdef LOCAL
        FOREACH(i, v){
            cout << i.first << " : " << i.second << endl;
        }
    #endif
}
int bitCount(int bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >> 16);
}

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

void Main();

int main(void){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    string s,t;
    cin >> s >> t;
    cout << ((s==t.substr(0, t.length()-1))?"Yes\n":"No\n");
}

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

int main(){
  int i;
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  
  for(i = 0; i < n; i++){
   cin >> a[i]; 
  }
  
  for(i = k; i < n; i++){
    if(a[i] > a[i - k]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int k;
int main()
{
	cin>>a>>b>>c;
	cin>>k;
	while(k--)
	{
		if(b<=a)
		{
			b*=2;
		}
		else if(c<=b)
		{
			c*=2;
		}
	}
	if(b>a&&c>b)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	cout<<endl;
	return 0;
}


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

using namespace std;

#define MAX 55

int H,W,D,N,r[10],X,Y;
char field[MAX][MAX];
bool visited[MAX][MAX];
bool treasure[MAX][MAX];
bool possible[MAX][MAX];
const int dx[] = {-1,0,0,1};
const int dy[] = {0,-1,1,0};
typedef pair<int,int> P;

bool inField(int y,int x){
  return 0 <= y && y < H && 0 <= x && x < W;
}

bool check(int y,int x,int r){
  int x1 = x - r, x2 = x + r;
  int y1 = y - r, y2 = y + r;
  return x1 <= X && X <= x2 && y1 <= Y && Y <= y2;
}

void search(int y,int x,int s){
  if(visited[y][x]) return;
  visited[y][x] = true;

  if(s == 0){
    if(check(y,x,r[0]) && field[y][x] != '#'){
      treasure[y][x] &= true;
    }else{
      treasure[y][x] &= false;
    }
  }else if(s == D){
    if(!check(y,x,r[D-1]) && field[y][x] != '#'){
      treasure[y][x] &= true;
    }else{
      treasure[y][x] &= false;
    }
  }else{
    if(!check(y,x,r[s-1]) && check(y,x,r[s]) && field[y][x] != '#'){
      treasure[y][x] &= true;
    }else{
      treasure[y][x] &= false;
    }
  }

  for(int i = 0 ; i < 4 ; i++){
    int nx = x + dx[i];
    int ny = y + dy[i];
    if(!inField(ny,nx)) continue;    
    search(ny,nx,s);
  }
}

void bfs(int y,int x){
  memset(possible,false,sizeof(possible));
  queue<P> Q; Q.push(P(y,x));
  while(!Q.empty()){
    P now = Q.front(); Q.pop();
    x = now.second; y = now.first;
    if(possible[y][x]) continue;
    possible[y][x] = true;
    for(int i = 0 ; i < 4 ; i++){
      int nx = x + dx[i];
      int ny = y + dy[i];
      if(!inField(ny,nx) || field[ny][nx] == '#') continue;
      Q.push(P(ny,nx));
    }
  }
}

int main(){
  cin >> H >> W >> D >> N;
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      cin >> field[i][j];
      if(field[i][j] == 'D'){
        X = j; Y = i;
      }
      treasure[i][j] = true;
    }
  }
  bfs(Y,X);
  for(int i = 0 ; i < D ; i++){
    cin >> r[i];
  }
  for(int i = 0 ; i < N ; i++){
    int x,y,s;
    cin >> x >> y >> s; 
    memset(visited,false,sizeof(visited));
    X = x, Y = y; 
    search(y,x,s);
  }
  bool broken = true, c1 = false, c2 = false;
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      if(treasure[i][j]) broken = false;
      if(possible[i][j] && treasure[i][j]) c1 = true;
      if(!possible[i][j] && treasure[i][j]) c2 = true;
    }
  }

  if(broken){
    cout << "Broken" << endl;
  }else if(c1 && c2){
    cout << "Unknown" << endl;
  }else{
    cout << (c1 ? "Yes" : "No") << endl;
  }

  return 0;
}

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

int main() {
#ifdef LOCAL_DEFINE
	//freopen("data.in", "rt", stdin);
	//freopen("data.out", "w", stdout);
	long long _begin_time = clock();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	int k;
	cin >> k;
	int even = k / 2, odd = k - even;
	cout << (even * odd) << '\n';

#ifdef LOCAL_DEFINE
	long long _end_time = clock();
	cerr << "time = " << _end_time - _begin_time << " ms\n";
#endif
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in1(x) int x; cin>>x;
#define in2(x, y) int x, y; cin>>x>>y;
#define in3(x, y, z) int x, y, z; cin>>x>>y>>z;
#define in4(x, y, z, w) int x, y, z, w; cin>>x>>y>>z>>w;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
using namespace std;
bool primes[1000001];vi prime; void seive(); int gcd(int a, int b); int power(int x, int y);

int32_t main(void){
	IOS;
	string s;
	cin>>s;
	int ans = 0;
	rep(i, 0, s.length())
	{
		int tmp = s[i] - 48;
		ans += tmp;
	}
	if(ans%9) cout<<"No";
	else cout<<"Yes";
}

void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}
int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}
int power(int x, int y){ int res = 1;x = x % mod; if (x == 0) return 0;
while (y > 0){ if(y & 1) res = (res*x) % mod; y = y>>1; x = (x*x) % mod;} return res;}


Measured memory_bytes: 3748
N=list(map(int,input().split()))
if N[2]<=N[1]:
    print("Yes")
    exit()

takahashi=N[2]/N[1]
aoki=N[0]/N[3]

if aoki%1!=0:
   aoki=aoki+1 

if takahashi%1!=0:
    takahashi=takahashi+1
    

if takahashi<=aoki:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

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

int n,q;
int A[22];
set<int> s;

int main(){

  cin >> n;
  rep(i,0,n){
    cin >> A[i];
  }

  for(int S=0;S<1<<n;S++){
    int a=0;
    rep(i,0,n){
      if(S>>i & 1) a += A[i];
    }
    s.insert(a);
  }
  cin >> q;
  rep(i,0,q){
    int b;
    cin >> b;
    if(s.find(b) != s.end()) cout << "yes" << endl;
    else cout << "no" << endl;
  }


  return 0;
}



Measured memory_bytes: 3144
#include<stdio.h>
#include<math.h>
#define N 10000

int isprime();

int main(void)
{
  int a,i,j,n,div,count;
  int t[N];
  count = 0;
  scanf("%d", &n);

  for (i=0; i<n; i++) {
    scanf("%d", &t[i]);
  }
  for (i=0; i<n; i++) {
    a = t[i];
    if(isprime(a)==0){
      count++;
    }
    /*a = t[i];
    div = 0;
    for (j=1; j<=t[i]; j++) {
      if(t[i]%j==0)div++;
    }
    if(div==2){
      count++;
    }else if(div<2||div%2==0){
      count = count;
    }else if()*/
  }
  printf("%d\n", count);

  return 0;
}

int isprime(int x)
{
  //int cnt=0;
  if(x==2){
    return 0;
  }
  if(x<2||x%2==0){
    return 1;
  }
  int i=3;
  while(i<=sqrt(x)){
    if(x%i==0){
      return 1;
    }
    i = i+2;
  }
  return 0;
}



Measured memory_bytes: 2056
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <math.h>

using namespace std;

struct Point{
	bool operator<(const struct Point &arg) const{
		if(y != arg.y)return y < arg.y;
		return x < arg.x;
	};
	double x,y;
};

//true?????????
bool calcGaiseki(Point left,Point base, Point right){
	double gaiseki = (left.x-base.x)*(right.y - base.y)-(left.y-base.y)*(right.x-base.x);
	if(gaiseki < -0.00000001)return false;
	else{
		return true;
	}
}

int main(){

	vector<Point> V,UP,DOWN;

	int n;
	double x,y;

	scanf("%d",&n);

	for(int i = 0; i < n; i++){
		scanf("%lf %lf",&x,&y);
		V.push_back(Point());
		V[i].x = x;
		V[i].y = y;
	}

	sort(V.begin(),V.end());

	UP.push_back(V[0]);
	UP.push_back(V[1]);

	DOWN.push_back(V[V.size()-1]);
	DOWN.push_back(V[V.size()-2]);

	for(int i = 2; i < V.size(); i++){
		while(UP.size() > 1 && calcGaiseki(UP[UP.size()-2],UP[UP.size()-1],V[i]) == false)UP.pop_back();
		UP.push_back(V[i]);
	}

	for(int i = V.size()-3; i >= 0; i--){
		while(DOWN.size() > 1 && calcGaiseki(DOWN[DOWN.size()-2],DOWN[DOWN.size()-1],V[i]) == false){
			DOWN.pop_back();
		}
		DOWN.push_back(V[i]);
	}

	printf("%d\n",UP.size()+DOWN.size()-2);
	for(int i = DOWN.size()-1; i >= 1;i--)printf("%.0lf %.0lf\n",DOWN[i].x,DOWN[i].y);
	for(int i = UP.size()-1; i >= 1 ;i--)printf("%.0lf %.0lf\n",UP[i].x,UP[i].y);

}

Measured memory_bytes: 6600
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        //char[] S = sc.next().toCharArray();
        int count=0;
        int S = Math.min(A, B);
        int L = Math.max(A, B);
        for(int i=S; i>0; i--){
            if(S%i==0 && L%i==0){
                count++;
                if(count==K){
                    System.out.println(i);
                    return;
                }

            }

        }

          //System.out.println(count);
        }
    }

Measured memory_bytes: 35800
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define F first
#define S second
#define s(x) #x<<" "<<x<<" | "<<
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define all(A)  A.begin(),A.end()  
#define has(m,x)   (m.find(x)!=m.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
#define endl "\n"
const int MSIZE = 1e5+5;
const int MOD = 1e9+7 ;




int main(){

    FIO
    string s; cin>>s;
    int cnt = 0, ans = 0;    char p = '#';
    for(char c : s) {
        if(c==p)    cnt++;
        else {
            if(p=='R')  ans = max(ans,cnt);
            cnt = 1; p = c;
        }
    }
    if(p=='R')  ans = max(ans,cnt);
    cout<<ans<<endl;

    return 0;
}
    


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

namespace ProgramingStudying2
{
    class Program
    {
        static void Main(string[] args)
        {
            var abcd = Console.ReadLine().Split();
            var a = long.Parse(abcd[0]);
            var b = long.Parse(abcd[1]);
            var c = long.Parse(abcd[2]);
            var d = long.Parse(abcd[3]);

            long gcd(long c, long d)
            {
                if(c % d == 0)
                {
                    return d;
                }
                else
                {
                    return gcd(d, c % d);
                }
            }

            var lcm = c * d / gcd(c, d);

            var cDiv = b / c - (a - 1) / c;
            var dDiv = b / d - (a - 1) / d;
            var lcmDiv = b / lcm - (a - 1) / lcm;

            Console.WriteLine(b - a + 1 - cDiv - dDiv + lcmDiv);
        }
    }
}

Measured memory_bytes: 27376
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <string>
#include <map>
#include <queue>
#include <list>


#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define vint vector<int>
#define INF 1e9

using namespace std;
typedef long long  ll;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    if (N != 1) res.push_back({N, 1});
    return res;
}

int main(){
    ll n;
    cin >> n;
    const auto &res = prime_factorize(n);
//    cout << n << ":";
    ll ans = 0;
    for (auto p : res) {
//        for (int i = 0; i < p.second; ++i) cout << " " << p.first;
        ll used = 0;
        ll cnt = 1;
        do{
            ans += 1;
            used += cnt;
            cnt += 1;
        }while (p.second >=  used + cnt);
    }
    p(ans);
}

Measured memory_bytes: 3232
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define print(x) cout << #x << " = " << x << endl;

using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;


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

	ll ans = 0;

	for (int b = K + 1; b <= N; b++) {
		int n = N / b;
		int k = N % b;

		ans += (b - K) * n;
		if (K <= k) {
			ans += k - K + 1;
		}

		if (K == 0) ans--;

		//// a < b のとき
		//ans += b - K;
		//if (K == 0) ans--;

		//// b < a のとき
		//ll k_ = N % b;
		//ll n_ = N / b;
		//if (k_ < K) ans += (n_ - 1) * (b - K);
		//else ans += n_ * (k_ - K + 1) + (n_ - 1) * (b - k_ - 1);
		
		// a < b のとき
		//cout << "b: " << b << "-----" << endl;
		//cout << "  if b > a:" << endl;
		//for (int a = K; a < b; a++) {
		//	if (a == 0) continue;
		//	//cout << "   k: " << a << endl;
		//	//cout << "     a: " << a << endl;
		//	//cout << "(" << a << ", " << b << ")" << endl;
		//	ans++;
		//}

		// a > b のとき
		//for (int k = K; k < b; k++) {
		//	////cout << "    k: " << k << endl;
		//	//int a = k;
		//	//while ((a += b) <= N) {
		//	//	//cout << "      a: " << a << endl;
		//	//	//cout << "(" << a << ", " << b << ")" << endl;
		//	//	ans++;
		//	//}

		//	ans += (N - k) / b;
		//}
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

struct Data{
    int A;
    string S;
    
    bool operator<( const Data& right ) const {
        return A == right.A ? S < right.S : A < right.A;
        //return A < right.A;
    }
};

int Func(){
    int x = 0;
    return x;
}

int main(){
    int A,B;
    
    cin >> A >> B;
    
    if (B%A==0) cout << A+B << endl;
    else cout << B-A << endl;
    
    return 0;
}


Measured memory_bytes: 256
N, X = (int(_) for _ in input().split())
L = list(map(int, input().split()))
D = [0 for i in range(N + 1)]
ans = 0
for i in range(N):
    D[i + 1]= D[i] + L[i]
for i in range(N + 1):
    if D[i] <= X:
        ans += 1
print(ans)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import itertools
import numpy as np

N, M = map(int, input().split())
input_list = []
for i in range(N):
    input_list.append(list(map(int, input().split())))

converted_list = np.empty((0, 8), int)
for i in input_list:
    tmp_list = []
    for k_i in [1, -1]:
        for o_i in [1, -1]:
            for n_i in [1, -1]:
                tmp_list.append(i[0] * k_i + i[1] * o_i + i[2] * n_i)
    converted_list = np.append(converted_list, np.array([tmp_list]), axis=0)

max_total = 0
for i in range(8):
    tmp_total = 0
    indices = np.argsort(converted_list[:, i])[::-1][:M]
    for ii in indices:
        tmp_total += converted_list[:, i][ii]
    if max_total < tmp_total:
        max_total = tmp_total
print(max_total)


Measured memory_bytes: 12696
#include <iostream>
#include <vector>
#include <cmath>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
using ll = long long;

using namespace std;

int main(){
	/*int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		int x;
		cin >> x;
		if(cin.eof())	break;	
		a[i]=x;
	}*/
	
	
	int x,y;
	
	cin >> x >> y;
	
	cout << x+y/2 << endl;
	
	return 0;
}


Measured memory_bytes: 256
N,*M=`dd`.split.map &:to_i;X,Y,*A,_=M.shift N;D=[*0..1e6];s=0;A.map{|e|s+=e.times{|j|D.unshift D[j*2+1]}};M.map{|e|p (D[e]||e-s)+X-Y}

Measured memory_bytes: 88456
//written by NewbieChd
#include <cstdio>
using namespace std;

int main() {
    int n, x;
    scanf("%d", &n);
    bool Y = 0, M = 0;
    x = n % 100;
    if (x && x <= 12)
        Y = 1;
    x = n / 100;
    if (x && x <= 12)
        M = 1;
    if (Y && M)
        printf("AMBIGUOUS\n");
    if (Y && (!M))
        printf("YYMM\n");
    if ((!Y) && M)
        printf("MMYY\n");
    if ((!Y) && (!M))
        printf("NA\n");
    return 0;
}


Measured memory_bytes: 128
def process(d, n):
    if n < 100:
        return n * (100 ** d)
    else:
        return 101 * (100 ** d)

def main():
    d, n = [int(i) for i in raw_input().strip().split()]
    print process(d, n)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll n;
    cin>>n;
    vector<ll> a(n,0),b(n,0),c(n,0);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n)cin>>c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll cumsum[n+1]={};
    rep(i,n){
        cumsum[i+1]=cumsum[i]+ll(lower_bound(a.begin(),a.end(),b[i])-a.begin());
    }
    DEBUG{
        rep(i,n)cout << cumsum[i+1]<<endl;
    }
    ll res=0;
    rep(i,n){
        ll cur= ll(lower_bound(b.begin(),b.end(),c[i])-b.begin());
        DEBUG{cout << cur << endl;}
        res+=cumsum[cur];
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	ll N,A,B,ANS=0;
	cin >> N >> A >> B;
	for(int i=0;i<=N;i++){
		ll t,t1,t2,t3,t4,t5;
		t1=i/10000;
		t2=(i-(t1*10000))/1000;
		t3=(i-(t1*10000)-(t2*1000))/100;
		t4=(i-(t1*10000)-(t2*1000)-(t3*100))/10;
		t5=(i-(t1*10000)-(t2*1000)-(t3*100)-(t4*10))/1;
		t=t1+t2+t3+t4+t5;
		if(t>=A&&B>=t){
			ANS=ANS+i;
		}
	}
	cout << ANS << endl;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    String op = sc.next();
    int B = sc.nextInt();
    
    System.out.println(op.equals("+") ? A+B : A-B);
  }
}

Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <map>


using namespace std;

#define MOD 1000000007
#define INF INT_MAX
#define ll long long

int main()
{
	string s;
	cin >> s;

	char tmp = s[0];
	int cnt = 0;
	for (int i = 1; i < s.size(); i++) {
		if (tmp != s[i]) {
			tmp = s[i];
			cnt++;
		}
	}

	cout << cnt << endl;

	return (0);
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int64_t ans = 0;
    for (int b = 1; b < n+1; b++) {
        int p = n / b;
        int r = n % b;
        ans += p * max(0, b - k);
        ans += max(0, r - k + 1);
    }
    if (k == 0) ans -= n;
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	s, t := nextLine(), nextLine()
	a, b := nextInt(), nextInt()
	u := nextLine()
	if u == s {
		fmt.Println(a-1, b)
	} else if u == t {
		fmt.Println(a, b-1)
	} else {
		fmt.Println(a, b)
	}
}

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


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

int main() {
  int N;
  cin >> N;
  string S = "APPROVED";
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    if (A % 2 == 0) if (A % 3 and A % 5) S = "DENIED";
  }
  cout << S << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,k;
  cin>>n>>k;
  int w[n];
  for(int i=0;i<n;i++) cin>>w[i];
  int sum=0;
  for(int i=0;i<n;i++) sum+=w[i];
  int l=0,r=sum;
  while(l+1<r){
    int m=(l+r)/2;
    int t=0,tmp=0;
    bool f=0;
    for(int i=0;i<n;i++){
      f|=w[i]>m;
      if(tmp+w[i]>m){
    tmp=w[i];
    t++;
      }else tmp+=w[i];
    }
    if(tmp) t++;
    if(!f&&t<=k) r=m;
    else l=m;
  }
  cout<<r<<endl;
  return 0;
}


Measured memory_bytes: 3868
#include <stdio.h>
#include <math.h>
#include <string.h>


int main(){
	int n;
    double w, h;
    while(scanf("%d,%lf,%lf",&n, &w, &h)!=EOF){
        double BMI = w /(h * h);
        if(BMI >= 25.0){
            printf("%d\n",n);
        }
    }
	return 0;
}

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

int main() {

	int n; cin>>n;
	int b[n-1],a[n]; 
	for(int i=0;i<n-1;i++) { cin>>b[i]; }
	long long int sum=0; a[0]=b[0]; a[n-1]=b[n-2];
	sum+=a[0]+a[n-1];
	for(int i=0;i<n-2;i++) {
		if(b[i]>b[i+1]) { a[i+1]=b[i+1]; sum+=a[i+1]; }
		else { a[i+1]=b[i]; sum+=a[i+1]; }
	}
	cout<<sum<<endl;
	return 0;
}

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

int main(){
    int N,M,sum=0,a;
    cin >> N >> M;
    for(int i=0;i<M;i++){
        cin >> a;
        sum+=a;
    }
    if(sum>N)
    cout << -1 << endl;
    else
    {
        cout << N-sum << endl;
    }
    
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9+7;


int main()
{
    int n;
    double ans = 0;
    cin >> n;
    vector <double> num(n+1);
    vector <vector <double>> dp(n+1, vector <double> (n+1, 0));
    dp[0][0] = 1;
    for (int i=1; i<=n; ++i)
    {
        cin >> num[i];
        for (int j=0; j<=i; ++j)
        {
            double x1=0, x2=0;
            if (j)
                x1 = num[i] * dp[i-1][j-1];
            x2 = (1 - num[i]) * dp[i-1][j];
            dp[i][j] = x1 + x2;
        }
    }

    for (int i = (n+1)/2; i<=n; ++i)
        ans += dp[n][i];

    cout.precision(20);
    cout << ans;

    return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}
void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        cout << 2 << " ";  
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            cout << i << " ";  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        cout << n << " ";  
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
   
    long long int n1,m1,t;
   //cin>>t;
 t=1;
    while(t--)
    {
   long long int i,j;
 //long long int b[1000000];
 //set<long long int >s;
       long long int f=0,p=0,o=0;
       double pie=3.141592653589793238;
    long long int c=0,n,m=0,l=0,r=0,k=0,min1=10000000000000,max2=0,ans=0;
      map<long long int,long long int>mp,mp1;
 cin>>n>>m>>k;
 cin>>r;
 
 if(n<m&&m<k)
 cout<<"Yes";
 else
 {
     while(n>=m&&r)
     {
         m=m*2;
         r--;
     }
     while(m>=k&&r)
     {
         k=k*2;
       r--;
     }
      if(n<m&&m<k)
 cout<<"Yes";
 else
 cout<<"No";
 }
 
 
    }
 return 0;
}


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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

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

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int N = input();
    range(i, 0, N) range(j, 0, N) {
        if (i * 4 + j * 7 == N) {
            cout << "Yes" << endl;
            return;
        }
    }

    cout << "No" << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b, h;
	cin >> a >> b >> h;
	int ans = (a + b)*h / 2;
	cout << ans << endl;
}

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

using namespace std;

int main(){
	
	while(1){
		string a;
		
		string ans = "yes";
		
		getline(cin,a);
		if(a==".") break;
		char st[100];
		int p=0;
		
		for(int i=0;a[i];i++){
			if(a[i]=='('){
				st[p]=')';
				p++;
			}else if(a[i]=='['){
				st[p]=']';
				p++;
			}
			if(a[i]==')'||a[i]==']'){
				p--;
				if(p<0){
					ans ="no";
					break;
				}
				if(st[p]!=a[i]){
					ans="no";
					break;
				}
			}
		}
		if(p!=0)ans="no";
		
		cout << ans << endl;
		
	}
	return 0;
}


Measured memory_bytes: 3208
#include <iostream>

using namespace std;

void insertionSort(int a[], int n){
	int v, j;
	for(int i=0; i<n; i++){
		if(i < n-1) cout << a[i] << " ";
		else cout << a[i] << endl;
	}
	for(int i=1; i<n; i++){
		v = a[i];
		j = i-1;
		while(j>=0 && a[j]>v){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
		for(int i=0; i<n; i++){
			if(i < n-1) cout << a[i] << " ";
			else cout << a[i] << endl;
		}
	}
}

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

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

	insertionSort(a, n);

	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int n;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	if(n%2 == 0) cout << 0.5 << "\n";
	else cout << setprecision(10) << (double)(n/2+1)/n << "\n";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        var tmp = ReadIntArray();
        int h = tmp[0], w = tmp[1];
        string s = new string('#', w+2);
        WriteLine(s);
        for (int i = 0; i < h; i++)
        {
            Write('#'); Write(ReadLine()); WriteLine('#');
        }
        WriteLine(s);
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
using namespace std;
const int N=1e5+5;
int b[N];

bool cmp(int x,int y)
{
	return x>y;
}

int main()
{
	int n,h,ma=0;
	cin>>n>>h;	
	for(int i=0;i<n;i++){
		int t;
		cin>>t>>b[i];
		if(t>ma)
			ma=t;
	}
	sort(b,b+n,cmp);
	int m=0,s=0;
	while(h>0){
		if(b[m]>ma){
			h-=b[m];
			s++;
			m++;
		}
		else{
			s+=h/ma;
			if(h%ma>0)
				s++;
			break; 
		}
	}
	cout<<s<<endl;
	return 0;	
} 

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

typedef long long ll;

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

    vector<ll> A(N);
    vector<ll> absA(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        A[i] = A[i] - (i+1);
    }

    sort(A.begin(), A.end());

    ll mid = A[A.size()/2];
    ll ans = 0;
    for(int i=0;i<N;i++){
        ans += abs(A[i]-mid);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328