akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <utility>
#include <algorithm>

using namespace std;

int solve( int w[], int n, int wmin , int wmax ){

    int i, buffer, ans = 0;

    int V[n];

    int A[n], T[ wmax + 1 ];

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

        V[i] = 0;

        A[i] = w[i];

    }

    sort( A, A + n );

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

        T[ A[i] ] = i;

    }

    int an, wsum, m, cursor;

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

        if( V[i] ) continue;

        cursor = i;

        an = 0;
        wsum = 0;
        m = 1000000;

        

        while(1){

            V[ cursor ] = 1;

            an++;

            buffer = w[cursor];

            m = min( m , buffer );

            wsum += buffer;

            cursor = T[ buffer ];



            if( V[cursor] ) break;

        }

        ans += min( ( wsum + (an - 2 ) * m ) , ( wsum + m + ( an + 1 ) * wmin ) );


    }

    return ans;

}



int main(){

    int n , i;

    scanf("%d", &n);

    int w[n], wmax = 0, wmin = 1000000;

    for( i = 0 ; i < n ; i++ ){
        
        scanf("%d", &w[i]);

        wmax = max( wmax, w[i] );

        wmin = min( wmin, w[i] );

    }


    int answer;

    answer = solve( w, n , wmin, wmax);

    printf("%d\n", answer);

    return 0;

}

Measured memory_bytes: 2768
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

ll a,b;

void solve(){
 cin >> a >> b;
 
  if(a<=b) cout << "unsafe" << endl;
  else cout << "safe" << endl;
 
}

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

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int n,a[100010][4],x[100010],f[2],g[2];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j;
	scanf("%d",&n);
	for(i=1;i<=3;i++)
	  for(j=1;j<=n;j++)
	    scanf("%d",&a[j][i]);
	for(i=1;i<=n;i++)
	  {
	   x[i]=(a[i][1]-1)/3;
	   if(a[i][1]==3*x[i]+1 && a[i][2]==3*x[i]+2 && a[i][3]==3*x[i]+3)
	     x[i]++;
	   else if(a[i][1]==3*x[i]+3 && a[i][2]==3*x[i]+2 && a[i][3]==3*x[i]+1)
	     x[i]=-x[i]-1;
	   else
	     {
		  printf("No\n");
		  return 0;
		 }
	  }
	for(i=1;i<=n;i++)
	  if((x[i]^i)&1)
	    {
		 printf("No\n");
		 return 0;
		}
	for(i=1;i<=n;i++)
	  if(x[i]<0)
	    f[i&1]^=1;
	for(i=1;i<=n;i++)
	  while(abs(x[i])!=i)
	    {
	     swap(x[i],x[abs(x[i])]);
	     g[i&1]^=1;
		}
	if((f[0]^g[1]) || (f[1]^g[0])) puts("No"); else puts("Yes");
	return 0;
}

Measured memory_bytes: 2176
#include<cstdio>
#include<iostream>
#include<cmath>
#include<string.h>
using namespace std;

#define maxn 101

int flag[101][101];
char c[101][101];
int main(){

   int h, w;
   while(cin >> h >> w ){
        memset(flag, 0, sizeof(flag));
        for(int i = 0; i < h; ++i){
            scanf("%s", &c[i]);
        }

        for(int i = 0; i < h; ++i){
             int p = 1;
             for(int j = 0; j < w; ++j){
                 if(c[i][j] != '.') p = 0;
             }
             if(p){
                 for(int j = 0; j < w; ++j) flag[i][j] = 1;
             }
        }
        for(int j = 0; j < w; ++j){
              int p = 1;
              for(int i = 0; i < h; ++i){
                  if(c[i][j] != '.') p = 0;
              }
              if(p){
                 for(int i = 0; i < h; ++i) flag[i][j] = 1;
              }
        }
        for(int i = 0; i < h; ++i){
            int p = 0;
            for(int j = 0; j < w; ++j){
                if(!flag[i][j]) {cout << c[i][j]; p = 1;}
            }
            if(p == 1)
               cout <<endl;
        }

   }
  return 0;
}


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

int main(){
  int k;
  cin >> k;
  if(k%2 == 0) cout << k*k/2/2 << endl;
  else cout << (k/2+1)*(k/2) << endl;
}

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

cnt = len(A)
box = []

for i in range(cnt-1):
    if A[i] < A[i+1]:
        box.append(0)
    else:
        num = A[i]-A[i+1]
        A[i+1] = A[i+1] + num
        box.append(num)

print(sum(box))

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

#define sz(x) (int) x.size()

using namespace std;
using pii = pair<int, int>;

const int N = 3e3+5;
const int MOD = 1e9 + 7;

double dp[N][N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<double> p(n);
    for (double& x : p)
        cin >> x;
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i)                                                    
        for (int cnt = 0; cnt <= i; ++cnt)                                                               
            dp[i][cnt] = dp[i-1][cnt-1] * p[i-1] + dp[i-1][cnt] * (1.0 - p[i-1]);        
    double sum = 0;
    for (int cnt = 0; cnt <= n; ++cnt)
        if (cnt > n - cnt)
            sum += dp[n][cnt];
    cout << setprecision(9) << fixed << sum;
    return 0;                                                                            
}                                                                                 

Measured memory_bytes: 68992
#include <bits/stdc++.h>
using namespace std;
int rt(int *uf,int i)
{
  return uf[i]<0?i:uf[i]=rt(uf,uf[i]);
}

