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

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 400010;
const int mod = 1e9 + 7;
typedef long long LL;
typedef pair<int, int> pii;
pii b[N];
vector<int> t[N];
int n, x, y, col[N], ls[N], w[N];

#define bi b[i].second

int f[N], st[N];
int f_f(int x) { return x == f[x] ? x : f[x] = f_f(f[x]);} 

void merge(int x1, int x2)
{
	int f1 = f_f(x1), f2 = f_f(x2);
	if (f1 != f2) f[f1] = f2;
}

LL p[N];
LL qpow(LL a, LL b)
{
	LL ret = 1, base = a;
	while (b) {
		if (b & 1) ret = ret * base % mod;
		base = base * base % mod, b >>= 1;
	}
	return ret;
}
LL C(int a, int b) {return p[a] * qpow(p[b], mod - 2) % mod * qpow(p[a - b], mod - 2) % mod;}

int main()
{
	scanf("%d%d%d", &n, &x, &y);
	Rep(i, n){
		scanf("%d%d", &col[i], &w[i]);
		b[i].first = w[i], b[i].second = i;
		f[i] = i;
	}
	sort(b + 1, b + 1 + n);
	
	memset(ls, -1, sizeof(ls));
	ls[col[b[1].second]] = 1;
	int ti = -1;
	for (int i = 2; i <= n; i ++){
		int tmp = ls[col[bi]];
		if (tmp != -1 && b[i].first + b[tmp].first <= x)
			merge(bi, b[tmp].second);
		if (col[bi] != col[b[1].second]){
			if (b[i].first + b[1].first <= y) merge(bi, b[1].second);
		}
		else if (ti != -1 && b[i].first + b[ti].first <= y) merge(bi, b[ti].second);
		
		if (ls[col[bi]] == -1) ls[col[bi]] = i;
		if (ti == -1 && col[bi] != col[b[1].second]) ti = i;
	}
	for (int i = 1; i <= n; i ++) 
		if (col[bi] != col[b[ti].second] && b[i].first + b[ti].first <= y) merge(bi, b[ti].second); 
	
	
	Rep(i, n) t[f_f(i)].push_back(col[i]);
	p[0] = 1;
	Rep(i, n) p[i] = p[i - 1] * i % mod;
	
	LL ans = 1;
	
	Rep(i, n) if (t[i].size()) {
		sort(t[i].begin(), t[i].end());	
		int top = 0, cnt = 0;
		for (int j = 0; j < t[i].size(); j ++){
			if (j != 0 && t[i][j] != t[i][j - 1]) st[++ top] = cnt, cnt = 0;
			cnt ++;
		}
		int tmp = cnt;
		LL tans = 1;
		while (top){
			tans = tans * C(tmp + st[top], st[top]) % mod;
			tmp += st[top], top --;
		}
		ans = ans * tans % mod;
	}
	printf("%lld\n", ans);
	
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  vector<long long> A(N);
  
  for(int i = 0;i<N;i++){
    cin >> A[i];
  }
  
  long long ans = 1;
  
  for(int i = 0;i<N;i++){
    if (A[i] == 0){
      ans = 0;
      break;
    }
  }
  
  long long eighteen = 1000000000000000000LL;
  
  if (ans == 0){
    cout << 0 << endl;
  }
  else {
    for (int i = 0;i<N;i++){
      
      if (eighteen/ans >= A[i]){
        ans *= A[i];
      }
      else{
        ans = -1;
        cout << ans << endl;
        break;
      }
    }
    
    if (ans != -1){
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 4044
<?php
$num = trim(fgets(STDIN));
$count = 0;
 
for($i=1;$i<=$num;$i++) {
  for($j=1;$j<=$num;$j++) {
    $gcd_ij = gmp_gcd($i,$j);
    for($k=1;$k<=$num;$k++) {
      $gcd_ijk = gmp_gcd($gcd_ij, $k);
      $count += $gcd_ijk;
    }
  }
}
echo $count;

Measured memory_bytes: 16340
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

template<typename T>
void chmin(T& a,const T& b){
	a=min(a,b);
}

int main()
{
	for(int n,m,c,s,t;cin>>n>>m>>c>>s>>t,n|m|c|s|t;){
		s--; t--;
		vector<vvi> dists(c,vvi(n,vi(n,INFTY)));
		rep(i,c) rep(j,n) dists[i][j][j]=0;
		rep(i,m){
			int x,y,d,c; cin>>x>>y>>d>>c; x--; y--; c--;
			chmin(dists[c][x][y],d);
			chmin(dists[c][y][x],d);
		}
		vi ps(c);
		rep(i,c) cin>>ps[i];
		vvi sums(c,vi(20000));
		rep(i,c){
			vi qs(ps[i]),rs(ps[i]);
			rep(j,ps[i]-1) cin>>qs[j+1];
			rep(j,ps[i])   cin>>rs[j];
			rep(j,ps[i]-1) repi(k,qs[j],qs[j+1])
				sums[i][k+1]=sums[i][k]+rs[j];
			repi(k,qs[ps[i]-1],20000)
				sums[i][k+1]=sums[i][k]+rs[ps[i]-1];
		}
		
		for(vvi& dist:dists)
			rep(k,n) rep(i,n) rep(j,n)
				chmin(dist[i][j],dist[i][k]+dist[k][j]);
		
		vvi dp(n,vi(n,INFTY));
		rep(i,n) rep(j,n) rep(k,c) if(dists[k][i][j]!=INFTY)
			chmin(dp[i][j],sums[k][dists[k][i][j]]);
		
		rep(k,n) rep(i,n) rep(j,n)
			chmin(dp[i][j],dp[i][k]+dp[k][j]);
		
		cout<<(dp[s][t]==INFTY?-1:dp[s][t])<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3756
import java.util.Arrays;
import java.util.Scanner;

/**
 * https://atcoder.jp/contests/abc138/tasks/abc138_b
 */
public class Main {

  private static double answer(int[] vs) {
    Arrays.sort(vs);
    double prev = 0;
    for (int v : vs) {
      if (prev == 0) {
        prev = v;
        continue;
      }

      prev = (prev + v) / 2;
    }

    return prev;
  }

  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int[] vs = new int[N];
    for (int i = 0; i < N; i++) {
      vs[i] = scan.nextInt();
    }
    scan.close();

    System.out.println(answer(vs));
  }
}


Measured memory_bytes: 23380
#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;
  string s;
  cin >> s;
  bool ans = 1;
  for(int i = 0; i < (int)s.size(); i += 2) {
    if(s[i] == 'L') ans = 0;
  }
  for(int i = 1; i < (int)s.size(); i += 2) if(s[i] == 'R') ans = 0;
  if(ans) cout << "Yes";
  else cout << "No";
  hinata;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
struct day{
	int a;
	int b;
	int c;
};
int main () {
	int n;
    cin>>n;
    day dp[n];
    cin>>dp[0].a>>dp[0].b>>dp[0].c;
	int a1,b1,c1 ;
    for(int i=1;i<n;i++){
    	cin>>a1>>b1>>c1;
    	dp[i].a=max((dp[i-1].b),dp[i-1].c)+a1;
    	dp[i].b=max((dp[i-1].a),dp[i-1].c)+b1;
    	dp[i].c=max((dp[i-1].b),(dp[i-1].a))+c1;
	}
	int ma=0;
	cout<<max(dp[n-1].a,max(dp[n-1].b,dp[n-1].c));
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main(){
	int H,W,N,A,sum=1;
	scanf("%d\n%d\n%d", &H,&W,&N);
	
	if (H>W){
		A=H;
	}
	else {
		A=W;
	}
	for(int i=A;i<N;i+=A){
		sum++;
	}
	printf ("%d", sum);
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
const long long inf = 1LL << 60;
vector<long long> IL(int n) {
    vector<long long> vec(n);
    for (int i=0; i<vec.size(); i++) cin >> vec.at(i);
    return vec;
}
vector<string> IS(int n) {
    vector<string> vec(n);
    for (int i=0; i<vec.size(); i++) cin >> vec.at(i);
    return vec;
}

void PA(vector<long long> vec) {
    for (int i=0; i<vec.size()-1; i++) cout << vec.at(i) << " ";
    cout << vec.at(vec.size()-1) << endl;
    return;
}
map<long long, long long> CL(vector<long long> vec) {
    map<long long, long long> count;
    for (long long x: vec) {
        count[x] += 1;
    }
    return count;
}

map<string, long long> CS(vector<string> vec) {
    map<string, long long> count;
    for (string s : vec) {
        count[s] += 1;
    }
    return count;
}


int main() {
    using ll = long long;
    using vl = vector<long long>;


    string s, t; cin >> s >> t;

    vector<vector<int>> dp(s.size()+1, vector<int>(t.size()+1));

    for (int i=0; i<s.size(); i++) {
        for (int j=0; j<t.size(); j++) {
            if (s[i] == t[j]) {
                dp[i+1][j+1] = dp[i][j]+1;
            }
            else {
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }

    string ans;
    vector<long long> zahyo = {s.size(), t.size()};
    int now = dp[s.size()][t.size()];

    while (now != 0) {
        while (dp[zahyo[0]-1][zahyo[1]] == now) zahyo[0]--;
        while (dp[zahyo[0]][zahyo[1]-1] == now) zahyo[1]--;
        ans += s[zahyo[0]-1];
        now--; zahyo[0]--; zahyo[1]--;
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;



}


Measured memory_bytes: 38572
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        a: i32,
        b: i32
    }
    println!("{}", std::cmp::max(std::cmp::max(a+b,a-b),a*b));
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 4352
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
//#pragma GCC target ("avx,avx2,tune=native")
//#pragma GCC optimization ("unroll-loops")
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(v) ((int)v.size())
#define all(v) v.begin(), v.end()
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define orz ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);    
#define inp freopen("input.txt","r",stdin);freopen("out.txt","w",stdout); 
ll mod=1e9+7;
void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    
}
const int N=2e5+5;

 
int main() {
	io();
	int n;
	cin>>n;
	double ans=1.0/1.0;
	if(n%2){
		double even=n/2;
		double odd=n-even;
		ans=odd/(n);
		cout<<fixed<<setprecision(10)<<ans;
	}
	else{
		cout<<"0.50000000";
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

ll mod = 1000000007;
int dp[3010][3010];
int sum[3010][3010];

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		dp[1][i] = 1;
		sum[1][i] = i + 1;
	}
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (s[i - 1] == '<') {
				dp[i + 1][j] = (sum[i][n - 1] - sum[i][j] + mod) % mod;
			}
			else {
				if (i + j < n) dp[i + 1][j] = sum[i][j];
			}
			if (j == 0) {
				sum[i + 1][j] = dp[i + 1][j];
			}
			else {
				sum[i + 1][j] = (sum[i + 1][j - 1] + dp[i + 1][j]) % mod;
			}
		}
	}
	cout << dp[n][0] << endl;
}

Measured memory_bytes: 141568
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const int INF=10010010;
const double PI=3.141592653589;
vector<vector<int>> g(100001);
int dist[100101][3];

int main(){
  int n,m; cin>>n>>m;
  rep(i,m){
    int u,v; cin>>u>>v;
    u--;v--;
    g[u].push_back(v);
  }
  int s,t; cin>>s>>t;
  s--,t--;

  rep(i,n)rep(j,3)dist[i][j]=INF;
  queue<P> q;
  q.push({s,0});
  dist[s][0]=0;
  while(!q.empty()){
    int v=q.front().first;
    int l=q.front().second;
    q.pop();
     // cout<<"v "<<v+1<<endl;
    rep(i,g[v].size()){
      int u=g[v][i];
      int nl=(l+1)%3;
      if(dist[u][nl]!=INF) continue;
      dist[u][nl]=dist[v][l]+1;
      q.push({u,nl});
       // cout<<"u "<<u+1<<" nl "<<nl<<" dist "<<dist[u][nl]<<endl;
    }
  }

  int ans=dist[t][0];
  if(ans==INF) ans=-1;
  else ans/=3;
  cout<<ans<<endl;

  // cout<<q.front().first<<endl;
  return 0;
}


Measured memory_bytes: 6912
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;
 
#define LL unsigned long long int
 
LL N,K;
LL A[200000];
 
LL ans;

LL f(LL X){
	LL ans = 0;
	for(int i=0;i<N;i++){
		ans+=(X^A[i]);
	}
	return ans;
}
 
void solve(){
	vector<int> bit_counter(64,0);
	//A[0]~A[N-1]のうち、
	//下から数えてibit目に1が出てきた回数をbit_counter[i]とおく
	for(int i=0;i<64;i++){
		for(int k=0;k<N;k++){
			int bit = (A[k]>>i)&1ll;
			bit_counter[i] += bit;
		}
	}
	for(int i=63;i>=0;i--){
		if(ans+(1ll<<i)<=K){
			if(bit_counter[i]<(N+N%2)/2) ans += (1ll<<i);
		}
	}
	ans = f(ans);
}
 
int main(){
	cin >> N >> K;
	for(int i=0;i<N;i++) cin >> A[i];
 
	solve();

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

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    int n,i,sum=0;
    cin>>n;
    int a[n],b[n-1];
    for(i=0;i<n-1;i++)
    {
        cin>>b[i];
    }
    a[0]=b[0];
    a[n-1]=b[n-2];
    for(i=n-2;i>0;i--)
    {
        a[i]=min(b[i-1],b[i]);
    }
    for(i=0;i<n;i++)
    {
        sum+=a[i];
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll c_div = b / c - (a - 1) / c;
    ll d_div = b / d - (a - 1) / d;
    ll cd = (c * d) / __gcd(c, d);
    ll cd_div = b / cd - (a - 1) / cd;
    cout << (b - a + 1) - (c_div + d_div - cd_div);
    return 0;
}


Measured memory_bytes: 256
// <------------- Template -----------------------> //


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(2);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	2 * 1e18;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;

vll adj[MAX5];ll visit[]={};

// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,q,m;
ll s,t,d;
ll sum = 0;


// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> m >> x >> y;
	ll maxi=INT_MIN,mini=INT_MAX;
	for(ll i=0;i<n;i++) {
		cin >> q;
		maxi = max(q,maxi);
	}
	for(ll i=0;i<m;i++) {
		cin >> q;
		mini = min(q,mini);
	}
	if(mini > maxi && maxi+1 > x && maxi+1 <= y) {
		cout<<"No ";
	}
	cout<<"War";
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 5968
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>
#include <functional>
#include <memory>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
std::vector<int> primes(const int upper_limit) {
	std::vector<bool> is_prime(upper_limit + 1, true);
	for (auto i = 2; i * i <= upper_limit; ++i) {
		if (is_prime[i]) {
			for (auto j = i * i; j <= upper_limit; j += i) {
				is_prime[j] = false;
			}
		}
	}
	std::vector<int> result;
	for (auto i = 2; i <= upper_limit; ++i) if (is_prime[i]) result.push_back(i);
	return result;
}
int main() {
	int l, r; std::cin >> l >> r;
	auto prime = primes(static_cast<int>(std::ceil(std::sqrt(r))));
	std::vector<int> targets(r - l + 1);
	for (auto i = 0; i < targets.size(); ++i) targets[i] = l + i;
	std::vector<int> count(r - l + 1, 0);
	for (const auto p : prime) {
		for (auto i = (l + p - 1) / p * p - l; i < targets.size(); i += p) {
			while (targets[i] % p == 0) {
				count[i]++;
				targets[i] /= p;
			}
		}
	}
	int res = 0;
	for (auto i = 0; i < targets.size(); ++i) {
		if (targets[i] != 1) count[i]++;
		if (std::binary_search(prime.begin(), prime.end(), count[i])) {
			++res;
		}
	}
	std::cout << res << std::endl;

}


Measured memory_bytes: 10784
def main():
    N = int(input())
    H = [int(h) for h in input().split()]

    increase = True
    for i in reversed(range(1, N)):
        if H[i] >= H[i-1]:
            pass
        elif H[i-1] - H[i] == 1:
            H[i-1] -= 1
        else:
            increase = False
            break

    if increase:
        print("Yes")
    else:
        print("No")
        
if __name__ == "__main__":
    main()

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

#define ll long long
#define ull unsigned long long
#define ld long double
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define fo(i,start,end) for(int i=start;start<end?i<end:i>end;start<end?i+=1:i-=1)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vop vector<pll>
#define vov vector<vector<ll>>
#define endl "\n"
using namespace std;
const ld pi=3.14159265358979323;

const long long mod1=1e9+7;
const long long mod2=1e18;
const ll mod3=9e18;
const ll N=1e9+7;

long long power(ll  x, ll n){if(n==0)return 1;ll temp=power(x,n/2);if(n%2==0)return temp*temp;else return x*temp*temp;}

ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return (a*b)/(gcd(a,b));}
void swap(int* a, int* b){int t = *a;*a = *b;*b = t;}
bool f(ll x,ll y){return x>y;}

ll MAX(ll a,ll b){return a>b?a:b;}
ll MIN(ll x,ll  y){return x>y?y:x;}

ll pmod(ll a, ll b,ll mod)//a^b%mod
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b/=2;
        a=(a*a)%mod;
    }
    return ans;
}

bool cmp2( pair<ll,ll> &a,
           pair<ll,ll> &b)
{
    return a.second>b.second;
}


void solve() {
   ll n;
   cin>>n;
   ll arr[n][3];
   fo(i,0,n){
       cin>>arr[i][0]>>arr[i][1]>>arr[i][2];

   }



   ll ans[n][3];
   ans[0][0]=arr[0][0];
   ans[0][1]=arr[0][1];
   ans[0][2]=arr[0][2];

   for(ll i=1;i<n;i++){
       ans[i][0]=arr[i][0]+MAX(ans[i-1][1],ans[i-1][2]);
       ans[i][1]=arr[i][1]+MAX(ans[i-1][0],ans[i-1][2]);
       ans[i][2]=arr[i][2]+MAX(ans[i-1][0],ans[i-1][1]);



   }

   cout<<MAX(MAX(ans[n-1][0],ans[n-1][1]),ans[n-1][2]);

}

























int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin) ;
    freopen("output.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
#endif








    ll t;
    t=1;
    //  cin>>t;
    //  cin.ignore();
    while(t--){

        solve();
    }




    return 0;


}

////vll adj[100001];
////ll vis[100001];
////ll sssp[100001];

Measured memory_bytes: 8348
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!
 
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);
 
typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
typedef vector<vector<int>> Graph;
 
signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
 
    int a;
    cin >> a;
    int n = 1;
    while (n * (n + 1) / 2 < a) {
        n++;
    }
 
    string s = string(n, ')') + string(n, '(');
 
    int pos = n;
    rep(i, n * (n + 1) / 2 - a) {
        swap(s[pos], s[pos - 1]);
        pos--;
    }
    cout << s << endl;
}

Measured memory_bytes: 3364
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e8 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	An := make([]int, N)
	var sum, cost1, cost2, ans int
	var ave float64
	for i := range An {
		An[i] = nextInt()
		sum += An[i]
	}
	ave = float64(sum) / float64(N)
	for _, Ai := range An {
		ave1 := int(math.Ceil(ave))
		ave2 := int(math.Floor(ave))
		cost1 += cost(Ai, ave1)
		cost2 += cost(Ai, ave2)
	}
	if cost1 < cost2 {
		ans = cost1
	} else {
		ans = cost2
	}
	fmt.Println(ans)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func cost(Ai int, ave int) int {
	if Ai > ave {
		return (Ai - ave) * (Ai - ave)
	} else {
		return (ave - Ai) * (ave - Ai)
	}
}


Measured memory_bytes: 5760
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a;
	int s=0;
	cin>>a;
	int n=a.size();
	for(int i=0;i<n;i++){
		if(a[i]=='2'){
			s++;
		}
	}
	cout<<s;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll t;
    {
        ll i,j,k,l,m,n;
        cin>>n;
        map <ll,ll> mp;
        for(i=0;i<n-1;i++)
        {
            cin>>k;
            mp[k]++;
        }
        for(i=1;i<=n;i++)
        {
            cout<<mp[i]<<endl;
        }
    }

}



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

