akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
//ここから

void solve(){
  string s;
  cin>>s;
  int n=s.size();
  int ans=n+5;
  rep(a,2){
    int cnt=(s[0]-'0')!=a;
    string t=s;
    t[0]=char('0'+a);
    rep(i,n-1){
      if(t[i+1]==t[i]){
        ++cnt;
        if(t[i]=='0')t[i+1]='1';
        else t[i+1]='0';
      }
    }
    //cerr<<t<<endl;
    chmin(ans,cnt);
  }
  cout<<ans;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


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

using namespace std;

int N;
int maxHeight = 0;
int cnt = 0;

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int nowHeight;
		cin >> nowHeight;

		if (nowHeight >= maxHeight)
		{
			maxHeight = nowHeight;
			cnt += 1;
		}
	}

	cout << cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>  
using namespace std;
using namespace __gnu_pbds;

#define int long long int
#define float long double
#define pb push_back
#define fi first
#define se second
#define vii vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define pq priority_queue<int>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) int a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define mem(a,k) memset(a,k,sizeof(a))
#define ub upper_bound
#define lb lower_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mii map<int,int>
#define all(v) v.begin(),v.end()
#define mod (int)(998244353)
#define inf LLONG_MAX
int exp(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int modinv(int x){return exp(x,mod-2);}


signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n,k,ans;
	cin>>n>>k;
	int a[n+1]={0};
	pii seg[k];
	for(int i=0;i<k;i++)
		cin>>seg[i].fi>>seg[i].se;
	int dif[n+10]={0};
	dif[1]+=1;
	dif[2]-=1;
	for(int i=1;i<=n;i++)
	{
		a[i]=(dif[i]+a[i-1])%mod;
		for(int j=0;j<k;j++)
		{
			if(i+seg[j].fi>n)
				continue;
			int l=i+seg[j].fi;
			int r=min(n,i+seg[j].se);
			dif[l]=(dif[l]+a[i])%mod;
			dif[r+1]=((dif[r+1]-a[i])%mod+mod)%mod;
		}
	}
	cout<<a[n];
	return 0;
}

Measured memory_bytes: 6760
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AnandOza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EAlmostEverywhereZero solver = new EAlmostEverywhereZero();
        solver.solve(1, in, out);
        out.close();
    }

    static class EAlmostEverywhereZero {
        int n;
        int[] digits;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] input = in.next().toCharArray();
            n = input.length;
            digits = new int[n];
            for (int i = 0; i < n; i++) {
                digits[i] = input[i] - '0';
            }
            int k = in.nextInt();

            long answer = f(0, k, true);

            out.println(answer);
        }

        private long f(int i, int k, boolean equal) {
            if (k == 0)
                return 1;

            long answer = 0;
            for (int j = i; j < n; j++) {
                if (equal) {
                    answer += digits[j] == 0 ? 0 : f(j + 1, k - 1, true);
                    answer += Math.max(digits[j] - 1, 0) * f(j + 1, k - 1, false);
                } else {
                    answer += 9 * f(j + 1, k - 1, false);
                }
                if (digits[j] > 0)
                    equal = false;
            }
            return answer;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main() {
  int N;
  cin >> N;
  vector<int> data(N);
  int max, semimax;
  for(int i = 0; i < N; i++) {
    int a;
    cin >> a;
    data.at(i) = a;
    if(i == 0) {
      max = a;
    }
    else if(i == 1) {
      if(a > max) {
        semimax = max;
        max = a;
      }
      else {
        semimax = a;
      }
    }
    else if(a > max) {
      semimax = max;
      max = a;
    }
    else if(a > semimax) {
      semimax = a;
    }
  }
  for(int i = 0; i < N; i++) {
    if(data.at(i) != max) {
      cout << max << endl;
    }
    else {
      cout << semimax << endl;
    }
  }
}

Measured memory_bytes: 3984
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    ll x;
    cin >> x;
    int t = 10 - x / 200;
    cout << min(t, 8) << endl;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int MOD = 1e9 + 7;

void solve_test() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];

	int answer = 0;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		answer = (answer + sum * a[i] % MOD) % MOD;

		sum = (sum + a[i]) % MOD;
	}

	cout << answer << '\n';
}

