akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    cin>>N;
    vector<vector<int>> E(N);
    for (int i=0; i<N-1; i++)
    {
        int A, B;
        cin>>A>>B;
        E[A-1].push_back(B-1);
        E[B-1].push_back(A-1);
    }
    int K;
    cin>>K;
    int oo = 2000000;
    vector<int> L(N,-oo), U(N,+oo), P(N,-1);

    for (int i=0; i<K; i++)
    {
        int v, p;
        cin>>v>>p;
        L[v-1] = U[v-1] = p;
        P[v-1] = p%2;
    }

    function<void(int,int)> BT1 = [&](int cur, int pre)
    {
        bool e = P[cur]==-1 || P[cur]==0;
        bool o = P[cur]==-1 || P[cur]==1;

        for (int c: E[cur])
        if (c!=pre)
        {
            BT1(c, cur);
            L[cur] = max(L[cur], L[c]-1);
            U[cur] = min(U[cur], U[c]+1);
            if (P[c]==0)
                e = false;
            if (P[c]==1)
                o = false;
        }

        if (e && !o)
            P[cur] = 0;
        if (!e && o)
            P[cur] = 1;
        if (!e && !o)
            L[cur] = +oo,
            U[cur] = -oo;
    };
    BT1(0, -1);

    bool ok = true;
    for (int i=0; i<N; i++)
        if (L[i]>U[i])
            ok = false;

    if (ok)
    {
        cout<<"Yes"<<endl;
        vector<int> A(N);

        function<void(int,int)> BT2 = [&](int cur, int pre)
        {
            if (pre==-1)
                A[cur] = L[cur];
            else
                A[cur] = L[cur]<=A[pre]-1 && A[pre]-1<=U[cur] ? A[pre]-1 : A[pre]+1;

            for (int c: E[cur])
            if (c!=pre)
                BT2(c, cur);
        };
        BT2(0, -1);
        for (int a: A)
            cout<<a<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


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

int main() {
  int A,B;
  cin >> A >> B;
  int p_8=0;
  int p_10=0;
  p_10=10*B;
  for(int i=0; i<10; i++){
    p_8 = p_10 + i;
    if(p_8*0.08 >= A && p_8*0.08 < A+1){
      cout << p_8 << endl;
      return 0;
    }
  }
  
  cout << -1 << endl;
  
  
}

  
  

  
  // int型の2次元配列(3×4要素の)の宣言
  //vector<vector<int>> data(3, vector<int>(4));

  // 入力 (2重ループを用いる)
  //for (int i = 0; i < 3; i++) {
    //for (int j = 0; j < 4; j++) {
      //cin >> data.at(i).at(j);
    //}
  //}


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

class Candies
{
private:
  std::vector<std::vector<int>> data;
  int n;
public:
  Candies ()
  {
    cin >> n;
    data.resize(2);
    for (auto &row : data)
    {
      row.resize(n);
      for (int i=0; i<n; ++i)
      {
        cin >> row[i];
      }
    }
  }
  
  int solve ()
  {
    for (int i=0; i<2; ++i)
    {
      for (int j=0; j<n; ++j)
      {
        int addition = 0;
		if (0 < i)
        {
          if (addition < data[i-1][j])
          {
            addition = data[i-1][j];
          }
        }
        if (0 < j)
        {
          if (addition < data[i][j-1])
          {
            addition = data[i][j-1];
          }
        }
        data[i][j] += addition;
      }
    }
    
    return data[1][n-1];
  }
};

int main ()
{
  Candies candies;
  cout << candies.solve() << endl;
  return 0;
}

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

int n, a, c = 1;
long long ans;

int main(){
    cin >> n;
    rep(i,n){
        cin >> a;
        if(!i) ans += a - c++;
        else if(a == c) c++;
        else ans += (a-1) / c;
    }
    cout << ans << '\n';
}

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

int main()
{
  int h, n, a;

  cin >> h >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> a;
    h -= a;
  }
  cout << (h <= 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.readInt();
            int[] a = in.readIntArray(n);
            int ans = 0;
            int cnt = 1;
            for (int i = 1; i < n; i++) {
                if (a[i] != a[i - 1]) {
                    ans += cnt / 2;
                    cnt = 1;
                } else cnt++;
            }
            ans += cnt / 2;
            out.println(ans);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int[] readIntArray(int size) {
            int[] ans = new int[size];
            for (int i = 0; i < size; i++) ans[i] = readInt();
            return ans;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
n = gets.to_i
work = Array.new(n).map{Array.new(2,0)}
n.times{|i| work[i] = gets.split.map(&:to_i)}
work.sort! {|a,b| a[1] <=> b[1]}
time = 0
for i in 0..n-1
  time += work[i][0]
  if time > work[i][1]
    puts "No"
    exit
  end
end
puts "Yes"


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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n;
        cin>>n;
        string s;
        map<string,int> ans;
        ans["AC"] = 0;
        ans["WA"] = 0;
        ans["TLE"] = 0;
        ans["RE"] = 0;
        for(int i=0;i<n;i++)cin>>s,ans[s]++;
        cout<<"AC x "<<ans["AC"]<<endl;
        cout<<"WA x "<<ans["WA"]<<endl;
        cout<<"TLE x "<<ans["TLE"]<<endl;
        cout<<"RE x "<<ans["RE"]<<endl;
    }
    return 0;
}


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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
// Sat Apr 11 06:23:29 IST 2020   

#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long    
#define MOD                998244353
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"  
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             (x).begin(),(x).end() 

using namespace std ; 
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
const int M = 1e9+7 ;

int tests(){ 
  int N ;
  cin >> N ; 
  string s ;
  cin >> s ;
  map <char,int> m;
  m['R'] = 0 ;
  m['G'] = 1 ;
  m['B'] = 2 ;
  vector <vector <int>> v(3);
  for(int i = 0 ;  i < N ;i++)
    v[m[s[i]]].push_back(i);

  ll ans  = 0 ;
  for(int i = 0 ; i < N ; i++ )
    for(int j = i+1 ; j < N ; j++ )
      if(s[i] != s[j]){ 
      int gen  = 3-m[s[i]]-m[s[j]] ;
      // cout << gen  << '\n' ;
      if(upper_bound(all(v[gen]),j)  != v[gen].end())
      ans += (ll)(v[gen].end()- upper_bound(all(v[gen]),j));
      if(binary_search(all(v[gen]),j-i+j) == true) 
        ans  -= 1 ;
    }
    cout << ans  << '\n' ;
  return  0; 
}
int32_t main(){
    I__O ;            
    int cases = 1 ;  
    // cin >> cases ;  
    for(int  _ = 1 ; _ <= cases ; _++ ){   
    // cout << "Case #" << _ << ": "; 
      tests(); 
    }
    return 0 ; 
}

// -Wall -Weptra -O2
// -pedantic -std=c++11
// -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC

Measured memory_bytes: 3688
#include <bits/stdc++.h>
    using namespace std;
    long long b[2*100000+1];
    long long a[2*100000+1];
    long long vis[2*100000+1];
    long long n,m;
    long long parent[2*100000+1];
    long long pre[2*100000+1],suf[2*100000+1];
     
    void dfs2(long long i,vector<long long> adj[],long long par){
        vis[i]=1;
        pre[0]=1;
        long long x=1;
        for(long long j=0;j<adj[i].size()-1;j++){
            
            if(adj[i][j]!=par)
                x=(x*(a[adj[i][j]]+1))%m;
            pre[j+1]=x;
        }
        
        suf[adj[i].size()-1]=1;
        x=1;
        for(long long j=adj[i].size()-1;j>0;j--){
            
            if(adj[i][j]!=par)
                x=(x*(a[adj[i][j]]+1))%m;
            suf[j-1]=x;
        }
        
        
        for(long long j=0;j<adj[i].size();j++){
            if(adj[i][j]!=par){
                b[adj[i][j]]=(pre[j]*suf[j])%m;
                b[adj[i][j]]=(b[i]*b[adj[i][j]]+1)%m;
            }
        }
        
        
        for(long long j=0;j<adj[i].size();j++){
            if(!vis[adj[i][j]]){
                dfs2(adj[i][j],adj,i);
            }
        }
    }
     
    void dfs(long long i,vector<long long> adj[]){
        vis[i]=1;
        a[i]=1;
        for(long long j=adj[i].size()-1;j>-1;j--){
            if(!vis[adj[i][j]]){
                dfs(adj[i][j],adj);
                a[i]=(a[i]*(a[adj[i][j]]+1))%m;
                
            }
        }
    }
     
    int main() {
    	long long x,y;
    	cin>>n>>m;
    	vector<long long> adj[n+1];
    	for(long long i=0;i<n-1;i++){
    	    cin>>x>>y;
    	    adj[x].push_back(y);
    	    adj[y].push_back(x);
    	}
     
    	memset(vis,0,sizeof(vis));
    	dfs(1,adj);
    	a[0]=0;
    	memset(vis,0,sizeof(vis));
    	b[1]=1;
    	if(n>1)
        	dfs2(1,adj,0);
    	for(long long i=1;i<=n;i++)
    	    cout<<((b[i]*a[i])%m)<<endl;
    }

Measured memory_bytes: 15348
///////////////////////////////////////////// Template /////////////////////////////////////////////
#![allow(non_snake_case, unused_imports)]
use std::io::Write;
use std::collections::*;
use template::*;

#[macro_use]
pub mod template {
	macro_rules! debug {
	    ($($v: expr),*) => {
	    	$(let _ = write!(std::io::stderr(), "{} = {:?} ", stringify!($v), $v);)*
	        let _ = writeln!(std::io::stderr(), "@ {}:{}", file!(), line!());
	    }
	}
	macro_rules! mat {
		($e:expr) => { $e };
		($e:expr; $d:expr $(; $ds:expr)*) => { vec![mat![$e $(; $ds)*]; $d] };
	}
	pub trait FromLn {
		fn fromln(s: &str) -> Self;
	}	
	pub fn readln<T: FromLn>() -> T {
		let mut buf = String::new();
		let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
		T::fromln(buf.trim())
	}
	pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
		let mut vs = vec![];
		for _ in 0..n { vs.push(readln()); }
		vs
	}
	macro_rules! fromln_primitives {
		($($t:ty),*) => { $(
			impl FromLn for $t {
				fn fromln(s: &str) -> $t {
					s.parse().unwrap()
				}
			}
		)* }
	}
	fromln_primitives!(String, bool, f32, f64, isize, i8, i16, i32, i64, usize, u8, u16, u32, u64);
	impl<T> FromLn for Vec<T> where T: FromLn {
		fn fromln(s: &str) -> Vec<T> {
			s.split_whitespace().map(T::fromln).collect()
		}
	}
	impl FromLn for Vec<char> {
		fn fromln(s: &str) -> Vec<char> {
			s.chars().collect()
		}
	}
	macro_rules! fromln_tuple {
		($($t:ident: $i:expr),*; $n:expr) => {
			impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
				fn fromln(s: &str) -> ($($t),*) {
					let ss = s.split_whitespace().collect::<Vec<_>>();
					assert_eq!(ss.len(), $n);
					($($t::fromln(ss[$i])),*)
				}
			}
		}
	}
	fromln_tuple!(A:0, B:1; 2);
	fromln_tuple!(A:0, B:1, C:2; 3);
	fromln_tuple!(A:0, B:1, C:2, D:3; 4);
	pub trait SetMin {
		fn setmin(&mut self, v: Self) -> bool;
	}
	impl<T> SetMin for T where T: PartialOrd {
		fn setmin(&mut self, v: T) -> bool {
			*self > v && { * self = v; true }
		}
	}
	pub trait SetMax {
		fn setmax(&mut self, v: Self) -> bool;
	}
	impl<T> SetMax for T where T: PartialOrd {
		fn setmax(&mut self, v: T) -> bool {
			*self < v && { * self = v; true }
		}
	}
}
fn main() {
	let _ = writeln!(std::io::stderr(), "----- {} -----", file!());
	let _ = std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}
