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

int main() {
   int a,b,c;
   cin>>a>>b>>c;
   set<int>K;
   K.insert(a);
   K.insert(b);
   K.insert(c);
   cout<<K.size()<<endl;
return 0;}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] ary = new int[n];
		for (int i = 0; i < n; i++) {
			ary[i] = sc.nextInt();
		}
		for (int i = ary.length - 1; i >= 0; i--) {
			while(i != 0){
			System.out.print(ary[i] + " ");
			i --;
			}
			System.out.print(ary[i]);
		}System.out.println("");
	}
}


Measured memory_bytes: 26344
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vvi vector<vi>
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;

int main() {
  int k,a,b;
  bool flag = false;
  cin >> k;
  cin >> a >> b;
  repi(i,a,b){
    if(i%k == 0) {
      flag = true;
      break;
    }
  }
  if(flag) {
    cout << "OK" << endl;
  }else{
    cout << "NG" << endl;
  }

}

Measured memory_bytes: 3620
#include <stdio.h>
int main(void){
    
    int N[10000], i, len, min, max;
    long long sum;
    
    min = 1000000;
    max = -1000000;
    sum = 0;


    scanf("%d", &len);
    for(i = 0; i < len; i++){
        scanf("%d", &N[i]);
    
        if(N[i] < min){
            min = N[i];
        }
    
        if(N[i] > max){
            max = N[i];
        }
    
        sum += N[i];
    
    }
    
    printf("%d %d %lld\n", min, max, sum);
    
    return 0;
}

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

int main() {
  long N = 0L; // problem, 1 <= N <= 10^9
  int K = 0; // base, 2 <= K <= 10
  int c = 1; // keta

  cin >> N >> K;
  while(N!=0 && N>=K) { // N!=0 is always true
    N = N / K;
    c++;
  }

  cout << c << endl;
}


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

char s[100100];

main()
{
	scanf("%s",s);
	if(strlen(s)==2)
	{
		if(s[0]==s[1])
		{
			printf("1 2\n");
			return 0;
		}
	}
	else
		for(int i=2;s[i];i++)
		{
			if(s[i]==s[i-1]||s[i]==s[i-2]||s[i-1]==s[i-2])
			{
				printf("%d %d\n",i-2+1,i+1);
				return 0;
			}
		}
	printf("-1 -1\n");
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
int main(){
  int x1, x2, y1, y2;
  scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
  printf("%d %d %d %d\n", x2+y1-y2, y2-x1+x2, x1+y1-y2, y1-x1+x2);
}

Measured memory_bytes: 256
#define _[2<<17]
n,i;A _,B _,T _,F _;long M,D _,P _,R _;s(u,p,i,I){D[u]=1;for(i=F[u];I=B[i];i=T[i])I-p?s(I,u),D[u]=D[u]*-~D[I]%M:0;}S(u,x,p,i,I){for(m(i=F[u],p);I=B[i];I-p?S(I,R[i]*x%M+1,u),x=x*-~D[I]%M:0)i=T[i];P[u]=x%M;}m(i,p){i?m(T[i],p),R[i]=R[T[i]]*(B[i]-p?-~D[B[i]]:1)%M:0;}main(u,v){for(;~scanf("%d%d",&u,&v);)i++?A[i-1]=B[i]=u,B[i-1]=A[i++]=v:(n=u,M=v);for(;--i;F[A[i]]=i)T[i]=F[A[i]];s(*R=1,0);for(S(1,1);i++<n;)printf("%d ",P[i]);}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define int long long

const LL mod = 1e9 + 7;


template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }

template<class T, class U>
istream& operator >> (istream& in, pair<T, U> & v){ in >> v.X >> v.Y;return in; }

template<class T, class U>
ostream& operator << (ostream& out, pair<T, U> & v){ out << v.X << " " << v.Y;return out; }

void chkmax(int &a, int b) {
    a = max(a, b);
    return;
}

void chkmin(int &a, int b) {
    a = min(a, b);
    return;
}

