akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define pb push_back
bool isPrime(ll n) 
{ 
    
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
   
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
ll minthis(ll a, ll b){
if(a < b){
return a;
}
return b;
}
ll maxthis(ll a, ll b){
if(a > b){
return a;
}
return b;
}
int gcd(int a, int b){
    if( a<0 ) a = -a;
    if( b<0 ) b = -b;
    while( b!=0 ){
        a %= b;
        if( a==0 ) return b;
        b %= a;
    }
    return a;
}
 
int findLargestDivisor(int n) 
{ 
	int max = 1;
    for (int i = 2; i < n; i++) {        
        if(n %(i) == 0) { 
            max = i;
        } 
    }
    return max;     
} 
	 
 
ll power(ll x, ll y)  
{  
    ll temp;  
    if(y == 0)  
        return 1;  
    temp = power(x, y / 2);  
    if (y % 2 == 0)  
        return (temp * temp)%1000000007;  
    else
    {  
        if(y > 0)  
            return (x * temp * temp)%1000000007;  
        else
            return (temp * temp)%1000000007 / x;  
    }  
} 
bool sortbysec(const pair<int, int>& a, 
               const pair<int, int>& b) 
{ 
    return (a.second < b.second); 

} 


void solve(){
    int n;
    cin >> n;
    if(n >= 30) cout << "Yes" << "\n";
    else cout << "No" << "\n";
}
int main(){ 
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
	solve();
    }
    return 0; 
}





Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
      os << *i;
  }
  return os;
}

ll W;
ll c[10],d[10];

void init(ll B[100]){
  rep(i,W-1){
    if(B[i]==1){
      c[i]++;
    }
  }
  rep(i,W){
    if(i==0){
      if(B[i]==0){
        d[i]++;
      }
    }
    else if(i==W-1){
      if(B[i-1]==0){
        d[i]++;
      }
    }
    else{
      if(B[i]==0 && B[i-1]==0){
        d[i]++;
      }
    }
  }
}

void dfs(ll i,ll B[100]){
  if(i>=W-1){
    init(B);
    return;
  }
  else{
    dfs(i+1,B);
    B[i]=1;
    dfs(i+2,B);
    B[i]=0;
  }
}

ll dp[1007][10];

