akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int v[2][3000];
	for (int a = 0; a < 3000; a++) {
		for (int b = 0; b < 2; b++) {
			cin >> v[b][a];
		}
		if (v[0][a] == 0 && v[1][a] == 0) break;
	}
	for (int a = 0; a < 3000; a++) {
		if (v[0][a] == 0 && v[1][a] == 0) break;
		int z[2]; z[0] = v[0][a]; z[1] = v[1][a];
		sort(z, z + 2);
		cout << z[0] << ' ' << z[1] << endl;
	}
}


Measured memory_bytes: 3172
#include<stdio.h>
int main(void)
{
	int n, m, i,j, sum=0;
	int a[100];
	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		sum += a[i];
	}
	for (i = 0,j=0; i < n; i++) {
		if (a[i]*4*m >= sum)
			j++;
	}
	if (j >= m)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 2092
// 基本テンプレート
 
#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>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N; cin >> N;
    vector<int> A(N);

    int ans = 0, sum = 0;
    map<int, int> mp;
    mp[0] = 1;
    for(int i=0; i<N; i++) {
        cin >> A[i];
        sum += A[i];
        ans += mp[sum];
        mp[sum]++;
    }

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

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REP1(i,n) for(int i=1;i<=(int)(n);i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;

void calc(ll N,int* ans,int count){
  N--;
  ans[count]=N%26;
  count++;
  if(N>25){
    calc(N/26,ans,count);
  }
}


int main(){
  ll N;
  cin >> N;
  vector<int> ans(15,100);
  int count=0;

  calc(N,&ans[0],count);

  reverse(ans.begin(),ans.end());
  REP(i,ans.size()){
    if(ans.at(i)<26){
      printf("%c",97+ans.at(i));
    }
  }
  cout << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

long long MOD = 1000000007;
int main(){
    long long n;
    cin >> n;
    long long answer = 1;
    for(long long i = 1; i <=n;i++){
        answer = (answer * i) % MOD;
    }
    cout << answer << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>    
using namespace std;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N          = 1000*100+5;
const ll N2      = 2000*1000*10;
const ld PI  = 3.14159265;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = INF){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
int fac[N+4];
int nCr(int n , int r)
{
  if(n<r)
    return 0;

  int res = fac[n];
  res*=power(fac[n-r],MOD-2,MOD);
  res%=MOD;
  res*=power(fac[r],MOD-2,MOD);
  res%=MOD;
  //cout<<n<<" "<<r<<" "<<res<<endl;
  return res;
}
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    /*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    fac[0]=1;
    for (int i = 1; i <=N; i++)
    {
        fac[i]=fac[i-1]*i;
        fac[i]%=MOD;
    }
    int n,k;
    cin>>n>>k;
    int a[n];
    for (int i = 0; i < n; ++i)
    {
      cin>>a[i];
    }
    sort(a,a+n);
    int pre[n];
    int res(0);
    int suff[n];
    pre[0]=a[0];
    suff[n-1]=a[n-1];
    for (int i = 1; i < n; ++i)
    {
      pre[i]=pre[i-1]+a[i];
      pre[i]%=MOD;
    }
    for(int j = n-2 ; j>=0 ; j--)
    {
      suff[j] = suff[j+1]+a[j];
      suff[j]%=MOD;
    }
    for (int i = k ; i <= (n); ++i)
    {
        int dum = nCr(i-2,k-2);
        int diff = suff[i-1] - pre[n-i] + MOD;
        diff%=MOD;
        dum*=diff;
        dum%=MOD;
        res+=dum;
        res%=MOD;
    }
    cout<<res;

    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 9e9;
typedef std::pair<int,int> P;
//struct edge {int to,cost;};
#define VMAX 200+10
    ll d[VMAX][VMAX];
    ll H,W;
    ll A[VMAX][VMAX];
    ll ans;
    void warshall_floyd(int n) { // nは頂点数
        for (int i = 0; i < n; i++)      // 経由する頂点
        for (int j = 0; j < n; j++)    // 開始頂点
        for (int k = 0; k < n; k++)  // 終端
        d[j][k] = std::min(d[j][k], d[j][i] + d[i][k]);
    }
int main(){
    //std::ios_base::sync_with_stdio(false);
    cin>>H>>W;
    REP(i,10)REP(j,10){
        cin>>d[i][j];
        if(d[i][j]==0)d[i][j]=INF;
    }
    warshall_floyd(10);
    REP(i,H)REP(j,W){
        int a;
        cin>>a;
        if(a!=1&&a!=-1){

            ans+=d[a][1];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import product
s=int(input())
sl=list(str(s))
n=len(sl)
ans=0
for i in product([0,1],repeat=n-1):
    
    temp=0
    for j in range(n):
        ans+=int(sl[n-j-1])*10**temp
        temp+=1
        if n-j-2>=0 and i[n-j-2]==1:
            temp=0
print(ans)

Measured memory_bytes: 68420
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#include <bitset>
#define ri register
#define inf 0x7fffffff
#define E (1)
#define mk make_pair
#define int long long
#define double long double
using namespace std; const int N=1000010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch-'0'), ch=getchar();
    return s*w;
}
void print(int x) { if(x<0) x=-x, putchar('-'); if(x>9) print(x/10); putchar(x%10+'0'); }
int n,K,a[N];
inline int Check(int x)
{
    int ans=0;
    for(ri int i=1;i<=n;i++) ans+=(a[i]-1)/x;
    return ans;
}
signed main()
{
    n=read(), K=read();
    for(ri int i=1;i<=n;i++) a[i]=read();
    sort(a+1,a+1+n);
    if(K==0) { printf("%lld\n",a[n]); return 0; }
    int L=1, R=2e9;
    int res=0;
    while(L<=R)
    {
        int mid=(L+R>>1);
        if(Check(mid)<=K) res=mid, R=mid-1;
        else L=mid+1;
    }
    printf("%lld\n",res);
    return 0;
}

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

#define DEBUG_ENABLED 0
//typedef long long int ll;

//using ll = long long;

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

    char c;
    cin >> c;

    if ('A' <= c && c <= 'Z')
    {
        cout << 'A' << endl;
    }
    else
    {
        cout << 'a' << endl;
    }

    return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
//		long start = System.currentTimeMillis();
		x--;
		y--;
		
		int[] k = new int[n];
		for (int i = 0; i < n - 1; i++) {
			for (int j = i + 1; j < n; j++) {
				int dist = Math.min(Math.abs(j - i), Math.abs(x - i) + Math.abs(y - j) + 1);
				k[dist]++;
			}
		}
		
		for (int i = 1; i < n; i++) {
			System.out.println(k[i]);
		}
		
		sc.close();
//		long end = System.currentTimeMillis();
//		System.out.printf("%05d", end - start);
	}
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);

vii dp(310, vi(310));
vi w(310);

int calc(int l, int r) {
  if (dp[l][r] >= 0) {
    return dp[l][r];
  }
  if (r - l == 1) {
    dp[l][r] = 0;
    return 0;
  }
  if (r - l == 2) {
    if (abs(w[r - 1] - w[l]) <= 1) {
      dp[l][r] = 2;
    }
    else {
      dp[l][r] = 0;
    }
    return dp[l][r];
  }
  int res = calc(l + 1, r - 1);
  if (res == (r - 1) - (l + 1) && abs(w[r - 1] - w[l]) <= 1) {
    res += 2;
    dp[l][r] = res;
    return res;
  }
  for (int i = l + 1; i < r; i++) {
    res = max(res, calc(l, i) + calc(i, r));
  }
  dp[l][r] = res;
  return res;
                                         
}

int main() {
  while (true) {
    int n;
    cin >> n;
    if (!n) {
      return 0;
    }
    rep (i, n) {
      cin >> w[i];
    }
    rep (i, n + 3) {
      rep (j, n + 3) {
        dp[i][j] = -1;
      }
    }
    cout << calc(0, n) << endl;
  }
}



Measured memory_bytes: 3328
#include <algorithm>
#include <iostream>
#include <climits>

using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)

int main() {
    int N;
    int W[100];
    cin >> N;
    REP(i, N) {
        cin >> W[i];
    }
    int minTdiff = INT_MAX;
    REP(T, N - 1) {
        int s1 = 0;
        for(int i = 0; i <= T; i++) {
            s1 += W[i];
        }
        int s2 = 0;
        for(int i = T + 1; i < N; i++) {
            s2 += W[i];
        }
        int diff = abs(s1 - s2);
        if (diff < minTdiff) {
            minTdiff = diff;
        }
    }
    printf("%d\n", minTdiff);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define rp(i, s, e) for(int i = s; i < e; i++)

int main() {
	int n;
	string s, shift = "";
	cin >> n >> s;
	for(char i : s)
		shift += 'A' + ((i-'A'+n)%26);
	cout << shift << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> hoge(n);
  int count = 0;
  long long prev, now;
  for (int i = 0; i < n; i++){
    if (i == 0){
      cin >> prev;
    }else if(i == n - 1){
      cin >> now;
      if (now <= prev){
        count += 1;
        prev = now;
        hoge.push_back(count);
        // cout << "count " << count << endl;
      }else{
        hoge.push_back(count);
        count = 0;
        prev = now;
      }
    }else{
      cin >> now;
      if (now <= prev){
        prev = now;
        count += 1;
        // hoge.push_back(count);
        // cout << "count " << count << endl;
      }else{
        hoge.push_back(count);
        count = 0;
        prev = now;
      }
    }
    // cin >> hoge.at(i);
  }

  // sort(hoge.begin(), hoge.end());
  sort(hoge.begin(), hoge.end(), greater<int>() );
  cout << hoge[0] << endl;
  // for (int i = 0; i < hoge.size(); i++){
  //   cout << hoge[i] << endl;
  // }
  
  // cout << hoge[0] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque> 
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype> 
using namespace std;

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

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n, k;
  cin>>n>>k;
  vector<int> v(n);
  rep(i, n) cin>>v[i]; sort(all(v)); reverse(all(v));
  int res = 0;
  rep(i, k) res += v[i];
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
def cross_product(a,b):
    return (a.conjugate()*b).imag
N = int(input().strip())
for _ in range(N):
    P = list(map(float,input().strip().split()))
    for i in range(len(P)):
        P[i] = int(P[i]*1000000.0)
    z = complex(P[0]-P[2],P[1]-P[3])
    w = complex(P[4]-P[6],P[5]-P[7])
    if abs(cross_product(z,w)) < 1:
        print("YES")
    else:
        print("NO")


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

bool graph [500][500][250];
bool cover [500][500];
int cur [500][500];
int N;

vector<pii> deltas = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

void dfs(int i, int j, int k) {
	graph[i][j][k] = true;
	cur[i][j] = min(cur[i][j], k);
	for (pii d : deltas) {
		int ni = d.first + i;
		int nj = d.second + j;
		int nk = k + cover[i][j];
		if (ni < 0 || ni >= N || nj < 0 || nj >= N || nk >= N || nk >= 250) continue;
		if (graph[ni][nj][nk]) continue;
		if (nk > 0 && graph[ni][nj][nk-1]) continue;
		dfs(ni, nj, nk);
	}
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	F0R(i, 500) F0R(j, 500) {
		cover[i][j] = true;
		F0R(k, 250) graph[i][j][k] = false;
	}

	F0R(i, N) F0R(j, N) {
		cur[i][j] = min(min(i, j), min(N-i-1, N-j-1));
		if (i < 250) graph[i][j][i] = true;
		if (j < 250) graph[i][j][j] = true;
		if (N-i-1 < 250) graph[i][j][N-i-1] = true;
		if (N-j-1 < 250) graph[i][j][N-j-1] = true;
	}

	int ans = 0;
	F0R(t, N*N) {
		int x; cin >> x; --x;
		int i = x/N;
		int j = x%N;
		int best = cur[i][j];
		cover[i][j] = false;
		ans += best;
		dfs(i, j, best);
	}
	print(ans);
}

Measured memory_bytes: 81060
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;

int main(){
  int n, m,a;
  cin >> n >> m;
  int mini=1,maxi=n;
  r(i,2*m){
    cin >> a;
    if(i%2==0)mini=max(mini,a);
    else maxi=min(maxi,a);
  }
  if(mini<=maxi)cout << maxi-mini+1<<endl;
  else cout << 0 << endl;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<long long> x(N),y(N),z(N);
  for(int i=0;i<N;i++)  cin >> x.at(i) >> y.at(i) >> z.at(i);
  
  long long ans=0;
  for(int bi=0;bi<(1<<3);bi++){
    vector<long long> sum(N,0);
    for(int i=0;i<N;i++){
      if(bi&1)  sum.at(i)+=x.at(i);
      else  sum.at(i)-=x.at(i);
      if(bi&(1<<1)) sum.at(i)+=y.at(i);
      else  sum.at(i)-=y.at(i);
      if(bi&(1<<2)) sum.at(i)+=z.at(i);
      else  sum.at(i)-=z.at(i);
    }
    sort(sum.begin(),sum.end(),greater<long long>());
    long long tmp=0;
    for(int i=0;i<M;i++)  tmp+=sum.at(i);
    ans=max(ans,tmp);
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
/* Author darklight13 -_- 
   IIT Patna 
*/
#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds; 
using namespace std;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
//typedef tree<int, null_type, less<int>, rb_tree_tag, 
//             tree_order_statistics_node_update> 
//    data_set;
#define rep(i,l,r)   for(int i=(l);i<(r);i++)
#define deb(x)     cout << (#x) << " is " << (x) << endl
#define dbg(x)     cout << x << ' '
#define here cout << " Hey baitch!!\n";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
const int MOD = 1e9+7;
const int MOD1 = 998244353;
const int N = 2e5+5;
const int INF = 1000111000111000111LL;
const ld PI = 3.1415926535898;

int32_t main()
{
	SYNC
	int n; cin >> n;
	vi a(n),cum(n);
	for(auto &it : a)	cin >> it;
	int dp[n][n];
	rep(i,0,n){
		rep(j,0,n)	dp[i][j] = INF;
	}
	cum[0] = a[0];
	for(int i =1; i < n; i++)	cum[i] = cum[i-1] + a[i];
	for(int i = 0; i < n; i++)	dp[i][i] = 0;
	for(int len = 2; len <= n; len++) {
		for(int i = 0; i + len -1 < n; i++) {
			int l = i, r = i + len - 1;
			int sum = cum[r];
			if(l > 0)	sum -= cum[l-1];
			for(int k = i; k < r; k++) {
				dp[l][r] = min(dp[l][r],dp[l][k]+dp[k+1][r]+sum);
			}
		}
	}
	cout << dp[0][n-1];
    return 0;
}

Measured memory_bytes: 1536
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    long x = sc.nextLong();
    long m = 100;
    int ans = 0;
    
    while(m<x){
      m = (long)(m*1.01);
      ans++;
    }
    System.out.println(ans); 
  }
}

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

struct NODE{
	int x,y,c;
	NODE(int x,int y,int c):x(x),y(y),c(c){}
	
};
char c[102][102];
int main(){
	int H,W;
	while(cin >> W >> H && W){
		int sx , sy;
		for(int i = 0 ; i <= H+1 ; i++)
			for(int j = 0 ; j <= W+1 ; j++)
				c[i][j] = '.';

		for(int i = 1 ; i <= H ; i++){
			for(int j = 1 ; j <= W ; j++){
				cin >> c[i][j];
				if(c[i][j] == '&'){
					sx = j , sy = i;
				}
			}
		}

		int dx[] = {-1,0,1,0};
		int dy[] = {0,1,0,-1};
		deque<NODE> Q;
		int memo[102][102] = {} ;
		Q.push_back(NODE(sx,sy,0));
		memo[sy][sx] = 1;
		while(Q.size()){
			NODE q = Q.front(); Q.pop_front();
			if(q.x == W+1 || q.x == 0 || q.y == H+1 || q.y == 0){
				cout << q.c << endl;
				break;
			}
			for(int i = 0 ; i < 4 ; i++){
				int tx = q.x + dx[i];
				int ty = q.y + dy[i];
				if(memo[ty][tx]) continue;
				if( c[q.y][q.x] != '#' && c[ty][tx] == '#' ){
					Q.push_back(NODE(tx,ty,q.c+1));
				}else{
					Q.push_front(NODE(tx,ty,q.c));
				}
				memo[ty][tx] = true;
			}
		}
		
	}
}

Measured memory_bytes: 0
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;

#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define Rep(i, a, b) for (int (i) = (a) - 1; (i) < (b); (i)++)
#define REP(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define Sort(a, len, cmp) sort(a + 1, a + len + 1, cmp)
#define ass(a, sum) memset(a, sum, sizeof(a))

#define ls ((rt) << 1)
#define rs ((rt) << 1 | 1)
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
#define ENDL cout << endl
#define SZ(x) ((int)x.size())

typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef pair <ll, ll> pll ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
typedef map <ll, ll> mll ;

const int N = 100010 ;
const double eps = 1e-8 ;
const int iinf = INT_MAX ;
const ll linf = 2e18 ;
const double dinf = 1e30 ;
const int MOD = 1000000007 ;

inline int read(){
    int X = 0, w = 0 ;
	char ch = 0 ;
    while (!isdigit(ch)) { w |= ch == '-' ; ch = getchar() ; }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar() ;
    return w ? - X : X ;
}

void write(int x){
     if (x < 0) putchar('-'), x = - x ;
     if (x > 9) write(x / 10) ;
     putchar(x % 10 + '0') ;
}

void print(int x) {
	cout << x << endl ;
	exit(0) ;
}

void PRINT(string x) {
	cout << x << endl ;
	exit(0) ;
}

void douout(double x){
	 printf("%lf\n", x + 0.0000000001) ;
}

string s ;
int n, q, k ;
int main(){
	cin >> n >> s >> q ;
	while (q--){
		scanf("%d", &k) ;
		ll cd = 0, cm = 0, c = 0, ans = 0 ;
		for (int i = 0; i < n; i++) {
			if (i >= k) {
				if (s[i - k] == 'D') cd--, c -= cm ;
				else if (s[i - k] == 'M') cm-- ;
			}
			if (s[i] == 'D') cd++ ;
			else if (s[i] == 'M') cm++, c += cd ;
			else if (s[i] == 'C') ans += c ;
		}
		cout << ans << endl ;
	}
}

/*
写代码时请注意：
	1.是否要开Long Long？数组边界处理好了么？
	2.实数精度有没有处理？
	3.特殊情况处理好了么？
	4.做一些总比不做好。
思考提醒：
	1.最大值和最小值问题可不可以用二分答案？
	2.有没有贪心策略？否则能不能dp？
*/


Measured memory_bytes: 1412
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)

