akhauriyash/Code-Regression huggingface dataset:
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

const int MAXN = 120000;

int n, q;

ll a[MAXN];
vector<pair<ll, int>> qq;
ll aans[MAXN];

ll sum[MAXN];
ll sum2[MAXN];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n >> q;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i)
		sum[i + 1] = sum[i] + a[i];
	sum2[0] = a[0];
	sum2[1] = a[1];
	for (int i = 2; i < n; ++i)
		sum2[i] = sum2[i - 2] + a[i];
	for (int i = 0; i < q; ++i) {
		ll x;
		cin >> x;
		qq.emplace_back(x, i);
	}
	sort(ALL(qq));
	reverse(ALL(qq));
	int now = n - 1;
	for (int i = 0; i < q; ++i) {
		ll x = qq[i].first;
		while (now >= 0) {
			ll d = abs(x - a[now]);
			int y = lower_bound(a, a + n, x - d) - a;
			if (now - y + 1 >= n - now)
				--now;
			else
				break;
		}
		int cnt = n - now - 1;
		int go = now - cnt;
		ll ans = sum[n] - sum[now + 1];
		if (go >= 0)
			ans += sum2[go];
		aans[qq[i].second] = ans;
	}
	for (int i = 0; i < q; ++i) {
		cout << aans[i] << "\n";
	}
	return 0;
}




Measured memory_bytes: 6512
#include<bits/stdc++.h>
using namespace std;
string s;
int n, q;
char a[200010], b[200010];

bool binarySearch(int mid, int forward)
{
    int cur = mid;
    for(int i=1; i<=q; i++)
    {
        // cout << i << " " << cur << endl;
        if(s[cur] == a[i])
        {
            if(b[i] == 'L')
            {
                cur --;
            }
            else
            {
                cur ++;
            }
        }
        if((cur == n && !forward) || (cur == -1 && forward))
        {
            return 1;
        }
    }
    return 0;
}

int main()
{
    cin >> n >> q;
    cin >> s; 
    for(int i=1; i<=q; i++)
    {
        cin >> a[i] >> b[i];
    }

    int low = -1, high = n, mid;
    int forwardAns = -1;
    while(high - low > 1)
    {
        mid = (low + high)/2;
        if(binarySearch(mid, 1))
        {
            low = mid;
        }
        else
        {
            high = mid;
        }
    }
    forwardAns = high;

    low = -1, high = n;
    int backwardAns = n;
    while(high - low > 1)
    {
        mid = (low + high)/2;
        if(binarySearch(mid, 0))
        {
            high = mid;
        }
        else
        {
            low = mid;
        }
    }
    backwardAns = n - high;
    cout << n - (forwardAns + backwardAns) << endl;
    return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0); cin.sync_with_stdio(false);
  string s; int gx, gy;
  cin >> s >> gx >> gy;
  int n = s.length();
  bool crr = 0; int tmp = 0;
  vector<vector<int>> cmd(2);
  for (int i = 0; i < n; i++) {
    if (s[i] == 'T') {
      if (!i || s[i - 1] == 'F') {
        cmd[crr].push_back(tmp);
        tmp = 0;
      }
      crr ^= 1;
    }
    else tmp++;
  }
  if (tmp) cmd[crr].push_back(tmp);
  vector<unordered_set<int>> psb(2);
  if (cmd[0].empty()) {
    psb[0].insert(0);
  } else {
    psb[0].insert(cmd[0][0]); cmd[0].erase(cmd[0].begin());
  }
  psb[1].insert(0);
  for (int q = 0; q < 2; q++) {
    for (auto const& len : cmd[q]) {
      unordered_set<int> nxs;
      for (auto const& e : psb[q]) {
        nxs.insert(e + len);
        nxs.insert(e - len);
      }
      psb[q] = nxs;
    }
  }
  for (auto e : psb[0]) {
    for (auto f : psb[1]) {
      if (e == gx && f == gy) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
const int maxn=2e5+5;
int segTree[maxn<<2],lazy[maxn<<2];
int h,w;

void PushDown(int node,int nodeLeft,int nodeRight)
{
    if(lazy[node]!=-1)
    {
        segTree[node]=lazy[node]+nodeLeft;
        int mid=(nodeLeft+nodeRight)/2;
        segTree[node*2]=lazy[node]+nodeLeft;
        segTree[node*2+1]=lazy[node]+mid+1;
        lazy[node*2]=lazy[node*2+1]=lazy[node];
        lazy[node]=-1;
    }
}

int query(int left,int right,int node,int nodeLeft,int nodeRight)
{
    if(right<left) return inf;
    if(left<=nodeLeft&&right>=nodeRight) return segTree[node];
    if(left>nodeRight||right<nodeLeft) return inf;
    PushDown(node,nodeLeft,nodeRight);
    int mid=(nodeLeft+nodeRight)/2;
    int lret=query(left,right,node*2,nodeLeft,mid);
    int rret=query(left,right,node*2+1,mid+1,nodeRight);
    return min(lret,rret);
}
int update(int left,int right,int val,int node,int nodeLeft,int nodeRight)
{
    if(left>nodeRight||right<nodeLeft) return segTree[node];
    if(left<=nodeLeft&&right>=nodeRight)
    {
        lazy[node]=val;
        return segTree[node]=lazy[node]+nodeLeft;
    }
    PushDown(node,nodeLeft,nodeRight);
    int mid=(nodeLeft+nodeRight)/2;
    int lret=update(left,right,val,node*2,nodeLeft,mid);
    int rret=update(left,right,val,node*2+1,mid+1,nodeRight);
    return segTree[node]=min(lret,rret);
}

int main(void)
{
    memset(segTree,0,sizeof(segTree));
    memset(lazy,-1,sizeof(lazy));
    cin>>h>>w;
    for(int i=1,a,b;i<=h;++i)
    {
        cin>>a>>b;
        a--,b--;
        int now=min(query(0,a-1,1,0,w-1),query(b+1,w-1,1,0,w-1));
        if(now>=inf)
            cout<<-1<<endl;
        else
            cout<<now+i<<endl;
        int val=query(a-1,a-1,1,0,w-1)+1-a;
        update(a,b,val,1,0,w-1);
    }
    return 0;
}

Measured memory_bytes: 9888
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

int h, w;

const int N = 410 * 410;
vector<vector<int>> g(N);
vector<bool> visited(N, false);
vector<vector<int>> comp;

int ind(int i, int j) {
  return i * w + j;
}

pii rind(int idx) {
  return {idx / w, idx % w};
}

bool valid(int i, int j) {
  return 0 <= i && i < h && 0 <= j && j < w;
}

void dfs(int v) {
  visited[v] = true;
  for (auto &u : g[v]) {
    if (!visited[u]) dfs(u);
  }
  comp.back().push_back(v);
}
signed main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin >> h >> w;

  string s[h];
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      vector<pii> dir = {{0, -1}, {0, 1}, {-1, 0}, {1, 0}};
      for (auto &d : dir) {
        int ii = i + d.fi, jj = j + d.se;
        if (!valid(ii, jj)) continue;
        if (s[i][j] != s[ii][jj]) {
          g[ind(i, j)].push_back(ind(ii, jj));
        }
      }
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (!visited[ind(i, j)]) {
        comp.push_back({});
        dfs(ind(i, j));
      }
    }
  }
  int ans = 0;
  for (auto &c : comp) {
    int cnt = 0;
    for (auto &idx : c) {
      auto r = rind(idx);
      if (s[r.fi][r.se] == '.') cnt++;
    }
    ans += cnt * (sz(c) - cnt);
  }
  cout << ans << "\n";
}



