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

#define ll long long int
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define eb(x) emplace_back(x)
#define mp(a,b) make_pair(a,b)
#define sz(a) int((a).size())
#define mod 1000000007
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }


void seethis(vector<ll>vect)
{
    for(ll x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / __gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];

//ModPower
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

int main()
{
	FASTIO;
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif*/
	ll n,m;
	 cin>>n>>m;

	 vector<ll>vect(n);
	 f(i,0,n)
	 	cin>>vect[i];

	 for(int i=0;i<m;i++)
	 {
	 	ll x,y;
	 	 cin>>x>>y;

	 	 adj[x].push_back(y);
	 	 adj[y].push_back(x);
	 }
	 ll ans=0;
	 for(int i=1;i<=n;i++)
	 {
	 	ll hill=vect[i-1];
	 	bool flag=true;
	 	for(int child:adj[i])
	 	{
	 		if(vect[child-1]>=hill)
	 		{
	 			flag=false;
	 			break;
	 		}
	 		
	 	}
	 	if(flag)
	 	{
	 		error(i);
	 		ans++;
	 	}
	 }
	 cout<<ans<<"\n";

	return 0;
}

Measured memory_bytes: 9724
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int a, b;
	cin >> a >> b;
	int sum = 1;
	int cnt = 0;
	while (b  >sum)
	{
		sum += a - 1;
		cnt++;
	}
	cout << cnt << endl;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x=sc.nextInt(),y=sc.nextInt(),a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
		long[] p = new long[a], q=new long[b], r=new long[c];
		for(int i=0;i<a;i++) p[i]=sc.nextLong();
		for(int i=0;i<b;i++) q[i]=sc.nextLong();
		for(int i=0;i<c;i++) r[i]=sc.nextLong();
		sc.close();
		Arrays.sort(p);
		Arrays.sort(q);
		Arrays.sort(r);
		int p_cnt=a-x,q_cnt=b-y,r_cnt=c-1;
		while(true) {
			if(r_cnt<0) break;
			if(p_cnt>=a) {
				if(r[r_cnt]>q[q_cnt]){
					q[q_cnt]=r[r_cnt];
					q_cnt++;
					r_cnt--;
				}else break;
			}else if(q_cnt>=b) {
				if(r[r_cnt]>p[p_cnt]){
					p[p_cnt]=r[r_cnt];
					p_cnt++;
					r_cnt--;
				}else break;
			}else if(p[p_cnt]>q[q_cnt]) {
				if(r[r_cnt]>q[q_cnt]){
					q[q_cnt]=r[r_cnt];
					q_cnt++;
					r_cnt--;
				}else break;
			}else{
				if(r[r_cnt]>p[p_cnt]){
					p[p_cnt]=r[r_cnt];
					p_cnt++;
					r_cnt--;
				}else break;
			}
		}
		long ans = 0;
		for(int i=a-x;i<a;i++) ans += p[i];
		for(int i=b-y;i<b;i++) ans += q[i];
		System.out.println(ans);
	}
}

Measured memory_bytes: 97872
#include <stdio.h>
#include <math.h>
int main(){
  int N,D;
  scanf("%d %d",&N,&D);
  int X[N],Y[N];
  int i;
  for (i=0;i<N;i++){
    scanf("%d %d",&X[i],&Y[i]);
  }
  double Z;
  int f=0;
  for (i=0;i<N;i++){
    Z = sqrt(pow(X[i],2)+pow(Y[i],2));
    if (Z<=D){
      f = f+1;
    }
  }
  printf("%d",f);
  return 0;
}

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

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;
}

vector<ll> A;

// {value, count}
map<int, int> m;