////////////////////////////////////////////////////////////////////////////////////////////////////

fn run() {
	let x: i32 = readln();
	println!("{}", if x < 1200 { "ABC" } else { "ARC" });
}


Measured memory_bytes: 8572
#include<bits/stdc++.h>
using namespace std;
int a[1000];
int main()
{
   int x,n;
   cin>>x>>n;
   if(n==0)
   {
   cout<<x;
   return 0;
   }
   for(int i=1;i<=n;i++)
   cin>>a[i];
   sort(a+1,a+n+1);
   int s=0,mins=100000,mini=0;
   bool pd=true;
   for(int i=-10000;i<=10000;i++)
   {
    pd=true;
    for(int j=1;j<=n;j++)
	if(i==a[j])
	{
	pd=false;
	break;	
	}
	if(pd==true)
	{
	  s=fabs(x-i);
      if(s<mins)
      {
        mini=i;
        mins=s;
      }			
	}   	 
    }
   cout<<mini;
   return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#define F first
#define S second
#define PB push_back
#define MP make_pair


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vii;
typedef set<int> si;
typedef map<string, int> msi;

#define INF 2000000000

const int maxn=10000009;
const ll mod=1e9+7;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    vii a(n);
    int i,p;
    for(i=0;i<n;i++){
        cin>>p;
        a[i]={p,i+1};
    }
    sort(a.begin(),a.end());
    for(i=0;i<n;i++){
        cout<<a[i].second<<' ';
    }

}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n,k;
  cin>>n>>k;
  vector<ll> h(n);
  rep(i,n)cin>>h[i];
  sort(h.begin(),h.end());
  ll a=0;
  k=min(n,k);
  rep(i,n-k) {
    a+=h[i];
  }
  cout<<a<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int x;
    cin >> x;
    cout << lcm(x,360)/x << endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  vector<int> b(M);
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 1; i <= N; i++) {
    int cnt = 0;
    for (int j = 0; j < M; j++) {
      if (i == a[j] || i == b[j])
        cnt++;
    }
    cout << cnt << endl;
  }
}

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