Measured memory_bytes: 21624
h,w = map(int,input().split())
n = int(input())
a = list(map(int,input().split()))
ans = [[0] * w for i in range(h)]
i = 0
j = 0
k = 0
flg = True
while i < h:
    ans[i][j] = str(k+1)
    a[k] -= 1
    if a[k] == 0:
        k += 1
    if flg:
        j += 1
        if j == w:
            j -= 1
            i += 1
            flg = False
    else:
        j -= 1
        if j == -1:
            j += 1
            i += 1
            flg = True
for i in range(h):
    print(' '.join(ans[i]))

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var edgeS = new int[N - 1, 2];
            var edge = new List<int>[N].Select(l => new List<int>()).ToArray();
            var cnt = new List<int[]>();
            for (int i = 0; i < N; i++) cnt.Add(new int[] { i, 0 });
            var ans = new int[N];
            for (int i = 0; i < N - 1; i++)
            {
                var input = ReadArrayInt();
                var a = input[0] - 1;
                var b = input[1] - 1;
                edge[a].Add(b);
                edge[b].Add(a);
                cnt[a][1]++;
                cnt[b][1]++;
                edgeS[i, 0] = a;
                edgeS[i, 1] = b;
            }
            var c = ReadArrayInt();
            Array.Sort(c);
            Array.Reverse(c);

            cnt = cnt.OrderByDescending(cn => cn[1]).ToList();
            var idxC = 0;
            var idxCnt = 0;
            var que = new Queue<int>();
            que.Enqueue(idxCnt);

            while (que.Any() && idxC < N)
            {
                var chk = que.Dequeue();
                if (ans[chk] == 0)
                {
                    ans[chk] = c[idxC];
                    idxC++;
                }
                else continue;
                if (idxC == N) break;

                var chkL = new List<int[]>();
                foreach (var e in edge[chk])
                {
                    if (ans[e] == 0) chkL.Add(new int[] { e, cnt[e][1] });
                }
                chkL = chkL.OrderByDescending(ch => ch[1]).ToList();
                for (int i = 0; i < chkL.Count(); i++)
                {
                    que.Enqueue(chkL[i][0]);
                }
            }

            var sum = 0;
            for (int i = 0; i < N - 1; i++)
            {
                var a = ans[edgeS[i, 0]];
                var b = ans[edgeS[i, 1]];
                sum += Math.Min(a, b);
            }
            Console.WriteLine(sum);
            foreach (var i in ans) Console.Write(i + " ");

            Console.WriteLine();
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 23484
n = int(input())
a = list(map(int, input().split()))

d = {}
for i, ai in enumerate(a):
    l = ai + i+1
    if l in d:
        d[l] += 1
    else:
        d[l] = 1

p = 0
for i, ai in enumerate(a):
    r = i+1 - ai
    p += d.get(r, 0)

print(p)

Measured memory_bytes: 40544
import math

N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]

cnt = 0
for i in range(N):
    for j in range(i, N):
        tmp = 0
        if i == j:
            continue
        for k in range(D):
            tmp += (X[i][k] - X[j][k]) ** 2
        if math.sqrt(tmp).is_integer():
            cnt += 1
        
print(cnt)

Measured memory_bytes: 38384
from bisect import bisect_left
N = int(input())
points = list(tuple(map(int,input().split())) for _ in range(N))

