akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n , a[N];
int main() {
    scanf("%d" , &n);
    for (int i = 0 ; i < n ; ++ i) {
        scanf("%d" , &a[i]);
    }
    int res = 1;
    int i = 0;
    bool f = 1 , g = 1;
    while (i + 1 < n) {
        f &= (a[i] <= a[i + 1]);
        g &= (a[i] >= a[i + 1]);
        if (f || g) {
            ++ i;
        } else {
            ++ res;
            ++ i;
            f = g = 1;
        }
    }
    cout << res << endl;
}


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

int main () {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  sort(A.begin(), A.end(), greater<ll>());
  
  ll pattern = N*(N-1)*(N-2)/6;
  for (ll i = 0; i < N-2; i++) {
    for (ll j = i+1; j < N-1; j++) {
      for (ll k = j+1; k < N; k++) {
        if (A[i]>=A[j]+A[k]) {
          pattern -= N-k;
          break;
        }
      }
    }
  }
  cout << pattern << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TypicalStairs solver = new TypicalStairs();
        solver.solve(1, in, out);
        out.close();
    }

    static class TypicalStairs {
        public static int MOD = 1_000_000_007;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            int[] stairs = new int[n + 1];
            long[] route = new long[n + 1];

            for (int i = 1; i <= m; i++) {
                int step = in.nextInt();
                stairs[step] = 1;
            }

            route[0] = 1;
            if (stairs[1] == 0) {
                route[1] = 1;
            }

            for (int i = 2; i <= n; i++) {
                if (stairs[i - 1] == 0) {
                    route[i] = route[i] + route[i - 1];
                }
                if (stairs[i - 2] == 0) {
                    route[i] = route[i] + route[i - 2];
                }
                route[i] %= MOD;
            }

            out.print(route[n]);

        }

    }
}



Measured memory_bytes: 61092
#include <iostream>
#include <string>

using namespace std;

int main(){
	string S;
	cin >> S;
	int ss = S.size(), i=0, n=0,w=0,s=0,e=0;

	while (i < ss) {
		if (S[i] == 'N')n=1;
		if (S[i] == 'W')w=1;
		if (S[i] == 'S')s=1;
		if (S[i] == 'E')e=1;
		++i;
	}
	if(n-s == 0 && w-e == 0)	cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        Arrays.sort(nums);
        int aliceSum = 0;
        int bobSum = 0;
        boolean isAliceTurn = true;
        for (int i = nums.length - 1; i >= 0; i--) {
            if (isAliceTurn) {
                aliceSum += nums[i];
                isAliceTurn = false;
            } else {
                bobSum += nums[i];
                isAliceTurn = true;
            }
        }
        System.out.println(aliceSum - bobSum);
    }
}

Measured memory_bytes: 21844
package main
import (
  "fmt"
)
func main() {
  var n int
  fmt.Scan(&n)
  as := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&as[i])
  }
  min := 1000000000
  max := 1
  for _, a := range as {
    if a < min {
      min = a
    }
    if max < a {
      max = a
    }
  }
  result := max - min
  fmt.Println(result)
  
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long int n,k;;
	cin>>n>>k;
	long long int a[(int)1e5+100];
	memset(a,0,sizeof a);
	for(int i=0;i<n;++i){
     long long int x,y;
     cin>>x>>y;
     a[x]=a[x]+y;
	}
	long long int sum=0;
	for(int i=1;i<=(int)1e5+100;++i){
		if(a[i]==0)continue;
		else{
			sum+=a[i];
			if(sum>=k){
				cout<<i;
				return 0;
			}

		}
	}
	return 0;

}

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <functional>

using namespace std;

int main(){
    int height[10];
    for(int i = 0; i < 10; i++){
        scanf("%d", &height[i]);
    }

    sort(height, height + 10, greater<int>());

    printf("%d\n%d\n%d\n", height[0], height[1], height[2]);
    return 0;

}

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


#define LL long long int
using namespace std;


