akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int sum = 0;
  for(int i = 0 ;i < 2;i++){
    if(a > b){
      sum += a;
      a--;
    }
    else{
      sum += b;
      b--;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


s = S()
flag = False
for i in s[::2]:
    if i not in ['R', 'U', 'D']:
        flag = True
for j in s[1::2]:
    if j not in ['L', 'U', 'D']:
        flag = True
if flag:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 39664
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (auto& x : A) cin >> x;
	long long r = 1;
	int hoge[3] = {0,0,0};
	for (int i = 0; i < N && r; ++ i) {
		int x = 0;
		for (int j = 0; j < 3; ++ j) {
			if (hoge[j] == A[i]) {
				if (x == 0) ++ hoge[j];
				++ x;
			}
		}
		r *= x;
		r %= mod;
	}
	cout << r << endl;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    ll x; cin >> x;
    ll a = x / 500;
    x -= a * 500;
    ll b = x / 5;
    cout << a * 1000 + b * 5 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  string a, b, c;
  cin >> n >> a >> b >> c;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == b[i] && b[i] != c[i] || a[i] != b[i] && b[i] == c[i] ||
        a[i] == c[i] && b[i] != c[i])
      ans++;
    else if (a[i] != b[i] && b[i] != c[i] && a[i] != c[i])
      ans += 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol gcd(lol x,lol y){//最大公約数
    if(y>x) swap(x,y);
    lol r=x%y;
    while(r!=0){
	x=y;
	y=r;
	r=x%y;
    }
    return y;
}
lol a,b;
bool i[300000];
lol ans[300000];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol c=1,d=1,e=0,f=0,g=0,h=0;
  cin >>a>>b;
  for(int n=0;n<b;n++){
      cin>>c;
      i[c]=true;
  }
  ans[0]=1;
  for(int n=0;n<a-1;n++){
      if(!i[n+1]) ans[n+1]=(ans[n+1]+ans[n])%inf;
      if(!i[n+2]) ans[n+2]=(ans[n+2]+ans[n])%inf;
  }
  cout <<(ans[a-1]+ans[a])%inf<<'\n';
  return (0);
}


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

