akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <vector>

const long mod = 1000000000 + 7;

long mod_pow(long a, long x, long m)
{
  if (x <= 0) return 1;
  return x & 1
      ? a * mod_pow(a, x - 1, m) % m
      : mod_pow(a * a % m, x >> 1, m);
}

long mod_combi(long n, long k, long m)
{
  long nume = 1;
  long deno = 1;
  for (long i = 0; i < k; ++i) {
    nume = nume * (n - i) % m;
    deno = deno * (k - i) % m;
  }
  return nume * mod_pow(deno, m - 2, m) % m;
}

long mod_sub(long a, long b, long m)
{
  const auto r = (a - b) % m;
  return r >= 0 ? r : r + m;
}

long solve(long n, long a, long b)
{
  return mod_sub(
      mod_sub(
        mod_sub(mod_pow(2, n, mod), 1, mod),
        mod_combi(n, a, mod),
        mod),
      mod_combi(n, b, mod),
      mod);
}

int main()
{
  long n, a, b;
  std::cin >> n >> a >> b;

  std::cout << std::setprecision(20);
  std::cout << solve(n, a, b) << std::endl;
}


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

int main() {
  while (true) {
    std::string s;
    std::cin >> s;
    if (s == "0")
      return 0;
    int sum = 0;
    for (int i = 0; i < s.length(); i++) {
      sum += (s[i] - '0');
    }
    std::cout << sum << std::endl;
  }
}



Measured memory_bytes: 3224
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'


void solve(){
  int n;
  cin >> n;
  vector<pair<int,int>> a(n);
  forn(i,n) {
    cin >> a[i].ff;
    a[i].ss = i + 1;
  }
  sort(all(a));
  forn(i,n) cout << a[i].ss << ' ';

}

