akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(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 tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<vi> f(n,vi(10)),p(n,vi(11));
    rep(i,n) rep(j,10) cin >> f[i][j];
    rep(i,n) rep(j,11) cin >> p[i][j];
    int ans = -inf;
    auto cnt = [&](int bit,int i) {
        int ret = 0;
        rep(j,10) {
            if(bit>>j&1 && f[i][j]) ret++;
        }
        return ret;
    };
//    int nbit;
    rep(bit,1<<10) {
        int now = 0;
        bool ok = false;
        rep(i,10) if(bit>>i&1) ok = true;
        if(!ok) continue;
        rep(i,n) now += p[i][cnt(bit,i)];
//        if(ans < now) nbit = bit;
        chmax(ans,now);
    }
//    rrep(i,10) cout << (nbit>>i&1 ? 1 : 0);
//    cout << endl;
//    cout << cnt(nbit,0) << " " << cnt(nbit,1) << endl;
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vvi a;
vi b;

int main(){
	cin>>n;
	a=vvi(n,vi(n-1));
	b=vi(n);
	for(int i=0;i<n;i++) for(auto &j:a[i]){
		cin>>j;
		j--;
	}
	int res=0;
	set<int> st;
	for(int i=0;i<n;i++) if(a[a[i][0]][0]==i&&i<a[i][0]) st.insert(i);
	while(b!=vi(n,n-1)){
		if(st.empty()){
			res=-1;
			break;
		}
		set<int> st_=st;
		for(auto i:st){
			st_.insert(a[i][b[i]]);
			b[a[i][b[i]]]++;
			b[i]++;
		}
		st=st_;
		st_.clear();
		for(auto i:st) if(b[i]<n-1){
			int j=a[i][b[i]];
			if(b[j]<n-1&&a[j][b[j]]==i) st_.insert(min(i,j));
		}
		st=st_;
		res++;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int n,k;const int maxn=1e+5+5;
int aa[maxn];
int main(){
	scanf("%d%d",&n,&k);
	rep(i,1,n)scanf("%d",aa+i);
	int ans=0x3f3f3f3f;
	rep(i,1,n){
		int j=i+k-1;
		if(j>n)break;
		int x=abs(aa[i]),y=abs(aa[j]);
		if((aa[j]<0)^(aa[i]<0))ans=min(ans,min(x*2+y,x+2*y));
		else ans=min(ans,max(x,y));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // printTestValue();
    // abc170_d();
    // abc169_b();
    abc169_c();
  }

  public static void abc169_c() {
    try (Scanner sc = new Scanner(System.in)) {
      BigDecimal a = new BigDecimal(sc.next());
      BigDecimal b = new BigDecimal(sc.next());

      System.out.println(a.multiply(b).setScale(0, RoundingMode.DOWN));

    } catch (Exception e) {
      System.out.println("エラー" + e);
    }
  }
}

Measured memory_bytes: 36104
#include "bits/stdc++.h"
using namespace std;
typedef long long int lli;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff first
#define ss second
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5 + 5;


int main() {
	IOS
	int T = 1;
	// cin >> T;
	while(T--) 
	{
		int k;
		cin>>k;
		vector<lli> v;
		for(int i=1;i<=9;i++) v.pb(i);
		int ind = 0;
		while(v.size() < k) 
		{
			lli x = v[ind];
			int j = x%10;
			if(j-1>=0) v.pb(x*10 + (j-1));
			v.pb(x*10 + j);
			if(j+1 != 10) v.pb(x*10 + (j+1));
			ind++;
		}
		cout<<v[k-1];
	}
	return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n, k;
  cin >> n >> k;
  set<int> s;
  rep(i, k) {
    int d;
    cin >> d;
    vector<int> a(d);
    rep(j, d) {
      int x;
      cin >> x;
      s.insert(x);
    };
  }

  cout << n - s.size() << endl;

  return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;


long long int e;
string str[25];
int main() {
	cout << fixed << setprecision(18);
	cin>>e;
	while(e!=0){
		long long int res=1000000000000000;
		for(int z=0;z*z*z<=e;z++){
			for(int y=0;z*z*z+y*y<=e;y++){
				res=min(res,(e-z*z*z-y*y)+y+z);
			}
		}
		cout<<res<<endl;
		cin>>e;
	}
} 


Measured memory_bytes: 3056
def solve(string):
    x, _, *p = map(int, string.split())
    for i in range(101):
        if x - i not in p:
            return str(x - i)
        if x + i not in p:
            return str(x + i)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 9048
N=int(input())
a_list = list(map(int, input().split()))

for i in range(len(a_list)):
  if a_list[i]%2==0:
    if a_list[i]%3!=0 and a_list[i]%5!=0:
      print('DENIED')
      break
    
  if i==len(a_list)-1:
     print('APPROVED')

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
//m.emplace(x,0).fi->se++;

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  string s;cin>>s;
  ll n=s.size();
  if(s[n-1]=='1')judge=false;
  if(s[0]=='0'||s[n-2]=='0')judge=false;
  rep(i,1,(n+1)/2){
    if(s[i]!=s[n-i-2]){
      judge=false;
      //test;
    }
  }
  if(judge){
    vector<P>ret;
    buf=2;
    ret.emplace_back(2,1);
    rep(i,1,n-1){
      if(s[i]=='1'){
        ret.emplace_back(i+2,buf);
        buf=i+2;
      }
      else{
        ret.emplace_back(i+2,buf);
      }
    }
    rep(i,0,n-1){
      cout<<ret[i].fi spa ret[i].se<<endl;
    }
  }
  else cout<<-1<<endl;

  return 0;
}

Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif
    int n,m,x,i,j;
    cin>>n>>m>>x;
    int c[n+1];
    int mat[n+1][m+1];
    for(i=0;i<n;i++)
    {
        cin>>c[i];
        for(j=0;j<m;j++)
        {
            cin>>mat[i][j];
        }
    }
    int y=1LL<<n;
    int minn=1e18;
    int cur[m+1],curcost=0;
    for(i=1;i<y;i++)
    {
        memset(cur,0,sizeof(cur));
        curcost=0;
        for(j=0;j<n;j++)
        {
            if(i&(1LL<<j))
            {
                curcost+=c[j];
                for(int k=0;k<m;k++)
                {
                    cur[k]+=mat[j][k];
                }
            }
        }
        int f=0;
        for(int k=0;k<m;k++)
        {
            if(cur[k]<x)
            {f=1;    break;}
        }
        if(f==0)
        {
            minn=min(minn,curcost);
        }
    }
    if(minn==1e18)
        cout<<"-1"<<endl;
    else 
        cout<<minn<<endl;
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <unordered_set>

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	unordered_set<char> vowel;
	vowel.insert('a');
	vowel.insert('i');
	vowel.insert('u');
	vowel.insert('e');
	vowel.insert('o');
	char c;
	cin >> c;

	if (vowel.find(c) != vowel.end()) {
		cout << "vowel" << endl;
	} else {
		cout << "consonant" << endl;
	}

}


Measured memory_bytes: 256
/*input
4
*/
#include<bits/stdc++.h>
using namespace std;
const int N=21;
const int mod=1e9 + 7;
#define int long long
#define pii pair<int, int>
#define f first
#define s second 
#define mp make_pair
int m, n;vector< pii > adjlist[N];
int b, l;vector<int> bits;
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>l;m=0;
	for(int i=0;(1<<i)<=l;i++) b=i;
	for(int i=0;i<b;i++)
	{
		adjlist[i+1].push_back(mp(i+2,1<<i));adjlist[i+1].push_back(mp(i+2, 0));
		n=i+2;m+=2;
	}
//	l--;
	for(int i=0;(1<<i)<=l;i++)
		if((l&(1<<i))) bits.push_back(i);
	
	//if(bits[0]!=0) bits.insert(bits.begin(), 0);
//	if(((l+1)&l)==0) bits.clear();
	int cur=1<<bits.back();b=bits.size()-2;
	while(b>=0) 
	{adjlist[bits[b]+1].push_back(mp(n, cur));
		m++;
		cur+=1<<bits[b];b--;
	}
	cout<<n<<" "<<m<<endl;
	for(int i=1;i<=n;i++)
	{
		for(auto j:adjlist[i])
		{
			cout<<i<<" "<<j.f<<" "<<j.s<<endl;
		}
	}
}

Measured memory_bytes: 256
import collections
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
n=int(readline())
s=read().rstrip().decode().split()
c=collections.Counter(s)
for x in ["AC","WA","TLE","RE"]:
    n=c[x]
    print("{} x {}".format(x, n))

Measured memory_bytes: 17468
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}



