akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const ll MAX = 10000;
static const ll INFTY = 1e12;

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 dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
using P = pair<ll, ll>;
// 入力
// 入力
ll h, w;
ll startX, startY, endX, endY;
vector<vector<char>> s;
vector<vector<ll>> cnts; // 魔法使った回数


int main() {

  string a, b;
  cin >> a >> b;
  int num = atoi((a+b).c_str());

  // cout << num << endl;

  int s_num = sqrt(num);

  if(s_num*s_num==num){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


   
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3532
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	int N;
	cin >> N;
	int spt[N] = {}; //0=なし 1=まえ　2=うしろ　3 = 両方
	string S[N];
	int cnt=0;
	int mae =0;
	int usiro = 0;
	int ryo = 0;
	rep(i,0,N){
		cin >> S[i];
	}
	rep(i,0,N){
		rep(j,0,S[i].size()-1){
			if(S[i][j] == 'A' && S[i][j+1] == 'B'){
				cnt++;
			}
		}
		if(S[i][0] == 'B'){
			spt[i] = 1;
		}
		if(S[i][S[i].size()-1] == 'A'){
			if(spt[i] == 1){
				spt[i] = 3;
			}else{
				spt[i] = 2;
			}
		}
	}
	rep(i,0,N){
		if(spt[i] == 1){
			mae++;
		}else if(spt[i] == 2){
			usiro++;
		}else if(spt[i] == 3){
			ryo++;
		}
	}
//	cout <<"cnt" << cnt << "mae:"<< mae << "ushiro:" << usiro << "ryo:" << ryo << endl;
	//前と後ろの差
	cnt += min(mae,usiro);
	int sa = max(mae,usiro) - min(mae,usiro);
//	if(sa == 0 && ryo != 0){
//		cnt += ryo-1;
//	}else{
	if(usiro == 0 && mae == 0 && ryo != 0){
		cnt += ryo-1;
	}else{
		cnt += ryo;
	}

//	}
	cout << cnt << endl;
}



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

int main() {
  int n;
  cin >> n;
  int a,b,c;
  a = n % 10;
  b = ( (n - a) % 100 ) / 10;
  c = ( n - a - (b * 10) ) / 100;
  if (a == 7) {
    cout << "Yes";
  } else if (b == 7) {
    cout << "Yes";
  } else if (c == 7) {
    cout << "Yes";
  } else {
    cout << "No";
  };
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define ll long long
#define mset(s, _) memset(s, _, sizeof s)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

int main(void) {
  int A, B;
  cin >> A >> B;
  int x = 100 * A / 8.0;
  rep(i, 0, 13) {
    int res8 = (x + i) * 0.08;
    int res10 = (x + i) * 0.1;
    // cout << i << " " << x + i << " " << res8 << endl;
    if (res8 == A && res10 == B) {
      cout << x + i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3576
#include<iostream>

int main(){
	int N;
	std::cin >> N;
	
	int a[110] = {0};
	for (int i=1;i<=N;i++) {
		std::cin >> a[i];
	}
	
	int ans=0;
	for (int i=2;i<=N;i++) {
		if (a[i-1]==a[i]) {
			a[i] = a[i+1]+1;
			ans++;
		}
	}
	
	std::cout << ans << '\n';
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int H, W, i, j;

	while (1){
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0) break;

		if (H < 301 && W < 301){
			for (i = 0; i < H; i++){
				for (j = 0; j < W; j++){
					printf("#");
				}
				printf("\n");
			}
		}
		printf("\n");
	}
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
string s, t; int dp[4009];
int main() {
	while(cin >> s >> t) {
		int n = s.size(), m = t.size(), ret = 0;
		fill(dp, dp + m + 1, 0);
		for(int i = 0; i < n; i++) {
			for(int j = m - 1; j >= 0; j--) {
				if(s[i] == t[j]) {
					dp[j + 1] = dp[j] + 1;
					ret = max(ret, dp[j + 1]);
				}
				else dp[j + 1] = 0;
			}
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 3176
from itertools import chain

target = input().lower()
sentence = []

while True:
  line = input()
  if line == 'END_OF_TEXT':
    break
  sentence.append(line.split())

flatten_list = list(chain.from_iterable(sentence))
word_list = [word.strip(',.') for word in flatten_list]
word_list = [word.lower() for word in word_list]
print(len(list(filter(lambda word: word == target, word_list))))



Measured memory_bytes: 5628
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
 
class Program{
    static void Main(){
        string[] inputs = Console.ReadLine().Split(' ');
        int k = int.Parse(inputs[0]);
        int t = int.Parse(inputs[1]);
        int[] a = Console.ReadLine().Split(' ')
                                         .Select(val => int.Parse(val))
                                         .ToArray();
        int m = a.Max();
        Console.WriteLine(Math.Max(m - 1 - (k - m), 0));
    }
}


Measured memory_bytes: 2904
#include <stdio.h>
#include <stdlib.h>

long min(int a,int b){
  if(a < b){
    return a;
  }
  return b;
}

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

int main(void){
  int N;
  long ans = 2000000000;
  scanf("%d",&N);

  long a[N];
  for(int i = 0;i < N;i++) scanf("%ld",&a[i]);
  qsort(a,N,sizeof(long),compare_int);

  long max = a[N-1];
  long middle = (max+1)/2;

  for(int i = 0;i < N-1;i++){
    if(llabs(ans-middle) > llabs(a[i]-middle)){
      ans = a[i];
    }
  }

  printf("%ld %ld\n",max,ans);
  return 0;
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int n;
int f[210][4][4][4];

int main()
{
	cin >> n;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			for(int k=0;k<4;k++){
				if(i==0&&j==1&&k==2)continue;
				if(i==0&&j==2&&k==1)continue;
				if(i==1&&j==0&&k==2)continue;
				f[3][i][j][k]=1;
			}
		}
	}
	for(int a=4;a<=n;a++){
		for(int t=0;t<4;t++){
			for(int i=0;i<4;i++){
				for(int j=0;j<4;j++){
					for(int k=0;k<4;k++){
						// t i j k
						if(i==0&&j==1&&k==2)continue;
						if(i==0&&j==2&&k==1)continue;
						if(i==1&&j==0&&k==2)continue;
						if(t==0&&i==1&&k==2)continue;
						if(t==0&&j==1&&k==2)continue;
						f[a][i][j][k]+=f[a-1][t][i][j];
						f[a][i][j][k]%=1000000007;
					}
				}
			}
		}
	}
	int ans=0;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			for(int k=0;k<4;k++){
				ans+=f[n][i][j][k];
				ans%=1000000007;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm> 
#include<cstring>
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
ll n,q,h,s,d;
int main()
{
	scanf("%lld%lld%lld%lld%lld",&q,&h,&s,&d,&n);
	s=min(s,q*4);
	s=min(s,h*2);
	if(s*2<=d)printf("%lld",n*s);
	else if(n%2==0)printf("%lld",n/2*d);
	else printf("%lld",n/2*d+s);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
//----------------------------------------------------------------

int MOD = 998244353;
// int MOD = 1000000007;
ll bitpow(ll x,ll n){
    ll ans = 1;
    while(n > 0){
        if(n%2 == 1) ans = ans * x % MOD;
        x = x * x %MOD;
        n = n >> 1;
    }
    return ans;
}
ll d[100010] = {0};
//----------------------------------------------------------------
signed main(){
   
    int n;
	cin >> n;
	
	ll ans = 0;
	for(int i = 1;i <= n;i++){
		if(i < n-i)ans++;
	}
	cout << ans << endl;

    
	return 0;
}

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

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://nikkei2019-2-qual.contest.atcoder.jp/tasks/nikkei2019_2_qual_b
// rm -r -f test;oj dl https://abc144.contest.atcoder.jp/tasks/abc144_b

Measured memory_bytes: 256
N, K = map(int, input().split())
A = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append((a, b))
A = sorted(A)
t = 0
i = 0
while t < K:
    t += A[i][1]
    i += 1
print(A[i-1][0])

Measured memory_bytes: 17824
import java.util.*;

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int ans;
    if(A >= 13) ans = B;
    else if(A >= 6 && A <= 12) ans = B / 2;
    else ans = 0;
    System.out.println(ans);
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] subordinates = new int[n];

        for (int i = 1; i < n; i++) subordinates[sc.nextInt() - 1]++;
        for (int num: subordinates) System.out.println(num);
        sc.close();
    }
}

Measured memory_bytes: 60616
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 1000000007
// order_of_key and *find_by_order
int32_t main()
{
	fast;
	int n;
	cin >> n;
	int m;
	cin >> m;
	int a[n + 1];
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	vector<int > v[n + 1];
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int fl = 0;
		for (int j = 0; j < v[i].size(); j++) {
			if (a[i] <= a[v[i][j]]) {
				fl = 1;
				break;
			}
		}
		if (fl == 0) {
			ans++;
		}
	}
	cout << ans;






}

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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long
#define mp make_pair

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;
const int dxl[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dyl[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dxs[4] = {1, 0, -1, 0};
const int dys[4] = {0, 1, 0, -1};

/* main */
signed main(void)
{
    int n, luc1 = 0, luc2 = 0;
    cin >> n;
    int a[n + 1] = {2, 1};
    REP(i, 2, n + 1)
    {
        a[i] = a[i - 1] + a[i - 2];
    }
    cout << a[n] << endl;
    return 0;
}

Measured memory_bytes: 256
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
// const long long MOD = (ll)1e6+3;
const long long MAX = (ll)1e5+10;


int main(void) {
    ll N;
    cin>>N;
    vector<ll> P(N);
    vector<ll> Q(N);
    rep(i,0,N) cin>>P[i];
    rep(i,0,N) cin>>Q[i];

    bool flag3 = true;
    rep(i,0,N) {
        if (P[i]!=Q[i]) {
            flag3 = (P[i]<Q[i]);
            break;
        }
    }
    if (!flag3) swap(P,Q);

    ll ans = 0;
    while(1) {
        // rep(i,0,N) cout<<P[i];
        // cout<<endl;
        // check terminate
        bool flag = true;
        rep(i,0,N) {
            flag = flag && (P[i]==Q[i]);
        }
        if (flag) break;

        // increment
        ans++;
        vector<ll> tmp;
        bool flag2 = false;
        for (int i = N-2;i>=0;i--) {
            if (flag2) break;
            if (P[i] < P[i+1]) {
                // do
                tmp.push_back(P[i]);
                ll ne = N+2;
                rep(j,i+1,N) {
                    if (P[i]<P[j]) chmin(ne,P[j]);
                }
                P[i] = ne;
                rep(j,i+1,N) {
                    if (P[j] == P[i]) continue;
                    tmp.push_back(P[j]);
                }
                sort(tmp.begin(),tmp.end());
                rep(j,i+1,N) P[j] = tmp[j-i-1];
                tmp.clear();
                flag2 = true;
            } else {
                // none
            }
        }
    }
    cout<<ans<<endl;








   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
 

int32_t main()
{
	IOS
	long long n ; cin >> n ;
	cout << ( n / 500 ) * ( 1000 ) + (( n % 500 ) / 5 ) * 5 << endl;
	
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for(int i = (int)(n); i > 0; --i)
#define all(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rall(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define sz(a) (int)(a).size()
#define mins(a,...) a = min({a, ## __VA_ARGS__})
#define maxs(a,...) a = max({a, ## __VA_ARGS__})
#define plusMod(a,b) a = (a % mod + b % mod) % mod
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);

template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}

constexpr ll V = 100005;

int n;
vector<int> to[2 * V];
bool visited[2 * V];

ll cnt[2];
void dfs(int v) {
    if (visited[v])
        return;
    visited[v] = true;

    ++cnt[v / V];
    for (auto& t : to[v])
        dfs(t);
}


void solve() {
    cin >> n;


    rep(i, n) {
        ll x, y;
        cin >> x >> y;

        y += V;
        to[x].push_back(y);
        to[y].push_back(x);

    }

    ll ans = 0;
    rep(i, 2 * V) {
        if (visited[i])
            continue;

        fillArray(cnt, 0);

        dfs(i);

        ans += cnt[0] * cnt[1];
    }

    cout << ans - n << endl;

}


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    solve();

    return 0;
}


Measured memory_bytes: 10240
def Next(S):
    if len(S)!=26:
        f=[0 for i in range(26)]
        for i in S:
            f[ord(i)-97]+=1
        t=""
        for i in range(26):
            if f[i]==0:
                t=chr(i+97)
                break
        return (S+t)
    else:
        if S=="zyxwvutsrqponmlkjihgfedcba":
            return (-1)
        else:
            k=0
            for i in range(25):
                if ord(S[25-i])>ord(S[24-i]):
                    k=24-i
                    break
            T=S[:k]
            g=[0 for i in range(26)]
            for i in T:
                g[ord(i)-97]=1
            for n in range(ord(S[k])-97):
                g[n]=1
            g[ord(S[k])-97]=1
            t=""
            #K=[25-i for i in range(26)]
            for i in range(26):
                if g[i]==0:
                    t=chr(i+97)
                    break
            return (T+t)
            return S
s=input()
print(Next(s))
'''
print("############")
for i in range(100):
    print(s)
    s=Next(s)
'''

Measured memory_bytes: 3064
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001



N = int(input())
SET = set()

for _ in range(N):
    number = int(input())
    if number in SET:
        SET.discard(number)
    else:
        SET.add(number)

print(len(SET))



Measured memory_bytes: 12464
use std::cmp;
use std::collections::VecDeque;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let n: usize = read_as_vec()[0];

    let mut a: Vec<i64> = vec![];
    let mut ans: i64 = 0;
    for _ in 0..n {
        a.push(read_as_vec()[0]);
    }
    a.sort();
    if a.len() % 2 == 0 {
        let mut a_smaller = a.iter().take(a.len() / 2).collect::<Vec<_>>();
        let mut a_larger = a.iter().skip(a_smaller.len()).collect::<Vec<_>>();
        a_smaller.sort();
        a_larger.sort();
        a_larger.reverse();
        ans = (a_larger.iter().map(|x| (**x) * 2).sum::<i64>() - *a_larger.last().unwrap())
            - (a_smaller.iter().map(|x| (**x) * 2).sum::<i64>() - *a_smaller.last().unwrap());
    } else {
        let mut a_smaller = a.iter().take(a.len() / 2).collect::<Vec<_>>();
        let mut a_larger = a.iter().skip(a_smaller.len()).collect::<Vec<_>>();
        a_smaller.sort();
        a_larger.sort();
        let pat1_ans =
            (a_larger.iter().map(|x| (**x) * 2).sum::<i64>() - a_larger[0] - a_larger[1])
                - a_smaller.iter().map(|x| (**x) * 2).sum::<i64>();

        // println!("smaller = {:?}", a_smaller);
        // println!("larger = {:?}", a_larger);

        let mut a_larger = a.iter().skip(a.len() / 2 + 1).collect::<Vec<_>>();
        let mut a_smaller = a.iter().take(a.len() - a_larger.len()).collect::<Vec<_>>();
        a_smaller.sort();
        a_smaller.reverse();
        a_larger.sort();
        let pat2_ans = a_larger.iter().map(|x| (**x) * 2).sum::<i64>()
            - (a_smaller.iter().map(|x| (**x) * 2).sum::<i64>() - a_smaller[0] - a_smaller[1]);
        //println!("pat1 = {}, pat2 = {}", pat1_ans, pat2_ans);
        // println!("smaller = {:?}", a_smaller);
        // println!("larger = {:?}", a_larger);
        ans = cmp::max(pat1_ans, pat2_ans);
    }
    println!("{}", ans);
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, r;
  cin >> n >> r;
  if(n >= 10) cout << r << endl;
  else cout << r +100*(10-n) << endl;
}


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

public class Main{
	private static Scanner scan;
	public static void main(String[] args) {
		int f[] = new int[1000000];
		Arrays.fill(f,1);
		for(int i = 2;i < 1000000;i++){
			if(f[i] == 1){
				for(int j = i*2;j < 1000000;j+=i){
					f[j] = 0;
				}
			}
		}
		scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = Integer.parseInt(scan.next());
			int m = 0;
			for(int i = 2;i <= n;i++){
				m += f[i];
			}
			System.out.println(m);
		}
		System.exit(0);
	}
}

Measured memory_bytes: 16000
#include <stdio.h>
    #include <stdlib.h>
    #define inf (int)(1e9)
     
    int min(int a, int b){
    	if(a < b){
    		return a;
    	}
    	else{
    		return b;
    	}
    }
     
    int solve(int N, int R, int **d, int *r, int pre){
    	int i, tmp, ans = inf;
    	for(i = 0; i < R; i++){
    		if(r[i] != -1){
    			tmp = r[i];
    			r[i] = -1;
    //			printf("pre = %d, before:ans = %d\n", pre, ans);
    //			printf("d[%d][%d] = %d\n", pre, r[i], d[pre][tmp]);
    			ans = min(ans, solve(N, R, d, r, tmp) + d[pre][tmp]);
    //			printf("pre = %d, after:ans = %d\n", pre, ans);
    			r[i] = tmp;
    		}
    	}
    	ans %= inf;
    //	printf("pre = %d, ans = %d\n", pre, ans);
    	return ans;
    }
     
    int main(){
    	int N, M, R, A, B, C, i, j, k;
    	scanf("%d%d%d", &N, &M, &R);
    	int *r = (int *)malloc(sizeof(int) * R);
    	for(i = 0; i < R; i++){
    		scanf("%d", &r[i]);
    	}
    	int **d = (int **)malloc(sizeof(int *) * (N + 1));
    	for(i = 0; i <= N; i++){
    		d[i] = (int *)malloc(sizeof(int) * (N + 1));
    		for(j = 0; j <= N; j++){
    			if(i == j || i == 0 || j == 0){
    				d[i][j] = 0;
    			}
    			else{
    				d[i][j] = inf;
    			}
    		}
    	}
    	for(i = 0; i < M; i++){
    		scanf("%d%d%d", &A, &B, &C);
    		d[A][B] = C;
    		d[B][A] = C;
    	}
    	for(k = 1; k <= N; k++){
    		for(i = 1; i <= N; i++){
    			for(j = 1; j <= N; j++){
    				if(d[i][j] > d[i][k] + d[k][j]){
    					d[i][j] = d[i][k] + d[k][j];
    				}
    			}
    		}
    	}
    /*	for(i = 0; i <= N; i++){
    		for(j = 0; j <= N; j++){
    			printf("%d  ", d[i][j]);
    		}
    		printf("\n");
    	}
    */	printf("%d\n", solve(N, R, d, r, 0));
    	return 0;
    }

Measured memory_bytes: 384
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

std::string substrBack(std::string str, size_t pos, size_t len) {
	const size_t strLen = str.length();

	return str.substr(strLen - pos, len);
}

int main()
{
	int n;
	cin >> n;
	vector<int> p(n);
	vector<int> q(n);
	vector<int> per(n);
	rep(i, n) {
		cin >> p[i];
		per[i] = i + 1;
	}
	rep(i, n) {
		cin >> q[i];
	}
	int i = 1;
	int pNum = 0;
	int qNum = 0;
	do
	{
		bool isPOK = true;
		bool isQOK = true;
		rep(i, n) {
			if (per[i] != p[i]) {
				isPOK = false;
			}
			if (per[i] != q[i]) {
				isQOK = false;
			}
		}
		if (isPOK) {
			pNum = i;
		}
		if (isQOK) {
			qNum = i;
		}
		++i;
	} while (next_permutation(per.begin(), per.end()));
	int ans = abs(pNum - qNum);
	cout << ans << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}




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

class Vector2{
  public:
  double x, y;
  Vector2(){}
  Vector2(double x, double y): x(x), y(y) {}

  Vector2 operator + (Vector2 v) {
    return Vector2(x + v.x , y + v.y);
  }
  Vector2 operator - (Vector2 v) {
    return Vector2(x - v.x , y - v.y);
  }

  Vector2 operator * (double d){
    return Vector2(d*x, d*y);
  }

};

double dot(Vector2 a, Vector2 b){
  return a.x * b.x + a.y * b.y; 
}

double cross(Vector2 a, Vector2 b){
  return a.x * b.y - a.y*b.x;
}

Vector2 projection(Vector2 a, Vector2 b, Vector2 p){
  Vector2 base = b - a;
  Vector2 hypo = p - a;
  double norm_base = pow(base.x,2) + pow(base.y,2);

  Vector2 x;
  x = a + base*(dot(hypo,base) / norm_base);
  return x;
}

Vector2 refrection(Vector2 a, Vector2 b, Vector2 p){
  Vector2 v, p_projection;
  p_projection = projection(a,b,p); 
  v = p_projection + (p_projection - p);
  return v;
}

int main(){
  Vector2 a,b,p,q;
  int queri;
  cin >> a.x >> a.y >> b.x >> b.y;
  cin >> queri;
  rep(i,queri){
    cin >> p.x >> p.y;
    q = refrection(a,b,p);
    cout << fixed << setprecision(10); 
    cout << q.x << " " << q.y << endl;
  }
  
  return 0;
}


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

using namespace std;

#pragma GCC optimize("O3")
static const auto __ = [] {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    return nullptr;
}();

int main(int argc, char* argv[]) {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.length(); ++i) {
        ans += (s[i] != t[i]);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3724
# ABC152C

# p[0] ~ p[i] の最小値と p[i] を比べればよい
# 最小値は逐次更新する

n = int(input())
p = list(map(int, input().split()))
count = 0
min_val = p[0]
for i in range(n):
    if min_val > p[i]:
        min_val = p[i]
    if min_val >= p[i]:
        count += 1
print(count)


Measured memory_bytes: 24744
#include "bits/stdc++.h"
using namespace std;
int a[5005], b[5005], org[5005];
int used[5005];
int start;
int id[5005];
int n;

bool cmp(int i, int j) {
	return a[i] < a[j];
}

int count(int st, int bad = 0) {
	used[bad] = true;
	int cur = 1;
	int cnt = 0;
	for(int i = 1; i <= n; i++) {
		if(used[i]) continue;
		while(cur <= n && id[cur] < st) {
			++cur;
		}
		if(a[cur] < b[i]) {
			++cnt;
			++cur;
		}
	}
	used[bad] = false;
	return cnt;
}
int position(int x) {
	for(int i = 1; i <= n; i++) {
		if(!used[i]) {
			--x;
		}
		if(x == 0) {
			return i;
		}
	}
	return 0;
}
int search(int b, int e, int optimal) {
	if(b == e) {
		int pos = position(b);
		return 1 + count(start + 1, pos) == optimal ? pos : 0; 
	}
	int m = (b + e + 1) >> 1;
	int pos = position(m);
	int match = 1 + count(start + 1, pos);
	if(match == optimal) {
		return search(m, e, optimal);
	} else {
		return search(b, m - 1, optimal);
	}
}
int find(int b, int e, int optimal) {
	if(b == e) {
		int pos = position(b);
		return count(start + 1, pos) == optimal ? pos : 0; 
	}
	int m = (b + e + 1) >> 1;
	int pos = position(m);
	int match = count(start + 1, pos);
	if(match == optimal) {
		return find(m, e, optimal);
	} else {
		return find(b, m - 1, optimal);
	}
}
int getOpt(int x) {
	start = x;
	int no_match = 0;
	for(int i = 1; i <= n; i++) {
		if(used[i]) continue;
		if(b[i] <= org[start]) {
			no_match += 1;
		}
	}
	int opt = count(start);
	int idx = 0;
	// cout << x << ' ' << opt << endl;
	// if(x == 2) {
	// 	cout << count(3, 5) << endl;
	// 	exit(0);
	// } 
	if(no_match) {
		idx = max(idx, find(1, no_match, opt));
	}
	if(no_match < n - start + 1) {
		idx = max(idx, search(no_match + 1, n - start + 1, opt));
	}
	return idx;
}

int main(int argc, char const *argv[])
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		id[i] = i;
		org[i] = a[i];
	}
	for(int i = 1; i <= n; i++) {
		scanf("%d", &b[i]);
	}

	sort(id + 1, id + n + 1, cmp);
	sort(a + 1, a + n + 1);	
	sort(b + 1, b + n + 1);

	for(int i = 1; i <= n; i++) {
		int idx = getOpt(i);
		used[idx] = true;
		if(i == n) printf("%d\n", b[idx]);
		else printf("%d ", b[idx]);
	}
	return 0;
}


Measured memory_bytes: 3356
#include<bits/stdc++.h>
using namespace std;
int n,ans;
char a;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a=='Y'){
            ans=1;
        }
    }
    if(ans==1)cout<<"Four"<<endl;
    else cout<<"Three"<<endl;
}


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

typedef long long ll;
const int N=200005;
ll a[N],b[N];
int n;
struct node{
	int id;
	ll val;
	bool operator <(const node &x)const{
		return val<x.val;
	}
};
priority_queue<node> myline;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){scanf("%lld",&a[i]);}
	for(int i=1;i<=n;i++){scanf("%lld",&b[i]);myline.push((node){i,b[i]});}
    bool flag=false;
    ll ans=0;
    while(!myline.empty()){
		node head=myline.top();myline.pop();
		int dd=head.id;
	//	printf("b[%d]=%d,a[%d]=%d\n",dd,b[dd],dd,a[dd]);
		if(a[dd]==b[dd]) continue;
		int l,r;
		if(dd==1) l=n;else l=dd-1;
		if(dd==n) r=1;else r=dd+1; 
		//b[dd]-=b[l];b[dd]-=b[r];
		if(b[dd]-b[l]-b[r]<a[dd]) {puts("-1");flag=true;break;}
		ll tmp=(b[dd]-a[dd])/((b[l]+b[r]));
		b[dd]-=tmp*(b[l]+b[r]);
		ans+=tmp;
		if(b[dd]<a[dd]) {puts("-1");flag=true;break;}
		myline.push((node){dd,b[dd]});
	}
	if(!flag) printf("%lld",ans);
}