LL ppow (LL x, LL s) {
    if (!s) return 1;
    if (!(s - 1)) return x % mod;
    if (s % 2) return (x * ppow (x, s - 1)) % mod;
    LL b = ppow (x, s / 2);
    return (b * b) % mod;
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("ILUXA.in", "r", stdin);
    int n;
    cin >> n;
    vector<LD> a(n);
    cin >> a;
    LD dp[n][n + 1];
    for (int i = 0;i < n;i++) {
        for (int j = 0;j <= n;j++) {
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1 - a[0];
    dp[0][1] = a[0];
    for (int i = 1;i < n;i++) {
        for (int j = 0;j <= n;j++) {
            if (j) {
                dp[i][j] += dp[i - 1][j - 1] * a[i];
            }
            dp[i][j] += dp[i - 1][j] * (1 - a[i]);
        }
        //cout << dp[i][i + 1] << '\n';
    }
    LD ans = 0;
    for (int i = 0;i <= n;i++) {
        if (i > n - i) {
            //cout << i << ":" << dp[n - 1][i] << '\n';
            ans += dp[n - 1][i];
        }
    }
    cout << setprecision(15) << fixed << ans;
    return 0;
}


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

#define R register
#define ll long long

const ll inf=(1LL<<60);
const int MAXN=2e5+10;

int n;
struct Pair
{
	int x,y;
}p[MAXN];

ll ans=inf;
int a[MAXN],b[MAXN];

inline void solve1()
{
	for(R int i=1;i<=n;i++)
	a[i]=p[i].x,b[i]=p[i].y;
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	ll res=(ll)(a[n]-a[1])*(b[n]-b[1]);
	if(res<ans) ans=res;
}

struct Segment_Tree
{
	int mx[MAXN<<2],mn[MAXN<<2];
	inline int ls(int x) { return x<<1; }
	inline int rs(int x) { return x<<1|1; }
	inline void update(int x)
	{
		mx[x]=max(mx[ls(x)],mx[rs(x)]);
		mn[x]=min(mn[ls(x)],mn[rs(x)]);
	}
	inline void chg(int x,int l,int r,int ad,int k)
	{
		if(l==r)
		{
			mn[x]=mx[x]=k;
			return;
		}
		int mid=l+r;mid>>=1;
		if(ad<=mid) chg(ls(x),l,mid,ad,k);
		else chg(rs(x),mid+1,r,ad,k);
		update(x);
	}
	inline int findmin()
	{
		return mn[1];
	}
	inline int findmax()
	{
		return mx[1];
	}
}Tr,Tb;

inline bool cmp(Pair p1,Pair p2)
{
	if(p1.x==p2.x) return p1.y<p2.y;
	return p1.x<p2.x;
}

int tag[MAXN];

inline void solve2()
{
	sort(p+1,p+1+n,cmp);
	int mxnode=-1,mxnum1=-1,mxnum2=-1;
	for(R int i=1;i<=n;i++)
	{
		if(p[i].y>mxnum1)
		{
			mxnode=i;
			mxnum1=p[i].y;
			mxnum2=p[i].x;
			continue;
		}
		if(p[i].y==mxnum1)
		{
			if(p[i].x>mxnum2)
			{
				mxnode=i;
				mxnum2=p[i].x;
				continue;
			}
		}
	}
	tag[mxnode]=1;
	swap(p[1].x,p[1].y);
	tag[1]=1;
	for(R int i=1;i<=n;i++)
	{
		Tb.chg(1,1,n,i,p[i].x);
		Tr.chg(1,1,n,i,p[i].y);
	}
	ll res=(ll)(Tb.findmax()-Tb.findmin())*(Tr.findmax()-Tr.findmin());
	if(res<ans) ans=res;
	for(R int i=1;i<=n;i++)
	{
		if(tag[i]) continue;
		Tb.chg(1,1,n,i,p[i].y);
		Tr.chg(1,1,n,i,p[i].x);
		ll tres=(ll)(Tb.findmax()-Tb.findmin())*(Tr.findmax()-Tr.findmin());
		if(tres<ans) ans=tres;
	}
}

int main()
{
	scanf("%d",&n);
	for(R int i=1;i<=n;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		if(x>y) swap(x,y);
		p[i].x=x;
		p[i].y=y;
	}
	solve1();
	solve2();
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 16000
#include <map>
#include <cstdio>
using namespace std;
typedef map<pair<int,int>,int> mpiii;

void solve(int T){
	mpiii m;
	mpiii::iterator it,it2;
	char cmd[2];
	int n,k;
	for(;T--;){
		scanf("%s%d",cmd,&n);
		if(*cmd=='D'){
			for(it=m.begin();it!=m.end();){
				if(it->second==n){
					it2=it++;
					m.erase(it2);
				}else{
					++it;
				}
			}
		}else if(*cmd=='R'){
			it=m.lower_bound(make_pair(n,2000000000));
			if(it==m.begin()){
				puts("-1");
			}else{
				--it;
				printf("%d\n",it->first.first<=n&&n<=it->first.second ? it->second : -1);
			}
		}else if(*cmd=='W'){
			int cur=0;
			scanf("%d",&k);
			for(it=m.begin();it!=m.end();++it){
				int d=it->first.first-cur;
				if(d>k)d=k;
				if(d)m[make_pair(cur,cur+d-1)]=n;
				k-=d;
				if(k==0)break;
				cur=it->first.second+1;
			}
			if(k)m[make_pair(cur,cur+k-1)]=n;
		}
	}
}
int main(){for(int T;~scanf("%d",&T)&&T;puts(""))solve(T);}

Measured memory_bytes: 1240
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc =new Scanner(System.in);
		
		int n = sc.nextInt();
		int a[] = new int[n+1];
		int b[] = new int[n+1];
		
		for(int i=0;i<=n;i++) {
			a[i]=sc.nextInt();
		}
		for(int i=0;i<n;i++) {
			b[i]=sc.nextInt();
		}
		b[n]=0;
		
		long ans =0;
		int res =0;
		
		for(int i=0;i<=n;i++) {
			ans+=Math.min(a[i], b[i]+res);
			res=Math.min(b[i], b[i]+res-a[i]);
			res=Math.max(res, 0);
		}
		
		System.out.println(ans);

}
	
	
	
}





Measured memory_bytes: 64748
#include<stdio.h>
#define N 1000000
int h;
void maxHeapify(int *,int);
void buildMaxHeap(int *);

int main(){
    int A[N],i;

    scanf("%d",&h);
    for(i = 1;i <= h;i++){
        scanf("%d",&A[i]);
    }
    buildMaxHeap(A);

    for(i = 1;i <= h;i++){
        printf(" %d",A[i]);
    }
    printf("\n");

    return 0;
}

void maxHeapify(int *A,int i){
    int a,l,r,max;
    l = i*2;
    r = i*2+1;

    if(l <= h && A[l] > A[i])max = l;
    else max = i;
    
    if(r <= h && A[r] >A[max])max = r;

    if(max != i){
        a = A[i];
        A[i] = A[max];
        A[max] = a;
        maxHeapify(A,max);
    }
}

void buildMaxHeap(int *A){
    int i;

    for(i = h/2;i >=1;i--)maxHeapify(A,i);
}


Measured memory_bytes: 3656
import functools
import math

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


x, y = inl()
print(x+y // 2)


Measured memory_bytes: 3700
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main() {
  int N, result;
  int i;
  scanf ("%d", &N);
  
  result = 0;
  
  if      (N <10    ) result = N;
  else if (N <100   ) result = 9;
  else if (N <1000  ) result = 9+N-99;
  else if (N <10000 ) result = 909;
  else if (N <100000) result = 909+N-9999;
  else if (N==100000) result = 90909;
  printf("%d", result);
  return 0;
}




Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;
using System.Text;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var a = consoleReader.Int;
            var b = consoleReader.Int;
            return new[] { a + b, a - b, a * b }.Max();
        }

        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

#pragma warning disable
    public class ConsoleReader
    {
        private string[] line = Array.Empty<string>();
        private int linePosition;
        private TextReader textReader;
        public ConsoleReader(TextReader tr) { textReader = tr; }
        public int Int => int.Parse(String);
        public long Long => long.Parse(String);
        public double Double => double.Parse(String);
        public string String
        {
            get
            {
                if (linePosition >= line.Length)
                {
                    linePosition = 0;
                    line = textReader.ReadLine().Split();
                }
                return line[linePosition++];
            }
        }
        public class SplitLine
        {
            private string[] splited;
            public SplitLine(ConsoleReader cr) { splited = cr.textReader.ReadLine().Split(); }
            public int[] Int => String.Select(x => int.Parse(x)).ToArray();
            public long[] Long => String.Select(x => long.Parse(x)).ToArray();
            public double[] Double => String.Select(x => double.Parse(x)).ToArray();
            public string[] String => splited;
        }
        public SplitLine Split => new SplitLine(this);
        public class RepeatReader
        {
            ConsoleReader cr; int count;
            public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; }
            public IEnumerable<T> Select<T>(Func<ConsoleReader, T> func) { for (int i = 0; i < count; i++) yield return func(cr); }
            public IEnumerable<string> String { get { for (int i = 0; i < count; i++) yield return cr.String; } }
            public IEnumerable<int> Int { get { for (int i = 0; i < count; i++) yield return cr.Int; } }
            public IEnumerable<double> Double { get { for (int i = 0; i < count; i++) yield return cr.Double; } }
        }
        public RepeatReader Repeat(int count) => new RepeatReader(this, count);
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
    int n;
    double X[100];
    double Y[100];
    cin >>n;

    for(int i=0; i<n; i++){
        cin >> X[i];
    }
    for(int j=0; j<n; j++){
        cin >> Y[j];
    }

    for(int p=1; p<=4; p++){
        double S=0;
        double D;

        if(p==4){
            double max=0;
            for(int l=0; l<n; l++){
                if(fabs(X[l]-Y[l]) > max) max = fabs(X[l]-Y[l]);
            }
            printf("%lf\n",max);

        } else {
            for(int k=0; k<n; k++){
                S += fabs(pow(X[k]-Y[k], p));
            }
            D = pow(fabs(S), (1.0/p));
            printf("%lf\n", D);
        }
    }

    return 0;
}


