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

using namespace std;

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


int main(){
	
	int s=0,t=0;
	int a,b,c;
	while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
		//if(a==0)break;
		if(a*a+b*b==c*c)s++;
		if(a==b)t++;
	}
	printf("%d\n%d\n",s,t);
	
}

Measured memory_bytes: 1172
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

vint a,b;
int foo(int x){
	int ret=0;
	rep(i,a.size()){
		if(a[i]==b[x+ret]){
			ret++;
		}
		if(x+ret==b.size()) break;
	}
	return ret;
}
void mainmain(){
	int n,m;
	cin>>n>>m;
	a=vint(n);
	b=vint(m);
	rep(i,n) cin>>a[i];
	rep(i,m) cin>>b[i];
	int ans=0;
	rep(i,m){
		ans=max(ans,foo(i));
	}
	cout<<ans<<endl;
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<string,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
const double PI=acos(-1);
 
using namespace std;

int main( ) {
    ll H1,M,H2,N,K,a,b;
    cin>>H1>>M>>H2>>N>>K;
    a=H2*60+N-H1*60-M;
    if(a<=K) cout<<"0"<<endl;
    else {
        cout<<a-K<<endl;
    }
    }


Measured memory_bytes: 3636
N,M = map(int,input().split())

wa = [0]*N
ac = [0]*N

wac = 0
acc = 0

for i in range(M):
  p,s = input().split()
  p = int(p)
  if s == "AC":
    if ac[p-1] != 1:
      ac[p-1] = 1
      acc += 1
      wac += wa[p-1]
  else:
    if ac[p-1] == 0:
      wa[p-1] += 1
print(str(acc) +" "+ str(wac))

Measured memory_bytes: 4596
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

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

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int N = 52;

int n, m, ss, c[N], d[N], dis[N][N*N];
vector<pair<int, PII>> child[N];

signed main() {
  init_ios();
  cin >> n >> m >> ss;
  ss = min(ss, N*N-1);
  for (int i = 1; i <= m; ++i) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    child[u].PB({v, {a, b}});
    child[v].PB({u, {a, b}});
  }
  for (int i = 1; i <= n; ++i)
    cin >> c[i] >> d[i];
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j < N*N; ++j)
      dis[i][j] = 1e18;
  dis[1][ss] = 0;
  set<pair<int, PII>> s;
  s.insert({dis[1][ss], {1, ss}});
  while (!s.empty()) {
    auto el = *s.begin();
    s.erase(s.begin());
    int cost = el.ST;
    int v = el.ND.ST;
    int hajs = el.ND.ND;

    int now = min(N*N-1, hajs+c[v]);
    if (dis[v][now] > cost + d[v]) {
      s.erase({dis[v][now], {v, now}});
      dis[v][now] = cost + d[v];
      s.insert({dis[v][now], {v, now}});
    }

    for (auto kr: child[v]) {
      int u = kr.ST;
      int krcena = kr.ND.ST;
      int dlu = kr.ND.ND;
      if (krcena <= hajs && dis[u][hajs-krcena] > cost + dlu) {
        s.erase({dis[u][hajs-krcena], {u, hajs-krcena}});
        dis[u][hajs-krcena] = cost+dlu;
        s.insert({dis[u][hajs-krcena], {u, hajs-krcena}});
      }
    }
  }
  for (int i = 2; i <= n; ++i) {
    int res = 1e18;
    for (int j = 0; j < N*N; ++j)
      res = min(res, dis[i][j]);
    cout<<res<<"\n";
  }
}

Measured memory_bytes: 8372
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#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)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int x,n;
    cin >> x >> n;
    if(n==0){
        cout << x << endl;
        return 0;
    }
    int p[n];
    rep(i,n)cin >> p[i];
    int ans = -1;
    int min_dif = INF;
    vector<int> ind(102,0);
    rep(i,n)ind[p[i]]=1;
    for(int i = 0;i<=101;i++){
        if(ind[i]==0){
            if(chmin(min_dif,abs(i-x))){
                ans = i;
            }
        }
    }
    if(chmin(min_dif,abs(x+1)))ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

string s;
int ans;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> s;
    int n = s.size();
    bool flag = true;
    rep(i, 1, n) {
        if (s[i] != '9') flag = false;
        ans += s[i]-'0';
    }
    if (!flag) ans = 9*(n-1)+s[0]-'1';
    else ans += s[0]-'0';
    cout << ans << endl;
    return 0;
}


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

using namespace std;

