akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <iomanip>
#include <climits>
#include <vector>
#include <map>
#include <algorithm>
#include <cstring>
#include <queue>
#define ll long long
#define REP(a,b) for(ll a=0; a<b; a++)
using namespace std;

vector <int> base;
vector <bool> tempbase;

int main() {
  int N;
  cin >> N;
  REP(i, 2*N-1){
    int temp;
    cin >> temp;
    base.push_back(temp);
  }
  int l = 1;
  int r = 2*N-1;
  int ans = 0;
  while(l <= r){
    int mid = (l+r)/2;
    REP(i, base.size()){
      tempbase.push_back(base[i] >= mid);
    }
    int flag = -1;
    REP(i, N-1){
      if(tempbase[N-1+i] == tempbase[N+i]){
        flag = tempbase[N+i];
        break;
      }
      if(tempbase[N-1-i] == tempbase[N-2-i]){
        flag = tempbase[N-1-i];
        break;
      }
    }
    if(flag == -1) flag = tempbase[0];
    if(flag == 1){
      ans = max(ans, mid);
      l = mid+1;
    }else r = mid-1;
    tempbase.clear();
  }
  cout << ans << endl;
}

Measured memory_bytes: 1400
#include<stdio.h>

int main(void)
{
    int i, n, a[200000], b[200000], max = 0, mix = 0;

    scanf("%d", &n);

    for(i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        b[a[i] - 1]++;
        b[a[i]]++;
        b[a[i] + 1]++;
        if(max < a[i])
            max = a[i];
    }

    for(i = 0; i <= max + 1; i++) {
        if(mix < b[i])
            mix = b[i];
    }

    printf("%d\n", mix);

    return 0;
}

Measured memory_bytes: 896
a, b, c, x = map(int, [input() for i in range(4)])
r = 0
for j in range(a+1):
    for i in range(b+1):
        for k in range(c+1):
            if j * 500 + i * 100 + k * 50 == x:
                r += 1

print(r)

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <math.h>
#include <cstdlib>
#include <cctype>
#include <random>

using namespace std;

