akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long x = sc.NextLong();
        long t = sc.NextLong();

        long answer = ((n + x - 1) / x) * t;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27504
#include <cstdio>
#define MIN(a, b) a < b ? a : b
#define SUPER_LARGE 987654321
int V, E, R, D[1000];
struct edges {
	int s;
	int d;
	int w;
};
struct edges A[2000];
void input(void);
bool DP(void);
int main(void){
	input();
	if (DP())
		printf("NEGATIVE CYCLE\n");
	else{
		int i;
		for (i = 0; i < V; i++){
			if (D[i] > 10000000)
				printf("INF\n");
			else
				printf("%d\n", D[i]);
		}
	}
		
	return 0;
}
bool DP(void){
	int i, j, k;
	for (i = 0; i < V; i++) D[i] = SUPER_LARGE;
	D[R] = 0;
	for (j = 0; j < V; j++)  // for relaxation order
		for (k = 0; k < E; k++) D[A[k].d] = MIN(A[k].w + D[A[k].s], D[A[k].d]); // relaxation 

	bool nc = false;
	for (k = 0; k < E; k++){
		if (D[A[k].d] <= 10000000 && D[A[k].d] > A[k].w + D[A[k].s]) {
			nc = true;
			break;
		}
	}
	return nc;
}
void input(void){
	scanf("%d%d%d", &V, &E, &R);
	int i;
	for (i = 0; i < E; i++) scanf("%d%d%d", &A[i].s, &A[i].d, &A[i].w);
}

