akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
 
public class Main {
	     
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int cnt = 0;
		int[][] a = new int[11175][2];
		for(int i=1;i<=150;i++){
			for(int j=i+1;j<=150;j++){
				a[cnt][0] = i;
				a[cnt][1] = j;
				cnt++;
			}
		}
		
		Arrays.sort(a, new Comparator<int[]>(){
			public int compare(int[] o1, int[] o2) {
				int p = o1[0]*o1[0]+o1[1]*o1[1];
				int q = o2[0]*o2[0]+o2[1]*o2[1];
				if(p==q) return o1[0]-o2[0];
				return p-q;
			}
		});
		
		while(true){
			int h = sc.nextInt();
			int w = sc.nextInt();
			if(h==0 && w==0) break;
			
			for(int i=0;i<11175;i++){
				if(a[i][0]==h && a[i][1]==w){
					System.out.println(a[i+1][0] + " " + a[i+1][1]);
					break;
				}
			}
		}
    }   
}

Measured memory_bytes: 30664
#include <iostream>

using namespace std;

int main()
{
  int n, k[102], v[101][102] = {0}, i, j, l, a;

  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a;
    cin >> k[i];
    for (j = 0; j < k[i]; j++) {
      cin >> v[i][j + 1];
    }
  }

  for (i = 0; i < n; i++) {
    for (j = 0; j < n + 1; j++) {
      if (k[i] == 0) {
        for (l = v[i][j - 1]; l < n - 1; l++) {
          cout << "0 ";
        }
        cout << "0\n";
        break;
      }
      else {
        if (v[i][j] != 0) {
          k[i]--;
          for (l = v[i][j - 1]; l < v[i][j] - 1; l++) {
            cout << "0 ";
          }
          if (v[i][j] == n) {
            cout << "1\n";
            break;
          }
          else {
            cout << "1 ";
          }
        }
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> ii;

const int N = 3e5+100;

string ss[N];

string extend(string s){
	string t = s;
	reverse(t.begin(), t.end());
	s.insert(s.end(), t.begin(), t.end());
	return s;
}

signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n, k;cin >> n >> k;
	string s;cin >> s;
	char c = *min_element(s.begin(), s.end());
	if(k>14){
		for(int i=0 ; i<n ; i++)
			cout << c;
		cout << "\n";
		return 0;
	}
	if(k == 1){
		s = extend(s);
		for(int i=0 ; i<=n ; i++)
			ss[i] = s.substr(i, n);
		sort(ss, ss+n+1);
		cout << ss[0] << "\n";
		return 0;
	}
	k --;
	s = extend(s);
	for(int i=0 ; i<=n ; i++){
		ss[i] = s.substr(i, n);
		reverse(ss[i].begin(), ss[i].end());
	}
	sort(ss, ss+n+1);
	s = ss[0];
	reverse(s.begin(), s.end());
	int cnt=0;
	for(int i=s.size()-1 ; i>=0 ; i--)
		if(s[i] == s.back())
			cnt ++;
		else
			break;
	while(k){
		for(int i=0 ; i<cnt ; i++)
			s.push_back(s.back());
		if(cnt>n)
			break;
		k --;
		cnt *= 2;
	}
	s = s.substr(s.size()-n, n);
	reverse(s.begin(), s.end());
	cout << s << "\n";
 	return 0;
}
















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

int main() {

	long long  x[10000];
	int i;
	i = 0;

	do {i++;
		cin >> x[i];
		if(x[i]!=0)
		cout << "Case " << i << ": " << x[i] << endl;
		
	} while (x[i] != 0);

}

Measured memory_bytes: 3144
#![allow(unused)]

use std::io::{Read, Stdin, StdinLock};
use std::iter::{FromIterator, Iterator};
use std::str::{FromStr};
use std::string::String;

macro_rules! debug {
    ($($a:expr),*) => {
	eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

struct TokenReader<'a> {
    lock: StdinLock<'a>,
}

impl<'a> TokenReader<'a> {
    fn new(s: &'a Stdin) -> TokenReader<'a> {
        TokenReader { lock: s.lock() }
    }

    fn read_chars<T: FromIterator<char>>(&mut self) -> T {
        self.lock
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<T>()
    }

    fn read_str(&mut self) -> String {
        self.read_chars::<String>()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read_str().parse().ok().unwrap()
    }
}

//==============================================================================
//
// Problem specific code
//
//==============================================================================

fn iceil(n: i64, d: i64) -> i64 {
    n / d + (if n % d == 0 { 0 }  else { 1 })
}

fn main() {
    let sin = std::io::stdin();
    let mut tr = TokenReader::new(&sin);

    let a: i64 = tr.read();
    let b: i64 = tr.read();
    let c: i64 = tr.read();
    let d: i64 = tr.read();

    println!("{}", if iceil(c, b) <= iceil(a, d) { "Yes" } else { "No" });
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  long long N;
  cin >> N;
  string ans;
  do
  {
    N--;
    int mod = N % 26;
    char c = 'a' + mod;
    ans += c;
    N = N - mod;
    N /= 26;
  } while (N != 0);
  REVERSE(ans);
  cout << ans << endl;
  return 0;
}

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

int main() {
int n,r=0,c=0;
cin>>n;
string s;
cin>>s;
for(int i=0;i<n;i++){
    if(s[i]=='R'){
        r++;
    }
}
for(int j=0;j<r;j++){
     if(s[j]=='R'){
         c++;
     }
}
cout<<r-c;

	return 0;
}

Measured memory_bytes: 3708
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;
	using BigNum = std::vector<long long>;

	class InputData {
	public:
		void getInput(void);
		void skipInput(void);
		Str getStr(void);
		Num getNum(void);
		BigNum getBigNum(void);
	private:
		Str str;
		Num num;
		BigNum bNum;
	};
	Str AtCoder::InputData::getStr(void) {
		return this->str;
	}
	Num AtCoder::InputData::getNum(void) {
		return this->num;
	}
	BigNum AtCoder::InputData::getBigNum(void) {
		return this->bNum;
	}
	void AtCoder::InputData::skipInput(void) {
		std::string buf = "";
		std::getline(std::cin, buf);
	}
	void AtCoder::InputData::getInput(void) {
		this->str.clear();
		this->num.clear();
		this->bNum.clear();

		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				this->str.push_back(row);
				this->num.push_back(std::atoi(row.c_str()));
				this->bNum.push_back(std::atoll(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		this->str.push_back(row);
		this->num.push_back(std::atoi(row.c_str()));
		this->bNum.push_back(std::atoll(row.c_str()));
	}

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(long long);
		void decrement(void);
		void decrement(long long);
		long long getResult(void);
	private:
		long long result;
	};
	void Ans::showResult(void) {
		printf("%lld\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(long long value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(long long value) {
		this->result -= value;
	}
	long long AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::InputData* data = new AtCoder::InputData();
	data->getInput();

	AtCoder::BigNum big = data->getBigNum();

	const long long int N = 0 == big[0] ? big[1] : big[0];
	const long long int K = big[1];

	AtCoder::Ans* ans = new AtCoder::Ans();

	{
		const long long int buf = N % K;
		if (0 == buf) {
			ans->showResult();
			delete(ans);
			delete(data);
			return 0;
		} else {
			const long long int bufans = std::abs(buf - K);
			if (buf < bufans) {
				ans->increment(buf);
			} else {
				ans->increment(bufans);
			}
		}
	}

	ans->showResult();

	delete(ans);
	delete(data);

	return 0;
}


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

using namespace std;

int ans, N, M, a[2017][2017], h[2017], lft[2017], rgt[2017];
char sir[2017][2017];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d\n", &N, &M), ans = max (N, M);
for (int i=1; i<=N; i++)
    scanf ("%s", sir[i] + 1);
for (int i=1; i<N; i++)
    for (int j=1; j<M; j++)
        a[i][j] = ((sir[i][j] == sir[i + 1][j + 1]) == (sir[i + 1][j] == sir[i][j + 1]));
N --, M --;
/*for (int i=1; i<=N; i++, printf ("\n"))
    for (int j=1; j<=M; j++)
        printf ("%d", a[i][j]);*/
for (int i=1; i<=N; i++)
{
    for (int j=1; j<=M; j++)
        if (a[i][j]) h[j] ++;
        else h[j] = 0;
    if (i == N)
        i = N;
    int nr = 0, st[2017];
    st[0] = 0;
    for (int j=1; j<=M; j++)
    {
        while (nr > 0 && h[st[nr]] >= h[j]) nr --;
        lft[j] = st[nr] + 1;
        st[++nr] = j;
    }
    nr = 0, st[0] = M + 1;
    for (int j=M; j>=1; j--)
    {
        while (nr > 0 && h[st[nr]] >= h[j]) nr --;
        rgt[j] = st[nr] - 1;
        st[++nr] = j;
    }
    for (int j=1; j<=M; j++)
        if ((rgt[j] - lft[j] + 2) * (h[j] + 1) > ans && h[j] >= 1)
            ans = (rgt[j] - lft[j] + 2) * (h[j] + 1);//, printf ("%d (%d, %d) [%d, %d] -> %d\n", i, j, h[j], lft[j], rgt[j], ans);
}
printf ("%d\n", ans);
return 0;
}


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

using namespace std;

int main()
{
  int n, m;
  string s1, s2;

  while(1){
    cin >> n;
    if(n == -1){
      break;
    }

    s1 = "0000000";
    while(n--){
      cin >> m;
      if(m == 0){
	s2 = "0111111";
      } else if(m == 1){
	s2 = "0000110";
      } else if(m == 2){
	s2 = "1011011";
      } else if(m == 3){
	s2 = "1001111";
      } else if(m == 4){
	s2 = "1100110";
      } else if(m == 5){
	s2 = "1101101";
      } else if(m == 6){
	s2 = "1111101";
      } else if(m == 7){
	s2 = "0100111";
      } else if(m == 8){
	s2 = "1111111";
      } else {
	s2 = "1101111";
      }
      for(int i = 0; i < 7; i++){
	if(s1[i] == s2[i]){
	  cout << 0;
	} else {
	  cout << 1;
	}
      }
      cout << endl;
      s1 = s2;
    }

  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const int MOD = 1000000007; 

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    rng(i, 1, b+1) {
        if (a * i % b == c) {
            cout << "YES" << endl;
            return 0;
        } 

    } 
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    if n==1:
        print(0)
        return
    k = int(n**0.5)+1
    ans = 0
    for i in range(2,k+1):
        if n%i==0:
            m = 0
            cnt = 0
            while n%i==0:
                cnt +=1
                n = int(n/i)
                if cnt>m:
                    ans += 1
                    cnt = 0
                    m +=1
                if n==1:
                    break
    if n==1:
        print(ans)
    else:
        print(ans+1)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 9444
//
// Created by albicilla on 2018/12/03.
//


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

long long N;
long long ans;


void dfs(long long num,bool flag0,bool flag1,bool flag2){
    cerr<<num<<endl;
    if(num<=N && flag0 &&flag1 &&flag2)ans++;

    if(num>N)return;

    dfs(num*10+3,true,flag1,flag2);
    dfs(num*10+5,flag0,true,flag2);
    dfs(num*10+7,flag0,flag1,true);

}

int main(){
    cin>>N;


    dfs(3,true,false,false);
    dfs(5,false,true,false);
    dfs(7,false,false,true);

    cout<<ans<<endl;



}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<double> v(n);
  for(int i = 0; i < n; i++)
    cin >> v[i];
  sort(v.begin(), v.end());
  for(int i = 0; i < n-1; i++)
    v[i+1] = (v[i]+v[i+1])/2;
  cout << v[n-1] << endl;  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a) (a).begin(),(a).end()

struct res{
    int x, y , z, w;
};

int main(){
    int h, w;
    cin >> h >> w;

    int a[h][w];
    rep(i, h)rep(j, w)cin >> a[i][j];

    vector<res> ans;
    rep(i, h)rep(j, w){
        if(a[i][j] % 2 == 0)continue;
        if(i+1 < h && j+1 < w){
            if(a[i][j+1] % 2 != 0 || a[i+1][j] % 2 == 0){
                a[i][j+1]++;
                a[i][j]--;
                res back;
                back.x = i+1;
                back.y = j+1;
                back.z = i+1;
                back.w = j+2;
                ans.push_back(back);
            }
            else {
                a[i+1][j]++;
                a[i][j]--;
                res back;
                back.x = i+1;
                back.y = j+1;
                back.z = i+2;
                back.w = j+1;
                ans.push_back(back);
            }
        }
        else if(j+1 < w){
            a[i][j+1]++;
            a[i][j]--;
            res back;
            back.x = i+1;
            back.y = j+1;
            back.z = i+1;
            back.w = j+2;
            ans.push_back(back);
        }
        else if(i+1 < h){
            a[i+1][j]++;
            a[i][j]--;
            res back;
            back.x = i+1;
            back.y = j+1;
            back.z = i+2;
            back.w = j+1;
            ans.push_back(back);
        }
    }

    cout << ans.size() << endl;
    rep(i, ans.size())cout << ans[i].x << " " << ans[i].y << " " << ans[i].z << " " << ans[i].w << endl;
}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef long double ld;
typedef string st;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;
ll mpow(ll a,ll b,ll p=MOD){a=a%p;ll res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const ll N=200005;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 
  ll n,a,b;
  cin>>n>>a>>b;
  ll an[n];
  ll w[3]={0};
  forn(i,n)
  {
    cin>>an[i];
    if(an[i]<=a)
    {
      w[0]++;
    }
    else if(an[i]>=a+1&&an[i]<=b)
    {
      w[1]++;
    }
    else w[2]++;
  }
  cout<<min({w[0],w[1],w[2]});
} 
// Never give up, and be confident in what you do. There may be tough times, but the difficulties which you face will make you more determined to achieve your objectives and to win against all the odds
// O Krishna, the mind is restless

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
 
  vector<vector<int>> d(N,vector<int>(2));
  
  for(int i=0;i<N;i++){
    cin >> d.at(i).at(0) >> d.at(i).at(1);
  }
  
  bool yn=false;
  
  for(int i=0;i<N-2;i++){
    int ct=0;
    
    for(int j=i;j<i+3;j++){
      if(d.at(j).at(0)==d.at(j).at(1))ct++;
    }
    
    if(ct==3){
      yn=true;
      break;
    }
  }
  
  if(yn==true){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
      

Measured memory_bytes: 3628
#include <stdio.h>

int main(void){
  char s[101],p[101];
  int i,j,sn=0,pn=0,t;

  scanf("%s %s",s,p);

  while(s[sn] != '\0') sn++;
  while(p[pn] != '\0') pn++;

  for(i=0;i<sn;i++){
    t=1;
    for(j=0;j<pn;j++)
      if(s[(i+j)%sn] != p[j]) t=0;
    if(t) break;
  }
  if( t )
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}
  
      



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 2e5+10;
using namespace std;

int N;
ll h[maxn],w[maxn],tr[maxn],f[maxn];

int lowbit(int x){
    return x&-x;
}
void add(int x,ll v){
    for(int i = x;i<=N;i += lowbit(i)) tr[i] = max(tr[i],v);
}
ll query(int r){
    ll res = 0;
    for(int i = r;i>=1;i -= lowbit(i)) res = max(res,tr[i]);
    return res;
}

ll solve(){
    for(int i = 1;i<=N;i++){
        f[i] = query(h[i]-1) + w[i];
        add(h[i],f[i]);
    }
    ll mx = 0;
    for(int i = 1;i<=N;i++) mx = max(mx,f[i]);
    return mx;
}
int main(){
    // debug;
    ios;

    cin>>N;
    for(int i = 1;i<=N;i++) cin>>h[i];
    for(int i = 1;i<=N;i++) cin>>w[i];
    cout<<solve()<<'\n';
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

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

ll fac(ll n){
    if (n > 0) {
        return  n * fac(n - 1);
    }else{
        return 1;
    }
}

int main()
{
    ll n,ans = 0,c = 0;
    cin >> n;
    vector<ll> h(n);
    rep(i, n)cin >> h[i];
    rep(i, n){
        if (h[i] > c)ans += h[i] - c;
        c = h[i];
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    int ans;
    for(int i=0;i<s.size();i++){
        if(s[s.size()-i-1]=='F'){
        ans=i;
        break;
        }
    }
    for(int i=0;i<s.size()-ans-1;i++)cout << s[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if X - (a*500 + b*100 + c*50) == 0:
                count = count + 1
print(count)


Measured memory_bytes: 3060
n,m = map(int,input().split())
l = [-1] * n
for i in range(m):
  s,c = map(int,input().split())
  if n != 1 and [s,c] == [1,0]:
    print(-1)
    exit()
  if l[s-1] == -1 or l[s-1] == c:
    l[s-1] = c
  else:
    print(-1)
    exit()
if l[0] == -1 and n != 1:
  l[0] = 1
elif l[0] == -1:
  l[0] = 0
print(*[i if i != -1 else 0 for i in l],sep='')

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

class Program
{
    static int Solve(List<int> p)
    {
        if (p.Count == 1)
            return p[0];
        else
        {
            int m = int.MaxValue;
            for (int i = 0; i < p.Count; i++)
            {
                List<int> f = new List<int>();
                for (int j = 0; j < p.Count; j++)
                {
                    if (i != j)
                        f.Add(p[j]);
                }
                if(p[i] %10 ==0 )
                    m = Math.Min(m, Solve(f) + p[i]);
                else
                    m = Math.Min(m, Solve(f) + (p[i] / 10 + 1) * 10);
            }
            return m;
        }
    }
    public static void Main()
    {
        List<int> p = new List<int>();
        p.Add(int.Parse(Console.ReadLine()));
        p.Add(int.Parse(Console.ReadLine()));
        p.Add(int.Parse(Console.ReadLine()));
        p.Add(int.Parse(Console.ReadLine()));
        p.Add(int.Parse(Console.ReadLine()));
        Console.WriteLine(Solve(p));
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    string s;
    cin >> s;
    vector<bool> ans(10000, true);
    int l = s.size();
    rep(i, l) {
        if(ans[s[i]] == true) ans[s[i]] = false;
    }
    for(char i = 'a'; i <= 'z'; i++) {
        if(ans[i] == true) {
            cout << i << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    
    return 0;
}

Measured memory_bytes: 512
//
// Created by rajshah9914 on 28/03/20.
//

#include <bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long l;
    cin>>l;
    unsigned long long ans=0;
    ans+=1000*(l/500);
    l=l%500;
    ans+=5*(l/5);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	set<int> side; side.clear();
	rep (i, 3){
		int in; cin >> in;
		side.insert(in);
	} // end rep

	cout << ((int)side.size() == 1 ? "Yes" : "No") << endl;

	return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

bool gen_next_A(vector<int>& A, int max) {
  int N = A.size();
  for (int i = N - 1; i >= 0; --i) {
    if (A[i] < max) {
      int n = ++A[i];
      for (int j = i + 1; j < N; ++j) {
        A[j] = n;
      }
      return true;
    }
  }

  return false;
}

int calc_score(const vector<int>& A, const vector<int>& a, const vector<int>& b,
               const vector<int>& c, const vector<int>& d) {
  int score = 0;
  
  for (size_t i = 0; i < a.size(); ++i) {
    if (A[b[i]-1] - A[a[i]-1] == c[i]) {
      score += d[i];
    }
  }

  return score;
}



int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, M, Q;
  cin >> N >> M >> Q;

  vector<int> a(Q), b(Q), c(Q), d(Q);
  for (int i = 0; i < Q; ++i) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }

  // main procedure
  vector<int> A = vector<int>(N, 1);

  int max_score = 0;
  
  // int count = 0;
  
  while (true) {
    int score = calc_score(A, a, b, c, d);
    max_score = max(max_score, score);

    // for (auto x : A) {
    //   WRITE(x);
    //   WRITE(", ");
    // }
    // WRITE(": ");
    // WRITE_N(score);
    // if (++count > 20) break;

    bool is_next_A_exist = gen_next_A(A, M);
    if (is_next_A_exist == false) {
      break;
    }
  }

  // output
  WRITE_N(max_score);

  return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(void) {
    int K;
    cin >> K;

    queue<ll> q;
    for (int i = 1; i <= 9; i++) {
        q.push(i);
    }

    int cur_no = 0;

    while (!q.empty()) {
        ll cur = q.front();
        q.pop();
        cur_no++;
        if (cur_no == K) {
            cout << cur << endl;
            break;
        }

        int d = cur % 10;
        if (d != 0) {
            q.push(cur * 10 + (d - 1));
        }
        q.push(cur * 10 + d);
        if (d != 9) {
            q.push(cur * 10 + (d + 1));
        }
    }

    return 0;
}


Measured memory_bytes: 5124
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	set<int>in;
	rep(i,2){
		int n;
		cin>>n;
		rep(j,n){
			int a,b;
			cin>>a>>b;
			in.insert(a*60+b);
		}
	}
	for(set<int,int>::iterator it=in.begin();it!=in.end();it++){
		if(it!=in.begin())cout<<" ";
		int d=*it;
		printf("%d:%02d",d/60,d%60);
	}
	cout<<endl;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

template<typename T> bool chmin(T &a,const T b){if(a>b){a=b; return true;}return false;}
template<typename T> bool chmax(T &a,const T b){if(a<b){a=b; return true;}return false;}


int main(){
    int N; cin >> N;
    int tmp=N;
    int cnt=0;
    while(tmp > 0){
        cnt++;
        tmp/=10;
    }
    int ans=0;
    for(int i=1; i<=cnt; i++){
        if(i%2 == 1){
            if(i == cnt) ans+=N-pow(10, i-1)+1;
            else ans+=pow(10, i)-pow(10, i-1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4040
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<int>())
using namespace std;
int main()
{
  speed_up;
  string a[4] = {"dream", "dreamer", "erase", "eraser"};
  int b[4] = {};
  int n, i, j, ans;
  string s, s1;
  cin>>s;
  reverse(s.begin(), s.end());
  for(i = 0; i<4; i++)
  {
      reverse(a[i].begin(), a[i].end());
      //cout<<a[i]<<endl;
  }
  //cout<<s<<endl;
  s1 = {};
  n  = s.size();
  for(i = 0; i<n; i++)
  {
      s1+= s[i];
      //cout<<s1<<endl;
      for(j = 0; j<4; j++)
      {
          if(s1 == a[j])
          {
              b[j]++;
              s1 = "";
              //cout<<a[i]<<endl;
          }
      }


  }
  ans = 0;
   for(i = 0; i<4; i++)
   {
       ans += b[i]*(a[i].size());
       //cout<<b[i]<<endl;
   }
  //cout<<ans<<endl;
  n = s.size();
  if(n == ans) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int n,m,t;
    cin >> n >> m >> t;
    int a;
    vector<int> tim(t,1);
    REP(i,n){
        cin >> a;
        a--;
        for(int j=a-m+1;j<=a+m&&j<t;j++){
            tim[j]=0;
        }
    }
    int sum=0;
    REP(i,t){
        sum+=tim[i];
    }
    cout << sum << endl;
}



Measured memory_bytes: 3144
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq


def dfs(s, prev, pre):
  val[s] += Ope[s] + prev
  for i in G[s]:
    if(i == pre):
      continue
    dfs(i, val[s], s)

def bfs(sx, sy, n):
  que = deque([[sy,sx]])
  while que:
    y,x = que.popleft()
    for i,j in D:
      if(x+i<0 or y+j<0 or x+i>W-1 or y+j>H-1):
        continue
      dist = G[y+j][x+i]
      if(G[y+j][x+i] != "X"):
        if(type(G[y+j][x+i]) is str):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        elif(dist>G[y][x]+1):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        

def combinations_count(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]



N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
AA = [0]*N
BB = [0]*N
ans = 0

A.sort()
B.sort()
C.sort()


for i in range(N):
  AA[i] = bisect.bisect_right(A, B[i]-1)

for j in range(N):
  BB[j] = bisect.bisect_left(C, B[j]+1)

for k in range(N):
  ans += AA[k]*(N-BB[k])

print(ans)


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

int main() {
        int a, b;
        scanf("%d%d", &a, &b);
        string s;
        cin >> s;
        if (s.size() != a + b + 1) return !printf("No");
        for (int i = 0; i < a; i ++) {
                if (!isdigit(s[i])) return !printf("No");
        }
        if (s[a] != '-') return !printf("No");
        for (int i = a + 1; i < a + 1 + b; i ++) {
                if (!isdigit(s[i])) return !printf("No");
        }
        printf("Yes");
        return 0;
}



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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N; cin >> N;
    set<int> s;
    REP(i,N){
        int a; cin >> a;
        s.insert(a);
    }

    cout << (s.size() == N ? "YES" : "NO") << endl;
    return 0;
}

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

int main(){
		int N,M;
		cin >> N >> M;
		vector<ll> s(N),t(M);
		for(int i=0;i<N;i++)
				cin >> s[i];
		for(int i=0;i<M;i++)
				cin >> t[i];

		vector<vector<ll> > dp(N+1,vector<ll>(M+1, 0));
		vector<vector<ll> > sum(N+1,vector<ll>(M+1, 0));

		for(int i=1;i<=N;i++){
				for(int j=1;j<=M;j++){
						if(s[i-1]==t[j-1]){
								dp[i][j] = (sum[i-1][j-1]+1);
						}else{
								dp[i][j] = 0;
						}
						sum[i][j] = sum[i][j-1] + sum[i-1][j] - sum[i-1][j-1] + dp[i][j] + MOD;
						sum[i][j] %= MOD;
				}
		}
		cout << sum[N][M] + 1 << endl;
}

Measured memory_bytes: 62976
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// 2???????????????????????????????±???????
double dot(P a, P b) {
    return (a.X * b.X + a.Y * b.Y);
}

// 2???????????????????????????????±???????
double cross(P a, P b) {
    return (a.X * b.Y - a.Y * b.X);
}

int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if( cross(b,c) > EPS ) return +1;
    if( cross(b,c) < -EPS ) return -1;
    if( dot(b,c) < 0 ) return +2;
    if( norm(b) < norm(c) ) return -2;
    return 0;
}

// ???????§???¢????????¨?????? O(n)
int inPolygon(P p, const vector<P> &ps) {
    int n = ps.size();
    bool in = false;
    rep(i,0,n) {
        P a = ps[i] - p;
        P b = ps[(i+1) % n] - p;
        if(EQ(cross(a,b), 0) && LE(dot(a,b), 0)) return 2;
        if(a.Y > b.Y) swap(a,b);
        if((a.Y * b.Y < 0 || (a.Y * b.Y < EPS && b.Y > EPS)) && LE(cross(a,b), 0)) in = !in;
    }
    return in;
}

int main() {
    int n; cin >> n;
    vector<P> ps;
    P a;
    rep(i,0,n) {
        cin >> a.X >> a.Y;
        ps.pb(a);
    }

    map<int, int> d;
    d[2] = 1;
    d[1] = 2;

    int m; P b;
    cin >> m;
    rep(i,0,m) {
        cin >> b.X >> b.Y;
        cout << d[inPolygon(b, ps)] << endl;
    }
    return 0;
}

Measured memory_bytes: 1240
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder output = new StringBuilder();

        String input = br.readLine();
        int n = Integer.parseInt(input);
        input = br.readLine();
        String[] strArray = input.split(" ");

        for(int i = n; i >= 1; i--){

            int x = Integer.parseInt(strArray[i-1]);
            output.append(x);

            if(i == 1){
                break;
            }
            output.append(" ");
        }
        output.append("\n");
        System.out.print(output);
    }
}

Measured memory_bytes: 24388
#include<iostream>
using namespace  std;
main(){
  string s,t;
  cin>>s>>t;
  int r=0;
  for(int i=0;i<3;i++){
    if(s[i] == t[i]){
      r= r+1;
    }
  }
  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = b = c = d = e = 0
for _ in range(n):
    s = input()
    if s[0] == 'M':
        a += 1
    elif s[0] == 'A':
        b += 1
    elif s[0] == 'R':
        c += 1
    elif s[0] == 'C':
        d += 1
    elif s[0] == 'H':
        e += 1
print(a * b * c + a * b * d + a * b * e + a * c * d + a * c * e + a * d * e +
      b * c * d + b * c * e + b * d * e + c * d * e)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n);
#define DEBUG printf("%s\n","debug")
using namespace std;
//////////////////////////////////////////////////////
long long intpow(int x,int y){
	if (y == 0) return 0;
	long long xx = x;
	long long xin = x;
	REP(i,y-1){
		xx = xx * xin;
	}
	return xx;
}


int main(){
	int N,P; SCD2(N,P);
	int A[N];
	int E = 0;
	int O = 0;
	
	REP(i,N){
		SCD(A[i]);
		if (A[i] % 2 == 0){
			E++;
		}else{
			O++;
		}
	}
	
	if (O==0){
		if (P==0){
			printf("%lld\n",(intpow(2,N)));
			return 0;
		}else{
			PRINTD(0);
			return 0;
		}
	}
	
	printf("%lld\n",(intpow(2,N-1)));
	return 0;
}








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

map<string, vector<string>> tb;
map<string, int> cost;
map<string, bool> done;
int N, M;

int search(string s)
{
  int ans = cost[s];
  done[s] = true;
  for(int i = 0; i < tb[s].size(); i++)
    if(done.find(tb[s][i]) == done.end())
      ans = min(ans, search(tb[s][i]));
  return ans;
}

int main()
{
  cin >> N;
  for(int i = 0; i < N; i++)
  {
    string a;
    int x;
    cin >> a >> x;
    cost[a] = x;
  }
  cin >> M;
  for(int i = 0; i < M; i++)
  {
    string s1, s2;
    cin >> s1 >> s2;
    tb[s1].push_back(s2);
    tb[s2].push_back(s1);
  }
  int ans = 0;
  for(auto it = cost.begin(); it != cost.end(); ++it)
  {
    done.clear();
    ans += search(it->first);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2312
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=j;i<(int)(n);i++)
int main(){
  int n,count=0;
  cin >> n;
  vector<int> p(n);
  rep(i,0,n) cin >> p[i];
  rep(i,1,n-1){
    if(p[i]<max(p[i-1],p[i+1])&&p[i]>min(p[i-1],p[i+1])) count++;
  }
  cout << count << endl;
}

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

int main() {
	int d;
	cin >> d;
	const int n = 26;
	vector<int> c(n);
	vector<vector<int>> s(d, vector<int>(n));
	rep(i, n) cin >> c[i];
	rep(i, d) rep(j, n) cin >> s[i][j];
	vector<int> t(d), last(n);
	
	// 貪欲
	ll ans = 0;
	rep(i, d) {
		ll mx = -1001001001;
		int now = 0;
		
		rep(j, n) {
			ll tmp = ans;
			tmp += s[i][j];
			rep(k, n) {
				if(j == k) continue;
				tmp -= c[k] * (i+1-last[k]);
			}
			if(mx < tmp) {
				mx = tmp;
				now = j;
			}
		}
		ans = mx;
		last[now] = i+1;
		t[i] = now+1;
	}
	int cnt = 0;
	while(1) {
		// 局所探索法
		cnt++;
		if(cnt > 200000) break;
		vector<int> old = t;
		const int CH = rand()%100 + 1; // CH箇所変える
		rep(i, CH) {
			int nd = rand()%d;
			int nq = rand()%n + 1;
			t[nd] = nq;	
		}
		
		// 点数の再計算
		vector<int> nlast(n);
		ll now = 0;
		rep(i, d) {
			now += s[i][t[i]];
			nlast[t[i]-1] = i+1;
			rep(j, n) {
				now -= c[j] * (i+1-nlast[j-1]);
			}
		}
		
		// 良くなれば更新
		if(now > ans) {
			ans = now;
		} else {
			t = old;
		}
	}
	
	rep(i, d) printf("%d\n", t[i]);
	return 0;
}

Measured memory_bytes: 3772
from collections import deque

n, m = map(int, input().split())
ab = [map(int, input().split()) for _ in range(m)]
links = [[] for _ in range(n + 1)]
for a, b in ab:
  links[a].append(b)
  links[b].append(a)
par = [0]*(n+1)
visited = [0]*(n+1)
root = 1
visited[root] = 1
q = deque([root])
while q:
  v = q.popleft()
  for w in links[v]:
    if visited[w]:
      continue
    visited[w] = 1
    par[w] = v
    q.append(w)
    
print('Yes')
print(*par[2:], sep='\n')

Measured memory_bytes: 107360
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

bool tJudge(string text);
void tShift(string &text);

int main(void) {
	string text;
	while(1) {
		getline(cin, text);
		
		if( cin.eof() )		break;
		while(1) {
			if( tJudge(text) ) {
				cout << text << endl;
				break;
			} else {
				tShift(text);
			}
		}
	}
	
	return 0;
}

bool tJudge(string text) {
	string word[3] = {"the", "this", "that"};
	for(int i = 0; i < 3; i++) {
		if(text.find(word[i], 0) != string::npos) {
			return true;
		}
	}
	return false;
}

void tShift(string &text) {
	for(unsigned int i = 0; i < text.size(); i++) {
		if ( text[i] >= 'a' && text[i] < 'z') {
			text[i]++;
		} else if (text[i] == 'z') {
			text[i] = 'a';
		}
	}
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int k=sc.nextInt(), res=0;
		int[] s=new int[k*2];
		for(int i=0; i<k*2; ++i) s[i]=sc.nextInt();
		Arrays.sort(s);
		for(int i=0; i<k*2; i+=2)  res+=s[i];
		System.out.println(res);
		sc.close(); 
	}

}

Measured memory_bytes: 36168
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>

using namespace std;
typedef long long ll;
int n;
int a[1505][1505];
char ss[1505];
int L[1505][1505],R[1505][1505];
ll f[1505][1505];
ll ans;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%s",&ss[1]);
		for(int j=1;j<=n;j++) {
			a[i][j] = (ss[j]=='#'?0:ss[j]-'0');
		}
	}
	for(int i=n;i>=1;i--) {
		for(int j=n;j>=1;j--) {
			if(a[i][j]) {
				bool mk1 = a[i+1][j] , mk2 = a[i][j+1];
				if( (!mk1) && (!mk2) ) {
					L[i][j] = R[i][j] = j;
					f[i][j] = 0;
					for(int k=i+1;k<=n;k++) L[k][j] = n+1,R[k][j] = 0;
				} else if(!mk1) {
					f[i][j] = f[i][j+1];
					L[i][j] = j; R[i][j] = R[i][j+1];
					for(int k=i+1;k<=n;k++) L[k][j] = L[k][j+1] , R[k][j] = R[k][j+1];
				} else if(!mk2) {
					f[i][j] = f[i+1][j];
					L[i][j] = R[i][j] = j;
				} else {
					int msr = 0;
					int yoo = f[i][j+1] + f[i+1][j];
					L[i][j] = j; R[i][j] = R[i][j+1];
					for(int k=i+1;k<=n;k++) {
						if( (L[k][j+1]>msr) && (L[k][j+1]<=R[k][j])  ) yoo -= f[k][L[k][j+1]];
						msr = max(msr,R[k][j]);
						L[k][j] = min(L[k][j],L[k][j+1]);
						R[k][j] = max(R[k][j],R[k][j+1]);
					}
					f[i][j] = yoo;
				}
				ans += f[i][j] * a[i][j];
				f[i][j] += a[i][j];
			} else L[i][j] = n+1,R[i][j] = 0;
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 22144
/*
      author  : nishi5451
      created : 14.08.2020 15:52:51
*/

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


int main(){
    int x,y,z;
    cin >> x >> y >> z;
    cout << (x-z)/(y+z) << endl;
    return 0;
}

Measured memory_bytes: 3556
mod = 10**9+7

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())

soinsu = {}
for i in range(1,n+1):
    f = factorization(i)
    for r in f:
        if r[0] not in soinsu:
            soinsu[r[0]] = r[1]
        else:
            soinsu[r[0]] += r[1]

ans = 1
for k,v in soinsu.items():
    if k == 1:
        continue
    ans *= (v+1)%mod
    
print(ans%mod)

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

#define int long long

signed main() {
  int q;
  cin >> q;

  int l = 0, r = 0;
  while ( q-- ) {
    int p, n;
    char c;
    scanf("%lld %c %lld", &p, &c, &n);    
    if ( c == ')' ) l += n;
    else r += n;
    if ( l == r ) {
      puts("Yes");
      l = r = 0;
    } else {
      puts("No");
    }
  }
  
  return 0;
}



Measured memory_bytes: 3160
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;


int main(void) {
    string s;
    cin >> s;
    int len = (Int)s.length();
    if (s[len - 1] == '3') {
        cout << "bon" << endl;
    }
    else if ((s[len - 1] == '0') || (s[len - 1] == '1') || (s[len - 1] == '6') || (s[len - 1] == '8')) {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
    return 0;
}


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

int main() {
    int n, m, A[100][100], b[100], c[100];
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> A[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    for (int i = 0; i < n; i++) {
        c[i] = 0;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            c[i] += A[i][j] * b[j];
        }
    }
    for (int i = 0; i < n; i++) {
        cout << c[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int A[100000];
	rep(i, N) A[i] = -1;

	int k = N - 1;

	rep(i, N) {
		int a = getint();
		auto itr = lower_bound(A + k, A + N, a) - 1;
		*itr = a;
		if (itr == A + k) k--;
	}

	co(N - k - 1);

	Would you please return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef pair <int, int> pii;

pii a[5010];
long long dp[5010];

bool cmp(pii a, pii b) {
	return a.fi + a.se < b.fi + b.se;
}

int main () {
	int n; scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &a[i].fi, &a[i].se);
	}
	sort(a, a + n, cmp);
	memset(dp, 0x3f, sizeof(dp));
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j >= 1; j--) {
			if (dp[j - 1] <= a[i].fi) dp[j] = min(dp[j], dp[j - 1] + a[i].se);
		}
	}
	for (int i = n; i >= 0; i--) {
		if (dp[i] <= 5000000000000) {
			printf("%d\n", i);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

int cost[200][200];

constexpr int Inf = 1000000000;

std::vector<int> rs;

int dfs(int current, int used) {
	int ret = Inf;
	for (int i = 0; i < rs.size(); ++i)
		if (((used >> i) & 1) == 0)
			ret = std::min(ret, cost[rs[current]][rs[i]] + dfs(i, used | (1 << i)));

	if (ret != Inf)
		return ret;
	else
		return 0;
}

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

	rs.resize(r);
	for (auto&& e : rs) {
		std::cin >> e;
		--e;
	}

	for (auto&& c : cost)
		for (auto&& e : c)
			e = Inf;

	for (int i = 0; i < m; ++i) {
		int a, b, c;
		std::cin >> a >> b >> c;
		--a, --b;

		cost[a][b] = c;
		cost[b][a] = c;
	}

	for (int k = 0; k < n; ++k)
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				if (cost[i][j] > cost[i][k] + cost[k][j])
					cost[i][j] = cost[i][k] + cost[k][j];

	int ans = Inf;
	for (int i = 0; i < r; ++i)
		ans = std::min(ans, dfs(i, 1 << i));

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

Measured memory_bytes: 384