akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>

int main(){
	double g;
	double f;
	int x;
	int h;
	double s;
	while(1){
		scanf("%d%d", &x, &h);
		if(x == 0 && h == 0) break;
		f = 4 * h * h + x * x;
		g = sqrt(f);
		s = g * x + x * x;
		printf("%f\n", s);
	}
	return 0;
}

Measured memory_bytes: 632
N, S = gets.to_i, gets.chomp
max = 0

0.upto(S.size-2) do |i|
  fh = S[0..i].split('').uniq
  rh = S[(i+1)..-1].split('').uniq
  count = (fh&rh).count
  max = count if count > max
end

puts max

Measured memory_bytes: 1788
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] temp = new int[n+1];
		ArrayList<Edge>[] list = new ArrayList[n+1];
		for(int i = 1; i <= n; i++){
		    list[i] = new ArrayList<Edge>();
		}
		for(int i = 1; i < n; i++){
		    int u = sc.nextInt();
		    int v = sc.nextInt();
		    int w = sc.nextInt();
		    if(w%2 == 0){
		        w = 1;
		    }else{
		        w = -1;
		    }
		    /*if(u > v){
		        int temp = u;
		        u = v;
		        v = temp;
		    }*/
		    list[u].add(new Edge(u, v, w));
		    list[v].add(new Edge(v, u, w));
		}
		
		// 計算
		int[] result = new int[n+1];
		ArrayDeque<Integer> q = new ArrayDeque<Integer>();
		q.add(1);
		while(!q.isEmpty()){
		    int now = q.poll();
		    if(result[now] == 0) result[now] = 1;
		    for(Edge e : list[now]){
		        int i = e.v;
		        if(result[i] != 0) continue;
		        result[i] = result[now]*e.w;
		        q.add(i);
		    }
		}
		
		// 出力
        for(int i = 1; i <= n; i++){
		    System.out.println(max(0, result[i]));
		}
		//System.out.println(result);
	}

}

class Edge {
    int u;
    int v;
    int w;
    
    Edge(int u, int v, int w){
        this.u = u;
        this.v = v;
        this.w = w;
    }
    
    
    public String toString(){
        return "u:" + u + " v:" + v + " w:" + w;
    }
    
}

Measured memory_bytes: 105100
use std::io::{BufRead, Write};
use std::io;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut buf = String::new();
    input.read_line(&mut buf).unwrap();
    let s = buf.trim().as_bytes();
    let counts: Vec<usize> = (b'a'..b'z' + 1)
        .map(|x| s.iter().filter(|&&y| x == y).count())
        .collect();
    let result = s.len() * (s.len() - 1) / 2 -
        counts
            .iter()
            .map(|&x| if x == 0 { 0 } else { x * (x - 1) } / 2)
            .sum::<usize>() + 1;
    writeln!(output, "{}", result).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test("aatt\n", "5\n");
    }
    #[test]
    fn case2() {
        test("xxxxxxxxxx\n", "1\n");
    }
    #[test]
    fn case3() {
        test("abracadabra\n", "44\n");
    }
}