Measured memory_bytes: 8816
N = int(input())

BA_dict = dict()

for i in range(N):
    A,B = map(int, input().split())
    
    if B not in BA_dict:
        BA_dict[B] = list()
        
    BA_dict[B].append(A)
    
#単純に締め切り時間が早いのから片付ける
BA_sorted = sorted(BA_dict.items(), key=lambda x:x[0])

now_time = 0
for BA in BA_sorted:
    deadline = BA[0]
    now_time += sum(BA[1])
    
    if now_time > deadline:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 65908
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

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

int l, r;

signed main() {
  init_ios();
  cin >> l >> r;
  if (r-l > 2020) {
    cout<<"0\n";
    return 0;
  }
  int res = 2020;
  for (int i = l; i < r; ++i)
    for (int j = i+1; j <= r; ++j)
      res = min(res, (i*j)%2019);
  cout<<res<<"\n";
}

Measured memory_bytes: 256
class UnionFind():
 def __init__(self, n):
  self.n = n
  self.parents = [-1] * n

 def find(self, x):
  if self.parents[x] < 0:
   return x
  else:
   self.parents[x] = self.find(self.parents[x])
   return self.parents[x]

 def union(self, x, y):
  x = self.find(x)
  y = self.find(y)

  if x == y:
   return

  if self.parents[x] > self.parents[y]:
   x, y = y, x

  self.parents[x] += self.parents[y]
  self.parents[y] = x
 def roots(self):
   return [i for i, x in enumerate(self.parents) if x < 0]

 def group_count(self):
  return len(self.roots())