int main() {
  ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 

1
322123


n - 1
0 ... (n-1) [res ... res] S - (n-1) ... S


 */

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

#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int n;
string s;
int main()
{
    ios_base::sync_with_stdio(false);

    int cnt = 0;
    cin >> n >> s;
    for(int i = 0; i < n; i ++){
        int j = i;
        while(j < n && s[i] == s[j]){
            j ++;
        }
        cnt ++;
        i = j - 1;
    }
    cout << cnt << "\n";
}


Measured memory_bytes: 512
using System;

public class Hello{
    public static void Main(){
        int i = 1;
        int x = 1;
        while(x != 0){
            x = int.Parse(Console.ReadLine());
            if(x != 0){
              Console.WriteLine("Case "+i+": "+x);
              i = i + 1;
            }
        }
    }
}



Measured memory_bytes: 19852
import sys
while True:
 h,w=map(int,raw_input().split())
 if h==0 and w==0:break
 for i in range(0,h):
  for j in range(0,w):
  
   if (i+j)%2==0:sys.stdout.write("#")
   else :sys.stdout.write(".")
  
  print ""
 print ""

Measured memory_bytes: 4212
#include<iostream>
#include<cmath>

using namespace std;
int main() {
	int K, S;
	cin >> K >> S;
	int count = 0;
	for (int x = 0; x <= K; x++) {
		for (int y = 0; y <= K&&S>=x+y; y++) {
			if (S - x - y <= K)count++;
		}
	}
	cout << count << endl;
}

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

struct DP {
	pair<int, int> maxi[2];
	void init(int val, int id) {
		maxi[0] = {val, id};
		maxi[1] = {0, -1};
	}
	void chmax(DP &e) {
		set<pair<int, int>> ret;
		ret.insert(maxi[0]);
		ret.insert(maxi[1]);
		ret.insert(e.maxi[0]);
		ret.insert(e.maxi[1]);
		maxi[0] = *ret.rbegin();
		ret.erase(maxi[0]);
		maxi[1] = *ret.rbegin();
	}
};

int main() {
	int n; cin >> n;
	const int N = 1 << n;
	int a[N];
	for(int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	DP dp[N];
	for(int i = 0; i < N; ++i) {
		dp[i].init(a[i], i);
	}
	for(int i = 0; i < n; ++i) {
		for(int mask = 0; mask < N; ++mask) {
			if((mask >> i) & 1) {
				dp[mask].chmax(dp[mask ^ (1 << i)]);
			}
		}
	}
	int ans = 0;
	for(int i = 1; i < N; ++i) {
		ans = max(ans, dp[i].maxi[0].first + dp[i].maxi[1].first);
		cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 8192
import sys

for line in sys.stdin:
  a, op, b = line.split()
  a = int(a)
  b = int(b)

  if op == '?':
    break

  if op == '+':
    print(a+b)
  elif op == '-':
    print(a-b)
  elif op == '*':
    print(a*b)
  elif op == '/':
    print(a//b)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int h, n; cin >> h >> n;
	int sum = 0, a;
	REP(i, n) {
		cin >> a;
		sum += a;
	}
	if (sum >= h)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
        int i,n,a[26]={0};
        char s[27];

        scanf("%s",s);
        n=strlen(s);
        for(i=0;i<n;i++)
                a[s[i]-'a']++;

        for(i=0;i<26;i++)
                if(a[i]>1){
                        printf("no");
                        return 0;
                }

        printf("yes");
        return 0;
}


Measured memory_bytes: 1716
n = int(input())
s = input()

ans = 0
for i in range(1, n):
    head = s[:i]
    tail = s[i:]
    cnt = 0
    for i in range(26):
        c = chr(ord('a') + i)
        if c in head and c in tail:
            cnt += 1

    ans = max(ans, cnt)

print(ans)

Measured memory_bytes: 3060
#include<stdio.h>


int main(void)
{
    int n,t,i;
    int c[100][2];
    int min=1001;
    scanf("%d%d",&n,&t);
    for(i=0;i<n;i++){
        scanf("%d%d",&c[i][0],&c[i][1]);
    }
    for(i=0;i<n;i++){
        if(c[i][1]<=t){
            if(min>c[i][0]) min=c[i][0];
        }
    }
    if(min==1001){
        printf("TLE\n");
    }
    else printf("%d\n",min);


    return 0;
}


Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
D = [A[i]-B[i] for i in range(N)]
D.sort()
s = 0
for i in range(N):
    if D[i] >= 0:
        break
    s -= D[i]
if s == 0:
    print(0)
else:
    D = [x for x in D if x>0]
    D.sort()
    D.reverse()
    pos = False
    for j in range(len(D)):
        if s-D[j] <= 0:
            pos = True
            break
        s -= D[j]
    if pos:
        print(i+j+1)
    else:
        print(-1)

Measured memory_bytes: 18292
#include <stdio.h>

int selectsort(int a[],int N){
  int i,j,s,z,minj;
  s=0;
  z=0;
  for(i=0;i<N-1;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(a[j]<a[minj]){
        minj=j;
      }
    }
    z=a[i];
    a[i]=a[minj];
    a[minj]=z;
    if(i!=minj){
      s++;
    }
  }
  return s;
}

int main(void)
{
  int i,N,s,a[100];
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
  }
  s=selectsort(a,N);
  for(i=0;i<N;i++){
    if(i>0){
      printf(" ");
    }
    printf("%d",a[i]);
  }
  printf("\n");
  printf("%d\n",s);

  return 0;
}

Measured memory_bytes: 1796
# coding: utf-8
# Your code here!

n=int(input())
SP=[]
ind=1
for _ in range(n):
    s,p=(i for i in input().split())
    p=int(p)
    SP.append([s,p,ind])
    ind+=1
    
SP=sorted(SP, key=lambda x: (x[0],-x[1]))
for res in SP:
    print(res[2])

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

using namespace std;

int n, m;
const int N = 110;
vector<int> G[N];
int d[N], f[N];
int timestamp = 1;

void dfs(int u) {
    d[u] = timestamp++;
    for (int i = 0; i < G[u].size(); i++) {
        int v = G[u][i];
        if (d[v] > 0) continue;
        dfs(v);
    }
    f[u] = timestamp++;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int u, k;
        cin >> u >> k;
        int v;
        for (int j = 0; j < k; j++) {
            cin >> v;
            if (u != v)
            G[u].push_back(v);
        }
    }

    for (int u = 1; u <= n; u++) {
        if (d[u] == 0) dfs(u);
    }

    for (int u = 1; u <= n; u++) {
        cout << u << " " << d[u] << " " << f[u] << endl; 
    }

    return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int32 n = s.size();
  int32 a,b;
  REP(i,n){
    if(s[i] == 'A'){
      a = i;
      break;
    }
  }
  FORR(i,n-1,0){
    if(s[i] == 'Z'){
      b = i;
      break;
    }
  }
  ANS(b-a+1);
  return 0;
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N,T;
    cin >>N>>T;

    vector<int> t(N);
    rep(i,N) cin >> t[i];
    
    ll ans=0;
    repd(i,1,N){
        ans+=min(t[i]-t[i-1],T);
    }
    ans+=T;

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int n=s.size();
	if(s.back()=='1' || s[0]=='0'){
		cout<<-1<<endl;
		return 0;
	}
	rep(i,n-1){
		if(s[i]!=s[n-2-i]){
			cout<<-1<<endl;
			return 0;
		}
	}
	vector<int> ind;
	rep(i,n){
		if(s[i]=='1') ind.push_back(i);
	}
	ind.push_back(n-1);
	int par;
	rep(i,n-1){
		if(s[i]=='1'){
			par=*upper_bound(begin(ind),end(ind),i);
			cout<<i+1<<' '<<par+1<<endl;;
		}else{
			cout<<i+1<<' '<<par+1<<endl;
		}
	}
}

Measured memory_bytes: 1992
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  int N, X, T;
  cin >> N >> X >> T;
  int ans = T * ((N-1) / X + 1);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3644
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            int n = sc.nextInt();
            if(n==0) break;

            int cnt = 0;
            for(int i=1; i<n; i++){
                int sum = 0;
                for(int j=i; j<n; j++){
                    sum += j;
                    if(sum==n) cnt++;
                    if(sum>=n) break;
                }
            }

            System.out.println(cnt);
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 19892
(loop with n = (read)
      with count = 0
      for a from 1 to (round n 2)
      do (incf count #1=(- (floor n a)
                           (if (zerop (mod n a))1 0)))
      ;;do (print (list a n #1# count))
      finally (format t "~A~%" (+ count (- n (round n 2) 1))))

Measured memory_bytes: 24440
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  string str;
  cin >> str;
  int len = str.size();
  int i;
  if(str.at(0) != 'A'){
    cout << "WA" << endl;
    return 0;
  }
  int couc = 0;
  int modec;
  for(i = 2;i < len-1;++i){
    if(str.at(i) == 'C'){
      modec = i;  ++couc;
    }
  }
  if(couc != 1){
    cout << "WA" << endl;
    return 0;
  }
  for(i = 1;i < len;++i){
    if(i == modec){
      continue;
    }else{
      if((int)str.at(i) < 97){
        cout << "WA" << endl;
        return 0;
      }
    }
  }
  cout << "AC" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  string s;
  scan(s);
  int n = s.length();
  int color = s[0] - '0';
  int cnt = 1;
  int ans = 0;
  FOR (i, 1, n) {
    if (s[i] - '0' == color) {
      cnt += 1;
    } else {
      if (cnt > 0) {
        cnt -= 1;
        ans += 2;
      } else {
        color = 1 - color;
        cnt += 1;
      }
    }
  }
  print(ans);

  return 0;
}


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

int main()
{
    ll A;
    long double B;
    cin >> A >> B;
    int C;
    C = 100 * B + 0.5;
    int D = B ;
    D *= 100 ;
    int E = C - D ;

    ll F = E*A ;
    ll G = D*A ;
    ll ans = F+G ;
    ans /= 100 ;
    cout << ans << endl ;
}

Measured memory_bytes: 3728
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
	long long x,k,a,i;
	cin>>x>>k;
	a=1;
	for(i=0;i<x;i++)
	{
		if(a<k)
			a*=2;
		else
			a+=k;
	}
	cout<<a;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define NIL -1

typedef struct node {
    int parent, left, right;
}Node;

Node T[26];

int getSibling(int i){
    if (T[i].parent == NIL || T[T[i].parent].left == NIL ||
                                T[T[i].parent].right == NIL)
        return NIL;
    if (T[ T[i].parent ].left == i)
        return T[ T[i].parent ].right;
    else
        return T[ T[i].parent ].left;
}

int getDegree(int i){
    int num = 0;
    if (T[i].left != NIL)
        num++;
    if (T[i].right != NIL)
        num++;
    return num;
}

int getDepth(int i){
    int num = 0;
    while (T[i].parent != NIL){
        num++;
        i = T[i].parent;
    }
    return num;
}

int getHeight(int i){
    int left, right;
    left = right = 0;
    if (T[i].left != NIL)
        left = getHeight(T[i].left) + 1;
    if (T[i].right != NIL)
        right = getHeight(T[i].right) + 1;
    return left > right ? left : right;
}

void print(int n){
    for (int i = 0; i < n; i++){
        printf("node %d: parent = %d, sibling = %d, degree = %d, ",
                        i, T[i].parent, getSibling(i), getDegree(i));
        printf("depth = %d, height = %d, ", getDepth(i), getHeight(i) );
        if (T[i].parent == NIL)
            printf("root\n");
        else if (getDegree(i) != 0)
            printf("internal node\n");
        else
            printf("leaf\n");
    }
}

int main(){
    int n, num, p;
    scanf("%d", &n);
    for (int i = 0 ; i < n; i++){
        T[i].parent = NIL;
        T[i].left = NIL;
        T[i].right = NIL;
    }
    for(int i = 0; i < n; i++){
        scanf("%d", &num);
        scanf("%d %d", &T[num].left, &T[num].right);
        if (T[num].left != NIL)
            T[T[num].left].parent = num;
        if (T[num].right != NIL)
            T[T[num].right].parent = num;
    }


    print(n);

    return 0;
}
//兄弟节点编号，先找爹，再找和自己不同编号的那个
//度，数非NIL个数
//深度，递归求解?
//高度，从叶往上数?


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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ld long double
#define forn(low,high,i) for(i = low; i < high; i++)
#define forrev(high,low,i) for(i = high; i >= low; i--)
#define all(v) v.begin(),v.end()
#define decimal_digits cout << fixed << setprecision(15);

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int inf = 1e9;
const long long INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(long long a, long long b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(long long a, long long b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(long long a, long long b){a %= mod; b %= mod; return (int)((long long) a * b % mod);}
inline int modexpo(long long a, long long b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(long long a, long long b){return mul(a, modexpo(b, mod - 2));}
inline int inv(long long a){return modexpo(a, mod - 2);}

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre(){ // Reset each global variable (esp. for graphs)
  
}

void solve(){
  int n, i, j, k;
  cin >> n;
  vector<int> a(n), ans(n);
  int total_xor = 0;
  for(i = 0; i < n; i++){
    cin >> a[i];
    total_xor ^= a[i];
  }
  for(i = 0; i < n; i++){
    ans[i] = total_xor ^ a[i];
  }
  for(i = 0; i < n; i++){
    assert(a[i] == (ans[i] ^ total_xor));
  }
  for(i = 0; i < n; i++){
    cout << ans[i] << " \n"[i == n - 1];
  }
}


#define GOOGLE 0
#define MULTIPLE_TC 0

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

  pre();

  int t = 1, T;
  if(MULTIPLE_TC)
    cin >> t;

  for(T = 1; T <= t; T++){
    if(GOOGLE)
      cout << "Case #" << T << ": ";
    solve();
  }

  ktj();
}

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

using namespace std;

const int maxn = 100010;

typedef long long ll;

priority_queue<ll> pq;
map<ll, int> mp;

int n, l[maxn], dep[maxn], sz[maxn], w[maxn], vis[maxn], e_u[maxn], e_v[maxn], tot, e = 0;
ll D[maxn], S[maxn];

struct Edge {
    int v, x;
} E[maxn];

inline void addEdge(int u, int v) {
    E[e].v = v; E[e].x = l[u]; l[u] = e++;
}

void dfs1(int u) {
    sz[u] = 1;
    for (int p = l[u]; p >= 0; p = E[p].x) {
        int v = E[p].v;
        dep[v] = dep[u] + 1;
        dfs1(v);
        sz[u] += sz[v];
    }
}

void dfs2(int u) {
    for (int p = l[u]; p >= 0; p = E[p].x) {
        int v = E[p].v;
        S[v] = S[u] + n - 2 * sz[v];
        dfs2(v);
    }
}

int main() {
    memset(l, -1, sizeof(l));
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%lld", &D[i]);
    for (int i = 1; i <= n; i++) {
        mp[D[i]] = i;
        pq.push(D[i]);
        w[i] = 1;
    }
    vis[0] = 1;
    while (pq.size() > 1) {
        ll v = pq.top(); pq.pop();
        int u = mp[v];
        vis[u] = 1;
        if (!vis[mp[v + 2 * w[u] - n]]) {
            int t = mp[v + 2 * w[u] - n];
            w[t] += w[u];
            addEdge(t, u);
            ++ tot;
            e_u[tot] = t; e_v[tot] = u;
        } else {
            puts("-1");
            return 0;
        }
    }
    int r = mp[pq.top()];
    dfs1(r);
    for (int i = 1; i <= n; i++) S[r] += dep[i];
    dfs2(r);
    for (int i = 1; i <= 1; i++) {
        if (S[i] != D[i]) {
            puts("-1");
            return 0;
        }
    }
    for (int i = 1; i <= tot; i++) printf("%d %d\n", e_u[i], e_v[i]);
    return 0;
}

Measured memory_bytes: 15092
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
  while (true)
  {
    int H, W;
    cin >> H >> W;
    if (!H)
      return 0;

    for (int i = 1; i <= H; i++)
    {
      for (int j = 1; j <= W; j++)
      {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
}

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

#define ll long long
#define db double
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ino freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);

#define fr(i,n) for(i=0;i<n;i++)
#define frs(i,a,n) for(i=a;i<n;i++)
#define frv(i,n) for(i=n-1;i>=0;i--)

#define ne cout<<"\n";
#define cas(i) cout<<"Case #"<<i<<": "

#define vi vector <int>
#define vpi vector <pair <int,int> >
#define vpin(v,a,b) v.push_back(make_pair(a,b))
#define vsort(v) sort(v.begin(),v.end());
#define all(v) ((v).begin()),((v).end())
#define sz(v) ((int)((v).size()))

#define todegree(rad) rad*(180.0/pi)
#define isnttriangle(a,b,c) (a+b<c||a+c<b||b+c<a)
#define pi acos(-1)
#define siz 1000


int main()
{
    int A,B,num,cn;
    cin>>A>>B;
    cn=0;
    num=1;
    while(num<B)
    {
        num+=A-1;
        cn++;
    }
    cout<<cn<<"\n";

    return 0;
}



Measured memory_bytes: 3560
a,b,c,d,e,f = 1,2,3,4,5,6

def North():
    global a,b,c,d,e,f
    a,b,c,d,e,f =b,f,c,d,a,e
def South():
    global a,b,c,d,e,f
    a,b,c,d,e,f =e,a,c,d,f,b
def East():
    global a,b,c,d,e,f
    a,b,c,d,e,f =d,b,a,f,e,c
def West():
    global a,b,c,d,e,f
    a,b,c,d,e,f =c,b,f,a,e,d
def Right():
    global a,b,c,d,e,f
    a,b,c,d,e,f =a,c,e,b,d,f
def Left():
    global a,b,c,d,e,f
    a,b,c,d,e,f =a,d,b,e,c,f


x = int(raw_input())
while x > 0:
    y = range(x)
    z =1
    a,b,c,d,e,f =1,2,3,4,5,6
    for i in y :
        In = raw_input()
        if In == "North":
            North()
            z +=a
        elif In == "South":
            South()
            z +=a
        elif In == "East":
            East()
            z +=a
        elif In == "West":
            West()
            z +=a
        elif In == "Right":
            Right()
            z +=a
        elif In == "Left":
            Left()
            z +=a
    print z
    x = int(raw_input())

Measured memory_bytes: 4444
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int (i)=(a);(i)<(int)(b);(i)++)
#define RREP(i,a,b) for(int (i)=(a);(i)>=(int)(b);(i)--)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;

const int Maxn = 1000010;

class Combination{
    public:
        ll M;
        vector<ll> fact;
        vector<ll> finv;
        vector<ll> inv;

        Combination(int MAX_N, ll p);
        ll comb(int n, int k);
};

Combination::Combination(int MAX_N, ll p){
    fact = vector<ll>(MAX_N);
    finv = vector<ll>(MAX_N);
    inv = vector<ll>(MAX_N);
    fact[0] = fact[1] = finv[0] = finv[1] = inv[1] = 1;

    M = p;
    REP(i,2,MAX_N){
        fact[i] = i * fact[i - 1] % M;
        inv[i] = M - inv[M % i] * (M / i) % M;
        finv[i] = inv[i] * finv[i - 1] % M;
    }
}

ll Combination::comb(int n, int k){
    if (n < k || n < 0 || k < 0) return 0;
    return fact[n] * (finv[k] * finv[n - k] % M) % M;
}

int main(){
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    Combination c(Maxn, MOD);
    ll ans = 0;
    REP(i,b,w){
        ll temp = c.comb(h - a - 1 + i, h - a - 1);
        (temp *= c.comb(a - 1 + w - i - 1, a - 1)) %= MOD;
        (ans += temp) %= MOD;
    }

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

Measured memory_bytes: 23680
s = str(input())
if s == 'SUN':
    print(7)
elif s == 'MON':
    print(6)
elif s == 'TUE':
    print(5)
elif s == 'WED':
    print(4)
elif s == 'THU':
    print(3)
elif s == 'FRI':
    print(2)
elif s == 'SAT':
    print(1)

Measured memory_bytes: 3060
/**

太郎が花子と一緒にトランプ遊びをしようとしたところ、52枚あるはずのカードが n 枚のカードしか手元にありません。これらの n 枚のカードを入力として、足りないカードを出力するプログラムを作成して下さい。

太郎が最初に持っていたトランプはジョーカーを除く52枚のカードです。

52枚のカードは、スペード、ハート、クラブ、ダイヤの４つの絵柄に分かれており、各絵柄には13のランクがあります。

  */
//S,スペード、H,ハート、C,クラブ、D,ダイヤ
/*sucannerクラス使うためにインポート*/
import java.util.Scanner;

class Main {
	// プログラムのエントリポイント
	public static void main(String[] args) {
		// 入力ストリームの生成
		Scanner sc = new Scanner(System.in);
		// 現在手元にある枚数を受け取る
		int intKazu = sc.nextInt();
		// カード全５２枚の配列をつくる
		int card[][] = new int[4][13];
		// カードの絵面と数字を受け取る変数を宣言
		String strEzura = "";
		int intSuuji = 0;

		// 手元にある枚数の数だけ処理を繰り返す
		for (int i = 0; i < intKazu; i++) {
			// 絵面、数字をうけとる
			strEzura = sc.next();
			intSuuji = sc.nextInt();
			// 受け取った絵面、数字の配列に１を入力する。
			// equals : 2つの変数が持っているオブジェクトが同一か判断するメソッド
			if (strEzura.equals("S")) {
				card[0][intSuuji - 1] = 1;
			} else if (strEzura.equals("H")) {
				card[1][intSuuji - 1] = 1;
			} else if (strEzura.equals("C")) {
				card[2][intSuuji - 1] = 1;
			} else if (strEzura.equals("D")) {
				card[3][intSuuji - 1] = 1;
			}
		}

		//処理を絵面の数４、カードの数字１３回繰り返す
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 13; j++) {
				//配列に値が入ってない場合処理を実行する
				if (card[i][j] == 0){
					//絵面の数字が0,1,2,3いずれかのときに表示する
					//数字のずれを調整するためｊに＋１して表示
					if(i == 0){
						System.out.println("S " + (j + 1));
					}else if ( i == 1){
						System.out.println("H " + (j + 1 ));
					}else if ( i == 2) {
						System.out.println("C " + (j + 1 ));
					}else if ( i == 3) {
						System.out.println("D " + (j + 1 ));
					}

				}
			}
		}
	}
}

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

using namespace std;

int main() {
    int N, K, temp;
    cin >> N >> K;
    vector<int> h(N);
    for(int i = 0; i < N; i++) {
        cin >> h[i];
    }
    vector<int> dp(N, INT_MAX);
    dp[0] = 0;
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j <= i + K; j++) {
            if(j < N) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));     
            }
        }
    }
    cout << dp[N-1] << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