Measured memory_bytes: 4352
int main(){
	int H,W,i,j,n;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0)break;
		for(i=1;i<=H;i++){
			if(i%2==1)n=1;
			else n=0;
			for(j=1;j<=W;j++){
				if(j%2==n)printf("#");
				else printf(".");
			}
			printf("\n");
			if(i==H)printf("\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 572
def solve():
  N, K = map(int, input().split())
  A = list(map(int, input().split()))
  dp = ['Second']*(K*2)
  for i in range(K):
    if dp[i]!='Second':
      continue
    for j in range(N):
      dp[i+A[j]]='First'
  ans = dp[K]
  return ans
print(solve())

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> b(1000001,0);
  rep(i,n) b[a[i]]++;
  
  ll ans = n;
  rep(i,n) {
    for (ll j=1; j*j<=a[i]; j++) {
      if (a[i] % j == 0) {
        
        if (a[i] == 1) {
          if (b[j] > 1) {
            ans--;
            break;
          }
        }
        
        else if (j==1) {
          if (b[j] > 0 || b[a[i]/j] > 1) {
            ans--;
            break;
          }
        }
        
        else if (b[j] > 0 || b[a[i]/j] > 0) {
          ans--;
          break;
        }
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 12700
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,x,y,cnt=0,sum=0;
    cin>>t>>x;
    for(int i=0;i<t;i++)
    {
        cin>>y;
        sum+=y;
        if(sum<=x)
        {
            cnt++;
        }
        else if(sum>x)
        {
            break;
        }
    }
    cout<<cnt+1<<endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
MOD = 10**9+7

if abs(n-m) > 1:
    print(0)
else:
    nf, mf = 1, 1
    for i in range(1, min(n, m)+1):
        nf = (nf*i) % MOD

    if n != m:
        mf = max(n, m) * nf
    else:
        mf = nf

    if n == m:
        print(nf * mf * 2 % MOD)
    else:
        print(nf * mf % MOD)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, K, Q; cin >> N >> K >> Q;
    vector<int> A(N); for (auto& a : A) cin >> a;
    auto B = A;
    sort(begin(B), end(B));
    int ans = INT_MAX;
    for (int Y : B) {
        vector<int> T;
        auto candidate = [&](int i, int j) {
            int t = (j - i) - (K - 1);
            if (t <= 0) return;
            vector<int> U(begin(A)+i, begin(A)+j);
            nth_element(begin(U), begin(U)+t-1, end(U));
            copy_n(begin(U), t, back_inserter(T));
        };
        int cnt = 0;
        for (int i = 0; i < N; i++) {
            if (A[i] >= Y) {
                cnt++;
            } else {
                candidate(i-cnt, i);
                cnt = 0;
            }
        }
        candidate(N-cnt, N);
        if (T.size() >= Q) {
            nth_element(begin(T), begin(T)+Q-1, end(T));
            int X = *(begin(T)+Q-1);
            ans = min(ans, X - Y);
        } else {
            break;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,i,num[4],count=0;
    scanf("%d%d",&a,&b);
    for(i=a;i<=b;i++)
    {
        num[0]=i%10;
        num[1]=i/10%10;
        num[2]=i/1000%10;
        num[3]=i/10000%10;
        if(num[0]==num[3]&&num[1]==num[2])
            count++;
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 128
import bisect
n,m = map(int,input().split())

d = [[] for _ in range(n)]
P = [0] * m
Y = [0] * m

for i in range(m):
    p,y = map(int,input().split())
    P[i] = p
    Y[i] = y
    d[p-1].append(y)
for i in range(n):
    d[i].sort()

for i in range(m):
    p,y = P[i],Y[i]
    D = d[p - 1]
    idx = bisect.bisect_left(D, y) + 1
    print(str(p).zfill(6) + str(idx).zfill(6))


Measured memory_bytes: 24184
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
ll arr[100005];
ll b[100005];

int main() {
	scanf("%lld", &N);
	for(int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
	}
	ll sum = 0;
	for(int i = 0; i < N; i++) {
		if(i % 2 == 1) {
			arr[i] = -arr[i];
		}
		sum += arr[i];
		if(i % 2 == 1) {
			arr[i] = -arr[i];
		}
	}
	b[0] = sum;
	for(int i = 0; i < N - 1; i++) {
		// cout << i << " ";
		// cout << arr[i] << " " << b[i] << "\n";
		b[i + 1] = arr[i] - (b[i] / 2);
		b[i + 1] *= 2;  
	}
	for(int i = 0; i < N; i++) {
		printf("%lld ", b[i]);
	}
	// printf("%lld\n", sum);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 2816
import sys

def prime_factorize(n, factor):
    base = 2
    exp = 0
    while base < n:
        while n % base == 0:
            n = n // base
            exp += 1
        if exp > 0:
            factor[base] = factor.get(base, 0) + exp
        base += 1
        exp = 0
    if n > 1:
        factor[base] = factor.get(base, 0) + 1
    return factor

n = int(input())

if n == 1:
    print(1)
    sys.exit(0)

factor = {}
for i in range(2, n+1):
    factor = prime_factorize(i, factor)

ans = 1
for v in factor.values():
    ans *= v + 1

print(ans % (10 ** 9 + 7))

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int[] prime = new int[999999];
        prime[0] = 2;
        int num = 1;
        while(s.hasNext()) {
            int n = s.nextInt();
	    if (n==0)
		break;
            if (num < n) {
                for (int i=prime[num-1]+1 ; num<n ; i++) {
                    boolean flag = true;
                    for (int j=0 ; prime[j]*prime[j] <= i ; j++) {
                        if(i % prime[j] == 0) {
                            flag = false;
                            break;
                        }
                    }
                    if(flag) {
                        prime[num] = i;
                        num++;
                    }
                }
	    }
	    int out = 0;
	    for(int i=0 ; i<num ; i++)
		out += prime[i];
	    System.out.println(out);
        }
    }
}

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

using namespace std;
#define mp make_pair
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef pair<int,int> pii;
typedef long long ll;

using t3 = tuple<int,int,int>;

const int maxS = 2500;

int enc(int v, int s){
    // 0 <= s <= maxS, 0 <= v < n
    // 0 ... maxS 
    // maxS+1 ... 2*maxS + 1
    return v*(maxS+1) + s;
}

pii dec(int idx){
    int v = idx/(maxS+1);
    int s = idx%(maxS+1);
    return {v,s};
}

vector<vector<t3>> g;
vi cr;
vi T;

vl sp; //shortes path to i in [0,n-1]
int nMrk; // number of cities visited

class Dijkstra{
public:
    static vl solve(int s, int target = -1){
        //g[v] = list of (u,w) , where v->u with weight w.
        int n = (maxS+1)*cr.size();

        assert(s >= 0 && s < n);

        vl dist(n, -1);
        set<pair<ll,int>> S;
        S.insert(mp(0, s));
        
        while(!S.empty()){
            auto min_data = *S.begin();
            S.erase(S.begin());

            ll min_dist = min_data.first;
            int v = min_data.second;
            dist[v] = min_dist;

            int vc,vs;
            auto pp = dec(v);
            vc = pp.first; vs = pp.second;
            if(sp[vc] == -1){
                sp[vc] = min_dist;
                nMrk++;
            }
            if(nMrk == sp.size()) break;

            // buy silver from gold
            int u = enc(vc, min(maxS, vs + cr[vc]));
            int uw = T[vc];

            if(dist[u] == -1 || dist[v]+uw < dist[u]){
                if(dist[u] != -1) S.erase({dist[u],u});
                dist[u] = dist[v] + uw;
                S.insert({dist[u],u});
            }
            // travel
            for(auto u_data : g[vc]){
                int uc = get<0>(u_data);
                int us = get<1>(u_data);                
                int w = get<2>(u_data);
                if(us > vs) continue;
                us = vs - us;
                int u = enc(uc, us);
                if(dist[u] == -1 || (dist[v]+w < dist[u])){
                    if(dist[u] != -1) S.erase({dist[u],u});
                    dist[u] = dist[v] + w;
                    S.insert({dist[u],u});
                }
            }
        }
        return dist;
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, i, j, u, v, s0, w, s;
    cin >> n >> m >> s0;

    g.resize(n, vector<t3>());    
    for(i=0;i<m;i++){
        cin >> u >> v >> s >> w;
        u--;v--;
        g[u].push_back({v,s,w});
        g[v].push_back({u,s,w});
    }

    cr.resize(n);
    T.resize(n);
    for(i=0;i<n;i++){
        cin >> cr[i] >> T[i];
    }

    sp = vl(n, -1);
    nMrk = 0;

    int v0 = enc(0, min(s0,maxS));
    Dijkstra::solve(v0);

    for(i=1;i<n;i++)
        cout << sp[i] << "\n";

    return 0;
}

Measured memory_bytes: 7604
/*
Author: Fuadul Hasan(fuadul202@gmail.com)
BSMRSTU,Gopalganj
*/

#include <set>
#include <map>
#include <list>
#include <queue>
#include <ctime>
#include <deque>
#include <stack>
#include <cmath>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <string>
#include <chrono>
#include <random>
#include <cassert>
#include <complex>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <fstream>
#include <climits>
#include <stdio.h>
#include <cstring>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
//#include <bits/stdc++.h>
using namespace std;
 
int         cinn()              {int x; scanf("%d", &x); return x;}
long long   scll()              {long long x; scanf("%lld", &x); return x;}
double      scd()               {double x; scanf("%lf", &x); return x;}
void        coutt(int x)        {printf("%d ", x);}
 
#define  scll                   scll()
#define  gcd(a,b)               __gcd(a,b)
#define  lcm(a,b)               (a*b)/gcd(a,b)
#define  PI                     acos(-1.0)
#define  vi                     std::vector<int>
#define  vll                    std::vector<ll>
#define  vit                    vector<int> :: iterator
#define  sit                    set<int> :: iterator
#define  mpsi                   std::map<string, int>
#define  pb                     push_back
#define  ll                     long long int
#define  ld                     long double
#define  ull                    unsigned long long int
#define  min3(a,b,c)            min(a,min(b,c))
#define  min4(a,b,c,d)          min(d,min(a,min(b,c)))
#define  max3(a,b,c)            max(a,max(b,c))
#define  max4(a,b,c,d)          max(d,max(a,max(b,c)))
#define  nl                     printf("\n");
#define  no                     printf("No");
#define  yes                    printf("Yes");
#define  F                      first
#define  S                      second

typedef pair<int,int> ii;
typedef std::vector<ii> vii;
 
const int mod           = 1e9 + 7;
const int inf           = (int)2e9 + 5;
const ll  Inf           = (ll)1e18 + 5;
const int N             = 1e6 + 5;
const int nn           = 4e5 + 5;

/*bool isPalindrom1(string s){int n = s.size();
for(int i=0;i<=n/2;i++){if(s[i]!=s[n-1-i]){return false;}}return true;}
bool isPalindrom2(string s1,string s2){int n = s1.size();
for(int i=0;i<n;i++){if(s1[i]!=s2[n-1-i]){return false;}}return true;}*/



int solve()
{
	int n,y=0;
	cin>>n;
	map<string , int> m;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		m[s]++;
		if(m[s]>y) y = m[s];
	}
	for(auto i : m){
		if(i.S == y){
			cout<<i.F<<endl;
		}
	}
	return 0;
}

int main()
{
    int test = 1, tc = 0;
    //scanf("%d", &test);
    //(void)getchar();
    //cin >> test;
    while (test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 25216
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

// 約数列挙
vector<LL> divisor(LL n) {
	vector<LL> ret;
	for (LL i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.pb(i);
			if (i * i != n) ret.pb(n / i);
		}
	}
	SORT(ret);
	return ret;
}

int main() {
	int n;
	cin >> n;

	int count = 0;
	for (int i = 105; i < n + 1; i += 2) {
		if (divisor(i).size() == 8) count++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto S = RD!string;
	auto T = RD!string;
	string ans;
	foreach (i; 0..S.length)
	{
		ans ~= [S[i], T[i]];
	}
	
	writeln(ans);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, m, r[3], ans, t[110000];
string s;

int main() {
	cin >> n >> m;
	REP(i, 3)cin >> r[i];
	cin >> s;
	REP(i, n) {
		if (s[i] == 'r')t[i] = 1;
		if (s[i] == 's')t[i] = 2;
		if (s[i] == 'p')t[i] = 3;
	}
	REP(i, m) {
		vector<vector<ll>> dp(n / m + 10, vector<ll>(3));
		ll j = 0;
		ll now = i;
		while (now < n) {
			REP(k, 3) {
				REP(l, 3) {
					if (k == l)continue;
					if ((l - t[now] + 3) % 3 == 1) {
						dp[j + 1][l] = max(dp[j + 1][l], dp[j][k] + r[l]);
					}
					else dp[j + 1][l] = max(dp[j + 1][l], dp[j][k]);
				}
			}
			now += m;
			j++;
		}
		
		ll t = 0;
		REP(l, 3)t = max(t, dp[j][l]);
		ans += t;
	}
	cout << ans << endl;
}





Measured memory_bytes: 6528
n, y = gets.split.map(&:to_i)
ans = '-1 -1 -1'

(0..n).each do |i|
  (0..n).each do |j|
    if n - i - j < 0
      next
    end
      
    if 10000 * i + 5000 * j + 1000 * (n - i - j) == y 
      ans = "#{i} #{j} #{n-i-j}"
      break
    end
  end
end

puts ans

Measured memory_bytes: 3836
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
//max_element

int N;
set<int> st[26];
int Q;


signed main()
{
	cin >> N;
	string str;
	cin >> str;
	for (int i = 0; i < str.length(); i++)
	{
		int a = str[i] - 'a';
		st[a].insert(i + 1);
	}
	cin >> Q;
	REP(q, Q)
	{
		int a, b;
		cin >> a >> b;
		if (a == 1)
		{
			char ch;
			cin >> ch;
			int c = ch - 'a';
			for (int i = 0; i < 26; i++)
			{
				auto it = st[i].lower_bound(b);
				if (it != st[i].end())
				{
					int n = *it;
					if (n == b)
					{
						st[i].erase(it);
						st[c].insert(n);
						break;
					}
				}
			}
		}
		else
		{
			int c;
			cin >> c;

			int cnt = 0;
			for (int i = 0; i < 26; i++)
			{
				auto it = st[i].lower_bound(b);
				if (it != st[i].end())
				{
					int n = *it;
					if (b <= n && n <= c)
					{
						cnt++;
					}
				}
			}
			cout << cnt << endl;
		}
	}
}




Measured memory_bytes: 24184
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
      	String u = t.substring(0,t.length()-1);
        if (s.equals(u)){
          
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35676
# coding: utf-8
# Your code here!
N,M = map(int, input().split())
List = [list(input().split()) for i in range(M)]

ACList=[0]*N
WAList=[0]*N

i=0
while i<M:
    if List[i][1]=="AC":
        ACList[int(List[i][0])-1]=1
    if List[i][1]=="WA" and ACList[int(List[i][0])-1]==0:
        WAList[int(List[i][0])-1]+=1
    i+=1

j=0
while j<len(WAList):
    if ACList[j]!=1 and WAList[j]!=0:
        WAList[j]=0
    j+=1

print(sum(ACList),sum(WAList))

Measured memory_bytes: 27452
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
  
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 1e5+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
    ll n,i,j;
    cin >> n;
    ll x = n;
    n = n/1000 + (n%1000 != 0);
    cout << 1000*n-x ;

}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL); 
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

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

string s, t;
vector<int>ans;
bool change(int t_i, int s_i){
    if(t_i == 0 && (s[s_i]==t[t_i]||s[s_i]=='?')) {
        ans.push_back(s_i);
        return true;
    }
    if(s[s_i]==t[t_i]||s[s_i]=='?'){
        ans.push_back(s_i);
        return change(t_i-1, s_i-1);
    }
    return false;
}
int main(void){
    cin>>s>>t;
    vector<string> kouho;
    for(int i=t.size()-1;i<=s.size()-1;i++){
        if(change(t.size()-1, i)){
            string tmp=s;
            rep(i, ans.size()) tmp[ans[i]]=t[t.size()-1-i];
            rep(i, tmp.size()){
                if(tmp[i]=='?') tmp[i]='a';
            }
            kouho.push_back(tmp);
        }
        ans=vector<int>();
    }
    if(kouho.size()==0) {
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    sort(kouho.begin(), kouho.end());
    cout<<kouho[0]<<endl;
    return 0;
}

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

int a[20][20];
int main(){
	int n;
	while(scanf("%d",&n),n){
		memset(a,0,sizeof(a));
		int px=n/2+1,py=n/2;
		rep(i,n*n){
			a[px][py]=i+1;
			px=(px+1)%n;
			py=(py+1)%n;
			if(a[px][py]){
				px=(px+1+n)%n;
				py=(py-1+n)%n;
			}
		}
		rep(i,n){
			rep(j,n){
				printf("%4d",a[i][j]);
			}
			printf("\n");
		}
	}
}

Measured memory_bytes: 3196
N=int(input())
S=[]
for i in range(0, N):
    val = input()
    S.append(val)
ac=S.count('AC')
wa=S.count('WA')
tle=S.count('TLE')
re=S.count('RE')

print("AC x ", end='') 
print(ac)
print("WA x ", end='') 
print(wa)
print("TLE x ", end='') 
print(tle)
print("RE x ", end='') 
print(re)

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

#include <bits/stdc++.h>
#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF ll(1e9)
#define INFL ll(1e18)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int ctoi(char c) {return c - '0';}

class BBingo {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int A[3][3];
	    REP(i, 3) REP(j, 3) in >> A[i][j];
	    int N;
	    in >> N;
	    int b[N];
	    bool c[3][3] = {false};
	    string ans = "No";
	    REP(i, N) in >> b[i];
	    REP(i, 3) {
	        REP(j, 3) {
	            REP(k, N) {
	                if (A[i][j] == b[k]) c[i][j] = true;
	            }
	        }
	    }
	    REP(i, 3) {
	        if (c[i][0] && c[i][1] && c[i][2]) {
	            ans = "Yes";
	        } else if (c[0][i] && c[1][i] && c[2][i]) {
	            ans = "Yes";
	        }
	    }
	    if (c[0][0] && c[1][1] && c[2][2]) ans = "Yes";
	    if (c[0][2] && c[1][1] && c[2][0]) ans = "Yes";
	    out << ans << '\n';
	}
};


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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
  cin>>a>>b>>c;
  vector<int> v;
  v.push_back(a);
  v.push_back(b);
  v.push_back(c);
  if(count(v.begin(),v.end(),5)==2 && count(v.begin(),v.end(),7)==1)
    cout<<"YES";
  else
    cout<<"NO";
}


Measured memory_bytes: 256
using System;

namespace AIZUJudge {
    class PrimeNumber {
        static void Main(string[] args) {
            const int MAX = 1000000;
            bool[] primeList = new bool[MAX];

            for (int i = 2; i < MAX; i++) {
                if (checkPrime(i)) {
                    primeList[i] = true;
                }
            }
            for (string n; (n = Console.ReadLine()) != null;) {
                if (n == ""||n==null) break;
                int upper = int.Parse(n);
                int numPrime = 0;
                for (int i = 2; i <= upper; i++) {
                    if (primeList[i]) {
                        numPrime++;
                    }
                }
                Console.WriteLine(numPrime);
            }
       }
                

        static bool checkPrime(int a) {
            int range = (int)Math.Sqrt(a);
            bool isPrime = true;
            for (int i = 2; i <= range; i++) {
                if (a%i==0) {
                    isPrime = false;
                    break;
                }
            }
            return isPrime;
        }
    }
}

Measured memory_bytes: 10120
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(){
	char table[7][6],moji,chara[5]={'z','.','?','!',' '},s[256];
	moji='a';
	for(int i=1;i<7;i++){
		for(int j=1;j<6;j++){
			if(i<6) table[i][j]=moji++;
			else table[i][j]=chara[j-1];
		}
	}
	while(~scanf("%s",s)){
		int length=strlen(s);
		if(length%2!=0) printf("NA");
		else{
			int i;
			for(i=1;i<length;i+=2) if(s[i-1]-48>6||s[i]-48>5||s[i-1]-48<1||s[i]-48<1) break;
			if(i>length) for(i=1;i<length;i+=2) printf("%c",table[s[i-1]-48][s[i]-48]);
			else printf("NA");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 956
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    ll ans = 1000 * (n/500);
    n %= 500;
    ans += (n/5) * 5;
    cout << ans << endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define ll long long
#define ld long double
#define fi first
#define se second
#define INF 1000000000+10
const ll mod = 1000000000+7;
const int N = 100000+50;

vector<int> g[N];
int dp[N];

int go(int i)
{
	if(dp[i]!=-1)return dp[i];
	int ans = 0;
	for(auto it : g[i])
	{
		ans = max(ans,1+go(it));
	}
	return dp[i] = ans;
}

main()
{ 
	SPEED;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n,m;
	cin >> n >> m; 
	for(int i = 1; i<=m; i++)
	{
		int u,v;
		cin >> u >> v;
		g[u].pb(v);
	}
	memset(dp,-1,sizeof(dp));
	int ans = 0;
	for(int i = 1; i<=n; i++)
	{
		ans = max(ans,go(i));
	}
	cout << ans << endl;
}

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

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)
#define rrep(i, a) RREP(i, a, 0)
#define RREP(i, a, b) for(int i = a; i >= b; --i)
#define repll(i, a) REPLL(i, 0, a)
#define REPLL(i, a, b) for(ll i = a; i < b; ++i)
#define rrepll(i, a) RREPLL(i, a, 0)
#define RREPLL(i, a, b) for(ll i = a; i >= b; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<int, P> PP;
const double PI = 3.14159265358979323846;
const double eps = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;

int n;
ll a[100001], sum[200001];

int main() {
	std::cin >> n;
	rep(i, n)std::cin >> a[i];

	REP(i, 1, 2 * n + 1)sum[i] = sum[i - 1] + a[(i - 1 >= n ? i - n - 1 : i - 1)];

	ll l = 0, r = infll;
	while (l <= r) {
		ll m = (l + r) / 2;

		bool flg = false;
		rep(i, n) {
			int be = i;
			rep(j, 3) {
				be = std::lower_bound(sum + i, sum + i + n + 1, m + sum[be]) - sum;
				if (be == i + n + 1)break;
			}
			if (be <= i + n) flg = true;
		}
		if (flg) l = m + 1;
		else r = m - 1;
	}

	std::cout << l - 1 << std::endl;

	return 0;
}

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

int main(){
  int n;
  cin>>n;
  int a=n;
  int b=1;
  int ans=0;
  for(int i=0;i<6;i++){
    if(a/10!=0) b++;
    else break;
    a/=10;
  }
  if(b==1) cout<<n<<endl;
  else{
    ans+=9;
    if(b>3) ans+=900;
    if(b>5) ans+=90000;
    if(b%5==3) ans+=n-100+1;
    else if(b%5==0) ans+=n-10000+1;
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 384
/*input
5
3 3 3 3 3
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
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> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=1e6+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=3.14159265358979323846;
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int32_t main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n;
    cin>>n;
    int pv=0;
    ll ans=0;
    REP(i,n){
        int x;
        cin>>x;
        ans+=max(pv-x,0);
        MXTO(x,pv);
        pv=x;
    }
    cout<<ans;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    ll n;
    cin >> n;
    ll capa[5];
    ll time[5];
    for (int i = 0; i < 5; i++) cin >> capa[i];
    capa[0] = min(capa[0], n);
    time[0] = (n + capa[0] - 1) / capa[0];
    for (int i = 1; i < 5; i++){
        capa[i] = min(capa[i], capa[i-1]);
        time[i] = (n + capa[i] - 1) / capa[i];
    }
    ll time_diff[5];
    time_diff[0] = 1;
    for (int i = 1; i < 5; i++){
        time_diff[i] = time[i] - (time[i-1] - 1);
    }
    ll ans = time[0];
    for (int i = 1; i < 5; i++){
        ans += time_diff[i];
    }
    cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int N;
int F[100][10];
int P[100][11];

int main() {
	cin >> N;
	REP(i, N) REP(j, 10) scanf("%d", &F[i][j]);
	REP(i, N) REP(j, 11) scanf("%d", &P[i][j]);
	
	int ans = -INF;
	FOR(s, 1, 1<<10) {
		int cur = 0;
		
		REP(i, N) {
			int cnt = 0;
			REP(j, 10) if ((s >> j & 1) && F[i][j]) cnt++;
			cur += P[i][cnt];
		}
		
		chmax(ans, cur);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int n,a,b;
  cin >> n >> a >> b;
  long long int x[n];
  for(int i = 0;i < n;i++)cin >> x[i];
  long long int ans = 0;
  for(int i = 1;i < n;i++){
    if((x[i]-x[i-1])*a < b)ans += (x[i]-x[i-1])*a;
    else ans += b;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
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 d = sc.nextInt();
    int sum = 0;
    if(a <= b){
      sum = sum + a;
    }else{
      sum = sum + b;
    }
    if(c <= d){
      sum = sum + c;
    }else{
      sum = sum + d;
    }
    System.out.println(sum);
  }
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

typedef long long LL;
typedef pair<int, int> P;
const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;

char A[101][101];

void solve()
{
    int H, W;
    cin >> H >> W;
    map<char, int> mp;

    REP0 (h, H)
    {
        REP0 (w, W)
        {
            char c;
            cin >> c;
            mp[c]++;
        }
    }

    if (H % 2 == 0 and W % 2 == 0)
    {
        for (auto p : mp)
        {
            if (p.second % 4 != 0)
            {
                std::cout << "No" << endl;
                return;
            }
        }
        std::cout << "Yes" << endl;
        return;
    }

    if (H % 2 and W % 2)
    {
        map<int, int> cnt;
        for (auto p : mp)
        {
            cnt[p.second % 4]++;
        }
        if (cnt[3] or cnt[1] != 1 or cnt[2] > (H - 1) / 2 + (W - 1) / 2)
        {
            std::cout << "No" << endl;
            return;
        }

        std::cout << "Yes" << endl;
        return;
    }

    // どちらかだけが奇数(Hであるとする)
    if (W % 2)
        swap(H, W);

    map<int, int> cnt;
    for (auto p : mp)
    {
        cnt[p.second % 4]++;
    }
    if (cnt[3] or cnt[1] or cnt[2] > W / 2)
    {
        std::cout << "No" << endl;
        return;
    }

    std::cout << "Yes" << endl;

    return;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


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

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

struct edge { int u, v; ll cost; };

const int INF = (int)2e+9;
int N;
vector<pi> X, Y;
vector<int> par;
vector<int> t_rank;
vector<edge> es;

void init_union_find(int n) {
	t_rank.resize(n, 0);
	par.resize(n);
	for (int i = 0; i < n; i++)
		par[i] = i;
}

int find(int x) {
	if (par[x] == x)
		return x;
	else
		return par[x] = find(par[x]);
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)
		return;
	if (t_rank[x] < t_rank[y])
		par[x] = y;
	else {
		par[y] = x;
		if (t_rank[x] == t_rank[y])
			t_rank[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}

bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}

ll kruskal(void) {
	ll res;
	sort(es.begin(), es.end(), comp);
	init_union_find(N);
	res = 0;
	for (int i = 0; i < (int)es.size(); ++i) {
		edge e = es[i];
		if (!same(e.u, e.v)) {
			unite(e.u, e.v);
			res += e.cost;
		}
	}
	return res;
}

int main(void) {
	cin >> N;

	X.resize(N);
	Y.resize(N);
	for (int i = 0; i < N; ++i) {
		int x, y;
		cin >> x >> y;
		X[i] = make_pair(x, i);
		Y[i] = make_pair(y, i);
	}

	sort(X.begin(), X.end());
	sort(Y.begin(), Y.end());
	for (int i = 1; i < N; ++i) {
		edge xe; xe.u = X[i - 1].second; xe.v = X[i].second; xe.cost = (ll)(X[i].first - X[i - 1].first);
		edge ye; ye.u = Y[i - 1].second; ye.v = Y[i].second; ye.cost = (ll)(Y[i].first - Y[i - 1].first);
		es.push_back(xe);
		es.push_back(ye);
	}

	ll ans = kruskal();
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 7792
N, M = map(int, input().split())
count = [0]*N
ans = 0
ok = 0
for _ in range(M):
    p, s = input().split()
    if count[int(p)-1] >= 0 and s == "WA":
        count[int(p) - 1] += 1
    elif count[int(p)-1] >= 0 and s == "AC":
        ans += count[int(p)-1]
        count[int(p)-1] = -1
        ok += 1
print(ok, ans)

Measured memory_bytes: 9528
#include <iostream>
#include <vector>


using namespace std;


using ll = long long;


void max_heapify(vector<ll> &A, ll i)
{
    ll li, ri, max_i;
    li = i * 2;
    ri = i * 2 + 1;
    max_i = i;

    if (li <= A.size() - 1 && A[i] < A[li]) {
        max_i = li;
    }

    if (ri <= A.size() - 1 && A[max_i] < A[ri]) {
        max_i = ri;
    }

    if (i != max_i) {
        ll t = A[max_i];
        A[max_i] = A[i];
        A[i] = t;

        max_heapify(A, max_i);
    }
}


void build_max_heap(vector<ll> &A)
{
    for (ll i = (A.size() - 1) / 2; i >= 1; i--) {
        max_heapify(A, i);
    }
}


int main()
{
    ll H;
    cin >> H;
    vector<ll> A(H + 1);
    for (ll i = 1; i <= H; i++)
        cin >> A[i];
    build_max_heap(A);
    for (ll i = 1; i <= H; i++) {
        cout << " " << A[i];
    }
    cout << endl;
}



Measured memory_bytes: 6728
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int S, W; cin >> S >> W;
    if (S <= W) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
    return 0;
}

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


int main(){
    while (1){
	vector<long long> inp;
	long n, k, input;
	cin >> n >> k;
	if (!(n || k)) break;

	for (long long i = 0; i < n; i++){
	    cin >> input;
	    inp.push_back(input);
	}
	
	int s, sum = 0;
	for (int i = 0; i < k; i++) sum += inp[i];
	s = sum;
	for (int i = 0; k < inp.size(); i++, k++){
	    s -= inp[i];
	    s += inp[k];
	    if (sum < s) sum = s;
	}
	cout << sum << endl;
    }
}

Measured memory_bytes: 2120
#include <bits/stdc++.h>
int N;
int a[100000 + 10];
using namespace std;
int main () {
  cin >> N;
  int ret = 0;
  for(int i = 0; i < N; ++i) {
    int x;
    cin >> x;
    if (x > N) ret++;
    else {
      a[x]++;
    }
  }

  for(int i = 0; i <= N; ++i) {
    if (a[i] < i) ret += a[i];
    else if (a[i] > i) ret += a[i] - i;
  }
  cout << ret << endl;
}

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

int main() {
    int a, b, c;
    bool ans = false;
    cin >> a >> b >> c;
    if (((a + b) == c) || ((a + c) == b) || ((b + c) == a)) {
        ans = true;
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n, t = li()
a = list(li())

mina = [0]*n
mina[0] = a[0]
maxprof = 0

for i in range(1, n):
    mina[i] = min(mina[i-1], a[i])

ans = 0
for i in range(n):
    if a[i] - mina[i] > maxprof:
        maxprof = a[i] - mina[i]
        ans = 1

    elif a[i] - mina[i] == maxprof:
        ans += 1

print(ans)

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

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

using namespace std;

int main(){
	int n,T[100]; cin>>n;
	double V[100];
	rep(i,n) cin>>T[i];
	rep(i,n) cin>>V[i];

	int t=0;
	double vl[40001],vr[40001];
	vl[0]=0;
	rep(i,n) rep(j,2*T[i]) {
		vl[t+1]=min(vl[t]+0.5,V[i]);
		t++;
	}
	vr[t]=0;
	for(int i=n-1;i>=0;i--) rep(j,2*T[i]) {
		vr[t-1]=min(vr[t]+0.5,V[i]);
		t--;
	}

	double ans=0;
	t=0;
	rep(i,n) rep(j,2*T[i]) {
		ans+=(min(vl[t],vr[t])+min(vl[t+1],vr[t+1]))/4;
		t++;
	}
	cout<<setprecision(9)<<ans<<endl;

	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (int i=0; i<n; i++){
    cin >> a[i];
  }
  map<ll, ll> mp;
  ll sum = 0;
  rep(i, n) {
    mp[a[i]]++;
    sum += a[i];
  }
  ll q;
  cin >> q;
  vector<ll> b(q);
  vector<ll> c(q);
  for (int i=0; i<q; i++){
    cin >> b[i];
    cin >> c[i];
    ll t = mp[b[i]];
    mp[b[i]] = 0;
    mp[c[i]] += t;
    sum += (c[i]-b[i])*t;
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 11352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
		int m = sc.nextInt();
		int f = sc.nextInt();
		int r = sc.nextInt();
		int p = m + f;
		
		if(m == -1 && f == -1)
				break;
		
		if(m == -1 || f == -1)
			System.out.println("F");
		else if(p >= 80)
			System.out.println("A");
		else if(p >= 65)
			System.out.println("B");
		else if(p >= 50)
			System.out.println("C");
		else if(p >= 30)
			if(r < 50)
				System.out.println("D");
			else
				System.out.println("C");
		else
			System.out.println("F");
		
		}
	}
}



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

constexpr int INF = 1e9;

int main() {
    int n, m;
    vector<int> a(3);
    cin >> n >> m >> a[0] >> a[1] >> a[2];
    vector<vector<int>> g(n);
    for(int i=0; i<m; ++i) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
    }
    vector<vector<vector<int>>> to(n, vector<vector<int>>(3));
    for(int v = 0; v < n; ++v) {
        vector<vector<bool>> visited(101, vector<bool>(n));
        visited[0][v] = true;
        for(int i = 0; i < 100; ++i) {
            for(int j = 0; j < n; ++j) {
                if(visited[i][j]) {
                    for(auto t : g[j]) {
                        visited[i+1][t] = true;
                    }
                }
            }
        }
        for(int i = 0; i < 3; ++i) {
            for(int j = 0; j < n; ++j) {
                if(visited[a[i]][j]) {
                    to[v][i].push_back(j);
                }
            }
        }
    }
    vector<int> d(n, INF);
    d[n-1] = 0;
    while(true) {
        bool update = false;
        for(int v = 0; v < n; ++v) {
            vector<int> mi(3, INF);
            for(int j = 0; j < 3; ++j) {
                for(auto t : to[v][j]) {
                    mi[j] = min(mi[j], d[t]);
                }
            }
            int ma = *max_element(mi.begin(), mi.end()) + 1;
            if(ma < d[v]) {
                update = true;
                d[v] = ma;
            }
        }
        if(!update) {
            break;
        }
    }

    if(d[0] == INF) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << d[0] << endl;
    }
}


Measured memory_bytes: 3180
n=int(input())
H=list(map(int,input().split()))
dp=[10**9]*(n)
dp[0]=0
for i in range(n):
    if i==1:
        dp[i]=min(dp[i],dp[i-1]+abs(H[i]-H[i-1]))
    elif i>1:
        dp[i]=min(dp[i],dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]))

print(dp[-1])  

Measured memory_bytes: 13976
#!/usr/bin/perl
#abc081_a.pl
#Thu Feb  8 23:24:03 2018
#

use warnings;
use strict;

my $temp = <STDIN>;
chomp $temp;

my @temps = split("",$temp);
my $ans = 0;


foreach (@temps){
	if ($_==1){
		$ans++;
	}
}

print $ans,"\n";

Measured memory_bytes: 640
import math
import sys

def gcd(a,b):
	if b == 0:
		return a
	return gcd(b,a%b)


n,m = map(int, input().split())
s = input()
t = input()

if s[0] != t[0]:
	print(-1)
	sys.exit()

GCD = gcd(n,m)

if GCD == 1:
	print(n*m)
	sys.exit()

LCM = n*m//GCD


s_k = LCM//m
t_k = LCM//n
for i in range(GCD):
	if s[i*s_k] != t[i*t_k]:
		print(-1)
		sys.exit()

print(LCM)

Measured memory_bytes: 3316