akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll  A,B,C,D,E,F,G,H,K,L,M,N,P,Q,R,U,W,X,Y,Z;
string S,T;

int main(){
  cin >> N  >> A >> B;
  cout << (A*(N/(A+B))+min(A,(N%(A+B)))) << endl;
}


Measured memory_bytes: 256
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        int p, q, r;
        cin >> p >> q >> r;
        cout << min({p + q, q + r, r + p}) << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()
q=int(input())
k=list(map(int,input().split()))
for x in k:
  d,m,dm,ans=0,0,0,0
  for i in range(n):
    ss=s[i]
    if ss=='D':
      d+=1
    elif ss=='M':
      m+=1
      dm+=d
    elif ss=='C':
      ans+=dm
    if i>=x-1:
      ss=s[i-x+1]
      if ss=='D':
        dm-=m
        d-=1
      elif ss=='M':
        m-=1
  print(ans)


Measured memory_bytes: 75432
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N, D, A;
  cin >> N >> D >> A;
  vector<vector<int64_t>> vec(N,vector<int64_t>(2));
  for(int i=0; i<N; i++){
    for(int j=0; j<2; j++){
      cin >> vec.at(i).at(j);
    }
  }
  sort(vec.begin(),vec.end());
  
  vector<int64_t> damage(N,0);
  vector<int64_t> dist(N);
  for(int i=0; i<N; i++){
    dist.at(i) = vec.at(i).at(0);
  }
  int64_t ans = 0;
  
  vector<int64_t>::iterator pos;
  int64_t idx = -1;
  
  for(int i=0; i<N; i++){
    if(vec.at(i).at(1) > damage.at(i)*A){
      vec.at(i).at(1) -= damage.at(i)*A;
      int bomb = (vec.at(i).at(1) + A - 1) / A;
      ans += bomb;
      pos = upper_bound(dist.begin(),dist.end(),vec.at(i).at(0)+2*D);
      idx = distance(dist.begin(),pos);
      //cout << idx << endl;
      if(idx < N){
        damage.at(idx) -= bomb;
      }
      damage.at(i) += bomb;
    }
    if(i != N-1){
      damage.at(i+1) += damage.at(i);
    }
    /*for(int i=0; i<N; i++){
      cout << damage.at(i) << " ";
    }
    cout << endl;*/
  }
  cout << ans << endl;
}



Measured memory_bytes: 14336
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int list[][] = new int[3][3]; // 3*3の二次元配列
        // 二次元配列に値を格納
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                list[i][j] = Integer.parseInt(sc.next());
            }
        }
        int n = Integer.parseInt(sc.next());
        for (int i = 0; i < n; i++) {
            // bの値
            int num = Integer.parseInt(sc.next());
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    // bと一致する値が二次元配列に存在する場合
                    if (list[j][k] == num) {
                        // 該当箇所を0に更新(当たりとして扱う)
                        list[j][k] = 0;
                    }
                }
            }
        }
        int a = list.length;
        // 二次元配列の確認
        if (checkBingoVertical(list) ||
                checkBingoParallel(list) ||
                checkBingoLeftUpToRightDown(list) ||
                checkBingoRightUpToLeftDown(list)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        sc.close();
    }

    // ビンゴの縦列
    private static boolean checkBingoVertical(int[][] plist) {
        int verticalsize = plist.length;
        int parallelsize = plist[0].length;
        HashSet<Integer> hs = new HashSet<>();
        for (int i = 0; i < verticalsize; i++) {
            hs.clear();
            hs.add(plist[0][i]);
            for (int j = 0; j < parallelsize; j++) {
                hs.add(plist[j][i]);
            }
            if (hs.size() == 1) {
                return true;
            }
        }
        return false;
    }

    // ビンゴの横列
    private static boolean checkBingoParallel(int[][] plist) {
        int verticalsize = plist.length;
        int parallelsize = plist[0].length;
        HashSet<Integer> hs = new HashSet<>();
        for (int i = 0; i < verticalsize; i++) {
            hs.clear();
            hs.add(plist[i][0]);
            for (int j = 0; j < parallelsize; j++) {
                hs.add(plist[i][j]);
            }
            if (hs.size() == 1) {
                return true;
            }
        }
        return false;
    }

    // ビンゴの斜め列(＼：左上から右下)
    private static boolean checkBingoLeftUpToRightDown(int[][] plist) {
        int size = plist.length;
        HashSet<Integer> hs = new HashSet<>();
        for (int i = 0; i < size; i++) {
            hs.add(plist[i][i]);
        }
        if (hs.size() == 1) {
            return true;
        }
        return false;
    }

    // ビンゴの斜め列(／：右上から左下)
    private static boolean checkBingoRightUpToLeftDown(int[][] plist) {
        int size = plist.length;
        HashSet<Integer> hs = new HashSet<>();
        for (int i = 0; i < size; i++) {
            hs.add(plist[i][size - 1 - i]);
        }
        if (hs.size() == 1) {
            return true;
        }
        return false;
    }

}


