akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

char str[100005];

int main(int argc, char* argv[])
{
    int n,m;
    scanf("%d%d", &n, &m);
    scanf("%s", str);

    vector<int> prev(n+1);
    vector<int> dp(n+1,-1);
    set<int> ss;
    ss.insert(0);
    dp[0]=0;
    int i;
    for(i=1; i<n+1; i++) {
        if(ss.empty()) {
            printf("-1\n"); return 0;
        }
        {
            auto it=ss.begin();
            if(*it<i-m) {
                ss.erase(*it);
            }
        }
        if(ss.empty()) {
            printf("-1\n"); return 0;
        }
        if(str[i]=='0') {
            auto it=ss.begin();
            dp[i]=dp[*it]+1;
            prev[i]=*it;
            ss.insert(i);
        }
    }
    vector<int> ans;
    int curr=n;
    while(curr>0) {
        ans.push_back(curr);
        curr = prev[curr];
    }
    reverse(ans.begin(), ans.end());
    for(i=0; i<(int)ans.size(); i++) {
        if(i==0) printf("%d ", ans[0]);
        else     printf("%d ", ans[i]-ans[i-1]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 3840
NM = input().split()
N = int(NM[0])
M = int(NM[1])

A = []
kosuu = 0

tmp = input().split()
for i in range(N):
  A.append(int(tmp[i]))

tmp = sum(A)/(4*M)

for i in A:
  if i >= tmp:
    kosuu += 1

if kosuu >= M:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0

for A in range(0,a+1):
    for B in range(0,b+1):
        for C in range(0,c+1):
            total = 500*A + 100*B + 50*C
            if total == x:
                ans += 1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d,e;
	int ans=0;
	cin>>a>>b>>c>>d>>e;
	if(a<=0){
		ans=(a*-1)*c+d+b*e;
	}
	else{
		ans=(b-a)*e;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3112
import sys
import math
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")



N,M=MI()
A=LI()
if N-sum(A) < 0 :
  print(-1)
else:
  print(N-sum(A))

Measured memory_bytes: 10112
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair
#define PB push_back

ll cost[10][10];
ll n,m;


void wf(){
  rep(k,m){
    rep(i,m){
      rep(j,m)cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
    }
  }
}

main(){
  while(cin>>n,n){
    m=0;
    rep(i,10){
      rep(j,10){
        cost[i][j]=1<<20;
      }
      cost[i][i]=0;
    }

    rep(i,n){
      ll a,b,c;
      cin>>a>>b>>c;
      m=max(m,max(a,b));
      cost[a][b]=c;
      cost[b][a]=c;
    }
    ++m;
    wf();
    ll minan=2<<20,town;

    rep(i,m){
      ll sum=0;
      rep(j,m)sum+=cost[i][j];
      if(sum<minan){
        minan=sum;
        town=i;
      }
    }
    cout<<town<<" "<<minan<<endl;
  }
}

Measured memory_bytes: 0
#include <stdio.h>
#define N 100001

typedef struct{
  int par;
  int l_child;
  int r_sib;
}node;

node tree[N];

int depth(int);

int main(){
  int n,id,cnum,lef,child,i,j;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    tree[i].par = -1;
    tree[i].l_child = -1;
    tree[i].r_sib = -1;
  }
  
  for(i=0; i<n; i++){
    scanf("%d %d", &id, &cnum);
    for(j=0; j<cnum; j++){
      scanf("%d", &child);
      if(j == 0) tree[id].l_child = child;
      else tree[lef].r_sib = child;
      tree[child].par = id;
      lef = child;
    }
  }

  for(i=0; i<n; i++){
    printf("node %d: parent = %d, depth = %d, ", i, tree[i].par, depth(i));
    if(tree[i].par == -1) printf("root, [");
    else if(tree[i].l_child == -1) printf("leaf, [");
    else printf("internal node, [");
    lef = tree[i].l_child;
    for(j=0; ; j++){
      if(lef == -1) break;
      if(j != 0) printf(", ");
      printf("%d",lef);
      lef = tree[lef].r_sib;
    }

    printf("]\n");
  }
  
  return 0;
  
}

int depth(n){
  if(tree[n].par == -1) return 0;
  return depth(tree[n].par)+1;
}

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

int main() {
    int n;
    while(cin >> n, n) {
        vector<int> a(n);
        int sum = 0;
        for(int i = 0; i < n; ++i) {
            cin >> a[i];
            sum += a[i];
        }
        int ans = 0;
        for(int i = 0; i < n; ++i) {
            ans += a[i] * n <= sum;
        }
        cout << ans << endl;
    }
}



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

using namespace std;

const int N = 100010;

int a[3][N];
long long f[3][N];

int main() {
  int n;
  scanf("%d", &n);
  for (int j = 0; j < 3; ++j) {
    for (int i = 0; i < n; ++i) {
      scanf("%d", a[j] + i);
    }
    sort(a[j], a[j] + n);
  }
  for (int i = 0; i < n; ++i) {
    f[0][i] = 1;
  }
  for (int k = 1; k < 3; ++k) {
    long long s = 0;
    for (int i = 0, j = 0; i < n; ++i) {
      while (j < n && a[k - 1][j] < a[k][i]) {
        s += f[k - 1][j];
        ++j;
      }
      f[k][i] = s;
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += f[2][i];
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 3712
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{

    int x,a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j,sum=0 ;
   scanf("%d", &x);
   a=x%10  ;
   b=x%100;
      b=b/10;
   c=x%1000;
      c=c/100;
   d=x%10000;
      d=d/1000;
   e=x%100000;
      e=e/10000;
   f=x%1000000;
      f=f/100000;
   g=x%10000000;
      g=g/1000000;
   h=x%100000000;
      h=h/10000000;
   i=x%1000000000;
      i=i/100000000;
    j=x%10000000000;
      j=j/1000000000;
    sum=a+b+c+d+e+f+g+h+i+j ;
    if (x%sum==0)
   printf("Yes");
   else
    printf("No");



}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    char input[4];
    int len;
    char temp;
    int one;
    scanf("%s", input);
    len = strlen(input);
    temp = input[len - 1];
    one = temp - '0';
    if (one == 0 || one == 1 || one == 6 || one == 8)
    {
        printf("pon");
        return 0;
    }
    else if (one == 3)
    {
        printf("bon");
        return 0;
    }
    else
    {
        printf("hon");
        return 0;
    }
}

Measured memory_bytes: 1680
n,k = gets.split.map &:to_i
s = gets.chomp

a = []
b = "0"
s.size.times do |i|
  c = s[i]
  if c != b
    a[i] = a[i-1].to_i + 1
  else
    a[i] = a[i-1].to_i
  end
  b = c
end

max = a[-1]
temp = 0
(0..max).each do |i|
  l = a.bsearch_index{|x| x >= i}
  r = a.bsearch_index{|x|
    if i & 1 == 1
      x >= i + 2 * k + 1
    else
      x >= i + 2 * k
    end
  }
  if r
    r = r - 1
  else
    r = n-1
  end
  temp = [temp, r-l].max
end

puts temp + 1



Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define PF first
#define PS second
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 100000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main() {
  IN(ll,N);
  AIN(ll,A,N);
  AIN(ll,B,N);
  AIN(ll,C,N-1);
  ll sum = 0;
  REP(i,N){
    sum += B.at(i);
    if(i != N-1 && A.at(i+1) - A.at(i) == 1)
      sum += C.at(A.at(i)-1);
  }
  OUT(sum);
}



Measured memory_bytes: 256
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline LL ri() {LL x; scanf("%lld", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/

//mod int
struct mint{
  const static long long mod = 1e9 + 7;
  int x;
  mint():x(0){}       
  mint(long long x):x(((x%mod)+mod)%mod){};
  mint operator+=(const mint&a){if((x+=a.x)>=mod) x-=mod; return *this;}
  mint operator-=(const mint&a){if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint operator*=(const mint&a){x=((LL)x*a.x)%mod; return *this;}
  mint operator*(const mint&a){return mint(*this)*=a;}
  mint operator-(const mint&a){return mint(*this)-=a;}
  mint operator+(const mint&a){return mint(*this)+=a;}
  template<typename T>mint operator*(const T&a){return mint(*this)*=a;}
  template<typename T>mint operator-(const T&a){return mint(*this)-=a;}
  template<typename T>mint operator+(const T&a){return mint(*this)+=a;}
  template<typename T>friend mint operator*(T x,const mint&m){return mint(x)*=m;}
  template<typename T>friend mint operator-(T x,const mint&m){return mint(x)-=m;}
  template<typename T>friend mint operator+(T x,const mint&m){return mint(x)+=m;}
  bool operator==(const mint& a)const{ return x == a.x;}
  operator long long () const {return x;}
};
mint pw(mint a, long long b){mint res(1);while(b){if(b&1)res*=a;a*=a;b>>=1;}return res;}
mint inv(mint a){return pw(a, mint::mod - 2);}
//mod int

int a[100010], n;

mint fac[100010];

int main() {

  cin >> n;
  rep(i, n) cin >> a[i];
  fac[0] = 1;
  rep(i, n) fac[i + 1] = fac[i] * (i + 1);

  mint res = fac[n];
  mint s = 1;
  //cout << res << endl;

  for (int j = 0, i = 0; i < n; i ++) {
    if (a[i] < 2 * (i  - j) + 1) {
      //cout << i << ' ' << res  << endl;
      res -= fac[n - j - 1] * s * (n - i - 1);
      s *= i + 1 - j;
      j ++;
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>

using namespace std;

int main(){
    int w,h;
    vector<int> L[900];
    int dist[900];
    
    while(true){
        scanf("%d %d",&w,&h);
        
        if(w == 0) break;
        
        int V = w * h;
        
        for(int i = 0;i < V;++i)
            L[i].clear();
        
        for(int i = 0,x;i < 2*h - 1;++i){
            if(i & 1){
                for(int j = 0;j < w;++j){
                    scanf("%d",&x);
                    
                    if(!x){
                        L[(i / 2) * w + j].push_back((i / 2 + 1) * w + j);
                        L[(i / 2 + 1) * w + j].push_back((i / 2) * w + j);
                    }
                }
            }else{
                for(int j = 0;j < w - 1;++j){
                    scanf("%d",&x);
                    
                    if(!x){
                        L[(i / 2) * w + j].push_back((i / 2) * w + j + 1);
                        L[(i / 2) * w + j + 1].push_back((i / 2) * w + j);
                    }
                }
            }
        }
        
        queue<int> Q;
        
        memset(dist,-1,sizeof dist);
        
        Q.push(0);
        dist[0] = 0;
        
        while(!Q.empty()){
            int cur = Q.front();
            Q.pop();
            
            for(int i = L[cur].size() - 1,to;i >= 0;--i){
                to = L[cur][i];
                
                if(dist[to] == -1){
                    Q.push(to);
                    dist[to] = 1 + dist[cur];
                }
            }
        }
        
        printf("%d\n",dist[h * w - 1] + 1);
    }
    
    return 0;
}

Measured memory_bytes: 0
/*
  In the name of ALLAH
  Author : Raashid Anwar
*/
 
#include <bits/stdc++.h>
using namespace std;
 
#define int int64_t
const int M1 =  998244353;
const int M2 =  1000000007;



void solve() {
  int n;
  cin >> n;
  cout << (((n + 999) / 1000) * 1000) - n << "\n";
}
 
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<ll> x(n+1), y(m+1);
    mint X = 0, Y = 0;
    rep(i,n) cin >> x[i+1];
    rep(i,m) cin >> y[i+1];
    vector<ll> dx(n+1), dy(m+1);
    for(ll i = 1; i < n; i++){
        dx[i] = x[i+1] - x[i];
        X += dx[i] * i * (n-i);
    }
    for(ll i = 1; i < m; i++){
        dy[i] = y[i+1] - y[i];
        Y += dy[i] * i * (m - i);
    }
    mint ans = X * Y;
    cout << ans.x << endl;
	return 0;
}

Measured memory_bytes: 3456
import java.util.*;
public class Main{
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);
    
    int h = sc.nextInt();
    int a = sc.nextInt();
    
    int ans = 0;
    
    ans = h/a;
    
    if(h%a != 0){
      ans++;
    }
    
    System.out.println(ans);
  }
}

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

int main() {
	int k;
	scanf("%d", &k);
	
	if (k % 2 == 0 || k % 5 == 0)
		printf("-1\n");
	else {
		if (k % 7 == 0) k /= 7;
		k *= 9;

		long long p = 1;
		for (int i = 0; i < k; i++) {
			p *= 10;
			if (p % k == 1) {
				printf("%d\n", i + 1);
				break;
			}
			else {
				p %= k;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3808
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

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

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n; cin >> n;
	for (int i = 0; i <= n; i++)
	{
		if (i % 4 == 0 && (n - i) % 7 == 0)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	
	return 0;
}

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

vector<int> cnt(1001001);

void calc(int n) {
  for(ll i = 2; i*i <= n; i++) {
    if(n % i != 0) continue;
    while(n % i == 0) {
      n/= i;
    }
    cnt[i]++;
  }
  if(n != 1) cnt[n]++;
}

int main() {
  int n;
  cin >> n;
  rep(i,n) {
    int a;
    cin >> a;
    calc(a);
  }
  int mx = 0;
  rep(i,1001001) {
    mx = max(mx, cnt[i]);
  }
  if (mx >= n) cout << "not coprime" << endl;
  else if (mx <= 1) cout << "pairwise coprime" << endl;
  else cout << "setwise coprime" << endl;
  return 0;
}


Measured memory_bytes: 7064
/*  CF_CC_
            4U7H0R:_C4551DY */

#include <bits/stdc++.h>
#include <fstream>

using namespace std;

typedef long long ll;

#define IC ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(a,b,c) for(ll a=b;a<c;a++)
#define lb lower_bound
#define pii pair<int,int>
#define vec vector<int>
#define fir first
#define sec second
#define pb push_back
#define mp make_pair
#define len length()
#define rev reverse
#define con continue

const int mxi=1e5+666;
const ll mod=1e9;
const ll inf=1e18;

ll n,x,t;
string s;

int main(){
    IC
    cin >> s;
    rep(i,0,s.len)
        t+=s[i]-'0';
    if(t%9==0) cout << "Yes";
    else cout << "No";
}


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

int solve(int n, int* h)
{
  int dp[n];
  int a = 0;
  int b = abs(h[1]-h[0]);
  int c = b;
  for (int i = 2; i < n; i++)
  {
    c = min(b + abs(h[i]-h[i-1]), a + abs(h[i]-h[i-2]));
    a = b;
    b = c;
  }
  return c;
}

int main()
{
  int n;
  cin >> n;
  int h[n];
  for (int i=0; i<n; i++)
  {
    cin >> h[i];
  }
  int r = solve(n, h);
  cout << r << endl;
}


Measured memory_bytes: 3480
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

vector<int> a;
vector<int> b;

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    for (int i = 0; ; i++) {
        for (int j = 0; ; j++) {
            int val = 100 * A * i + 100 * B * j;
            if (val > F) { break; }
            else { a.push_back(val); }
        }
        if (100 * A * i > F) { break; }
    }

    for (int i = 0; ; i++) {
        for (int j = 0; ; j++) {
            int val = C * i + D * j;
            if (val > F) { break; }
            else { b.push_back(val); }
        }
        if (C*i > F) { break; }
    }

    int wSugar = 0;
    int wSugarWater = 0;
    double c = 0.0;

    for (auto aElem : a) {
        for (auto bElem : b) {
            int sat = E * aElem / 100;
            if (aElem + bElem <= F && bElem <= sat && aElem != 0) {
                double temp_c = 100 * bElem / double(aElem + bElem);
                if (temp_c >= c) {
                    c = temp_c;
                    wSugar = bElem;
                    wSugarWater = aElem + bElem;
                }
            }
        }
    }

    cout << wSugarWater << " " << wSugar << endl;

    cin >> A;

    return 0;
}

Measured memory_bytes: 1400
import sys; readline = sys.stdin.readline
from collections import deque

from collections import Counter
P = 998244353
N = int(readline())
D = list(map(int, readline().split()))

c = Counter(D)
c = sorted(c.items(), key=lambda x:x[0])

def mod_pow(a, b):
    ret = 1
    for i in range(b):
        ret = ret * a % P
    return ret

if D[0] != 0 or c[0][1] != 1:
    print(0)
else:
    ans = 1
    for i in range(1, len(c)):
        if c[i - 1][0] != c[i][0] - 1:
            print(0)
            exit(0)
        ans = ans * mod_pow(c[i-1][1], c[i][1]) % P
    print(ans)

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

using namespace std;

const int N = 50;
vector<int> edges[N];
int tin[N], tout[N], timer, lca[N][N], p[N], add[N];
int ql[N], qr[N];
int n, m;

void dfs(int v, int _p) {
    tin[v] = timer++;
    p[v] = _p;
    for (int u : edges[v]) {
        if (u == _p) continue;
        dfs(u, v);
    }
    tout[v] = timer++;
}

bool ancestor(int v, int u) {
    return tin[v] <= tin[u] && tout[u] <= tout[v];
}

int calcLCA(int v, int u) {
    if (ancestor(v, u)) return v;
    if (ancestor(u, v)) return u;
    while (!ancestor(p[v], u)) v = p[v];
    return p[v];
}

void prec() {
    dfs(0, 0);
    for (int v = 0; v < n; v++) {
        for (int u = 0; u < n; u++) {
            lca[v][u] = calcLCA(v, u);
        }
    }
}

int getcnt;

void dfsForC(int v, int p) {
    for (int u : edges[v]) {
        if (u == p) continue;
        dfsForC(u, v);
        add[v] += add[u];
        if (add[u] > 0) getcnt--;
    }
}

int calcMask(int mask) {
    memset(add, 0, sizeof add);
    for (int i = 0; i < m; i++) {
        if (!(mask & (1 << i))) continue;
        int v = ql[i], u = qr[i], w = lca[v][u];
        add[v]++, add[u]++, add[w] -= 2;
    }
    getcnt = n - 1;
    dfsForC(0, 0);
    return getcnt;
}

int getSign(int mask) {
    int cnt = __builtin_popcount(mask);
    if (cnt % 2 == 0) return 1;
    else return -1;
}

void solve() {
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int v, u; cin >> v >> u; v--, u--;
        edges[v].push_back(u); edges[u].push_back(v);
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
        cin >> ql[i] >> qr[i]; ql[i]--, qr[i]--;
    }
    prec();
    long long ans = 0;
    for (int mask = 0; mask < (1 << m); mask++) {
        int sign = getSign(mask);
        ans += 1LL * sign * (1LL << calcMask(mask));
    }
    cout << ans;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int n,k;
    cin >> n >> k;
    vector<int> v(n);
    for (int i=0;i<n;i++) cin >> v[i];
    vector<int> a;
    for (int i=0; i < n; i++){
        int S = 0;
        for (int j=i; j < n; j++){
            S += v[j];
            a.push_back(S);
        }
    }
    sort(a.begin(), a.end(), greater<int>());
    //for (int i=0;i<k;i++)  cout << a[i] << endl;
    int ans = 0;
    for (int j=50; j >= 0; j--){
        int cand = ans + (1LL<<j);
        int S=0;
        for (int i=0;i<a.size(); i++){
            int ba = (cand & a[i]);
            if (ba == cand) S++;
        }
        if (S >= k) ans = cand;
    }
    cout << ans;


}


Measured memory_bytes: 5876
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>

using namespace std;

int main(void)
{
    int x;
    cin >>x;

    vector<bool> can(100010, false);

    vector<int> goods;
    goods.push_back(100);
    goods.push_back(101);
    goods.push_back(102);
    goods.push_back(103);
    goods.push_back(104);
    goods.push_back(105);

    can[0] = true;
    for(int i = 1; i <= x; i++){
        for(int j = 0; j < goods.size(); j++){
            if(i - goods[j] < 0){
                continue;
            }
            if(can[i - goods[j]]){
                can[i] = true;
            }
        }
    }
    if(can[x]){
        printf("1\n");
    }else{
        printf("0\n");
    }

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math
from collections import Counter
import collections
INF = float("inf")


def factorial(n):
    # 試し割りによる素因数分解
    prime_count = collections.Counter()

    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[int(n)] += 1

    return prime_count


def GCD(a, b):
    if a == 0:
        return b
    else:
        return GCD(b % a, a)


def GCDs(*a):
    # リストで入力しないよう注意。
    if len(a) == 0:
        return -1  # エラー

    if len(a) == 1:
        return a[0]

    res = a[0]
    for i in range(1, len(a)):
        res = GCD(res, a[i])
    return res


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def solve(N: int, A: "List[int]"):

    asc = [0]
    for i in range(N):
        asc.append(GCD(asc[-1], A[i]))
    desc = [0]
    for i in range(N):
        desc.append(GCD(desc[-1], A[N-i-1]))

    buf = []
    for i in range(N):
        buf.append(GCD(asc[i], desc[N-i-1]))
    print(max(buf))

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 17968
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <cmath>

using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

const ll mod = 1000000007;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

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


    vector<ll> p;
    vector<ll > a(n);

    p.push_back(2);
    for (ll i = 3; i <= 2000; i += 2) {
        bool is_ok = true;
        ll max_i = sqrt(i) + 10;
         for(ll cur : p) {
            if (cur >= max_i) {
                break;
            }
            if (i % cur == 0) {
                is_ok = false;
                break;
            }
         }
         if (is_ok) {
            p.push_back(i);
         }
    }

    map<ll,ll> lcm;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ll val = a[i];

        for(int j = 0; p[j] <= 1010; j++) {
            ll cur = p[j];
            ll count = 0;
            while ((val % cur) == 0) {
                val /= cur;
                count++;
            }
            if (count > 0) {
                lcm[cur] = max(count, lcm[cur]);
                if (val == 1) {
                    break;
                }
            }
        }
        if (val > 1) {
            lcm[val] = 1;
        }
    }



    ll lcm_val = 1;
    for(auto itr : lcm) {
        ll k = itr.first;
        ll v = itr.second;
        for (int i = 0; i < v; i++) {
            lcm_val = (lcm_val * k) % mod;
        }

    }
    ll ans = 0;

    for (int i = 0; i < n; i++) {
        ll cur_ans = (lcm_val *  modinv(a[i], mod)) % mod;
        ans = (ans + cur_ans) % mod;
    }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
int main(){
  int a;
  cin >> a;
  int res = 0;
  rep(i,1,a+1){
   int buf = i;
   int count = 0;
   while(buf != 0){
    buf /= 10;
    count++;
   }
   if(count%2 == 1)res++;
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 384
A, B, C, D, E, F = map(int, input().split())

# x = 100A, 100B  , y = C, Dが与えられたとき
# x + y <= F を満たす(x, y)の組み合わせを求める。
# X = []
# Y = []
# print(F // 100)
# for x in range(1, (F // 100) + 1):
#     for y in range(1, F - x + 1):
#         if (100*x % A == 0) or (100*x % B == 0) and (y % C == 0 or y % D == 0) and (y/(100+y)) <= (E/(100+E)):
#             X.append(100*x)
#             Y.append(y)
# (100y/(100+y) <= (100E/(100+E))が成り立つときtrue
# for i in range(len(X)):
#     print(X[i] + Y[i], Y[i])
X = []
Y = []
Den = []
for i in range(31):
    for j in range(31):
        x = 100*A*i + 100*B*j
        for l in range(101):
            for m in range(101):
                y = C*l + D*m
                if 0 < x + y <= F and (y/(x+y)) <= (E/(100+E)):
                    X.append(x)
                    Y.append(y)
                    density = y/(x+y)
                    Den.append(density)
max_d = 0
max_i = 0
for i in range(len(Den)):
    if Den[i] > max_d:
        max_d = Den[i]
        max_i = i

print(X[max_i]+Y[max_i], Y[max_i])


Measured memory_bytes: 14276
import 'dart:io';

main(List<String> args) {
  var K = int.parse(stdin.readLineSync());
  var ans = 0;
  for (var i = 1; i <= K; i++) {
    for (var j = 1; j <= K; j++) {
      for (var k = 1; k <= K; k++) {
        var tmp = i.gcd(j);
        ans += tmp.gcd(k);
      }
    }
  }
  print(ans);
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main() {
  INIT;
  VAR(int,a,b);
  OUT((a+b>=10?"error":to_string(a+b)))BR;
  
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;



typedef pair < long long, long long > pll;
typedef unsigned long long ull;
typedef pair < int, int > pii;
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;
typedef long long ll;
typedef double db;
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 4e5 + 111;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 466;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;



int n, v, u, a[N], cnt[N], res[N], par[N];
stack < int > st[N];
vi g[N], gg[N];

int get (int x) {
	return x * (x + 1) / 2;
}

void dfs1 (int v, int p = 0) {
	cnt[v] = 1;
	par[v] = p;
	for (auto to : g[v])
		if (to != p) {
			dfs1(to, v);
			cnt[v] += cnt[to];
		}
}
	

void dfs (int v, int p = 0) {
	st[a[p]].push(v);
	if (!sz(st[a[v]]))
		gg[a[v] + n].pb(v);
	else {
		int u = st[a[v]].top();
		gg[u].pb(v);
	}

	for (auto to : g[v])
		if (to != p)
			dfs(to, v);
		

	st[a[p]].pop();
}

main () {
	scanf("%lld", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%lld", &a[i]); 
		res[i] = get(n);
	}
	
	for (int i = 1; i < n; ++i) {
		scanf("%lld%lld", &v, &u);
		g[v].pb(u);
		g[u].pb(v);
	}

	dfs1(1);
	dfs(1);	
	
	for (int i = 1; i <= n + n; ++i)
		if (i <= n) {
			int c = cnt[i];
			for (auto j : gg[i])
				c -= cnt[j];
			res[a[par[i]]] -= get(c);
//			cerr << par[i] << ' ' << c << endl;
		} else {
			int c = n;
			for (auto j : gg[i])
				c -= cnt[j];
			res[i - n] -= get(c);
//			cerr << i - n << ' ' << c << endl;
		}

	for (int i = 1; i <= n; ++i)
		printf("%lld\n", res[i]);
}



Measured memory_bytes: 324308
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;

const ll MOD = 1000000007;
ll modPow(ll a, ll n){
  if (n == 0) return 1;
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n-1)) % MOD;
  ll t = modPow(a, n/2);
  return (t * t) % MOD;
}

int main(){
  ll n;
  cin >> n;
  ll ans = (modPow(10, n) - modPow(9, n) * 2 + modPow(8, n) + MOD*10) % MOD;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;


int32_t main(){
	ios::sync_with_stdio(false);
    int n, ma, mb;
    cin>>n>>ma>> mb;
    vi a(n),b(n),c(n);
    REP(i,0,n){
        cin>>a[i]>>b[i]>>c[i];
    }
    // deb(a);
    // deb(b);
    // deb(c);
    map<pair<int, int> , int>M;
    map<pair<int, int> , int>M1;
    for(int i=0;i<n;i++){
        M1.clear();
        if(M.count({a[i],b[i]})==0)
        M1[{a[i],b[i]}]=c[i];
        else{
           M1[{a[i],b[i]}]=min(c[i],M[{a[i],b[i]}]);
        }
        for(auto g:M){
            int A=g.F.F;
            int B=g.F.S;
            int C=g.S;
            if(M.count({A+a[i],B+b[i]})==0){
                M1[{A+a[i],B+b[i]}]=C+c[i];
            }
            else{
                int cost=M[{A+a[i],B+b[i]}];
                if(cost>C+c[i]){
                    M1[{A+a[i],B+b[i]}]=C+c[i];
                }
            }
        }
        // deb(i);
        // deb(M1);

        for(auto g:M1){
            M[{g.F.F,g.F.S}]=g.S;
        }
        // deb(M);
    }
    int f=0;
    int ans=1e18;
    for(auto g:M){
        int A=g.F.F;
        int B=g.F.S;
        int C=g.S;
        int temp=__gcd(A,B);
        A=A/temp;
        B=B/temp;
        if(ma==A && mb==B){
            f=1;
            ans=min(ans,C);
        }
    }
    // for(auto g: M){
    //     int temp=__gcd(g.F.F,g.F.S);
    //     if((g.F.F/temp)==ma && (g.F.S/temp)==mb){
    //         deb(g);
    //     }
    // }
    if(f==0){
        cout<<-1<<"\n";
    }
    else{
        cout<<ans<<"\n";
    }


    return 0;
}

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

r = n // 100
l = n % 100

if r <= 12 and 1 <= r:
  if l <= 12 and 1 <= l:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if l <= 12 and 1 <= l:
    print("YYMM")
  else:
    print("NA")

Measured memory_bytes: 9020
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool>    vecbool;
typedef vector<int>     vecint;
typedef vector<ll>      vecll;
typedef vector<string>  vecstr;
typedef vector<vecint>  vec2int;
typedef vector<vecbool> vec2bool;
int dx[4] {-1,+1, 0, 0};
int dy[4] { 0, 0,-1,+1};
void init(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int main()
{
  init();
  int n, x; cin >> n >> x;
  vecint w(n,0), v(n,0); REP(i,n) cin >> w[i] >> v[i];
  int vmax = 0;
  REP(i,n) vmax = max(vmax, v[i]);
  int vsize = vmax*n;
  vector<vecint > dp(n + 1,vecint(vsize + 1, 1e9));
  REP(i,n + 1){
    dp[i][0] = 0;
  }
  // REP(j,vsize + 1){
  //   dp[0][j] = 0;
  // }
  REP(i,n){
    REP(j,vsize + 1){
      if(j - v[i] >= 0){
        dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
      }else{
        dp[i + 1][j] = dp[i][j];
      }
    }
  }
  // REP(j, vsize + 1){
  //     cout << dp[1][j] <<" " << j << endl;
  // }
  // REP(j, vsize + 1){
  //     cout << j << " " << dp[2][j] << endl;
  // }
  int ans = 0;
  for(int i = vsize; i >= 0; i --){
    if(dp[n][i] <= x){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;
typedef vector<unordered_map<lli,lli>> graph;

const lli mod = 1000000007;
lli n;
mat dp;

int main(){
  cin >> n;
  dp = mat(65,vll(3,0));
  dp[63][0] = 1;
  for(lli i = 62;i >= 0;i--){
    if((n & (1ll << i ))== 0){
      dp[i][0] += dp[i+1][0]+dp[i+1][1];//(0,0),(1,1)
      dp[i][1] += dp[i+1][1];//(1,0)
      dp[i][2] += dp[i+1][1];//(0,0)
      dp[i][2] += dp[i+1][2]*3;//(0,0),(1,0),(1,1)
    }else{
      dp[i][0] += dp[i+1][0];//(1,0)
      dp[i][1] += dp[i+1][1]+dp[i+1][0];//(1,1),(0,0)
      dp[i][2] += dp[i+1][1]+dp[i+1][1];//(0,0),(1,0)
      dp[i][2] += dp[i+1][2]*3;//(0,0),(1,0),(1,1)
    }
    dp[i][0] %= mod;
    dp[i][1] %= mod;
    dp[i][2] %= mod;
  }
  cout << (dp[0][0]+dp[0][1]+dp[0][2])%mod << endl;
}


Measured memory_bytes: 256
a,b,c = map(int, input().split())
def calc(x,y,z):
    print(((x -x//2) - x//2) * y * z)

if a%2==0:
    calc(a,b,c)
elif b%2==0:
    calc(b,a,c)
elif c%2==0:
    calc(c,a,b)
else:
    l = sorted([a,b,c])[::-1]
    calc(l[0], l[1], l[2])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main(){
    Hello
    char b, c;
    cin >> b;
    if(b == 'A') c = 'T';
    else if(b == 'T') c = 'A';
    else if(b == 'G') c = 'C';
    else c = 'G';
    cout << c;
    return 0;
}


Measured memory_bytes: 3564
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String str = br.readLine();
			
			if(str.equals(".")){
				break;
			}
			
			char[] input = str.toCharArray();
			
//			System.out.println(str);
			if(balanced(input)){
				System.out.println("yes");
			}
			else {
				System.out.println("no");
			}
		}
	}
	
	static boolean balanced(char[] input){
		Stack<Character> stack = new Stack<Character>();
		
		for(int i = 0; i < input.length ; i++){
			char c = input[i];
			
			if(c == '(' || c == '['){
				stack.push(c);
			}
			
			else if(c == ')'){
				if(stack.isEmpty() || stack.peek() != '('){
					return false;
				}
				stack.pop();
			}
			
			else if(c == ']'){
				if(stack.isEmpty() || stack.peek() != '['){
					return false;
				}
				stack.pop();
			}
		}
		
		if(stack.isEmpty()){
			return true;
		}
		else {
			return false;
		}
	}

}

Measured memory_bytes: 31540
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use proconio::marker::{Bytes, Chars};
use std::collections::*;

fn main() {
    input! {
        n:usize,
        mut a:[i64;n],
    }
    a.sort_by_key(|&x| std::cmp::Reverse(x));
    let mut ans: i64 = a.iter().map(|x| x * 2).take((n + 1) / 2).sum();
    ans -= a[0];
    if n % 2 != 0 {
        ans -= a[(n - 1) / 2];
    }
    println!("{}", ans);
}

Measured memory_bytes: 6224
// #include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define int long long

// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define all(v) v.begin(), v.end()
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
// union of two containers
template <typename T>
void container_union(T &c1, T &c2, T &c3) {
  std::vector<int> vec;
  std::set_union(c1.begin(), c1.end(),
                 c2.begin(), c2.end(),
                 std::back_inserter(vec));
  T tmp(vec.begin(), vec.end());
  c3 = tmp;
}

// chmax, chmin
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

// grid-search
std::vector<int> dx = {1, -1, 0,  0};
std::vector<int> dy = {0,  0, 1, -1};
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// type alias
using VI = std::vector<int>;
using VII = std::vector<VI>;
using VB = std::vector<bool>;
using VBB = std::vector<VB>;
using VS = std::vector<std::string>;
using PII = std::pair<int, int>;

// yes/no
std::string yes = "Yes";
std::string no = "No";
std::string YES = "YES";
std::string NO = "NO";

void solve();

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

void solve() {
  std::string s;
  std::cin >> s;
  REP(i, SIZE(s)) {
    std::cout << 'x';
  }
  std::cout << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

string N;
  cin>>N;
  int sum1=0;
  int sum2=0;
  for(int i=0;i<N.size();i++){
if(N.at(0)==N.at(i)){
  sum1++;
}
    else if(N.at(1)==N.at(i)){
      sum2++;
    }
  }
  
  
    if(sum1==3&&N.at(0)!=N.at(3)){
      cout<<"Yes"<<endl;
    }
    else if(sum1==4||sum2==4){
      cout<<"Yes"<<endl;
    }
    else if(sum2==3&&N.at(3)!=N.at(0)){
      cout<<"Yes "<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }


  
    



Measured memory_bytes: 256