int a[100];
LL f[100][2];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	f[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		if (a[i] & 1) f[i][1] += 2 * f[i - 1][0] + 3 * f[i - 1][1], f[i][0] += f[i - 1][0];
		else f[i][1] += f[i - 1][0] + 3 * f[i - 1][1], f[i][0] += 2 * f[i - 1][0];
	} 
	return printf("%lld\n", f[n][1]), 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        long[] xs = new long[n];
        long[] ys = new long[m];
        for (int i = 0; i < n; i++) {
            xs[i] = sc.nextLong();
        }
        for (int i = 0; i < m; i++) {
            ys[i] = sc.nextLong();
        }
        long x = 0L;
        for (int k = 1; k <= n; k++) {
            x += (k - 1) * xs[k - 1] - (n - k) * xs[k - 1];
        }
        long y = 0L;
        for (int k = 1; k <= m; k++) {
            y += (k - 1) * ys[k - 1] - (m - k) * ys[k - 1];
        }
        System.out.println(new BigInteger(String.valueOf(x)).multiply(new BigInteger(String.valueOf(y))).remainder(new BigInteger(String.valueOf("1000000007"))));
    }
}


Measured memory_bytes: 91948
#include <bits/stdc++.h>
#define int long long
using namespace std;

int c,a[555],b[555],w[555];