Measured memory_bytes: 1052
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define FINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) ((a) <= (i) && (i) <= (b))
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a < b) { a = b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(begin(a), end(a)); }
template <typename T> inline void REV(T& a) { reverse(begin(a), end(a)); }
template <typename T> inline void UNI(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <typename S, typename T> inline T LB(S& v, T a) { return *lower_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int LBP(S& v, T a) { return lower_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> inline T UB(S& v, T a) { return *upper_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int UBP(S& v, T a) { return upper_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> ostream& operator << (ostream& os, const pair<S, T>& p) { os << p.first << " " << p.second; return os; }
template <typename S, typename T> istream& operator >> (istream& is, pair<S, T>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator >> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int N;
int A[100010];

void _main() {
    cin >> N;
    REP (i, N) cin >> A[i];
    int mn = 1, mx = N;
    FOR (i, 1, N) if (A[i - 1] >= A[i]) mn++;
    cout << mn << endl;
    cout << mx << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


Measured memory_bytes: 3992
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define mo 1000000007
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);putchar('\n');
}
template<typename T> void chkmod(T &x,T y){x=(x+y>=mo)?(x+y-mo):(x+y);}
template<typename T> void chkmax(T &x,T y){x=x>y?x:y;} 

int co[10010];
int prime[1000010];int f[1000010];int num[1000010];int len=0;
inline void Pre(){
	rep(i,2,1000000){
		if(!f[i]){f[i]=i;prime[++len]=i;}
		rep(j,1,len){
			if(prime[j]*i>1000000)break;
			f[i*prime[j]]=prime[j];
			if(i%prime[j]==0)break;
		}
	}
}
inline int poww(int n,int m){
	int ret=1;int temp=n;int tmp=m;
	while(tmp){
		if(tmp&1)ret=(1ll*ret*temp)%mo;
		temp=(1ll*temp*temp)%mo;
		tmp>>=1;
	}
	return ret;
}

int main(){
	int n;read(n);
	rep(i,1,n)read(co[i]);
	Pre();
	
	rep(i,1,n){
		int x=co[i];
		while(x!=1){
			int nop=f[x];int cnt=0;
			while(x%nop==0){x/=nop;cnt++;}
			chkmax(num[nop],cnt);
		}
	}
	int lcm=1;
	rep(i,1,1000000){
		if(!num[i])continue;
		lcm=(1ll*lcm*poww(i,num[i]))%mo;
	}
	
	int ans=0;
	rep(i,1,n){
		int nop=(1ll*lcm*poww(co[i],mo-2))%mo;
		chkmod(ans,nop);
	}
	write(ans);
	return 0;
}


Measured memory_bytes: 8192
#line 2 "cpplib/util/template.hpp"
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")
#include<bits/stdc++.h>
using namespace std;
struct __INIT__{__INIT__(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}__INIT__;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define endl ('\n')
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,...) for(auto i:range(__VA_ARGS__)) 
#define rrep(i,...) for(auto i:reversed(range(__VA_ARGS__)))
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
inline vector<long long> range(long long n){if(n<=0)return vector<long long>();vector<long long>v(n);iota(v.begin(),v.end(),0LL);return v;}
inline vector<long long> range(long long a,long long b){if(b<=a)return vector<long long>();vector<long long>v(b-a);iota(v.begin(),v.end(),a);return v;}
inline vector<long long> range(long long a,long long b,long long c){if((b-a+c-1)/c<=0)return vector<long long>();vector<long long>v((b-a+c-1)/c);for(int i=0;i<(int)v.size();++i)v[i]=i?v[i-1]+c:a;return v;}
template<typename T>inline T reversed(T v){reverse(v.begin(),v.end());return v;}
#define all(n) begin(n),end(n)
template<typename T,typename E>bool chmin(T& s,const E& t){bool res=s>t;s=min<T>(s,t);return res;}
template<typename T,typename E>bool chmax(T& s,const E& t){bool res=s<t;s=max<T>(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
template<typename T,typename ...Args>auto make_vector(T x,int arg,Args ...args){if constexpr(sizeof...(args)==0)return vector<T>(arg,x);else return vector(arg,make_vector<T>(x,args...));}
//#include "../graph_tree/graph_template.hpp"
#line 2 "code.cpp"

int main(){
    lint n,m;
    cin>>n>>m;
    mat v(n,vec(n,INF));
    vec x(m),y(m),z(m);
    rep(i,m){
        lint s,t,c;
        cin>>s>>t>>c;
        s--;t--;
        x[i]=s;y[i]=t;z[i]=c;
        v[s][t]=c;
        v[t][s]=c;
    }
    rep(i,n)v[i][i]=0;
    rep(k,n)rep(i,n)rep(j,n){
        chmin(v[i][j],v[i][k]+v[k][j]);
    }
    lint ans=0;
    rep(i,m){
        if(v[x[i]][y[i]]!=z[i])ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3720
import math
s=int(input())
n=int(math.sqrt(s))
number1=n**2
number2=(n+1)**2
if n!=10**9:
    x_1=0
    y_1=0
    #x_3*y_2-x_2*y_3=sなる自然数四つを適当に構成する
    if s-number1>=n+1:
        x_3=n+1
        y_2=n+1
        x_2=1
        y_3=(n+1)**2-s
    
    elif s-number1<=n:
        x_3=n
        y_2=n+1
        y_3=n*(n+1)-s
        x_2=1
    lists=[x_1,y_1,x_2,y_2,x_3,y_3]    
    print(*lists)
if n==10**9:
    lists=[0,0,0,10**9,10**9,0]
    print(*lists)

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

int main() {
    int X,t;
    cin >> X >> t;
    cout << max(0,X - t) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int cnt=0;
	for(int i=0;i<=n;i++){
		int w=0;
		int j=i;
		while(j>0){
			w++;
			j/=10;
		}
		if(w%2!=0) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

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

int main(void){
	long long N,T,A,k,t=1,a=1;
	cin>>N;
	while(N--){
		cin>>T>>A;
		k=max((t-1)/T+1,(a-1)/A+1);
		t=T*k;
		a=A*k;
	}
	cout<<t+a<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>

using namespace std;

int a[200005];
int b[200005];

vector<int>ma;
vector<int>mb;

int main() {

	int N;

	scanf("%d",&N);

	int i,k;

	for(i=0;i<N;i++){
	scanf(" %d",&a[i]);
	}
	for(i=0;i<N;i++){
	scanf(" %d",&b[i]);
	}

	long long ans=0ll;
	for(k=0;k<=28;k++){
	long long t=pow(2,k);
	ma.clear();
	mb.clear();
	for(i=0;i<N;i++){
		ma.push_back(a[i]%(2*t));
		mb.push_back(b[i]%(2*t));
	}
	sort(mb.begin(),mb.end());
	long long cnt=0;
	for(i=0;i<N;i++){
		cnt+=lower_bound(mb.begin(),mb.end(),2*t-ma[i])-lower_bound(mb.begin(),mb.end(),t-ma[i])+mb.end()-lower_bound(mb.begin(),mb.end(),3*t-ma[i]);
	}
	if(cnt%2==1){ans+=t;}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3572
N, K = map(int, input().split())

if K == 0:
  print(N**2)
  exit()

ans = 0
for b in range(1, N+1):
  if b <= K:
    continue
  ans += (N // b) * (b - K)
  ans += max(0, N % b - K + 1)

print(ans)

Measured memory_bytes: 3060
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${rg(Qbk;6n!V*A8xX2!mLJ;Em?@{EB5AmfVRNRYOAH7`}?&PrB3@)&N<wB?zw#e`fFMxbD#_d>`=+#OZPmEYOQu7x!jk!6oLz&xZ5jjV6RKrTtosZy6g-?b>$mwXj^Jxg(yuON0jjzgp$qXePvI!1vY|~x4+3G1*sYoc^rW~SE?dFp@5Z#k1Yxg*(h?SvgFt;NhcU<%dFw;BZo@!@@HaPH43kgtzd373#;*@=BC#Y=;&)u$e?5_aW0UY&75vcdN&B`0%Tx`ZEy?o0#1P)_l@uZ3k<S=uHX6c4~F-G|Dz*(!Yb(1xx%ht*lRKM3I^+fz@-bpg-+lwUG0>HKu=(Zqa&L3##F7et%`EoeInD`$75s6h%b>omLAf;vAOh{p#B~j?jgHUlaCK7nLP{kEobB$;gH%jx=Wu1dM-NdE%x5xV97snn#0W")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 12920
#include<stdio.h>

typedef struct sweet{
        int num, p, q, r, col;
} Sweet;

int main(){
        while(1){
                int n, i;
                scanf("%d", &n);
                if(n==0) break;

                Sweet sweets[n];
                for(i=0; i<n; i++){
                        int num, p, q, r;
                        scanf("%d %d %d %d", &sweets[i].num, &sweets[i].p, &sweets[i].q, &sweets[i].r);
                        sweets[i].col = sweets[i].p*4 + sweets[i].q*9 + sweets[i].r*4;
                }

                int p, q, r, c, cnt=0;
                scanf("%d %d %d %d", &p, &q, &r, &c);

                for(i=0; i<n; i++){
                        Sweet sw = sweets[i];
                        if(sw.p<=p && sw.q<=q && sw.r<=r && sw.col<=c){
                                printf("%d\n", sw.num);
                                cnt++;
                        }
                }
                if(cnt==0) puts("NA");
        }
        return 0;
}



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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<pi> vpi;
typedef vector<bool> vbool;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define forall(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define F0(i,n) for(ll i = 0; i < n; i++)
#define F1(i,n) for(ll i = 1; i <= n; i++)
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define per(i,a,b) for(int i = b-1; i >= a; i--)
#define FIN ios::sync_with_stdio(false);cin.tie(0);
#define db(x) cout<<#x<<" = "<<x<<"\n"
#define all(v) v.begin(),v.end()
#define modulo(a,b) ((a%b)+b)%b
#define F first
#define S second
#define INF 1000000010
#define INFLL 1000000000000000000
#define eps 0.000000000001
#define mod 1000000007
template<class C> void mini(C&a, C b){ a=min(a, b);}
template<class C> void maxi(C&a, C b){a=max(a,b);}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

//=======================//
int n;

/*
dp[L][R] = costo de unir a[L..R] en un solo elemento.
dp[L][L] = 0
dp[L][R] = Primero reduzco a dos slimes: para eso pago dp[L][i] y dp[i+1][R].
Despues para unificarlos pago sum(a[L...R]).
Para que cuando estoy en un estado dp[L][R] ya esten definidos los dp[L][i] con i<R R tiene que iterar desde L hasta n.
Para que este definido dp[i+1][R] con i>=L, itero L desde n-1 hasta 0.
*/


int main () {
	//FIN
	cin >> n;
	ll a[n]; F0(i,n) cin >> a[i];
	ll dp[n+1][n+1];
	F0(i,n+1) F0(j,n+1) dp[i][j] = INFLL;
	ll prefix_sum[n];
	prefix_sum[0] = a[0];
	rep(i,1,n-1) prefix_sum[i] = a[i] + prefix_sum[i-1];
	auto sum = [&](int i, int j) {
		ll res = prefix_sum[j];
		if(i > 0) res -= prefix_sum[i-1];
		return res;
	};

	for (int L = n-1; L >= 0; L--) {
		for (int R = L; R < n; R++) {
			if (L == R) dp[L][R] = 0;
			else {
				for (int i = L; i < R; i++) {
					mini(dp[L][R], dp[L][i] + dp[i+1][R]);
				}
				dp[L][R] += sum(L,R);
			}
		}
	}

	cout << dp[0][n-1] << "\n";

	return 0;
}










Measured memory_bytes: 4836
n,k=map(int,input().split())
l=list(map(int,input().split()))
dp=[float('inf') for i in range(n+1)]
dp[0]=0
for i in range(len(dp)):
    for j in range(i+1,i+k+1):
        if(j<len(l)):
      	    dp[j]=min(dp[j],dp[i]+abs(l[j]-l[i]))
print(dp[n-1])

Measured memory_bytes: 56928
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    vector<int> a (3);
    cin >> a.at(0) >> a.at(1) >> a.at(2);
    sort(a.begin(),a.end());
    if(a.at(2) == a.at(0) + a.at(1)){
    cout << "Yes" << endl;
    }
    else{
    cout << "No" << endl;
    }
    return 0;
}

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

void print_vec(vector<int> vec)
{
  cout << "[";
  for (int i = 0; i < vec.size(); i++)
  {
    cout << vec.at(i);
    if (i < vec.size() - 1)
    {
      cout << ", ";
    }
  }
  cout << "]...size: " << vec.size() << endl;
}

int main()
{
  vector<int> vec;
  int tmp = 1001001001;

  while (tmp != 0)
  {
    cin >> tmp;
    vec.push_back(tmp);
  }

  rep(i, vec.size() - 1)
  {
    printf("Case %d: %d\n", i + 1, vec.at(i));
  }
}



Measured memory_bytes: 3396
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>
#include <omp.h>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;

const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
const long long int pl=1000000;
long long int N;

int main(){

    cout << fixed << setprecision(18);
    cin>>N;
    cout<<(((N-1)/1000+1)*1000-N)%1000<<endl;
}



Measured memory_bytes: 3616
/**
 *  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_A
 */
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>

using namespace std;

void
printv(const vector<int> a)
{
    stringstream ss;
    for (auto it = a.cbegin(); it != a.cend(); it++) {
        if (it != a.begin()) {
            ss << ' ';
        }
        ss << *it;
    }
    cout << ss.str() << endl;
}

void
selectionsort(const vector<int> a)
{
    vector<int> work(a);

    int count = 0;
    for (auto it1 = work.begin(); it1 != work.end(); it1++) {
        auto mini = it1;
        for (auto it2 = it1; it2 != work.end(); it2++) {
            if (*it2 < *mini) {
                mini = it2;
            }
        }
        if (it1 != mini) {
            iter_swap(it1, mini);
            count++;
        }
    }
    printv(work);
    cout << count << endl;
}

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

    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i]; cin.ignore();
    }
    selectionsort(A);

    return 0;
}

Measured memory_bytes: 3164
# 100000 100000
A, B = map(int, input().split())

def gcd(x, y):
    '''
    最大公約数の計算
    '''
    if y == 0:
        return x
    return gcd(y, x % y)

def lcm(x, y):
    '''
    最小公倍数の計算
    '''
    return (x * y) // gcd(x, y)

print(lcm(A,B))

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ; 
  cin >> n ;
  vector<int> v(n);
  int now = INF ;
  
  rep(i,n){
    cin >> v.at(i);
    now = min(now,v.at(i));
  }
  
  int MIN = INF ;
  while(MIN !=now){
    MIN = now ;
    rep(i,n){
      if(v.at(i) % MIN !=0){
        v.at(i) %= MIN;
        now = min(now,v.at(i));
      }
    }
  }
  
  cout << now ;
    
             
  
  
}


Measured memory_bytes: 640
n=int(input())
x=[-1]*n
y=[-1]*n
h=[-1]*n
for i in range(n):
  x[i],y[i],h[i]=map(int,input().split())

mh=max(h)
for cx in range(0,101):
  for cy in range(0,101):
    for H in range(mh,mh+216):
      if all(h[j]==max(H-abs(cx-x[j])-abs(cy-y[j]),0) for j in range(n)):
        print(cx,cy,H)
        exit()


Measured memory_bytes: 70616
fn main() {
    let s: Vec<char> = read::<String>().chars().collect();

    let mut max_count = 0;
    let mut count = 0;
    for c in s.iter() {
        if *c == 'R' {
            count += 1;
        } else {
            count = 0;
        }

        if max_count < count {
            max_count = count;
        }
    }

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

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


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

int main(){
    ll a,b;
    cin >> a >> b;
    if (a>0&&b>0){
        cout << "Positive" << endl;
    }
    else if (a<0&&b<0){
        ll x=b-a+1;
        if (x%2==1){
            cout << "Negative" << endl;
        }
        else {
            cout << "Positive" << endl;
        }
    }
    else {
        cout << "Zero" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int64_t gcd(int64_t A,int64_t B){
  if(B==0){return A;}
  return gcd(B,A%B);
}
 
map<int64_t,int> prime_list(int64_t n){
  map<int64_t,int> ans;
  for(int64_t i=2;i*i<=n;++i){
    while(n%i==0){
      ++ans[i];
      n=n/i;
    }
  }
  if(n!=1){
    ++ans[n];
  }
  return ans;
}
 
 
 
int main(){
  int64_t A,B;
  cin>>A>>B;
  int64_t G=gcd(A,B);
  cout<<prime_list(G).size()+1<<endl;
}

Measured memory_bytes: 256
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def powd(x, n, m):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = (ans*x)%m
    x = x*x % m
    n = n >> 1 #ビットシフト
  return ans


#a = list(map(int, input().split()))

n = int(input())
city = []
for i in range(n):
    city.append(list(map(int, input().split())))
ans=0
for i in range(n):
    for j in range(n-1-i):
        ans += ((city[i][0]-city[j+i+1][0])**2 + (city[i][1] - city[j+i+1][1])**2)**0.5
        
com=[1 for i in range(12)]
 
for ii in range(10):
    i = ii+1
    com[i+1] = (com[i]*(i+1))

ans *= com[n-1]
ans /= com[n]
print(ans*2)

Measured memory_bytes: 38284
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

H, W = inm()


def solve():
    sc = Counter()
    for i in range(H):
        s = ins()
        for c in s:
            sc[c] += 1
    sv = sorted(sc.values(), reverse=True)
    fours = (H // 2) * (W // 2)
    for i in range(len(sv)):
        while fours > 0 and sv[i] >= 4:
            sv[i] -= 4
            fours -= 1
    if fours > 0:
        return False
    maxtwos = 0
    if H % 2 == 1:
        maxtwos += W // 2
    if W % 2 == 1:
        maxtwos += H // 2
    for i in range(len(sv)):
        while maxtwos > 0 and sv[i] >= 2:
            sv[i] -= 2
            maxtwos -= 1
    if maxtwos > 0:
        return False

    if (H * W) % 2 == 1:
        maxodds = 1
    else:
        maxodds = 0
    return sum(sv) == maxodds


print("Yes" if solve() else "No")


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

int main() {

    int N, A;
    cin >> N >> A;

    N = N % 500;

    if (A>=N) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0]);
		long B = long.Parse(str[1]);
		long ans = Math.Max(Math.Max(A-B,A+B),A*B);
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> vec(n);
  rep(i,n){
    cin >> vec[i];
  }
  chmin(k,100ll);
  rep(i,k){
    vector<ll> cnt(n+1,0);
    rep(j,n){
      cnt[max(0ll,j - vec[j])]++;
      cnt[min(n,j + vec[j] + 1)]--;
      //cout << j - vec[j] << " " << j + vec[j] + 1 << endl;
    }
    ll sum = 0;
    rep(j,n){
      //cout << cnt[j] << endl;
      sum += cnt[j];
      vec[j] = sum;
    }
    if(i == k-1){
      rep(j,n){
        cout << vec[j] << " ";
      }
      cout << endl;
      break;
    }
  }

}

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

using namespace std;
using u64 = uint64_t;
constexpr const u64 INF = UINT64_MAX / 2;

bool inbound(int H, int W, int h, int w) {
    return (0 <= h && h < H) && (0 <= w && w < W);
}

bool continuing(int dh, char ch) {
    return ch == (dh == 0 ? '-' : '|');
}

vector<vector<u64>> parse(int H, int W, vector<vector<char>> const &aa) {
    int h, w;
    for (h = 0; h < H; h++) {
        for (w = 0; w < W; w++) {
            if (isupper(aa[h][w])) goto loopend;
        }
    }
loopend:
    vector<vector<u64>> graph(26, vector<u64>(26, INF));
    queue<pair<int, int>> q; // <h, w>
    q.push({h, w});
    while (!q.empty()) {
        auto c = q.front();
        auto cv = aa[c.first][c.second] - 'A';
        q.pop();
        int adh[] = { -2, 0, 2, 0 };
        int adw[] = { 0, -2, 0, 2 };
        for (int i = 0; i < 4; i++) {
            int dh = adh[i], dw = adw[i];
            int h = c.first + dh, w = c.second + dw;
            if (inbound(H, W, h, w) && continuing(dh, aa[h][w])) {
                dh /= 2; dw /= 2;
                char ch;
                while (!isupper((ch = aa[h][w]))) {
                    h += dh, w += dw;
                }
                auto tv = ch - 'A';
                if (graph[cv][tv] == INF) {
                    graph[cv][tv] = graph[tv][cv] = 1;
                    q.push({h, w});
                }
            }
        }
    }
    return graph;
}

void warshall_floyd(vector<vector<u64>> &graph) {
    int N = graph.size();
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }
}

int main() {
    string line;
    getline(cin, line);
    istringstream ss(line);
    int H, W;
    ss >> H >> W;
    char S, T;
    ss >> S >> T;
    S -= 'A'; T -= 'A';

    vector<vector<char>> aa(H, vector<char>(W));

    for (int h = 0; h < H; h++) {
        string line;
        getline(cin, line);
        for (int w = 0; w < W; w++) {
            aa[h][w] = line[w];
        }
    }

    auto graph = parse(H, W, aa);
    warshall_floyd(graph);
    cout << graph[S][T] << endl;

    return 0;
}




Measured memory_bytes: 3240
#include<stdio.h>

int main()
{
	int high,wide,i,j;

	while(1){
		scanf("%d %d",&high,&wide);
		
		if(high==0&&wide==0)break;

		for(i=0;i<high;i++){
			if(i % 2 ==0){
				for(j=0;j<wide;j++){
					if(j % 2 == 0) printf("#");
					else printf(".");
				}
			}else{
				for(j=0;j<wide;j++){
					if(j % 2 == 0) printf(".");
					else printf("#");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

int main(){
  string s;
  vector<string> youbi = {"MON", "TUE", "WED", "THU", "FRI", "SAT"};
  cin >> s;
  if (s == "SUN") cout << 7 << endl;
  else {
    for (int i = 0; i < 6; i++) {
      if ( youbi.at(i) == s) {
        cout << 6-i << endl;
        break;
      }
    }
  }
}
    

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

int main(void)
{
	float a = 0;
	float b = 0;
	float c = 0;
	float d = 0;
	float e = 0;
	float f = 0;

	float x = 0;
	float y = 0;

	while (std::cin >> a >> b >> c >> d >> e >> f)
	{
		float tmp_a = a * e;
		float tmp_c = c * e;
		float tmp_d = d * b;
		float tmp_f = f * b;

		if (tmp_c == tmp_f)
		{
			x = 0;
		}
		else
		{
			x = (tmp_c - tmp_f) / (tmp_a - tmp_d);
		}

		float tmp_b = b * d;
		tmp_c = c * d;
		float tmp_e = e * a;
		tmp_f = f * a;

		if (tmp_c == tmp_f)
		{
			x = 0;
		}
		else
		{
			y = (tmp_c - tmp_f) / (tmp_b - tmp_e);
		}

		std::cout << std::fixed << std::setprecision(3) << x << " " << y << std::endl;
	}

	return 0;
}

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

int main(){
  string fcst;
  cin >> fcst;
  string tt;
  cin >> tt;
  int ans = 0 ;
  for(int i=0;i<3;i++){
    if(fcst.at(i)==tt.at(i)){
      ans+=1;
    }
  }
  cout << ans;
  }

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::Reverse;

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

const MOD: usize = 1000000007;

fn rec(v: usize, parent: usize, dp: &mut Vec<Vec<usize>>, adj: &Vec<Vec<usize>>) {
    let mut whites = 1;
    let mut blacks = 1;
    for &y in adj[v].iter() {
        if parent != y {
            rec(y, v, dp, adj);
            whites *= (dp[y][0] + dp[y][1]) % MOD;
            whites %= MOD;
            blacks *= (dp[y][0]) % MOD;
            blacks %= MOD;
        }
    }
    dp[v][0] = whites;
    dp[v][1] = blacks;
}

#[fastout]
pub fn main() {
    input! {
        n: usize,
        v: [(Usize1, Usize1); n - 1],
    }
    let mut adj = vec![Vec::new(); n];
    v.into_iter().for_each(|(x, y)| {
        adj[x].push(y);
        adj[y].push(x);
    });

    let mut dp = vec![vec![0; 2]; n];
    rec(0, std::usize::MAX, &mut dp, &adj);
    println!("{}", (dp[0][0] + dp[0][1]) % MOD);
}


Measured memory_bytes: 22416
package main

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

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	list := getStdinIntArr()
	N := list[0]
	K := list[1]
	d := make([]int, K)
	A := make([][]int, K)
	X := make([]int, N) // すぬけ君
	for i := 0; i < K; i++ {
		d[i] = getStdinInt()
		A[i] = getStdinIntArr()
	}

	for i := 0; i < K; i++ {
		for j := 0; j < d[i]; j++ {
			X[A[i][j]-1]++
		}
	}

	ans := 0
	for i := 0; i < N; i++ {
		if X[i] == 0 {
			ans++
		}
	}

	fmt.Printf("%d\n", ans)
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 1024*1024*10)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 23780
#include<stdio.h>
using namespace std;
#include<queue>
#define rep(i, a, b) for(long long i=(a); i<(b); i++)

int main(){
  long long N,M,temp,count,sum=0;
  priority_queue<long long, vector<long long>, greater<long long> > Q;
  priority_queue<pair<long long, long long> > CB;
  scanf("%lld %lld",&N,&M);
  
  rep(i,0,N){
    scanf("%lld",&temp);
    Q.push(temp);
  }
  rep(i,0,M){
    long long b_temp,c_temp;
    scanf("%lld %lld",&b_temp,&c_temp);
    CB.push(make_pair(c_temp,b_temp));
  }
  rep(i,0,M){
    pair<long long, long long> CB_temp = CB.top();
    CB.pop();
    long long b_temp=CB_temp.second,c_temp=CB_temp.first;
    while(b_temp>0 && Q.top()<c_temp){
      Q.pop();
      Q.push(c_temp);
      b_temp--;
    }
  }
  rep(i,0,N){
    long long element = Q.top();
    Q.pop();
    sum += element;
  }
  printf("%lld\n",sum);
  return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, K;
  cin >> N >> K;
  int ans = 1;
  for(int i = 0; i < N; i++) {
    if(i == 0) ans *= K;
    else ans *= K - 1;
  }
  cout << ans << endl;
  return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(a * n, b) << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		int[] occur = new int[100];
		int max = 0;

		Arrays.fill(occur, 0);

		while ((line = br.readLine()) != null) {
			int i = ++occur[Integer.parseInt(line) - 1];
			if (i > max)
				max = i;
		}
		for (int i = 0; i < 100; i++) {
			if (occur[i] == max)
				System.out.println(i + 1);
		}
	}
}

Measured memory_bytes: 16868
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var abq = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var a = abq[0];
        var b = abq[1];
        var q = abq[2];
        var ss = new long[a + 2];
        ss[0] = long.MinValue / 4;
        ss[ss.Length - 1] = long.MaxValue / 4;
        for (int i = 0; i < ss.Length - 2; i++)
        {
            ss[i + 1] = long.Parse(Console.ReadLine());
        }
        var ts = new long[b + 2];
        ts[0] = long.MinValue / 4;
        ts[ts.Length - 1] = long.MaxValue / 4;
        for (int i = 0; i < ts.Length - 2; i++)
        {
            ts[i + 1] = long.Parse(Console.ReadLine());
        }
        var queries = new long[q];
        for (int i = 0; i < queries.Length; i++)
        {
            queries[i] = long.Parse(Console.ReadLine());
        }

        var sb = new System.Text.StringBuilder();
        foreach (var x in queries)
        {
            var s = Neighbors(x, ss);
            var t = Neighbors(x, ts);
            var d = new [] 
            { 
                x - Math.Min(s.Item1, t.Item1), 
                (x - s.Item1) * 2 + t.Item2 - x,
                (x - t.Item1) * 2 + s.Item2 - x,
                x - s.Item1 + (t.Item2 - x) * 2,
                x - t.Item1 + (s.Item2 - x) * 2,
                Math.Max(s.Item2, t.Item2) - x,
            };
            sb.AppendLine(d.Min().ToString());
        }
        Console.WriteLine(sb);
    }

    static Tuple<long, long> Neighbors(long p, long[] ps)
    {
        var ok = 0;
        var ng = ps.Length;
        while (Math.Abs(ok - ng) > 1)
        {
            var m = (ok + ng) / 2;
            if (p > ps[m])
            {
                ok = m;
            }
            else
            {
                ng = m;
            }
        }

        return Tuple.Create(ps[ok], ps[Math.Min(ok + 1, ps.Length - 1)]);
    }
}


Measured memory_bytes: 27072
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
const int mo=1e9+7;
int n,a,b;
long long ans;
long long po(long long a,long long b)
{
	if (b==0) return 1;
	if (b==1) return a%mo;
	long long c=po(a,b/2);
	if (b&1) return c*c%mo*a%mo;else return c*c%mo;
}
long long C(long long n,long long m)
{
	long long now=1;
	for (long long i=n;i>=n-m+1;i--) now=now*i%mo;
	for (long long i=1;i<=m;i++) now=now*po(i,mo-2)%mo;
return now;
}
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	ans=(po(2,n)-1+mo)%mo;
	ans=(ans-C(n,a)+mo)%mo;
	ans=(ans-C(n,b)+mo)%mo;
	printf("%lld\n",ans);
return 0;
}

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

using namespace std;

long long x[100000], v[100000], cw1[100000], cw2[100000], ccw1[100000], ccw2[100000];

int main() {
	int n;
	long long c, tot, mx = 0;

	scanf("%d %lld", &n, &c);

	for (int i = 0;i < n;++i)
		scanf("%lld %lld", &x[i], &v[i]);

	tot = v[0];
	cw1[0] = max((long long)0, v[0] - x[0]);
	cw2[0] = max((long long)0, v[0] - x[0] * 2);

	mx = cw1[0];

	for (int i = 1;i < n;++i) {
		tot += v[i];
		cw1[i] = max(cw1[i - 1], tot - x[i]);
		cw2[i] = max(cw2[i - 1], tot - x[i] * 2);

		mx = max(mx, cw1[i]);
	}

	tot = v[n - 1];
	ccw1[n - 1] = max((long long)0, v[n - 1] - (c - x[n - 1]));
	ccw2[n - 1] = max((long long)0, v[n - 1] - (c - x[n - 1]) * 2);

	mx = max(mx, ccw1[n - 1]);

	for (int i = n - 2;i >= 0;--i) {
		tot += v[i];
		ccw1[i] = max(ccw1[i + 1], tot - (c - x[i]));
		ccw2[i] = max(ccw2[i + 1], tot - (c - x[i]) * 2);

		mx = max(mx, ccw1[i]);

		if (i > 0) {
			mx = max(mx, ccw1[i] + cw2[i - 1]);
			mx = max(mx, ccw2[i] + cw1[i - 1]);
		}
	}

	for (int i = 0;i < n - 1;++i) {
		mx = max(mx, cw1[i] + ccw2[i + 1]);
		mx = max(mx, cw2[i] + ccw1[i + 1]);
	}

	printf("%lld", mx);

	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
const ll INF = 1ll << 60;

ll dp[100010][3];
ll a[100010][3];

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

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            cin >> a[i][j];
        }
    }
    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[0][2] = 0;

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            for (int k = 0; k < 3; ++k)
            {
                if (j == k)
                    continue;
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }
    ll res = 0;
    for (int j = 0; j < 3; ++j)
        res = max(res, dp[n][j]);

    cout << res << endl;

    return 0;
}

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

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

    for (int i = 0; i <= n; i++) {
        for (int j = 0; i+j <= n; j++) {
            int k = n-i-j;
            int sum = i*10000 + j*5000 + k*1000;
            if (sum == y) {
                printf("%d %d %d",i,j,k);
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

char input[N][N] ;
bool row[N] , col[N] ;

int main() {
    //#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    //freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    //freopen("output.txt", "w", stdout);
    //#endif

    int n, m ;
    vector<string>ans ;
    scanf("%d %d" ,&n ,&m) ;

    for(int i = 0 ;i<n ;i++){
        scanf("%s" ,input[i]) ;
    }

    for(int i = 0 ; i<n ;i++){
      bool ok = true ;
      for(int j = 0 ;j<m ; j++){
        if(input[i][j] == '#'){
          ok = false ;
          break ;
        }
      }
      if(ok)row[i] = true ;
    }

    for(int j = 0 ; j<m ; j++){
      bool ok = true ;
      for(int i = 0 ; i<n ; i++){
        if(input[i][j] == '#'){
          ok =false ;
          break ;
        }
      }
      if(ok)col[j] = true ;
    }

    for(int i = 0 ; i<n ;i++){
      if(!row[i]){
        string s ="" ;
        for(int j =0 ; j<m ;j++){
          if(!col[j])s+=input[i][j] ;
        }
        ans.pb(s) ;
      }
    }

    for(int i = 0 ;i<ans.size() ;i++){
      cout << ans[i] << '\n' ;
    }
   
    return 0 ;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int result = 0;

        for (int i = 0; i < N; i++) {
            int X = sc.nextInt();
            int Y = sc.nextInt();

            double calcResult = Math.sqrt(Math.pow(X, 2) + Math.pow(Y, 2));
            if (calcResult <= D) {
                result += 1;
            }
        }
        
        System.out.println(result);
        sc.close();
    }
}

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

using namespace std;

const int N = (1<<19) , mod = 1e9 +7;


int main()
{
    int n , mn = 1e7 , sol = 0;
    cin>>n ;
    while(n--)
    {
        int t ;
        cin>>t ;
        if(t<mn)
            sol++;
        mn = min(mn , t) ;
    }
    cout<<sol;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const int N = 300006;

int main() { 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    string ans;
    while(n) {
        n--;
        ans.pb((char) ('a' + n % 26));
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << '\n';

    // 0..25
    // 26 in baza 26
    // 10
    // 
    return 0; 
}
 

Measured memory_bytes: 3644
#include <stdio.h>
struct emp{
    int num;
    long long sale;
};
int main(){
    while(1){
        int n,num,count=0,c,flag1=0,flag2=0;
        long long p,q;
        struct emp e[4000];
        scanf("%d",&n);
        if(n==0) return 0;
        for(int i=0;i<n;i++){
            scanf("%d %lld %lld",&num,&p,&q);
            c=count;
            flag1=0;
            for(int j=0;j<count;j++){
                if(e[j].num==num) {
                    e[j].sale+=p*q;
                    flag1=1;
                    break;
                }
            }
            if(!flag1){
                e[count].num=num;
                e[count].sale=p*q;
                count++;
            }
        }
        for (int i=0; i<count; i++){
            if (e[i].sale>=1000000) {
                printf("%d\n",e[i].num);
                flag2=1;
            }
        }
        if(!flag2) printf("NA\n");
    }
}

Measured memory_bytes: 1060
#include <iostream>
#include <algorithm>
#include <cmath>

int main() {
    std::string s, t;
    std::cin >> s >> t;
    
    std::sort(s.begin(), s.end());
    std::sort(t.begin(), t.end(), [](char a, char b){return a > b;});

    std::cout << (s < t ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<string>


using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)

vector<ll> sieve(ll n) {
	vector<ll> res(n, 0);
	for (ll i = 2; i*i < n; ++i) {
		if (res[i] < i) continue;
		for (ll j = i * i; j < n; j += i)
			if (res[j] == j) res[j] = i;
	}
	return res;
}


signed main() {
	ll a, ans = 6;
	rep(i, 2) {
		cin >> a;
		ans -= a;
	}
	cout << ans;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    int R,G;
    cin >> R >> G;
    
    cout << G*2-R << endl;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n, x;
    cin>>n>>x;
    vl ls(n);
    cin>>ls;
    
    ll cur = 0;
    ll cnt = 1;
    rep(i, n) {
        cur += ls[i];
        if (cur > x) break;
        cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256