akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int a_max = -1;
    int a_max_index = -1;
    for (int i = 0; i < n; i++) {
      int ai = sc.nextInt();;
      a[i] = ai;
      if (ai > a_max) {
        a_max = ai;
        a_max_index = i;
      }
    }

    double a_max_half = a_max / 2.0;
    double diff_min = Double.MAX_VALUE;
    int r = -1;
    for (int i = 0; i < n; i++) {
      if (i == a_max_index) {
        continue;
      }
      if (Math.abs(a[i] - a_max_half) < diff_min) {
        diff_min = Math.abs(a[i] - a_max_half);
        r = a[i];
      }
    }

    System.out.println(a_max + " " + r);
  }
}


Measured memory_bytes: 50064
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> t(n);
	vector<ll> a(n);
	REP(i,n) cin>>t[i];
	REP(i,n) cin>>a[i];
	vector<P> h(n,P(0,INF*INF));
	REP(i,n) {
		if(i==0||t[i]!=t[i-1]) {
			h[i].first=1;
			h[i].second=t[i];
		} else {
			h[i].second=t[i];
		}
	}
	for(ll i=n-1; i>=0; i--) {
		if(i==n-1||a[i]!=a[i+1]) {
			if(h[i].first==0) {
				if(h[i].second>=a[i]) {
					h[i].first=1;
					h[i].second=a[i];
				} else {
					h[i].first=2;
				}
			} else {
				if(h[i].second!=a[i]) {
					h[i].first=2;
				}
			}
		} else {
			if(h[i].first==0) {
				h[i].second=min(h[i].second,a[i]);
			} else {
				if(h[i].second>a[i]) {
					h[i].first=2;
				}
			}
		}
	}
	ll ret=1;
	REP(i,n) {
		if(h[i].first==2) ret*=0;
		if(h[i].first==1) ret*=1;
		if(h[i].first==0) ret*=h[i].second;
		ret%=MOD;
	}
	cout<<ret<<endl;
}


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

using namespace std;

inline void Boost() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}
typedef long long int ll;
typedef long double ld;