int main(){
  ll H,K,B[100];
  rep(i,99){
    B[i]=0;
  }
  cin >> H >> W >> K;
  dfs(0LL,B);
  dp[0][0]=1;
  Rep(i,1,H+1){
    rep(j,W){
      dp[i][j]=(j>0 ? dp[i-1][j-1]*c[j-1] : 0)+dp[i-1][j]*d[j]+(j<W-1 ?  dp[i-1][j+1]*c[j] : 0);
      dp[i][j]%=MOD;
    }
  }
  cout << dp[H][K-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#define MOD 1000000007
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;

signed main(){
    int n;
    cin>>n;
    string s[114514];
    for(int i=0;i<n;i++){
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
    }
    sort(s,s+n);
    int ans=0;
    int c=1;
    for(int i=1;i<n;i++){
        if(s[i]==s[i-1]){
            c++;
        }else{
            ans+=c*(c-1)/2;
            c=1;
        }
    }
    ans+=c*(c-1)/2;
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
int n, a[100020];
int ans, t;
int lg(int x) {
	if (x == 1) {
		return 0;
	}
	return lg(x / 2) + 1;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		int c = lg(x);
		int d = 0;
		if (x != (1 << c)) {
			d = 1;
		}
		if (t < c) {
			ans += c - t;
			t = c;
		}
		if (t > c) {
			t = c;
			d = 0;
		}
		if (d) {
			ans++;
			t++;
		} 
	}
	printf("%d\n", ans);
}

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

ll two(ll n){
	ll res = 0;
	while(n % 2 == 0){
		n /= 2;
		res++;
	}
	return res;
}

int main(){
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >>a[i];
	ll ans = 0;
	rep(i,n){
		ans += two(a[i]);
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
using ll = long long;
int main(void){
    int n;
    cin >> n;
    ll mn = 1000001, mx = -1000001, sum = 0;
    for(int i = 0; i < n; i++){
        ll data;
        cin >> data;
        mn = min(mn, data); mx = max(mx, data);
        sum += data;

    }
    cout << mn << ' ' << mx << ' ' << sum << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int n;

std::vector<int> x;
std::vector<int> v;

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		x.push_back(a);
	}
	v = x;
	std::sort(v.begin(), v.end());
	int med1, med2;
	med1 = v[n/2-1];
	med2 = v[n/2];
	for(int i = 0; i < n; i++){
		if(x[i] < med2){
			printf("%d\n", med2);
		}else{
			printf("%d\n", med1);
		}
	}
	return 0;
}


Measured memory_bytes: 3828
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>
#define PI acos(-1)
typedef long long ll;
const long long mod = 1e9 + 7;
const long long maxn = 1e5 + 5; 
using namespace std;

int main()
{
	int k, a, b;
	scanf("%d", &k);
	scanf("%d %d",&a, &b);
	int flag = 0;
	for (int i = a; i <= b; i++)
	{
		if (i % k == 0)
		{
			flag = 1;
			break;
		}
	}
	if (flag)
	{
		printf("OK\n");
	}
	else
	{
		printf("NG\n");
	}
	return 0;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n, v, p;
ll m, a[100005];
bool f(int x) {
    if (x < p) return true;
    if (a[x] + m < a[p - 1]) return false;

    ll res = 0;
    rep(i, n) {
        if (i < p - 1 || i >= x) res += m;
        else res += a[x] + m - a[i];
    }

    return res >= m * v;
}

void solve() {
    cin >> n >> m >> v >> p;
    rep(i, n) cin >> a[i];
    sort(a, a + n, greater<>());

    int l = -1, r = n;
    while (r - l > 1) {
        auto x = (l + r) / 2;

        if (f(x)) l = x;
        else r = x;
    }

    cout << r << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 1152
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for i in range(min(A, X//500) + 1):
  X_pool = X
  if X - 500 * i >= 0:
    X_pool = X_pool - 500 * i
    for j in range(min(B, X_pool//100) + 1):
      X_pool_2 = X_pool
      if X_pool - 100 * j >= 0:
        X_pool_2 = X_pool - 100 * j
        if X_pool_2%50 == 0 and X_pool_2//50 <= C :
            count += 1
print(count)

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

using namespace std;

int a[5];
int main()
{
    string s;
    cin >> s;
    int axis = 0, ord = 0;
    for (int i = 0; i < s.size(); ++i) {
        switch (s[i]) {
            case 'E':
                if (!a[0]) {
                    axis = !axis;
                }
                a[0] = 1;
                break;
            case 'W':
                if (!a[1]) {
                    axis = !axis;
                }
                a[1] = 1;
                break;
            case 'N':
                if (!a[2]) {
                    ord = !ord;
                }
                a[2] = 1;
                break;
            case 'S':
                if (!a[3]) {
                    ord = !ord;
                }
                a[3] = 1;
                break;
        }
    }
    if (axis || ord) puts("No");
    else puts("Yes");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int cnt=0;
 string s,t;
 cin>>s;
 t=s;
 reverse(s.begin(),s.end());
 for(int i=0;i<s.size();i++)
 {
     if(s[i]!=t[i])
     {
         cnt++;
     }
 }
 cout<<cnt/2<<endl;
    return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;

    if(a % 2 == 1 && b % 2 == 1) {
        cout << "Odd" << endl;
    } else {
        cout << "Even" << endl;
    }
}


Measured memory_bytes: 3588
using System;
using System.Linq;

namespace ConsoleApp_ITP1_7_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] dimension = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int n = dimension[0];
            int m = dimension[1];
            int l = dimension[2];

            int[,] matrixa = new int[n, m];
            int[,] matrixb = new int[m, l];
            double[,] matrixc = new double[n, l];

            for(int i = 0; i < n; i++)
            {
                int[] matrixaRank = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

                for (int j = 0; j < m; j++)
                {
                    matrixa[i, j] = matrixaRank[j];
                }
            }

            for (int i = 0; i < m; i++)
            {
                int[] matrixbRank = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

                for (int j = 0; j < l; j++)
                {
                    matrixb[i, j] = matrixbRank[j];
                }
            }

            for(int i = 0; i < n; i++)
            {
                for(int j = 0; j < l; j++)
                {
                    for(int k = 0; k < m; k++)
                    {
                        matrixc[i, j] += matrixa[i, k] * matrixb[k, j];
                    }
                }
            }

            for(int i = 0; i < n; i++)
            {
                for(int j = 0; j < l; j++)
                {
                    Console.Write(matrixc[i, j]);
                    if (j < l - 1)
                        Console.Write(" ");
                }
                Console.WriteLine();
            }
        }
    }
}



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

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

int main() {
	string s; cin >> s;
	int K; cin >> K;
	int n = s.size();
	dp[0][0][0] = 1;
	rep(i, n)rep(j, 4)rep(k, 2) {
		int nd = s[i] - '0';
		rep(d, 10) {
			int ni = i + 1, nj = j, nk = k;
			if (d != 0) nj++;
			if (nj > K) continue;
			if (k == 0) {
				if (nd > d) nk = 1;
				if (nd < d) continue;
			}
			dp[ni][nj][nk] += dp[i][j][k];
		}
	}
	int ans = dp[n][K][0] + dp[n][K][1];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
d={}
for i in range(m):
    p,s=map(str,input().split())
    if p not in d:
        d[p]=[s,1]
    elif d[p][0]=="WA":
        d[p][0]=s
        d[p][1]+=1
ans=[0,0]
for i in d:
    if d[i][0]=="AC":
        ans[0]+=1
        ans[1]+=d[i][1]-1
print(*ans)


Measured memory_bytes: 73048
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define mp unordered_map
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    ll n;
    cin>>n;
    if(n==1){
        cout<<0;
    }else{
    cout<<1;
    }
}
		

Measured memory_bytes: 3592
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    ll a, b;
    cin >> a >> b;

    if(a%2==1 && b%2==1){
        p("Odd");
    }else{
        p("Even");
    }
    
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w;
	cin >> h >> w;
	vector<vector<int>> c(10, vector<int>(10));
	for (int i = 0; i < 10; i++) {
		for( int j = 0; j < 10; j++) {
			cin >> c[i][j];
		}
	}
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			for (int k = 0; k < 10; k++) {
				c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int in;
			cin >> in;
			ans += in >= 0 ? c[in][1] : 0;
		}
	}
	cout << ans << '\n';
	return 0;	
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> l,r;
    for(int i=0; i<N; i++)
    {
        int x,y;
        cin >> x >> y;
        l.push_back(x);
        r.push_back(y);
    }

    int total = 0;
    for(int i=0; i<N; i++)
    {
    	total += r[i]-l[i]+1;
    }
    cout << total << endl;


	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    char c; cin>>c;
    
    bool OK = false;
    for(char a='a'; a<='z'; a++){
        if(OK){
            cout << a << endl;
            return 0;
        }
        if(a == c) OK = true; 
    }

    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::*;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: i64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        N: usize,
        S: Chars,
    }

    let R = S.iter().filter(|&&s| s == 'R').count();
    let G = S.iter().filter(|&&s| s == 'G').count();
    let B = S.iter().filter(|&&s| s == 'B').count();

    let mut ans = R * G * B;

    for i in 0..N {
        for k in i+1..N {
            let j2 = i + k;
            if j2 % 2 == 1 {
                continue;
            }

            let (si, sj, sk) = (S[i], S[j2 / 2], S[k]);

            if si != sj && sj != sk && sk != si {
                ans -= 1;
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2168
#include <algorithm>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

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

  vector<ll> A;
  ll a;
  int counter[100];
  memset(counter, 0, sizeof(counter));
  ll base[100];
  memset(base, 0, sizeof(base));

  for (int i = 0; i < N; ++i) {
    cin >> a;
    A.push_back(a);

    for (int j = 0; j < 63; ++j) {
      base[j] = pow(2, j);
      base[j] %= MOD;

      if (((a >> j) & 1) == 1) {
        ++counter[j];
      }
    }
  }

  ll ans = 0;

  for (int i = 0; i < N - 1; ++i) {
    int remain = N - (i + 1);
    a = A[i];

    for (int j = 0; j < 63; ++j) {
      if (((a >> j) & 1) == 1) {
        --counter[j];
        ans += (base[j] * (remain - counter[j])) % MOD;
      } else {
        ans += (base[j] * counter[j]) % MOD;
      }
    }
  }

  cout << ans % MOD << endl;

  return 0;
}


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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  i64 n, k;
  cin >> n >> k;

  i64 ans = n % k;

  if (ans > k / 2) {
    cout << abs(ans - k);
  } else {
    cout << ans;
  }

  return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

int main() {
	int N,M,X;
    cin >> N >> M >> X;
    vector<int> cost(N);
    vector<vector<int>> vec(N,vector<int>(M));
    for(int i = 0;i < N;i++) {
        cin >> cost.at(i);
        for(int j = 0;j < M;j++) {
            cin >> vec.at(i).at(j);
        }
    }
    int ret = Inf;
    for(int bit = 0;bit < (1 << N);bit++) {
        vector<int> cnt;
        for(int i = 0;i < N;i++) {
            if(bit & (1 << i)) {
                cnt.push_back(i);
            }
        }
        vector<int> cnt2(M);
        for(int i = 0;i < cnt.size();i++) {
            for(int j = 0;j < M;j++) {
                cnt2.at(j) += vec.at(cnt.at(i)).at(j);
            }
        }
        bool ret2 = true;
        for(int i = 0;i < M;i++) {
            if(cnt2.at(i) < X) {
                ret2 = false;
            }
        }
        if(ret2 == true) {
            int cnt3 = 0;
            for(int i = 0;i < cnt.size();i++) {
                cnt3 += cost.at(cnt.at(i));
            }
            ret = min(ret,cnt3);
        }
    }
    if(ret == Inf) {
        cout << -1 << endl;
    }
    else {
        cout << ret << endl;
    }
}

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

#define fi                      first
#define se                      second
#define pb                      push_back
#define endl                    '\n'
#define all(x)                  x.begin(),x.end()
#define pii                     pair<int,int>
#define pll                     pair< long long int, long long int> 
#define fast                    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define SZ(x)                   ((int)x.size())

#define FOR(i,a,b)              for(int i = a; i < b; ++i)
#define REV(i,a,b)              for(int i = a; i >= b; --i)
#define FORE(i,a,b)             for(int i = a; i <= b; ++i)

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

void solve();

int32_t main()
{
        fast;
        int t = 1;
        // cin >> t;
        for(int i = 1; i <= t; ++i)
                solve();
        cerr << "Time taken: " << ((clock() * 1000) / CLOCKS_PER_SEC) << "ms\n";
}

void solve() {
        string s;
        cin >> s;
        FOR(i,0,SZ(s)) {
        	cout << 'x';
        }
        cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long int n,k;
    cin>>n>>k;
    int i,a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int sum=0;
    for(i=0;i<k;i++)
    {
        sum=sum+a[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3588
import java.awt.geom.Rectangle2D;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Rectangle2D a = new Rectangle2D.Double();
		Rectangle2D b = new Rectangle2D.Double();
		while (in.hasNext()) {
			double xa1 = in.nextDouble();
			double ya1 = in.nextDouble();
			double xa2 = in.nextDouble();
			double ya2 = in.nextDouble();
			double xb1 = in.nextDouble();
			double yb1 = in.nextDouble();
			double xb2 = in.nextDouble();
			double yb2 = in.nextDouble();
			String result = xa1 <= xb2 && xa2 >= xb1 && ya1 <= yb2
					&& ya2 >= yb1 ? "YES" : "NO";
			System.out.println(result);
		}
	}
}

Measured memory_bytes: 20764
#include<bits/stdc++.h>                          
using namespace std;
int n,m,a[105],ans;
double x;
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++) 
	    cin>>a[i],x+=a[i];
    x=x/m/4;
    for(int i=1;i<=n;i++)
        if(a[i]>=x) ans++;
    if(ans>=m) cout<<"Yes";
    else cout<<"No";
	return 0;
}
//68871358
//76140264
//25446011
//200841159
//914174775

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

const int maxN = 1e5 + 10, mod = 1e9 + 7;

int n;
int fac[maxN + 1], inv[maxN + 1];
int g[maxN + 1];

inline int read()
{
	int num = 0, f = 1;
	char ch = getchar();
	while( !isdigit( ch ) ) { if(ch == '-') f = -1; ch = getchar(); }
	while( isdigit( ch ) ) num = (num << 3) + (num << 1) + (ch ^ 48), ch = getchar();
	return num * f;
}

inline int mpow(int a, int x)
{
	int ans = 1;
	while(x)
	{
		if(x & 1) ans = 1ll * ans * a % mod;
		a = 1ll * a * a % mod;
		x >>= 1;
	}
	return ans;
}

inline int ADD(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }

int main()
{
	n = read();
	fac[0] = 1;
	for(int i = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[n] = mpow(fac[n], mod - 2);
	for(int i = n - 1; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;

	for(int i = 1; i <= n; i++) inv[i] = 1ll * inv[i] * fac[i - 1] % mod;
	for(int i = 2; i <= n; i++) inv[i] = ADD(inv[i - 1], inv[i]);

	int ans = 0, last = read();
	for(int i = 2; i <= n; i++) 
	{
		int x = read();
		ans = ADD(ans, 1ll * (x - last) * inv[i - 1] % mod);
		last = x;
	}
	printf("%lld", 1ll * ans * fac[n - 1] % mod);
	return 0;
}

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

int main(){
  
  string a;
  cin >> a;
  
  if( a.at(0) == a.at(2) ){
    
    cout << "Yes" << endl;
    
  }
  
  else{
    
    cout << "No" << endl;
    
  }
  
}


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

int main() {
  int n, o = 0;
  cin >> n;
  vector<int> p(n);
  for(int i = 0; i < n; i++) {
    cin >> p.at(i);
    if(i > 1) {
      if(p.at(i) > p.at(i - 1) && p.at(i - 1) > p.at(i - 2))
        o++;
      if(p.at(i) < p.at(i - 1) && p.at(i - 1) < p.at(i - 2))
        o++;
    }
  }
  cout << o << endl;
}

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

class Program
{
    static void Solve()
    {
        var a = sc.Int();
        var b = sc.Int();

        if (a % 2 == 0 || b % 2 == 0)
            pr.WriteLine("Even");
        else
            pr.WriteLine("Odd");
    }

    static void Main(string[] args)
    {
        // pr.AutoFlush = true;
        Solve();
        pr.Flush();
    }

    static Scanner sc = new Scanner();
    static Printer pr = new Printer();
}

#region IO
class Scanner
{
    private int _i = 0;
    private string[] line = new string[0];

    private T[] Enumerate<T>(int n, Func<T> f)
    {
        T[] ret = new T[n];
        for (int i = 0; i < n; i++)
            ret[i] = f();
        return ret;
    }

    public string Str()
    {
        if (line.Length <= _i)
        {
            line = Console.ReadLine().Split(' ');
            _i = 0;
        }

        return line[_i++];
    }

    public int Int() => int.Parse(Str());
    public long Long() => long.Parse(Str());
    public double Double() => double.Parse(Str());
    public int[] Int(int n) => Enumerate(n, Int);
    public long[] Long(int n) => Enumerate(n, Long);
    public double[] Double(int n) => Enumerate(n, Double);
    public string[] Str(int n) => Enumerate(n, Str);
}

class Printer : StreamWriter
{
    public Printer() : base(Console.OpenStandardOutput())
    {
        AutoFlush = false;
    }
}
#endregion

Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int main()
{
    int a[4],b[4];
    while(cin>>a[0])
    {
        int hit=0;
        int blow=0;
        for(int i=1;i<4;++i){
            cin>>a[i];
        }
        for(int i=0;i<4;++i){
            cin>>b[i];
        }
        for(int i=0;i<4;++i){
            for(int j=0;j<4;++j){
                if(a[i]==b[j]){
                    if(i==j)hit++;
                    else blow++;
                }
            }
        }
        cout<<hit<<" "<<blow<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define ARRAY_LEN(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INTINF = 2147483647;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  string result = "No";
  if ( N/10 == 9 || N%10 == 9 ) result = "Yes";
  cout << result << endl;
  return 0;
}

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

int main() {

  int N = 0;
  int R = 0;

  cin >> N >> R;

  if (N >= 10) {
    cout << R << endl;
  } else {
    cout << R + (100 * (10 - N)) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 1e5+7;

int mem[N];
int n,k;
int h[N];
int dp(int i)
{
    int &ret = mem[i];
    if (ret != -1) return ret;
    if (i == n-1) return 0;
    ret = OO;
    REP(j,1,k)
    {
        if (i+j >= n) break;
        ret = min(ret,dp(i+j)+abs(h[i]-h[i+j]));
    }
    cerr << i << ' ' << ret << endl;
    return ret;
}

int main()
{
    //ios::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);
    memset(mem,-1,sizeof mem);
    scanf("%d %d",&n,&k);
    REP(i,0,n-1) scanf("%d",&h[i]);
    printf("%d\n",dp(0));

    return 0;
}


Measured memory_bytes: 9216
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();
	        int M = sc.nextInt();
	        long[] a = new long[N];
	        for (int i=0 ; i<N; i++) {
	            a[i] = Long.parseLong(sc.next())-1;
	        }
	        Unionfind uf = new Unionfind(N);
	        for (int i=0 ; i<M; i++) {
	        	int ai = sc.nextInt()-1;
	        	int b = sc.nextInt()-1;      	
	            uf.union(ai,b);
	        }
	        long ans=0;
	        for(int i=0;i<N;i++) {
	        	if(uf.same(i, (int)a[i]))ans++;
	        }
	        
	        System.out.println(ans);
	    }
	}

	 class Unionfind {
		 
			private int[] data;
			private int []size;
			
			public Unionfind(int size) {
				this.data = new int [size];
				this.size = new int [size];
				for(int i = 0 ;i < size ;i++) {
					initnode(i);
				}
				clear();
			}
			
			public void initnode(int i) {
				size[i] = 1;
			}
			
			public void clear() {
				Arrays.fill(data, -1);
			}
			
			public void union(int x , int y ) {
				if((x = root(x)) != (y = root(y))) {
					if(data[y] < data[x]) {
						final int t = x;
						x = y;
						y = t;
					}
					data[x] += data[y];
					size[root(x)] += size[root(y)];
					data[y] = x;
				}
			}
			
			public int getSize(int i) {
				return size[root(i)];
			}
			
			public int root(int x) {
				if(data[x] < 0) {
					return x;
				}
				else {
					return data[x] = root(data[x]);
				}
			}
			
			public boolean same(int x, int y) {
				return root(x) == root(y);
			}
			
		}


Measured memory_bytes: 94316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define dd double
#define f0(i, n) for(int i = 0; i < n; i++)
#define fab(i,a,b) for(int i=a;i<b;i++)
#define f1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second



ll dp[105][100005];
int ans;

int main() {


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

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif


//ios_base& scientific (ios_base& str);
	int n, w;
	cin >> n >> w;

	int wt[n], val[n];

	int total_val = 0;

	for (int i = 0; i < n; i++) {

		cin >> wt[i] >> val[i];

		total_val += val[i];
	}

	dp[0][0] = 0;

	for (int i = 1; i <= total_val; i++) {

		dp[0][i] = 1e18;
	}
	// cout << "hi";

	for (int i = 0; i < n; i++) {

		for (int j = 0; j <= total_val; j++) {

			if (j >= val[i]) {

				dp[i + 1][j] = min(dp[i][j], dp[i][j - val[i]] + wt[i]);
			}
			else {

				dp[i + 1][j] = dp[i][j];
			}

			if (dp[i + 1][j] <= w) {

				ans = max(ans, j);
			}
		}
	}

	cout << ans << endl;





	return 0;
}

Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
const int mod = 1e9 + 7;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, m;
	cin >> n >> m;
	vector<ll>v(m);
	for (int i = 0; i < m; i++) 	{
		cin >> v[i];
	}
	vector<ll>dp(n + 5, -1);
	for (int i = 0; i < m; i++) {
		dp[v[i]] = 0;
	}
	dp[0] = 1;
	if (dp[1] == -1)dp[1] = 1;
	for (int i = 2; i <= n; i++) {
		if (dp[i] == 0)continue;
		else
			dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;


int main()
{
	IOS;
	int a;
	cin>>a;
	cout<<a+a*a+a*a*a;
	return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  map<int,int> mp;
  for(int i = 0; i < n; ++i){
    int x; cin >> x;
    mp[x]++;
  }
  int ans = 0;
  for(auto e:mp){
    if(e.first <= e.second) ans += e.second - e.first;
    else ans += e.second;
  }
  cout << ans << endl;
}



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

using namespace std;
using LL = long long;

constexpr int MAXN = 2e5 + 5;

template <typename T>
inline void read(T &x) {
    int f = 1; x = 0;
    char ch = getchar();
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

LL n, cnt;
vector<LL> factor;

int main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    n--;
    for (LL i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt += (i * i == n) ? 1 : 2;
        }
    }
    cnt--, n++;
    for (LL i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            if ((n - 1) % i == 0 || (n - 1) % (n / i) == 0) continue;
            if (i * i != n) {
                factor.emplace_back(i);
                factor.emplace_back(n / i);
            } else factor.emplace_back(i);
        }
    }
    for (auto &i : factor) {
        LL tmp = n;
        while (tmp % i == 0) {
            tmp /= i;
        }
        if (tmp % i == 1) cnt++;
    }
    cout << ++cnt << endl;
    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	double x,q;
	while(q=in(),q>0){
		x=q/2;
		while(fabs(x*x*x-q)>=0.00001*q){
			x=x-(x*x*x-q)/(3*x*x);
		}
		printf("%.6f\n",x);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	string s;
	cin >> s;
	rep(i, s.size()) {
		if(s[i]=='C'){
			range(j, i + 1, s.size()) {
				if (s[j] == 'F') {
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

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

int main(){
   int N;
   cin >> N;
   vector<int> P(N);
   for (int i = 0; i < N; i++){
      cin >> P[i];
   }
   int usi = P[0];
   int ans = 0;
   for (int i = 0; i < N; i++){
      if (usi >= P[i]){
         ans++;
         usi = P[i];
      }
   }
   cout << ans<< endl;
}


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

int main(){
  int N,K,sum=0;
  cin >> N >> K;
  vector<int> P(N);
  for(int i=0;i<N;i++){
    cin >> P.at(i);
  }
  sort(P.begin(),P.end());
  for(int i=0;i<K;i++){
    sum+=P.at(i);
  }
  cout << sum << endl;
}

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

int main(){
  vector<char> c;
  char a;
  while(cin>>a)
    c.emplace_back(a);

  for(int i=0;i<(int)c.size();++i){
    if(c[i]=='A')
      cout<<'X';
    else if(c[i]=='B')
      cout<<'Y';
    else if(c[i]=='C')
      cout<<'Z';
    else{
      c[i] -= 3;
      cout<<c[i];
    }
  }

  cout<<endl;

  return EXIT_SUCCESS;
}

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

int main() {
  int K = 0;
  cin >> K;
  
  vector<int> suretsu(32);
  suretsu = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << suretsu.at(K-1) << endl; 
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
  
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;

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

  int n;
  cin>>n;
  int p[n+5];
  reps(i,n){
    cin>>p[i];
  }

  int sum=1,maxv=p[1];
  for(int i=2;i<=n;i++){
    if(p[i]<=maxv){
      sum++;
    }
    maxv=min(maxv,p[i]);
  }

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


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

int main() {
  int N, M;
  cin >> N >> M;
  vector <int> A(M);
  for(int i = 0; i < M; ++i){
    cin >> A.at(i);
  }

  int sum = 0;
  for(int i = 0; i < M; ++i){
    sum += A.at(i);
  }

  int ans = max(N - sum, -1);
  
  cout << ans << endl;
}


Measured memory_bytes: 3668
#include<cstdio>
#include<cstring>

int main(){
  char s1[200], s2[100], p[100];
  scanf("%s %s", s1, p);

  strcpy(s2, s1);
  strcat(s1, s2);
  if (strstr(s1, p) == NULL ) printf("No\n");
  else printf("Yes\n");

  return 0;
}


Measured memory_bytes: 2756
#include<iostream>
#include<vector>
#include<string>
#include<cstring>

// ref : http://kyopro.hateblo.jp/entry/2018/12/25/174720

using ll = long long;
/*
dp[d][smaller][leadingZero][num]
numは3, 5, 7を少なくとも1回選んだかどうかのフラグとする
具体的には3bit(つまり0 ~ 7)のうち各bitで管理する
*/
ll dp[11][2][2][8];

int main(){
    std::string S;
    std::cin >> S;

    memset(dp, sizeof dp, 0);
    dp[0][0][0][0] = 1;
    for(int d = 0; d < S.size(); d++){
        for(int smaller = 0; smaller < 2; smaller++){
            for(int leadingZero = 0; leadingZero < 2; leadingZero++){
                for(int num = 0; num < 8; num++){
                    // 未計算は使わないので飛ばす
                    if(dp[d][smaller][leadingZero][num] == -1) continue;

                    int val;
                    if(smaller == 1){
                        // 0 ~ 9まで選べる
                        val = 9;
                        if(leadingZero == 0){
                            // まだ0が続いている状態
                            // 必ず小さいのでsmallerは1
                            dp[d + 1][1][leadingZero][0] += dp[d][smaller][leadingZero][num];
                        }
                    }else{
                        val = S[d] - '0';
                        // 0 ~ valまで選べる
                        if(leadingZero == 0){
                            // まだ0が続いている状態
                            // 必ず小さいのでsmallerは1
                            dp[d + 1][1][leadingZero][0] += dp[d][smaller][leadingZero][num];
                        }
                    }

                    // valの値に応じてsmallerを切り替えて計算
                    if(val == 3) dp[d + 1][0][1][num | 1] += dp[d][smaller][leadingZero][num];
                    if(val > 3) dp[d + 1][1][1][num | 1] += dp[d][smaller][leadingZero][num];
                    if(val == 5) dp[d + 1][0][1][num | 2] += dp[d][smaller][leadingZero][num];
                    if(val > 5) dp[d + 1][1][1][num | 2] += dp[d][smaller][leadingZero][num];;
                    if(val == 7) dp[d + 1][0][1][num | 4] += dp[d][smaller][leadingZero][num];;
                    if(val > 7) dp[d + 1][1][1][num | 4] += dp[d][smaller][leadingZero][num];
                }
            }
        }
    }

    std::cout << dp[S.size()][0][1][7] + dp[S.size()][1][1][7] << std::endl;
    return 0;
}


Measured memory_bytes: 256
//by The_One_Solver
#include<bits/stdc++.h>
using namespace std;
string str,str2;
bool a;
int main()
{
    cin>>str>>str2;
    int n=str.size();
    int m=str2.size();
    for(int i=0;i<str.size();i++)
    {
        if(str[i]!=str2[i]){a=0;break;}
        else a=1;
    }
    if(a&&m-1==n)cout<<"Yes";
    else cout<<"No";

    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(int argc, const char * argv[]) {
    int n;
    double x[1000],y[1000];
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> x[i];
    }
    for (int i=0; i<n; i++) {
        cin >> y[i];
    }
    for (int p=1; p<=3; p++) {
        double sum =0;
        for (int i=0; i<n; i++) {
            sum+=pow(abs(x[i]-y[i]),(double)p);//p乗 absは絶対値をとる
        }
        sum = pow(sum,1.0/p); //1/p乗
        cout << fixed;
        cout << setprecision(6) << sum << endl;
    }
    double max = 0;
    for (int i=0; i<n; i++) {
        double comp = 0;
        comp = abs(x[i]-y[i]);
        if (comp > max) {
            max = comp; //絶対値の最大を記録
        }
    }
    cout << max << endl;
    return 0;
}



Measured memory_bytes: 3472
//  [[8] {} [24]] ->  MAMBA FOREVER.

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

typedef long double ld;
#define int long long
#define RAGE ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(i=0; i <n; i++)
#define repv(i,k,n) for(i=k; i<n; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define endl '\n'
int mod = 1e9+7;
int power(int x,int n)
{   if(n==0)    return 1;
    if(n==1)    return x%mod;
    if(n%2==0)  {   int y = power(x,n/2)%mod;   return (y*y)%mod;   }
    if(n&1)     {   int y =  power(x,n-1);  return (x%mod * y%mod)%mod; }
    return 0;
}
const int maxn = 200005;
//  --------------------------------------------------------------------
void solve()
{
    int n,i,j,k,m;
    cin>>n;
    int ar[n+1][3];
    for(i=1; i<=n; i++)  
    {   
        rep(j,3)    
            cin>>ar[i][j];
    }

    int dp[n+1][3];
    const int swim =0,bug=1,work=2;
    memset(dp,0,sizeof(dp));
    for(i=1; i<=n; i++)
    {
        dp[i][swim] = ar[i][swim] + max( dp[i-1][bug] ,dp[i-1][work]);
        dp[i][bug]  = ar[i][bug] +  max( dp[i-1][work] ,dp[i-1][swim]);
        dp[i][work]  = ar[i][work] +  max( dp[i-1][bug] ,dp[i-1][swim]);
    }

    cout<<max({dp[n][swim] , dp[n][work] ,dp[n][bug]});

}
signed main()
{
    RAGE;
    int t=1;
    //cin>>t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 4992
n = gets.to_i
ar = []
for num in 0..n-1 do
 word = gets.chomp
  ar << word
end
  ac = ar.count("AC")
  wa = ar.count("WA")
  tle = ar.count("TLE")
  re = ar.count("RE")
puts "AC x #{ac}"
puts "WA x #{wa}"
puts "TLE x #{tle}"
puts "RE x #{re}"

Measured memory_bytes: 20612
//B - Grid Compression
#include <bits/stdc++.h>
using namespace std;

int main() {
   int h, w; cin >> h >> w;
   vector<string> mas;
   for(int i = 0; i < h; i++){
      string line; cin >> line;
      int num = count(line.begin(), line.end(), '.');
      if(num != line.size())
         mas.push_back(line);
   }
   
   for(int i = 0; i < w; i++){
      int count = 0;
      for(int j = 0; j < mas.size(); j++){
         if(mas.at(j).at(i)=='.') count++;
      }
      
      if( count == mas.size() ){
         for(int j = 0; j < mas.size(); j++){
            if(mas.at(j).at(i)=='.') mas.at(j).at(i) = '-';
         } 
      }
   }
   
   for(int i = 0; i < mas.size(); i++){
      for(int j = 0; j < mas.at(i).size(); j++){
         if(mas.at(i).at(j) != '-'){
            cout << mas.at(i).at(j);
         }
      } cout << endl;
   }
}


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

using namespace std;
bool ii(float k)
{
  if(floor(k) == k)return 1;
  else return 0;
}
void x(ll a[],ll n){
    ll bb[n];
    for(ll i=0;i<n;i++)
    bb[i]=a[i];
    for(ll i=1;i<n;i++)
    if(i!=n-1)a[i]=bb[i-1];
    a[0]=bb[n-1];
}
int main()
{
	ll T,n;
   
	//cin>>T;
	//while(T--){
	    ll k,m,p=0;
	    float d=0;
	    //b,e=0,o=0,d=0,c=0;
	    cin>>n>>k;
	    ll a[n][k];
	    for(ll i=0;i<n;i++)
	    for(ll j=0;j<k;j++)
	    cin>>a[i][j];
	    for(ll i=0;i<n;i++)
	    for(ll o=i+1;o<n;o++){
	        d=0;
	    for(ll j=0;j<k;j++)
	    {  d+=(a[i][j]-a[o][j])*(a[i][j]-a[o][j]);
	        
	    }
	      if(ii(sqrt(d)))p++;
	    }
cout<<p<<endl;
}








Measured memory_bytes: 256