int main() {
    int n,a,b;
    cin >> n >> a >> b;

    if (n*a > b) cout << b << endl;
    else cout << n*a << endl;    

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

int main(){
    int R, C;
    LL K;
    cin >> R >> C >> K;
    vector<vector<LL>> Point(R, vector<LL>(C, 0LL));
    REP(i,K){
        int r , c;
        LL v;
        cin >> r >> c >> v;
        Point[r-1][c-1] = v;
    }

    vector<vector<vector<LL>>> dp(R, vector<vector<LL>>(C, vector<LL>(4,0LL)));
    LL lower_row_point = 0;
    FOR(i, 0, R){
        FOR(j, 0, C){
            if(i==0 && j==0){
                dp[i][j][1] = Point[i][j];
            }else if(i==0){
                dp[i][j][3] = max({dp[i][j-1][2] + Point[i][j], dp[i][j-1][3]});
                dp[i][j][2] = max({dp[i][j-1][1] + Point[i][j], dp[i][j-1][2]});
                dp[i][j][1] = max({Point[i][j], dp[i][j-1][1]});
                dp[i][j][0] = lower_row_point;

            }else if(j==0){
                lower_row_point = max({dp[i-1][j][0], dp[i-1][j][1], dp[i-1][j][2], dp[i-1][j][3]});
                dp[i][j][1] = lower_row_point + Point[i][j];
                dp[i][j][0] = lower_row_point;
            }else{
                lower_row_point = max({dp[i-1][j][0], dp[i-1][j][1], dp[i-1][j][2], dp[i-1][j][3]});
                dp[i][j][3] = max({dp[i][j-1][2] + Point[i][j], dp[i][j-1][3]});
                dp[i][j][2] = max({dp[i][j-1][1] + Point[i][j], dp[i][j-1][2]});
                dp[i][j][1] = max({lower_row_point + Point[i][j], dp[i][j-1][1]});
                dp[i][j][0] = lower_row_point;
            }
        }
    }

    LL ans = max({dp[R-1][C-1][0],dp[R-1][C-1][1],dp[R-1][C-1][2],dp[R-1][C-1][3]});

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

Measured memory_bytes: 706740
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int r;
    cin >> r;
    cout << 3*r*r << endl;


    return 0;
}

Measured memory_bytes: 3640
# 整数(数列長)の入力
N = int(input())
# 数列の入力
A = [int(input()) for _ in range(N)]
# 数列の最も大きい値取得
A_max = sorted(A)[-1]
# 数列の二番目に大きい値取得
A_2ndmax = sorted(A)[-2]

# 出力
for i in range(N):
    
    if A[i] == A_max:
        print("{}".format(A_2ndmax))
    
    else:
        print("{}".format(A_max))

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

int main(){
    int N, ans = 0;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; ++i) {
        cin >> L[i];
    }
    
    sort(L.begin(), L.end());
    
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            for (int k = j + 1; k < N; ++k) {
                if (L[k] < L[i] + L[j]) {
                    ++ans;
                }
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);



int main(){
    FIN;
    string s;
    cin >> s;
    int ans = 0;
    int cur = 0;
    for(int i=0;i<s.size();i++){
        if(s[i] == 'R') cur++;
        else cur = 0;
        ans = max(ans,cur);
    }

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


Measured memory_bytes: 3560
#include<iostream>
#include<vector>
#include<cstdio>

using namespace std;

bool visited[50];
vector<int> v[50];

void DFS(pair<int,int> forbidden,int node)
{
    if(visited[node])
        return;

    visited[node] = true;
    for(int i = 0;i < v[node].size();i++) {
        if((forbidden.first == node && forbidden.second == v[node][i]) ||
                (forbidden.second == node && forbidden.first == v[node][i]))
            continue;

        DFS(forbidden,v[node][i]);
    }

    return;
}

int Bridge(int n,vector<pair<int,int> > &edge)
{
    int count = 0;

    for(int i = 0;i < edge.size();i++)
    {
        DFS(edge[i],0);
        for(int j =0;j < n;j++)
            if(visited[j] == false) {
                count++;
                break;
            }

        memset(visited,false,50);
    }

    return count;
}

int main(void)
{
    int n,m;

    cin>>n>>m;

    vector<pair<int,int> > edge;

    memset(visited,false,50);

    for(int i = 0;i < m;i++) {
        int a,b;
        cin>>a>>b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);

        pair<int,int> temp;
        temp.first = a;
        temp.second = b;
        edge.push_back(temp);
    }

    cout<<Bridge(n,edge)<<endl;

    return 0;
}


Measured memory_bytes: 888
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

void solve();

int a, b, c;

int main() {
  cin >> a >> b >> c;

  solve();

  return 0;
}

void solve() {

  if(a==b&&a==c) cout << 1 << endl;
  else if(a==b||b==c||c==a) cout << 2 << endl;
  else cout << 3 << endl;

  return;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n){ cin >> a[i]; }

    for (int i = k; i < n; i++)
    {
        if (a[i] > a[i-k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    

}



Measured memory_bytes: 4056
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

const int Maxn = 2010;

ll a[Maxn], minv[Maxn];
int n;
ll x;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> x;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        minv[i] = a[i];
    }

    ll ans = (ll) 1e15;
    for (int k = 0; k < n; ++k) {
        ll cost = x * k;
        for (int i = 0; i < n; ++i) {
            cost += minv[i];
            minv[i] = min(minv[i], a[(i - k - 1 + n) % n]);
        }
        ans = min(ans, cost);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
s=list(input())

for i in range(2**(len(s)-1)):
    f =['']*(len(s)-1)
    siki=''
    for j in range(len(s)-1):
        if(i>>j & 1):
            f[j] = '+'
        else:
            f[j] = '-'
    for k in range(len(s)-1):
        siki += s[k] + f[k]
    siki += s[-1]
    if eval(siki)==7:
        siki += '=7'
        print(siki)
        break
    

Measured memory_bytes: 9028
#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;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'
typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
	faster
	double a,b,c;
	cin>>a>>b>>c;
	double ans;
	ans=a/c;
	if(ans<=b)cout<<"Yes"<<nl;
	else cout<<"No"<<nl;
	return 0;
}

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

ans=0
beforeN=-1
for i in range(N):
  ans += B[A[i]-1]
  #print(ans)
  #print(A[i]-beforeN)
  if A[i]-beforeN==1:
    ans += C[A[i]-2]
  beforeN=A[i]
print(ans)
  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    ll i = 0;
    while(true){
        if(s[i] == 'r'){
            if(i + 5 < s.size() && s.substr(i, 6) == "resare"){
                i += 6;
            }else if(i + 6 < s.size() && s.substr(i, 7) == "remaerd"){
                i += 7;
            }else{
                cout << "NO" << endl;
                return 0;
            }
        }else if(s[i] == 'e'){
            if(i + 4 < s.size() && s.substr(i, 5) == "esare"){
                i += 5;
            }else{
                cout << "NO" << endl;
                return 0;
            }
        }else if(s[i] == 'm'){
            if(i + 4 < s.size() && s.substr(i, 5) == "maerd"){
                i += 5;
            }else{
                cout << "NO" << endl;
                return 0;
            }
        }else{
            cout << "NO" << endl;
            return 0;
        }
        if(i == s.size()) break;
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
 using namespace std;
  pair<pair<string,int>,int> a[110];
int main(){
  int r, D;
  cin >> r >> D;
  int x[15];
  cin >> x[0];
  for(int i = 0; i < 10; i++){
    x[i + 1] = r* x[i] - D;
    cout << x[i + 1] << '\n';
  }

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long max = 0;
		for (int i = 1; i < N; i++) {max +=i;}
		System.out.println(max);
	}

}

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

int lcs(string s1, string s2) {
    int m = s1.size();
    int n = s2.size();
    int c[m+1][n+1];
    int maxl = 0;
    s1 = " " + s1;
    s2 = " " + s2;

    for (int i = 0; i <= m; i++) c[i][0] = 0;
    for (int j = 0; j <= n; j++) c[0][j] = 0;

    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            if (s1[i] == s2[j]) c[i][j] = c[i-1][j-1] + 1;
            else c[i][j] = max(c[i][j-1], c[i-1][j]);
            maxl = max(maxl, c[i][j]);
        }
    }

    return c[m][n];
}