int main() {
	Boost();

	string a, b;
	cin >> a >> b;

	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());

	vector < vector < int > > DP;
	DP.assign(a.size() + 1, vector < int > (b.size() + 1));

	for (int i = 1; i <= (int)a.size(); ++i) {
		for (int j = 1; j <= (int)b.size(); ++j) {
			if (a[i - 1] == b[j - 1]) {
				DP[i][j] = DP[i - 1][j - 1] + 1;
			} else {
				DP[i][j] = max(DP[i - 1][j], DP[i][j - 1]);
			}
		}
	}

	int x, y;
	x = a.size(); y = b.size();
	while (x > 0 && y > 0) {
		if (a[x - 1] == b[y - 1]) {
			cout << a[x - 1];
			--x; --y;
		} else {
			if (DP[x - 1][y] > DP[x][y - 1]) {
				--x;
			} else {
				--y;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map>       // pair
#include <string>
#include <stdio.h>
using namespace std;

int main(int argc, const char *argv[])
{   
    int A,B;
    double T;
    cin>>A>>B>>T;

    cout<<int(T+0.5)/A*B;

    return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
	ll n;
	cin >> n;
	ll a[n];
	ll b[n];
	vector<ll> c;
	ll ans = 0;
	for(ll i = 0; i < n; i++){
		cin >> a[i] >> b[i];
		c.push_back(a[i]+b[i]);
		ans -= b[i];
	}
	sort(c.rbegin(), c.rend());
	for(ll i = 0; i < n; i+=2){
		ans += c[i];
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2676
#include<bits/stdc++.h>                                                   //---------------------------------------------------------------
                                                                    
# define ll long long   
# define ld long double                                               
# define mod 1000000007                                                   
# define MAX 100005
# define pi 3.141592653589793238                                                                                  //shortcut keys
                                                                                
# define pb push_back                                                                     
# define mp make_pair 
# define all(x) x.begin(),x.end()                                                      
                                                                  
# define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);        //---------------------------------------------------------------                                       
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	int n=s.size();
	for(int i=0;i<n;i++){
		if(s[i]!=t[i]){
			cout<<"No"<<"\n";return 0;
		}
	}
	cout<<"Yes"<<"\n";
	return 0;
	
}

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

int main() {
  int N;
  cin >> N;
  
  int A[N+1], B[N+1], C[N];
  
  A[0] = -1;
  B[0] = -1;
  C[0] = -1;
  
  for (int i = 0; i < N; i++) cin >> A[i+1];
  for (int i = 0; i < N; i++) cin >> B[i+1];
  for (int i = 0; i < N-1; i++) cin >> C[i+1];

  
  int ans = 0;
  
  for (int i = 1; i <= N; i++) {
    ans += B[A[i]];
    if (A[i] - A[i-1] == 1) ans += C[A[i-1]];
  }
  cout << ans << endl;
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
struct SegTree{
    int n;
    vector <pair <int,int> > node;
    SegTree(vector <int> v){
        int sz = v.size();
        n = 1;
        while(n<sz) n*=2;
        node.resize(2*n-1, {-INF,-INF});
        for(int i=0; i<sz; i++) node[i+n-1] = {v[i],i}; //一番下側
        for(int i=n-2;i>=0;i--) node[i] = max(node[2*i+1], node[2*i+2]);
    }
    int getnum(int p){
        return node[n-1+p].F;
    }
    int geti(int p){
        return node[n-1+p].S;
    }
    void update(int number, int val){
        number += n-1;
        node[number].F = val;
        while(number>0){
            number=(number-1)/2;
            node[number] = max(node[number*2+1], node[number*2+2]);
        }
    }
    void add(int number, int val){
        number += n-1;
        node[number].F += val;
        while(number>0){
            number=(number-1)/2;
            node[number] = max(node[number*2+1], node[number*2+2]);
        }
    }
    pair <int,int> getmax(int a, int b, int k=0, int l = 0, int r = -1){ //0~n
        
        if(r<0) r=n;
        if(r<=a||b<=l) return {-INF,-INF};
        if(a <= l&& r<=b) return node[k];
        pair <int,int>  vl = getmax(a, b, 2*k+1, l, (l+r)/2);
        pair <int,int>  vr = getmax(a, b, 2*k+2, (l+r)/2, r);
        return max(vl, vr);
    }
    void showall(){
        for(int i=0;i<2*n-1;i++)cout<<node[i].F<<'&'<<node[i].S<<endl;
    }
};

signed main(void){
    int n; cin>>n;
    vector <int> a(n); 
    rep(i,n) cin>>a[i];
    SegTree seg(a);
    int ans = 0;
    while(1){
        auto tmp = seg.getmax(0,n);
        if(tmp.F <= n-1) break;
        int add = tmp.F/n;
        tmp.F -= n*add;
        rep(i,n){
            if(i==tmp.S) seg.update(tmp.S, tmp.F);
            else seg.add(i, add);
        }
        ans += add;
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 384
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n; cin>>n; 
    vi a(n),b(n);
    for (int &i: a) cin >> i ; 
    for (int &i: b) cin >> i ; 
    int f=0,s=0; 
    int ok = 0;
    for (int i=0;i<n;i++){
        if (a[i]<b[i]) f += b[i]-a[i];
        else s += (a[i]-b[i])*2;
        if (b[i]-a[i]>1) ok+=(b[i]-a[i])/2; 
    }
    if ((f >= s and ok >= s/2) or (s==0) ) printf("Yes\n");
    else printf("No\n");
}

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


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

// const ll mod = 1e9+7;

// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }


int main(){
    int N; cin >> N;
    vector<int> a(N), b(N);
    for(int i=0; i<N; ++i) cin >> a[i];
    for(int i=0; i<N; ++i) cin >> b[i];

    int ans = 0;

    for(int k=28; k>=0; --k){
        int T = 1<<k;
        for(int i=0; i<N; ++i) { a[i] %= 2*T; b[i] %= 2*T; }
        sort(b.begin(), b.end());
        int cnt = 0;
        for(int i=0; i<N; ++i){
            cnt += (lower_bound(b.begin(), b.end(), 2*T-a[i]) - lower_bound(b.begin(), b.end(), T-a[i]));
            cnt += (lower_bound(b.begin(), b.end(), 4*T-a[i]) - lower_bound(b.begin(), b.end(), 3*T-a[i]));
        }
        if(cnt%2) ans += T;
        // 上、if(cnt%2 == 1)にするとWAになる　cnt<0 になることなんてある？
    }

    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;

class book
{
	public:
		int cost;
		int learn[20];
}b[20];
int have[20];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m,x;
	cin>>n>>m>>x;
	rep(i,0,n)
	{
		cin>>b[i].cost;
		rep(j,0,m) cin>>b[i].learn[j];
	}
	int ans=inf;
	rep(i,0,(1<<n))
	{
		int cost=0;
		mes(have,0);
		rep(j,0,n)
		{
			if(i&(1<<j))
			{
				cost+=b[j].cost;
				rep(k,0,m) have[k]+=b[j].learn[k];
			}
		}
		bool flag=1;
		rep(j,0,m) if(have[j]<x)
		{
			flag=0;
			break;
		}
		if(flag) ans=min(ans,cost);
	}
	if(ans==inf) cout<<"-1\n";
	else cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int,int>;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    ll h, w; cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }
    cout << ((h*w + 2 -1) / 2) << endl;;
    return 0;
}






























Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-9, PI = acos(-1);
const int N = 3e3 + 9, M = 5e2 + 9, OO = 1e9 + 7, MOD = 1e9 + 9;
const ll inf = 1e18;

double mem[N][N], p[N];
int n;

double solve(int idx, int heads) {
  if(idx == n)
    return (heads > n - heads) ? 1 : 0;
  double& ret = mem[idx][heads];
  if(ret == ret)
    return ret;
  ret = 0;
  ret = solve(idx + 1, heads + 1) * p[idx];
  ret += solve(idx + 1, heads) * (1.0 - p[idx]);
  return ret;
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif

  cin >> n;
  for (int i = 0; i < n; ++i)
    cin >> p[i];
  memset(mem, -1, sizeof mem);
  cout << solve(0, 0);
  return 0;
}


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

int main (){
  int a ;
  cin >> a ;
  double b = (double)a;
  if(a%2 == 0){
    cout << 0.5 << endl;
  } else {
    cout << (b-(double)(a/2))/b<< endl;
  }
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

typedef long long ll;

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


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

    int a,b;
    cin>>a>>b;

    string  u;
    cin>>u;

    if(u==s)cout<<a-1<<" "<<b<<endl;
    else cout<<a<<" "<<b-1<<endl;
}


Measured memory_bytes: 256
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e15 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve() {
  int n, k; cin >> n >> k;
  set <int> s;
  while(k--) {
    int m; cin >> m;
    for(int i = 1; i <= m; i++) {
      int x; cin >> x;
      s.insert(x);
    }
  }
  cout << (n-sz(s)) << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif
    int t = 1; // cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }
}    


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define maxn 202111
int a[maxn];
int l[maxn],r[maxn];
int n;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i)
    {
        scanf("%d",a+i);
        l[i] = max(l[i-1],a[i]);
    }
    for(int i=n;i>=1;--i)
    {
        r[i] = max(r[i+1],a[i]);
    }
    for(int i=1;i<=n;++i)
    {
        printf("%d\n",max(l[i-1],r[i+1]));
    }
}

Measured memory_bytes: 3968
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
//ll a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
ll n,w;
void solve(){
	ll a,b,c;
	cin>>a>>b>>c;
	if(c-a-b>0&&(c-a-b)*(c-a-b)>4*a*b){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





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

int main() {
  int n;

  while (cin >> n, ~n) {
    long double x = 1;
    long double y = 0;

    for (int i = 1; i < n; ++i) {
      long double dx = -y;
      long double dy = x;
      long double d = sqrt(static_cast<long double>(dx * dx + dy * dy));

      x += dx / d;
      y += dy / d;
    }

    cout << x << endl;
    cout << y << endl;
  }
}

Measured memory_bytes: 3076
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s=sc.next();
    long countl=0,countr=0;
    long sum=0;
    for(int i=0;i<s.length();i++) {
    	if(s.substring(i, i+1).equals("<")) {
    		countl++;
    		if(i!=s.length()-1&&s.substring(i+1, i+2).equals(">")) {
    			
    		}else {
    			sum+=countl;
    		}
    	}else {
    		countr++;
    		if(i!=s.length()-1&&s.substring(i+1, i+2).equals("<")) {
    			if(countr>=countl) {
    				sum+=countr*(countr+1)/2;
    			}else {
    				sum+=countl;
    				sum+=countr*(countr-1)/2;
    			}
    			countl=0;
    			countr=0;
    		}else {

    		}
    	}
    	//System.out.print(sum);
    }
    //System.out.println();
    if(s.substring(s.length()-1, s.length()).equals(">")) {
		if(countr>=countl) {
			sum+=countr*(countr+1)/2;
		}else {
			sum+=countl;
			sum+=countr*(countr-1)/2;
		}
    }else {
    	//sum+=countl;
    }
    //System.out.println(sum+" "+countl+" "+countr);
    System.out.println(sum);
  }
}

Measured memory_bytes: 49108
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class AACOrWA {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N, M;
        in>>N>>M;
        if(N==M) out<<"Yes\n";
        else out<<"No\n";
    }
};


int main() {
	AACOrWA solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3612
using System;
using System.Collections.Generic;

namespace ABC114_C
{
    class Program
    {
        static long N;
        static List<int> num = new List<int>() { 3, 5, 7 };

        static void Main(string[] args)
        {
            N = int.Parse(Console.ReadLine());

            Console.WriteLine(dfs(0));
        }

        static long dfs(long number)
        {
            if (number > N)
            {
                return 0;
            }

            long ans = number.ToString().Contains("3")
                && number.ToString().Contains("5")
                && number.ToString().Contains("7") ? 1 : 0;

            foreach (var n in num)
            {
                ans += dfs(number * 10 + n);
            }

            return ans;
        }
    }
}


Measured memory_bytes: 15316
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define bitget(a, b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(), x.end())

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;

int main() {
	int n, k;
	scanf("%d", &n);
	int l[1003], r[1003];
	rep(i, 0, n)
		scanf("%d %d", &l[i], &r[i]);
	int64 ans = 0;
	rep(i, 0, n){
		ans += r[i] - l[i] + 1;
	}
	printf("%lld", ans);
	return 0;
}


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

using namespace std;

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

int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;

  string x = "";
  int indent = 0;
  for (string::iterator it = s.begin(); it != s.end(); ++it) {
    if (*it == ')') {
      if (indent == 0)
        x = "(" + x;
      else --indent;
      x += ")";
    } else if (*it == '(') {
      ++indent;
      x += "(";
    }
  }
  REP(i, indent) x += ")";

  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
class test
{
  public static void Main(string[] args)
  {
    int k;
    string s;
    k = int.Parse(Console.ReadLine());
    s = Console.ReadLine();
    if(s.Length<=k)
      Console.WriteLine(s);
    else
      Console.WriteLine(s.Substring(0,k)+"...");
  }
}

Measured memory_bytes: 27472
#define DEBUG 0
/**
 * File    : C2.cpp
 * Author  : Kazune Takahashi
 * Created : 6/22/2019, 11:48:13 PM
 * Powered by Visual Studio Code
 */
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
typedef long long ll;
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}
void No()
{
  cout << "No" << endl;
  exit(0);
}
const int MAX_SIZE = 1000010;
class mint
{
public:
  static ll MOD;
  ll x;
  mint() : x(0) {}
  mint(ll x) : x(x % MOD) {}
  mint operator-() const { return x ? MOD - x : 0; }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= MOD)
    {
      x -= MOD;
    }
    return *this;
  }
  mint &operator-=(const mint &a) { return *this += -a; }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator/=(const mint &a) { return (*this *= power(MOD - 2)); }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
  const mint power(ll N)
  {
    if (N == 0)
    {
      return 1;
    }
    else if (N % 2 == 1)
    {
      return *this * power(N - 1);
    }
    else
    {
      mint half = power(N / 2);
      return half * half;
    }
  }
};
ll mint::MOD = 1e9 + 7;
istream &operator>>(istream &stream, mint &a) { return stream >> a.x; }
ostream &operator<<(ostream &stream, const mint &a) { return stream << a.x; }
mint inv[MAX_SIZE];
mint fact[MAX_SIZE];
mint factinv[MAX_SIZE];
void init()
{
  inv[1] = 1;
  for (int i = 2; i < MAX_SIZE; i++)
  {
    inv[i] = (-inv[mint::MOD % i]) * (mint::MOD / i);
  }
  fact[0] = factinv[0] = 1;
  for (int i = 1; i < MAX_SIZE; i++)
  {
    fact[i] = mint(i) * fact[i - 1];
    factinv[i] = inv[i] * factinv[i - 1];
  }
}
mint choose(int n, int k)
{
  if (n >= 0 && k >= 0 && n - k >= 0)
  {
    return fact[n] * factinv[k] * factinv[n - k];
  }
  return 0;
}
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
// const double epsilon = 1e-10;
// const ll infty = 1000000000000000LL;
// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

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

