akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s,t;
	cin>>s>>t;
	ll ans=0;
	for(ll i=0;i<s.size();i++){
		if(s[i]!=t[i]) ans++;
	}
	cout<<ans;
	
	
	return 0;
}

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

int main () {
  int n, r;
  while(true){
    cin >> n >> r;
    if(n == 0 && r == 0) break;
    else{
      stack <int> l1, l2, l3;
      while(!l1.empty()) l1.pop();
      int p, c;
      for(int j = 0;j < n; j++) {
        l1.push(j + 1);
      }
      for(int i = 0; i < r; i++) {
        cin >> p >> c;
        for(int j = 0;j < p - 1; j++) {
          l2.push(l1.top());
          l1.pop();
        }
        for(int j = 0;j < c; j++) {
          l3.push(l1.top());
          l1.pop();
        }
        for(int j = 0;j < p - 1; j++) {
          l1.push(l2.top());
          l2.pop();
        }
        for(int j = 0;j < c; j++) {
          l1.push(l3.top());
          l3.pop();
        }
      }
      cout << l1.top() << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3068
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int count = scanner.nextInt();
			scanner.nextLine();
			String string = scanner.nextLine();
			if (string.chars().filter(x -> x == 'R').count() > count / 2) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}

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

using namespace std;

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

int M, T, P, R;
vector<vector<int>> v;

bool init() {
	cin >> M >> T >> P >> R;
	v.clear();
	v.resize(T, vector<int>(P, 0));
	return M != 0;
}

bool check(int a, int b, int c, int d) {
	int A = a * a + b * b;
	int B = c * c + d * d;
	if (A != B) return A < B;
	return a < c;
}

struct score {
	int x;
	int s;
	int t;
};

void solve() {
	vector<score> S(T);
	rep(i, T) S[i].x = i+1;
	rep(i, R) {
		int m, t, p, j;
		cin >> m >> t >> p >> j;
		if (j) {
			v[t-1][p-1] += 20;
		} else { // AC
			S[t-1].s++;
			S[t-1].t += m + v[t-1][p-1];
		}
	}
	sort(S.rbegin(), S.rend(), [](auto a, auto b) {
		return a.s == b.s ? 
				a.t == b.t ? a.x < b.x :
				a.t > b.t : a.s < b.s;
	});
	cout << S[0].x;
	reps(i, 1, T) {
		if (S[i-1].s == S[i].s && S[i-1].t == S[i].t) cout << "=";
		else cout << ",";
		cout << S[i].x;
	}
	cout << endl;
}

int main() {
	while (init()) {
		solve();
	}
}


Measured memory_bytes: 3072
#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 PB push_back
#ifdef LOCAL
	#define DEBUG(...) printf(__VA_ARGS__)
#else
	#define DEBUG(...)
#endif

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

int n, m; ll x;
vector<pli> *road;
ll *h;

int main(){
	scanf("%d%d%lld", &n, &m, &x);
	h = new ll[n]; REP(i, n) scanf("%lld", h+i);
	road = new vector<pli>[n];
	REP(i, m){
		ll a, b, t; scanf("%lld%lld%lld", &a, &b, &t); a--; b--;
		road[a].PB(pli(t, b));
		road[b].PB(pli(t, a));
	}

	const ll INF = LLONG_MAX/2;
	bool close[n]; REP(i, n) close[i]=false;
	priority_queue<pli, vector<pli>, greater<pli>> que;
	ll dist[n]; REP(i, n) dist[i]=INF;
	dist[0]=0;
	que.push(pli(0, 0));

	while(!close[n-1] && que.size()){
		pli pr = que.top(); que.pop();
		int node = pr.second;
		if(close[node]) continue;
		ll here = pr.first;
		close[node]=true;
		DEBUG("node=%d, here=%lld\n", node, here);
		for(auto it = road[node].begin();
				it != road[node].end();
				it++){
			int dest = it->second;
			DEBUG(" dest=%d\n", dest);
			if(close[dest]) continue;
			ll dis = it->first;
			DEBUG(" dis=%lld\n", dis);
			if(h[node]<dis) continue;
			ll hei = x-here; if(hei<0) hei=0;
			DEBUG(" hei=%lld\n", hei);
			ll newdist;
			if(hei<dis){
				newdist = here+dis*2-hei;
			}else if(hei-dis>h[dest]){
				newdist = x-h[dest];
			}else{
				newdist = here+dis;
			}
			DEBUG(" newdist=%lld\n", newdist);
			if(newdist<dist[dest]){
				dist[dest]=newdist;
				que.push(pli(newdist, dest));
			}
		}
	}

	if(dist[n-1]==INF){
		printf("-1\n");
	}else{
		ll here = dist[n-1];
		ll hei = x-here; if(hei<0) hei=0;
		ll ans = here+h[n-1]-hei;
		printf("%lld\n", ans);
	}
}

Measured memory_bytes: 23196
maisuu, goukei = gets.chomp.split(' ').map(&:to_i)
0.upto(maisuu) do |i|
  0.upto(maisuu) do |j|
    k = (maisuu-i-j)
    break if (k < 0)
    if ((10000*i) + (5000*j) + (1000*k) == goukei)
      puts "#{i} #{j} #{k}"
      exit
    end
  end
end
puts "-1 -1 -1"

Measured memory_bytes: 1788
($n,$l) =split/ /,<>;
$sum=0;
for($i=0;$i<$n;$i++){
	$aji=$i+$l;
	push @ary,$aji;
    $sum+=$aji;
}
if($l>=0){
	print $sum-$l;
}elsif($n > abs($l)){
	print $sum;
}else{
	print $sum-$aji;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
sx, sy, tx, ty = map(int, input().split())
x, y = tx - sx, ty - sy
print("R"*x + "U"*-~y + "L"*-~x + "D"*-~y + "R" + "U"*y + "R"*-~x + "D"*-~y + "L"*-~x + "U")

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

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int n; scanf("%d", &n);
	long long T, A; scanf("%lld%lld", &T, &A);
	for (int i = 1; i < n; ++i) {
		long long t, a; scanf("%lld%lld", &t, &a);
		long long lo = 0, hi = 1e18+1;
		while (lo+1 < hi) {
			long long mid = lo+(hi-lo)/2;
			long long tm = t*mid, am = a*mid;
			if ((tm >= T && am >= A) || (tm/t != mid || am/a != mid)) hi = mid;
			else lo = mid;
		}
		T = t*hi; A = a*hi;
	}
	printf("%lld", T+A);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

int main()
{
    int H, W;
    cin >> H >> W;

    int M[H][W];
    rep(i, H)
    {
        rep(j, W)
        {
            M[i][j] = 0;
        }
    }
    char S[H][W];

    rep(i, H)
    {
        rep(j, W)
        {
            cin >> S[i][j];
            if (S[i][j] == '#')
            {
                rep_s(_i, i - 1, i + 2)
                {
                    rep_s(_j, j - 1, j + 2)
                    {
                        if ((_i >= 0 && _j >= 0) && (_i < H && _j < W))
                        {
                            M[_i][_j]++;
                        }
                    }
                }
            }
        }
    }

    rep(i, H)
    {
        rep(j, W)
        {
            if (S[i][j] == '#')
            {
                cout << '#';
            }
            else
            {
                cout << M[i][j];
            }
        }

        cout << endl;
    }
}


Measured memory_bytes: 256
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
#define F first
#define S second
#define pb push_back
using namespace std;
using ll = long long;
const ll maxn=2e5+5,inf=1e18+18;
ll n,a[maxn],k;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(i>=k){
			if(a[i]>a[i-k])cout<<"Yes"<<endl;
			else cout<<"No"<<endl;
		}
	}
}


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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    int h,w,k;
    cin>>h>>w>>k;
    vector<string> s(h);
    vector<int> H(h),W(w);
    rep(i,h) cin>>s[i];
    int ans=0;
    rep(is,1<<h)rep(js,1<<w){
        int cnt=0;
        rep(i,h)rep(j,w){
            if(is>>i&1) continue;
            if(js>>j&1) continue;
            if(s[i][j]=='#') cnt++;
        }
        if(cnt==k) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3 2");
            WillReturn.Add("2 1");
            //1
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("5 5");
            WillReturn.Add("2 3");
            //6
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("2 4");
            WillReturn.Add("2 4");
            //0
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = InputList[0].Split(' ').Select(X => int.Parse(X)).ToArray();
        int H = wkArr[0];
        int W = wkArr[1];

        wkArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();
        int h = wkArr[0];
        int w = wkArr[1];

        Console.WriteLine((H - h) * (W - w));
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,x,ans;
    cin>>a>>b>>x;
    if(a%x==0)
        ans=b/x-a/x+1;
    else
        ans=b/x-a/x;
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
  int n;
  cin >> n;
  vector<string> s(n);
  REP(i, n)
  cin >> s[i];
  
  int l;
  
  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());
  
  l = s.size();
  printf("%d", l);
}