//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

const ll MAX = 2000005;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll sum(ll n, ll m)
{
    if (n < 0 || m < 0) return 0;
    return ((COM(n+m+2, m+1))-1) % MOD;
}

void solve()
{
    COMinit();
    IN(a, b, c, d);
    cout << (sum(c, d) - sum(a-1, d) - sum(c, b-1) + sum(a-1, b-1) + MOD) % MOD << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

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

int main(){
  int n,m,k,c=0; cin>>n>>m>>k;
  int b[m];
  for(int i=0;i<m;i++) cin>>b[i];
  
  for(int i=0;i<n;i++){
    int s=0;
    for(int j=0;j<m;j++){
      int k; cin>>k;
      s += k*b[j];
    }
    if(s+k>0) c++;
  }
  
  cout<<c<<endl;
  return 0;
}

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

using namespace std;

const int N = 2'009;

char a[N][N];
int f[N][N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%s", a[i]);
  }
  memset(f, 0, sizeof f);
  for (int i = 0; i < n; ++i) {
    {
      int cnt = 0;
      for (int j = 0; j < m; ++j) {
        if (a[i][j] == '.') {
          f[i][j] += cnt;
          ++cnt;
        } else {
          cnt = 0;
        }
      }
    }
    {
      int cnt = 0;
      for (int j = m - 1; j >= 0; --j) {
        if (a[i][j] == '.') {
          f[i][j] += cnt;
          ++cnt;
        } else {
          cnt = 0;
        }
      }
    }
  }
  for (int j = 0; j < m; ++j) {
    {
      int cnt = 0;
      for (int i = 0; i < n; ++i) {
        if (a[i][j] == '.') {
          f[i][j] += cnt;
          ++cnt;
        } else {
          cnt = 0;
        }
      }
    }
    {
      int cnt = 0;
      for (int i = n - 1; i >= 0; --i) {
        if (a[i][j] == '.') {
          f[i][j] += cnt;
          ++cnt;
        } else {
          cnt = 0;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (a[i][j] == '.') {
        if (f[i][j] + 1 > ans) {
          ans = f[i][j] + 1;
        }
      }
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 19968
n, x = map(int, input().split())

def num_patty(n, x):
  if 2**(n+2)-3 <= x:
    return 2**(n+1)-1
  elif 2**(n+1) <= x and x <= 2**(n+2)-4:
    return num_patty(n-1, x-2**(n+1)+1)+(2**n-1)+1
  elif x == 2**(n+1)-1:
    return (2**n-1)+1
  elif 2 <= x and x <= 2**(n+1):
    return num_patty(n-1, x-1)
  else:
    return 0
    
print(num_patty(n, x))

Measured memory_bytes: 3064
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use smallvec::alloc::collections::VecDeque;
use text_io::*;

fn main() {
    const U_INF: usize = 1 << 50;
    const I_INF: isize = 1 << 50;

    let n: usize = read!();
    let m: usize = read!();
    let mut vertexes = vec![vec![]; n];
    let mut deg = vec![0; n];
    for _ in 0..m {
        let mut x: usize = read!();
        let mut y: usize = read!();
        x -= 1;
        y -= 1;
        vertexes[x].push(y);
        deg[y] += 1;
    }

    let mut queue = VecDeque::new();
    let mut sorted = Vec::new();
    for (i, _) in deg.iter().enumerate().filter(|(a, &b)| b == 0) {
        queue.push_back(i);
    }

    while let Some(q) = queue.pop_front() {
        sorted.push(q);

        for &x in &vertexes[q] {
            deg[x] -= 1;
            if deg[x] == 0 {
                queue.push_back(x);
            }
        }
    }

    let mut dp = vec![0; n + 10];
    let mut dpx = sorted
        .iter()
        .zip((0..))
        .map(|(&u, index)| (u, index))
        .collect::<Vec<(usize, usize)>>();
    dpx.sort();
    let dpx = dpx.iter().map(|x| x.1).collect::<Vec<usize>>();

    for i in 0..n {
        let now = sorted[i];
        for &j in &vertexes[now] {
            dp[dpx[j]] = (dp[dpx[j]]).max(dp[i] + 1);
        }
    }

    println!("{}", dp.iter().max().unwrap());
}


Measured memory_bytes: 11368
# heapq -> deque

def main():
    from collections import defaultdict, deque

    T = int(input())
    for _ in range(T):
        N, A, B, C, D = map(int, input().split())

        inf = N * D + 1

        dq = deque()
        dq.append((0, N))  # cost,value

        checked = defaultdict(lambda: inf)
        checked[N] = 0

        ans = inf
        while dq:
            cost, x = dq.popleft()
            if cost >= ans: continue
            if cost > checked[x]: continue

            # 0まで1ずつ減らす
            ans = min(ans, cost + x * D)

            for d, c in ((2, A), (3, B), (5, C)):
                nx, r = divmod(x, d)
                ncost = cost + r * D + c
                if checked[nx] > ncost:
                    checked[nx] = ncost
                    dq.append((ncost, nx))

                if r == 0: continue
                ncost = cost + (d - r) * D + c
                if checked[nx + 1] > ncost:
                    checked[nx + 1] = ncost
                    dq.append((ncost, nx + 1))

        print(ans)


if __name__ == '__main__':
    main()


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n,x,t; cin >> n >> x >> t;
  int mul = n/x;
  int ans;
  if(mul==0) ans = t;
  else{
    if(n%x!=0) mul++;
    ans = mul*t;
  }

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


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

void fnTrace(vector<int> &argviSort, int argiSize)
{
  for (int i = 0; i < argiSize; i++)
  {
    if (i) cout << " ";
    cout << argviSort[i];
  }
  cout << endl;
}

void fnInsertionSort(vector<int> &argviSort, int argiSize)
{
  for (int i = 1; i < argiSize; i++)
  {
    int iTarget = argviSort[i];
    int j = i - 1;
    while (iTarget < argviSort[j] &&
           j       >= 0            )
    {
      argviSort[j + 1] = argviSort[j];
      j--;
    }
    argviSort[j + 1] = iTarget;
    fnTrace(argviSort, argiSize);
  }
}

int main()
{
  vector<int> viSort;
  int iMaxSize;
  
  cin >> iMaxSize;
  viSort.resize( iMaxSize );
  for (int i = 0; i < iMaxSize; i++) cin >> viSort[i];

  fnTrace(viSort, iMaxSize);
  fnInsertionSort(viSort, iMaxSize);

  return 0;
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<std::vector<char> > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    int n; cin >> n;
    v_int t(n);
    irep(i, n) {
        cin >>t[i];
    }

    int m; cin >> m;
    
    v_int ans(m, 0);

    irep(i, m) {
        int p, x;
        cin >> p >> x;

        int org = t[p-1];
        t[p-1] = x;
    
        irep(j, n) {
            ans[i] += t[j];
        }
        t[p-1] = org;
    }

    irep(i, m) {
        cout << ans[i] << endl;
    }
    return 0;
}
/** atcoder **/


Measured memory_bytes: 256
a,b,c=input().split()
if ((int(a)+int(b)+int(c)==17) and int(a)<=10 and int(b)<=10 and int(c)<=10 and int(a)>=1 and int(b)>=1 and int(c)>=1):
    if ((int(a)==5 or int(a)==7) and (int(b)==5 or int(b)==7) and (int(c)==5 or int(c)==7)):
        print("YES")
    else:
        print("NO")
else:
    print("NO")
 
 

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

int main()
{
    int n, m, l;
    int A[100][100] = {}, B[100][100] = {};

    cin >> n >> m >> l;

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> A[i][j];
        }
    }
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < l; j++)
        {
            cin >> B[i][j];
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < l; j++)
        {
            long sum_ = 0;
            for (int k = 0; k < m; k++)
            {
                sum_ += A[i][k] * B[k][j];
            }
            cout << sum_ << (j < l - 1 ? " " : "\n");
        }
    }

    return 0;
}


Measured memory_bytes: 3184
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

int main(){
  int n, q;
  string s;
  cin >> n >> q >> s;
  
  vector<int> vec(s.size() + 1, 0);
  for (int i = 0; i < s.size(); i++) {
    vec[i + 1] = vec[i] + (s[i] == 'A' && s[i + 1] == 'C' ? 1 : 0);
  }
  
  while(q--) {
    int l, r;
    cin >> l >> r;
    cout << vec[r - 1] - vec[l - 1] << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;

template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);


int main(){
  FAST_IO  

  LL cnt = 0;
  int N, k; cin >> N >> k;
  for(int b = 1; b <= N; ++b){
    int r = N % b;
    int p = N / b;
    cnt += (b - k > 0 ? (LL)(b - k) * p : 0);
    cnt += max(0, r - k + 1);
  }

  if(k == 0) cnt -= N;

  cout << cnt <<"\n";
  return 0;
}

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

using namespace std;

const int MOD = 1'000'000'007;

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

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

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

    vector<int> dp(k + 1);
    dp[0] = 1;
    for (int i = 1; i <= n; ++i) {
        vector<int> pref(k + 2);
        partial_sum(dp.begin(), dp.end(), pref.begin() + 1,
                    [](int x, int y) { return (x + y) % MOD; });

        for (int j = 0; j <= k; ++j) {
            dp[j] = (pref[j + 1] - pref[max(0, j - a[i - 1])]) % MOD;
            if (dp[j] < 0) dp[j] += MOD;
        }
    }

    cout << dp[k] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main(void) {
	char s[233];
	scanf("%s", s+1);
	for (int i=1; i<strlen(s+1); i++) {
		if (s[i]=='A' && s[i+1]=='C') {
		   cout<<"Yes"<<'\n';
		   return 0;
		}
	}
	cout<<"No"<<'\n';
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define all(v) (v).begin(), (v).end()

typedef long long ll;

template <class T = int>
T in() { T x; cin >> x; return x; }
#define output(e) cout << e << '\n'

#ifdef LOCAL
    #define dr(x) cout << "L" << __LINE__ << ": " << #x << " -> " << x << "\n"
#else
    #define dr(x)
#endif

//
// Implementation
//

int main() {
    int N = in();
    int A = in();
    int nokori = N % 500;
    if (nokori <= A) {
        output("Yes");
    } else {
        output("No");
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int i = 0;
        while (a > 0 && c > 0) {
            if (i % 2 == 0) {
                c -= b;
            } else {
                a -= d;
            }
            i++;
        }
        if (a <= 0) {
            System.out.println("No");

        } else {
            System.out.println("Yes");
        }

    }
}


Measured memory_bytes: 35784
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <memory.h>
#include <math.h>

int main(int argc, char *argv[])
{
    int n;
    int v[20], c[20];
    int i;
    int ans;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        scanf("%d", &v[i]);
    }
    
    for (i = 0; i < n; i++) {
        scanf("%d", &c[i]);
    }

    ans = 0;

    for (i = 0; i < n; i++) {
        if (v[i] > c[i]) {
            ans += v[i] - c[i];
        }
    }

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

    return 0;
}


Measured memory_bytes: 128
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;

int main() {
long long A;
cin>>A;
float B;
cin>>B;
B=B*(100);
long long C=(long long)round(B);
long long ans=(A)*C;
ans=ans/100;
cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 3748
# AtCoder Beginner Contest 128
# C - Switches
# https://atcoder.jp/contests/abc128/tasks/abc128_c
N, M = map(int, input().split())
S = [tuple(map(int, input().split()[1:])) for _ in range(M)]
*P, = map(int, input().split())

switch2bulb = [[] for _ in [0]*N]

for i, ss in enumerate(S):
    for s in ss:
        switch2bulb[s-1].append(i)

ans = 0
for bit in range(2**N):
    sw = [p ^ 1 for p in P]
    for i in range(N):
        if bit >> i & 1:
            for m in switch2bulb[i]:
                sw[m] ^= 1
    if all(sw):
        ans += 1
print(ans)


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

using namespace std;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 0;
    for(int i = 1; i < N; i++) {
        string s = S.substr(0, i);
        string t = S.substr(i);
        set<char> se;
        for(int j = 0; j < s.size(); j++) {
            for(int k = 0; k < t.size(); k++) {
                if (s[j] == t[k]) se.insert(s[j]);
            }
        }
        ans = max(ans, (int)se.size());
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 256
let () =
  let l = Str.split (Str.regexp " ") (read_line ()) in
  let doit = function
    | (x::y::acc, "+") -> (y + x) :: acc
    | (x::y::acc, "-") -> (y - x) :: acc
    | (x::y::acc, "*") -> (y * x) :: acc
    | (acc, n) -> (int_of_string n) :: acc in
  Printf.printf "%d\n" (List.hd (List.fold_left (fun acc x -> doit (acc, x)) [] l))

Measured memory_bytes: 2284
#include <stdio.h>

int main(int argc, const char * argv[])
{

    int d;
    int i;
    int total = 0;
    while (scanf("%d", &d) != EOF) {
        total = 0;
        for (i = d; i < 600; i += d) {
            total += i * i * d;
        }
        printf("%d\n", total);
    }
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    ll ans = 0;
    // nが奇数なら答えは常に0
    if(n%2 == 0){
        // n*(n-2)*(n-4)*...*2を素因数分解した時、min(2の個数,5の個数)個が答えとなる。
        // 明らかに2の回数のほうが多いため、5が何回含まれるか考える。
        // 2..nまでに5の冪で割り切れる数がいくつあるかカウントする。
        for(long long i=5; i<=n; i*=5) ans += (n/2)/i;
    } 
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
constexpr double pi=3.14159265358979;
 
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;
}
using namespace std;

void solve(){
  string s;
  cin>>s;
  string t=s.substr(0,4);
  if(t=="YAKI")cout<<"Yes\n";
  else cout<<"No\n";
  return;
}
 
signed main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
  cout<<fixed<<setprecision(20);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int nth_bit(int x, int n){
    return (x >> n) & 1;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K; cin >> N >> K;
    vector<string> c;
    VI A(N);
    VL B(N);
    REP(i,N) cin >> A[i] >> B[i];

    string ck;
    REP(_,32){
        ck += char('0'+K%2);
        K /= 2;
    }
    reverse(ck.begin(),ck.end());
    c.eb(ck);
    int ck_len = ck.length();

    FOR(i,0,ck_len){
        if(ck[i] == '1'){
            string tmp = ck.substr(0,i);
            tmp += '0';
            tmp += string(ck_len-1-i,'1');
            c.eb(tmp);
        }
    }

    LL ans = 0;
    for(auto s : c){
        reverse(s.begin(),s.end());
        LL tmp = 0;
        REP(i,N){
            bool ok = 1;
            REP(j,32){
                if(nth_bit(A[i],j) == 0 || s[j] == '1'){

                }else{
                    ok = 0;
                }
            }
            if(ok) tmp += B[i];
        }
        ans = max(ans,tmp);
    }
    cout << ans << endl;




}


Measured memory_bytes: 1408
while n = gets.chomp
  n = n.to_i
  break if n.zero?

  lp, rp = 0, 0;
  n.times do
    l, r = gets.chomp.split.map(&:to_i)
    if l > r
      lp += l + r
    elsif l < r
      rp += l + r
    else
      lp += l
      rp += r
    end
  end
  puts "#{lp} #{rp}"
end

Measured memory_bytes: 8748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int h, a;
	cin >> h >> a;
	int n = h/a;
	if(h % a != 0) n++;
	cout << n << endl;
	return 0;
}



Measured memory_bytes: 3616