X = sorted(set(x for x,y in points))
Y = sorted(set(y for x,y in points))

points = set((bisect_left(X, x), bisect_left(Y, y)) for x,y in points)

xty = [list() for _ in range(len(X))]
ytx = [list() for _ in range(len(Y))]
for x,y in points:
    xty[x].append(y)
    ytx[y].append(x)

area = 0
visited = set()

for p in points:
    if p in visited:
        continue

    stack = [p]

    dx = set()
    dy = set()

    while stack:
        x,y = stack.pop()
        visited.add((x,y))
        if x not in dx:
            for yy in xty[x]:
                if yy != y:
                    stack.append((x,yy))
            dx.add(x)
        if y not in dy:
            for xx in ytx[y]:
                if xx != x:
                    stack.append((xx,y))
            dy.add(y)
    area += len(dx)*len(dy)

print(area-len(points))

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
    int n;
    cin>>n;
    int ac,wa,tle,re;
    ac=wa=tle=re=0;
    rep(i,0,n){
        string s;
        cin>>s;
        if(s=="AC")ac++;
        else if(s=="WA")wa++;
        else if(s=="TLE")tle++;
        else re++;
    }

    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;

}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] N = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int[] A = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int num = A.Sum();
            string message = "-1";
            if(N[0] - num >= 0)
            {
                message = (N[0] - num).ToString();
            }

            Console.WriteLine(message);
        }
    }
}

//24579 =  hon
//0168 = pon
//3 = bon
//long n = long.Parse(Console.ReadLine());
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine(cnt);
//Console.ReadKey();


Measured memory_bytes: 29068
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
using namespace std;
const int inf=1e9+10;
const ll llinf=1e16+10;
const int maxn=1e5+10;
const int maxm=2e5+10;
const int mod=1e9+7;
int n,m,k;
pair<int,int> point[4][maxn];
int c[4];
bool judge(int x,int y)
{
    if(x==0||y==0||x==m||y==n)
        return true;
    return false;
}
void func(int x,int y,int t)
{
    if(y==0)
        point[0][c[0]++]=make_pair(x,t);
    else if(x==m)
        point[1][c[1]++]=make_pair(y,t);
    else if(y==n)
        point[2][c[2]++]=make_pair(x,t);
    else if(x==0)
        point[3][c[3]++]=make_pair(y,t);
}
bool cmp(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}
int main()
{
    //freopen("in.txt","r",stdin);
    while(~scanf("%d %d %d",&n,&m,&k))
    {
        int flag=1;
        cls(c,0);
        for(int i=1;i<=k;i++)
        {
            int x1,y1,x2,y2;
            scanf("%d %d %d %d",&y1,&x1,&y2,&x2);
            if(judge(x1,y1)&&judge(x2,y2))
            {
                func(x1,y1,i);
                func(x2,y2,i);
            }
        }
        sort(point[0],point[0]+c[0]);
        sort(point[1],point[1]+c[1]);
        sort(point[2],point[2]+c[2],cmp);
        sort(point[3],point[3]+c[3],cmp);
        stack<int> S;
        for(int i=0;i<4;i++)
            for(int j=0;j<c[i];j++)
            {
                if(S.empty())
                    S.push(point[i][j].second);
                else
                {
                    if(S.top()==point[i][j].second)
                        S.pop();
                    else S.push(point[i][j].second);
                }
            }
        if(!S.empty()) flag=0;
        if(flag) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


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

using namespace std;
using ll = long long int;
#define long ll

struct Prime {
    vector<char> nprime;
    Prime(size_t n) : nprime(n+1) {
        nprime[0] = nprime[1] = 1;
        for(size_t i=2; i<=n; i++) {
            if(nprime[i]) continue;
            for(size_t j=2; i*j<=n; j++)
                nprime[i*j] = 1;
        }
    };
    bool is(size_t i) {
        return nprime[i] == 0;
    };
};

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

    Prime pr(2e5);

    ll x;
    cin >> x;
    for(ll i=x; ; i++) {
        if(pr.is(i)) {
            cout << i << endl;
            return 0;
        }
    }
}


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

using namespace std;
#define int long long
signed main(){
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int n,x,y;
	cin>>n;
	int ans[n];
	pair<int,int>p[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>x;
		p[i]=make_pair(x,i+1);
	}
	sort(p,p+n);
	for (int i = 0; i < n; ++i)
	{
		cout<<p[i].second<<" ";
	}
	return 0;
}

Measured memory_bytes: 2432
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;



public class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    static int gcd(int a,int b)
	{
		if(a == 0) return b;
		if(b == 0) return a;
		
		return gcd(b,a%b);
	}


    public static void main(String[] args)
    {
        OutputStream outputStream = System.out;
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(outputStream);
       
        
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        int a[] = new int[n];
        
        for(int i = 0; i < n; i++)
        {
        	a[i] = sc.nextInt();
        }
        
        int map[] = new int[n];
        
        for(int i = 0; i < m; i++)
        {
        	int x = sc.nextInt()-1;
        	int y = sc.nextInt()-1;
        	
        	if(a[x] > a[y])
        	{
        		map[y] = -1;
        	}
        	else if(a[x] < a[y])
        	{
        		map[x] = -1;
        	}
        	else
        	{
        		map[x] = -1;
        		map[y] = -1;
        	}
        }
        
        int cnt = 0;
        for(int i = 0; i < n; i++)
        {
        	if(map[i] == 0) cnt++;
        }
        
        out.println(cnt);
        out.close();
    }

}

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