int main() {
 
	
	ll N;
	cin >> N;
	ll an=0,A=9999,B;

	
	
	for (ll i = 0; i < N; i++) {
		cin >> B;
		an = max(an, B);
		A = min(A, B);
	}
	
	cout <<an-A<< endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <limits>
#include <iomanip>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
	ll N, A, B;
	cin >> N >> A >> B;

	ll num = N / (A + B);
	ll count = num * A;

	ll remain = N - (num * (A + B));
	if (remain - A > 0)
	{
		count += A;
	}
	else
	{
		count += remain;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3112
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <utility>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

static sl H, N;
static vector<sl> Ai;

void solve(void) {
  cout << ((H <= accumulate(Ai.begin(), Ai.end(), 0)) ? "Yes" : "No") << endl;
}

int main(void) {
  cin >> H >> N;
  Ai.resize(N);
  FOR0(i, N) {
    cin >> Ai[i];
  }
  solve();
  return 0;
}

Measured memory_bytes: 1024
program hrn;
 var
  s:string;
  i,l,sc,sf:longint; 
   //l表示字符串长度; sc,sf分别表示第一个C的坐标和最后一个F的坐标.
 begin
  read(s);
  l:=length(s);sc:=maxlongint; //sc一定要赋值为maxlongint！
  for i:=1 to l do if s[i]='F'then sf:=i; //寻找最后一个F
  for i:=l downto 1 do if s[i]='C'then sc:=i;//寻找第一个C
  if sc<sf then writeln('Yes')
           else writeln('No');  //注意输出格式
 end.

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

signed main() {
	double x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	printf("%.6lf", sqrt(abs((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))));
}



Measured memory_bytes: 3196
/**
 *    author:  border
 *    created: 06.01.2019 17:10:22     
**/
#include <bits/stdc++.h>

using namespace std;

#define debug(s) cout<< #s <<" = "<< s <<endl
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a,val,sizeof a)

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define endl '\n'

int h[100010],dp[100010];

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  /*#ifndef ONLINE_JUDGE
    freopen("in", "r", stdin);
    freopen("out","w",stdout);
  #endif*/
  int n,k;
  cin >> n >> k;
  for(int i = 0; i < n; ++i) cin >> h[i];
  for(int i = n-2; i >= 0; --i){
    dp[i] = INT_MAX;
    for(int j = 1; j <= k; ++j){
      if(i+j >= n) break;
      dp[i] = min(abs(h[i]-h[i+j])+dp[i+j],dp[i]);
    }
  }
  cout << dp[0] << endl;
}



Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#define mod 1000000007
#define maxn 1005
#define LL long long
int n,m,lr,ud,v,ev,eh;
LL k;
char s[maxn][maxn];
int powmod(int a,LL n)
{
	int res=1;
	while(n)
	{
		if(n&1ll) res=1ll*res*a%mod;
		a=1ll*a*a%mod;
		n>>=1ll;
	}
	return res;
}
void swap(int &a,int &b) { int t=a; a=b; b=t; }
struct mat { int a[2][2]; };
mat operator * (mat a,mat b)
{
	mat c;
	memset(c.a,0,sizeof(c.a));
	for(int i=0;i<2;i++)
		for(int j=0;j<2;j++)
			for(int k=0;k<2;k++)
				c.a[i][j]=(c.a[i][j]+1ll*a.a[i][k]*b.a[k][j]%mod)%mod;
	return c;
}
mat operator ^ (mat a,LL n)
{
	mat res;
	memset(res.a,0,sizeof(res.a));
	res.a[0][0]=res.a[1][1]=1;
	while(n)
	{
		if(n&1ll) res=res*a;
		a=a*a;
		n>>=1ll;
	}
	return res;
}
int main()
{
	scanf("%d%d%lld",&n,&m,&k);
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(s[i][j]=='#') { v++,ev+=(s[i-1][j]=='#'),eh+=(s[i][j-1]=='#'); }
	for(int i=1;i<=n;i++) lr+=(s[i][1]=='#'&&s[i][m]=='#');
	for(int i=1;i<=m;i++) ud+=(s[1][i]=='#'&&s[n][i]=='#');
	if(ud&&lr) { printf("1\n"); return 0; }
	if(!ud&&!lr) { printf("%d\n",powmod(v,k-1)); return 0; }
	if(lr) { swap(ud,lr); swap(ev,eh); swap(n,m); }
	mat ans,tmp;
	ans.a[0][0]=ans.a[0][1]=ans.a[1][1]=0,ans.a[1][0]=1;
	tmp.a[0][0]=ud,tmp.a[0][1]=ev,tmp.a[1][0]=0,tmp.a[1][1]=v;
	ans=(tmp^(k-1))*ans;
	//printf(" - %d %d\n",ans.a[0][0],ans.a[1][0]);
	printf("%d\n",(ans.a[1][0]-ans.a[0][0]+mod)%mod);
}

