akhauriyash/Code-Regression huggingface dataset:
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
 
template <ll mod> class ModInt {
    ll a;
public:
    constexpr ModInt(const ll a = 0) noexcept : a((a % mod + mod) % mod) {}
    constexpr ll &value() noexcept { return a; }
    constexpr ModInt operator + (const ModInt &rhs) const noexcept { return ModInt(*this) += rhs; }
    constexpr ModInt operator - (const ModInt &rhs) const noexcept { return ModInt(*this) -= rhs; }
    constexpr ModInt operator * (const ModInt &rhs) const noexcept { return ModInt(*this) *= rhs; }
    constexpr ModInt operator / (const ModInt &rhs) const noexcept { return ModInt(*this) /= rhs; }
    constexpr ModInt &operator += (const ModInt &rhs) noexcept {
        a += rhs.a;
        if (a >= mod) a -= mod;
        return *this;
    }
    constexpr ModInt &operator -= (const ModInt &rhs) noexcept {
        a += mod - rhs.a;
        if (a >= mod) a -= mod;
        return *this;
    }
    constexpr ModInt &operator *= (const ModInt &rhs) noexcept {
        a = a * rhs.a % mod;
        return *this;
    }
    constexpr ModInt pow(ll t) const noexcept {
        if (t == 0) return 1;
        auto ret = pow(t >> 1);
        ret *= ret;
        if (t & 1) ret *= *this;
        return ret;
    }
    constexpr ModInt inv() const noexcept { return pow(mod - 2); }
    constexpr ModInt operator /=(const ModInt &rhs) { return (*this) *= rhs.inv(); }
    constexpr bool operator == (const ModInt &rhs) const noexcept { return this->a == rhs.a; }
    constexpr bool operator != (const ModInt &rhs) const noexcept { return this->a != rhs.a; }
    friend constexpr ostream &operator << (ostream &os, const ModInt &rhs) noexcept { return os << rhs.a; }
    friend constexpr istream &operator >> (istream &is, ModInt &rhs) {
        is >> rhs.a;
        return is;
    }
};
using mint = ModInt<MOD>;
 