using namespace std;
#define int long long
const int MOD = 998244353;
int dp[3001][3001];
void add(int &a, const int &b) {
	a += b;
	if (a >= MOD) a -= MOD;
}
void sub(int &a, const int &b) {
	a -= b;
	if (a < 0) a += MOD;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	dp[A][B] = 1;
	for (int i = A; i <= C; i++) {
		for (int j = B; j <= D; j++) {
			add(dp[i][j], dp[i - 1][j] * j % MOD);
			add(dp[i][j], dp[i][j - 1] * i % MOD);
			sub(dp[i][j], dp[i - 1][j - 1] * (i - 1) * (j - 1) % MOD);
		}
	}
	cout << dp[C][D] << endl;
}

Measured memory_bytes: 73868
#include<stdio.h>


int bitcnt( int bit )
{
	int ret = 0 ;

	int i ;
	for( i = 0 ; i < 3 ; ++i )
	{
		ret += ( bit >> i ) & 1 ;
	}

	return ret ;
}


int main()
{
	int n ,m ;
	
	while( 1 )
	{
		int lp ;
		for( lp = m = 0 ; lp < 3 ; ++lp )
		{
			scanf( "%d" ,&n ) ;

			m += n ;
		}

		if( m == 0 )
		{
			return 0 ;
		}

		scanf( "%d" ,&n ) ;

		int ans[ 1000 + 1 ] ;

		for( lp = 1 ; lp <= m ; ++lp )
		{
			ans[ lp ] = 2 ;
		}

		int i[ 1000 + 1 ] ,I[ 1000 + 1 ] = { 0 } ;
		int j[ 1000 + 1 ] ,J[ 1000 + 1 ] = { 0 } ;
		int k[ 1000 + 1 ] ,K[ 1000 + 1 ] = { 0 } ;

	


		for( lp = 1 ; lp <= n ; ++lp )
		{
			int ifs ;

			scanf( "%d %d %d %d" ,&i[ lp ] ,&j[ lp ] ,&k[ lp ] ,&ifs ) ;


			if( ifs )
			{
				I[ i[ lp ] ] = 4 ;
				J[ j[ lp ] ] = 2 ;
				K[ k[ lp ] ] = 1 ;

				ans[ i[ lp ] ] = ans[ j[ lp ] ] = ans[ k[ lp ] ] = 1 ;
			}
		}

		for( lp = 1 ; lp <= n ; ++lp )
		{
			if( bitcnt( I[ i[ lp ] ] | J[ j[ lp ] ] | K[ k[ lp ] ] ) == 2 )
			{
				ans[ ( I[ i[ lp ] ] & 7 ) == 0 ? i[ lp ] : ( J[ j[ lp ] ] & 7 ) == 0 ? j[ lp ] : ( K[ k[ lp ] ] & 7 ) == 0 ? k[ lp ] : 0 ] = 0 ;
			}
		}

		for( lp = 1 ; lp <= m ; ++lp )
		{
			printf( "%d\n" ,ans[ lp ] ) ;
		}
	}
}

Measured memory_bytes: 2604
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 1000000000
typedef long long int lli;
typedef pair<int,int> P;

const int MAX_V=100;
int cost[MAX_V][MAX_V];
int mincost[MAX_V];
bool used[MAX_V];

int prim(int V){
	for(int i=0; i<V; ++i){
		mincost[i]=INF;
		used[i]=false;
	}
	mincost[0]=0;
	int res=0;
	
	while(true){
		int v=-1;
		for(int u=0; u<V; ++u){
			if(!used[u]&&(v==-1||mincost[u]<mincost[v])) v=u;
		}
		if(v==-1) break;
		used[v]=true;
		res+=mincost[v];
		for(int u=0; u<V; ++u){
			mincost[u]=min(mincost[u],cost[v][u]);
		}
	}
	return res;
}

int main(){
	int n,m;
	while(cin>>n>>m){
		if(n==0&&m==0) break;
		for(int i=0;i<n;++i)for(int j=0;j<n;++j) cost[i][j]=INF;
		for(int i=0; i<m; ++i){
			int a,b,c;
			cin >> a >> b >> c;
			cost[a][b]=cost[b][a]=c;
		}
		cout << prim(n) << "\n";
	}
	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
  cin>>a>>b;
  string B=to_string(b);
  int n=B.size();
  int X=a*pow(10,n)+b;
  bool ans=false;
  for(int i=0;i*i<=X;i++)
    if(i*i==X)
      ans=true;
  if(ans)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

  return 0;
}

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

int  main()
{
    int s, w;
    cin >> s >> w;
    if (w >= s) {
        cout << "unsafe" << endl;
    }
    else {
        cout << "safe" << endl;
    }
    return 0;
}

Measured memory_bytes: 3676
import java.util.Scanner;

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

		String s = sc.next();
		int a = 0;
		int z = 0;

		char[] ch = s.toCharArray();

		for (int i = 0; i < s.length(); i++) {
			if (ch[i] == 'A') {
				a = i;
				break;
			}
		}
		for (int i = 0; i < s.length(); i++) {
			if (ch[i] == 'Z') {
				z = i;
			}
		}
		System.out.println(z - a + 1);
	}
}

Measured memory_bytes: 27988
#include <bits/stdc++.h>
typedef long long ll; 

using namespace std;

