akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define repd(i, a, b) for (int i = a; i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main()
{
    int d, t, s;
    cin >> d >> t >> s;
    if (d / s + (d % s != 0) <= t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int count=0;
    REP(i,1000) {
        std::stringstream ss;
        ss << setw(3) << setfill('0') << i;
        string str=ss.str();
        bool flag1=false;
        bool flag2=false;
        bool flag3=false;
        REP(j,N) {
            if (!flag1) {
                if (str[0]==S[j]) flag1=true;
                continue;
            }
            if (!flag2) {
                if (str[1]==S[j]) flag2=true;
                continue;
            }
            if (str[2]==S[j]) {
                flag3=true;
                break;
            }
            continue;
        }
        if (flag3) count++;
    }
    cout << count << endl;


    return 0;
}


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

void insertionSort(int A[], int n);
void printArray(int A[], int n);

int main(void)
{
    int n, i;
    cin >> n;
    int *A = new int[n];
    for (i = 0; i < n; i++)
        cin >> A[i];
    
    insertionSort(A, n);
    
}

void insertionSort(int A[], int n)
{
    int i, j, v;
    for (i = 0; i < n; i++) 
    {
        v = A[i];
        for (j = i - 1; j >= 0 && A[j] > v; j--)
        {
            A[j + 1] = A[j];
        }
        A[j + 1] = v;
        printArray(A, n);
    }
}

void printArray(int A[], int n)
{
    int i;
    for (i = 0; i < n - 1; i++)
        cout << A[i] << " ";
    cout << A[i] << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

const long long MOD = 1000000007;

struct Number {
    int zero;
    __float128 lg_sum;
    int neg;


};

void solve(long long N, long long K, std::vector<long long> A) {
    sort(A.begin(), A.end());
    Number current = {0, 0, 0};
    auto add = [&](int v, int coef) {
        current.zero += (v == 0) * coef;
        if (v != 0) {
            current.lg_sum += log((long double)abs(v)) * coef;
        }
        current.neg += (v < 0) * coef;
    };

    for (int j = 0; j < K; j++) {
        add(A[j], +1);
    }

    pair<Number, int> ans = {current, 0};
    auto cmp = [&](Number v) {
        auto good = ans.first;
        if (good.zero > 0) {
            return v.neg % 2 == 0;
        }

        if (good.neg % 2 != 0) {
            if (v.zero > 0) {
                return true;
            }
            if (v.neg % 2 == 0) {
                return true;
            }
            assert(v.neg % 2 == 1 && good.neg % 2 == 1);
            return v.lg_sum < good.lg_sum;
        }

        if (v.neg % 2 != 0) {
            return false;
        }

        if (v.zero > 0) {
            return false;
        }

        return v.lg_sum > good.lg_sum;;
    };

    for (int i = 0; i < N; i++) {
        add(A[(i + K) % N], 1);
        add(A[i], -1);
        if (cmp(current)) {
            ans.first = current;
            ans.second = i + 1;
        }
    }

    long long answer = 1;
    for (int i = 0; i < K; i++) {
        answer *= A[(i + ans.second) % N];
        answer %= 1000000007;
    }
    answer = (answer + 1000000007) % 1000000007;
    cout << answer << endl;

}


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


Measured memory_bytes: 4800
#include <iostream>
#include <vector>
#include <math.h>
#include <iomanip>//cout << fixed << setprecision() <<
#include <set>
#include <map>
using ll = long long;
using namespace std;

int main(void){
    int n,n2;
    cin>>n;
    n2=n%10;
    if(n2==2 || n2==4||n2==5||n2==7||n2==9){
        cout<<"hon";
    }else if(n2==0||n2==1||n2==6||n2==8){
        cout<<"pon";
    }else{
        cout<<"bon";
    }
}


Measured memory_bytes: 3652
a, b, c, d = map(int, input().split())
if abs(a-c)<=d:
    print('Yes')
elif not ((a<=b<=c)or(c<=b<=a)):
    print('No')
else:
    if (abs(a-b)<=d)and(abs(b-c)<=d):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

string s,t,tmp;
int lens,lent;
bool flag=false;
string ans="z";

void key(int pos)
{
  //pos~~pos+t-1まで比べる
  s=tmp;
  int cnt=0;
  rep(i,lent)
  {
    char x=s.at(pos+i);

    if(x==t.at(i)) cnt++;
    else if(x=='?')
    {
      s.at(pos+i)=t.at(i);
      cnt++;
    }
    else break;
  }

  if(cnt==lent)
  {
    flag=true;
    rep(i,lens)
    {
      //それ以外の場所をaにする
      if(s.at(i)=='?') s.at(i)='a';
    }

    if(ans>s) ans=s;
  }
}

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

  lens=s.size(),lent=t.size();
  tmp=s;
  rep(i,lens-1) ans+="z";

  if(lens<lent) flag=false;
  else
  {
    //始める位置は0~s-t
    rep(i,lens-lent+1) key(i);
  }

  if(flag) cout<<ans;
  else cout<<"UNRESTORABLE";
  cout<<endl;
}

Measured memory_bytes: 256
N, D = map(int, input().split())
zahyo = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for i in range(N):
    for j in range(i+1, N):
        distance = (sum([(a-b)**2 for a, b in zip(zahyo[i], zahyo[j])]))**(1/2)
        if distance == int(distance):
            ans += 1
print(ans)


Measured memory_bytes: 3064
marks = ['S', 'H', 'C', 'D']
cards = {x:[0 for y in range(13)] for x in marks}

cnt = int(input())
while cnt > 0:
    values = input().split()
    cards[values[0]][int(values[1]) - 1] += 1
    cnt -= 1

for key in marks:
    for val in range(13):
        if 0 == cards[key][val]:
            print('{0} {1}'.format(key, val + 1))

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

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

void dfs1(int cur, int par, vector<vector<int>> &g, vector<int> &D) {
  for (auto nxt : g[cur]) {
    if (nxt == par) continue;
    dfs1(nxt, cur, g, D);
  }

  int maxLen = -1;
  for (auto nxt : g[cur]) {
    if (nxt == par) continue;
    maxLen = max(maxLen, D[nxt]);
  }

  D[cur] = maxLen + 1;
}

void dfs2(int cur, int par, vector<vector<int>> &g, vector<int> &D, vector<int> &ans, int Dpar) {

  
  int maxLen = Dpar;
  vector<int> left;
  vector<int> right;
  for (auto nxt : g[cur]) {
    if (nxt == par) continue;
    left.push_back(D[nxt]);
    right.push_back(D[nxt]);
    maxLen = max(maxLen, D[nxt]);
  }
  ans[cur] = maxLen + 1;
  
  for (int i = 1; i < left.size(); i++) {
    left[i] = max(left[i], left[i - 1]);
  }

  for (int i = (int)right.size() - 2; i >= 0; i--) {
    right[i] = max(right[i], right[i + 1]);
  }

  int id = 0;
  for (auto nxt : g[cur]) {
    if (nxt == par) continue;
    
    int nxtDpar = Dpar + 1;
    if (id != 0) nxtDpar = max(nxtDpar, left[id - 1] + 1);
    if (id != (int)right.size() - 1) nxtDpar = max(nxtDpar, right[id + 1] + 1);
    id++;

    dfs2(nxt, cur, g, D, ans, nxtDpar);
  }

}

int main() {
  
  int n; cin >> n;
  vector<vector<int>> g(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b; cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<int> D(n, -1);
  vector<int> ans(n, -1);
  dfs1(0, -1, g, D);
  dfs2(0, -1, g, D, ans, -1);
  for (int i = 0; i < n; i++) {
    cout << 2 * (n - 1) - ans[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 33972
#include "bits/stdc++.h"
using namespace std;

int main(){
  
  int n,ans = 0;
  cin >> n;
  
  ans = n%10 + (n%100-n%10)/10 + (n%1000-n%100)/100 + (n%10000-n%100)/1000 + (n%100000-n%1000)/10000 + (n%1000000-n%10000)/100000 + (n%10000000-n%100000)/1000000 + (n%100000000-n%100000)/10000000;
  
  string l;
  if(n%ans == 0)l = "Yes";
  else l = "No";
  
  cout << l << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <stack>

using namespace std;

int main(){
  int N,Z,W;
  long a[2];
  long k;
  cin >> N >> Z >> W;
  for(int i=0;i<N;++i){
    cin >> k;
    if(i >= N-2){
      a[i-N+2] = k;
    }
  }
  if(N!=1){
    cout << max(abs(a[1]-W),abs(a[1]-a[0])) << endl;
  }else{
    cout << abs(k-W) << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        int n = sc.nextInt();
        if(n == 100){
            System.out.println(101 * (int)Math.pow(100,d));
        }
        else System.out.println(n * (int)Math.pow(100,d));
    }


}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  int n; cin >> n;
  string s; cin >> s;
  int ans=0;
  for(int i=1;i<n-1;i++){
    vector<int> c('z'-'a'+1,0);
    for(int j=0;j<i;j++){
      if(c.at(s.at(j)-'a')==0) c.at(s.at(j)-'a')++;
    }
    for(int j=i;j<n;j++){
      if(c.at(s.at(j)-'a')==1) c.at(s.at(j)-'a')++;
    }
    int cont =0;
    for(int j=0;j<'z'-'a'+1;j++){
      if(c.at(j)==2) cont++;
    }
    ans = max(cont,ans);
  }
  cout << ans <<endl;

}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) 
	{
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
	        int a=in.nextInt();
	        int b=in.nextInt();
	        int c=in.nextInt();
	        boolean flag=false;
	        for(int i=b;i<=c;i++)
	        {
	        	if(i%a==0)
	        	{
	        		flag=true;
	        		break;
	        	}
	        }
	        System.out.println((flag==true)?"OK":"NG");    
	}

}


Measured memory_bytes: 35780
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
int main(){
    int n;
    long long ans=1;
    cin>>n;
    vector<long long> a(n);
    rep(i,n){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    if(a[0]==0){
        cout<<"0"<<endl;
        return 0;
    }
    rep(i,n){
        if(a[i]>1000000000000000000/ans){
            cout<<"-1"<<endl;
            return 0;
        }
        ans=ans*a[i];
    }
    cout<<ans<<endl;
    return 0;
}

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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    typedef pair<i32,i32> pii;
    const i32 MAXN=1024;
    typedef i32 ar[MAXN];
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

int main(){
    i64 X=read(),Now=100;
    i32 Cnt=0;
    while(Now<X){
        Now*=1.01;
        Cnt++;
    }
    print(Cnt);
    output();
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i=(a); i<(b); i++)

int main() {
  int64_t N;
  cin >> N;
  int64_t a[3*N];
  FOR(i,0,3*N)  cin >> a[i];
  sort(a,a+3*N,greater<int>());
  int64_t sum = 0;
  FOR(i,0,N) sum += a[2*i+1];
  cout << sum << endl;
  return 0;
}


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

int main() {
    int N; cin >> N;
    int sum = 0;
    int max_value = 0;
    for (int i = 0; i < N; ++i) {
        int v; cin >> v;
        if (max_value < v) max_value = v;
        sum += v;
    }
    if (sum - max_value * 2 > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d%d",&a,&b);
    int ans=0;
    ans=a+(a-1);
    if(a+b>ans)ans=a+b;
    if(2*b-1>ans)ans=2*b-1;
    printf("%d\n",ans);
}

Measured memory_bytes: 128
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  ll n;
  cin >> n;
  ll ans2 = 0, ans5 = 0;
  if(n % 2) {
    // ll x = 5;
    // ll t;
    // while(t = n / x - n / x / 2) ans5 += t, x *= 5;
    // x = 2;
    ans2 = 0;
  } else {
    ll x = 5;
    ll t;
    while(t = n / (x * 2)) ans5 += t, x *= 5; // overflow?
    x = 2;
    while(t = n / x) ans2 += t, x *= 2;
  }
  cout << min(ans2, ans5) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <complex>
#include <cmath>
#include <algorithm>

using namespace std;

int n, m;
int a[500], b[500], c[500];

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int j = 1; j <= n; j++) cin >> b[j];
    for (int k = 2; k <= n; k++) cin >> c[k];
    for (int i = 0; i < n; i++)
    {
        m += b[a[i]];
        if (i > 0)
        {
            if (a[i - 1] + 1 == a[i])
            {
                m += c[a[i]];
            }
        }
    }
    cout << m;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N, K, h, count=0;
    cin >> N >> K;
    for(int i=0; i<N; i++){
        cin >> h;
        if(h>=K)
            count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}


int main(){

  ll N;
  cin >> N;
  vector<ll> A(N);
  vector<bool> is_ok(1000006,0);
  vector<bool> two(1000006,0);
  FOR(i,0,N){
    cin >> A[i];
    if(is_ok[A[i]])two[A[i]]=true;
    is_ok[A[i]] = true;
  }

  ll ans = 0;
  FOR(i,1,1000004){
    if(is_ok[i]){
      ans++;
      if(two[i])ans--;
      FOR(j,2,1000008){
        if(j*i>1000004)break;
        is_ok[j*i] = false;
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 5052
#include <cstdio>
#include <queue>
using namespace std;


#define INF 1 << 30
#define min(a,b) ((a) > (b) ? (b) : (a))
typedef struct P {
	int x, y;
	P(){}
	P(int i, int j) {
		x = i;
		y = j;
	}
	P operator+(const P r) {
		return{ x + r.x,y + r.y };
	}
	bool operator==(const P r) {
		return x == r.x && y == r.y;
	}
}P;

int H, W, N;
char map[1001][1001];
bool dp[1001][1001];
P mv[4] = { {-1,0},{0,-1},{0,1},{1,0} };
P fac[10];
queue<P> q;

void ini() {
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			dp[i][j] = false;
		}
	}
}

inline bool ok(P p) {
	return p.x >= 0 && p.x < H && p.y >= 0 && p.y < W && !dp[p.x][p.y] && map[p.x][p.y] != 'X';
}

int road(P s, P e) {
	ini();
	q = queue<P>();
	q.push(s);
	int l = 0;
	while (true) {
		l++;
		int ql = q.size();
		if (ql == 0) break;
		for (int i = 0; i < ql; i++) {
			P f = q.front();
			q.pop();
			for (int j = 0; j < 4; j++) {
				P p = f + mv[j];
				if (ok(p)) {
					if (p == e) {
						return l;
					}
					q.push(p);
					dp[p.x][p.y] = true;
				}
			}
		}
	}
	return -1;
}

int main(){
	scanf("%d%d%d", &H, &W, &N);
	for (int i = 0; i < H; i++) {
		scanf("%s", map[i], 1001);
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (map[i][j] == 'S') {
				fac[0] = P(i, j);
			}
			else if (map[i][j] > '0' && map[i][j] <= '9') {
				fac[(unsigned)(map[i][j] - '0')] = P(i, j);
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans += road(fac[i], fac[i + 1]);
	}
	printf("%d\n", ans);

	return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    set<int> S;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        S.insert(x);
    }
    if ((int)S.size() == n) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}



Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>

using namespace std;

int main() {
	int n;
	string input;

	while (cin >> n) {
		vector<string> v;
		string result = "0";
		string prev = "1000000001";
		int up = 1000000010;
		int low = -1000000010;

		if (n == 0) {
			break;
		}

		for (int i = 0; i < n; i++) {
			cin >> input;
			v.push_back(input);
		}

		for (int i = 0; i < n; i++) {
			if (v[i] == "x") {
				if (prev == "x") {
					result = "none";
					break;
				}
				else if (i % 2 == 1) {
					low = max(low, (int)atoi(prev.c_str()));
					if (i != n - 1) {
						low = max(low, (int)atoi(v[i + 1].c_str()));
					}
				}
				else if (i % 2 == 0) {
					up = min(up, (int)atoi(prev.c_str()));
					if (i != n - 1) {
						up = min(up, (int)atoi(v[i + 1].c_str()));
					}
				}
			}
			else if (i % 2 == 1 && prev != "x" && (int)atoi(v[i].c_str()) <= (int)atoi(prev.c_str())) {
				result = "none";
				break;
			}
			else if (i % 2 == 0 && prev != "x" && (int)atoi(v[i].c_str()) >= (int)atoi(prev.c_str())) {
				result = "none";
				break;
			}

			prev = v[i];

			if (up - low < 2) {
				result = "none";
				break;
			}
		}

		if (result != "none" && up - low > 2) {
			result = "ambiguous";
		}
		else if (result != "none" && up - low == 2) {
			result = to_string((up + low) / 2);
		}

		cout << result << endl;
	}
}

Measured memory_bytes: 3260
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

int main() {
	int n, k;
	cin >> n >> k;
	int ans = 0;
	rep(i, n) {
		int h;
		cin >> h;
		if (h >= k) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3604
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        ArrayList<Integer> l = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            l.add(sc.nextInt());
        }
        Collections.sort(l);
        Collections.reverse(l);
        int ans = 0;
        for (int i = 0; i < k; i++) {
            ans += l.get(i);
        }
        System.out.println(ans);
    }
}

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

using namespace std;
#define MAX 200000
int N, K, temp;
int cnt[MAX+1];
int ans = 0;

int main()
{
  cin >> N >> K;
  for(int i = 0; i < N; ++i) {
    cin >> temp;
    cnt[temp]++;
  }
  sort(cnt, cnt+MAX+1, greater<int>());

  for(int i = 0; i < K; ++i) {
    ans += cnt[i];
  }
  cout << N - ans << endl;
  return 0;
}

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

using namespace std;

const int maxn = 2e5 + 5;
bool flag[maxn];
struct
{
    int v, next;
}e[maxn<<1];

int dep[maxn];
int h[maxn], mem;
void pre()
{
    flag[1] = 1;
    flag[2] = 0;
    flag[3] = 1;
    memset(h, -1, sizeof(h));
    mem = 0;
    for(int i=4; i<maxn; i++)
    {
        if(flag[i-1]&flag[i-2]) flag[i] = 0;
        else flag[i] = 1;
    }
}

void add(int u, int v)
{
    e[mem].v = v;
    e[mem].next = h[u];
    h[u] = mem++;
    e[mem].v = u;
    e[mem].next = h[v];
    h[v] = mem++;
}

void dfs(int u, int fa)
{
    dep[u] = dep[fa] + 1;
    for(int i=h[u]; i+1; i=e[i].next)
    {
        int v = e[i].v;
        if(v==fa) continue;
        dfs(v, u);
    }

}


int main()
{
    pre();
    int n;
    scanf("%d", &n);
    for(int i=1; i<n; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        add(x, y);
    }
    memset(dep, 0, sizeof(dep));
    dfs(1, 1);
    int maxdep=0, id=0;
    for(int i=1; i<=n; i++)
    {
        if(dep[i] > maxdep){
            maxdep = dep[i];
            id = i;
        }
    }

    memset(dep, 0, sizeof(dep));
    dfs(id, id);
    maxdep = 0;
    for(int i=1; i<=n; i++)
    {
        if(dep[i] > maxdep){
            maxdep = dep[i];
            id = i;
        }
    }

    printf("%s\n", flag[maxdep]?"First":"Second");

    return 0;
}
























Measured memory_bytes: 11392
#include<stdio.h>
#include<string.h>
#define LEN 1000000

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head=1, tail=1, n;

void enqueue(P x){
  strcpy(Q[tail].name,x.name);
  Q[tail].t = x.t;
  if( tail + 1 == LEN )tail = 0;
  else tail++;

}

P dequeue(){
  P x;
  x = Q[head];
  if( head + 1 == LEN )head = 0;
  else head++;
  return x;
}


int main(){
  int i, q, c=0, p_count=0, ans=0;

  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    if( strlen(Q[i].name) > 10 ){
      printf("%s\n", Q[i].name);
      p_count++;
      break;
    }
    scanf("%d", &Q[i].t);
    enqueue(Q[i]);
  }
  
  while(1){
    c++;
    if( n == p_count )break;
    if( Q[c].t - q > 0 ){
      ans += q;
      Q[c].t -= q;
      enqueue(Q[c]);
    }    
    else{
      ans += Q[c].t;
      printf("%s %d\n", Q[c].name, ans);
      p_count++;
      Q[c] = dequeue();
    }
  }

  return 0;
}

Measured memory_bytes: 21084
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a * b % 2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}

	}

}


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

int main()
{
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end());
    int ans = 0;
    rep(b, n)rep(a, b) {
        int ab = l[a] + l[b];
        int R = lower_bound(l.begin(), l.end(), ab) - l.begin();
        int L = b + 1;
        ans += max(R - L, 0);
    } 
    cout << ans << endl;
    return 0;
}

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

constexpr int MAX_N = 100;

int N;
int A[2][MAX_N], csum[2][MAX_N];

int main(){

	std::cin >> N;

	for(int i = 0; i < 2; ++i){
		for (int j = 0; j < N; ++j){
			std::cin >> A[i][j];
			if(j != 0){
				csum[i][j] = csum[i][j - 1] + A[i][j];
			}
			else{
				csum[i][j] = A[i][j];
			}
		}
	}

	int ans = 0;
	for(int i = 0; i < N; ++i){
		if(i != 0){
			ans = std::max(ans, csum[0][i] + csum[1][N - 1] - csum[1][i - 1]);
		}
		else{
			ans = std::max(ans, csum[0][i] + csum[1][N - 1]);
		}
	}

	std::cout << ans << std::endl;

	return 0;
}


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

int main()
{
  string s;
  int a = 700;
  cin >> s;
  for (int i = 0; i < s.length(); i++) 
    if (s[i] == 'o') a += 100;
  
  cout << a << endl;
  
  return 0;
}

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

bool j(string s){
    string t = s;
    reverse(t.begin(),t.end());
    return t == s;
}

int main(){
    int k,n,ans(0),d(0);
    cin >> k >> n;
    int a[n];

    rep(i,n){
        cin >> a[i];
    }

    rep(i,n-1){
        d = max(d,a[i+1]-a[i]);
    }
    d = max(d,a[0]+(k-a[n-1]));

    cout << k-d << endl;
    return 0;
}

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


int main() {
	int a,b;
    string s1,s2;
    s1 = "";
    s2 = "";
    
    cin >> a >> b;

    rep(i,a){
        s1 = s1 + char('0'+b);
    }
    rep(i,b){
        s2 = s2 + char('0'+a);
    }

    if (s1 > s2){
        cout << s2 << endl;
    }else{
        cout << s1 << endl;
    }

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int n;
    map<ll,ll> m;
    cin >> n;
    rep(i,n){
        int x;
        cin >> x;
        m[-x]++;
    }
    ll fi = 0;
    for(auto i:m){
        if(i.second>=4){
            if(fi==0){
                cout << abs(i.first*i.first)<<endl;
            }
            else{
                cout << abs(fi*i.first) << endl;
            }
            return 0;
        }
        else if(i.second==2 || i.second==3){
            if(fi==0){
                fi = i.first;
            }
            else{
                cout << abs(fi*i.first) << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
    return 0;
}

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

int main() {
  int k;
  cin >> k;
  int x = 7%k;
  set<int> s;
  int i = 1;
  while (s.count(x) == 0) {
    if (x == 0) {
      cout << i << endl;
      return 0;
    }
    s.insert(x);
    x = (x*10+7)%k;
    ++i;
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 50464
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define inf 1001001001
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(void) {
    string s, t; cin >> s >> t;
    int n = s.size();
    rep(i, n) {
        bool ok = true;
        rep(j, n) {
            if(s[(i+j)%n] != t[j]) {
                ok = false; break;
            }
        }
        if(ok) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include <math.h>
#include<stdio.h>
#include <climits>
#include<algorithm>
#include<string>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define LL  long long 

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int k;//入力
	string s;
	int i = 0, j = 0;//内部使用

					   //出力
	cin >> k;
	cin >> s;
	
	if (s.size() <=  k) {
			cout << s<< "\n";
	}
	else {
		rep(i, k) {
			cout << s[i];
		}
		cout << "..." << "\n";
	}
	

}


Measured memory_bytes: 3656
#include<iostream>
#define I(i,n)for(int i=0;i<n;i++)
long long M=1e9+7,n,a[2],s[100000],w[2][100001],e[2],l[2][100000],p,v[2];
int main(){
	std::cin>>n>>a[0]>>a[1];
	I(i,n)std::cin>>s[i];
	I(k,2){
		p=0;
		I(i,n){
			while(s[i]-s[p]>=a[k]&&p<i-1)p++;
			l[k][i]=p;
		}
	}
	I(k,2){e[k]=-1;w[k][0]=1;}
	I(i,n){if(i){
		I(k,2)v[k]=(e[1-k]<l[k][i]?w[1-k][l[k][i]]:0);
		I(k,2)if(s[i]-s[i-1]<a[k]){e[k]=i-1;}else{(v[k]+=w[k][i-1])%=M;}
		I(k,2)w[k][i+1]=w[k][i]=v[k];
	}
	}
	std::cout<<(w[0][n-1]+w[1][n-1])%M<<"\n";
	return 0;
}


Measured memory_bytes: 4224
def main():
    N = int(input())
    h = list(map(int, input().split()))

    dp = [0] * (N+5)
    dp[1] = abs(h[1]-h[0])

    for i in range(2, N):
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))

    print(dp[N-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 20572
#include<stdio.h>

int main(void){
  int n,k,i;
  char target;
  scanf("%d",&n);
  char s[n];
  scanf("%s",s);
  scanf("%d",&k);
  target = s[k-1];
  for(i=0;i<n;i++){
    if(s[i]!=target){
      s[i] = '*';
    }
  }
  printf("%s",s);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


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

    if(X>=30){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    


    return 0;
    

}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	long long n, i, j, k, ans;
	cin >> n;
	vector<long long> a(n);
	for (i = 0; i < n; i++) cin >> a[i];
	ans = 0;
	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) ans += (a[i] * a[j]);
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 888
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>


#define ll long long
#define int ll
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 3e5 + 1;

int n, m, k;
int a[N], f[N];
pii p[N];
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		cin >> p[i].fi;
		p[i].se = i;
	}
	sort(p + 1 , p + 1 + n);
	for(int i = 1 ;i <= n; i++){
		cout << p[i].se << ' ';
	}


}


Measured memory_bytes: 2432
n=1<<18;L[1<<18],p;F[1<<18],X[1<<18];i;
long D[1<<20],Z[1<<20],A[1<<18],x,z;
long f(a,k,l,r){D[k]+=z=Z[k];Z[2*k]+=z;Z[2*k+1]+=z;Z[k]=0;return a<=l&r<i+2?D[k]+(Z[k]=x):l<=i&a<r?D[k]=fmax(f(a,2*k,l,(l+r)/2),f(a,2*k+1,(l+r)/2,r)):D[k];}
main(j){for(gets(L);~scanf("%d%d%ld",L+j,&p,A+j);F[p]=j++)X[j]=F[p];for(;p?:(p=F[++i],f(i,1,0,n),n/i);p=X[p])x=A[p],x=f(L[p],1,0,n);printf("%ld",x);}

Measured memory_bytes: 19200
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 400005;
using lint = long long;
using pi = pair<int, int>;

int n;
lint a[MAXN];
lint ans;

void Try(int x, int y, int z){
	if(0 < x && x < y && y < z && z < n){
		lint d1 = a[x] - a[0];
		lint d2 = a[y] - a[x];
		lint d3 = a[z] - a[y];
		lint d4 = a[n] - a[z];
		ans = min(ans, max({d1, d2, d3, d4}) - min({d1, d2, d3, d4}));
	}
}

int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		scanf("%lld",&a[i]);
		a[i] += a[i-1];
	}
	ans = 1e18;
	for(int i=2; i<=n-2; i++){
		auto l = lower_bound(a + 1, a + n + 1, (a[i] + 1) / 2) - a;
		auto r = lower_bound(a + 1, a + n + 1, a[i] + (a[n] - a[i] + 1) / 2) - a;
		for(int j = l - 3; j <= l + 3; j++){
			for(int k = r - 3; k <= r + 3; k++){
				Try(j, i, k);
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<stack>
using namespace std;
long long n;
void slove()
{
	stack<char>p;
	while(n)
	{
		int t=n%26;
		
		if(n)
		{
		if(t==0)
		p.push('z');
		else
		p.push((char)('a'+t-1));
		}
		n/=26;
		if(!t)
		n--;
	}
	while(!p.empty())
	putchar(p.top()),p.pop();
	putchar('\n');
}
int main(void)
{
	
	while(~scanf("%lld",&n))
	{
		slove();
	}
	return 0;
}

Measured memory_bytes: 3184
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(c>=a && c<=b)printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
while True:
    n = int(raw_input())
    if n == 0: break
    a = b = 0
    for i in range(n):
        pa, pb = map(int, raw_input().split())
        if pa > pb:
            a += pa+pb
        elif pa == pb:
            a += pa
            b += pb
        elif pa < pb:
            b += pa+pb
    else:
        print a, b

Measured memory_bytes: 4508
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

L = get_int

@cur_index = 1
@cur_target = L
@max = 0
@hens = []

def list
  n = 0
  while 2 ** n <= @cur_target
    n += 1
  end
  # n-1個の全ての辺を作成
  start = @cur_index
  if @hens.length == 0
    over20 = n == 20
    m = over20 ? n - 1 : n

    (m-1).times do |i|
      @hens << [start, start + 1, 0]
      @hens << [start, start + 1, 2**i]
      start = start+1
    end
    @hens << [start, nil, 0]
    @hens << [start, nil, 2**18] if over20 # n == 20のときのみ点の数が20を超えないように最後に辺を追加
  else
    @hens << [n, nil, @max]
  end

  @max += 2 ** (n-1)
  @cur_index = start
  @cur_target -= 2 ** (n-1)
end

while @cur_target > 0
  list
end

n = @cur_index + 1
@hens = @hens.map do |h|
  if h[1] == nil
    h[1] = n
  end
  h
end
puts "#{n} #{@hens.length}"
@hens.each do |h|
  puts "#{h[0]} #{h[1]} #{h[2]}"
end


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

int main() {
  int N,i;
  cin>>N;
  vector<int> a(N),b(N),c(N);
  for (i=0;i<N;i++) {
    cin>>a[i]>>b[i]>>c[i];
  }
  vector<vector<int> > dp(N, {0,0,0});
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  for (i=1;i<N;i++) {
    dp[i][0] = max(dp[i-1][1] + a[i], dp[i-1][2] + a[i]);
    dp[i][1] = max(dp[i-1][2] + b[i], dp[i-1][0] + b[i]);
    dp[i][2] = max(dp[i-1][0] + c[i], dp[i-1][1] + c[i]);
  }
  int ans = 0;
  for (i=0;i<3;i++) {
    ans = max(ans, dp[N-1][i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 9388
l = list(map(int, input().split()))
if(l[0] %2 == 0 or l[1] %2==0 or l[2]%2==0):
  print(0)
else:
  a = l.pop(l.index(min(l)))
  b = l.pop(l.index(min(l)))
  print(a*b)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
ll p[200005];
int a[200005];
typedef pair<int, int> P;
int main() {
	ll n;
	cin >> n;
	ll a[100005];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	ll count = 1;
	ll ans = 0;
	for (int i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1]) {
			count++;
		}
		else {
			if (count % 2 == 1) {
				ans++;
			}
			count = 1;
		}
	}
	if (count % 2 == 1) {
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
 
#define N 1000003
 
void insert(char*);
void find(char*);
int hash1(int);
int hash2(int);
int hash(char*,int);

char D[N][13];
 
int main(){
  int n,i;
  char str[13];
   
  scanf("%d",&n);
  
  for(i=0;i<N;i++){
    strcpy(D[i],"\0");
  }//?????????
 
  for(i=0;i<n;i++){
    scanf("%s",str);
    if(strcmp(str,"insert")==0){
      scanf("%s",str);
      insert(str);
    }
    else if(strcmp(str,"find")==0){
      scanf("%s",str);
      find(str);
    }
  }
  
  return 0;
}
 
void insert(char *str){
  int i=0;
 
  while(strcmp(D[hash(str,i)],"\0")!= 0){
    i++;
  }
  strcpy(D[hash(str, i)],str);
}

void find(char *str){
  int i=0;
  
  while(1){
    if(strcmp(D[hash(str, i)],"\0")==0){
      printf("no\n");
      break;
    }
    else if(strcmp(D[hash(str,i)],str)==0){
      printf("yes\n");
      break;
    }
    i++;
  }
}

int hash(char *str, int i){
  int j,k=0,n=1;
  
  for(j=0;str[j]!='\0';j++){
    if(str[j]=='A'){
      k+=n*0;
    }
    else if(str[j]=='C'){
      k+=n*1;
    }
    else if(str[j]=='G'){
      k+=n*2;
    }
    else if(str[j]=='T'){
      k+=n*3;
    }
    n=n*4;
  }
  
  return (hash1(k)+i*hash2(k))%N;
}

int hash1(int k){
  return k%N;
}

int hash2(int k){
  return 1+k%(N-1);
}

Measured memory_bytes: 13296
h, w = map(int, input().split())
s = []
for i in range(h):
    s.append(input())

# print(s)

d = [[-1, -1], [0, -1], [1, -1], [1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0]]



for i in range(h):
    si = ""
    for j in range(w):
        c = 0
        if s[i][j] == ".":
            for di in d:
                if i+di[0] >= 0 and i+di[0] < h and j+di[1] >= 0 and j+di[1] < w:
                    if s[i+di[0]][j+di[1]] == "#":
                        c += 1
            si += str(c)
        else:
            si += s[i][j]
    s[i] = si

for si in s:
    print(si)


Measured memory_bytes: 9108
#include <stdio.h>

main(){
  int a = 0, b = 0;
  char op;

  scanf("%d %c %d", &a, &op, &b);

  while(op != '?'){
    if(op == '+')printf("%d\n", a+b);
    else if(op == '-')printf("%d\n", a-b);
    else if(op == '*')printf("%d\n", a*b);
    else if(op == '/')printf("%d\n", a/b);

    scanf("%d %c %d", &a, &op, &b);

  }
  return 0;
}



Measured memory_bytes: 2048
#import hoge
##################################################################
Input1 = [input() for i in range(1)]
N,M = list(map(int,Input1[0].split()))
Input2 = [input() for i in range(M*2)]
A,B,C = [],[],[]
for i in range(M):
    a,b = list(map(int,Input2[i*2].split()))
    A.append(a)
    B.append(b)
    c = list(map(int,Input2[i*2+1].split()))
    C.append(c)

d = []
for c in C:
    r = 0
    for j in c:
        r |= 2**(j-1)
    d.append(r)

dp = [1000000000]*2**N
dp[0] = 0
for i in range(2**N): #あらゆる開け方をsimする
    for j in range(M): #すべての鍵について確認する
        temp = d[j] | i #今回の開け方についてさらに鍵jを使ったとき
        cost = dp[i] + A[j]
        if dp[temp] > cost: #costが既知の開け方よりも安ければ
            dp[temp] = cost #それを新しい開け方とする

if dp[-1] == 1000000000:
    print(-1)
else:
    print(dp[-1])
#print([format(dd, 'b') for dd in d])
    
#print(' '.join(map(str,B)))
    


Measured memory_bytes: 3444
#include<iostream>
using namespace std;
const int MAXN = 500000+5;
int n,nu[MAXN],an[MAXN],tt(0);
void init(){
	cin>>n;
	for(int i=0;i<n;i++)
	    cin>>nu[i];
}
void sor(int l,int r){
	if(r-l>1){
	    int m(l+(r-l)/2),p(l),q(m),i(l);//l - m-1,m - r
		sor(l,m);
		sor(m,r);
		//cout<<"lmr  p="<<p<<"   m="<<m<<"  r="<<r<<endl;
		while(p<m||q<r){
			if(q>=r||(p<m&&nu[p]<=nu[q])) an[i++]=nu[p++];
			else an[i++]=nu[q++];
			tt++;
			//cout<<"p="<<p<<"   q="<<q<<endl;
			//cout<<an[i-1]<<' ';
	        //system("pause");
		}
		//cout<<endl;
		for(i=l;i<r;i++)
		    nu[i]=an[i];
		//cout<<"l="<<l<<"   r="<<r<<endl;for(i=l;i<r;i++) cout<<nu[i]<<' ';cout<<endl;
	}
}
int main(){
	init();
	sor(0,n);
	for(int i=0;i<n-1;i++)
	   cout<<nu[i]<<' ';
	cout<<nu[n-1]<<endl<<tt<<endl;
	return 0;
}

Measured memory_bytes: 6972
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N, K, Q; cin >> N >> K >> Q;
  vector<int> point(N, K-Q);
  int A;
  rep(i,Q) {
    cin >> A;
    A--;
    point[A]++;
  }

  rep(i,N){
    cout << (point[i]>0? "Yes" : "No") << endl;
  }

  

  // cout << fixed << setprecision(6);
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long g[200][200],N,M,R,INF=1L<<60,i,j,k,a,b,c,ans=INF,tmp;
vector<long>r;
int main(){
  cin>>N>>M>>R;
  r.resize(R);
  for(i=0;i<R;i++)cin>>r[i],r[i]--;
  fill((long*)g,(long*)(g+200),INF);
  for(i=0;i<N;i++)g[i][i]=0;
  for(i=0;i<M;i++){
    cin>>a>>b>>c;
    a--;b--;
    g[a][b]=g[b][a]=c;
  }
  for(k=0;k<N;k++){
    for(i=0;i<N;i++){
      for(j=0;j<N;j++){
        g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
      }
    }
  }
  sort(r.begin(),r.end());
  do{
    tmp=0;
    for(i=0;i<R-1;i++)tmp+=g[r[i]][r[i+1]];
    ans=min(ans,tmp);
  }while(next_permutation(r.begin(),r.end()));
  cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;
int a[N];

int main()

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

    char c;

    cin >> c;

    if (c == 'A') cout << "T";
    else if (c == 'T') cout << "A";
    else if (c == 'G') cout << "C";
    else cout << "G";

    return 0;
}


Measured memory_bytes: 256
s=input()
d={}
for ss in s:
  d[ss]=0
for ss in s:
  d[ss]+=1
if len(d.keys())==2:
  f=True
  for k in d:
    if d[k]!=2:
      f=False
  if f :
    print("Yes")
  else:
    print("No")
else:
  print("No")

Measured memory_bytes: 3060
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.range;

// from https://ei1333.github.io/luzhiled/snippets/structure/union-find.html
class UnionFind {
  public:
    long[] par;

    this(long size) {
      par = new long[](size);
      foreach (i; 0..size) {
        par[i] = -1;
      }
    }

    long size(long x) {
      return -(par[find(x)]);
    }

    long find(long x) {
      if (par[x] < 0) {
        return x;
      }
      par[x] = find(par[x]);
      return par[x];
    }

    bool same(long x, long y) {
      return !unite(x, y);
    }

    bool unite(long x, long y) {
      x = find(x);
      y = find(y);

      if (x == y) {
        return false;
      }
      if (par[x] > par[y]) {
        par[y] += par[x];
        par[x] = y;
      } else {
        par[x] += par[y];
        par[y] = x;
      }
      return true;
    }
}


void main() {
  long n, m;
  readf("%d %d\n", &n, &m);

  auto uf = new UnionFind(n);
  
  long a, b;
  long[] as = new long[](m), bs = new long[](m);
  foreach (i; 0..m) {
    readf("%d %d\n", &a, &b);
    as[i] = a-1;
    bs[i] = b-1;
  }

  long[] cnt = new long[](m);
  foreach_reverse(i; 0..m) {
    a = uf.size(as[i]);
    b = uf.size(bs[i]);
    if (uf.unite(as[i], bs[i])) {
      cnt[i] = a * b;
    } else {
      cnt[i] = 0;
    }
  }

  long ans = 0;
  foreach (i; 0..m) {
    ans += cnt[i];
    writeln(ans);
  }
}


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

using namespace std;

// 321654987 234567891 13245
// 249999999 250000000 999999998

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	long long int a,b,c;
 
	cin >> a >> b >> c;
	__int128 A = a;
	__int128 B = b;
	__int128 C = c;
	__int128 val = (C - A - B);
 
	if(4LL*A*B < val*val && val > 0)
	{
		cout << "Yes" << '\n';
	}
	else
	{
		cout << "No" << '\n';
	}
 
	return 0;
}

Measured memory_bytes: 3656