akhauriyash/Code-Regression huggingface dataset:
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int f(int x,int y,int z){
	return x*x+y*y+z*z+x*y+y*z+z*x;
}
int main(){
	int N;
	scan(N);
	int ans[100000]={};
	rep1(x,100){
		rep1(y,100){
			rep1(z,100){
				int F=f(x,y,z);
				if(F<=N){
					ans[F]++;
				}
			}
		}
	}
	rep1(k,N){
		prin(ans[k]);
	}
	return 0;
}


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

int main() {
 int a,b,c,d;
 cin >> a >> b >> c;
 if(a==b&&a==c&&b==c){
  d = 1;
 }else if (a==b||b==c||a==c)
 {
     d = 2; 
 }else{
     d = 3;
 }
 cout << d << endl;
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>


int main() {
	int n; std::cin >> n;
	std::string s; std::cin >> s;
	int ans = 1;
	for (int i = 0; i < n - 1; i++) {
		ans += s[i] != s[i + 1];
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(){
  int A,B;
  int max=-100000;
  scanf("%d %d",&A,&B);
  if(A+B > max)
    max=(A+B);
  if(A-B > max)
    max=(A-B);
  if(A*B > max)
    max=(A*B);
  printf("%d\n",max);
  return 0;
}
  

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;

#define _GLIBCXX_DEBUG
#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

ll yaku(ll a, ll b){
    if(a>b) return yaku(b,a);
    return b%a ? yaku(b%a,a) : a;
}


vec Sosu;
void Eratosthenes(ll N, vec &ret){
    vector<bool> a(N+1,true);
    a.at(0)=false;
    a.at(1)=false;
    REP(i,2,N+1){
        if(a.at(i)) for(ll k=2*i;k<=N;k+=i) a.at(k)=false;
    }
    rep(i,N+1) if(a.at(i)) ret.pb(i);
    return;
}

void init(ll N){
    ll BIG=N,SMALL=0;
    while(BIG>SMALL+1){
        ll MID=(BIG+SMALL)/2;
        if(MID*MID>=N) BIG=MID;
        else SMALL=MID;
    }
    //cout<<"era"<<N<<' '<<BIG+3<<endl;
    Eratosthenes(BIG+100,Sosu);
}

const ll MAXN=1000010;

bool Toku(vector<bool> & used, ll N){
    if(N==1) return true;
    for(int i=0;Sosu.at(i)*Sosu.at(i)<=N;i++){
        ll k=Sosu.at(i);
        ll count=0;
        while(true){
            if(N%k!=0) break;
            count++;
            N/=k;
        }
        if(count!=0) {
            if(used[k]) return false;
            else used[k]=true;
        }
    }
    if(N==1) return true;
    if(used[N]) return false;
    used[N]=true;
    return true;

}

string Solve(){
    ll N; cin>>N;
    vec d(N); rep(i,N) cin>>d[i];
    ll memo=d[0];
    REP(i,1,N) {
        memo=yaku(d[i],memo);
        if(memo==1) break;
    }
    if(memo>1) return "not coprime";

    init(MAXN);
    //rep(i,Sosu.size()) cout<<Sosu[i]<<endl;
    vector<bool> used(MAXN,false);
    rep(i,N) if(!Toku(used,d[i])) return "setwise coprime";
    return "pairwise coprime";
}

int main(){
    cout<<Solve()<<endl;
}

Measured memory_bytes: 11320
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long int a,b,c,d;
  cin >> a >> b;
  c = a;
  d = b;
  
  int p,q,x;
  
  if (a >= b) {
    while (b > 0) {
      p = b;
      q = a % b;
  	  a = p;
      b = q;
    }
    x = a;
  }
  else {
    while (a > 0) {
      p = a;
      q = b % a;
      b = p;
      a = q;
    }
    x = b;
    
  }
  cout << c * (d / x) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<char> s(n);
	bool y=false;
	for (int i = 0; i < n; i++) {
		cin >> s.at(i);
		if (s.at(i) == 'Y') y = true;
	}
	if (y) {
		cout << "Four" << endl;
	}
	else {
		cout << "Three" << endl;
	}

}

Measured memory_bytes: 3620
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;


 int main()
 {
   int n;
   while(cin>>n)
   {
     int arr[100000+5]={0};
     long long int temp;
     long long int cnt=0; 
     for(int i=0;i<n;i++)
     {
       cin>>temp;
       if(temp>100000) cnt++;
       else arr[temp]++;        
     }           
     for(int i=1;i<100001;i++)
     {
       if(arr[i]<i) cnt=cnt+arr[i];
       else if(arr[i]>i) cnt=cnt+(arr[i]-i);
       else continue;        
     }
     cout<<cnt<<endl;
   }
   return 0;
 }
 


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    rep(i, N, 1000)
    {
        stringstream ss;
        ss << i;
        string s;
        ss >> s;
        if (s[0] == s[1] && s[1] == s[2])
        {
            cout << i << endl;
            return;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
using namespace std;


int main()
{
	int N, T, A;
	cin >> N >> T >> A;

	auto minDiff = 10e6;
	auto result = -1;
	for (auto i = 0; i < N; ++i)
	{
		int H;
		cin >> H;
		auto t = T - H * 0.006;
		auto diff = abs(A - t);
		if (diff < minDiff)
		{
			minDiff = diff;
			result = i;
		}
	}

	cout << result + 1 << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    /*
     * 整数 -> nextInt() (遅い場合は下のni())
     * 単語 -> next()
     * 1行 -> nextLine()
     * 注意 : nextLIneをnext(),nextInt()のあとに呼び出す場合、次が改行だと改行だけ取ってしまうので注意
     */
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long x = sc.nextLong();
        long[] A = new long[(int)N];
        for(int i=0;i<N;i++) A[i] = sc.nextLong();
        Arrays.sort(A);
        for(int i=1;i<N;i++){
            A[i] += A[i-1];
        }
        for(int i=0;i<N;i++){
            if(A[i] == x){
                System.out.println(i+1);
                return;
            }
            if(A[i] > x){
                System.out.println(i);
                return;
            }
        }
        System.out.println(N-1);
    }
}


Measured memory_bytes: 21716
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cstring>
#include <cctype>
using namespace std;

const int maxn = 1000 + 10;
char s[maxn];
int A, B;

bool check()
{
    int len = strlen(s);
    if(len != A + B + 1)
    {
        // printf("*\n");
        return false;
    }
    for(int i = 0; i < A; i++)
    {
        if(!isdigit(s[i]))
        {
            // printf("**\n");
            return false;
        }
    }
    if(s[A] != '-')
    {
        // printf("***\n");
        return false;
    }
    for(int i = 1; i <= B; i++)
    {
        if(!isdigit(s[i + A]))
        {
            // printf("****\n");
            return false;
        }
    }
    return true;
}

int main()
{
    scanf("%d%d%s", &A, &B, s);
    printf("%s\n", check() ? "Yes" : "No");
    return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    ll x, result;
    cin >> x;
    if (x <= 6) {
        result = 1;
    } else if (x <= 11) {
        result = 2;
    } else {
        result = x / 11;
        result *= 2;
        if (x % 11 != 0) {
            if (x % 11 <= 6) {
                result += 1;
            } else {
                result += 2;
            }
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

int v, e;
vector<long long> d(200);
long long a[200][200];

void warshall() {
    for (int k = 0; k < v; ++k) {
        for (int i = 0; i < v; ++i) {
            if(a[i][k] == INT_MAX) continue;
            for (int j = 0; j < v; ++j) {
                if(a[k][j] == INT_MAX) continue;
                a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
            }

        }
    }
}

int main() {
    cin >> v >> e;
    for (int i = 0; i < v; ++i) {
        for (int j = 0; j < v; ++j) {
            if (i == j)
                a[i][j] == 0;
            else
                a[i][j] = INT_MAX;
        }
    }
    for (int k = 0; k < e; ++k) {
        int s,t,dd;
        cin >> s >> t>>dd;
        a[s][t] = dd;
    }
    warshall();

    bool flag = false;
    for (int l = 0; l < v; ++l) {
        if(a[l][l] < 0) flag = true;
    }
    if(flag) {
        cout << "NEGATIVE CYCLE" << endl; return 0;
    }
    for (int m = 0; m < v; ++m) {
        for (int i = 0; i < v; ++i) {
            if(i) cout << " ";
           if(a[m][i] == INT_MAX) cout << "INF" ;
           else
               cout << a[m][i];
        }

        cout << endl;
    }

    return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int a, b;
  cin>>a>>b;
  REP(i, 10000){
    if(i*8/100==a && i/10==b){
      cout<<i<<'\n';
      return 0;
    }
  }
  cout<<-1<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;


int main(){
  int a,b;
  cin >> a >> b;
  if (a+b==15) cout << "+" << endl;
  else if (a*b==15) cout << "*" << endl;
  else cout << "x" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

#define rep(i, n) for (int i=0; i<int(n); i++)
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using ll = long long;


int main() {
	int C[3][3];
	rep(i, 3) {
		rep(j, 3) cin >> C[i][j];
	}
	int cnt = 0;
	for (int j=0; j<3; j++) {
		for (int i=j+1; i<3; i++) {
			if (C[0][j]-C[0][i]==C[1][j]-C[1][i] && C[0][j]-C[0][i]==C[2][j]-C[2][i]) cnt++;
			}
	}
	if (cnt==3) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3536
//    ____       ____                 _           
//   |  _ \ _ __|  _ \  ___ _ __   __| |_ __ ___  
//   | | | | '__| | | |/ _ \ '_ \ / _` | '__/ _ \ 
//   | |_| | |_ | |_| |  __/ | | | (_| | | | (_) |
//   |____/|_(_)|____/ \___|_| |_|\__,_|_|  \___/ 
//                                                

 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;


#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define f first
#define s second
#define pb push_back
#define ll long long

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll LLOO = 1e18+7;
const ll OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 1e5+7;
const double PI = acos(-1);


int main()
{
	
	int r;
	scanf("%d",&r);
	printf("%.2f\n",2*PI*r);
	
    return 0;
}



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

using namespace std;

int main(){
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if(s == u)
    cout << a-1 << " " << b << endl;
  else
    cout << a << " " << b-1 << endl;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

bool prime[1000100];


void mainmain(){
	rep(i,1000100) prime[i]=true;
	rep(i,2) prime[i] = false;
	for(ll i = 2; i * i <= 1000100; i++){
		if(prime[i]){
			for(ll j = i*i; j < 1000100; j+=i){
				prime[j] = false;
			}
		}
	}
	int a,d,n;
	while(cin>>a>>d>>n,a||d||n){
		rep(i,n){
			while(!prime[a]) a+=d;
			a+=d;
		}
		cout << a-d << endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 4116
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
#include<initializer_list>
#include<stack>
using namespace std;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

//隣接リスト
mat G(100010);
//入次数
vec in(100010);
//頂点数,辺数
int N,M;

vec Topological_Sort(){
    vec v;

    //入次数0の頂点集合
    stack<int> st;

    for(int i=1;i<=N;i++)
        if(in[i]==0)st.push(i);
    
    while(st.size()){
        int i=st.top();st.pop();
        v.push_back(i);
        for(auto k:G[i]){
            in[k]--;
            if(in[k]==0)st.push(k);
        }
    }

    return v;
}

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

    int x,y;
    for(int i=0;i<M;i++){
        cin>>x>>y;
        G[x].push_back(y);
        in[y]++;
    }
    
    vec v=Topological_Sort();
    map<int,int> mp;
    for(int i=0;i<N;i++)
        mp[v[i]]=N-i;
    
    int dp[100010],ans=0;
    for(int i=0;i<N;i++){
        dp[i+1]=0;
        for(auto k:G[v[N-1-i]])
            dp[i+1]=max(dp[i+1],dp[mp[k]]+1);
        ans=max(ans,dp[i+1]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11512
import           Control.Monad

main :: IO ()
main = do
    [n, _, c] <- fmap (map read . words) getLine :: IO [Int]
    bs        <- fmap (map read . words) getLine :: IO [Int]
    as        <- replicateM n $ fmap (map read . words) getLine :: IO [[Int]]
    print $ solve c bs as

solve :: Int -> [Int] -> [[Int]] -> Int
solve _ _  []       = 0
solve c bs (a : as) = solve c bs as + judge c bs a

judge :: Int -> [Int] -> [Int] -> Int
judge c bs as = if prod bs as + c > 0 then 1 else 0

prod :: [Int] -> [Int] -> Int
prod []       _        = 0
prod _        []       = 0
prod (b : bs) (a : as) = a * b + prod bs as


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
int N,x,a,b;
long long ans;
int main(){
    cin>>N>>x>>a;
    while(--N){
        cin>>b;
        if(a>x){
            ans+=a-x;
            a=x;
        }
        if(a+b>x){
            ans+=a+b-x;
            b=x-a;
        }
        a=b;
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1e5+5;
const ll INF = 1e18+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX, true);
vector<int> MinDiv(MAX);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
    		MinDiv[i]=i;
        	for (j = i * i; j <= MAX; j += i)
            {
				is_prime[j] = false;
				MinDiv[j]=i;
    		}
    	}
	}
	for(int i=2;i<=MAX;i++) if(is_prime[i]) MinDiv[i]=i;
}
//////////////////Sieve////////////////////

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	string s,t;
	cin>>s>>t;
	int n=s.length();
	int une=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]!=t[i]) une++;
	}
	cout<<une<<endl;
}		

Measured memory_bytes: 4324
#include<iostream>
#include<queue>
#include<deque>
#include<vector>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>
#include<unordered_set>
//~ #include<unordered_map>
#include<stack>
 
#define pi 3.141592653
#define in freopen("entrada","r",stdin);
#define out freopen("myfile.txt","w",stdout);
#define ii pair<int,int> 
#define fast_io cin.tie(0), cin.sync_with_stdio(false);
#define inf 0x3f3f3f3f
#define sup_inf 1e18
#define f first
#define s second
#define eps 1e-9

#define nl ( no << 1)
#define nr ( no << 1)|1
#define mid l+(( r-l)>>1)
 
using namespace std;
typedef long long ll;	
typedef long double ld;
typedef unsigned long long ull;
typedef  pair< long long , pair< int,int> > iii;

const int maxn = 2e5 + 100; 
const int MAX = 1010;
const int mod = 1e9 + 7;
const int MAXLV = 16;
 

using namespace std;

int main () {
	int a, b, c;
  cin >> a >>b >> c;
  cout << ( a + b - 1 )/  b * c << '\n';
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
#define vi vector<ll>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vt vector<tuple<ll, ll, ll>>
using namespace std;
//vector<vector<ll>> vv(110, vector<ll>(50, 0));

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	ll n;
	cin >> n;
	vi v(n);
	REP(i, n) cin >> v[i];
	ll a = v[0], b = accumulate(ALL(v), 0LL) - v[0], ans = abs(a - b);
	FOR(i, 1, n - 1)
	{
		a += v[i]; b -= v[i];
		ans = min(ans, abs(a - b));
	}
	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int num[10]={0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int dp[12525];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, a[10];
	cin>>n>>m;
	REP(i, m){
		cin>>a[i];
	}
	sort(a, a+m);
	FOR(i, 1, n+1){
		dp[i]=-1;
	}
	REP(i, n+1){
		int ma=-1;
		REP(j, m){
			if(i>=num[a[j]]){
				CHMAX(ma, dp[i-num[a[j]]]);
			}
		}
		if(ma>=0){
			dp[i]=ma+1;
		}
	}
	int x=n;
	string ans="";
	while(x>0){
		FORR(i, 0, m){
			if(x>=num[a[i]] && dp[x-num[a[i]]]==dp[x]-1){
				ans+=to_string(a[i]);
				x-=num[a[i]];
				break;
			}
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define Maxn 100010
#define LL long long
const int INF=1000010;

int mymin(int x,int y) {return x<y?x:y;}

struct node
{
	int x,y,next;
}t[Maxn*2];
int len,first[Maxn];

void ins(int x,int y)
{
	t[++len].x=x;t[len].y=y;
	t[len].next=first[x];first[x]=len;
}

int r1,r2,ad;
int sm[Maxn],ss[Maxn],ans,d[Maxn],h[Maxn];
int dfs(int x,int fa,int dep)
{
	sm[x]=1;ss[x]=dep;d[x]=dep;
	if(x==r1||x==r2) sm[x]+=ad,ss[x]+=ad;
	int tt=0;
	for(int i=first[x];i;i=t[i].next) if(t[i].y!=fa)
	{
		int y=t[i].y;
		tt+=dfs(y,x,1-dep);
		sm[x]+=sm[y];ss[x]+=ss[y];
	}
	if(x==r1) tt++;
	if(x==r2) tt--;
	if(tt==-1) h[++h[0]]=ss[x]-(sm[x]-ss[x]);
	else if(tt==1) h[++h[0]]=(sm[x]-ss[x])-ss[x];
	else ans+=abs(ss[x]-(sm[x]-ss[x]));
	// ans+=abs(ss[x]-(sm[x]-ss[x]));
	return tt;
}

int ff[Maxn];
int ffa(int x)
{
	if(ff[x]!=x) ff[x]=ffa(ff[x]);
	return ff[x];
}

int main()
{
	// int T;
	// scanf("%d",&T);
	// while(T--)
	{
		int n,m;r1=r2=0;
		scanf("%d%d",&n,&m);
		len=0;
		memset(first,0,sizeof(first));
		for(int i=1;i<=n;i++) ff[i]=i;
		for(int i=1;i<=m;i++)
		{
			int x,y;
			scanf("%d%d",&x,&y);
			if(ffa(x)!=ffa(y))
			{
				ff[ffa(x)]=ffa(y);
				ins(x,y);ins(y,x);
			}
			else r1=x,r2=y;
		}
		if(m==n-1)
		{
			dfs(1,0,0);
			ans=0;
			for(int i=1;i<=n;i++) ans+=abs(ss[i]-(sm[i]-ss[i]));
			if(sm[1]-ss[1]!=ss[1]) printf("-1\n");
			else printf("%d\n",ans);
		}
		else
		{
			// printf("-2\n");
			ad=0;
			dfs(1,0,0);
			if(d[r1]==d[r2])
			{
				ad=abs(ss[1]-(sm[1]-ss[1]));
				if(ad&1) printf("-1\n");
				else
				{
					ad/=2;
					if(ss[1]>sm[1]-ss[1]) dfs(1,0,1);
					else dfs(1,0,0);
					ans=ad;
					for(int i=1;i<=n;i++) ans+=abs(ss[i]-(sm[i]-ss[i]));
					printf("%d\n",ans);
				}
			}
			else
			{
				h[0]=0;h[++h[0]]=0;
				ans=0;
				dfs(1,0,0);
				if(sm[1]-ss[1]!=ss[1]) printf("-1\n");
				else
				{
					sort(h+1,h+1+h[0]);
					int x=h[h[0]/2+1];
					for(int i=1;i<=h[0];i++) ans+=abs(h[i]-x);
					printf("%d\n",ans);
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 12288
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t A, B;
    std::cin >> A >> B;

    if (A > 8 || B > 8) {
        std::cout << ":(" << std::endl;
    }
    else {
        std::cout << "Yay!" << std::endl;
    }

    return 0;
}


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

namespace Tasks
{
    public class C
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (A, B) = Scanner.Scan<int, int>();
            var c10 = B * 100;
            var answer = -1;
            for (var i = 0; i < 100; i += 10)
            {
                if ((c10 + i) / 125 == A)
                {
                    answer = (c10 + i) / 10;
                    break;
                }
            }

            Console.WriteLine(answer);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 28324
import math

A, B, H, M = list(map(int, input().split()))

theta = abs(6 * M - (60 * H + M) / 2)
if theta > 180:
    theta = 360 - theta
theta = abs(math.radians(theta))
ans = A ** 2 + B ** 2 - 2 * A * B * math.cos(theta)
ans = math.sqrt(ans)
print(ans)


Measured memory_bytes: 9440
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int a,b;
    scanf("%d%d",&a,&b);
    if(a>0) 
	    printf("Positive\n");               
    else 
	    if(b>=0)
		    printf("Zero");            
        else 
		    if((a&1)^(b&1))
			    printf("Positive"); 
            else 
			    printf("Negative");
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <queue>
#define INF 0x3f3f3f3f
#define ll long long
using namespace std;
int a[3000],vis[3000],n,x,mi[2100][2100];
long long solve(int z)
{
    long long ans=(long long)z*x;;
    for(int i=1;i<=n;i++) ans=ans+mi[i][z];
    return ans;
}
int main()
{
    scanf("%d%d",&n,&x);
    long long ans=0;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]),ans+=a[i];
    for(int i=1;i<=n;i++)
    {
        mi[i][0]=a[i];
        int xx=i,xxx=i;
        for(int j=1;j<=n;j++)
        {
            xx--;
            xxx++;
            if(xx==0) xx=n;
            if(xxx==n+1) xxx=1;
            mi[i][j]=min(mi[i][j-1],a[xx]);
            mi[i][j]=min(mi[i][j-1],a[xxx]);
        }
    }
    for(int i=0;i<=n;i++) ans=min(ans,solve(i));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 16640
n = int(input())
cs = list(input())

c = 0
i = 0
j = n - 1

while True:
   while cs[i] != 'W' and i < j:
      i += 1
   while cs[j] != 'R' and i < j:
      j -= 1
   if i < j:
      cs[i], cs[j] = cs[j], cs[i]
      c += 1
   else:
      break

print(c)


Measured memory_bytes: 10764
#include <stdio.h>

int main(void)
{
	int train[100];
	int out_train[100];
	int temp_train;
	int i, j;
	
	i = j = 0;
	
	while (scanf("%d", &temp_train) != EOF){
		if (temp_train != 0){
			train[i] = temp_train;
			i++;
		}
		
		else {
			i--;
			out_train[j] = train[i];
			printf("%d\n", out_train[j]);
			j++;
		}
	}
	
	return (0);
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll x;
  cin >> x;
  
  ll now = 100;
  int ans = 0;
  while (now < x) {
    now *= 1.01;
    ans++;
  }
  
  cout << ans << '\n';
}

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

int main(){
  int a, b;
  int x[10];
  cin >> a >> b;
  if (a < b) {
    for (int i = 0; i < b; i++) {
      x[i] = a;
      cout << x[i];
    }
  } else {
    for (int i = 0; i < a; i++) {
      x[i] = b;
      cout << x[i];
    }
  } cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
using namespace std;

const int mod = 1e9 + 7;
const int maxn = 100000 + 10;

int n;
int a[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);

    int pre = 1, used = 0;
    long long ans = 1;
    for (int i = 2; i <= n; i++) {
        if (a[i] < pre + 2) {
            ans = ans * (i - used) % mod;
            used++; 
        }
        else {
            pre += 2;
        }
    }
    for (int i = n - used; i > 0; i--) ans = ans * i % mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 3.14159265358979323846264

int main()
{
	ios::sync_with_stdio(false); 
	cin.tie(0); 
	cout.tie(0);
	int l,r,d;
	cin>>l>>r>>d;
	int cnt=0;
	int i=1;
	while(1)
	{
		int x=d*i;
		if(x>=l && x<=r)cnt++;
		if(x>r)break;
		i++;
		
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 3580
#include <iostream>
using namespace std;
 
int main() 
{
  int x[10001] = {0};
  int i;
  for(i = 0;i < 10000;i++){
    cin >> x[i];
    if(x[i] == 0){
      break;
    }
  }
  i = 0;
  while(x[i] != 0){
    cout << "Case " << i+1 << ": " << x[i] << endl;
    i++;
  }
  return 0;
}


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


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

int n;

using node = bool[200];
void input(node &d) {
	rep(i, n) {
		char c; cin >> c;
		d[i] = c == '1';
	}
}

node v[200];
bool p[200];

vector<vector<int>> e;

void solve() {
	cin >> n;
	rep(i, n) { input(v[i]); }

	e.resize(n);
	rep(i, n) {
		rep(j, n) {
			if (v[i][j])e[i].push_back(j);
		}
	}

	int ans = 0;
	rep(i, n) {
		int d[200]; rep(j, n) d[j] = 99999;
		queue<int> q;
		q.push(i); d[i] = 1;
		while (!q.empty()) {
			int p = q.front(); q.pop();
			ans = max(ans, d[p]);
			for (int pp : e[p]) {
				if (d[pp] != 99999) {
					if ((d[p] - d[pp]) % 2 == 0) {
						cout << -1 << endl;
						return;
					}
					continue;
				}
				d[pp] = d[p] + 1;
				q.push(pp);
			}
		}
	}

	if (ans == 1) cout << -1 << endl;
	 else cout << ans << endl;
}

int main() {

	solve();

	return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

int data;
stack<int> st;

int main()
{
  while(cin >> data){
    if(data) st.push(data);
    else{
      data = st.top();
      st.pop();
      cout << data << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <algorithm>
#include <utility>
#include <cstring>

using namespace std;

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

int caves[2000][2000];

bool sieve[1000001];
int SX, SY;

typedef pair<int, int> PII;

PII dp[2000][2000];
bool vis[2000][2000];

int main()
{
	int nx, ny;
	fill(sieve, sieve + 1000001, true);
	sieve[0] = sieve[1] = false;
	for(int i = 2; i * i <= 1000000; ++i) {
		if(sieve[i]) {
			for(int j = i * i; j <= 1000000; j += i) {
				sieve[j] = false;
			}
		}
	}
	
	int M, N;
	while (cin>>M>>N, M||N) {
		memset(caves, -1, sizeof(caves));
		
		for (int j=0; j<2000; j++) {
			for (int i=0; i<2000; i++) {
				dp[i][j] = PII(0, -1);
			}
		}
		
		nx = ny = 2000/2;
		int len=1, num=2;
		int d = 0;
		
		caves[nx][ny] = 1;
		
		while (num <= M) {
			for (int j=0; j<len; j++) {
				nx += dx[d];
				ny += dy[d];
				caves[nx][ny] = num++;
				if (num > M) break;
			}
			d++; d %= 4;
			if (num > M) break;
			
			for (int j=0; j<len; j++) {
				nx += dx[d];
				ny += dy[d];
				caves[nx][ny] = num++;
				if (num > M) break;
			}
			
			d++;
			d %= 4;
			len++;
		}
		
		for (int i=0; i<2000; i++) {
			for (int j=0; j<2000; j++) {
				if (caves[j][i] == N) {
					SX = j, SY = i;
					if(sieve[N]) {
						dp[i][j] = PII(1, N);
					}
					else {
						dp[i][j] = PII(0, -1);
					}
				}
			}
		}
		
		#if 0
		for (int i=1000-10; i<1000+10; i++) {
			for (int j=1000-10; j<1000+10; j++) {
				printf("%3d", caves[j][i]);
			}
			printf("\n");
		}
		#endif
		memset(vis, 0, sizeof(vis));
		vis[SY][SX] = true;
		for(int i = 0; i < 2000 - 1; ++i) {
			for(int j = 0; j < 2000; ++j) {
				if(vis[i][j] == false) continue;
				for(int k = -1; k <= 1; ++k) {
					int nx = j + k;
					if(nx < 0 || nx >= 2000) continue;
					int add = dp[i][j].first;
					int maxP = dp[i][j].second;
					if(caves[nx][i + 1] > 0 && sieve[caves[nx][i + 1]]) {
						add++;
						maxP = caves[nx][i + 1];
					}
					dp[i + 1][nx] = max(dp[i + 1][nx], PII(add, maxP));
					vis[i + 1][nx] = true;
				}
			}
		}
		PII ans(-1, -1);
		for(int j = 0; j < 2000; ++j) {
			ans = max(ans, dp[2000 - 1][j]);
		}
		cout << ans.first << ' ' << max(0, ans.second) << endl;
	}	
}

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

int main() {
    int d, n;
    cin >> d >> n;
    if(d==0) {
        if(n==100){ cout << 101 << endl; return 0;}
        cout << n << endl;
    }
    else if(d==1){
        if(n==100){ cout << 10100 << endl; return 0;}
        cout << 100*n << endl;
    }
    else {
        if(n==100) {
             cout << 1010000 << endl; 
             return 0;
        }
        cout << 10000*n << endl;
    }
    return 0;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    uint64_t N, A, B;
    cin >> N >> A >> B;

    uint64_t j = N / (A + B);
    uint64_t m = N % (A + B);
    uint64_t h = 0;
    if (m > 0) {
        if (m >= A) {
            h += A;
        } else {
            h += m;
        }
    }

    uint64_t a_c = (j * A) + h;
    cout << a_c << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char s[4];
  scanf("%s",s);
  if(s[0] == 'S' && s[1] == 'U'){
    printf("7\n");
  }else if(s[0]=='M' && s[1]=='O'){
    printf("6\n");
  }else if(s[0]=='T' && s[1]=='U'){
    printf("5\n");
  }else if(s[0]=='W' && s[1]=='E'){
    printf("4\n");
  }else if(s[0]=='T' && s[1]=='H'){
    printf("3\n");
  }else if(s[0]=='F'){
    printf("2\n");
  }else{
    printf("1\n");
  }
  return 0;
}

Measured memory_bytes: 128
import java.io.BufferedInputStream;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;

public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
        int a=sc.nextInt();
        long all=0;
        for(int i=1;i<=a;i++){
            if(i%3!=0&&i%5!=0)
                all+=i;
        }
        System.out.println(all);


    }
}


Measured memory_bytes: 35780
//start of jonathanirvings' template v3.0.3 (BETA)

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

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}

//end of jonathanirvings' template v3.0.3 (BETA)

int n,k;
int data[100005];
LL sum1[100005],sum2[100005];
LL risan = -INFF;

LL jum1(int a,int b) {return (a <= b ? sum1[b]-sum1[a-1] : 0) ;}
LL jum2(int a,int b) {return (a <= b ? sum2[b]-sum2[a-1] : 0) ;}

int main()
{
  scanf("%d %d",&n,&k);
  REPN(i,n)
  {
    scanf("%d",&data[i]);
    sum1[i] = sum1[i-1] + data[i];
    sum2[i] = sum2[i-1] + (data[i] > 0 ? data[i] : 0);
  }
  REPN(i,n)
  {
    int a = i;
    int b = i + k - 1;
    if (b > n) break;
    LL res1 = jum2(1,a-1) + jum2(b+1,n);
    MAX(risan, res1);
    MAX(risan, res1 + jum1(a,b));
    //debug("%lld %lld\n",res1,jum1(a,b));
  }
  printf("%lld\n",risan);
  return 0;
}










Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
long long  arr[10000005];
int main(){
#define int long long 
	int n;
	cin >> n;
	int ans=1;
	for(int i=2;i<=n;i++){
		if(arr[i])
			continue;
		for(int j=2*i;j<=n;j+=i){
			int me=j;
			int cnt=0;
			while(me%i==0){
				me/=i;
				cnt+=1;
			}
			cnt+=1;
			if(arr[j]==0){
				arr[j]=cnt;
			}
			else
				arr[j]*=cnt;
		}
	}
	for(int i=2;i<=n;i++){
		if(arr[i]){
			ans+=(i*arr[i]);
		}
		else
			ans+=(2*i);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 81760
import numpy as np

H, W, M = map(int, input().split())
h_t = [0]*H
w_t = [0]*W
t = {}
for i in range(M):
    h, w = map(int, input().split())
    t[(h-1, w-1)] = 1
    h_t[h-1]+=1
    w_t[w-1]+=1
h_max = max(h_t)
h_max_list = [i for i in range(len(h_t)) if h_t[i] == h_max]
w_max = max(w_t)
w_max_list = [i for i in range(len(w_t)) if w_t[i] == w_max]

for h in h_max_list:
    for w in w_max_list:
        if (h, w) not in t:
            print(h_max + w_max)
            exit()
print(h_max + w_max - 1)

Measured memory_bytes: 103284
#include <bits/stdc++.h>
using namespace std;
using ll = long long;


int main(int argc, char **argv)
{
	ll bingo[3][3];
	for (ll i = 0; i < 3; ++i)
		for (ll j = 0; j < 3; ++j)
			cin >> bingo[i][j];
	ll N; cin >> N;
	vector<ll> num(N); for (ll i = 0; i < N; ++i) cin >> num[i];
	bool match[3][3];
	memset(match, 0, sizeof(match));

	for (ll i = 0; i < 3; ++i)
		for (ll j = 0; j < 3; ++j)
		{
			ll t = bingo[i][j];
			auto it = find(num.begin(), num.end(), t);
			if (it == num.end()) continue;

			match[i][j] = true;
		}

	string ans = "No";

	for (ll i = 0; i < 3; ++i)
		if (match[i][0] && match[i][1] &&match[i][2]) ans = "Yes";

	for (ll i = 0; i < 3; ++i)
		if (match[0][i] && match[1][i] && match[2][i]) ans = "Yes";

	if (match[0][0] && match[1][1] && match[2][2])  ans = "Yes";
	if (match[0][2] && match[1][1] && match[2][0]) ans = "Yes";

	std::cout << ans << std::endl;
}


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

int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>> a(h, vector<char>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a.at(i).at(j);
        }
    }

    for(int i=h-1;i>=0;i--){
        int count = 0;
        for(int j=0;j<w;j++){
            if(a.at(i).at(j) != '.'){
                break;
            }
            count++;
        }
        if(count == w){
            a.erase(a.begin() + i);
        }
    }

    h = a.size();
    for(int i=w-1;i>=0;i--){
        int count = 0;
        for(int j=0;j<h;j++){
            if(a.at(j).at(i) != '.'){
                break;
            }
            count++;
        }
        if(count == h){
            for(int j=0;j<h;j++){
                a.at(j).erase(a.at(j).begin() + i);
            }
        }
    }

    w = a.at(0).size();
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<a.at(i).at(j);
        }
        cout<<endl;
    }
}

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

int results[10005];

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

    for (int i = 1; i <= n; ++i) {
        if (i*i + 2 + 2*i + 1 > n)
            break;
        for (int j = 1; j <= n; ++j) {
            if (i*i + j*j + 1 + i + j + i*j > n)
                break;
            for (int k = 1; k <= n; ++k) {
                if (i*i + j*j + k*k +i*j + i*k + j*k > n)
                    break;
                ++results[i*i + j*j + k*k +i*j + i*k + j*k];
            }
        }
    }

    for (int i = 1; i <= n; ++i)
        cout << results[i] << "\n";
    return 0;
}


Measured memory_bytes: 3584
import java.util.Scanner;


public class Main{
    public  static void main(String[] args) {
    	try (Scanner sc = new Scanner(System.in)) {
    		int N=sc.nextInt();
    		int[] a=new int[N+1];
    		int A=0,B=0;
    		for(int i=1; i<=N; i++) {
    			a[i]=sc.nextInt();
    		}
    		for(int i=1; i<=N; i++) {
    			for(int j=i+1; j<=N; j++) {
    				if(a[i]<a[j]) {
    					int num=a[j];
    					a[j]=a[i];
    					a[i]=num;
    				}
    			}
    		}//昇順に並び替える
    		for(int i=1; i<=N; i++) {
    			if(i%2==1) {
    				A+=a[i];
    			}
    			else {
    				B+=a[i];
    			}
    		}
    		System.out.println(Math.abs(A-B));
    	}
    }
}

Measured memory_bytes: 24020