typedef unsigned long long ull;


int main(){
	ull d, ans = 0;
	while(cin >> d){
		for(int i = 1; 600/d > i; i++){
			ans += (d*i*d*i*d);
		}
		cout << ans << endl;
		ans = 0;
	}
}

Measured memory_bytes: 1144
/*
Author: CNYALI_LK
LANG: C++
PROG: A.cpp
Mail: cnyalilk@vip.qq.com
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG printf("Passing [%s] in LINE %lld\n",__FUNCTION__,__LINE__)
#define Debug debug("Passing [%s] in LINE %lld\n",__FUNCTION__,__LINE__)
#define all(x) x.begin(),x.end()
using namespace std;
const double eps=1e-8;
const double pi=acos(-1.0);
typedef long long ll;
typedef pair<ll,ll> pii;
template<class T>ll chkmin(T &a,T b){return a>b?a=b,1:0;}
template<class T>ll chkmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
#define min mmin
#define max mmax
#define abs aabs
ll read(){
	ll s=0,base=1;
	char c;
	while(!isdigit(c=getchar()))if(c=='-')base=-base;
	while(isdigit(c)){s=s*10+(c^48);c=getchar();}
	return s*base;
}
char WritellBuffer[1024];
template<class T>void write(T a,char end){
	ll cnt=0,fu=1;
	if(a<0){putchar('-');fu=-1;}
	do{WritellBuffer[++cnt]=fu*(a%10)+'0';a/=10;}while(a);
	while(cnt){putchar(WritellBuffer[cnt]);--cnt;}
	putchar(end);
}
int main(){
#ifdef cnyali_lk
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
#endif
	ll x,y;
	x=read();y=read();
	ll s=0;
	while(x<=y){
		++s;
		x<<=1;
	}
	write(s,'\n');
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <string.h>
#include <limits.h>
using namespace std;
typedef long long ll;

ll INF=1e18;
struct edge { ll from, to, cost; };

edge es[2005];
ll d[1005];
ll v, e;
bool neg = false;

void shortest_path(int s) {
    for (int i = 0; i < v; i++) d[i] = INF;
    d[s] = 0;
    int l;
    for (int i = 0; i < v; i++) {
        bool update = false;
        for (int j = 0; j < e; j++) {
            edge e = es[j];
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                update = true;
                if (i == v - 1 && d[v - 1] != l) {
                    neg = true;
                }
            }
        }
        if (!update) break;
        l = d[v - 1];
    }
}

int main(void){
    cin >> v >> e;
    for (int i = 0; i < e; i++) {
        ll pt;
        cin >> es[i].from >> es[i].to >> pt;
        es[i].from--;  es[i].to--;
        es[i].cost = -pt;
    }
    
    shortest_path(0);
    if (neg) cout << "inf" << endl;
    else {
        cout << -d[v - 1] << endl;
    }
    
}

Measured memory_bytes: 256
def triangle?(a, b, c)
  a <= b + c && b <= c + a && c <= a + b
end

def valid?(a, b, c)
  triangle?(a, b, c) || triangle?(a + 1, b, c)
end

def calc(rear, front, west, east, north, south, best)
  path = ''
  loop do
    x = best ? best[path.size] : 'Z'

    a = rear + front
    b = west + east
    c = north + south

    return path if a + b + c == 0

    if east > 0 && valid?(b - 1, c, a)
      return best if x < 'E'
      best = nil if x > 'E'
      rear, front, west, east = east - 1, west, rear, front
      path << 'E'
      next
    end
    if north > 0 && valid?(c - 1, a, b)
      return best if x < 'N'
      best = nil if x > 'N'
      rear, front, north, south = north - 1, south, front, rear
      path << 'N'
      next
    end
    if south > 0 && valid?(c - 1, a, b)
      return best if x < 'S'
      best = nil if x > 'S'
      rear, front, north, south = south - 1, north, rear, front
      path << 'S'
      next
    end
    if west > 0 && valid?(b - 1, c, a)
      return best if x < 'W'
      best = nil if x > 'W'
      rear, front, west, east = west - 1, east, front, rear
      path << 'W'
      next
    end

    throw 'error'
  end
end

def find(target)
  best = nil
  target.permutation(6).to_a.uniq.each do |rear, front, west, east, north, south|
    a = rear + front
    b = west + east
    c = north + south
    if valid?(a, b, c)
      best = calc(rear, front, west, east, north, south, best)
    end
  end
  best
end

loop do
  target = STDIN.gets.split.map!(&:to_i)
  break if target.max == 0
  p, q = STDIN.gets.split.map!(&:to_i)
  result = find(target)
  puts result ? result[p-1...q] : 'impossible'
end

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long
#define db double
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T &a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T &a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T a) { return 1ll * a * a; }
template <class T> void compress(T &a){
  sort(all(a)); a.resize(unique(all(a)) - a.begin());  
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 1e9;
const int MOD = 1e9+7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

int main()
{
  fastio;
  int x, y; cin >> x >> y;
  for (int i = 0; i <= x; i++){
    if (i * 2 + (x - i) * 4 == y) return cout << "Yes", 0;
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 3588
#!/usr/bin/env python3
# -*- Coding: utf-8 -*-

import sys
from collections import Counter


input = sys.stdin.readline
MOD = 998244353


def main():
    N = int(input())
    D = [int(i) for i in input().split()]
    c = Counter(D)
    k = list(c.keys())
    k.sort()
    if D[0] != 0 or c[0] != 1:
        print(0)
        sys.exit(0)

    ans = 1
    for i, n in enumerate(k):
        if i != n:
            print(0)
            sys.exit(0)
        if n == 0:
            continue
        ans *= c[n-1]**c[n]

    print(ans % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62884
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int n,a,b,e=0;
  cin>>n>>a>>b;
  for(int i=1;i<=n;i++){
    int c=i,d=0;
    while(c){
      d+=c%10;
      c/=10;
    }
    if(d>=a&&d<=b) e+=i;
  }
  cout<<e;
}


Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	int n,a,t=0;
	cin>>n;
	rep(i,n){
		cin>>a;
		if(a%2>0) t++;
	}
	if(t%2==0) cout<<"YES"<<endl;else cout<<"NO"<<endl;
}


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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

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

#define si(a)           scanf("%d",&a)
#define sii(a,b)        scanf("%d %d",&a,&b)
#define siii(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define sl(a)           scanf("%lld",&a)
#define sll(a,b)        scanf("%lld %lld",&a,&b)
#define slll(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)

#define un(x)           x.erase(unique(all(x)), x.end())
#define xx              first
#define yy              second
#define pb              push_back
#define mp              make_pair
#define all(v)          v.begin(),v.end()
#define D(x)            cerr << #x " = " << x << '\n'
#define DBG             cerr << "Hi!" << '\n'

#define CLR(a)          memset(a,0,sizeof(a))
#define SET(a)          memset(a,-1,sizeof(a))

#define PI              acos(-1.0)

//inline int setBit(int n,int pos) { return n = n | (1 << pos); }
//inline int resetBit(int n,int pos) { return n = n & ~(1 << pos); }
//inline bool checkBit(int n,int pos) { return (bool)(n & (1 << pos)); }
//inline int countBit(ll n) { return __builtin_popcountll(n); }


//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction

/******************************************************************************************/