int main()
{
  std::cout << std::fixed << std::setprecision(15);
  Main();
}

Measured memory_bytes: 9604
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

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

    int n;
    cin >> n;
    map<string, int> c;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        c[s]++;
    }

    int cmax = 0;
    for (auto p : c) {
        cmax = max(cmax, p.second);
    }

    vector<string> ans;
    for (auto p : c) {
        if (p.second == cmax) {
            ans.push_back(p.first);
        }
    }
    sort(ans.begin(), ans.end());

    for (string s : ans) {
        cout << s << endl;
    }

    return 0;
}


Measured memory_bytes: 25584
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>

using namespace std;

class SSSPath
{
public:
  vector<int> v;
  int solve();
};

int SSSPath::solve()
{
  int n;
  cin >> n;

  const int infty = 200000;
  vector<int> d( n, infty );
  
  d[0] = 0;

  vector<vector<int>> adj( n, vector<int>( n, -1 ) );


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

  vector<int> sv( n, true );

  while ( true )
    {
      int md = infty;
      int u;
      
      for ( auto i = 0; i < n; ++i )
        {
          if ( sv[i] && d[i] < md )
            {
              u = i;
              md = d[i];
            }
        }

      if ( md == infty ) break;

      sv[u] = false;
      
      for ( auto i = 0; i < n; ++i )
        {
          if ( sv[i] && adj[u][i] >= 0 )
            {
              if ( d[u] + adj[u][i] < d[i] )
                {
                  d[i] = d[u] + adj[u][i];
                  
                }
            }
          
        }
    }

  for ( auto i = 0; i < n; ++i )
    {
      cout << i << " " << d[i] << endl;
    }
  
  return 0;
}