int main(){
    string s1, s2;
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s1 >> s2;
        cout << lcs(s1, s2) << endl;
    }
    return 0;
}



Measured memory_bytes: 7068
#include <cstdio>

using namespace std;

int main()
{
    int d;
    scanf("%d", &d);
    if(d == 25)
        printf("Christmas\n");
    else if(d == 24)
        printf("Christmas Eve\n");
    else if(d == 23)
        printf("Christmas Eve Eve\n");
    else if(d == 22)
        printf("Christmas Eve Eve Eve\n");
    return 0;
}


Measured memory_bytes: 128
N=int(input())
ans=A=B=BA=0
for _ in range(N):
    S=input()
    ans+=S.count("AB")
    if S[0]=='B'and S[-1]=='A':BA+=1
    elif S[0]=='B':B+=1
    elif S[-1]=='A':A+=1
if BA!=0:
    ans+= BA if A+B>0 else BA-1
print(ans+min(A,B))

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

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

    if (N % 2 == 1) { 
        cout << "0\n"; 
    } 
    else {
        long long answer = 0;
        N /= 2;
        while (N > 4) {
            answer += N / 5;
            N /= 5;
        }
        cout << answer << endl;
    }

}

Measured memory_bytes: 256
// 2017-02-03
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 7368791

int main() {
	int m, n;
	static bool b[MAX];
	while (cin >> m >> n, m) {
		fill(b, b + MAX, false);
		int y = MAX;
		for (int i = m; i < MAX; i++) {
			if (!b[i]) {
				if (n > 0) {
					n--;
					for (int j = i; j < MAX; j += i) b[j] = true;
				} else {
					y = i;
					break;
				}
			}
		}
		cout << y << endl;
	}
	return 0;
}

Measured memory_bytes: 10268
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;


int main(){
    int R,G,B,N;
    cin >>  R >> G >> B>>N;
    ll ans=0;
    for(int i=0; i*R<=N; i++){
        for(int j=0; j*G<=N; j++){
            
            if((N-i*R-j*G)%B==0 && (N-i*R-j*G)>=0){
                ans++;
            }
            
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] S = new long[n];

		for(int i = 0; i < n; i++) {
			S[i] = sc.nextLong();
		}

		int q = sc.nextInt();
		int count = 0;

		for(int j = 0; j < q; j++) {
			long T = sc.nextLong();
			for(int i = 0; i < n; i++) {
				if(T == S[i]) {
					count++;
					break;
				}
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 40228
N = int(input())
L = []
for i in range(N) :
    L.append(list(map(int,input().split())))

dp = [[0,0,0] for i in range(N+1)]

for i in range(N) :
    for j in range(3) :
        for k in range(3) :
            if j == k :
                continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + L[i][k]) 
print(max(dp[-1]))


Measured memory_bytes: 47324
import java.io.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    try (BufferedReader br = 
				new BufferedReader(new InputStreamReader(System.in))) {
      solve(br);
    } catch (IOException e) {
			e.printStackTrace();
		}
  }

  static void solve(BufferedReader br) throws NumberFormatException, IOException {
    int n = Integer.parseInt(br.readLine());
    ArrayDeque<Integer> list = new ArrayDeque<>();// 連結リスト
    String insert = "insert";
    String delete = "delete";
    String delFirst = "deleteFirst";
    String deleteLast = "deleteLast";

    for (int i = 0; i < n; i++) {
      String[] input = br.readLine().split("\\s");

      String command = input[0];
      if (command.equals(insert)) {
        list.addFirst(Integer.parseInt(input[1]));
      } else if (command.equals(delete)) {
        list.removeFirstOccurrence(Integer.parseInt(input[1]));
      } else if (command.equals(delFirst)) {
        list.removeFirst();
      } else if (command.equals(deleteLast)) {
        list.removeLast();
      }
    }

    StringBuilder sb = new StringBuilder();
    list.forEach(e -> sb.append(e).append(' '));
    System.out.println(sb.toString().trim());
  }
}



Measured memory_bytes: 573876
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}