int main() {
	int Q;
	cin >> Q;
	vector<ll> a(Q);
	vector<ll> b(Q);
	for (int i = 0; i < Q; i++) {
		cin >> a[i] >> b[i];
	}

	ll lp = 0;
	for (int i = 0; i < Q; i++) {
		ll m = a[i] * b[i];

		ll res = 0;
		ll low = 0, high = m;
		while ((high - low) != 1) {
			if (lp++ > 1e10) break;

			ll mid = (high + low) / 2;

			ll x = m / mid;
			if (m % mid == 0) x--;

			if (mid > x) {
				high = mid;
			} else {
				low = mid;
			}
		}

		if (low == 0) {
			cout << res << endl;
			continue;
		}

		res = low * 2;

		ll x = m / low;
		if (m % low == 0) x--;

		if (low == x) res--;
		if (low >= a[i]) res--;
		if (low >= b[i]) res--;

		cout << res << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solveMulti(sc: Scanner, pw: java.io.PrintWriter) {
        for (t in 1..sc.next().toInt()) {
            solve(sc, pw)
        }
    }

    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt() % 10
        val s = arrayOf("pon", "pon", "hon", "bon", "hon", "hon", "pon", "hon", "pon", "hon")
        pw.println(s[N])
    }
}


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int tmp=a;
    string ans="NO";
    for(int i=1; i<=b*2; i++){
        if(tmp%b==c){
            ans="YES";
            break;
        }
        tmp+=a;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int N, score = 0;
  	vector<int> v;
  	cin >> N;
  	for(int i = 0; i < N; i++){
    	int a; cin >> a;
      	v.push_back(a);
    }
  	sort(v.begin(), v.end(), greater<int>());
  	for(int i = 0; i < N; i++){
    	if (i % 2 == 0){
        	score += v[i];
        } else {
        	score -= v[i];
        }
    }
  	cout << score;
}	

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define range_for(i, b, e) for(int i=(b), i##_len=(e); i<=i##_len; ++i)
# define step(n) rep(_, n)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define Unique(a) a.erase(unique(ALL(a)), a.end())
# define pb push_back
# define len(x) ((int)(x).size())
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
# define LINT_MAX (LLONG_MAX)
# define LINT_MIN (LLONG_MIN)
# define cauto const auto
using namespace std;
using lint = long long;
template <class Type> inline constexpr Type Square(Type x) { return x * x; }
template <class Type> inline constexpr bool InRange(const Type& x, const Type& i, const Type& a) { return (i <= x) && (x <= a); }
template<class Integer>bool chmax(Integer &a, const Integer &b) { if (a<b) { a=b; return 1; } return 0; }
template<class Integer>bool chmin(Integer &a, const Integer &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Integer>bool IsOdd(Integer &n) { return n & 1; }
template<class Integer>bool IsEven(Integer &n) { return !(n & 1); }
int ctoi(const char c) { return ('0' <= c && c <= '9') ? (c - '0') : -1; }
string YesNo(bool b) { return b ? "Yes" : "No"; }
string YESNO(bool b) { return b ? "YES" : "NO"; }
string yesno(bool b) { return b ? "yes" : "no"; }
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
#define Cin(Type, ...) Type __VA_ARGS__; _cin(__VA_ARGS__)
#define Cinv(Type, xs, n) vector<Type> xs(n); rep(i, n) cin >> xs[i]
#define Cinv2(Type, xs, ys, n) vector<Type> xs(n), ys(n); rep(i, n) cin >> xs[i] >> ys[i]
#define Cinv3(Type, xs, ys, zs, n) vector<Type> xs(n), ys(n), zs(n); rep(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinvv(Type, xs, h, w) vector<vector<Type>> xs(h, vector<int>(w)); rep(i, h) rep(j, w) cin >> xs[i][j]
void Print() { cout << endl; }
template <class Head, class... Tail> void Print(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(tail) != 0) cout << " "; Print(forward<Tail>(tail)...); }
template <class Type> void Print(vector<Type> &vec) { for (auto& a : vec) { cout << a; if (&a != &vec.back()) cout << " "; } cout << endl; }
template <class Type> void Print(vector<vector<Type>> &df) { for (auto& vec : df) { Print(vec); } }
void Debug() { cerr << endl; }
template <class Head, class... Tail> void Debug(Head&& head, Tail&&... tail) { cerr << head; if (sizeof...(tail) != 0) cerr << " "; Debug(forward<Tail>(tail)...); }
template <class Type> void Debug(vector<Type> &vec) { for (auto& a : vec) { cerr << a; if (&a != &vec.back()) cerr << " "; } cerr << endl; }
template <class Type> void Debug(vector<vector<Type>> &df) { for (auto& vec : df) { Debug(vec); } }

int main()
{
    Cin(int, A, B, C);

    Print(max(0, C - (A-B)));

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int N,i,j,minj,count;
    
        scanf("%d",&N);
        int A[N];
        for(i=0;i<N;i++)
        {
            scanf("%d",&A[i]);
        }

        count=0;
        for(i=0;i<N;i++)
        {
            minj=i;
            for(j=i;j<N;j++)
            {
                if(A[j]<A[minj])
                {
                    minj=j;
                }
            }
            if(minj!=i)
            {
                int a=A[i];
                A[i]=A[minj];
                A[minj]=a;
                count++;
            }
            
        }
        
        
        for(i=0;i<N;i++)
        {
            printf("%d",A[i]);
            if(i==N-1) printf("\n");
            else printf(" ");
        }
        printf("%d\n",count);

}



Measured memory_bytes: 1932
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[310][310][310] = {};
string S;

ll calc(ll i, ll j, ll k){
    ll &res = dp[i][j][k];
    if(~res) return res;
    if(j - i == 0){
        return res = 0;
    }else if(j - i == 1){
        return res = 1;
    }
    res = 0;
    if(S[i] == S[j-1]){
        res = 2 + calc(i+1, j-1, k);
    }else{
        if(k > 0){
            res = 2 + calc(i+1, j-1, k-1);
        }
    }
    rep(l,i+1,j){
        res = max(res, calc(i, l, k));
    }
    rep(l,i+1,j){
        res = max(res, calc(l, j, k));
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> S;
    ll K;
    cin >> K;
    memset(dp, -1, sizeof(dp));
    ll N = S.size();
    ll ans = calc(0,N,K);
    print(ans);

    

}

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

int n;
vector<int> a;
template <class T>
void readVector(int n, vector<T> &v){
	for(int i=0; i<n; ++i){
		T t;
		cin >> t;
		v.push_back(t);
	}
}
int ans;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	readVector(n, a);
	for(int i=0; i<n; ++i)
		for(int j=i+1; j<n; ++j)
			ans = max(ans, abs(a[i] - a[j]));
	cout << ans << "\n";
}

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

using namespace std;

#include<bits/stdc++.h>
using namespace std;
template <typename T,typename E>
struct SegmentTree{
  typedef function<T(T,E)> G;
  typedef function<T(E,E)> H;
  int n;
  G g;
  H h;
  T d1;
  E d0;
  vector<T> dat;
  vector<E> laz;
  SegmentTree(int n_,G g,H h,T d1,E d0,
	      vector<T> v=vector<T>()){
    this->g=g;
    this->h=h;
    this->d1=d1;
    this->d0=d0;
    init(n_);
    if(n_==(int)v.size()) build(n_,v);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(n,d1);
    laz.clear();
    laz.resize(2*n-1,d0);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[i]=v[i];
  }
  void update(int a,int b,E x,int k,int l,int r){
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      laz[k]=h(laz[k],x);
      return;
    }
    update(a,b,x,k*2+1,l,(l+r)/2);
    update(a,b,x,k*2+2,(l+r)/2,r);
  }
  void update(int a,int b,E x){
    update(a,b,x,0,0,n);
  }
  T query(int k){
    T c=dat[k];
    k+=n-1;
    E x=laz[k];
    while(k>0){
      k=(k-1)/2;
      x=h(x,laz[k]);
    }
    return g(c,x);
  }
};

