akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>

#define CK(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long  LLINF = 1e18;

using namespace std;


/*==================================================*/

/*==================================================*/

int N;
long long T[100005], A[100005];

const long long MOD = 1000000007;

int main(){
  cin>>N;
  REP(i,0,N) cin>>T[i];
  REP(i,0,N) cin>>A[i];

  //矛盾の確認
  for(int i = N-1; 0 <= i; i--){
    if(i < N-1){
      if(A[i] > T[i] && A[i] > A[i+1]){
        cout<<0<<endl;
        return 0;
      }
    }
    if(i == N-1){
      if(A[i] > T[i]){
        cout<<0<<endl;
        return 0;
      }
    }

    //例外
    if(i > 0 && i < N-1){
      if(T[i-1] < T[i] && A[i] > A[i+1]  && A[i] != T[i]){
        cout<<0<<endl;
        return 0;
      }
    }
  }

  for(int i = 0; i<N; i++){
    if(i > 0){
      if(T[i] > A[i] && T[i] > T[i-1]){
        cout<<0<<endl;
        return 0;
      }
    }
    if(i == 0){
      if(T[i] > A[i]){
        cout<<0<<endl;
        return 0;
      }
    }

    //例外
    if(i > 0 && i < N-1){
      if(T[i-1] < T[i] && A[i] > A[i+1]  && A[i] != T[i]){
        cout<<0<<endl;
        return 0;
      }
    }
  }



  //確定した標高を決める
  bool flag[100005];
  REP(i,0,N) flag[i] = false;

  flag[0] = true;
  REP(i,1,N){
    if(T[i-1] < T[i]){
      flag[i] = true;
      //cout<<"i: "<<i<<", i+1: "<<i+1<<"@T"<<endl;
    }
  }

  flag[N-1] = true;
  for(int i = N-2; 0 <= i; i--){
    if(A[i] > A[i+1]){
      //cout<<"i: "<<i<<", i+1: "<<i+1<<"@A"<<endl;
      flag[i] = true;
    }
  }

  //答えの計算
  long long h[100005];
  REP(i,0,N) h[i] = -1;
  REP(i,0,N){
    if(flag[i]) continue;
    h[i] = min(A[i], T[i]);
  }

  long long ans = 1;
  REP(i,0,N){
    if(flag[i]) continue;
    ans = (ans * h[i]) % MOD;
  }
  //test
  //REP(i,0,N) cout<<h[i]<<" ";
  //cout<<endl;

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
   string S;
   cin>>S;
   bool OK=true;
   map<char,int> data;
   rep(i,4){
      data[S[i]]++; 
   }
   if(data.size()!=2){
       OK=false;
   }
   for(auto p:data){
       auto v=p.second;
       if(v!=2){
           OK=false;
       }
   }
   if(OK==true){
       cout<<"Yes"<<endl;
   }
   else{
       cout<<"No"<<endl;
   }
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <fstream>
using namespace std;
#define mp make_pair

vector<int> median(vector<int> v) {
	sort(v.begin(), v.end());
	int n = v.size();
	vector<int> ret;
	for (int i=(n-1)/2; i<=(n+1)/2; ++i) {
		if (i < 0 || n <= i) continue;
		ret.push_back(v[i]);
	}
	return ret;
}

int main() {
	int W, H, N;
	cin >> W >> H >> N;
	vector<int> xs(N), ys(N);
	for (int i=0; i<N; ++i) {
		cin >> xs[i] >> ys[i];
	}
	vector<int> mx = median(xs);
	vector<int> my = median(ys);
	long long res = LLONG_MAX;
	int x, y;
	for (int i=0; i<(int)mx.size(); ++i) {
		for (int j=0; j<(int)my.size(); ++j) {
			long long time = 0, m = 0;
			for (int k=0; k<N; ++k) {
				long long t = abs(xs[k] - mx[i]) + abs(ys[k] - my[j]);
				time += t;
				m = max(m, t);
			}
			long long res2 = 2 * time - m;
			if (mp(res2, mp(mx[i], my[j])) < mp(res, mp(x, y))) {
				res = res2;
				x = mx[i];
				y = my[j];
			}
		}
	}
	cout << res << endl;
	cout << x << " " << y << endl;
	return 0;
}

Measured memory_bytes: 2328
import sys
sys.setrecursionlimit(10**6)

def main():
    input = sys.stdin.readline
    V = 10**5  # max size of x
    N = int(input())
    bgraph = [[] for _ in range(2*V)]
    for _ in range(N):
        x, y = map(int, input().split())
        x -= 1
        y += V - 1
        bgraph[x].append(y)
        bgraph[y].append(x)

    def dfs(i):
        if visited[i]:
            return cnt
        visited[i] = True
        cnt[i//V] += 1
        for j in bgraph[i]:
            dfs(j)
        return cnt

    visited = [False] * (2*V)
    ans = 0
    for i in range(V):
        if visited[i]:
            continue
        cnt = [0, 0]
        cnt = dfs(i)
        ans += cnt[0] * cnt[1]

    ans -= N
    return ans


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


Measured memory_bytes: 96816
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,count=0;
  cin >>n >>m;
  int a[n+1];
  for(int i=0;i<n+1;i++)a[i]=0;
  int l[m],r[m];
  for(int i=0;i<m;i++){
    cin >> l[i] >> r[i];
    a[l[i]-1]++;
    a[r[i]]--;
  }
  if(a[0]==m)count++;
  for(int i=0;i<n;i++){
    a[i+1]=a[i]+a[i+1];
    if(a[i+1]==m)count++;
  }
  cout <<count <<endl;
  
}

Measured memory_bytes: 1408
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
int main() {
	int n, p[8], q[8], t[8], pCnt, qCnt, cnt = 0;
	bool isUse[8], isPerm, isP, isQ;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &p[i]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &q[i]);
	}
	for (int i = 0; i < pow(n, n) - 1; i++) {
		int num = i;
		isPerm = true;
		for (int j = 0; j < n; j++) {
			isUse[j] = false;
		}
		for (int j = 0; j < n; j++) {
			t[j] = num % n + 1;
			isUse[t[j] - 1] = true;
			num /= n;
		}
		for (int j = 0; j < n; j++) {
			if (!isUse[j]) {
				isPerm = false;
				break;
			}
		}
		if (isPerm) {
			cnt++;
			isP = isQ = true;
			for (int j = 0; j < n; j++) {
				if (t[n - j - 1] != p[j]) {
					isP = false;
				}
				if (t[n - j - 1] != q[j]) {
					isQ = false;
				}
				if (!isQ && !isP)
					break;
			}
			if (isP) {
				pCnt = cnt;
			}
			if (isQ) {
				qCnt = cnt;
			}
		}
	}
	printf("%d\n", abs(pCnt - qCnt));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<cstring>
