akhauriyash/Code-Regression huggingface dataset:
//Compiler optimization
#pragma GCC optimize("Ofast")

//include
#include <bits/stdc++.h>
using namespace std;

//typedef
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;

//macro
#define reverse(a) reverse(a.begin(),a.end())
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define each(x, v) for (auto &x : v)

//abbreviation
#define pb push_back
#define elif else if
#define mp make_pair
#define endl '\n'

//debug
#define debug(x) cerr << #x << ": " << x << endl
#define v_debug(v) cerr << #v << endl;fr(i,v.size()) cerr << i << ": " << v[i] << endl

//const
const  ll INF = 1e18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(20);
    S s,t;cin >> s;
    cin >> t;
    ll ans = 0;
    fr(i,s.size()){
        if(s[i] !=t[i])ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3788
n = int(input())
a = list(map(int, input().split()))
s = list(set(x//400 for x in a))

normal = [x for x in a if x < 3200]
strong = [x for x in a if x >= 3200]

normal_s = set(x // 400 for x in normal)


print(max(len(normal_s), 1), len(normal_s) + len(strong))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> p(n), q(n);
    for (auto &e : p) std::cin >> e;
    for (auto &e : q) std::cin >> e;

    std::vector<int> a;
    for (int i = 1; i <= n; i++) a.push_back(i);

    int pi, qi, j = 0;
    do {
        if (a == p) pi = j;
        if (a == q) qi = j;
        j++;
    } while (std::next_permutation(a.begin(), a.end()));

    std::cout << abs(pi - qi) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,m,n) for(int i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;


int main(){
  int n,k;
  cin >> n >> k;
  int a=n;
  vector<int>b(n,0);
  rep(i,k){
    int d;
    cin >> d;
    rep(j,d){
      int A;
      cin >> A;
      if(b[A-1]==0)b[A-1]=1;
    }
  }
  int sum=0;
  rep(i,n){
    if(b[i]==0)sum++;
  }
  cout << sum;
}




Measured memory_bytes: 3616
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    for(char c : s){
        ans += (c-'0');
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    h, w = ns()
    d = []
    for _ in range(h):
        tmp = list(input())
        d.extend(tmp)

    c = collections.Counter(d)

    flg1 = w % 2
    flg2 = h % 2
    even_pocket = h * flg1 + w * flg2 - flg1 * flg2 * 2
    odd_pocket = flg1 * flg2

    ans = True
    for k, v in c.items():
        even_pocket -= ((v % 4) // 2) * 2
        odd_pocket -= v % 2
        if even_pocket < 0 or odd_pocket < 0:
            ans = False
            break

    print("Yes" if ans else "No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 64620
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{
    #ifdef DOC
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int n, k; cin >> n >> k;
    auto c = [k](long long p) -> int
    {
        if(p >= k) return 0;
        for(int i = 1;;)
        {
            p *= 2;
            if(p >= k) return i;
            ++i;            
            
        }
    };
    double re = 0;
    cout << std::setprecision(12);
    for(int i = 1; i <= n; ++i)
    {

        re += 1.0/n * pow(0.5, c(i));                
    }
    cout << re;
    
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(),b = sc.nextInt(),cnt=0;
		for(; cnt<Math.max(a, b); cnt++) {
			if(a+b-(cnt*2) == 0)break;
		}
		System.out.println(cnt<Math.max(a, b)?cnt:"IMPOSSIBLE");
	}
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if(N<=111)System.out.println(111);
		else if(112<=N && N <=222)System.out.println(222);
		else if(223<=N && N <=333)System.out.println(333);
		else if(334<=N && N <=444)System.out.println(444);
		else if(445<=N && N <=555)System.out.println(555);
		else if(556<=N && N <=666)System.out.println(666);
		else if(667<=N && N <=777)System.out.println(777);
		else if(778<=N && N <=888)System.out.println(888);
		else if(889<=N && N <=999)System.out.println(999);
		sc.close();
	}

}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    string s; cin >> s;
    cout << s[0] << s.length()-2 << s[s.length()-1] << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	if(s[s.length() -1] == 's') cout << s + "es" << endl;
	else cout << s + "s" << endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
string S;
  for(int i=0;i<N;i++){
  cin>>S;
    if(S=="Y"){
    cout<<"Four"<<endl;
      break;
    }
    if(i == N-1){
      cout<<"Three"<<endl;
      break;
    }
  }
}


Measured memory_bytes: 256
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	int a, b;
	cin >> a >>b;
	if((a+b)% 2==1)  cout << "IMPOSSIBLE" << endl;
    else cout << (a+b )/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>
#include<bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;



int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;
	
	string s;
	cin >> s;

	if (s[s.size() - 1] == 's')
	{
		cout << s << "es" << endl;
	}
	else
		cout << s << "s" << endl;

	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int n,x;
  long z;
  cin >> n;
  int max = -1000000;
  int min = 1000000;
  z = 0;

  for (int i=0;i<n;i++) {
    // 最大値
    cin >> x;
    if (max <= x) {
      max = x;
    }
    // 最小値
    if (min >= x) {
      min = x;
    }
    // 合計
    z = z + x;
  }
  printf("%d %d %ld\n",min,max,z);
}


Measured memory_bytes: 3160
import java.util.Scanner;

class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();

    int sum1 = A + B ;

    if (A % 3 == 0 || B % 3 == 0 || sum1 % 3 == 0) {
      System.out.println("Possible");
    }
    else {
      System.out.println("Impossible") ;
    }

  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define sz(x) ll(x.size())
using namespace std;

int main() {
  int n,ans=0;
  cin >> n;
  vector<int>v(n);
  vector<int>c(n);
  rep(i,n) cin >> v.at(i);
  rep(i,n) cin >> c.at(i);
  rep(i,n) ans+=max(0,v.at(i)-c.at(i));
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define lson root<<1
#define rson root<<1|1
#define Mid int mid=(l+r)>>1;
#define FREI freopen("in.txt","r",stdin)
#define FREO freopen("out.txt","w",stdout)
#define Mem(a,b) memset(a,b,sizeof(a))
#define MAXN 400
#define mod 1000000007
#define ll long long
#define eps 1e-6
using namespace std;
int main()
{
    char s[10];
    scanf("%s",s+1);
    int len=strlen(s+1);
    bool flag=1;
    for(int i=1;i<=len;i++){
        if(s[i]!=s[len-i+1]) {
            flag=0;
            break;
        }
    }
    flag?puts("Yes"):puts("No");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner sc;
	void run() {
		sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			int p = sc.nextInt();
			if (n ==0 && p ==0) break;
			int tmp = p;
			int[] sto = new int[n];
			int ans;
			
			for (int i=0;i<n;i++) sto[i] = 0;
			
			for (int i=0;;i++) {
//				System.out.println(i + " " + p);
//				for (int j=0;j<n;j++) System.out.print(sto[j]);
//				System.out.println();
				if(tmp != 0) {
					sto[i] += 1;
					tmp -= 1;
					
				}
				else {
					tmp = sto[i];
					sto[i] = 0;
				}
				if(sto[i] == p) {
					ans = i;
					break;
				}
				
				if (i==n-1) i=-1;
				
			}
			System.out.println(ans);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

ll inversion(const Vi &v){
  //0, 1からなるvectorの点灯数
  ll cnt = 0, pos = 0;
  REP(i, (ll)v.size()){
    if(v[i] == 1){
      cnt++; pos += i;
    }
  }
  return pos - (cnt * (cnt - 1) / 2);
}
int main(){
  string s; cin >> s;
  ll n = s.size();
  ll i = 0;
  Vi v(0);
  ll ans = 0;
  while(i <= n){
    if(s[i] == 'A'){
      v.pb(0);
      i++;
    }
    else if(s[i] == 'B' && (i + 1 < n && s[i + 1] == 'C')){
      v.pb(1);
      i += 2;
    }
    else{
      ans += inversion(v);
//      printf("i = %lld, inversion(v) = %lld\n", i, inversion(v));
      v.erase(v.begin(), v.end());
      i++;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef vector<ll,ll> vll;
typedef pair<ll,ll> pll;

//DP[n][v] = min weight can have using up to first n items, and value v

const int MAX_V = 100010;
ll DP[101][MAX_V];

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int n, W;
	cin >> n >> W;
	vi w(n), val(n);
	M00(i, n) {
		cin >> w[i] >> val[i];
	}
	ll inf = 1e15;

	MOO(i,1,MAX_V) {
		DP[0][i] = inf;
	}
	DP[0][0] = 0;


	MOO(i, 1, n+1) {
		M00(j, MAX_V) {
			DP[i][j] = DP[i-1][j];
			if(j >= val[i-1])
				DP[i][j] = min(DP[i][j], DP[i-1][j-val[i-1]] + w[i-1]);
		}
	}
	ll best = 0;
	M00(i, MAX_V) {
		if(DP[n][i] <= W) best = i;
	}
	finish(best);
}


Measured memory_bytes: 79232
#include<iostream>
#include<set>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef unsigned long long ll;

const ll base = 1299709ULL;
const ll maxn = 300300;

vector<ll> hash;
ll power[maxn];

void init(int n){
  power[0] = 1;
  for(int i=1;i<=n;i++){
    power[i] = power[i-1] * base;
  }
}

string s,t;

int main(){
  cin >> s >> t;
  int n = t.size();

  init(n);

  ll val = 0;
  for(int i=0;i<n;i++)val = val*base + t[i];

  for(int i=0;i<n;i++){
    for(int j=0;j<26;j++){
      char tmp = 'a' + j;
      if(t[i] == tmp)continue;
      ll hoge = val + tmp * power[n-1-i] - t[i] * power[n-1-i];

      hash.push_back(hoge);
    }
    for(int j=0;j<26;j++){
      char tmp = 'A' + j;
      if(t[i] == tmp)continue;
      ll hoge = val + tmp * power[n-1-i] - t[i] * power[n-1-i];

      hash.push_back(hoge);
    }
  }

  sort(hash.begin(),hash.end());

  val = 0;
  for(int i=0;i<n;i++)val = val*base + s[i];
  int res = 0;
  if(binary_search(hash.begin(),hash.end(),val))res++;

  for(int i=1;i+n<=s.size();i++){
    val = val*base + s[i+n-1];
    val = val - s[i-1] * power[n];
    if(binary_search(hash.begin(),hash.end(),val))res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 70540
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <math.h>
 
int main(void){
long long int a,b,c;
scanf("%lld %lld %lld",&a,&b,&c);
long long int d=c-a-b;
if(d>0&&d*d>4*a*b){printf("Yes\n");}
else{printf("No\n");}

}

Measured memory_bytes: 128
N, A, B = map(int, input().split())
val = [int(i) for i in input().split()]

def combi(n, m):
    from math import factorial
    return factorial(n) // (factorial(m) * factorial(n-m))

val.sort(reverse=True)
ave = sum(val[:A])/A

l = val.index(val[A-1])
x = val.count(val[A-1])
ct = 0

if val[0] == val[A-1]:
    for i in range(A, x+1):
        if i > B:
            break
        else:
            ct += combi(x, i)
else:
    ct = combi(x, A-l)
print(ave)
print(ct)


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
const int MOD=1e9+7;
long dp[1<<17];
inline void solve(void){
  int N,M;in(N,M);
  vector<bool>a(N+1,true);
  rep(i,M){
    int b;in(b);
    a[b]=false;
  }
  dp[0]=1;
  if(a[1])dp[1]=1;
  else dp[1]=0;
  up(i,2,N){
    if(a[i]){
      dp[i]=(dp[i-1]+dp[i-2])%MOD;
    }
  }
  out(dp[N]);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=610;
const int mod=998244853;
const int base=131;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,pw[N],hshr[N][N],hshc[N][N];
char s[N][N];
int gethshr(int i,int l,int r) {
    return (hshr[i][r]-1ll*hshr[i][l-1]*pw[r-l+1]%mod+mod)%mod;
}
int gethshc(int i,int l,int r) {
    return (hshc[r][i]-1ll*hshc[l-1][i]*pw[r-l+1]%mod+mod)%mod;
}
int check(int x,int y) {
    for(int i=x,j=y;i<=x+n-1;i++,j++)
        if(gethshr(i,y,y+n-1)!=gethshc(j,x,x+n-1)) return 0;
    return 1;
}
int main() {
    n=gi();
    for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
    for(int i=1;i<=n;i++)
        for(int j=n+1;j<2*n;j++) s[i][j]=s[i][j-n];
    for(int i=n+1;i<2*n;i++)
        for(int j=1;j<=n;j++) s[i][j]=s[i-n][j];
    for(int i=n+1;i<2*n;i++)
        for(int j=n+1;j<2*n;j++) s[i][j]=s[i-n][j-n];
    for(int i=1;i<2*n;i++)
        for(int j=1;j<2*n;j++) hshr[i][j]=(1ll*hshr[i][j-1]*base+s[i][j]-'a'+1)%mod;
    for(int i=1;i<2*n;i++)
        for(int j=1;j<2*n;j++) hshc[i][j]=(1ll*hshc[i-1][j]*base+s[i][j]-'a'+1)%mod;
    pw[0]=1;for(int i=1;i<2*n;i++) pw[i]=1ll*pw[i-1]*base%mod;
    int ans=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++) if(check(i,j)) ++ans;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3456
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

class WeightedUnionFind():

    def __init__(self,N):
        self.N = N
        self.parents = [-1] * self.N
        self.diff_weight = [0] * self.N
    
    def find(self,x):
        if self.parents[x] < 0:
            return x
        else:
            p = self.find(self.parents[x])
            self.diff_weight[x] += self.diff_weight[self.parents[x]]
            self.parents[x] = p
            return p
    
    def weight(self,x):#xの親からの重みを返す
        self.find(x)
        return self.diff_weight[x]
    
    def diff(self,x,y):#同じグループにいたらxとyの重みの差を返す
        if self.find(x) == self.find(y):
            return self.weight(y) - self.weight(x)
        else:
            return 1e10

    def unite(self,x,y,w):#wieght(y) = weight(x) + dとなるように合体
        w += self.weight(x)
        w -= self.weight(y)

        x = self.find(x)
        y = self.find(y)
        if x == y:
            if self.diff(x,y) == w:
                return True
            else:
                return False

        if self.parents[x] > self.parents[y]:
            x,y = y,x
            w *= -1
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        self.diff_weight[y] = w
        return True
    
    def size(self,x):
        return - self.parents[self.find(x)]

def main():
    n,m = map(int,input().split())
    uf = WeightedUnionFind(n)
    flag = True
    for _ in range(m):
        l,r,d = map(int,input().split())
        l -= 1
        r -= 1
        if uf.unite(l,r,d):
            continue
        else:
            flag = False
            break
    print('Yes' if flag else 'No')
if __name__ == '__main__':
    main()

Measured memory_bytes: 8944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int h,w,k;
char s[15][1005];
int a[15][1005];
int b[15][1005];
int B[15];
int ans=1000000000,x,c;
int main(void){
	cin>>h>>w>>k;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>s[i][j];
			if(s[i][j]=='1') a[i][j]=1;
			b[i+1][j+1]=b[i+1][j]+b[i][j+1]-b[i][j]+a[i][j];
		}
	}
	if(h==1){
		for(int i=0;i<w;i++){
			if(s[0][i]=='1'){
				c++;
			}
			if(c>k){
				x++;
				c=1;
			}
		}
		cout<<x<<endl;
		return 0;
	}
	int t;
	int le;
	for(int bit=0;bit<(1<<(h-1));bit++){
		t=1;
		le=0;
		x=0;
		for(int i=0;i<h-1;i++){
			B[i]=0;
		}
		for(int i=0;i<h-1;i++){
			if(bit&(1<<i)){
				x++;
				B[t]=i+1;
				t++;
			}
		}
		B[t]=h; t++;
		for(int i=1;i<=w;i++){
			for(int j=1;j<t;j++){
				if(b[B[j]][i]-b[B[j]][le]-b[B[j-1]][i]+b[B[j-1]][le]>k){
					if(le==i-1) x=100000000;
					x++;
					le=i-1;
					break;
				}
			}
		}
		//cout<<x<<endl;
		ans=min(ans,x);
	}
	cout<<ans<<endl;
	
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;

  for (int i = 0; i < (int) s.size(); i++) {
    char c = s.at(i) + n;
    if (c > 'Z') {
      c = c - ('Z' - 'A' + 1);
    }
    cout << c;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define MAX 11

int main(){
  long int n;
  cin >> n;
  
  int ans = MAX;
  for (int a = 1; a <= sqrt(n); a++){
    if (n % a == 0){
      long int b = n / a;
      
      long int x;
      int x_digitnum = 1;
      if (a > b) x = a;
      else x = b;
      while (x / 10 != 0){
        x /= 10;
        x_digitnum++;
      }
      if (x_digitnum < ans) ans = x_digitnum;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long 
#define INF 1e9
#define LINF 1e18
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
 
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;
 
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
 
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int N, x, a[100000];

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

    cin >> N >> x;
    rep(i, N) cin >> a[i];
    int res = 0;
    if(a[0] > x) {res = a[0] - x; a[0] = x;}
    FOR(i, 1, N) {
        if(a[i - 1] + a[i] > x) {
            res += (a[i - 1] + a[i]) - x;
            a[i] = x - a[i - 1];
        }
    }
    cout << res << endl;
    return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  int r = 2;
  vector<vector<int>> a(r,vector<int>(n));
  rep(i,r){
    rep(j,n) cin >> a[i][j];
  }

  int k = 4;
  vector<int> dx = {1,0,-1,0}, dy = {0,1,0,-1};
  int ans = -1;
  int x = 0,y = 0;
  int cnt = 0;
  while(1){
    int tmp = a[0][0];
    int j=0;
    if(cnt == 0){
      rep(i,n){
	if(i==cnt) j++;

	tmp += a[j][i];
      }      
    }
    
    else{
      for(int i = 1;i<n;i++){
	if(i==cnt){
	  tmp += a[j][i];
	  j++;
	}

	tmp += a[j][i];
      }
    }
    ans = max(ans,tmp);
    cnt++;
    if(cnt==n) break;
  }

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


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

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

using namespace std;

const int INF = 100;

int main()
{
	
	int row, col;
	cin >> row >> col;

	int A[100][100];

	rep(i, row)rep(j, col)cin >> A[i][j];

	int B[100];
	rep(i, col)cin >> B[i];

	rep(i, row) {
		int sum = 0;
		rep(j, col) {
			sum += A[i][j] * B[j];
		}

		cout << sum << endl;
	}



	return 0;
}



Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main() {
    int n;
    cin>>n;
    vector<int>a(n);
    vector<int>b(n);
    vector<int>c(n-1);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }
    for(int i=0;i<n;i++){
        cin>>b.at(i);
    }
    for(int i=0;i<n-1;i++){
        cin>>c.at(i);
    }
    a.push_back(0);
    b.push_back(0);
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=b.at(a.at(i)-1);
        if(a.at(i)+1==a.at(i+1)){
            ans+=c.at(a.at(i)-1);
        }
    }
    cout<<ans<<endl;






    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
int n,a[100001]; 
int num[100001];
int x=0;
int main(void)
{
	cin>>n;
	memset(num,0,sizeof(num));
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		num[a[i]]++;
		num[a[i]+1]++;
		num[a[i]-1]++;
		x=max(x,a[i]);
	}
	int ans=0;
	for(int i=0;i<=x;i++)
	{
		ans=max(num[i],ans);
	} 
	cout<<ans<<endl;
	return 0; 
}

Measured memory_bytes: 1024
z = []
w = []

for _ in range(int(input())):
    x, y = map(int, input().split())
    z.append(x + y)
    w.append(x - y)


z_max = max(z)
z_min = min(z)
w_max = max(w)
w_min = min(w)

print(max([abs(z_max - z_min), abs(w_max - w_min)]))

Measured memory_bytes: 24820
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.equals("AAA") || s.equals("BBB")) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
        sc.close();
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N, K, C;
    string S;
    cin >> N >> K >> C >> S;

    vec a(N+C+2, 0), b(N+C+2, 0);
    
    Rep (i, N+C+1) {
        chmax(a[i+1], a[i]);
        if (i < N and S[i] == 'o') {
            chmax(a[i+C+1], a[i] + 1);
        }
    }

    for (ll i = N+C+1; i > 1; i--) {
        chmax(b[i-1], b[i]);
        if (i-C-1 >= 0 and S[i-C-1] == 'o') chmax(b[i-C-1], b[i] + 1);
    }

    // Rep (i, N+C+1) {
    //     cout << a[i] << " \n"[i==N+C];
    // }
    // Rep (i, N+C+1) {
    //     cout << b[i] << " \n"[i==N+C];
    // }

    Rep (i, N) {
        if (a[i+C] + b[i+1] < K) {
            cout << i+1 << "\n";
        }
    }
}

Measured memory_bytes: 5012
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(long long i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<long long,long long> pii;
const long long inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);
 
const long long mod=1e9+7;
struct matrix
{
	long long a[3][3];
	void clear(long long x=0)
	{
		for(long long i=0;i<3;i++)for(long long j=0;j<3;j++)a[i][j]=(i==j)*x;
	}
	matrix(){clear();}
	long long *operator [](long long x)
	{
		return a[x];
	}
}sum,tran;
matrix operator *(matrix a,matrix b)
{
	matrix ret;
	ret.clear(0);
	for(long long i=0;i<3;i++)for(long long j=0;j<3;j++)for(long long k=0;k<3;k++)
		ret[i][j]=(ret[i][j]+1ll*a[i][k]*b[k][j])%mod;
	return ret;
}
matrix power(matrix x,long long y)
{
	matrix ret;ret.clear(1);
	while(y)
	{
		if(y&1)ret=ret*x;
		x=x*x;
		y>>=1;
	}
	return ret;
}
 
long long calc(long long x)
{
	matrix t;t.clear();t[0][0]=0;t[1][0]=1;t[2][0]=5;
	t=power(tran,x)*t;
	return t[0][0];
}
long long f[100111],n,x[100111],m;
int main()
{
	sum.clear();tran.clear();tran[0][1]=1;tran[1][2]=1;tran[2][0]=1;tran[2][1]=-2;tran[2][2]=4;
	get2(n,m);
	for(long long i=1;i<=m;i++)get1(x[i]);
	x[++m]=n;
	for(long long i=1;i<=m;i++)
	{
		sum=power(tran,x[i]-x[i-1])*sum;
		f[i]=((calc(x[i])-sum[0][0])%mod+mod)%mod;
		
		sum[1][0]=(sum[1][0]+f[i])%mod;
		sum[2][0]=(sum[2][0]+5ll*f[i])%mod;
	}
	printendl(f[m]);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[10001],dp[100][100];

int main(){
  int a = 0,b = 0;
  cin >> n;
  rep(i,0,n){
    cin >> m;
    if(m % 4 == 0)a++;
    else if(m % 2 == 0)b++;
  }
  if(n <= 2*a+1)puts("Yes");
  else if(n <= 2*a+b)puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  scanf("%d %d",&n,&m);
  int ara[n+5];
  int sum=0;
  for(int i=0;i<n;i++)
  {
    scanf("%d",&ara[i]);
    sum+=ara[i];
  }
  int need=sum/(4*m);
  if(sum%(4*m)!=0)need++;
  int cnt=0;
  for(int i=0;i<n;i++)
  {
    if(ara[i]>=need)cnt++; 
  }
  if(cnt>=m)puts("Yes");
  else puts("No");
  
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

typedef pair<ll,ll> p;

int main(){
  ll n,k;
  cin >> n >> k;
  ll max_d[n]; //種類ごとのdの最大値
  fill(max_d,max_d+n,0);
  vector<p> sushis;
  REP(i,n){
    ll t,d;
    cin >> t >> d;
    t--;
    sushis.push_back(p(d,t));
    max_d[t] = max(max_d[t], d);
  }
  sort(sushis.begin(),sushis.end(),greater<p>());
  priority_queue<p,vector<p>,greater<p> > s;

  ll type_cnt[n];
  fill(type_cnt,type_cnt+n,0);
  ll types = 0;
  ll sum = 0;

  //初期集合の構成
  REP(i,k){
    if(type_cnt[sushis[i].second]==0 && max_d[sushis[i].second]==sushis[i].first){ //これは削除しない
      types++;
      type_cnt[sushis[i].second]++;
    }else{
      s.push(sushis[i]);
    }
    sum += sushis[i].first;
  }

  ll ans = types*types+sum;

  //dの最大値が大きい順に種類を追加していく
  vector<p> waiting;
  REP(i,n) if(max_d[i]!=0) waiting.push_back(p(max_d[i],i));
  sort(waiting.begin(),waiting.end(),greater<p>());

  for(p type : waiting){
    if(type_cnt[type.second]) continue;
    if(s.empty()) break;
    sum -= s.top().first;
    sum += type.first;
    types++;
    s.pop();
    ans = max(ans,types*types+sum);
  }

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


Measured memory_bytes: 6384
import numpy as np

N, L = map(int, input().split())

A = np.arange(N)+L

if A[0] <= 0 and A[N-1] >= 0:
    print(np.sum(A))
elif A[0] < 0 and A[N-1] < 0:
    print(np.sum(A)-A[N-1])
else:
    print(np.sum(A)-A[0])

Measured memory_bytes: 12420
/*	AtCoder 2375 Closed Rooms
	1st Edition:2017.7.9 Sunday
	Algorithm:Greedy,BFS
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <cstdlib>
#include <ctime>
using namespace std;

#define For(a,b,c) for(int (a)=(b);(a)<=(c);a++)
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
const long double eps=1e-9;
const ll inf=1000000007LL;
const ll maxn=805LL;
const ll mod=1000000007LL;

//input
int n,m,k;
int sx,sy;
bool g[maxn][maxn];

void input(){
	cin>>n>>m>>k;
	For(i,1,n)
		For(j,1,m){
			char c;
			cin>>c;
			g[i][j]=(c!='#');
			if(c=='S'){
				sx=i;
				sy=j;
			}
		}
}

//BFS
int ans;
int vis[maxn][maxn];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};

void BFS(){
	queue<pii> q;
	ans=inf;
	q.push(mp(sx,sy));
	memset(vis,-1,sizeof(vis));
	vis[sx][sy]=0;
	while(!q.empty()){
		int x=q.front().first,y=q.front().second;
		q.pop();
		int tmp=min(min(n-x,x-1),min(m-y,y-1));
		if(x==0 || y==0 || x==n || y==m){
			ans=0;
			break;
		}
		ans=min(ans,(tmp+k-1)/k);
//		cout<<x<<" "<<y<<endl;
		if(vis[x][y]==k)
			continue;
		For(i,0,3){
			int nx=x+dx[i],ny=y+dy[i];
			if(nx<=0 || nx>n || ny<=0 || ny>m)
				continue;
			if(vis[nx][ny]!=-1 || !g[nx][ny])
				continue;
			vis[nx][ny]=vis[x][y]+1;
			q.push(mp(nx,ny));
		}
	}
}

//main
int main(){
	input();
	BFS();
	cout<<ans+1<<endl;
	return 0;
}


Measured memory_bytes: 3456
N = int(input())
 
input_list = []
tmplist = []
 
for i in range(N):
  input_list.append(int(input()))

sorted_list = sorted(input_list)

first_val = sorted_list[-1]
second_val = sorted_list[-2]

for i in input_list:
  if i == first_val:
    print(second_val)
  else:
    print(first_val)




Measured memory_bytes: 14112
using System;
using System.Linq;

namespace ABC154_C
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Trim().Split(' ').Select(a => int.Parse(a)).ToArray();
            Console.WriteLine();
            Array.Sort(A);
            for(int i = 0; i < N - 1; i++)
            {
                if (A[i]==A[i+1])
                {
                    Console.WriteLine("NO");
                    Environment.Exit(0);
                }
            }
            Console.WriteLine("YES");
        }
    }
}


Measured memory_bytes: 32988
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor_ct.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/strong_components.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/bellman_ford_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
using namespace std;
using namespace boost::math;

int main() {
	int N, Q;

	cin >> N >> Q;
    multimap<int, int> adj;
  
    REP(i, N-1) {
      int a, b;
      
      cin >> a >> b;
      adj.emplace(a, b);
      adj.emplace(b, a);
    }
  
    vector<long long> count(N+1, 0);
  
    REP(i, Q) {
      long long p, x;
      cin >> p >> x;
      
      count[p] += x;
    }
  
    auto dfs = [&](auto f, int n, int v, int p) -> void{
      auto it = adj.lower_bound(n), eit = adj.upper_bound(n);

      for (; it != eit; ++it) {
        if (it->second != p)
          f(f, it->second, v + count[n], n);
      }
      count[n] += v;
    };

    dfs(dfs, 1, 0, -1);
	cout << count[1];
    for (auto i : boost::irange(2, N+1))
      cout << " " << count[i];
  cout << endl;
 
	return 0;
}


Measured memory_bytes: 31104
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll> >
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll T;cin>>T;while(T--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define prll(a)                 cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,cur)               lower_bound(all(v),cur)-v.begin()
#define ub(v,cur)               upper_bound(all(v),cur)-v.begin()
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
long long pows(long long a, long long b) {
  long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD){if(m == 1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}
int main()
{
fastIO
ld rad;
cin>>rad;
ld pi=3.14159265359;
ld cir=2*pi*rad;
cout<<setprecision(9)<<cir;
}


Measured memory_bytes: 3808
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
  	Scanner sc = new Scanner(System.in);
    String t = sc.next();
    t = t.replace("P?","PD");
    t = t.replace("?D","PD");
    t = t.replace("??","PD");
    t = t.replace("?","D");
    System.out.println(t);
  }
}

Measured memory_bytes: 42132
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main()
{
    int m,n;
    cin >> n >> m;
    cout << (n*(n-1))/2 + (m*(m-1))/2 << endl;
}


Measured memory_bytes: 256
n = gets.to_s.to_i
s = gets.to_s.chomp.chars

ans = s.count('R') * s.count('G') * s.count('B')
n.times do |i|
  t = 1
  while i + 2 * t < n
    j = i + t
    k = j + t
    ans -= 1 if s[i] != s[i+t] && s[i+t] != s[i+2*t] && s[i] != s[i+2*t]
    t += 1
  end
end

puts ans

Measured memory_bytes: 14340
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

const int maxn = 1e5+5;
const LL MOD = 1e9+7;

LL F[maxn], invF[maxn], inv[maxn];

void init() {
    inv[1] = 1;
    for(int i = 2; i < maxn; ++i)
        inv[i] = (MOD - MOD / i) * 1LL * inv[MOD % i] % MOD;
    F[0] = invF[0] = 1;
    for(int i = 1; i < maxn; ++i) {
        F[i] = F[i-1] * 1LL* i % MOD;
        invF[i] = invF[i-1] * inv[i] % MOD;
    }
}

LL comb(int n, int m) {   // C(n, m)
    if(m < 0 || m > n) return 0;
    return F[n] * invF[n-m] % MOD * invF[m] % MOD;
}

void run_case() {
    init();
    int n, k;
    cin >> n >> k;
    vector<LL> a(n);
    LL ans = 0;
    for(auto &x: a) cin >> x;
    sort(a.begin(), a.end(), greater<LL>());
    for(int i = 0; i <= n-k; ++i) {
        (ans += comb(n-i-1, k-1)*a[i] % MOD) %= MOD;
    }
    sort(a.begin(), a.end());
    for(int i = 0; i <= n-k; ++i) {
        (ans -= comb(n-i-1, k-1)*a[i] % MOD) %= MOD;
    }
    cout << (ans + MOD) % MOD;
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

int main(){
	ll N;
	cin >> N;
	vector<ll> A(N);
	vector<ll> B(N);
	REP(i, N){
		cin >> A[i];
		B[i] = A[i];
	}
	sort(A.begin(),A.end());
	REP(i, N){
		if(A[N-1] == B[i]){
			cout << A[N-2] << endl;
		}else{
			cout << A[N-1] << endl;
		}
	}
}

Measured memory_bytes: 4736
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define lowbit(x) x&(-x)
#define PII  pair<int, int> 
#define FAST ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e5 + 5;
using namespace std;

int p[11], c[11];

int main()
{
	int D, G; scanf("%d %d", &D, &G);
	for(int i = 0; i < D; i++) scanf("%d %d", p + i, c + i);
	int ans = inf;
	for(int i = 0; i < (1 << D); i++){
		ll sum = 0;
		int cnt = 0;
		for(int j = 0; j < D; j++){
			if((i >> j) & 1){
				sum += p[j] * (j + 1) * 100 + c[j];
				cnt += p[j];
			}
		}
		for(int j = D - 1; j >= 0; j--){
			if((i >> j) & 1) continue;
			if(sum >= G) continue;
			int q = min((G - sum)/((j + 1) * 100), (ll)p[j]);
			cnt += q;
			sum += (j + 1) * 100 * q;
		}
		if(G <= sum) ans = min(ans, cnt);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256