int H;
int W;
vector<string> S;
int cnt;

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

int b = 0;
int dfs(int y,int x,int p){
  if( x < 0 || y < 0 || x >= W || y >= H) return 0;
  if( S[y][x] == p ) return 0;
  if( d[y][x]++ ) return 0;
  cnt++;
  b += S[y][x] == '#';
  for(int i = 0 ; i < 4 ; i++){
    dfs(y + dy[i], x + dx[i], S[y][x]);
  }
  return 0;
}
void solve(long long H, long long W, vector<string> S) {
  ::H = H;
  ::W = W;
  ::S = S;
  long long cnt2 = 0;
  rep(i, H) rep(j, W){
    if( !d[i][j] && S[i][j] == '#'){
      cnt = 0;
      b = 0;
      dfs(i, j, 0);
      cnt2 += 1ll * b * (cnt-b);
    }
  }
  cout << cnt2 << endl;
}

int main() {

  long long H;
  scanf("%lld", &H);
  long long W;
  scanf("%lld", &W);
  vector<string> S(H);
  for (int i = 0; i < H; i++) {
    cin >> S[i];
  }
  solve(H, W, S);
  return 0;
}


Measured memory_bytes: 13824
N = int(input())
lis = list(map(int, input().split()))

for i in range(N-1):
    if lis[i] < lis[i+1]:
        lis[i+1] -= 1
    elif lis[i] == lis[i+1]:
        continue
    else:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 20652
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T & a, T b) { if (a < b)a = b; }
template<class T>void chmin(T & a, T b) { if (a > b)a = b; }
constexpr int INF = 1000000000000000000;
constexpr int mod = 1000000007;
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int kaijo[2000010];
struct edge { int to, cost; };
int gcd(int a, int b) {
    if (b == 0)return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
bool prime(int a) {
    if (a == 1)return false;
    for (int i = 2; i * i <= a; i++) {
        if (a % i == 0)return false;
    }
    return true;
}
void init_fact() {
    kaijo[0] = 1;
    for (int i = 1; i <= 2000000; i++) {
        kaijo[i] = kaijo[i - 1] * i;
        kaijo[i] %= mod;
    }
}
int modpow(int a, int b) {
    if (b == 0)return 1;
    if (b % 2)return modpow(a, b - 1) * a % mod;
    int memo = modpow(a, b / 2);
    return memo * memo % mod;
}
int comb(int a, int b) {
    if (!kaijo[0])init_fact();
    return kaijo[a] * modpow(kaijo[a - b], mod - 2) % mod * modpow(kaijo[b], mod - 2) % mod;
}
int inv(int x) {
    x = modpow(x, mod - 2);
    return x;
}
bool kosa(double ax, double ay, double bx, double by, double cx, double cy, double dx, double dy) {
    double ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax);
    double tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx);
    double tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx);
    double td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx);
    return tc * td < 0 && ta * tb < 0;
}
int n, m, k, s[100010], sum[100010], dp[110][40000], ans;
void init() {
    for (int i = 1; i <= n;) {
        int j = n / i;
        if (i <= j) {
            s[m++] = 1;
            i++;
        }
        else {
            s[m++] = n / j - i + 1;
            i = n / j + 1;
        }
    }
}
signed main() {
    cin >> n >> k;
    init();
    dp[0][0] = 1;
    rep(i, k) {
        fill(sum, sum + m + 2, 0);
        rep(j, m + 1) {
            sum[j + 1] = sum[j] + dp[i][j];
            sum[j + 1] %= mod;
        }
        rep(j, m) {
            dp[i + 1][j] = sum[m - j] * s[j];
            dp[i + 1][j] %= mod;
        }
    }
    rep(i, m + 1) {
        ans += dp[k][i];
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 36736
//Author : Sukarna Paul

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1)
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;




int main(){
    IOS
    //freopen("output.txt","w",stdout);
    int n,k;
    cin>>n>>k;

    bool hav[n+1];
    memset(hav,false,sizeof hav);

    for(int i=0;i<k;i++){
        int d;
        cin>>d;
        for(int j=0;j<d;j++){
            ll a;
            cin>>a;
            hav[a]=true;
        }
    }
    int ans =0;
    for(int i=1;i<=n;i++){
        if(hav[i]==false)ans++;
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 3624
#include <iostream>
using namespace std;
static const int MAX = 100;

void trace(int A[], int N){
    for(int i = 0; i < N; i++){
        if(i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

void insertionSort(int A[],int N){
    int i,j,v;
    for(i = 1; i < N; i++){
        v = A[i];
        j = i-1;
        while (j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace(A, N);
    }
}

int main(){
    int A[MAX], N;
    
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];
    
    trace(A, N);
    insertionSort(A, N);
    
    
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;
const int size=1e5+5;
int fa[size],A[size],B[size];
vector<int> G[size];
queue<int> q;
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n-1+m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
		A[u]++,B[v]++;
	}
	for(int i=1;i<=n;i++) if(!B[i]) {q.push(i);fa[i]=0;}
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		for(auto v:G[u])
		{
			if(B[v]==1){q.push(v),fa[v]=u;}
			B[v]--;
		}
	}
	for(int i=1;i<=n;i++)
	{
		cout<<fa[i]<<endl;
	}
}
		

Measured memory_bytes: 7424
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int count = 0;
		for (int i=0; i < 3; i++) {
			if (N.charAt(i) == '7') {
				count++;
			}
		}
		if (count > 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 35740
import array


n = int(input())
a=[]
a=input().split(" ")
f=0
f1=0
b=0
for i in a:
    if int(i) == 0:
        print("0")
        f1=1
        break
        

sum =1
if f1==0:
    for i in a:
        sum=sum*int(i)
        if sum>1e18:
            f=1
            print("-1")
            break
    


if f==0 and f1==0:
    print(sum)

Measured memory_bytes: 20088
#include <stdio.h>

    int main()      /*this code is written by 190042146*/
{
    int N,i;

    scanf("%d", &N);
    int ara[N-1];
    int ara2[N];

    for(i=0;i<N-1;i++)
    {
        scanf("%d", &ara[i]);
        ara2[i]=0;
    }

    for(i=0;i<N-1;i++)
    {
        ara2[ara[i]-1]++;
    }

    for(i=0;i<N-1;i++)
    {
        printf("%d\n",ara2[i]);
    }

    printf("0");


    return 0;
}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  string t;
  cin >> s >> t;
  for(int i = 0; s[i]; ++i) {
    if(s[i] != t[i]) {
      cout << "No\n";
      return;
    }
  }
  cout << "Yes\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tc = 1;
  // cin >> tc;
  for(int i = 1; i <= tc; ++i) {
    // cout << "Case #" << i <<": ";
    solve();
  }
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    string s;
    cin >> s;
    string t;
    cin >> t;
    sort(All(s));
    sort(All(t));
    reverse(All(t));
    if(s < t) puts("Yes");
    else puts("No");
    return 0;
}

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n,a,b;
cin>>n>>a>>b;
if(a>b){
    cout<<0<<endl;
}
else if(a==b){
    cout<<1<<endl;
}
else{
    if(n-2>=0){
        cout<<b*(n-2)-a*(n-2)+1<<endl;
    }
    else{
        cout<<0<<endl;
    }
}
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main(){
	int n,m,tmp;
	scanf("%d %d",&n,&m);
	int** A = new int*[n];
	for(int i = 0; i < n; i++) A[i] = new int[m];
	int b[m];

	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			scanf("%d",&tmp);
			A[i][j] = tmp;
		}
	}
	for(int i = 0; i < m; i++){
		scanf("%d",&tmp);
		b[i] = tmp;
	}
	long long int sum;
	for(int i = 0; i < n; i++){
		sum = 0;
		for(int j = 0; j < m; j++){
			sum += A[i][j] * b[j];
		}
		printf("%lld\n",sum);
	}

	for(int i = 0; i < n; i++){
		delete[] A[i];
	}
	delete A;
}


Measured memory_bytes: 2740
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
struct edge{ll to;};
struct graph{
    ll N;
    vector<vector<edge> > G;
    vector<bool> used;

    graph(ll n): N(n), G(N), used(N,false) {}

    void ade(ll s, ll t){
        G[s].emplace_back((edge){t});
        G[t].emplace_back((edge){s}); //無向ならON
    }

    ll dfs(ll v=0){
        used[v]=true;
        ll sita=0;
        ll nai=0;
        for(auto E : G[v]){
            if(!used[E.to]){
                int tmp=dfs(E.to);
                sita+=tmp;
                if(tmp==0) ++nai;
            }
        }
        return sita+max(0LL,nai-1);
    }
};
//--MAIN-----------------------------------
void Main(){
    ll N; cin>>N;
    graph g(N);
    ll ct[N]={};
    ll root=-1;
    rep(i,N-1){
        ll a,b; cin>>a>>b;
        g.ade(a,b);
        if(++ct[a]>2) root=a;
        if(++ct[b]>2) root=b;
    }

    cout<< ( root==-1 ? 1 : g.dfs(root) ) << "\n";

}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 8192
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;

int main(){

	int n, s[100], ans=0;
	bool flag=false;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> s[i];
		ans+=s[i];
		if(s[i]%10!=0){
			flag=true;
		}
	}
	sort(s, s+n);
	if(flag){
		if(ans%10!=0){
			cout << ans << endl;
		} else {
			for(int i=0; i<n; i++){
				if(s[i]%10!=0){
					cout << ans-s[i] << endl;
					return 0;
				}
			}
		}
	} else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
PROGRAM ATCODER

implicit none
integer(16) :: n, a, b, c, i, j, s, cost, lena, lenb, lenc
integer(16),allocatable :: l(:,:),ans(:)

read(*,*) n, a, b, c
allocate(l(n,2), ans(4**n-1))
l = 0
ans = 10**9

do i = 1, n
	read(*,*) l(i,1)
end do

do j = 1, 4**n-1
	s = j
    cost = 0
    lenA = 0
    lenB = 0
    lenC = 0
	do i = 1, n
    	if (s /= 0) then
    		l(i,2) = mod(s,4)
        	s = s/4
        else
        	l(i,2) = 0
            exit
        end if
	end do
	do i = 1, n
		if (l(i,2) == 1) then
    		cost = cost + 10
        	lenA = lenA + l(i,1)
    	else if (l(i,2) == 2) then
    		cost = cost + 10
        	lenB = lenB + l(i,1)
    	else if (l(i,2) == 3) then
    		cost = cost + 10
        	lenC = lenC + l(i,1)            
		end if
    end do
    if(lenA /= 0 .and. lenB /= 0 .and. lenC /= 0)then
    	cost = cost + abs(a-lenA) + abs(b-lenB) + abs(c-lenC) - 30
        ans(j) = cost
    end if
end do

write(*,'(i0)') minval(ans)

END PROGRAM ATCODER

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;

static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra(){
    int minv;
    int d[MAX], color[MAX];

    for (int i=0;i<n;i++){
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[0] = 0;
    color[0] = GRAY;
    while (true){
        minv = INFTY;
        int u= -1;
        for (int i=0;i<n;i++){
            if(minv > d[i] and color[i] != BLACK){
                u = i;
                minv = d[i];
            }
        }
        if (u==-1){
            break;
        }
        color[u] = BLACK;
        for (int v=0;v<n;v++){
            if (color[v] != BLACK and M[u][v] != INFTY){
                if (d[v] > d[u] + M[u][v]){
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    for (int i=0;i<n;i++){
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }

}

int main(){
    
    cin >> n;
    for (int i=0;i<n;i++){
        for (int j=0;j<n;j++){
            M[i][j] = INFTY;
        }
    }
    int k,c,u,v;
    for (int i=0;i<n;i++){
        cin >> u >> k;
        for (int j=0;j<k;j++){
            cin >> v >> c;
            M[u][v] = c;
        }
    }

    dijkstra();
}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

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

int main(){
    bool flag=false;
    ll ans=LINF,sum=0;

    int n,k;
    cin >>n>>k;
    vector<int> x(n);

    rep(i,n){
        cin>>x[i];
    }

    rep(i,n-k+1){
        ll l=x[i];
        ll r=x[i+k-1];

        if(l*r < 0){
            chmin(ans, abs(r)+abs(l)+min(abs(r),abs(l)) );
        }else{
            chmin(ans,max(abs(l),abs(r)));
        }
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout<<ans<<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define lli long long int
#define double long double
#define all(x) x.begin(),x.end()
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define siz(x) x.size()
#define prs(x,y) x.find(y)!=x.end()
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define forn(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}
inline int level(int n){int ans=0;while(n%2==0){n/=2;ans++;}return ans;}
lli gr[3001][3001];
lli dp[3001][3001][4];
int main()
{
	fast_io //REMOVE FOR interactive problems
	int r,c,k;
	cin>>r>>c>>k;
	lli x,y,z;
	while(k--)
	{
		cin>>x>>y>>z;
		x--;
		y--;
	   gr[x][y]=z;
	}
	forn(i,r)
	{
		forn(j,c)
		{
			forn(k,4)
			{
				lli ans=0;
				if(k==1 && gr[i][j])
					ans+=gr[i][j];
				if(i>0 && (k==0 || k==1))
				{
					forn(k1,4)
						dp[i][j][k]=max(dp[i][j][k],ans+dp[i-1][j][k1]);
				}
				if(j>0)
				dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]);
				if(k>0)
				dp[i][j][k]=max(dp[i][j][k],gr[i][j]+((j>0)?dp[i][j-1][k-1]:0));
			}
		}
	}
	lli ansa=0;
	forn(k,4)
		ansa=max(ansa,dp[r-1][c-1][k]);
	cout<<ansa;
}



Measured memory_bytes: 355252
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        //int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();

        var x = 0;
        var ans = 0;
        while(x < 1000)
        {
            var t = String.Format("{0:000}", x);
            var index = 0;
            var search = t[index].ToString();
            for (int i = 0; i < n; i++)
            {
                if(search == s[i].ToString())
                {
                    index++;
                    
                    if(index >= 3)
                    {
                        ans++;
                        break;
                    }
                    else
                    {
                        search =  t[index].ToString();
                    }
                }
            }
            x++;
        }


        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 46248
#include <iostream>
#include <math.h>
using namespace std;
const double pi=acos(-1);
int main(){
    double x=0,y=0,a,d;
    bool f;
    int ang=90,p;
    string s;
    while(true){
        cin>>s;
        for(a=d=p=0;s[p]!=',';p++)a=a*10+s[p]-'0';
        p++;
        f=s[p]=='-';
        if(!f)d=s[p]-'0';
        while(++p<s.size())d=d*10+s[p]-'0';
        if(f)d=-d;
        if(a==0&&d==0)break;
        x+=a*cos(ang*2*pi/360);
        y+=a*sin(ang*2*pi/360);
        ang-=d;
    }
    cout<<(int)x<<endl<<(int)y<<endl;
}


Measured memory_bytes: 3452
s = input()

if s == 'SUN':
    print('7')
if s == 'SAT':
    print('1')
if s == 'FRI':
    print('2')
if s == 'THU':
    print('3')
if s == 'WED':
    print('4')
if s == 'TUE':
    print('5')
if s == 'MON':
    print('6')

Measured memory_bytes: 3060
#include <math.h>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <set>
#include <unordered_map>
#include <vector>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  bool S[1000000];
  for (int i = 0; i < N; i++) {
    char c;
    cin >> c;
    if (c == 'E') {
      S[i] = false;
    } else {
      S[i] = true;
    }
  }
  int ans = N;
  int num;
  for (int j = 0; j < N; j++) {
    if (j > 0) {
      if (S[j] == false) num++;
    }
  }
  ans = num;
  for (int i = 1; i < N; i++) {
    if (S[i] == false) {
      num--;
    }
    if (S[i - 1] == true) {
      num++;
    }
    if (num < ans) ans = num;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>

int main(void){
    int n;
    scanf("%d",&n);

    int check[300];
    for(int i=0; i*4<=n; i++){
        for(int j=0; j*7<=n; j++){
            int ans=i*4+j*7;
            check[ans]=10;
        }
    }
    if(check[n]==10)printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  string s,t;cin>>s>>t;
  int a,b;cin>>a>>b;
  string u;cin>>u;
  if(u==s)a--;
  else if(u==t)b--;
  cout<<a<<" "<<b<<ENDL;

}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 256