int main()
{
  SSSPath s;

  s.solve();

  return 0;
}

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
const long long mod = 1000000007;
typedef long long ll;

int n,h;
string s,t;

int main() {
  cin >> n >> s;
  map<char,ll> m;
  for(char c='a'; c<='z'; c++) m[c]=count(all(s),c);
  ll ans=1;
  for(auto p : m) ans=ans*(p.second+1)%mod;
  cout << ans-1 << endl;
}

Measured memory_bytes: 512
#define Oo ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#include <bits/stdc++.h>
using namespace std;
#define PI acos(-1.0)
#define int long long
typedef long long ll;
string s;
string e="dreameraser";
string f="dreamerase";
string a="dream", b="dreamer", c="erase", d="eraser";
int jud(int i, string ss)
{
      for (int j=0; j<ss.size();j++)
      {
            if (j+i>=s.size())return 0;
            if (s[i+j]!=ss[j])return 0;
      }return 1;
}
signed main()
{
      Oo

      cin>>s;
      int flag=1;
      for (int i=0; i<s.size(); i++)
      {
            if (jud(i, e))
            {
                  i+=e.size()-1;
                  continue;
            }
            else if (jud(i, f))
            {
                  i+=f.size()-1;
                  continue;
            }
            else if (jud(i, b))
            {
                  i+=b.size()-1;
                  continue;
            }
            else if (jud(i, d))
            {
                  i+=d.size()-1;
                  continue;
            }
            else if (jud(i, a))
            {
                  i+=a.size()-1;
                  continue;
            }
             else if (jud(i, c))
            {
                  i+=c.size()-1;
                  continue;
            }
            flag=0;
            break;
      }
      if (flag==1)cout << "YES" << endl;
      else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 3716
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next(),b= sc.next();
        int c = Integer.parseInt(a+b);
        String ans = "No";
        for(int i = 1;i*i<=c;i++){
            if(i*i==c){
                ans = "Yes";
            } else {
                ans = "No";
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
 
int main(void)
{
    int i;
    int ca = 1;
 
    while(1){
        scanf("%d", &i);
 
        if(i != 0) {
            printf("Case %d: %d\n", ca, i);
            ca++;
        }
        else{
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 600
makeA = lambda c: (ord('z')-ord(c)+1) % 26
s = list(map(makeA,list(input())))
#print(s)
K = int(input())
len_s = len(s)
#print(len_s)
for i in range(len_s-1):
    if s[i] <= K:
        K -= s[i]
        s[i] = 0
        #print(s)
if K > 0:
    s[-1] = (s[-1] + 26 - (K % 26)) % 26
#print(s)
makeS = lambda n: chr((26-n)%26+ord('a'))
print(''.join(list(map(makeS,s))))



Measured memory_bytes: 4836
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[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() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;


fn main() {
    input!{n:i32,k:i32,x:i32,y:i32};
    println!("{}", min(n,k)*x+max(0,(n-k)*y));
}

Measured memory_bytes: 4352
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	ll k;
	cin>>k;
	vector<string> vec;
	REP(i,(ll)s.size()) {
		FOR(j,i,(ll)s.size()) {
			if(j-i+1>k) break;
			vec.pb(s.substr(i,j-i+1));
		}
	}
	sort(ALL(vec));
	vec.erase(unique(ALL(vec)),vec.end());
	cout<<vec[k-1]<<endl;
}


Measured memory_bytes: 1660
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
bool x[110];
bool y[110];
int main()
{
    int n;
    char s[110];
    cin>>n;
    cin>>s;
    int ans,coust;
    ans=0;
    for(int i=0;i<n;i++)
    {
        coust=0;
        x[s[i]-'a']=true;
        memset(y,false,sizeof(y));
        for(int j=i+1;j<n;j++)
        {
            y[s[j]-'a']=true;
        }
        for(int j=0;j<26;j++)
        {
            if(x[j]==true&&y[j]==true)
                coust++;
        }
        if(coust>ans)
        {
            ans=coust;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    ll Q,H,S,D,N;
    cin >> Q >> H >> S >> D >> N;
    chmin(H,2*Q);
    chmin(S,2*H);
    cout << min(N*S,N/2*D+(N%2)*S) << endl;
    


}

/*



 */



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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define VECCIN(x)            \
	for (auto &youso_ : (x)) \
	cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long>
inline T IN()
{
	T x;
	cin >> x;
	return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail)
{
	cin >> head;
	CIN(move(tail)...);
}
#define CINT(...)    \
	int __VA_ARGS__; \
	CIN(__VA_ARGS__)
#define LCIN(...)   \
	ll __VA_ARGS__; \
	CIN(__VA_ARGS__)
#define SCIN(...)       \
	string __VA_ARGS__; \
	CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int N, K;
string S;

int main()
{
	cin >> N >> S >> K;
	K--;
	string s;
	REP(i, N)
	{
		if (S[i] == S[K])
		{
			s += S[K];
		}
		else
		{
			s += "*";
		}
	}
	cout << s << "\n";
	return 0;
}

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

int conv(char c);

int main(void){
	int i,l,ans,f,s,t;
	char a,b,c[100];
	
	while(scanf("%s",c)!=EOF){
		ans=0;
		f=0;
		
		for(i=1;i<(int)strlen(c);i++){
			a=c[i-1];
			b=c[i];
			
			s=conv(a);
			t=conv(b);
			
			if(s<t){
				ans+=t-s;
				i+=1;
			}
			else ans+=s;
			
			if(i==(int)strlen(c)-1){
				ans+=conv(c[strlen(c)-1]);
			}
		}
		
		if((int)strlen(c)==1)ans=conv(c[0]);
		
		printf("%d\n",ans);
		
	}
	
	return 0;
}

int conv(char c){
	if(c=='I')return 1;
	if(c=='V')return 5;
	if(c=='X')return 10;
	if(c=='L')return 50;
	if(c=='C')return 100;
	if(c=='D')return 500;
	if(c=='M')return 1000;
}

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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

int n, m;
int pref[303][303];

int ptr[303];
int freq[303];

queue<int> Q;

bool die[303];

void incre(int j, int c){
//	printf(" ++%d\n", j);
	freq[j]++;
	if(freq[j] == c + 1){
//		printf("c = %d, die %d\n", c, j);
		die[j] = true;
		Q.push(j);
	}
}

bool possible(int c){
	// can choose with <= c ppl per event?
	memset(freq, 0, sizeof(freq));
	
	while(!Q.empty()){
		Q.pop();
	}
	
	for(int j = 1; j <= m; j++){
		die[j] = false;
	}
	
	for(int i = 1; i <= n; i++){
		ptr[i] = 1;
		incre(pref[i][1], c);
	}
	
	while(!Q.empty()){
		int del = Q.front();
		Q.pop();
		for(int i = 1; i <= n; i++){
			while(ptr[i] <= m && die[pref[i][ptr[i]]]){
				ptr[i]++;
				incre(pref[i][ptr[i]], c);
			}
		}
	}
	
	for(int j = 1; j <= m; j++){
		if(!die[j]){
			return true;
		}
	}
	return false;
}

int main(){
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			scanf("%d", &pref[i][j]);
		}
	}
	int l = 0, r = n;
	while(r - l > 1){
		int mid = (l + r) >> 1;
		if(possible(mid)){
			r = mid;
		}else{
			l = mid;
		}
	}
	printf("%d\n", r);
	return 0;
}

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

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

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

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

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    string s,t; cin>>s>>t;
    rep(i,n){
        cout<<s[i]<<t[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
pub 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()
}

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

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let mut a: Vec<Vec<u32>> = read_vec2(3);
    let n: usize = read();

    for _ in 0..n {
        let b: u32 = read();
        for i in 0..3 {
            for j in 0..3 {
                if a[i][j] == b {
                    a[i][j] = 0;
                }
            }
        }
    }

    if a[0][0] == 0 && a[0][1] == 0 && a[0][2] == 0
        || a[1][0] == 0 && a[1][1] == 0 && a[1][2] == 0
        || a[2][0] == 0 && a[2][1] == 0 && a[2][2] == 0
        || a[0][0] == 0 && a[1][0] == 0 && a[2][0] == 0
        || a[0][1] == 0 && a[1][1] == 0 && a[2][1] == 0
        || a[0][2] == 0 && a[1][2] == 0 && a[2][2] == 0
        || a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0
        || a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0
    {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int MAXN = 5005;
const int MOD = 1000000007;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define fst first
#define snd second
#define UP(v,x) (upper_bound(v.begin(),v.end(),(x))-v.begin())
#define LOW(v,x) (lower_bound(v.begin(),v.end(),(x))-v.begin())

int N,M;
string S,T;
int d,x,y;

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

    cin>>N>>M;
    cin>>S>>T;
    d=__gcd(N,M);
    x=N/d; y=M/d;
    FOR(i,0,d-1){
        if (S[i*x]!=T[i*y]){
            cout<<"-1\n";
            return 0;
        }
    }
    cout<<(ll)x*y*d<<"\n";
    /*
    FOR(i,0,x*y*d-1){
        if (i%y==0)cout<<S[i/y];
        else if (i%x==0)cout<<T[i/x];
        else cout<<'z';
    }
    cout<<"\n";
    */
}
/*
5 5 6 6
.....
...#.
.#...
..#..
.....
1 1
4 2
3 3
2 5
1 2
1 3
1 2
2 4
1 3
3 4
1 5
1 6

156..
..##4
.#3..
.2#..
.....
1 2
2 4
1 3
3 4
1 5
1 6

5 5 6 6
.....
..##.
.#...
..#..
.....
1 1
4 2
3 3
2 5
1 2
1 3
1 2
2 4
1 3
3 4
1 5
1 6

5 5 4 4
.....
..##.
.#...
..#..
.....
1 1
4 2
3 3
2 5
1 2
2 4
1 3
3 4
Ans:
3
4
4
2


5 5 3 2
...#.
..#..
#....
.##..
...#.
1 3
5 2
1 5
1 2
1 3
Ans:
-1
7
*/

Measured memory_bytes: 640
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long int64;
map<int, int> P;
map<int, int> M;

int main() {
	//memset(P, 0, sizeof(P));
	//memset(P, 0, sizeof(M));
	int N;
	cin >> N;
	int tmp;
	int64 ans = 0;
	for (int i = 0; i < N; ++i) {
		cin >> tmp;
		if (i+tmp < 200000) ++P[i+tmp];
		if (i-tmp > 0) ++M[i-tmp];
	}
	for (int i = 1; i < N; ++i) {
		ans += (int64)P[i] * M[i];
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 22432
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll> 
#define pic pair<ll,char>
#define vi vector< ll > 
#define vvi vector< vi > 
#define vpi vector< pii > 
#define vvpi vector< vpi > 
#define st  set <ll, greater <ll> >
#define mst  multiset <ll, greater <ll> >
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mapp  unordered_map <ll, ll>
#define ppii pair< pii, pii > 
#define test(t) ll t;cin>>t;while(t--)
#define inarr(n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i];
#define ingra(m) vvi arr(100005);for(ll i=0;i<m;i++){ll u,v;cin>>u>>v;arr[u].pb(v);arr[v].pb(u);}
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
pair < ll , pair < ll , ll > > arr[1000];
ll dp[1000][10001];
ll n;
bool cmp(pair < ll , pair < ll ,ll > > a,pair < ll , pair < ll ,ll > > b)
{
    if(a.fi+a.sec.fi<b.fi+b.sec.fi)
        return true;
    return false;
}
ll func(ll index,ll done)
{
    if(done>1e4)
        return 0;
    if(index==n)
        return 0;
    ll &ret = dp[index][done];
    if(ret!=-1)
        return ret;
    ret = 0;
    if(done<=arr[index].fi)
        ret = arr[index].sec.sec+func(index+1,done+arr[index].sec.fi);
    ret = max(ret,func(index+1,done));
    return ret;
}
signed main()
{
    fast;
    mem(dp,-1);
    cin>>n;
    ll i;
    for(i=0;i<n;i++)
        cin>>arr[i].sec.fi>>arr[i].fi>>arr[i].sec.sec;
    sort(arr,arr+n,cmp);
    cout<<func(0,0);
}

Measured memory_bytes: 78464
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define MAX_N 200005
#define LL long long
int n;
LL va[MAX_N];
LL num[MAX_N];
LL ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>va[i];
	for(int i=1;i<=n;i++)num[va[i]]++;
	for(int i=1;i<=n;i++)if(num[i])ans+= num[i]*(num[i]-1)/2;
	for(int i=1;i<=n;i++)
		printf("%lld\n",ans- num[va[i]]+1);
}


Measured memory_bytes: 4736
#include<stdio.h> 
short f[100];short ans=0;short n;int main(){while(scanf("%d",&n)!=EOF){f[n-1]++;if(f[ans]<f[n-1])ans=n-1;}for(n=0;n<100;n++)if(f[n]==f[ans])printf("%d\n",n+1);}

Measured memory_bytes: 1024
def li():
    return list(map(int, input().split()))


def mi():
    return map(int, input().split())


def ii():
    return int(input())


N = ii()
d = li()

d.sort()

mean = d[len(d) // 2]

res = 0
if d[len(d) // 2 - 1] < mean:
    res = mean - d[len(d) // 2 - 1]
print(res)


Measured memory_bytes: 14428
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    vector<int> adj[100100];
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    int ans = 0;
    rep(i, n) {
        bool good = true;
        for (int t : adj[i]){
            if(h[t] >= h[i]){
                good = false;
                break;
            }
        }
        if(good){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 8804
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	double density=0;
	int t=0,s=0;
	for(int i=0;i<=50;++i)
		for(int j=0;j<=50;++j)
			for(int k=0;k<=50;++k)
				for(int g=0;g<=50;++g){
					int water=i*a+j*b;
					int sugar=k*c+g*d;
					int req=sugar/e+(sugar%e!=0);
					if(water>=req&&100*water+sugar<=f){
						double cur_dense=100.0*sugar/(water*1.0+sugar*1.0);
						if(cur_dense>=density){
							density=cur_dense;
							t=100*water+sugar;
							s=sugar;
						}
					}
				}
	cout<<t<<' '<<s<<'\n';
}



Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long int ll;
int main()
{
	ll a,b,c;
	cin >> a >> b >> c;

	ll ans=0;
	if(c>=b){
		ans += 2*b;
		c -= b;
		ans += min(a+1,c);
	}else{
		ans += b+c;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
	
	char str1[200],str2[200],judgement[3][10]={"IDENTICAL","CLOSE","DIFFERENT"};
	int count1,count2,flag1,flag2,judge;

	for(;;){

		judge=0;
		
		count1=0;
		count2=0;

		scanf("%s",str1);
		if(str1[0]=='.')break;
		scanf("%s",str2);

		for(;;){

			if(str1[count1]!=str2[count2])judge=2;

			if(str1[count1]=='\0' || str2[count2]=='\0')break;

//printf("aa");

			if(str1[count1]=='"'){///””の中

				count1++;
				count2++;
				flag1=0;
				flag2=0;

				for(;;){
					if(str1[count1]!=str2[count2]){
						if(judge==1){
							judge=2;
							break;
						}
						judge=1;
						break;
					}

					if(str1[count1]=='"')flag1=1;
					if(str2[count2]=='"')flag2=1;
					if(flag1+flag2>=1)break;
				
					count1++;
					count2++;

				}
				if(flag1==0)for(;str1[count1]!='"';count1++);
				if(flag2==0)for(;str2[count2]!='"';count2++);
			}

		if(judge==2)break;

		count1++;
		count2++;
		}

		printf("%s\n",judgement[judge]);
	}



	return 0;
}


Measured memory_bytes: 2044
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
using namespace std;
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define ipair pair<int,int>
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;
int main() {
	int a=0, b=0;
	TFOR(i, 4) {
		int n;
		cin >> n;
		a += n;
	}
	TFOR(i, 4) {
		int n; cin >> n;
		b += n;
	}
	cout << max(a, b) << endl;
	return 0;
}

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

using namespace std;
vector<int> vc;

int binary_search(int key)
{
    int left = 0, right = (int)vc.size() - 1; // 配列 a の左端と右端
    while (right >= left)
    {
        int mid = left + (right - left) / 2; // 区間の真ん中
        if (vc[mid] == key)
            return mid;
        else if (vc[mid] > key)
            right = mid - 1;
        else if (vc[mid] < key)
            left = mid + 1;
    }
    return -1;
}

int main()
{

    int N, Q, s, t;
    int count = 0;
    cin >> N;

    for (int i = 0; i < N; i++)
    {
        cin >> s;
        vc.push_back(s);
    }

    sort(vc.begin(), vc.end());
    unique(vc.begin(), vc.end());

    cin >> Q;
    for (int i = 0; i < Q; i++)
    {
        cin >> t;
        if (binary_search(t) != -1){
            count++;
        }
    }

    cout << count << '\n';

    return 0;
}


Measured memory_bytes: 3156
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>
#include <bits/stdc++.h>
#include <queue>

using namespace std;
// for loop
#define F(i, L, R) for(long i = L; i < R; i++)
#define FE(i, L, R) for(long i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(long i = L; i > R; i--)
#define FRE(i, L, R) for(long i = L; i >= R; i--)

// data types
#define Int long
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

void printM(vector<vector<long> > &vec, long height, long width){
    F(i, 0, height){
        F(j, 0, width){
            cout << vec[i][j] << space;
        }
        cout << endl;
    }
}

#define TST 0
int main() {
#if TST==1
    ifstream in ("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    map<string, bool> dict;
    long n;
    cin >> n;
    string ope;
    string operand;
    F(i, 0, n){
        cin >> ope >> operand;
        if(ope == "insert"){
            dict[operand] = true;
        }else{
            map<string,bool>::iterator iter = dict.find(operand);
            if(iter == dict.end()){
                cout << "no" << endl;
            }else{
                cout << "yes" << endl;
            }
        }
    }

#if TST==1

#endif
}



Measured memory_bytes: 36884
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  vector<int>C(N-1),S(N-1),F(N-1);
  for(int i=0;i<N-1;i++){
    cin>>C[i]>>S[i]>>F[i];
  }
  for(int i=0;i<N-1;i++){
    int sum=S[i]+C[i];
    for(int j=i+1;j<N-1;j++){
      if(sum<=S[j]){sum+=(S[j]-sum);}
      else if(sum%F[j]!=0){sum+=(F[j]-sum%F[j]);}
      sum+=C[j];
    }
    cout<<sum<<endl;
  }
  cout<<0<<endl;
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
string s,t;
cin >> s >> t;
if(s == t){
    cout << "Yes" << endl;
    return 0;
}
for(ll i =0; i < s.size(); i++){
    char k = s.back();
    s.pop_back();
    s = k + s;
    if(s == t){
        cout << "Yes" << endl;
        return 0;
    }
}
cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    
    vector<int> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    
    int before = 0;
    int ans = 1;
    for(int i = 0; i < n; i++) {
        int now = before + v[i];
        before = now;
        if(now <= x) {
            ans++;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        String S = scan.nextLine();
        String T = scan.nextLine();
        char[] yohou = S.toCharArray();
        char[] tenki = T.toCharArray();
        int ans=0;
        for(int i=0;i<3;i++) {
            if(yohou[i]==tenki[i]){
                ans++;
            }
        }
        System.out.println(ans);
    }
}


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

int main()
{
    long long int row , col ;
    cin>>row>>col;
    if(row%2==0)
        cout<<(row*col)/2;
    else if(col==1ll || row==1ll)
        cout<<"1";
    else
        cout<<((row-1ll)*col)/2ll+(col/2ll)+(col%2ll!=0ll);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100000

/*
How to test
% diff <(./a.out < b1in.txt) <(cat b1out.txt) 

  for( i=0 ; i < n ; i++){
    fprintf(stderr, "%d: C2[%d] = %c%c \n" ,__LINE__ ,i ,C2[i].suit ,C2[i].value );
  }

 */
void swap(short *a_p, short *b_p){
  int k;
  k    = *a_p;
  *a_p = *b_p;
  *b_p = k;
}


int prt(short* a_p, int p, int r ){
  int j;
  short x = a_p[r];
  int i = p-1;

  for( j = p ; j <= (r-1) ; j++){
    if(a_p[j]<=x){
      i++;
      swap(&a_p[i] ,&a_p[j]);
    }
  } 
  swap(&a_p[i+1] ,&a_p[r]);
  
  return i+1;
}

int main(){
  int n, i, j, k;
  int q;
  short x;
  short a[N];
  short a2[N][2] = {0};
  
  scanf("%d", &n);
  for ( i = 0; i <= n; i++ ) scanf("%d", &a[i]);

  x = a[n-1];
  q = prt(a,0,n-1);  

  for( i=(n-1) ; i>=0 ; i--){
    a2[i][0] = a[i];
    if(a[i]==x){
      a2[i][1] = 1; // piviot
      x = -1;
    }
  }


  for( i=0 ; i<n ; i++){
    if( a2[i][1] != 1){
      printf("%d" ,a2[i][0]);
    } else {
      printf("[%d]" ,a2[i][0]);
    }
    if( i != (n-1)){
      printf(" ");// Don't print more than enough space
    }
  }
  printf("\n");

  return 0; // Don't forget return 0
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define inf 1e16
int n,m,q;
int s[111111],t[111111];
signed main(){
	cin>>n>>m>>q;
	rep(i,n)cin>>s[i];
	rep(i,m)cin>>t[i];
	rep(i,q){
		int x,a,b,c,d,ans=inf;
		cin>>x;
		if(x<s[0])a=inf;
		else a=*(upper_bound(s,s+n,x)-1);
		if(x<t[0])b=inf;
		else b=*(upper_bound(t,t+m,x)-1);
		if(x>s[n-1])c=inf;
		else c=*lower_bound(s,s+n,x);
		if(x>t[m-1])d=inf;
		else d=*lower_bound(t,t+m,x);
		a=abs(a-x);
		b=abs(b-x);
		c=abs(c-x);
		d=abs(d-x);
		ans=min({max(a,b),max(c,d),min(d,a)+a+d,min(b,c)+b+c});
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    lint price = 700;
    for (const char c : S) {
        price += (c == 'o' ? 100 : 0);
    }
    cout << price << "\n";
}

Measured memory_bytes: 256
from heapq import heapify, heappop, heappush

N = int(input())
V = list(map(int, input().split()))

heapify(V)

while len(V)>1:
    x = heappop(V)
    y = heappop(V)
    heappush(V, (x+y)/2.0)

print(heappop(V))

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	long long s;
	int a[12]={0};
	cin>>s;
	int n=0;
	for(int i=0;;i++)
	{
		a[i]=s%10;
		n++;
		s/=10;
		if(s==0)break;
	}
	int m=1e4;
	for(int i=n-1;i>1;i--)
	{
		m=min(m,abs(a[i]*100+a[i-1]*10+a[i-2]-753));
	}
	cout<<" "<<m<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const long long MOD = 998244353;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
constexpr auto PI = 3.14159265358979323846264338327950L;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    ll a, ans = 1;
    cin >> N;
    bool flag = false;
    for (int i = 0; i < N; ++i) {
        cin >> a;
        ans *= a;
        if (a == 0) {
            cout << 0 << endl;
            return 0;
        }
        if (ans > 1000000000000000000)flag = true;
    }
    if (flag == false && ans > 0 && ans <= 1000000000000000000) {
        cout << ans << endl;
    }
    else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3656