Measured memory_bytes: 3404
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(void) {
    int a[5], k;
    rep(i, 5) cin >> a[i]; cin >> k;

    sort(a, &a[5]);
    if (a[4] - a[0] > k)
        cout <<  ":(" << endl;
    else
        cout << "Yay!" << endl;
}


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

int main()
{
	string s;

   cin >> s;

   if(s=="Sunny"){
     cout << "Cloudy" << endl;
   }
   else if(s=="Cloudy"){
     cout << "Rainy" << endl;
   }
   else if(s=="Rainy"){
     cout << "Sunny" << endl;
   }

	return 0;
}

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

typedef long long ll;

ll N, K;
map<ll, ll> B;
vector<ll> C;

ll solve() {
  if (C.size() <= K) return 0;
  ll r = 0;
  for (ll i = 0; i < C.size() - K; ++i) {
    r += C[i];
  }
  return r;
}
int main() {
  cin >> N >> K;
  for (ll i = 0; i < N; ++i) {
    ll a;
    cin >> a;
    ++B[a];
  }
  for (auto an : B) {
    ll a, n;
    tie(a, n) = an;
    C.push_back(n);
  }
  sort(C.begin(), C.end());
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 14964
z[9999],r[9999],x,a,b,c,h;
f(a,b){
	fflush(!printf("? %d %d\n",a,b));
	scanf("%s",&x);
	x=x=='Y';
}
main(i){
	if(scanf("%d%d",&a,&b),a<=b){puts("Impossible");return 0;}
	for(i=a+=b;~--i;)!c||f(i,z[c-1])?(z[c++]=i):c--;
	for(h=*z,i=a;~--i;)r[i]=f(h,i);
	for(printf("! "),i=0;i<a;)printf("%d",r[i++]);
	puts("");
}

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

int main(){
	string s1,s2;
	cin >> s1 >> s2;
	int num = 0;
	for (int i =0; i < 3; i++){
		if(s1[i] == s2[i]){
			num++;
		}
	}
	cout << num << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
     
typedef long long ll;
typedef vector <int> vi;
typedef pair <int,int> pi;
typedef tuple <int,int,int> ti;

#define forn(i,a,n) for(int i = a; i < n ; i++)
#define mem(str,a) memset(str, a, sizeof(str));
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(nullptr)
const int MOD = 1e9+7, N = 1e7 + 10, E = 1e-9;
/*
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
//vector <int> show;
//for (auto x : show)
//   cout << x << " ";
getline(cin,s);


*/

int main() {
    int a,b;
    cin >> a >> b;
    if(a+b >= 24)
        cout << a+b-24 << endl;
    else
        cout << a+b << endl;
    return 0;
}

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

using namespace std ;

const long long mod = 1e9 + 7ll ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	long long n , k;
	cin>>n>>k ;
	int arr[n] ;
	for(int i = 0 ; i < n ; ++i)
		cin>>arr[i] ;
	long long ans = 0ll ;
	long long x = k * (k+1ll) / 2ll ;
	long long y = k * (k-1ll) / 2ll ;
	x %= mod ;
	y %= mod ;
	for(int i = 0 ; i < n ; ++i)
	{
		long long cnt = 0ll ;
		for(int j = i+1 ; j < n ; ++j)
		{
			if(arr[i] > arr[j])
				cnt++ ;
		}
		ans += (x * cnt) % mod ;
		cnt = 0 ;
		for(int j = i-1 ; j >= 0 ; --j)
		{
			if(arr[i] > arr[j])
				cnt++ ;
		}
		ans += (y * cnt) % mod ;
		ans %= mod ;
	}
	return cout<<ans<<"\n" , 0 ;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc161/tasks/abc161_b
//B - Popular Vote
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
#if LOCAL&0
  std::ifstream in("./test/sample-3.in");
  //std::ifstream in("./input.txt");
  std::cin.rdbuf(in.rdbuf());
#else
  cin.tie(0);
  ios::sync_with_stdio(false);
#endif
  ll N,M; cin>>N>>M;
  vector<ll> an(N);
  ll sums=0;
  for(auto&& a:an){
    cin>>a;
    sums += a;
  }
  ll lim=(sums+(4*M-1)) / (4*M);
  ll sel=0;
  for(const auto&a:an){
    if(a>=lim)++sel;
  }
  if(sel>=M)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 256
//#include <iostream>
//#include <vector>
//#include <set>
//#include <map>
//#include <algorithm>

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 998244353;
const ll len = 2 * (int) 1e5 + 1;


int main() {
//    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ans += a[i];
    }
    ans = ans * ans;
    for (int i = 0; i < n; i++) {
        ans -= a[i] * a[i];
    }
    cout << ans / 2;
}

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

// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> P;
typedef pair<lint, lint> Plint;
 
const int MOD = 1e9+7;
const int INF = 1<<18;
const lint INFLINT = 1LL<<60;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define reps(i,n) for(lint i=0;i<=(lint)(n);i++)
#define rrep(i,n) for(lint i=(lint)(n)-1;i>0;i--)
#define rreps(i,n) for(lint i=(lint)(n)-1;i>=0;i--)

#define pb push_back

#define ALL(s) (s.begin(), s.end())
#define SZ(s) (s.size())

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

// Union-Find-Tree
class UnionFind {
	vector<int> par;
	UnionFind(int n):par(n){rep(i,n)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);int ry=root(y);if(rx==ry)return;par[rx]=ry;}
	bool same(int x,int y){return root(x)==root(y);}
};