int main(void) {
    string S; cin >> S;
    vector<string> vs = {"Sunny", "Cloudy", "Rainy", "Sunny"};
    for (int i = 0; i < 3; i++) {
        if (S == vs[i]) {
            cout << vs[i+1] << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 888
#pragma gcc optimize (o3)
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define S second
#define F first
#define ll long long
#define ld long double
#define U unsigned
#define pi acos(-1)

using namespace std;

const ll N = 1e5+5;

ll dp[N][4], a[N][2], n, mxW;

ll solveI()
{
    for(int i = n ; i > 0 ; i--)
    {
        for(int j = 0 ; j <= mxW ; j++)
        {
            dp[i][j] = dp[i+1][j];
            if(j+a[i][0] <= mxW) dp[i][j] = max(dp[i][j], dp[i+1][j+a[i][0]] + a[i][1]);
        }
    }
    return dp[1][0];
}

int main()
{
    scanf("%lld%lld", &n, &mxW);
    for(int i = 1 ; i <= n ; i ++) scanf("%lld%lld", &a[i][0], &a[i][1]);
    printf("%lld", solveI());
    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

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

    // sum:和の二乗　sumpow:二乗の和
    ll sum = 0, sumpow = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        sum += a;
        sumpow += (a * a) % mod;

        sum %= mod;
        sumpow %= mod;
    }

    sum = (sum * sum) % mod;

    cout << (((sum - sumpow + mod) % mod) * (mod + 1) / 2) % mod << "\n";
    return 0;
}

Measured memory_bytes: 3636
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace debug
{
    class ProgramA
    {
        static void Main(string[] args)
        {

            //入力
            string s  = Console.ReadLine();

            //
            int flag1 = 0;
            int flag2 = 0;

            int y = (s[0] - '0') * 10 + (s[1] - '0');
            int m = (s[2] - '0') * 10 + (s[3] - '0');

            if (0 < y && y < 13)
                flag1 = 1;
            if (0 < m && m < 13)
                flag2 = 1;

            if(flag1 == 1 && flag2 == 1)
            {
                Console.WriteLine("AMBIGUOUS");
                return;
            }

            if (flag1 == 1 && flag2 == 0)
            {
                Console.WriteLine("MMYY");
                return;
            }

            if (flag1 == 0 && flag2 == 1)
            {
                Console.WriteLine("YYMM");
                return;
            }

            Console.WriteLine("NA");
            return;




        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int i=0;
string S,s;
int num[30];
int main()
{
    while(cin>>S)
    {
        i=0;
        int W=1;
        int n=0;
        while(S[n++]);
        n--;
        memset(num,0,sizeof(num));
        for(int i=0;i<n;i++)
            num[S[i]-'a']++;
        for(int i=0;i<=26;i++)
            if((num[i]%2)==1)
                W=0;
        if(W==1)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
#define pb push_back
#define F first
#define S second
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)

# define M_PIl          3.141592653589793238462643383279502884L /* pi */

const ll M=1e9+7;
const int MaxM=100005;


void SieveOfEratosthenes(int n)                                   //all prime <= n
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }

    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}


bool isPowerOfTwo (int x)
{
    return x && (!(x&(x-1)));
}



bool comp(pair<int,int> a,pair<int,int> b){
  if(a.F==b.F){
    return a.S>b.S;
  }
  return a.F<b.F;
}








void solve(){

  int n;
  cin>>n;
  int a[n];
  int dp[n];
  dp[0]=0;

  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  dp[1]=abs(a[1]-a[0]);

  for(int i=2;i<n;i++){
     dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
  }
  cout<<dp[n-1]<<endl;

}

int main(){


   int t=1;
//  cin>>t;
   while(t--){
      solve();
       }

 }


Measured memory_bytes: 4300
n, k = map(int, input().split())
h = list(map(int, input().split()))
inf = float("INF")
dp = [inf] * n
dp[0] = 0
for i in range(1, n):
    for j in range(max(i - k, 0), i):
        dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]))

print(int(dp[n - 1]))

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr ll mo2 = 998244353;
const double PAI = acos(-1);
constexpr long double eps = 1e-9;
const ull in = 1000000000000000000ull;

std::ostream &operator<<(std::ostream &dest, __uint128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    long double a,b;
    cin>>a>>b;
    cout << __uint128_t(floor(a*b)) << endl;
    return 0;
}


Measured memory_bytes: 3780
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
struct Node{
	int key;
	Node *parent, *left, *right;
	Node():parent(NULL),left(NULL),right(NULL),key(0){ }
};
Node *root=NULL;int m,cnt=0;
Node * insert(int k,Node *r){
	if(!r){
		r=new Node;
		r->key=k;
	}else if(k>r->key) {
		r->right=insert(k,r->right);
	}else {
		r->left=insert(k,r->left);
	}
	return r;
}
void inorder(Node * r){
	if(!r)return;
	inorder(r->left);
	cout<<" "<<r->key;
	inorder(r->right);
}
void preorder(Node *r){
	if(!r)return ;
	cout<<" "<<r->key;
	preorder(r->left);
	preorder(r->right);
}
void print(){
	cnt=0;
	inorder(root);
	putchar('\n');
	cnt=0;
	preorder(root);
	putchar('\n');
}
bool find(int k,Node * r){
	if(!r) return false;
	if(k==r->key)return true;
	bool flag=false;
	if(k>r->key) flag|=find(k,r->right);
	else flag|=find(k,r->left);
	return flag;
}
int main(){
	int key;
	string s;
	cin>>m;
	for(int i=0;i<m;i++){
		cin>>s;
		if(s=="insert"){
			cin>>key;
			root=insert(key,root);
		}else if(s=="print"){
			print();
		}else if(s=="find"){
			cin>>key;
			cout<< (find(key,root)?"yes":"no") <<endl; 
		}
	}
	return 0;
}


Measured memory_bytes: 21904
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int main()
{
	string a;
	cin>>a;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='9')
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
}