const int MAX = 3010;
const int INF = 0x3f3f3f3f;
//const double inf = 1.0/0.0;
//const int MOD = 1000000007;

int ara[MAX];
ll dp[MAX][MAX];

ll call(int L,int R) {
    if(L>R) return 0;
    if(dp[L][R]!=-1) return dp[L][R];
    ll ret = max(ara[L]-call(L+1,R),ara[R]-call(L,R-1));
    return dp[L][R] = ret;
}


int main() {
//    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    int n;
    si(n);
    for(int i=1;i<=n;i++) si(ara[i]);

    SET(dp);
    cout << call(1,n) << endl;

    return 0;
}



Measured memory_bytes: 71168
import numpy as np
#input
S = str(input())
ans = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "1":
            ans += 1
    else:
        if S[i] == "0":
            ans += 1
print(min(ans,len(S)-ans))

Measured memory_bytes: 21380
// 2013/11/25 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

const int INF = 100000;

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;

		if(n==0&&m==0)
			break;

		int C[100][100];
		int T[100][100];
		for(int i=0; i<m; i++){
			for(int j=0; j<m; j++){
				if(i==j){
					C[i][j] = T[i][j] = 0;
				}
				else{
					C[i][j] = T[i][j] = INF;
				}
			}
		}

		for(int i=0; i<n; i++){
			int a, b, c, t;
			cin >> a >> b >> c >> t;

			C[a-1][b-1] = C[b-1][a-1] = c;
			T[a-1][b-1] = T[b-1][a-1] = t;
		}

		for(int k=0; k<m; k++){
			for(int i=0; i<m; i++){
				for(int j=0; j<m; j++){
					C[i][j] = min(C[i][j], C[i][k]+C[k][j]);
					T[i][j] = min(T[i][j], T[i][k]+T[k][j]);
				}
			}
		}

		int k;
		cin >> k;

		for(int i=0; i<k; i++){
			int p, q, r;
			cin >> p >> q >> r;

			if(r==0){
				cout << C[p-1][q-1] << endl;
			}
			else{
				cout << T[p-1][q-1] << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1236
fun main() {
  val N = readInt()
  val S = (1..N).map { readString() }
  println(S.toSet().size)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }


Measured memory_bytes: 75080
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:isize,
    b:isize,
    c:isize,
    }
    println!("{}",if a==b&&b==c{"1"}else if a==b||b==c||a==c{"2"}else{"3"})
}

Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
char a[52],b[52];
int main()
{
    cin>>a;
    cin>>b;
    int la=strlen(a),lb=strlen(b);
    int l=min(la,lb),ll=max(la,lb);
    for(int i=0;i<=l-1;i++)
        cout<<a[i]<<b[i];
    if(la>lb)
        for(int i=l;i<=ll-1;i++)
            cout<<a[i];
    else for(int i=l;i<=ll-1;i++)
            cout<<b[i];
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int y = scan.nextInt();
		int z = scan.nextInt();
		int sum = 0;
		for(int i = x;i <= y;i++){
			if(z % i == 0)sum++;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 26356
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy*/
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------

signed main() {
	ld a, b, x;
	cin >> a >> b >> x;
	ld k = x / b / a * 2;
	if (k > a) {
		k = x * 2 / a / a - b;
		printf("%.20LF\n", 90 - atan2(a, b - k) * 180 / M_PI);
	}
	else {
		printf("%.20LF\n", 90 - atan2(k, b) * 180 / M_PI);
	}
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
X, A, B = MAP()

if B <= A:
	print("delicious")
elif B <= A+X:
	print("safe")
else:
	print("dangerous")

Measured memory_bytes: 5272
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;

int main(){
bool correct=true;

int c[4][4];
for(int i=1;i<=3;i++){
    for(int k=1;k<=3;k++){
        cin >>c[k][i];//c[x][y]
    }
}
int a[4]={1,2,3,1};
int i=0;

for(int t=1;t<=3;t++){
    int l=c[a[t-1]][a[0]]-c[a[t]][a[0]];
    for(int k=1;k<=3;k++){
        if(l!=c[a[t-1]][a[k-1]]-c[a[t]][a[k-1]]){
        correct=false;
        break;
        }
    }
    i++;
}
i=0;
for(int t=1;t<=3;t++){
    int l=c[a[0]][a[t-1]]-c[a[0]][a[t]];
    for(int k=1;k<=3;k++){
        if(l!=c[a[k-1]][a[t-1]]-c[a[k-1]][a[t]]){
        correct=false;
        break;
        }
    }
    i++;
}
if(correct){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}

 return 0;
}

Measured memory_bytes: 256