akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; }
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; }
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
void print(void) { cout << endl; }
template <class Head> void print(Head&& head) { cout << head; print(); }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); }
template <class T> void chmax(T& a, const T b) { a = max<T>(a, b); }
template <class T> void chmin(T& a, const T b) { a = min<T>(a, b); }
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }

int main() {
	int N; cin >> N;
	V<ll> L(N); REP(i, N) cin >> L[i];
	int R = *max_element(ALL(L)),sum = accumulate(ALL(L),0);
	Yn(sum - R > R);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<i64> a(n);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);

	auto dp = make_v<i64>(n / 2 + 1, 4);
	for(int i = 0; i < (int)dp.size(); i++) for(int j = 0; j < (int)dp[i].size(); j++) dp[i][j] = -(1LL << 60);

	dp[0][0] = dp[0][1] = 0;
	for(int i = 0; i < n / 2; i++) {
		dp[i + 1][0] = std::max(dp[i + 1][0], dp[i][0] + a[i * 2]);
		dp[i + 1][1] = std::max(dp[i + 1][1], dp[i][0] + a[i * 2 + 1]);
		dp[i + 1][1] = std::max(dp[i + 1][1], dp[i][1] + a[i * 2 + 1]);

		dp[i + 1][2] = std::max(dp[i + 1][2], dp[i][2] + a[i * 2]);
		dp[i + 1][3] = std::max(dp[i + 1][3], dp[i][2] + a[i * 2 + 1]);
		dp[i + 1][3] = std::max(dp[i + 1][3], dp[i][3] + a[i * 2 + 1]);

		dp[i + 1][2] = std::max({dp[i + 1][2], dp[i][0], dp[i][1]});
		dp[i + 1][3] = std::max({dp[i + 1][3], dp[i][0], dp[i][1]});
	}
	
	i64 ans = -(1LL << 60);
	if(n % 2) {
		ans = std::max({dp.back()[0], dp.back()[1], dp.back()[2] + a.back()});
	} else {
		ans = std::max(dp.back()[0], dp.back()[1]);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 11976
import math as m
from Queue import Queue

class Program:
    
    def main(self):
        D = dict()
        D['a'] = list(raw_input())
        D['b'] = list(raw_input())
        D['c'] = list(raw_input())
        
        current = 'a'
        
        while len(D[current])>0:
            current = D[current].pop(0)
        
        print current.upper()
        
if __name__ == '__main__':
    p=Program();
    p.main()

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

int main()
{

    //入力を受け取る
    int h, w, k;
    cin >> h >> w >> k;

    //盤面を受け取る
    char c[6][6];
    int black = 0;
    //2重ループ
    //ひとつめ(i)のループが行,ふたつめ(j)のループが列を表す
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> c[i][j];
        }
    }
    int ans = 0;
    //i,j:bit全探索
    //bit全探索の詳細はLTとか
    //https://qiita.com/drken/items/7c6ff2aa4d8fce1c9361
    //とか

    //iは0~2^hまでループ
    for (int i = 0; i < (1 << h); i++)
    {
        //jは0~2^wまでループ
        for (int j = 0; j < (1 << w); j++)
        {
            int count = 0;
            //すべてのマスのなかから、行が選ばれていない,かつ,列が選ばれていない,かつ,黒色のマスを数える
            for (int p = 0; p < h; p++)
            {
                for (int q = 0; q < w; q++)
                {
                    if ((i & (1 << p)) == 0 && (j & (1 << q)) == 0 && c[p][q] == '#')
                    {
                        count++;
                    }
                }
            }

            //残った黒マスの数がkと一致したら、答えをインクリメント
            if (count == k)
            {
                ans++;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3636
import numpy as np
import math
import scipy as sp
import queue
import collections

MOD = 10 ** 9 + 7
INF = 10 ** 9

def main(kwargs):
    n = kwargs["n"]
    r = sum([int(i) for i in n])
    res = "No"
    if r % 9 == 0:
        res = "Yes"
    return res

if __name__ == "__main__":
    kwargs = {}

    cin = input().split()
    kwargs["n"] = cin[0]

    cout = main(kwargs)
    print(cout)

Measured memory_bytes: 32676
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;


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

    int N;

    cin >> N;

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

    cout << "No";

    return 0;
}


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

int		main(void)
{
	string A, B, C;

	cin >> A >> B >> C;
	A.push_back('A');
	B.push_back('B');
	C.push_back('C');
	int a = 0, b = 0, c = 0;
	char next = 'a';

	while ('a' <= next && next <= 'c')
	{
		if (next == 'a')
		{
			next = A[a];
			a++;
		}
		if (next == 'b')
		{
			next = B[b];
			b++;
		}
		if (next == 'c')
		{
			next = C[c];
			c++;
		}
	}
	cout << next << endl;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> number(m);
  vector<string> answer(m);

  for (int i = 0; i < m; i++) {
    cin >> number.at(i) >> answer.at(i);
  } // input
  vector<int> correct(n + 1, 0);
  int Correct = 0;
  vector<int> wrong(n + 1, 0);
  int penalty = 0;

  for (int i = 0; i < m; i++) {
    if (answer.at(i) == "WA") {
      // NO
      wrong.at(number.at(i))++;
    } else { // OK
      if (correct.at(number.at(i)) == 0) {
        correct.at(number.at(i))++;
        Correct++;
        if (wrong.at(number.at(i)) != 0) {
          penalty += wrong.at(number.at(i));
        }
      }
    }
  }

  cout << Correct << " " << penalty;

  return 0;
}


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

int main(){
  string s;
  cin >> s;
  int n = atoi(s.c_str());
  int x = 0;
  rep(i, s.length()){
     x += s[i] - 48;
  }
  cout << ((n % x == 0) ? "Yes":"No" ) << endl;
}

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

// Driver Code to test above function 
int main() 
{ 
	int n;
	cin>>n;
	int u[n-1],v[n-1];
	for(int i=0;i<n;i++)
	    cin>>u[i]>>v[i];
	long long ans=0;
    for(int L=1;L<n+1;L++)
    {
        ans+= 1ll * L * (L+1) /2;
    }
    for(int i=0;i<n-1;i++)
    {
        if(u[i]>v[i])   swap(u[i],v[i]);
        ans-= 1ll * u[i] * (n-v[i]+1);
    }
    cout<<ans;
	return 0; 
} 


Measured memory_bytes: 5124
#include<iostream>
using namespace std;
int main () {
  int N, M, C;
  cin >> N >> M >> C;
  int B[21];
  for (int i = 0; i < M; i ++) cin >> B[i];
  int ans = 0;
  for (int i = 0; i < N; i ++) {
    int an = 0;
    for (int j = 0; j < M; j ++) {
      int jun;
      cin >> jun;
      an += jun * B[j];
    }
    if (an > -C) ans ++;
  }
  cout << ans << endl;
}

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

using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    int h[n];
    int good[n];
    for(int i=0;i<n;i++)good[i]=1;

    for(int i=0;i<n;i++)cin >> h[i];
    int a[m],b[m];
    for(int i=0;i<m;i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        if(h[a[i]]==h[b[i]]){
            good[b[i]]=0;
            good[a[i]]=0;
        }else if(h[a[i]]>h[b[i]])good[b[i]]=0;
        else good[a[i]]=0;
    }

    int sum = 0;
    for(int i=0;i<n;i++){
        sum += good[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 5140
// Author -> Preeyadarshee Dev
//
// train hard win easy :D
// nik is love
// nik is motivation
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculation
#include<bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                    long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define eps                   0.000000000000001
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define endl                 '\n'
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={1,-1,0,0,-1,-1,1,1};
int dy[8]={0,0,-1,1,-1,1,-1,1};
vector<int> adj[100010],adj1[100010],vis(100010,0),dis(100010,0),par(100010,0);
int myrandom (int i) { return std::rand()%i;}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    int n;
    cin>>n;
    vector<int> v(n);
    f(i,n)
    {
        cin>>v[i];
    }
    sort(all(v),less<int>());
    long double sum=v[0];
    for(int i=1;i<n;i++)
    {
        sum=((sum+v[i])*1.0)/2.0;
    }
    cout<<fixed<<setprecision(20)<<sum<<endl;
}


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

int main(){
  int N;
  long D;
  cin>>N>>D;
  long X,Y;
  int count=0;
  for(int i=0;i<N;i++){
    cin>>X>>Y;
    if(X*X+Y*Y<=D*D)
      count=count+1;
  }
  cout<<count<<endl;

}

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

class Main {
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		//?????????
        StringBuilder sb=new StringBuilder("");
		int n = scan.nextInt();
		int[]hako = new int[n];
		
		for(int i = 0; i < hako.length ; i++){
			int a = scan.nextInt();
			hako[i] = a; 
		}//for
	    

		
		//??\?????????
		for(int i = hako.length-1; i >= 0; i--){
			sb.append(hako[i]);
			if(i > 0){
				sb.append(" ");
			}
		}//for
		
		//??????
		System.out.println(sb);
	}
}

Measured memory_bytes: 26356
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main(){
    int N, T, A, i;
    cin >> N;
    cin >> T;
    cin >> A;

    vector<int> H(N);
    vector<double> Diff(N);

    double temp;
    for (i=0; i<N; i++){
        cin >> H[i];
        temp = A - (T - H[i] * 0.006);
        Diff[i] = abs(temp);
    }

    vector<double>::iterator min = min_element(Diff.begin(), Diff.end());
    int index = distance(Diff.begin(), min);

    cout << index + 1 << '\n';

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
char maps[150][150];
int xiang[4][2]={ {0,1},{0,-1},{1,0},{-1,0} };
int n,m;
void dfs(int x,int y,char c)
{
    int i,tx,ty;
    for(i=0;i<4;i++)
    {
        tx=x+xiang[i][0];
        ty=y+xiang[i][1];
        if(tx<0 || ty<0 || tx>=n || ty>=m || maps[tx][ty]!=c)
            continue;
        maps[tx][ty]='.';
        dfs(tx,ty,c);
    }
}
int main()
{
    while(scanf("%d%d",&n,&m) && n && m)
    {
        int i,j;
        for(i=0;i<n;i++)
        {
            scanf("%s",maps[i]);
        }
        int ans=0;
        for(i=0;i<n;i++)
        {
            for(j=0;j<m;j++)
            {
                if(maps[i][j]!='.')
                {
                    ans++;
                    dfs(i,j,maps[i][j]);
                    maps[i][j]='.';
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}



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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int M = 0, m = 0;
    int idx;
    rep(i, 0, n){
        cin >> a[i];
        if(M < a[i]){
            M = a[i];
        }else if(m < a[i]){
            m = a[i];
        }
    }
    rep(i, 0, n){
        if(a[i] == M){
            cout << m << endl;
        }else{
            cout << M << endl;
        }
    }

}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX_N=1005;
const int Mod=1e9+7;
int H,W;
char mp[MAX_N][MAX_N];
LL dp[MAX_N][MAX_N];
int main()
{
	cin>>H>>W;
	for(int i=1;i<=H;i++)
	{
		scanf("%s",mp[i]+1);
	}
	dp[1][1]=1;
	for(int i=1;i<=H;i++)
	{
		for(int j=1;j<=W;j++)
		{
			if(mp[i][j]=='#')continue;
			if(mp[i-1][j]!='#')dp[i][j]+=dp[i-1][j];
			if(mp[i][j-1]!='#')dp[i][j]+=dp[i][j-1];
			dp[i][j]%=Mod;
		}
	}
	cout<<dp[H][W]<<endl;
	return 0;
}


Measured memory_bytes: 9088
using System;
using System.Collections.Generic;
using System.Linq;



class Program
{
 
    public static void Main( )
    {
        var s = Console.ReadLine( ).Select( x => (char)x ).ToArray();
        Console.WriteLine( char.IsUpper(s[0]) ? "A" : "a" );
       
        
    }

}




Measured memory_bytes: 26612
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

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

ll Gcd(ll a,ll b) {
    while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
    }
    return a;
}
#define debug(v) cout<<#v<<": ",prt(v);
template <typename A,typename B>
inline void prt(pair<A,B> p){cout<<"("<<p.first<<", "<<p.second<<")\n";}
template <typename A,typename B,typename C>
inline void prt(tuple<A,B,C> p){cout<<"("<<get<0>(p)<<", "<<get<1>(p)<<", "<<get<2>(p)<<")\n";}
inline void prt(bool p){if(p)cout<<"True"<<'\n';else cout<<"False"<<'\n';}
template <typename T> 
inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(deque<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(unordered_map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(set<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(multiset<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A(N,0);
    for(ll i=0;i<N;++i)cin>>A[i];
    vector<bool> check(1000001,0);
    bool B=1,C=1;
    for(ll i=0;i<N;++i){
        um MM=prime_factor(A[i]);
        for(auto p: MM){
            ll E=p.first;
            if(check[E]){B=0;goto SKIP;}
            check[E]=1;
        }
    }
    SKIP:
    ll GGG=A[0];
    for(ll i=1;i<N;++i){
        GGG=Gcd(GGG,A[i]);
    }
    //debug(GGG);
    if(GGG==1)C=1;
    else C=0;
    if(B)prt("pairwise coprime");
    else if(C)prt("setwise coprime");
    else prt("not coprime");


    return 0;
}



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

int main(int argc, char const *argv[]) { 
    string S;
    cin >> S;
    int hug = 0;
    int max = S.size() / 2;

    for (int i = 0; i < max; i++) {
        if (S.at(i) != S.at(S.size() - 1 - i)) {
            hug += 1;
        }
    }

    cout << hug << endl;
    return 0;    
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  ll ans=0;
  cin >> N;
  int p,q=0;
  for(int i=0;i<N;i++){
    cin >> p;
    q=max(p,q);
    ans+=p;
  }
  cout << ans-q/2 << endl;
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    int l;
    int lmax = 0;
    int lsum = 0;
    for(int i = 0; i < n; i++){
        cin >> l;
        lmax = max(lmax, l);
        lsum += l;
    }
    if(lmax < lsum - lmax){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int n;
int a;
int b;
int main(){
	scanf("%d", &n);
	scanf("%d", &a);
	for (int i=1;i<n;i++){
		scanf("%d", &b);
		a = __gcd(a, b);	
	}
	printf("%d\n", a);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <ctype.h>

using namespace std;


int main()
{
    int n,i;
    scanf("%d",&n);
        int a[n+1];
        for(i=1;i<=n;i++)
            scanf("%d",&a[i]);

        int k=1,cnt=0;
        while(true)
        {
            k=a[k];
            cnt++;
            if(cnt>n)
            {
                cnt=-1;
                break;
            }
            if(k==2)
                break;
        }
        printf("%d",cnt);
    return 0;
}


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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define FORR(i, a, b) for(int i=(b-1);i>=(a);--i)
#define FORRE(i, a, b) for(int i=(b);i>=(a);--i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define repr(i, n) for(int i=(n-1);i>=0;--i)
#define repre(i, n) for(int i=(n);i>=0;--i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int INF = (int) 1e9;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int k;
	cin >> k;
	ll a[k];
	rep(i, k) cin >> a[i];
	
	ll l = 2, r = 2;
	repr(i, k) {
		l = (l + (a[i] - 1)) / a[i] * a[i];
		r = (r / a[i]) * a[i] + a[i] - 1;
		if(l>r){
			cout<<-1<<endl;
			return 0;
		}
	}
	
	cout << l << " " << r << endl;
	
	return 0;
}

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

typedef pair<int, int> Pi;

int N, M;
vector< int > G[100005];
bool flag[100005] = {0};

int check(int node)
{
  for(int &e : G[node]) {
      if(!flag[e]) {
	flag[e] = true;
	return e;
      }
  }
  return node;
}

int main()
{
  int A, B;
  deque< int > ans;
  
  cin >> N >> M;

  while(M--) {
    cin >> A >> B; --A, --B;
    G[A].push_back(B); G[B].push_back(A);
  }

  int lnode = 0, rnode = 0;
  int l = -1, r = -1;
  flag[0] = true;
  ans.push_back(0);
  
  while(lnode != l || rnode != r) {
    l = lnode, r = rnode;
    lnode = check(lnode);
    rnode = check(rnode);
    if(lnode != l) ans.push_front(lnode);
    if(rnode != r) ans.push_back(rnode);
  }

  cout << ans.size() << endl;
  for(auto itr = ans.begin(); itr != ans.end(); itr++) {
    cout << *itr + 1;
    if((itr + 1) == ans.end()) cout << endl;
    else cout << " ";
  }

  return 0;
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
char S[210][210];
int idx[210];
vector<int> G[210];

bool judge(){
    for(int i = 1; i <= N; ++i) idx[i] = -1;
    idx[1] = 0;
    queue<int> q;
    q.push(1);
    while(!q.empty()){
        int v = q.front();
        q.pop();
        for(auto u : G[v]){
            if(idx[u] == -1){
                idx[u] = (idx[v] + 1) & 1;
                q.push(u);
            }else if(idx[u] != ((idx[v] + 1) & 1)) return false;
        }
    }
    
    return true;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    for(int i = 1; i <= N; ++i){
        for(int j = 1; j <= N; ++j){
            cin >> S[i][j];
            if(S[i][j] == '1'){
                G[i].emplace_back(j);
            }
        }
    }
    if(!judge()){
        cout << -1 << endl;
    }else{
        int ans = 0;
        int d[210][210];
        for(int i = 1; i <= N; ++i){
            for(int j = 1; j <= N; ++j){
                if(i == j) d[i][j] = 0;
                else if(S[i][j] == '1') d[i][j] = 1;
                else d[i][j] = 1 << 20;
            }
        }
        for(int k = 1; k <= N; ++k){
            for(int i = 1; i <= N; ++i){
                for(int j = 1; j <= N; ++j){
                    chmin(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }
        for(int i = 1; i <= N; ++i){
            for(int j = 1; j <= N; ++j){
                chmax(ans, d[i][j]);
            }
        }
        cout << ans + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  int w,h,n;
  cin>>n>>w>>h;
  int x,y,B=2*(w+h);
  char c;
  vector<P> m;
  for(int i=0;i<n;i++){
    cin>>x>>y>>c;
    if(c=='S')m.push_back(P((x-y+B)%B,x+y));
    if(c=='E')m.push_back(P(w+y-(w-x),w+y+(w-x)));
    if(c=='N')m.push_back(P(w+h+(w-x)-(h-y),w+h+(w-x)+(h-y)));
    if(c=='W')m.push_back(P(w*2+h+(h-y)-x,(w*2+h+(h-y)+x)%B));
  }

  for(int i=0;i<n;i++)swap(m[i].first,m[i].second);
  sort(m.begin(),m.end());
  for(int i=0;i<n;i++)swap(m[i].first,m[i].second);
  int ans=n;
  for(int i=0;i<n;i++){
    int tp=1,p=m[i].second;
    for(int j=0;j<n;j++){
      int s=m[(i+j)%n].first,g=m[(i+j)%n].second;
      if(s>g&&!(g<p&&p<s))continue;
      if(s<g&&s<=p&&p<=g)continue;
      tp++,p=g;
    }
    ans=min(tp,ans);
  }
  cout<<ans<<endl;
  return 0;
}

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

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

    if( N == 1 ){
        cout << 1 << endl;
        return 0;
    }


    int ans = 0, sum = 0;
    for( int i = 1; i <= N; ++i ){
        int n = i, s = 0;
        while( !(n % 2) ){
            n /= 2;
            ++s;
        }
        if( sum < s ){
            sum = s;
            ans = i;
        }
    }


    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(N//2)]+a[N//2:]

for i in range(N//2-1, -1, -1):
  if sum(b[i::i+1])%2 == 0:
    b[i] = a[i]
  else:
    b[i] = 1-a[i]

ans = []
for i in range(N):
  if b[i] == 1:
    ans.append(i+1)
    
print(len(ans))
print(' '.join(map(str, ans)))

Measured memory_bytes: 20276
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back

using namespace std;

typedef pair< int, int > P;
typedef pair< int, P > iP;
typedef long long LL;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const int MOD = (10^9 + 7);

int dx[] = {0, -1, 1, 0};
int dy[] = {-1, 0, 0, 1};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; ++i) cin >> a[i];
    sort(a, a + n);
    int sum = 0;
    for(int i = 0; i < n - 1; ++i) sum += a[i];

    if(sum > a[n - 1]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

int table[2000][2000];
bool f[1111111];
int dy[]={0,-1,0,1};
int dx[]={1,0,-1,0};
pint dp[2000][2000];
pint idx[1111111];
signed main(){
    int y=1000,x=1000,c=1;
    table[y][x]=1;
    idx[1]=pint(1000,1000);
    for(int i=0;;i++){
        int d=i%4;
        int l=i/2+1;
        rep(j,l){
            c++;
            y+=dy[d];
            x+=dx[d];
            if(c>1000000)break;
            table[y][x]=c;
            idx[c]=pint(y,x);
        }
        if(c>1000000)break;
    }
    memset(f,1,sizeof(f));
    f[0]=f[1]=0;
    for(int i=2;i<1111111;i++){
        if(!f[i])continue;
        for(int j=i+i;j<1111111;j+=i)f[j]=0;
    }

    int N,M;
    while(cin>>N>>M,N||M){
        fill_n(*dp,2000*2000,pint(-1001001001,0));
        dp[idx[M].fi][idx[M].se]=pint(f[M],M*f[M]);
        for(int i=0;i<2000;i++){
            for(int j=0;j<2000;j++){
                for(int k=-1;k<=1;k++){
                    int ii=i+1;
                    int jj=j+k;
                    if(ii>=2000||jj<0||jj>=2000)continue;
                    if(f[table[ii][jj]]&&table[ii][jj]<=N){
                        chmax(dp[ii][jj],pint(dp[i][j].fi+1,table[ii][jj]));
                    }
                    else{
                        chmax(dp[ii][jj],dp[i][j]);
                    }
                }
            }
        }
        pint ma;
        rep(i,2000)rep(j,2000)chmax(ma,dp[i][j]);
        cout<<ma.fi<<" "<<ma.se<<endl;
    }
    return 0;
}

Measured memory_bytes: 94068
N = int(input())
A = list(map(int, input().split(" ")))
B = list(map(int, input().split(" ")))

cnt = 0

if B[0] > A[0]:
    amari = B[0] - A[0]
    cnt += A[0]
else:
    amari = 0
    cnt +=  B[0]
    
for i in range(1,N):
    if A[i] > amari:
        cnt += amari
        nokori = A[i] - amari
    else:
        cnt += A[i]
        nokori = 0
    
    if nokori > B[i]:
        cnt += B[i]
        amari = 0
    else:
        cnt += nokori
        amari = B[i] - nokori
        
if amari > A[N]:
    cnt += A[N]
else:
    cnt += amari

print(cnt)
        

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

typedef long long ll;
typedef int ii;
//typedef vector<ll> vi;

#define INF 1000000007

#define pi 3.141592654

#define T while(t--)
#define for2(i,a,b) for(i=a;i>=b;i--)
#define for3(i,a,b) for(i=a;i<=b;i=i+2)
#define for1(i,a,b) for(i=a;i<=b;i++)
#define pb push_back
#define mp make_pair

#include<sstream>

#define si set<ll>
#define se multiset<ll>

typedef long double ld;

typedef vector<ll> vi;

#define bb(arr,nn,xx) upper_bound(arr,arr+nn,xx)-arr
#define aa(arra,nna,xxa) lower_bound(arra,arra+nna,xxa)-arra

#define all(v) sort(v.begin(),v.end())
 
#define all1(v) sort(v.rbegin(),v.rend())

ii main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);

    string s,t; cin>>s>>t; ll i,j;
    
    ll p=s.length(); ll q=t.length(); ll x=(p-q)+1;
    
    ll minimum=INF;
    
    for1(i,0,x-1)
    {
         
        ll f=0;
        
        for1(j,i,i+(q-1))
        {
        
            if(s[j]!=t[j-i]) f++;

        
        }

        minimum=min(minimum,f);
    
    }
    
    cout<<minimum<<"\n";
    
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n,m;
    cin>>n>>m;
    int s=0;
    vector<int> p(n);
    rep(i,n){
        cin>>p[i];
        s+=p[i];
    }
    int c=0;
    rep(i,n){
        if(p[i]*4*m >= s) c++;
    }
    cout<<((c>=m)? "Yes": "No")<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

S=input().strip()
T=input().strip()

ANS=10000
LENT=len(T)
LENS=len(S)

for i in range(LENS-LENT+1):
    score=0
    for j in range(LENT):
        if T[j]!=S[i+j]:
            score+=1

    #print(i,score)
    ANS=min(ANS,score)

print(ANS)


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

using namespace std;
typedef long long ll;

int main()
{
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k){
        cout << s;
    }else{
        for (int i = 0; i < k;i++){
            cout << s[i];
        }
        cout << "...";
    }
}


Measured memory_bytes: 3624
N = int(raw_input())
sp_list = []
for i in range(N):
    sp_list.append(map(str, raw_input().split()))
    sp_list[i][1] = int(sp_list[i][1])
    sp_list[i].append(i+1)

sp_list.sort()

check_set = set()
for i in range(N):
    check_set.add(sp_list[i][0])

for i in check_set:
    idx_list = []
    num_list = []
    for j in range(N):
        if sp_list[j][0] == i:
            idx_list.append(j)
            num_list.append([sp_list[j][1],sp_list[j][2]])
    idx_list.sort()
    num_list.sort()
    num_list.reverse()
    for k in range(len(idx_list)):
        sp_list[idx_list[k]][1] = num_list[k][0]
        sp_list[idx_list[k]][2] = num_list[k][1]


for i in range(N):
    print sp_list[i][2]

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

def io_generator():
	return input()

#+++++++++++++++++++

def n_pat(a_n):
	return 2**a_n - 1
	
def n_size(a_n):
	return 4 * (2** (a_n -1))- 3
	
def get_size(n,x):
	if x == 0:
		return 0
	elif x==1:
		return 0
	elif x < 1 + n_size(n):
		return get_size(n-1, x -1)
	elif x == 1 + n_size(n):
		return n_pat(n)
	elif x == 1 + n_size(n) + 1:
		return n_pat(n) + 1
	elif x < 1 + n_size(n) +1 + n_size(n):
		offset=2 + n_size(n)
		return n_pat(n)+1+get_size(n-1, x - offset)
	else:#if x == 1+n_size(n)+1+n_size(n):
		return n_pat(n)+1+n_pat(n)

def main(io):
	n,x= map(int, io().split())
	return get_size(n,x)
	#for i in range(1,51):
	#	print(n_pat(i),n_size(i))
	#return str(a+b+c) + " " + s

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define debug(x) cout<<#x<<": "<<x<<endl
typedef complex<double> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()
const double EPS = 1e-9; // ?¨±?????????^2
#define EQ(n,m) (abs((n)-(m)) < EPS)

double dot(Point a, Point b) {
  return a.X*b.X + a.Y*b.Y;
}

double cross(Point a, Point b) {
  return a.X*b.Y - a.Y*b.X;
}

int ccw(Point a, Point b, Point c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

bool isecSP(Point a1, Point a2, Point b) {
  return !ccw(a1, a2, b);
}

Point proj(Point a1, Point a2, Point p) {
  return a1 + dot(a2-a1, p-a1)/norm(a2-a1) * (a2-a1);
}

VP crosspointSC(Point a1, Point a2, Point c, double r) {
  VP ps;
  Point ft = proj(a1, a2, c);
  if (r*r < norm(ft-c)) return ps;
  Point dir = sqrt(max(r*r - norm(ft-c), 0.0)) / abs(a2-a1) * (a2-a1);
  if(isecSP(a1,a2,ft+dir)) ps.push_back(ft+dir);
  if (!EQ(r*r, norm(ft-c)) && isecSP(a1,a2,ft-dir))
    ps.push_back(ft-dir);
  return ps;
}

double sector(Point c,double r,Point p,Point q){
    p-=c, q-=c;
    double t = -arg(p);
    double theta = arg(Point(q.X*cos(t)-q.Y*sin(t),q.X*sin(t)+q.Y*cos(t)));
    return r*r*theta/2.0;
}

int main(void){
    int n;
    double r,x,y;
    cin>>n>>r;
    VP ps(n);
    rep(i,n){
        cin>>x>>y;
        ps[i] = Point(x,y);
    }

    double area=0;
    Point c = Point(0,0);
    rep(i,n){
        Point p=ps[i], q=ps[(i+1)%n];
        VP cp = crosspointSC(p,q,c,r);
        if(abs(p)<r && abs(q)<r){
            assert(cp.size()==0);
            area += cross(p,q)/2.0;
        }
        else if(abs(p)<r && abs(q)>=r){
            assert(cp.size()==1);
            area += cross(p,cp[0])/2.0;
            area += sector(c,r,cp[0],q);
        }
        else if(abs(p)>=r && abs(q)<r){
            assert(cp.size()==1);
            area += sector(c,r,p,cp[0]);
            area += cross(cp[0],q)/2.0;
        }
        // abs(p)>=r && abs(q)>=r
        else if(cp.size()==2){
            if(abs(p-cp[0])>abs(p-cp[1])) swap(cp[0],cp[1]);
            area += sector(c,r,p,cp[0]);
            area += cross(cp[0],cp[1])/2.0;
            area += sector(c,r,cp[1],q);
        }
        else area += sector(c,r,p,q);
    }
    printf("%.10f\n",area );

    return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int h, a;
  cin >> h >> a;
  cout << (h + a - 1) / a << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	if(a>=MOD){
		a -= MOD;
	}
}

int main(void){
	int n,p=0,q=0,i;
	string s;
	cin >> s;
	n = s.l_ength();
	for(i=0; i<n; ++i){
		if(s[i]!='0'+(i%2)){
			++p;
		}else{
			++q;
		}
	}
	cout << min(p,q) << endl;
	return 0;
}


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

int N;
ll B[110];

int main() {
    cin >> N;
    for (int i = 0; i < N-1; i++) cin >> B[i];
    
    ll ans = B[0];
    for (int i = 0; i < N-2; i++) {
        ans += min(B[i], B[i+1]);
    }
    ans += B[N-2];

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


Measured memory_bytes: 256
#include <cmath>
#include <functional>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  map <int, int> dp;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    dp[x] = max(dp[x], dp[x - 1] + 1);
    ans = max(ans, dp[x]);
  }
  cout << n - ans << endl;
}


Measured memory_bytes: 9600
K,N = list(map(int, input().split()))
MAX = K+N+3
mod = 998244353

fac = [1]*(MAX+1)
for i in range(1,MAX+1):
	fac[i] = (fac[i-1]*i)%mod

rev_m = [1]*(MAX+1)
rev_m[MAX] = pow(fac[MAX],mod-2,mod)
for i in range(MAX,0,-1):
	rev_m[i-1] = (rev_m[i]*i)%mod

def Comb(n,k):#nCk
	return (fac[n]*rev_m[k]*rev_m[n-k])%mod


def f(n,k,i):
	if i == 2:
		if n < 0 or (k==1 and n>=2): #例外処理
			return 0

		if n == 0:
			ans = 1
		else:
			ans = Comb(k-2+n,n) + Comb(k-2+n-1,n-1)
		return ans % mod
	else: #i>2
		Sp = i//2-1
		ans = 0
		for p in range(Sp+1):
			ans += g(n,k,i,p)
		return ans % mod

def g(n,k,i,p):
	Sp = i//2-1
	if p == 0:
		return f(n-Sp,k-Sp,2) * pow(2,Sp,mod) % mod
	else: #p>0
		return g(n,k-2*p,i-2*p,0) * Comb(Sp,p)

ans = []
for i in range(2,K+2):
	if i%2 == 0:
		tmp = f(N,K,i)
	ans.append(tmp)
	print(tmp)

ans = ans[::-1]
for i in range(1,K):
	print(ans[i])


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

int main() {

    int N, K;
    std::cin >> N >> K;

    std::vector<bool> A(N, false);

    for (int i = 0; i < K; i++) {
        // お菓子 i の個数を取得
        int num;
        std::cin >> num;

        // お菓子 i をもらった人を true に変えていく
        for (int j = 0; j < num; j++) {
            int ind;
            std::cin >> ind;
            A[ind-1] = true;
        }
    }

    int ans = 0;
    for (int i = 0; i < A.size(); i++) {
        if (A[i] == false) ans++;
    }
    std::cout << ans << std::endl;

    return 0;
}

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

int main(){
  string S;
  cin >> S;
  int s=S.size();
  int ans=0;
  for(int i=0;i<s;i++){
    int cnt=0;
    if(S[i]=='A' || S[i]=='G' || S[i]=='C' || S[i]=='T'){
      while(S[i]=='A' || S[i]=='G' || S[i]=='C' || S[i]=='T'){
        cnt++; i++;
      }
      ans=max(ans,cnt);
    }
  }
  cout << ans << endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int M;
  cin >> M;
  cout << 48 - M;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	while(true){
		int n, m;
		cin >> n >> m;
		if(n == 0 && m == 0){ break; }
		vector<int> p(1, 0);
		for(int i = 0; i < n; i++){
			int val;
			cin >> val;
			p.push_back(val);
		}
		vector<int> p2;
		for(int i = 0; i <= n; i++){
			for(int j = 0; j <= i; j++){
				if(p[i] + p[j] <= m){ p2.push_back(p[i] + p[j]); }
			}
		}
		sort(p2.begin(), p2.end());
		int answer = 0;
		for(int i = 0; i < p2.size(); i++){
			vector<int>::iterator it = upper_bound(p2.begin(), p2.end(), m - p2[i]);
			int v = p2[i] + *(--it);
			answer = max(answer, v);
		}
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 3004
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define PI acos(-1)
#define fs first
#define sc second
#define MAX 0x3f3f3f3f
#define debug freopen("1.in", "r", stdin), freopen("1.out", "w", stdout);
#define ios                                                                    \
    ios::sync_with_stdio(false);                                               \
    cin.tie(0);                                                                \
    cout.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 2005;
const ll k = 1e9 + 7;
int s;
ll arr[maxn] = {0, 0, 0, 1, 1};

int main() {
    ios;
    cin >> s;
    for (int i = 4; i <= s; i++)
        arr[i] = (arr[i - 1] + arr[i - 3]) % k;
    cout << arr[s] << '\n';
    return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <stdio.h>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cassert>
#include <random>
#include <time.h>
#define fi first
#define se second
#define pb emplace_back
#define all(x) x.begin(),x.end()
#define re return
#define mp make_pair

using namespace std;

typedef long long ll;

const double pi = 3.14159265;
const ll mod = 1e9 + 7;
const ll N = 1e3 + 5;
const int OMG = 9e6 + 5;
const ll P0 = 281;
const ll P1 = 257;

vector <ll> tree;

void Upd (int v, int L, int R, int l, int r, ll k)
{
    if(l == L && r == R)
    {
        tree[v] += k;
        return;
    }
    int c = (L + R) / 2;
    if(l < c)
        Upd(v * 2, L, c, l, min(r, c), k);
    if(c < r)
        Upd(v * 2 + 1, c, R, max(l, c), r, k);
}

ll Sum (int v, int L, int R, int pos)
{
    if(R - L == 1)
        return tree[v];
    ll c = (L + R) / 2, an = tree[v];
    if(c > pos)
        an += Sum(v * 2, L, c, pos);
    else an += Sum(v * 2 + 1, c, R, pos);
    return an;
}

int main()
{
    //freopen("ladder.in ", "r", stdin);
    //freopen("OMOMOMMG.txt", "w", stdout);
    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, d, k;
    cin >> n >> d >> k;
    vector <pair <ll, ll> > a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i].fi >> a[i].se;
    sort(all(a));
    tree.resize(n * 4);
    ll an = 0;
    for (int i = 0; i < n; i++)
    {
        ll kol = Sum(1, 0, n, i);
        if(kol >= a[i].se)
            continue;
        ll times = (a[i].se - kol - 1) / k + 1;
        an += times;
        times *= k;
        int r = upper_bound(all(a), mp((ll)a[i].fi + d * 2 + 1,(ll) -1)) - a.begin();
        Upd(1, 0, n, i, r, times);
    }
    cout << an;
}





Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

pair<ll,ll> p[200001];
int main(){
    int n,xi,yi;
    cin>>n;
    ll lmn=1000100010,lmx=0,rmn=1000100010,rmx=0;
    ll pl,pr;
    rep(i,n){
        cin>>xi>>yi;
        if(xi>yi) swap(xi,yi);
        p[i]=mp(xi,yi);
        if(lmn>xi) lmn=xi,pl=yi;
        if(lmx<xi) lmx=xi;
        if(rmn>yi) rmn=yi;
        if(rmx<yi) rmx=yi,pr=xi;
    }
    ll ans1=(rmx-rmn)*(lmx-lmn);
    sort(p,p+n);
    ll ans2=1000100010;
    ll mx=p[n-1].first;ll mn=1000100010;
    FOR(i,0,n-1){
        //if(p[i].first==pr) continue;
        mx=max(mx,p[i].second);
        mn=min(mn,p[i].second);
        ll mn2=min(mn,p[i+1].first);
        ans2=min(ans2,mx-mn2);
    }
    //cout<<ans1<<" "<<ans2<<endl;
    ll ans=min(ans1,ans2*(rmx-lmn));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
// D - Grid Repainting
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using VC = vector<char>;
using VVC = vector<VC>;
using PII = pair<int,int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)
#define mp(a,b) make_pair(a,b)

int bfs(int H, int W, VVC &S){
	int dx[4]={0,-1,0,1}, dy[4]={-1,0,1,0};
	vvi dist(H+1,vi(W+1, -1));
	dist[1][1] = 0;
	queue<PII> q;
	q.push(mp(1, 1));
	while(!q.empty()){
		int i,j; tie(i,j)= q.front(); q.pop();
		if(S[i][j] == '_') continue;
		S[i][j] = '_';
		if(i==H && j==W) break;
		rpz(k, 4){
			int y = i + dy[k], x = j + dx[k];
			if(S[y][x] != '.') continue;
			dist[y][x] = dist[i][j] + 1;
			q.push(mp(y, x));
		}
	}
	return dist[H][W];
}

int main(){
	int H,W; cin>>H>>W;
	VVC S(H+2,VC(W+2, '#'));
	int block = 0;
	rp(i, 1, H+1){
		string s; cin>>s;
		rp(j, 0, W){
			if(s[j] == '#') block++;
			S[i][j+1] = s[j];
		}
	}
	int dist = bfs(H, W, S);
	// for(auto v:S){for(auto c:v){printf("%c",c);}puts("");}///
	cout<< (dist<0? -1: H*W - block - dist - 1) <<endl;
}

Measured memory_bytes: 256
N = int(input())
S = list(map(int,input()))
count = 0
for i in range(10):
    if i in S[:-2] :
        v1 = S[:-2].index(i)
        for j in range(10):
            if j in S[v1+1:-1] :
                v2 = S[v1+1:-1].index(j) + v1 + 1
                for k in range(10):
                    if k in S[v2+1:] :
                        count += 1
print(count)







Measured memory_bytes: 3640