int main(void)
{
	int i, j;
	string s, t;
	cin >> s >> t;

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

	if (s < t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
using namespace std;
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  ll h[n];
  REP(i,n) cin >> h[i];
  ll cost[n];
  cost[0] = 0;
  cost[1] = abs(h[1]-h[0]);
  for(ll i = 2; i < n; i++){
    cost[i] = min(cost[i-2]+abs(h[i]-h[i-2]),cost[i-1]+abs(h[i]-h[i-1]));
  }
  cout << cost[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1792
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;


int main(){	
	fastio;
	string s;cin>>s;
	set<char>ss;
	ss.insert('A');
	ss.insert('T');
	ss.insert('C');
	ss.insert('G');
	int ans=0;
	int mx=0;
	FER(i,0,sz(s)){
		if(ss.count(s[i]))ans++;
		else ans=0;
		mx=max(mx,ans);
	}
	cout<<mx<<endl;
	
	
	return 0;
}


Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 111;
const int M = 11;

int n;
int k;
int v[N];
int mem[N][N][N];

int go(int l , int r , int stp){
    if(stp < 0)
        return -1e9;
    if(l > r || stp == 0)
        return 0;
    if(~mem[l][r][stp])
        return mem[l][r][stp];
    int ret = 0;
    int c1 , c2 , c3 , c4;
    c1 = go(l + 1 , r , stp - 1) + v[l];
    c2 = go(l , r - 1 , stp - 1) + v[r];
    c3 = go(l + 1 , r , stp - 2);
    c4 = go(l , r - 1 , stp - 2);
    return mem[l][r][stp] = max(0 , max(max(c1 , c2) , max(c3 , c4)));
}

int main(){
    scanf("%d%d" , &n , &k);
    for(int i = 1; i <= n; i++){
        scanf("%d" , &v[i]);
    }
    memset(mem , -1 , sizeof mem);
    printf("%d\n" , max(go(1 , n , k) , 0));
}


Measured memory_bytes: 5632
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;


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

	int x,a,b;
	cin >> x >> a >> b;
	if (abs(x-a) > abs(x-b))
		puts("B");
	else
		puts("A");
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
typedef long long LL;

int n, k, p[5001];
LL c[5001], ans;

LL getmax(LL a, LL b) {return a>b?a:b;}

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1 ; i <= n ; i++) scanf("%d", &p[i]);
    for (int i = 1 ; i <= n ; i++) scanf("%lld", &c[i]);
    ans = c[1];
    for (int i = 1 ; i <= n ; i++) {
        int cur = i, len = 0;
        bool f = false;
        LL tot = 0, sum = 0;
        for (int j = 1 ; j <= k ; j++) {
            cur = p[cur];
            tot += c[cur];
            if (cur == i) {
                if (f) break;
                f = true, sum = tot, len = j;
            }
            ans = getmax(tot, ans);
            if (f) ans = getmax(ans, tot + (k - j) / len * sum);
        }
    }
    printf("%lld", ans);
}


Measured memory_bytes: 1784
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>
#include <set>
#include <numeric>

using namespace std;


template <typename T>
using TABLE = vector<vector<T>>;

long long PRIME = 1e9 + 7;
long long PRIME2 = 998244353;


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

    vector<long long> mod_count(2019, 0);
    ++mod_count[0];

    long long factor = 10;
    long long prev = S.back() - '0';
    ++mod_count[prev];

    for(int i = S.size() - 2; i >= 0; --i){
        long long next = (S[i] - '0') * factor;
        next %= 2019;
        next = (next + prev) % 2019;
        ++mod_count[next];

        factor = (factor * 10) % 2019;
        prev = next;
    }

    long long sum = 0;
    for(int i = 0; i < 2019; ++i){
        sum += (mod_count[i] * (mod_count[i] - 1)) / 2;
    }
    cout << sum;

}


Measured memory_bytes: 3756
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int N, M, Q;
vector<int> endp[501];
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);

    cin>>N>>M>>Q;
    for(int m = 0; m < M; m++) {
        int l, r;cin>>l>>r;
        endp[l].push_back(r);
    }
    for(int i = 1; i <= N; i++) sort(endp[i].begin(), endp[i].end());
    for(int qi = 0; qi < Q; qi++) {
        int p, q, cnt = 0;cin>>p>>q;
        for(int i = p; i <= q; i++) {
            cnt += upper_bound(endp[i].begin(), endp[i].end(), q) - endp[i].begin();
        }
        cout<<cnt<<'\n';
    }

    return 0;
}

Measured memory_bytes: 2176
a,b = gets.chomp.split.map(&:to_i)
s = gets.chomp
for i in 0...s.length
    if i == a
        if s[i] != "-"
            print("No")
            exit()
        end
    else
        if ! (s[i] =~ /^[0-9]+$/)
            print("No")
            exit()
        end
    end
end
print("Yes")

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

ll n;
ll ans;

void dfs(ll x, ll a, ll b, ll c){
	if(x > n) return;
	if(a&&b&&c) ans++;
	dfs(x*10+3, 1, b, c);
	dfs(x*10+5, a, 1, c);
	dfs(x*10+7, a, b, 1);
}



int main(){
	cin >> n;
	dfs(0, 0, 0, 0);
	cout << ans << endl;
}

Measured memory_bytes: 764
#include <stdio.h>

int main() {
    unsigned long a, b, c, ans = 0;

    scanf("%lu%lu%lu", &a, &b, &c);

    if (a+b < c) {
        ans = a + b + b + 1;
    } else {
        ans = b + c;
    }

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

    return 0;
}