#include<math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<cctype>
#include<utility>
#include<set>
#include<map>
#include<sstream>
#include<iterator>
#include<limits>
#include<map>
#include<deque>
#include<stack>
#include<queue>
using namespace std;
#define pb push_back
#define ff(i,a,b) for(int i=a;i<b;++i)
#define ffl(i,a,b) for(long long i=a;i<b;++i)
#define all(v) v.begin(), v.end() 
#define X first
#define Y second
#define mp make_pair
typedef long long ll;
typedef std::vector<int> vec;
typedef std::vector<long long> vecl;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef std::pair<int,int> pii;
typedef pair<ll,ll> pll; 
const int md = 1000000007;
#define pi 3.141592653589793238462643383279

bool sortbysec(const pair<int,int> &a, const pair<int,int> &b){ 
    return (a.second < b.second); 
} 
int main() {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);    
    
 	int tt{},T{};
 	//cin>>tt;T=tt;
    tt=1;
 	while(tt--){
        //cout<<"------------- #"<<T-tt<<endl;
        ll n{},m{},ans{},k{},a{},x,y,b{},c{},f{};
        
        cin>>n;
        vector<pll> v;
        ff(i,0,n){
            cin>>a>>b;
            v.pb(mp(a,b));
        }
        //sort(all(v));
        map<pll,int> mm;
        a=md;
        x=-md,y=md;
        b=-md;
        //vecl vv;
        ff(i,0,n){
            //if(mm[pll(v[i].X,v[i].Y)]==0){
                mm[pll(v[i].X,v[i].Y)]=1;
            a=min(a,v[i].X+v[i].Y);
            b=max(b,v[i].X+v[i].Y);
            
            x=max(x,(v[i].X-v[i].Y));
            y=min(y,(v[i].X-v[i].Y));
            //vv.pb(abs(v[i].X-v[i].Y));
           // }
        }
        //sort(vv.rbegin(),vv.rend());
        
        cout<<max(abs(b-a),abs(x-y))<<"\n";
    }
    
    
	return 0;
}


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