int main(){
    int n;
    cin >> n;
    vector<int64_t> H(n), A(n);
    copy_n(istream_iterator<int64_t>(cin), n, H.begin());
    copy_n(istream_iterator<int64_t>(cin), n, A.begin());
    SegmentTree<int64_t,int64_t> rmq(n + 1,
                [](auto a,auto b){return max(a, b);},
                [](auto a,auto b){return max(a, b);},
                0,0);

    for (int i = 0; i < n; i++){
        rmq.update(H[i], n + 1, rmq.query(H[i] - 1) + A[i]);
    }

    int64_t ma = 0;
    for (int i = 0; i <= n; i++)
        ma = max(ma, int64_t(rmq.query(i)));
    cout << ma << endl;
}

Measured memory_bytes: 9472
RC = []
r, c = [int(e)for e in input().split()]
sum_col = [0]*(c+1)

for i in range(r):
    R = [int(e)for e in input().split()]
    R.append(sum(R))
    RC.append(R)
    for j in range(c+1):
        sum_col[j] += RC[i][j]

RC.append(sum_col)

for x in range(len(RC)):
    print(" ".join(map(str, RC[x])))


Measured memory_bytes: 5680
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 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};
ll MOD = 1000000007;

int main(){
  int n, t;
  cin >> n >> t;
  ll a[n];
  REP(i,n)cin >> a[i];
  ll mx[n];
  mx[n-1] = a[n-1];
  REP(i,n-1)mx[n-2-i] = max(mx[n-1-i], a[n-2-i]);
  ll gain[n-1];
  REP(i,n-1)gain[i] = mx[i+1] - a[i];
  sort(gain, gain+n-1);
  cout << n-1- (lower_bound(gain,gain+n-1, gain[n-2])-gain) << endl;

  return 0;
}


Measured memory_bytes: 2560
import java.io.*;
import java.util.*;
public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] s = br.readLine().toCharArray();
		int n = s.length;
		boolean[] gat = new boolean[n];
		for(int i = 0; i < n-1; i++){
			if(s[i] == 'R' && s[i+1] == 'L'){
				gat[i] = true;
			}
		}
		int[] res = new int[n];
		int c = 0, d = 0;
		for(int i = 0; i < n-1; i++){
			if(s[i] == 'R'){
				if(i % 2 == 0) c++;
				else d++;
			}
			if(gat[i]){
				if(i % 2 == 0){
					res[i] += c; res[i+1] += d;
				}
				else{
					res[i] += d; res[i+1] += c;
				}
				c = 0; d = 0;
			}
		}
		c = 0; d = 0;
		for(int i = n-1; i >= 0; i--){
			if(s[i] == 'L'){
				if(i % 2 == 0) c++;
				else d++;
			}
			if(gat[i]){
				if(i % 2 == 0){
					res[i] += c; res[i+1] += d;
				}
				else{
					res[i] += d; res[i+1] += c;
				}
				c = 0; d = 0;
			}
		}
		StringBuilder sb = new StringBuilder();
		for(int k: res){
			sb.append(k+" ");
		}
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		bw.write(sb.toString().trim());
		bw.write("\n");
		bw.flush();
	}

}