int32_t main() {
	int T; 
	// cin >> T;
	T = 1;
	while (T--)
		solve_test();

	return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;


int main(){
   vector<string>l;
   string s;cin>>s;
   ll k;cin >>k;
   ll n=s.size();
    for (int i = 1; i <=k ; ++i) {//長さ固定
        for (int j = 0; j <=n - i; ++j) {
            l.push_back(s.substr(j,i));
        }
    }
    sort(all(l));
    l.erase(unique(all(l)),l.end());
    //for(auto v:l){
      //  cout <<v<<endl;
    //}
    cout <<l[k-1]<<endl;
    return 0;
}

Measured memory_bytes: 1660
n,m=map(int,input().split())
ps=[]
x=[[0,0] for i in range(n)]
#0がWA、1がAC
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    ps.append([p,s])

for i in range(m):
    p,s=ps[i]
    if s=="WA":
        if x[p][0]==0:
            x[p][1]+=1
        else:
            pass
    else:
        if x[p][0]==0:
            x[p][0]=1
            #x[p][1]+=1
        else:
            pass
c1,c2=0,0
for i in range(n):
    if x[i][0]==1:
        c1+=1
        c2+=x[i][1]
print(c1,end=" ")
print(c2)


Measured memory_bytes: 32256
def calcTotalOfRowAndCol(matrix, r, c):
    for l in matrix:
        total = 0
        for val in l:
            total += val
        l.append(total)
    matrix.append([])
    for i in range(c + 1):
        total = 0
        j = 0
        while j < r:
            total += matrix[j][i]
            j += 1
        matrix[r].insert(i, total)

if __name__ == '__main__':
    matrix = []
    row, col = [int(x) for x in input().split()]
    i = row
    while i > 0:
        matrix.append([int(y) for y in input().split()])
        i -= 1
    calcTotalOfRowAndCol(matrix, row, col)
    for l in matrix:
        print(' '.join(str(x) for x in l))

Measured memory_bytes: 7760
def solve():
    from sys import stdin
    f_i = stdin
    
    while True:
        N, T, L, B = map(int, f_i.readline().split())
        if N == 0:
            break
        
        skip = {}
        sq_attr = [None] * N
        for i in range(L):
            sq = int(f_i.readline())
            sq_attr[sq] = 'Lose'
            skip[sq] = 0
        for i in range(B):
            sq_attr[int(f_i.readline())] = 'Back'
        
        dp1 = [0] * N
        dp2 = [0] * N
        dp1[0] = 1
        ans = 0
        
        for i in range(T):
            for sq, pr in skip.items():
                tmp = dp1[sq]
                dp1[sq] = pr
                skip[sq] = tmp
            for sq, pr in enumerate(dp1):
                if pr == 0:
                    continue
                
                new_pr = pr / 6
                for next_sq in range(sq + 1, sq + 7):
                    if next_sq > N:
                        next_sq = 2 * N - next_sq
                    elif next_sq == N:
                        ans += new_pr
                        continue
                    
                    if sq_attr[next_sq] == 'Back':
                        next_sq = 0
                    dp2[next_sq] += new_pr
                    
            dp1 = dp2
            dp2 = [0] * N
        
        print('{:.6f}'.format(ans))

solve()


Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int ans;
char s[maxn];
int main()
{
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	string pre, cur;
	for(int i = 1; i <= n; ++i)
	{
		if(cur + s[i] != pre)
		{
			++ans;
			pre = cur + s[i];
			cur.clear();
		}
		else
			cur += s[i];
	}
	printf("%d\n", ans);
	return 0;
}
			

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

long long int mem[100006];


long long int frog_dp(long long int i,long long int n,long long int ht[])
{
    if(i>=n)return 0;
    if(mem[i]!=-1)return mem[i];
    mem[i]=min(frog_dp(i+1,n,ht)+abs(ht[i+1]-ht[i]),frog_dp(i+2,n,ht)+abs(ht[i+2]-ht[i]));
    return mem[i];
}

int main()
{
    long long int n,i,c;
    cin>>n;
    long long int ht[n+3];
    for(i=1; i<=n; i++)
        cin>>ht[i];
        ht[n+1]=9999999999999;

        memset(mem,-1,sizeof(mem));
    c=frog_dp(1,n,ht);
    cout<<c<<endl;


    return 0;
}


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

int main(){
   
    int N;
    cin>>N;
    vector<int> A(100003);
    for(int i=0;i<N;i++){
        int k;cin>>k;
        A[k]++;
        A[k+1]++;
        A[k+2]++;
    }
    sort(A.begin(),A.end());
    cout<<A.at(100002)<<endl;
}


Measured memory_bytes: 640
n, Q = [int(i) for i in input().split(" ")]
deepx = [-1] * (n-2)
deepy = [-1] * (n-2)
queries = [[0, 0] for i in range(Q)]
for i in range(Q):
  queries[i] = [int(j) for j in input().split(" ")]

curx = n-2
cury = n-2
ans = 0

for q in queries:
  d = q[0]
  pos = q[1]-2
  if d == 1:
    if curx < pos:
      ans += deepx[pos]
    else:
      ans += cury
      for i in range(pos+1, curx):
        deepx[i] = cury
      curx = pos
  else:
    if cury < pos:
      ans += deepy[pos]
    else:
      ans += curx
      for i in range(pos+1, cury):
        deepy[i] = curx
      cury = pos
  # print("curx", curx)
  # print("cury", cury)
  # print("ans", ans)
print((n-2)**2-ans)

Measured memory_bytes: 116192
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
using namespace std;
typedef long long int ll;
const int MOD = 1000000007;

int main(){
  int N,L;
  string s[110];
  cin >> N >> L;
  for(int i=0;i<N;i++){
    cin >> s[i];
  }
  sort(s,s+N);
  for(int i=0;i<N;i++){
    cout << s[i];
  }
  cout << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  double sum=0.0;
  cin >> N;
  vector<int> vec(N); 
  
  for(int i=0;i<N;i++ ){
    cin >> vec.at(i);
    //cout << vec.at(i)<<endl;
    sum=sum+(1.0/vec.at(i));
    //cout << sum<< endl;
  } 
//  cout << 1.0/sum<< endl;
  cout.precision(20);cout<<showpoint<<1.0/sum<<endl;
}  

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

int main(){
  int n,ptr=0,res=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
      cin>>a[i];
  }
  sort(a,a+n);
  while(ptr<n){
      int cc=a[ptr],f=0;
      while(ptr<n&&a[ptr]==cc){
          f++;
          ptr++;
      }
      res+=f%2;
  }
  cout<<res<<endl;

}

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

