akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int N = 2e3+10;

//head

int n;
int l[N];
int ans;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  rep(i, n) cin >> l[i];

  sort(l, l+n);

  rep(i, n) rep(j, i) rep(k, j) {
    if(l[i] < l[j]+l[k]) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3620
/*
 * Created by Dipta Das on 27-06-2019
 * Title: 
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/

#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;

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

    int n;
    cin >> n;
    vector<vector<int>> ar (n, vector<int>(3));
    for (auto &i : ar) for (auto &j : i) cin >> j;
    vector<vector<ll>> dp (n, vector<ll> (3, 0));
    for (int i = 0; i < 3; ++i) dp[0][i] = ar[0][i];

    // 1 -> 2, 3
    for (int i = 1; i < n; ++i) {
        dp[i][0] = ar[i][0] + max (dp[i-1][1], dp[i-1][2]);
        dp[i][1] = ar[i][1] + max (dp[i-1][2], dp[i-1][0]);
        dp[i][2] = ar[i][2] + max (dp[i-1][1], dp[i-1][0]);
    }


    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
    


    return 0;
}



Measured memory_bytes: 11264
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

int main() {
	int n; cin >> n ;
	vector<int> p(n);

	for (int i = 0; i < n; i++) {
			cin >> p[i];
	}
	int cnt = 0,a;
	double temp=0;
	vector<pair<int, int>> x[1000];
	

	for (int i = 1; i < n - 1; i++) {
		if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1])) cnt++;
	}
	
	cout << cnt;


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
    int n,k;
    int ans=1;//初值一定不要忘赋值！！！
    scanf("%d%d",&n,&k);//输入
    for(int i=1;i<=n;i++)//循环n次
    {
        ans=fmin(ans*2,ans+k);//两种方法的最小值再还给ans
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<set>
using namespace std;
#define MAX 10

int n, k;
string T[MAX];
bool used[MAX];

void rec(int pos, string str, set<string> &S){
  if ( pos == k ) {
    S.insert(str);
    return;
  }

  for ( int i = 0; i < n; i++ ){
    if ( used[i] ) continue;
    string next = str;
    next += T[i];
    used[i] = true;
    rec(pos+1, next, S);
    used[i] = false;
  }
}

int compute(){
  set<string> S;
  for ( int i = 0; i < n; i++ ) used[i] = false;
  rec(0, "", S);

  return S.size();
}

main(){
  while(1){
    cin >> n >> k;
    if ( n == 0 && k == 0 ) break;
    for ( int i = 0; i < n; i++ ) cin >> T[i];
    cout << compute() << endl;
  }
}

Measured memory_bytes: 0
#include <cstdio>

int main()
{
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  
  for (int i = 0; i <= m; ++i)
  {
    for (int j = 0; j <= n; ++j)
    {
      if (k == i * n + j * m - 2 * i * j)
      {
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;


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

  int N, A, B, C, X;

  while(1){
  cin >> N >> A >> B >> C >> X;

  if(N==0) break;

  int Y[N];
  REP(i, N) cin >> Y[i];

  int j=0;
  int cnt=0;

  while(j < N){
    if(X == Y[j]){
      X = (A*X+B)%C;
      j++;
      cnt++;
  }else{
    X = (A*X+B)%C;
    cnt++;
  }
  if(cnt>10000){
    break;
  }
}
if(cnt == 10001 && j < N) cout << -1 << endl;
else cout << cnt-1 << endl;
}
  return 0;
}

Measured memory_bytes: 3072
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#endif

const double PI=3.1415926535897932384626433;
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    cini(r);
    cout<<r*r<<endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------

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

  ll n,a,b; cin >> n >> a >> b;
  ll tmp = n/(a+b);
  ll tmp2 = n%(a+b);

  if(tmp2>a){
    cout << tmp * a + a << endl;
  }else{
    cout << tmp * a + tmp2 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<iomanip>
using namespace std;
int main()
{
	int r, d, x;
	cin >> r >> d >> x;
	for (int i = 0; i < 10; i++) {
      x = (x * r) - d;
	  	cout << x << endl;
    }
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int a,b;
    cin>>a>>b;
    cout<<a+b/2<<endl;
}

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

using namespace std;

#define forn(i,n) for(int i=0;i<(int)(n); i++)
#define forsn(i,s,n) for(int i=(s);i<(int)(n); i++)
#define debug(x) cout << #x << " = "  << x << endl
#define pb push_back
#define mp make_pair
typedef long long tint;
int toNumber (string s)
{
	int Number;
	if ( ! (istringstream(s) >> Number) ) Number = 0; // el string vacio lo manda al cero
	return Number;
}
string toString (int number)
{
    ostringstream ostr;
    ostr << number;
    return  ostr.str();
}

tint ele(tint a, tint b){
	if(b==0)return 1;
	if(b%2==0){
		return ele((a*a), b/2);
	}else{
		return a*ele((a*a), b/2);
	}
}

tint mcd(tint a, tint b){
	if(a==0)return b;
	return mcd(b%a, a);
}

double d_abs(long a, long b){
	if(a>b){
		return a-b;
	}
	return b-a;
}

int main(){
	int h, w;
	cin>>h>>w;
	char tab[h][w];
	map<char,int> m;
	forn(i,h){
		forn(j,w){
			cin>>tab[i][j];
			m[tab[i][j]]++;
		}
	}
	int im=0;
	int c4=0;
	for(char x='a'; x<='z'; x++){
		if(m[x]%2)im++;
		if(m[x]>=4)c4+=(m[x]/4);
	}
	if(h==1 || w==1){
		if( ( (h+w)%2==0 && im==1) || ((h+w)%2==1 && im==0) ){
			cout<<"Yes";
		}else{
			cout<<"No";
		}
		return 0;
	}
	if(h%2==0 && w%2==0){
		for(char x='a'; x<='z'; x++){
			if(m[x]%4!=0){
				cout<<"No";
				return 0;
			}
		}
		cout<<"Yes";
		return 0;
	}else if(h%2==1 && w%2==1){
		if(im==1 && c4>=((h/2)*(w/2))){
			cout<<"Yes";
		}else{
			cout<<"No";
		}
		return 0;
	}else{
		if(im==0 && c4>=((h/2)*(w/2))){
			cout<<"Yes";
		}else{
			cout<<"No";
		}
		return 0;
	}
	
}


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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll n,maxi = 0;
	cin>>n;
	string s;
	vector<string>ans;
	map<string,ll>mp;
	forn(i,n){
		cin>>s;
		mp[s]++;
		if(mp[s]>maxi){
			ans.clear();
			ans.pb(s);
			maxi = mp[s];
		}else if(mp[s]==maxi)ans.pb(s);
	}
	sort(ans.begin(),ans.end());
	for(auto a : ans) cout<<a<<'\n';
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""
 


Measured memory_bytes: 25112
#include <iostream>
#include <queue>
#include <utility>
using namespace std;

typedef pair<int, int> P;

priority_queue<int> pq;

int main(int argc, char const* argv[]) {
  int n, m;
  cin >> n;
  cin >> m;

  for (int i = 0; i < n; i++) {
    int pri;
    cin >> pri;
    pq.push(pri);
  }

  for (int i = 0; i < m; i++) {
    int maxpri = pq.top();
    pq.pop();
    pq.push(maxpri / 2);
  }

  long long ans = 0;
  while (!pq.empty()) {
    ans += pq.top();
    pq.pop();
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 892
from bisect import bisect_right
n=int(input())
A=[int(input()) for _ in range(n)][::-1]

DP=[A[0]]
for i in range(1,n):
    num=A[i]
    if num>=DP[-1]:
        DP.append(num)
    else:
        index=bisect_right(DP,num)
        DP[index]=num
print(len(DP))

Measured memory_bytes: 82508
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
using namespace std;

const int maxn = 3e5 + 10;
int cntr[maxn], cntc[maxn];
vector<int> g[maxn * 2];
int sz = 0;
bool was[maxn * 2];

void dfs(int v) {
	sz++;
	was[v] = true;
	for(int x : g[v]) {
		if(was[x]) continue;
		dfs(x);
	}
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m, k;
	cin >> n >> m >> k;
	int c[maxn], r[maxn];
	for(int i = 0; i < k; i++) {
		cin >> r[i] >> c[i];
		cntr[r[i]]++;
		cntc[c[i]]++;
	}
	int ansr = *max_element(cntr, cntr + maxn);
	int ansc = *max_element(cntc, cntc + maxn);
	vector<int> maxrows, maxcols;
	for(int i = 1; i <= n; i++) {
		if(cntr[i] == ansr) maxrows.push_back(i);
	}
	for(int i = 1; i <= m; i++) {
		if(cntc[i] == ansc) maxcols.push_back(i);
	}
  	int edges = 0;
	for(int i = 0; i < k; i++) {
		if(cntr[r[i]] == ansr and cntc[c[i]] == ansc) {
			//g[r[i]].push_back(c[i] + maxn);
			//g[c[i] + maxn].push_back(r[i]);
          	edges++;
		}
	}
	if(edges == (int)maxrows.size() * (int)maxcols.size()) {
		cout << ansr + ansc - 1 << endl;
	}
	else cout << ansr + ansc << endl;
	return 0;
}

Measured memory_bytes: 26184
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<long long>> vvll;
typedef long double ld;
typedef std::vector<long double> vld;
typedef std::vector<std::vector<long double>> vvld;
using namespace std;
void yesno(bool state);



void Main(){
    ll N;
    cin >> N;
    vll A(N);
    rep(i,N) cin >> A[i];
    sort(A.begin(),A.end());

    ll ans = 0;

    vector<bool> C(1000001);
    ll n =0;
    for (auto i : A)
    {
        if(n == 0 || A[n]!=A[n-1]){
            if(!C[i]){
                ans++;
                if(n != N-1 && A[n]==A[n+1])
                    ans--;
            }
            for (ll j = i; j < 1000001; j+=i)
            {
                C[j] = true;
            }
        }
        n++;
    }

    cout << ans << endl;
    
    

}

int main(int argc, char const *argv[])
{
    Main();
    return 0;
}

void yesno(bool state){
    if(state)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

#define INF 1000000000000000000LL

int N, M;
int L[200005], R[200005], D[200005];
vector<pair<int,ll>> G[100005];
ll pos[100005];

void dfs(int p){
  rep(i,G[p].size()){
    int q = G[p][i].first;
    ll dist = G[p][i].second;
    if(pos[q] == -INF){
      pos[q] = pos[p] + dist;
      dfs(q);
    }
  }
}


int main(){
  cin >> N >> M;
  rep(i,100005){
    pos[i+1] = -INF;
  }
  
  rep(i,M){
    cin >> L[i] >> R[i] >> D[i];
    G[L[i]].push_back(make_pair(R[i],D[i]));
    G[R[i]].push_back(make_pair(L[i],-D[i]));
  }

  rep(i,N){
    int p = i+1;
    if(pos[p] == -INF){
      pos[p] = 0;
      dfs(p);
    }
  }

  ll mn = INF, mx = -INF;
  rep(i,N){
    mn = min(mn, pos[i+1]);
  }
  rep(i,N){
    pos[i+1] += mn;
    mx = max(mx, pos[i+1]);
  }
  if(mx > 1000000000){
    cout << "No" << endl;
    return 0;
  }
  
  rep(i,M){
    if(pos[L[i]] + D[i] != pos[R[i]]){
      cout << "No" << endl;
      return 0;
    }
  }


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

Measured memory_bytes: 19712
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 string S;
 int w;
 cin >> S;
 cin >> w;
 int s=S.size();
 string a;
 for(int i=0;i<s;i++){
  if(i%w==0){a+=S.at(i);}
 }
 cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string.h>
#include <stack>
#include <map>
#include <unordered_map>
#include <climits>
using namespace std;
const int INF = 1e9;
#define ll long long
#define int ll
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define testcase \
    int t;       \
    cin >> t;    \
    while (t--)
#define pb push_back
#define endl "\n"
#define deb1(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << " | " << #y << ": " << y << endl
#define deb3(x, y, z) cout << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl
#define deb4(x, y, z, w) cout << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << " | " << #w << ": " << w << endl
#define deb5(a, b, c, d, e) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(a) int((a).size())
#define pii pair<int, int>
#define fi first
#define se second
#define ld long double
#define vii vector<int>
#define all(v) v.begin(), v.end()
#define prec(n) fixed << setprecision(n)
const int MOD = (int)1e9 + 7;
const int MOD2 = 1007681537;
const ll LINF = (ll)1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-12;
inline ll gcd(ll a, ll b)
{
    ll r;
    while (b)
    {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
inline ll fpow(ll n, ll k, int p = MOD)
{
    ll r = 1;
    for (; k; k >>= 1)
    {
        if (k & 1)
            r = r * n % p;
        n = n * n % p;
    }
    return r;
}
template <class T>
inline int chkmin(T &a, const T &val) { return val < a ? a = val, 1 : 0; }
template <class T>
inline int chkmax(T &a, const T &val) { return a < val ? a = val, 1 : 0; }
inline void addmod(int &a, int val, int p = MOD)
{
    if ((a = (a + val)) >= p)
        a -= p;
}
inline void submod(int &a, int val, int p = MOD)
{
    if ((a = (a - val)) < 0)
        a += p;
}
inline int mult(int a, int b, int p = MOD) { return (ll)a * b % p; }
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
inline void get_arr(int arr[], int n)
{
    for (int i = 0; i < n; i++)
        cin >> arr[i];
}
inline void print_arr(int arr[], int n)
{
    for (int i = 0; i < n; i++)
        cout << arr[i] << " ";
    cout << endl;
}

int32_t main()
{
    int n;
    cin>>n;
    int dp[n+1][3];
    memset(dp,0,sizeof(dp));
    int a,b,c;
    for(int i=1;i<=n;i++)
    {
        cin>>a>>b>>c;
        dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a;
        dp[i][2]=max(dp[i-1][1],dp[i-1][3])+b;
        dp[i][3]=max(dp[i-1][1],dp[i-1][2])+c;
    }
    int ans=0;
    for(int i=1;i<=3;i++)
    {
        ans=max(dp[n][i],ans);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2688
s = input()

i = 0
j = len(s)-1

ans = 0
while i < j:
    if s[i] == s[j]:
        i += 1
        j -= 1
    elif s[i] == "x":
        i += 1
        ans += 1
    elif s[j] == "x":
        j -= 1
        ans += 1
    else:
        break

if i >= j:
    print(ans)
else:
    print(-1)


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << 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; }

int main(void){
    long double L; cin >> L;
    long double ans = (L*L*L)/27;
    cout << fixed << setprecision(10) << ans << en;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,m,x,y,ans[111111],dp[111111],pre[222222],suf[222222],a[222222],cnt;
vector<long long> g[111111];
void dfs(long long i,long long fa)
{
	dp[i]=1;
	for (long long j=0;j<g[i].size();j++)
	{
		long long to=g[i][j];
		if (to==fa) continue;
		dfs(to,i);
		dp[i]=dp[i]*(dp[to]+1)%m;
	}
}
void dft(long long i,long long fa)
{
	long long pcnt=cnt,ncnt,fo,anp,ant,anr;
	ans[i]=dp[i];
	for (long long j=0;j<g[i].size();j++)
	{
		long long to=g[i][j];
		a[++cnt]=dp[to]+1;
	}
	ncnt=cnt;
	pre[pcnt+1]=a[pcnt+1];
	for (long long j=pcnt+2;j<=ncnt;j++) pre[j]=pre[j-1]*a[j]%m;
	suf[ncnt]=a[ncnt];
	for (long long j=ncnt-1;j>pcnt;j--) suf[j]=suf[j+1]*a[j]%m;
	fo=pcnt;
	for (long long j=0;j<g[i].size();j++)
	{
		long long to=g[i][j];
		fo++;
		if (to==fa) continue;
		if (fo>pcnt+1) anp=pre[fo-1];
		else anp=1;
		if (fo<ncnt) anp=anp*suf[fo+1]%m;
		ant=dp[to];anr=dp[i];
		dp[i]=anp;
		dp[to]=dp[to]*(dp[i]+1)%m;
		dft(to,i);
		dp[i]=anr;dp[to]=ant;
	}
}
int main()
{
	scanf("%lld%lld",&n,&m);
	for (long long i=1;i<n;i++)
	{
		scanf("%lld%lld",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);  
	}
	dfs(1,0);
	dft(1,0);
	for (long long i=1;i<=n;i++) printf("%lld\n",ans[i]);
	return 0;
} 

Measured memory_bytes: 21760
import java.util.Scanner;

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

        int[][] dp = new int[s.length()+1][t.length()+1];
        for(int i=1 ; i<= s.length() ; i++ ){
            char ci = s.charAt(i-1);
            for(int j=1 ; j<= t.length() ; j++ ){
                char cj = t.charAt(j-1);
                if(ci == cj){
                    dp[i][j]=dp[i-1][j-1]+1;
                }else{
//                    System.out.println("[i][j]="+i+" "+j +" dp[i][j-1]="+dp[i][j-1] + " dp[i-1][j]="+dp[i-1][j]);
                    if(dp[i][j-1]>=dp[i-1][j]){
                        dp[i][j]=dp[i][j-1];
                    }else{
                        dp[i][j]=dp[i-1][j];
                    }
                }
            }
        }
//        System.out.println(dp[s.length()][t.length()]);

        int i=s.length();
        int j=t.length();
        StringBuilder sb = new StringBuilder();
        while(i>0 && j>0){
            char ci= s.charAt(i-1);
            char cj=t.charAt(j-1);
            if(ci==cj){
                sb.insert(0,ci);
                i--;
                j--;
            }else if(dp[i][j] ==dp[i][j-1]){
                j--;
            }else{
                i--;
            }
        }
        System.out.println(sb.toString());

    }
}


Measured memory_bytes: 87888
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1LL << 60;
//const int INF = 1001001001;

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(void){
    ll n;
    cin >> n;
    auto v=divisor(n);
    ll ans=INF;
    REP(i,v.size()/2){
        if(ans>v[i]+v[v.size()-1-i])
            ans=v[i]+v[v.size()-1-i];
    }
    if(v.size()%2==1)
        if(ans>v[v.size()/2]*2)
            ans=v[v.size()/2]*2;
    cout << ans-2;
    return 0;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	vector<int> c(n - 1), s(n - 1), f(n - 1);
	for (int i = 0; i < n - 1; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}

	for (int i = 0; i < n; i++) {
		int t = 0;
		for (int j = i; j < n - 1; j++) {
			if (t <= s[j]) {
				t = s[j];
			} else if (t % f[j] == 0) {
				t = t;
			} else {
				t = t + f[j] - (t % f[j]);
			}
			t += c[j];
		}
		cout << t << endl;
	}
	return 0;
}


Measured memory_bytes: 256
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
	var one = nextIntArray();
	var N = one[0];
	var X = one[1];
	var Y = one[2];
	var k = new Array(N - 1).fill(0);
	for(var i = 1; i <= N - 1; i++){
		for(var j = i + 1; j <= N; j++){
			var L = Math.min(j - i, Math.abs(i - X) + Math.abs(Y - j) + 1);
			k[L - 1]++;
		}
	}
	myout(myconv(k,9));
}

Measured memory_bytes: 21320
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
ll u, v;

// dont declare n in main,clear adj,as init doesnt do it,call init()
ll depth[N];
ll dp[N][20];
vector<ll> adj[N];
ll n;
void dfs(ll curr, ll prev1 = -1, ll depth1 = 0) {
  depth[curr] = depth1;
  dp[curr][0] = prev1;

  for (ll x : adj[curr]) {
    if (x != prev1) {
      dfs(x, curr, depth1 + 1);
    }
  }
}

ll findLca(ll a, ll b) {
  if (a == b)
    return a;
  if (depth[a] < depth[b])
    swap(a, b);
  ll rem = depth[a] - depth[b];
  for (ll i = 19; i >= 0; i--) {
    if (rem & (1 << i))
      a = dp[a][i];
  }

  if (a == b)
    return a;

  for (ll i = 19; i >= 0; i--) {
    if (dp[a][i] != dp[b][i])
      a = dp[a][i], b = dp[b][i];
  }
  return dp[a][0];
}
void init() {
  memset(dp, -1, sizeof(dp));
  dfs(v);
  for (ll i = 1; i < 20; i++) {
    for (ll j = 1; j <= n; j++) {
      if (dp[j][i - 1] != -1)
        dp[j][i] = dp[dp[j][i - 1]][i - 1];
    }
  }
}
ll dist(ll a, ll b) { return depth[a] + depth[b] - 2 * depth[findLca(a, b)]; }

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

  cin >> n >> u >> v;

  for (ll i = 1; i < n; i++) {
    ll a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }

  init();

  ll res = 0;
  for (ll i = 1; i <= n; i++) {
    if (adj[i].size() == 1 && i != v) {

      ll dist1 = dist(u, i);

      ll lc = findLca(u, i);
      if (lc != u) {
        ll distT = dist(u, lc);
        ll distA = dist(v, lc);
        if (distT >= distA) {
          continue;
        }
        ll dist2 = dist(v, i);
        res = max(res, dist2 - 1);
      } else {

        //  cout << i << en;
        ll dist2 = dist(v, i);
        res = max(res, dist2 - 1);
      }
    }
  }

  cout << res << en;

  return 0;
}

Measured memory_bytes: 26112
#include <iostream>
#include <string>

using namespace std;

int main(){
	int i,N,min_rank = -10000,min_val=100000000;
	int A,B;//int* A,B;
	int ans=0;
	cin>>N;

	//A = new int [N];
	//B = new int [N];

	for(i=0;i<N;i++){
		cin>>A>>B;
		if( A > min_rank){
			min_rank = A;
			min_val = B;
		}
	}
	
	//cout<<min_rank<<" "<<min_val<<endl;
	ans = min_rank + min_val;

	cout<<ans<<endl;


	
	
	//delete [] A;
	//delete [] B;
	return 0;
}

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

int main () {

    string S;
    cin >> S;

    string ans;
    if (S == "Sunny") ans = "Cloudy";
    else if (S == "Cloudy") ans = "Rainy";
    else ans = "Sunny";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
s = input()
ans = ''
while 1:
    if s[-7:] == 'dreamer':
        s = s[:-7]
        continue
    if s[-6:] == 'eraser':
        s = s[:-6]
        continue
    if s[-5:] == 'dream':
        s = s[:-5]
        continue
    if s[-5:] == 'erase':
        s = s[:-5]
        continue
    if s == '':
        ans = 'YES'
        break
    else:
        ans = 'NO'
        break
print(ans)

Measured memory_bytes: 3188
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();
        System.out.println((a==b)?(a==c)?1:2:(a==c)?2:(b==c)?2:3);
    }
}


Measured memory_bytes: 21844
#include<iostream>

typedef unsigned long long  ULL;
using namespace std;
int main(){
	ULL n,m;
	ULL sum = 0;
	ULL temp;
	cin >> n >> m;
	
	temp = n*2;
	if( temp <= m ){
		sum = n;
		m -= n*2;
		sum += m/4;
	}else{
		sum = m/2;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

h,n = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]

dp = [[10**10]*(h+10**4+1) for _ in range(n+1)]
for i in range(n+1):
    dp[i][0] = 0

for i in range(1,n+1):
    a,b = ab[i-1][0], ab[i-1][1]
    for j in range(h+10**4+1):
        if j - a >= 0:
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-a]+b, dp[i][j-a]+b)
        else:
            dp[i][j] = dp[i-1][j]

print(min(dp[-1][h:]))


Measured memory_bytes: 191512
#include<iostream>
using namespace std;
int N;
long long A[100];
int main(){
    int mini,maxi;
    mini = 1000000001;
    maxi = 0;
    cin >> N;
    for(int i = 0;i < N; i++){
        cin >> A[i];
        if(A[i] < mini){
            mini = A[i];
        }
        if(A[i] > maxi){
            maxi = A[i];
        }
    }
    cout << maxi - mini << endl;
    return 0;
}

Measured memory_bytes: 256
/******************************************************************************
 
рассвет. 
 
*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define all(a) (a).begin(),(a).end()
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int> 
#define vplli vector <pair <lli,lli> >
#define vvi vector <vector <int> >
#define vvlli vector <vector <lli> >
#define vvpii vector <vector <pair <int,int>> >
#define fr(i,n) for (int i = 0; i < (n); ++i)
#define frbig(i,n) for (lli i = 0; i < (n); ++i)
#define fra(i,a,n) for (int i = a; i < (n); ++i)
#define run(c,s) for(auto c:s) 
#define read(n) int n; cin >> n;
#define readchar(n) char n; cin >> n;
#define readstr(n) string n; cin >> n;
#define readarr(a,n) fr(i,n) cin >> a[i];
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i] << " ";
using namespace std;
 
const lli MOD=1e9+7;
const lli MAXN=1e5+1;
const ld PI=acos(-1);

vvpii g(MAXN);
bool used[MAXN];
vi ans(MAXN,0);

void dfs(int v=1, int odd=0){
    ans[v]=odd;
    used[v]=1;
    run(to,g[v]){
        if(!used[to.fst]){
            if(to.sec){
                dfs(to.fst,odd^to.sec);
            }
            else dfs(to.fst,odd);
        }
    }
}

int main(){
    rapgame
    //freopen("brokeday.in", "r", stdin);
    //freopen("richday.out", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--){
        read(n);
        fr(i,n-1){
            read2(v,u);read(w);
            g[v].pb({u,w%2});
            g[u].pb({v,w%2});
        }
        dfs();
        fr(i,n){
            cout << ans[i+1] << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 11004
N = int(input())

MX = 10**4
ans = {}
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            tmp = x**2+y**2+z**2+x*y+x*z+y*z

            if not(tmp in ans):
                ans[tmp] = 1
            else:
                ans[tmp] += 1

for i in range(1, N+1):
    if i in ans:
        print(ans[i])
    else:
        print(0)


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

const int MAXN=2000001;

int n,q;

int head[MAXN],pnt[MAXN],nxt[MAXN],w[MAXN]={0},vis[MAXN],sum[MAXN]={0};

int po=1;
void add(int a,int b)
{
	pnt[po]=b;
	nxt[po]=head[a];
	
	head[a]=po;
	po++;
	
}

void dfs(int v,int fa)
{
	for(int i=head[v];i!=-1;i=nxt[i]){
		int to=pnt[i];
		if(to!=fa) 
		{
			sum[to]+=sum[v];
			dfs(to,v);
		}
	}
}

signed main(){
	memset(head,-1,sizeof(head));
	scanf("%lld%lld",&n,&q);
	
	for(int i=1;i<=n-1;++i)
	{
		int u,v;
		scanf("%lld%lld",&u,&v);
		add(u,v);
		add(v,u);
	}
	sum[1]=1; 
	
	for(int i=1;i<=q;++i)
	{
		int r,s;
		scanf("%lld%lld",&r,&s);
		sum[r]+=s;
	} 
	cout<<endl;
	dfs(1,0);
	for(int i=1;i<=n;++i)
	{
		cout<<sum[i]-1<<" ";
	} 
	return 0;
}


Measured memory_bytes: 38400
#!/usr/bin/env python3
import sys
import fractions

def solve(A: int, B: int, C: int, D: int):
    def can_div_by(x: int):
        return (B // x) - (A - 1) // x

    c = can_div_by(C)
    d = can_div_by(D)
    cd = can_div_by(C*D // fractions.gcd(C, D))
    return B - A + 1 - (c + d - cd)

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    print(solve(A, B, C, D))

if __name__ == '__main__':
    main()


Measured memory_bytes: 5076
#include<iostream>
#include<cmath>
#include<queue>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cstring>
#include<string>
#include<utility>
#include<set>
#include<map>
#include<stack>
#include<vector>
#define inf 0x3f3f3f3f
using namespace std;
int T;
int n;
int cnt[105];
int x,a,b;
int main()
{
    while(~scanf("%d%d%d",&x,&a,&b))
    {
        int aa = abs(x-a);
        int bb = abs(x-b);
        if(aa<=bb)
            puts("A");
        else
            puts("B");
    }
}


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

#define loop(s, e, i) for (int i = s; i < e; ++i)
#define print(s) cout << s << endl;
#define DIV 1000000007
#define ll long long
using namespace std;

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int x;
  cin >> x;
  if (x == 1) print(0)
  else print(1);
}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 29)
using namespace std;

int main(){
    string str;
    string a = "CODEFESTIVAL2016";
    int cnt = 0;
    cin >> str;
    rep(i,str.size()){
        if(str[i] != a[i]) cnt++;
    } 
    cout << cnt << endl;
}


Measured memory_bytes: 764
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Ord

main :: IO ()
main = readLn >>= main'
    where
        main' n = readLine >>= print . solve n 

solve :: Int -> [Int] -> Int 
solve n as = fst . head . sortBy cmpf . map mf . zip [0..] $ map fromIntegral as
    where
        avrage = (fromIntegral . sum) as / fromIntegral n
        mf (x, y) = (x, abs $ y - avrage)
        cmpf lhs rhs = comparing snd lhs rhs `mappend` comparing fst lhs rhs

readLine :: IO [Int]
readLine = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 508
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

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

    rep(i, N) {
        int K, P; cin >> K >> P;
        cout << (K % P == 0 ? P : K % P) << endl;
    }
}

Measured memory_bytes: 1160
# https://atcoder.jp/contests/abc156/submissions/10277689

# コンテスト中に通せたけどmodintクラスで実装してみる
import sys
read = sys.stdin.readline


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


class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x + other.x)
        else:
            return ModInt(self.x + other)

    def __sub__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x - other.x)
        else:
            return ModInt(self.x - other)

    def __mul__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x * other.x)
        else:
            return ModInt(self.x * other)

    def __truediv__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x * pow(other.x, MOD - 2, MOD))
        else:
            return ModInt(self.x * pow(other, MOD - 2, MOD))

    def __pow__(self, other):
        if isinstance(other, ModInt):
            return ModInt(pow(self.x, other.x, MOD))
        else:
            return ModInt(pow(self.x, other, MOD))

    __radd__ = __add__

    def __rsub__(self, other):  # 演算の順序が逆
        if isinstance(other, ModInt):
            return ModInt(other.x - self.x)
        else:
            return ModInt(other - self.x)

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        if isinstance(other, ModInt):
            return ModInt(other.x * pow(self.x, MOD - 2, MOD))
        else:
            return ModInt(other * pow(self.x, MOD - 2, MOD))

    def __rpow__(self, other):
        if isinstance(other, ModInt):
            return ModInt(pow(other.x, self.x, MOD))
        else:
            return ModInt(pow(other, self.x, MOD))


def combination_mod(n, r, mod):
    if r > n:
        return 0  # このような通りの数は無いため便宜上こう定義する
    r = min(r, n - r)
    nf = rf = 1
    for i in range(r):
        nf = nf * (n - i) % mod
        rf = rf * (i + 1) % mod
    return nf * pow(rf, mod - 2, mod) % mod


def combination(n, r):
    if r > n:
        return 0  # このような通りの数は無いため便宜上こう定義する
    r = min(r, n - r)
    nf = rf = ModInt(1)
    for i in range(r):
        nf = nf * (n - i)
        rf = rf * (i + 1)
    return nf / rf


# すべての通り(2^n-1)からnCa,nCbを引けば良い
MOD = 10**9 + 7
n, a, b = read_ints()
# tmp = pow(2, n, MOD) - 1
# ans = tmp - combination_mod(n, a, MOD) - combination_mod(n, b, MOD)
# print(ans % MOD)

tmp = ModInt(2)**n - 1
ans = tmp - combination(n, a) - combination(n, b)
print(ans)


Measured memory_bytes: 3192
n = int(input())
a1 = [int(input()) for i in range(n)]
a2 = sorted(a1, reverse=True)

for v1 in a1:
    count = 0
    for v2 in a2:
        if v1 == v2 and count == 0:
            count += 1
        else:
            print(v2)
            break


Measured memory_bytes: 14112
fun main(args: Array<String>) {
    val k = readLine()!!.toLong()
    var num = 0L
    var d = 1L
    for (i in 1..k) {
        val sumKeta = (num + d).toDouble() / sumKeta(num + d).toDouble()
        val sumKeta1 = (num + 10 * d).toDouble()  / sumKeta(num + 10 * d).toDouble()
        if (sumKeta > sumKeta1) d *= 10
        num += d
        println(num)
    }
}

fun sumKeta(num: Long): Int {
    val str = num.toString()
    var sum = 0
    str.forEach { sum += it.toString().toInt() }
    return sum
}

Measured memory_bytes: 31892
import java.util.Scanner;

public class Main {
    static int N;
    static int[] h;
    static int[] dp;

    private static void init() {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        h = new int[N];
        dp = new int[N];
        for(int i = 0; i < N; i++) {
            h[i] = scanner.nextInt();
        }
        scanner.close();
    }

    public static void main(String args[]) {
        init();

        dp[0] = 0;
        dp[1] = Math.abs(h[0] - h[1]);

        for(int i = 2; i < N; i++) {
            int one = dp[i - 1] + Math.abs(h[i] - h[i - 1]);
            int two = dp[i - 2] + Math.abs(h[i] - h[i - 2]);
            dp[i] = Math.min(one ,two);
        }
        
        System.out.println(dp[N - 1]);
    }
}

Measured memory_bytes: 60940
import Control.Monad
import Data.List

type Trump = (Char, Int)

toTrump :: String -> Trump
toTrump l = let (c:n:_) = words l
                charC = head c
            in (charC, read n)

allTrump :: [Trump]
allTrump = let c = concat . map (\c -> take 13 . repeat $ c) $ ['S', 'H', 'C', 'D']
               n = concat . take 4 . repeat $ [1..13]
           in zip c n

trumpShow :: (Trump) -> String
trumpShow (c, n) = c : " " ++  show n

main = do
  n <- getLine
  l <- replicateM (read n) getLine
  let tlist = map toTrump $ l
      solvTrump = filter (\x -> not $ x `elem` tlist) allTrump
  mapM_ (putStrLn . trumpShow) $ solvTrump

Measured memory_bytes: 4000
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int n;
        cin >> n;
        string s;
        cin >> s;
        if (n % 2) {
            cout << "No" << endl;
            return;
        }

        for (int i = 0; i < n / 2; ++i) {
            if (s[i] != s[i + n / 2]) {
                cout << "No" << endl;
                return;
            }
        }
        cout << "Yes" << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<math.h>
#include<algorithm>
typedef long long ll;

using namespace std;

ll n, a, b;
ll x[200005], y[200005], z[200005];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		x[i] = a + b;
		y[i] = a - b;
		z[i] = b - a;
	}
	sort(x, x + n); sort(y, y + n); sort(z, z + n);
	cout << max((x[n - 1] - x[0]), max((y[n - 1] - y[0]), (z[n - 1]-z[0])));
	return 0;
}

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

int main()
{
    int n, a, b, c;
    scanf("%d", &n);
    a = n / 100;
    b = n % 10;
    c = (n % 100) / 10;
    if(a == 7 || b == 7 || c == 7)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 3688