int main(){
	int n;
	double ans = 0;
    cin >> n;
	rep(i,n){
		double x;
		string u;
		cin >> x >> u;
		if(u == "JPY") ans += x;
		else ans += x*double(380000);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();

    int P = A * B;
    int Q = C * D; 
    if(P < Q ) {
      System.out.println(Q);
    }else{
      System.out.println(P);
    }
  }
}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
#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 repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define loop(i,a,B) for (int i = a; i B; i++)
#define loopR(i,a,B) for (int i = a; i B; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", my_dmp(#__VA_ARGS__, __VA_ARGS__)
void my_dmp(const char*) { cerr << endl; }
template <class T, class... U>
void my_dmp(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; my_dmp(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
#define OUTPUT(...) ostream& operator<<(ostream& os, __VA_ARGS__ const& v) { os << "{"; for (auto const& x : v) os << " " << x; return os << " }"; }
template <class T> OUTPUT(vector<T>)
template <class T> OUTPUT(deque<T>)
template <class T> OUTPUT(set<T>)
template <class T> OUTPUT(multiset<T>)
template <class T, class U> OUTPUT(map<T,U>)
#undef OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S>& p) { return is >> p.first >> p.second; }
struct my_Init { my_Init() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } my_init;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
template <class It> auto sumof(It b, It e) { return accumulate(b,e,typename iterator_traits<It>::value_type{}); }
////////////////////////////////
int n,m,L;
const int MAX_N = 300 + 10, INF = 1e15;
int d[MAX_N][MAX_N], d2[MAX_N][MAX_N];

int32_t main() {
    rep (i,MAX_N) rep (j,MAX_N) d[i][j] = d2[i][j] = INF;
    rep (i,MAX_N) d[i][i] = d2[i][i] = 0;
    
    cin >> n >> m >> L;
    rep (i,m) {
        int a,b,c; cin >> a >> b >> c; a--,b--;
        d[a][b] = d[b][a] = c;
    }
    rep (k,n) rep (i,n) rep (j,n) chmin(d[i][j], d[i][k] + d[k][j]);
    rep (i,n) rep (j,n) if (d[i][j] <= L) chmin(d2[i][j],1LL);
    rep (k,n) rep (i,n) rep (j,n) chmin(d2[i][j], d2[i][k] + d2[k][j]);

    int q; cin >> q;
    while (q--) {
        int s,t; cin >> s >> t; s--,t--;
        int x = d2[s][t];
        cout << (x == INF ? -1 : x-1) << "\n";
    }
}


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

using ll = long long int;
using P = pair<int, int>;
using P3 = pair<ll,P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-8;

int V, E;
vector<vector<int> > g;
vector<char> ch;

bool solve(){
    cin >> V >> E;
    g.resize(V);
    ch.resize(V);
    for(int i=0;i<V;i++){
        cin >> ch[i];
    }
    for(int i=0;i<E;i++){
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<bool> used(26);
    for(int i=0;i<V;i++){
        if(ch[i] != '?') continue;
        fill(used.begin(),used.end(),false);
        for(auto j : g[i]){
            if(ch[j]=='?') continue;
            used[ch[j]-'a'] = true;
        }
        for(int j=0;j<26;j++){
            if(!used[j]){
                ch[i] = char('a'+j);
                break;
            }
        }
    }
    for(auto c: ch){
        cout << c;
    }
    cout << endl;
    return false;
}

int main(){
    solve();
    // while(!solve());
    // int t; cin >> t; for(;t>0;t--) solve();
    return 0;
}


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

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

int n, hmax;
bool maps[6000][5];

int serch(int x, int l) {
	for (int i = hmax; i >= 0; i--) {
		REP(j, l) if (maps[i][x + j]) return i + 1;
	}
	return 0;
}

int check(int y, int l) {
	REP(i, l) {
		bool flag = true;
		REP(j, 5) if (!maps[y + i][j]) flag = false;
		if (flag) return y + i;
	}
	return -1;
}

void bset(int d, int p, int q) {
	int hl = d == 2 ? p : 1;
	int xl = d == 1 ? p : 1;
	int hpos = serch(q - 1, xl);
	
	if (d == 1) REP(i, p) maps[hpos][q + i - 1] = true;
	else REP(i, p) maps[hpos + i][q - 1] = true;
	hmax = max(hmax, hpos + hl);
	
	int tmp;
	while ((tmp = check(hpos, hl)) != -1) {
		REP(i, 5) maps[tmp][i] = false;
		FOR(i, tmp, hmax) {
			REP(j, 5) swap(maps[i][j], maps[i + 1][j]);
		}
		hmax--;
	}
}

int main() {
	while (cin >> n, n) {
		memset(maps, 0, sizeof(maps));
		hmax = 0;
		
		while (n--) {
			int d, p, q;
			scanf("%d %d %d", &d, &p, &q);
			bset(d, p, q);
		}
		cout << count(maps[0], maps[6000], true) << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
#define watch(x) cout << (#x)<<" = "<<x<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}

int main() {
	file();
	fast();
	bool ok = 0;
	int n; cin >> n;
	vii v1(n);
	for (auto& it : v1)
		cin >> it.first >> it.second;
	for (int i = 0; i + 2 < n; i++) {
		if (v1[i].first == v1[i].second && v1[i + 1].first == v1[i + 1].second &&
			v1[i + 2].first == v1[i + 2].second)
			ok = 1;
	}
	cout << (ok == 1 ? "Yes" : "No") << endl;
	return 0;
}

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

int main()
{
    unsigned long long n,k; cin >> n >> k;

    if(n%k==0){
        cout << 0 << endl; return 0;
    }
    unsigned long long a = n%k;

    if(n>=k) n-=k;
    else n = k-n;

    unsigned long long b = n%k;

    a = (a>=k)? (a>=(a-k)?a-k:a) : (a>=(k-a)?k-a:a);
    b = (b>=k)? (b>=(b-k)?b-k:b) : (b>=(k-b)?k-b:b);

    if(a<=b){
        cout << a << endl;
    }
    else{
        cout << b << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
const int64_t INF = 1000000000000000;
const int64_t MOD = 1000000007;

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

int64_t N , M; cin >> N >> M;
if (N < M) swap(N, M);

int64_t ans = 1;
if (N == M){
    rep(i, 1, N+1) ans = ans * i % MOD;
    ans *= ans * 2;
}
else if (N - M == 1){
    rep(i, 1, M+1) ans = ans * i % MOD;
    ans *= (ans * N) % MOD;
}
else ans = 0;

cout << ans % MOD << endl;


}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

void solve(long long N, long long K, std::vector<long long> x){
    ll ans = INF;
    for(ll i = 0; i < N - K + 1; ++i){
        ans = min(ans, abs(x[i]) + abs(x[i+K-1] - x[i]));
        ans = min(ans, abs(x[i+K-1]) + abs(x[i+K-1] - x[i]));
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> a(n, vector<ll>(m));
  rep(i, n) {
    rep(j, m) {
      cin >> a[i][j];
      --a[i][j]; // 0-indexed
    }
  }
  // cout << "a:" << endl;
  // printtree(a);

  set<ll> hidden;
  ll ans = INF;
  rep(iter, m) { // loop for the number of sports
    // Here, we calculate the most populate one.
    vector<ll> cnts(m);
    rep(i, n) {
      // cout << i << ": ";
      rep(j, m) {
        if (hidden.find(a[i][j]) == hidden.end()) { // not in hidden
          ++cnts[a[i][j]];
          // cout << a[i][j] << endl;
          break;
        }
      }
    }
    // cout << "cnts: "; printvec(cnts);

    // Here, we want to know the maximum count
    ll maxCnt = 0;
    ll popularSport;
    rep(i, m) {
      if (maxCnt < cnts[i]) {
        maxCnt = cnts[i];
        popularSport = i;
      }
    }

    ans = min(ans, maxCnt); // update by current maxCnt
    hidden.insert(popularSport);
  }

  cout << ans << endl;
}


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

using namespace std;

int main(){

  	int n,a,b;
  
  	cin>>n>>a>>b;
  
  	if(n*a<b)
		cout<<(n*a)<<"\n";
	else
      	cout<<b<<"\n";
  
	return 0;
}

Measured memory_bytes: 256
import heapq
n,m = map(int,input().split())
ma = {}
for _ in range(n):
    a,b = map(int,input().split())
    start = a
    if start<0:
        continue
    if start in ma:
        ma[start].append(-b)
    else:
        ma[start] = [-b]
li = []
heapq.heapify(li)
ans_li = []
#print(li,ma)
for i in range(m):
    if i+1 in ma:
        for m in ma[i+1]:
            heapq.heappush(li, m)
    if len(li)>0:
        tmp = heapq.heappop(li)
        ans_li.append(-tmp)
        #print(tmp)
print(sum(ans_li))

Measured memory_bytes: 29408
// Problem : E - Count Median
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#define w cout
#define e '\n'
#define int long long
#define sz(x) (int)x.size()
#define re return 
#define vi vector<int>
#define vii vector<pair<int ,int > >
#define F first
#define S second
#define pussy push_back
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

const int N = 1e6 , mod = 1e9 + 7;

void solve() {
	int n;cin >> n ;
	vector<pair<int,int> > v(n);
	for(auto &i : v) cin >> i.F >> i.S;
	vi mn,mx;
	for(auto i : v) {
		mn.pussy(i.F);
		mx.pussy(i.S);
	}
	sort(begin(mn) , end(mn));
	sort(begin(mx) , end(mx));
	int maxx = 0,minn = 0;
	if(n % 2) {
		minn = mn[n/2];
		maxx = mx[n/2];
	} else {
		minn = mn[n/2 - 1] + mn[n/2];
		maxx = mx[n/2 - 1] + mx[n/2];
	}
w << maxx - minn + 1 << endl;
}

signed main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
	int t = 1;
	// cin >> t;
	while(t--) {
		solve();
	}	
}


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

int main(){
	int h,w,n;
	static bool field[1001][1001] = {};
	static int dp[1001][1001] = {};
	while(cin >> h >> w >> n,h){
		for(int i = 0;i <= h;i++){
			for(int j = 0;j <= w;j++) {
				field[i][j] = false;
				dp[i][j] = 0;
			}
		}
		dp[0][0] = n - 1;
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				cin >> field[i][j];
			}
		}
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				dp[i + 1][j] += dp[i][j] / 2;
				dp[i][j + 1] += dp[i][j] / 2;
				if(dp[i][j] % 2 == 1){
					if(!field[i][j]) dp[i + 1][j]++;
					else dp[i][j + 1]++;
					field[i][j] = !field[i][j];
				}
			}
		}
		int x = 0,y = 0;
		while(x < h && y < w){
			if(field[x][y]) y++;
			else x++;
		}
		cout << x + 1 << " " << y + 1 << endl;
	}
	return 0;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  for(int i=0;i<W+2;i++){
   cout << "#" ;
  }
  cout << endl;
  
  string s;
  for(int i=0;i<H+1;i++){
     getline (cin,s);
    if(i==0){
      continue;
    }
    cout << "#" << s << "#" << endl;
  }
  
  for(int i=0;i<W+2;i++){
   cout << "#" ;
  }
  cout << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int N,A,B;
	cin>>N>>A>>B;
	print(min(B,A*N));
	return 0;
}


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

int main(){
  int n;
  cin>>n;
  string s;
  set<string> set;
  for(int i=0;i<n;i++){   
    cin>>s;
    set.insert(s);
  }
  cout<<set.size()<<endl;
}
    
  
  
  
  


Measured memory_bytes: 19252
strs=input()
che=True
c=True
coun=False
for i in range(0,len(strs)) :
    if(i==0):
        c=True if strs[i]=="A" else False
    else :
        if(strs[i].isupper()):
            if( (not coun) and i>=2 and i<=len(strs)-2 and strs[i]=='C'):
                coun=True
            else:
                che=False
print("AC") if che and coun and c else print("WA")



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

using namespace std;


int main(){
    int n;
    cin>>n;
    vector<pair<long long,long long>> val(n,pair<long long,long long>());

    for(int i=0;i<n;i++){
        cin>>val.at(i).second>>val.at(i).first;
    }

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

    long long cv=0;
    int t = 0;
    for(int i=0;i<n;i++){
        cv += val.at(i).second;
        if(cv>val.at(i).first){
            t = 1;
            cout<<"No"<<endl;
            break;
        }
    }

    if(t==0){
        cout<<"Yes"<<endl;
    }
}


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

int main( ){
    long long n,k;
    cin>>n;
    k = sqrt(n);
    
    for(long long i=k;i>=1;i--){
        if(i * (n/i) == n){
            cout<<i+(n/i)-2;
            return 0;
        }
    }
    
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <vector>

using namespace std;

#define debug(x) (cout << # x ": " << x << endl)
#define int long long int
#define repeat(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()

signed main() {
    int x, y, a, b ,c;
    cin >> x >> y >> a >> b >> c;

    vector<int> va, vb, vc;
    repeat(i, a) {
        int x;
        cin >> x;
        va.push_back(x);
    }
    repeat(i, b) {
        int x;
        cin >> x;
        vb.push_back(x);
    }
    repeat(i, c) {
        int x;
        cin >> x;
        vc.push_back(x);
    }

    sort(all(va), std::greater());
    sort(all(vb), std::greater());

    repeat(i, a - x) {
        va.pop_back();
    }
    repeat(i, b - y) {
        vb.pop_back();
    }

    vector<int> v;
    for (auto x: va) {
        v.push_back(x);
    }
    for (auto x: vb) {
        v.push_back(x);
    }
    for (auto x: vc) {
        v.push_back(x);
    }

    int ans = 0;

    sort(all(v), greater());
    auto it = v.begin();
    repeat(i, x + y) {
        ans += *it;
        ++it;
    }

    cout << ans;
    
    return 0;
}


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

string s, t;

int main(void){
	cin >> s >> t;
	int n = s.size();
	rep(i, s.size()){
		char r;
		r = s[n-1];
		s = r+s.substr(0, n-1);
		if(s == t){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <cmath>
#include <algorithm>
#include <cstring>
#include <cstdio>
 
using namespace std;
 
int dp[100][5000];
int const mod=100000;
 
int main(){
    int N,M,S;
    while(scanf("%d%d%d",&N,&M,&S)!=EOF && N|M|S){
        memset(dp,0,sizeof(dp));
        dp[0][0]=1;
        for(int i=1; i<=M; ++i){
            for(int j=N*N; j>0; --j){
                for(int k=i; k<=S; ++k){
                    dp[j][k]+=dp[j-1][k-i];
                    dp[j][k]%=mod;
                }
            }
        }
 
        printf("%d\n",dp[N*N][S]%mod);
    }
}

Measured memory_bytes: 4672
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int[][] a = new int[4][4];
		for(int i = 0; i < 4; i++) {
			a[i][0] = stdIn.nextInt();
			a[i][1] = stdIn.nextInt();
		}
		for(int i = 0; i< 4; i++) {
			switch(a[i][0]) {
			case 1: System.out.println(a[i][1] * 6000);break;
			case 2: System.out.println(a[i][1] * 4000);break;
			case 3: System.out.println(a[i][1] * 3000);break;
			case 4: System.out.println(a[i][1] * 2000);break;
			}
		}
	}
		
}

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

void solve() {
    int n;
    cin >> n;
    vector<int>w(n + 1), e(n + 1);
    int sw = 0, se = 0;
    vector<char> s(n);
    for (int i = 0; i < n; i++) {
        char x;
        cin >> x;
        s[i] = x;
        if(s[i] == 'W') {
            sw++;
        }
        else {
            se++;
        }
        w[i + 1] = sw;
        e[i + 1] = se;
    }
    int ans = 3 * 1e5 + 1;
    for (int i = 0; i <= n; i++) {
        ans = min(ans, w[i - 1] + e[n] - e[i]);
    }
    cout << ans;

}

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


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

using namespace std;
using ll = long long;
int MOD = (int)(1e9 + 7);

int mult (int a, int b) {
	return ((a % MOD) * 1LL * (b % MOD)) % MOD;
}

int add (int a, int b) {	
	b = (b + MOD) % MOD;
	return (a + b) % MOD;
}

int pw (int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) {
			res = mult (res, a);
		}
		b >>= 1;
		a = mult (a, a);
	}
	return res;
}

int main () {
	ll n, a, b;
	cin >> n >> a >> b;
	int ans = add (pw(2, n), -1), aa = 1, bb = 1, da = 1, db = 1;
	for (int i = 1; i <= a; i++) {
		da = mult (i, da);
		aa = mult (n - i + 1, aa);
	}
	for (int i = 1; i <= b; i++) {
		db = mult (db, i);
		bb = mult (n - i + 1, bb);
	}
	ans = add (ans, -1 * (mult (aa, pw (da, MOD - 2))));
	ans = add (ans, -1 * (mult (bb, pw (db, MOD - 2))));
	cout << ans << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

struct _Node{
  int key;
  struct _Node *next;
  struct _Node *prev;
};
typedef struct _Node Node;

Node *nil;

void insert(int key) {
  Node *n;
  n = (Node *)malloc(sizeof(Node));
  n->key = key;
  n->next = nil->next;
  nil->next = nil->next->prev = n;
  n->prev = nil;
}

void deleteNode(Node *n) {
  n->prev->next = n->next;
  n->next->prev = n->prev;
}

void delete(int key) {
  Node *n;
  for (n = nil->next; n != nil; n = n->next) {
    if (n->key == key) {
      deleteNode(n);
      return;
    }
  }
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

int main() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
  int i, key, N;
  char *command;
  command = (char *)malloc(sizeof(char) * 12);

  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf(" %s", command);
    switch(*command) {
    case 'i': scanf(" %d", &key); insert(key); break;
    default :
      switch(*(command + 6)) {
      case 'F': deleteFirst(); break;
      case 'L': deleteLast(); break;
      default: scanf(" %d", &key); delete(key); break;
      }
    }
  }

  Node *node;
  for (node = nil->next;; node = node->next) {
    if (node->next == nil) {
      printf("%d\n", node->key);
      break;
    }
    printf("%d ", node->key);
  }
  return 0;
}



Measured memory_bytes: 36116
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}

		int ans = 0;

		for (int i = 0; i < N - 1; i++) {
			for (int j = i + 1; j < N; j++) {
				if(ans<Math.abs(A[i]-A[j])){
					ans=Math.abs(A[i]-A[j]);
				}
			}
		}
		System.out.println(ans);
		sc.close();

	}
}


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