Measured memory_bytes: 39892
def getMaxValue(s)
  v = s.split(/[a-z]?/).sort
  max = ""
  v.length.step(0, -1){|n|  max += v[n].to_s }
  return max.to_i
end

def getMinValue(s)
  v = s.split(/[a-z]?/).sort
  min = ""
  v.each{|n|  min += n.to_s  }
  return min.to_i
end

$stdin.gets.to_i.times{
  input = $stdin.gets.chomp
  p getMaxValue(input) - getMinValue(input)
}

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

using namespace std;

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

    int n, m, x, y;
    cin >> n >> m >> x >> y;
    int maxx = INT_MIN;
    int miny = INT_MAX;
    int k;
    for (int i = 0; i < n; ++i) {
        cin >> k;
        maxx = max(maxx, k);
    }
    for (int i = 0; i < m; ++i) {
        cin >> k;
        miny = min(miny, k);
    }
    x = max(x, maxx);
    y = min(y, miny);
    if (y > x) {
        cout << "No War" << endl;
    } else {
        cout << "War" << endl;
    }

    return 0;
}


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

int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n){
        cin >> a[i] >> b[i];
    }
    
    rep(i, n - 2){
        if(a[i] == b[i] && a[i + 1] == b[i + 1] && a[i + 2] == b[i + 2]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3132
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int p[SIZE];
int main(){
    int N; R(N);
    set<int>AA{0,N+1};
    FOR(i,1,N){
        int x; R(x);
        p[x]=i;
    }
    LL an=0;
    for(int i=N;i>0;i--){
        AA.insert(p[i]);
        auto it=AA.find(p[i]);
        int rr=*next(it);
        int ll=*prev(it);
        if(rr!=N+1){
            int rr2=*next(next(it));
            an+=(LL)i*(p[i]-ll)*(rr2-rr);
        }
        if(ll){
            int ll2=*prev(prev(it));
            an+=(LL)i*(rr-p[i])*(ll-ll2);
        }
    }
    W(an);
    return 0;
}


Measured memory_bytes: 5376
import Data.List
import qualified Data.ByteString.Char8 as B
import Control.Monad

main :: IO ()
main = readLn >>= main'
    where
        main' n = replicateM 3 breads >>= print . solve n . fmap sort

solve :: Int -> [[Int]] -> Int 
solve n [as, bs, cs] = check2 as $ check n bs cs
    where
        check cn (x : xs) (y : ys)
            | x < y = (x, cn + v) : next
            | otherwise = check (cn - 1) (x : xs) ys
            where
                next@((_, v) : _) = check cn xs $ y : ys
        check _ _ _ = [(0, 0)]

        check2 (x : xs) yys@((y, v) : ys)
            | x < y = v + check2 xs yys
            | otherwise = check2 (x : xs) ys
        check2 _ _ = 0
        
breads :: IO [Int]
breads = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)

Measured memory_bytes: 56700
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N;cin>>N;
  map<int,int> m;
  for(int i=2;i<=N;i++){
    int k=i;
    for(int j=2;j*j<=k;j++){
      if(k%j==0){
        k/=j;
        m[j]++;
        j=1;
      }
    }
    if(k>1)m[k]++;
  }
  int ans=1;
  for(auto p:m){
    ans*=p.second+1;
    ans%=MOD;
  }
  cout<<ans<<endl;
}


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

int sum(int a, int b) {
	return a + b;
}

int main() {
	int N;
	int s;
	int min = 100;
	int ans = 0;
	bool flag = true;

	cin >> N;
	for (int i = 0; i < N;i++) {
		cin >> s;
		ans += s;
		if (s % 10 > 0 && min > s) {
			min = s;
		}
		if (s % 10 > 0) {
			flag = false;
		}
	}
	if (ans % 10 == 0) {
		ans -= min;
	}
	if (flag) {
		ans = 0;
	}
	cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define N 2001
int main(void){
	int n,i,A[N]={0};
	double m,l;
	char str[N],*line;

	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		line=strtok(str,",");
		sscanf(line,"%d",&n);
		line=strtok(NULL,",");
		sscanf(line,"%lf",&m);
		line=strtok(NULL,",");
		sscanf(line,"%lf",&l);
		if(m/(l*l)>=25)
			A[n]=1;
	}
	for(i=1;i<N;i++)
		if(A[i]) printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 656
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>
 
#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
 
int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}
 
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;
 
const int N=400000+19;
const ll oo=1ll<<40;
 
struct Edge{
	int x,y;
	ll z;
	bool operator < (const Edge &B) const {return z<B.z;}
} E[N];
int fa[N];
ll val[N],tmp=oo;
int n,m,Qc,A,B,C;
 
int getf(int x){
	return fa[x]==x?x:fa[x]=getf(fa[x]);
}
ll Kruskal(){
	ll res=0;
	For(i,0,n) fa[i]=i;
	sort(E,E+m);
	For(i,0,m){
		int x=getf(E[i].x),y=getf(E[i].y);
		if (x!=y) fa[x]=y,res+=E[i].z;
	}
	return res;
}
 