ll f(ll x, ll c, ll d)
{
  ll res = x;
  res -= x / c;
  res -= x / d;
  res += x / lcm(c, d);
  return res;
}

int main()
{
  // init();
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = f(b, c, d) - f(a - 1, c, d);
  cout << ans << endl;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	constexpr int INF = 1e9 + 10;
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }
	vector<vector<int>> g(N);
	for (int i = 0; i < N - 1; ++i) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		g[u].emplace_back(v);
		g[v].emplace_back(u);
	}

	vector<int> ans(N, 0);
	vector<bool> used(N, false);
	used[0] = true;
	vector<int> dp(N, INF);
	dp[0] = a[0];
	function<void(int)> dfs = [&](int u) -> void {
		ans[u] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
		for (auto v : g[u]) {
			if (used[v]) { continue; }
			used[v] = true;
			int idx = lower_bound(dp.begin(), dp.end(), a[v]) - dp.begin();
			int tmp = dp[idx];
			dp[idx] = a[v];
			dfs(v);
			dp[idx] = tmp;
		}
		return;
	};

	dfs(0);
	for (auto v : ans) { cout << v << endl; }

	return 0;
}


Measured memory_bytes: 30924
function main (input) {
    const S = input.split('');
    var ans = 'yes';

    for (var i = 0; i < S.length; i++){
        for (var j = i+1; j < S.length; j++) {
            if (S[i] === S[j]) {
                ans = 'no';
                break;
            }
        }
    }
    console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;
typedef long long ll;
const long long mod=1e9+7; //10^9+7


int main() {

    int n,l;
    cin >> n >> l;

    int aji=0;
    int min = 10000;

    for(int i=1;i<=n;i++){
        int a = l+i-1;
        if(abs(min)>abs(a)){
            min = a;
        }
        aji += l+i-1;
    }
    aji -= min;

    cout << aji << endl;



  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int n,m,c;
	cin >> n >> m >> c;
	
	vector<int> b(m);
	for(auto &i : b){
		cin >> i;
	}
	
	vector<int> a(m);
	int result = 0;
	for(int i=0;i<n;++i){
		for(auto &j : a){cin >> j;}
		int val = 0;
		for(int j=0;j<m;++j){
			val += b[j] * a[j];
		}
		if((val + c) > 0){++result;}
	}
	cout << result << endl;
}

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

class segment {
public:
	int n;
	vector<int> tree;

	segment(int n) {
		this->n = n;
		tree.resize(4 * n);
	}
	
	void update(int idx, int val, int l, int r, int v) {
		if (r - l == 1) {
			tree[v] = max(tree[v], val);
			return;
		}

		int mid = (l + r) / 2;
		if (idx < mid) {
			update(idx, val, l, mid, 2 * v);
		} else {
			update(idx, val, mid, r, 2 * v + 1);
		}
		tree[v] = max(tree[2 * v], tree[2 * v + 1]);
	}

	void update(int idx, int val) {
		update(idx, val, 0, n, 1);
	}

	int mx(int p, int q, int l, int r, int v) {
		if (q <= l || p >= r) {
			return INT_MIN;
		}
		if (p <= l && r <= q) {
			return tree[v];
		}

		int mid = (l + r) / 2;
		int x = mx(p, q, l, mid, 2 * v);
		int y = mx(p, q, mid, r, 2 * v + 1);
		return max(x, y);
	}

	int mx(int p, int q) {
		return mx(p, q, 0, n, 1);
	}
};

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	const int MAX_A = 300 * 1000;
	segment tree(MAX_A + 1);

	vector<int> dp(n);
	dp[n - 1] = 1;
	tree.update(a[n - 1], 1);
	for (int i = n - 2; i >= 0; i--) {
		dp[i] = tree.mx(max(0, a[i] - k), min(MAX_A + 1, a[i] + k + 1)) + 1;
		tree.update(a[i], dp[i]);
	}
	cout << *max_element(dp.begin(), dp.end()) << '\n';

	return 0;
}