#define pb push_back
#define fi first
#define se second
#define eb emplace_back

using namespace std;
typedef pair<int, int> ii;
typedef long long ll;

const double pi = 3.141592653589793;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    double r; cin >> r;

    cout << fixed << setprecision(4) << r * 2.0 * pi << endl;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if( a%3 == 0 || b%3 == 0 || (a+b)%3 == 0 ){
    cout << "Possible" << endl;
  }else{
	cout << "Impossible" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	mp := make(map[string]int)

	for i := 0; i < 4; i++ {
		mp[s[i:i+1]]++
	}

	if len(mp) == 2 && mp[s[0:1]] == 2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
string s;
int main(){
	ios::sync_with_stdio(0);
	cin>>s;
	if(s.size()%2)
	cout<<"No";
	else{
		bool ok=true;
		while(s.size()>=2){
			if(s[0]!='h'||s[1]!='i')
			ok=false;
			if(!ok)
			break;
			s=s.substr(2);
		}
		if(!ok)
		cout<<"No";
		else
		cout<<"Yes";
	}
	re 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define mod         (ll)1000000007
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = (ll)1e18;
ld pi = 3.141592653589;
using namespace std;

ll bpow(ll x, ll v) {	
	if (v == 0)
		return 1 % mod;
	if (v % 2 == 1)
		return (x * bpow(x, v - 1)) % mod;
	ll r = bpow(x, v / 2);
	return (r * r) % mod;	
}

ll lcm(ll a,ll b)
{
	ll ret=(a*b)/__gcd(a,b);
	return ret;
} 

ll solve(){ 
	string a; cin>>a;
	lp(i,0,sz(a)) cout<<"x";
}
int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
    	solve();
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  int n,c;
  cin>>n>>c;
  long long a[n],b[n];
  REP(i,n){
    cin>>a[i];
  }
  REP(i,n){
    cin>>b[i];
  }
  
  long long g[n][c+1]={};
  REP(i,n){
    REP(r,c+1){
      for(int x = a[i];x<=b[i];x++){
        g[i][r] += po(x,r);
        g[i][r] = mod(g[i][r]);
      }
    }
  }
  
  long long dp[n][c+1]={};
  REP(i,n){
    if(i==0){
      REP(j,c+1){
        dp[i][j] = g[i][j];
      }
    }else{
      REP(j,c+1){
        for(int k=0;k<=j;k++){
          dp[i][j] += dp[i-1][k]*g[i][j-k];
          dp[i][j] = mod(dp[i][j]);
        }
      }
    }
  }
  
  long long ans;
  ans = dp[n-1][c];
  cout<<ans<<endl;
  return 0;
}


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

int main() {
    int n, m, ac=0, wa=0;
    cin >> n >> m;
    vector<int> vec1(m), d(n), e(n);
    vector<string> vec2(m);

    for(int i=0; i<m; i++) {
        cin >> vec1.at(i) >> vec2.at(i);

        if(vec2.at(i)=="AC") d.at(vec1.at(i)-1)++;
        if(d.at(vec1.at(i)-1) == 0) e.at(vec1.at(i)-1)++;
    }
    
    for(int i=0; i<n; i++) {
        if(d.at(i) > 0) {
            ac++;
            wa += e.at(i);
        }
    }
    cout << ac << " " << wa << endl;
}

Measured memory_bytes: 6912
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
prev = -5

for i in a:
  ans += b[i-1]
  if prev == i-2:
    ans += c[i-2]
  prev = i-1

print(ans)

Measured memory_bytes: 3064
N=int(input())
A=map(int,input().split())
if N%2==0:
  if sorted(A)==sorted([i*2+1 for i in range(N//2)]*2):
    print(2**(N//2) % (10**9+7))
  else:
    print('0')
else:
  if sorted(A)==sorted([(j+1)*2 for j in range(N//2)]*2+[0]):
      print(2**(N//2) % (10**9+7))
  else:
    print('0')
  

Measured memory_bytes: 14008
int top3[4];
#include <stdio.h>
void sounyuu(int m,int top){
    top3[top]=m;
}
void handan(int m){

    if(m>top3[0]){
        top3[2]=top3[1];
        top3[1]=top3[0];
        sounyuu(m,0);
        return;
    }
    
    if(m>top3[1]){
        top3[2]=top3[1];
        sounyuu(m,1);
        return;
    }
    
    if(m>top3[2]){
        sounyuu(m,2);
        return;
    }
    
    
}
int main(int argc,const char *argv[]){
    int m,i;
    for(i=0;i<10;i++){
        scanf("%d",&m);
        handan(m);
    }
    for(i=0;i<3;i++){
        printf("%d\n",top3[i]);
    }
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <stdlib.h>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))

typedef long long ll;
typedef struct {
	ll indx, height;
} Pair;

int cmp(const Pair *x, const Pair *y);

ll n;
ll is_island[100005];
Pair p[100005];

int main()
{
	ll island_nums;
	ll ans;
	ll i;

	scanf("%lld", &n);
	for (i = 1; i <= n; i++) {
		scanf("%lld", &p[i].height);
		p[i].indx = i;
	}

	qsort(p + 1, n, sizeof(Pair), (int (*)(const void *, const void *))cmp);

	p[0].height = -1;
	p[n + 1].height = -1;
	

	island_nums = 0;
	ans = 0;
	i = 1;
	while (i <= n) {

		do {
			if (p[i].height > 0) {
				ll indx = p[i].indx;
				is_island[indx] = 1;

				if (is_island[indx - 1] && is_island[indx + 1]) {
					island_nums--;
				} else if (!is_island[indx - 1] && !is_island[indx + 1]) {
					island_nums++;
				}
			}

			i++;
		} while(p[i].height == p[i - 1].height);

		ans = max(island_nums, ans);
	}

	printf("%lld\n", ans);

	return 0;
}

int cmp(const Pair *x, const Pair *y)
{
	if (x->height > y->height) {
		return -1;
	} else if (x->height == y->height) {
		return 0;
	} else {
		return 1;
	}
}



Measured memory_bytes: 4620
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	var inputs []string
	for i := 0; i <= 0; i++ {
		sc.Scan()
		inputs = strings.Split(sc.Text(), " ")
	}
	a, _ := strconv.Atoi(inputs[0])
	b, _ := strconv.Atoi(inputs[1])
	c, _ := strconv.Atoi(inputs[2])
	howTime, _ := strconv.Atoi(inputs[3])

	sum := 0
	countA := count(howTime, a)
	howTime -= countA
	sum += countA * 1
	if howTime > 0 {
		countB := count(howTime, b)
		howTime -= countB
		if howTime > 0 {
			countC := count(howTime, c)
			sum += countC * -1
		}
	}
	fmt.Println(sum)
}

// 実行数を回数をカウント
func count(howTime, abc int) int {
	if howTime-abc > 0 {
		return abc
	}
	return howTime
}

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

#define oo(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
  cout << name << ": " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
  const char *comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
#define frii(i , j , n) for (int i = j; i < n; ++i)
#define friie(i , j , n) for (int i = j; i <= n; ++i)
#define ra(a) for(int &x : (a)) cin >> (x);
typedef long long int lli;
typedef unsigned long long int ulli;
const lli MOD = 1e9 + 7;
#define pb emplace_back
#define mp make_pair
#define vi vector<int>
#define vlli vector<lli>

template <typename T> void mx(T& a, T b) {
    a = max(a, b);
}

bool wow(pair<int,int> p) {
    return p.first == 0 || p.second == 0;
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string a, b;
  cin >> a >> b;
  vector< vector<pair <int , pair <int , int>>>> dp(a.length() + 1 , 
    vector<pair <int , pair <int , int>>> (b.length()+1 , {INT_MIN,{0,0}}));
  dp[0][0]= {0,{0,0}};
  frii(i,0,a.length())
  frii(j,0,b.length()){
	  if(  a[i] == b[j]){
	    mx(dp[i+1][j+1] , make_pair(dp[i][j].first +1 , make_pair(i,j)));
	  }
	  mx(dp[i+1][j] , make_pair( dp[i][j].first , make_pair(i,j)));
	  mx(dp[i][j+1] , make_pair( dp[i][j].first , make_pair(i,j)));
  }
  pair <int , pair <int , int>> ans = {0,{0,0}};
  friie(i,0,a.length())
  friie(j,0,b.length())
  mx(ans , make_pair( dp[i][j].first , make_pair(i,j)) );
  string s;
  pair<int , int> curr = ans.second;
  while(!wow(curr)){
    int i = curr.first;
    int j = curr.second;
    pair<int , int> previous = dp[i][j].second;
    if(previous == make_pair(i-1,j-1) ) s+=a[i-1];
    curr = previous;
  }
  reverse(s.begin() , s.end());
  cout << s;
  return 0;
}

Measured memory_bytes: 105984
N=int(input())
A=list(map(int, input().split()))  #複数数値入力
B=list(map(int, input().split()))  #複数数値入力
C=list(map(int, input().split()))  #複数数値入力

Sat = sum(B) # Bの合計

for idx, a in enumerate(A):
  if idx == N-1:
    break
  if ((a+1) == A[idx+1]):
    Sat = Sat+C[a-1]

print(Sat)

Measured memory_bytes: 3064
#include <cstdio>
#define SIZE 244140625

char Key[128];
#define HASH(c) 
int Hash(const char* c)
{
    int Hash = 1;
    while(*c){
        Hash  *= 5;
        Hash += Key[*c];
        ++c;
    }
    return Hash;
}
int main()
{
    Key['A'] = 1;
    Key['C'] = 2;
    Key['G'] = 3;
    Key['T'] = 4;
    bool* dic = new bool[SIZE];
    int n;
    std::scanf("%d\n", &n);
    char str[21];
    for(int i = 0; i < n; ++i){
        std::gets(str);
        if(str[0] == 'i'){
            dic[Hash(str+7)] = true;
        }else{
            std::puts((dic[Hash(str+5)] ? "yes" : "no"));
        }
    }
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  vector<ll> B(N, 0);
  ll tmp_x {};
  rep(i, N) {
    if (i % 2 == 0) {
      tmp_x += A[i];
    } else {
      tmp_x -= A[i];
    }
  }
  B[0] = tmp_x/2;
  srep(i, 1, N) {
    B[i] = A[i-1] - B[i-1];
  }

  bool is_first {true};
  rep(i, N) {
    if (is_first == true) {
      is_first = false;
    } else {
      cout << ' ';
    }
    cout << B[i]*2;
  }
  cout << '\n';
}


Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
#define pii pair<int, int>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    vector<pii> p(n);

    rep(i, n) {
        int a;
        cin >> a;

        p[i] = make_pair(a, i+1);
    }
    sort(p.begin(), p.end());

    rep(i, n) {
        cout << p[i].second;
        if(i != n-1) {
            cout << " ";
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 1664
using System;
class Program
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string[] ttemp = Console.ReadLine().Split(' ');
        int[] t = new int[n];
        int tsum = 0;
        for (int i = 0; i < n; i++)
        {
            t[i] = int.Parse(ttemp[i]);
            tsum += t[i];
        }
        int m = int.Parse(Console.ReadLine());
        string[] px;
        int p, x;
        int[] ans = new int[m];
        for (int i = 0; i < m; i++)
        {
            px = Console.ReadLine().Split(' ');
            p = int.Parse(px[0]);
            x = int.Parse(px[1]);
            ans[i] = tsum - t[p - 1] + x;
        }
        for (int i = 0; i < m; i++)
            Console.WriteLine(ans[i]);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const int INF=2*1e9;
int main()
{
    ll a[5][5],n,b;
    rep1(i,3) rep1(j,3) cin>>a[i][j];
    bool x=0;
    cin>>n;
    rep(i,n)
    {
        cin>>b;
        rep1(i,3)
        {
            rep1(j,3)
            {
                if(a[i][j]==b) a[i][j]=0;
            }
        }
    }
    if(a[1][1]==0&&a[2][2]==0&&a[3][3]==0) x=1;
    if(a[1][3]==0&&a[2][2]==0&&a[3][1]==0) x=1;
    rep1(i,3)
    {
        if(a[i][1]==0&&a[i][2]==0&&a[i][3]==0) x=1;
        if(a[1][i]==0&&a[2][i]==0&&a[3][i]==0) x=1;
    }
    if(x) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256