int main() {
    int n;
    cin >> n;
 
    mint ans = 0;
    ans += ((mint)10).pow(n);
    ans -= ((mint)9).pow(n);
    ans -= ((mint)9).pow(n);
    ans += ((mint)8).pow(n);
 
    cout << ans << endl;
    return 0;
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	int n; cin >> n;
	cout << 800 * n - 200 * (n / 15) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main{
	public static void main(String args[]){
        int sum = 0;
        int inf = 1000;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n-1];
        for(int i = 0; i < n; i++){ //a
            a[i] = sc.nextInt();
        }
        for(int j = 0; j < n; j++){ //b
            b[j] = sc.nextInt();
        }
        for(int k = 0; k < n-1; k++){ //c
            c[k] = sc.nextInt();
        }
        for(int m = 0; m < n; m++){ //syori
            
            int index = a[m];
            sum += b[index - 1];
            if(index- inf == 1){
                sum += c[index-2];
            }
            inf = a[m];
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 23636
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define MP make_pair

inline int gn(){
    int s=0,f=1; 
    char ch = getchar();
    while(!isdigit(ch)) {if(ch == '-') f=-1;ch = getchar();}
    while(isdigit(ch)) {s=s*10+ch-'0';ch = getchar();}
    return s*f;
}

inline ll gl(){
    ll s=0,f=1; 
    char ch = getchar();
    while(!isdigit(ch)) {if(ch == '-') f=-1;ch = getchar();}
    while(isdigit(ch)) {s=s*10+ch-'0';ch = getchar();}
    return s*f;
}

const int N=2e5+100;

void solve(){
    int x=gn();
    for(ll i=0;i<=1000;++i){
        for(ll j=0;j<=1000;++j){
            ll a=i*i*i*i*i;
            ll b=j*j*j*j*j;
            if(a+b==x){
                cout<<i<<" "<<-j<<endl;
                return ;
            }
            if(a-b==x){
                cout<<i<<" "<<j<<endl;
                return ;
            }
        }
    }
}

int main(){
    // int t;
    // t=gn();
    // while(t--)
        solve();
}

/**
* In every life we have some trouble
* When you worry you make it double
* Don't worry,be happy.
**/


Measured memory_bytes: 3636
function Main(input) {
	tmp = input.split(" ");
	var a = parseInt(tmp[0]);
	var b = parseInt(tmp[1]);
	var t = parseInt(tmp[2]);
	t = t+0.5;
	var ct = parseInt(t/a);
	console.log(ct*b);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22076
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define full(v) v.begin(),v.end()

void solve()
{
  string s;
  cin >> s;
  for (char c : s)
  {
    if (c=='?')
      cout << 'D';
    else
      cout << c;
  }
  cout << endl;
}

int main()
{
  ios_base::sync_with_stdio(false);
  // Remove for interactive problems
  //cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  //cin >> t;
  while (t--)
  {
      solve();
  }
}



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

int main()
{
	int x;
	cin >> x;
	if (x >= 400 & x <= 599) cout << 8 << endl;
	else if (x >= 600 & x <= 799) cout << 7 << endl;
	else if (x >= 800 & x <= 999) cout << 6 << endl;
	else if (x >= 1000 & x <= 1199) cout << 5 << endl;
	else if (x >= 1200 & x <= 1399) cout << 4 << endl;
	else if (x >= 1400 & x <= 1599) cout << 3 << endl;
	else if (x >= 1600 & x <= 1799) cout << 2 << endl;
	else cout << 1 << endl;
	return 0;
}

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

if a>=b and a>=c:
    ans = a
    cou = a
elif b>=a and b>=c:
    ans = b
    cou=b
else:
    ans = c
    cou=c
for i in range(k):
    count=ans*2
    ans = count
if cou==a:
    print(ans+b+c)
elif cou==b:
    print(ans+a+c)
else:
    print(ans+b+a)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int N = 300000;

int n, a[N]; long long ans = 0;

int main()
{
	scanf( "%d", &n );
	
	for( int i = 1; i <= n; i ++ )
		scanf( "%d", &a[i] );
	
	if( a[1] != 0 ) {
		printf( "-1\n" ); return 0;
	}
	
	for( int i = 2; i <= n; i ++ )
	{
		if( a[i] - a[i-1] >= 2 ) {
			printf( "-1\n" ); return 0;
		}
	
		if( a[i] - a[i-1] == 1 ) 
			ans ++;
		else ans += a[i];
	}
	
	printf( "%lld\n", ans );
	
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>

int main() {
  std::string S;
  std::cin >> S;
  std::sort(S.begin(), S.end());
  if (S == "abc") {
    std::cout << "Yes\n";
  } else {
    std::cout << "No\n";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    string s;
    cin>>s;
    n=s.size();
    string ss;
    ss=s;
    reverse(ss.begin(),ss.end());
    if(s!=ss)
    {
        cout<<"No"<<endl;
        return 0;
    }
    m=(n-1)/2;
    ss=s.substr(0,m);
    string s1;
    s1=ss;
    reverse(s1.begin(),s1.end());
    if(s1!=ss)
    {
        cout<<"No"<<endl;
        return 0;
    }
    m=(n+3)/2;
    m--;
    ss=s.substr(m,n-m);
    s1=ss;
    reverse(s1.begin(),s1.end());
    if(s1!=ss)
    {
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 100005

template <class T>
void scan(T &number)
{
    bool negative = false;
    register T c;
    number = 0;
    c = getchar();
    if (c=='-')
    {
        negative = true;
        c = getchar();
    }
    for (; (c>47 && c<58); c=getchar())
        number = number *10 + c - 48;
    if (negative)
        number *= -1;
}

int n,A,B;
int h[N],Max;

bool  check(int x)
{
	int least = x;
	for(int i = 1; i <= n && least >= 0; i++)
		least-=(max(h[i] - x * B, 0) + A - 1) / A;
	return (least>=0);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	
	scan(n); scan(A); scan(B);
	A-=B;
	for(int i = 1; i <= n; i++)
	{
		scan(h[i]);
		Max=max(Max, h[i]);
	}

	int l = 0, r = Max / B + 1;

	while(l < r)
	{
		int mid = l + r >> 1;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	printf("%d\n", l);
    return 0;
}

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

def main():
    N = int(input())
    D = [int(x) for x in input().split()]

    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            ans += D[i] * D[j]
    print(ans)

    

if __name__ == '__main__':
    main()



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

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< int, ll > pil;
typedef pair< ll, int > pli;
typedef pair< ll, ll > pll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< ll > vl;
typedef vector< vl > vvl;
typedef vector< double > vd;
typedef vector< vd > vvd;
typedef vector< pii > vp;
typedef vector< vp > vvp;
typedef vector< bool > vb;
typedef vector< vb > vvb;

template< class T1, class T2 >
bool upmin( T1 &x, T2 v ){
    if( x > v ){
        x = v;
        return true;
    }
    return false;
}

template< class T1, class T2 >
bool upmax( T1 &x, T2 v ){
    if( x < v ){
        x = v;
        return true;
    }
    return false;
}

void dfs( const vvi &G, vi &dpt, int d, int u, int fa ){
    dpt[ u ] = d;
    for( int v : G[ u ] ){
        if( v == fa ) continue;
        dfs( G, dpt, d + 1, v, u );
    }
}

void mark( const vvi &G, vi &vis, int d, int u, int fa, int K ){
    if( d == K ) return;
    vis[ u ] = 1;
    for( int v : G[ u ] ){
        if( v == fa ) continue;
        mark( G, vis, d + 1, v, u, K );
    }
}

void solve(){
    int N, K; cin >> N >> K;
    vi A( N );
    for( int i = 0; i < N; ++i )
        cin >> A[ i ],
        --A[ i ];
    int ans = 0;
    if( A[ 0 ] != 0 ) A[ 0 ] = 0, ++ans;
    vvi G( N );
    for( int i = 1; i < N; ++i )
        G[ A[ i ] ].push_back( i );
    vi dpt( N );
    dfs( G, dpt, 0, 0, -1 );
    vvi dpt2node( N );
    for( int i = 0; i < N; ++i )
        dpt2node[ dpt[ i ] ].push_back( i );
    vi vis( N );
    for( int i = N - 1; i > K; --i )
        for( int n : dpt2node[ i ] ){
            if( not vis[ n ] ){
                int u = n;
                for( int k = 0; k < K - 1; ++k )
                    u = A[ u ];
                mark( G, vis, 0, u, -1, K );
                ++ans;
            }
        }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio( false );
    solve();
    return 0;
}


Measured memory_bytes: 20224
// Last Change: 05/26/2019 21:01:54.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  ll A, P;
  cin >> A >> P;

  P += A * 3;

  cout << P / 2 << endl;

  //NS::LoopUntilZeroInpput();
}


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

int sum = 0;

bool calculate (string number, int mask) {
    int bit_flag, sign = 1, sum = 0;
    string buff;
    for (int i = 0; i < number.length(); i++) {
        sum += sign * (number[i] - '0');
        bit_flag = (1 << i);
        if ((mask & bit_flag) != 0) {
            sign = -1;
        }
        else {
            sign = 1;
        }
    }
    return sum == 7;
}

void output (string number, int mask) {
    int bit_flag;
    for(int i = 0; i < number.length(); i++) {
        cout << number[i];
        if (i == (number.length() - 1)) {
            cout << "=7" << endl;
        }
        else {
            bit_flag = (1 << i);
            if ((mask & bit_flag) != 0) {
                cout << "-";
            }
            else {
                cout << "+";
            }
        }
    }
}

int main() {
    string number;
    cin >> number;
    for(int i = 0; i < (1 << (number.length() - 1)); i++) {
        if(calculate(number, i)) {
            output(number, i);
            exit(0);
        }
    }
    return 0;
}

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

int Gcd(int a, int b) {
  if (b == 0) return a;
  return Gcd(b, a % b);
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  int ans = A[0];
  for (int i = 1; i < N; i++) ans = Gcd(ans, A[i]);
  cout << ans << endl;
}

Measured memory_bytes: 640
N,M,R=map(int,input().split())
X=list(map(int,input().split()))
from collections import defaultdict
from collections import deque
branch=defaultdict(set)
for m in range(M):
    a,b,c=map(int,input().split())
    branch[a]|={(b,c)}
    branch[b]|={(a,c)}
def makedist(x):
    dist=[float('inf')]*(N+1)
    dist[x]=0
    check={x,}
    while len(check)>0:
        now=check.pop()
        for b in branch[now]:
            if dist[now]+b[1]<dist[b[0]]:
                dist[b[0]]=dist[now]+b[1]
                check|={b[0],}
    return dist
data=dict()
for x in X:
    data[x]=makedist(x)
def roop(now,D,notvisit,ans):
    if len(notvisit)==0:
        return min(D,ans)
    for nex in notvisit:
        ans=roop(nex,D+data[now][nex],notvisit-{nex,},ans)
    return ans
ans=float('inf')
for x in X:
    ans=min(ans,roop(x,0,set(X),float('inf')))
print(ans)

Measured memory_bytes: 8520
#include<bits/stdc++.h>
#define f0(i,n) for(long long int i=0;i<n;i++)
#define f1(i,n) for(long long int i=1;i<=n;i++)
#define f2(i,a,b) for(long long int i=a;i<=b;i++)
#define sp <<" "                // giving space
#define sp1 <<" "<<              // giving space between two elements
#define nl <<"/n"                  // new line
#define M 1000000007              // for mod
#define ll long long
#define ld long double
#define F first
#define S second
using namespace std;


int main()
{
     ll n,x;
     cin>>n>>x;
     vector <ll> v(n);
     
     f0(i,n) cin>>v[i];
     
     ll d=0;
     
     ll c=1;
     
     f1(i,n){
         if(x>=d+v[i-1]) c++;
         d=d+v[i-1];
     }
     
     cout<<c;
    return 0;
    }

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define N 100000
int hi[N+1],dp[N+1];
int main(){
	int n,m,i;scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)scanf("%d",hi+i);
	memset(dp,0x3f,sizeof(dp));dp[1]=0;
	for(i=2;i<=n;i++)for(int j=max(1,i-m);j<=i-1;j++)
		dp[i]=min(dp[i],dp[j]+abs(hi[i]-hi[j]));
	printf("%d\n",dp[n]);
	return 0;
}
/*1
5 3
10 30 40 50 20
*/
/*2
3 1
10 20 10
*/
/*3
2 100
10 10
*/
/*4
10 4
40 10 20 70 80 10 20 70 80 60
*/

Measured memory_bytes: 1024
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){function t(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=[],n=!0,o=!1,u=void 0;try{for(var i,f=e[Symbol.iterator]();!(n=(i=f.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(e){o=!0,u=e}finally{try{n||null==f.return||f.return()}finally{if(o)throw u}}return t}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}e.exports=function(e){for(var r=t(e.split("\n")[0].split(" ").map(function(e){return Number(e)}),2),n=r[0],o=r[1],u=0;u<1e3;u++)if(1+(n-1)*u>=o)return void console.log(u)}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 21192
import itertools
import bisect
N,x = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
cumsum = list(itertools.accumulate(A))
ans = bisect.bisect_right(cumsum,x)

if ans == N:
  rest = cumsum[-1] - x
  if rest != 0:
    ans -= 1

print(ans)


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

int main()
{
  int n;
  cin >> n;
  
  int count = 0;
  bool ans = false;
  for(int i = 0; i < n; ++i)
  {
    int d1, d2;
    cin >> d1 >> d2;
    if(d1 == d2) count++;
    else count = 0;
    
    if(count == 3) ans = true;
  }
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3632
//テンプレ
#include <bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i = 0; i < (n); ++i)
#define FOR(i,a,b)  for(int i = (a); i <= (b); ++i)
#define ALL(v) (v).begin(),(v).end()

using namespace std;
//constexpr int MOD = 10e9+7;
//constexpr int INF = 1LL << 60;
template <class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}  
template <class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}  
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
//
signed main (){
   ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   int N;
   cin >> N;
   int L[N];
   int max = 0;
   int sum=0;
   REP(i,N)
   {
      cin >>L[i] ;
      chmax(max,L[i]);
      sum += L[i];
   }
   if(max < sum -max)
   {
      cout << "Yes" <<endl;
   }else{
      cout << "No" <<endl;
   }

}

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

using namespace std;

int main(void){
	int N; cin >> N;
	char S[N];
	cin >> S;
	int i;
	char now = S[0];
	int ans = 1;
	for(i = 1; i < N; i++){
		if(now != S[i]){
			now = S[i];
			ans++;
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,k,a[26];
int main(){
	char s[99];
	scanf("%d%d",&n,&k);
	while(n--){
		scanf("%s",s);
		a[*s-'A']++;
	}
	n=0;
	while(1){
		sort(a,a+26);
		reverse(a,a+26);
		if(a[k-1]==0){
			break;
		}
		n++;
		for(int i=0; i<k; i++)
			a[i]--;
	}
	printf("%d\n",n);
	return 0;
}


Measured memory_bytes: 128
//writer：Sakura
//problem：
//id：
//from：

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
//#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll a,b,c;
ll k;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%lld %lld %lld %lld",&a,&b,&c,&k);
	if(k%2==0){
		printf("%lld\n",a-b);
	}
	else{
		printf("%lld\n",b-a);
	}
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	n := readInt()
	m := readInt()
	s := []byte(readString())
	t := []byte(readString())

	g := gcd(n, m)
	// d__n__s__u__s__r__a__y__u__k__u__a__i__i__a
	// d____u____j____r____u____n____u____m____a
	var i, j, k int
	for j < n && k < m {
		if s[j] != t[k] {
			println(-1)
			return
		}
		i++
		j = n / g * i
		k = m / g * i
	}
	println(lcm(n, m))
}

func lcm(a, b int) int {
	g := gcd(a, b)
	return a / g * b
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 10000
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

string s, t;
int dp[3010][3010];
string ans;

signed main() {
	cin >> s >> t;
	for (int i = 0; i < (int)s.size(); i++) {
		for (int j = 0; j < (int)t.size(); j++) {
			if (s[i] == t[j])dp[i + 1][j + 1] = dp[i][j] + 1;
			else dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
		}
	}
	int i = (int)s.size(), j = (int)t.size();
	while (i > 0 && j > 0) {
		if (dp[i][j] == dp[i - 1][j])i--;
		else if (dp[i][j] == dp[i][j - 1])j--;
		else {
			i--, j--;
			ans = s[i] + ans;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 70784
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
 
 
public class Main {


	public static void main(String[] args) {
		// TODO Auto-generated method stub
		//int Q = Integer.parseInt(sc.next());
		//long L = Long.parseLong(sc.next());
		//char[] c = sc.next().toCharArray();
		int INF = Integer.MAX_VALUE;
		Scanner sc = new Scanner(System.in);
		
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		long MOD = 1_000_000_007;
		
		//素因数分解
		List<int[]> primes = new ArrayList<>();
		
		
		int now_prime = 2;
		int now_M = M;
		int MAX = Math.max(N*2, 1000000);
		while(now_prime*now_prime<=M){
			if(now_M%now_prime == 0){
				now_M /= now_prime;
				int[] prime = new int[2];
				prime[0] = now_prime;
				prime[1] = 1;
				while(now_M%now_prime == 0){
					now_M /= now_prime;
					prime[1]++;
				}
				primes.add(prime);
				
			}
			now_prime++;
		}
		if (now_M>1){
			int[] prime = new int[2];
			prime[0] = now_M;
			prime[1] = 1;
			primes.add(prime);
		}
		
		long ans = 1L;
		
		//二項係数演算用前処理
		long[] fac = new long[MAX+1];
		fac[0] = 1L;
		fac[1] = 1L;
		long[] inv = new long[MAX+1];
		inv[1] = 1L;
		long[] finv = new long[MAX+1];
		finv[0] = 1L;
		finv[1] = 1L;
		for(int i=2;i<MAX;i++){
			fac[i] = fac[i-1] * i % MOD;
			inv[i] = MOD - inv[(int)(MOD%i)] * (MOD/i) % MOD;
			finv[i] = finv[i-1] * inv[i] % MOD;
		}
		
		
		
		for(int[] prime : primes){
			//因数K個のN分割を求める
			int K = prime[1];
			ans *= fac[N+K-1] * finv[K]%MOD * finv[N-1]%MOD;
			ans %= MOD;
		}
		ans %= MOD;
		System.out.println(ans);
		
	}
}



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

const int N = 1e5 + 77;
signed main()
{
#ifdef home
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#else
    // freopen("poly.in", "r", stdin);
    // freopen("poly.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    int n, ans = 0;
    cin >> n;
    vector<int> s;
    set<int> f;
    for (int i = 0; i < n; i++)
    {
        int v;
        cin >> v;
        if (i & 1)
        {
            f.insert(v);
        }
        s.push_back(v);
    }
    sort(s.begin(), s.end());
    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 0 && f.count(s[i]))
        {
            ans++;
        }
    }
    cout << ans;
}

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

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

  int R; cin >> R;

  printf("%.10lf\n", 2 * M_PI * R);

  return 0;
}


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

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

using namespace std;

typedef vector< vector<int> > table;
typedef long long ll;

ll g1(ll n,int p)
{
    if(n==0)return 0;
    return n/p +g1(n/p,p);
}

ll g2(ll n, int p)
{
    if(n%2==1)
    {
        return g1(n,p) -g2(n-1,p);
    }
    ll res=g1(n/2,p);
    if(p==2)res+=n/2;
    return res;
}

int main()
{
    ll n;
    cin>>n;
    ll ans=min(g2(n,2),g2(n,5));
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstdlib>

using namespace std;

typedef long long LL;
const int maxn = 100005;
const LL MOD = 1e9 + 7;
int ti[maxn], ai[maxn];
int N;

int main() {
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) scanf("%d", &ti[i]);
    for (int i = 1; i <= N; i++) scanf("%d", &ai[i]);
    int mxt = 0, mxa = 0;
    LL num = 1;
    for (int i = 1; i <= N; i++) {
        if (i > 1 && i < N) {
            if (ti[i] > ti[i - 1]) { // h[i] = ti[i]
                if (ai[i] < ti[i]) num = 0;
                if (ai[i - 1] < ai[i]) num = 0;
            } else {
                if (ti[i] < ti[i - 1]) num = 0;
                else {
                    if (ai[i] == ai[i + 1])
                        num *= min(ti[i], ai[i]);
                    else if (ai[i] < ai[i + 1]) num = 0;
                    num %= MOD;
                }
            }
        }
        mxt = max(mxt, ti[i]);
        mxa = max(mxa, ai[i]);
    }
    if (mxt == mxa) {
        printf("%lld\n", num);
    } else puts("0");
    return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_C

最長共通部分列
"""


c = []
def prep_array(X, Y):
    global c
    """ 値が0の2次元配列を用意する。サイズは入力データの最大値を想定して縦横(1000+1)以上必要。 """
    # from array import array
    # c = [array('I', [0] * (len(X)+1)) for _ in range(len(Y)+1)]  #  arrayで用意
    c = [[0]*(len(Y)+2) for _ in range(len(X)+2)] #  リストで用意
    return c


def check_max(array):
    """ 2次元配列の中の最大の値を返す """
    max_lcs = 0
    for row in array:
        temp_max = max(row)
        if temp_max > max_lcs:
            max_lcs = temp_max
    return max_lcs


def calc_lcs4(X, Y, c):
    """
    Y[j]のアクセス方法を変更
    リストの値を一旦変数に保存するように変更
    最長共通部分長を関数内で計算するように変更
    4/5 のテストデータを使用してプロファイリングすると実効時間は 5.6秒
    """
    X = ' ' + X
    Y = ' ' + Y
    m = len(X)
    n = len(Y)
    max_lcs = 0

    pre_row = c[0]
    for i in range(1, m):
        row = c[i]
        XX = X[i]
        for j, YY in enumerate(Y):
            if XX == YY:
                pr_j1 = pre_row[j - 1]
                row[j] = pr_j1 + 1
                if pr_j1+1 > max_lcs:
                   max_lcs = pr_j1 + 1
            else:
                pr_j = pre_row[j]
                r_j1 = row[j-1]
                if pr_j >= r_j1:
                    row[j] = pr_j
                else:
                    row[j] = r_j1
        pre_row = row
    return max_lcs


if __name__ == '__main__':
    # データの入力
    num = int(input())
    #f = open('input.txt')
    #num = int(f.readline())

    for _ in range(num):
        X = input().strip()
        Y = input().strip()

        # 処理の実行
        result = calc_lcs4(X, Y, prep_array(X, Y))

        # 結果の表示
        print(result)




Measured memory_bytes: 31056
#include<stdio.h>
#include<stdlib.h>
char mozi[300];
int cnt=0;
int stack[100];
int sp=0;

void push(int i){
	stack[sp]=i;
	sp++;
}
int pop(){
	sp--;
	return stack[sp];
}

int main(){
	char c;
	int a1,a2,i,num;
	
	while( scanf("%s",&mozi) != EOF){
		if(mozi[0]=='+'){
			a2 = pop();a1 = pop();push(a1+a2);
		}else if(mozi[0] == '-'){
			a2 = pop();a1 = pop();push(a1-a2);
		}else if(mozi[0] == '*'){
			a2 = pop();a1 = pop();push(a1*a2);
		}else push(atoi(mozi));
		
	}
	
	printf("%d\n",pop());
	return 0;
	
}

Measured memory_bytes: 1796
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	if (n > k * 2) {

	}
	return fac[n] / (fac[k] * fac[n - k]);
}

ll dp[201010][2];
ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };

//long longしか使わない
//素数は1より大きい
int main() {
	ll n, p;
	cin >> n >> p;
	if (n == 1) {
		cout << p << endl;
		return 0;
	}
	map<ll, ll>mp;
	ll target = p;
	for (ll i = 2;i <= sqrt(p)+1;++i) {
		if (target % i == 0) {
			while (target % i == 0) {
				mp[i]++;
				target /= i;
			}
		}
	}
	ll res = 1;
	for (auto p : mp) {
		ll x = p.first;
		ll y = p.second;
		if (y >= n) {
			res *= pow(x, y / n);
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3968
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();

		if (N <= 999) {
			System.out.println("ABC");
		} else {
			System.out.println("ABD");
		}
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 27076
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> X(3);
  int count5 = 0;
  int count7 = 0;
  for (int i = 0; i < 3; i++) {
    cin >> X.at(i);
  }
  for (int i = 0; i < 3; i++) {
    if (X.at(i) == 5) {
      count5++;
    }
    if (X.at(i) == 7) {
      count7++;
    }
  }
  if (count5 == 2 && count7 == 1) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
N = gets.to_i
x = y = z = t = 0
N.times{
  s = gets.chomp
  case
  when s.match(/^B.*A$/); z += 1
  when s.match(/^B/); x += 1
  when s.match(/A$/); y += 1
  end
  t += s.scan("AB").size
}

p ([x,y].max == 0 ? [z - 1, 0].max : [x,y].min + z) + t

Measured memory_bytes: 2684
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
typedef pair<int,int>pii;
#define fi first
#define se second
const int MN=505;
int n,a[MN][MN];
pii loc[MN][MN];
int main(){
	scanf("%d",&n);
	if(n<=500){
		printf("%d\n",n);
		for(reg int i=1;i<=n;i++,puts(""))
			for(reg int j=1;j<=n;j++)
				printf("%d ",i);
		return 0;
	}
	reg int N=500;printf("%d\n",N);
	for(reg int i=1;i<=N;i++)
		for(reg int j=1,t=i;j<=N;j++,t=t%N+1)
			loc[t][i]=make_pair(i,j),a[i][j]=t;
	for(reg int i=N+1;i<=n;i++)
		for(reg int j=1;j<=N;j+=2)
			a[loc[i-N][j].fi][loc[i-N][j].se]=i;
	for(reg int i=1;i<=N;i++,puts(""))
		for(reg int j=1;j<=N;j++)
			printf("%d ",a[i][j]);
	return 0;
}

Measured memory_bytes: 4224
a = list(input())
for i in range(4):
	a[i] = int(a[i])
s = [0,0]
s[0] = a[0]* 10 +a[1]
s[1] = a[2] * 10 + a[3]
def judge(a):
	if 0<a<13:
		return True
	else:
		return False
if judge(s[0]):
	if judge(s[1]):
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	if judge(s[1]):
		print("YYMM")
	else:
		print("NA")



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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int N = fs.nextInt(), M = fs.nextInt();
		int info[][] = new int[M][3];
		for(int i=0;i<M;i++) {
			int x = fs.nextInt()-1, y = fs.nextInt()-1, z = fs.nextInt();
			info[i][0] = x;
			info[i][1] = y;
			info[i][2] = z;
		}
		
		UnionFind uf = new UnionFind(N);
		for(int i=0;i<M;i++) {
			int x = info[i][0];
			int y = info[i][1];
			int z = info[i][2];
			uf.unite(x, y);
		}
		int ans = uf.groupnum();
		System.out.println(ans);
		
	}
}

class UnionFind{
	int parent[];
	UnionFind(int n){
		parent = new int[n];
		Arrays.fill(parent, -1);
	}
	void unite(int x, int y) {
		if(root(x)==root(y))return;
		if(size(x)<size(y))unite(y,x);
		else {
			parent[root(y)] -= size(x);
			parent[root(x)] = root(y);
		}
	}
	int size (int x) {
		return -parent[root(x)];
	}
	
	int root(int x) {
		if(parent[x]<0)return x;
		return parent[x] = root(parent[x]);
	}
	
	int groupnum() {
		int res = 0;
		for(int t:parent) {
			if(t<0)res++;
		}
		return res;
	}
	
	
}


//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 46948
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>


int main() {

    int N, M;
    std::cin >> N >> M;
    std::vector<int> K;
    std::vector<int> P;

    for (int i = 0; i < M; ++i) {
        int k;
        std::cin >> k;

        int S = 0;
        for (int j = 0; j < k; ++j) {
            int s;
            std::cin >> s;
            S = S | (1 << (s-1));
        }
        K.push_back(S);
    }

    for (int l = 0; l < M; ++l) {
        int p;
        std::cin >> p;
        P.push_back(p);
    }
    
    int cnt = 0;
    for (int bit = 0; bit < (1 << N); ++bit) {
        bool ok = true;
        for (int i = 0; i < M; ++i) {


            if ((__builtin_popcount(bit & K[i]) % 2) != P[i]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            cnt += 1;
        }
    }

    std::cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
MOD = 1000000007
 

a = set()

for m in range(M):
    aa = int(input())
    a.add(aa)

x = [0 for n in range(N+1)]
x[0] = 1
for n in range(1,N+1):
    if n in a or (n-1 in a and n-2 in a):
        x[n] = 0
    elif n-1 in a:
        x[n] = x[n-2]%MOD
    elif n-2 in a:
        x[n] = x[n-1]%MOD
    else:
        x[n] = (x[n-1] + x[n-2])%MOD

print(x[N])

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define l_l pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

class Cycle {
 private:
  ll _index = 1;
  ll _cycle_entrance = -1;
  ll _cycle_length = -1;
  ll _cycle_sum = 0;

  vector<ll> _list;
  map<ll, ll> _m;

 public:
  Cycle() {
    _list.emplace_back(-1);  // dummy
  }

  bool add(ll value) {
    if (_m[value]) {
      _cycle_entrance = _m[value];
      _cycle_length = _index - _cycle_entrance;

      ll cycle_sum = 0;
      for (ll i = 0; i < _cycle_length; i++) {
        ll index = _cycle_entrance + i;
        cycle_sum += _list[index];
      }
      _cycle_sum = cycle_sum;

      return false;
    }

    _m[value] = _index;
    _list.emplace_back(value);
    _index++;
    return true;
  }

  ll sum(ll length) {
    ll result = 0;
    ll rest = length;

    for (ll i = 1; i < _cycle_entrance; i++) {
      if (rest < -0) {
        break;
      }
      result += _list[i];
      rest--;
    }
    ll cycle_num = rest / _cycle_length;
    result += (_cycle_sum * cycle_num);

    rest = rest % _cycle_length;

    for (ll i = 0; i < rest; i++) {
      ll index = _cycle_entrance + i;
      result += _list[index];
    }
    return result;
  }
};

int main() {
  ll N, X, M;
  scanf("%lld %lld %lld", &N, &X, &M);

  auto cycle = Cycle();

  ll x = X;
  for (;;) {
    if (!cycle.add(x)) {
      break;
    }
    x = x * x % M;
  }

  ll sum = cycle.sum(N);
  cout << (sum) << endl;
}


Measured memory_bytes: 5704
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    string s;
    cin >> s;
    rep(i, s.size()) {
        if(!(i%2)) cout << s[i];
    }
    
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
inline ll read(){
	ll res=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){res=(res<<3)+(res<<1)+ch-'0';ch=getchar();}
	return res*f;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10|'0');
}
struct Node{
	int id,j;
}e[100003];
bool cmp(Node a,Node b){
	return a.id<b.id;
}
signed main(){
	int n=read();
	for(int i=1;i<=n;i++) e[i].id=read(),e[i].j=i;
	sort(e+1,e+1+n,cmp);
	for(int i=1;i<=n;i++) cout<<e[i].j<<" ";
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define f first
#define s second
#define ll long long
using namespace std;
int main(){
	int r, c, k, ans=0;
	cin>>r>>c>>k;
	vector<string>A(r);
	for(auto &s:A)cin>>s;
	for(int maskr=0; maskr<(1<<r); maskr++){
		for(int maskc=0; maskc<(1<<c); maskc++){
			int e=0;
			for(int i=0; i<r; i++){
				for(int j=0; j<c; j++){
					if(A[i][j]=='#'&&!(maskr&(1<<i))&&!(maskc&(1<<j)))e++;
				}
			} 
			if(e==k)ans++;
		}
	}
	cout<<ans<<"\n";
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define inf (long long)(1e9)
using namespace std;

struct data {
  long long r, a, w, t;
};

bool asc(const data &l, const data &r) {
  return l.t + l.r > r.t + r.r;
}

long long n;
vector<data> v;
long long dp[2005][4005][2] = {0};

long long solve();

int main() {
  cin >> n;
  v.resize(n);
  for(int i = 0; i < n; ++i)
    cin >> v[i].r >> v[i].a >> v[i].w >> v[i].t;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  sort(v.begin(), v.end(), asc);
  long long ans = 0;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j <= 4000; ++j) dp[i][j][1] = -inf;
  for(int i = 0; i < n; ++i) {
    for(int j = 4000; j >= 0; --j) {
      dp[i + 1][j][0] = max(dp[i][j][0], dp[i][j][1]);
      if(min(v[i].t, j - v[i].r) >= 0) {
        dp[i][min(v[i].t, j - v[i].r)][1] =
            max(dp[i][min(v[i].t, j - v[i].r)][1],
                dp[i][j][0] + v[i].a);
        if(dp[i][j][1] != -inf)
          dp[i][min(v[i].t, j - v[i].r)][1] =
              max(dp[i][min(v[i].t, j - v[i].r)][1],
                  dp[i][j][1] + v[i].w);
      }
      if(j != 0) ans = max({ans, dp[i][j][0], dp[i][j][1]});
    }
  }
  return ans;
}



Measured memory_bytes: 128448
'use strict';

const receive = () => require('fs').readFileSync('/dev/stdin', 'utf8').split(/\s/);

const main = input => {
  const K = Number(input[0]);
  const ans = K % 2 == 0 ? (K / 2) ** 2 : (K - 1) / 2 * ((K - 1) / 2 + 1)
  console.log(ans);
};

main(receive());


Measured memory_bytes: 7820
n = int(input())
a = list(map(int, input().split()))
 
count = 0
flag = True
while flag:
    for i in range(len(a)):
        if a[i] % 2 == 1:
            flag = False
        else:
            a[i] //= 2
    count += 1
 
print(count - 1)

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		int c = saori.saori_hayami();
		int x = saori.saori_hayami();
		int ans = 0;
		int sum = 0;
		for(int i = 0;i <= a;i++){
			for(int j = 0;j <= b;j++){
				for(int k = 0;k <= c;k++){
					sum = 500*i + 100*j + 50*k;
					if(sum == x){
						ans++;
					}
					sum = 0;
				}
			}
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21332