int main()
{
  int x, y, z, cnt = 0;
  cin >> x >> y >> z;

  x -= z;

  while (1)
  {
    if (x < y + z)
    {
      break;
    }

    x -= y + z;
    cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int d=1<<k;
    cout<<max({a*d+b+c,a+b*d+c,a+b+c*d})<<endl;
}


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

int main(){
  int n,y; cin>>n >>y;
  y/=1000;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n-i;j++){
      if(10*i+5*j+n-i-j==y){
        cout<<i<<" "<<j<<" "<<n-i-j<<endl;
        return 0;
      }
    }
  }
  cout<<"-1 -1 -1"<<endl;
}

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

int main() {
	string S;
	cin >> S;

	if( S.at( 0 ) == S.at( 1 ) || S.at( 1 ) == S.at( 2 ) || S.at( 2 ) == S.at( 3 ) ) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Deque<Integer> ad = new ArrayDeque<Integer>();

		for(int i = 0; i < n; i++) {
			if(i%2==n%2) {
				ad.offerLast(a[i]);
			} else {
				ad.offerFirst(a[i]);
			}
		}
		for(int num : ad) {
			System.out.print(num+" ");
		}
		System.out.println();
	}
}

Measured memory_bytes: 92320
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	string s,t;

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

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

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

    vl b;
    b.resize(n-1);
    REP(i,n-1) cin>>b[i];


    vl a(n);
    ll ans = 0;

    a[0] = b[0];
    a[n-1] = b[n-2];
    FORR(i,1,n-1){
        a[i] = min(b[i],b[i-1]);
    }
    //DEBUG_VEC(a);

    REP(i,n){
        ans += (ll)a[i];
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    
    int n, l; cin >> n >> l;
    vector<string> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    sort(v.begin(), v.end());
    for(int i = 0; i < n; i++) cout << v[i];
    cout << endl;
    return 0;
}



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