Measured memory_bytes: 128
#import<iostream>
#import<algorithm>
long long i,j,n,x,m=1000000007,s[200],d[1<<17];
main(){std::cin>>n>>x;for(i=0;i<n;++i)std::cin>>s[i];std::sort(s,s+n);for(i=0;i++<x;)d[i]=i;for(i=0;i<n;++i)for(j=x;j;--j)d[j]=(d[j]*i+d[j%s[i]])%m;std::cout<<d[x];}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            int[] sInt = s.ToCharArray().Select(e => (int)e).OrderBy(e => e).ToArray();
            int[] tInt = t.ToCharArray().Select(e => (int)e).OrderByDescending(e => e).ToArray();
            string res = string.Empty;
            int length = s.Length > t.Length ? t.Length : s.Length;
            for (int i = 0; i < length; i++)
            {
                if (sInt[i] == tInt[i])
                {
                    continue;
                }
                else if (sInt[i] > tInt[i])
                {
                    res = "No";
                    break;
                }
                else if (sInt[i] < tInt[i])
                {
                    res = "Yes";
                    break;
                }
            }

            if (string.IsNullOrEmpty(res))
            {
                res = s.Length >= t.Length ? "No" : "Yes";
            }

            Console.WriteLine(res);
        }
    }
}


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

using namespace std;
typedef long long ll;

int main() {
    ll n, d;
    cin >> n >> d;
    vector<ll> x(n), y(n);
    int cnt = 0;
    for (ll i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        if (x[i] * x[i] + y[i] * y[i] <= d * d) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 6428
#include <iostream>
#include <cstring>
#include <vector>
#include <string>
using namespace std;

int w, h;
int cnt;
char cur;
vector<string> F;

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

bool finish() {
    for (int i = 0; i < w; i++) {
        if (F[0][i] == '&') return true;
        if (F[h-1][i] == '&') return true;
    }
    for (int i = 0; i < h; i++) {
        if (F[i][0] == '&') return true;
        if (F[i][w-1] == '&') return true;
    }
    return false;
}

#define MAX 100
bool used[MAX][MAX];
void dfs(int y, int x) {
    used[y][x] = true;
    F[y][x] = '&';
    for (int i = 0; i < 4; i++) {
        int ny = y + dy[i];
        int nx = x + dx[i];
        if (0 <= nx && nx < w && 0 <= ny && ny < h && !used[ny][nx] && (F[ny][nx] == cur || F[ny][nx] == '&')) {
            dfs(ny, nx);
        }
    }
}

int main() {
    while (cin >> w >> h, w || h) {
        F.clear(); F.resize(h);
        for (int i = 0; i < h; i++) {
            cin >> F[i];
        }
        int y, x; // &の位置
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (F[i][j] == '&') {
                    y = i;
                    x = j;
                }
            }
        }
        cnt = 0;
        cur = '.';
        while (!finish()) {
            memset(used, 0, sizeof(used));
            dfs(y, x);
            if (cur == '#') {
                cur = '.';
                cnt++;
            } else cur = '#';
        }
        cout << cnt << endl;
    }
    return 0;
}

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

