akhauriyash/Code-Regression huggingface dataset:
from logging import *
basicConfig(level=DEBUG, format='%(levelname)s: %(message)s')
disable(CRITICAL)

def solve():
    debug('k {} n {}'.format(k,n))
    debug('P {}'.format(P))
    debug('M {}'.format(M))
    can_positive = False
    if len(P) > 0:
        if k < n: can_positive = True
        else: can_positive = len(M)%2 == 0
    else: can_positive = k%2 == 0

    if can_positive:
        debug('positive')
        P.sort()
        M.sort(reverse = True)
        p0 = []
        if k%2: p0.append(P.pop())
        ar = []
        while len(P) >= 2: ar.append(P.pop() * P.pop())
        while len(M) >= 2: ar.append(M.pop() * M.pop())
        ar.sort(reverse = True)
        debug('p0 {}'.format(p0))
        debug('ar {}'.format(ar))
        debug('ar[:k] {}'.format(ar[:(k-k%2)//2]))
        return p0 + ar[:(k-k%2)//2]
    else: # can negative
        debug('negative')
        return sorted(P+M, key=lambda x: abs(x))[:k]


n, k = map(int, input().split())
P, M = [], [] # plus, minus
for a in map(int, input().split()):
    if a < 0: M.append(a)
    else: P.append(a)
ans, MOD = 1, 10**9 + 7
for a in solve(): ans *= a; ans %= MOD
ans += MOD; ans %= MOD
print(ans)


Measured memory_bytes: 34824
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>
 
using namespace std;
int main() {
    
    double long L;
    cin >> L;
    L/=3;
    L=pow(L,3);
    cout << scientific << setprecision(7) << L << endl;
    
    return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef pair< int, int > Pi;

class bipartite_matching{
private:
  int V;
  vector< vector< int > > info;
  vector< int > match;
  vector< bool > used;
public:
  bipartite_matching(int V_size):V(V_size){
    info.resize(V_size);
    used.resize(V_size);
    match.resize(V_size);
  };
  void add_edge( int u, int v){
    info[u].push_back(v);
    info[v].push_back(u);
  }
  bool dfs( int v){
    used[v] = true;
    for(int i = 0; i < info[v].size(); i++){
      int u = info[v][i], w = match[u];
      if(w < 0 || !used[w] && dfs(w)){
        match[v] = u, match[u] = v;
        return true;
      }
    }
    return false;
  }
  int run(){
    match.assign(V,-1);
    int ret = 0;
    for(int i = 0; i < V; i++){
      if(match[i] < 0){
        used.assign(V,false);
        if(dfs(i)) ret++;
      }
    }
    return ret;
  }
};

int main()
{
  int n;
  vector< int > data[31];
  cin >> n;
  for(int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    for(int j = x; j <= y; j++) {
      data[j].push_back(i);
    }
  }

  int ret = 0;
  for(int i = 0; i < 31; i++) {
    ret += !data[i].empty();
  }

  bipartite_matching bp(n + 31);
  for(int i = 0; i < 31; i++) {
    for(int j = 0; j < data[i].size(); j++) {
      bp.add_edge(i + n, data[i][j]);
    }
  }
  cout << ret * 50 + bp.run() * 50 << endl;
}

Measured memory_bytes: 1244
ans = 0
n, h, w = gets.chomp.split(" ").map(&:to_i);
a = (1..n).to_a
n.times do |i|
  a[i] = gets.chomp.split(" ").map(&:to_i);
  if a[i][0] >= h && a[i][1] >= w
    ans += 1
  end
end

p ans

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <iomanip>
#define ll long long
 
using namespace std;
 
int main()
{
	int n;
	cin >> n;
	int a[n];
	for (int i = 0;i<n;i++)
	{
		cin >> a[i];
	}
	int otpt=0;
	for (int i = 0;i<n;i++)
	{
		for (int j = i+1;j<n;j++)
		{
			otpt = otpt + a[i]*a[j];
		}
	}
	cout << otpt;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 10000007;
const int inf = 1001001001;



int main(void) {
  string s;
  cin >> s;
  int n = s.size();
  string p = "";
  for(int i = 0;i<n;i++){
    if(s[i]=='B' && p!=""){
      p.pop_back();
      continue;
    }
    if(s[i]!='B') p.push_back(s[i]);
    
  }
  cout << p << endl;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d', $cnt);
$map = ['AC' => 0, 'WA' => 0, 'TLE' => 0, 'RE' => 0];
for ($i=0; $i < $cnt; $i++) { 
    fscanf(STDIN, '%s', $str);
    $map[$str]++;
}
echo "AC x ".$map['AC']."\n";
echo "WA x ".$map['WA']."\n";
echo "TLE x ".$map['TLE']."\n";
echo "RE x ".$map['RE']."\n";


Measured memory_bytes: 16192
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
typedef long long ll;
template<typename T>
void print_to(std::ostream &os,const char *,const char *tail,const T &fst){
  os<<fst<<tail;
}
template<typename Fst,typename... Rst>
void print_to(std::ostream &os,const char *del,const char *tail,const Fst &fst,const Rst &... rst){
  os<<fst<<del;
  print_to(os,del,tail,rst...);
}
template<typename Iter>
void print_to_(std::ostream &os,const char *del,const char *tail,Iter bgn,Iter end){
  for(Iter it=bgn;it!=end;){
    os<<*it;
    if(++it!=end)os<<del;
    else os<<tail;
  }
}
template<typename Fst,typename... Rst>
void println(const Fst &fst,const Rst &... rst){
  print_to(std::cout,"\n","\n",fst,rst...);
}
template<typename Fst,typename... Rst>
void print(const Fst &fst,const Rst &... rst){
  print_to(std::cout," ","\n",fst,rst...);
}
template<typename Iter>
void println_(Iter bgn,Iter end){
  print_to_(std::cout," ","\n",bgn,end);
}
using namespace std;
//const ll MOD=(ll)1e9+7;
//const ll inf=(ll)1e14;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
int n,m,h,w;
string s;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  cin>>s;
  n=(int)s.size();
  for(int i=0;i<26;i++){
    char a=char('a'+i);
    stack<char> st;
    bool flag=1;
    int start=0;
    for(int j=0;j<n;j++){
      if(s[j]==a){
        st.push(a);
        flag=0;
      }else{
        if((int)st.size()>0){
          st.pop();
        }else{
          start=j+1;
          flag=1;
        }
      }
      if(!flag && (int)st.size()>0 && j-start>0){
        print(start+1,j+1);
        return 0;
      }
    }
  }
  print(-1,-1);
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}






Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
using namespace std;
typedef pair<char, int> P;

const int MAX_N = 100000, MAX_Q = 100000;
int N, Q;

int par[MAX_N+5];
int par2[MAX_N+5];
bool marked[MAX_N+5];

stack<P> s;

void init(int N) {
    for(int i = 0; i <= N; i++) {
        par[i] = i;
        par2[i] = i;
        marked[i] = false;
    }
}

int find(int n) {
    if(par[n] == n) return n;
    par[n] = find(par[n]);
    return par[n];
}

bool same(int x, int y) {
    return find(x) == find(y);
}

void unite(int x, int y) {
    // x is above
    if(same(x, y)) return;
    par[y] = x;
}

int main() {
    while(true) {
        // input
        cin >> N >> Q;
        if(!N && !Q) break;
        init(N);
        int p;
        for(int i = 2; i <= N; i++) {
            cin >> p;
            par[i] = p;
            par2[i] = p;
        }
        char c;
        int t;
        for(int i = 0; i < Q; i++) {
            cin >> c >> t;
            if(c == 'M') {
                if(marked[t]) continue;
                marked[t] = true;
                par[t] = t;
            }
            P q;
            q.first = c;
            q.second = t;
            s.push(q);
        }

        // solve
        long long int ans = 0;
        while(!s.empty()) {
            P q = s.top(); s.pop();
            if(q.first == 'M') {
                unite(par2[q.second], q.second);
            } else {
                ans += find(q.second);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2824
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      int X = sc.nextInt();
      int N = sc.nextInt();
      int[] p = new int[N];
      int result = 0;
      if(N == 0){
        result = X;
      }else{
        for(int i = 0; i < N; i++){
          p[i] = sc.nextInt();
        }
      }
      
      // 判定
      if(N != 0){
        boolean[] list = new boolean[102];
        Arrays.fill(list, true);
        for(int i = 0; i < N; i++){
          int index = p[i];
          list[index] = false;
        }
        
        int pos = X;
        int dif = 0;
        boolean judge = list[X];
        while(!judge){
          dif++;
          pos = X - dif;
          judge = list[pos];
          if(!judge){
            pos = X + dif;
            judge = list[pos];
          }
        }
        result = pos;
      }
      
      // 出力
      System.out.println(result);
    }
    

}

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

int main(){
  int N, M;
  cin >> N >> M;
  int s[M];
  char c[M];
  for(int i=0; i<M; i++) cin >> s[i] >> c[i]; 
  int ans=-1;
  for(int i=(N==1 ? 0 : pow(10,N-1)); i<pow(10,N); i++){
    string S = std::to_string(i);
    int cnt=0;
    for(int j=0; j<M; j++){
      if(S.at(s[j]-1)==c[j]) cnt++;
    }
    if(cnt==M){
      ans=i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a,b,i;
	scanf("%d %d",&a,&b);
	if(a>b){
		for(i=0;i<a;i++){
			printf("%d",b);
		}
	}
	else {
		for(i=0;i<b;i++){
		printf("%d",a);
	}
	}
	return 0;
} 

Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))

x1 = 0
for i,a in enumerate(A):
  if (i&1):
    x1 -= a
  else:
    x1 += a
x1 //= 2

res = [0] * N
res[0] = x1
for i in range(N-1):
  res[i+1] = A[i] - res[i]
for i in range(N):
  res[i] *= 2

print(" ".join(map(str, res)))

Measured memory_bytes: 84324
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

int main()
{
    int N;

    cin >> N;

    N %= 10;

    string ans;
    switch(N){
        case 3:
            ans = "bon";
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            ans = "pon";
            break;
        default:
            ans = "hon";
            break;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3600
N, K = map(int, input().split())
A = list(map(int, input().split()))
# 扱いやすいので1-indexedにする
A = [0] + A
# dp[k][i] はiから2^k回移動したときの移動先を表す
dp = [A]
for k in range(1, 100):
    dp.append([0])  # 先頭はダミー（1-indexedにするため）
    for i in range(1, N + 1):
        # jはiから2^{i - 1}回移動した先
        j = dp[k - 1][i]
        # iから2^k回移動した先 = jから2^{i - 1}回移動した先
        dp[k].append(dp[k - 1][j])
ans = 1
for k in range(100):
    if K & 2 ** k > 0:
        ans = dp[k][ans]
        K -= 2 ** k
print(ans)


Measured memory_bytes: 284080
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int n,m;
  cin >> n >> m;
  
  vector<pair<pair<int,int> , int>> cont(m);
  
  for(int i = 0 ; i < m ; i++){
    cin >> cont.at(i).first.first;
    cin >> cont.at(i).first.second;
    cont.at(i).second = i;
  }
  
  sort(cont.begin() , cont.end());
  for(int i = 0 ; i < m ; i++){
  }
  
  vector<pair<int , int>> ans(m);
  
  int jad = -1;
  int active = 0;
  for(int i = 0 ; i < m ; i++){
    if(cont.at(i).first.first != jad){
      active = 0;
      jad = cont.at(i).first.first;
    }
    else{
      active++;
    }
    
    int a = cont.at(i).second;
    ans.at(a).first = cont.at(i).first.first;
    ans.at(a).second = active+1;
  }
  
  for(int i = 0 ; i < m ; i++){
    
    string s1 = to_string(ans.at(i).first);
    string s2 = to_string(ans.at(i).second);
    
    while(s1.size() < 6){
      s1 = "0" + s1;
    }
    while(s2.size() < 6){
      s2 = "0" + s2;
    }
    
    string s3 = s1+s2;
    
    cout << s3 << endl;
  }
}

Measured memory_bytes: 3456
package main

import (
    "fmt"
)

func main() {
    var n, mochi int
    fmt.Scan(&n)
    m := make(map[int]int)

    for i := 0; i < n; i++ {
        fmt.Scan(&mochi)
        m[mochi]++
    }

    fmt.Println(len(m))
}

Measured memory_bytes: 512
import qualified Data.Map as MP
import Data.Char
import Data.List
import Control.Monad

toTuple [a,b] = (a,b)

parse :: Int -> [Int]
parse x = map digitToInt $ show x

solve :: Int -> [(Int, Int)] -> Int -> Int
solve n xs i
    | i > 1000 = -1
    | (length p) /= n = solve n xs (i+1)
    | not search = solve n xs (i+1)
    | otherwise = i
    where
        p = parse i 
        search = foldl' (\b sc -> step p b sc) True xs
        step p b (s,c) = b && (p !! (s-1) == c)

main = do
   [n,m] <- map read . words <$> getLine :: IO [Int]
   xs <- replicateM m (toTuple . map read . words <$> getLine) :: IO [(Int,Int)]
   print $ solve n xs 0
    

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

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

  if ( (N[0] == N[1] and N[1] == N[2] ) or
       (N[1] == N[2] and N[2] == N[3]) )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<string> card(36);
    int a[36];
    int b[36];
    vector<string> ocard(36);
    int oa[36];
    int ob[36];
    bool isstable=false;
    bool flag=true;
    int count=0;
    for(int i=0;i<n;i++){
        cin >> ocard[i];
        oa[i]=atoi(&ocard[i].back());
        ob[i]=i;
    }

    for(int i=0;i<n;i++){
        card[i]=ocard[i];
        a[i]=oa[i];
        b[i]=ob[i];
    }

    while(flag){
        flag=false;
        for(int i=0;i<n-1;i++){
            if(a[i]>a[i+1]){
                int tmp=a[i];
                a[i]=a[i+1];
                a[i+1]=tmp;
                tmp=b[i];
                b[i]=b[i+1];
                b[i+1]=tmp;
                string tmpp=card[i];
                card[i]=card[i+1];
                card[i+1]=tmpp;
                flag=true;
                count++;
            }
        }

    }
    isstable=true;
    for(int i=0;i<n;i++){
        cout << card[i];
        if(i!=n-1){
            cout << " ";
        }
        if(a[i]==a[i+1] && b[i]>b[i+1]){
            isstable=false;
        }
    }
    cout << endl;
    if(isstable){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }

        for(int i=0;i<n;i++){
        card[i]=(string)ocard[i];
//        cout << oa[i] << endl;
        a[i]=oa[i];
        b[i]=ob[i];
    }
    for(int i=0;i<n;i++){
        int minj=i;
        for(int j=i;j<n;j++){
            if(a[minj]>a[j]){
                minj=j;
            }
        }
        if(a[i]!=a[minj]){
            int tmp=a[i];
            a[i]=a[minj];
            a[minj]=tmp;
            tmp=b[i];
            b[i]=b[minj];
            b[minj]=tmp;
            string tmpp=card[i];
            card[i]=card[minj];
            card[minj]=tmpp;
            count++;
        }
    }
    isstable=true;
    for(int i=0;i<n;i++){
        cout << card[i];
        if(i!=n-1){
            cout << " ";
        }
        if(a[i]==a[i+1] && b[i]>b[i+1]){
            isstable=false;
        }
    }
    cout << endl;
    if(isstable){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }


    return 0;
}


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

class BSet {
    unsigned long long *data;
    int length, max_val;
public:
    BSet(int n) : max_val(n) {
        length = n / 64 + 1;
        data = new unsigned long long[length];
        fill(data, data+length, 0);
        data[0] = 1;
    }
    void add(int x) {
        int y = x / 64, z = x % 64;
        for (int i = length-y-1; i >= 0; i--) {
            const unsigned long long v = data[i],
                low = v << z, high = z ? v >> (64 - z) : 0;
            if (i + y + 1 < length) data[i+y+1] |= high;
            data[i+y] |= low;
        }
    }
    int get_max() {
        for (int r = max_val; r >= 0; r--)
            if (data[r / 64] & (1ULL << (r % 64))) return r;
        return 0;
    }
};

int main() {
    int n; cin >> n;
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    int sum = accumulate(a, a+n, 0);

    BSet s(sum/2);
    for (int x : a) s.add(x);
    cout << sum - s.get_max() << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);  
    string s;
    cin >> s;
    int cc= 0;
    REP(i,s.length()/2){
        if(s[i]!=s[s.length()-1-i]) cc++;
    }
    cout << cc << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = 1000000007;

LL N,M;
LL a,b,c,d;
string s;

int main(){
    cin>>N>>a>>b;
    cout<<max((LL)0,-(a*(N-1)+b)+(b*(N-1)+a)+1)<<endl;


    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d%d", $n, $k);
$A = array_map("intval", explode(" ", trim(fgets(STDIN))));
$sum = 0;
$max = 0;
for($i = 0; $i < $k; $i++){
  $sum += $A[$i];
  $max = $sum;
}
for($i = $k; $i < $n; $i++){
  $sum += $A[$i];
  $sum -= $A[$i-$k];
  $max = max($max, $sum);
}
echo ($max+$k)/2;
 



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

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

  int H, W; cin >> H >> W;
  vector<string> s(H);
  for (int i = 0; i < H; i++) cin >> s[i];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (s[i][j] == '.') continue;
      bool flag = false;
      if (i > 0 && s[i-1][j] == '#') flag = true;
      if (i < H-1 && s[i+1][j] == '#') flag = true;
      if (j > 0 && s[i][j-1] == '#') flag = true;
      if (j < W-1 && s[i][j+1] == '#') flag = true;
      if (!flag) {
        cout << "No" << "\n";
        return 0;
      }
    }
  }
  cout << "Yes" << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	int x = a + b + c + d;
	cout << x / 60 << endl;
	cout << x % 60 << endl;
}





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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;


int N, K, V[600];
int64 pre[600][600];
int64 dp[600][600];

int64 rec(int l, int r) {
  l %= N;
  r %= N;
  if(pre[l][r] == 0) return 0;
  if(l == r) return 0;
  if((l + 1) % N == r) return pre[l][r];
  if(~dp[l][r]) return dp[l][r];
  int64 ret = 0;
  if(l == 0 && r == N - 1) {
    for(int m = 0; m < N; m++) {
      for(int n = 0; n < N; n++) {
        if((m + N - 1) % N == n) continue;
        if(m <= n && m >= 1) continue;
        (ret += mod - 1LL * rec(m, n) * pre[(n + 1) % N][(m + N - 1) % N] % mod) %= mod;
      }
    }
    ret %= mod;
  } else if(l > r) {
    for(int m = l; m < r + N; m++) {
      (ret += mod - 1LL * rec(l, m) * pre[(m + 1) % N][r % N] % mod) %= mod;
    }
  } else {
    for(int m = l; m < r; m++) {
      (ret += mod - 1LL * rec(l, m) * pre[(m + 1) % N][r % N] % mod) %= mod;
    }
  }
  (ret += pre[l][r]) %= mod;

  return dp[l][r] = ret;
}

int64 LatteMalta(int l, int r) {
  bool v[600] = {};
  if(l > r) r += N;
  for(int i = l; i <= r; i++) {
    v[i % N] = true;
  }
  int space = 0;
  for(int i = l; i <= r; i++) {
    if(V[i % N] == -1) {
      ++space;
    } else {
      if(!v[V[i % N]]) return 0;
    }
  }
  if(space & 1) return 0;
  int64 mul = 1;
  while(space > 0) {
    --space;
    (mul *= space) %= mod;
    --space;
  }
  return mul;
}

int main() {
  memset(V, -1, sizeof(V));
  memset(dp, -1, sizeof(dp));

  cin >> N >> K;
  N *= 2;
  for(int i = 0; i < K; i++) {
    int p, q;
    cin >> p >> q;
    --p, --q;
    V[p] = q;
    V[q] = p;
  }
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
      pre[i][j] = LatteMalta(i, j);
    }
  }

  int64 ret = rec(0, N - 1);

  for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) {
      if((i + N - 1) % N == j) continue;
      if((j + 1 + N - 1) % N == (i + N - 1) % N) continue;
      (ret += rec(i, j) * pre[(j + 1) % N][(i + N - 1) % N] % mod) %= mod;
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 5888
s, t= [""] * 2
a, b = [0] * 2
u = [""]

def format_input(filename = None):
	global s,t
	global a,b
	global u
	if filename == None:
		s, t = list(map(str, input().split()))
		a, b = list(map(int, input().split()))
		u = list(map(str, input().split())).pop()

def get_answer():
	answer = [a, b]
	if u == s:
		answer[0] -= 1
	else:
		answer[1] -= 1

	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans[0], ans[1])


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int sum = 0;
		sum = (N + 1) / 2;
		System.out.println(sum);
		stdIn.close();
	}
}

Measured memory_bytes: 35772
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,m,x;
    cin >> n >> m >> x;
    VVI a(n,VI(m));
    VI c(n);
    REP(i,0,n) {
        cin >> c[i];
        REP(j,0,m) cin >> a[i][j];
    }
    int ans = 1<<30;
    REP(p,0,1<<n) {
        int sum = 0;
        VI s(m);
        REP(i,0,n) {
            if (!(p & (1<<i))) continue;
            sum += c[i];
            REP(j,0,m) s[j] += a[i][j];
        }
        bool b = true;
        REP(i,0,m) if (s[i] < x) {
            b = false;
            break;
        }
        if (b) chmin(ans, sum);
    }
    if (ans == 1<<30) cout << -1 << endl;
    else cout << ans << endl;
}

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

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


def main():
    from collections import Counter

    n, t = map(int, input().split())
    a = list(map(int, input().split()))
    minmum_numbers = [a[0] for _ in range(n)]
    diff = [0 for _ in range(n)]

    for i in range(1, n):
        minmum_numbers[i] = min(minmum_numbers[i - 1], a[i])
        diff[i] = a[i] - minmum_numbers[i]

    print(sorted(Counter(diff).items(), key=lambda x: x[0], reverse=True)[0][1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 27164
#include<bits/stdc++.h>
//#include<atcoder/all>

using namespace std;
//using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){
  
  ll n,x,m;
  ll X;
  cin >> n >> x >> m;
  X = x;
  vector<vector<pair<int,ll>>> nxt(m,vector<pair<int,ll>>(60,make_pair(-1,-1)));
  while(nxt[x][0].second == -1){
    nxt[x][0] = make_pair(x*x%m,x);
    x = x*x%m;
  }
  for(int j = 1;j < 60;j++){
    rep(i,m){
      if(nxt[i][j-1].second < 0)continue;
      nxt[i][j].second = nxt[i][j-1].second + nxt[nxt[i][j-1].first][j-1].second;
      nxt[i][j].first = nxt[nxt[i][j-1].first][j-1].first;
    }
  }
  ll res = 0;
  rep(i,60){
    if(n >> i & 1){
      res += nxt[X][i].second;
      X = nxt[X][i].first;
    }
  }
  cout << res << "\n";



  return 0;
}

Measured memory_bytes: 100932
using System;
class B{
  static void Main(){
    long[] A = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
    long H = A[0], W = A[1];
    if (H == 1 || W == 1) Console.WriteLine("1");
    else Console.WriteLine((H * W + 1) / 2);
  }
}

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


int main() {
	int n; cin >> n;
	vector<int> a(n), b(n), c(n - 1);
	rep(i, 0, n) cin >> a[i];
	rep(i, 0, n) cin >> b[i];
	rep(i, 0, n - 1) cin >> c[i];

	int ans = 0;
	rep(i, 0, n) {
		ans += b[a[i] - 1];
		if (i > 0) if (a[i - 1] + 1 == a[i]) ans += c[a[i - 1] - 1];
	}
  
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	string a;
	cin>>a;
	
	bool tj[4]={false};
	
	if(a[0]=='A')
	tj[1]=true;
	
	int tj2=0;
	
	for(int i=2;i<=a.size()-2;i++)
	{
		if(a[i]=='C')
		tj2++;
	}
	
	if(tj2==1)
	tj[2]=true;
	
	int tj3=0;
	
	for(int i=0;i<=a.size()-1;i++)
	{
		if(a[i]>=65 && a[i]<=90)
		tj3++;
	}
	
	if(tj3==2)
	tj[3]=true;
	
	if(tj[1] && tj[2] && tj[3])
	cout<<"AC";
	
	else
	cout<<"WA";
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	vector<int> h(n);
	rep(i,n) cin >> h.at(i);
	vector<int> dp(n+2,1000000000);
	dp[0]=0;
	rep(i,n){
		for(int j=1;j<=k;++j){
			if(i+j>=n) break;
			dp[i+j]=min(dp[i+j],dp[i]+(abs(h.at(i+j)-h.at(i))));
		}
	}
	cout << dp[n-1] << endl;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
typedef vector<pp> vpp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back

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

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


template <typename T>
void printV(vector<T> A) {
  if (A.empty()) cerr << "EMTPY\n";
  else { 
    cerr << "[";
    for (int i = 0; i < A.size() -1 ; ++i) {
      cerr << A[i] << ", ";
    }
    if (A.size()) cerr << A.back() << "]\n";
  }
}


template <typename T>
void printVV(vector<vector<T>> A) {
  cerr << "[";
  for (auto v : A) {
    printV<T>(v);
  }
  cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

int main(int argc, char **argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, k; cin >> a >> b >> c >> k;
  int ret =0 ;
  ret += min(a,k);
  k -= min(a,k);
  k -= min(b, k);
  ret -= min(c, k);
  cout << ret << endl;
  return 0;
}



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

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 1e6 + 5;
string s;
int n;
int mx_suf[N];

int f(int z) {
    int mn = 0, suf = 0;

    for (int i = 0; i < n; i++) {
        for (char c = '1'; c >= '0'; c--) {
            int d = (c == '1' ? 1 : -1);
            if ((c == s[i] || s[i] == '?') &&
                suf + d + mx_suf[i + 1] <= z) {
                suf += d;
                break;
            }
        }
        mn = min(mn, suf);
    }

    return z - mn;
}

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

    cin >> s;
    n = s.size();

    for (int i = n - 1; i >= 0; i--) {
        mx_suf[i] = max(mx_suf[i + 1] + (s[i] == '1' ? 1 : -1), 0);
    }

    cout << min(f(mx_suf[0]), f(mx_suf[0] + 1));

	return 0;
}

Measured memory_bytes: 8232
/* ex3-3
    kas056*/

#include<stdio.h>
#include<stdlib.h>

int main(void){
    int i,j;
    int row, column;
    char **ptr;
    int *judge_r, *judge_c;
    scanf("%d %d" ,&row, &column);

    

    //ptrのメモリ確保
    ptr = (char**)calloc(row, sizeof(char*));

    if(ptr == NULL){
        exit(1);
    }
    
    for(i=0; i<row; i++){
        ptr[i] = (char*)calloc(column, sizeof(char));
        if(ptr[i] == NULL){
            exit(1);
        }
    }

    //judge_rのメモリ確保
    judge_r = (int*)calloc(row, sizeof(int));
    if(judge_r == NULL){
        exit(1);
    }

    //judge_cのメモリ確保
    judge_c = (int*)calloc(column, sizeof(int));

    for(i=0; i<row; i++){
        for(j=0; j<column; j++){
            scanf(" %c", &ptr[i][j]);
        }
    }

    //＃があるか判定
    for(i = 0; i < row; i++){//まず行を固定して
        for (j = 0; j < column; j++){//その行の各要素に対して
            if(ptr[i][j] == '#'){//＃と一致するものがあったら終了する。
                break;
            }
        }

        if(j == column){//最後まで＃がなかったら
            judge_r[i] = 1;
        }
    }

    for(j = 0; j < column; j++){//列を固定して、行の場合と同様の操作を行う
        for(i = 0; i < row; i++){
            if(ptr[i][j] == '#'){
                break;
            }
        }
        if(i == row){
            judge_c[j] = 1;
        }
    }

    for(i=0; i<row; i++){//ある行において＃があった時、かつ
        if(judge_r[i] == 0){
            for(j = 0; j<column; j++){//その列に＃があったとき、
                if(judge_c[j] == 0){
                    printf("%c", ptr[i][j]);//(i,j)番目の文字を一文字出力
                }
            }//折り返し。これをcolumnの数だけ繰り返す
            printf("\n");//終点で改行
        }
    }//これをrowの数だけ繰り返す

    //逆順に開放
    for(i=0; i<row;i++){
        free(ptr[i]);
    }
    free(ptr);

    return 0;
}

Measured memory_bytes: 1640
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def solve(N, W, ws, vs):
    # S[i] = (v, w): 価値v, 重さw
    *S, = zip(vs, ws)

    def make(S):
        T = {0: 0}
        for v, w in S:
            # 価値v, 重さw
            T0 = dict(T)
            for k, val in T.items():
                if k + w > W:
                    continue
                if k + w in T0:
                    T0[k + w] = max(T0[k + w], val + v)
                else:
                    T0[k + w] = val + v
            T = T0
        v = 0
        R = []
        for k in sorted(T):
            v = max(v, T[k])
            # (重さk, 重さk以下での価値の最大v)
            R.append((k, v))
        return R

    def solve(T0, T1):
        T0.sort()
        T1.sort(reverse=1)

        it = iter(T1)
        k1, v1 = next(it)
        yield 0
        for k0, v0 in T0:
            # 重さの和がW以下になるようにスライドする
            while k0 + k1 > W:
                k1, v1 = next(it)
            yield v0 + v1

    # ２つの集合に分けて、それぞれ全列挙
    T0 = make(S[:N // 2])
    T1 = make(S[N // 2:])

    # 2つの全列挙を元に解を求める
    return max(solve(T0, T1))


def main():

    N, K = in_nn()
    A = in_nl()

    max_num = max(K, max(A))
    bit_len = max_num.bit_length()

    ws = []
    vs = []

    sum_value = 0
    for i in range(bit_len):

        cnt = 0
        for j in range(N):
            cnt += (A[j] >> bit_len - i - 1) & 1

        n = 2 ** (bit_len - i - 1)
        if cnt < -(-N // 2):
            value = (N - 2 * cnt) * n
            weight = n
            vs.append(value)
            ws.append(weight)
        sum_value += cnt * n

    ret = solve(len(vs), K, ws, vs)
    print(sum_value + ret)


if __name__ == '__main__':
    main()


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

bool prime(int n)
{
  for(int i=2;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      return 0;}
  }
  return 1;
}

int main()
{
	int n;
	cin>>n;
	if(n==1)
  {
    cout<<"Yes";
    return 0;
  }
  if(n<1 || n>81 || (prime(n) && n>9))
  {
    cout<<"No";
    return 0;
  }
  else{
  	for(int i=sqrt(n);i>0;i--)
  	{
  		if(n%i==0 && (n/i)<=9){
  			cout<<"Yes";
  			return 0;
		  }
  }
  cout<<"No";
  
  return 0;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    int happi[3][N];
    for(int i = 0; i < N; i++)
        for(int j = 0; j < 3; j++) cin >> happi[j][i];

    int ans[3][N];
    for(int i = 0; i < N; i++)
        for(int j = 0; j < 3; j++) ans[j][i] = 0;
    for(int i = 0; i < 3; i++) ans[i][0] = happi[i][0];

    for(int i = 0; i < N - 1; i++) {
        ans[0][i + 1] = max(ans[0][i + 1], max(ans[1][i], ans[2][i]) + happi[0][i + 1]);
        ans[1][i + 1] = max(ans[1][i + 1], max(ans[0][i], ans[2][i]) + happi[1][i + 1]);
        ans[2][i + 1] = max(ans[2][i + 1], max(ans[0][i], ans[1][i]) + happi[2][i + 1]);
    }

    cout << max(ans[0][N - 1], max(ans[1][N - 1], ans[2][N - 1])) << "\n";
    return 0;
}

Measured memory_bytes: 5904
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define inf 1e9
#define pp pop_back
#define pii pair<int,int>
#define vec vector<int>
#define mp make_pair
using namespace std;
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t=1;
  //cin>>t;
  while(t--)
  {
    int n;
    cin>>n;
    int i;
    int a[n+1],b[n+1],c[n+1];
    for(i=1;i<=n;i++)
        cin>>a[i]>>b[i]>>c[i];
    int dp[n+1][4];
    dp[0][0]=dp[0][1]=dp[0][2]=dp[0][3]=0;
    for(i=1;i<=n;i++)
    {
      dp[i][0]=max(a[i]+dp[i-1][1],max(b[i]+dp[i-1][2],c[i]+dp[i-1][3]));
      dp[i][1]=max(b[i]+dp[i-1][2],c[i]+dp[i-1][3]);
      dp[i][2]=max(a[i]+dp[i-1][1],c[i]+dp[i-1][3]);
      dp[i][3]=max(a[i]+dp[i-1][1],b[i]+dp[i-1][2]);
    }
    cout<<dp[n][0];
  }
}


Measured memory_bytes: 9120
program gacha;
type 
    arr = array[1..200000] of string;

var
    n, i, count : longint;
    list : arr;

procedure swap(var x: string; var y: string);
var tmp: string;
begin
    tmp := x;
    x := y;
    y := tmp;
end;

procedure quicksort(var x: arr; left, right: longint);
var 
    i, j: integer;
    k: string;

begin
    i := left; 
    j := right;
    k := x[(left + right) div 2];
    while i <= j do begin
        while x[i] < k do 
            inc(i);
        while x[j] > k do
            dec(j);
        if i <= j then begin
            swap(x[i], x[j]);
            inc(i);
            dec(j);
        end;
    end;
    if left < j then
        quicksort(x, left, j);
    if right > i then 
        quicksort(x, i, right);
end;

begin
    readln(n);
    for i := 1 to n do 
        readln(list[i]);
    quicksort(list, 1, n);
    count := 1;
    for i := 2 to n do begin
        if list[i - 1] <> list[i] then 
            inc(count);
    end;
    writeln(count);
end.

Measured memory_bytes: 58432
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int ans = 0;
		for(int i = 1 ;; i++) {
			if(x < y * i + z * (i + 1)) {
				break;
			} else {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#include<stdio.h>
int main()
{
    int A, B, C, D, t=1;
    scanf("%d%d%d%d", &A, &B, &C, &D);
    C=C-B;
    while(C>0){
        A=A-D;
        if(A<1){
            t=0;
            break;
        }
        else{
            C=C-B;
        }
    }
    if(t==1){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 1644
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }
 
typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
struct Node{
  char value;
  Node* child[2];
  Node() { memset(child, 0, sizeof(child)); }
  Node(char c) : value(c) { memset(child, 0, sizeof(child)); }
};
struct Result{
  Node* n;
  int p;
  Result(){}
  Result(Node* n, int p) : n(n), p(p) {}
};
int G;
map<char, int> ope_d;
char type[100];
bool is_ope(char c){
  return ope_d.count(c);
}
Result expr(const string& s, int p, int depth){
  //printf("p = %d depth = %d s[p] = %c\n", p, depth, s[p]);
  if(depth == G){
    if(s[p] == '('){
      Result r = expr(s, p + 1, 0);
      assert(s[r.p] == ')');
      r.p++;
      return r;
    }else if(isalpha(s[p])){
      Node* n = new Node(s[p]);
      return Result(n, p + 1);
    }else{
      assert(false);
    }
  }else{
    if(type[depth] == 'L'){
      Result r = expr(s, p, depth + 1);
      while(is_ope(s[r.p]) && ope_d[s[r.p]] == depth){
        Node* n = new Node(s[r.p]);
        Result r_ = expr(s, r.p + 1, depth + 1);
        n->child[0] = r.n;
        n->child[1] = r_.n;
        r.n = n;
        r.p = r_.p;
      }
      return r;
    }else if(type[depth] == 'R'){
      Result r = expr(s, p, depth + 1);
      if(is_ope(s[r.p]) && ope_d[s[r.p]] == depth){
        Result r_ = expr(s, r.p + 1, depth);
        Node* n = new Node(s[r.p]);
        n->child[0] = r.n;
        n->child[1] = r_.n;
        r.n = n;
        r.p = r_.p;
      }
      return r;
    }else{
      assert(false);
    }
  }
}
void print(Node* p){
  assert(p);
  if(isalpha(p->value)){
    assert(!p->child[0]);
 
    putchar(p->value);
  }else{
    assert(p->child[0]);
 
    putchar('(');
    print(p->child[0]);
    putchar(p->value);
    print(p->child[1]);
    putchar(')');
  }
}
int main(){
  int D;
  cin >> D;
  bool first = true;
  while(D--){
    if(first) first = false;
    else cout << endl;
 
    cin >> G;
    REP(i, G){
      cin >> type[i];
      int T; cin >> T;
      while(T--){
        char ope; cin >> ope;
        ope_d[ope] = i;
      }
    }
    int N; cin >> N;
    REP(i, N){
      string s;
      cin >> s;
      Result r = expr(s, 0, 0);
      print(r.n);
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 8644
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

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

signed main(){
    int N; cin>>N;
    vec h(N); REP(i,N) cin>>h[i];
    vec DP(100010,INF);
    DP[0]=0;
    FOR(i,1,N){
        DP[i]=min(DP[i],DP[i-1]+abs(h[i]-h[i-1]));
        if(i>1) DP[i]= min(DP[i],DP[i-2]+abs(h[i]-h[i-2]));
    }
    Out(DP[N-1]);
}

Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
int n,k;
int a[200005],maxx,minn,num=0;
bool flags=1;
long long ans=1;
long long ksm(long long x,long long n)
{
	long long ans=1;
	while(n)
	{
		if(n&1) ans=ans*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return ans;
}
bool cmp(int x,int y)
{
	return abs(x)>abs(y);
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) if(a[i]>=0) flags=0;
	sort(a+1,a+n+1,cmp);
	if(flags)
	{
		if(k&1) for(int i=n;i>=n-k+1;i--) ans=ans*a[i]%mod;
		else for(int i=1;i<=k;i++) ans=ans*a[i]%mod;
		ans=(ans%mod+mod)%mod;
		printf("%lld\n",ans);
		return 0;
	}
	if(n==k)
	{
		ans=1;
		for(int i=1;i<=k;i++) ans=ans*a[i]%mod;
		ans=(ans%mod+mod)%mod;
		printf("%lld\n",ans);
		return 0;
	}
	ans=1;
	for(int i=1;i<=k;i++)
	{
		ans=ans*a[i]%mod;
		if(a[i]<0) num++,maxx=a[i];
		if(a[i]>0) minn=a[i];
	}
	if(!ans)
	{
		printf("%lld\n",ans);
		return 0;
	}
	if(!(num&1)) printf("%lld\n",ans);
	else
	{
		long long u=0,v=0,u2=0,v2=0;
		v=-maxx,v2=minn;
		for(int i=n;i>k;i--)
		if(a[i]>0) u=a[i];
		else u2=-a[i];
		if(!v2) ans=ans*ksm(-v,mod-2)%mod*u%mod;
		else
		{
			if(u*v2>u2*v) ans=ans*ksm(-v,mod-2)%mod*u%mod;
			else ans=ans*ksm(v2,mod-2)%mod*-u2%mod;
		}
		ans=(ans%mod+mod)%mod;
		printf("%lld\n",ans);
	}
}

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

int main() {
	int N;
	string S;
	cin >> N >> S;
	vector<vector<int>> dp(N+1, vector<int>(2, 0));
	for(int i=0; i<N; ++i){
	    int tmp=(S[i]=='.' ? 0 : 1);
	    dp[i+1][0]=dp[i][0]+tmp;
	    dp[i+1][1]=min(dp[i][0], dp[i][1])+1-tmp;
	        
	}
	cout << min(dp[N][0], dp[N][1]) << endl;
	return 0;
}


Measured memory_bytes: 11396
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=2e18;
const double EPS=1e-7;

ll N;
ll a[100010];
map<ll,ll> pos;
int main(){
    cin>>N;
    for(ll i=0;i<N;i++){
        cin>>a[i];
        pos[a[i]]=i;
    }
    sort(a,a+N);
    ll cnt=0;
    for(ll i=0;i<N;i++){
        if(abs(pos[a[i]]-i)%2==1){
            cnt++;
        }
    }
    cout<<cnt/2<<endl;    
}

Measured memory_bytes: 7296
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        string s = Console.ReadLine();
        int K = int.Parse(Console.ReadLine());
        // Console.WriteLine(UsingList(s, K));
        // Console.WriteLine(UsingHashSetOrderBy(s, K));
        Console.WriteLine(UsingSortedSet(s, K));
    }

    // List→IEnumerable→IOrderedEnumerable
    static string UsingList(string s, int K)
    {
        List<string> list = new List<string>();
        for (int len = 1; len <= Math.Min(s.Length, 5); len++)
        {
            for (int i = 0; i <= s.Length - len; i++)
            {
                list.Add(s.Substring(i, len));
            }
        }
        var list_d = list.Distinct();
        var ranking = list_d.OrderBy(i => i);
        return ranking.ElementAt(K - 1);
    }

    // HashSet→IOrderedEnumerable
    static string UsingHashSetOrderBy(string s, int K)
    {
        HashSet<string> hs = new HashSet<string>();
        for (int len = 1; len <= Math.Min(s.Length, 5); len++)
        {
            for (int i = 0; i <= s.Length - len; i++)
            {
                hs.Add(s.Substring(i, len));
            }
        }
        var ranking = hs.OrderBy(i => i);
        return ranking.ElementAt(K - 1);
    }

    // SortedSetのみ！
    static string UsingSortedSet(string s, int K)
    {
        SortedSet<string> ss = new SortedSet<string>();
        for (int len = 1; len <= Math.Min(s.Length, 5); len++)
        {
            for (int i = 0; i <= s.Length - len; i++)
            {
                ss.Add(s.Substring(i, len));
            }
        }
        return ss.ElementAt(K - 1);
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
using namespace std;
int main(){
    int N;
    cin >> N;
    int S[2*N];
    int count=0;
    for(int i=0;i<N;i++){
        cin >> S[i] >> S[i+1];
        count += S[i+1]-S[i]+1;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256