Measured memory_bytes: 256
n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]
bc.sort(reverse = True, key = lambda x: x[1])
i = 0
counter = 0
while 1:
    for j in range(bc[i][0]):
        a.append(bc[i][1])
        counter += 1
        if counter == n:
            break
    if counter == n or i == len(bc)-1:
        break
    i += 1

a.sort(reverse = True)
print(sum(a[:n]))


Measured memory_bytes: 34500
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll ans = 0;
    int N;
    cin >> N;
    vector<int> A(N),B(N),C(N);
    rep(i,N)cin >> A[i];
    rep(i,N)cin >> B[i];
    rep(i,N)cin >> C[i];
    sort(ALL(A));
    sort(ALL(B));
    sort(ALL(C));
    rep(i,N){
        int now = B[i];
        ll top =  (lower_bound(ALL(A),now) - A.begin());
        ll bot = N - (upper_bound(ALL(C),now) - C.begin());
        ans += top*bot;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
bool b[1000];
int main()
{
	int nb;
	cin>>nb;
	int nbok=0;
	for (int i=0;i<nb;i++)
	{
		int a;
		cin>>a;
		if (!b[a])
		{
			nbok++;
			b[a]=true;
		}
	}
	cout<<nbok;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <map>
#include <cstdlib>
#include <bitset>
#include <assert.h>
//defines
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
//const int N = int(3e5), mod = int(1e9)  + 7; 
//functions


using namespace std;    



int main () {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    string st;
    cin>>st;
    int res = 0;
    for(int i = 0; i<st.length(); i++){
    	if(st[i]=='o')res++;
    }
    cout<<700+100*res;
return 0;
}

Measured memory_bytes: 256
# Problem B - Easy Linear Programming

# input
A, B, C, K = map(int, input().split())

# initialization
ans = 0
# calc a
nokori = K
if nokori>=A:
    ans += 1 * A
    nokori -= A
else:
    ans += 1 * nokori
    nokori = 0

# calc b
if nokori>=B:
    nokori -= B
else:
    nokori = 0

# calc c
ans -= 1 * nokori

# output
print(ans)


Measured memory_bytes: 9192
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long
map<char, int> m;
signed main() {
    int a,b,m;
    cin >> a >> b>> m;
    vector<int> aa(a);
    rep(i,a) cin >> aa[i];
    vector<int> bb(b);
    rep(i,b) cin >> bb[i];
    int mi = inf;
    rep(i,m) {
        int x,y,c;
        cin >> x >> y >> c;
        x--; y--;
        mi = min(aa[x]+bb[y]-c,mi);
    }
    sort(aa.begin(),aa.end());
    sort(bb.begin(),bb.end());
    mi = min(aa[0]+bb[0],mi);
    cout << mi << endl;
  return 0;
}



Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)  
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
#define pp printf("Case %d: \n",t)
const unsigned int mod = 1e9+7;
const int mx=1000005;
const int maxInt = 2147483647;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,d;
    int ans=0;
    cin >> n >> d;
    int a[n][d];
    rep(i,n)rep(j,d)cin >> a[i][j];
    for(int i=0;i<n;++i){
    	for(int j=i+1;j<n;++j){
    		double p=0;
    		for(int k=0;k<d;++k){
    			p+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
    		}
    		if(floor(sqrt(p))==ceil(sqrt(p)))++ans;
    	}
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int dp[100005][3];
void solve(string s1,string s2){
  memset(dp,0,sizeof(dp));
  dp[0][0]=0;
  dp[0][1]=1000;
  dp[0][2]=1000;
  for(int i=0;i<s1.size();i+=2){
    if((s1[i]=='Y'||s1[i+1]=='Y')&&(s2[i]=='Y'||s2[i+1]=='Y')){
      dp[i+2][0]=min(dp[i][0]+3,min(dp[i][1]+2,dp[i][2]+2))+1;
      dp[i+2][1]=min(dp[i][0]+2,min(dp[i][1]+2,dp[i][2]+2))+1;
      dp[i+2][2]=min(dp[i][0]+2,min(dp[i][1]+2,dp[i][2]+3))+1;
    }
    else if(s1[i]=='Y'||s1[i+1]=='Y'){
      dp[i+2][2]=min(dp[i][0]+2,min(dp[i][1]+2,dp[i][2]+3))+1;
      dp[i+2][1]=min(dp[i][0]+1,min(dp[i][1]+1,dp[i][2]+2))+1;
      dp[i+2][0]=min(dp[i][0]+1,min(dp[i][1]+1,dp[i][2]+2))+1;
    }
    else if(s2[i]=='Y'||s2[i+1]=='Y'){
      dp[i+2][0]=min(dp[i][0]+3,min(dp[i][1]+2,dp[i][2]+2))+1;
      dp[i+2][1]=min(dp[i][0]+2,min(dp[i][1]+1,dp[i][2]+1))+1;
      dp[i+2][2]=min(dp[i][0]+2,min(dp[i][1]+1,dp[i][2]+1))+1;
    }
    else{
      dp[i+2][0]=min(dp[i][0],min(dp[i][1]+1,dp[i][2]+2))+1;
      dp[i+2][1]=min(dp[i][0]+1,min(dp[i][1],dp[i][2]+1))+1;
      dp[i+2][2]=min(dp[i][0]+2,min(dp[i][1]+1,dp[i][2]))+1;
    }
  }
  cout<<dp[s1.size()][0]-1<<endl;
}
void sol(){
  int n;
  cin>>n;
  string tmp,s1,s2;
  cin>>tmp;
  s1="N"+tmp.substr(0,n*2)+"N";
  s2="N"+tmp.substr(n*2)+"N";
  solve(s1,s2);
}
int main(){
  int TEST;
  cin>>TEST;
  while(TEST--)sol();
}


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

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

int gcd(int a, int b) 
{ 
	if (a == 0) 
		return b; 
	return gcd(b % a, a); 
} 

int main(){
  int n;
  scanf("%d",&n);
  int a[n];
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  vector<int> left(n+1,0) , right(n+1,0);
  for(int i=0;i<n;i++)  left[i+1]=gcd(left[i],a[i]);
  for(int i=n-1;i>=0;i--)  right[i]=gcd(right[i+1],a[i]);

 int res=0;
 for(int i=0;i<n;i++){
   int l=left[i];
   int r=right[i+1];


   chmax(res,gcd(l,r));
 }
 printf("%d\n",res);
 return 0;
}

Measured memory_bytes: 1408
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

s=input()
q=int(input())
query=[input().split() for i in range(q)]
now=0
d=deque(s)
# print(d)
for i in range(q):
    if query[i][0]=="1":
        now+=1
    else:
        if now%2==0:
            if query[i][1]=="1":
                d.appendleft(query[i][2])
            else:
                d.append(query[i][2])
        else:
            if query[i][1]=="1":
                d.append(query[i][2])
            else:
                d.appendleft(query[i][2])
if now%2==1:
    d.reverse()
print("".join(d))

Measured memory_bytes: 128684
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

ll mine(char q){
  if(q == '.'){
    return 0;
  } else{
    return 1;
  }
}

int main(){
  ll H, W;
  cin >> H >> W;
  string S;
  vvc HW(H, vc(W));
  rep(i, H){
    cin >> S;

    rep(j, W) HW[i][j] = S[j];
  }

  rep(i, H){
    rep(j, W){
      if(HW[i][j] == '#')
		cout << '#';
      else{
        ll cnt = 0;

        if(i > 0){
          if(j > 0) cnt += mine(HW[i - 1][j - 1]);
          cnt += mine(HW[i - 1][j]);
          if(j < W - 1) cnt += mine(HW[i - 1][j + 1]);
        }
        if(j > 0) cnt += mine(HW[i][j - 1]);
        if(j < W - 1) cnt += mine(HW[i][j + 1]);
        if(i < H - 1){
          if(j > 0) cnt += mine(HW[i + 1][j - 1]);
          cnt += mine(HW[i + 1][j]);
          if(j < W - 1) cnt += mine(HW[i + 1][j + 1]);
        }
        
        cout << cnt;
      }
    }

    cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();

        if (x>=2000){
            System.out.println(1);
            return;
        }
        if (x<100){
            System.out.println(0);
            return;
        }

        int n = String.valueOf(x).length();

        if (n==3){
            int tmp = (int)Math.pow(10, n-1);

            int top = x / tmp;

            int bottom = x % tmp;

            if ((0 <= bottom) && (bottom <= (top * 5))){
                System.out.println(1);
                return;
            }else {
                System.out.println(0);
                return;
            }
        }

        if (n==4){
            int tmp = (int)Math.pow(10, n-2);
            int top = x / tmp;

            int bottom = x % tmp;

            if ((0 <= bottom) && (bottom <= (top * 5))){
                System.out.println(1);
                return;
            }else {
                System.out.println(0);
                return;
            }
        }

    }
}

Measured memory_bytes: 23508
A, B, C, D, E, F = map(int, input().split())
A *= 100
B *= 100
water = []
sugar = []
for i in range(1+F//A):
    for j in range(1+F//B):
        if i * A + j * B <= F:
            water.append(i * A + j * B)
for i in range(1+F//C):
    for j in range(1+F//D):
        if i * C + j * D <= F:
            sugar.append(i * C + j * D)
max_sugar_percent = 0
max_sugar_water = 0
max_sugar = 0
water.sort()
sugar.sort()
for i in water:
    for j in sugar:
        if i + j > F:
            break
        if j > E * i / 100:
            break
        sugar_percent = i and (100 * j) / (i + j)
        if sugar_percent >= max_sugar_percent:
            max_sugar_percent = sugar_percent
            max_sugar = j
            max_sugar_water = i + j
print(max_sugar_water, max_sugar)

Measured memory_bytes: 13384
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;

ll diff(ll x, ll y, ll z){
	if(x <= y && y <= z) return z-x;
	if(x <= z && z <= y) return y-x;
	if(y <= x && x <= z) return z-y;
	if(y <= z && z <= x) return x-y;
	if(z <= x && x <= y) return y-z;
	return x-z;
}


int main(){
	ll H, W;
	cin >> H >> W;

	if(H%3==0 || W%3==0){
		cout << 0 << endl;
		return 0;
	}

	ll ans = 1e10;
	ans = min(ans, diff((H/3)*W, (H-H/3)*(W/2), (H-H/3)*(W-W/2)));
	ans = min(ans, diff((H/3+1)*W, (H-H/3-1)*(W/2), (H-H/3-1)*(W-W/2)));
	ans = min(ans, diff((W/3)*H, (W-W/3)*(H/2), (W-W/3)*(H-H/2)));
	ans = min(ans, diff((W/3+1)*H, (W-W/3-1)*(H/2), (W-W/3-1)*(H-H/2)));
	ans = min(ans, diff((W/3)*H, (W/3+1)*H, (W-2*W/3-1)*H));
	ans = min(ans, diff((H/3)*W, (H/3+1)*W, (H-2*H/3-1)*W));

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
N, M = map(int, input().split())
if M == 1 or N >= M: print(0); exit()

X = sorted(list(map(int, input().split())))
if N == 1: print(max(X) - min(X)); exit()

dif = list(sorted([[X[i+1] - X[i], i] for i in range(M-1)], reverse=True))[:N-1]
col = [x[1] for x in dif]
if col[0]:
	l = col[0]
	s = X[l] - X[0]
else:
	l = 0
	s = 0

col.append(M-1)

for i in col:
	s += X[i] - X[l]
	l = i+1
print(s)

Measured memory_bytes: 21520
#include<bits/stdc++.h>
using namespace std ;
int a[110] ;
int main(){
    int n ;
    cin >> n ;
    for( int i = 1 ; i <= n ; i++ )
        cin >> a[i] ;
    int minx , maxx ;
    minx = maxx = a[1] ;
    for( int i = 2 ; i <= n ; i++ ){
        minx = min( minx , a[i] ) ;
        maxx = max( maxx , a[i] ) ;
    }
    cout << maxx - minx << endl ;
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

int k, x;
int main() {
    IOS
    cin >> k >> x;
    for (int i = x-k+1; i < x+k; ++i) {
        cout << i << " \n"[i==x+k-1];
    }

    return 0;


}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int n;
    int middle;
    long long ans = 1000000000000000;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
        a.at(i) -= i + 1;
    }
    sort(a.begin(), a.end());
    long long sum = 0;
    if (n % 2 == 0) {
        for (int i = a.at(n / 2); i <= a.at(n / 2 + 1); i++) {
            sum = 0;
            for (int j = 0; j < n; j++) {
                sum += abs(a.at(j) - i);
            }
            ans = min(ans, sum);
        }
    }
    else {
        middle = a.at(n / 2);
        for (int i = 0; i < n; i++) {
            sum += abs(a.at(i) - middle);
        }
        ans = sum;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main()
{

int i,j;
long int K,A,B,k=1;

scanf("%ld %ld %ld",&K,&A,&B);

if((B-A)>2){
K = K - (A-1);
if((K%2)==0){
k = A + ((K)/2 * (B-A));
}
else{
k = A + ((K)/2 * (B-A))+1;
}
}
else
k = k+ K;

printf("%ld\n",k);

return 0;
} 


Measured memory_bytes: 128
import sys

sys.setrecursionlimit(10 ** 9)


# map(int, sys.stdin.read().split())


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    be = 100
    ans = 0
    for i in A:
        ans += B[i - 1]
        if be == i - 1:
            ans += C[i - 2]
        be = i

    print(ans)


if __name__ == "__main__":
    main()


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//end



int main(){
   int n; scanf("%d",&n);
   vector<int> a(3*n); rep(i,0,3*n)scanf("%d",&a[i]);
   sort(ALL(a),greater<int>());
   ll res=0;
   rep(i,1,n+1)res+=a[i*2-1];
   printf("%lld\n",res);
   return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> X_with_idx;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        X_with_idx.emplace_back(tmp, i);
    }
    sort(X_with_idx.begin(), X_with_idx.end());
    vector<int> org_idx_to_sorted(N, 0);
    for (int i = 0; i < N; i++) {
        int org_i = X_with_idx.at(i).second;
        org_idx_to_sorted.at(org_i) = i;
    }
    int left_mid = X_with_idx.at(N / 2 - 1).first;
    int right_mid = X_with_idx.at(N / 2).first;
    for (int i = 0; i < N; i++) {
        int sorted_pos = org_idx_to_sorted.at(i);
        int mid = (sorted_pos >= N / 2) ? left_mid : right_mid;
        cout << mid << "\n";
    }
}


Measured memory_bytes: 4592
n,m=map(int,input().split())

tree=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  tree[a].append(b)
  tree[b].append(a)

for i in tree[0]:
  for j in tree[i]:
    if j==n-1:
      print('POSSIBLE')
      exit()
print('IMPOSSIBLE')

Measured memory_bytes: 38320
def check(a):
  n=len(a)
  if n%2:
    return -1
  else:
    if s[0:n//2]==s[n//2:n]:
      return 0
    else:
      return -1

s=input()
x=len(s)
for i in range(1,x):
  A=s[0:x-i]
  if check(A)==0:
    print(len(A))
    break

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <climits>

using namespace std;
using ll = long long;
using pint = pair<int, int>;

bool isKaibun(string& S) {
	bool ans = true;
	for (int i = 0; i < S.size() / 2; ++i) {
		if (S[i] != S[S.size() - 1 - i]) {
			ans = false;
			break;
		}
	}
	return ans;
}

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

	bool ans = isKaibun(S);
	if (!ans) {
		cout << "No" << endl;
		return 0;
	}

	string tmp = S.substr(0, ((S.size() - 1) / 2));
	ans = isKaibun(tmp);
	if (!ans) {
		cout << "No" << endl;
		return 0;
	}

	tmp = S.substr(((S.size()+3) / 2) -1);
	ans = isKaibun(tmp);
	if (!ans) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
	return 0;
}


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

int main(){
    string f;
    string w;
    int c = 0;
    cin>>f>>w;
    for(int i=0;i<3;i++){
        if(f.at(i)==w.at(i)){
            c++;
        }
    }
    cout<<c<<endl;
}

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

#define ll long long int

using namespace std;

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll num, sum = 0, a;
  cin >> num;
  for (ll i = 1; i <= num; i++){
    a = num / i;
    sum += ((1 + a) * a / 2) * i;
  }
  cout << sum << '\n';
  return 0;
}


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

int main() {
	string S;
	cin >> S;
	int count = 0;
	for (int i = 0; i < S.size(); ++i) {
		if ('1' == S[i]) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

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

int main() {
    int n, k; cin >> n >> k;
    string s; cin >> s;
    int cnt = 0;

    for (int i = 0; i < n - 1; i++) {
        if (s[i] == 'R' && s[i + 1] == 'L') cnt++;
    }

    if (cnt < k) cout << n - 1 << endl;
    else {
        int happy = n - 2 * (cnt - k);
        if (s[0] == 'L') happy--;
        if (s[n - 1] == 'R') happy--;
        if (happy == n) happy--;
        cout << happy << endl;
    }

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  300005

vi X(N),Y(N);
void solve()
{
    ll h,w,m,x,y;
    cin>>h>>w>>m;
    map<pii,ll>lol;
    rep(i,0,m)
    {
        cin>>x>>y;
        lol[{x,y}]=1;
        X[x]++;
        Y[y]++;
    }
    ll mx=*max_element(all(X));
    ll my=*max_element(all(Y));
    vi vx,vy;
    rep(i,1,N)
    {
        if(X[i]==mx)
        {
            vx.pb(i);
        }
        if(Y[i]==my)
        {
            vy.pb(i);
        }
    }
    ll ans=mx+my-1,res=0;
    for(auto u:vx)
    {
        for(auto v:vy)
        {
            if(lol.find({u,v})==lol.end())
            {
                ans++;
                cout<<ans<<endl;
                return;
            }
        }
    }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 32992
import java.util.Scanner;
public class Main{
	public static void main(String[] args){

        Scanner s = new Scanner(System.in);
		int n,i;
        n = s.nextInt();
        int[] gya=new int[n];		//逆列
        
        for(i=0;i<gya.length;i++){
			n = s.nextInt();
            gya[i]=n;
        }
        for(i=gya.length-1;i>=0;i--){
System.out.print(gya[i]);
        if(i!=0)System.out.print(" ");
        else System.out.println();
}
            
       
		s.close();
	}
}


Measured memory_bytes: 26412