int main(){
  int a,b,c;
  double d;
  cin >> a >> b;
  c = (a + b) / 2;
  d = (a + b) / 2.0;
  if (c == d){
    cout << c << endl;
  }
  else {
    cout << c + 1 << endl;
  }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  char str[4];
  int count=0;
  for(int i=0;i<3;i++){
    cin>>str[i];
    if(str[i]=='R')count++;
  }
  if(str[0]==str[1]==str[2]=='R')count=3;
  if((str[0]=='R')&&(str[1]=='S')&&(str[2]=='R'))count=1;
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 3596
a, b, c, k = map(int, input().split())

for i in range(3):
    if i == 0:
        if k <= a:
            print(k)
            break
        else:
            k -= a

    elif i == 1:
        if k <= b:
            print(a)
            break
        else:
            k -= b

    elif i == 2:
        if k <= c:
            print(a+(-1*k))
        else:
            print(a+c)


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

int main()
{
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  bool flag = 0;
  rep(i, n - 1){
    if (a[i] == a[i + 1]){
      flag = 1;
      break ;
    }
  }
  if (flag) cout << "NO" << endl;
  else cout << "YES" << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007

    using namespace std;
     //int g[105][105];
    //vector < int > wt(100004);
   // vector < int > a;
    //vector < int > v(30500);
    //int cst[102][100005];
    //int ansr[100005];
 //ll int sum,x=0,c=0,n,m,flag=0,a1,a2,flag1=0,flag2=0;
    //vector < vector < int > > adj(5000, vector < int > (5000));
 //int  dp[1000006];
   // int level[500];

    void solve()
    {
         ll int i,j=0,r=200,p,q,y=0,ans=0,d,h,flag=0,n,m;
         cin>>n>>m; ll int sum=0;
         if(n+m<=0)
         {
             rep(i,0,n-1) sum+=(m+i);
             cout<<sum;
             return;
         }
         if(m<=0 and n+m>0)
         {
             rep(i,0,n) sum+=(m+i);
             cout<<sum;
             return;
         }
         else if(m>0)
         {
             rep(i,1,n) sum+=(m+i);
             cout<<sum;
         }



    }



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

       /*

  void bfs( int i , int j)
       {
           vis[i][j]= true;
         queue < int > que;
         que.push(k);
         while(!que.empty())
         {
            int x= que.front();
            que.pop();
             for ( int i=1;i<=n;i++)
             {
                 if((!g[1][n] and g[x][i] ) or (g[1][n] and ! g[x][i]))
                 {
                   if(!vis[i])
                   {
                       que.push(i);
                       level[i]=level[x]+1;
                       vis[i]= true;
                   }
                 }
             }
         }
       }

      ll int por(ll int a,ll int b)
         {
            ll int k=1;
            while(b>0)
            {
                if(b%2) k=k*a,k%=hell;
                b/=2;
                a*=a; a%=hell;
            }
            return k;
         } */


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
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;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

vector<int> dp(100000, -1); // dp[i] = iが始点の最長路の長さ

int dfs(int pos, vector<vector<int>> &G) {
    if(dp[pos] != -1) return dp[pos];
    if(G[pos].size() == 0) {
        dp[pos] = 0;
        return 0;
    }
    int len = 0;
    for(auto v : G[pos]) {
        chmax(len, dfs(v, G) + 1);
    }
    return dp[pos] = len;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<vector<int>> G(n, vector<int>());
    int from, to;
    rep(i, m) {
        cin >> from >> to;
        from--; to--;
        G[from].push_back(to);
    }
    int ans = 0;
    rep(i, n) chmax(ans, dfs(i, G));
    cout << ans << endl;
}

Measured memory_bytes: 11020
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000009;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
map<pair<long long,long long>,long long >M;
long long f(long long A,long long B){
	if(A>B)return 0;
	long long cur=(B|A);
	long long N=B-A+1;
	for(int i=0;i<60;i++){
		if(N>(1LL<<i))cur|=(1LL<<i);
	}
	return cur;
}
bool chk(long long A,long long B,long long C){
	long long now=0;
	for(int i=0;i<60;i++){
		if(C&(1LL<<i)){
			long long tmp=C-(1LL<<i);
			if(A<=tmp&&tmp<=B){
				return true;
			}else{
				;
			}
		}
	}
//	long long need=0;
//	for(int i=0;i<60;i++)if((C-now)&(1LL<<i))need+=1LL<<i;
//	printf("%lld %lld %lld: %lld %lld\n",A,B,C,now,need);
//	if(need==0||(A<=need&&need<=B))return true;
//	else return false;
	return false;
}
long long calc(long long A,long long B){
	if(M.count(make_pair(A,B)))return M[make_pair(A,B)];
	long long ret=0;
	if(A==B)ret=1;
	else{
		ret=calc((A+1)/2,B/2);
		int ks=1;
		if(B%2==0){
			/*
			long long left=A-1;
			long long right=B;
			while(left+1<right){
				long long mid=(left+right)/2;
				long long cur=f(mid,B-1);
				if((cur|B)!=cur)right=mid;
				else left=mid;
			}
			if(right/2<=(B-1)/2)ret+=calc(right/2,(B-1)/2);
			*/

			if(!chk(A/2,B/2-1,B/2))ret--;
		}
		ret+=calc(A/2,B/2);

	}
	//printf("%lld %lld: %lld\n",A,B,ret);
	return M[make_pair(A,B)]=ret;
}
int main(){
	long long A,B;
	scanf("%lld%lld",&A,&B);
	printf("%lld\n",calc(A,B));
}

Measured memory_bytes: 384
from itertools import product


def solve(string):
    s = [0] * 7
    for i, _s in enumerate(string):
        s[2 * i] = _s
    for op in product("+-", repeat=3):
        for i, o in enumerate(op):
            s[2 * i + 1] = o
        if eval("".join(s)) == 7:
            return "".join(s) + "=7"


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 3064
#include <stdio.h>

void selectionSort(int A[], int N) {
    int i, j;
    int tmp, minj;
    int c = 0;
    for (i = 0; i < N; i++) {
        minj = i;
        for (j = i; j < N; j++) {
            if (A[j] < A[minj]) {
                minj = j;
            }
        }

        if (i != minj) {
            tmp = A[i];
            A[i] = A[minj];
            A[minj] = tmp;
            c++;
        }
    }
    for (i = 0; i < N; i++) {
        printf("%d", A[i]);
        printf((i == N-1) ? "\n%d\n" : " ", c);
    }
}

int main()
{
    int i;
    int N, A[101];

    scanf("%d", &N);

    for (i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }

    selectionSort(A, N);

    return 0;
}

Measured memory_bytes: 1852
#include<bits/stdc++.h>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define ull unsigned long long int  // ranges from (0 - twice of long long int)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define mod 1000000007LL
#define llpair pair<ll,ll>
#define INF 1000000000000000000ll
#define np next_permutation
//ALWAYS USE ll DATA TYPE FOR INTEGER(FASTER THAN INTEGER AS WELL AS SOMETIMES WITHOUT USE LONG UR ANSWER WILL NOT ACCEPTED) && DOUBLE FOR DECIMAL VALUE
template<typename T> // for removing front element from the vector
void pop_front(std::vector<T> &v)
{
    if (v.size() > 0) {
        v.erase(v.begin());
    }
}
template<typename R> // for removing back element from the vector or can directly
void pop_back(std::vector<R> &v) // use vec.pop_back() function...
{
    if (v.size() > 0) {
        v.erase(v.begin()+v.size()-1);
    }
}

bool isprime(ll n)  //IN  O(sqrt(n))
{
    if(n<=1) return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;

    return true;
}

vector<ll> factors(ll n){    //IN  O(sqrt(n))

    vll v;
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
        {
            v.pb(i);
            if((n/i)!=i)
            v.pb(n/i);
        }
    }
    return v;
}

ll power(ll a, ll n)  // using Binary Exponential in TC O(logn)
{                     // Self Written By </ME> :)
    ll res=1;
    while(1)
    {
        if(n%2){
            res=res*a; n--;
        }
        if(n==0) break;
        a=a*a; n/=2;
    }
    return res;
}


int main() {

    fio;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll a,b,c; 
        cin>>a>>b>>c;
        if(((a==b) && (a!=c)) || ((b==c && b!=a)) || ((a==c && (a!=b))))
        cout<<"Yes"<<"\n";
        else
        cout<<"No"<<"\n";
    }
      
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int n, k, a[100001], dp[100001];
int main() {
	cin >> n >> k;
	rep(i, n)  cin >> a[i];
	fill(dp, dp + n, 2000000001);
	dp[0] = 0;
	rep(i, n) {
		rep(j, k + 1) {
			dp[i + j] = min(dp[i + j], dp[i] + abs(a[i + j] - a[i]));
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int L;
    cin >> L;
    vector<ll> A(L + 1, 0);
    for (int i = 1; i <= L; i++)
        cin >> A[i];
    vector<vector<ll>> dp(L + 1, vector<ll>(5, 1e15));
    dp[0][0] = 0;
    for (int i = 1; i <= L; i++)
    {
        dp[i][0] = dp[i - 1][0] + A[i];

        ll cost = 0;
        if (A[i] == 0)
            cost = 2;
        else if (A[i] % 2)
            cost = 1;
        dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + cost;
        dp[i][3] = min(dp[i - 1][0], min(dp[i - 1][1], min(dp[i - 1][2], dp[i - 1][3]))) + cost;

        cost =  1 - A[i] % 2;
        dp[i][2] = min(dp[i - 1][0], min(dp[i - 1][1], dp[i - 1][2])) + cost;

        dp[i][4] = min(dp[i - 1][0], min(dp[i - 1][1], min(dp[i - 1][2], min(dp[i - 1][3], dp[i - 1][4])))) + A[i];
    }
    ll res = dp[L][0];
    for (int i = 1; i < 5; i++)
        res = min(res, dp[L][i]);
    cout << res << endl;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

int V, H;
ll x[100100], y[100100], row, tot;

int main () {
        scanf("%d %d", &V, &H);
        fo(i, 0, V) scanf("%lld", &x[i]);
        fo(i, 0, H) scanf("%lld", &y[i]);
        sort(x, x+V), sort(y, y+H);

        fo(i, 1, V) {
                ll a = (x[i] - x[i-1]) * i % MOD;
                a = a * (V-i) % MOD;
                row = (row + a) % MOD;
        }

        fo(i, 1, H) {
                ll a = row * (y[i] - y[i-1]) % MOD;
                a = a * i % MOD;
                a = a * (H-i) % MOD;
                tot = (tot + a) % MOD;
        }

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

        return 0;
}



Measured memory_bytes: 1792
using System;
namespace a{
  public class buri{
    public static void Main(){
      int n = int.Parse(Console.ReadLine()),
      k = int.Parse(Console.ReadLine()),
      x = int.Parse(Console.ReadLine()),
      y = int.Parse(Console.ReadLine());
      if (k <= n)
      {
        Console.WriteLine(k * x + (n - k) * y);          
      }
      else
      {
          Console.WriteLine(n * x);
      }
    }
  }
}

Measured memory_bytes: 13140
using System;

namespace AtCoder169
{
    public class ProgramA
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var inputList = input.Split(" ");
            int.TryParse(inputList[0], out var a);
            int.TryParse(inputList[1], out var b);
            Console.WriteLine(a * b);
        }
    }
}


Measured memory_bytes: 27532
#include<bits/stdc++.h>
using namespace std;
int main(){
   string S,T;
   cin >> S >> T;

   int count=0;
   for(int i=0;i<S.length();i++){
      char s=S.at(i);
      char t=T.at(i);

      if(s==t)
         count++;
   }
   cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define CLR(a) memset(a, 0, sizeof(a))
#define DBG(x) cout<<(#x)<<"="<<x<<endl
#define FOR(i, a, b)  for(int i=(a); i<(b); i++)
#define REP(i, a, b)  for(int i=(a); i<=(b); i++)
#define DOWN(i, a, b) for(int i=(a); i>=(b); i--)

using namespace std;

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

const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1000000009;
const int N= 1e3 +10;

int n;
int ans=INF;

int digit(int n) {
	int ret=0;
	while(n) {
		ret+=n%10;
		n/=10;
	}
	return ret;
}

int main() {
	cin>>n;
	REP(i, 1, n-1) {
		ans=min(ans, digit(i)+digit(n-i));
	}
	cout<<ans<<endl;
	//cout<<1.*clock()/CLOCKS_PER_SEC<<"ms"<<"\n";
	return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    cnt = 0
    while True:
        for i in range(N):
            if A[i] % 2:
                print(cnt)
                exit()
            A[i] /= 2
        cnt += 1


if __name__ == '__main__':
    main()

Measured memory_bytes: 38512
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n=II()
	G=[]
	for _ in range(n):
		s=input().rstrip().decode()
		G.append(list(s*2))

	ans=0
	for x in range(n):
		f=1
		for i in range(n):
			if f==0:
				break
			for j in range(n):
				#print(i,j)
				if G[i][j]!=G[j-x][i+x]:
					f=0
					break
		else:
			#print(x)
			ans+=n
	print(ans)










if __name__ == "__main__":
	main()


Measured memory_bytes: 80116
def north(list):
    List = []
    List.append(list[1])
    List.append(list[5])
    List.append(list[2])
    List.append(list[3])
    List.append(list[0])
    List.append(list[4])
    return List

def west(list):
    List = []
    List.append(list[2])
    List.append(list[1])
    List.append(list[5])
    List.append(list[0])
    List.append(list[4])
    List.append(list[3])
    return List
    
def south(list):
    List = []
    List.append(list[4])
    List.append(list[0])
    List.append(list[2])
    List.append(list[3])
    List.append(list[5])
    List.append(list[1])
    return List

def east(list):
    List = []
    List.append(list[3])
    List.append(list[1])
    List.append(list[0])
    List.append(list[5])
    List.append(list[4])
    List.append(list[2])
    return List
dice = list(map(int, input().split()))
D = [dice]
for i in range(0, 3):
    D.append(north(D[i]))
D.append(south(west(D[0])))
D.append(south(east(D[0])))
for i in range(6):
    for j in range(3):
        if j == 0:
            D.append(east(D[i + j]))
        else:
            D.append(east(D[5 + 3 * i + j]))

x = int(input())
for i in range(x):
    a, b = map(int, input().split())
    for i in range(len(D)):
        if a == D[i][0] and b == D[i][1]:
            print(D[i][2])
            break



Measured memory_bytes: 5624
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  sort(p.begin(), p.end());
  int ans = 0;
  rep(i,k) ans += p[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3120
n = int(input())
a = list(map(int,input().split()))

zero = 0
two = 0
odd = 0

for i in range(len(a)):
    if a[i] % 4 == 1 or a[i] % 4 == 3:
        odd = odd + 1
    elif a[i] % 4 == 0:
        zero = zero + 1
    else:
        two = two + 1
        
if zero >= odd -1 and two == 0:
    print('Yes')
elif zero >= odd:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14252
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int input[] = new int[3];
		
		input[0] = sc.nextInt();
		input[1] = sc.nextInt();
		input[2] = sc.nextInt();
		
		Arrays.sort(input);
		
		if((input[0] != input[2]) && (input[0] == input[1] || input[1] == input[2])){
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21844
ins = [int(input()) for i in range(4)]
cnt = 0
for i in range(ins[0]+1):
    for j in range(ins[1]+1):
        for k in range(ins[2]+1):
            if ins[3] == 500*i + 100*j + 50*k:
                cnt += 1
print(cnt)

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    string S, T;
    cin>>S;
    cin>>T;

    int max = 0;
    for(int i=0;i<S.size()-T.size()+1;i++){
        int temp = 0;
        for(int j=0;j<T.size();j++){
            if(S.at(i+j)==T.at(j))temp++;
        }
        if(temp>max)max=temp;
    }
    cout<<T.size()-max<<endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) a.begin(),a.end()


using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool upd_min (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool upd_max (T &a, T b) {return a < b ? (a = b, true) : false; }


main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    int t = h * 60 + m;
    ld angle = (ld)t * 360.0 / 60.0;
    ld ang = (ld)t * 360.0 / (60.0 * 12.0);
    while (angle >= 360.0) angle -= 360.0;
    while (ang >= 360.0) ang -= 360.0;
    ld A = abs(angle - ang);
    cout << fixed;
    cout.precision(100);
    cout << sqrt(a * a + b * b - 2.0 * a * b * cos(A / 180.0 * acos(-1.0)));
}


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

struct VRTX {
	int dt, ft, v[101];
};

int curtime = 1;
VRTX ver[101];

void depthFirstSearch(int u);

int main() {
	int i, j, n, u, k;

	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> u >> k;
		for (j = 0; j < k; j++) {
			cin >> ver[u].v[j];
		}
	}
	
	for (i = 1; i <= n; i++) {
		depthFirstSearch(i);
	}

	for (i = 1; i <= n; i++) {
		cout << i << " " << ver[i].dt << " " << ver[i].ft << endl;
	}

	return 0;
}

void depthFirstSearch(int u) {

	if (ver[u].dt == 0) {
		int i = 0;

		ver[u].dt = curtime++;

		while (ver[u].v[i] != 0) {
			depthFirstSearch(ver[u].v[i]);
			i++;
		}

		ver[u].ft = curtime++;

		return;
	}
	return;
}

Measured memory_bytes: 3100
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
typedef long long int ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fora(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define mp make_pair 
#define sc second 
#define f first 
#define kek cout<<"\n" 
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
const ll MOD = 1e9 + 7;
const int MAXN = 100005;
const int INF = 1e8;
using namespace std;
int main()

{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 fast;
   int n;
   cin>>n;
   cout<<(n+1)/2;
   return 0;
  
     
 
}

Measured memory_bytes: 256
import random
import time
import copy
start=time.time()
d=int(input())
c=list(map(int, input().split()))
cli=[]
for i in range(d+1):
  ch=[]
  for j in c:
    ch.append(i*j)
  cli.append(ch)
s=[]
solution=[]
last=[0]*26
sco=0
for i in range(d):
  s.append(list(map(int, input().split())))
for day in range(1,d+1):
  man=[]
  for i in range(26):
    man.append(s[day-1][i]+last[i]*c[i])
  con=man.index(max(man))
  sco+=s[day-1][con]
  last[con]=day
  for (i,j) in zip(last,range(26)):
    sco-=cli[i][j]
  solution.append(con)
#print(sco)
while time.time()-start<1.9:
  sc=0
  sol=copy.deepcopy(solution)
  for x in [random.randrange(d) for i in range(10)]:
    sol[x]=random.randrange(26)
  last=[0]*26
  for (day,i) in zip(range(1,d+1),sol):
    sc+=s[day-1][i]
    last[i]=day
    for (i,j) in zip(last,range(26)):
      sc-=cli[i][j]
  if sc>sco:
    solution=copy.deepcopy(sol)
    sco=sc
for i in solution:
  print(i+1)
#print(sco)

Measured memory_bytes: 10348
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define INF 10000000000000000000

int main(){
  ll n,k;
  cin >> n >> k;
  ll a[n];
  ll sum = 0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum += a[i];
  }
  vector<ll> ref;
  for(int i=1;i<100000;i++){
    if(sum%i == 0){
      ref.push_back(i);
      ref.push_back(sum/i);
    }
  }
  ll ans = 1;
  ll r[n];
  ll sr[n+1];
  for(int i=0;i<ref.size();i++){
    ll d = ref[i];
    for(int j=0;j<n;j++){
      r[j] = a[j]%d;
    }
    sort(r,r+n);
    sr[0] = 0;
    for(int j=0;j<n;j++){
      sr[j+1] = sr[j]+r[j];
    }
    ll l,r;
    ll flag = false;
    for(int j=0;j<n+1;j++){
      l = sr[j];
      r = (n-j)*d - (sr[n]-sr[j]);
      if(l == r && l <= k){
        flag = true;
      }
    }
    if(flag) ans = max(ans,d);

  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#define N 100001 
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,l,r,d,v[N],fa[N];
int Find(int x)
{
	if(fa[x]==x)return x;
	int tmp=Find(fa[x]);
	v[x]+=v[fa[x]];
	return fa[x]=tmp;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)fa[i]=i;
	for(int i=1;i<=m;i++)
	  {
	  scanf("%d%d%d",&l,&r,&d);
	  int fl=Find(l),fr=Find(r);
	  if(fl==fr){if(v[r]-v[l]!=d)
	    return printf("No\n"),0;}
	  else v[fr]=v[l]+d-v[r],fa[fr]=fl;
	  }
	return printf("Yes\n"),0;
}

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

int main() {
	int n,f;
	cin>>f;
	n = f%10;
	if(n==3)
    {
        cout<<"bon"<<endl;
    }
    else if(n==1 || n==0 || n==6 || n==8)
    {
        cout<<"pon"<<endl;
    }
    else
    {
        cout<<"hon"<<endl;
    }
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define testcase int t;cin>>t;while(t--)
#define fast_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define P pair<int,int>
/*bool isprime(lli n)
{
    if(n==1) return 0;
    for(lli i=2;i<=n/2;i++)
    {
        if(n%i==0) return 0;
    }
    return 1;
}
bool issemiprime(lli n)
{
    for(int i=2;i<n;i++)
    {
        if(isprime(i)&&isprime(n/i)&&n%i==0&&i!=n/i){
            return 1;
        }
    }
    return 0;
}
lli extendedgcd(lli q,lli r1,lli r2,lli r,lli s1,lli s2,lli s,lli t1,lli t2,lli t)
{
if(r2==0) return r1;
	r1=r2;
        r2=r;
        s1=s2;
        s2=s;
        t1=t2;
        t2=t;
        q=r1/r2;
        r=r1%r2;
        s=s1-(s2*q);
        t=t1-(t2*q);
return extendedgcd(q,r1,r2,r,s1,s2,s,t1,t2,t);
}
lli gcd(lli a,lli b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
void SOE()
{
    for(lli i=2;i<=100000;i++)
    {
        if(sieve[i]) continue;
        for(lli x=i;x<=100000;x+=i)
        {
            sieve[x]+=1;
        }
    }
}*/
/*bool func(pair<int,int> a,pair<int,int> b)
{
    return a.first<b.first;
}*/
int n,k,a[1000000];
int dp[1000000];
int f(int i)
{
    if(i==(n-1)) return 0;
    if(i>=n) return INT_MAX;
    if(dp[i]!=-1) return dp[i];
    int right=INT_MAX;
    for(int j=1;j<=k;j++)
    {
    if((i+j)<n)
    {
    right=min(right,abs(a[i]-a[i+j])+f(i+j));
    }
    }
    return dp[i]=right;
}
void solve()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<f(0);
}
int main()
{
    fast_io;
    solve();
}


Measured memory_bytes: 15696
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














ll N;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;

	if (N % 2 == 1) {
		cout << 0 << endl;
		return;
	}
	
	ll ans = N / 10;
	N /= 10;

	ll p5 = 5;
	while (p5 <= N) {
		ans += N / p5;
		p5 = p5 * 5;
	}
	cout << ans << endl;
}







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

int n,a[20];
int solve(int i,int m){
	if(m==0) return 1;
	if(i>=n) return 0;
	int ans = solve(i+1,m) || solve(i+1,m-a[i]);
	return ans;
}
int main() {
	int q,x;
	cin>>n;
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	scanf("%d",&q);
	while(q--){
		scanf("%d",&x);
		if(solve(0,x)) printf("yes\n");
		else printf("no\n");
	}
	return 0;
}


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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

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

    int A,B,C; cin >> A>>B>>C;
    int ans = A + B + C + 9 * max({A,B,C});    
    cout << ans << endl;
}


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


template <typename t> void max_self(t &a,t b)
{
	a=max(a,b);
}
bool row_col(pair<int,int> p)
{
	if(p.first==0||p.second==0)
		return 1;
	return 0;
}
int main()
{
	//#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	string a,b;
	cin>>a>>b;
	int n=a.length();
	int m=b.length();
	const int INF=1e9+5;
	vector<vector<pair<int,pair<int,int>>>> dp(n+1,vector<pair<int,pair<int,int>>>(m+1,{-INF,{0,0}}));
	dp[0][0]={0,{0,0}};
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(a[i]==b[j])
			{
				max_self(dp[i+1][j+1],make_pair(dp[i][j].first+1,make_pair(i,j)));
			}
			else
			{
				max_self(dp[i+1][j],make_pair(dp[i][j].first,make_pair(i,j)));
				max_self(dp[i][j+1],make_pair(dp[i][j].first,make_pair(i,j)));
			}
		}
	}
	pair<int,pair<int,int>> ans={0,{0,0}};
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			max_self(ans,make_pair(dp[i][j].first,make_pair(i,j)));
		}
	}
	string s;
	pair<int,int> curr=ans.second;
	while(!row_col(curr))
	{
		int i=curr.first;
		int j=curr.second;
		pair<int ,int> prev=dp[i][j].second;
		if(prev==make_pair(i-1,j-1))
		{
			s+=a[i-1];
		}
		curr=prev;
	}
	reverse(s.begin(),s.end());
	cout<<s<<'\n';
	return 0;
}

