akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

struct edge {
    ll to, cap, rev;
};

int V;
vector<edge> G[1000000];
ll level[1000000];
int iter[1000000];

void addedge(int from, int to, ll cap) {
    G[from].push_back((edge){to, cap, (ll)G[to].size()});
    G[to].push_back((edge){from, 0, (ll)G[from].size() - 1});
}

void dinicbfs(int s) {
    fill(level, level + V, -1);
    queue<ll> que;
    level[s] = 0;
    que.push(s);
    while (!que.empty()) {
        ll v = que.front();
        que.pop();
        for (int i = 0; i < (int)G[v].size(); i++) {
            edge e = G[v][i];
            if (e.cap > 0 && level[e.to] == -1) {
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

ll dinicdfs(ll v, ll t, ll f) {
    if (v == t) {
        return f;
    }
    for (int &i = iter[v]; i < (int)G[v].size(); i++) {
        edge &e = G[v][i];
        if (e.cap > 0 && level[v] < level[e.to]) {
            ll d = dinicdfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

ll dinic(int s, int t) {
    ll flow = 0;
    while (1) {
        dinicbfs(s);
        if (level[t] < 0) {
            return flow;
        }
        fill(iter, iter + V, 0);
        ll f;
        while ((f = dinicdfs(s, t, inf)) > 0) {
            flow += f;
        }
    }
}

int main() {
    int N;
    cin >> N;
    V = N + 2;
    ll a[N + 1];
    ll sum = 0;
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
        if (a[i] <= 0) {
            addedge(0, i, -a[i]);
        } else {
            addedge(i, N + 1, a[i]);
            sum += a[i];
        }
        for (int j = 2 * i; j <= N; j += i) {
            addedge(i, j, inf);
        }
    }
    ll tmp = dinic(0, N + 1);
    cout << sum - tmp << endl;
}


Measured memory_bytes: 27264
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int a,b,c;
  int n1=0,n2=0;

  while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
    if(a*a+b*b==c*c)n1++;
    if(a==b)n2++;
  }
  cout<<n1<<endl;
  cout<<n2<<endl;
}

Measured memory_bytes: 1212
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n, q;
  cin >> n >> q;
  int s[n], t[n], x[n];
  for(int i = 0; i < n; i++){
    cin >> s[i] >> t[i] >> x[i];
  }
  int d[q];
  for(int i = 0; i < q; i++){
    cin >> d[i];
  }

  set< pii > ds;
  for(int i = 0; i < q; i++){
    ds.insert(make_pair(d[i], i));
  }

  vector< pii > v(n);
  for(int i = 0; i < n; i++){
    v[i] = make_pair(x[i], i);
  }
  sort(v.begin(), v.end());

  int ans[q];
  fill(ans, ans + q, -1);
  for(int i = 0; i < n; i++){
    int j = v[i].second;
    auto left = ds.lower_bound(make_pair(s[j] - x[j], 0));
    auto right = ds.upper_bound(make_pair(t[j] - 1 - x[j], q));
    vector< pii > toRemoved;
    for(auto it = left; it != right; it++){
      ans[(*it).second] = x[j];
      toRemoved.push_back(*it);
    }
    for(pii p: toRemoved) ds.erase(p);
  }

  string buf;
  for(int i = 0; i < q; i++){
    buf += to_string(ans[i]) + "\n";
  }

  cout << buf;

  return 0;
}


Measured memory_bytes: 19824
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>

#define MAX 2000001
#define INFTY (1<<30)//左シフト

using namespace std;

int H;
int A[MAX];

void maxHeapify(int i) {
	int l, r, largest;
	l = 2 * i;
	r = 2 * i + 1;

	if (l <= H && A[l] > A[i]) {
		largest = l;
	}
	else {
		largest = i;
	}
	if (r <= H && A[r] > A[largest]) {
		largest = r;
	}
	if (largest != i) {
		swap(A[i], A[largest]);
		maxHeapify(largest);
	}
}

void heapIncreasekey(int i, int k) {
	//int parent = i / 2;
	if (k < A[i]) return;

	A[i] = k;
	while (i > 1 && A[i / 2] < A[i]) {
		swap(A[i], A[i / 2]);

		i = i / 2;
	}
}

void insert(int k) {
	H++;

	A[H] = -INFTY;
	//A[H] = k;
	heapIncreasekey(H, k);
}



int extract() {
	int max;

	if (H < 1) {
		return -INFTY;
	}
	max = A[1];
	A[1] = A[H--];


	maxHeapify(1);

	//cout << max << endl;
	return max;

}

int main() {

	int k;
	char com[10];


	while (1) {
		cin >> com;
		//scanf_s("%s", com);
		//scanf("%s", command);

		if (com[0] == 'e' && com[1] == 'n') {
			break;
		}


		if (com[0] == 'i') {
			//cout << "値";
			cin >> k;
			//scanf_s("%d", &k);
			//scanf("%d", &k);
			insert(k);
		}
		else {
			//extract();
			printf("%d\n", extract());
		}
	}

	return 0;
}




Measured memory_bytes: 7012
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,flag=1;
    cin>>n;
    while(flag--)
    {
        long double sr = sqrt(n);
        if(sr-floor(sr)==0)
            cout<<n<<endl;
        else
        {
            n--;
            flag++;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

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

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")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

fn gcd(a: i32, b: i32) -> i32 {
    if b==0 { return a; }
    return gcd(b, a%b);
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let a:i32 = read();
    let b:i32 = read();
    let k:i32 = read();

    let g = gcd(a,b);
    //debug!(g);

    let mut cnt:i32 = 0;
    for i in 1..g+1 {
        let i = g - i+1;
        if a%i==0 && b%i==0 {
            cnt += 1;
        }
        //debug!(i,cnt);
        if cnt == k {
            println!("{}", i);
            return ();
        }
    }

}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  ll tmp=1e9;
  bool judge = true;
  ll h,w,n;cin>>h>>w>>n;
  vector<ll> a(n),b(n);
  for(i=0;i<n;i++){cin>>a[i]>>b[i];a[i]--;b[i]--;}
  unordered_set<ll>c;
  for(i=0;i<n;i++){
    c.insert({a[i]+tmp*(b[i]+1)});
  }
  unordered_map<ll,ll> x;
  for(i=0;i<n;i++){
    for(j=-1;j<=1;j++){
      for(o=-1;o<=1;o++){
        if(a[i]+j<1||a[i]+j>=h-1||b[i]+o<1||b[i]+o>=w-1)continue;
        buf=0;
        for(ll p=-1;p<=1;p++){
          for(ll q=-1;q<=1;q++){
            buf+=c.find(a[i]+j+p+(b[i]+o+q+1)*tmp)!=c.end();
          }
        }
        //cout<<a[i]+j spa b[i]+o spa buf<<endl;
        x.insert({a[i]+j+(b[i]+o+1)*tmp,buf});
      }
    }
  }
  vector<ll>m(10);
  for(auto y:x){
    m[y.second]++;
  }
  cout<<(h-2)*(w-2)-x.size()<<endl;
  for(i=1;i<=9;i++)cout<<m[i]<<endl;

  return 0;
}

Measured memory_bytes: 42256
#include <stdio.h>
struct arrow
{
    int origin;
    int next;
};
int checkLoop(int start, struct arrow *arrows, int arrowsCount)
{
    int maps[200];
    int i, j, k;
    for(i = 0; i < 200; i++)
    {
        maps[i] = -1;
    }
    maps[start] = 0;
    for(i = 0 ; i < 200; i++)
    {
        for(j = 0; j < 200; j++)
        {
            if(maps[j] != i) continue;
            for(k = 0; k < arrowsCount; k++)
            {
                if(arrows[k].origin == j)
                {
                    if(maps[arrows[k].next] == 0)
                    {
                        return 1;
                    }
                    maps[arrows[k].next] = i + 1;
                }
            }
        }
    }
    return 0;
}
int main(void){
    // Here your code !
    int count;
    int i;
    struct arrow arrows[1000];
    for(i = 0; i < 1000; i++)
    {
        arrows[i].origin = -1;
    }
    scanf("%d", &count);
    for(i = 0; i < count; i++)
    {
        char tmp[100];
        int origin, next;
        scanf("%d %s %d", &origin, tmp, &next);
        origin --;
        next--;
        next += 100;
        if(tmp[0] == 'l')
        {
            arrows[i].origin = origin;
            arrows[i].next = next;
        } else {
            arrows[i].origin = next;
            arrows[i].next = origin;
        }
    }
    for(i = 0; i < 100; i++)
    {
        if(checkLoop(i, arrows, 1000))
        {
            printf("%d\n", 1);
            return 0;
        }
    }
    printf("%d\n", 0);
    return 0;
}

Measured memory_bytes: 2764
#include <algorithm>
#include <iostream>
#include <limits>
using namespace std;
int main() {
  int n;
  while (cin >> n && n) {
    int m = numeric_limits<int>::min();
    int s = 0;
    while (n--) {
      int k;
      cin >> k;
      s += k;
      m = max(m, s);
      if (s < 0) s = 0;
    }
    cout << m << endl;
  }
}

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

#define all(x) (x).begin(), (x).end()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

int main() {
  _upgrade;
  string s;
  cin >> s;
  if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
    cout << 3 << "\n";
    return 0;
  }
  if ((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')) {
    cout << 2 << "\n";
    return 0;
  }
  if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') {
    cout << 1 << "\n";
    return 0;
  }
  cout << 0 << "\n";
  return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
bool cmp(char a,char b){
    return a>b;
}
int main(){
    string a,b;
    cin>>a>>b;
    sort(&a[0], &a[a.size()]);
    sort(&b[0], &b[b.size()],cmp);
    if(b>a){
        printf("Yes");
    }
    else{
        printf("No");
    }
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int maxn = 200010;

vi g[2][maxn];
int dep[maxn], par[maxn]; //sugim

void dfs(int v, int p, int d) { //on sugim
	dep[v] = d;
	par[v] = p;
	for (int to : g[1][v]) if (to != p) {
		dfs(to, v, d + 1);
	}
}

bool far(int a, int b) { //on sugim, 3
	if (dep[a] > dep[b]) swap(a, b);
	if (a == b || par[b] == a || par[a] == par[b] || (par[b] != -1 && par[par[b]] == a)) {
		return false;
	} else {
		return true;
	}
}

const int INF = 1e8;

int DFS(int v, int p, int d) { //on sigma
	int res = (dep[v] - d) * 2;
	for (int to : g[0][v]) if (to != p) {
		if (dep[to] > d+1) {
			res = max(res, DFS(to, v, d + 1) + 2);
		}
		if (far(v, to)) {
			res = max(res, INF);
		}
	}
	return res;
}

int main() {
	int N, X, Y;
	cin >> N >> X >> Y; --X; --Y;

	rep(t, 2) {
		rep(i, N-1) {
			int a, b;
			cin >> a >> b;
			--a; --b;
			g[t][a].pb(b); g[t][b].pb(a);
		}
	}

	dfs(Y, -1, 0);
	int ans = DFS(X, -1, 0);
	if (ans >= INF) ans = -1;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 33536
s = list(input())
n = len(s)

ans = []
for i in range(n):
  if s[i] == '0':
    ans.append('0')
  elif s[i] == '1':
    ans.append('1')
  elif ans == []:
    continue
  else:
    ans.pop()
    
print(''.join(ans))
    


Measured memory_bytes: 9020
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
String s=sc.next();
StringBuilder sb=new StringBuilder();
sb.append(s);
    for (int i = 0; i < s.length(); i++) {
        if(i%2==1)sb.setCharAt(i, '-');
    }
    s=sb.toString();
    s=s.replaceAll("-", "");
out.println(s);
}
}

Measured memory_bytes: 30216
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>

using namespace std;
typedef long long ll;

int n, m;
ll ans = 0;
vector<bool> load;
vector<vector<int>> vec;

void dfs(int now, int cnt) {
  load[now] = true;
  
  if (cnt == n - 1) {
    ans++;
  }
  
  for (auto itr = vec[now].begin(); itr != vec[now].end(); itr++) {
    if (load[*itr]) {
      continue;
    }
    dfs(*itr, cnt + 1);
  }
  load[now] = false;
}

int main()
{
  cin >> n >> m;
  load.resize(n, false);
  vec.resize(n);
  for (int i = 0; i < m; i++) {
    int from, to;
    cin >> from >> to;
    from--;
    to--;
    vec[from].push_back(to);
    vec[to].push_back(from);
  }
  
  dfs(0, 0);
  
  cout << ans << endl;
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<ll> h(n);
  
  for(int i=0;i<n;i++) cin >> h[i];
  int pre = -10;
  for(int i=0;i<n;i++){
    if(pre<h[i]){
      pre = h[i]-1;
    }else if(pre==h[i]){
      pre = h[i];
    }else{
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
int main(){
  string s;cin>>s;
  int z = 0,o = 0;
  for(int i = 0; s.size()>i;i++){
    if(s[i] == '0')z++;
    else o++;
  }
  cout << min(o,z)*2 << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

string s;
int main() {
    cin >> s;
    int n = s.length();
    int i = n;
    while (i > 0) {
        if (i >= 5) {
            if (s.substr(i - 5, 5) == "dream") {
                i -= 5;
                continue;
            } else if (s.substr(i - 5, 5) == "erase") {
                i -= 5;
                continue;
            }
            if (i >= 6) {
                if (s.substr(i - 6, 6) == "eraser") {
                    i -= 6;
                    continue;
                }
                if (i >= 7) {
                    if (s.substr(i - 7, 7) == "dreamer") {
                        i -= 7;
                        continue;
                    }
                }
            }
            cout << "NO" << endl;
            return 0;
        } else {
            break;
        }
    }
    if (i == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


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

#define ll long long

int main()
{
    stringstream ss;
    // 入力
    int N;
    ll C;

    cin>>N>>C;
    ll x[N];
    ll v[N];
    for(int i=0;i<N;i++){
        cin>>x[i]>>v[i];
    }
    ll calL[N];
    ll calR[N];
    ll calLmax[N];
    ll calRmax[N];
    ll calLmaxval=0;
    ll calRmaxval=0;
    int calLmaxid=0;
    int calRmaxid=0;
    int calLid[N];
    int calRid[N];

    ll cal=0;
    ll calmax=0;
    calL[0]=v[0]-x[0];
    calR[0]=v[N-1]-(C-x[N-1]);
    calLmaxval=calL[0];
    calLmax[0]=calL[0];
    calRmaxval=calR[0];
    calRmax[0]=calR[0];
    calLid[0]=0;
    calRid[0]=0;
    for(int i=1;i<N;i++){
        calL[i]=calL[i-1]+v[i]-(x[i]-x[i-1]);
        calR[i]=calR[i-1]+v[N-i-1]-(x[N-i]-x[N-i-1]);
        if(calLmaxval<calL[i]){
        	calLmaxid=i;
        	calLmaxval=calL[i];
        }
        if(calRmaxval<calR[i]){
        	calRmaxid=i;
        	calRmaxval=calR[i];
        }
        calLmax[i]=calLmaxval;
        calRmax[i]=calRmaxval;
        calLid[i]=calLmaxid;
        calRid[i]=calRmaxid;
    }
    cout<<endl;
    for(int i=0;i<N;i++){
        cal=calL[i];
        if(cal>calmax)calmax=cal;
        cal=calR[i];
        if(cal>calmax)calmax=cal;
    }

    for(int i=0;i<N-1;i++){
    	//cout<<"i="<<i<<": "<<calLmax[i]<<","<<calRmax[N-i-2]<<","<<C-x[N-calRid[N-i-2]-1]<<","<<x[calLid[i]]<<endl;
            if(x[calLid[i]]>C-x[N-calRid[N-i-2]-1]) cal=calLmax[i]+calRmax[N-i-2]-(C-x[N-calRid[N-i-2]-1]);
            else cal=calLmax[i]+calRmax[N-i-2]-x[calLid[i]];
            if(cal>calmax) calmax=cal;
    }
    // cout<<endl;
    cout<<calmax<<endl;
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define reprd(i,a,b) for (int i=(a);i>=(b);--i)
#define repr(i,n) reprd(i,n,0)
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; }

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 210000;
int N;
ll K;
int A[Max], F[Max];

ll bsearch(ll t) {
    ll tr = 0;
    rep(i, N) {
        tr += max(0LL, A[i] - t / F[i]);
    }
    return tr - K;
}

int main(int argc, const char * argv[]) {
    cin >> N >> K;
    inputArray(A, N);
    inputArray(F, N);
    sort(F, F+N, greater<int>());
    sort(A, A+N);

    ll mint = -1;
    ll maxt = 2e12;
    ll t;

    while (mint + 1 < maxt) {
        t = (mint + maxt) / 2;
        ll diff = bsearch(t);
        // printf("%lld, %lld, %lld, %lld,\n", diff, t, mint, maxt);

        if (diff > 0) {
            mint = t;
        } else {
            maxt = t;
        }
    }

    output(maxt);

    return 0;
}

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

int main()
{
	long long int N,s;
	int i,a[10],sum=0;
	
	scanf("%lld",&s); 
	N=s;
	for(i=0;N!=0;i++){
		a[i]=N%10;
		sum=sum+a[i];
		N=N/10;
		}
	
	if(s%sum==0)printf("Yes");
	  else printf("No");
	return 0;
}
 


Measured memory_bytes: 1732
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int whitecnt = 0;
		for(int i = 0;i < n;i ++) {
			char c = s.charAt(i);
			if(c == '.') whitecnt ++; //一旦全部黒にすることを考える
		}
		int cntmin = whitecnt, cnt = whitecnt;
		//前から徐々に白にする
		for(int i = 0;i < n;i ++) {
			char c = s.charAt(i);
			if(c == '.') cnt--; //黒にしてあったところ分のカウントを無くす
			else cnt++; //黒を白にする
			cntmin = Math.min(cnt, cntmin);
		}
		System.out.println(cntmin);
	}
}

Measured memory_bytes: 28720
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define llrp(i,n) for(long long i=0;i<n;i++)
#define llrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define vcin(a); rp(i,a.size()){cin>>a[i];}
#define vcout(a); rp(i,a.size()){cout<<a[i]<<endl;}
#define allchar(c) for(char c='a';c<='z';c++)

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef queue<int> qi;

const int mod=1e9+7;

ll modpow(ll a,ll b,ll p){
    if(b==0){
        return 1;
    }elif(b%2==0){
        return modpow((a*a)%p,b/2,p);
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll prime;
    prime.pb(2);
    if(n<=2){    
        cout << 0 << endl;
        return 0;
    }
    llrep(i,3,n){
        bool ok=true;
        llrep(j,2,i-1){
            if(i%j==0){
                ok=false;
            }
        }
        if(ok){
            prime.pb(i);
        }
    }
    vll nkai(prime.size());
    ll bunkai[n][prime.size()];
    llrp(i,prime.size()){
           nkai[i]=0;
    }
    llrp(i,n){
        ll k=i+1;
        llrp(j,prime.size()){
            while(k%prime[j]==0){
                k/=prime[j];
                nkai[j]++;
            }
        }
    }
    //rp(i,prime.size()){
    //  cout << prime[i] << ' ' << nkai[i] << endl; 
    //}
    ll ans=0;

    //2,4,4
    llrp(i,prime.size()-2){
        llrep(j,i+1,prime.size()-2){
            llrep(k,j+1,prime.size()-1){
                if(nkai[i]>=2&&nkai[j]>=4&&nkai[k]>=4){
                    ans++;
                }
                if(nkai[i]>=4&&nkai[j]>=2&&nkai[k]>=4){
                    ans++;
                }
                if(nkai[i]>=4&&nkai[j]>=4&&nkai[k]>=2){
                    ans++;
                }
            }
        }
    }
    //cout << ans << endl;
    
    //2,24
    llrp(i,prime.size()-1){
        llrep(j,i+1,prime.size()-1){
            if(nkai[i]>=2&&nkai[j]>=24){
                ans++;
            }
            if(nkai[i]>=24&&nkai[j]>=2){
                ans++;
            }
        }
    }
    //cout << ans << endl;
    
    //4,14
    llrp(i,prime.size()-1){
        llrep(j,i+1,prime.size()-1){
            if(nkai[i]>=4&&nkai[j]>=14){
                ans++;
            }
            if(nkai[i]>=14&&nkai[j]>=4){
                ans++;
            }
        }
    }
    //cout << ans << endl;
    
    //74
    llrp(i,prime.size()){
        if(nkai[i]>=74){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
using namespace std;
int main(void)
{
  string s,t="CODEFESTIVAL2016";
  cin >> s;
  int answer=0;
  REP(i,16) if(s[i]!=t[i]) ++answer;
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 256
main = do
  li <- getLine
  let n = read li
  co <- getContents
  let dds = map (l2p . map read . words) $ lines co
  let ans = compute n dds
  putStrLn $ if ans then "Yes" else "No"

l2p [a,b] = (a,b)

compute :: Int -> [(Int,Int)] -> Bool
compute n dds = loop bs
  where
    bs = [d1 == d2 | (d1,d2) <- dds]

loop (True:True:True:_) = True
loop (_:_:False:bs) = loop bs
loop (_:False:bs) = loop bs
loop (False:bs) = loop bs
loop _ = False

Measured memory_bytes: 4320
S = list(input())
MOD = 10 ** 9 + 7

length = len(S)
dp = [[0] * 13 for _ in range(length + 1)]
dp[0][0] = 1

for i in range(length):
    if S[i] == '?':
        s = -1
    else:
        s = int(S[i])

    for j in range(10):
        if s != -1 and s != j:
            continue
        for k in range(13):
            index = (k * 10 + j) % 13
            dp[i + 1][index] = (dp[i + 1][index] + dp[i][k]) % MOD

print(dp[length][5])


Measured memory_bytes: 65400
s = input()
t = input()


flag = False
for i in reversed(range(len(s)-len(t)+1)):
    count = 0
    for j in range(len(t)):
        if s[i+j] == t[j] or s[i+j] == '?':
            count += 1
        else:
            break
    if count == len(t):
        flag = True
        list_s = list(s)
        list_t = list(t)
        list_s[i:i+len(t)] = list_t
        s = ''.join(list_s).replace('?', 'a')
        break
if flag:
    print(s)
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
import java.util.Scanner;

class Main{

	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int count = 0;
		for(int i = a;i <= b ;i++){
			if(c%i == 0)count++;
		}
			System.out.println(count);
	}
}



Measured memory_bytes: 26340
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef
tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long long ll;
typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    string str;
    cin >> str;
    bool n = 0, w = 0, s = 0, e = 0;
    for (char c : str) {
        if (c == 'N') n = 1;
        if (c == 'W') w = 1;
        if (c == 'S') s = 1;
        if (c == 'E') e = 1;
    }
    cout << (n == s && w == e ? "Yes" : "No") << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 3532
#include <stdio.h>

int main(){
  int flag,i,j,N,A[100],B[100],count=0;

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

  while(flag){
    flag=0;
    for(j=N-1;j>=1;j--){
      if(A[j]<A[j-1]){
	B[j]=A[j-1];
	A[j-1]=A[j];
	A[j]=B[j];
	flag=1;
	count++;
      }
    }
  }
  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[N-1]);
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cctype>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <deque>
#include <map>
#include <bitset>
#include <functional>
#include <cmath>

#define INF 1000000000
using namespace std;

int main(){
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
}

Measured memory_bytes: 3596
use std::collections::VecDeque;
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let s: String = read();
    let q: u64 = read();
    
    
    let mut buf: VecDeque<char> = VecDeque::from(s.chars().collect::<Vec<_>>());
    let mut is_reverse = false;

    for _ in 0..q {
        let input = read_vec::<String>();
        if input[0] == "1" {
            is_reverse = !is_reverse;
        } else if input[0] == "2" {
            if input[1] == "1" {
                if !is_reverse {
                    buf.push_front(input[2].chars().next().unwrap());
                } else {
                    buf.push_back(input[2].chars().next().unwrap());
                }
            } else if input[1] == "2" {
                if !is_reverse {
                    buf.push_back(input[2].chars().next().unwrap());
                } else {
                    buf.push_front(input[2].chars().next().unwrap());
                }
            }    
        }
    }

    if is_reverse {
        let ans = buf.iter().rev().fold(String::new(), |mut x,y| {x.push(*y); x });
        println!("{}", ans);
    } else {
        let ans = buf.iter().fold(String::new(), |mut x, y| {x.push(*y); x });
        println!("{}", ans);
    }

}

Measured memory_bytes: 6652
#include <stdio.h>

#define SIZE 2048

typedef struct {
	long long key, id;
} data;

void merge_sort(data x[], int n)
{
	static data y[10001] = {};
	if (n <= 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p].key < x[q].key)? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N, Q, V[300000], W[300000];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d %d", &(V[i]), &(W[i]));
	scanf("%d", &Q);
	
	int j, k, l, m, size[SIZE];
	const int bit[12] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048};
	data d[SIZE][SIZE];
	for (i = 0; i < SIZE - 1 && i < N; i++) {
		for (k = 0; bit[k] <= i + 1; k++);
		for (j = 0; j < bit[k]; j++) {
			d[i][j].key = 0;
			d[i][j].id = 0;
			for (l = 0, m = i + 1; l <= k; l++, m >>= 1) {
				if ((j & bit[l]) != 0) {
					d[i][j].key += W[m];
					d[i][j].id += V[m];
				}
			}
		}
		merge_sort(d[i], bit[k]);
		for (j = 1, size[i] = 1; j < bit[k]; j++) if (d[i][j].id > d[i][size[i]-1].id) d[i][size[i]++] = d[i][j];
	}
	
	int q, v, L;
	long long ans;
	data tmp[SIZE];
	for (q = 1; q <= Q; q++) {
		scanf("%d %d", &v, &L);
		if (v < SIZE) {
			v--;
			for (j = 0, ans = 0; j < size[v] && d[v][j].key <= L; j++) ans = d[v][j].id;
			printf("%lld\n", ans);
			continue;
		}
		
		i = v / SIZE - 1;
		for (k = 0; bit[k] <= i + 1; k++);
		for (j = 0; j < bit[k]; j++) {
			tmp[j].key = 0;
			tmp[j].id = 0;
			for (l = 0, m = v; l <= k; l++, m >>= 1) {
				if ((j & bit[l]) != 0) {
					tmp[j].key += W[m];
					tmp[j].id += V[m];
				}
			}
		}
		merge_sort(tmp, bit[k]);
		
		for (j = 0, m = v / bit[k] - 1, l = size[m] - 1, ans = 0; j < bit[k] && tmp[j].key <= L; j++) {
			for (; l >= 0 && tmp[j].key + d[m][l].key > L; l--);
			if (l < 0) break;
			if (tmp[j].id + d[m][l].id > ans) ans = tmp[j].id + d[m][l].id;
		}
		printf("%lld\n", ans);
	}
	
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 51792
#include<cstdio>
inline int abs(int x) {return x>0?x:-x;}
inline int min(int x,int y) {return x<y?x:y;}
int a[100005];
int main()
{
	int n,k;scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int ans=0x3f3f3f3f;
	for(int i=1;i<=n-k+1;i++)
	if(a[i+k-1]<=0) ans=min(ans,-a[i]);
	else if(a[i]>=0) ans=min(ans,a[i+k-1]);
	else ans=min(ans,min(abs(a[i]),abs(a[i+k-1]))+a[i+k-1]-a[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 
 class Dijkstra {
 public:
     struct edge { long long v, dist; };
 
     struct state {
         long long v, cost;
         bool operator>(const state s) const { return cost > s.cost; }
     };
 
     const long long INF = (1LL << 60);
     long long N;
     vector< vector<edge> > E;
 
     Dijkstra(long long n): N(n), E(n) {}
 
     //有効グラフの時はこっち。u→vに距離dで結ぶ
     void add_directed_edge(long long u, long long v, long long d) {
         E[u].push_back((edge) { v, d });
     }
 
     //無向グラフの時はこっち。uとvを双方向に距離dで結ぶ
     void add_undirected_edge(long long u, long long v, long long d) {
         E[u].push_back((edge) { v, d });
         E[v].push_back((edge) { u, d });
     }
 
     //Sを始点として、他の頂点への最短経路を探す
     vector<long long> shortest_path(long long S) {
         vector<long long> dp(E.size(), INF);
         priority_queue<state, vector<state>, greater<state> > q;
         q.push((state) { S, 0 });
         while(!q.empty()) {
             long long v = q.top().v, cost = q.top().cost;
             q.pop();
             if(dp[v] <= cost) continue;
             dp[v] = cost;
             for(int i=0;i < E[v].size() ; i++) {
             long long nv = E[v][i].v, ncost = cost + E[v][i].dist;
             if(dp[nv] > ncost) q.push((state) { nv, ncost });
             }
         }
         return dp;
     }
 };
 

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


    long long n;
    cin>>n;
    long long u,v,w;
    Dijkstra d(n);
    for(int i=0;i<n-1;i++){
        cin>>u>>v>>w;
        u--,v--;
        d.add_undirected_edge(u,v,w);
    }
    vector<long long> vv=d.shortest_path(0);

    for(int i=0;i<n;i++){
        if(vv[i]%2==0){
            cout<<0<<endl;

        }
        else cout<<1<<endl;
    }
    
    
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, ac=0, wa=0, tle=0, re=0;
  cin>>n;
  string s;
  for (int i=0; i<n; i++) {
    cin>>s;
    if (s=="AC") ac++;
    else if (s=="WA") wa++;
    else if (s=="TLE") tle++;
    else re++;
  }
  cout<<"AC x "<<ac<<'\n';
  cout<<"WA x "<<wa<<'\n';
  cout<<"TLE x "<<tle<<'\n';
  cout<<"RE x "<<re<<'\n';
}

Measured memory_bytes: 3608
#include <stdio.h>

int main() {
	int N;
	scanf("%d",&N);
	int p[N];
	for (int i = 0; i < N; i++) {
		scanf("%d",&p[i]);
	}
	int flag = 0;
	for (int i = 1; i <= N; i++) {
		if (p[i-1] != i) {
			int tmp = p[i-1];
			if (p[tmp-1] == i) flag += 1;
			else {
				printf("NO\n");
				flag = -1;
				break;
			}
		}
	}

	if (flag == 2 || flag == 0) printf("YES\n");
	else if (flag > 2) printf("NO\n");
	return 0;
}

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

int main(){

    int h,w;
    char grid[100][100];
    int answer[100][100]={0};
        
    cin>>h>>w;

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>grid[i][j];
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(grid[i][j]=='c') answer[i][j]=0;
            else{
                for(int k=0;k<j;k++){
                    if(grid[i][k]=='c'){
                        answer[i][j]=j-k;
                    }
                }
                if(answer[i][j]==0){
                    answer[i][j]=-1;
                }
            }
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<answer[i][j];
            if(j<w-1) cout<<' ';
        }
        cout<<endl;
    }
    
}



Measured memory_bytes: 3128
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    A2IN(string, s, ll, t, N);
    IN(string, X);
    ll ans = 0;
    bool b = false;
    REP(i, N)
    {
        if (b)
        {
            ans += t[i];
        }
        b |= s[i] == X;
    }
    OUT(ans);
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1e9 + 7, maxN = 1e5 + 13;
int n, x, dp[maxN], dpw[maxN];
vector<int> vec;
int pw (int a, int b) {
    int ret = 1;
    for (; b; b >>= 1, a = 1ll * a * a % mod)
	if (b & 1)
	    ret = 1ll * ret * a % mod;
    return ret;
}

					
int32_t main () {
    cin >> n >> x;
    int cur = 1;
    for (int i = 0; i < n; i++) {
	int a;
	cin >> a;
	if (a <= x)
	    vec.push_back(a);
	cur = (cur * (i + 1)) % mod;
    }
    sort(vec.begin(), vec.end());

    for (int i = 0; i <= n; i++)
	dpw[i] = pw(i, mod - 2);
    
    for (int i = 0; i <= x; i++) {
	int pos = upper_bound(vec.begin(), vec.end(), i) - vec.begin();
	if (pos == 0)
	    dp[i] = i;
	for (int j = 0; j < pos; j++) {
	    //cout << i << " " << vec[j] << " " << dp[i % vec[j]] << endl;
	    dp[i] = (dp[i] + dpw[pos] * dp[i % vec[j]]) % mod;
	}
	
	//cout << i << " " << pos << " " << dp[i] << endl;
    }
    
    //cout << solve(x, n) << " " << cur  << endl;
    cout << 1ll * dp[x] * cur % mod << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    string S; cin >> S;
    int cnt[26] = {0};
    REP(i,S.length())
    {
        cnt[S[i] - 'a']++;
    }

    REP(i,26)
    {
        if(cnt[i] == 0)
        {
            cout << string(1,i+'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;

}


Measured memory_bytes: 512
#include<iostream>
#include<set>
using namespace std;
#define rep(i, c) for(int i=0; i<(int)c; i++)

int main(){
    int H,A;
    cin >> H >> A;
    int ans=0;
    int Mon=H;

    for(int i=1; Mon>0; i++){
        Mon=H-A*i;
        ans++;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include <cstdlib>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++) 

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> vec(N);
    for (int i = 0; i < M; i++) {
        int a_i, b_i;
        cin >> a_i >> b_i;
        for (int j = 0; j < N; j++) {
            if (a_i == j+1) {
                vec.at(j) += 1;
            }
            if (b_i == j+1) {
                vec.at(j) += 1;
            }
        }
    }

    for (int i = 0; i < N; i++) {
        cout << vec.at(i) << endl;
    }
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int h,m,s;

  scanf("%d",&s);

  h=s/3600;
  s=s%3600;
  m=s/60;
  s=s%60;

  printf("%d:%d:%d\n",h,m,s);
  
  return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e6,mod=1000003;
int fac[N],q,n,x,d,a[N];
int ny(int x)
{
	if(a[x])return a[x];
	return a[x]=(-ny(mod%x)*(mod/x)%mod+mod)%mod;
}
int pow(int a,int m)
{
	int ret=1;
	for(;m;a=(a*a)%mod,m>>=1)
		if(m&1)ret=(ret*a)%mod;
	return ret;
}
main()
{a[1]=1;
	fac[0]=1;for(int i=1;i<=mod;i++)fac[i]=(fac[i-1]*i)%mod;
	scanf("%lld",&q);
	while(q--)
	{
		scanf("%lld%lld%lld",&x,&d,&n);
		if(!x){puts("0");continue;}
		if(!d){printf("%lld\n",pow(x,n));continue;}
		x=(x*ny(d))%mod;
		if(x+n-1>=mod){puts("0");continue;}
		printf("%lld\n",(fac[x+n-1]*ny(fac[x-1])%mod*pow(d,n))%mod);
	}
}

Measured memory_bytes: 19328
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Random;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static final int INF = 0xFFFFFFF;
	static long[][] hash = new long[32][32];
	static long finish;

	public static void main(String[] args) {
		Random rnd = new Random();
		for (int i = 0; i < 32; ++i) {
			for (int j = 0; j < 32; ++j) {
				hash[i][j] = rnd.nextLong();
			}
		}
		for (int i = 0; i < 4; ++i) {
			for (int j = 2; j <= 7; ++j) {
				finish ^= hash[(j - 1) * 4 + i][i * 8 + j];
			}
		}
		int T = sc.nextInt();
		for (int i = 0; i < T; ++i) {
			System.out.println(solve());
		}
	}

	static int solve() {
		ArrayList<Board> cur = new ArrayList<Board>();
		HashSet<Long> hashes = new HashSet<Long>(30000);
		cur.add(new Board());
		if (cur.get(0).h == finish) return 0;
		hashes.add(cur.get(0).h);
		int i = 0;
		for (; !cur.isEmpty(); ++i) {
//			System.out.println("turn:" + i + " size:" + cur.size());
			ArrayList<Board> next = new ArrayList<Board>(cur.size());
			for (Board b : cur) {
				for (int j = 4; j < 32; ++j) {
					if (b.f[j] == INF && (b.f[j - 4] & 7) != 7) {
						Board created = new Board(b, j);
						if (hashes.contains(created.h)) continue;
						if (created.h == finish) return i + 1;
						hashes.add(created.h);
						next.add(created);
					}
				}
			}
			cur = next;
		}
		return -1;
	}

	static class Board {
		int[] f;
		long h;

		Board() {
			f = new int[32];
			for (int i = 0; i < 4; ++i) {
				for (int j = 1; j <= 7; ++j) {
					String v = sc.next();
					int suit = v.charAt(0) - '1';
					int num = v.charAt(1) - '0';
					int card = suit * 8 + num;
					if (num == 1) {
						f[j * 4 + i] = INF;
						f[suit] = card;
					} else {
						f[j * 4 + i] = card;
						h ^= hash[j * 4 + i][card];
					}
				}
			}
		}

		Board(Board orig, int pos) {
			this.f = orig.f.clone();
			this.h = orig.h;
			final int target = orig.f[pos - 4] + 1;
			for (int i = 4; i < 32; ++i) {
				if (orig.f[i] == target) {
					this.f[i] = INF;
					this.h ^= hash[i][target];
					break;
				}
			}
			this.f[pos] = target;
			this.h ^= hash[pos][target];
		}
	}
}

Measured memory_bytes: 90620
#include<stdio.h>

int main(){
  int i,n,key[251];

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&key[i]);
  }

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

    printf("node %d: key = %d, ",i,key[i]);

    if(i>1){
      printf("parent key = %d, ",key[i/2]);
    }

    if(2*i<=n){
      printf("left key = %d, ",key[2*i]);
    }

    if(2*i+1<=n){
      printf("right key = %d, ",key[2*i+1]);
    }

    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600