int cost(int height[],int size)
{
	int arr[size]={0};
	for(int i=0;i<size;i++)
	{
		if(i!=0)
		{
			if(i==1)
				arr[i]=abs(height[1]-height[0]);
			else arr[i]=min(abs(height[i]-height[i-1])+arr[i-1],abs(height[i]-height[i-2])+arr[i-2]);
		}
	}
	return arr[size-1];
}
int main()
{
	int size;
	cin>>size;
	int height[size];
	for(int i=0;i<size;i++)
		cin>>height[i];
	int dp[size]={0};
	int answer=cost(height,size);
	cout<<answer<<endl;

}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
int main()
{

	std::string str;
    std::cin >> str;
	if (str[0] == '7' || str[1] == '7' || str[2] == '7') {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}

	return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

int N,M;
string S;

int dist[111111];
signed main(){
    cin>>N>>M>>S;
    vint lis;
    memset(dist,-1,sizeof(dist));
    dist[N]=0;
    rep(i,N+1)if(S[i]=='0')lis.pb(i);
    for(int i=N-1;i>=0;i--){
        if(S[i]=='1')continue;
        int k=lower_bound(all(lis),i+M+1)-lis.begin()-1;
        k=lis[k];
        if(k==i){
            cout<<-1<<endl;
            return 0;
        }
        dist[i]=dist[k]+1;
    }


    vint ans;
    int p=0;
    while(p<N){
        int q=p;
        while(dist[q]!=dist[p]-1){
            q++;
        }
        ans.pb(q-p);
        p=q;
    }

    rep(i,ans.size()){
        if(i)cout<<" ";
        cout<<ans[i];
    }cout<<endl;
    return 0;
}

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

struct TNode
{
	int Id;
	TNode* Parent;
	TNode* LChild;
	TNode* RChild;
};

struct TTree
{
	TNode* Root;
};

void Insert(TTree& Tree, TNode* z)
{
    assert(z != NULL);
	TNode* y = NULL;
	TNode* x = Tree.Root;
	while(x != NULL){
		y = x;
		if(z->Id < x->Id){
			x = x->LChild;
		}else{
			x = x->RChild;
		}
	}
	z->Parent = y;
	if(y == NULL){
		Tree.Root = z;
	}else if(z->Id < y->Id){
		y->LChild = z;
	}else{
		y->RChild = z;
	}
}

void InorderOutput(const TNode* Node)
{
	if(Node == NULL) return;
	InorderOutput(Node->LChild);
	cout << ' ' << Node->Id;
	InorderOutput(Node->RChild);
}

void PreorderOutput(const TNode* Node)
{
    if(Node == NULL) return;
    cout << ' ' << Node->Id;
    PreorderOutput(Node->LChild);
    PreorderOutput(Node->RChild);
}

void Print(const TTree& Tree)
{
	InorderOutput(Tree.Root);
	cout << endl;
	PreorderOutput(Tree.Root);
	cout << endl;
}

void Delete(const TNode* Node)
{
    if(Node == NULL) return;
    Delete(Node->LChild);
    Delete(Node->RChild);
    delete Node;
}

int main()
{
	int n;
	cin >> n;
	TTree Tree;
	Tree.Root = NULL;
	for(int i = 0; i < n; i++){
		string Command;
		cin >> Command;
		if(Command == "insert"){
			int Id;
			cin >> Id;
			TNode* Node;
			Node = new TNode;
			*Node = {Id, NULL, NULL, NULL};
			//?????¨??????TNode* Node = {Id, NULL, NULL, NULL};??¨????????¨??¨??????
			Insert(Tree, Node);
		}else{
			Print(Tree);
		}
	}
	Delete(Tree.Root);
    return 0;
}

Measured memory_bytes: 26536
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 120000;
int x[N], y[N], cnt1[5000], cnt2[5000], s1[5000], s2[5000];
char c[N];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++){
        cin >> x[i] >> y[i];
        cin >> c[i];
        x[i] %= (k + k);
        y[i] %= (k + k);
        y[i]++;
    }
    int ans = 0;
    for (int i = 0; i <= k; i++){
        memset(cnt1, 0, sizeof(cnt1));
        memset(cnt2, 0, sizeof(cnt2));
        for (int j = 1; j <= n; j++){
            if (x[j] >= i && x[j] < i + k){
                if (c[j] == 'B') cnt1[y[j]]++; else cnt2[y[j]]++;
            } else{
                if (c[j] == 'B') cnt2[y[j]]++; else cnt1[y[j]]++;
            }
        }
        for (int j = 1; j <= k + k; j++){
            s1[j] = s1[j - 1] + cnt1[j];
            s2[j] = s2[j - 1] + cnt2[j];
        }
        int res = 0;
        for (int j = 1; j <= k + 1; j++){
            int l = j;
            int r = l + k - 1;
            int ress = s1[r] - s1[l - 1] + s2[k + k] - s2[r] + s2[l - 1];
            res = max(res, max(ress, n - ress));
        }
        res = max(res, n - res);
        ans = max(ans, res);
    }
    cout << ans;
}


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

signed main() {
  ios::sync_with_stdio(false);

  int64_t N;
  cin >> N;

  set<int64_t> bag;
  for (int i = 1; 1LL * i * i <= 4 * N; ++i) {
    {
      int64_t m = i - 1;
      if (m != 0 && N / m == N % m) bag.insert(m);
    }
    {
      int64_t m = N / i - 1;
      if (m != 0 && N / m == N % m) bag.insert(m);
    }
  }

  int64_t ans = 0;
  for (auto u : bag) ans += u;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<numeric>
#include<cmath>

using namespace std;

int main()
{
	int n; cin >> n;
	string s;
	vector<string> str;
	for (int i = 0; i < n; ++i)
	{
		cin >> s;
		str.push_back(s);
	}
	int s1 = 0, s2 = 0, s3 = 0, s4 = 0;
	for (int i = 0; i < n; ++i)
	{
		if (str[i] == "AC")
		{
			++s1;
		}
		else if (str[i] == "WA")
		{
			++s2;
		}
		else if (str[i] == "TLE")
		{
			++s3;
		}
		else if (str[i] == "RE")
		{
			++s4;
		}
	}
	cout << "AC x " << s1 << endl;
	cout << "WA x " << s2 << endl;
	cout << "TLE x " << s3 << endl;
	cout << "RE x " << s4 << endl;


	return 0;
}


Measured memory_bytes: 7460
#include<iostream>

using namespace std;

int main(){

    int x,a,b;

    cin >> x;
    cin >> a;
    cin >> b;

    if(a >= b)
        cout << "delicious" << endl;
    else if(b-a < x+1)
        cout << "safe" << endl;
    else 
        cout << "dangerous" << endl;    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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;
}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int X, Y, Z, k; cin >> X >> Y >> Z >> k;
    vector<ll> alis(X), blis(Y), clis(Z);
    REP(i, 0, X){cin >> alis[i];}
    REP(i, 0, Y){cin >> blis[i];}
    REP(i, 0, Z){cin >> clis[i];}
    sort(ALL(alis), greater<>());
    sort(ALL(blis), greater<>());
    sort(ALL(clis), greater<>());
    map<ll, ll> mp;
    mp[0] = 1;
    priority_queue<Pll> pq;
    int count = 0;
    pq.push(Pll(alis[0]+blis[0]+clis[0], 0));
    while(count != k){
        count++;
        Pll k = pq.top();
        //cout << k.second << endl;
        pq.pop();
        cout << k.first << endl;
        ll z = k.second;
        ll a = z / 1e10;
        z -= a * 1e10;
        ll b = z / 1e5;
        z -= b * 1e5;
        ll c = z;
        ll aa = (a + 1) * 1e10 + b * 1e5 + c;
        if(a+1 < Z && mp[aa] == 0){
            //cout << aa << endl;
            ll aasum = alis[a+1] + blis[b] + clis[c];
            mp[aa]++;
            pq.push(Pll(aasum, aa));
        }
        ll bb = a * 1e10 + (b+1) * 1e5 + c;
        if(b+1 < Y && mp[bb] == 0){
            //cout << bb << endl;
            ll bbsum = alis[a] + blis[b+1] + clis[c];
            mp[bb]++;
            pq.push(Pll(bbsum, bb));
        }
        ll cc = a * 1e10 + b * 1e5 + (c+1);
        if(c+1 < Z && mp[cc] == 0){
            //cout << cc << endl;
            ll ccsum = alis[a] + blis[b] + clis[c+1];
            mp[cc]++;
            pq.push(Pll(ccsum, cc));
        }
    }
}