// Final Weapon!
// #define int lint

int main() {
    int n, i;
    cin >> n;
    int v[] = { 64, 32, 16, 8, 4, 2, 1 };
    for(i = 0; i <= 6; i++) {
        if(v[i] <= n) break;
    }
    cout << v[i];
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()

int main()
{
  string s; cin >> s;
  int ans=0;
  if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') ans =3;
  if (s[0] == 'R' && s[1] == 'R' && s[2] == 'S') ans =2;
  if (s[0] == 'R' && s[1] == 'S' && s[2] == 'S') ans =1;
  if (s[0] == 'S' && s[1] == 'S' && s[2] == 'S') ans =0;
  if (s[0] == 'S' && s[1] == 'R' && s[2] == 'R') ans =2;
  if (s[0] == 'S' && s[1] == 'S' && s[2] == 'R') ans =1;
  if (s[0] == 'R' && s[1] == 'S' && s[2] == 'R') ans =1;
  if (s[0] == 'S' && s[1] == 'R' && s[2] == 'S') ans =1;
  
  cout << ans << endl;
}


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

int main()
{
    int j=0,k=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if((i+1)%2!=0 && s[i]=='L') {j++;break;}
        if((i+1)%2==0 && s[i]=='R') {j++;break;}
    }
    if(j!=0)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}



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

using namespace std;
int main(){
    int N,M,S;cin >> N >> M;S = 0;
    std::vector<int> A(M);
    for (int i=0;i<M;i++) cin >> A[i];
    for (int i=0;i<M;i++) S= S+A[i];
    if(S<=N){
        cout << N-S << endl;
    }else{
        cout << "-1" << endl;
    }
}




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

int main(){
	/*input*/
	int n;	cin >> n;
	int* p = new int [n];
	for(int i = 0; i < n; i++){
		cin >> p[i];
	}

	/*calculation*/
	int ans = 0;
	for(int i = 0; i < n - 2; i++){
		if(p[i] < p[i + 1] && p[i + 1] < p[i + 2]){
			ans++;
		}else if(p[i] > p[i + 1] && p[i + 1] > p[i + 2]){
			ans++;
		}
	}
	/*output*/
	cout << ans << endl;
	delete[] p;
	return 0;
}


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

//segment tree
const ll n = 1 << 19; 
ll dat[26][2*n-1];

void init(ll j) {
  for (ll i = 0; i < 2*n-1; i++) dat[j][i] = 0;
}

void update(ll k, ll a, ll j) {
  k += n-1;
  dat[j][k] = a;
  while (k > 0) {
    k = (k-1)/2;
    dat[j][k] = dat[j][k*2+1]|dat[j][2*k+2];
  }
}

ll query(ll a, ll b, ll k, ll l, ll r, ll j) {
  if (r <= a || b <= l) return 0;
  if (a <= l && r <= b) return dat[j][k];
  else {
    ll vl = query(a, b, k*2+1, l, (l+r)/2, j);
    ll vr = query(a, b, k*2+2, (l+r)/2, r, j);
    return vl|vr;
  }
}

