akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <vector>
#include <cctype>
#include <cstdio>
using namespace std;
#define rep(i, n) for( int i = 0; i < n; i++ )
typedef vector<int> vec;

int main(){
    int n;
    cin >> n;
    int sum_t = 0, sum_h = 0;
    rep(i, n){
        string taro, hana;
        cin >> taro >> hana;
        if( taro < hana ){
            sum_h += 3;
        }else if( taro > hana ){
            sum_t += 3;
        }else{
            sum_t += 1;
            sum_h += 1;
        }
    }
    cout << sum_t << ' ' << sum_h << endl;
}

Measured memory_bytes: 1208
#include <iostream>
using namespace std;
int p[100005];
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	scanf("%d",&p[i]);
	int ans=0;
	for (int i=1;i<=n;i++)
	{
		if (p[i]==i)
		{
			ans++;
			i++;
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 640
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    n = int(input())
    s = input()
    t = input()
    max_common = 0
    for i in range(1, n + 1):
        s_tail = s[-i:]
        t_head = t[:i]
        if s_tail == t_head:
            max_common = i
    print(2 * n - max_common)

main()



Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int p, q, r; cin >> p >> q >> r;
    int mx = max(p, max(q, r));
    cout << p+q+r-mx << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int a[200005];
int mm[200005];
signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        mm[a[i]]++;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans+=(mm[i]*(mm[i]-1))/2;
    }
    for(int i=1;i<=n;i++)
    {
        int z=(mm[a[i]]*(mm[a[i]]-1))/2;
        mm[a[i]]--;
        int z2=(mm[a[i]]*(mm[a[i]]-1))/2;
        mm[a[i]]++;
        cout<<ans-z+z2<<'\n';
    }


// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }
 

Measured memory_bytes: 4736
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i, n)  FOR(i,0,(n))

struct stru {
    string s;
    int p;
    int i;
};

