akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<=(end);i++)
#define REP(i, n) FOR(i,1,n)
#define IFOR(i, begin, end) for(int i=(end);i>=(begin);i--)
#define IREP(i, n) IFOR(i,1,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
using namespace std;

ll digits(ll a){
	ll digits=0;
	if(a>0) digits++;
	else return 0;

	while(a/10>0){
		a/=10;
		digits++;
	}
	return digits;
}

int main()
{
	ll N;
    cin>>N;
    ll B=0;

    ll ans=digits(N);

    for(ll A=1;A*A<=N;A++){
    	if(N%A==0){
    		B=N/A;
    		ans=min(ans,max(digits(A),digits(B)));
    	}
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

	int x,i,num[100];
	cin>>x;

	for( i=0;i<x;i++){
		cin>>num[i];
	}
	for(i=x-1;i>0;i--){
		cout<<num[i]<<' ';
	}
	cout<<num[0]<<endl;
	return 0;
}

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



int main() {
	
	string a,ans;
	bool check = true;
	cin >> a;
	
	//cout << a.at(0) << endl;

	for (int i = 0; i < a.size(); i++) {
		
		if ((i+1)%2==0) {
			//cout << "偶数　";
			if (a.at(i) == 'L' || a.at(i) == 'U' || a.at(i) == 'D') {
				continue;
				}
			else {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			//cout << "奇数　";
			if (a.at(i) == 'R' || a.at(i) == 'U' || a.at(i) == 'D') {
				continue;
			}
			else {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
ll dp[maxn];
ll a[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	dp[1]=0;
	dp[2]=abs(a[2]-a[1]);
	for(int i=3;i<=n;i++)
		dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
	printf("%lld\n",dp[n]);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	s[s.size()] = '0';
	deque<char> dq;
	rep(i, n) dq.push_back(s[i]);
	int L = 0;
	int R = 0;
	rep(i, n) {
		if (s[i] == '(') L++;
		else {
			if (L == 0) R++;
			else L--;
		}
	}
	rep(i, L) dq.push_back(')');
	rep(i, R) dq.push_front('(');
	while (!dq.empty()) {
		cout << dq.front();
		dq.pop_front();
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
pair<int,int> p[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		int x,y;scanf("%d%d",&x,&y);
		p[i]=make_pair(x+y,x);
	}
	std::sort(p,p+a);
	long long ret=0;
	for(int i=0;i<a;i++){
		if(i%2==0)ret+=p[a-1-i].second;
		else ret-=p[a-1-i].first-p[a-1-i].second;
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 896
#include <stdio.h>
int main(){
  char S[100];
  int Count;
  int i;
  
  scanf("%s", S);
  
  for(i=0; S[i]!='\0'; i++);
  Count = i;
  
  for(i=0; i<Count; i++){
    if(i%2==0){
      if(S[i]!='R' && S[i]!='U' && S[i]!='D'){
        printf("No\n");
        break;
      }
    }
    else if(i%2==1){
      if(S[i]!='L' && S[i]!='U' && S[i]!='D'){
        printf("No\n");
        break;
      }
    }
  }
  
  if(i==Count){
    printf("Yes\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;
 
#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999
 
#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
 
typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;
 
typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;
 
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;
 
namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// 2???????????????????????????????±???????
double dot(P a, P b) {
    return (a.X * b.X + a.Y * b.Y);
}
 
// 2???????????????????????????????±???????
double cross(P a, P b) {
    return (a.X * b.Y - a.Y * b.X);
}
 
int main() {
 	P a, b, c, d;
 	while(cin >> a.X >> a.Y >> b.X >> b.Y >> c.X >> c.Y >> d.X >> d.Y) {
 		P x = b - a;
 		P y = d - c;
 		if(EQ(dot(x,y), 0)) cout << "YES" << endl;
 		else cout << "NO" << endl;
 	}
    return 0;
}

Measured memory_bytes: 1216
# -*- coding: utf-8 -*-

"""
・ダイクストラ(優先度付きキュー)
"""

from heapq import heappop, heappush

# 今回はダイクストラするので、データの持ち方は隣接リスト
N = int(input())
nodes = [[] for _ in range(N+1)]
for i in range(N-1):
    a, b, c = map(int, input().split())
    # nodes[出発ノード](到着ノード, コスト))
    nodes[a].append((b, c))
    # 無向グラフなのでこっちも入れる
    nodes[b].append((a, c))

def dijkstra(nodes, start):
    # 最短距離メモ
    memo = [float('inf')] * (len(nodes))
    # 訪問済メモ
    visited = [False] * (len(nodes))
    # スタート位置
    que = [(0, start)]
    memo[start] = 0
    # キューが空になるまで
    while len(que) != 0:
        # startからの距離, 現在のノード
        dist, cur = heappop(que)
        # 訪問済にする
        visited[cur] = True
        # 出発ノードcurの到着ノードでループ
        for i in range(len(nodes[cur])):
            nxt, cost = nodes[cur][i]
            # 訪問済ではないかつ今回の経路のが短い時
            if not visited[nxt] and memo[cur] + cost < memo[nxt]:
                memo[nxt] = memo[cur] + cost
                # 現在の移動距離をキューの優先度として、早い方から先に処理するようにする
                heappush(que, (memo[nxt], nxt))
    # ノードstartからの最短距離リストを返却
    return memo

Q, K = map(int, input().split())
# 引数：(ノードの隣接リスト, 出発ノード)
memo = dijkstra(nodes, K)

for i in range(Q):
    x, y = map(int, input().split())
    # 今回は全てKを経由するので、Kからの距離さえ分かれば全部出る
    print(memo[x] + memo[y])


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

const int MOD = (int)1e9+7;

int main(){
	int A,B,C;
	cin >> A >> B >> C;

	if(A==B && B==C)	cout << "Yes" << endl;
	else	cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
using namespace std;

struct Edge{
    int to,d,c,next;
}edge[200005];

struct Node{
    int u,d;
    bool operator < (const Node &A) const{
        return d > A.d;
    }
}node[200005];
int vis[200005],use[200005];

int head[200004];

int dis[200005];
int to[100005];
priority_queue<Node> Q;
int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m) && n+m){
        while(!Q.empty()) Q.pop();
        memset(vis,0,sizeof(vis));
        memset(use,0,sizeof(use));
        memset(dis,0x3f,sizeof(dis));
        memset(head,-1,sizeof(head));
        memset(to,0,sizeof(to));
        dis[1] = 0;
        
        int cnt = 1;
        int u,v,d,c;
        for(int i = 1;i <= m;++i){
            scanf("%d%d%d%d",&u,&v,&d,&c);
            edge[cnt].to = v,edge[cnt].d = d,edge[cnt].c = c,edge[cnt].next = head[u],head[u] = cnt++;
            edge[cnt].to = u,edge[cnt].d = d,edge[cnt].c = c,edge[cnt].next = head[v],head[v] = cnt++;
        }
        
        int tot = 0;
        Node A;
        A.d = 0,A.u = 1;
        Q.push(A);
        
        while(tot < n){
            A = Q.top();
            int u = A.u;
            if(!vis[u]){
                //cout << u << ' ' << dis[u] << endl;
                tot++;
                vis[u] = 1;
                for(int i = head[u];i != -1;i = edge[i].next){
                    int v = edge[i].to;
                    if(dis[v] > dis[u] + edge[i].d){
                        use[to[v]] = 0;
                        dis[v] = edge[i].d + dis[u];
                        to[v] = i;
                        use[i] = 1;
                        if(!vis[v]){
                            Node tmp;
                            tmp.u = v,tmp.d = dis[v];
                            Q.push(tmp);
                        }
                    }
                    else if(dis[v] == dis[u] + edge[i].d){
                        if(edge[to[v]].c > edge[i].c){
                            use[to[v]] = 0;
                            to[v] = i;
                            use[i] = 1;
                        }
                    }
                }
            }
            Q.pop();
        }
        int ans = 0;
        for(int i = 1;i < cnt;++i){
            if(use[i]){
                ans += edge[i].c;
            }
        }
        cout << ans << endl;
        
    }
    return 0;
}



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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    V<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    V<int> dp(k + 1);
    for (int i = 1; i <= k; i++) {
        for (int j: a) {
            if (j <= i && dp[i - j] == 0) dp[i] = 1;
        }
    }
    if (dp.back()) cout << "First" << endl;
    else cout << "Second" << endl;

    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int ptr=0;
		int[] stack=new int[10];
		while(sc.hasNext()){
			int x=sc.nextInt();
			if(x==0){
				if(stack[ptr-1]!=0){
					System.out.println(stack[ptr-1]);
					stack[ptr-1]=0;
					ptr--;
				}
			}else{
				stack[ptr]=x;
				ptr++;
			}
		}
	}
}

Measured memory_bytes: 17212
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las

solve :: [Int] -> Bool
solve [] = True
solve (x:[]) = True
solve heights = let
    inner mayMax num = do
        maxNum <- mayMax
        if maxNum > num + 1 then Nothing 
        else
            pure $ max maxNum num
    in
        case foldl' inner (Just 0 ) heights of
            Nothing -> False
            _ -> True
    

main = do
    _ <- readInt
    heights <- readInts
    putStrLn $ if solve heights then "Yes" else "No"




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

int main(){
    int n, k; cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    vector<double> e_d(n);
    rep(i, n) e_d[i] = (p[i] + 1)/2.0;
    vector<double> c(n);
    c[0] = e_d[0];
    for(int i = 1; i < n; i++) c[i] = c[i-1] + e_d[i];
    double ans = c[k-1];
    for(int i = 1; i <= n - k; i++){
        ans = max(ans, c[i+k-1] - c[i-1]);
    }
    cout << fixed << setprecision(7) << ans << endl;
}

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

using namespace std;
using ll = long long;
const ll INF = 1e18;

int main()
{
    ll n, m, r;
    cin >> n >> m >> r;
    vector<vector<pair<ll,ll>>> hen(n);
    vector<ll> dist(n, INF);
    for(ll i = 0; i < m; i++) {
        ll a, b, d;
        cin >> a >> b >> d;
        hen[a].emplace_back(b, d);
    }

    {
        bool ok = true;
        ll cycle = 0;
        dist[r] = 0;
        while(ok) {
            ok = false;
            for(ll i = 0; i < n; i++) {
                if(dist[i] == INF)continue;
                for(auto j : hen[i]) {
                    if(dist[j.first] > dist[i] + j.second)ok = true;
                    dist[j.first] = min(dist[j.first], dist[i] + j.second);
                }
            }
            if(cycle >= 2 * n && ok) {
                cout << "NEGATIVE CYCLE" << endl;
                return 0;
            }
            cycle++;
        }
    }

    for(ll i = 0; i < n; i++) {
        if(dist[i] == INF) {
            cout << "INF" << endl;
        } else {
            cout << dist[i] << endl;
        }
    }


}


Measured memory_bytes: 3176
def dfs(a,y,x)
  a[y][x]=?.
  sum=1
  [0,1,0,-1,0].each_cons(2) do |dy, dx|
    ny=y+dy
    nx=x+dx
    next unless 0<=nx && nx<W
    next unless 0<=ny && ny<H
    next unless a[ny][nx]==?#
    sum += dfs(a,ny,nx)
  end
  sum
end

H,W=gets.split.map &:to_i
A=H.times.map{gets.chomp}
puts dfs(A,0,0)==(H+W-1) ? "Possible" : "Impossible"


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

int main()
{
	int nN, nX;
	while (cin >> nN >> nX, nN | nX)
	{
		int nCount = 0;
		for (int a = 1; a < nX / 3; ++a)
		{
			for (int b = a + 1; b < nX * 2 / 3; ++b)
			{
				if (nX - a - b > b&&nX - a - b <= nN)
				{
					nCount++;
				}
			}
		}
		cout << nCount << endl;
	}
	//getchar();
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define INF 100000000000

using namespace std;
vector<ll> hold;
unordered_map<ll,ll> ma;
unordered_map<ll,ll> mar;

bool isCyclicUtil(ll v, bool visited[], bool *recStack, vector<ll> adj[], bool he) 
{ 
    if(mar[v] == 1)
        return 0;
    if(visited[v] == false) 
    { 
        visited[v] = true; 
        recStack[v] = true; 
        //list<ll>::iterator i; 
        for(auto i = adj[v].begin(); i != adj[v].end(); ++i) 
        { 
            if ( !visited[*i] && isCyclicUtil(*i, visited, recStack, adj,he) ) 
            {
                if(he)
                    hold.pb(v), ma[v] = 1;
                return true; 
            }
            else if (recStack[*i]) 
            {
                if(he)
                    hold.pb(v), ma[v] = 1;
                return true;
            }
        } 
  
    } 
    recStack[v] = false;   
    return false; 
} 
  
bool isCyclic(ll V, vector<ll> adj[],bool he) 
{ 
    bool *visited = new bool[V]; 
    bool *recStack = new bool[V]; 
    for(ll i = 0; i < V; i++) 
    { 
        visited[i] = false; 
        recStack[i] = false; 
    } 
    
    for(ll i = 0; i < V; i++) 
        if (isCyclicUtil(i, visited, recStack,adj,he)) 
            return true; 
  
    return false; 
} 


int main()
{
   FAST/**/
    
   ll n,m;
   cin>>n>>m;
   vector<ll> v[n];
   ll mat[n][n];
   memset(mat,0,sizeof(mat));
   
   for(ll i=0;i<m;i++)
   {
       ll a,b;
       cin>>a>>b;
       
       a--,b--;
       mat[a][b] = 1;
       v[a].pb(b);
       //v[b].pb(a);
   }
   
   bool pos = isCyclic(n,v,1);
   if(pos == 0)
   {
       cout<<-1;
       return 0;
   }
   
   vector<ll> g[n];
   
   for(ll i=0;i<hold.size();i++)
   {
        for(ll j=0;j<hold.size();j++)
        {
            if(mat[hold[i]][hold[j]])
                g[hold[i]].pb(hold[j]);
        }
   }
   
   ll cnt = 0;
   
   for(ll i=0;i<hold.size();i++)
   {
       //cout<<"ith is "<<hold[i] + 1<<"\n";
       mar[hold[i]] = 1;
       cnt++;
       bool temp = isCyclic(n,g,0);
       if(temp == 0)
            mar[hold[i]] = 0,cnt--;
   }
   
   ll ans = hold.size() - cnt;
   cout<<ans<<"\n";
   for(ll i=0;i<hold.size();i++)
   {
       if(mar[hold[i]] == 0)
            cout<<hold[i]+1<<"\n";
   }
       
   
   return 0;
}

Measured memory_bytes: 10368
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll ans=s.size();
    rep(i,(ll)s.size()-1){
        if(s[i]!=s[i+1]){
            ans=min(ans,max(i+1,(ll)s.size()-i-1));
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  
  long long a,b,c,k,sum=0;
  cin >> a >> b >> c >> k;
  sum+=(a+b+c);
  long long x=max(a,max(b,c));
  sum-=x;
  for(long long i=0; i<k; i++){
    x*=2;
  }
  cout << x+sum << endl;
}

Measured memory_bytes: 3564
N, H, W = list(map(int, input().split()))
A, B = [], []
count = 0
for i in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)
for i, j in zip(A, B):
    if i>=H and j>=W:
        count += 1
print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

ll mod_pow(ll x, ll n, ll mod){ // x ^ n % mod
    ll res = 1;
    while(n > 0){
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int ask(int a,int b,int c,int d){
	cout<<"? "<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"<<flush;
	int res;
	cin>>res;
	return res;
}

ll h, w, n, K;
int a[55][55];

int main() {
    cin >> h >> w >> n >> K;
    rep(i,h)rep(j,w)a[i][j] = -1;

    int sol = 2;
    if(sol == 1){
        rep(i,h){
            rep(j,w){
                if(i%2==0&&j%2==0){
                    int res = ask(i,j,i+1,j+1);
                    if(res == 0){
                        a[i][j] = a[i][j+1] = a[i+1][j] = a[i+1][j+1] = 0;
                    }
                    if(res == 4){
                        a[i][j] = a[i][j+1] = a[i+1][j] = a[i+1][j+1] = 1;
                    }
                }
            }
        }
    }

    if(sol == 2){
        rep(i,h){
            rep(j,5){
                int bomb = ask(i,j*10,i,j*10+9);
                if(bomb == 0){
                    srep(k,j*10,j*10+9)a[i][k] = 0;
                    continue;
                }
                if(bomb == 1){
                    int l = 0, r = 10;
                    while(l+1 < r){
                        int m = (l+r)/2;
                        int tmp = ask(i,j*10+l,i,j*10+m-1);
                        if(tmp == 1) r = m;
                        else l = m;
                    }
                    srep(k,j*10,j*10+9)a[i][k] = 0;
                    a[i][j*10+l] = 1;
                    continue;
                }
                if(bomb >= 2){
                    srep(k,j*10,j*10+9){
                        if(bomb == 0){
                            a[i][k] = 0;
                        }else{
                            a[i][k] = ask(i,k,i,k);
                        }
                        bomb -= a[i][k];
                    }
                }
            }
        }
    }
        





    // 愚直
    int cnt = 0;
    rep(i,h){
        rep(j,w){
            if(a[i][j] == 1){
                cnt++;
                if(cnt == n)break;
                continue;
            }
            if(a[i][j] == -1){
                cout << "? " << i << " " << j << " " << i << " " << j << endl << flush;
                int res;
                cin >> res;
                a[i][j] = res;
                cnt += a[i][j];
            }
            if(cnt == n)break;
        }
        if(cnt == n)break;
    }

    // ans出力
    ll ans = 0;
    rep(i,h){
        rep(j,w){
            if(a[i][j]==1)ans = (ans + mod_pow(2,i*w+j,K)) % K;
        }
    }
    cout << "! " << ans << endl << flush;
    return 0;
}




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

int main() {
  int64_t N, K;
  cin >> N >> K;
  vector<int64_t> A(N);
  int64_t sum=0;
  for(int64_t i; i<N; i++){
    cin >> A[i];
  }
  
  sort(A.begin(), A.end());
  
  if(K >= N) cout << 0 << endl;
  else{
    rep(i, N-K){
      sum += A[i];
    }
    cout << sum << endl;
  }

}

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



using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long int ll;
const ll N = 62;
const int mod = 1000000007;
const long long int inf = 10e12;
#define pp pair<ll,ll>
 
typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<*i<<" "; cout<<endl; 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   
void fastIO(void);
 
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);


int main()
{ 
   ll n;
   cin>>n;
   ll a[n];
   rep(i,n) cin>>a[i];
   ll zero[N], one[N];
   rep(i,N){
      one[i] = 0;
      zero[i] = 0;
   }
   rep(i,n){
      rep(j,N){
         if(a[i]%2==0) zero[j]++;
         else one[j]++;
         a[i] = a[i]/2;
      }
   }
   ll ans = 0;
   rep(i,N){
     // cout<<zero[i]<<" "<<one[i]<<endl;
      ans = modadd(ans,modmulti(zero[i],modmulti(one[i],modpower(2,i))));
   }
   cout<<ans<<endl;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   return ((a%mod)+(b%mod)+mod)%mod;
}
ll modpower(ll a, ll n){
   if(n==0)
      return 1;
   ll result = 1;
   while(n>0){
      if(n%2==1)
         result = modmulti(result,a);
      a = modmulti(a,a);
      n = n/2;
   }
   return result;
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}
 



Measured memory_bytes: 2560
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class Task {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt(), W = in.nextInt();
            int[] w = new int[n + 1];
            long[] v = new long[n + 1];

            for (int i = 1; i < n + 1; i++) {
                w[i] = in.nextInt();
                v[i] = in.nextLong();
            }

            long[][] dp = new long[n + 1][W + 1];

            for (int i = 0; i < n + 1; i++) {

                for (int j = 0; j < W + 1; j++) {
                    if (i == 0 || j == 0)
                        dp[i][j] = 0;
                    else if (j >= w[i]) {
                        dp[i][j] = Math.max(v[i] + dp[i - 1][j - w[i]], dp[i - 1][j]);
                    } else
                        dp[i][j] = dp[i - 1][j];
                }
            }

            out.println(dp[n][W]);
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

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

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

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

    }
}



Measured memory_bytes: 125392
#include <stdio.h>

int search(const int p[],int flag[],int length){
    int minVal = 1000,minIndex = 0;
    for(int i = 0;i < length;i++){
        if(p[i] <= minVal && flag[i] != 1){
            minVal = p[i];
            minIndex = i;
        }
    }
    flag[minIndex] = 1;
    return minVal;
}

int main() {
    int n,k;
    int p[1000];
    int flag[1000];
    int ans = 0;
    scanf("%d %d",&n,&k);
    for(int i = 0;i < n;i++){
        scanf("%d",&p[i]);
        flag[i] = 0;
    }
    for(int i = 0;i < k;i++){
        ans += search(&p[0],&flag[0],n);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1700
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;
int dp[100][100][2][2];

int main() {
  dp[0][0][0][0] = 1;
  dp[0][0][1][0] = 1;
  for (int i = 0; i < 100; ++i) {
    for (int j = 0; j < 100; ++j) {
      if (i >= 1) {
        dp[i][j][0][0] = (dp[i-1][j][0][0] + dp[i-1][j][0][1]) % 100000;
        dp[i][j][1][1] = dp[i-1][j][0][0];
      }
      if (j >= 1) {
        dp[i][j][1][0] = (dp[i][j-1][1][0] + dp[i][j-1][1][1]) % 100000;
        dp[i][j][0][1] = dp[i][j-1][1][0];
      }
    }
  }
  while(1){
    int w,h;
    cin >> w >> h;
    if(!w)break;
    int sum = 0;
    for (int i = 0; i < 2; ++i)
      sum += dp[w-1][h-1][i][0];
    if (w > 1 || h > 1)
      cout << (sum % 100000) << endl;
    else
      cout << 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1316
#define scanf_s scanf
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;
#define MAX 20
int main(void)
{
	int n, cou;
	int i = 0, j = 0, l = 0, k = 0;
	while (scanf_s("%d", &n) != EOF) {
		for (int i = 0; i <= 9 && i <= n; ++i) {
			for (int j = 0; j <= 9 && i + j <= n; ++j) {
				for (int l = 0; l <= 9 && i + j + l <= n; ++l) {
					for (int k = 0; k <= 9 && i + j + l + k <= n; ++k) {
						if (i + j + l + k == n) ++cou;
					}
				}
			}
		}
		printf("%d\n", cou);
		cou = 0;
	}
}

Measured memory_bytes: 1188
#include<vector>
#include<algorithm>
using namespace std;
class LowLink{
private:
    vector<vector<int>> Graph;
    vector<bool> visited; 
    vector<int> order, low;

    void dfs(int u = 0 , int ord = 0, int par = -1){
        visited[u] = true;
        order[u] = ord;
        low[u] = ord;
        bool is_articulation = false;
        int deg = 0;
        for(int& v : Graph[u]){
            if(par == v) continue;
            if(visited[v] == false){
                deg++;
                dfs(v, ord+1, u);
                is_articulation |= (par != -1 && order[u] <= low[v]);
                low[u] = min(low[u], low[v]);
                if(order[u] < low[v]) bridge.emplace_back(make_pair(u, v));
            } else {
                low[u] = min(low[u], order[v]);
            }
        }
        is_articulation |= (par == -1 && deg > 1);
        if(is_articulation) articulation.emplace_back(u);
    }
public:
    vector<int> articulation;
    vector<pair<int, int>> bridge;
    LowLink() = delete;
    LowLink(vector<vector<int>>& G) :  Graph(G){
        visited.assign(Graph.size(), false);
        order.resize(Graph.size());
        low.resize(Graph.size());
        dfs(); 
    }

    vector<int> get_articulation(){
        return articulation;
    }

    vector<pair<int,int>> get_bridge(){
        return bridge;
    }
};

#include<iostream>
int main(){
    int V, E, u, v;
    cin >> V >> E;
    vector<vector<int>> G(V);
    for(int i = 0; i < E; i++){
        cin >> u >> v;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    LowLink lowlink(G);
    auto articulations = lowlink.get_articulation();
    sort(articulations.begin(), articulations.end());
    for(auto& v : articulations){
        cout << v << endl;
    }
}


Measured memory_bytes: 4912
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N;
string a, b;
vector<vector<char>> v(2);

int main(void){
    
    scanf("%d", &N);
    cin >> a >> b;
    
    for(int i = 0; i < N; ++i){
        if(a[i] == a[i + 1]) v[0].push_back(a[i]), v[1].push_back(b[i]), ++i;
        else v[0].push_back(a[i]), v[1].push_back(b[i]);
    }
    
    int n = v[0].size();
    
    ll ans = (v[0][0] == v[1][0]) ? 3 : 6;
    for(int i = 1; i < n; ++i){
        if(v[0][i] == v[1][i]){
            if(v[0][i - 1] == v[1][i - 1]) ans *= 2;
        }
        else{
            if(v[0][i - 1] == v[1][i - 1]) ans *= 2;
            else ans *= 3;
        }
        ans %= MOD;
    }
    printf("%lld\n", ans);
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<LL,LL>
#define pb(x) push_back(x)
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define mii map<int,int>
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define N 200005
//#define M 1000005
#define pi 3.14159265359
#define cpdd const pdd
#define MAXN 100005
#define MAXD 2
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
char F(int a,int b,int i,int x){
	if(a<=x&&b<=x){
		if(i<=a)
		return 'A';
		else
		return 'B';
	}
	if(a>b){
		int Max=a/x+1,Min=1;
		while(Max>Min+1){
			int mid=(Max+Min)/2;
			int aa=a-mid*x;
			int bb=b-mid+1;
			if(bb/(aa+1)<x||(bb/(aa+1)<=x&&bb%(aa+1)==0)){
				Min=mid;
			}
			else{
				Max=mid;
			}
		}
		if(i<=Min*(x+1)){
			if(i%(x+1)==0)
			return 'B';
			else
			return 'A';
		} 
		else{
			return F(a-Min*x,b-Min,i-Min*(x+1),x);
		}
	}
	else{
		int Max=b/x+1,Min=1;
		while(Max>Min+1){
			int mid=(Max+Min)/2;
			int aa=a-mid+1;
			int bb=b-mid*x;
			if(aa/(bb+1)<x||(aa/(bb+1)<=x&&aa%(bb+1)==0)){
				Min=mid;
			}
			else{
				Max=mid;
			}
		}
	//	printf("%d %d %d %d\n",a,b,x,Min);
		if(i>a+b-Min*(x+1)){
			i-=a+b-Min*(x+1);
			if(i%(x+1)==1)
			return 'A';
			else
			return 'B'; 
		}
		else{
			return F(a-Min,b-Min*x,i,x);
		}
	}
}
int main(){
	int q;
	scanf("%d",&q);
	while(q--){
		int a,b;
		int c,d;
		scanf("%d %d %d %d",&a,&b,&c,&d);
		int x;
		if(a>b){
			x=a/(b+1);
			if(a%(b+1)!=0)
			x++;
		}
		if(b>a){
			x=b/(a+1);
			if(b%(a+1)!=0)
			x++;
		}
	//	printf("%d",x);
		for(int i=c;i<=d;i++){
			if(a==b){
				if(i%2==1)
				printf("A");
				else
				printf("B");
			}
			else
			printf("%c",F(a,b,i,x));
		}
		printf("\n");
	}
}
//AABAAABBABBABBABBABB

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <math.h>
#include <cstdio>
#include <iomanip>
typedef  long long ll;
using namespace std;


bool is_sosu(ll n){
	if ( n <= 1 ) return false;
	for (ll i = 2; i * i <= n; i++)
	{
		if (n % i == 0) return false;
	}
	return true;
}

vector<ll> yakusu(ll n){
	vector<ll> res;
	for (int i = 1; i * i <= n; i++)
	{
		if (n % i == 0)
		{res.push_back(i);
		if (i != n / i) res.push_back(n / i);
		}
	}
	sort(res.begin(), res.end());
	return res;
}

ll check_digi(ll n){
	ll digit = 0;
	while (n > 0)
	{
		digit++;
		n /= 10;
	}
	return digit;
}

int main(void) {
	ll n;
	cin >> n;
	int ans = 1000;
	for (ll a = 1; a * a <= n; a++)
	{
		if (n % a == 0)
		{
			ll b = n / a;
			int f = max(check_digi(a), check_digi(b));
			ans = min(ans, f);
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    nDict = dict()
    Atype = list(set(A))
    Atype.sort(reverse = True)
    Atype.append(0)
    for i, a in enumerate(A):
        if a in nDict: nDict[a].append(i)
        else: nDict[a] = [i]
    count = [0] * N
    minIndex = N
    group = 0
    for i in range(len(Atype) - 1):
        cN = Atype[i]
        minIndex = min(minIndex, nDict[cN][0])
        group += len(nDict[cN])
        nextN = Atype[i + 1]
        count[minIndex] += (cN - nextN) * group
    print("\n".join(map(str, count)))

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 38924
a,b,c,d=map(int,list(input()))
 
lis=[[i,-i] for i in [b,c,d]]
#print(lis)
for i in range(8):
    sam=[a]
    #print(sam)
    for j in range(3):
        boolen=((i>>j)&1)
        sam.append(lis[j][int(boolen)])
    #print(sam)
    if sum(sam)==7:
        #print(sam)
        dis=[str(sam[0])]
        for num in sam[1:]:
            if num>=0:
                dis.append('+'+str(num))
            else:
                dis.append(str(num))
        print('%s%s%s%s=7'%(dis[0],dis[1],dis[2],dis[3]))
        break

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

struct Trie {
	Trie *next[26];
	vector<int>cnt;

	Trie() {
		fill(next, next + 26, (Trie *)0);
		cnt.resize(27);
	}

	void insert(const char *s) {
		//cerr << *s << endl;
		if (*s == '\0') {
			cnt[26]++;
			return;
		}
		else cnt[*s - 'a']++;
		if (this->next[*s-'a'] == NULL)
			this->next[*s-'a'] = new Trie();
		this->next[*s-'a']->insert(s + 1);
	}

	bool find(const char *s) {
		if (*s == '\0') return true;
		if (this->next[*s] == NULL)
			return false;
		return this->next[*s]->find(s + 1);
	}
};

int solve(Trie* trie, int depth) {
	int maxDepth = depth;
	bool equal = true;
	for (int i = 0; i < 26; i++) {
		if (trie->cnt[i] >= 2) {
			maxDepth = max(maxDepth, solve(trie->next[i], depth + 1));
		}
		if (trie->cnt[i] != 0)equal = false;
	}
	if (trie->cnt[26] >= 2)equal = true;

	if (equal)return 100;

	return maxDepth;
}

int main()
{
	while (1) {
		int n; cin >> n;
		if (n == 0)break;
		Trie* trie = new Trie();
		for (int i = 0; i < n; i++) {
			string s; cin >> s;
			string code;
			code.push_back(s[0]);
			bool flag = false;
			for (int j = 0; j < s.size(); j++) {
				if (flag)code.push_back(s[j]);
				if (s[j] == 'a' || s[j] == 'i' || s[j] == 'u' || s[j] == 'e' || s[j] == 'o')flag = true;
				else flag = false;
			}

			trie->insert(code.data());
		}

		int ans = solve(trie, 1);
		if (ans == 100)cout << -1 << endl;
		else cout << ans << endl;
	}
    return 0;
}

Measured memory_bytes: 6320
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> m(n+1, n);
	rep(i, n) {
		cin >> a[i];
		m[i+1] = min(m[i], a[i]);
	}
	int ans = 0;
	rep(i, n) {
		if (a[i] <= m[i+1]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
--import Data.Array.Unboxed
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
-- templete

nextStep (x,y) = filter (\(x,y) -> 0<=x && x<=9 && 0<=y && y<=9) $ concat [[(x+t,y-2), (x+t,y+2), (x-2,y+t), (x+2,y+t)] | t <- [-1..1]]

near (x,y) (x',y') = max (abs $ x-x') (abs $ y-y') <= 1

f :: [(Int,Int)] -> (Int,Int) -> [(Int,Int)]
f ps s = map head $ group $ sort [ns | p <- ps, ns <- nextStep p, near s ns]

main = do
    [px,py] <- getInts
    unless (px==0 && py==0) $ do
        getLine
        ds <- map (apply2 (,)) . splitRec 2 <$> getInts
        putStrLn $ cond "NA" "OK" $ null $ foldl f [(px,py)] ds
        main


Measured memory_bytes: 4044
z['   '],i;
main(j){
	for(;++i<2e3;)
//		if(!(z[i>>5]&1<<i))
			for(j=-2*i*~i;j<5e6;j+=i-~i)z[j>>5]|=1<<j;
	for(;scanf("%d",&i),i;)
		for(j=i+1>>1;i;)
			z[--j>>5]&1<<j|
			z[j-1>>5]&1<<j-1|
			z[j-3>>5]&1<<j-3|
			z[j-4>>5]&1<<j-4||printf("%d\n",j*2+1,i=0);
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int N; cin >> N;
	int ans = 0;
	for(int C = 1; C < N; C++) {
		for(int A = 1; A * A <= N - C; A++) {
			if((N - C) % A == 0) {
				if(A * A < N - C) ans += 2;
				else ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
MOD = 10**9 + 7
n = int(input())

def pow(x, n):
    res = 1
    while n > 0:
        if n & 1:
            res = res * x % MOD
        
        x = x**2 % MOD
        n >>= 1
    return res

print((pow(10,n) - pow(9,n)*2 + pow(8,n)) % MOD)

Measured memory_bytes: 61764
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
    int i,j;
    int n, t, l, b;
    while(cin >> n >> t >> l >> b, n){
        vi in(n+1,0);//1:L,2:B
        rep(i,l){
            int t;
            cin >> t;
            in[t] = 1;
        }
        rep(i,b){
            int t;
            cin >> t;
            in[t] = 2;
        }
        double dp[105][105] = {};
        dp[0][0] = 1;
        rep(i,t)rep(j,n)if(dp[i][j] > 0){
            loop(k,1,7){
                int ne = j+k;
                if(ne > n){
                    ne -= n;
                    ne = n - ne;
                }
                if(in[ne] == 2){//back
                    dp[i+1][0] += dp[i][j]/6.0;
                }else if(in[ne] == 1){//lose
                    dp[i+2][ne] += dp[i][j]/6.0;
                }else{
                    dp[i+1][ne] += dp[i][j]/6.0;
                }
            }
        }

        double ans = 0;
        rep(i,t+1) ans += dp[i][n];
        cout << shosu(10) << ans << endl;
    }
}



Measured memory_bytes: 3392
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int W = sc.nextInt();
		sc.close();
		if(W>=S) {
			System.out.println("unsafe");
		}else {
			System.out.println("safe");
		}

	}

}

Measured memory_bytes: 35708
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

int main() {
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    int mx = max(max(A1, A2), A3);
    int mn = min(min(A1, A2), A3);

    cout << mx - mn << endl;

    return 0;
}

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

#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

   /*
   int A,B,C;
   cin>>A>>B>>C;

   int m = A%B;
   if(m == 0){
      if(C == 0){
         cout<<"YES"<<endl;
         return 0;
      }
      else{
         cout<<"NO"<<endl;
         return 0;
      }
   }
   cout<<m<<endl;
   */

   ll N,T;
   cin>>N>>T;
   ll ans = 0;
   vector<ll>t(N);
   for(int i=0;i<N;i++)cin>>t[i];
   for(int i=0;i<N;i++){
      if(i==N-1)ans+=T;
      else{
         if(t[i+1]<t[i]+T)ans += T-(t[i]+T-t[i+1]);
         else ans += T;
      }
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 1792
a = []
b = "ij"
for i in range(5):
    a.append(int(input()))
    

n = int(input())
for j in range(5):
             for k in range(5):
                 if -n <= a[j]-a[k] <= n:
                     pass
                 else:
                     b = ":("
                     break
if b == ":(":
             print(b)
else:
             print("Yay!")

Measured memory_bytes: 3060
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int l = s.length();
        //System.out.println(s.substring(l - 1, l));
        if(s.substring(l - 1, l).equals("s")){
            System.out.print(s);
            System.out.println("es");
        }else{
            System.out.print(s);
            System.out.println("s");
        }
    }
}


Measured memory_bytes: 35644
using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		while(true){
		var d=double.Parse(Console.ReadLine());
			if(d==0.0)break;
			Sol mySol =new Sol(d);
			mySol.Solve();
		}
	}
}

class Sol{
	public void Solve(){
		double eps=1e-9;
		if(px*vy-py*vx>eps || px*vy-py*vx<-eps){
			Console.WriteLine("impossible");
			return;
		}
		
		double r=Math.Abs(vx)<eps?py/vy:px/vx;
		
		
		if(r<-eps){
			if(Math.Sqrt(px*px+py*py)<D+eps){
				Console.WriteLine(Math.Sqrt(px*px+py*py));
				return;
			}
			Console.WriteLine("impossible");
			return;
		}
		if(r>eps){
			if((2.0-Math.Sqrt(px*px+py*py))<D+eps){
				Console.WriteLine(2.0-Math.Sqrt(px*px+py*py));
				return;
			}
			Console.WriteLine("impossible");
			return;
		}
	}
	double D;
	double px;
	double py;
	double vx;
	double vy;
	public Sol(double d_){
		D=d_;
		var d=rda();
		px=d[0];py=d[1];vx=d[2];vy=d[3];
	}




	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}

Measured memory_bytes: 5792
class UnionFind
    def initialize(size)
        @parent = Array.new(size)
        @rank = Array.new(size, 0)
        N.times{|i| @parent[i] = i}
    end 

    def find(x)
        return x if @parent[x] == x
        return @parent[x] = find(@parent[x])
    end

    def unite(x, y)
        x = find(x)
        y = find(y)
        if @rank[x] < @rank[y] then
            @parent[x] = y
        else
            @parent[y] = x
            @rank[x] += 1 if @rank[x] == @rank[y]
        end
    end

    def same?(x, y)
        return find(x) == find(y)
    end
end

N, M = gets.split.map(&:to_i)
P = gets.split.map(&:to_i)
xy = M.times.map { gets.split.map(&:to_i) }
uf = UnionFind.new(N)
xy.each{|v| uf.unite(v[0] - 1, v[1] - 1)}
puts N.times.select{|v| uf.same?(v, P[v] - 1)}.length

Measured memory_bytes: 17972
#include <iostream>
#include <vector>
#include <cmath>
#include <limits>
#include <algorithm>

using namespace std;
typedef long long int ll;

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

	vector<string> substrings;

	for(int i=0; i<S.length(); i++) {
		int n = min(K, int(S.length()-i));
		for(int j=1; j<=n; j++) {
			substrings.push_back(S.substr(i, j));
		}
	}

	sort(substrings.begin(), substrings.end());
	unique(substrings.begin(), substrings.end());
	cout << substrings[K-1] << endl;
}


Measured memory_bytes: 1160