import sys
input = sys.stdin.readline
n,m = map(int,input().split())
uf = UnionFind(n)
for i in range(m):
 x,y,z = map(int,input().split())
 uf.union(x-1,y-1)
print(uf.group_count())

Measured memory_bytes: 63448
#include <iostream>
#include <vector>
 
int main(){
  unsigned n; std::cin >> n;
  unsigned a[n];
  unsigned total=0;
  
  for(int i=0; i<n; i++){
    unsigned tmp;
    std::cin >> tmp;
    a[i] = tmp;
    total += tmp;
  }
  
  float avg = (float)total/n;
  unsigned pos=0;
  float diff = (a[pos]>avg)? a[pos]-avg : avg- a[pos];
  for(int i=1; i<n;i++){
    float tmp = (a[i]>avg)? a[i]-avg : avg- a[i];
    if(tmp<diff){
      diff = tmp;
      pos = i;
    }
  }
  std::cout << pos << std::endl;
  return 0;
}

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

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

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

//---------------------------
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }

  mint p(int n, int k) {
    return fact[n]*ifact[n-k];
  }
}comb(1000005);
//----------------------------

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

  for(int i=1; i<=k; i++){
    mint blue = comb(k-1, k-i);
    mint red = comb(n-k+1,i);
    mint ans = blue * red;
    cout << ans << endl;
  }
  
}


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