signed main(){
  int n,N,o;
  cin>>n;
  if(n==1){
    cout<<2<<' '<<1<<endl;
    cout<<1<<' '<<2<<' '<<0<<endl;
    return 0;
  }
  o=n;
  for(int i=1;;i++){
    if(pow(2,i)<=n&&n<pow(2,i+1)){
      N=i+1;
      n-=pow(2,i);
      break;
    }
  }
  for(int i=0;i<N-1;i++){
    a[c]=i;
    b[c]=i+1;
    w[c]=0;
    c++;
    a[c]=i;
    b[c]=i+1;
    w[c]=pow(2,i);
    c++;
  }
  for(int i=N;i>=0;i--){
    int x=pow(2,i);
    if(n>=x){
      int s=o-n;
      n-=x;
      int X=N-(N-i);
      a[c]=X;
      b[c]=N-1;
      w[c]=s;
      c++;
    }
  }
  cout<<N<<' '<<c<<endl;
  for(int i=0;i<c;i++){
    cout<<a[i]+1<<' '<<b[i]+1<<' '<<w[i]<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
using namespace std;
int main()
{
    char a, b;
    scanf("%c %c", &a, &b);
    if(a=='H' || a=='D'){
            if(b=='H' || b=='D'){
        if(a==b){
            printf("H\n");
        }
        else{
            printf("D\n");
        }
    }
    }
   return 0;
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

struct color{
    string name;
    int r,g,b;
};

int xx(int a){ return a * a; }

string colorName(struct color c[8], double r, double g, double b){
    double near = 99999;
    string name;
    rep(i,8){
        double dis = sqrt(xx(r - c[i].r) + xx(g - c[i].g) + xx(b - c[i].b));
        if(near > dis){
            near = dis;
            name = c[i].name;
        }
    }
    return name;
}

int chenge(char a){
    if(a >= '0' && a <= '9') return a - '0';
    else return a - 'a' + 10;
}

int DecimalNumber(char c16[2]){
    int c10 = 0;
    rep(i,chenge(c16[0])){
        c10 += 16;
    }
    c10+=chenge(c16[1]);
    
    return c10;
}


int main(){
    struct color c[8] = {
        {"black", 0, 0, 0},
        {"blue", 0, 0, 255},
        {"lime", 0, 255, 0},
        {"aqua", 0, 255, 255},
        {"red", 255, 0, 0},
        {"fuchsia", 255, 0, 255},
        {"yellow", 255, 255, 0},
        {"white", 255, 255, 255}
    };

    char r[2],g[2],b[2],gar;
    while(true){
        int R,G,B;
        cin >> gar;
        if(gar == '0') break;
        rep(i,2) cin >> r[i]; 
        rep(i,2) cin >> g[i]; 
        rep(i,2) cin >> b[i]; 

        R =  DecimalNumber(r);
        G =  DecimalNumber(g);
        B =  DecimalNumber(b);
        cout << colorName(c,static_cast<int>(R),static_cast<int>(G),static_cast<int>(B)) << endl;
    }

}

Measured memory_bytes: 1180
use std::cmp;
use std::io::*;
use std::str::FromStr;

fn main() {
    let (q, h, s, d): (i64, i64, i64, i64) = (read(), read(), read(), read());
    let n: i64 = read();
    let mut min = q * 4;
    min = cmp::min(min, h * 2);
    min = cmp::min(min, s);
    let min2 = cmp::min(min * 2, d);
    println!("{}", (n / 2) * min2 + (n % 2) * min);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
import sys


def resolve(in_):
    S = next(in_).strip()
    
    if S[0] != 'A':
        return False
    if S.count('C', 2, -1) != 1:
        return False
    i = S.find('C')
    a = S[1:i]
    b = S[i + 1:]
    if not (a.islower() and b.islower()):
        return False
    
    return True


def main():
    answer = resolve(sys.stdin)
    print('AC' if answer else 'WA')


if __name__ == '__main__':
    main()


Measured memory_bytes: 8944
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll

int dist[200][200];
int frozen[200];
void solve(){
	while (true) {
		int n, m, l, k, a, h;
		cin >> n >> m >> l >> k >> a >> h;
		if (n == 0) return;
		REP(i, 200) {
			REP(q, 200) {
				if (i != q) {
					dist[i][q] = 1e9;
				}
				else {
					dist[i][q] = 0;
				}
			}
			frozen[i] = 0;
		}
		REP(i, l) {
			int a;
			cin >> a;
			frozen[a] = 1;
		}
		frozen[a] = 1;
		frozen[h] = 1;
		REP(i, k) {
			int a, b, c;
			cin >> a >> b >> c;
			dist[a][b] = c;
			dist[b][a] = c;
		}
		// suspicious
		REP(tea,4)
		REP(i, n) {
			REP(q, n) {
				REP(j, n) {
					dist[q][j] = min(dist[q][j], dist[q][i] + dist[i][j]);
				}
			}
		}
		int visited[200] = {};
		int cost[200] = {};
		REP(i, n) {
			cost[i] = 1e9;
		}
		cost[a] = 0;
		REP(tea, n) {
			int now_itr = -1;
			REP(q, n) {
				if (visited[q] == 1) continue;
				if (frozen[q] == 0) continue;
				if (now_itr == -1 || cost[now_itr] > cost[q]) {
					now_itr = q;
				}
			}
			if (now_itr == -1) continue;
			visited[now_itr] = 1;
			REP(j, n) {
				if (dist[now_itr][j] <= m) {
					cost[j] = min(cost[j], dist[now_itr][j] + cost[now_itr]);
				}
			}
		}
		swap(a, h);
		if (cost[a] == 1e9) {
			cout << "Help!" << endl;
		}
		else {
			int hoge = cost[a];
			hoge += max(0LL, cost[a] - m);
			cout << hoge << endl;
		}
	}
}

#undef int
int main() {
	init();
	solve();
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


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

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

ll dp[1001];

void fn(int n){
	FOR(i,2,n+1){
		if(i==n) dp[n]=2;
		if(n%i==0) dp[n]=dp[n%i]*(dp[i]-1);
	}
}

int main(void){	
	int n,dp[100005]={};
	ll result=1;

	cin>>n;
	int number;
	REP(i,n){
		cin>>number;
		dp[number]++;
	}

	if(n%2){
		if(dp[0]==1){
			FOR(i,1,n+1){
				if(i==n){
					REP(i,n/2) result=(result*2)%MOD;
					cout<<result<<endl;
					return 0;
				}
				if(i%2==1&&dp[i]!=0) break;
				if(i%2==0&&dp[i]!=2) break;
			}
		}
	}else{
		REP(i,n+1){
			if(i==n){
				REP(i,n/2) result=(result*2)%MOD;
				cout<<result<<endl;
				return 0;
			}
				if(i%2==1&&dp[i]!=2) break;
				if(i%2==0&&dp[i]!=0) break;
		}
	}
	puts("0");
	return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll h, w;std::cin >> h >> w;
  vector<string> s(h);
  re(i, h) std::cin >> s[i];

  re(i, h){
    re(j, w){
      ll c = 0;
      if(s[i][j]=='.') continue;
      for(int l=-1;l<=1;l++){
        for(int r=-1;r<=1;r++){
          if(l!=0&&r!=0) continue;
          if(l==0&&r==0) continue;
          if(i+l<0||i+l>=h||j+r<0||j+r>=w) continue;
          if(s[i+l][j+r]=='#') c++;
        }
      }
      if(c==0){
        std::cout << "No" << '\n';
        return 0;
      }
    }
  }
  std::cout << "Yes" << '\n';
  return 0;
}


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

int main(void){
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  string ans = ":(";
  if(e-a <= k){
    ans = "Yay!";
  }
  cout << ans << endl;
}

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

AC = [0 for i in range(N+1)]
WA = [0 for i in range(N+1)]

for i in range(M):
    a,b=input().split()
    a2 = int(a)
    if b == 'AC':
      AC[a2 - 1] = 1
    elif b == 'WA' and AC[a2 - 1] == 0:
      WA[a2-1]+= 1

ans_WA = 0
for i, j in zip(WA, AC):
  ans_WA += i * j
  
print(sum(AC), ans_WA)

Measured memory_bytes: 10400
//*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <functional>
#define MOD 1000000007
#define MAX 0x3f3f3f3f
#define MAX2 0x3f3f3f3f3f3f3f3fll
#define ERR 1e-10
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

int n, m;
char in[4000];
int a[4000];
int s[4000];

ll d[3005][3005];

ll ncr[3005][3005];

pii b[4000];

int main()
{
	int i, j, k, l;
	cin>>n>>m>>in;
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=i;j++)
		{
			if(j == 0 || j == i) ncr[i][j]=1;
			else ncr[i][j]=ncr[i-1][j-1]+ncr[i-1][j], ncr[i][j]%=MOD;
		}
	}
	for(i=0;i<n;i++) a[i]=in[i]-'0';
	partial_sum(a, a+n, s);
	for(i=0;i<m;i++)
	{
		scanf("%d%d", &b[i].first, &b[i].second), b[i].first--, b[i].second--;
		if(i && b[i].second <= b[i-1].second)
		{
			m--;
			i--;
		}
	}
	d[0][0]=1;
	b[m]=mp(n, n);
	for(i=0;i<m;i++)
	{
		int st=(i?max(b[i-1].second+1, b[i].first):b[i].first);
		int jma=st-b[i].first+1;
		int kma=max(b[i].second-b[i+1].first+1, 0);
		int len=b[i].second-b[i].first+1;
		for(j=0;j<=jma;j++)
		{
			if(d[i][j] == 0) continue;
			int ones=j+(s[b[i].second]-(st?s[st-1]:0));
			for(k=ones+kma-len;k<=kma;k++)
			{
				d[i+1][k]+=d[i][j]*ncr[len-kma][ones-k], d[i+1][k]%=MOD;
			}
		}
	}
	cout<<d[m][0]<<endl;
	return 0;
}
//*/

Measured memory_bytes: 52096
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            long x = long.Parse(Console.ReadLine());
            long m = 100;
            long y = 0;
            while(true){
                if(m >= x){
                    Console.WriteLine(y);
                    return;
                }
                m = (long)(m * 1.01);
                y++;
            }
        }
    }
}