Measured memory_bytes: 105984
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#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> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
int a;
cin>>a;
cout<<a+a*a+a*a*a;
}
int main()
{
//code
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 3612
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();

    if n % 2 == 0 {
        let s: String = read();
        let mid = n / 2;
        if &s[0..mid] == &s[mid..n] {
            println!("Yes");
            return ();
        }
    }

    println!("No");
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <stack>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <functional>
//#include <unordered_set>
#define INF 2147483647
#define MAXN  100005
#define mod 1000000007
#define PII pair<int, int>
#define lowbit(x) (x&-x)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int d[4][2] = { 0,1,0,-1,1,0,-1,0 };
char c[60][60];
int vis[60][60];
int h, w;
struct node {
	int x, y, sp;
};
int bfs()
{
	queue<node> q;
	node t{ 1,1,1 };
	q.push(t);
	memset(vis, 0, sizeof(0));
	vis[1][1] = 1;
	while (!q.empty())
	{
		auto t = q.front();
		q.pop();
		if (t.y == h && t.x == w)
			return t.sp;
		node x;
		int a, b;
		for (int i = 0; i < 4; i++)
		{
			a=x.x = t.x + d[i][0];
			b=x.y = t.y + d[i][1];
			x.sp = t.sp + 1;
			if (a<1 || b<1 || a>w || b>h)
				continue;
			if (vis[a][b] == 0&&c[b][a]=='.')
			{
				vis[a][b] = 1;
				q.push(x);
			}
		}
	}
	return -1;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef local_debug1
	ifstream inputs("input.txt");
	cin.rdbuf(inputs.rdbuf());
	freopen("input.txt", "r", stdin);
#endif

	int s = 0;
	cin >> h >> w;

	for (int i = 1; i <= h; i++)
	{
		cin.ignore();
		//cin.get(c[i]+1, w+1);
		for (int j = 1; j <= w; j++)
		{
			cin >> c[i][j];
			if (c[i][j] == '#')
				s++;
		}
	}
	int t = bfs();
	if (t == -1)
	{
		cout << -1 << endl;
		return 0;
	}
	//cout << t << endl;
	cout << h * w - t - s << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;

constexpr long long int mod = 1e9 + 7;

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

	vector<int> vec(60);
	for (int i = 0; i < n; i++) {
		long long int x;
		cin >> x;

		for (int j = 0; j < 60; j++) {
			vec.at(j) += x & 1;
			x >>= 1;
		}
	}

	long long sum = 0;
	long long base = 1;
	for (int i = 0; i < 60; i++) {
		sum += (base * vec.at(i) % mod) * (n - vec.at(i)) % mod;
		sum %= mod;
		base *= 2;
		base %= mod;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;

#define REP(i, s, n) for(int i = (s); i < int(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(co) co.begin(), co.end()

int dp[101][3][2];
int sche[101];
const int MOD = 10000;

int main()
{
	int n, k; cin >> n >> k;
	n--;
	memset(sche, -1, sizeof(sche));
	rep(i, k)
	{
		int a, b; cin >> a >> b;
		a--; b--;
		sche[a] = b;
	}

	if (~sche[0]) dp[0][sche[0]][0] = 1;
	else rep(i, 3) dp[0][i][0] = 1;

	rep(i, n)
	{
		if (~sche[i + 1]) rep(j, 3)
		{
			if (j == sche[i + 1]) dp[i + 1][sche[i + 1]][1] += dp[i][sche[i + 1]][0] % MOD;
			else dp[i + 1][sche[i + 1]][0] += (dp[i][j][0] + dp[i][j][1]) % MOD;
		}
		else rep(j, 3) rep(k, 3)
		{
			if (j == k) dp[i + 1][j][1] += dp[i][k][0] % MOD;
			else dp[i + 1][j][0] += (dp[i][k][0] + dp[i][k][1]) % MOD;
		}
	}

	int ans = 0;
	rep(i, 3) (ans += (dp[n][i][0] + dp[n][i][1])) %= MOD;
	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,W;
const int N = 1e2 + 5;
const int m =1e5 +5;
vector<vector<int>> dp(N, vector<int> (m, -1));
vector<int> w(N),v(N);
int res(vector<int> &w,vector<int> &v,int n,int W)
{
	if(n==0 )
  {
  	if(W >= 0)
  		return 0;
  	else return -1e9;
	}
  if(W < 0)
  {	
  	return -1e9;
  }
  if(dp[n][W] != -1)
  {
  	return dp[n][W];
  }
  dp[n][W] = 0;
  dp[n][W] = max(res(w, v, n - 1, W), v[n] + res(w, v, n - 1, W - w[n]) );
  return dp[n][W];
}
int32_t main()
{
	
	cin>>n>>W;
  
  for(int i=1;i<=n;i++)
  {
  	cin>>w[i]>>v[i];
  }
  cout<<res(w, v, n, W);
}

Measured memory_bytes: 86232
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/math/tools/minima.hpp>

const int MOD = 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::math::tools::brent_find_minima;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::split;
using boost::algorithm::replace_all;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	int	n;
	cin >> n;
	if (n == 1)
	{
		int a;
		cin >> a;
		cout << a << endl;
		return ;
	}
	if (n == 2)
	{
		int a, b;
		cin >> a >> b;
		cout << b << " " << a << endl;
		return ;
	}

	vector<int>	VA(n / 2 + 1);
	vector<int>	VB((n - 1) / 2);
	cin >> VA.at(0);

	rep(i, n - 1)
	{
		int	x;
		cin >> x;

		if (i % 2 == 0)
			VA.at(i / 2 + 1) = x;
		else
			VB.at(i / 2) = x;
	}
	if (n % 2)
	{
		rrep(i, (n - 1) / 2 - 1)
		{
			if (i != (n - 1) / 2 - 1)
				cout << " ";
			cout << VB.at(i);
		}
		rep(i, n / 2 + 1)
			cout << " " << VA.at(i);
	}
	else
	{
		rrep(i, n / 2)
		{
			if (i != n / 2)
				cout << " ";
			cout << VA.at(i);
		}
		rep(i, (n - 1) / 2)
			cout << " " << VB.at(i);

		// rrep(i, (n - 1) / 2 - 1)
		// {
		// 	if (i != (n - 1) / 2 - 1)
		// 		cout << " ";
		// 	cout << VB.at(i);
		// }
		// rep(i, n / 2 + 1)
		// 	cout << " " << VB.at(i);
	}
	cout << endl;
}
// END

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


Measured memory_bytes: 2944
using System;

class MyClass
{
    public static void Main(string[] args)
    {
        string str;
        while ((str = Console.ReadLine()) != null)
        {
            string[] str2 = str.Split(',');
            int num = int.Parse(str2[0]);
            double w = double.Parse(str2[1]);
            double h = double.Parse(str2[2]);
            double bmi = w / (h * h);
            if (bmi >= 25)
            {
                Console.WriteLine(num);
            }
        }
    }
}


Measured memory_bytes: 5676
N = int(input())
A = [int(x) for x in input().split()]
B = [0] * (N + 2)
for k in range(N):
    B[k+1] = A[k]
sumofdis = 0
for i in range(N+1):
    sumofdis += abs(B[i+1]-B[i])
for j in range(1, N+1):
    if B[j - 1] <= B[j] <= B[j + 1] or B[j - 1] >= B[j] >= B[j + 1]:
        print(sumofdis)
    elif B[j] <= B[j-1] <= B[j + 1] or B[j] >= B[j-1] >= B[j + 1]:
        print(sumofdis-2*abs(B[j-1]-B[j]))
    else:
        print(sumofdis-2*abs(B[j+1]-B[j]))
# print(B)


Measured memory_bytes: 13792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <cstdlib>
#include <ctime>
using namespace std;

#define X first
#define Y second
#define N 200010
#define M 500010

typedef long long ll;
const int INF=1ll<<30;

int x[N],dpl[N<<2],dpr[N<<2],len[20];
int mxl[20][N],mxr[20][N];
bool vis1[N<<2],vis2[N<<2];
vector<int> lis1[N],lis2[N];

int main()
{
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
	
	int n,m=0,V,tmp,lim; scanf("%d%d",&n,&V);
	for (int i=1;i<=n;i++) scanf("%d",&x[i]);
	for (tmp=V;;tmp>>=1) 
	{
		len[m]=tmp;
		for (int l=1,r=1;l<=n;l++)
		{
			r=max(r,l);
			while (r<n && x[r+1]-x[r]<=tmp) r++;
			mxl[m][l]=r-l+1;
			//cout<<tmp<<" "<<l<<" "<<mxl[m][l]<<endl;
		}
		for (int r=n,l=n;r>=1;r--)
		{
			l=min(r,l);
			while (l>1 && x[l]-x[l-1]<=tmp) l--;
			mxr[m][r]=r-l+1;
			//cout<<tmp<<" "<<r<<" "<<mxr[m][r]<<endl;
		}
		m++;
		if (tmp==0) break;
	}
	dpl[0]=dpr[0]=0; lim=1<<m; lim>>=1;
	for (int mask=0;mask<lim;mask++)
	{
		lis1[dpl[mask]].push_back(mask);
		lis2[dpr[mask]].push_back(mask);
		//cout<<mask<<" "<<dpl[mask]<<" "<<dpr[mask]<<endl;
		for (int j=0;j<m;j++)
		{
			if (mask&(1<<j)) continue;
 			dpl[mask|(1<<j)]=max(dpl[mask|(1<<j)],dpl[mask]+mxl[j+1][dpl[mask]+1]);
 			dpr[mask|(1<<j)]=max(dpr[mask|(1<<j)],dpr[mask]+mxr[j+1][n-dpr[mask]]);
		}
	}
	int cnt1=lim,cnt2=0,l=1,r=mxl[0][1];
	for (int i=0;i<lim;i++) 
	{
		vis1[i]=true;
		if (dpr[i]>=n-r) vis2[i]=true,cnt2++;
	}
	if (cnt2) printf("Possible\n");
	else printf("Impossible\n");
	
	for (int i=2;i<=n;i++)
	{
		int nl=i-mxr[0][i]+1,nr=i+mxl[0][i]-1;	
		//cout<<nl<<" "<<nr<<endl;
		for (int j=l-1;j<nl-1;j++)
		{
			for (int k=0;k<lis1[j].size();k++)
			{
				if (vis1[lis1[j][k]]) 
				{
					vis1[lis1[j][k]]=false;
					cnt1--;
					if (vis2[(lim-1)^lis1[j][k]]) vis2[(lim-1)^lis1[j][k]]=false,cnt2--;
				}
			}
		}
		for (int j=n-nr;j<n-r;j++)
		{
			for (int k=0;k<lis2[j].size();k++)
			{
				//cout<<lis2[j][k]<<" "<<((lim-1)^lis2[j][k])<<endl;
				if (vis1[(lim-1)^lis2[j][k]]) cnt2++,vis2[lis2[j][k]]=true;
			}
		}
		if (cnt2) printf("Possible\n");
		else printf("Impossible\n");
		l=nl,r=nr;
	}
	
	
	return 0;
}

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

int main() {
  int long long N;
  int long long a[1000000];
  cin>>N;
  rep(i,N){
  a[i]=i+1;
  }
  int long long sum=0;
  rep(i,N){
   if(a[i]%3!=0&&a[i]%5!=0){
    sum+=a[i];
    }
  }
 
  cout<<sum<<endl;
  
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define pb(a) push_back(a)
#define vi vector<int>
#define loop(i, n) for(int i=1;i<=n;i++)
#define loop0(i, n) for(int i=0;i<n;i++)
#define in(i) scanf("%lld", &i);
#define out(i) printf("%d", i)
long long int n, k, h[100001], dp[100001];

long long int solve(long long int stone)
{
  if(stone==n)
    return 0;
  if(stone>n)
    return INT_MAX;
  if(dp[stone]!=-1)
    return dp[stone];
  if(stone==n-1)
    return dp[stone]=abs(h[n]-h[stone]);

  long long int ans=INT_MAX;
  loop(i, k)
  {
    ans=min(ans, solve(stone+i)+abs(h[stone]-h[stone+i]));
  }
  return dp[stone]=ans;
}
int main()
{
  memset(dp, -1, sizeof(dp));
  in(n);
  in(k);
  loop(i, n)
    in(h[i]);
  cout<<solve(1)<<"\n";
}



Measured memory_bytes: 11492
MOD = 998244353

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N, S = ZZ()
    A = ZZ()
    dp = [[0] * (S+1) for _ in range(N + 1)]
    dp[0][0] = 1
    for i in range(N):
        for j in range(S+1):
            dp[i+1][j] += 2*dp[i][j]
            if A[i] <= j <= S: dp[i+1][j] += dp[i][j-A[i]]
            dp[i+1][j] %= MOD
    print(dp[N][S])

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 135364