ll comb2(const ll n) {
    if (n <= 1) return 0;
    return (n * (n - 1)) / 2;
}

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

    A.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        m[A[i]]++;
    }

    ll sum = 0;
    for (auto &p : m) {
        ll cnt = p.second;
        sum = sum + comb2(cnt);
    }

    for (int i = 0; i < N; i++) {
        ll x = A[i];
        ll cnt = m[x];
        ll ans = sum - comb2(cnt) + comb2(cnt - 1);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 9088
#include<cstdio>
#include<cstring>
using namespace std;
#define ll long long
const int mod = 1e9 +7;
int n,num[1005];
void fun()
{
    memset(num,0,sizeof num);
    for (int i = 2; i <= n; i++)
    {
        int temp = i;
        for (int j = 2; j <= i; j++)
        {
            while(temp % j == 0)
            {
                num[j]++;
                temp /= j;
            }
            if(!temp)break;
        }
    }
}
int main()
{
    while(~scanf("%d",&n))
    {
        fun();
        ll ans = 1;
        for (int i = 2; i <= n; i++)
        {
            ans = ans * (num[i] + 1) % mod;
        }
        printf("%lld\n",ans);
    }
}


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

#define int long long
#define f(i,l,n) for(int i=l;i<n;i++)
#define E "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAX 1e5
#define MIN -1e5

const int N=1e5+2;
int n,k;
vector<int> a;
int dp[N][2];



int solve(int x,int k)
{
	if(k<a[0]) return 1-x;

	if(dp[k][x]!=-1) return dp[k][x];

	int ans=1-x;

	for(int i=0;i<n;i++)

	{
		if(a[i]<=k)
		{
			if(solve(1-x,k-a[i])==x)
			{
				ans=x;
				break;
			}
		}
		else break;
	}
	return dp[k][x]=ans;
}

int32_t main()
{

 

  cin >> n >> k;
  a.resize(n);


  f(i,0,N) f(j,0,2) dp[i][j]=-1;
  for (int i = 0; i < n; ++i)
  {
  	cin >> a[i];
  }
  if(solve(0,k)==0) cout<<"First\n";
  else cout<<"Second";
}


Measured memory_bytes: 6528
#include <stdio.h>

class Dice4{
public:
	int number[6];

	void roll(char dst){
		switch(dst){
		case 'E':
			setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
			break;
		case 'N':
			setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
			break;
		case 'S':
			setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
			break;
		case 'W':
			setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
			break;
		}
	};

	bool isSameDice(int inputed[]){
		char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
		for(int i = 0; i < 24; i++){
			roll(order[i]);
			for(int j = 0; j < 6; j++){
				if(inputed[j] != number[j])
					break;
				if(j == 5)
					return true;
			}
		}
		return false;
	}

private:
	void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

};

int main(){
	int n,k,j;
	scanf("%d",&n);
	Dice4 array[n];
	for(int i = 0; i < n; i++){
		scanf("%d %d %d %d %d %d",&array[i].number[0],&array[i].number[1],&array[i].number[2],
				&array[i].number[3],&array[i].number[4],&array[i].number[5]);
	}
	for(k = 0; k < n-1; k++){
		for(j = k+1; j < n; j++){
			if(array[k].isSameDice(array[j].number))
				break;
		}
		if(j < n) break;
	}
	if(k == n-1){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}


Measured memory_bytes: 2696
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define SZ(n) (int)(n).size()
#define ALL(n) (n).begin(), (n).end()
using namespace std;
typedef long long LL;
typedef vector<int> VI;

int main() {
	int n;
	cin >> n;
	VI a;
	REP(i, n) {
		int t;
		cin >> t;
		a.push_back(t);
	}
	int cnt[101010] = {};
	REP(i, n) {
		cnt[a[i]]++;
	}
	int ans = 0;
	FOR(i, 0, 101010 - 2) {
		ans = max(ans, cnt[i] + cnt[i + 1] + cnt[i + 2]);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;

    if (a <= 5) {
        cout << 0 << endl;
    } else if (6 <= a && a <= 12) {
        cout << b / 2 << endl;
    } else {
        cout << b << endl;
    }

    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define INF 93193111451418101
#define MIN -93193111451418101
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//----------program from here----------

string s;
int n,sa,w,e;



int main(){
    cin>>s;

    REP(i,s.length()){
        if(s[i]=='W')w=1;
        if(s[i]=='S')sa=1;
        if(s[i]=='E')e=1;
        if(s[i]=='N')n=1;
    }
    if(w==e && sa==n){
        cout<<"Yes";
        return 0;
    }
    
    cout<<"No";



    


    return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  string s,t;
 cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  
  if(s<t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<char> vec(N);
  
  string ans = "Three";
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    if (vec.at(i) == 'Y') {
      ans = "Four";
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#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 ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, p, q;
    cin >> n >> p;
    VI d(n);
    REP(i,n) scanf("%d", &d[i]);
    cin >> q;
    VI s(n+1);
    s[0] = p;
    FOR(i,1,n){
        s[i] = min(s[i-1], abs(s[i-1]-d[i-1]));
    }

    if (s[n] != 0){
        REP(i,q) printf("YES\n");
        return 0;
    }

    VI b(n+1);
    b[n] = 1;
    FORR(i,n-1,0){
        if (b[i+1] <= d[i]/2) b[i] = b[i+1];
        else b[i] = b[i+1] + d[i];
    }

    VI ans(n);
    REP(i,n){
        if (s[i] >= b[i+1]) ans[i] = 1;
    }

    while (q--){
        int p;
        cin >> p;
        p--;
        cout << (ans[p] ? "YES" : "NO") << endl;
    }

    return 0;
}

Measured memory_bytes: 9728
'use strict';
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim().split(' ');
 var a = Number(inputs[0]);
 var b = Number(inputs[1]);

 console.log(a*b,(a+b)*2);
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15556
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <functional>
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------

// Binary indexed Tree(BIT)
template <typename T>
struct BIT{
    private:
    vector<T> array;
    const int n;

    public:
    // 初期化
    BIT(int _n) : array(_n+1,0),n(_n) {}

    // 1番目からi番目までの累積和を求める
    T sum(int i){
        T s = 0;
        while(i > 0){
            s += array[i];
            // LSB減算
            i -= i & -i;
        }
        return s;
    }
    
    // [i,j]の要素の総和
    T sum(int i,int j){
        // 1番目からi-1番目までの総和
        T ret_i = sum(i-1);
        // 1番目からj番目までの総和
        T ret_j = sum(j);
        // i番目からj番目までの総和
        return ret_j - ret_i;
    }

    // i番目に要素xを追加
    void add(int i,T x){
        while(i <= n){
            array[i] += x;
            // LSB加算
            i += i & -i;
        }
    }
};


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,Q;
  cin >> N >> Q;
  vector<int> A(N+1);
  for(int i=1; i<=N; i++){
    cin >> A[i];
    A[i]--;
  }
  // r,l,id
  vector<tuple<int,int,int>> q(Q);
  for(int i=0; i<Q; i++){
    int l,r;
    cin >> l >> r;
    q[i] = tuple<int,int,int>(r,l,i);
  }
  BIT<int> bit(N);
  vector<int> c(N,-1);
  vector<int> ans(Q);
  sort(q.begin(),q.end());
  reverse(q.begin(),q.end());
  for(int i=1; i<=N; i++){
    if(c[A[i]] != -1){
      bit.add(c[A[i]],-1);
    }
    c[A[i]] = i;
    bit.add(c[A[i]],1);
    while(q.size()){
      int l,r,id;
      tie(r,l,id) = q.back();
      if(r != i) break;
      q.pop_back();
      ans[id] = bit.sum(l,r);
    }
  }
  for(int i=0; i<Q; i++){
    cout << ans[i] << "\n";
  }
  return 0;
}

Measured memory_bytes: 17396
A, B = map(int, input().split())
# 消費税8%でA円、10%のときB円の消費税が課される
# 税抜き価格は？
# 小数点以下切り捨て

# 税抜きx円
def tax(x):
  return 8 * x // 100, 10 * x // 100

# A = |.08x|
# B = |.10x|

# x >= A / 1.08
# x >= B / 1.10

x = int(min(A / 0.08, B / 0.1))
Xmax = x * 1.5
while x <= Xmax:
  a, b = tax(x)
#  print(x, a, b)
  if a == A and b == B:
    print(x)
    break
  x += 1
else:
  print(-1)

Measured memory_bytes: 61988
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
	stack<int> S1;
	stack<pair<int,int> > S2;
	char ch;
	int sum=0;
	for(int i=0;cin>>ch;i++){
		if(ch=='\\')S1.push(i);
		else if(ch=='/' && S1.size()>0){
			int j=S1.top();S1.pop();
			sum+=i-j;
			int a=i-j;
			while(S2.size()>0 && S2.top().first>j){
				a+=S2.top().second;S2.pop();
			}
			S2.push(make_pair(j,a));
		}
	}
	
	vector<int> ans;
	while(S2.size()>0){ans.push_back(S2.top().second);S2.pop();}
	reverse(ans.begin(),ans.end());
	cout<<sum<<endl;
	cout<<ans.size();
	for(int i=0;i<ans.size();i++){
		cout<<" ";
		cout<<ans[i];
	}
	cout<<endl;
	
	return 0;
}


Measured memory_bytes: 3256
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
D=[]
p=0
s=0
q=0
r=0
for i in range(N):
  D.append(A[i]-B[i])
D.sort(reverse=True)
#print(D)
for i in range(N):
  if D[i]<0:
    s=s+1
    p=p+D[i]
for i in range(N):
  if D[i]>0 and D[i]+r>=abs(p):
    r=r+D[i]
    q=q+1
    break
  else:
    if D[i]>0:
      r=r+D[i]
      q=q+1
    else:
      break
#print("s,p,r",s,p,r,r+p)
if s==0:
  print(0)
else:
  if r<abs(p):
    print(-1)
  else:
    print(s+q)

Measured memory_bytes: 18492
#include<iostream>
#include<algorithm>
using namespace std;
int main ( ){
    long long int n;cin>>n;
    long long int a[n],b[n],c[n],d[n+1][3],k;
    for (long long int i=0;i<n;i++) {
        cin>>a[i]>>b[i]>>c[i];
    }
    d[0][0]=0;d[0][1]=0;d[0][2]=0;
    for (long long int i=1;i<=n;i++) {
        d[i][0]=a[i-1]+max(d[i-1][1],d[i-1][2]);
        d[i][1]=b[i-1]+max(d[i-1][0],d[i-1][2]);
        d[i][2]=c[i-1]+max(d[i-1][0],d[i-1][1]);
    }
    k=max(d[n][0],d[n][1]);
    k=max(d[n][2],k);
    cout<<k<<endl;
}

Measured memory_bytes: 4992
from itertools import combinations
n = int(input())

#cnt for every appearance of each prime number
primelist = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
cntlist = [0]*50
res = 0

for num in range(2,n+1):
    for prime in primelist:
        while(num%prime==0):
            num //= prime
            cntlist[prime] += 1

nonZeroPrime = [prime for prime in primelist if cntlist[prime]!=0]

#print(nonZeroPrime)
#print(cntlist)

#(3,5,5) (2,4,4)
perm = list(combinations(nonZeroPrime,3))
for t in perm:
    nonZeroCnt = [cntlist[prime] for prime in t]
    nonZeroCnt.sort()
    if(nonZeroCnt[0]>1 and nonZeroCnt[1]>3 and nonZeroCnt[2]>3):
        res+=1
    if(nonZeroCnt[0]>=4):
        res+=2

tuples = []
#(5,15) (4,14)
perm = list(combinations(nonZeroPrime,2))
for t in perm:
    nonZeroCnt = [cntlist[prime] for prime in t]
    nonZeroCnt.sort()
    nonZeroCnt = tuple(nonZeroCnt)
    if(nonZeroCnt[0]>=4 and nonZeroCnt[1]>=14):
        res += 1
    if(nonZeroCnt[0]>=14):
        res += 1

#(3,25) (2,24)
for t in perm:
    nonZeroCnt = [cntlist[prime] for prime in t]
    nonZeroCnt.sort()
    nonZeroCnt = tuple(nonZeroCnt)
    if(nonZeroCnt[0]>=2 and nonZeroCnt[1]>=24):
        res += 1
    if(nonZeroCnt[0]>=24):
        res += 1

#(75)

res += len([cnt for cnt in cntlist if cnt>=74])
print(res)
        


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

int bubbleSort(int *numbers, int array_size)
{
  int i, j, temp,count=0;

  for (i = 0; i < (array_size - 1); i++) {
    for (j = (array_size - 1); j > i; j--) {

      if (numbers[j-1] > numbers[j]) {
	count++;
	temp = numbers[j-1];
	numbers[j-1] = numbers[j];
	numbers[j] = temp;
      }
    }
  }
  return count;
}

int main(){
  int array_size,i,count;
  int *numbers;

  scanf("%d",&array_size);

  numbers = (int *)malloc(sizeof(int) * array_size);

  for(i = 0;i<array_size;i++){
    scanf("%d",&numbers[i]);
  }

  count = bubbleSort(numbers,array_size);

  for(i = 0;i<array_size;i++){
    if(i == array_size - 1)
      printf("%d\n",numbers[i]);
    else
      printf("%d ",numbers[i]);
  }

  printf("%d\n",count);

  return 0;

}



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

#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()

using namespace std;

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<vector<int>> A(3, vector<int>(N));
    REP(i, 3) {
        REP(j, N) cin >> A[i][j];
        sort(all(A[i]));
    }
    ll result = 0;
    REP(i, N) {
        ll x = distance(A[0].begin(), lower_bound(all(A[0]), A[1][i]));
        ll y = distance(upper_bound(all(A[2]), A[1][i]), A[2].end());
        result += x * y;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
#include <iomanip>
#include <fstream>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef long long ll;
typedef pair<int,int> pii;

int b[300];
int dist[300];
vector<int> pv[300];

int main() {
  int m;
  cin >> m;
  int a[6];
  REP(i,6) cin >> a[i];
  int s,g;
  cin >> s >> g;
  s--;g--;
  REP(i,m) {
    cin >> b[i];
    pv[i+b[i]].push_back(i);
  }
  queue<int> Q;
  Q.push(g);
  REP(i,m) dist[i] = INF;
  dist[g] = 0;
  while(!Q.empty()) {
    int p = Q.front(); Q.pop();
    FOR(it, pv[p]) {
      REP(i,6) {
        REP(j,2) {
          int d = a[i]*(j?1:-1);
          int np = *it+d;
          if (np<0||np>=m) continue;
          if (dist[np] == INF) {
            dist[np] = dist[p] + 1;
            Q.push(np);
          }
        }
      }
    }
  }
  // REP(i,m) cout << dist[i] << " "; cout << endl;

  int cur = s;
  while(1){
    int dice;
    cin >> dice;
    dice--;

    int f = 0;
    REP(j,2) {
      int d = a[dice]*(j?1:-1);
      int nc = cur+d;
      if (nc<0||nc>=m) continue;
      nc = nc + b[nc];
      if (dist[nc] < dist[cur]) {
        f = (j?1:-1);
        cur = nc;
        break;
      }
    }
    printf("%d\n", f); fflush(stdout);
    if (cur == g) break;
  }
}

Measured memory_bytes: 1304
#include<stdio.h>
#include<math.h>

/*studentID:107033227 Name:Mark Yeh Department:PME22*/

int main()
{
    int a,b,sum,i;
   while(scanf("%d %d", &a, &b)!=EOF)
   {
       int i=1;
       sum=a+b;
       do
       {
           sum=sum/10;
           i++;
       }while(sum!=0);
       printf("%d\n",i-1);
   }
   return 0;
}



Measured memory_bytes: 1904
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

MOD = 10**9 + 7


B = [0] * N

for i in range(len(A)-1):
    cnt = 0
    for j in range(i+1, len(A)):
        if A[j] < A[i]:
            cnt += 1
    B[i] = cnt
# print(B)


C = [0] * N

for i in range(len(A)):
    cnt = 0
    for j in range(len(A)):
        if j != i:
            if A[i] > A[j]:
                cnt += 1
    C[i] = cnt
# print(C)    

D = []
for i in range(N):
    tmp = B[i] * K + C[i] * K * (K-1) // 2 
    D.append(tmp % MOD)
print(sum(D)% MOD)

Measured memory_bytes: 9232
#include <iostream>

int main(void){
    using namespace  std;

    int N;
    cin >> N;

    for (int i = 1; i < 10;i++){
        if(N%i==0 && N/i < 10){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	long long n; cin >> n;
	if (!n) { cout << "0\n"; return 0; }
	string ans;
	while (n != 0) {
		ans = ((n%-2) ? '1' : '0') + ans;
		if (n%-2)n--;
		n /= -2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Here your code !

def func():
    try:
        line=input().rstrip()
        list=line.split(" ")
        a=int(list[0])
        b=int(list[1])
    except:
        print("input error")
        return -1
    
    print(str(a*b)+" "+str(a*2+b*2))

func()

Measured memory_bytes: 7628
#include "bits/stdc++.h"
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define ld           long double
#define vi           vector<int>
#define pii          pair<int,int>
#define pb           push_back
#define mp           make_pair
#define ff           first
#define ss           second
#define endl         '\n'
#define rep(i,s,e)   for(int i=(s);i<=(e);i++)
#define brep(i,s,e)  for(int i=(s);i>=(e);i--)
#define all(x)       (x).begin(),(x).end()
#define ball(x)      (x).rbegin(),(x).rend()
#define sz(x)        (int)x.size()
#define mem(x,y)     memset(x,(char)y,sizeof(x))
#define milf(x)      x.reserve(1LL<<14LL); x.max_load_factor(0.25); // less_equal
#define pbds         tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
mt19937              rng(chrono::steady_clock::now().time_since_epoch().count());
#define int          long long
const int INF = 0x3F3F3F3F3F3F3F3F;
const int MOD = 1e9+7;
ld EPS = 1e-12;


short rain()
{
    // int t;cin>>t;rep(test,1,t)
    {
        string s, t;
        cin >> s >> t;
        int ans = 0;
        int n = s.length();
        rep(i,0,n-1)
        {
            if( s[i]!=t[i] )
                ans++;
        }
        cout << ans << endl;
    }

    return 0;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    // freopen("ip.txt","r",stdin);
    // freopen("op.txt","w",stdout);
    int tt = 1000*clock()/CLOCKS_PER_SEC;
    cout<<fixed<<setprecision(15);rain();
    cerr<<1000*clock()/CLOCKS_PER_SEC-tt<<"ms\n";
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string w;
    cin >> w;
    int count = 0;
    sort(w.begin(), w.end());
    for (int i = 0; i < w.size(); ++i) {
        if ((w[i] != w[i + 1]) && (i % 2 == 0)) ++count;
    }
    cout << (count == 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
 
typedef struct{
    long long int code;
    int steps;
} puzz;
 
int q[1000000][14],size[500000];
long long int FR,TO,SW;
puzz* hash[500000][10];
 
void swap (int* x,int* y){
    int z;
    z=*x;
    *x=*y;
    *y=z;
}
 
long long int convert(int a[]){
    long long int ret=0;
    int i;
    for(i=0;i<13;i++)ret=ret*13+a[i];
    return ret;
}
 
void hashadd(long long int code,int step){
    int ccc=code%500000;
    puzz* ppp=(puzz*)malloc(sizeof(puzz));
    ppp->code=code;
    ppp->steps=step;
    if(size[ccc]>9){fprintf(stderr,"SIZE OVER!! (%d)\n",ccc);return;}
    hash[ccc][size[ccc]]=ppp;
    size[ccc]++;
}
 
int hashsearch(long long int code){
    int ccc=code%500000;
    int i=size[ccc]-1;
    for(;i>=0;i--){
        if(hash[ccc][i]->code==code)return hash[ccc][i]->steps;
    }
    return -1;
}
 
void mark(int x,int y){
    int k;
    long long int cd;
 
    swap(&q[FR][x],&q[FR][y]);
    cd=convert(q[FR]);
 
    if(SW==1 || hashsearch(cd)<0){
        for(k=0;k<14;k++){q[TO][k]=q[FR][k];}
        q[TO][13]++;
        if(SW==0)hashadd(cd,q[TO][13]);
        TO++;
    }
 
    swap(&q[FR][x],&q[FR][y]);
 
}
 
void check(){
    if(q[FR][0]==0){mark(0,2);}
    if(q[FR][1]==0){mark(1,2);mark(1,5);}
    if(q[FR][2]==0){mark(2,0);mark(2,1);mark(2,3);mark(2,6);}
    if(q[FR][3]==0){mark(3,2);mark(3,7);}
    if(q[FR][4]==0){mark(4,5);}
    if(q[FR][5]==0){mark(5,1);mark(5,4);mark(5,6);mark(5,9);}
    if(q[FR][6]==0){mark(6,2);mark(6,5);mark(6,7);mark(6,10);}
    if(q[FR][7]==0){mark(7,3);mark(7,6);mark(7,8);mark(7,11);}
    if(q[FR][8]==0){mark(8,7);}
    if(q[FR][9]==0){mark(9,5);mark(9,10);}
    if(q[FR][10]==0){mark(10,6);mark(10,9);mark(10,11);mark(10,12);}
    if(q[FR][11]==0){mark(11,7);mark(11,10);}
    if(q[FR][12]==0){mark(12,10);}
}
 
 
int main(){
    int i,ans;
    long long int cd;
 
    for(i=1;i<12;i++)q[0][i]=i;
    q[0][0]=0;q[0][12]=0;q[0][13]=0;
    hashadd(convert(q[0]),0);
 
    FR=0;TO=1;SW=0;
 
    while(FR<TO && q[FR][13]<=13){
        check();
        FR++;
    }

    while(scanf("%d",&q[0][0])*q[0][0]>=0){
        for(i=1;i<13;i++)scanf("%d",&q[0][i]);
        q[0][13]=0;FR=0;TO=1;SW=1;ans=9999;
 
        while(FR<TO){
            cd=hashsearch(convert(q[FR]));
            if(cd>=0){
                ans=(int)cd+q[FR][13];
                break;
            }
            if(q[FR][13]<6)check();
            FR++;
        }
 
        if(ans>20)printf("NA\n"); else printf("%d\n",ans);
    }
 
    return 0;
}

Measured memory_bytes: 54116
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n,k=n1()
P=n1()
P.sort()
print(sum(P[:k]))

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  if ((N % 10 == 9) || (N - (N % 10) == 90)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
		try{
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			int T = sc.nextInt();
			int[] input = new int[N];
			long result = T;
			input[0] = sc.nextInt();
			for(int i = 1; i < N; i++){
				input[i] = sc.nextInt();
				if(input[i] - input[i-1] <= T){
					result += input[i] - input[i-1];
				}else{
					result += T;
				}
			}
			System.out.println(result);
			
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 64548
#include <algorithm>
#include <bitset>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pp;       // int aa = pp.first;
typedef tuple<int, int, int> tp; // int aa = get<0>(tp);

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

int all[100100];

class BIT {
public:
  vector<int> bit;
  int M;

  BIT(int M) : bit(vector<int>(M + 1, 0)), M(M) {}

  int get(int i) const {
    // if (!i)
    //   return 0;
    // return bit[i] + get(i - (i & -i));
    int sum = 0;
    for (int x = i; x > 0; x -= x & -x)
      sum += bit[x];
    return sum;
  }

  void add(int i, int x) {
    // if (i > M)
    //   return;
    // bit[i] += x;
    // add(i + (i & -i), x);
    for (int in = i; in < M; in += in & -in)
      bit[in] += x;
  }
};

void solve(long long N, long long M, vector<long long> l, vector<long long> r) {
  BIT bit(100010);

  vector<tp> vtp;
  REP(i, N) { vtp.push_back(tp(r[i] - l[i] + 1, l[i], r[i])); }
  sort(ALL(vtp));

  int pc = 0;
  FOR(m, 1, M + 1) {
    ll ans = 0;

    while (pc < N && get<0>(vtp[pc]) < m) {
      bit.add(get<1>(vtp[pc]), 1);
      bit.add(get<2>(vtp[pc]) + 1, -1);
      pc++;
    }

    ans += N - pc;

    for (int v = m; v <= 100000; v += m) {
      ans += bit.get(v);
    }

    cout << ans << endl;
  }
}

int main() {
  ios::sync_with_stdio(false);
  long long N;
  long long M;
  cin >> N;
  vector<long long> r(N - 1 + 1);
  vector<long long> l(N - 1 + 1);
  cin >> M;
  for (int i = 0; i <= N - 1; i++) {
    cin >> l[i];
    cin >> r[i];
  }
  solve(N, M, l, r);
  return 0;
}


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

int gcd(int a, int b){
  int x,y,temp;
  if(a >= b){
    x = a;
    y = b;
  }else{
    x = b;
    y = a;
  }
  
  while(1){
    temp = x%y;
    if(temp==0){
      return y;
      break;
    }else{
      x = y;
      y = temp;
    }
  }
  
}
    
    
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  
  int ans=a[0];
  for(int i=1;i<n;i++){
    ans = gcd(ans,a[i]);
  }
  cout<<ans<<endl;
  
  return 0;
}
  

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

int main() {
  ll x, y;
  cin >> x >> y;
  ll ans;
  if (x * y > 0) {
    if (x <= y) ans = y - x;
    else ans = x - y + 2;
  } else if (x * y < 0) {
    ans = abs(abs(x) - abs(y)) + 1;
  } else if (x > y) {
    ans = x - y + 1;
  } else {
    ans = -x + y;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    S=input()
    w=I()
    ans=[]
    for i in range(0,len(S),w):
        ans.append(S[i])
        
    print(''.join(map(str,ans)))

main()


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

int main() {
	int n;
	cin >> n;
	int a = 0, b = 0;
	for (int i = 0; i < n; i++) {
		string w1, w2;
		cin >> w1 >> w2;
		int s1 = w1.size();
		int s2 = w2.size();

		int N;
		if (s1 >= s2) N = s2;
		else N = s1;
        
		if (w1[0] == w2[0]) {
			int c = 0;
			if (s1 == 1 && s2 == 1) {
				a++;
				b++;
			}
			int a_tmp = a;
			int b_tmp = b;

			for (int j = 1; j < N; j++) {
				if (w1[j] > w2[j]) {
					a = a + 3;
					break;
				}
				else if (w1[j] < w2[j]) {
					b = b + 3;
					break;
				}
				else if (s1 == s2 && w1[s1 - 1] == w2[s2 - 1]) {
					c = 1;
				}
			}
			if (a == a_tmp && b == b_tmp && s1 > s2) {
				a = a + 3;
			}
			else if (a == a_tmp && b == b_tmp && s1 < s2) {
				b = b + 3;
			}

			if (c == 1) {
				a++;
				b++;
			}

		}
		else if (w1[0] > w2[0]) {
			a = a + 3;
		}
		else b = b + 3;
	}
	cout << a << ' ' << b << endl;

	return 0;
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
#define N 1000000
using namespace std;

int main(){
 int pol[201],ans[N],ans2[N];

 for(int i=0;i<N;i++)ans[i]=ans2[i]=N;
 for(int i=1;i<201;i++){
   pol[i]=i*(i+1)*(i+2)/6;
   if(pol[i]<N){
     ans[pol[i]]=1;
   if(pol[i]%2)ans2[pol[i]]=1;
   }
 }
 for(int i=1;i<=N;i++)
   for(int j=1;j<201;j++){
     if(i-pol[j]>=0 && pol[j]<N) ans[i]=min(ans[i-pol[j]]+ans[pol[j]],ans[i]);
     if(i-pol[j]>=0 && pol[j]%2 && pol[j]<N)ans2[i]=min(ans2[i-pol[j]]+ans2[pol[j]],ans2[i]);
   }
 while(1){
   
  int n;
   cin>>n;
   if(n==0) break;
  cout<<ans[n]<<" "<<ans2[n]<<endl;
 }

  
  return 0;
}

Measured memory_bytes: 8972
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

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

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

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

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int main() {
	int N; cin >> N;
	while(N--) {
		double x[4], y[4];
		for(int i = 0; i < 4; i++) {
			cin >> x[i] >> y[i];
		}
		if((y[1] - y[0]) / (x[1] - x[0]) == (y[3] - y[2]) / (x[3] - x[2])) {
			cout << "YES" << endl;
		} else
			cout << "NO" << endl;
	}
	return 0;
}

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

int main(){
	float n, x, s;
	string u;
	cin >> n;
	s = 0;
	for (int i = 0; i < n; ++i){
		cin >> x >> u;
		s += x * (u == "JPY" ? 1 : 380000);
	}
	cout << s;
}

Measured memory_bytes: 256
is_prime = [True for i in range(10**3+1)]
is_prime[0] = is_prime[1] = False
primes = []
for i in range(2, len(is_prime)):
    if is_prime[i]:
        primes.append(i)
        for j in range(i*2, len(is_prime), i):
            is_prime[j] = False

prime_num_mapping = {p: 0 for p in primes}
def count(x):
    for p in primes:
        while x % p == 0:
            prime_num_mapping[p] += 1
            x /= p
        if x == 1:
            break
ans = 1
N = int(raw_input())
for x in range(N, 0, -1):
    count(x)
for k, v in prime_num_mapping.items():
    ans = (ans * (v+1)) % (10**9+7)
print ans

Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int dp[(1<<26)];
string s;
int main(){
	cin>>s;
	int n=s.size();
	rep(i,(1<<26)) dp[i] = INF;
	dp[0] = 0;
	int cur = 0;
	for(int i=0;i<s.size();i++){
		cur ^= (1<<(s[i]-'a'));
		int v = dp[cur]+1;
		for(int j=0;j<26;j++){
			int cur2 = cur ^ (1<<j);
			v = min(v,dp[cur2]+1);
		}
		dp[cur] = min(dp[cur],v);
	}
	if(dp[cur]==0) dp[cur]=1;
	cout<<dp[cur]<<endl;
}

Measured memory_bytes: 262660
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";


    void Solve()
    {
        var T = cin.Scanint;
        if (T[0] <= T[2] && T[2] <= T[1])
        {
            WriteLine("Yes");
        }
        else
        {
            WriteLine("No");
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

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

int main(){
    int N;
    cin >>N;
    string S;
    cin >>S;
    int x=0;
    int max_x=0;
    for(int i=0;i<N;i++){
      if(S.at(i)=='I')x++;
      else if(S.at(i)=='D')x--;
      max_x=max(max_x,x);
    }
    cout<<max_x<<endl;
  }


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int n;
	char s[1000];
	scanf("%d", &n);
	scanf("%s", s);
	char ans[1000];
	if (n == 1) {
		printf("No\n");
		return 0;
	}
	else {
		int cnta = 0;
		for (int i = 0; i < n / 2; i++) {
			ans[i] = s[i];
		}
		for (int i = n / 2 ; s[i] != '\0'; i++){
			if (ans[cnta++] != s[i]) {
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
X, Y, Z, K = map(int, input().split())
# A = list(map(int, input().split()))
# A.sort(reverse=True)
# B = list(map(int, input().split()))
# B.sort(reverse=True)
# C = list(map(int, input().split()))
# C.sort(reverse=True)
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

AB = []
ABC = []
for b in B:
    for a in A:
        AB.append(a+b)
AB.sort(reverse=True)
AB = AB[:K+1]

for c in C:
    for ab in AB:
        ABC.append(ab+c)
ABC.sort(reverse=True)
for i in range(K):
    print(ABC[i])

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

int main()
{
	string s, t;
	cin >> s;
	cin >> t;

	int ssize = static_cast<int>(s.size());
	int tsize = static_cast<int>(t.size());
	int ret = tsize;
	for (int i = 0; i < (ssize - tsize + 1); ++i) {
		int temp = 0;
		for (int j = 0; j < tsize; ++j) {
			if (s[i + j] != t[j]) {
				++temp;
			}
		}
		ret = min(ret, temp);
	}
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 3628
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int all = sc.nextInt();
        String s = sc.next();
        s = s.replaceAll("B","");
        int R = s.length();
        if(all - R >= R || all-R == 0){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }

    }
}

Measured memory_bytes: 21712
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int as;
int a[30000];
int bs;
int b[30000];
int cs;
int c[30000];
int res[20000];
int ress;
int main(){
  int i;
  rd(N);
  for(i=(30001)-1;i>=(1);i--){
    if(i%6==0){
      c[cs++] = i;
      continue;
    }
    if(i%2==0){
      a[as++] = i;
      continue;
    }
    if(i%3==0){
      b[bs++] = i;
      continue;
    }
  }
  if(N==3){
    res[ress++] = 2;
    res[ress++] = 5;
    res[ress++] = 63;
  }
  else{
    int Q5VJL1cS, RZTsC2BF;
    for(Q5VJL1cS=(0);Q5VJL1cS<(2);Q5VJL1cS++){
      res[ress++] = a[--as];
      N--;
    }
    for(RZTsC2BF=(0);RZTsC2BF<(2);RZTsC2BF++){
      res[ress++] = b[--bs];
      N--;
    }
    while(as >= 2 && N >= 2){
      int KrdatlYV;
      for(KrdatlYV=(0);KrdatlYV<(2);KrdatlYV++){
        res[ress++] = a[--as];
        N--;
      }
    }
    while(bs >= 2 && N >= 2){
      int V9aVTaxx;
      for(V9aVTaxx=(0);V9aVTaxx<(2);V9aVTaxx++){
        res[ress++] = b[--bs];
        N--;
      }
    }
    while(cs >= 1 && N >= 1){
      res[ress++] = c[--cs];
      N--;
    }
  }
  {
    int ZIeRIny5;
    if(ress==0){
      putchar_unlocked('\n');
    }
    else{
      for(ZIeRIny5=(0);ZIeRIny5<(ress-1);ZIeRIny5++){
        wt_L(res[ZIeRIny5]);
        wt_L(' ');
      }
      wt_L(res[ZIeRIny5]);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20191125-1

// --- original code ---
// int N;
// int as, a[30000];
// int bs, b[30000];
// int cs, c[30000];
// int res[20000], ress;
// {
//   rd(N);
//   rrep(i,1,30001){
//     if(i%6==0) c[cs++] = i, continue;
//     if(i%2==0) a[as++] = i, continue;
//     if(i%3==0) b[bs++] = i, continue;
//   }
//   if(N==3){
//     res[ress++] = 2;
//     res[ress++] = 5;
//     res[ress++] = 63;
//   } else {
//     rep(2) res[ress++] = a[--as], N--;
//     rep(2) res[ress++] = b[--bs], N--;
//     while(as >= 2 && N >= 2) rep(2) res[ress++] = a[--as], N--;
//     while(bs >= 2 && N >= 2) rep(2) res[ress++] = b[--bs], N--;
//     while(cs >= 1 && N >= 1) res[ress++] = c[--cs], N--;
//   }
//   wt(res(ress));
// }
// 


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

int main(void)
{
    using namespace std;

    string str;
    cin >> str;
    string s = str + str;
    string p;
    cin >> p;
    
    if (s.find(p) != string::npos) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define maxn 100010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;

const int mod = 1e9 + 7;

ll dp[maxn][13];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); 
  string str;
  cin >> str;
  int n = str.length();
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    int c;
    if (str[i] == '?') c = -1;
    else c = str[i] - '0';
    for (int j = 0; j < 10; ++j) {
      if (c != -1 && c != j) continue;
      for (int k = 0; k < 13; ++k) {
        dp[i + 1][(k * 10 + j) % 13] = (dp[i + 1][(k * 10 + j) % 13] + dp[i][k]) % mod;
      }
    }
  }
  cout << dp[n][5] << endl;  
}


Measured memory_bytes: 10604
#include "bits/stdc++.h"
using namespace std;
#define rep(i, N) for (int (i) = 0; (i) < (N); (i)++)
typedef pair<long long, long long> P;

int main() {
	string S, T;
	cin >> S >> T;
	T.pop_back();
	if (S == T) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

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

    string s;
    cin >> s;

    int ss = s.size();

    int cnt = 0;
    for(int i = 0; i < ss / 2; i++){
        if(s[i] != s[ss - i - 1]){
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
using System;

class Program {
  static void Main(string[] args) {
    int N, L;
    string[] strs;
    string[] buf = Console.ReadLine().Split(' ');

    N = int.Parse(buf[0]);
    L = int.Parse(buf[1]);
    strs = new string[N];
    for(int i = 0; i < N; ++i)
      strs[i] = Console.ReadLine();
    
    Array.Sort(strs);
    foreach(string s in strs)
      Console.Write(s);
    Console.WriteLine();
  }
}


Measured memory_bytes: 13408
# -*- coding: utf-8 -*-

def hitachi2020b(a, b, discount):
    min_a = a[0]
    for i in range(len(a)):
        if a[i] < min_a:
            min_a = a[i]
    min_b = b[0]
    for i in range(len(b)):
        if b[i] < min_b:
            min_b = b[i]
    min_val = min_a + min_b

    for k in range(len(discount)):
        disc = discount[k]
        cand_a = disc[0] - 1
        cand_b = disc[1] - 1
        cand_val = a[cand_a] + b[cand_b] - disc[2]
        if cand_val < min_val:
            min_val = cand_val

    return min_val

###
# main
if(__name__ == '__main__'):
    # input
    num_a, num_b, m = map(int, input().split(" "))
    val_a = list(map(int, input().split(" ")))
    val_b = list(map(int, input().split(" ")))

    discount = []
    for k in range(m):
        discount.append(list(map(int, input().split(" "))))
    
    accomplishment = hitachi2020b(val_a, val_b, discount)
    
    # output
    print(accomplishment)
# else:
    # do nothing


Measured memory_bytes: 38492