Measured memory_bytes: 4184
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        long[] A = in.nl(n);
        long ans = 0, count = 0;
        boolean flag = false;
        for(long a: A){
            if(a==0){
                ans += count/2;
                count = 0;
            }else{
                count += a;
            }
        }
        ans += count/2;
        out.println(ans);
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 36252
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>H>>W;
    mat a(H,vec(W));
    rep(i,H) rep(j,W) cin>>a[i][j];
    mat ans(0);
    rep(i,H){
        rep(j,W){
            if((i == H - 1) && (j == W - 1)) break;
            ll id = (i&1) ? W - 1 - j : j;
            if(a[i][id]&1) {
                vec temp(4);
                temp[0] = i + 1;
                temp[1] = id + 1;
                temp[2] = (j == W - 1) ? i + 2 : i + 1;
                temp[3] = (i&1) ? max(1LL, id) : min(W, id + 2);
                ans.push_back(temp);
                ++a[temp[2] - 1][temp[3] - 1];
            }
        }
    }
    cout<<ans.size()<<endl;
    for(vec ANS : ans){
        rep(j,3) cout<<ANS[j]<<' ';
        cout<<ANS[3]<<endl;
    }
}


Measured memory_bytes: 12848
using System;

namespace OJcsharp
{
    class Program
    {
        static void swap<T>(ref T x, ref T y)
        {
            T t;
            t = x;
            x = y;
            y = t;
        }
        static void Main(string[] args)
        {
            long[] x = new long[100000];
            long[] y = new long[100000];
            long count = 0;
            do
            {
                string[] str = Console.ReadLine().Split(' ');
                x[count] = long.Parse(str[0]);
                y[count] = long.Parse(str[1]);
                if (x[count] == 0 && y[count] == 0)
                    break;
                if (x[count] > y[count])
                {
                    swap(ref x[count], ref y[count]);
                }
                count++;
            } while (true);
            for (int n = 0; n < count; n++)
            {
                Console.WriteLine(x[n] + " " + y[n]);
            }
        }
    }
}

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