Measured memory_bytes: 27540
/*
ID: yaoxinw2
TASK: test
LANG: C++
*/
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	for(int i=0;;i++){
		a-=d;
		c-=b;
		if(c<=0){
			cout<<"Yes"<<endl;
			return 0;
		}
		if(a<=0){
			cout<<"No"<<endl;
			return 0;
		}
	}
	return 0;
} 

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

int main(){
	int r, D, x; cin >> r >> D >> x;

	for(int i = 0; i < 10; i++){
		x = r * x - D;
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s.find('a')!=string::npos && s.find('b')!=string::npos && s.find('c')!=string::npos) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void) {
  int i, j, k;
  int r[6][2] = {
    {3, 4},
    {4, 3},
    {1, 4},
    {-1, 5},
    {3, -1},
    {2, 1}
  };
  char s[120];
  while( 1 ) {
    int now = 0, ans = 1;
    scanf("%s", s);
    if(s[0] == '#') break;
    for(i = 0; i < strlen(s); ++i) {
      now = r[now][s[i] - '0'];
      if(now == -1) {
        ans = 0;
        break;
      }
    }
    if(now != 1) ans = 0;
    if(ans) printf("Yes\n");
    else printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <cstdio>
const int MAX_N = 10;
using namespace std;

int main(void) {
  int n;
  while (1) {
    cin >> n;
    if (n == 0) break;
    int masu[MAX_N + 1][MAX_N + 1];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        cin >> masu[i][j];
      }
    }

    for (int i = 0; i < n; i++) {
      int tmp = 0;
      for (int j = 0; j < n; j++) {
        tmp += masu[i][j];
      }
      masu[i][n] = tmp;
    }
    for (int i = 0; i < n; i++) {
      int tmp = 0;
      for (int j = 0; j < n; j++) {
        tmp += masu[j][i];
      }
      masu[n][i] = tmp;
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
      sum += masu[n][i];
    }
    masu[n][n] = sum;

    for (int i = 0; i < n + 1; i++) {
      for (int j = 0; j < n; j++) {
        printf("%5d", masu[i][j]);
      }
      printf("%5d\n", masu[i][n]);
    }
  }

  return 0;
}