void con(int *uf,int a,int b)
{
  a=rt(uf,a);
  b=rt(uf,b);
  if(a!=b){
    if(-uf[a]<-uf[b]){
      uf[a]=b;
    }
    else if(-uf[a]>-uf[b]){
      uf[b]=a;
    }
    else{
      uf[a]=b;
      uf[b]--;
    }
  }
}

int main()
{
  int n,m;
  scanf("%d%d",&n,&m);
  static int uf[200000];
  for(int i=0;i<n+m;i++){
    uf[i]=-1;
  }
  for(int i=0;i<n;i++){
    int K;
    scanf("%d",&K);
    while(K--){
      int l;
      scanf("%d",&l);
      l--;
      con(uf,i,n+l);
    }
  }
  int R=rt(uf,0);
  bool F=0;
  for(int i=1;i<n;i++){
    int r=rt(uf,i);
    if(r!=R){
      F=1;
    }
  }
  puts(!F?"YES":"NO");
  return 0;
}


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

int m,n,g;
int card[7][2]; // ??°???????????°

int calc( int cnt , int N ){
	if( N < 0 ) return 0;
	if( N == 0 ) return 1;
	
	if( cnt == m-1 ){
		if( N%card[cnt][0] == 0 && N/card[cnt][0] <= card[cnt][1] ) return 1;
		else return 0;
	}
	
	int ans = 0 ;
	for( int i=0 ; i<=card[cnt][1] ; i++ ){
		ans += calc( cnt+1 , N - (i*card[cnt][0]) ) ;
	}
	
	return ans ;
}

int main(){
	
	while( cin >> m , m ){
		for( int i=0 ; i<m ; i++ ){
			cin >> card[i][0] >> card[i][1];
		}
		for( int i=0 ; i<m ; i++ ){
			for( int j=i+1 ; j<m ; j++ ){
				if( card[i][0] < card[j][0] ){
					swap( card[i] , card[j] ) ;
				}
			}
		}
		
		cin >> g ;
		while( g-- ){
			cin >> n ;
			cout << calc(0,n) << endl ;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1160
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.size = [1] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
"""
N=int(input())
X=[]
Y=[]
for i in range(N):
    x,y=map(int,input().split())
    X.append((x,i))
    Y.append((y,i))
X.sort()
Y.sort()
E=[]
ans=0
count=1
for i in range(N-1):
    a=X[i]
    b=X[i+1]
    c=Y[i]
    d=Y[i+1]
    E.extend([(b[0]-a[0],X[i][1],X[i+1][1]),(d[0]-c[0],Y[i][1],Y[i+1][1])])
E.sort()
"""
N = int(input())
P = [[i, list(map(int, input().split()))] for i in range(N)]

X = sorted([[i, xy[0]] for i, xy in P], key=lambda x: x[1])
Y = sorted([[i, xy[1]] for i, xy in P], key=lambda y: y[1])

Xe = [[X[i][0], X[i+1][0], abs(X[i][1]-X[i+1][1])] for i in range(N-1)]
Ye = [[Y[i][0], Y[i+1][0], abs(Y[i][1]-Y[i+1][1])] for i in range(N-1)]
E = sorted(Xe + Ye, key=lambda e: e[2])
U=UnionFind(N)
i=0
ans=0
count=1
while(count<N):
    v1,v2,cost=E[i]
    if not U.same_check(v1,v2):
        U.union(v1,v2)
        ans+=cost
        count+=1
    i+=1
print(ans)


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

using namespace std;

map<int, int> mp1, mp2;

int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i = 0; i < n; ++i){
        cin >> vec[i];
    }
    for(int i = 0; i < n; ++i){
        if(i % 2) mp1[vec[i]]++;
        else mp2[vec[i]]++;
    }
    int mx = 0, val = 0;
    for(auto& p : mp1){
        if(mx < p.second){
            mx = p.second, val = p.first;
        }
    }
    int mx2 = 0, val2 = 0;
    for(auto& p : mp2){
        if(mx2 < p.second){
            mx2 = p.second, val2 = p.first;
        }
    }
    if(val == val2){
        int x = 0, y = 0;
        for(auto& p : mp1){
            if(x < p.second && p.first != val) x = p.second;
        }
        for(auto& p : mp2){
            if(y < p.second && p.first != val2) y = p.second;
        }
        cout << min(n - mx2 - x, n - mx - y) << "\n";
    }else{
        cout << n - mx - mx2 << "\n";
    }
}

Measured memory_bytes: 5376
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));
		String[] s = br.readLine().trim().split(" ");
		int n = Integer.parseInt(s[0]);
		int m = Integer.parseInt(s[1]);
		int[] dist = new int[n+1];
		Map<Integer, List<Integer>> h = new HashMap<>();
		for(int i = 0; i < m; i++){
		    String[] str = br.readLine().trim().split(" ");
		    int u = Integer.parseInt(str[0]);
		    int v = Integer.parseInt(str[1]);
		    if(h.containsKey(u)){
		        h.get(u).add(v);
		    }
		    else{
		        List<Integer> l = new ArrayList<>();
		        l.add(v);
		        h.put(u, l);
		    }
		    if(h.containsKey(v)){
		        h.get(v).add(u);
		    }
		    else{
		        List<Integer> l = new ArrayList<>();
		        l.add(u);
		        h.put(v, l);
		    }
		}
		boolean[] visited = new boolean[n+1];
        Queue<Integer> q = new LinkedList<>();
        q.add(1);
        visited[1] = true;
        while(!q.isEmpty()){
            int parent = q.poll();
            for(int i : h.get(parent)){
                if(visited[i] == false){
                    q.add(i);
                    visited[i] = true;
                    dist[i] = parent;
                }
            }
        }
        boolean ans = false;
        for(int i = 2; i <= n; i++){
            if(dist[i] == 0){
                System.out.println("No");
                ans = true;
            }
        }
        if(ans != true){
            System.out.println("Yes");
            for(int i = 2; i <= n; i++){
                System.out.println(dist[i]);
            }
        }
	}
}



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