int main(){
	n=IN();Qc=IN();
	For(i,0,n) val[i]=oo;
	while (Qc--){
		A=IN(),B=IN(),C=IN();
		E[m++]=(Edge){A,B,C};
		val[A]=min(val[A],C+1ll);
		val[B]=min(val[B],C+2ll);
	}
	for (int i=0,x=0;i<3*n;i++,x=(x+1)%n){
		val[x]=min(val[x],tmp);
		tmp=min(tmp,val[x])+2;
	}
	For(i,0,n) E[m++]=(Edge){i,(i+1)%n,val[i]};
	cout<<Kruskal()<<endl;
}

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

class Cmondai
{
    static void Main()
    {
        var nm = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var N = nm[0];
        var M = nm[1];
        var ans = 0L;
        if (N == M)
        {
            var n = 1L;
            for (long i=N;0<i;--i) n = (n * i) % 1000000007;
            var num = n * n % 1000000007;
            ans = num * 2 % 1000000007;
        }
        else if(Math.Abs(N - M) < 2)
        {
            var n = 1L;
            for (long i = N; 0 < i; --i) n = (n * i) % 1000000007;
            var m = 1L;
            for (long i = M; 0 < i; --i) m = (m * i) % 1000000007;
            ans = n * m % 1000000007;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13396
k, n = map(int,input(). split())
lstr_a = input().split(" ")
lint_a = [int(n) for n in lstr_a]
alist = sorted(lint_a)
t = alist.count(0)
x = 0
for i in range(n-1):
  x = max(alist[i+1]-alist[i], x)
b = k-alist[n-1]+alist[0]
c = max(x,b)
answer = k-c
print(answer)

Measured memory_bytes: 26988
import math

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

# 総和が等しくなることが必要条件なので、操作回数は sum(B) - sum(A)
def f():
    a_ctr = 0
    b_ctr = 0
    handle = sum(B) - sum(A)
    if handle < 0: return 0 # Aの総和が大きければ無理
    # A に足していく
    for i in range(N):
        if A[i] == B[i]:
            pass
        if A[i] > B[i]: 
            b_ctr += A[i] - B[i]
        else: 
            a_ctr += math.ceil((B[i] - A[i]) / 2)
            if (B[i] - A[i]) % 2 == 1: b_ctr += 1
    # print(a_ctr, b_ctr, handle)
    if a_ctr == b_ctr == handle: return 1
    if a_ctr < handle and b_ctr < handle and (handle - a_ctr) * 2 == handle - b_ctr: return 1
    return 0

if f():
    print("Yes")
else:
    print("No")

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

int p, pp;

int main() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  for (int i = 0; i < 2 * n; i++) {
   	if (i & 1) 
    	cout << t[pp++];
    else
      	cout << s[p++];
  }
  cout << '\n';
 	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	char s[12];
	for (int i = 0; i < 12; i++)cin >> s[i];
	for (int j = 0; j < 12; j++) {
		if (j == 4)cout << " " << s[j];
		else cout << s[j];
	}
	cout << endl;
	int x;
	cin >> x;
}

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

g = {}
n_path = 0
for i in range(N):
    g[i] = set()
for _ in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a].add(b)
    g[b].add(a)

dp = [[0 for _ in range(N)] for _ in range(1 << N)]
dp[1][0] = 1

for bit in range(1 << N):
    for v in range(N):

        if bit & (1 << v) is False:
            continue

        sub = bit ^ (1 << v)

        for u in range(N):
            if (v in g[u]) and (sub & (1 << u)):
                dp[bit][v] += dp[sub][u]

print(sum(dp[-1]))


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

using namespace std;

typedef long long ll;

bool odddig(int n ) {
	string num = to_string(n);
	return num.size() & 1;
}

void solve() {
	ll n, ctr = 0;
	cin >> n;
	while (n) {
		if (odddig(n))	ctr++;
		n--;
	}
	cout << ctr << endl;
}

int main() {
	ll t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


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

int main(){
    int A[100][100]={},B[100]={},C[100]={};
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++)cin>>A[i][j];
    }
    for(int i=0;i<m;i++)cin>>B[i];
    
    for(int x=0;x<n;x++){
        for(int y=0;y<m;y++){
            C[x]+=A[x][y]*B[y];
        }
    }
    
    for(int i=0;i<n;i++)cout<<C[i]<<endl;
    
    return 0;
}



Measured memory_bytes: 3148
#include <cstdio>
#include <functional>
#include <algorithm>
 
#define SIZE 10
#define MAX 10000
#define TOP 3
 
using namespace std;
 
int main() {
 int i = 0;
 int buf;
 int height[SIZE];
  
 while(i < SIZE) {
  scanf("%d", &buf);
   
  height[i] = buf;
 
  ++i;
 }
 
 sort(height, height + SIZE, greater<int>());
 
 for(i = 0; i < TOP; ++i) {
  printf("%d\n",height[i]);
 }
 
 return 0;
}

Measured memory_bytes: 2748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
	string s;
	cin>>s;
	ll cnt=s.size();
	cout<<(cnt%2==(s[0]==s[s.size()-1])?"Second":"First");
	return 0;
}

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

#define mp make_pair
#define pb push_back

using namespace std;

typedef long long ll;

const int maxn=1e5+10 , inf=1e9+10;

int a[maxn];

int main()
{
    ios_base::sync_with_stdio(false);
    int n,m;
    ll ans=0;
    cin>>n>>m;
    for(int i=0 ; i<n ; i++)
        cin>>a[i];
    if(a[0]>m)
        ans+=a[0]-m , a[0]=m;
    for(int i=1 ; i<n ; i++)
    {
        if(a[i]+a[i-1]>m)
            ans+=a[i-1]+a[i]-m , a[i]-=a[i-1]+a[i]-m;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 640