akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;

class Reader 
{
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    static void init(InputStream input) 
    {
        reader = new BufferedReader(new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }
   
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) 
        {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}

class Main
{
	public static void main( String[] args ) throws IOException
	{
		Reader.init(System.in);
		long x = Reader.nextInt();
		long a = Reader.nextInt();
		long b = Reader.nextInt();
		
		if ( a < x )
		{
			if ( b <= a )
			{
				System.out.println("delicious");
			}
			else if ( a + x < b )
			{
				System.out.println("dangerous");
			}
			else
			{
				System.out.println("safe");
			}
		}
		else
		{
			//System.out.println((a+x)+"  "+(a-x));
			if ( a + x < b ) 
					//|| ( b < x && a-x < b ) )
			{
				System.out.println("dangerous");
			}
			else if ( b >= a-x && a >= b )
			{
				System.out.println("delicious");
			}
			else
			{
				System.out.println("safe");
			}
		}
	}
}


Measured memory_bytes: 21076
#include <stdio.h>

int main(void)
{
  int x, a, b;
  scanf("%d %d %d", &x, &a, &b);

  int dista, distb;
  dista = x - a;
  distb = x - b;

  if (dista < 0)
  {
        dista = -1 * dista;
  }
  if (distb < 0)
  {
        distb = -1 * distb;
  }

  if (dista < distb)
  {
        printf("A\n");
  }
  else
  {
        printf("B\n");
  }

  return 0;
}


Measured memory_bytes: 128
n = [int(x) for x in input()]
op_cnt = len(n) - 1
for i in range(2**op_cnt):
  op = ["-"] * op_cnt #for文の中にあるよ！
  for j in range(op_cnt):
    if((i>>j) & 1): #もしフラグが立ってたら、"+"になるようにする。つまり、1="+", 0="-"
      op[op_cnt -1 -j] = "+"  #j桁目が１だったら、j桁目(要素番号は全体-1-j)を"+"に変更
  formula = ""
  for z_n, z_op in zip(n,op + [""]):
    formula += (str(z_n) + z_op)
  if eval(formula) == 7:
    print(formula + "=7")
    break



Measured memory_bytes: 3064
#!/usr/bin/python3
# -*- coding: utf-8 -*-


MOD = 1000000007


def main():
  N,M = map(int, input().split())
  Sn = list(map(int, input().split()))
  Tn = list(map(int, input().split()))

  ## dp[n][m] := Snの先頭nコ、Tnの先頭mコでの組み合わせ総数
  dp = [[1 for m in range(M+1)] for n in range(N+1)]

  for n in range(N):
    for m in range(M):
      if Sn[n]==Tn[m]:
        dp[n+1][m+1] = (dp[n][m+1]+dp[n+1][m]) % MOD
      else:
        dp[n+1][m+1] = (dp[n][m+1]+dp[n+1][m]-dp[n][m]) % MOD
  print(dp[N][M])


if __name__ == "__main__":
  main()

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  priority_queue<ll> a;
  ll n;cin>>n;
  string s,t;cin>>s>>t;
  if(s[0]==t[0])res=3;
  else res=6;
  for(i=1;i<n;i++){
    if(s[i]==t[i]){
      if(s[i-1]==t[i-1])qmod(res,2);
    }
    else{
      if(s[i-1]==t[i-1]){
        qmod(res,2);
      }
      else if(s[i]!=s[i-1]){
        qmod(res,3);
      }
    }
    //cout<<res<<endl;
  }
  cout<<res<<endl;
  


  return 0;
}

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

