akhauriyash/Code-Regression huggingface dataset:
//Author- VMAX


#include<bits/stdc++.h>
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_multiset tree<long long , null_type,less_equal<long long >, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<long long , null_type,less<long long >, rb_tree_tag,tree_order_statistics_node_update>
*/
using namespace std;
#define ll long long int
#define YES cout<<"YES"<<"\n";
#define NO cout<<"NO"<<"\n";
#define ld     long double 
#define yes cout<<"yes"<<"\n";
#define no cout<<"no"<<"\n";
#define No cout<<"No"<<"\n";
#define Yes cout<<"Yes"<<"\n";
#define f(i,a) for(i=0;i<a;i++)
#define fo(i,a) for(i=1;i<=a;i++)
#define fa(i,a) for(auto i:a)
#define r(i,a) for(auto i=a.rbegin();i!=a.rend();i++)
#define en cout<<"\n";
#define ull unsigned long long int
#define o(x) cout<<x<<"\n";
#define o1(x) cout<<x<<" ";
#define pb push_back
#define F first
#define in insert
#define mp make_pair
#define S second
#define pre(n) cout<<fixed<<setprecision(n);
#define      gcd(a,b)    __gcd(a,b)
#define bs            binary_search
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t-->0)
const ll Mod = 998244353;
#define mod 1000000007
#define pi 3.14159265358979323846
#define all(x) x.begin(),x.end()
#define re return 0;
// *#######################################################################################*

/*
bool isp(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            return false;
        }
        
    }
}
  */
  /*
  ll powerm(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;    
  
    x = x % p; 
   
    if (x == 0) return 0;
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
   
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}
  long long lcm(long long a, long long b){//最小公倍数を求める
   return a * b / gcd(a, b);
}
*/
/*
ll po(ll z,ll z1)
{
    ll rer=0;
    rer=     ((z*(z-1))/2+(z1*(z1-1))/2);
    return rer;

}
*/
/*
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
*/


       int main()
       {
      fast
   
         ll l,r,n;
         cin>>l>>r>>n;
         l--;
         
         o((r/n)-(l/n))
   
   
   
   
   
   
   
   
             
             
           
             

re}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main() {
	cout << fixed << setprecision(10);
	double_t x1, y1, x2, y2;
	std::cin >> x1 >> y1 >> x2 >> y2;
	double_t x = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
	cout << sqrt(x) << endl;
}


Measured memory_bytes: 3272
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i;
		int n,max=0,min=1000,sum=0,ave;
		
		while(true) {
			n = sc.nextInt();
			if (n==0) {
				break;
			}
			
			max=0;min=1000;sum=0;
			
			for (i=0 ; i<n ; i++) {
				int p = sc.nextInt();
				if (p>max) {
					max=p;
				}
if(p<min) {
					min=p;
				}
				sum += p;
			}
			
			sum -= max;
			sum -= min;
			ave = sum/(n-2);
			System.out.println(ave+"");
		}
	}
}


Measured memory_bytes: 28324
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define ll long long