using namespace std;

int a,b;
string s;

int main(){
    cin >> a >> b;
    cin >> s;
    
    if(s[b-1] == 'A'){
        s[b-1] = 'a';
    }
    if(s[b-1] == 'B'){
        s[b-1] = 'b';
    }
    if(s[b-1] == 'C'){
        s[b-1] = 'c';
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<pair<int, int>, int>>a(m);
	rep(i, m) {
		cin >> a[i].first.first >> a[i].first.second;
		a[i].second = i;
	}
	sort(a.begin(), a.end());
	vpint b(m);
	int cnt = 1;
	rep(i, m) {
		b[a[i].second].first = a[i].first.first;
		if (i != 0) {
			if (a[i - 1].first.first != a[i].first.first) {
				cnt = 1;
			}
			else {
				cnt++;
			}
		}
		b[a[i].second].second = cnt;
	}
	rep(i, m) {
		printf("%06d%06d\n", b[i].first, b[i].second);
	}
	return 0;
}


Measured memory_bytes: 3456
N = int(input())

X = [list(map(int,input().split())) for _ in range(N-1)]


for j in range(N-1):
	time = 0	
	for i in range(j,N-1):
		if time <= X[i][1]:
			time = X[i][0]+X[i][1]
		elif (time-X[i][1])%X[i][2] == 0:
			time += X[i][0]
		else:
			time += X[i][0]+(X[i][2]-(time-X[i][1])%X[i][2])
	print(time)
print(0)

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

int main() {
  int N;
  cin >> N;
  
  if ((N % 1000) % 111 == 0 ) {
    cout << "Yes" << endl;
  }
  else if ((N / 10) % 111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n, T;
vector<ll> v;
int main() {
    cin>>n>>T;
    REP(i, 0, n){
        ll c, t;
        cin>>c>>t;
        if(t<=T){
            v.emplace_back(c);
        }
    }

    if(v.size()==0){
        cout<<"TLE"<<endl;
    }
    else{
        sort(v.begin(), v.end());
        cout<<v[0]<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class A
{
	public static void Main()
	{
		string[] args = Console.ReadLine().Split(' ');		
		int A = Int32.Parse(args[0]);
		int B = Int32.Parse(args[1]);
		int C = Int32.Parse(args[2]);
		Console.WriteLine((A+B >= C) ? "Yes" : "No");
	}
}





Measured memory_bytes: 11092
# coding: utf-8
# Your code here!
import heapq as hq
H,W,K = map(int,input().split())
A = []
X,Y=0,1
start = None
for h in range(H):
    tmp = list(input())
    A.append(tmp)
    if "S" in tmp:
        start = (tmp.index("S"), h)

def minCost(x,y):
    return min(start[X], W-1-start[X], start[Y], H-1-start[Y]) // K
search = []
searched = [[False for w in range(W)] for h in range(H)]
hq.heapify(search)
search.append((0, start[X], start[Y]))
vector = [(1,0),(-1,0),(0,1),(0,-1)]
max_x,min_x,max_y,min_y = 0,W-1,0,H-1
while len(search) > 0:
    cnt,x,y = hq.heappop(search)
    if x == 0 or x == W-1 or y == 0 or y == H-1:
        print(1)
        exit()
    if searched[y][x]:
        continue
    searched[y][x] = True
    max_x = max(max_x, x)
    min_x = min(min_x, x)
    max_y = max(max_y, y)
    min_y = min(min_y, y)
    for v in vector:
        newX,newY = x+v[X], y+v[Y]
        if not searched[newY][newX] and cnt < K and A[newY][newX] != "#":
            hq.heappush(search,(cnt+1,newX,newY))
dist = min(min_x, min_y, W-1-max_x, H-1-max_y)
print(1 + (dist+K-1)//K)

Measured memory_bytes: 14580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 5;
const int INF = 0x3f3f3f3f;
#define DEBUG(x) cout << x << '\n'

int n, a[MAXN], p[MAXN * 5];
void run(){
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i], p[a[i]]++;
    sort(a + 1, a + n + 1);
    int ans = 0, mx = a[n];
    for(int i = 1; i <= n; i++){
        ans += p[a[i]] == 1;
        for(int j = a[i] + a[i]; j <= mx; j += a[i]) p[j] = 0;
    }
    cout << ans;
}
int main(){
#ifdef Irene
    freopen("in.txt", "r", stdin);
#endif // Irene
    ios::sync_with_stdio(false);

    run();
}


Measured memory_bytes: 8236
#!/usr/bin/env python3
import sys


def solve(a: int, b: int):
    str_a = str(a) * b
    str_b = str(b) * a
    print(sorted([str_a, str_b])[0])


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
#include <cassert>
using namespace std;
#define File(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
typedef long long ll;
template<typename T> inline void gi(T &x){
  char ch; x = 0;
  int f = 1;
  while(isspace(ch = getchar()));
  if(ch == '-') ch = getchar(), f = -1;
  do x = x * 10 + ch - '0'; while(isdigit(ch = getchar()));
  x *= f;
}
template<class T> void upmax(T &x, T y){x = x>y ? x : y;}
template<class T> void upmin(T &x, T y){x = x<y ? x : y;}

const int N = 200005;

int fa[N], rk[N], tot = 0;
int find(int x){
  return !fa[x] ? x : fa[x] = find(fa[x]);
}
void merge(int x, int y){
  // printf("Merge components : %d %d\n", x, y);
  x = find(x), y = find(y);
  if(x == y) return;
  --tot;
  if(rk[x] < rk[y]) swap(x, y);
  fa[y] = x; rk[x] += rk[x] == rk[y];
}

struct Edge{
  int v, w;
  Edge(int _v, int _w) : v(_v), w(_w) {};
};
struct Data{
  ll v1; int c1;
  ll v2; int c2;
};
const ll inf = 0x3FFFFFFFFFFFFFFFLL;
const Data INF = {inf, 0, inf, 0};
Data operator+=(Data &a, const Data &b){
  if(b.v1 < a.v1){
    if(b.c1 != a.c1) a.v2 = a.v1, a.c2 = a.c1;
    a.v1 = b.v1, a.c1 = b.c1;
  }
  else if(b.v1 < a.v2 && b.c1 != a.c1)
    a.v2 = b.v1, a.c2 = b.c1;
  if(b.v2 < a.v2 && b.c2 != a.c1)
    a.v2 = b.v2, a.c2 = b.c2;
  
  return a;
}
Data inc(Data x, int d){
  x.v1 += d; x.v2 += d;
  return x;
}
vector<Edge> G[N];
int w[N];
Data f[N], mined[N];

void dfs1(int x, int fa){
  f[x] = INF;
  for(auto e : G[x]){
    if(e.v == fa) continue;
    dfs1(e.v, x);
    f[x] += inc(f[e.v], e.w);
  }
  f[x] += {w[x], find(x), inf, 0};
}
void dfs2(int x, int fa){
  Data s = f[x];
  for(auto e : G[x]){
    if(e.v == fa) continue;
    f[e.v] += inc(s, e.w);
    s += inc(f[e.v], e.w);
  }
  s = INF;
  for(auto e = G[x].rbegin(); e != G[x].rend(); ++e){
    if(e->v == fa) continue;
    f[e->v] += inc(s, e->w);
    s += inc(f[e->v], e->w);
    dfs2(e->v, x);
  }
}

int main(){
  // File("at3611");
  int n;
  gi(n);
  for(int i=1; i<=n; i++) gi(w[i]);
  for(int i=1; i<n; i++){
    int x, y, w;
    gi(x), gi(y), gi(w);
    G[x].emplace_back(y, w); G[y].emplace_back(x, w);
  }
  tot = n;
  ll res = 0;
  while(tot != 1){
    fill(mined + 1, mined + 1 + n, INF);
    dfs1(1, 1);
    dfs2(1, 1);
    for(int i=1; i<=n; i++) mined[find(i)] += inc(f[i], w[i]);
    for(int i=1; i<=n; i++){
      int rt = find(i);
      if(rt != i) continue;
      if(find(mined[rt].c1) == rt){
        merge(rt, mined[rt].c2);
        res += mined[rt].v2;
      }
      else{
        merge(rt, mined[rt].c1);
        res += mined[rt].v1;
      }
    }
  }
  printf("%lld\n", res);
  return 0;
}

Measured memory_bytes: 47720
import java.util.Scanner;
 
public class Main{
	static Scanner sc = new Scanner(System.in);
	static int[] prin = new int[52365];
    
    static void SystemOut(){
    	while(sc.hasNext()){
            int n=sc.nextInt();
            if(n==0){
                break;
            }
            int ans=2;
            for(int i = 1;i < 52365;i++){
                if(prin[i] == 0)continue;
                if(n<2)break;
                ans+=(2*i+1);
                n--;
            }
            System.out.println(ans);
        }
    }
   
    void sub(){
        for(int i = 0;i < 52365;i++){
            prin[i]=1;
        }
        int temp1=3;
        while(true){
            if(temp1*temp1>104730){
                break;
            }else{
                if(prin[(temp1-1)/2] == 0){
                    temp1 += 2;
                }else{
                    int temp2 = temp1*temp1;
                    while(temp2 < 104730){
                        prin[(temp2-1)/2] = 0;
                        temp2 += 2*temp1;
                    }
                    temp1 += 2;
                }
            }
        }
        SystemOut();
   }
    
    public static void main(String[] args){
    	Main app=new Main();
    	app.sub();
       
    }
}

Measured memory_bytes: 19844
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define F first
#define S second
#define dq deque
#define vc vector
#define INF ((int)(1e9))
#define LINF ((ll)(1e18))
#define pb push_back
#define mp make_pair
#define ll long long
#define _tp template
#define _tyn typename
#define pf push_front
#define itor iterator
#define sint short int
#define ull unsigned ll
#define pq priority_queue
#define pii pair<int,int>
#define uint unsigned int
#define B cout << "BreakPoint" << endl;
#define ms(_data) memset(_data,0,sizeof(_data))
#define fin(_filename) freopen(_filename,"r",stdin)
#define fout(_filename) freopen(_filename,"w",stdout)
#define msn(_data,_num) memset(_data,_num,sizeof(_data))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
_tp<_tyn T>void mymax( T &_a , T _b ){ if( _a < _b ) _a = _b; }
_tp<_tyn T>void mymin( T &_a , T _b ){ if( _a > _b ) _a = _b; }
void print(int _x){printf("%d ",_x);}
void print(ll _x){printf("%I64d ",_x);}
_tp<_tyn T>void print( T _a[] , int _s , int _t ){
	for( int i = _s ; i <= _t ; i++ )
		cout << _a[i] << " ";
   	cout << endl;
}
#define il inline
struct InputReader{
    static const int bs = 1000000;
    char buf[bs];
    int p;
    InputReader():p(bs) {}
    void flush(){
        p = 0;
        fread(buf, 1, bs, stdin);
    }
    char c(){
        if(p >= bs) flush();
        return buf[p++];
    }
    int operator() (){
        int ans = 0;
        char ch = c();
        while( ch < '0'  ||  ch > '9' ) ch = c();
        while( ch >= '0'  &&  ch <= '9' ){
            ans *= 10;
            ans += ch-'0';
            ch = c();
        }
        return ans;
    }
    void nextlet( int &x ){
    	char ch = c();
    	while( ch < 'a'  ||  ch > 'z' ) ch = c();
    	if( ch == 'c' ) x = 1;
    	if( ch == 'd' ) x = 2;
    	if( ch == 'q' ) x = 3;
	}
	ll readll(){
		ll ans = 0LL;
        char ch = c();
        while( ch < '0'  ||  ch > '9' ) ch = c();
        while( ch >= '0'  &&  ch <= '9' ){
            ans *= 10LL;
            ans += ch-'0';
            ch = c();
        }
        return ans;
	}
}in;
il void read( int &x ){
	x = in();
}
il void read2( int &x, int &y ){
	x = in(); y = in();
}
il void read3( int &x1 , int &x2 , int &x3 ){
	x1 = in(); x2 = in(); x3 = in();
}
/*********************************************************************/
/*********************************************************************/
string a;
int main(){
	cin >> a;
	cout << a.substr(0,a.length()-8) << endl;
	return 0;
}


Measured memory_bytes: 764