const long long INF = (long long)1e10;
int n;
const int N = 110;
long long w[N], v[N];    
map<long long, long long> dp[N];

long long f(int pos, long long r) {
	if(r < 0) return -INF;
	if(pos == n) return 0;

	if(dp[pos].count(r - w[0]))
		return dp[pos][r - w[0]];

	long long ans = 0;
	ans = max(f(pos + 1, r), v[pos] + f(pos + 1, r - w[pos]));
	return dp[pos][r - w[0]] = ans;
}

int main(void) {

	long long W;

	cin >> n >> W;
	for(int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
	}

	//memset(dp, -1, sizeof(dp));
	cout << f(0, W) << endl;

	return 0;
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
#define int long long
int a[20];
using namespace std;
signed main(){
    int n;
    cin>>n;
    int waru=1;
    int ans=0;
    for(int k=0;k<20;k++){
        waru=1;
        for(int l=0;l<k+1;l++){
            waru=waru*10;
        }
        a[k]=(n%waru)/(waru/10);
        ans+=a[k];
        }
    if(n%ans==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
import bisect
import collections
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 32


def lmi():
    return list(map(int, input().split()))


def llmi(n):
    return [lmi() for _ in range(n)]
V = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())
print(V[K-1])

Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
#include<vector>
const int INF = 1 << 20;
const int N = 11;
int tim[N][N];
using namespace std;
int main()
{
	int a, b, ti, n;
	while (1){
		cin >> n;
		if (n == 0)break;

		for (int i = 0; i < N; i++){
			for (int i2 = 0; i2 < N; i2++){
				if (i != i2){
					tim[i][i2] = INF;
				}
				else
					tim[i][i2] = 0;
			}
		}

		int m = 0;
		for (int i = 0; i < n; i++){
			cin >> a >> b >> ti;
			tim[a][b] = ti;
			tim[b][a] = ti;
			m = max(m, a);
			m = max(m, b);
		}

		for (int k = 0; k <= m; k++)
			for (int i = 0; i <= m; i++)
				for (int j = 0; j <= m; j++){
					tim[i][j] = min(tim[i][j], tim[i][k] + tim[k][j]);
				}

		int mint = INF;
		vector<int>p;
		//p.clear();
		for (int i = 0; i <= m; i++){
			int mt = 0;
			for (int i2 = 0; i2 <= m; i2++){
					mt += tim[i][i2];
			}
			p.push_back(mt);
			mint = min(mt, mint);
		}

		for (int i = 0; i <= p.size(); i++){
			if (p[i] == mint){
				cout << i << " " << mint << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1216
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inp = sys.stdin.buffer.readline

from itertools import accumulate
def resolve():
 
    N, K = map(int, inp().split())
    A = list(map(int, inp().split()))
 
    for _ in range(K):
        imos_table = [0]*(N+1)
        for i, a in enumerate(A):
            # 配列の個数を超えないように注意
            imos_table[max(i - a, 0)] += 1
            imos_table[min(i + a + 1, N)] -= 1
        A = list(accumulate(imos_table))[:-1]
        if all([True if a == N else False for a in A]):
            print(*A)
            return
    else:
        print(*A)
        
if __name__ == "__main__":
    resolve()

Measured memory_bytes: 185108
#include <stdio.h>
#include <stdlib.h>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#pragma warning(disable:4996)

int h[3200000];

int compareint(const void* a, const void* b)
{
    int aNum = *(int*)a;
    int bNum = *(int*)b;

    return aNum - bNum;
}


int main()
{
	int n, k;
    unsigned long long a = 0;
    scanf("%d %d", &n, &k);
    for (int i = 0; i != n; i++) {
        scanf("%d", &h[i]);
    }
    qsort(h, SIZE_OF_ARRAY(h), sizeof(int), compareint);

    for (int i = 0; i != n; i++) {
        if (i < k) {
            continue;
        }
        else {
            a += h[3200000 - i - 1];
        }
    }
    printf("%llu", a);

	return 0;
}

Measured memory_bytes: 25212
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

class UnionFind {
  vector<int> par, sz;
public:
  UnionFind(int n) {
    par.resize(n);
    for (int i = 0; i < n; i++)
      par[i] = i;
    sz.resize(n, 1);
  }
  int root(int x) {
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return sz[root(x)];
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (sz[x] >= sz[y]) {
      sz[x] += sz[y];
      par[y] = x;
    } else {
      sz[y] += sz[x];
      par[x] = y;
    }
    return true;
  }
};

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  if (m == n-1) {
    cout << 0 << endl;
    return 0;
  }
  UnionFind uf(n);
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    uf.unite(x, y);
  }
  map<int, vector<int>> mp;
  rep(i, n)
    mp[uf.root(i)].push_back(a[i]);
  for (auto& e : mp)
    sort(e.second.begin(), e.second.end());
  ll ans = 0;
  vector<int> node;
  for (auto e : mp) {
    ans += e.second[0];
    for (int i = 1; i < (int)e.second.size(); i++)
      node.push_back(e.second[i]);
  }
  if (node.size() < (int)mp.size()-2) {
    cout << "Impossible" << endl;
    return 0;
  }
  sort(node.begin(), node.end());
  rep(i, mp.size()-2)
    ans += node[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 15256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <limits>

using namespace std;

using i64 = long long int;
using P = pair<i64, i64>;

struct edge {
    i64 from, to, cost;
    edge(i64 from, i64 to) : from(from), to(to), cost(1) {}
    edge(i64 from, i64 to, i64 cost) : from(from), to(to), cost(cost) {}
};
using Graph = vector<vector<edge>>;

constexpr i64 SINF = std::numeric_limits<i64>::max() / 10;
const i64 MOD = 1000000007;
const i64 dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
//const i64 dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//const i64 dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//const i64 dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main() {
    i64 h, w;
    cin >> h >> w;
    vector<string> s(h);
    for(int i = 0; i < h; ++i) cin >> s[i];
    vector<vector<i64>> ans(h, vector<i64>(w, 0));
    for (int i = 0; i < h; ++i) {
        i64 tmp = 0;
        for (int j = 0; j < w; ++j) {
            if(s[i][j] == '#') tmp = 0;
            else {
                ans[i][j] += tmp;
                ++tmp;
            }
        }
        tmp = 0;
        for (int j = w - 1; j > 0; --j) {
            if (s[i][j] == '#') tmp = 0;
            else {
                ans[i][j] += tmp;
                ++tmp;
            }
        }
    }
    for (int j = 0; j < w; ++j) {
        i64 tmp = 0;
        for (int i = 0; i < h; ++i) {
            if (s[i][j] == '#') tmp = 0;
            else {
                ans[i][j] += tmp;
                ++tmp;
            }
        }
        tmp = 0;
        for (int i = h - 1; i > 0; --i) {
            if (s[i][j] == '#') tmp = 0;
            else {
                ans[i][j] += tmp;
                ++tmp;
            }
        }
    }
    i64 anss = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (s[i][j] == '#') continue;
            anss = max(anss, ans[i][j] + 1);
        }
    }
    cout << anss << endl;
 }

Measured memory_bytes: 35840
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

int main(){
    int n; cin>>n;
    for(int i=0; i<n; i++){
        int k, p; cin>>k>>p;
        if(k % p == 0) cout << p << endl;
        else cout << k % p << endl;
    }
}


Measured memory_bytes: 3104
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
  dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 13980
import sys
from collections import deque

sys.setrecursionlimit(200000)

class Dinic:
    
    def __init__(self,v, inf =10**10):
        self.v = v
        self.inf = inf
        self.G = [[] for _ in range(v)]
        self.level = [-1]*v#深さ
        self.ite = [0]*v#DFSでの探索が済んでいるか否か
    
    def add_edge(self, fr, to, cap):#末尾はself.G[to]から対応する辺のself.G[fr]内でのindex
        self.G[fr].append([to,cap,len(self.G[to])])###{'to':to,"cap":cap,"rev";len(self.G[to})}みたいにしたほうがいいか
        self.G[to].append([fr,0,len(self.G[fr])-1])

    
    def bfs(self,s):#BFSで深さ決定,sがstart
        self.level = [-1]*self.v#必要
        self.level[s] = 0
        Q = deque()
        Q.append(s)
        while Q:
            v = Q.popleft()
            for i in range(len(self.G[v])):
                e = self.G[v][i]
                if e[1]>0 and self.level[e[0]]<0:###capacity>0かつtoの深さ未定
                    self.level[e[0]] = self.level[v]+1
                    Q.append(e[0])

        
    def dfs(self,v,t,f):#DFSで増加パス探索,v開始、t終点、総フローf
        if v==t:
            return f
        for i in range(self.ite[v],len(self.G[v])):
            self.ite[v] = i
            e = self.G[v][i]
            if e[1]>0 and self.level[v]<self.level[e[0]]:
                d = self.dfs(e[0],t,min(f,e[1]))
                if d>0:
                    e[1] -= d #cap減少
                    self.G[e[0]][e[2]][1] += d#逆辺のcap増加
                    return d
        return 0
    
    def max_flow(self,s,t):
        flow = 0
        while True:
            self.bfs(s)
            if self.level[t]<0:
                return flow
            self.ite = [0]*self.v#DFSでの探索が済んでいるか否か
            f =self.dfs(s,t,self.inf)
            while f>0:
                flow+= f
                f = self.dfs(s,t,self.inf)
            
v,e = map(int, input().split( ))
D = Dinic(v)
for _ in range(e):
    u,w,c = map(int, input().split( ))
    D.add_edge(u,w,c)
ans = D.max_flow(0,v-1)
print(ans)


        
                    


Measured memory_bytes: 6072
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;cin>>n;
    vector<int> P(n),Q(n);
    for(int i=0;i<n;i++)cin>>P[i];
    for(int i=0;i<n;i++)cin>>Q[i];
    int a=0,b=0;
    vector<int> mirror;
    for(int i=1;i<=n;i++)mirror.push_back(i);
    int cou=0;
    do{
        cou++;
        bool jud=true;
        for(int i=0;i<n;i++){
            if(P[i]!=mirror[i]){
                jud=false;
                break;
            }
        }
        if(jud)a=cou;
        jud=true;
        for(int i=0;i<n;i++){
            if(Q[i]!=mirror[i]){
                jud=false;
                break;
            }
        }
        if(jud)b=cou;
    }while(next_permutation(mirror.begin(), mirror.end()));
    int res=a-b;
    if(res<0)res*=(-1);
    cout<<res<<endl;
}


Measured memory_bytes: 256
import scala.io.StdIn.{readInt,readLine}
import scala.collection.mutable.ArrayBuffer

object Main {
  def max(x:Int,y:Int) = if(x>y) x else y

  def main(args:Array[String]) = {
    val n = readInt
    val b = new ArrayBuffer[Int]

    for(i<-0 until n) {
      val s1 = ' ' + readLine
      val s2 = ' ' + readLine
      val maxN = s1.length
      val maxM = s2.length

      val a = Array.ofDim[Int](maxN,maxM)
      for(i<-1 until maxN) {
        for(j<-1 until maxM) {
          if(s1(i)==s2(j)) {
            a(i)(j) = a(i-1)(j-1)+1
          } else {
            a(i)(j) = max(a(i-1)(j), a(i)(j-1))
          }
        }
      }
      b += a(maxN-1)(maxM-1)
    }
    println(b.mkString("\n"))
  }
}

Measured memory_bytes: 124144
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

#[allow(non_snake_case)]
fn main() {
    input! {
        K:usize,
        A:usize,
        B:usize,
    }
    for i in A..(B + 1) {
        if i % K == 0 {
            println!("OK");
            return;
        }
    }
    println!("NG");
}


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

long int digit_sum(string);

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

	long int ans = digit_sum(str);

	cout << ((ans % 9 == 0)? "Yes" : "No");

	return 0;
}

long int digit_sum(string num) {
	long int ans = 0;
	for (int i = 0; i < num.length(); i++) {
		ans += (int)(num[i] - '0');
	}
	return ans;
}

//made by myself

Measured memory_bytes: 3468
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<int>> v(n, vector<int>(m, 0));
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < m; ++j) {
            v[i][j] = (s[j] == '#');
        }
    }
    int ans = 0;
    for (int S = 0; S < (1 << n); ++S) {
        for (int T = 0; T < (1 << m); ++T) {
            int val = 0;
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    if(v[i][j] && !(S & (1 << i)) && !(T & (1 << j))) val++;
                }
            }
            if(val == k) ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(void){
    int max = 0;
    int n;
    int x = 0;
    char s[101] = {};
    int i;
    
    scanf("%d %s", &n, s);
    for( i = 0; i < n; ++i){
        if( s[i] == 'I'){
            ++x;
        }else{
            --x;
        }
        if( x > max){
            max = x;
        }
    }
    printf("%d\n", max);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,count=0;
  string S;
  cin >> N >> S;
  for(int i=0;i<N;i++){
    if(S.at(i)=='R'){
      count++;
    }
    else{
      count--;
    }
  }
  if(count>0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
    
      

Measured memory_bytes: 3608
#include <stdio.h>

int main(void) {
    int n;
    scanf("%d", &n);
    int arr[n];

    for (int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }

    for (int i = n - 1; 0 <= i; i--) {
        if (0 < i) printf("%d ", arr[i]);
        else printf("%d\n", arr[i]);
    }

    return 0;
}


Measured memory_bytes: 2084
#include<bits/stdc++.h>
using namespace std;
#define int int64_t 
const int INF = 1e9;
const int MOD = INF+7;
const int LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)

signed main(){
    int A,B,Q;
    cin >> A >> B >> Q;
    vector<int> S(A+1,-LINF),T(B+1,-LINF);
    for(int i=1;i<=A;i++) cin >> S[i]; S.push_back(LINF);
    for(int i=1;i<=B;i++) cin >> T[i]; T.push_back(LINF);
    
    vector<int> ans(Q,LINF);
    rep(i,Q) {
        int x,s,t;
        cin >> x;
        s = lower_bound(all(S),x) - S.begin();
        t = lower_bound(all(T),x) - T.begin();
        for(int j=s-1;j<=s;++j){
            for(int k=t-1;k<=t;++k){
                ans[i] = min({ans[i],abs(S[j] - x) + abs(T[k] - S[j]), abs(T[k] - x) + abs(T[k] - S[j])});
            }
        }
    }

    for(auto r : ans) cout << r << endl;
}


Measured memory_bytes: 3680
#include <stdio.h>
#include <math.h>
main(){
  int a,b,ra=90,x,y;
  double xx=0,yy=0,pi;
  while(1){
    scanf("%d,%d",&a,&b);
    if(a==0&&b==0) break;
    pi=acos(-1);
    xx+=a*cos(pi*ra/180);
    yy+=a*sin(pi*ra/180);
    ra-=b;
  }
  x=xx;
  y=yy;
  printf("%d\n%d\n",x,y);
  return 0;
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif



signed main() {

    int n;
    cin>>n;
    map<string,int> m;
    rep(i,n){
        string s;cin>>s;
        m[s]++;
    }
    cin>>n;
    rep(i,n){
        string s; cin>>s;
        m[s]--;
    }
    int ans=0;
    map<string,int>::iterator p;    //イテレーターを用いた走査
    for (p=m.begin(); p!=m.end(); p++){
        ans = max(ans, p->second);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
const int MOD=1e9+7;
using pii=std::pair<int,int>;
using namespace std;

int a, b, c, k;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> a >> b >> c >> k;
    int ans = 0;
    int take = min(a, k);
    k -= take;
    ans += take;
    take = min(b, k);
    k -= take;
    take = min(c, k);
    k -= take;
    ans -= take;
    cout << ans << "\n";
    return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 N, A, B;
  cin >> N >> A >> B;
  cout << (N/(A+B))*A+min(A, N%(A+B)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  int n; cin>>n;
  vll l(n); rep(i,n) cin>>l[i];
  int cnt=0;
  sort(l.begin(),l.end());
  rep(i,n)for(int j=i+1;j<n;j++)for(int k=j+1;k<n;k++){
    if(l[i]==l[j]||l[j]==l[k]||l[i]==l[k]) continue;
    if(l[i]+l[j]>l[k]) cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int n, m, v, p;
Int a[110000];
Int b[110000];
bool ok(Int x){
    for(Int i = 0;i < n;i++)b[i] = a[i];
    Int rest = v*m;
    Int up_cnt = 0;
    for(Int i = n;i > 0;i--){
        if(b[(i+x)%n] + min(rest, m) <= a[x] + m){
            b[(i+x)%n] += min(rest, m);rest -= min(rest, m);
            continue;
        }
        if(up_cnt < p-1){
            b[(i+x) % n] += min(rest, m);rest -= min(rest, m);
            up_cnt++;
        }
        else{
            int tmp = max(0ll, a[x] + m - b[(i+x)%n]);
            rest -= tmp;
            b[(i+x)%n] += tmp;
        }        
    }
    if(rest != 0)return false;
    sort(b, b + n);
    return b[n-p] <= a[x] + m;
}

int main(){
    cin >> n >> m >> v >> p;
    for(int i = 0;i < n;i++)cin >> a[i];
    sort(a, a + n);
    if(ok(0)){
        cout << n << endl;
        return 0;
    }
    int bottom = 0, top = n-1;
    while(top - bottom> 1){
        int mid = (top + bottom) / 2;
        if(ok(mid))top = mid;
        else bottom = mid;
    }
    cout << n - top << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
vector<int> edge[100000];
int N, K;
long ans;

void dfs(int n, int p) {
  int k;
  if (p == -1) {
    ans = K;
    k = K-1;
  }
  else
    k = K-2;
  for (auto &e: edge[n]) {
    if (e == p)
      continue;
    ans *= k;
    ans %= MOD;
    dfs(e, n);
    k--;
  }
  return ;
}

int main() {
  int a, b;
  cin >> N >> K;
  for (int i=0; i<N-1; i++) {
    cin >> a >> b;
    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  dfs(0, -1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 10368
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n, m = [int(x) for x in input().split()]
    s = []
    for _ in range(n):
        s.append([int(x) for x in input().split()])
    c = []
    for _ in range(m):
        c.append([int(x) for x in input().split()])
    for x, y in  s:
        ans = 0
        d = float('inf')
        for i, (a, b) in enumerate(c):
            if abs(x-a) + abs(y-b) < d:
                ans = i
                d = abs(x-a) + abs(y-b)
        print(ans + 1)
        

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""


"""


Measured memory_bytes: 9376
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
      	boolean flg = true;
      	if(N<4){
        	System.out.println("No");
        }else{
      		for(int i=0;i<30;i++){
              	if(!flg){
                 	break;
                 }
        		for(int j=0;j<30;j++){
            		if(N==7*i+4*j){
                		System.out.println("Yes");
                	  	flg = false;
                  		break;
               		 }
           	 	}
        	}
        	if(flg){
        		System.out.println("No");
        	}
        }
    }
}

Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException{
		InputStreamReader in = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(in);
		String[] line = br.readLine().split(" ");
		long n = Long.parseLong(line[0]);
		long a = Long.parseLong(line[1]);
		long b = Long.parseLong(line[2]);
		br.close();
		long blue = 0;
		if(a == 0) {
			blue = 0;
		}else {
			long mod = n%(a+b);
			long div = n/(a+b);
			if(mod==0 || mod<=a) {
				blue = a * div + mod;
			}else {
				blue = a * div + a;
			}
		}
		System.out.println(blue);
	}
}


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

public class Main{
	static void main() throws Exception{
		int n=sc.nextInt();
		int ans=0;
		for(int a=1;a<=n;a++) {
			for(int b=1;b<=n && b*1l*a<=n;b++) {
				int c=n-a*b;
				if(c>0) {
					ans++;
				}
			}
		}
		pw.println(ans);
	}
	public static void main(String[] args) throws Exception {
		sc = new MScanner(System.in);
		pw = new PrintWriter(System.out);
//		int tc = 1;
//		tc=sc.nextInt();
//		while (tc-- > 0)
			main();
		pw.flush();
	}

	static PrintWriter pw;
	static MScanner sc;

	static class MScanner {
		StringTokenizer st;
		BufferedReader br;

		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int[] intArr(int n) throws IOException {
			int[] in = new int[n];
			for (int i = 0; i < n; i++)
				in[i] = nextInt();
			return in;
		}

		public long[] longArr(int n) throws IOException {
			long[] in = new long[n];
			for (int i = 0; i < n; i++)
				in[i] = nextLong();
			return in;
		}

		public int[] intSortedArr(int n) throws IOException {
			int[] in = new int[n];
			for (int i = 0; i < n; i++)
				in[i] = nextInt();
			shuffle(in);
			Arrays.sort(in);
			return in;
		}

		public long[] longSortedArr(int n) throws IOException {
			long[] in = new long[n];
			for (int i = 0; i < n; i++)
				in[i] = nextLong();
			shuffle(in);
			Arrays.sort(in);
			return in;
		}

		public Integer[] IntegerArr(int n) throws IOException {
			Integer[] in = new Integer[n];
			for (int i = 0; i < n; i++)
				in[i] = nextInt();
			return in;
		}

		public Long[] LongArr(int n) throws IOException {
			Long[] in = new Long[n];
			for (int i = 0; i < n; i++)
				in[i] = nextLong();
			return in;
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}

	static void shuffle(int[] in) {
		for (int i = 0; i < in.length; i++) {
			int idx = (int) (Math.random() * (i + 1));
			int tmp = in[i];
			in[i] = in[idx];
			in[idx] = tmp;
		}
	}

	static void shuffle(long[] in) {
		for (int i = 0; i < in.length; i++) {
			int idx = (int) (Math.random() * (i + 1));
			long tmp = in[i];
			in[i] = in[idx];
			in[idx] = tmp;
		}
	}
}

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

int main(void)
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    
    for (int i = 0; i < k; i++){
        if (a >= b){
            b *= 2;
            continue;
        }
        else if (b >= c){
            c *= 2;
            continue;
        }
        else{
            break;
        }
    }

    if (a < b && b < c){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    
    
    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main()
{
    int i;
    scanf("%d", &i);
    int k = -1;
    int tab[i][3];
    while (++k < i)
        scanf("%d %d %d", &tab[k][0], &tab[k][1], &tab[k][2]);
    k = 0;
    while (++k < i)
    {
        tab[k][0] = tab[k][0] + ((tab[k - 1][1] >= tab[k - 1][2]) ? tab[k - 1][1] : tab[k - 1][2]);
        tab[k][1] = tab[k][1] + ((tab[k - 1][0] >= tab[k - 1][2]) ? tab[k - 1][0] : tab[k - 1][2]);
        tab[k][2] = tab[k][2] + ((tab[k - 1][1] >= tab[k - 1][0]) ? tab[k - 1][1] : tab[k - 1][0]);
    }
    if (tab[i - 1][0] > tab[i - 1][1])
    {
        if (tab[i - 1][0] > tab[i - 1][2])
            printf("%d", tab[i - 1][0]);
        else
            printf("%d", tab[i - 1][2]);
    }
    else
    {
        if (tab[i - 1][1] > tab[i - 1][2])
            printf("%d", tab[i - 1][1]);
        else
            printf("%d", tab[i - 1][2]);
    }
    
   
}

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

using namespace std;

typedef long long ll;

int main(){
  ll N,i,k;
  bool x = false;
  ll count = 0;
  ll a,b;
  cin >> N;
  for(i=0;i<=N-1;i++){
    cin >> a >> b;
    if(a==b) count++;
    else count = 0;
    if(count == 3) x = true;
    }
  if(x) cout << "Yes";
  else cout << "No";
}

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

using namespace std;

typedef long long ll;

const int N = 3030;
const int Mod = 998244353;

int a[N];
int Dp[N][N];

void add_self(int& x, int y)
{
    if((x += y) >= Mod) x -= Mod;
}

void sub_self(int& x, int y)
{
    if((x -= y) < 0)    x += Mod;
}

int add(int x, int y)
{
    return add_self(x, y), x;
}

int sub(int x, int y)
{
    return sub_self(x, y), x;
}

int mul(int x, int y)
{
    return (ll) x * y % Mod;
}

int Rec(int i, int Sum)
{
    if(Sum < 0) return 0;
    if(!Sum)    return i + 1;
    if(i == 0)  return 0;

    if(Dp[i][Sum] + 1)  return Dp[i][Sum];

    return Dp[i][Sum] = add(Rec(i - 1, Sum), Rec(i - 1, Sum - a[i]));
}

int main()
{
    memset(Dp, -1, sizeof(Dp));

    int n, s;   cin >> n >> s;

    for(int i = 1; i <= n; i++) scanf("%d", a + i);

    int Ans = 0;

    for(int i = n; i > 0; i--)
        add_self(Ans, Rec(i, s));

    cout << Ans << endl;
}


Measured memory_bytes: 36224
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
 
public class Main {
	private	static			BufferedReader	br = null;
	private	static	final	int[]			SV = { -2, -2, -2, -1, 0, 1, 2, 2, 2,  -1, 0,  1  };
	private	static	final	int[]			SH = { -1, 0,  1,  2,  2, 2, 1, 0, -1, -2, -2, -2 };

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		int[]	start = null;

		while ((start = parseStart()) != null) {
			Next[]	next = parseNext();
			solve(start, next);
		}
	}

	public static void solve(int[] start, Next[] next) {
		Point	cp = new Point();
		Point	np = null;

		cp.add(String.format("%d %d", start[0], start[1]));

		for (int i = 0; i < next.length && cp.size() > 0; i++) {
			int	sz = cp.size();

			np = new Point();
			for (int j = 0; j < sz; j++) {
				String[]	sp = cp.get(j).split(" ");
				int[]		t1 = { Integer.parseInt(sp[0]), Integer.parseInt(sp[1]) };

				for (int k = 0; k < SV.length; k++) {
					int[]	t2 = { t1[0]+SH[k], t1[1]+SV[k] };
					if (next[i].contains(t2[0], t2[1])) {
						String	st = String.format("%d %d", t2[0], t2[1]);
						if (!np.contains(st)) {
							np.add(st);
						}
					}
				}
			}

			cp = np;
		}

		if (cp.size() > 0) {
			System.out.println("OK");
		} else {
			System.out.println("NA");
		}
	}

	private static Next[] parseNext() {
		Next[]	next  = null;
		int		cnt   = parseNum();

		if (cnt > 0) {
			String	stdin = null;

			next = new Next[cnt];
			if ((stdin = parseStdin()) != null) {
				String[]	lines = stdin.split(" ");

				for (int i = 0; i < cnt; i++) {
					int	x = Integer.parseInt(lines[i*2]);
					int	y = Integer.parseInt(lines[i*2+1]);
					next[i] = new Next(x, y);
				}
			}
		}

		return next;
	}

	private static int[] parseStart() {
		int[]	start = null;
		String	stdin = null;

		if ((stdin = parseStdin()) != null) {
			if (!stdin.equals("0 0")) {
				String[]	lines = stdin.split(" ");

				start    = new int[2]; 
				start[0] = Integer.parseInt(lines[0]);
				start[1] = Integer.parseInt(lines[1]);
			}
		}

		return start;
	}

	private static int parseNum() {
		int		num = 0;
		String	str = null;

		if ((str = parseStdin()) != null) {
			num = Integer.parseInt(str);
		}

		return num;
	}

	private static String parseStdin() {
		String  stdin = null;

		try {
			String  tmp = br.readLine();
			if (tmp != null) {
				if (!tmp.isEmpty()) stdin = tmp;
			}
		}
		catch (IOException e) {}

		return stdin;
	}
}

class Point extends Stack<String> {	
}

class Next {
	int	xs;
	int	xe;
	int	ys;
	int	ye;

	public Next(int x, int y) {
		xs = (x>0) ? x-1: x;
		xe = (x<9) ? x+1: x;
		ys = (y>0) ? y-1: y;
		ye = (y<9) ? y+1: y;
	}

	public boolean contains(int x, int y) {
		return (xs <= x && x <= xe && ys <= y && y <= ye);
	}
}

Measured memory_bytes: 20028
///**Bismillahir Rahmanir Rahim.**

#include <bits/stdc++.h>
#define clr(a, v)             memset(a, v, sizeof a)
#define all(v)                v.begin(), v.end()
#define ast(v)                sort(v.begin(),v.end())
#define dst(v)                sort(v.begin(),v.end(), greater <int> ())
#define fast ios_base::       sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ass(cur, v)           cur.assign(v.begin(), v.end())
#define rep(i, l, r)          for (int i = l; i <= r; i++)
#define rep2(i, l, r)         for (int i = l; i >= r; i--)
#define sfs(s)                scanf("%s", s)
#define sfl(n)                scanf("%lld", &n)
#define sffl(n, m)            scanf("%lld %lld",&n,&m)
#define sfffl(n, m, o)        scanf("%d %d %d",&n,&m, &o)
#define pf(n)                 printf("%d", n)
#define debug                 printf(" debug\n")
#define yes                   printf("YES\n")
#define no                    printf("NO\n")
#define sp                    printf(" ")
#define nl                    printf("\n")
#define prln(n)               printf("%d\n", n)
#define pfl(n)                printf("%lld\n", n)
#define I(n)                  cin >> n
#define II(n, m)              cin >> n >> m
#define III(a, b, c)          cin >> a >> b >> c
#define P(n)                  cout << n
#define PP(n, m)              cout << n << " " << m << "\n"
#define PPP(a, b, c)          cout << a << " " << b << " " << c << "\n"
#define R(n)                  return n
#define mid(b, e)             (b+e)/2
#define left(node)            node*2
#define right(node)           node*2+1
#define pii                   pair<int,int>
#define mp                    make_pair
#define pb                    push_back
#define S                     second
#define F                     first
#define PI                    3.1415926

struct greaters{
    bool operator()(const long& a, const long& b) const{
        return a > b;
    }
};

//-----------------------------------***********************----------------------------------------------//

typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
const int N = 2e5+5;
const int mod = 1e9+7;

void reset(){

}

int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    int tc = 1, cas = 0;
    while(tc--){
        reset();
        int n; I(n);
        vector <int> v(n);
        rep(i, 0, n-2){
          cin >> v[i];
        }
        int ans = v[0];
        rep(i, 0, n-2){
          ans += (min(v[i], v[i+1]));
        }
        ans += v[n-2];
        cout << ans;
    }
    return 0;

}

//-----------------------------------***********************----------------------------------------------//



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	char s[100010], o[100010];
	int i;

	scanf("%s", s);

	for (i = 0; s[i] != '\0'; i++)
	{
		o[i] = s[i * 2];
	}

	printf("%s\n", o);

	return 0;
}

Measured memory_bytes: 384