int main() {
	// your code goes here
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i]; 
	}
	int count;
	count=0;
	sort(a,a+n);
	for(int i=0;i<n-1;i++){
		if(a[i]==a[i+1]){
			count=1;
			break;
			
		}		
	}
	if(count==0)
	cout << "YES" << endl;
	else cout << "NO" << endl;
		
	
	return 0;
	
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int read() {
	char c=getchar(); int x=0,f=1;
	while (c<'0' || c>'9') {
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int main() {
	int a=read(),b=read();
	if (a<b) printf("0\n");
	else printf("10\n");
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i).sort

tmp = a[-1] / 2.0
idx = a.bsearch_index { |i| i > tmp }

print a[-1]
puts tmp - a[idx - 1] <= a[idx] - tmp ? " #{a[idx - 1]}" : " #{a[idx]}"

Measured memory_bytes: 10096
fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(" ").map { it.toInt() }
    if (x == 0 || y == 0 || x < 0 && y > 0) println("Zero")
    else {
        val n =  y - x
        (if (x > 0 || n % 2 != 0) "Positive" else "Negative").let { println(it) }
    }
}


Measured memory_bytes: 36376
#include<iostream>
#include<string>
#include<utility>
#include<map>
#include<algorithm>
#include<cstdio>
#define Fast ios_base :: sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int main() {
    Fast;
    int n, m;
    cin >> n;
    map<string, int> blue, red;
    int i;
    string s;
    for(i=0; i<n; i++){
        cin >> s;
        blue[s]++;
        //red[s] = 0;
    }
    cin >> m;
    for(i=0; i<m; i++){
        cin >> s;
        red[s]++;
        //if()
    }
    int count = 0;
    for(auto it=blue.begin(); it!=blue.end(); it++){
        //count = max(count, blue[i].second - red[i].second);
        //cout << it->first << " " << it->second << endl;
        //cout << red[it->first] << endl;
        //int tmp =
        count = max(count, it->second-red[it->first]);
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
import sys


def main():
    N = int( sys.stdin.readline() )
    c_list = list(sys.stdin.readline().rstrip())
    

    cnt = 0
    L = 0
    R = len(c_list) - 1

    while L < R:
        if (c_list[L] == "W") and (c_list[R] == "R"):
            c_list[L], c_list[R] = c_list[R], c_list[L]
            cnt += 1
            L += 1
            R -= 1
        elif c_list[L] == "R":
            L += 1
        elif c_list[R] == "W":
            R -= 1
    
    
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10772
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n, x, t;
  cin >> n >> x >> t;
  cout << (n+x-1)/x*t << endl;
  return 0;
}

Measured memory_bytes: 3636
N = int(input())
A = list(map(int, input().split()))
MOD=1000000007

# cnt[x]: 赤、青、緑の中で、帽子の人数がAi人の色の数(0<=cnt[x]<=3)
# A[0]=0（最初の人は前に人がいないため）ので、cnt[0] = 3
cnt = [0] * (N + 1)
cnt[0] = 3

cmb = 1
for Ai in A:
  # i-1番目までの組み合わせ(cmb) * i番目の人がかぶれる色の数(cnt[Ai])
  # i番目の人がかぶれる色の数 = i番目の前までに同じ色の人がAi人いる色の数
  cmb = (cmb * cnt[Ai]) % MOD
  
  # 今回1つ選択したことで、何らかの色の帽子をかぶっている人がAi+1人になった。
  # となれば、赤、青、緑の中で、使用人数がAi人の色の数は1減ったはず
  cnt[Ai] -= 1
  # また、赤、青、緑の中で、使用人数がAi+1人の色の数が1増えたはず
  cnt[Ai+1] += 1

print(cmb)

Measured memory_bytes: 13964
#include<stdio.h>
int main()
{
    long a, b;
    scanf("%ld %ld", &a, &b);
    long ans = 0;
    long i;
    int x, y;
    for (i = a; i <= b; i++)
    {
        x = i / 1000;
        y = i % 100;
        if ((x / 10) == (y % 10))
        {
            if ((x % 10) == (y / 10))
                ans++;
        }
    }
    printf("%ld\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,n,x;
	int a,b,s,h;
	s=0;
	h=0;
	cin>>n>>a>>b;
	for (i=1;i<=n;i++)
	{
		x=i;
		h=0;
		while (x>0)
		{
			h=h+x%10;
			x=x/10;
		}
		if (h>=a&&h<=b) s=s+i;
		else s=s+0;
	}
	cout<<s;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)



ll POW(ll a, ll n){
    if(n == 0){
        return 1;
    }
    if(n == 1){
        return a;
    }
    if(n % 2 == 0){
        return POW(a, n / 2) * POW(a, n / 2);
    }
    else{
        return a * POW(a, n - 1);
    }
}

int main()
{
    ll n, p, a[55], f = 1;

    cin >> n >> p;
    REP(i, n){
        cin >> a[i];
        if(a[i] % 2 == 1){
            f = 0;
        }
    }

    if(p == 0){
        if(f){
            cout << POW(2, n) << endl;
        }
        else{
            cout << POW(2, n - 1) << endl;
        }
    }
    else{
        if(f){
            cout << 0 << endl;
        }
        else{
            cout << POW(2, n - 1) << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll m=1e9+7;
int main()
{
    int n;
    cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    ll ans=0;ll sum=arr[n-1];
    for(int i=n-2;i>=0;i--)
    {
        ans=(ans + (sum*arr[i]))%m;
        sum=(sum + arr[i])%m;
    }
    cout<<ans;
}


Measured memory_bytes: 5152
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll N; cin >> N;
	rep(i, 0, N) {
		char c; cin >> c;
		if (c == 'Y') {
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> P;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const int inf = 1e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

vector<ll> fac,inv,finv;

void initcom(){
    fac=inv=finv=vector<ll>(1e6);
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(ll i=2;i<1e6;++i){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll com(int n,int k){
    if(n<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll x,ll y){
    if(y==0) return x;
    return gcd(y,x%y);
}
ll mopow(ll a,ll x,ll mod){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%mod;
        a=a*a%mod;
        x>>=1;
    }
    return res;
}

int main(){
    string n;cin>>n;
    int sum=0;
    for(int i=0;i<(int)n.size();++i){
        sum+=(int)(n[i]-'0');
    }
    cout<<(sum%9==0?"Yes":"No")<<endl;
    return 0;
}


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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main()
{
    int X,result;
    cin >> X;

    for(int i=X;i<1000004;i++){
        if(IsPrime(i)){
            result = i;
            break;
        }
    }

    cout << result << endl;
}

Measured memory_bytes: 256
#template
def inputlist(): return [int(j) for j in input().split()]
#template
#issueから始める
Q,H,S,D = inputlist()
N = int(input())
l = min(4*Q,2*H,S)
l2 = min(2*l,D)
d2 = N//2
d1 = (N-d2*2)
print(d2*l2 + d1*l)

Measured memory_bytes: 3060
main = interact $ unlines . map (show . goldbach . read) . takeWhile (/= "0") . lines

goldbach :: Int -> Int
goldbach x
 | odd x = if elem (x-2) p then 1 else 0
 | otherwise = goldbach' p (reverse p)
 where
  p = takeWhile (<= x) primes
  goldbach' (p1:ps1) (p2:ps2)
   | p1 > div x 2 = 0
   | p1 == p2 = if p1+p2==x then 1 else 0
   | p1+p2 < x = goldbach' ps1 (p2:ps2)
   | p1+p2 > x = goldbach' (p1:ps1) ps2
   | p1+p2 == x = 1 + goldbach' ps1 ps2
  goldbach' _ _ = 0

primes = 2:3:[x | i<-[1..], j<-[-1,1], let x = 6*i+j, isPrime x]
 where isPrime n = null [i | i<-takeWhile (\x -> x*x <= n) primes, rem n i == 0]

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

ll dp[102][100009];

ll maxknapsack(ll wt[], ll value[], ll n, ll w){

    if(n == 0 || w==0){
        return 0;
    }

    if(dp[n][w] != -1)
        return dp[n][w];

    ll ans1 = INT_MIN, ans2 = INT_MIN;
    if(wt[n] <= w)
        ans1 = value[n] + maxknapsack(wt, value, n-1, w - wt[n]);
    ans2 = maxknapsack(wt, value, n-1, w);

    return dp[n][w] = max(ans1, ans2);
}

int main() {

    memset(dp, -1, sizeof dp);
    ll n, w;
    cin >> n >> w;
    ll wt[n+1] = {0}, value[n+1] = {0};

    for(ll i=1; i<n+1; i++){
        cin >> wt[i] >> value[i];
    }
    cout << maxknapsack(wt, value, n, w) << endl;

    return 0;
}


Measured memory_bytes: 83356
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
struct Node
{
	int x,y;
};
struct Edge
{
	int to,next;
}e[5000005];
vector<Node>a[1000005];
int f[100005],rt[100005],d[400005],h[400005],cnt;
inline void Addedge(int x,int y)
{
	e[++cnt]=(Edge){y,h[x]};h[x]=cnt;return;
}
inline int GetFather(int x)
{
	if(f[x]==x)return x;
	return f[x]=GetFather(f[x]);
}
inline void Merge(int x,int y)
{
	x=GetFather(x);
	y=GetFather(y);
	if(x!=y)f[x]=y;
	return;
}
queue<int>q;
int main(void)
{
	int i,j,x,y,n,m,c,id;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;++i)
	{
		scanf("%d%d%d",&x,&y,&c);
		a[c].push_back((Node){x,y});
	}
	id=n;
	for(i=1;i<=1000000;++i)
	{
		for(j=0;j<a[i].size();++j)
		{
			x=a[i][j].x;y=a[i][j].y;
			f[x]=x;f[y]=y;
			rt[x]=rt[y]=0;
		}
		for(j=0;j<a[i].size();++j)Merge(a[i][j].x,a[i][j].y);
		for(j=0;j<a[i].size();++j)
		{
			x=a[i][j].x;y=a[i][j].y;
			if(!rt[GetFather(x)])rt[GetFather(x)]=++id;
			if(!rt[GetFather(y)])rt[GetFather(y)]=++id;
			Addedge(x,rt[GetFather(x)]);
			Addedge(rt[GetFather(x)],x);
			Addedge(y,rt[GetFather(y)]);
			Addedge(rt[GetFather(y)],y);
		}
	}
	q.push(1);
	while(!q.empty())
	{
		x=q.front();q.pop();
		for(i=h[x];i;i=e[i].next)
		{
			y=e[i].to;
			if(!d[y]){d[y]=d[x]+1;q.push(y);}
		}
	}
	if(d[n])printf("%d\n",d[n]/2);
	else printf("-1\n");
	return 0;
}

Measured memory_bytes: 40704
/*


SPOJ DQUERY offline updates using BIT


*/


// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 500005;
//
//
int tree[MAX];
int last[MAX];
struct queries{
    int l;
     int r;
      int index;
};
bool comparator(const queries& fst, const queries& snd){
    if(fst.r == snd.r)
        return fst.l < snd.l;
    return fst.r < snd.r;
}
                void update(int n,int idx, int val){
                    while (idx <= n){
                        tree[idx] += val;
                        idx += (idx & -idx);
                    }
                }
                int read(int idx){
                    int sum = 0;
                    while (idx > 0){
                        sum += tree[idx];
                        idx -= (idx & -idx);
                    }
                    return sum;
                }
                void solve(){
                    int n, q;
                    cin>>n>>q;
                    int arr[n];
                    for(int i = 0; i < MAX; i++)
                        tree[i] = 0;
                    for(int i = 0; i < MAX; i++)
                        last[i] = -1;
                    for(int i = 0; i < n; i++){
                        cin>>arr[i];
                    }
                    queries quer[q];
                    for(int i = 0; i < q; i++){
                        cin>>quer[i].l>>quer[i].r;
                        quer[i].index = i;
                    }
                    sort(quer, quer+q, comparator);
                    int idx = 0;
                    map<int, int> store;
                    for(int i = 0; i < n; i++){
                        update(n, i+1, +1);
                        if(last[arr[i]] != -1)
                            update(n, last[arr[i]], -1);
                        last[arr[i]] = i+1;

                        while(idx < q && quer[idx].r == i+1){
                            int ans = read(quer[idx].r);
                            ans -= read(quer[idx].l-1);
                            store[quer[idx].index] = ans;
                            ++idx;
                        }
                        // ++idx;
                    }
                    for(auto &itr : store)
                        cout<<itr.second<<"\n";
                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //cout<<"Case #"<<i<<": ";
                                solve();
                         }
        return 0; 
}         
 
 

Measured memory_bytes: 38948
/*
  In the name of ALLAH
  Author : Raashid Anwar
*/
 
#include <bits/stdc++.h>
using namespace std;
 
#define int int64_t
const int M1 =  998244353;
const int M2 =  1000000007;


 
void solve() {
  int n;
  double d, x, y;
  cin >> n >> d;
  int ans = 0;
  while(n--) {
    cin >> x >> y;
    if(sqrt(x * x + y * y) <= d)
      ans++;
  }
  cout << ans << "\n";
}
 
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}

Measured memory_bytes: 3860
numbers = input().split(" ")
a = int(numbers[0])
b = int(numbers[1])
c = int(numbers[2])
k = int(numbers[3])

ans = 0
if k > a and k-a > b:
    ans = a + (k - a - b) * -1
elif k >= a:
    ans = a
else:
    ans = k

print(ans)

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

int main(){
  int A, B, K;
  cin >> A >> B >> K;
  
  int cnt = 0;
  for(int i = min(A, B);i > 0 ;i--){
    if(A % i + B % i == 0) cnt++;
    if(cnt == K){
      cout << i << endl;
      return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		if (S[i] == 'J')a[i] = 1;
		if (S[i] == 'O')a[i] = 2;
		if (S[i] == 'I')a[i] = 4;
	}
	vector<vector<int> >  dp(N, vector<int>(8, 0));
	for (int i = 0; i < 8; i++) {
		if (i & a[0] && i & 1)dp[0][i] = 1;
	}

	for (int i = 0; i < N-1; i++) {
		for (int j = 0; j < 8; j++) { //来る人
			if (dp[i][j] == 0)continue;
			dp[i][j] %= 10007;
			for (int k = 0; k < 8; k++) { //明日来る人
				if (k & a[i+1] && k & j) { //今日来る人と明日来る人のうち共通な人間が一人いる　かつ　明日の責任者が明日来る人に含まれている
					dp[i + 1][k] += dp[i][j];
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < 8; i++)ans += dp[N - 1][i];
	cout << ans % 10007 << endl;
	return 0;
}


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

using namespace std;

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    vector<long long> a(n);
    for(int i=0;i<n;i++) scanf("%lld",&a[i]);
    vector<pair<long long,int> > v(m);
    for(int i=0;i<m;i++) scanf("%d%lld",&v[i].second,&v[i].first);
    sort(v.begin(),v.end(),greater<pair<long long,int> >());
    vector<long long> best;
    for(int o=0;o<m;o++)
    {
        for(int i=0;i<v[o].second;i++) best.push_back(v[o].first);
        if((int)best.size()>=n) break;
    }
    sort(a.begin(),a.end());
    int idx=0;
    long long res=0;
    for(int i=0;i<n;i++)
    {
        if(best[idx]>a[i])
        {
            res+=best[idx];
            idx++;
        }
        else res+=a[i];
    }
    printf("%lld\n",res);
    return 0;
}


Measured memory_bytes: 4724
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 200000;
const int N = 100;

int main() {
	int n;cin>>n;
	int x[MAX],y[MAX];
	rep(i,n) cin>>x[i];
	rep(i,n) y[i]=x[i];
	sort(y,y+n);
	rep(i,n){
		if(x[i]<=y[n/2-1]) cout<<y[n/2]<<endl;
		else cout<<y[n/2-1]<<endl;
	}
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}

const double pi = 22/7.0;
int main(){
  double r;
  cin>>r;

  cout<<(2.00*pi*r)<<setprecision(5)<<endl;
}

Measured memory_bytes: 3788
#include <stdio.h>
#include <utility>
#include <algorithm>
#include <stack>
#include <functional>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, ans, now = 0, cnt = 0;
  scanf("%lld%lld", &n, &k);
  pair<ll, ll> s[n];
  bool f[n];
  for(i = 0; i < n; ++i) scanf("%lld%lld", &s[i].second, &s[i].first), s[i].second--, f[i] = true;
  sort(s, s + n, greater< pair<ll, ll> >());
  stack<ll> st;
  for(i = 0; i < k; ++i) {
    if(f[s[i].second]) {
      f[s[i].second] = false;
      cnt++;
    } else st.push(s[i].first);
    now += s[i].first;
  }
  ans = now + cnt * cnt;
  for(; i < n && st.size(); ++i) if(f[s[i].second]) {
    now -= st.top();
    st.pop();
    now += s[i].first;
    cnt++;
    f[s[i].second] = false;
    if(now + cnt * cnt > ans) ans = now + cnt * cnt;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 2176
#include <iostream>

using namespace std;

int main() {
  int x, y;
  for (;;) {
    cin >> x >> y;
    if (!x && !y)
      break;
    if (x < y)
      cout << x << " " << y << endl;
    else
      cout << y << " " << x << endl;
  }
  return 0;
}

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

int main(){
  
  vector<vector<char>> matrix(2, vector<char>(3));
  for ( int i = 0 ; i < 2 ; i++) for( int j = 0; j < 3; j++){
      cin >> matrix.at(i).at(j);
    }

  if( matrix.at(0).at(0) == matrix.at(1).at(2) &&
     matrix.at(0).at(1) == matrix.at(1).at(1) &&
     matrix.at(0).at(2) == matrix.at(1).at(0) ){
    cout << "YES";
  }
  else cout << "NO";
}


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


void main() {
    auto N = readln.chomp.to!int;
    bool[string] s;
    foreach (_; 0..N) {
        auto t = readln.chomp;
        s[t] = true;
    }

    s.keys.length.writeln;
}


Measured memory_bytes: 26872
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define endl '\n'
using namespace std;

int R, C, K;
int f[3010][3010][4];
int g[3010][3010];

int dfs(int r, int c, int k) {
    if (r < 1 or r > R or c < 1 or c > C or k < 0) return 0;
    int& res = f[r][c][k];
    if (~res) return res;
    res = 0;
    int grc = g[r][c];

    res = max(dfs(r + 1, c, 3), dfs(r, c + 1, k));
    if (grc) {
        if (k >= 1) {
            res = max(res, max(dfs(r + 1, c, 3), dfs(r, c + 1, k - 1)) + grc);
        } else {
            res = max(res, dfs(r + 1, c, 3));
        }
    } 
    return res;
}

signed main() {
    fastio;
    cin >> R >> C >> K;
    memset(f, -1, sizeof f);
    memset(g, 0, sizeof g);
    rep(k, K) {
        int r, c;
        cin >> r >> c;
        cin >> g[r][c];
    }

    int res = dfs(1, 1, 3);
    cout << res << endl;
}

Measured memory_bytes: 357660
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int n, k;
    cin >> n >> k;
    vector<Int> x(n);
    for (Int i = 0; i < n; i++) {
        cin >> x[i];
    }

    Int ans = INT64_MAX;
    Int count = n - k + 1;
    for (Int i = 0; i < count; i++) {
        ans = min(ans, min(abs(x[i]) + abs(x[i + k - 1] - x[i]), abs(x[i + k - 1]) + abs(x[i] - x[i + k - 1])));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

int main()
{
	int n, count[100010] = { 0 };
	std::cin >> n;
	
	for (int i = 0; i < n; ++i)
	{
		int x;
		std::cin >> x;
		if (x >= 1)
			++count[x - 1];
		++count[x];
		++count[x + 1];
	}
	
	int best = 0, bestPointer = 0;
	for (int i = 0; i < 100010; ++i)
	{
		if (count[i] > best)
		{
			best = count[i];
		}
	}
	
	std::cout << best;
}

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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    string s;
    cin >> s;

    vi num;
    for (auto ch : s) {
        num.push_back(ch - '0');
    }
    // 処理
    int minV = INT_MAX;
    int x    = 0;
    rep(i, num.size() - 2) {
        x    = num[i] * 100 + num[i + 1] * 10 + num[i + 2];
        minV = min(minV, abs(753 - x));
    }
    // 出力
    cout << minV << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int P[101][101], f[101], d[101], Color[101];
int n, t=0;
void visit(int);

int main() {
  int i, j, x, y, z;
  scanf("%d",&n);
  for(i=0; i<101; i++)      Color[i]=0;
  for(i=0; i<n; i++) {
    for(j=0; j<n; j++) {
      P[i][j] = 0;
    }
  }
  
  for(i=0; i<n; i++) {
    scanf("%d%d",&x, &y);
    for(j=0; j<y; j++) {
      scanf("%d", &z);
      P[x-1][z-1] = 1;
    }
  }
  for(i=0; i<n; i++)
    if(Color[i]==0)   visit(i); 
  for(i=0; i<n; i++)      printf("%d %d %d\n", i+1, d[i], f[i]);
  return 0;
}

void visit( int r) {
  int v;
  d[r] = ++t;
  Color[r] = 1;
  for(v=0; v<n; v++) {
    if(P[r][v] == 1 && Color[v] == 0)
      visit(v);
  }
  f[r] = ++t;
}



Measured memory_bytes: 2112
#include <stdio.h>
#include <math.h>
#define LINE_MAX 30
double cos(double);
double sin(double);
double floor(double);

struct Data{
	int length;
	int angle;
};
struct Position{
	double x;
	double y;
	int angle;
};

double degToRad(int degree){
	return degree * 3.1415926536 / 180; 
}
void walk(struct Data buf, struct Position *position){
	position->x += (buf.length * cos(degToRad(position->angle)));
	position->y += (buf.length * sin(degToRad(position->angle)));
	position->angle += buf.angle;
	if(position->angle > 180){position->angle -= 360;}
	else if(position->angle < -180){position->angle += 360;}
}

int main(void){
	char c;
	int length;
	int argnum = 0;
	int minus_flag = 0;
	struct Data buf;
	struct Position position;
	position.x = 0;
	position.y = 0;
	position.angle = 0;
	buf.length = 0;
	buf.angle = 0;
	while(1){
		c = getchar();
		if(c == EOF){
			break;
		}else if(c =='\n'){
			if(minus_flag){buf.angle = -buf.angle;}
			if(buf.length == 0 && buf.angle == 0){
				break;
			}
			walk(buf,&position);
			argnum = 0;
			buf.length = 0;
			buf.angle = 0;
			minus_flag = 0;
		}else if('0' <= c && c <= '9'){
			switch(argnum){
				case 0:
					buf.length = buf.length * 10 + (c - '0');
				break;
				case 1:
					buf.angle = buf.angle * 10 + (c - '0');
				break;
			}
		}else if(c == ','){
			if(minus_flag){buf.length = -buf.length;}
			argnum++;
			minus_flag = 0;		
		}else if(c == '-'){
			minus_flag = 1;
		}
	}

	printf("%d\n%d\n",(int)position.y,(int)position.x);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  int n, t, a, h, ans = -1;
  double min;
  cin >> n >> t >> a;
  for(int i = 0; i < n; i++){
    cin >> h;
    if(i == 0 || min > abs(a-(t - h * 0.006))){
      min = abs(a-(t - h * 0.006));
      ans = i+1;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def test():

	n = int(input())
	i = list(map(int,input().split()))
	

	max = -1000000
	min = 1000000
	sum = 0

	for num in range(n):
		
		if max < i[num]:
			max = i[num]
		if min > i[num]:
			min = i[num]
		sum += i[num]

	print(f"{min} {max} {sum}")

if __name__ == "__main__":
	test()



Measured memory_bytes: 6616