int main() {
    int d;
    cin >> d;
    vector<vector<int>> s(d+1, vector<int>(26+1, 0));
    vector<int> c(26+1);
    for(int i = 0; i < 26; i++) cin >> c[i];
    for(int i = 0; i < d; i++) {
        for(int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    /////////////////
    vector<int> t(d);
    for(int i = 0; i < d; i++) cin >> t[i];

    ///////////////
    int m;
    cin >> m;
    vector<pair<int, int>> dq(m);
    for(int i = 0; i < m; i++) {
        cin >> dq[i].first >> dq[i].second;
        //int tmp = t[dq[i].first-1];
        //t[dq[i].first-1] = dq[i].second;
        
    }
    vector<ll> ans(d, 0);
    ll v = 0;
    ll tmp = 0;
    for(int k = 0; k < m; k++) {
        tmp = t[dq[k].first-1];
        t[dq[k].first-1] = dq[k].second; 
        vector<ll> last(26+1, 0);
        for(int i = 0; i < d; i++) {
            v += s[i][t[i]-1];
            last[t[i]-1] = i+1;
            for(int j = 0; j < 26; j++) {
                v -= c[j]*((i+1)-last[j]);
            }
            
        }
        cout << v << endl;
        v = 0;
    }
    return 0;
}

Measured memory_bytes: 3964
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int main()
{
	string s;
	cin >> s ;
	if (s == "++++")
	{
		cout<< 4 << endl;
	}
	else if (s == "+++-")
	{
		cout << 2 << endl;
	}
	else if(s == "++-+")
	{
		cout << 2 << endl;
	}
	else if(s == "++--")
	{
		cout << 0 << endl;
	}
	else if(s == "+-++")
	{
		cout << 2 << endl;
	}
	else if(s == "+-+-")
	{
		cout << 0 << endl;
	}
	else if(s == "+--+")
	{
		cout << 0 << endl;
	}

	else if(s == "+---")
	{
		cout << -2 << endl;
	}

	else if(s == "----")
	{
		cout << -4 << endl;
	}

	else if(s == "---+")
	{
		cout << -2 << endl;
	}

	else if(s == "--+-")
	{
		cout << -2 << endl;
	}
	else if(s == "--++")
	{
		cout << 0 << endl;
	}

	else if(s == "-+--")
	{
		cout << -2 << endl;
	}
	else if(s == "-+-+")
	{
		cout << 0 << endl;
	}
	else if(s == "-++-")
	{
		cout << 0 << endl;
	}
	else if(s == "-+++")
	{
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
a=input()
if a=="a":
  print("vowel")
else:
  if a=="i":
    print("vowel")
  else:
    if a=="u":
      print("vowel")
    else:
      if a=="e":
        print("vowel")
      else:
        if a=="o":
          print("vowel")
        else:
          print("consonant")

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

struct edge{
  int to,cost;
};

vector<edge> g[100000];
long long dist[100000];


void dfs1(int idx, int par){
  for(edge &e:g[idx]){
    if(e.to==par)continue;
    dfs1(e.to,idx);
    dist[idx]=max(dist[idx],dist[e.to]+e.cost);
  }
}

int dfs2(int idx,int d_par,int par){//idxを根として見ている、parは元（今回だとN/2が根の時代）の親で、d_parはparの自分を含まない側での最長パスの長さ
  vector<pair<int,int>> d_child;//idxを根とした時の（各子の持つ最長パスの長さ,子の番号）が入る
  d_child.emplace_back(0,-1);//番兵みたいなアレ
  for(edge &e:g[idx]) {
    if(e.to==par)d_child.emplace_back(d_par+e.cost,e.to);
    else d_child.emplace_back(e.cost+dist[e.to],e.to);
  }
  sort(d_child.rbegin(),d_child.rend());
  int ret=d_child[0].first+d_child[1].first;//最大から2つ このretがidxを通る最大パスの長さ
  for(edge&e:g[idx]){
    if(e.to==par)continue;
    //基本はd_child()の最大がd_parになるが,e.toの部分木が最大値のときはそれを取り除く必要がある
    ret=max(ret,dfs2(e.to,d_child[d_child[0].second==e.to].first,idx));//自分の各子に対してそれを通る最長パスの長さと比較
  }
  return(ret);
}

int main(){
  int N;
  cin>>N;
  for(int i=0;i<N-1;i++){
    int a,b,w;
    cin>>a>>b>>w;
    g[a].push_back((edge){b,w});
    g[b].push_back((edge){a,w});
  }
  //dfs1(N/2,-1);//N/2が根の時の各点の子孫との最大距離を求める
  //cout<<dfs2(N/2,0,-1)<<endl;
  dfs1(0,-1);
  cout<<dfs2(0,0,-1)<<endl;
}



Measured memory_bytes: 31208
import java.io.*;
import java.util.*;
import java.math.BigInteger;

public class Main{
	//for(Map.Entry<Object, Object> e: map.entrySet()){ ...
	public static void main(String[] args){
		try{
//-*-*- tp start -*-*-
			final int INF = Integer.MAX_VALUE, MINF = Integer.MIN_VALUE;
			SpecialComparator scomparator = new SpecialComparator();
			Scanner s = new Scanner(System.in);
//-*-*- tp end -*-*-
			//write a program...
			int N = s.nextInt();
			for(int i = 0; i < N; i++){
				int[] in = new int[3];
				for(int j = 0; j < 3; j++){
					in[j] = s.nextInt();
				}
				Arrays.sort(in);
				if((int)Math.pow(in[0],2)+(int)Math.pow(in[1],2)==(int)Math.pow(in[2],2)){
					debugl("YES");
				}else debugl("NO");
			}
//-*-*- tp start -*-*-
		}catch(Exception e){
			e.printStackTrace();
		}
	}
//-*-*- tp end -*-*-
	//functions
//-*-*- tp start -*-*-
	private static void debugl(Object obj){
		System.out.println(obj);
	}
	private static void debug(Object obj){
		System.out.print(obj);
	}
	private static String toStrmd(Object[] obj){
		return Arrays.deepToString(obj);
	}
}

class SpecialComparator implements Comparator{
	private int index = 0;
	public void setIndex(int index){
		this.index = index;
	}
	public int compare(Object a, Object b){
		String[] sa = (String[])a;
		String[] sb = (String[])b;
		return (sa[index].compareTo(sb[index]));
	}
}
//-*-*- tp end -*-*-

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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e5+5;

vector<int> adj[N];
int ans[N][2];
int n;

void dfs(int x, int p) {
	if(adj[x].size()==1 && x>1) {
		ans[x][0]=1;
		ans[x][1]=1;
		return;
	}
	int bans=1, wans=1;
	for(int i: adj[x]) {
		if(i==p)
			continue;
		dfs(i, x);
		int bcnt = ans[i][0];
		int wcnt = ans[i][1];
		bans = (bans*wcnt)%MOD;
		wans = (wans*(wcnt+bcnt))%MOD;
	}
	ans[x][0]=bans;
	ans[x][1]=wans;
}

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

	cin>>n;
	int u,v;
	for(int i=1;i<n;i++) {
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}

	dfs(1, -1);

	cout<<(ans[1][0]+ans[1][1])%MOD;

	return 0;
}

Measured memory_bytes: 17512
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 3e+5+5;

int n,m;
struct edge{
	int x,nxt;
}e[N];
int h[N],et;
struct node{
	int l,r,tot;
}tree[N*18];
int rt[N],tot;

void inse(int x,int y){e[++et].x=y;e[et].nxt=h[x];h[x]=et;}

void add(int &now,int qf,int l,int r,int x){
	tree[now=++tot]=tree[qf];
	tree[now].tot++;
	if (l==r)return;
	int mid=(l+r)/2;
	if (x<=mid)add(tree[now].l,tree[qf].l,l,mid,x);
	else add(tree[now].r,tree[qf].r,mid+1,r,x);
}

int gettot(int now,int qf,int l,int r,int x,int y){
	if (x<=l&&r<=y)return tree[now].tot-tree[qf].tot;
	int mid=(l+r)/2,cnt=0;
	if (x<=mid)cnt=gettot(tree[now].l,tree[qf].l,l,mid,x,y);
	if (y>mid)cnt+=gettot(tree[now].r,tree[qf].r,mid+1,r,x,y);
	return cnt;
}

int main(){
	n=get();m=get();
	fo(i,1,n){int l=get(),r=get();inse(r,l);}
	fo(i,1,m){
		rt[i]=rt[i-1];
		for(int p=h[i];p;p=e[p].nxt)add(rt[i],rt[i],1,m,e[p].x);
	}
	printf("%d\n",n);
	fo(i,2,m){
		int ans=n;
		fo(j,0,m/i)
			ans=ans-gettot(rt[min(m,(j+1)*i-1)],rt[j*i],1,m,j*i+1,min(m,(j+1)*i-1));
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 68096
// C - Fennec vs Monster
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N,K;
	int H[200000];
	cin>>N>>K;
	long long ans = 0;
	if(N > K){
		rp(i,0,N) cin>>H[i];
		sort(H, H+N);
		rp(i,0,N-K) ans += H[i];
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
template <typename T>
void warshall_floyd(vector<vector<T>> &g, T inf) {
    rep(k, g.size()) {
        rep(i, g.size()) {
            rep(j, g.size()) {
                if (g[i][k] == inf || g[k][j] == inf) continue;
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
}

/*
vector<vector<ll>> G(V, vector<ll>(V,INF));
rep(i,V) G[i][i]=0;
rep(i,E)G[from][to]=cost;
warshall_floyd(G, )
*/

int main() {
    init();
    ll N,M,R;
    cin>>N>>M>>R;
    vc<ll> r(R);
    rep(i, R) cin >> r[i], r[i]--;
    vector<vector<ll>> G(N, vector<ll>(N,INF));
    rep(i,N) G[i][i]=0;
    
    rep(i,M){
        ll a,b,c;
        cin >> a >> b >> c;
        a--, b--;
        G[a][b] = G[b][a] = c;
    }

    warshall_floyd(G, INF);

    sort(all(r));

    ll ans = INF;
    do{
        ll tmp = 0;
        rep(i, R - 1) tmp += G[r[i]][r[i + 1]];
        chmin(ans, tmp);
    } while (next_permutation(all(r)));

    cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<cctype>

using namespace std;

int main(){

	int n;
	int num=0;
	cin>>n;

	for(int i=0;i<101;i++){
		
		num = n-7*i;
		if(num<0){
		break;
		}else if(num%4==0){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;


return 0;

}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void) {
  int x, a, b;
  cin >> x >> a >> b;
  if (b <= a) {
    cout << "delicious" << endl;
  } else if (b <= a + x) {
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t--!=0){
			int runner = 0;
			int point = 0;
			int out = 0;
			while(out < 3){
				String c = sc.next();
				if(c.equals("HIT")){
					if(runner<3)runner++;
					else point++;
				}
				else if(c.equals("HOMERUN")){
					point += runner+1;
					runner = 0;
				}
				else{
					out++;
				}
			}
			System.out.println(point);
		}
	}
}

Measured memory_bytes: 17196
INF = 10 ** 18
N = int(input())
A = list(map(int, input().split()))
up = max(A)
low = min(A)
res = INF
for i in range(low, up + 1):
    t = 0
    for a in A:
        t += (i - a) ** 2
    res = min(res, t)
print(res)


Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

string s;
cin >> s;

string t = {};
rep(i,s.size()) {
    if(i%2 == 0) t.push_back(s[i]);
}

cout << t << endl;

return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#ifdef LOCAL
#include "debug_print.hpp"
#else
void debug(...) {}
#endif

const int mod = 1000000007;
// const int mod = 998244353;

struct mint
{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint &operator+=(const mint m)
    {
        if((x += m.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator-=(const mint m)
    {
        if((x += mod - m.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator*=(const mint m)
    {
        (x *= m.x) %= mod;
        return *this;
    }
    mint operator+(const mint m) const
    {
        return mint(*this) += m;
    }
    mint operator-(const mint m) const
    {
        return mint(*this) -= m;
    }
    mint operator*(const mint m) const
    {
        return mint(*this) *= m;
    }
    mint pow(ll n) const
    {
        if(!n) return 1;
        mint m = pow(n>>1);
        m *= m;
        if(n & 1) m *= *this;
        return m;
    }
    mint inv() const { return pow(mod-2);}
    mint &operator/=(const mint m) { return *this *= m.inv();}
    mint operator/(const mint m) const { return mint(*this) /= m;}
};
istream &operator>>(istream &is, mint &m) { return is >> m.x;}
ostream &operator<<(ostream &os, const mint &m) { return os << m.x;}

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1)
    {
        assert(n < mod);
        fact.at(0) = 1;
        for(int i=1; i<=n; i++)
        {
            fact.at(i) = fact.at(i-1) * i;
        }
        ifact.at(n) = fact.at(n).inv();
        for(int i=n; i>=1; i--)
        {
            ifact.at(i-1) = ifact.at(i) * i;
        }
    }
    mint operator()(int n, int k)
    {
        if(k < 0 || k > n) return 0;
        return fact.at(n) * ifact.at(k) * ifact.at(n-k);
    }
};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int S;
    cin >> S;
    mint ans = 0;
    combination comb(S);
    // i個の項に分ける
    for(int i=1; i*3 <= S; i++)
    {
        int N = S - i * 3;
        ans += comb(N + i - 1, i-1);
        debug(i, comb(N, i-1));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3648
import java.util.*;

public class Main {
	static boolean arive=false;
	static int t[];
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt(); t=new int[n];
		
		for(int i=0;i<n;i++)t[i]=Integer.parseInt(in.next());
		
		
		if(solve(0,'p') && solve(n-1,'r'))System.out.println("yes");
		else System.out.println("no");

	}
	
	static boolean solve(int u,char odr) {
		Stack<Integer> stk=new Stack<>();
		int d[]=new int[t.length];
		boolean jd=false;
		stk.add(u);
		while(!stk.isEmpty()) {
			int n=stk.peek();
			//System.out.println(n);
			if((odr=='p' && n==t.length-1) || odr=='r' && n==0) {
				jd=true;
				break;
			}
			
			if(odr=='p') {
				int v=n+(t[n]/10)-d[n];
				if(v>n) {
					if(v<t.length)stk.push(v);
					d[n]++;
				}
				else {
					stk.pop();
				}
			}
			else {
				int v=n-(t[n]/10)+d[n];
				if(v<n) {
					if(v>=0)stk.push(v);
					d[n]++;
				}
				else {
					stk.pop();
				}
			}
			
		}
		return jd;
	}

}



Measured memory_bytes: 82216
"""AtCoder Beginner Contest 178.

A
"""

import sys


def input() -> str:  # noqa: A001
    """Input."""
    return sys.stdin.readline()[:-1]


def main():
    """Run."""
    v = int(input())
    pattern = {0: 1, 1: 0}
    print(pattern[v])


main()


Measured memory_bytes: 9164
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

N = int(input())
a = []
dp = [0]*(N+1)
for i in range(N+1):
    dp[i] = [0]*3
#print('dp', dp)
for _ in range(N):
    a.append(tuple(map(int, input().split())))
#print('a', a)
dp[0][0] = 0

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


Measured memory_bytes: 74700
#include <bits/stdc++.h>
typedef long long LL;
const int MaxN = 2e5;
const int inf = 1<<30;
using namespace std;

int num[MaxN + 5],b[MaxN + 5];
int main(){
	int n;
	cin>>n;
	for(int i=1; i<=n; ++i)cin>>num[i];
	sort(num+1,num+n+1);
	int min = inf,min_i;
	for(int i = 1;i<n;i++){
		if(num[i]<=num[n]/2){
			if(min > abs(num[i] - num[n]/2)){
				min = abs(num[i] - num[n]/2);
				min_i = i;
			}
		}
		else{
			if(min > abs(num[i] - num[n]/2 - 1)){
				min = abs(num[i] - num[n]/2 - 1);
				min_i = i;
			}
		}
	}
	printf("%d %d\n",num[n],num[min_i]);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
    long long n,l,i;
    string s[2000];
    cin>>n>>l;
    for(i=1;i<=n;i++)
    {
        cin>>s[i];
    }
    sort(s+1,s+1+n);
    for(i=1;i<=n;i++)
    {
        cout<<s[i];
    }
    cout<<endl;
}

Measured memory_bytes: 3712
<?php
// abc079_d
list($h, $w) = ints();
for ($i = 0; $i < 10; ++$i)
    foreach (ints() as $j => $v) $cost[$i][$j] = $v;
for ($i = 0; $i < 10; ++$i) $d[$i] = dijkstra($i, 10);
$ans = 0;
for ($i = 0; $i < $h; ++$i)
    foreach (ints() as $v) $ans += $v !== -1 ? $d[$v][1] : 0;
echo $ans;

function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}

// ノードsからの各ノードへの最短距離
function dijkstra($s, $n)
{
    global $cost;
    $d = array_fill(0, $n, INF);
    $d[$s] = 0;
    $used = array_fill(0, $n, false);
    while (true) {
        $v = -1;
        // 残りのノードのうち最短で到達出来るノードを選択
        for ($i = 0; $i < $n; ++$i) {
            if (!$used[$i] && $v === -1) $v = $i;
            elseif (!$used[$i] && $d[$i] < $d[$v]) $v = $i;
        }
        if ($v === -1) break;
        for ($i = 0; $i < $n; ++$i) $d[$i] = min($d[$i], $d[$v] + $cost[$v][$i]);
        $used[$v] = true;
    }
    return $d;
}


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

l=[]
r=[]
for i in range(M):
    l.append(L[i][0])
    r.append(L[i][1])
a=min(r)-max(l)+1
if a>=0:
    print(a)
else:
    print(0)


Measured memory_bytes: 72280
x, y = map(int, input().split())

if (x+y)%3 != 0:
    print(0)
    exit()

m = (2*x - y)//3
n = (2*y - x)//3

if m<0 or n<0:
    print(0)
    exit()

"""Combination(mod付き)の高速計算"""
def extgcd(a, b):
    if b == 0:
        return a, 1, 0
    else:
        d, x, y = extgcd(b, a % b)
        x -= (a // b) * y
        return d, y, x
    
def modinv(a, mod): 
    return extgcd(a, mod)[1] % mod

def modcomb(n, k, mod):
    q, a = 1, 1
    for i in range(n-k+1, n+1):
        q = (q * i) % mod
    for i in range(2, k+1):
        a = (a * i) % mod
    return int(q * modinv(a, mod) % mod)

ans = modcomb(n+m, m, 10**9+7)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
    int a, b, c;
    scanf("%d %d", &a, &b);
    if((a*b)%2 == 0){
        printf("No\n");
    } else {
        if(a*b == 1)
            printf("Yes\n");
        else
            printf("Yes\n");
    }

}


Measured memory_bytes: 128
/* ex 5_4
   potter0723sw */

#include <stdio.h>
#include <string.h>
#define SIZE 11

int main(void){
    int i,pre,counter = 0,ans = 0;
    char str1[SIZE],sub[2] = "A", *ret;
    scanf("%s", str1);
    while(counter != 4){//4回ループでそれぞれA,T,C,Gから始まる部分文字列に対して長さを調べる
        pre=0;
        while((ret = strstr(str1+pre,sub)) != NULL){
            i = 0;
            while(*(ret+i) == 'A' || *(ret+i) == 'T' || *(ret+i) == 'C' || *(ret+i) == 'G'){
                i++;//ATCGが続く度長さを追加
            }
            if(i > ans){//部分文字列が今までで最長なら更新
                ans = i;
            }
            pre+=strlen(str1)-strlen(ret)+strlen(sub);
        }
        switch(counter){//次の頭文字に変換
            case 0:
                sub[0] = 'T';
                break;
            case 1:
                sub[0] = 'C';
                break;
            case 2:
                sub[0] = 'G';
                break;
            case 3:
                break;//4回終わったあとなので特にする必要なし
        }
        counter++;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1732
## for use in beginner level questions where speed is key
## and also for single test case code
## mastercopy for x,y,z

import sys
import heapq, functools, collections
import random
from collections import Counter, defaultdict

# read line as a string
strr = input()

# read line as an integer
# k = int(input())

# read one line and parse each word as a string
# lst = input().split()

# read one line and parse each word as an integer
# arr = list(map(int,input().split()))

if "RRR" in strr:
    print(3)
elif "RR" in strr:
    print(2)
elif "R" in strr:
    print(1)
else:
    print(0)


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

int main() {
    int N;
    cin>>N;
    int k = -1;
    int tmp = 0;
    vector<vector<int> > ansarr;
    vector<int>tmparr;;
    for(int i=1;i<=N;++i){
        tmp += i;
        for(int j=tmp-i+1;j<=tmp;++j){
            tmparr.push_back(j);
        }
        ansarr.push_back(tmparr);
        tmparr.clear();
        if(N==tmp){
            k = i;
            break;
        }
        if(N < tmp) {
            break;
        }
    }
    reverse(ansarr.begin(), ansarr.end());
    /**
    for(int i=0;i<ansarr.size();++i){
        for(int j=0;j<ansarr[i].size();++j){
            cout<<ansarr[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
    **/
    if(k==-1){
        cout<<"No"<<endl;
    }
    else {
        cout<<"Yes"<<endl;
        cout<<k+1<<endl;
        for(int i=0;i<k;++i){
            cout<<k<<" ";
            for(int j=0;j<=i;++j){
                if(j!=i){
                    cout<<ansarr[j][i-j-1]<<" ";
                }
                else {
                    for(int k=0;k<ansarr[j].size();++k){
                        cout<<ansarr[j][k]<<" ";
                    }
                }
            }
            cout<<endl;
        }
        cout<<k<<" ";
        for(int i=0;i<k;++i){
            cout<<ansarr[i][ansarr[i].size()-1]<<" ";
        }
        cout<<endl;
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(S == T) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inp_ll;

const int MAXN = 300010;
const int MOD = 998244353;

ll p[MAXN], r[MAXN];

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b%2) t = t*a%p;
	return t;
}

ll C(ll n, ll m)
{
	return p[n]*r[m]%MOD*r[n-m]%MOD;
}

int main()
{
	
	p[0] = r[0] = 1;
	for (int i = 1; i < MAXN; ++ i)
	{
		p[i] = p[i-1]*i%MOD;
		r[i] = power(p[i], MOD-2, MOD);
	}
	
	ll N, A, B, K;
	cin >> N >> A >> B >> K;
	ll ans = 0;
	for (ll x = 0; x <= N; ++ x)
	{
		ll res = K-A*x;
		if (res >= 0 && res%B == 0)
		{
			ll y = res/B;
			if (0 <= y && y <= N)
				ans = (ans+C(N, x)*C(N, y))%MOD;
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x;
	int y;
	int a;
	int b;
	int c;
	scanf("%d",&x);
	a=800*x;
	y=x/15;
	floor(y);
	b=200*y;
	c=a-b;
	printf("%d\n",c);
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

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

    string s,t;
    cin>>s>>t;
    int r = s.size();
    bool f=0;
    for(int i=0;i<r;i++)
    {
        if(s[i]!=t[i])
        {
            f=1;
            break;
        }
    }
    if(f==1)
        cout<<"No";
    else
        cout<<"Yes";

    return 0;
}

Measured memory_bytes: 3648
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <cmath>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;


signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;

    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }

    return 0;
}


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

using namespace std;
using ll = long long;
constexpr ll mod = 1e9+7;
constexpr ll md = mod;
constexpr ll inf = 1e15;
int main(){
    int n;
    cin>>n;
    int k;
    cin>>k;
    vector<pair<int,int>> v;
    if(k > (n-2)*(n-1)/2){
        cout << -1 << endl;
    }else{
        for(int i=2;i<=n;++i)v.push_back({1,i});
        int sum = (n-2)*(n-1)/2;
        sum -= k;
        bool ok = false;
        for(int i=2;i<n;++i){
            for(int j=i+1;j<=n;++j){
                if(sum <= 0){
                    ok = true;
                    break;
                }
                v.push_back({i,j});
                sum--;
            }
            if(ok) break;
        }
        cout << v.size() << endl;
        for(auto &a : v) cout << a.first << " " << a.second << endl;
    }
    return 0;
}



Measured memory_bytes: 384
import sys
n = int(input())
pt, px, py = 0, 0, 0
for _ in range(n):
    t, x, y = map(int,input().split())
    dt = abs(t-pt)
    dx = abs(x-px)
    dy = abs(y-py)
    if dt<dx+dy or dt%2!=(dx+dy)%2:
        print('No')
        sys.exit()    
    pt,px,py = t,x,y
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 52;

int n, m, s;

vector<int> dist[N];
vector<bool> vis[N];
   
vector<vector<int>> convert;
vector<vector<int>> v[N];

int32_t main(){_
   
   cin>>n>>m>>s;
   const int M = 50 * n;
   
   for (int i = 0; i < N; ++i)
   {
      dist[i].resize(M+10, inf);
      vis[i].resize(M+10, 0);
   }

   for (int i = 0; i < m; ++i)
   {
      int x, y, silver, time;
      cin >> x >> y >> silver >> time;
      v[x].push_back({y, silver, time});
      v[y].push_back({x, silver, time});
   }

   convert.resize(n+1);
   for (int i = 1; i <= n; ++i)
   {
      int c, d;
      cin >> c >> d;
      convert[i] = {c, d};
   }

   s = min(s, M);
   dist[1][s] = 0;

   set<vector<int>> ms;//function of time
   ms.insert({0, s, 1}); // inserted time, silver coins, vertex

   vector<int> ans(n+1, inf);
   while(!ms.empty()){
      vector<int> f = *ms.begin();
      ms.erase(ms.begin());

      int time = f[0], vertex = f[2], silvers = f[1];

      if (vis[vertex][silvers]){
         continue;
      }

      tr(f);//2500*50
      vis[vertex][silvers] = 1;
      smin(ans[vertex], time);
      for (int i = silvers + convert[vertex][0], ch = time + convert[vertex][1]; i <= M; i += convert[vertex][0], ch += convert[vertex][1])
      {
         if (dist[vertex][i] > ch){
            dist[vertex][i] = ch;
            ms.insert({ch, i, vertex});
         }
      }

      for(auto it: v[vertex]){
         int nxt_vertex = it[0];
         int required_silver = it[1];
         int update_time = it[2];
         if (silvers >= required_silver){
            if (dist[nxt_vertex][silvers - required_silver] > dist[vertex][silvers] + update_time){
               dist[nxt_vertex][silvers - required_silver] = dist[vertex][silvers] + update_time;
               ms.insert({dist[vertex][silvers] + update_time, silvers - required_silver, nxt_vertex});
            }
         }
      }

   }

   for (int i = 2; i <= n; ++i)
   {
      cout<<ans[i]<<endl;
   }

   return 0;
}


Measured memory_bytes: 131244
import Foundation

let N = Int(readLine()!)!
let a = readLine()!.components(separatedBy: " ").map{ Int($0)! }
var count = 0


for i in 0...N - 1 {
    if (i + 1) % 2 != 0 && a[i] % 2 != 0 {
        count += 1
    }
}

print(count)

Measured memory_bytes: 14176
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

int n,x,p[2];
int main() {
	scanf("%d",&n);
	for (int i=0;i<n;i++) {
		scanf("%d",&x);
		p[x%2]++;
	}
	if (p[0]==0||p[1]==0) puts("0");
	else if (p[1]%2==0) printf("%d\n",n-2);
	else printf("%d\n",n-1);
}



Measured memory_bytes: 3212
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

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

int main() {
    int n;
    cin >> n;
    map<char, int> v;
    for (int i = 0; i < n; ++i) {
        map<char, int> v2;
        string s;
        cin >> s;
        for (auto &&a : s) {
            v2[a]++;
        }
        if(i == 0) v = v2;
        for (auto &&a : v) {
            a.second = min(v2[a.first], a.second);
        }
    }
    string k;
    for (auto &&a : v) {
        k += string(static_cast<unsigned int>(a.second), a.first);
    }
    sort(k.begin(), k.end());
    cout << k << "\n";
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>
const int maxn=3e5+100;
const int mod=1e9+7;
typedef long long ll;
using namespace std;

ll num[110];
ll a[maxn];
ll p[110];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%lld",&a[i]);
    p[0]=1;
    for(int i=1;i<=61;i++)
        p[i]=(p[i-1]*2)%mod;
    ll sum=0;
    for(int i=n-1;i>=0;i--){
        ll x=a[i],tot=n-i-1;
        for(int j=0;j<=60;j++){
            int now=x%2;
            if(now==1){
                sum=(sum+((tot-num[j])*p[j])%mod)%mod;
                num[j]++;
            }else{
                //cout<<num[j]<<endl;
                sum=(sum+(num[j]*p[j])%mod)%mod;
            }
            x=x>>1;
            //cout<<sum<<endl;
        }

    }
    printf("%lld\n",sum);
}
/*
17
AAAAABBBCCBBBBCCC
100 1 10
*/


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define itn int
#define gI gi

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

int n, m, a[100003];
char s[100003];

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gi(), m = gi();
	if (n == m) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <set>
#include <list>
#include <map>
#include <queue>
#include <iterator>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <utility>
#include <functional>
#include <stack>
#include <deque>
#include <sstream>
using namespace std;

#define ll long long
#define mod 1000000007
#define ld long double
#define infinity (ll)1e18+1
#define PI 3.14159265358979

#define pdd pair<ld,ld>
#define pll pair<ll, ll>
#define pii pair<int,int>

#define MP make_pair
#define SZ size()
#define PB push_back

#define vi vector<int>//ll
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define vch vector<char>
#define vb vector<bool>
#define vld vector<ld>

#define FOR(i,a,b) for(ll i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(ll i = (b) - 1; i >= (a); --i)
#define REPEAT(i) FOR(counter1234,0,i)
#define ALL(a) a.begin(), a.end()
#define X first
#define Y second
#define MAXN 100001
clock_t startTime;

ll power(ll n, ll to)
{
	if (to == 0) return 1;
	if (to == 1) return n;
	int exp = 1;
	ll ans = n;
	while (2 * exp <= to)
	{
		ans *= ans;
		exp *= 2;
	}
	return ((ans*power(n, to - exp)));
}

int main()
{
	srand(time(NULL));
	startTime = clock();
	ios_base::sync_with_stdio(false), cin.tie(0);
	//ifstream in("In.txt");

	int n; cin >> n;
	int p;
	cin >> p;
	vi a(n); FOR(i, 0, n)cin >> a[i];

	FOR(i, 0, n)
		a[i] %= 2;

	ll ans = 0;
	int odd = 0, even = 0;
	FOR(i, 0, n)
		if (a[i] == 0)
			even++;
		else
			odd++;

	if (p == 1 && odd == 0)
	{
		cout << 0;
		return 0;
	}

	ans = power(2, even);

	if (p == 0)
	{
		if (odd > 0)
			ans *= power(2, odd - 1);
	}
	else
	{
		if (odd > 0)
			ans *= power(2, odd - 1);
	}
	//cin >> n;
	cout << ans;
	//cin >> n;
	return 0;
}
//don't forget about MAXN, mod and infinity 

Measured memory_bytes: 256
n = int( input() )

A = [0]*(n+2)
B = [0]*(n+1)
t = list(map(int,input().split()))

S_Bn = 0
for i in range(1,n+2):
    A[i] = t[i-1] if i<n+1 else 0
    B[i-1] = abs( A[i] - A[i-1] )
    S_Bn += B[i-1]


#print(A)
#print(B)
#print(S_Bn)

for i in range(n):
    ans_i = S_Bn - ( B[i] + B[i+1] ) + abs( A[i+2] - A[i] )
    print(ans_i)

Measured memory_bytes: 15712
import java.util.Scanner;

public class Main {
    public void main(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int mod = a % b;

        int tmp = mod;
        while (tmp != 0) {
            if (tmp == c) {
                println("YES");
                return;
            }
            tmp = (tmp + mod) % b;
        }

        println("NO");
    }

    public void print(Object o) {
        System.out.print(o);
    }

    public void println(Object o) {
        System.out.println(o);
    }

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


Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<char> t(q), d(q);
    for (int i = 0; i < q; ++i) {
        cin >> t[i] >> d[i];
    }
    int ret = n;
    int ok = 0;
    int ng = n + 1;
    auto check = [&](int mid, bool left) {
        int pos = mid;
        int end = left ? 0 : n + 1;
        for (int i = 0; i < q; ++i) {
            if (s[pos - 1] == t[i]) {
                if (d[i] == 'L')
                    pos--;
                else
                    pos++;
            }
            if (pos == end)
                break;
        }
        return pos == end;
    };
    while (ok + 1 != ng) {
        int mid = (ok + ng) / 2;
        if (check(mid, true))
            ok = mid;
        else
            ng = mid;
    }
    ret -= ok;
    ok = n + 1;
    ng = 0;
    while (ng + 1 != ok) {
        int mid = (ok + ng) / 2;
        if (check(mid, false))
            ok = mid;
        else
            ng = mid;
    }
    ret -= (n - (ok - 1));
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep2(i,n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
template <class T>
using Grid = vector<vector<T>>;

int main(){
    string s;
    cin >> s;
    if (count(all(s), s[0]) == 2 && count(all(s), s[1]) == 2 &&
        count(all(s), s[2]) == 2 &&count(all(s), s[3]) == 2)
        cout << "Yes" << endl;
        else cout << "No" << endl;
}

Measured memory_bytes: 3552
# solution

import io

array = [1]

def tommy(numbers):
  t, x, y = map(int, numbers.split())
  time_x = t - x
  time_y = time_x - y
  if time_y%2 == 0 and time_y >=0:
    array.append(1)
  else:
    array.append(-1)

data = int(input())

counter = 0

while counter < data:
  tommy(input())
  counter += 1

if array.count(1) == data+1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3960
#include<bits/stdc++.h>
using namespace std;
#define fi              first
#define se              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define endl			"\n"
void fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int n, weight;
vector<int> w, v;
vector<vector<int> > dp;
int solve(int i, int weight_till_now)
{
	// Base case
	if (i == n + 1)
	{
		if (weight_till_now <= weight)
			return 0;
		else
			return INT_MIN;
	}
	if (weight_till_now > weight)
		return INT_MIN;

	if (dp[i][weight_till_now] != -1)
		return dp[i][weight_till_now];
	// recursive case
	int op1 = v[i] + solve(i + 1, weight_till_now + w[i]); // taking the item at index i.
	int op2 = 0 + solve(i + 1, weight_till_now);	// skipping the item at index i.
	return dp[i][weight_till_now] = max(op1, op2);
}
int32_t main()
{
	fast();
	cin >> n >> weight;
	w.resize(n + 1);
	v.resize(n + 1);
	for (int i = 1; i <= n; i++)	cin >> w[i] >> v[i];
	dp.resize(n + 1, vector<int> (500000 + 1, -1));
	cout << solve(1, 0);
	return 0;
}


Measured memory_bytes: 401792
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



// dp[i][j]: i番目まででj個のうれしさ
// dp[i][j] = Σ_l{dp[i-1][j-k] * (Σ_x(a[i]+x)^k)}
// 0<=i番目のはしゃぎ度x<=b[i]-a[i]
// ps[i][j] = Σ_i i^j

int n, c, a[404], b[404], dp[404][404], p[404][404], ps[404][404];

signed main() {
	cin >> n >> c;
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	p[0][0] = 1;
	reps(i,1,404) {
		p[i][0] = 1;
		reps(j,1,404) p[i][j] = p[i][j-1]*i %mod;
	}
	reps(i,1,404) rep(j,404) ps[i][j] = (p[i][j] + ps[i-1][j]) %mod;
	dp[0][0] = 1;
	reps(i,1,n+1) rep(j,c+1) rep(k,j+1)
		(dp[i][j] += dp[i-1][j-k] * (ps[b[i-1]][k] - ps[a[i-1]-1][k] + mod)) %= mod;
	cout << dp[n][c] << endl;
}

Measured memory_bytes: 4096