Measured memory_bytes: 10396
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	while(1){
		int n,m,p;
		cin >> n >> m >> p;
		if(n==0&&m==0&&p==0) break;
		ll int sum = 0;
		ll int ans;
		REP(i,n){
			int tmp;
			cin >> tmp;
			sum += tmp;
			if(i==m-1) ans = tmp;
		}
		if(ans!=0) ans = sum*(100-p)/ans;
		cout << ans << endl;
	}
}

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

int main() {
	int ans;
	size_t N;
	cin >> N;
	vector<int> h(N);
	for (auto& x : h) cin >> x;
	ans = h.at(0);
	for (size_t i = 1; i < N; ++i) ans += max(h.at(i) - h.at(i - 1), 0);
	cout << ans;
}

Measured memory_bytes: 256
n = int(input())
taro = 0
hanako = 0
for i in range(n):
    t, h = input().split()
    if t > h:
        taro += 3
    elif t < h:
        hanako += 3
    else:
        taro += 1
        hanako += 1
print("%d %d" %(taro, hanako))


Measured memory_bytes: 5604
#include <iostream>

using namespace std;

int main() {
    int x, a, b, count = 0;
    bool row = false, ans = false;
    
    cin >> x;
    
    for(int i = 0; i < x; i++) {
        cin >> a >> b;
        if(a == b) {
            count++;
            if(!row) row = true;
        }
        else {
            row = false;
            count = 0;
        }
        
        if(count == 3) ans = true;
    }
    
    cout << (ans?"Yes":"No") << endl;
    

    return 0;
}