int main() {
  for(int n; cin >> n && n; ) {
    vector<int> s(n);
    for(int i = 0; i < n; ++i) cin >> s[i];
    sort(s.begin(), s.end());
    cout << accumulate(s.begin()+1, s.end()-1, 0) / (n-2) << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> as(n); cin >> as;
    ll a = as[0], b = as[1], c = 0;
    for(int i = 2; i < n; i++){
        c ^= as[i];
    }
    printde(as);
    printde(a, b, c);
    ll ans = 0;
    for(int i = 60; i >= 0; i--){
        bool ab = a >> i & 1, bb = b >> i & 1, cb = c >> i & 1;
        ll mask = (1ll << (i + 1)) - 1;
        if((ab ^ bb) == cb){
            continue;
        }
        if(cb){
            if(!ab & !bb){
                ll num = (1ll << i) - (b & mask);
                if(a < num){
                    cout << -1 << '\n';
                    return 0;
                }
                a -= num;
                b += num;
                ans += num;
            }else{
                ll num = (a & mask) - (1ll << i) + 1;
                a -= num;
                b += num;
                ans += num;
                if((b >> i & 1) == 0){
                    cout << -1 << '\n';
                    return 0;
                }
            }
        }else{
            if(ab){
                ll num = min((1ll << i) - (b & mask), (a & mask) - (1ll << i) + 1);
                if(a < num){
                    cout << -1 << '\n';
                    return 0;
                }
                a -= num;
                b += num;
                ans += num;
            }else if(bb){
                ll num = (1ll << i) - (b & (1ll << i) - 1);
                if(a < num){
                    cout << -1 << '\n';
                    return 0;
                }
                a -= num;
                b += num;
                ans += num;
                i++;
                // cout << -1 << '\n';
                // return 0;
            }
        }
    }
    if(a == 0 || (a ^ b) != c){
        cout << -1 << '\n';
        return 0;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3164
#include <iostream>
#include <math.h>
using namespace std;
int main(){
	int l,a,b,c,d,mday,jday,ans;
	cin>>l>>a>>b>>c>>d;
	if(a%c==0)jday=a/c;
	else jday=(a/c)+1;
	if(b%d==0)mday=b/d;
	else mday=(b/d)+1;
	//cout<<jday<<" "<<mday<<endl;
	ans=max(jday,mday);
	//cout<<ans<<endl;
	cout<<l-ans<<endl;
}

Measured memory_bytes: 1164
A,B,C,D=map(int,input().split())
if A <= C and C <= B and B <= D:
  print(B-C)
elif C <= A and A <= B and B <= D:
  print(B-A)
elif A <= B and B <= C and C <= D:
  print(0)
elif C <= A and A <= D and D <= B:
  print(D-A)
elif A <= C and C <= D and D <= B:
  print(D-C)
elif C <= D and D <= A and A <= B:
  print(0)

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

using namespace std;
typedef long long ll;

inline int at(ll x, int k){ return (x >> k) & 1; }
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)

int main(){
  int x[5];
  rep(i,0,5){
    cin >> x[i];
    if(x[i]==0){
      cout << i+1 << endl;
      break;
    }
  }
}


Measured memory_bytes: 3592
import static java.lang.Math.*;
import static java.util.Arrays.*;

import java.util.*;
import java.io.*;
import java.math.BigInteger;

import static java.math.BigInteger.*;

public class Main {
	void solve() {
		char[] s = sc.next().toCharArray();
		
		int[] cnt = new int[4];
		for (char c : s) {
			cnt["NWSE".indexOf(c)]++;
		}
		
		boolean ans = true;
		if (cnt[0] == 0 && cnt[2] > 0) ans = false;
		if (cnt[0] > 0 && cnt[2] == 0) ans = false;
		if (cnt[1] == 0 && cnt[3] > 0) ans = false;
		if (cnt[1] > 0 && cnt[3] == 0) ans = false;
		out.println(ans ? "Yes":"No");
	}

	static void tr(Object... os) { System.err.println(deepToString(os)); }

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

Measured memory_bytes: 8020
n = int(input())
p = list(map(int, input().split()))
answer = 0
for i in range(1, n - 1):
    tmp = [p[i-1], p[i], p[i+1]]
    if len(set(tmp)) != 3:
        break
    if sorted(tmp)[1] == p[i]:
        answer += 1
print(answer)


Measured memory_bytes: 3060
a,b,c,d=[i[::-1] for i in ['dream','dreamer','erase','eraser']]
s,j=input()[::-1],True
while j:
  j=False
  for i in [a,b,c,d]:
    if s.startswith(i): s=s[len(i):];j=True
print('YNEOS'[len(s)>0::2])

Measured memory_bytes: 9236
using System;

namespace CompetitiveProgramming
{
    class Program
    {
        static void Main(string[] args)
        {
            int ab, bc;

            string[] str = Console.ReadLine().Split(' ');
            ab = int.Parse(str[0]);
            bc = int.Parse(str[1]);
            Console.WriteLine(ab*bc/2);
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
vector<vector<ll>> g;
vector<ll> sum;
vector<bool> seen;

void dfs(int x, int c){
  if(seen[x]) return;
  seen[x] = true;
  for(auto nv: g[x]){
    if(c==nv) continue;
    sum.at(nv) += sum.at(x);
    dfs(nv, x);
  }
}

int main(){
  int n, q; cin >> n >> q;
  g.resize(n);
  for(int i=0; i<n-1; i++){
    int a, b; cin >> a >> b;
    a--;  b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  sum.assign(n, 0);
  seen.assign(n, false);
  for(int i=0; i<q; i++){
    int x, y;  cin >> x >> y;
    sum.at(x-1) += y;
  }
  dfs(0, -1);
  for(auto x: sum) cout << x << ' ';
}


Measured memory_bytes: 27392
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int x, t;
	cin >> x >> t;

	cout << max(0LL,x-t) << "\n";

}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String ars[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        int n=Integer.parseInt(br.readLine());
        String str[]=br.readLine().split(" ");
        int arr[]=new int[n];
        HashMap<Integer,Integer> hmap=new HashMap<>();
        long sum=0;
        for(int i=0;i<n;i++)
        {
            arr[i]=Integer.parseInt(str[i]);
            hmap.put(arr[i],hmap.getOrDefault(arr[i],0)+1);
            sum=sum+arr[i];
        }
        int q=Integer.parseInt(br.readLine());
        for(int i=0;i<q;i++)
        {
            str=br.readLine().split(" ");
            int b=Integer.parseInt(str[0]);
            int c=Integer.parseInt(str[1]);
            if(hmap.containsKey(b))
            {
                int freq=hmap.get(b);
                sum+=freq*(c-b);
                hmap.remove(b);
                if(hmap.containsKey(c))
                hmap.put(c,hmap.get(c)+freq);
                else
                hmap.put(c,freq);
            }
            pw.println(sum);
        }
        pw.flush();
        pw.close();
    }
}

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

int main (void){
	int a,b,c;
	cin >> a >> b >> c;
	if(a>=b&&a>=c) cout << (b*c)/2 << endl;
	else if(b>=a&&b>=c) cout << (a*c)/2 << endl;
	else if(c>=b&&c>=a) cout << (a*b)/2 << endl;
	return 0;
}

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

int main() {
    int a[4];
    int mem[4];
    string S;
    cin >> S;
    for(int i=0;i<4;i++){
        a[i] = S[i] - '0';
    }

    for(int bit = 0; bit<(1<<3); bit++){
        int sums = a[0];
        mem[0] = 0;
        mem[1] = 0;
        mem[2] = 0;
        for(int i=0;i<3;i++){
            if(1 & (bit>>i)){
                mem[3-(i+1)] = 1;
                sums -= a[3-i];
            }else{
                sums += a[3-i];
            }
        }
        if(sums == 7){
            cout << a[0];
            for(int i=0;i<3;i++){
                if(mem[i] == 1){
                    cout << "-" << a[i+1];
                }else{
                    cout << "+" << a[i+1];
                }
            }
            cout << "=7" << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int n,m,ans;
    cin >> n >> m;
    vector<int> l(m), r(m);
    //int l[m], r[m];

    for(int i=0;i<m;i++) cin >> l[i] >> r[i];
    
    sort(l.begin(), l.end());
    sort(r.begin(), r.end());
    
    ans = max(0, r[0]-l[m-1]+1);
    cout << ans << endl;
   
    return 0;
}

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

int main() {
  ll K,N,d=0,dl=0;
  cin >> K >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  dl=K-A[N-1]+A[0];
  rep(i,N-1) {
    d=A[i+1]-A[i];
    if(d>dl)dl=d;
  }
  cout << K-dl << endl;
  return 0;
}

Measured memory_bytes: 4840
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64_t INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  
  vector<int64> a(n + 1), b(n);

  rep(i, n + 1) cin >> a[i];
  rep(i, n) cin >> b[i];

  int64 ans = 0;

  rep(i, n) {
    if (b[i] < a[i]) {
      ans += b[i];
    } else if (b[i] < a[i] + a[i + 1]) {
      ans += b[i];
      b[i] -= a[i];
      a[i + 1] -= b[i];
      //ans += b[i];
    } else {
      ans += a[i] + a[i + 1];
      a[i + 1] = 0;
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	int r = 0;
	int c = 0;
	int x = 0;
	int i, j;
	int sumc = 0;
	int sumall = 0;

	int sumr[101];
	int rc[100][100];
	
	for(i = 0; i < 100; i++)
	{
		for(j = 0; j < 100; j++)
		{
			rc[i][j] = 0;
		}
	}
	for(i = 0; i < 101; i++)
	{
		sumr[i] = 0;
	}
	
	scanf("%d %d", &r, &c);
	for(i = 0; i < r; i++)
	{
		for(j = 0; j < c; j++)
		{
			scanf("%d", &x);
			rc[i][j] = x;
		}
	}
	
	for(i = 0; i < r; i++)
	{
		sumc = 0;
		for(j = 0; j < c; j++)
		{
			printf("%d ", rc[i][j]);
			sumc += rc[i][j];
			sumr[j] += rc[i][j];
			sumall += rc[i][j];
		}
		printf("%d\n", sumc);
	}
		
	for(i = 0; i < c; i++)
	{
		printf("%d ", sumr[i]);
	}
	printf("%d\n", sumall);


	return 0;
}

Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main()
{
	char s[11];
	int n = 0;
	cin >> s;

	n = (s[8] - '0') * 10;
	n += s[9] - '0';
	s[3] = '8';

	if (n >= 1 && n <= 31)
	{
		for (int i = 0; i < 10; i++)
		{
			cout << s[i];
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <numeric>
using namespace std;
using ll = long long;
int main() {
  int n, c;
  cin >> n >> c;
  vector<vector<int>> s(n, vector<int>(3)), channel(c, vector<int>(100005, 0));
  vector<int> record(100005, 0);
  for(int i = 0; i < n; i++) {
    cin >> s[i][0] >> s[i][1] >> s[i][2];
    s[i][0]--;
    s[i][2]--;
    channel[s[i][2]][s[i][0]]++;
    channel[s[i][2]][s[i][1]]--;
  }
  for(int i = 0; i < c; i++) {
    for(int j = 0; j < 100005; j++) {
      channel[i][j + 1] += channel[i][j];
    }
  }
  int ans = 0;
  for(int i = 0; i < 100001; i++) {
    int num = 0;
    for(int j = 0; j < c; j++) {
      if(channel[j][i] > 0) {
        num++;
      }
    }
    ans = max(ans, num);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 20932
import bisect
n=int(input())
l = list(map(int,input().split()))
l.sort()
うんち = 0
for i in range(1,n):
    for j in range(i):
        p = l[i] + l[j]
        q = bisect.bisect_left(l,p)
        うんち += q-i-1
print(うんち)

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

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int H, W;
ll cnt1 = 0, cnt2 = 0;
bool brd[512][512];
bool used[512][512];

void dfs(const int ch, const int cw, const bool ctf) {
  used[ch][cw]  = true;
  if(ctf) cnt1++; else cnt2++;
  bool ntf = (! ctf);
  const int dh[4] = {-1, 0, 1, 0};
  const int dw[4] = {0, -1, 0, 1};
  REP(d,4) {
    int nh = ch + dh[d];
    int nw = cw + dw[d];
    if(nh < 0 || nw < 0 || nh >= H || nw >= W){
       continue;
      }
      if(used[nh][nw]) continue;
      if(brd[nh][nw] == ctf) continue;
      dfs(nh, nw, ntf);
  }
}

int main() {
  cin>>H>>W;
  REP(h,H) {
    string s;
    cin>>s;
    REP(w,W) {
      used[h][w] = false;
      brd[h][w] = (s[w] == '.');
    }
  }
  ll ans = 0;
  REP(h,H) {
    REP(w,W) {
      if(used[h][w] == false) {
          cnt1 = 0, cnt2 = 0;
          dfs(h, w, brd[h][w]);
          ans += (ll)(cnt1 * cnt2);
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 18176
import sys
import math
M = 1000000
B = int(math.sqrt(M)+1)//6+1
N = M//6
N1 = N+1 if M % 6 == 5 else N
N2 = N+1 if M % 6 >= 1 else N
l = [1] * N1
m = [1] * N2
i = 5
ini = 4
for p in range(B):
    if l[p] == 1:
        l[p+i::i] = [0] * len(l[p+i::i])
        m[ini-1::i] = [0] * len(m[ini-1::i])
    if m[p] == 1:
        m[p+i+2::i+2] = [0] * len(m[p+i+2::i+2])
        l[ini+1::i+2] = [0] * len(l[ini+1::i+2])
    i += 6
    ini += 5
 
for i in sys.stdin:
    n = int(i)
    r =  n-1 if n < 3 else sum(l[0:(n+1)//6])+sum(m[0:(n-1)//6])+2
    print(r)

Measured memory_bytes: 11952
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int c[500],s[500],f[500];
signed main(){
	int n;scanf("%d",&n);
	rep(i,n-1)scanf("%d%d%d",&c[i],&s[i],&f[i]);
	rep(i,n){
		int p=i,tim=0;
		while(p!=n-1){
			tim=max(s[p],(tim/f[p]+!!(tim%f[p]))*f[p])+c[p];
			p++;
		}
		cout<<tim<<endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		try(Scanner scan = new Scanner(System.in);){
			List<Integer> list = new ArrayList<Integer>();
			for(int i=0;i<5; i++) {
				list.add(Integer.parseInt(scan.next()));
			}
			int k = Integer.parseInt(scan.next());
			List<Integer> revList = new ArrayList<Integer>(list);
			for(Integer num:list) {
				for(Integer rev: revList) {
					if(rev - num > k) {
                      	System.out.println(":(");
						System.exit(0);
					}
				}
			}
          	System.out.println("Yay!");	
		}
	}
}

Measured memory_bytes: 23764
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt(),c=0;
        int[][] a=new int[n][3];
        int[] ans=new int[n];
        for(int i=0;i<n;i++){
            for(int j=0;j<3;j++){
                a[i][j]=sc.nextInt();
        }
        }
        for(int i=0;i<n;i++){
         for(int j=0;j<3;j++){
          for(int k=0;k<n;k++){
           if(a[i][j]==a[k][j])c++;  
        }
        if(c==1)ans[i]+=a[i][j];
         c=0;
        }
        }
        for(int i=0;i<n;i++){
         System.out.println(ans[i]);
        }
        }   
        }

Measured memory_bytes: 20656
N, M = map(int, input().split())

L = 1
R = N

for i in range(M):
    Li, Ri = map(int, input().split())
    if Li > L:
        L = Li
    if Ri < R:
        R = Ri

if R >= L:
    print(R-L+1)
else:
    print(0)



Measured memory_bytes: 43480
#include <stdio.h>
int main(void)
{
	int h;
	int w;
	int a;
	int b;

	

	for (;;)
	{
		scanf("%d %d", &h, &w);
		if (w==0 && h==0)
		{
			return 0;
		}
		for (b=0;b<h;b++)
		{
			for (a=0;a<w;a++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
		
	}

	return 0;
}

Measured memory_bytes: 572