Measured memory_bytes: 1160
a = list(str(input()))
cnt=0

if a[0]=="R":
    cnt+=1
    if a[1]=="R":
        cnt+=1
        if a[2]=="R":
            cnt+=1
elif a[1]=="R":
    cnt+=1
    if a[2]=="R":
        cnt+=1
elif a[2]=="R":
    cnt+=1


print(cnt)

Measured memory_bytes: 9036
import sys
input = sys.stdin.readline
import math
def main():
    A, B, H, M = map(int, input().split())
    hour = math.radians(360/12)
    minute = math.radians(360/60)
    hm = math.radians(1/2)
    Ax = math.cos((hour*H + hm*M ))*A
    Ay = math.sin((hour*H + hm*M))*A
    Bx = math.cos((minute*M))*B
    By = math.sin((minute*M))*B
    # print(Ax,Ay)
    # print(Bx,By)
    # print(math.sin(math.radians(30)))
    ans = math.sqrt(abs(Ax-Bx)*abs(Ax-Bx) + abs(Ay-By)*abs(Ay-By))
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9324
/*
 * main.c
 *
 *  Created on: 2020/02/22
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}


int main()
{
	char S[4] = {0};
	int ans = 0;
	scanf("%s", S);

	if ((S[0] == 'A') && (S[1] == 'A') && (S[2] == 'A')) {
		ans = 1;
	}
	if ((S[0] == 'B') && (S[1] == 'B') && (S[2] == 'B')) {
		ans = 1;
	}
	if (ans == 1) {
		printf("No\n");
	} else {
		printf("Yes\n");
	}
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
 
int main(){
	char b;
  	cin >> b;
  	if(b == 'A'){
    	cout << "T";
    }
	if(b == 'T'){
    	cout << "A";
    }
	if(b == 'G'){
    	cout << "C";
    }  
	if(b == 'C'){
    	cout << "G";
    }  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	char a;
	cin >> a;
	if (a == 'A') {
		cout << 'T' << endl;
		return 0;
	}
	if (a == 'T') {
		cout << 'A' << endl;
		return 0;
	}
	if (a == 'G') {
		cout << 'C' << endl;
		return 0;
	}
	if (a == 'C') {
		cout << 'G' << endl;
		return 0;
	}
	return 0;
}


Measured memory_bytes: 256
n=int(input())
b=list(map(int,input().split()))
ans=[]
while b:
    f=1
    for i in range(len(b)-1,-1,-1):
        if b[i]==i+1:
            x=b.pop(i)
            f=0
            ans.append(x)
            break
    if f:
        print(-1)
        exit()
print(*list(reversed(ans)))


Measured memory_bytes: 38544
A, B, N = map(int, input().split())
Ans = []
X = B * (N // B)
if X != 0:
    ans_1 = (A * (X - 1) // B) - A * ((X - 1) // B)
else:
    ans_1 = 0
ans_2 = (A * N // B) - A * (N // B)
Ans.append(ans_1)
Ans.append(ans_2)

print(max(Ans))

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n; cin>>n;
    vi M(n+1);
    rep(i, n){
        int p; cin>>p;
        M[p] = i;
    }
    multiset<int> D;
    D.ins(-1); D.ins(-1);
    D.ins(n);  D.ins(n);

    ll ans=0;
    for(int i=n; i>=1; i--){
        auto itr = D.lower_bound(M[i]); itr++;
        int r2 = *itr; itr--;
        int r1 = *itr; itr--;
        int l1 = *itr; itr--;
        int l2 = *itr;

        int Right = (M[i]-l1)*(r2-r1);
        int Left = (l1-l2)*(r1-M[i]);
        ans += (ll)(Right+Left)*i;
        //cout << Right+Left << endl;
        D.ins(M[i]);
    }
    cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 5376
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){

	int n;
	cin>>n;
    int k;
    cin>>k;
    int a,b;
    for(int i=0;i<k;i++){
        cin>>a>>b;
        a=min(a,n-a+1);
        //cout<<a<<"-";
        b=min(b,n-b+1);
        //cout<<b<<"-";
        a=min(a,b);
        //cout<<a<<"-"<<endl;
        switch(a%3){
            case 0:cout<<3<<endl;break;
            case 1:cout<<1<<endl;break;
            case 2:cout<<2<<endl;break;

        };

    }

	return 0;
}

Measured memory_bytes: 1160
#include <unordered_set>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <cstring>
#include <cassert>
#include <fstream>
#include <climits>
#include <cstdio>
#include <vector>
#include <string>
#include <memory>
#include <queue>
#include <cmath>
#include <list>
#include <set>
#include <map>


using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;

const int maxn=2e5+10;
int main()
{
  int n;
  ll a[maxn];
  scanf("%d",&n);
  ll sum=0;
  for(int i=0;i<n;sum+=a[i],i++)
    scanf("%lld",&a[i]);
  ll res=0;
  ll now=0;
  for(int i=0;i<n-1;i++)
  {
    now+=a[i];
    if(i==0) res=abs(sum-now-now);
    else res=min(abs(sum-now-now),res);
  }
  cout<<res<<endl;
  return 0;
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct Edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n; ll w;
    cin >> n >> w;
    vector<ll> a(n+1);
    rep(n) cin >> a[i+1];
    sort(all(a));

    if(w < a[0]){
        cout << 0 << endl;
        return 0;
    }

    vector<ll> sum(n+1, 0);
    rep(n) sum[i+1] = sum[i] + a[i+1];

    if(sum[n] <= w){
        cout << 1 << endl;
        return 0;
    }

    ll ans = 0, dp[2][w+1];
    fill(dp[0], dp[2], 0LL);
    dp[1-(n&1)][0] = 1;
    for(int i=n;i>=1;i--){
        for(int j=w-sum[i-1];j>=max(0LL, w-sum[i-1]-a[i]+1);j--) (ans += dp[1-(i&1)][j]) %= MOD;
        repp(j, w+1) dp[i&1][j] = dp[1-(i&1)][j];
        repp(j, w-a[i]+1) (dp[i&1][j+a[i]] += dp[1-(i&1)][j]) %= MOD;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3352
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
 int dp[1001][1001];
int main(){
    int cnt=0;
    int N,W;
    int w[1000],v[1000];
    while(cin>>W,W){
        cnt++;
        cin>>N;
        fill(dp[0],dp[0]+1001*1001,-1);
        dp[0][0]=0;
        for(int i=0;i<N;i++)(cin>>v[i]).ignore()>>w[i];
        for(int i=0;i<N;i++){
            for(int j=0;j<=W;j++){
                int res;
                if(j-w[i]<0)res=dp[i][j];
                else if(dp[i][j-w[i]]==-1)res=dp[i][j];
                else res=max(dp[i][j],dp[i][j-w[i]]+v[i]);
                dp[i+1][j]=res;
            }
        }
        for(int i=W;i>=0;i--){
            if(dp[N][i]!=-1&&dp[N][i]>dp[N][i-1]){
                cout<<"Case "<<cnt<<":"<<endl;
                cout<<dp[N][i]<<endl<<i<<endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 5084
import java.util.*;

/**
 * AOJ #2399 Save Your Privacy!
 */