Measured memory_bytes: 3592
import sys
input = sys.stdin.readline
N=int(input())
a=list(map(int,input().split()))
a0 = a[0]
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
ma = N
mi = N//2
for i in range(len(bin(N))-2):
    for j in range(ma,mi,-1):
        if a[j-1]%2==1:
            tg_list = make_divisors(j)
            for k in tg_list:
                if k!=j:
                    a[k-1] += 1
    #a[mi//2:mi] %= 2
    #print(a)
    ma = mi
    mi = mi//2
if sum(a)%2 == a0:
    #print(a)
    res = [str(i+1) for i in range(N) if a[i]%2==1]
    M = len(res)
    print(M)
    if M!=0:
        print(' '.join(res))
else:
    print(-1)


Measured memory_bytes: 72056
import java.util.Scanner;

public class Main {

	private void solve() {
		Scanner io = new Scanner(System.in);
		int N = io.nextInt();
		int M = io.nextInt();
		boolean[] medium = new boolean[N];
		boolean[] ableToN = new boolean[N];
		for(int i=0;i<M;i++){
			int a = io.nextInt()-1;
			int b = io.nextInt()-1;
			if(a==0) medium[b] = true;
			if(b==0) medium[a] = true;
			if(a==N-1) ableToN[b] = true;
			if(b==N-1) ableToN[a] = true;
		}
		for(int i=0;i<N;i++){
			if(medium[i] && ableToN[i]){
				System.out.println("POSSIBLE");
				return;
			}
		}
		System.out.println("IMPOSSIBLE");
	}

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

Measured memory_bytes: 93600
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        String ans = "Yes";