int main(){
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    ll p[100005]={};
    ll q[100005]={};
    ll r[100005]={};
    REP(i,a)cin>>p[i];
    REP(i,b)cin>>q[i];
    REP(i,c)cin>>r[i];
    sort(p,&p[a],std::greater<ll>());
    sort(q,&q[b],std::greater<ll>());
    sort(r,&r[c],std::greater<ll>());
    ll sum=0;
    ll anum=min(x,a);
    ll bnum=min(y,b);
    ll cnum=x-anum+y-bnum;
    REP(i,anum)sum+=p[i];
    REP(i,bnum)sum+=q[i];
    REP(i,cnum)sum+=r[i];
    int flag=0;
    while(!flag){
        if(cnum>=c){
            flag=1;break;
        }
        if(anum==0 && bnum==0){
            flag=1;break;
        }
        ll cha;
        if(anum==0){
            cha=q[bnum-1];
        }
        else if(bnum==0){
            cha = p[anum-1];
        }
        else{
            ll rb = p[anum-1];
            ll bb = q[bnum-1];
            cha = min(rb,bb);
            
            //cout<<rb<<bb<<cha<<endl;
        }
        ll cf = r[cnum];
        //cout<<"##"<<cf<<endl;
        if(cha>=cf){
            flag=1;break;
        }
        sum = sum -cha+cf; cnum++;
        if(anum==0){
            bnum--;
        }
        else if(bnum==0){
            anum--;
        }
        else{
            ll rb = p[anum-1];
            ll bb = q[bnum-1];
            if(cha==rb)anum--;
            else bnum--;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;

  int sum = 0;
  for(int i=0;i<2;i++){
    if(A > B){
      sum += A;
      A--;
    }
    else{
      sum += B;
      B--;
    }
  }
  cout << std::setprecision(20);
  cout << sum << endl;
}


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

long long intersect(long long st1, long long en1,
                    long long st2, long long en2)
{
    if (st1 > st2)
        swap(st1, st2), swap(en1, en2);
    if (en1 < st2)
        return 0;
   
    return min(en1, en2) - st2 + 1;
}

int main(void)
{
    long long a, b;
    cin >> a >> b;
    
    if (a == b) {
        cout << 1 << endl;
        return 0;
    }
    
    for (long long i = 1LL << 60; i; i >>= 1) {
        if ((a & i) and (b & i))
            a ^= i, b ^= i;
        
        if ((a & i) not_eq (b & i)) {
            if (a > b) swap(a, b);
            
            for (long long j = i; j; j >>= 1) {
                if (i + j > b) continue;
                
                long long sg1 = (i - 1) - (a - 1),
                          sg2 = (i + (j << 1) - 1) - (i - 1),
                          sg3 = ((i << 1) - 1) - (i + a - 1);
                
                cout << sg1 + sg2 + sg3 - intersect(i, i + (j << 1) - 1, i + a, (i << 1) - 1) << endl;
                return 0;
            }
            
            long long sg1 = (i - 1) - (a - 1),
                      sg2 = i - (i - 1),
                      sg3 = ((i << 1) - 1) - (i + a - 1);
            
            cout << sg1 + sg2 + sg3 - intersect(i, i, i + a, (i << 1) - 1) << endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  char a[2]="A",s1[2],s2[2];
  while(scanf("%1s,%1s",s1,s2)!=EOF){
    if(a[0]==s1[0])
      a[0]=s2[0];
    else if(a[0]==s2[0])
      a[0]=s1[0];
  }
  printf("%s\n",a);
  return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

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

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

const long long INF = 10000000000;

const int M = 100010;
long long h[M];

long long dp[M];

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

    rep(i, N) cin >> h[i];
    rep(i, M) dp[i] = INF;

    dp[0] = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    cout << dp[N - 1] << endl;
}


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

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

	const int mod = 1e9 + 7;
	int dx[] = {1, 0}, dy[] = {0, 1};
	int h, w;
	cin >> h >> w;
	vector<string> g(h);
	for(int i = 0; i < h; i++) {
		cin >> g[i];
	}
	vector<vector<long long>> dp(h, vector<long long>(w));
	vector<vector<bool>> vis(h, vector<bool>(w, false));
	vis[0][0] = true;
	dp[0][0] = 1;
	queue<pair<int, int>> que;
	que.push(make_pair(0, 0));
	while(!que.empty()) {
		int x = que.front().first;
		int y = que.front().second;
		que.pop();
		for(int i = 0; i < 2; i++) {
			int xx = x + dx[i];
			int yy = y + dy[i];
			if(xx >= h || yy >= w || g[xx][yy] == '#') continue;
			dp[xx][yy] += dp[x][y];
			dp[xx][yy] %= mod;
			if(!vis[xx][yy]) que.push(make_pair(xx, yy));
			vis[xx][yy] = true;
		}
	}
	cout << dp[h - 1][w - 1] << endl;
	return 0;	
}

Measured memory_bytes: 9344
from collections import defaultdict

n, m = map(int, input().split())

d = defaultdict(int)
res_ans = 0
res_pena = 0

for _ in range(m):
    p, s = input().split()
    if s == "AC":
        if d[p] == -1:
            continue
        else:
            res_ans += 1
            res_pena += d[p]
            d[p] = -1
    else:
        if d[p] == - 1:
            continue
        else:
            d[p] += 1

print(res_ans, res_pena)

Measured memory_bytes: 17492
#include <bits/stdc++.h>
using namespace std;
     
#define int  long long
#define endl '\n'
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e5 + 11;

void solve(){
  int n;
  string s;
  cin >> n >> s;
  map<char, int> m;
  for(auto it : s)
    m[it]++;
  int ret = 1;
  for (auto it : m){
    ret *= (it.second + 1);
    ret %= MOD;
    }	
  ret = (ret - 1 + MOD) % MOD;
  cout << ret << endl;
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  solve();	
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
string s;
char ans[200007][7];
char anss[200007][7];
int main(){
    cin>>s;
    int n=s.size();
    int sta=0;
    int cnt=1;
    int flag=0;
    ans[cnt][0]=s[0];
    for(int i=1;i<n;++i){
        if(s[sta]==s[i]&&flag==0){
            if(i+1<n){
                cnt++;
                flag=1;
                i++;
                ans[cnt][0]=s[i-1];
                ans[cnt][1]=s[i];
            }
            else{
                if(i==1){
                    cnt--;
                    flag=2;
                }
            }
        }
        else if(s[sta]!=s[i]&&flag==0){
            cnt++;
            sta=i;
            ans[cnt][0]=s[i];
        }
        else if(flag==1){
            cnt++;
            sta=i;
            flag=0;
            ans[cnt][0]=s[i];
        }
    }
    if(flag==2){
        sta=n-1;
        int cntt=1;
        flag=0;
        anss[cntt][0]=s[n-1];
        for(int i=n-2;i>=0;--i){
            if(s[sta]==s[i]&&flag==0){
                if(i>0){
                    cntt++;
                    flag=1;
                    i--;
                    anss[cntt][0]=s[i+1];
                    anss[cntt][1]=s[i];
                }
                else{
                    if(i==n-2)
                        cntt--;
                }
            }
            else if(s[sta]!=s[i]&&flag==0){
                cntt++;
                sta=i;
                anss[cntt][0]=s[i];
            }
            else if(flag==1){
                cntt++;
                sta=i;
                flag=0;
                anss[cntt][0]=s[i];
            }
        }
        cnt=max(cnt,cntt);
    }
    cout<<cnt;
    return 0;
}


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

int main() {
	int a, b, c; cin >> a >> b >> c;
	if(a > b) swap(a, b);
	if(b > c) swap(b, c);
	if(a > b) swap(a, b);
	int res;
	if(a % 2 != b % 2) {
		res = 1;
		a++;
		c++;
	}
	else res = 0;
	cout << (2 * c - a - b) / 2 + res << 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 pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
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; }

struct UnionFind {
    vector<int> par;
    vector<int> sz;
 
    UnionFind(int n=0){ if(n>0) initialize(n); }
    void initialize(int n){
        par.resize(n);
        sz.assign(n, 1);
        for(int i=0; i<n; i++){
            par[i] = i;
        }
    }
 
    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }
 
    bool unite(int x, int y){
        x = find(x), y = find(y);
        if(x == y) return false;
        if(sz[x] > sz[y]) swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
        return true;
    }
 
    bool same(int x, int y){ return find(x) == find(y); }
    int size(int x){ return sz[find(x)]; }
};

int main(int argc, char const *argv[]) {
  int n, m;
  cin >> n >> m;
  int x, y;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  UnionFind uf(n);
  rep(i,m){
    cin >> x >> y;
    x--, y--;
    uf.unite(x, y);
  }
  int ans = 0;
  rep(i,n){
    if (uf.same(p[i]-1, i)) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4572
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}

int main() {
  LL X;
  cin >> X;
  LL ans = ceil((double)(-1 + sqrt(1 + 8 * X)) / 2);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a;
    cin>>a;
    cout<<(a*a)+(a*a*a)+a<<endl;

    return 0;
}


Measured memory_bytes: 3648
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    abs_A = list(map(abs, A))
    neg_cnt = sum([1 if a < 0 else 0 for a in A])
    if neg_cnt % 2 == 0:
        print(sum(abs_A))
    else:
        abs_A.sort()
        print(sum(abs_A) - 2 * abs_A[0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 14284
nxm = list(map(int,input().split()))

matrix = []
vector = []

for i in range(nxm[0]):
    matrix.append(list(map(int,input().split())))
    
for k in range(nxm[1]):
    vector.append(int(input()))
    

for n in range(nxm[0]):
    ans = 0
    for m in range(nxm[1]):
        ans += matrix[n][m]*vector[m]       
    print(ans)
    
    


Measured memory_bytes: 6008
use proconio::{input, fastout};
use std::collections::{HashMap, BTreeMap};
use std::fmt::Write;

#[fastout]
fn main() {
    input! {
        _n: usize,
        m: usize,
        py: [(usize, usize); m],
    }

    let mut nums = vec![None; m];

    let mut prefectures = HashMap::new();
    
    for (i, (p, y)) in py.into_iter().enumerate() {
        prefectures.entry(p).or_insert_with(|| BTreeMap::new()).insert(y, i);
    }

    for (prefecture, cities) in prefectures {
        for (i, (_year, order)) in cities.into_iter().enumerate() {
            nums[order] = Some(format!("{:06}{:06}", prefecture, i+1));
        }
    }

    let mut ans = String::new();
    for num in nums {
        if let Some(num) = num {
            writeln!(ans, "{}", num).unwrap();
        } else {
            unreachable!();
        }
    }
    print!("{}", ans);
}


Measured memory_bytes: 31772
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;

using namespace std;

int main() 
{
    int n;
    cin >> n;
    v_int a(n);
    int m = INF;
    int ans = 0;

    irep(i, n) { 
        int tmp;
        cin >> tmp;
        m = min(m, tmp);
        if(m >= tmp) {
            ans++;
        }
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define mod 1000000007
#define INF2 9999999999
#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)

using namespace std;
using ll = __int64_t;

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

void solve(){
    int N, K;
    cin >> N >> K;
    cout << N - K + 1<< endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = ['0']*N
for i in range(N):
  S[i] = input()
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
  if S[i] == 'AC':
    AC = AC+1
  elif S[i] == 'WA':
    WA = WA+1
  elif S[i] == 'TLE':
    TLE = TLE+1
  else:
    RE = RE+1
print('AC x ',end='')
print(AC)
print('WA x ',end='')
print(WA)
print('TLE x ',end='')
print(TLE)
print('RE x ',end='')
print(RE)

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

typedef long long ll;
const ll MOD = 1000000007ll;
const int N_DIGITS = 60;
ll L[N_DIGITS], R[N_DIGITS];
ll Dp[1 + N_DIGITS][2][2][2]; // これまでで L<x, y<R, x,y>0 が 不成立/成立
const bool Bs[2] = {false, true};

void go(ll &tgt, ll src) { (tgt += src) %= MOD; }
int main() {
  ll l, r;
  cin >> l >> r;
  for (int i = N_DIGITS - 1; i >= 0; --i) {
    L[i] = l % 2;
    R[i] = r % 2;
    l /= 2;
    r /= 2;
  }
  Dp[0][0][0][0] = 1;
  for (int i = 0; i < N_DIGITS; ++i) {
    for (bool overL : Bs) {
      for (bool underR : Bs) {
        for (bool some : Bs) {
          ll src = Dp[i][overL][underR][some];
          // 0,0
          if (overL || L[i] == 0) {
            go(Dp[i + 1][overL][underR || R[i] == 1][some], src);
          }
          // 0,1
          if ((overL || L[i] == 0) && (underR || R[i] == 1) && some) {
            go(Dp[i + 1][overL][underR][true], src);
          }
          // 1,1
          if (underR || R[i] == 1) {
            go(Dp[i + 1][overL || L[i] == 0][underR][true], src);
          }
        }
      }
    }
  }
  ll res = 0;
  for (bool overL : Bs) {
    for (bool underR : Bs) {
      for (bool some : Bs) {
        (res += Dp[N_DIGITS][overL][underR][some]) %= MOD;
      }
    }
  }
  cout << res << endl;
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];
    int b[n - 1];

    int i = 0;
    ll ans = 0;

    while (i < n - 1){
        if (a[i] < a[i + 1]){
            while (a[i] <= a[i + 1]) i++;
            if(i < n - 1) ans ++;
        }
        else if (a[i] > a[i + 1]){
            while (a[i] >= a[i + 1]) i++;
            if(i < n - 1) ans ++;
        }
        i++;
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 1024
n=int(input())
x=[0]*n
y=[0]*n
sum=0

for i in range(n):
    x[i],y[i]=map(int,input().split())

for i in range(n):
    for j in range(n):
        if j!=i:
            sum+=((x[i]-x[j])**2+(y[i]-y[j])**2)**0.5

print(sum/n)

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

int ctoi(char c){
  return(c-'0');
}

int main(){
  string s;
  cin >> s;
  int m, v;
  v = 100 * ctoi(s.at(0)) + 10 * ctoi(s.at(1)) + ctoi(s.at(2));
  m = max(v,753)-min(v,753);
  for(int i = 1; i < s.size()-2; i++){
    int x, d;
    x = 100 * ctoi(s.at(i)) + 10 * ctoi(s.at(i+1)) + ctoi(s.at(i+2));
    d = max(x,753)-min(x,753);
    if(d < m){
      m = d;
    }
  }
  cout << m;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,i,cnt=0,ck;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    while(1){
        ck=0;
        for(i=0;i<n;i++){
            if(a[i]%2==0){
                ck++;
            }
            else{
                break;
            }
        }
        if(ck==n){
            for(i=0;i<n;i++){
                 a[i]=a[i]/2;
            }
            cnt++;
        }
        else{
            break;
        }
    }
    cout<<cnt<<endl;
    return 0;

}

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

typedef long long i64;
const int MAX_N = 205, MOD = 1000000007;

i64 fac[MAX_N], inv[MAX_N], ifac[MAX_N];
i64 result = 0;

int N, K;
char S[MAX_N];

i64 binom(int n, int m) {
  if (n < m) return 0;
  return fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;
}

int tot = 0, pos[MAX_N], st[MAX_N];

bool check() {
  static bool vis[105];
  static int posb[105];
  memset(vis, 0, sizeof vis);
  for (int i = 1; i <= tot; ++i)
    if (pos[i])
      vis[pos[i]] = 1;
    else
      return false;
  for (int i = 1, j = 1; i <= tot; ++i) {
    j = max(j, pos[i]);
    if (st[i] == 1) break;
    while (j <= K && S[j] != 'b') j++;
    if (j > K) return false;
    vis[j] = 1, j++;
    posb[i] = j;
  }
  for (int i = 1, j = 1; i <= tot; ++i) {
    int cnt = st[i] - 2;
    j = max(j, posb[i]);
    while (cnt > 0 && j <= K) {
      if (!vis[j]) cnt--;
      vis[j] = 1, j++;
    }
    if (cnt > 0) return false;
  }
  return true;
}

void dfs(int rest, int restN, int lim) {
  if (restN < 0 || rest < 0) return;
  if (rest >= 0) {
    if (!check()) return;
    i64 now = fac[tot];
    int cnt = 0, sum_len = 0;
    for (int i = 1; i <= tot; ++i) {
      if (st[i] == 1) {
	now = now * ifac[tot - i + 1] % MOD;
	sum_len += tot - i + 1;
	break;
      } else {
	int j = i, num = 0;
	while (st[j + 1] == st[i]) j++;
	num = j - i + 1, cnt += num, sum_len += num * (st[i] * 2 - 3);
	now = now * ifac[num] % MOD;
	i = j;
      }
    }
    assert(sum_len == N - restN);
    i64 temp = 0;
    for (int i = 0; i <= N - sum_len; ++i) {
      int l = sum_len + i;
      temp = (temp + now * binom(cnt * 2, i) % MOD * binom(N + 1, l + tot) % MOD) % MOD;
    }
    result = (result + temp) % MOD;
  }
  for (int i = lim; i; --i) {
    st[++tot] = i;
    dfs(rest - i, restN - max(i * 2 - 3, 1), i);
    tot--;
  }
}

int main() {
  fac[0] = ifac[0] = inv[1] = 1;
  for (int i = 1; i < MAX_N; ++i) fac[i] = fac[i - 1] * i % MOD;
  for (int i = 2; i < MAX_N; ++i) inv[i] = -(MOD / i) * inv[MOD % i] % MOD;
  for (int i = 1; i < MAX_N; ++i) ifac[i] = ifac[i - 1] * inv[i] % MOD;
  
  scanf("%d%d", &N, &K);
  scanf("%s", S + 1);
  
  for (int i = 1, temp = 0; i <= K; ++i)
    if (S[i] == 'r') pos[++temp] = i;

  dfs(K, N, K);

  printf("%lld\n", (result + MOD) % MOD);
  return 0;
}


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

int main(void)
{
  int l,r,d,sum=0;
  
  scanf("%d%d%d", &l,&r,&d);
  
  for(int i = l;i<=r;i++){
    if(i%d==0)
      sum++;
  }
  
  printf("%d", sum);
  
  return 0;
  
    
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,W;cin>>N>>W;int v[N],w[N];
  for(int i=0;i<N;i++)cin>>w[i]>>v[i];
  long long int dp[N+1][W+1];
  for(int i=0;i<=W;i++)dp[0][i]=0;
  for(int i=1;i<=N;i++)dp[i][0]=0;
  for(int i=1;i<=N;i++){
    for(int j=1;j<w[i-1];j++)dp[i][j]=dp[i-1][j];
    for(int j=w[i-1];j<=W;j++)dp[i][j]=max(v[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
  }
  cout<<dp[N][W]<<endl;
}

Measured memory_bytes: 79104
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
#include<ctime>

using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0)
#define ll long long
#define ull unsigned ll 
#define pb push_back

#define endl '\n'
#define mod 1000000007

#define FOR(i,k,n) for(int i=k; i<n; i++)
#define ROF(i,k,n) for(int i=k; i>=n; i--)
#define MEMSET(t) memset(t,0,sizeof(t));
#define time clock_t tStart
#define Start clock()
#define Time printf("Time taken: %.3fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC)



ll minC(int ar[], int n,int k, ll dp[], int i)  
{
  if(i>=n) return 0;
  if(i==n-1) return 0;
  if(dp[i]!=-1) return dp[i]; 

  int t=n;
    ll mini=INT_MAX;
  for(int j=i+1; j<=i+k && j<n ; j++) 
  {
    mini= min( abs(ar[i]-ar[j])+minC(ar,n,k,dp,j), mini); 
  //  cout<<mini<<" "<<i<<" "<< j<<endl;
  }
   dp[i] = mini;
   return dp[i];
  //return 0
}

int main()
{
  fastio; 
  int t=1;
  while(t--)
  {
    int n,k;
    cin>>n>>k;

    int ar[n];
    ll dp[n+1];
    FOR(i,0,n) cin>>ar[i];
    memset(dp,-1,sizeof(dp));
    cout<<minC(ar,n,k,dp,0);

  }
  return 0;
}   

Measured memory_bytes: 14128
<?php

$input = trim(fgets(STDIN));
$numbers = explode(" ", $input);

$input = trim(fgets(STDIN));
$dirs  = str_split($input);

$dice = new Dice($numbers);

foreach ($dirs as $dir) {
    $dice->roll($dir);
}

echo $dice->getNumber("T") . PHP_EOL;

//========================================

class Dice
{
  private $numbers;
  private $IDX_ROLL = array(
    array(4, 0, 2, 3, 5, 1),  // -> S
    array(3, 1, 0, 5, 4, 2),  // -> E
    array(2, 1, 5, 0, 4, 3),  // -> W
    array(1, 5, 2, 3, 0, 4)   // -> N
  );

  public function __construct($numbers)
  {
    $this->numbers = $numbers;
  }

  public function roll($dirs)
  {
    foreach (str_split($dirs) as $dir) {
      $idx = strpos("SEWN", $dir);
      if ($idx === false) {
        continue;
      }

      $old = $this->numbers;
      for ($i = 0; $i < 6; $i++) {
        $this->numbers[$i] = $old[$this->IDX_ROLL[$idx][$i]];
      }
    }
  }

  public function getNumber($dir) {
    $idx = strpos("TSEWNB", $dir);
    if ($idx !== false) {
      return $this->numbers[$idx];
    }
    return false;
  }

  public function getDirection($number) {
    $idx = array_search($number, $this->numbers);
    if ($idx !== false) {
      return "TSEWNB"[$idx];
    }
    return false;
  }
}

Measured memory_bytes: 15496
# -*- coding: utf-8 -*-
import sys;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

# 整数の入力
#n = int(input())

# スペース区切りの整数の入力
#a = [x for x in map(int, input().split())]
n, m = map(int, input().split())

# 改行区切りの整数の入力
#a = []
#for x in range(n):
#  a.append(int(input()))

# 文字列の入力
#s = input()

# 出力
#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(a, file=sys.stderr)

#surfixes = ("dream", "dreamer", "erase", "eraser")

def doit():
  ma = 0
  mi = 100000 + 1
  for i in range(m):
    l, r = map(int, input().split())
    print(l, r, file=sys.stderr)
    ma = max(ma, l)
    mi = min(mi, r)
    print(ma, mi, file=sys.stderr)
  if ma > mi:
    print("0")
  else:
    print(mi - ma + 1)
  
try:
  doit()
except Exception as e:
  print(e, file=sys.stderr)


Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	var ans int
	n := getNextInt(scanner)
	for i := 0; i < n; i++ {
		a := getNextInt(scanner)
		if i%2 == 0 {
			if a%2 == 1 {
				ans++
			}
		}
	}
	fmt.Fprintln(writer, ans)
}


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

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n,m,i,j,k,sum=0;
    cin>>n;
    vector<int> a(n);
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=n-1;i>=1;i--){
        if(a[i-1]<=a[i]){
            continue;
        }
        else if(a[i-1]-1<=a[i]){
            a[i-1]--;
        }
        else {
            cout<<"No"<<'\n';
            return 0;
        }
    }
    cout<<"Yes"<<'\n';


    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;

int main(){
  int x,a,b; cin>>x>>a>>b;
  if(a>=b){
    cout<<"delicious"<<endl;
  }else if(a+x>=b){
    cout<<"safe"<<endl;
  }else{
    cout<<"dangerous"<<endl;
  }

}

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

int main(){
    int N, D[50];
    cin >> N;
    for(int i=0; i<N; i++) cin >> D[i];
    int ans = 0;
    for(int i=0; i<N; i++) for(int j=0; j<i; j++) ans += D[i]*D[j];
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int MAX = 200000;

int main() {
  ll n, k;
	cin >> n;
  vector<ll> a;
  map<ll,ll> m;
  rep(i,n) {
    cin >> k;
    a.push_back(k);
    auto itr = m.find(k);
    if (itr == m.end()) {
      m.insert(make_pair(k, 1));
    } else {
      m[k] = itr->second + 1;
    }
  }
  ll sum = 0;
  for(auto itr = m.begin(); itr != m.end(); ++itr) {
    ll t = itr->second;
    if(t > 1) {
      sum += t * (t-1) / 2;
    }
  }
  rep(i,n) {
    cout << sum - m[a.at(i)] + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 11120
#include<iostream>
#include<vector>
#include<set>
#include<string.h>
using namespace std;

set<string> dict[26];

int main(){
	int n,k;
	scanf("%d %d",&n,&k);getchar();
	
	int jumlahGrup = n/k;
	
	int soal[jumlahGrup+1][27];
	memset(soal, 0, sizeof(soal));
	
	string s;
	for(int i = 0;i<n;i++){
		getline(cin,s);
		dict[s[0]-'A'].insert(s);
	}
	
	int satu = 0;
	int z =0;
	for(int i = 0;i<26;i++){
		int size = dict[i].size();
		
		int sdhah = 0;
		int y=0;
		while(y<size){
			if(sdhah == jumlahGrup) break;
			if(z == jumlahGrup) z = 0;
			if(!soal[z][i]) {
				soal[z][i] = 1;
				sdhah++;	
			}
			z++;y++;
		}
	}
	
	int grupjadi = 0;
	for(int c = 0;c<jumlahGrup;c++){
		int tot = 0;
		for(int i = 0;i<26;i++){
//			cout<<soal[c][i]<<" ";
			if(soal[c][i]){
				tot++;
			}
		}
//		cout<<"\n";
		if(tot >= k) grupjadi++;
		else{
			int selisih = k - tot;
			for(int f = c;f<jumlahGrup;f++){
				if(selisih<=0) break;
				if(f!=c){
					for(int u = 0;u<26;u++){
						if(soal[c][u] == 0 && soal[f][u]==1) {
							selisih--;soal[f][u] = 0;
							
						}
					}
				}
			}
			if(!selisih) grupjadi++;
		}
//		cout<<tot<<"t\n";
	}
	
	printf("%d\n",grupjadi);
	return 0;
	
}

Measured memory_bytes: 2304
N = int(input())
A = [0]*N
for i in range(N):
    A[i] = int(input())
AA = sorted(A, reverse=True)
no1 = AA[0]
no2 = AA[1]
for i in A:
    if i == no1:
        print(no2)
    else:
        print(no1)


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

int main()
{
	int n, m;
	cin >> n >> m;
	map<int, int> M;
	int k;
	int a;
	for (int i = 0; i < n; ++i)
	{
		cin >> k;
		for (int j = 0; j < k; ++j)
		{
			cin >> a;
			++M[a];
		}
	}
	int ans = 0;
	for (int i = 1; i <= m; ++i)
	{
		ans += (M[i] == n);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
s = int(input())
mod = 10**9+7
 
dp = [0]*(s+1)
dp[0] = 1
for i in range(1,s+1):
  for j in range(0,(i-3)+1):
    dp[i] += dp[j]
    dp[i] %= mod
    
print(dp[s])

Measured memory_bytes: 9136
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define read(a) scanf("%d", &a)
#define readl(a) scanf("%lld", &a)
#define reads(a) scanf("%s", a)
#define readf(a) scanf("%lf", &a)
#define readc(a) scanf("%c", &a)
#define debug(a, b) printf("%s = %d\n", a, b)
#define debug1(a, i, b) printf("%s[%d] = %d", a, i, b)
#define show(a) putchar(a)
#define pb emplace_back
#define mk make_pair
#define _rand mt19937 RAND(time(0))
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define mem(a) memset(a, 0, sizeof(a))
#define Buff ios::sync_with_stdio(false)
typedef long long ll;
typedef long long LL;
typedef int Int;
typedef double db;
using namespace std;
const int INF = 1e9 + 7;
const int N = 2e5 + 7;
const int M = 5e6 + 7;
char s[N];
ll dp[N];
signed main()
{
    int n, p;
    read(n); read(p);
    reads(s + 1);

    ll ans = 0;
    if(p == 2 || p == 5)
    {
        for(int i = n; i; i--)
            if((s[i]-'0') % p == 0)
                ans += 1ll*i;
    }
    else
    {
        ll d = 1, x = 0;
        for(int i = n; i; i--)
        {
            x += (s[i]-'0') * d;
            x %= p;

            d *= 10;
            d %= p;

            ans += dp[x];
            dp[x]++;
            if(x == 0) ans++;
        }
    }
    printf("%lld\n", ans);
    return 0;
}
/**

**/



Measured memory_bytes: 4040
#include <iostream>
#include <vector>

using namespace std;

#define P(a,n) for (int k = 0; k < n; k++) printf("%d ", a[k]);

int main(){
    int n, r;
    while (cin >> n >> r && n && r) {
        vector<int> pct(n);
        for (int i = 0; i < n; i++) { pct[i] = n-i; }
        for (int i = 0; i < r; i++) {
            int p, c; cin >> p >> c;
            vector<int> tmp1(c);
            vector<int> tmp2(p-1);
            for (int j = 0; j < c; j++) tmp1[j] = pct[p+j-1];
            for (int j = 0; j < p-1; j++) tmp2[j] = pct[j];
            for (int j = 0; j < p-1; j++) pct[c+j] = tmp2[j];
            for (int j = 0; j < c; j++) pct[j] = tmp1[j];
        }
        cout << pct[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
	string s;
	cin >> s;
	int ans = 0;
	rep(i, s.length()/2)
		ans += s[i] != s[s.length() - 1 - i];
	cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import bisect
import heapq
import itertools
import math
import numpy as np
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

n,k = MI()
li = []
for i in range(k):
    d = int(input())
    a = LI()
    li += a
a = set(li)
print(n-len(a))


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

const ll MOD = 1e9 + 7;

ll modPow(ll a, ll x) {
  if (x == 0) return 1;
  if (x == 1) return a;
  ll temp = modPow(a, x / 2);
  ll ans = (temp * temp) % MOD;
  if (x % 2 == 1) ans = (ans * a) % MOD;
  return ans;
}

ll modInv(ll a) {
  return modPow(a, MOD - 2);
}

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

  ll N; cin >> N;
  ll K; cin >> K;

  ll cnt_p = 0, cnt_0 = 0, cnt_n = 0;
  vector<ll> A(N, 0);
  vector<pair<ll, ll>> ab(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] > 0) {
      cnt_p++;
      ab[i] = {abs(A[i]), 1};
    } else if (A[i] == 0) {
      cnt_0++;
      ab[i] = {abs(A[i]), 0};
    } else if (A[i] < 0) {
      cnt_n++;
      ab[i] = {abs(A[i]), -1};
    }
  }
  sort(ab.rbegin(), ab.rend());

  ll new_cnt_p = 0, new_cnt_0 = 0, new_cnt_n = 0;
  ll new_last_p = 0, new_last_n = 0;
  for (ll i = 0; i < K; i++) {
    if (ab[i].second == -1) {
      new_cnt_n++;
      new_last_n = ab[i].first;
    } else {
      new_last_p = ab[i].first;
    }
  }

  if (new_cnt_n % 2 == 0 || N == K) {
    ll ans = 1;
    for (ll i = 0; i < K; i++) {
      ans = (ans * ab[i].first * ab[i].second) % MOD;
      ans = (ans + MOD) % MOD;
    }
    cout << ans << '\n';
    return 0;
  }

  if (cnt_p == 0 && cnt_0 > 0) {
    cout << 0 << '\n';
    return 0;
  }
  if (cnt_p == 0 && cnt_0 == 0) {
    sort(ab.begin(), ab.end());
    ll ans = 1;
    for (ll i = 0; i < K; i++) {
      ans = (ans * ab[i].first) % MOD;
      ans = (-ans + MOD) % MOD;
    }
    cout << ans << '\n';
    return 0;
  }

  ll next_p = 0, next_n = 0, prev_p = 0, prev_n = 0;
  if (new_cnt_p < cnt_p) {
    for (ll i = K; i < N; i++) {
      if (ab[i].second > 0) {
        next_p = ab[i].first;
        break;
      }
    }
  }
  if (new_cnt_n < cnt_n) {
    for (ll i = K; i < N; i++) {
      if (ab[i].second < 0) {
        next_n = ab[i].first;
        break;
      }
    }
  }


  ll ans = 1;
  for (ll i = 0; i < K; i++) {
    ans = (ans * ab[i].first * ab[i].second) % MOD;
  }

  if (new_last_p == 0) {
    new_last_n = (-new_last_n + MOD) % MOD;
    ans = (ans * modInv(new_last_n)) % MOD;
    ans = (ans * next_p) % MOD;

  } else if (new_last_p == 0) {
    new_last_p = (new_last_p + MOD) % MOD;
    ans = (ans * modInv(new_last_p)) % MOD;
    ans = (ans * -next_n) % MOD;

  } else if (next_p * new_last_p >= next_n * new_last_n && new_cnt_p < cnt_p) {
    new_last_n = (-new_last_n + MOD) % MOD;
    ans = (ans * modInv(new_last_n)) % MOD;
    ans = (ans * next_p) % MOD;
    
  } else {
    new_last_p = (new_last_p + MOD) % MOD;
    ans = (ans * modInv(new_last_p)) % MOD;
    ans = (ans * -next_n) % MOD;
  }

  ans = (ans + MOD) % MOD;
  cout << ans << '\n';

  return 0;
}

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

typedef long long LL;
typedef vector < int > VI;
typedef vector < VI > VVI;
typedef pair < int , int > PII;

#define ALL(x) x.begin(),x.end()
#define PB push_back
#define MP make_pair
#define SZ(x) x.size()
#define SET(a , b) memset(a , b , sizeof(a))
#define REP(i, n) for(int i = 0 ; i < n ; i++)
#define FOR(i, a, b) for(int i = a ; i <= b ; i++)
#define FORD(i, a, b) for(int i = a ; i >= b ; i--)
#define BOOST ios_base::sync_with_stdio(0);

const int N = 3e5 + 5;
int n;
int arr[N];
LL ans;
int main(){
	BOOST;
	cin >> n;
	FOR(i , 1 , 3 * n) cin >> arr[i];
	sort(arr + 1 , arr + 1 + 3 * n);
	REP(i , n){
		ans += (LL) (arr[3 * n - 1 - 2 * i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1408
#価格の差の最大値を求める
#2重ループを防ぐためにループを一つにまとめる
n =int(input())
r = [0]*n
for i in range(n):
    r[i] = int(input())

maxv = -200000000000000000
minv = r[0]
ans = 0 
#最小値を保持しておく
for i in range(1,len(r)):
    maxv = max(maxv,r[i] - minv)
    minv = min(minv,r[i])

print(maxv)


Measured memory_bytes: 13368
from collections import deque


def main():
    n, q = map(int, input().split())
    tree = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = map(lambda x: int(x) - 1, input().split())
        tree[a].append(b)
        tree[b].append(a)
    counter = [0 for _ in range(n)]
    for _ in range(q):
        p, x = map(int, input().split())
        p -= 1
        counter[p] += x
    q = deque([0])
    checked = [False for _ in range(n)]
    checked[0] = True
    while q:
        now = q.pop()
        for next_v in tree[now]:
            if not checked[next_v]:
                counter[next_v] += counter[now]
                checked[next_v] = True
                q.append(next_v)
    print(" ".join(map(str, counter)))


if __name__ == '__main__':
    main()



Measured memory_bytes: 67180
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


#define X real()
#define Y imag()
typedef complex<double> P;

int main(){
	  
	  double a;
	  while(cin>>a){
	  	double t = a/9.8;
		for(int i=0;;i++){
			double h = 5*i-5;
			if(h>=4.9*t*t){
				printf("%d\n",i);
				break;
			}
		}
	  }
	
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
string dfs(mti vec,int x,int cnt,int n)
{
	if(cnt==0){
		if(x==n) return "POSSIBLE";
		else return "IMPOSSIBLE";
	}
	for(int c:vec[x]){
		string s;
		s=dfs(vec,c,cnt-1,n);
		if(s=="POSSIBLE") return s;
	}
	return "IMPOSSIBLE";
}

signed main(){
	int n,m; cin>>n>>m;
	mti vec(n+1,vi(0));
	vi one(0);
	rep(i,0,m){
		int a,b; cin>>a>>b;
		if(a==1) one.push_back(b);
		if(b==1) one.push_back(a);
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	string ans="IMPOSSIBLE";
	if(one.size()==0) ans=dfs(vec,1,2,n);
	else{
		for(int c:one){
			for(int d:vec[c]){
				if(d==n){
					cout<<"POSSIBLE";
					return 0;
				}
			}
		}
	}
	cout<<ans;
	
	
	return 0;
}

Measured memory_bytes: 12392
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


import numpy as np

A, B, H, M = read_ints()

thetaA = (H + M / 60) / 12 * 2 * np.pi
thetaB = (M / 60) * 2 * np.pi
pA = A * np.exp(complex(0, thetaA))
pB = B * np.exp(complex(0, thetaB))

print(np.abs(pA - pB))


Measured memory_bytes: 27092
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(string,s);
	int n=s.size();

	bool same = true;
	int st=0,lst=-1,ans=0;
	REP(i,n){
		if (i>0) same &= (s[i] == s[i-1]);
		if(s[i]=='0') --st;
		else ++st;

		if(st==0){
			ans += i-lst;
			lst = i;
		}
		//debug(st);
		//debug(ans);
		//debug(lst);
	}
 
	
	if(st!=0){
		ans += n-1-lst-abs(st);
	}
	OUT(ans)BR;
	
  return 0;
}


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

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

    int s1 = stoi(s.substr(0,2));
    int s2 = stoi(s.substr(2,2));
    bool ym, my;

    if(0 < s1 && s1 <= 12){
        my = true;
    }
    else{
        my = false;
    }
    if(0 < s2 && s2 <= 12){
        ym = true;
    }
    else{
        ym = false;
    }
    
    if(my){
        if(ym){
            cout << "AMBIGUOUS";
            return 0;
        }
        cout << "MMYY";
        return 0;
    }
    else if(ym){
        cout << "YYMM";
        return 0;
    }
    cout << "NA";
    return 0;
}

Measured memory_bytes: 256
while(True):
    hoge = input().split()
    a = int(hoge[0])
    b = int(hoge[2])
    op = hoge[1]
    if(op == '+'):
        ans = a + b
    elif(op == '-'):
        ans = a - b
    elif(op == '*'):
        ans = a * b
    elif(op == '/'):
        ans = int(a / b)
    else:
        exit()
    print(ans)

Measured memory_bytes: 7576
# -*- coding: utf-8 -*-
def solve():
    N = int(input())
    B = list(range(N+1))
    for i,a in enumerate(map(int, input().split()), start=1):
        B[a] = str(i)
    res = ' '.join(B[1:])
    

    return str(res)

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 18616