Measured memory_bytes: 1152
import math
s = int(input())
ans = [0] * 100000
a = 0
b = 0
c = 0

for i in range(3, 3 * math.floor(math.sqrt(s))):
    for j in range(1, i):
        a = j
        for k in range(1, i - j):
            b = k
            c = i - a - b
            d = a*a + b*b + c*c + a*b + b*c + c*a
            ans[d - 1] += 1

for i in range(s):
    print(str(ans[i]))

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int , int>ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string,int>msi;

#define fr(i,a,b) for(int i = (int)a; i<=(int)b;i++)
#define frit(c,it) for(vii::itrator it = (c).being(); it != (c).end();it++)

int pabe(int a)
{
    if(a>3)
    {
        return 0;
    } else if( a == 3)
    {
        return 100000;
    }else if(a==2)
    {
        return 200000;
    }else if(a==1){
        return 300000;
    }
}

int main(int argc, char const *argv[])
{
    int a,b;
    cin>>a>>b;
    if(a==1&&b==1){
    cout<<pabe(a)+pabe(b)+400000<<endl;
    }else {
        cout<<pabe(a)+pabe(b)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin >>n;
  	int sn=0;
  	int al=n;
  	for(int i=0;i<10;i++){
    	sn+=n-n/10*10;
      	n/=10;
    }
  	if (al%sn==0) cout << "Yes" << endl;
  	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int T[100100],Head,Tail,N,C,K,ans;
int main()
{
	cin>>N>>C>>K;
	for(int i=0;i<N;i++)
		cin>>T[i];
	sort(T,T+N);
	while(true)
	{
		while(Tail<min(N,Head+C)&&T[Tail]<=T[Head]+K)
			Tail++;
		Head=Tail;
		ans++;
		if(Tail==N)
			break;
	}
	cout<<ans<<endl;
	return 0;
}


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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main() {
    int n;
    cin >> n;
    int count = 0;
    vector<int>a(n);
    rep(i, 0, n)cin >> a[i];
    int cnt = 0;
    rep(i, 0, n-1){
        if(a[i]==i+1){
            cnt++;
            swap(a[i],a[i+1]);
        }
    }
    if(a[n-1]==n)cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void solve()
{
   string s;
   cin>>s;
   if(s[2]==s[3] && s[4]==s[5])
    cout<<"Yes";
  else
    cout<<"No";
}
int main()
{
  ll t=1;
 // cin>>t;
  while(t--)
  {
    solve();
  }
}


Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//
//                            ▒█████▒▒
//                             ██████████▒
//                             ▒████████████▒
//                            ██████████████████
//                           ████████████████████▒
//                          ▒██████████████████████▒
//                          ▒███████████████████████
//                      ▒████▒▒▒▒▒▒█████████████████▒
//                    ███▒▒▒▒▒▒██████████████████████▒▒▒
//                  ▒██▒▒███████████████████████▒▒▒▒▒██████
//                 ▒█████████████████████████▒▒▒▒▒▒█████████▒
//                 ▒█████████████████████▒▒▒▒▒▒██████████████
//                  ▒████         ████▒▒▒▒▒████         ████▒
//              ▒█████▒    ████    ▒▒▒▒███████    ████    ██████▒
//            ▒██▒▒▒▒▒    ██████    █████████    ██████    ██▒▒▒██▒
//           █████████   ████████   █████████   ████████   ▒▒▒▒█████
//          ▒█████████    ██████    ████████▒    ██████    █████████
//          ▒██████████    ████    █████▒▒▒▒▒▒    ████    ██████████
//           ████████████        ▒▒▒▒▒▒▒████████        ███████████▒
//       ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒
//     ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒
//   ▒▒▒▒▒▒▒▒▒██████████████                         ███████▒▒▒▒███████████
//   █████████████████████████                     ███████▒▒▒██████████████▒
//   █████████████████████████████             ███████▒▒▒██████████████████▒
//   ██████████████████████████████████████████████████████████████████████
//    ██████████████████████████████████████████████████████████████████▒
//      ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

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

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  sort(a.rbegin(),a.rend());

  int ans = 0;
  REP(i,k) ans += a[i];

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
N,K = list(map(int,input().split()))
lst = [0]*N
for i in range(K):
    d = int(input())
    for Ai in list(map(int,input().split())):
        lst[Ai-1] += 1

ans = 0
for num in lst:
    if num == 0:
        ans += 1
print(ans)

Measured memory_bytes: 9188
#include<stdio.h>
#include<stdlib.h>
int MIN(int a,int b){return a<b?a:b;}
int x[3000],y[3000],nt[3000],ta[3000],max,d[3010];
int main(){
  int h,w,i,j,k,gy,gx,r,n;
  char s[10];
  while(scanf("%d %d",&w,&h),h||w){
    for(i=r=max=0;i<3000;i++)ta[i]=-1;
    for(i=0;i<3000;i++)d[i]=1e8;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	scanf("%s",s);
	if(s[0]=='.')continue;
	if(s[0]=='G'){
	  gy=i;
	  gx=j;
	}
	else{
	  n=0;
	  if(s[0]-'S'){
	    for(k=0;s[k];k++)n=n*10+s[k]-'0';
	  }
	  nt[r]=ta[n];
	  y[r]=i;
	  x[r]=j;
	  ta[n]=r++;
	  if(max<n)max=n;
	}
      }
    }
    n=max+1;
    nt[r]=ta[n];
    y[r]=gy;
    x[r]=gx;
    ta[n]=r;//printf("m%d\n",max);
    d[ta[0]]=0;
    for(i=0;i<n;i++){//printf("%d:",i);
      for(j=ta[i];j+1;j=nt[j]){//printf("%d y%d x%d:",d[j],y[j],x[j]);
	for(k=ta[i+1];k+1;k=nt[k]){
	  d[k]=MIN(d[k],d[j]+abs(x[j]-x[k])+abs(y[j]-y[k]));
	}
      }//printf("\n");
    }
    printf("%d\n",d[r]);
  }
  return 0;
}
    

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pair<ll, ll>> vpll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vi a(n);
    vi cnt(1e6 + 1);
    forn(i, n) cin >> a[i], cnt[a[i]]++;
    int ans = 0;
    forn(i, n) {
        cnt[a[i]]--;
        bool ok = true;
        forab(d, 1, int(sqrt(a[i]))+2) {
            if (a[i] % d == 0) {
                if (cnt[(a[i] / d)] != 0 || cnt[d] != 0) {
                    ok = false;
                    break;
                }
            }
        }
        ans += ok;
        cnt[a[i]]++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 7944
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <complex>
#include <algorithm>

using namespace std;
using i64 = int_fast64_t;
using u64 = int_fast64_t;
using i32 = int_fast32_t;
using u32 = int_fast32_t;

#define int i64
#define uint u64

template<class T>
inline bool chmin(T &a, T b) { if(a > b) {a = b; return true;} return false; }
template <class T>
inline bool chmax(T &a, T b) { if(a < b) {a = b; return true;} return false; }
const int INF = 1LL << 60;

int abso(int a, int b) {
	if(a > b) return a - b;
	return b - a;
}

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

	int x = n / k;
	int res = abso(n, x * k);
	int res2 = abso(n, (x + 1) * k);

	if(res < res2) cout << res << endl;
	else cout << res2 << endl;
	
	return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const string YES = "Yes";
const string NO = "No";
const ll mod = 1e9+7;



int main(){
	cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,k,r,s,p; cin >> n >> k;
    cin >> r >> s >> p;
    string t; cin >> t;
    vll win(n);

    ll ans = 0;
    REP(i,n){
        if(i >= k && t[i] == t[i-k] && win[i-k] == 1){
            win[i] = 0;
            continue;
        }
        win[i] = 1;
        if (t[i] == 'r') ans += p;
        if (t[i] == 'p') ans += s;
        if (t[i] == 's') ans += r;
    }

    cout << ans;
    return 0;
    
}



Measured memory_bytes: 1232
#include<cstdio>

using namespace std;

int main(){
	int n, m; scanf("%d %d", &n, &m);
	int res[50] = {};
	for(int i = 0; i < m; i++){
		int a, b; scanf("%d %d", &a, &b);
		res[a - 1]++; res[b - 1]++;
	}
	for(int i = 0; i < n; i++) printf("%d\n", res[i]);
	return 0;
}

Measured memory_bytes: 128
program V1503;
 var
  a:array[0..100001] of longint;
  i,n,s,p:longint;
 procedure haha(l,r:longint);
  var
   o,p,m,t:longint;
  begin
   o:=l;
   p:=r;
   m:=a[(l+r) div 2];
   repeat
    while a[o]<m do inc(o);
    while a[p]>m do dec(p);
    if o<=p then
     begin
      t:=a[o];
      a[o]:=a[p];
      a[p]:=t;
      inc(o);
      dec(p);
     end;
   until o>p;
   if o<r then haha(o,r);
   if l<p then haha(l,p);
  end;
 begin
  readln(n);
  for i:=1 to n do
   readln(a[i]);
  haha(1,n);
  a[0]:=-1008208820;
  a[n+1]:=1008208820;
  s:=0;
  p:=0;
  for i:=1 to n+1 do
   if a[i]<>a[i-1] then
    begin
     if p mod 2=1 then inc(s);
     p:=1;
    end
                   else inc(p);
  writeln(s);
 end.


Measured memory_bytes: 512
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

using ll = long long ;

class BBreakNumber {
public:
	void solve(std::istream& cin, std::ostream& cout) {
	    int n ;
	    cin >> n ;
	    int ans = 0 ;
	    for(int i = n ; i>=0 ; --i){
	        if(i && (!(i & (i - 1)))){
	            ans = i ;
	            break ;
	        }
	    }
	    cout << ans ;
	}
};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	BBreakNumber solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//↑templete
signed main(){
	int N, K;
	cin>>N>>K;
	int win[3];
	cin>>win[0]>>win[1]>>win[2];
	string T;
	cin>>T;

	vint U;
	for(int i=0;i<N;i++){
		if(T[i]=='r')
			U.pb(0);
		else if(T[i]=='s')
			U.pb(1);
		else
			U.pb(2);
	}
	// for(int i=0;i<N;i++)
	// 	cout<<U[i]<<" ";
	// 	cout<<endl;

	ll ans=0;
	for(int k=0;k<K;k++){
		vll DP[3];	//DP[3][SIZE];
		for(int i=k;i<N;i+=K){
			for(int j=0;j<3;j++){
				if(DP[j].empty()){
					if(j==( (U[i]+3-1)%3))
						DP[j].pb(win[j]);
					else
						DP[j].pb(0);
					//cout<<k<<" "<<j<<" "<<DP[j].back()<<endl;
				}
				else{
					ll temp=0;
					for(int l=0;l<3;l++)
						if(l!=j)
							temp=max(temp, DP[l][DP[j].size()-1]);
					DP[j].pb( max(temp+((j==(U[i]+3-1)%3)?win[j]:0), DP[j].back()) );
				}
			}
		}
		ll temp=0;
		for(int l=0;l<3;l++)
			temp=max(temp, DP[l].back());
		//cout<<k<<" "<<temp<<endl;
		ans+=temp;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3724
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		int kosu=0;
		String str="";
		str=bfr.readLine();
		kosu=Integer.parseInt(str);
		int[] suji=new int[kosu];
		str=bfr.readLine();
		String[] mtm=str.split(" ");
		int[] suzis=new int[kosu];
		int minx=32;
		for(int i=0; i<kosu; i++) {
			if(minx==1) {
				break;
			}
			else {
				suzis[i]=Integer.parseInt(mtm[i]);
				for(int j=0; j<33; j++) {
					if(suzis[i]%2==1 && minx>j) {
						minx=j;
					}
					suzis[i]=suzis[i] >> 1;
				}
			}
		}
		System.out.println(minx);
	}
}

Measured memory_bytes: 21204
#include <stdio.h>
#include <string.h>
int main(){
  int a=0,c=0,f=0,m;
  char s[11];
  scanf("%s",s);
  m=strlen(s);
  if(s[0]=='A')f++;
  for(int i=2;i<m-1;i++)if(s[i]=='C')c++;
  if(c==1)f++;
  for(int i=1;i<m;i++)if(!('a'<=s[i]&&s[i]<='z'))a++;
  if(a==1)f++;
  puts(f==3?"AC":"WA");
  return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

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

	if(b*2>=a){
		cout<<0<<endl;
	}else{
		cout<<a-b*2<<endl;
	}
	

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 4040;
const int K = 25;
const int mod = 1e9 + 7;
int f[N][N], dp[N][N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt", "r", stdin);
    int n, m, k;
    cin >> n >> m >> k;
    dp[0][0] = 1;
    for (int i = 0; i <= m; i++){
        f[0][i] = 1;
    }
    for (int i = 1; i <= n + m; i++){
        for (int j = 0; j <= m; j++){
            dp[i][j] = (f[i - 1][j] - (j >= k) * f[i - 1][j - k] + mod) % mod;
            f[i][j] = ((j != 0) * f[i][j - 1] + dp[i][j]) % mod;
        }
    }
    if (m == 0){
        cout << 1;
        return 0;
    }
    int ans = 0;
    for (int i = 1; i <= n + m; i++){
        int l = -n + k + (k - 1) * (i - 1);
        int r = m;
        int c = m % (k - 1);
        for (int j = c; j <= r; j += (k - 1)){
            if (j < l) continue;
            ans = (ans + dp[i][j] - dp[i - 1][j] + mod) % mod;
        }
    }
    cout << ans;
}


Measured memory_bytes: 253440
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1e9+5
using namespace std;

int n,lake[MAXN],k;
int dp[MAXN];

int solve(int v){
    if(v==n-1)return 0;
    if(dp[v]>=0)return dp[v];

   int temp=INF;
   for(int i=1;i<=k;i++){
        if(v+i>=n)break;
        temp=min(temp,abs(lake[v]-lake[v+i])+solve(v+i));
   }
   return dp[v]=temp;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    memset(dp,-1,sizeof(dp));
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>lake[i];
    }

    cout<<solve(0);
}

Measured memory_bytes: 5760
#include <stdio.h>
int main(void){
    int a, b, op;
    for(;;){
        scanf("%d %s %d", &a, &op, &b);
        if ( op == '+' ){
            printf("%d\n",a+b);
        } else if ( op == '-' ){
            printf("%d\n",a-b);
        } else if ( op == '*' ){
            printf("%d\n",a*b);
        } else if ( op == '/' ){
            printf("%d\n",a/b);
        } else break ;
    }
    return 0;
}



Measured memory_bytes: 2044
N, M = map(int, input().split())
S = [[0, 0] for i in range(N)]
for i in range(N):
  S[i] = [int(x) for x in input().split()]
S.sort()
money = 0
for s in S:
  money += s[0] * min(s[1], M)
  M -= s[1]
  if M <= 0:
    break
print(money)

Measured memory_bytes: 21676
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll n;
  cin >> n;
  ll p[n], rec[n];
  REP(i, n){
    cin >> p[i];
    rec[p[i] - 1] = i + 1;
  }

  ll a[n], b[n], s[n];
  REP(i, n){
    a[i] = (i + 1) * 40000 + rec[i];
    b[i] = (n - i) * 40000;
  }

  REP(i, n) cout << a[i] << " ";
  cout << endl;
  REP(i, n) cout << b[i] << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 1280
/*
[abc135] C - City Savers
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5;

int N;
int A[MAX_N + 1], B[MAX_N];

ll solve() {
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        int d = min(A[i], B[i]);
        ans += d;
        int e = min(A[i + 1], B[i] - d);
        A[i + 1] -= e;
        ans += e;
    }

    return ans;
}

int main() {
    cin >> N;
    for (int i = 0; i < N + 1; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 1024
a, b = map(int, input().split())
i = 1
f = 0
while True:
    if int(i*0.08)==a and int(i*0.1)==b:
        print(i)
        f = 1
        break
    if int(i*0.08)>a:
        break
    i += 1
if not f:
    print(-1)

Measured memory_bytes: 9120
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("unroll-loops")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define EB emplace_back
#define MP make_pair
#define TS to_string
#define TU to_ullong
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
//#define ERR 0.00000000000001
#define NUM 200010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}

int main(){
  FAST;
  LL i,ans=0,N,K,a,b;
  cin>>N>>K;
  a=N%K;
  b=K-a;
  cout<<min(a,b)<<endl;
}


Measured memory_bytes: 256
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i > 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int N;
    cin >> N;
    string S,T,ans = "";
    cin >> S >> T;
    rep(i, N){
        rep(j, 2){
            if(j == 0){
                ans += S[i];
            }else{
                ans += T[i];
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
 
struct Card{
  char suit;
  char value;
};
 
struct Card C1[101], C2[101];
void trace(struct Card *, int);
void Bubble(struct Card *, int);
void Selection(struct Card *, int);
int main(){
  int n, i,j,mini;
  char ch;
 
  scanf("%d%c", &n, &ch);
  for ( i = 1; i <= n; i++ ){
    scanf("%c%c%c", &C1[i].suit, &C1[i].value, &ch);
    C2[i]=C1[i];
  }
 
  Bubble(C1, n);
  Selection(C2, n);
  return 0;
}


void trace(struct Card C[], int n)
{
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%c%c",C[i].suit, C[i].value);
  }
  printf("\n");
}
 
void Bubble(struct Card CB[], int n)
{
  struct Card CB2[101];
  int i,j,mini;
  for(i=0 ; i<n ; i++)
    {
      for(j=n ; j >= i+1 ; j--)
    {
      if(CB[j].value < CB[j-1].value)
        {
          CB2[j] = CB[j];
          CB[j] = CB[j-1];
          CB[j-1] = CB2[j];
        }
    }
    }
  trace(CB,n);
  printf("Stable\n");
}
 
void Selection(struct Card CS[], int n)
{
  struct Card CS2[101];
  int i,j,mini,count,flag=0;
  for(i=0 ; i<=n ; i++)
    {
      mini = i;
      count=0;
      for(j=i ; j<=n ; j++)
    {
      if(CS[j].value < CS[mini].value)
        {
          mini = j;
          count=1;
        }
    }
      if(count==1)
    {
      CS2[i] = CS[i];
      CS[i] = CS[mini];
      CS[mini] = CS2[i];
    }
      if(CS[i].suit != C1[i].suit)
    flag = 1;
    }
  trace(CS,n);
  if(flag==1)
    printf("Not stable\n");
  else printf("Stable\n");
}
 

Measured memory_bytes: 612
#include "bits/stdc++.h"

#define REP(i, n, N) for(int i=(n); i<(N); i++)
#define RREP(i, n, N) for(int i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll N, M;
ll A[100010], B[100010];
pair<ll, ll> pr[100010];
ll ans;
int main() {
	cin >> N >> M;
	REP(i,0,N){
		cin>>A[i]>>B[i];
		pr[i] = make_pair(A[i], B[i]);
	}
	sort(pr, pr+N);
	REP(i,0,N){
		ans += pr[i].first*(min(M, pr[i].second));
		M-=pr[i].second;
		if(M<=0) break;
	}
	p(ans);

	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;

int M,N; vi A;
void input()
{
    cin>>N>>M;
    for(int i=0;i<N;++i){
        int a;cin>>a;A.emplace_back(a);
    }
}

void solve()
{
    sort(A.begin(),A.end(),greater<int>());
    int sum=0;
    for(int i=0;i<N;++i) sum+=A[i];
    if(A[M-1]*4*M>=sum) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int n;
vector<pair<int, int>> v;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int x, y; cin >> x >> y;
        v.push_back(make_pair(x, y));
    }
    vector<pair<int, int>> target;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            if(i == j) continue;
            int y = v[j].first - v[i].first;
            int x = v[j].second - v[i].second;
            target.push_back(make_pair(y, x));
        }
    }
    int ans = n;
    for(int k = 0; k < target.size(); k++)
    {
        int cnt = n;
        int p = target[k].first, q = target[k].second;
        if(p == 0 and q == 0) continue;
        for(int i = 0; i < n; i++)
        {
            bool flag = false;
            for(int j = 0; j < n; j++)
            {
                if(i == j) continue;
                if(v[j].first - p == v[i].first and v[j].second - q == v[i].second) flag = true;
            }
            if(flag) cnt--;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
//
struct poi{
  int X;int Y;int Z;
  bool operator<(const poi&R)const{
    return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
  }
};
//
//
int main(){
	int N;
	int A[10000],B[10000];
	cin>>N;
	ll S=0;
	FOR(i,0,N){
		cin>>A[i];
		S-=A[i];
	}
	FOR(i,0,N){
		cin>>B[i];
		S+=B[i];
	}
	ll cnt=0;
	FOR(i,0,N){
		if(A[i]<B[i]){
			cnt+=(B[i]-A[i]+1)/2;
		}
	}
	if(cnt<=S){
		Yes(1);
	}else{
		Yes(0);
	}
	return 0;
}


Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
  ll n,y;
  cin>>n>>y;
  for(ll i=0;i<=n;i++){
    for(ll j=0;j+i<=n;j++){
      if(i*1000+j*5000+(n-i-j)*10000==y){
        cout<<n-i-j<<" "<<j<<" "<<i<<endl;
        return 0;
      }
    }
  }cout<<-1<<" "<<-1<<" "<<-1<<endl;
}
      


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

int main()
{
	char a[5];

	cin >> a;

	if ((a[0] == a[1] && a[0] != a[2] && a[2] == a[3]) ||
		(a[0] == a[2] && a[0] != a[1] && a[1] == a[3]) ||
		(a[0] == a[3] && a[0] != a[1] && a[1] == a[2]))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<set>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#define my_max zhi5968
typedef long long ll;
using namespace std;
string s;
int main()
{
	int k;
	cin>>s;
	cin>>k;
	for(int i=0;i<s.length();i++)
	{
		if(i%k==0)
			cout<<s[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, ans = 1;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int m = a[0];
    for(int i = 1; i < n; i++){
        if(m <= a[i]){
            ans++;
        }
        m = max(m, a[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256