class Main {
    public static void main(String[] arg) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            int n = scanner.nextInt();
            if (n == 0) { break; }
            List<Set<Integer>> list = new ArrayList<Set<Integer>>(n);
            for (int i = 0; i < n; i++) {
                list.add(readOneSet(scanner));
            }
            Set<Integer> leaked = readOneSet(scanner);
            System.out.println(findLeaker(list, leaked));
        }
    }

    static int findLeaker(List<Set<Integer>> list, Set<Integer> leaked) {
        int leaker = -1;
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).containsAll(leaked)) {
                if (leaker != -1) { return -1; }
                leaker = i + 1;  // member id is between 1 and n
            }
        }
        return leaker;
    }

    static Set<Integer> readOneSet(Scanner scanner) {
        Set<Integer> set = new TreeSet<Integer>();
        int m = scanner.nextInt();
        for (int i = 0; i < m; i++) {
            set.add(scanner.nextInt());
        }
        return set;
    }
}

Measured memory_bytes: 16000
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
	int m, d;
	for (; cin >> m >> d;)
	{
		if (m == 0 && d == 0)
		{
			break;
		}

		vector<int> mon = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

		int mm = 0;
		for (int i = 0; i < m; i++)
		{
			mm += mon.at(i);
		}
		int y = (3 + mm + d) % 7;

		vector<string> sy = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

		cout << sy.at(y) << endl;
	}
}



Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=0;cin>>n;
  for(ll i=1;i<=n;++i) {
    if(1<=i&&i<10) ans++;
    if(100<=i&&i<1000) ans++;
    if(10000<=i&&i<100000) ans++;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,c=parseMap(split(readline()))
    if a==b==c && a%2==b%2==c%2==0
        println(-1)
    else
        ans=0
        while a%2==b%2==c%2==0
            d,e,f = a,b,c
            a = e÷2 + f÷2
            b = d÷2 + f÷2
            c = d÷2 + e÷2
            ans+=1
        end
        println(ans)
    end
end
main()

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

int n, m;
int s[100002], t[50002];

int main(){
  cin >> n;
  for(int i = 0; i < n; i++) cin >> s[i];
  cin >> m;
  for(int i = 0; i < m; i++) cin >> t[i];

  sort(s, s + n);

  int c = 0;

  for(int i = 0; i < m; i++){
    if(binary_search(s, s + n, t[i])){
      c++;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 1760
a,b,c = map(int, input().split())
k = int(input())
for n in range(k):
    if max(a,b,c)==a:
        a*=2
    elif max(a,b,c)==b:
        b*=2
    elif max(a,b,c)==c:
        c*=2
print(a+b+c)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	long long n, a; cin >> n;
	long long mini = 1e16;
	for (int i = 0; i < 5; ++i) {
		cin >> a;
		mini = min(mini, a);
	}
	cout << (n - 1) / mini + 5 << endl;

	return 0;
}

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

int num_digit(int n)
{
    int count = 0;
    while(n)
    {
        count++;
        n /= 10;
    }
    return count;
}

int main()
{
    int num1,num2;
    cin>>num1>>num2;  // 1 21
    int l1 = num_digit(num1); //1
    int l2 = num_digit(num2); //2
    int temp = num1*pow(10,l2); //
    //cout<<temp<<endl;
    temp += num2;
    //cout<<temp<<endl;
    int flag = sqrt(temp);
    flag *= flag;
    if(flag == temp)
        cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

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

using namespace std;

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  for (int i = l; i <= r; i++) {
    ans += (i % d == 0);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3608
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string text=Console.ReadLine();
    char[] chararray = text.ToCharArray();
      Array.Sort(chararray);
      char[] dis=chararray.Distinct().ToArray();
      if(dis.Length==26){
        Console.WriteLine("None");
      }else{
        for(char c='a';c<='z';c++){
          if(text.IndexOf(c)==-1){
            Console.WriteLine(c);
            break;
        }
        }  
      }
    }
    
  }

}

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

int main(){
  
  string s;
  cin >> s;
  
  int sum = 0;
  
  for(int i = 0; i < 4; i++){
    if(s.at(i) == '+'){
      sum++;
    }else if(s.at(i) == '-'){
      sum--;
    }
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 256