class BGuidebook {
public:
    void solve(std::istream &in, std::ostream &out) {
      int n;
      in >> n;
      vector<stru> sp(n);
      REP(i, n) {
        in >> sp[i].s >> sp[i].p;
        sp[i].i = i + 1;
      }
      sort(sp.begin(), sp.end(), [](stru a, stru b) {
          if (a.s == b.s) {
            return a.p > b.p;
          } else {
            return a.s < b.s;
          }
      });
      REP(i, n) out << sp[i].i << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  BGuidebook solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cassert>

using namespace std;
string s;
int pos;

int calc(vector<int> &v){
  sort(v.begin(),v.end());
  int res=0,len=v.size();
  for(int i=0;i<(len-len/2);i++){
    res+=v[i];
  }
  return res;
}

int solve();
int getNum();

int getNum(){
  int res=0;
  while(1){
    if('0'<=s[pos]&&s[pos]<='9'){
      res*=10;
      res+=(s[pos]-'0');
      pos++;
    }else break;
  }
  return res-res/2;
}

int solve(){
  vector<int> v;

  pos++;
  if(s[pos]!='['){
    int res=getNum();
    pos++;
    return res;
  }

  while(1){
    v.push_back(solve());
    if(s[pos]==']')break;
  }

  if(s[pos]==']')pos++;
  else assert(0);

  if(v.size()==1)return v[0];
  else return calc(v);
}

int main(){
  int Tc;
  cin>>Tc;
  while(Tc--){
    cin>>s;
    pos=0;
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1276
q = int(input())
lr = [list(map(int, input().split())) for i in range(q)]

MAX = 100010
is_prime = [True] * MAX
is_prime[0] = False
is_prime[1] = False
for i in range(2, MAX):
    if is_prime[i]:
        j = i * 2
        while j < MAX:
            is_prime[j] = False
            j += i

ruiseki = [0] * MAX
for i in range(1,MAX):
    if is_prime[i]:
        if is_prime[(i + 1) // 2]:
            ruiseki[i] = ruiseki[i - 1] + 1
        else:
            ruiseki[i] = ruiseki[i - 1]
    else:
        ruiseki[i] = ruiseki[i - 1]

for i in range(q):
    print(ruiseki[lr[i][1]] - ruiseki[lr[i][0] - 1])


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

using namespace std;

#define MOD 1000000007

int n;
long long aa, bb;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		long long ta;
		scanf("%lld", &ta);
		aa = (aa + ta) % MOD;
		bb = (bb + ta * ta) % MOD;
	}
	printf("%lld\n", (aa * aa % MOD + MOD - bb) % MOD * ((MOD + 1) / 2) % MOD);
}

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

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for (int i = n - 1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif = uint_fast64_t;
using ll = long long int;
using tTree = __gnu_pbds::tree<ll, __gnu_pbds::null_type, less<ll>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

int qp(int a, ll b)
{
  int ans = 1;
  do
  {
    if (b & 1)
      ans = 1ll * ans * a % mod;
    a = 1ll * a * a % mod;
  } while (b >>= 1);
  return ans;
}
int qp(int a, ll b, int mo)
{
  int ans = 1;
  do
  {
    if (b & 1)
      ans = 1ll * ans * a % mo;
    a = 1ll * a * a % mo;
  } while (b >>= 1);
  return ans;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll, ll);
ll mod_add(ll, ll);
ll mod_mul(ll, ll);
ll mod_div(ll, ll);
void make_fact(ll);
void make_invfact(ll);

ll powLL(ll x, ll y)
{
  ll ans = 1;
  for (ll i = 0; i < y; i++)
    ans *= x;
  return ans;
}

int main(void)
{

  ll n;
  cin >> n;
  vector<ll> c(n);
  rep(i, n) cin >> c[i];

  if (n == 1)
  {
    cout << 1 << endl;
    return 0;
  }

  vector<ll> dp(n);

  unordered_map<ll, ll> um;
  dp[0] = 1;
  um[c[0]]++;

  for (ll i = 1; i < n; i++)
  {
    auto x = c[i];
    if (um.find(x) == end(um))
    {
      um[x] = dp[i - 1];
      dp[i] = dp[i - 1];
    }
    else
    {
      if (c[i - 1] == x)
      {
        dp[i] = dp[i - 1];
      }
      else
      {
        dp[i] = mod_add(dp[i - 1], um[x]);
        um[x] = dp[i];
      }
    }
    //cout << dp[i] << endl;
  }

  cout << dp[n - 1] << endl;

  return 0;
}

ll mod_pow(ll x, ll r)
{
  if (r == 0)
    return 1;
  else if (r == 1)
    return x % mod;
  else if (r % 2 == 0)
  {
    ll t = mod_pow(x, r / 2) % mod;
    return mod_mul(t, t);
  }
  else
  {
    ll t = mod_pow(x, r / 2) % mod;
    ll k = mod_mul(t, t);
    return (k % mod) * (x % mod);
  }
}
ll mod_add(ll a, ll b)
{
  return ((a % mod) + (b % mod)) % mod;
}

ll mod_mul(ll a, ll b)
{
  return ((a % mod) * (b % mod)) % mod;
}

ll mod_div(ll a, ll b)
{
  return mod_mul(a, mod_pow(b, mod - 2));
}

void make_fact(ll n)
{
  fac[0] = 1;
  rep(i, n)
  {
    fac[i + 1] = mod_mul(fac[i], i + 1);
  }
}

void make_invfact(ll n)
{
  invfac[n] = mod_pow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
  {
    invfac[i] = mod_mul(invfac[i + 1], i + 1);
  }
}

Measured memory_bytes: 11592
import sys
from math import gcd

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

def eratosthenes_sieve(n):

    table = [0] * (n+1)
    table[1] = 1
    for i in range(2, n+1):
        if table[i] == 0:
            for j in range(i, n+1, i):
                table[j] = i
    return table

def factorize(table, num: int) -> dict:
    """ 素因数分解 """
    from math import sqrt
    from collections import Counter

    d = Counter()
    while num != table[num]:
        d[table[num]] += 1
        num = num // table[num]
    if num != 1:
        d[num] += 1
    return d

N = INT()
A = LIST()

def check(se, fact):
    for k in fact:
        if k not in se:
            se.add(k)
        else:
            return False
    return True

table = eratosthenes_sieve(10**6)

is_pc = 1
se = set()
for a in A:
    fact = factorize(table, a)
    if not check(se, fact):
        is_pc = 0
        break

is_sc = 1
g = 0
for a in A:
    g = gcd(g, a)
if g != 1:
    is_sc = 0

if is_pc:
    print('pairwise coprime')
elif is_sc:
    print('setwise coprime')
else:
    print('not coprime')


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

ans = 0
isEven = True

while isEven:
  list_tmp = []
  for an in a:
    if an % 2 ==0:
      list_tmp.append(an / 2)
    else:
      isEven = False
      break;
  a = list_tmp
  ans += 1

print(ans - 1)


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

A = []

for i in range(N):
    A.append((data[i][1],data[i][0]))

A = sorted(A)

a = 0  #i番目にやった仕事の終了時間
for i in range(N):
    a += A[i][1]
    if a > A[i][0]:
        print('No')
        break
    else:
        continue
else:
    print('Yes')

Measured memory_bytes: 67036
import sys
import math
a,b,h,m=map(int,input().split())

f=h / 12 * 360 - m / 60 * 360 + m / 60 / 12 * 360

print((a**2+b**2-2*b*a*(math.cos(math.radians(f))))**(0.5))

Measured memory_bytes: 9400
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
 
using namespace std;
using LL = long long;
 
int main(void)
{
  LL n;
  cin >> n;
  vector<LL> v(n);
  LL sum=0,once=n*(n+1)/2;
  for(auto &x: v) cin >> x;
  for(auto x:v) sum+=x;
  bool flag = true;
  if(sum%once) flag = false;
  LL times = sum/once;
  REP(i,n) {
    LL diff = v[(i+1)%n] - v[i];
    diff -= times;
    if(diff%n) flag = false;
    if(diff>0) flag = false;
  }
  
  cout << (flag?"YES":"NO") << endl;
  return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            var res = (ab[0] + ab[1]) / 2.0;
            Console.WriteLine((int)(res)== (res ) ? (res ) : (int)((res )+1));
        }
    }
}


Measured memory_bytes: 13268
""" C
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return reduce(lambda acc, _: acc + [readIntegerSet(m)], range(0, n), [])

def main(N, A):
    M = pow(10, 9) + 7
    result = 0
    S = sum(A)
    for i in range(len(A)):
        S = S - A[i]
        result = (result + A[i] * S) % M
    return result

if __name__ == "__main__":
    _N = readInteger()
    _A = readIntegerSet(_N)

    print(main(_N, _A))

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    // ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, M; cin >> N >> M;
	
	vector<vi> dum (N, vi (M));
	F0R(i, N) {
		F0R(j, M) {
			cin >> dum[i][j];
		}
	}
	// misread inputs have to reformat
	vector<vi> grid (N, vi (M));
	F0R(i, N) F0R(j, M) grid[i][dum[i][j]-1] = j + 1;

	vector<bool> used (M);

	int worst = N;

	F0R(t, M) {
		int best = N;
		vi count (M);
		
		F0R(i, N) {
			int lo_ind = M + 1;
			int lo_act = -1;
			F0R(j, M) if (!used[j]) {
				if (grid[i][j] < lo_ind) {
					lo_ind = grid[i][j];
					lo_act = j;
				}
			}
			count[lo_act]++;
		}
		int biggest = 0;
		F0R(i, M) if (count[i] > count[biggest]) biggest = i;

		worst = min(worst, count[biggest]);
		used[biggest] = true;
	}
	print(worst);
}

Measured memory_bytes: 1024
#pragma comment(linker, "/stack:200000000")
        #pragma GCC optimize ("Ofast")
        #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
         
         
        #include <iostream>
        #include <iomanip>
        #include <sstream>
        #include <cstring>
        #include <vector>
        #include <deque>
        #include <queue>
        #include <set>
        #include <map>
        #include <valarray>
        #include <iterator>
        #include <functional>
        #include <limits>
        #include <algorithm>
        #include <numeric>
        #include <cmath>
        #include <cassert>
        #include <unordered_map>
        #include <unordered_set>
        #include <stack>
        using namespace std;
        #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
         #define trace(x) cerr << #x << ": " << x << " " << endl;
     
        typedef int64_t ll;
     
        #define endl '\n'
        #define int ll
        ll mod=1e9+7;
        ll mod1=1e9+5;
        ll power(ll a,ll b)
        {
            if(b==0) return 1;
            else if(b%2==0)
                return power((((a%mod)*(a%mod))%mod),b/2)%mod;
            else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
        }
        #define PI 3.14159265
     int32_t main()
        {
            IOS
        
        int a,b;
        cin>>a>>b;
        if(a<=9 and b<=9)
        {
            cout<<a*b;
          return 0;
        }
        cout<<-1;
        }

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

typedef long long ll ; 
typedef unsigned long long ull ; 
typedef vector<int> vi ; 
typedef vector<vi> vii ;
typedef vector<ll> vl ;
typedef vector<vl> vll ;
typedef set<int> si ; 
typedef map<int,int> mii ; 
typedef map<ll,ll>  mll ; 
typedef map<string,int> msi ;
typedef set<ll> sl ; 
typedef set<char> sc ; 
typedef pair<int,int> pii ;


#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
const int INF = 1 << 29 ; 
#define MOD (ll)(1e9+7)
#define eps 1e-6
#define pb push_back 
#define mp make_pair 
#define DEBUG(x)		cout << '>' << #x << ':' << x << endl;
#define F first 
#define S second 
#define all(s) s.begin,s.end() 

int main() 
{
	ios::sync_with_stdio(0) ;
	cin.tie(NULL) ; 
	string s , t;
	cin >> s >> t;
	int sl = s.length();
	int tl = t.length();
	int dp[sl+1][1+tl];
	REP(i,sl+1) {
		REP(j,1+tl) dp[i][j] = 0;
	}

	for(int i = 0; i < sl; ++i) {
		for(int j = 0; j < tl; ++j) {
			if(s[i] == t[j]) {
				dp[1+i][1+j] = dp[i][j] + 1; 
			}
			else {
				dp[i+1][j+1] = max(dp[i][j+1] , dp[i+1][j]);
			}
		}
	}
	/*
	REP(i,sl+1) {
		REP(j,tl+1) {
			cout << dp[i][j] << " "; 
		}
		cout << endl;
	}
	*/
	vector<char> ans;
	int sti = sl , lti = tl;
	while(sti && lti) {
		if(s[sti-1] == t[lti-1]) {
			ans.push_back(s[sti-1]);
			sti--;
			lti--;
		}
		else {
			if(dp[sti-1][lti] == dp[sti][lti]) {
				sti--;
			}
			else {
				lti--;
			}
		}
	}
	reverse(ans.begin() , ans.end());
	for(auto i : ans) cout << i ;
	cout << endl;



	return 0 ; 
}



Measured memory_bytes: 35456
#include <stdio.h>

int main(void){
    int count=0,n,x;
    while(1){
        scanf("%d %d",&n,&x);
        if(n==0 && x == 0){
            break;
        }
        int i;
        for(i=1;i<n+1;i++){
            int j;
            for(j=i;j<n+1;j++){
                int k;
                for(k=j;k<n+1;k++){
                    if(i+j+k == x && i != j && j!= k && k != i){
                        count += 1;
                    }
                }
            }
        }
        printf("%d\n",count);
        count = 0;
    }    
}


Measured memory_bytes: 2036
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int P = int.Parse(str[1]);
        long[,] DP = new long[N+1,2];
        DP[0,0] = 1;
        str = Console.ReadLine().Split(' ');
        for(int i=0;i<N;i++){
            if(int.Parse(str[i]) % 2 == 0){
                DP[i+1,0] = DP[i,0]*2;
                DP[i+1,1] = DP[i,1]*2;
            }
            else{
                DP[i+1,0] = DP[i,0]+DP[i,1];
                DP[i+1,1] = DP[i,0]+DP[i,1];
            }
        }
        long count;
        if(P == 0){
            count = DP[N,0];
        }
        else{
            count = DP[N,1];
        }
        sb.Append(count+"\n");
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>a>>b>>c;
	if(b-a==c-b)
	cout<<"YES";
	else
	cout<<"NO";
	return 0;
 }


Measured memory_bytes: 256
N = int(input())
W = [int(w) for w in input().split()]

for i in range(1, N):
    W[i] += W[i-1]
    
s = W[N-1]
ans = 10**9
for i in range(N):
    ans = min(ans, abs(s-2*W[i]))
print(ans)

Measured memory_bytes: 3060
// i hope i get better                                                           
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int sz=1e5+9;
int n,k;
ll ans;
ll mod=1e9+7;
ll add(ll a,ll b){return ((a%mod+b%mod)%mod+mod)%mod;}
ll mul(ll a,ll b){return (a%mod*b%mod)%mod;}
ll cnt[sz];

ll modpow(ll b,ll p){
	if(!b) return 0;
	if(!p) return 1;
	ll u=modpow(b,p>>1);
	u=mul(u,u);
	if(p&1) return mul(u,b);
	return u;
}


int main(){
	cin>>n>>k;
	ans=k;
	cnt[k]=1;
	for(int i=k-1;i>=1;i--){
		cnt[i]=modpow(k/i,n);
		for(int j=i*2;j<=k;j+=i) cnt[i]=add(cnt[i],-cnt[j]);
		ans=add(ans,mul(cnt[i],i));
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4328
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
#define vi vector<ll>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vt vector<tuple<ll, ll, ll>>
using namespace std;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
map<ll, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	ll n;
	cin >> n;
	vi v(n);
	REP(i, n) cin >> v[i];
	sort(ALL(v));
	cout << abs(v[0] - v[n - 1]) << endl;
}

Measured memory_bytes: 256
def main():
    from collections import defaultdict

    N = int(input())
    S = str(input())

    dic = defaultdict(int)

    for i in range(2 ** N):
        a = str()
        b = str()
        for j in range(N):
            if (i >> j) & 1:
                a += S[j + N]
            else:
                b += S[j + N]
        
        dic[(a, b)] += 1

    count = 0
    for i in range(2 ** N):
        a = str()
        b = str()
        for j in range(N):
            if (i >> j) & 1:
                a += S[j]
            else:
                b += S[j]
        count += dic[b[::-1], a[::-1]]

    print (count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 125900
#include <cstdio>

#define MAXN 100000

int n, v[MAXN];

inline int gcd(int a, int b) {
    int r;
    while (b) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

inline bool solve() {
    if (n == 1)
        return 0;
    int pare = 0;
    for (int i = 0; i < n; i++)
        pare += 1 - v[i] % 2;
    if (pare < n - 1)
        return pare % 2;
    if ((n - 2) % 2 == 0)
        return 1;
    for (int i = 0; i < n; i++)
        if (v[i] % 2 == 1 && v[i] != 1)
            v[i]--;
    int a = v[0];
    for (int i = 1; i < n; i++)
        a = gcd(v[i], a);
    if (a == 1)
        return 0;
    for (int i = 0; i < n; i++)
        v[i] /= a;
    return 1 - solve();
}

int main() {
    scanf("%d", &n);

    for (int i = 0; i < n; i++)
        scanf("%d", &v[i]);

    if (solve())
        printf("First\n");
    else
        printf("Second\n");

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int, int>
using namespace std;
const LL INF = (LL) 1e9 + 5;
const LL MOD = (LL) 1e9 + 7;
const int MAXN = 15;

int n, m;
LL dp[1 << MAXN][MAXN], G[MAXN][MAXN], prof[1 << MAXN], sum;

int forbid(int x) {
	return ((1 << n) - 1) ^ 1 << x;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		G[a][b] = G[b][a] = c;
		sum += c;
	}
	
	for (int i = 0; i < (1 << n); i++) {
		for (int j = 0; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if ((i >> j & 1) && (i >> k & 1)) {
					prof[i] += G[j][k];
				}
			}
		}
	}
	
	int t = n - 1;
	for (int i = 0; i < (1 << n); i++) {
		dp[i][t] = prof[i];
	}
	for (int i = 0; i < (1 << n); i++) {
		if (~i >> t & 1) continue;
		for (int a = 0; a < t; a++) {
			dp[i][a] = -1;
			if (~i >> a & 1) continue;
			for (int b = 0; b < n; b++) {
				if ((~i >> b & 1) || a == b || G[a][b] == 0) continue;
				int tot = i & forbid(a) & forbid(b) & forbid(t), sub = tot;
				while (1) {
					int take = sub | 1 << a;
					if (dp[i ^ take][b] != -1) {
						dp[i][a] = max(dp[i][a], dp[i ^ take][b] + prof[take] + G[a][b]);
					}
//					cout << a << " to " << b << " take " << take << " prof " << prof[take] + G[a][b] << '\n';
					if (sub == 0) break;
					sub = (sub - 1) & tot;
				}
			}
//			cout << "DP " << i << ' ' << a << ' ' << dp[i][a] << '\n';
		}
	}
	
	cout << sum - dp[(1 << n) - 1][0] << '\n';
	
	return 0;
}

Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

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

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;



void solve() {
    int n, m;
    cin >> n >> m;
    vector<vector<int> > d(n, vector<int>(n, 0));
    int a, b;
    for (int i = 0; i < m; ++i) {
        cin >> a >> b;
        --a, --b;
        d[a][b] = d[b][a] = 1;
    }
    vector<int> p(n);
    for (int i = 0; i < n; ++i) {
        p[i] = i;
    }
    int res = 0;
    do {
        int ok = 1;
        for (int i = 0; i < n - 1; ++i) {
            if (d[p[i]][p[i + 1]] == 0)
                ok = 0;
        }
        res += ok;
    } while (next_permutation(p.begin() + 1, p.end()));
    cout <<  res << endl;
}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
const int MOD = 1e9+7;
const int INF = 1e9+1000;
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);}
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct Edge{int to,weight;};
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
/*----------------------------------------------*/
int dp[110][101010]; 
int w[110],v[110];

signed main(){
  int n,W;
  cin>>n>>W;
  rep(i,n) cin>>w[i]>>v[i];
  rep(i,110)rep(j,101010) dp[i][j]=INF;
  
  dp[0][0]=0;
  rep(i,n+1)rep(j,101010){
    if(j>=v[i]) chmin(dp[i+1][j],dp[i][j-v[i]]+w[i]);
    chmin(dp[i+1][j],dp[i][j]);
  }

  int ans=0;
  rep(j,101010) if(dp[n][j]<=W) ans=j;
  cout<<ans<<endl;
  // rep(i,n+1){
  //   rep(j,101010) if(dp[i][j]<INF) cout<<dp[i][j]<<"/"<<j<<" ";
  //   cout<<endl;
  // }
  return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  int day = 0;
  for (int i = 0; i < M; i++) {
    int A;
    cin >> A;
    day += A;
  }
  if (day <= N)
    cout << N - day << endl;
  else
    cout << "-1" << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

long long cnt;

void print(vector<int> &data){
	for (int i = 0; i < data.size(); ++i){
		cout << data[i];
		if (i == data.size() - 1) cout << endl;
		else cout << " ";
	}
}


int partition(vector<int> &data, int p, int r){
	int p1 = p - 1;
	int p2 = p;
	int v = data[r];

	while (p2 < r) {
		if (data[p2] <= v)
			swap(data[++p1], data[p2]);
		p2++;
	}
	swap(data[++p1], data[r]);

	return p1;
}



int main(){
	int n; cin >> n;
	vector<int> data(n);
	for (int i = 0; i < n; ++i) cin >> data[i];

	int pos = partition(data, 0, data.size() - 1);
	//print(data);
	for (int i = 0; i < data.size(); ++i){
		if (i == pos) cout << "[";
		cout << data[i];
		if (i == pos) cout << "]";
		if (i == data.size() - 1) cout << endl;
		else cout << " ";
	}

	return 0;
}

Measured memory_bytes: 3132
l=list(input())
mod=pow(10,9)+7
n=len(l)

dp=[[0,0] for i in range(n+1)]
dp[0][1]=1
# dp[i][0] 未満確定した物
# dp[i][1] まだ未満確定していない
for i in range(n):
    if l[i]=='1':
        dp[i+1][0]=3*dp[i][0]%mod
        dp[i+1][0]+=dp[i][1]%mod
        dp[i+1][1]+=2*dp[i][1]%mod
    else:
        dp[i+1][0]=3*dp[i][0]%mod
        dp[i+1][1]=dp[i][1]%mod
print((dp[-1][0]+dp[-1][1])%mod)

Measured memory_bytes: 57868
import java.util.*;
public class Main {
	public static int calc(String s, String[] b, String[] r) {
		int buf = 0;
		for(String t: b) {
			if(t.equals(s)) buf++;
		}
		for(String t: r) {
			if(t.equals(s)) buf--;
		}
		return buf;
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		String[] blue = new String[N];
		for(int i = 0; i < N; i++) {
			blue[i] = stdIn.next();
		}
		
		int M = stdIn.nextInt();
		String[] red = new String[M];
		for(int i = 0; i < M; i++) {
			red[i] = stdIn.next();
		}
		
		int ans = 0;
		for(String t: blue) {
			ans = Math.max(ans, calc(t, blue, red));
		}
		
		System.out.println(ans);

	}

}

Measured memory_bytes: 21972
//By Vlgd
#include<bits/stdc++.h>
#define ass printf("ÒŠ¤Ä¤±¤Þ¤·¤¿\n");
#define LIMIT 45
using namespace std;
const int N=4,NN=16;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
int MDT[NN][NN],lim,ans=0; 
struct Puz{int pic[NN],space,path,MD;};
bool dfs(int dep,int prev,Puz cur){	
	if(cur.MD==0){
		ans=cur.path;
		return true;
	}
	if(dep+cur.MD>lim) return false;
	int sx=cur.space/N,sy=cur.space%N;
	for(int i=0;i<4;i++){
		Puz nxt=cur;
		int tx=sx+dx[i],ty=sy+dy[i];
		if(tx<0||ty<0||tx>=N||ty>=N) continue;
		if(max(i,prev)-min(i,prev)==2) continue;
		nxt.MD-=MDT[tx*N+ty][cur.pic[tx*N+ty]-1];
		nxt.MD+=MDT[sx*N+sy][cur.pic[tx*N+ty]-1];
		swap(nxt.pic[sx*N+sy],nxt.pic[tx*N+ty]);
		nxt.space=tx*N+ty;
		nxt.path++;
		if(dfs(dep+1,i,nxt)){
			return true;
		}
	}
	return false;	
}
int iterative(Puz in){
	for(lim=in.MD;lim<=LIMIT;lim++){
		if(dfs(0,-10,in)){
			printf("%d\n",ans);
			return 0;
		}
	}	
}
int main(){
	Puz src;
	int sum=0;
	for(int i=0;i<NN;i++){
		for(int j=0;j<NN;j++){
			MDT[i][j]=fabs(i/N-j/N)+fabs(i%N-j%N);
		}
	}
	for(int i=0;i<NN;i++){
		scanf("%d",&src.pic[i]);
		if(src.pic[i]==0){
			src.pic[i]=NN;
			src.space=i;
		}
		if(src.pic[i]!=NN)
			sum+=MDT[i][src.pic[i]-1];
	}	
	src.path=0;
	src.MD=sum;
	iterative(src);
	
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a%3==0 || b%3==0 || (a+b)%3==0)
    {
        cout<<"Possible\n";
    }
    else cout<<"Impossible\n";

    return 0;
}


Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
import math
num=[]
ans=10**5
for i in range(n):
    num.append(t-0.006*h[i])
for i in range(n):
    diff=abs(num[i]-a)
    if diff<ans:
        ans=diff
        tmp=i
print(tmp+1)
  

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

class Die
{
  public:
    Die();

  public:
    void North();
    void East();
    void South();
    void West();
    int Up_return();

  private:
    int m_up;
    int m_north;
    int m_west;
};

Die::Die()
{
  m_up = 1;
  m_north = 2;
  m_west = 3;
}

void Die::North()
{
  int buf_up = m_up;
  m_up = 7 - m_north;
  m_north = buf_up;
}

void Die::East()
{
  int buf_up = m_up;
  m_up = m_west;
  m_west = 7 - buf_up;
}

void Die::South()
{
  int buf_up = m_up;
  m_up = m_north;
  m_north = 7 - buf_up;
}

void Die::West()
{
  int buf_up = m_up;
  m_up = 7 - m_west;
  m_west = buf_up;
}

inline int Die::Up_return()
{
  return m_up;
}

int main(void)
{
  int n;
  string command;
  while (true)
  {
    cin >> n;
    if (n == 0) break;
    Die die;

    for (int i = 0; i < n; ++i)
    {
      cin >> command;
      if (command == "north")
      {
        die.North();
      }
      else if (command == "east")
      {
        die.East();
      }
      else if (command == "south")
      {
        die.South();
      }
      else if (command == "west")
      {
        die.West();
      }
    }
    cout << die.Up_return() << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
using namespace std;
template<class T>inline void read(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
const int maxn=2050;
int n,a[maxn];
int main()
{
	read(n);
	F(i,1,n) read(a[i]);
	sort(a+1,a+n+1);
	int ans=0;
	for(int i=1;i<=n-2;i++)
	{
		for(int j=i+1;j<=n-1;j++)
		{
			int l=j,r=n;
			while(l<r)
			{
				int mid=l+r+1>>1;
				if(a[mid]<a[i]+a[j]) l=mid;
				else r=mid-1;
			}
			if(l==j) continue;
			//cout<<i<<"..."<<j<<"..."<<l<<"...."<<endl;
			ans+=l-j;
		}
	}
	cout<<ans<<endl;
	return 0;
}



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

bool find(vector<int> v, int n) {
	for (int i = 0; i < v.size(); i++) {
		if (v[i] == n) return true;
	}
	return false;
}

int main() {
	int a, b, p[100] = { 0 };
	vector<int> v;
	char t;
	while (cin >> a >> t >> b) {
		if (a == 0 && b == 0) break;
		p[a - 1] = b;
		if (!find(v, b)) v.push_back(b);
	}

	sort(v.begin(), v.end(), greater<int>());
	while (cin >> a) {
		for (int i = 0; i < v.size(); i++) {
			if (v[i] == p[a - 1]) {
				cout << i + 1 << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
#define inf 1e9
#define F first
#define S second
#define dbg(x) cout<<#x<<" value : "<<x<<"\n";
#define rep(i,j,k) for(int i = (j); i <= (k); i++)
#define rep__(i,j,k) for(int i = (j); i < (k); i++)
#define per(i,j,k) for(int i = (j); i >= (k); i--)
#define per__(i,j,k) for(int i = (j); i > (k); i--)
#define mst(a,b) memset(a,b,sizeof(a))
#define sf(n) scanf("%d",&n)
#define stf(n,m) scanf("%d%d",&n,&m)
#define pf(n) printf("%d\n",n)
#define sllf(n) scanf("%lld",&n)
#define pllf(n) printf("%lld\n",n)
priority_queue<int,vector<int>,greater<int> > q;
const int N=1e2+10;
const int mod=1e9+7;
int n,a[N],sum=1;
int main()
{
	sf(n);
	string s;
	cin>>s;
	char b=s[0];
	rep(i,1,n-1){
		if(s[i]==b)continue;
		else b=s[i],sum++;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
//a atac taka
//b forca taka
//atac aoki
//forca aoki
int main(){
    int a,b,c,d;
    int saude1,saude2;


    scanf("%d %d %d %d",&a,&b,&c,&d);

    while(a>0 && c>0){
        c = c - b; //tirando vida do aoki
        a = a - d; //tirando vida do taka



    }
    if(c<=0){
        printf("Yes\n");
    }else  {
        printf("No\n");
    }






    return 0;
}


Measured memory_bytes: 1656
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N;
    cin >> N;
    vec A(N), dif(N);
    ll s = 0;
    Rep (i, N) {
        cin >> A[i];
        s += A[i];
        if (i > 0) {
            dif[i-1] = A[i] - A[i-1];
        }
    }
    dif[N-1] = A[0] - A[N-1];

    if (s % (N*(N+1)/2) > 0) {
        cout << "NO\n";
        return 0;
    }

    ll cnt = s / (N*(N+1)/2);

    Rep (i, N) {
        dif[i] -= cnt;
    }

    Rep (i, N) {
        if (dif[i] > 0) {
            cout << "NO\n";
            return 0;
        }
        dif[i] *= -1;
        if (dif[i] % N > 0) {
            cout << "NO\n";
            return 0;
        }

        cnt -= dif[i] / N;
    }

    if (cnt == 0) {
        cout << "YES\n";
        return 0;
    } else {
        cout << "NO\n";
        return 0;
    }


}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1 << 25
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cerr << #x << " = " << (x) << "\n";
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ull;
 
const double EPS = 1e-10;
const double PI = acos( -1.0 );
 
int a, b;

int main() {
    while ( scanf( "%d %d", &a, &b ) != EOF ) {
        a += b;
        int ans = 0;
        while ( true ) {
            if ( a / 10 == 0 && a % 10 == 0 ) {
                break;
            }
            ans++;
            a /= 10;
        }
        printf( "%d\n", ans );
    }
    return 0;
}

Measured memory_bytes: 1188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		// 1日1回ログインすることで貰えるA枚のコイン
		int A = sc.nextInt();
		// 月曜日～金曜日まで7連続でログインすると貰えるB枚のコイン
		int B = sc.nextInt();
		// 目標のコイン枚数
		int C = sc.nextInt();

		// コインの合計を格納する変数coinを初期化
		int coin = 0;

		// 目標のコインを得るために何日ログインすれば良いのかを格納する
		int count = 0;

		// コインの合計が目標のコイン数よりも小さい間
		while(coin < C) {

			count++;

			coin += A;
			if(count % 7 == 0){
				coin += B;
			}
		}
		System.out.println(count);

	}

}



Measured memory_bytes: 26360
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(a,b) cout << "debug" << a << " , "<< b << endl;
using ll=long long;
const ll INF=1LL<<60;



int main(){
  int n;
  ll k;
  cin >> k >> n;
  vector<ll>a(n);
  rep(i,n)cin >> a[i];
  sort(a.begin(),a.end());
  ll inv=0;
  for(int i=1;i<n;i++)inv=max(inv,a[i]-a[i-1]);
  inv=max(inv,(k-a[n-1])+a[0]);
  cout << k-inv;
}



Measured memory_bytes: 1792
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o A_Therefore.exe A_Therefore.cpp 
Execute: ./A_Therefore
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <iomanip>
#include <cstring> 
#include<bits/stdc++.h> 
using namespace std;

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


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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int,string> Pis;

int main(){
  string s,t;
  cin>>s>>t;
  t+=s;
  cout<<t<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Console.ReadLine();
		Console.WriteLine("{0}{1}{2}", p[0], p.Length - 2, p[p.Length-1]);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 13140
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

string s, t;

void init()
{
}

void solve()
{
    set<char> v[26];
    set<char> v2[26];
    ll l = s.size();
    REP(i, l){
        v[s[i] - 'a'].insert(t[i]);
        v2[t[i] - 'a'].insert(s[i]);
    }
    REP(i, 26){
        if(v[i].size() > 1 || v2[i].size() > 1){
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s >> t;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 916
#define M'   '
char*s,T[M],*r=T;U[M*35];i;k;main(n){for(;gets(r+1);k=0)for(--n;*++r&=31;)U[r-T]=k|=!!n<<*r;for(;s>T||(s=r,i++-2);k=U[k]=U[k-=~-~*s*M]?:*s?s-T:0)n+=__builtin_popcount(U[--s-T]&(U[k+M]^=!s[-1]<<*s));printf("%d",n);}

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

using namespace std;

int main(){
    string s, t;

    cin >> s;
    cin >> t;

    if(s.length() + 1 == t.length()){
        if(s == t.substr(0, s.length())){
            cout << "Yes" << endl;
        } else cout << "No" << endl;
    } else cout << "No" << endl;

    return 0;
}

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

    if ((s == "hi") || (s == "hihi") || (s == "hihihi") || (s == "hihihihi")
|| (s == "hihihihihi")){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
using R = double;
using Data = pair < ll, vector <ll>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 60;
struct edge { ll from; ll to; ll cost; };
typedef tuple<ll, ll, ll>T;
typedef pair<ll, ll>pll;
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2


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

	int po = 1;
	rep(i, 0, m)po *= 2;

	cout << po * (1800 * m + 100 * n) << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 4003;
const int INF = 1e9 + 7;
int n;
char c[N];
int a[N];
int p[2][N][N];
bool have[2][N];
int pos[2][N];
int dp[N][N];
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n;
    for (int i = 1; i <= 2 * n; ++i) cin >> c[i] >> a[i];
    for (int i = 1; i <= 2 * n; ++i) {
        if (c[i] == 'W') {
            pos[0][a[i]] = i;
        }
        else {
            pos[1][a[i]] = i;
        }   
    }   

    for (int i = 2 * n; i >= 1; --i) {
        if (c[i] == 'W') have[0][a[i]] = 1;
        else have[1][a[i]] = 1;
        for (int t = 0; t <= 1; ++t) {
            for (int j = 1; j <= n; ++j) {
                p[t][i][j] = p[t][i][j - 1] + have[t][j];
            }   
        }
    }

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            dp[i][j] = INF;
        }   
    }   
    dp[0][0] = 0;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            if (i < n) {
                int ps = pos[0][i + 1];
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + ps + p[0][ps + 1][i] + p[1][ps + 1][j] - i - j - 1);
            }
            if (j < n) {
                int ps = pos[1][j + 1];
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + ps + p[0][ps + 1][i] + p[1][ps + 1][j] - i - j - 1);
            }   
        }
    }   

    #ifdef HOME
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            cout << dp[i][j] << ' ';
        }   
        cout << '\n';
    }   
    #endif

    cout << dp[n][n] << '\n';
}


Measured memory_bytes: 187648