int main() {
  ll N, Q; string S; cin >> N >> S >> Q;
  map<char, int> ord;
  char C = 'a'; ord[C] = 0; 
  for (ll i = 1; i < 26; i++) {
    C++; ord[C] = i;
  }
  
  for (ll i = 0; i < 26; i++) {init(i);}
  for (ll i = 0; i < N; i++) {update(i, 1, ord[S[i]]);}
  
  for (ll i = 0; i < Q; i++) {
    ll x; cin >> x;
    if (x == 1) {
      ll i; cin >> i; i--;
      char c; cin >> c; 
      update(i, 0, ord[S[i]]); S[i] = c;
      update(i, 1, ord[S[i]]);
    }
    if (x == 2) {
      ll a, b; cin >> a >> b; a--; b--;
      ll res = 0;
      for (ll i = 0; i < 26; i++) {
        res+=query(a,b+1,0,0,n,i);
      }
      cout << res << endl;
    }
  }
}

Measured memory_bytes: 214020
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d>0?i<n:i>n;i+=d)
#define endl "\n"
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

vector<ll> divisors(ll n){
  vector<ll> v0,v1;
  ll MAX=sqrt(n)+1;
  rep(i,1,MAX) if(n%i==0) {
    v0.push_back(i); v1.push_back(n/i);
  }
  reverse(v1.begin(),v1.end());
  auto it=v1.begin();
  if(v0.back()==v1.front()) it++;
  copy(it,v1.end(),back_inserter(v0));
  return v0;
}

void solve(){
    ll n; cin >> n;
    ll res = INF;
    for(auto d : divisors(n)){
        auto x = n / d;
        chmin(res, x + d - 2);
    }

    cout << res << endl;
}

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

typedef long long ll;
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

ll gcd(ll a,ll b){
    if(a < b){
        ll c = a;
        a = b;
        b = c;
    }
    if(a%b == 0) return b;
    else return gcd(b,a%b);
}
 
int main(){

    int n;
    cin >> n;

    ll x;
    REP(i,n){
        if(i == 0) cin >> x;
        else{
            ll y;
            cin >> y;
            x = x/gcd(x,y) * y;
        }
    }
    cout << x;
}
//for(int i=0;i<n;i++)

Measured memory_bytes: 256
import Control.Applicative

qsort [] = []
qsort (p:xs) = qsort lt ++ [p] ++ qsort ge
  where
    lt = [x | x <- xs, x < p]
    ge = [x | x <- xs, x >= p]

main = do
  a <- map (\x -> read x :: Int) . words <$> getLine
  putStrLn $ unwords $ map (\x -> show x) $ qsort a

Measured memory_bytes: 3676
n,m = map(int, input().split())
u = [0]*(n+1)
for i in range(m):
    u[int(input())] = 1
ll = [0]*(n+2)
ll[1] = 1
for i in range(2,n+2):
    if not u[i-1]:
        ll[i] = ll[i-1] + ll[i - 2]
print(ll[-1] % 1000000007)


Measured memory_bytes: 460788
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
 
	public static void main(String[] args) {  
		Scanner input = new Scanner(System.in);
		int R = input.nextInt();
		int C = input.nextInt();
		int N = input.nextInt();
		int[] arr = new int[N+1];
		int[][] ans = new int[R][C];
		for (int i = 1; i <= N; i++) {
			arr[i] = input.nextInt();
		}
		int index = 1;
		for (int r = 0; r < R; r++) {
			if (r%2==0) {
				for (int c = 0; c< C; c++){
					ans[r][c]=index;
					arr[index]--;
					if (arr[index]==0) index++;
				}
			}else {
				for (int c = C-1; c>=0; c--) {
					ans[r][c]=index;
					arr[index]--;
					if (arr[index]==0) index++;
				}
			}
		}
		for (int i = 0; i < R; i++) {
			for (int j = 0; j < C; j++) {
				System.out.print(ans[i][j]+" ");
			}
			System.out.print("\n");
		}
		//System.out.println((3&5)+(3^5));
	}
}