        int nowT = 0;
        int nowX = 0;
        int nowY = 0;

        for (int i = 0; i < n; i++) {
            int t = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();
            int vGap = Math.abs(x - nowX) + Math.abs(y - nowY);
            int tGap = t - nowT;
            if (vGap > t - nowT) {
                ans = "No";
                break;
            } else if (vGap % 2 != tGap % 2) {
                ans = "No";
                break;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 86068
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;



int main(){
  int n;
  cin >>n;
  ll a[n];
  rep(i,n)cin >>a[i];
  ll s=0;
  rep(i,n)s=s^a[i];

  rep(i,n){
    ll ans=s^a[i];
    cout << ans << " ";
  }
  cout << endl;
}

Measured memory_bytes: 5092
import java.util.ArrayList;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main{

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

	private Scanner scan;
	private int N,Q,now;
	private List<Process> L;
	private Deque<Process> queue;

	public void mainrun() {
		scan = new Scanner(System.in);
		L = new ArrayList<>();
		queue = new LinkedList<>();

		N = scan.nextInt();
		Q = scan.nextInt();
		now = 0;

		for(int i = 0;i < N;i++) {
			queue.add(new Process(scan.next(),scan.nextInt()));
		}

		while(!queue.isEmpty()) {
			looprun();
		}

		L.forEach(e->e.print());

		scan.close();

	}

	private void looprun() {
		Process p = queue.pop();
		if(p.getTime() <= Q) {
			now += p.getTime();
			p.setTotalTime(now);
			L.add(p);
		}else {
			now += Q;
			p.minusTime(Q);
			queue.add(p);
		}
	}
}

class Process{
	private String id;
	private int time,totalTime;

	public Process(String id,int time) {
		setId(id);
		setTime(time);
		setTotalTime(0);
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public int getTime() {
		return time;
	}

	public void setTime(int time) {
		this.time = time;
	}

	public void minusTime(int mtime) {
		time -= mtime;
	}

	public int getTotalTime() {
		return totalTime;
	}

	public void setTotalTime(int totalTime) {
		this.totalTime = totalTime;
	}

	public void print() {
		System.out.println(id + " " + Integer.toString(totalTime));
	}

}


Measured memory_bytes: 79212
import Data.Maybe (fromMaybe)
import System.IO (isEOF)
import Data.List

main = do
    eof <- isEOF
    if eof then return ()
           else getLine >>= putStrLn.readNumLine' codeCharTable.concatMap (toBin charCodeTable) >> main

toBin :: [(Char,String)] -> Char -> String
toBin list char = fromMaybe "" (lookup char list)
readNumLine :: String -> String
readNumLine (x:xs) = rnl [x] xs

rnl _   []   = []
rnl acc line = case lookup acc codeCharTable of
                 Just c -> c:readNumLine line
                 Nothing -> rnl (head line: acc) $ tail line

readNumLine' _      []  = []
readNumLine' []     _   = []
readNumLine' (t:ts) str = if isPrefixOf (fst t) str then snd t : (readNumLine' codeCharTable $ drop (length $ fst t) str)
                                                    else readNumLine' ts str



charCodeTable =  [('A',"00000"),('B',"00001"),('C',"00010"),('D',"00011")
                 ,('E',"00100"),('F',"00101"),('G',"00110"),('H',"00111")
                 ,('I',"01000"),('J',"01001"),('K',"01010"),('L',"01011")
                 ,('M',"01100"),('N',"01101"),('O',"01110"),('P',"01111")
                 ,('Q',"10000"),('R',"10001"),('S',"10010"),('T',"10011")
                 ,('U',"10100"),('V',"10101"),('W',"10110"),('X',"10111")
                 ,('Y',"11000"),('Z',"11001"),(' ',"11010"),('.',"11011")
                 ,(',',"11100"),('-',"11101"),('\'',"11110"),('?',"11111")]
                 
codeCharTable = [("101",' '),("000000",'\''),("000011",','),("10010001",'-')
                 ,("010001",'.'),("000001",'?'),("100101",'A'),("10011010",'B')
                 ,("0101",'C'),("0001",'D'),("110",'E'),("01001",'F'),("10011011",'G')
                 ,("010000",'H'),("0111",'I'),("10011000",'J'),("0110",'K'),("00100",'L')
                 ,("10011001",'M'),("10011110",'N'),("00101",'O'),("111",'P')
                 ,("10011111",'Q'),("1000",'R'),("00110",'S'),("00111",'T'),("10011100",'U')
                 ,("10011101",'V'),("000010",'W'),("10010010",'X'),("10010011",'Y'),("10010000",'Z')]

Measured memory_bytes: 4020
data Path = Path { cost :: Int, time :: Int }
readPath :: String -> Path
readPath s = let [a,b] = map read . words $ s
                 in Path a b

solve :: Int -> [Path] -> String
solve t ps = case filter ((<=t) . time) ps of
                [] -> "TLE"
                pp -> show . minimum . map cost $ pp


main = do
    [_,t] <- map read . words <$> getLine
    putStrLn . solve t . map readPath . lines =<< getContents

Measured memory_bytes: 1020
from collections import Counter
from copy import copy

def _check(pi):
    pi=sorted(pi)
    if len(pi)==0:
        return True
    retval=False
    try:
        _pi=copy(pi)
        tmp=_pi[0]
        for i in range(3):
            _pi.remove(tmp)
        retval = retval or _check(_pi)
    except:
        pass

    try:
        _pi=copy(pi)
        tmp=_pi[0]
        for i in range(3):
            _pi.remove(tmp+i)
        retval = retval or _check(_pi)
    except:
        pass

    return retval

def check(pi,tsumo):
    pi=pi+[tsumo]
    c=Counter(pi)
    for i in range(1,10):
        if c[i]>4:
            return False

    for i in range(1,10):
        if c[i]>=2:
            _pi = copy(pi)
            _pi.remove(i)
            _pi.remove(i)
            _pi=sorted(_pi)
            if _check(_pi):
                return True
    return False


while True:
    try:
        s=input()
        s=[int(i) for i in s]
        retval=[]
        for i in range(1,10):
            if check(s,i):
                retval.append(str(i))
        if len(retval)==0:
            print("0")
        else:
            print(" ".join(retval))
    except EOFError:
        break



Measured memory_bytes: 6316
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arrll(a,n);

  sort(all(a), greater<ll>());
  ll ans=0;
  bool ok=true;
  int id=0;
  rep(_,n-1){
    ans += a[id];
    if(ok) id++, ok=false;
    else ok=true;
  }

  prt(ans);
}


Measured memory_bytes: 4840
a,b=map(int,input().split())
bottom_list=[]

y=list(map(int,input().split()))
y.append(sum(y))
print(" ".join(list(map(str,y))))
for i in range(b):
  bottom_list.append(y[i])

for h in range (a-1):
  y=list(map(int,input().split()))
  y.append(sum(y))
  print(" ".join(list(map(str,y))))
  for i in range(b):
    bottom_list[i]+=y[i]
  
bottom_list.append(sum(bottom_list))
print(" ".join(list(map(str,bottom_list))))



Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll S[410];
ll dp[410][410];

ll loop(int a, int b) {
	if(dp[a][b] != -1) return dp[a][b];
	if(b - a == 1) return 0;
	ll res = linf;
	for(int i = a + 1; i < b; i++) {
		MIN(res, loop(a, i) + loop(i, b));
	}
	// debug(a, b, res + S[b] - S[a]);
	return dp[a][b] = res + S[b] - S[a];
}

void solve() {
	cin >> N;
	rep(i, 0, N) {
		cin >> S[i + 1];
		S[i + 1] += S[i];
	}
	memset(dp, -1, sizeof(dp));
	cout << loop(0, N) << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 1536
def solve():
  N, K, C = map(int, input().split())
  workable = [i for i, s in enumerate(input(), 1) if s=="o"]
  if len(workable) == K:
    return workable
    
  latest = set()
  prev = workable[-1]+C+1
  for x in reversed(workable):
    if prev - x > C:
      latest.add(x)
      prev = x
      if len(latest) > K:
        return []
  must = []
  prev = -C-1
  for x in workable:
    if x - prev > C:
      if x in latest:
        must.append(x)
      prev = x
  return must

print("\n".join(map(str, solve())))

Measured memory_bytes: 23968
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;
string S;
int cnt[3],ans[3];
int main(){
	cin>>S;
	int n=(int)S.size();
	REP(i,n){
		cnt[S[i]-'a']++;
	}
	sort(cnt,cnt+3);
	REP(i,3){
		ans[i]=n/3+(n%3>i);
	}
	sort(ans,ans+3);
	bool f=true;
	REP(i,3){
		f&=cnt[i]==ans[i];
	}
	cout<<(f ? "YES" :"NO")<<endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <stack>

using namespace std;

int main(void) {
	string date;

	cin >> date;

	cout << "2018/01" << date.substr(7, 3) << endl;
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 5010;
typedef long long ll;
const int mod = 1e9 + 7;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int f[maxn][maxn];
char s[maxn];
int n, L;
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> s, L = strlen(s);
	f[0][0] = 1;
	rep(i, 0, n - 1) {
		rep(j, 0, i) {
			f[i + 1][j + 1] = (f[i + 1][j + 1] + f[i][j] * 2u) % mod;
			f[i + 1][j ? j - 1 : 0] = (f[i + 1][j ? j - 1 : 0] + f[i][j]) % mod;
		}
	}
	cout << f[n][L] * pow(2, mod - 1 - L) % mod << '\n';
}


Measured memory_bytes: 96512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
    int n, m;   cin >> n >> m;
    int *ac = new int[n], *wa = new int[n];
    for (int i = 0; i < n; i++) {
        ac[i] = 0;
        wa[i] = 0;
    }
    for (int i = 0; i < m; i++) {
        int p;  cin >> p;
        string s;   cin >> s;
        if (s == "WA") {
            if (ac[p-1] == 0) {
                wa[p-1]++;
            }
        }
        else if (s == "AC") {
            ac[p-1]++;
        }
    }

    int ans_a = 0, ans_w = 0;
    for (int i = 0; i < n; i++) {
        if (ac[i] > 0)
            ans_a++;
        if (ac[i] > 0)
            ans_w += wa[i];
    }

    cout << ans_a << " " << ans_w << endl;
    return 0;
}

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

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

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        vector<int> scores;
        repeat(i, n) {
            int s; cin >> s;
            scores.push_back(s);
        }
        int max_s, min_s;
        max_s = *max_element(scores.begin(), scores.end());
        min_s = *min_element(scores.begin(), scores.end());
        int sum = -max_s-min_s;
        repeat(i, n) {
            sum += scores[i];
        }
        int average = sum / (n-2);
        cout << average << endl;
    }
    return 0;
}

        

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

int main() {
  kyun;
  int a,b;
  cin >> a >> b;
  int ans = b - a + 1;
  rep(i,a*2-1) {
    if(ans == b + a - 1) cout << ans;
    else cout << ans << " ";
    ans++;
  }
  hinata;
}

Measured memory_bytes: 256