using namespace std;

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

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

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

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

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

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  string s,t;
  cin>>s>>t;
  int n = s.size();
  REP(_,n){
    if(s==t){
      puts("Yes");return 0;
    }
    s = s.substr(1,n-1) + s.substr(0,1);
  }
  puts("No");
  return 0;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb emplace_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    char c;
    cin >> c;
    char ans = c + 1;
    if (c == 'z')
        ans = 'a';
    cout << ans << endl;
}

signed main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
int inf=100000000;
ll INF=100000000000000000;
ll MOD=1000000007;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> e(n,vector<int>(0));
    int y,u;
    rep(i,n-1){
        cin >> y >> u;
        e.at(y-1).push_back(u-1);
        e.at(u-1).push_back(y-1);
    }
    vector<int> b(n);
    rep(i,n) b.at(i)=0;
    b.at(0)=1;
    b.at(n-1)=1;
    queue<pp> q;
    pp v;
    int fe=0,nu=0;
    v.first=0;v.second=0;
    q.push(v);
    v.first=n-1;v.second=1;
    q.push(v);
    while(!q.empty()){
        int o=q.front().first,l=q.front().second;
        q.pop();
        for (int i=0;i<e.at(o).size();i++){
            if (b.at(e.at(o).at(i))==0){
                b.at(e.at(o).at(i))=1;
                if (l==0) fe++;
                if (l==1) nu++;
                v.first=e.at(o).at(i);
                v.second=l;
                q.push(v);
            }
        }
    }
    if (fe>nu) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
}


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

int main()
{
  bool pri[1000001];
  vector<int> price;
  fill(pri,pri+1000001,true);
  pri[0]=pri[1]=false;
  for(int i=2;i<1000001;i++)
    {
      if(pri[i]==0)
	continue;
      price.push_back(i);	
      for(int j=i+i;j<1000001;j+=i)
	{
	  pri[j]=false;
	}
    }
  int n;
  for(;cin>>n,n;)
    {     
      int count=0;

      for(int i=0;i<price.size();i++)
	{
	  if(n-price[i]<2)
	    break;
	  if(price[i]>(n-price[i]))
	     break;
	  if(pri[n-price[i]])
	    {
	      count++;
	    }
	}	  
      cout<<count<<endl;
    
    }
 
}

Measured memory_bytes: 2564
def main():
    n = int(input())
    flag = True
    cnt = 0
    for _ in range(n):
        i = int(input())
        if i == 2:
            flag = True
        else:
            for j in range(2, int(-(-i**0.5//1))+1):
                if i%j == 0:
                    flag = False
                    break
        if flag:
            cnt += 1
        flag = True   
    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5716
#include<bits/stdc++.h>
using namespace std;
const int MAX = 2e5;
int actv[MAX][3];
int memo[MAX][3];
int n;

int dp(int idx, int lst){
    if(idx >= n){
        return 0;
    }
    int& res = memo[idx][lst];
    if(res != 0){
        return res;
    }
    int mx = 0;
    switch (lst){
        case -1:
            mx = max(dp(idx+1, 2) + actv[idx][2], max(dp(idx+1, 0) + actv[idx][0], dp(idx+1, 1) + actv[idx][1]));
        break;
        case 0:
            mx = max(dp(idx+1, 1) + actv[idx][1], dp(idx+1, 2) + actv[idx][2]);
        break;
        case 1:
            mx = max(dp(idx+1, 0) + actv[idx][0], dp(idx+1, 2) + actv[idx][2]);
        break;
        case 2:
            mx = max(dp(idx+1, 1) + actv[idx][1], dp(idx+1, 0) + actv[idx][0]);
        break;
    }
    return res = max(res, mx);
}

int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d %d %d", &actv[i][0], &actv[i][1], &actv[i][2]);
    }
    printf("%d", dp(0, -1));
    return 0;
}



Measured memory_bytes: 15508
// 木の上で最長増加部分列 (LIS: Longest Increasing Subsequence)するだけ

#include <algorithm>
#include <array>
#include <bitset>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
using P = pair<int, int>;
constexpr int INF = 1000000000 + 8;

class Graph {
   private:
    struct edge {
        int to;
        edge(int i) : to(i) {}
    };
    vector<vector<edge>> edges;
    vector<int> numbers, answers, lis;

   public:
    Graph(int n) {
        edges.resize(n);
        numbers.resize(n);
        answers.resize(n);
        lis.assign(n, INF);
    };
    int size() const { return edges.size(); };
    void addDirectedEdge(int from, int to) { edges[from].push_back(edge(to)); }
    void addEdge(int from, int to) {
        addDirectedEdge(from, to);
        addDirectedEdge(to, from);
    }
    void writeNumber(int i, int num) { numbers[i] = num; }

    // p: 今の点の番号, pp: 移動前の点の番号, np: 移動後の点の番号
    void dfs(int p = 0, int pp = -1) {
        // LISのDP配列に今いる点の番号の情報を追加
        // 子を探索したあとにLISのDP配列をもとに戻すため、変更した要素の値とイテレータを記録
        const auto itr_updated_element =
            lower_bound(lis.begin(), lis.end(), numbers[p]);
        const int old_val_updated_element = *itr_updated_element;
        *itr_updated_element = numbers[p];

        answers[p] = lower_bound(lis.begin(), lis.end(), INF) - lis.begin();

        // 子を探索
        for (auto &&edge : edges[p]) {
            const int np = edge.to;
            if (np == pp) continue;
            dfs(np, p);
        }

        // LISのDP配列を元に戻す
        *itr_updated_element = old_val_updated_element;
    }
    int answer(int p) const { return answers[p]; }
};

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

    int n;
    cin >> n;
    Graph g(n);

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        g.writeNumber(i, a);
    }

    for (int i = 0; i < n-1; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;

        g.addEdge(u, v);
    }

    g.dfs();
    for (int i = 0; i < n; i++) {
        cout << g.answer(i) << endl;
    }
}


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