Measured memory_bytes: 39992
#include <iostream>
#include <vector>
#include <string>
#include <cassert>

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	string s;
	cin >> s;
	int cnt_ones = 0;
	for (auto c : s) {
		cnt_ones += (c == '1');
	}
	int cnt_zeroes = s.size() - cnt_ones;
	long long ans = 0;
	while (cnt_ones > 0) {
		ans += (cnt_ones + 1) / 2;
		cnt_ones--;
	}
	vector<pair<char, int>> comp;
	for (auto c : s) {
		if (comp.empty() || c != comp.back().first) {
			comp.emplace_back(c, 1);
		}
		else {
			comp.back().second++;
		}
	}
	for (auto seg : comp) {
		if (seg.first == '1') {
			int whole = (seg.second / 2);
			ans += 1LL * whole * cnt_zeroes;
		}
	}
	vector<pair<char, int>> new_comp;
	for (auto seg : comp) {
		if (seg.first == '1') {
			seg.second %= 2;
		}
		if (seg.second > 0) {
			if (new_comp.empty() || new_comp.back().first != seg.first) {
				new_comp.push_back(seg);
			}
			else {
				new_comp.back().second += seg.second;
			}
		}
	}
	if (new_comp.empty()) {
		cout << ans << endl;
		return 0;
	}
	if (new_comp[0].first == '1') {
		new_comp.insert(new_comp.begin(), make_pair('0', 0));
	}
	if (new_comp.back().first == '1') {
		new_comp.emplace_back('0', 0);
	}
	int n = new_comp.size() / 2;
	vector<int> zs;
	for (int i = 0; i < new_comp.size(); i += 2) {
		zs.push_back(new_comp[i].second);
	}
	assert(zs.size() == n + 1);
	vector<int> pref(n + 1);
	pref[0] = zs[0];
	for (int i = 1; i < n + 1; i++) {
		pref[i] = pref[i - 1] + zs[i];
	}
	vector<int> suf(n + 1);
	suf[n] = zs[n];
	for (int i = n - 1; i >= 0; i--) {
		suf[i] = suf[i + 1] + zs[i];
	}
	for (int i = 0; i < n; i++) {
		ans += suf[i + 1];
		int pos = pref[i] + i;
		ans += (pref[i] + !(pos & 1)) / 2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 8084
n = int(input())
b = list(map(int,input().split()))
rev = []
for i in range(n): #i番目の操作のものを見つける
    cand = []
    for j in range(len(b)):
        if b[j] != j+1:
            if cand:
                continue
            break
        else:
            cand.append(j+1)
    if not cand:
        print(-1)
        exit()
    rev.append(cand[-1])
    b.pop(cand[-1]-1)
ans = reversed(rev)
for k in ans:
    print(k)

Measured memory_bytes: 9220
#include "bits/stdc++.h"

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
//#define llint

#ifdef llint
#define int ll
static const int INF = numeric_limits<long long>::max();
#else
static const int INF = numeric_limits<int>::max();
#endif // llint
static const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int w, h;

void dfs(int x,int y,vector<vector<int>>& map) {
	map[y][x] = 0;
	//rep(y, h) {
	//	rep(x, w) {
	//		cout << map[y][x] << " ";
	//	}
	//	cout << endl;
	//}
	//cout << endl;
	//cout << "x : " << x << " y : " << y << endl;
	rep(i, 8) {
		int tx = x + dx[i];
		int ty = y + dy[i];
		//cout << "nx : " << tx << " ny : " << ty << endl;
		if (tx >= 0 and tx < map[0].size() and ty >= 0 and ty < map.size()) {
			if(map[ty][tx] == 1)
				dfs(tx, ty, map);
		}
	}
	return;
}

signed main() {
	ios::sync_with_stdio(true);
	while (true) {
		cin >> w >> h;
		if (w == 0 and h == 0) break;
		vector<vector<int>>  map(h);
		rep(i, h) {
			rep(j, w) {
				int x;
				cin >> x;
				map[i].pb(x);
			}
		}
		int ans = 0;
		rep(y,h){
			rep(x, w) {
				if (map[y][x] == 1) {
					dfs(x, y, map);
					ans++;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3192
#include <stdio.h>
#include <stdlib.h>
#define int long long

typedef struct {
	int val;
	int num;
}pair;

signed compare(const void *a, const void *b){
	int sub = *(int *)a - *(int *)b;
	if(sub < 0){
		return -1;
	}
	else if(sub == 0){
		return 0;
	}
	else{
		return 1;
	}
}

int min(int a, int b){
	return a <= b ? a : b;
}

int next_pow(int n){
	int ans = 1;
	while(ans <= n){
		ans *= 2;
	}
	return ans;
}

signed main(){
	int N, i, j, ans = 0;
	scanf("%lld", &N);
	int *A = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &A[i]);
	}
	qsort(A, N, sizeof(int), compare);
	pair *B = (pair *)malloc(sizeof(pair) * N);
	for(i = 1, j = 0, B[0].val = A[0], B[0].num = 1; i < N; i++){
		if(A[i] == A[i - 1]){
			B[j].num++;
		}
		else{
			j++;
			B[j].val = A[i];
			B[j].num = 1;
		}
	}
	N = j + 1;
	int l, h, r, k, minnum;
	for(i = N - 1; i >= 0; i--){
		if(B[i].num > 0){
			k = next_pow(B[i].val);
			l = -1;
			r = i + 1;
			while(r - l > 1){
				h = (l + r) / 2;
				if(B[h].val < k - B[i].val){
					l = h;
				}
				else{
					r = h;
				}
			}
			if(B[r].val + B[i].val == k){
				if(r == i){
					ans += B[i].num / 2;
					B[i].num %= 2;
				}
				else{
					minnum = min(B[r].num, B[i].num);
					ans += minnum;
					B[r].num -= minnum;
					B[i].num -= minnum;
				}
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

signed main() {
  ll N;
  cin>>N;
  vector<PLL> v(N); // {deadline, duration}
  rep(i,0,N) {
    cin>>v[i].second>>v[i].first;
  }
  sort(begin(v), end(v));

  ll endtime = v[N-1].first;

  for (ll i=N-1; i>=0; i--){
    ll e = min(endtime, v[i].first);
    ll s = e - v[i].second + 1;
    //printf("i=%d [%d %d] endtime=%d\n", i, s, e, endtime);
    //if (endtime < e){
    //  cout<<"No"<<endl;
    //  return 0;
    //}
    endtime = s-1;
  }
  if (endtime < 0) {
      cout<<"No"<<endl;
      return 0;
  }
  cout<<"Yes"<<endl;
  return 0;
}


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


int main() {
    int n,m;
    scanf("%d%d",&n,&m);
    vector<pair<int,int>>s;
    for(int i=0;i<n;++i){
        int a,b;
        cin>>a>>b;
        s.push_back({a,b});
    }
    sort(s.begin(),s.end());
    int64_t ans=0;
    for(int i=0;i<n;++i){
        int k=min(m,s[i].second);
        m-=k;
        ans+=1LL*k*s[i].first;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int cnt = 0;
	while(a >= b) b *= 2, cnt++;
	while(b >= c) c *= 2, cnt++;
	if(cnt <= k) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


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

#define   ll     long long int

int cnt[28];
int cur[28];

int main( )
{
    string con[55];
    string s;
    int i, j, k, n;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> con[i];
    }
    for (i = 0; i < (int) con[1].size(); i++) {
        cnt[con[1][i] - 'a']++;
    }
    for (i = 2; i <= n; i++) {
        memset(cur, 0, sizeof cur);
        for (j = 0; j < (int) con[i].size(); j++) {
            int x = con[i][j] - 'a';
            cur[x]++;
        }
        for (int i = 0; i < 26; i++) {
            cnt[i] = min(cnt[i], cur[i]);
        }
    }
    s = "";
    for (i = 0; i < 26; i++) {
        for (j = 0; j < cnt[i]; j++) {
            s.push_back(char(i + 'a'));
        }
    }
    cout << s << '\n';
    return 0;
}


Measured memory_bytes: 256
// ref: https://qiita.com/tubo28/items/e6076e9040da57368845
use std::io::{stdin, Read};
use std::str::FromStr;
use std::collections::BTreeMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let w: String = read();

    let mut counter = BTreeMap::new();
    for c in w.chars() {
        *counter.entry(c).or_insert(0) += 1
    }
    let ans = counter.values().all(|&val| val % 2 == 0);

    println!("{}", if ans { "Yes" } else { "No" });
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
using namespace std;
string A, B;

string merge(size_t la, size_t ra, size_t lb, size_t rb){
  int s = -1, t = -1, k = 0;
  if(ra-la <= 2 or rb-lb <= 2) return "";
  int x = 0;
  for(size_t i = la; i < ra; ++i){
    if(A[i] == '(') ++k;
    if(A[i] == ')') --k;
    if(not k){
      s = i+2;
      break;
    }
  }
  int s_ = s;
  if(s < 0) x = -1;
  else{
    while(A[s] != ']'){
      x *= 10;
      x += A[s++] - '0';
    }
  }
  k = 0;
  int y = 0;
  for(size_t i = lb; i < rb; ++i){
    if(B[i] == '(') ++k;
    if(B[i] == ')') --k;
    if(not k){
      t = i+2;
      break;
    }
  }
  int t_ = t;
  if(t < 0) x = -1;
  else{
    while(B[t] != ']'){
      y *= 10;
      y += B[t++] - '0';
    }
  }
  if(x < 0 or y < 0){
    return "()";
  }
  int z = x+y;
  return "("+merge(la+1,s_-1,lb+1,t_-1)+")["+to_string(z)+"]("+merge(s+2,ra-1,t+2,rb-1)+")";
}

int main(){
  cin >> A >> B;
  cout << merge(0,A.length(),0,B.length()) << endl;
}



Measured memory_bytes: 3288
N, Ma, Mb = [int(_) for _ in input().split()]
ABC = [[int(_) for _ in input().split()] for _ in range(N)]
dp = {}
dp[0] = 0
dp[ABC[0][0] + 1000 * ABC[0][1]] = ABC[0][2]
ans = 5000
for i in range(N - 1):
    dp_old = dp.copy()
    for ab in dp_old.keys():
        a = ab % 1000
        b = ab // 1000
        if a * Mb == b * Ma > 0:
            ans = min(ans, dp_old[ab])
        dp[a + ABC[i + 1][0] + 1000 * (b + ABC[i + 1][1])] = min(
            dp_old[ab] + ABC[i + 1][2],
            dp_old.get(a + ABC[i + 1][0] + 1000 * (b + ABC[i + 1][1]), 5000))
for ab in dp.keys():
    a = ab % 1000
    b = ab // 1000
    if a * Mb == b * Ma > 0:
        ans = min(ans, dp[ab])
if ans == 5000:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9932
#include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 using ll = long long;
 const int INF = 2147483647;

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

Measured memory_bytes: 3632
//Code is like humor. When you have to explain it, it’s bad.
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <bits/stdc++.h>
#define pii pair<int,int>
#define MOD 1000000007
#define int long long
using namespace std;
#define s second
#define f first
int32_t main()
{
    fastio;
    int T,n,m,i,j,k,a,b,c;
    T=1;
    while(T --> 0)
    {
        cin>>n>>m;
        int A[m];
        int sum=0;
        for(i=0;i<m;i++)
        {
            cin>>A[i];
            sum+=A[i];
        }
        cout<<max(-1LL,n-sum);
    }
    return 0;
}

Measured memory_bytes: 3716
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int sum = 0;
    rep(i, n) {
        sum += a[i];
    }
    if (sum % 10) {
        cout << sum << endl;
        return 0;
    }
    sort(a.begin(), a.end());
    int keep = -1;
    rep(i, n) {
        if (a[i] % 10) {
            keep = i;
            break;
        }
    }
    if (keep == -1) {
        cout << 0 << endl;
        return 0;
    }
    cout << sum - a[keep] << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
constexpr auto MAX = 10E9+1;
using namespace std;
using ll = long long;
using VI = vector<int>;

int main()
{
    
    ll n, m, k, t = 0;
    cin >> n >> m >> k;
    vector<ll> a, b, a_time = { 0 }, b_time = { 0 };
    for (int i = 0; i < n; i++) {
        ll input;
        cin >> input;
        t += input;
        a_time.push_back(t);
        a.push_back(input);
    }
    t = 0;
    for (int i = 0; i < m; i++) {
        ll input;
        cin >> input;
        t += input;
        b_time.push_back(t);
        b.push_back(input);
    }
    int j = m, ans = 0;
    for (int i = 0; i < n+1; i++) {
        if (a_time[i] > k) break;
        while (b_time[j] > k - a_time[i]) {
            j--;
        }
        ans = max(ans, i + j);
    }
    cout << ans << endl;
    
        
    

    

    return 0;
}


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

int main(){
  char S[4],T[4];
  scanf("%s %s",S,T);
  int flag=0,i;
  for(i=0;i<3;i++){
    if(S[i]==T[i]) flag++;
  }
  printf("%d\n",flag);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<set>
#include<random>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1145141919;
const long double pi = 3.1415926535897932384626433;
typedef pair<int, int> P;
struct edge { int to, cost; };
vector<P>V;
int dp[200005];
signed main() {
	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	int n; cin >> n;
	if (x1 > x2) {
		swap(x1, x2); swap(y1, y2);
	}
	int flg = 1;
	if (y1 > y2) {
		flg = -1;
		y1 *= -1; y2 *= -1;
	}
	rep(i, n) {
		int a, b; cin >> a >> b;
		b *= flg;
		if(x1<=a&&a<=x2&&y1<=b&&b<=y2)V.push_back(P(a,b));
	}
	int ls = 0;
	sort(V.begin(), V.end());
	fill(dp, dp + n, inf);
	rep(i, V.size()) {
		*lower_bound(dp, dp + n, V[i].second) = V[i].second;
	}
	ls = lower_bound(dp, dp + n, inf) - dp;
	//rep(i, ls)cout << dp[i] << endl;
	
	long double ans = 100 * (x2 + y2 - x1 - y1);
	ans -= 20 * ls;
	ans += pi*ls*5;
	if ((ls == x2-x1 + 1) || (ls == y2-y1 + 1)) {
		ans += pi * 5;
	}
	printf("%.13Lf\n", ans);
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  vector<int> T(N), A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d %d", &T[i], &A[i]);
  }
  ll a = 1, b = 1;
  for (int i = 0; i < N; ++i) {
    ll n = max((a + T[i] - 1) / T[i], (b + A[i] - 1) / A[i]);
    a = n * T[i];
    b = n * A[i];

  }
  ll ans = a + b;
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;


int main(){
        ll n;
        scanf("%ld", &n);

        std::vector<std::vector<P>> xys(n, std::vector<P>(0));
        for(ll i=0; i<n; i++){
                ll a;
                scanf("%ld", &a);
                for(ll j=0; j<a; j++){
                        ll x, y;
                        scanf("%ld %ld", &x, &y);
                        xys[i].push_back(P(x-1, y));
                }
        }

        ll ans = 0;
        for(ll i=0; i<(1<<n); i++){
                std::vector<bool> honest(n, 0), unkind(n, 0);
                ll cnt = 0;
                for(ll j=0; j<n; j++){
                        if((i>>j)&1){
                                if(unkind[j]) cnt = -1e18;
                                cnt ++;
                                honest[j] = true;
                                for(P p: xys[j]){
                                        if(p.second){
                                                if(unkind[p.first]) cnt = -1e18;
                                                honest[p.first] = true;
                                        }else{
                                                if(honest[p.first]) cnt = -1e18;
                                                unkind[p.first] = true;
                                        }
                                }
                        }else{
                                if(honest[j]) cnt = -1e18;
                                unkind[j] = true;
                        }
                }
                ans = std::max(ans, cnt);
        }

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

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, ans int
	fmt.Scan(&a, &b)
	ans += a - 1
	if a <= b {
		ans++
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}

func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return abs(a[i]) > abs(a[j]) }


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
signed main()
{
	int k;
	string s;
	cin>>k>>s;
	if (sz(s)>k)  s=s.substr(0,k)+"...";
	cout<<s; 
	re 0;
}

Measured memory_bytes: 3632
S = list(input())
n = len(S)
mod = 10**9 + 7

dpa = [0]*(10**5+10)
dpc = [0]*(10**5+10)

hatena_count = 0
pow3 = [1]*(10**5+10)

for i in range(1, 10**5+10):
    pow3[i] = pow3[i-1]*3 % mod

for i in range(n):
    if S[i] == "A":
        dpa[i+1] = (dpa[i] + pow3[hatena_count]) % mod
    elif S[i] == "?":
        dpa[i+1] = (3*dpa[i] + pow3[hatena_count]) % mod
        hatena_count += 1
    else:
        dpa[i+1] = dpa[i]

S.reverse()

hatena_count = 0
for i in range(n):
    if S[i] == "C":
        dpc[i+1] = (dpc[i] + pow3[hatena_count]) % mod
    elif S[i] == "?":
        dpc[i+1] = (3*dpc[i] + pow3[hatena_count]) % mod
        hatena_count += 1
    else:
        dpc[i+1] = dpc[i]

ans = 0
for i in range(1, n - 1):
    if S[i] == "B" or S[i] == "?":
        ans += dpa[n-1-i]*dpc[i]
        ans %= mod
print(ans)




Measured memory_bytes: 21372
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln =  '\n';

const int mx=200010;
//const ll mod=1e9+7;
const ll mod=998244353;

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

int main(){
  int n,s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }

  vector<vector<vector<mint>>> dp(3010, vector<vector<mint>>(3010, vector<mint>(3,0)));
  dp[0][0][0]=1;
  rep(i,n)rep(j,s+1){
    dp[i+1][j][0] += dp[i][j][0];
    dp[i+1][j][1] += dp[i][j][1];
    dp[i+1][j][2] += dp[i][j][2];
    if(j+a[i]<=s){
      dp[i+1][j+a[i]][1] += dp[i][j][0] * (i+1);
      dp[i+1][j+a[i]][2] += dp[i][j][0] * (i+1) * (n-i);
      dp[i+1][j+a[i]][1] += dp[i][j][1];
      dp[i+1][j+a[i]][2] += dp[i][j][1] * (n-i);
    }
  }
  ll ans = dp[n][s][2].x;
  cout << ans << ln;
  return 0;
}

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

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

	int ans = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == t[i])
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256