Measured memory_bytes: 35356
import java.util.*;
public class Main {
	public static void main(String arg[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int[] arr = new int[8];

		arr[a]++;
		arr[b]++;
		arr[c]++;

		if(arr[5] == 2 && arr[7] == 1) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 19796
#include<bits/stdc++.h>
#define ll long long
#define xll __int128
#define fo(i,n) for(int i=0;i<n;i++)
#define rfo(i,n) for(int i=n-1;i>=0;i--)
#define Fo(i,q,n) for(int i=q;i<n;i++)
#define rFo(i,q,n) for(int i=n-1;i>=q;i--)
#define fO(i,n,k) for(int i=0;i<n;i+=k)
#define FO(i,q,n,k) for(int i=q;i<n;i+=k)
#define zero(a,n) memset(a,0,sizeof(a[0])*n)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define Endl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
using namespace std;
const int MOD=1000000007;
void print(){cout <<endl;}
template <typename T, typename... Types> 
void print(T var1, Types... var2){cout << var1 << " " ;print(var2...) ;}
//ceil of a/b
template <typename T>
T fceil(T a,T b){return (T)(a+b-1)/b;}
template <typename T>
void printvec(vector<T> v){ for(int i=0;i<(int)v.size();i++){ cout<<v[i]<<" ";} cout<<endl;}
template <typename T>
void printarr(T a[],int n){ for(int i=0;i<n;i++){ cout<<a[i]<<" ";} cout<<endl;}
//const int N=2e5;
//int arr[N+1];

 
int main(){
	int n;
	cin>>n;
	int dp[n+1];
	memset(dp,0,sizeof(dp[0])*(n+1));
	dp[0]=0;
	dp[1]=0;
	if(n==1){
		cout<<dp[n]<<endl;
	return 0;	
	}
	dp[2]=0;
	if(n==2){
		cout<<dp[n]<<endl;
	return 0;	
	}
	dp[3]=1;
	if(n==3){
		cout<<dp[n]<<endl;
	return 0;	
	}
	Fo(i,4,n+1){
		dp[i]=1;
		Fo(j,3,i+1){
			dp[i] = ((ll)dp[i] +  (ll)dp[i-j])%MOD;	
		} 	
	}
	cout<<dp[n]%MOD<<endl;
	return 0;
}






/*NOTE: Take MOD after sorting and not before sorting!*/


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

int main() {
	string s;
	cin >> s;
	int a=0,b=0;
	rep(i,s.size()){
		if(s[i]=='A'){
			a=i;
			break;
		}
	}
	for(int i=s.size()-1; i>=0; i--){
		if(s[i]=='Z'){
			b=i;
			break;
		}
	}
	cout << b-a+1 << endl;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int ma,mi;
    cin>>ma;
    mi=ma;
    int x;
    for(int i=2;i<=n;++i)
    {
        cin>>x;
        if(mi>x)mi=x;
        if(ma<x)ma=x;
    }
    cout<<ma-mi;
    return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::vector<std::vector<long long>> A, long long N, std::vector<long long> b)
{
    map<int,int> mp;
    for(unsigned int i=0;i<b.size();i++)
        mp[b[i]]=1;
    bool flag=false;
    for(int i=0;i<3;i++)
        if(mp[A[i][0]]&&mp[A[i][1]]&&mp[A[i][2]])
            {
                flag=true;
                break;
            }
    for(int i=0;i<3;i++)
        if(mp[A[0][i]]&&mp[A[1][i]]&&mp[A[2][i]]&&!flag)
            {
                flag=true;
                break;
            }
    if(mp[A[1][1]]&&mp[A[2][2]]&&mp[A[0][0]])
        flag=true;
    if(mp[A[0][2]]&&mp[A[1][1]]&&mp[A[2][0]])
        flag=true;
    if(flag)
        cout<<YES<<endl;
    else
        cout<<NO<<endl;
}

int main()
{
    std::vector<std::vector<long long>> A(3, std::vector<long long>(3));
    for(int i = 0 ; i < 3 ; i++){
        for(int j = 0 ; j < 3 ; j++){
            scanf("%lld",&A[i][j]);
        }
    }
    long long N;
    scanf("%lld",&N);
    std::vector<long long> b(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&b[i]);
    }
    solve(std::move(A), N, std::move(b));
    return 0;
}


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

int main() {
    for (int i = 1; ; ++i) {
        int j;
        cin >> j;

        if (j == 0) {
            break;
        } else {
            cout << "Case " << i << ": " << j << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  ll M;
  while (cin >> N >> M) {
    vector<ll> A(N);
    for (auto& x : A) cin >> x;
    sort(A.begin(), A.end());
    ll pass = 0, fail = 2 * 1e5 + 10;
    while (fail - pass > 1) {
      ll X = (pass + fail) / 2;
      ll cnt = 0;
      for (int i = 0, j = N - 1; i < N; i++) {
        while (j >= 0 && A[i] + A[j] >= X) --j;
        cnt += N - j - 1;
      }
      if (cnt >= M) {
        pass = X;
      } else {
        fail = X;
      }
    }
    ll res = 0;
    ll sum = 0, rem = M;
    for (int i = 0, j = N - 1; i < N; i++) {
      while (j >= 0 && A[i] + A[j] > pass) {
        sum += A[j];
        --j;
      }
      ll c = N - j - 1;
      rem -= c;
      res += sum + c * A[i];
    }
    res += pass * rem;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#define print(n) std::cout << n << std::endl
#define print_no_indention(n) std::cout << n
#define FOR(i,n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    char A = a[0] - 0x20;
    char B = b[0] - 0x20;
    char C = c[0] - 0x20;
    print_no_indention(A);
    print_no_indention(B);
    print_no_indention(C);


}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    long long int n,m;
    cin >> n >> m;
    if(n == 1 && m == 1)
    {
        cout << "1\n";
    }
    else if(n == 1)
    {
        cout << m - 2 << "\n";
    }
    else if(m == 1)
    {
        cout << n - 2 << "\n";
    }
    else
    {
        cout << (n - 2) * (m - 2) << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
N,x = [int(i) for i in input().split()]

a = [int(i) for i in input().split()]
total = 0
for  a_ in a:
    total  += a_
a.sort()
c = 0
if total > x:
    i = 0
    while(True):
        x -= a[i]
        i+=1
        if x < 0:
            print(c)
            break
        c +=1
elif total < x:
    print(N-1)

else:
    print(N)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define N 100005
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
int p[N],sz[N],amt[N],n,m,c,visitn;
ll a[N],ans;
bool visit[N];
int uf_f(int x){if(p[x]<=0)return x;return p[x]=uf_f(p[x]);}
int uf_u(int x,int y){x=uf_f(x),y=uf_f(y);p[y]=x;sz[x]+=sz[y];}
priority_queue<P,vector<P>,greater<P>>pq;
priority_queue<ll,vector<ll>,greater<ll>>st[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        p[i]=-1,sz[i]=1;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=m;i++){
        int x,y;
        cin>>x>>y;
        x++;y++;
        uf_u(x,y);
    }
    for(int i=1;i<=n;i++){
        int pr=uf_f(i);
        if(pr==i)
            c++;
        st[pr].push(a[i]);
    }
    for(int i=1;i<=n;i++){
        int pr=uf_f(i);
        if(pr!=i)
            continue;
        int tp=st[pr].top();
        st[pr].pop();
        sz[pr]--;
        pq.push({tp,pr});
    }
    for(int ch=1;ch<=2*c-2;ch++){
        if(pq.size()==0){
            cout<<"Impossible";
            return 0;
        }
        if(2*c-1-ch==c-visitn){
            //cout<<2*c-2<<" "<<ch<<" "<<visitn<<" "<<ans<<endl;
            while(pq.size()!=0){
                P tp=pq.top();
                pq.pop();
                if(amt[tp.second])
                    continue;
                ans+=tp.first;
            }
            break;
        }
        P tp=pq.top();
        pq.pop();
        ans+=tp.first;
        if(!amt[tp.second])
            visitn++;
        amt[tp.second]++;
        if(st[tp.second].size()!=0&&amt[tp.second]<c-1){
            int tpp=st[tp.second].top();
            st[tp.second].pop();
            pq.push({tpp,tp.second});
        }
        //cout<<ch<<" :"<<ans<<" "<<tp.first<<endl;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 10484
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

using namespace std;

struct Info{
	Info(int arg_row,int arg_col,int arg_dist){
		row = arg_row;
		col = arg_col;
		dist = arg_dist;
	}
	Info(){
		row = 0,col = 0,dist = 0;
	}

	int row,col,dist;
};

int H,W,div_row[4] = {-1,0,0,1},div_col[4] = {0,-1,1,0};

bool rangeCheck(int row,int col){
	if(row >= 0 && row <= H-1 && col >= 0 && col <= W-1)return true;
	else{
		return false;
	}
}

int main(){

	int escape_row,escape_col;
	scanf("%d %d",&H,&W);
	char map[200][201];

	int distance[200][200];

	for(int i = 0; i < H; i++){
		scanf("%s",map[i]);
		for(int k = 0; k < W;k++){
			distance[i][k] = -1;
			if(map[i][k] == '%'){
				escape_row = i;
				escape_col = k;
			}
		}
	}

	distance[escape_row][escape_col] = 0;

	int prin = -1,enemy = 50000;

	queue<Info> Q;

	Q.push(Info(escape_row,escape_col,0));
	Info current;

	while(!Q.empty()){
		current = Q.front();
		Q.pop();

		if(map[current.row][current.col] == '@'){ //?§????????????°??????????????¢?´¢???????????????
			if(prin == -1){
				prin = current.dist;
			}else{
				prin = min(prin,current.dist);
			}
			continue;
		}else if(map[current.row][current.col] == '$'){
			enemy = min(enemy,current.dist);
			continue;
		}

		if((prin != -1 && current.dist >= prin) || (current.dist >= enemy))continue; //??????????????????????§????????????????????????????????????¢?´¢???????????????

		for(int i = 0; i < 4; i++){
			if(rangeCheck(current.row+div_row[i],current.col+div_col[i]) == true && map[current.row+div_row[i]][current.col+div_col[i]] != '#' &&  //???????????????????§???????????£???§?????????
					(distance[current.row+div_row[i]][current.col+div_col[i]] == -1 || distance[current.row+div_row[i]][current.col+div_col[i]] > current.dist+1)){ //??????(?§???????????????¢??????????¨????????????????????????????????????????????????????)
				distance[current.row+div_row[i]][current.col+div_col[i]] = current.dist+1;
				Q.push(Info(current.row+div_row[i],current.col+div_col[i],current.dist+1));
			}
		}
	}

	if(prin == -1 || prin >= enemy){
		printf("No\n");
	}else{
		printf("Yes\n");
	}

    return 0;
}

Measured memory_bytes: 2884
#include <bits/stdc++.h>
using namespace std;
 
typedef long double LD;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define REP(i,n) for (ll i = 0; i < n; i++)
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REPD(i,n) for (ll i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (ll i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define rsort(v) sort(v.begin(), v.end(), greater <>());
typedef map<ll,ll> mll;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
#define F first
#define S second
#define PQ(type) priority_queue<type>
#define PQD(type) priority_queue<type,vector<type>,greater<type> >
#define ITR :: iterator it
#define WL(t) while(t--)
#define SZ(x) ((int)(x).size())
#define TR(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define inrange(i,a,b) ((i>=min(a,b)) && (i<=max(a,b)))
#define i1(x) cin>>x
#define i2(x,n) cin>>x>>n
#define o1(x) cout<<x
#define o2(x,n) cout<<x<<n
int main(){
    ll n,m;
    i2(n,m);
    n=n%m;
    o1(max((ll)0,min(n,m-n)));
}

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

using namespace std;

map< long long, int > prime_factor(long long n) {
	map< long long, int > ret;
	for (long long i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

int main() {

	long long x;
	map<long long, int > a;
	cin >> x;
	a = prime_factor(x);
	a.insert(make_pair(1, 1));
//	a.insert(make_pair(x, 1));
	auto iter = a.begin();

	vector<long long> acount;

	while (iter != a.end()) {
		acount.push_back(iter->first);
		iter = next(iter, 1);
	}

	map<long long, int > b;
	cin >> x;
	b = prime_factor(x);
	b.insert(make_pair(1, 1));
//	b.insert(make_pair(x, 1));
	auto itr = b.begin();

	vector<long long> bcount;

	while (itr != b.end()) {
		bcount.push_back(itr->first);
		itr = next(itr, 1);
	}

	long long res = 0;
	for (int i = 0; i < acount.size(); i++) {
		for (int j = 0; j < bcount.size(); j++) {
			if (acount[i] == bcount[j]) {
				res++;
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

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

llint n;

void solve(){
  cin >> n;
  llint ans=inf;

  for(llint i=1;i<10000000;i++){
    if(n%i==0){
      llint j=n/i;
      chmin(ans,i+j-2);
    }
  }
  cout << ans << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
#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 <math.h>
using namespace std;
#define int long long



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

    int n; cin >> n;
    vector<int> x(n);
    for(int i = 0;i < n;i ++){
        cin >> x.at(i);
    }

    int ans = 10000000000;
    int sum;
    for(int i = 1;i <101;i ++){

        sum = 0;
        for(int j = 0;j < n;j ++){
            sum += (x.at(j) - i) * (x.at(j) - i);
        }

        ans = min(ans,sum);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	//"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	s, _ := r.ReadString('\n')
	s = strings.TrimRight(s, " \t\n")
	slice := strings.Split(s, " ")
	n := string(slice[0])
	i := string(slice[1])
	N, _ := strconv.Atoi(n)
	I, _ := strconv.Atoi(i)

	fmt.Println(N + 1 - I)
}


Measured memory_bytes: 1776
main = do
  n <- readLn
  if n == 0 then putStrLn "0"
            else putStrLn . reverse $ solve n

solve :: Int -> String
solve 0 = []
solve n
  | mod n 2 == 0 = '0': (solve $ div n (-2))
  | otherwise  = '1': (solve $ div (n-1) (-2))


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

int main() {
    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b) << endl;
}


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

int main(){
    int n, p, ans, m;
    cin >> n;
    ans = m = 0;
    for ( int i = 0; i < n; i++ ) {
        cin >> p;
        m = max(m, p);
        ans += p;
    }
    
    cout << ans - m/2 << endl;
    return (0);
}


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

template <typename T>
void print(const T &v);

int main()
{
    string s;
    ll k;
    cin >> s >> k;
    int n = s.size();
    vector<ll> sq(n);
    sq[0] = 1;
    int idx = 0;
    for (int i = 0; i < n - 1; i++)
    {
        if (s[i] == s[i + 1])
        {
            sq[idx]++;
        }
        else
        {
            idx++;
            sq[idx]++;
        }
    }
    if (idx == 0) // １種類の文字で構成されている場合
    {
        cout << (n * k) / 2 << endl;
        return 0;
    }
    ll ans = 0;
    for (int i = 0; i <= idx; i++)
    {
        ans += (sq[i] / 2);
    }
    ans *= k;
    if (s[0] == s[n - 1])
    {
        ans -= ((sq[0] / 2) + (sq[idx] / 2) - ((sq[0] + sq[idx]) / 2)) * (k - 1);
    }
    cout << ans << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3588
N,L = map(int,input().split())

x = 1000
p = -1

for i in range(N):
    y = abs(L + i)
    if y < x:
        x = y
        p = i
        
ans = (L-1) * N + N * (N + 1)/2 -(L + p)
print(int(ans))

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;
const int N=2e5+5;
map<int,ll>mp;
int main()
{
   IOS;
   int n;
   cin >> n;
   for(int i=2;i<=n;i++){
       int x;
       cin >> x;
       mp[x]++;
   }
   for(int i=1;i<=n;i++)cout<<mp[i]<<endl;
}


Measured memory_bytes: 16160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a[5];
  cin >> a;
 
  if(a[0]==a[1]&&a[1]==a[2]){
  cout << "Yes";
  }
  else if(a[1]==a[2]&&a[2]==a[3]){
  cout << "Yes";
  }
  else{
  cout << "No";
  }
}

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

int main()
{
	string s;
	int ans = 0;
	bool flag = false;
	cin >> s;
	for (int i = 0; i < s.size(); i++, flag = !flag)
	{
		if (((flag) ? 0 : 1) == s[i] - '0')
			ans++;
	}
	ans = (ans < s.size() - ans) ? ans : s.size() - ans;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
void read(pp& x){ scanf("%d%d",&x.first, &x.second); }
void read(pll& x){ scanf("%lld%lld",&x.first, &x.second); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define sz(x) (int)(x).size()

int main()
{
	int n, t;
	read(n, t);
	int bmin = 2e9;
	int ad = 0;
	int cc = 0;
	rep(i, n){
		int x; read(x);
		if(ad < x-bmin){
			ad = x-bmin;
			cc = 1;
		} else if(ad == x-bmin){
			++cc;
		}
		bmin = min(bmin, x);
	}
	printf("%d\n", cc);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
typedef long long ll;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)
#define swap(l,r) {ll tp=l;l=r;r=tp;}
const ll MOD = 1000000007;

int main(){
    //input
    int n;
    scanf("%d", &n);

    //output
    printf("%d", (n+1)/2);
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a >= 13){
        cout << b << "\n";
    } else if(a >= 6){
        cout << b / 2 << "\n";
    } else {
        cout << 0 << "\n";
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;

int main (){
  ll n,k;
  ll ans;
  cin>>n>>k;
  ans=(n+1)/2;
  if(ans>=k){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}


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

using namespace std;

int main() {
    int n; cin >> n;
    while (n > 0) {
        int r = n % 10;
        if (r == 7) {
            cout << "Yes";
            return 0;
        }
        n /= 10;
    }
    cout << "No";
    return 0;
}


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

public class Main {
    public static void main(String[] args) {
        String S;
        try (Scanner sc = new Scanner(System.in)) {
            S = sc.next();
        }
        char[] carr = S.toCharArray();
        int[] arr = new int[carr.length];
        for (int i = 0; i < carr.length; i++) {
            arr[i] = carr[i] - 48;
        }
        int baseMax = arr.length - 1;
        int bitSign = 0;
        while (bitSign < Math.pow(2, baseMax)) {
            StringBuilder sb = new StringBuilder();

            int result = arr[0];
            sb.append(arr[0]);

            for (int i = 0; i < baseMax; i++) {
                boolean isPlus = ((bitSign >>> (baseMax - 1 - i)) & 0x1) == 0;
                String s = isPlus ? "+" : "-";
                result += ((isPlus) ? (arr[i + 1]) : -(arr[i + 1]));
                sb.append(s).append(arr[i + 1]);
            }
            if (result == 7) {
                sb.append("=7");
                System.out.println(sb.toString());
                return;
            }
            bitSign++;
        }
    }
}


Measured memory_bytes: 22740
n = int(input())
X = list(map(int, input().split()))
X.sort()
ANS = []
for i in range(X[0],X[len(X)-1]+1):
  k = 0
  for j in range(len(X)):
    k += (i - X[j]) ** 2
  ANS.append(k)
  
print(min(ANS))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
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;
}
const int INF=1e18;
const int MOD=1e9+7;
const int MAX=200;
vector<int>G[MAX];
vector<int>color;
bool dfs(int v, int cur = 0){
    color[v] = cur;
    for (auto next_v : G[v]) {
        if (color[next_v] != -1) {
            if (color[next_v] == cur) return false; 
            continue;
        }
        if (!dfs(next_v , 1 - cur)) return false;
    }
    return true;
}

signed main(){
    int N;cin>>N;
    int d[N][N];
  	REP(i,N)REP(j,N)d[i][j]=INF;
  	REP(i,N)d[i][i]=0;
    REP(i,N){
        REP(j,N){
            char a;cin>>a;
            if(a=='1'){
                G[i].pb(j);
                d[i][j]=1;
            }
        }
    }
    color.assign(N,-1);
    bool is_bipartite = true;
    for (int v = 0; v < N; ++v) {
        if (color[v] != -1) continue; 
        if (!dfs(v)) is_bipartite = false;
    }
    if(!is_bipartite)cout<<-1<<endl;
    else{
        int ans=0;
        REP(k,N)REP(i,N)REP(j,N)chmin(d[i][j],d[i][k]+d[k][j]);
        REP(i,N)REP(j,N)if(d[i][j]!=INF)chmax(ans,d[i][j]);
        cout<<ans+1<<endl;
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    bool is_one = false;
    ll min = INF;
    rep(i,n) {
        cin >> a[i];
        sum += a[i];
        if(a[i] == 1)is_one = true;
        chmin(min, a[i]);
    }

    bool first = true;
    if(n % 2 == 1){
        if(sum % 2 == 0)first = false;
    }
    else {
        if(sum % 2 == 0 && is_one == false && min % 2 == 0)first = false;
    }

    cout << (first ? "First" : "Second") << endl;
    
}


Measured memory_bytes: 4428
#include <iostream>

using namespace std;

int main(){
    int X;
    cin >> X;
    int ans;
    int now = 0;
    for(int i=1; i<50000000; i++){
        now = now + i;
        if(X <= now){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

N,K=rl()
V=rl()
mV = [0]*(N)
mc = 0
for i in range(N):
    v = V[i]
    if v < 0:
        mV[i] = v
        mc += 1
rV = V[::-1]
rmV = mV[::-1]

if K >= (N+mc):
    print(sum(V)-sum(mV))
else:
    ans = 0
    for lc in range(K+1):
        rc = K - lc
        rr = 0
        l_ind = 0
        for ind in range(lc+1):
            if ind > N: break
            rm = lc - ind
            rr_ = sum(V[:ind])-sum(sorted(mV[:ind])[:rm])
            if rr < rr_:
                rr = rr_
                l_ind = ind
        rl = 0
        for ind in range(rc+1):
            if ind + l_ind > N: break
            rm = rc - ind
            rl = max(rl,sum(rV[:ind])-sum(sorted(rmV[:ind])[:rm]))
        ans = max(ans, rr+rl)
    print(ans)

        



Measured memory_bytes: 3064
S = list(str(input()))
S = list(map(int,S))

K = int(input())
cnt = 0

for i in range(len(S)):
	cnt += 1
	if(S[i]!=1 and K-1>i):
		ans = S[i]
		break

if(cnt==len(S) and K<=len(S)):
	print(S[K-1])
elif(cnt==len(S)):
	print(S[0])
else:
	print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
using namespace std;

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


Measured memory_bytes: 3016
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;

int main(){
  int N;
  cin >> N;
  vector<ll> A(N),B(N),C(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  for(int i=0; i<N; i++){
    cin >> B[i];
  }
  for(int i=0; i<N; i++){
    cin >> C[i];
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  vector<int> sumAB(N+1);
  ll sum=0;
  int i=0,j=0;
  while(1){
    if(A[i] < B[j]){
      sum++;
      i++;
    }else{
      sumAB[j] = sum;
      j++;
    }
    if(i>=N){
      while(j<N){
        sumAB[j] = sum;
        j++;
      }
    }
    if(j>=N){
      break;
    }
  }
  sum = i = j = 0;
  vector<ll> sumBC(N+1);
  while(1){
    if(B[i] < C[j]){
      sum += sumAB[i];
      i++;
    }else{
      sumBC[j] = sum;
      j++;
    }
    if(i>=N){
      while(j<N){
        sumBC[j] = sum;
        j++;
      }
    }
    if(j>=N){
      break;
    }
  }
  ll Sum=0;
  for(int i=0; i<N; i++){
    Sum += sumBC[i];
  }
  cout << Sum << endl;
  return 0;
}


Measured memory_bytes: 3712
//CLMN
//Every cloud has a silver lining
//Hakuna matata

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> ii;

#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x) * (x))

const char *fin = "arc077_a.inp";
const char *fon = "";

#define oo (int) (1e9+7)
#define maxn (int) (2e5+5)

int a[maxn];
int n;

void sol(int MOD) {
    for(int i = n; i >= 1; --i) if (i % 2 == MOD) cout << a[i] << ' ';
    for(int i = 1; i <= n; ++i) if (i % 2 != MOD) cout << a[i] << ' ';
}

void inp() {
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    sol(n % 2);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    //freopen(fin, "r", stdin); freopen(fon, "w", stdout);
    inp();
    return 0;
}


Measured memory_bytes: 2944
while True:
	test=list(map(int,input().split()))
	if test[0]==-1 and test[1]==-1 and test[2]==-1:
		break
	elif test[0]==-1 or test[1]==-1:
		print('F')
	elif 80<=test[0]+test[1]:
		print('A')
	elif 65<=test[0]+test[1]<80:
		print('B')
	elif 50<=test[0]+test[1]<65:
		print('C')
	elif 30<=test[0]+test[1]<50:
		if 50<=test[2]:
			print('C')
		else:
			print('D')
	elif test[0]+test[1]<30:
		print('F')


Measured memory_bytes: 5592
n,m=map(int,input().split())
wa=[0]*n
ac=[False]*n
for _ in range(m):
    p,s=input().split()
    p=int(p)
    if ac[p-1]: continue
    elif s=="WA": wa[p-1]+=1
    else: ac[p-1]=True
print(ac.count(True),end=" ")
w=0
for i in range(n):
    if ac[i]: w+=wa[i]
print(w)

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

using ll = long long;
using ull = unsigned long long;
#define repi(n) for (long long i = 0; i < (n); ++i)
#define repj(n) for (long long j = 0; j < (n); ++j)
#define repk(n) for (long long k = 0; k < (n); ++k)
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))

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


Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n;
  while(cin>>n){
    int out=n%39;
    if(!out)out=39;
    if(out/10==0)cout<<"3C0"<<out<<endl;
    else cout<<"3C"<<out<<endl;
  }


}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Here your code !
    int N,max=0;
    cin >> N;
    vector <int> v(N);
    for(int i=0;i<N;i++){
        
        cin >> v[i];
        max+=v[i];
    }
    if(max%10!=0){cout << max << "\n";return 0;}
    const int mmax=max;
    for(int i=0;i<v.size();i++){
        
        if(v[i]%10==0){v.erase(v.begin()+i);i--;}
    }
    if(v.empty()){cout << "0" << "\n";return 0;}
    sort(v.begin(),v.end());
    cout << mmax-v[0] << "\n";
    return 0;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>=n;i--)
#define INF 999999999
#define INF_M 2147483647
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
 
int main() {
    string s;
    int ans = 0;
    while(getline(cin,s)) {
        int a = 0;
        repr(i,s.length() - 1,0) {
            if('0' <= s[i] && s[i] <= '9') {
                ans += ((int)s[i] - 48) * pow(10,a);
                a++;
            }
            else a = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1216
#include <iostream>

using namespace std;
int main() {
  int n;
  long long money = 100000;
  cin >> n;
  for (int i = 0; i < n; i++) {
    money *= 1.05;
    if ((money % 1000) != 0)
      money = money - money % 1000 + 1000;
  }
  cout << money << endl;
  return 0;
}

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

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int n = sc.nextInt();
        long[] as = new long[n + 1];
        as[0] = 0;
        for (int i = 0; i < n; i++) {
            as[i + 1] = as[i] + sc.nextLong();
        }

        Arrays.sort(as);
        long count = 0;
        long tmp = 0;
        for (int i = 1; i < n + 1; i++) {
            if (as[i - 1] == as[i]) {
                tmp++;
                count += tmp;
            } else {
                tmp = 0;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 83860
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

int main(){
    ll h; cin>>h;
    ll ans=0;
    ll cnt=0;
    while(h>0){
        h=floor(h/2.0);
        ans+=modpow(2, cnt);
        cnt++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 205
using namespace std;
int n,tot;
int a[maxn],b[maxn],c[maxn],d[maxn];
int head[maxn],nex[maxn*maxn],to[maxn*maxn];
void add(int x,int y)
{
	to[++tot]=y;nex[tot]=head[x];head[x]=tot;
}
int vis[maxn],match[maxn];
int dfs(int now)
{
	for(int i=head[now];i;i=nex[i])
	{
		if(!vis[to[i]])
		{
			vis[to[i]]=1;
			if(!match[to[i]] || dfs(match[to[i]]))
			{
				match[to[i]]=now;
				return true;
			}
		}
	}
	return false;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i],&b[i]);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&c[i],&d[i]);

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		if(a[i]<c[j] && b[i]<d[j])
		{
			add(i,j);
		}
	}

	int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
			vis[j]=0;
		if(dfs(i))
			ans++;
	}

	printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    bool flg = false;
    rep(i, n) {
        ll a;
        cin >> a;
        if ((a&1)) {
            flg = true;
        } 
    }
    if (flg) {
        cout << "first" << endl;
    }
    else {
        cout << "second" << endl;
    }
    return 0;
}


Measured memory_bytes: 3652
from functools import reduce
from operator import mul

def gcd(a, b):
    m, n = a, b
    while m % n != 0:
        m, n = n, m%n
    return n


def lcm(a, b):
    return (a * b) // gcd(a, b)


N = int(input())
A = map(int, input().split(' '))
A = list(A)

m = reduce(lcm, A, 1) - 1

fm = 0
for ai in A:
    fm += m % ai

print(fm)

Measured memory_bytes: 3812
// =========
use std::cmp::{max, min};

const MOD: usize = 1000000007;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    // var... 変数の識別子, $t...型を一つよむ
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        //ここで繰り返し
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    //
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    // 配列の最後のNestではここで型が指定されてparseされる
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
// =========

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
    }
    let mut a = a;
    let mut b = b;
    let mut c = c;
    let mut res = 0;
    while a % 2 == 0 && b % 2 == 0 && c % 2 == 0 {
        let na = (b + c) / 2;
        let nb = (a + c) / 2;
        let nc = (a + b) / 2;
        if a == na && b == nb && c == nc {
            res = -1;
            break;
        }
        res += 1;
        a = na;
        b = nb;
        c = nc;
    }
    // println!("{:?}", a);
    // println!("{:?}", b);
    // println!("{:?}", c);
    println!("{:?}", res);
}


Measured memory_bytes: 4352