int main(){
	int N,M;
	cin >> N >> M;
	vector< pair<int,int> > e;
	int ans = N + 1 ;
	for(int i = 0 ; i < M ; i++){
		int a,b;
		cin >> a >> b;
		e.push_back(make_pair(a,b));
	}
	if( M == 0 ){
		cout << ans << endl;
		return 0;
	}
	sort(e.begin(),e.end());
	int le = e[0].first;
	int ri = e[0].second;
	for(int i = 1 ; i < M ; i++){
		if( ri < e[i].first ){
			ans += 2 * (ri - le);
			le = e[i].first;
			ri = e[i].second;
		}else ri = max(ri,e[i].second);
	}
	ans += 2 * (ri-le);
	cout << ans << endl;
	
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
int n;
int num[3] = {3,5,7};
ll dfs(ll x) {
	if (x > n) return 0;
	map<int,int> a;
	ll m = x;
	while (m > 0)
	{
		a[m%10]++;
		m /= 10;	
	}
	int res = (a[3]&&a[5]&&a[7])? 1 : 0;
	rep(i,3) {
		res += dfs(x*10+num[i]);
	}
	return res;
} 
int main() {
	cin >> n;
	cout << dfs(0) << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

main(){
	int a, b,t;
	cin  >> a >> b >> t;
	int total = (int)floor( ((double)(t) + 0.5)/(double)a   );
	cout << b*total << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections import defaultdict


def solve(N: int, A: "List[int]"):
    L = [0] * (100001)
    for a in A:
        L[a] += 1
        if L[a] >= 3:
            L[a] -= 2
    c = L.count(2)
    p, q = divmod(c, 2)
    res = sum(L) - 2 * (p + q)
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 53532
#n=int(input())
n,m=map(int,input().split())
#hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

citydic={}

def make_id(p):
    dif=6-len(str(p))
    res="".join(["0" for i in range(dif)])
    return res+str(p)

for i in range(1,m+1):
    p,y=map(int,input().split())
    templ=citydic.get(p,[])
    templ.append([i,p,y])
    citydic[p]=templ

#print(citydic)
id_dic={}

for pref, val in citydic.items():
    l=sorted(val,key=lambda x: x[2])
    for x,temp in enumerate(l,1):
        i,p,y=temp
        # make id
        cityid=make_id(p)+make_id(x)
        id_dic[i]=cityid

for i in range(1,m+1):
    print(id_dic[i])



Measured memory_bytes: 56912
#include <iostream>
#include <vector>
#include <map>

using lint = long long;

int main() {
    int n, k;
    std::cin >> n >> k;

    std::vector<int> sum(n + 1, 0);
    for (int i = 1; i <= n; ++i) {
        std::cin >> sum[i];
        (sum[i] += (sum[i - 1] + (k - 1)) % k) %= k;
    }

    std::map<int, lint> cnt;
    lint ans = 0;

    for (int i = 0; i <= n; ++i) {
        int x = sum[i];
        if (!cnt.count(x)) cnt[x] = 0;
        ans += cnt[x];

        ++cnt[x];
        if (i >= k - 1) --cnt[sum[i - (k - 1)]];
    }

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


Measured memory_bytes: 13568
#include<bits/stdc++.h>
#define ll long long
#define re register
#define ull unsigned int
using namespace std;
inline int read(){
	int s=0,t=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*t;
}
const int N=105;
int n,m,K,P,o;
int coe[N],C[N][N],p[N][N],f[2][N][N],tp[N][N];
int Mod(int x){return x>=P?x-P:x;}
void Pre(int n){
	coe[0]=1;for(int i=1;i<=n;i++)coe[i]=P-coe[i-1];
	for(int i=0;i<=n;i++){
		C[i][0]=p[i][0]=1;
		for(int j=1;j<=n;j++)p[i][j]=1ll*p[i][j-1]*i%P;
		for(int j=1;j<=i;j++)C[i][j]=Mod(C[i-1][j-1]+C[i-1][j]);
	}
}
void Clear(int t){
	for(int i=0;i<=n;i++)
	for(int j=0;j<=m;j++)f[t][i][j]=0;
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read(),m=read(),K=read(),P=read(),Pre(100);
	f[0][0][0]=1;
	for(int t=1;t<=K;t++){
		o^=1,Clear(o);
		for(int i=0;i<=n;i++)for(int j=0;j<=m;j++){
			int x=1ll*p[K-t+1][j]*p[t][m-j]%P,y=f[o^1][i][j];
			for(int a=0;a<=n-i;a++,y=1ll*y*x%P)if(f[o^1][i][j])f[o][i+a][j]=Mod(f[o][i+a][j]+1ll*C[n-i][a]%P*y%P);
		}o^=1,Clear(o);
		for(int i=0;i<=n;i++)for(int j=0;j<=m;j++){
			int x=1ll*p[K-t+1][i]*p[t][n-i]%P,y=f[o^1][i][j];if(y==0)continue;
			for(int b=0;b<=m-j;b++,y=1ll*y*x%P)if(f[o^1][i][j])f[o][i][j+b]=Mod(f[o][i][j+b]+1ll*C[m-j][b]%P*y%P);
		}o^=1,Clear(o);
		for(int i=0;i<=n;i++)for(int j=0;j<=m;j++){
			int x=1ll*(P-p[K-t][j])*p[t][m-j]%P,y=f[o^1][i][j];if(y==0)continue;
			for(int a=0;a<=n-i;a++,y=1ll*y*x%P)if(f[o^1][i][j])f[o][i+a][j]=Mod(f[o][i+a][j]+1ll*C[n-i][a]%P*y%P);
		}o^=1,Clear(o);	
		for(int i=0;i<=n;i++)for(int j=0;j<=m;j++){
			int x=1ll*(P-p[K-t][i])*p[t][n-i]%P,y=f[o^1][i][j];if(y==0)continue;
			for(int b=0;b<=m-j;b++,y=1ll*y*x%P)if(f[o^1][i][j])f[o][i][j+b]=Mod(f[o][i][j+b]+1ll*C[m-j][b]%P*y%P);
		}
	}printf("%d",f[o][n][m]);
	return 0;
}
/*2 2 2 998244353*/

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

#define REP(i,x,y) for(ll i=x; i<=y; i++)
#define BIT(t) ((long long 1) << t)
#define PER(i,y,x) for(ll i=y; i>=x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
typedef long long ll;

ll const MAX = 2e5 + 5;

struct node{
       ll pos; ll val;
};

struct sliding_largest{
       deque<node> dq;
       ll head = 0;
       ll tail = 0;
       ll x_is_xxx_than_y(ll x, ll y){//かならずイコールを含めること
               return x >= y;
       }
       void push(ll x){
               while(!dq.empty()){
                       if(x_is_xxx_than_y(x, dq.back().val)){
                               dq.pop_back();
                       }else{
                               break;
                       }
               }
               dq.push_back({tail, x});
               tail++;
       }
       void pop(){
               if(head == dq.front().pos){
                       dq.pop_front();
               }
               head++;
       }
       ll get(){
               return dq.front().val;
       }
       bool empty(){
               return dq.empty();
       }
};


struct sliding_smallest{
       deque<node> dq;
       ll head = 0;
       ll tail = 0;
       ll x_is_xxx_than_y(ll x, ll y){//かならずイコールを含めること
               return x <= y;
       }
       void push(ll x){
               while(!dq.empty()){
                       if(x_is_xxx_than_y(x, dq.back().val)){
                               dq.pop_back();
                       }else{
                               break;
                       }
               }
               dq.push_back({tail, x});
               tail++;
       }
       void pop(){
               if(head == dq.front().pos){
                       dq.pop_front();
               }
               head++;
       }
       ll get(){
               return dq.front().val;
       }
       bool empty(){
               return dq.empty();
       }
};

sliding_largest lar;
sliding_smallest sma;
vll b(MAX);
int main(){
    ll n, k;
    cin >> n >> k; 
    vll a(n+1);
    REP(i,1,n){
        cin >> a[i];
    }
    REP(i,1,n-1){
        if(a[i] < a[i+1]){
            b[i] = b[i-1] + 1;
        }else{
            b[i] = b[i-1];
        }
    }
    REP(i,1,k){
        lar.push(a[i]);
        sma.push(a[i]);
    }
    ll ans = 1;
    bool flag = 0;
    REP(i,2,n-k+1){
        lar.pop(); sma.pop();
        if(!(a[i-1] <= sma.get() && lar.get() <= a[i+k-1])){
            if(b[i+k-2] - b[i-1 ] == k-1){
                flag = 1;
                //cout << i << " / " << endl;
            }else{
                ans++;
               // cout << i << " ! " << endl;
            }
        }
        lar.push(a[i+k-1]); sma.push(a[i+k-1]);
    }   
    if(b[k-1] == k-1){
        flag = 1;
        ans--;
    }
    ans += flag;
    cout << ans << endl;
    REP(i,1,n){
     //   cout << b[i] << " ";
    }
   // cout << endl;
}


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

const int N = (int) 1e5;
int sum[N], lab[N];

int get(int a) {
    return lab[a] == a ? a : lab[a] = get(lab[a]);
}

void join(int a, int b) {
    //cout << "JOIN " << a << ' ' << b << endl;
    a = get(a);
    b = get(b);
    if (a == b) return;
    sum[b] += sum[a];
    lab[a] = b;
}

int main() {
    string s; cin >> s;
    int len = s.size();
    int n; cin >> n;
    int nnode = 0;
    for (int i = 0, j = len - 1; i < j; ++i, --j) {
        sum[i] = int(s[i]) - int(s[j]);
        ++nnode;
    }
    ++nnode;
    for (int i = 0; i < nnode; ++i) lab[i] = i;
    //for (int i = 0; i < nnode; ++i) cout << sum[i] << ' '; cout << endl;
    for (int i = nnode - 1; i > 0; --i) sum[i] -= sum[i - 1];
    //for (int i = 0; i < nnode; ++i) cout << sum[i] << ' '; cout << endl;
    for (int i = 0; i < n; ++i) {
        int l, r; cin >> l >> r; --l; --r;
        if (r <= (len - 1) / 2) {
            if (len % 2 == 1 && r == len / 2) --r;
            join(l, r + 1);
        } else if (l >= len / 2) {
            if (len % 2 == 1 && l == len / 2) ++l;
            join(len - 1 - r, len - l);
        } else {
            int a = l;
            int b = len - 1 - r;
            join(a, b);
        }
    }
    for (int i = 0; i < nnode; ++i) if (lab[i] == i && sum[i] % 26 != 0) {
        cout << "NO\n";
        return 0;
    }
    cout << "YES\n";
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  int N = S.size();
  int ans = 999;
  for (int i= 0; i <= N -3; i++){
   int num = (S.at(i) - '0') * 100 + (S.at(i + 1)- '0' )* 10 + S.at(i + 2) -'0';
   ans = min(ans,abs(753 - num));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
using namespace std;

int main(){
	string s;
	cin >> s;
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		string m;
		int a,b;
		cin >> m >> a >> b;
		if(m=="print") cout << s.substr(a,b-a+1) << endl;
		else if(m=="reverse"){
			string t;
			for(int j=0;j<a;j++) t += s[j];
			for(int j=b;j>=a;j--) t += s[j];
			for(int j=b+1;j<s.length();j++) t += s[j];
			s = t;
		}
		else if(m=="replace"){
			string p,t;
			cin >> p;
			t = s.substr(0,a) + p + s.substr(b+1,s.length()-b+1);
			s = t;
		}
	}
}

Measured memory_bytes: 1224
package main

import (
	"fmt"
)

func main() {
	var x int
	fmt.Scan(&x)

	a := 100
	var cnt int
	for {
		cnt++
		a = a + int(float64(a)*0.01)
		if a >= x {
			fmt.Println(cnt)
			return
		}
	}
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define SORT(n) sort((n).begin(),(n).end(),greater<int>())
#define SORTP sort((n).begin(),(n).end(),greater<pair<int,int>>());
#define D(x) for_each((x).begin(),(x).end(),[](auto&& x){cout<<x<<" ";});
#define ALL(n) begin(n),end(n)
#define rALL(n) rbegin(n),rend(n)
#define pb push_back
#define eb emplace_back
using LL=long long;
using ULL=unsigned long long;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const int INF = numeric_limits<int>::max();
int main()
{
    string S;
    cin >> S;
    cout << S[ 0 ] << S.size() - 2 << S[ S.size() - 1 ] << endl;
    return 0;
}

Measured memory_bytes: 256
int main(){
    int i,n,j,tem;
    int swap=0;
    int a[100];
    scanf("%d",&n);
    for(i =0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n-1;i++){
        for(j=0;j<n-i-1;j++){
            if (a[j]>a[j+1]){
            tem=a[j];
            a[j]=a[j+1];
            a[j+1]=tem;
            swap++;
           
            }
        }
    }
    for(i=0;i<n;i++){
        printf("%d",a[i]);
        if(i!=n-1){
            printf(" ");
        }
    }
    printf("\n");
    printf("%d\n",swap);
    
    return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<queue>
#include<vector>
#include<math.h>
#define ll long long
using namespace std;
int main()
{
	int n,m,l,r,i;
	int f[100010],minn=99999999,maxx=-99999999;
	cin>>n>>m;
	memset(f,0,sizeof(f));
	int mm=m;
	while(mm--)
	{
		cin>>l>>r;
		for(i=l;i<=r;i++)
		{
			f[i]++;
		}
		minn=min(minn,l);
		maxx=max(maxx,r);
	}
	int cnd=0;
	for(i=minn;i<=maxx;i++)
	{
		if(f[i]==m)
		cnd++;
	}
	cout<<cnd<<endl;
	return 0;
 } 

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;
const int MOD = 1000000007;

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

    ll n; cin >> n;

    if(n%2==1){
        cout << 0 << endl;
    } else {
        ll cnt=0;
        n/=2;

        while(n>0){
            cnt += n/5;
            n/=5;
        }
        cout << cnt <<  endl;
    }
    return 0;
}

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


int main(){
    set<int> st{1,2,3};
    int a, b; cin >> a >> b;
    st.erase(a);
    st.erase(b);
    auto itr = st.begin();
    cout << *itr << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int nex[101010];
int did[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>nex[i+1];
	
	int ret=0;
	int cur=1;
	while(cur!=2) {
		cur=nex[cur];
		ret++;
		if(ret>N) return _P("-1\n");
	}
	_P("%d\n",ret);
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 640
open Printf
open Scanf

let prn s x = printf "%s %d\n" s x

let num () = scanf "%d" (fun x -> x)
let num1 () = scanf "%d\n" (fun x -> x)
let num2 () = scanf "%d %d\n" (fun x y -> (x, y))
let num3 () = scanf "%d %d %d\n" (fun x y z -> (x, y, z))

let numN n =
  let rec loop rs k =
    if k=n then
      List.rev rs
    else
      let x = scanf " %d" (fun x -> x) in
      loop (x::rs) (k+1)
  in
  if n=0 then
    []
  else if n=1 then
    [num ()]
  else
    loop [num ()] 1

let () =
  let m = 1000000007 in
  let n = num1 () in
  let xs = numN n in
  let s = List.fold_left
            (fun s x -> (s + x) mod m) 0 xs in
  let s2 = (s * s) mod m in
  let d =
    List.fold_left
      (fun s x -> (s + (x * x)) mod m)
      0 xs
  in
  let rec loop x =
    if x >= d && (x - d) mod 2 = 0 then x else loop (x+m)
  in
  let s2 = loop s2 in
  let r = ((s2 - d) / 2) mod m in
  printf "%d\n" r


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

int main(){
    int N, K;
    cin >> N >> K;
    string s;
    cin >> s;
    vector<int> a;
    if(s[0]=='0')
        a.push_back(0);
    int temp=1;
    for(int i = 1; i < N; ++i) {
        if(s[i] == s[i-1]) {
            temp++;
        }
        else{
            a.push_back(temp);
            temp=1;
        }
    }
    a.push_back(temp);
    if(s[N-1]=='0')
        a.push_back(0);
    if(a.size() < 2*K+1) {
        cout << s.length() << endl;
        return 0;
    }
    for(int i = 1; i < a.size(); ++i) {
        a[i] += a[i-1];
    }
    int ret = a[2*K];
    for(int i = 2; i < a.size()-2*K; i+=2) {
        int temp = a[i+2*K] - a[i-1];
        if(temp > ret)
            ret = temp;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a-1;i>=(ll)b;i--)
#define Fi first
#define Se second
typedef pair<ll, ll> pll;
const ll MAX = 1000;
const char END = '\n';



int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	string S;
	char Ans;
	ll K;
	cin >> S >> K;
	bool flag = true;
	rep(i, K) {
		if (S[i] != '1') {
			flag = false;
			Ans = S[i];
			break;
		}
	}
	if (flag == false)
		cout << Ans << END;
	else
		cout << 1 << END;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long LL;
const int MaxN = 101;

LL N,W;
LL w[MaxN], v[MaxN];
LL DP[MaxN][4*MaxN][MaxN];
void solve()
{
    LL W1 = w[1];
    for(int i=1;i<=N;i++) 
    	w[i] = w[i] - W1;
	
	
    for(int i=1;i<=N;i++)
    {
        for(int j=0;j<=300;j++)
        {
            for(int k=1;k<=N;k++)
            {
                if( j >= w[i] ) 
                    DP[i][j][k] =std::max(DP[i-1][j][k], DP[i-1][j-w[i]][k-1]+v[i]);
                else 
                    DP[i][j][k] = DP[i-1][j][k];
            }
        }
    }
    LL ans = 0;
    for(int j=0;j<=300;j++)
    {
        for(int k=0;k<=N;k++)
        {
            if( k*W1+j<=W)
            {
                ans = std::max(ans, DP[N][j][k]);
            }
        }
    }
    printf("%lld\n", ans);
}

int main()
{
   
    scanf("%lld%lld", &N, &W);
    for(int i=1;i<=N;i++) scanf("%lld%lld", &w[i], &v[i]);
    solve();
   
}


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

int main() {

  int N,K;
  cin >> N >> K;
  
  int number =1;
  
  for(int i = 0; i < N; i++){
  	if(number * 2 < number + K){
      number *= 2;
    }
    
    else{
      number += K;
    }
  }

  cout << number << endl;

}




Measured memory_bytes: 3600
/*
Aldew
PROB: Multiple of Three
CLASSIFICATION: Math
DIFFICULTY:
*/

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <cmath>
#include <string>
#include <map>
#include <math.h>
#include <cstdio>
#define ll long long int


using namespace std;


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

    if (4*x >= y && ((4*x -y) % 2) == 0 && ((4*x -y) /2) <= x) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 3588
using System;

namespace ABC_171_A_C_sharp_ver
{
    class Program
    {
        static void Main(string[] args)
        {
            string word = Console.ReadLine();
            for (char c = 'a'; c <= 'z'; c++)
            {
                if (word == c.ToString())
                {
                    Console.WriteLine("a");
                    break;
                }
            }
            for (char C = 'A'; C <= 'Z'; C++)
            {
                if (word == C.ToString())
                {
                    Console.WriteLine("A");
                    break;
                }
            }
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 17356
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        PriorityQueue<Integer> pq = new PriorityQueue(Collections.reverseOrder());

        for (int i = 0 ; i < n; i++) {
            pq.add(sc.nextInt());
        }

//        debug(pq);

        for (int i = 0; i < m; i++) {
            int top = pq.remove();
            pq.add(top / 2);
        }

        long ans = 0;
        for (int i = 0; i < n; i++) {
            ans += pq.remove();
        }

        System.out.println(ans);
    }


    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 52212
#include <cstdio>
#include <cstdlib>
#include <string>
using namespace std;

int S[100];
int top = 1;
char s[10];

void push(int x) {
    S[top++] = x;
}

int pop() {
    return S[--top];
}

int main(void){
    // Your code here!
    int a, b;
    while (scanf("%s", s) != EOF) {
        if (s[0] == '+') {
            a = pop();
            b = pop();
            push(a+b);
        }
        else if (s[0] == '-') {
            a = pop();
            b = pop();
            push(b-a);
        }
        else if (s[0] == '*') {
            a = pop();
            b = pop();
            push(a*b);
        }
        else {
            push(atoi(s));
        }
    }
    printf("%d\n", S[1]);
}



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

int d;
double v[16];

double interpolate(int n,int e);
bool outlier(int e);

int main(){
  while(cin>>d && d){
    for(int i=0;i<d+3;++i) cin >>v[i];
    for(int i=0;i<d+3;++i){
      if(outlier(i)){
	cout<<i<<endl;
	break;
      }
    }
  }
}

double interpolate(int n,int e){
  double ln,numer,denom;
  ln=0.0;
  for(int i=0;i<d+3;i++){
    numer=1.0;
    denom=1.0;
    if(i!=n&&i!=e){
      for(int j=0;j<d+3;j++){
	if(j!=n&&j!=e&&j!=i){
	  numer*=n-j;
	  denom*=i-j;
	}
      }
      ln+=numer*v[i]/denom;
    }
  }
  return ln;
}

bool outlier(int e){
  for(int i=0;i<d+3;i++){
    if(i==e) continue;
    double p = interpolate(i,e);
    if(fabs(p-v[i])>0.1) return false;
  }
  return true;
}

Measured memory_bytes: 3224
//    https://youtu.be/N3oCS85HvpY

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

typedef long long ll;
typedef long double ld;
typedef long long unsigned llu;
typedef pair<long long, long long> pll;
const long long inf = 2000000000000000000LL;	// 2e18
#define pi                  acos(-1.0)
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define shesh               "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define bp                  pop_back
#define pf                  push_front
#define fp                  pop_front
#define ub                  upper_bound
#define lb                  lower_bound
#define all(x)              x.begin(), x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"
#define mest(a,b)           memset(a,b,sizeof(a))

int main()
{
    fast;
    ll t,n,m,i,j,k,temp,flag,ans=0,a,b,c,d,e,f,ans_a=0,ans_b=0;
    cin>>a>>b>>c>>d>>e>>f;
    set<ll>water,sugar;
    for(i=0; 100*a*i<=f; i++)
    {
        for(j=0;(100*a*i)+(100*b*j)<=f;j++){
            water.insert((100*a*i)+(100*b*j));
        }
    }
    for(i=0; c*i<=f; i++)
    {
        for(j=0;(c*i)+(d*j)<=f;j++){
            sugar.insert((c*i)+(d*j));
        }
    }
    water.erase(water.begin());
    //sugar.erase(sugar.begin());
    for(auto it1=water.begin(); it1!=water.end(); it1++)
    {
        for(auto it2=sugar.begin();it2!=sugar.end() && (*it1)+(*it2)<=f;it2++)
        {
            if(e*((*it1)/100)>=(*it2))
            {
                if(ans==0)
                {
                    ans_a=(*it1);
                    ans_b=(*it2);
                    ans++;
                }
                else
                {
                    temp=(*it1);
                    flag=(*it2);
                    if(flag*(ans_a+ans_b)>ans_b*(temp+flag))
                    {
                        ans_a=temp;
                        ans_b=flag;
                    }
                }
            }
        }
    }
    cout<<ans_a+ans_b<<" "<<ans_b;
    return 0;
}


Measured memory_bytes: 384
N = int(input())
data = ["AC","WA","TLE","RE"]
count = [0]*4
for num in range(N):
  s = input()
  for i in range(4):
    if(data[i]== s):
      count[i] = count[i]+1

print("AC x {}".format(count[0]))
print("WA x {}".format(count[1]))
print("TLE x {}".format(count[2]))
print("RE x {}".format(count[3]))

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
constexpr ll mod = 998244353;

#define NMAX 3030
ll dp[NMAX][NMAX];

void init() {
    rep(i, 0, NMAX) rep(j, 0, NMAX) dp[i][j] = 0;
}

int main(){

    init();

    // input
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    // dp
    dp[a][b] = 1;
    rep(h, a, c+1) {
        rep(w, b, d+1) {
            if(a < h) dp[h][w] += (dp[h-1][w] * w) % mod;
            if(b < w) dp[h][w] += (dp[h][w-1] * h) % mod;
            if(a < h && b < w) dp[h][w] -= (dp[h-1][w-1] * (w-1) * (h-1)) % mod;
            dp[h][w] = (dp[h][w] + mod) % mod;
        }
    }

    // print
    cout << dp[c][d] << endl;
    return 0;
}

Measured memory_bytes: 75348
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = sorted(list(set(table)))
    return table

n = INT()
a = divisor(n)
ans = 0
for x in a:
    if n // x <= x - 2:
        ans += x - 1
print(ans)

Measured memory_bytes: 10796
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1e9,MOD=1e9+7;

int main(){
	int k,t; cin>>k>>t;
	int a[t]; rep(i,t) cin>>a[i];
	int sum=0;
	sort(a,a+t); rep(i,t-1) sum+=a[i];
	int big=a[t-1];
	cout<<max(big-sum-1,0)<<endl;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    cnt = 0
    max = 0
    for i in range(n):
        d1, d2 = map(int, input().split(" "))
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0
        if max < cnt:
            max = cnt
    if max >= 3:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9180
#include <iostream>
#include <vector>
#include <time.h> 
#include <algorithm>
#include <string>

using namespace std;



int main(void){

int W, H, x, y, r;

cin >> W >> H >> x >> y >> r;

if(x >= r && y >= r && x <=W-r && y <= H-r){
    cout << "Yes" << endl;
}
else  cout << "No" << endl;

}

Measured memory_bytes: 3104