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

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
const int MOD = 1e9+7;
const int INF = 1e9;
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; }

// debug
template<class T>ostream& operator<<(ostream& os, vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}
#include<type_traits>
template<typename T,size_t SIZE,enable_if_t<!is_same<remove_cv_t<T>,char>::value,nullptr_t> = nullptr>ostream& operator<<(ostream& os,T(&arr)[SIZE]){os<<"{";for(size_t i=0;i<SIZE;++i)os<<(i?", ":"")<<arr[i];os<<"}";return os;}
#ifdef LOCAL
    #define debug(v) cerr<<v<<"\n"
#else
    #define debug(...) 42
#endif


int main() {
  int N, W; cin >> N >> W;

  int w[N], v[N];
  rep(i, N) {
    cin >> w[i] >> v[i];
  }
  // dp[i][w] = i番目(1-idx)までで、重さの総和がw以下になるよう入れたときの最大値
  ll dp[N+1][W+1];
  rep(i, N+1) rep(w, W+1) dp[i][w] = 0;
  rep(i, N) {
    rep(j, W+1) {
      dp[i+1][j] = dp[i][j];
      if (j >= w[i]) {
        dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
      }
    }
  }
  cout << dp[N][W] << endl;

  return 0;
}


Measured memory_bytes: 79104
#include <iostream>
using namespace std;
int main()
{
    char c[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }
    cout << c[0][0] << c[1][1] << c[2][2] << endl;
    return 0;
}

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

int main(){
	int a[3];
	for(int i=0; i<3;i++){
		cin>>a[i];
	}
		sort(a,a+3);
		cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
		return 0;

}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
    int n;cin >> n;
    map<string,LL> ma;
    LL ans=0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        sort(ALL(s));
        ans+=ma[s]++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 11136
#include <array>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;

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

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

	int turn[128];
	turn['L'] = -1;
	turn['R'] = 1;

	for(int h, w, n; cin >> h >> w >> n && h;) {
		string command;
		cin >> command;

		int dir = 0;
		array<vector<int>, 4> get_d{{{0}, {}, {}, {}}};
		for(int i = 0; i < n; ++i) {
			dir = (dir + turn[command[i]] + 4) % 4;
			get_d[dir].emplace_back(i + 1);
		}

		vector<string> field(h);
		for(auto &e : field) cin >> e;

		typedef tuple<int, int, int> P;
		priority_queue<P, vector<P>, greater<P>> que;
		vector<vector<int>> dist(h, vector<int>(w, n + 1));

		for(int i = 0; i < h; ++i) {
			for(int j = 0; j < w; ++j) {
				if(field[i][j] == 'S') {
					dist[i][j] = 0;
					que.push(make_tuple(0, j, i));
					goto unloop;
				}
			}
		}

	unloop:;

		while(!que.empty()) {
			int di, x, y;
			tie(di, x, y) = que.top();
			que.pop();

			if(dist[y][x] < di) continue;

			for(int d = 0; d < 4; ++d) {
				const int nx = x + dx[d];
				const int ny = y + dy[d];

				if(nx < 0 || ny < 0 || nx >= w || ny >= h || field[ny][nx] == '#') continue;

				const auto it = lower_bound(get_d[d].begin(), get_d[d].end(), di);
				if(it == get_d[d].end()) continue;

				if(dist[ny][nx] > *it) {
					if(field[ny][nx] == 'G') goto ok;
					dist[ny][nx] = *it;
					que.push(make_tuple(*it, nx, ny));
				}
			}	
		}

		cout << "No" << endl;
		continue;

	ok:;
		cout << "Yes" << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 6732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;



int main(){
    ll n;
    cin >> n;
    ll a[n];
    bool flag=true;
    for(ll i=0;i<n;i++){
        cin >> a[i];
        if(a[i]%2==1) flag=false;
    }
    if(flag) cout << "second" << endl;
    else cout << "first" << endl;
    return 0;
}  


Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload3(_1,_2,_3,name,...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) for (ll i=(a); i<(n); ++i)
#define rep(...) _overload3(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<class T> inline void print(const T& x) {cout << x << "\n";}
template<class T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<class T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
struct Init {Init() {cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10);}} init;

int main() {
    string s, t; cin >> s >> t;
    ll lens = sz(s), lent = sz(t);
    priority_queue<string, vs, greater<string>> pq;
    rep(i, lens - lent + 1) {
        string subs = s.substr(i, lent);
        bool isOk = true;
        rep(j, lent) {
            if (subs[j] != '?' && subs[j] != t[j]) isOk = false;
        }
        if (isOk) {
            string news = s.substr(0, i) + t + s.substr(i + lent);
            rep(j, lens) {
                if (news[j] == '?') news = news.substr(0, j) + "a"s + news.substr(j + 1);
            }
            pq.push(news);
        }
    }
    if (not pq.empty()) print(pq.top());
    else print("UNRESTORABLE");
}

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

class Program
{
    static void Main()
    {
        var str = Console.ReadLine();
        var index = str.Length;

        while (index > 0)
        {
            if (str.Substring(index - 5, 5) == "dream" || str.Substring(index - 5, 5) == "erase")
            {
                index -= 5;
            }
            else if (str.Substring(index - 6, 6) == "eraser")
            {
                index -= 6;
            }
            else if (str.Substring(index - 7, 7) == "dreamer")
            {
                index -= 7;
            }
            else
            {
                Console.WriteLine("NO");
                return;
            }
        }

        Console.WriteLine("YES");
    }
}

Measured memory_bytes: 11232
// C - K-th Substring

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	string s;
	cin >> s;

	int K;
	cin >> K;

	set<string> substr_list;
	for (int i=0; i<s.size(); i++) {
		for (int j=i; j<s.size(); j++) {
			if (j-i > 5) continue;
			substr_list.insert(s.substr(i, j-i+1));
		}
	}

	auto itr = substr_list.begin();
	for (int i=1; i<K; i++) {
		itr++;
	}

	string ans = *itr;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5156
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>

using namespace std;


vector <int> edges[10000];
vector <int> reverse_edges[10000];
vector <int> back_order;
bool used[10000];
int scc_no[10000];
int scc_counter = 1;
void dfs(int cur_v){
    used[cur_v] = true;
    for(int i = 0; i < edges[cur_v].size(); i++){
        int next_v = edges[cur_v][i];
        if(!used[next_v]){
            dfs(edges[cur_v][i]);
        }
    }
    back_order.push_back(cur_v);
}

void rdfs(int cur_v){
    scc_no[cur_v] = scc_counter;
    for(int i = 0; i < reverse_edges[cur_v].size(); i++){
        int next_v = reverse_edges[cur_v][i];
        if(scc_no[next_v] == 0){
            rdfs(next_v);
        }
    }
}

void scc(int V){
    for(int i = 0; i < V; i++){
        if(!used[i]){
            dfs(i);
        }
    }
    for(int i = back_order.size() - 1; i >= 0; i--){
        if(scc_no[back_order[i]] == 0){
            rdfs(back_order[i]);
            scc_counter++;
        }
    }
}

int main(){
    int V;
    int E;
    cin >> V >> E;
    for(int i = 0; i < E; i++){
        int s;
        int t;
        cin >> s >> t;
        edges[s].push_back(t);
        reverse_edges[t].push_back(s);
    }
    scc(V);

    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int u;
        int v;
        cin >> u >> v;
        if(scc_no[u] == scc_no[v]){
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}


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

long long GCD(long long n, long long m) {
    return m ? GCD(m, n % m) : n;
}

int main() {
    long long n, m; cin >> n >> m;
    string s, t; cin >> s >> t;
    
    long long g = GCD(n, m);
    long long res = n / g * m;
    n /= g, m /= g;
    bool ok = true;
    for (long long i = 0; i < g; ++i) {
        if (s[i*n] != t[i*m]) ok = false;
    }
    if (ok) cout << res << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string N;cin>>N;
  cout << (N[1]==N[2]&&(N[0]==N[1]||N[2]==N[3])? "Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int):
    if N % 2 == 0:
        print(N // 2)

    else:
        print(N // 2 + 1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
using namespace std;
int A[21];
int q[200];
int dp[21][100000];

int main(){
    int n,m;
    int max = 0;
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> A[i];
    cin >> m;
    for(int i =0; i < m; i++){
        cin >> q[i];
        if(q[i] > max) max = q[i];
    }
    for(int i = 1; i <= max; i++) dp[0][i] = false;
    dp[0][0] = true;
    for(int i = 1; i <= n; i++){    
        for(int j = 0; j <= max; j++){
            dp[i][j] |= dp[i-1][j];
            if(j-A[i] >= 0) dp[i][j] |= dp[i-1][j-A[i]];
        }
    }

    for(int i = 0; i < m; i++){
        if(dp[n][q[i]]) cout << "yes" << endl;
        else cout << "no" << endl;
    }


}


Measured memory_bytes: 3304
/*
ID: wangjun30
TASK:
LANG: C++
*/
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n,h,temp,closet=1e9,pos=-1;
	cin>>n>>h>>temp;
	h*=1000;
	temp*=1000;
	for(int i=0;i<n;i++){
		int x,val=0;
		cin>>x;
		val=(h-x*6);
		if(abs(val-temp)<abs(closet-temp))
			closet=val,pos=i+1;
//		cout<<val<<endl;
	}
	cout<<pos;
	return 0;
}

Measured memory_bytes: 384
a = input()

for x in range(1<<3):
  s = a[0]

  for i in range(3):
    if x & (1<<i):
      s += '+'
    else:
      s += '-'
    s += a[i+1]

  if eval(s) == 7:
    print(s + '=7')
    exit()

Measured memory_bytes: 8964
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int array[] = new int[n];
    long count = 1;
    int start = 0;
    for (int i = 0; i < n; i++) {
      array[i] = sc.nextInt();
    }
    
    int work = array[0];
    for (int i = 1; i < n;) {
      if ((work & array[i]) == 0) {
        work ^= array[i];
        i++;
        count += i - start;
      } else {
        work ^= array[start];
        start++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 87824
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <list>
#include <iomanip>

using namespace std;

#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
#define rep(i,a,n) for(Int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(Int (i)=(a); (i)<=(n); (i)++)
const int MAX_N = 1000000;
const Int MAX_N_Int = 1000000000000;

template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}

bool isPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}


Int fact_mod(Int n, Int mod) {
    Int f = 1; repq(i,2,n) f = f * (i % MOD) % MOD;
    return f;
}

// 繰り返し二乗法 (modの世界での累乗)
Int mod_pow(Int x, Int n, Int mod) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

// 組み合わせ nCr を求める
Int combination_mod(Int n, Int r, Int mod) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    Int a = 1;
    rep(i, 0, r) a = a * ((n-i) % mod) % mod;
    Int b = mod_pow(fact_mod(r, mod), mod-2, mod);
    return (a % mod) * (b % mod) % mod;
}

int main() {
    //COMinit();
    IOS;
    prec;
    Int a,b,c,d,n,m,k,x,y=0,ans=0;
    string str,s="",t,u;
    cin>>s;
    if(s.length()==2)cout<<s;
    else{
        cout<<s[2]<<s[1]<<s[0];
    }


    cout<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int N;
  cin>>N;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];

  ll ans=0;
  for(int i=1;i<N;i++){
    if(A[i-1]<=A[i]) continue;
    ans+=A[i-1]-A[i];
    A[i]=A[i-1];
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 4752
#include<bits/stdc++.h>
using namespace std;
#define int            int64_t
#define double         long double
#define nitro          ios_base::sync_with_stdio(false);cin.tie(0);
#define vi             vector<int64_t>
#define pub            push_back
#define puf            push_front
#define pob            pop_back
#define pof            pop_front
#define PI             3.1415926535897932384626433832795
#define read(a)        for(auto& x : a) cin>> x
#define endl           '\n'
#define gap            ' '
#define min3(a,b,c)    min(a, min(b, c))
#define max3(a,b,c)    max(a, max(b, c))
#define MOD            1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
    nitro
    string s;cin>>s;
    for(int i=0;i<s.size();++i){
    	if((i+1)%2!=0) cout<<s[i];
    }
}
    

Measured memory_bytes: 592
from math import gcd

n = int(input())
A = list(map(int, input().split()))

if n == 2:
    print(max(A))
else:
    # 最初の3個のうちの2個を選んで、最大の最大公約数
    # 最大公約数に選ばれなかったものを交換（rがaより大きいとき）
    r = max(gcd(A[0], A[1]), gcd(A[1], A[2]), gcd(A[2], A[0]))
    # リストaの最初3個の最大公約数
    a = gcd(A[0], gcd(A[1], A[2]))

    for i in range(3, n):
        r = max(gcd(A[i], r), a)
        a = gcd(A[i], a)

    print(r)

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   int n, a;
   cin >> n >> a;
   cout << n*n -a << endl;

   return 0;
}

Measured memory_bytes: 256
n = int(input())
if n % 10 == 1:
    m = 9
else:
    m = 1
n //= 10
if n % 10 == 1:
    m += 90
else:
    m += 10
n //= 10
if n % 10 == 1:
    m += 900
else:
    m += 100
print(int(m))

Measured memory_bytes: 3060
#include <stdio.h>
#include <ctype.h>

int main()
{
	char W[11];
	char str[1001];
	int count=0;
	int i,len;
	scanf("%s", W);
	len=strlen(W);
	for(i=0; i<len; i++){
		if(isalpha(W[i])){
			W[i]=tolower(W[i]);
		}
	}
	while(1){
		scanf("%s", str);
		if(strcmp(str, "END_OF_TEXT")==0){
			break;
		}
		else{
			len=strlen(str);
			for(i=0; i<len; i++){
				if(isalpha(str[i])){
					str[i]=tolower(str[i]);
				}
			}
			if(strcmp(str, W)==0){
				count++;
			}
		}
	}
	printf("%d\n", count);
	return 0;
}

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

int main() {
  double A, B, H, M, pi;
  cin >> A >> B >> H >> M;
  pi = 3.1415926535897932384626433832795028;
  double Dh = H / 12 + M / 60 / 12;
  double Dm = M / 60;
  double ma = max(Dh, Dm);
  double mi = min(Dh, Dm);
  double D = ma - mi;
  D *= 2 * pi;
  cout << fixed << setprecision(18);
  cout << sqrt(A * A + B * B - 2 * A * B * cos(D)) << endl;
}


Measured memory_bytes: 4252
#include <iostream>

using namespace std;

class Point{
public:
	int x;
	int y;

	Point(int x = 0, int y = 0){
		this->x = x;
		this->y = y;
	}

	int dot(Point other){
		int d =  (*this).x*other.x + (*this).y*other.y;
		return (*this).x*other.x + (*this).y*other.y;
	}

	int cross(Point other){
		return (*this).x*other.y - (*this).y*other.x;
	}

	int distsq(Point other){
		//int dx = (*this).x-other.x;
		//int dy = (*this).y-other.y;
		return ((*this).x-other.x)*((*this).x-other.x)+((*this).y-other.y)*((*this).y-other.y);
	}

	Point operator+(Point other){
		Point p;
		p.x = (*this).x + other.x;
		p.y = (*this).y + other.y;
		return p;
	}

	Point operator+=(Point other){
		(*this) = (*this)+other;
		return (*this);
	}

	Point operator-(Point other){
		Point p;
		p.x = (*this).x - other.x;
		p.y = (*this).y - other.y;
		return p;
	}

	Point operator-=(Point other){
		(*this) = (*this)-other;
		return (*this);
	}

	// cout 出力用
   friend ostream& operator << (ostream& os, const Point& p){
	   os << '(' << p.x << ", " << p.y << ')';
	   return os;
   }

};

class Triangle{
public:
	Point vertex[3];

	Triangle(Point a = Point(0,0), Point b = Point(0,0), Point c = Point(0,0)){
		vertex[0] = a;
		vertex[1] = b;
		vertex[2] = c;
	}

	bool isInclude(Point p){
		// 三角形ABCと点Pに関し、3つの外積 AB×AP, BC×BP, CA×CPの符号が同じであれば三角形の中
		int cnt = 0;
		for(int i = 0; i < 3; i++){
			Point vs = vertex[(i+1)%3] - vertex[i]; // 辺のベクトル
			Point vp = p - vertex[i];				// 各辺の始点→点Pのベクトル
			cnt += (vs.cross(vp) > 0)?1:-1;
		}
		cnt = (cnt>0)?cnt:-cnt;
		if(cnt == 3) return true;
		else return false;
	}
};

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

	while(n--){
		Triangle wall;
		Point a, b;
		for(int i = 0; i < 3; i++){
			cin >> wall.vertex[i].x >> wall.vertex[i].y;
		}
		cin >> a.x >> a.y >> b.x >> b.y;

		if(wall.isInclude(a)^wall.isInclude(b)) cout << "OK" << endl;
		else cout << "NG" << endl;
	}

	return 0;

}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

int main() {
	vector<int> A(3);
	for (int i = 0; i < 3; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	int x = 0;
	for (int j = 0; j < 2; j++) {
		x = x + A[j + 1] - A[j];
	}
	cout << x << endl;
}

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

int day(int M, int N){
    if(M % N == 0) return (M / N);
    return (M / N + 1);
}

int main(void){
    int L, A, B, C, D;
    cin >> L >> A >> B >> C >> D;

    if(day(A, C) >= day(B, D)) cout << (L - day(A, C)) << endl;
    else cout << (L - day(B, D)) << endl;

}



Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <cctype>

int main(void){
  int count=0;
  std::string word;
  std::string str;
  std::cin>>word;
  for(int i=0;i<word.size();i++){
    if(std::isupper(word[i])) word[i]=std::tolower(word[i]);
  }
  while(std::cin>>str){
    if(str=="END_OF_TEXT") break;
    for(int i=0;i<str.size();i++){
      if(std::isupper(str[i])) str[i]=std::tolower(str[i]);
    }
    if(word==str) count++;
  }
  std::cout<<count<<std::endl;
  return 0;
}



Measured memory_bytes: 3160
var
    a,b,c:longint;
procedure swap(var a,b:longint);
var
    t:longint;
begin
    t:=a;a:=b;b:=t;
end;
begin
    readln(a,b,c);
    if a<b then swap(a,b);if a<c then swap(a,c);
    writeln(a*10+b+c);
end.

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

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    
    auto judge = [](string a, string b) {
        int n1 = a.length();
        return a[n1-1] == b[0];
    };
    
    bool ans = true;
    set<string> str; str.emplace(s[0]);
    for (int i = 1; i < n; i++) {
        if (!judge(s[i-1], s[i])) ans = false;
        if (!str.insert(s[i]).second) ans = false;
    }
    
    cout << ((ans) ? "Yes" : "No") << endl;
    return 0;
}

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

int main()
{
    int n;
    cin>>n;
    unordered_set<string> st;
    string s[n];
    for(int i=0;i<n;++i)
    {
        cin>>s[i];
        st.insert(s[i]);
    }
    cout<<st.size()<<endl;
    return 0;
}

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

public class AtCoderA
{
    static void Main()
    {
        int n;
        long w;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            n = int.Parse(words[0]);
            w = long.Parse(words[1]);
        }

        Tuple<long, long>[] obj = new Tuple<long, long>[n];
        for (int i = 0; i < n; i++)
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            obj[i] = Tuple.Create(long.Parse(words[0]), long.Parse(words[1]));
        }

        long[,] dp = new long[n + 1, w + 1];
        for (int i = 0; i <= w; i++)
        {
            dp[0, i] = 0;
        }

        for (int i = 1; i <= n; i++)
        {
            long weight = obj[i - 1].Item1;
            long value = obj[i - 1].Item2;
            for (int j = 0; j <= w; j++)
            {
                if (j - weight >= 0)
                {
                    dp[i, j] = Math.Max(dp[i - 1, j], dp[i - 1, j - weight] + value);
                }
                else
                {
                    dp[i, j] = dp[i - 1, j];
                }
            }
        }

        Console.WriteLine(dp[n, w]);
    }
}

Measured memory_bytes: 89824
#E
N,K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))

A.sort(reverse=True)
F.sort()

left = 0
right = 10**12
while True:
    mid = (left+right)//2
    if right - left <= 1:
        count = 0
        for i in range(N):
            a = left//F[i]
            count+=max(0,A[i]-a)
        if count <= K:
            ans = left
        else:
            ans = right
        break
    
    
    count = 0
    for i in range(N):
        a = mid//F[i]
        count+=max(0,A[i]-a)
    if count <= K:
        right = mid
    else:
        left = mid
        
        

print(ans)
        
            



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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
	int x, a = 0;
	cin >> x >> a;
	int ans = 0;
	if (x < a)
	{
		ans = 0;
	}
	else if(x >= a)
	{
		ans = 10;
	}

	COUT(ans);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 100001
typedef struct {
    char a[10];
    int t;
}record;

record queue[N];
int head, tail;
void enQueue(record x){
    queue[tail] = x;
    tail = (tail+1)%N;
}
record deQueue(){
    record p = queue[head];
    head = (head+1)%N;
    return p;
}

int main(){
    int n, cmp;
    scanf("%d %d", &n, &cmp);
    for(int i = 0; i < n; i++){
        scanf("%s %d", queue[i].a, &queue[i].t);
    }

    head = 0, tail = n;
    int now = 0;
    while(head != tail){
        record top = deQueue();
        if(top.t <= cmp){
            now += top.t;
            printf("%s %d\n", top.a, now);
        }
        else{
            now += cmp;
            top.t -= cmp;
            enQueue(top);
        }
    }
    return 0;
}


Measured memory_bytes: 3384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
using namespace std;
#define MOD 998244353
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;
typedef bitset<4000> Num;

int N;
Num X, A[6];

Num in()
{
	char buf[4040];
	scanf("%s", buf);

	int len = strlen(buf);
	Num ret;
	for (int i = 0; i < len; ++i) {
		if (buf[i] == '1') ret.set(len - 1 - i);
	}
	return ret;
}

int msb(Num a)
{
	for (int i = 3999; i >= 0; --i) {
		if (a[i]) return i;
	}
	return -1;
}

Num gcd(Num a, Num b)
{
	for (;;) {
		int na = msb(a), nb = msb(b);
		if (na == -1) return b;
		if (nb == -1) return a;
		if (na < nb) {
			b ^= a << (nb - na);
		} else {
			a ^= b << (na - nb);
		}
	}
}

i64 toint(Num n)
{
	i64 ret = 0;
	for (int i = 3999; i >= 0; --i) {
		ret = ret * 2 % MOD;
		ret += n[i];
	}
	return ret;
}

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

	Num g = A[0];
	for (int i = 1; i < N; ++i) {
		g = gcd(g, A[i]);
	}
	int mg = msb(g);
	i64 ret = toint(X >> mg);

	Num waf = X, relka;
	for (int i = 3999; i >= mg; --i) {
		if (waf[i]) {
			waf ^= g << (i - mg);
			relka ^= g << (i - mg);
		}
	}
	bool toolarge = false;
	for (int i = mg - 1; i >= 0; --i) {
		int xi = X[i];
		int wi = relka[i];

		if (xi > wi) break;
		if (xi < wi) {
			toolarge = true;
			break;
		}
	}
	if (!toolarge) ADD(ret, 1);

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

	return 0;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())
a, b, c = 10000, 5000, 1000

for i in range(N + 1):
    for j in range(N - i + 1):
        if a * i + b * j + c * (N - i - j) == Y:
            print(i, j, (N - i - j))
            exit()

print(-1, -1, -1)


Measured memory_bytes: 40684
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] strlist = str.split(" ");
		int a = Integer.parseInt(strlist[0]);
		int b = Integer.parseInt(strlist[1]);
		int c = Integer.parseInt(strlist[2]);

		String answer = "NO";

		for(int i=0; i<b; i++){
			if((i*b+c) % a == 0){
				answer = "YES";
				break;
			}
		}
		System.out.println(answer);
	}


}


Measured memory_bytes: 21072
#include<cstdio>
#include<iostream>
#include<map>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
int main(){
	ll n,m;
	scanf("%lld%lld",&n,&m);
	ll ans=0;
	if(m==1&&n==1)
	{
		printf("0");
	}
	else
	{
		printf("%lld",n*(n-1)/2+(m-1)*m/2);
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
//#define int long long
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

ll dp[200010][3][2];

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	rep(i, n + 1) rep(j, 3) rep(k, 2) dp[i][j][k] = -INF;
	dp[0][0][0] = a[0];
	dp[0][1][1] = 0;
	rep(i, n) {
		rep(j, 3) {
			chmax(dp[i + 1][j][1], dp[i][j][0]);
		}
		rep(j, 2) {
			chmax(dp[i + 1][j + 1][1], dp[i][j][1]);
		}
		rep(j, 3) {
			if (i != n - 1) chmax(dp[i + 1][j][0], dp[i][j][1] + a[i + 1]);
		}
	}
	ll ans = -INF;
	if (!(n & 1)) rep(j, 2) rep(k, 2) chmax(ans, dp[n][j][k]);
	if (n & 1) rep(j, 2) rep(k, 2) chmax(ans, dp[n][j + 1][k]);
	cout << ans << '\n';
} 

Measured memory_bytes: 14276
k, n = map(int,input().split())
a = list(map(int,input().split()))
b = []
for i in range(1,n):
    l = a[i] - a[i-1]
    b.append(l)
    
b.append(k-a[-1] + a[0])
print(sum(b) - max(b))

Measured memory_bytes: 32244
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define ii pair<int,int>
#define st first
#define nd second
#define N 205
#define inf 1000000000
#define MOD 998244353
#define sz(x) ((int)x.size())
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
using namespace std;

int main(int arg,char* argv[]) {

	int n;
	double ans=0;

	cin>>n;

	for(int i=1;i<=n;i++) {

		int x;

		cin>>x;

		ans+=1.0/x;

	}

	cout<<fixed<<setprecision(15)<<1.0/ans;
 
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;



using Graph = vector<vector<int>>;

bool visit(int v, vector<int> &order, vector<int> &color, const Graph &g) {
    color[v] = 1;
    for (auto next : g[v]) {
        if (color[next] == 2) continue;
        if (color[next] == 1) return false;
        if (!visit(next, order, color, g)) return false;
    }
    order.push_back(v); color[v] = 2;
    return true;
}
bool topologicalSort(vector<int> &order, const Graph &g) {
    int n = g.size();
    vector<int> color(n, 0);
    rep(u, n) {
        if (!color[u] && !visit(u, order, color, g)) return false;
    }
    reverse(all(order));
    return true;
}



int main() {
    int N; cin >> N;
    vvi A(N, vi(N - 1));

    rep(i, N) {
        rep(j, N - 1) {
            cin >> A[i][j];
            A[i][j]--;
        }
    }

    int V = N * N;

    Graph G(V);

    rep(i, N) {
        rep(j, N - 2) { //試合i-j(i<j)を頂点N*i+jとして持つことにする
            int a = i; int b = i;
            int c = A[i][j]; int d = A[i][j + 1];
            if (a > c) swap(a, c);
            if (b > d) swap(b, d);
            G[a * N + c].pb(b * N + d);
        }
    }

    vi order;
    if (!topologicalSort(order, G)) {
        cout << -1 << endl;
        return 0;
    }
    int ans = 0;

    vi dp(V, 0);
    for (int i = V - 1; i >= 0; i--) {
        int from = order[i];
        for (auto to : G[from]) {
            chmax(dp[from], dp[to] + 1);
        }
        chmax(ans, dp[from]);
    }

    cout << ans + 1 << endl;

}



Measured memory_bytes: 53108
#include <stdio.h>
int main(void)
{
     int h,w,H,W;
    for(;;){
        scanf("%d %d",&H,&W);
    if(H==0 && W==0)break;
    for(h=0; h<H; h++){
        for(w=0; w<W; w++){
            if((w+h)%2==0)
            printf("#");
            else
            printf(".");
        }
        printf("\n");
        
    }
    printf("\n");
    }
    return 0;   
    
}


Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int n, m;

bool find(vector<vector<char>> &a, vector<vector<char>> &b, int x, int y){
  bool match=true;
  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
      if(b[i][j]!=a[i+x][j+y]){match=false;break;}
    }
    if(!match)break;
  }
  return match;
}

int main(){
  cin>>n>>m;
  vector<vector<char>> a(n, vector<char>(n)), b(m, vector<char>(m));
  for(int i=0;i<n;i++){
    string s;cin>>s;
    for(int j=0;j<n;j++)a[i][j]=s[j];
  }
  for(int i=0;i<m;i++){
    string s;cin>>s;
    for(int j=0;j<m;j++)b[i][j]=s[j];
  }
  bool ans=false;
  for(int x=0;x+m<=n;x++){
    for(int y=0;y+m<=n;y++){
      if(find(a, b, x, y)){ans=true;break;}
    }
    if(ans)break;
  }
  cout << (ans?"Yes":"No") << endl;
}


Measured memory_bytes: 256
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp,x,y;
string str;
set<ll> s;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>a;
	cin>>n;
	for(int i=0;i<n;i++)
	{
	    cin>>temp;
	    b+=temp;
	    
	}
	if(b>=a)
	{
	    cout<<"Yes";
	}
	else
	cout<<"No";
	
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
#define enld endl
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int K; cin >> K;
    int m = 7 % K;
    int ans = -1;
    for(int i=1;i<=K;i++){
        if(m % K == 0){
            ans = i;
            break;
        }
        m = (10 * m + 7) % K;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        Map<String, Integer> map = new HashMap<String, Integer>();

        for(int i = 0; i < n; i++){
            map.put(sc.next(), 0);
        }

        System.out.println(map.size());
    }
}


Measured memory_bytes: 77184
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
mod = 2019
if __name__ == "__main__":
    s = input()
    n = len(s)
    dp = [0]*(mod)
    dp[0] = 1
    r = 0
    t = 1
    for i in reversed(s):
        r += int(i)*t
        r%=mod
        t*=10
        t%=mod
        dp[r] +=1
    ans = 0
    for i in dp:
        ans += i*(i-1)//2
    print(ans)
    

    

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main (){
  int n,p;
  cin >> n >> p;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin >> a[i];
  ll dp[5001]={0};
  dp[0]=1;
  for(int i=1;i<=n;i++){
    for(int j=5000;j>=0;j--){
      if(j-a[i-1]>=0)
        dp[j]+=dp[j-a[i-1]];
    }
  }
  ll ans = 0;
  for(int i=0;i<5000;i++){
    if(p==0){
      if(i%2==0)
        ans+=dp[i];
    }else{
      if(i%2==1)
        ans+=dp[i];
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
    ll A,B;
    cin>>A>>B;
    ll ans=(A+B)/2;
    if((A+B)%2==0){
        cout<<ans<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }
}


Measured memory_bytes: 3560
/*
  coded by: mi_ni_
  "LIVE LONG AND PROSPER"
*/
 
#include <bits/stdc++.h>
using namespace std;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(fun) int tc; cin>>tc; while(tc--){ fun(); }
#define TEST_CASE_2 int tc; cin>>tc; for(int i=1;i<=tc;i++)
#define TEST_CASE_3(fun) int tc; cin>>tc; for(int i=1;i<=tc;i++){ cout<<"Case #"<<i<<": "; fun(); }
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define forab(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define forabr(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define all(x) x.begin(),x.end()
#define trav(i,x) for(auto& i:x)

using ll=long long int;
using ull=unsigned long long int;
using ld=long double;
using pii=pair<int, int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vl=vector<ll>;
using vii=vector<pii>;
using vll=vector<pll>;

const ld pi=acosl(-1);
const int inf=(int)1e9+7;
const ll INF=(ll)1e18+7;

//other
template<typename T> inline bool powerof2(T a){ return (a&&(!(a&(a-1)))); }
template<typename T> inline T log_2(T a){ T res=-1; while(a){ a/=2; res++; } return res; }

//make sure to choose TEST_CASE in main for multiple test cases
void solve(){
    int n,k;
    cin>>n>>k;
    vi arr(n+1);
    forab(i,1,n) cin>>arr[i];
    vi dp(n+1,inf);
    dp[1]=0;
    forab(i,2,n){
        forab(j,1,k){
            if(i-j>=1) dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
        }
    }
    cout<<dp[n]<<'\n';
}

int main(){
    FAST_IO
    cout<<fixed<<setprecision(10);
    //init_fact();
    //TEST_CASE(solve)
    //TEST_CASE_2{}
    //TEST_CASE_3(solve)
    solve();
    return 0;
}

Measured memory_bytes: 3972
import java.util.*;

public class Main{
  static int H, W;
  static char[][] field;
  static int[][] var, hor;
  static boolean[][] reached_v, reached_h;
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    H = Integer.parseInt(S[0]);
    W = Integer.parseInt(S[1]);
    
    field = new char[H][W];
    for(int i = 0; i < H; i++){
      String T = sc.nextLine();
      for(int j = 0; j < W; j++){
        field[i][j] = T.charAt(j);
      }
    }
    
    var = new int[H][W];
    hor = new int[H][W];
    reached_v = new boolean[H][W];
    reached_h = new boolean[H][W];
    
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if(!reached_v[i][j]){
          func(i,j,0,1);
        }
        if(!reached_h[i][j]){
          func(i,j,0,2);
        }
      }
    }
    int ans = 0;
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        int n = var[i][j] + hor[i][j];
        ans = ans < n ? n : ans; 
      }
    }
    System.out.println(ans-1);
  }
  
  public static int func(int h, int w, int count, int swi){
    if(h >= H || w >= W || h < 0 || w < 0){
      return count;
    }
    if(swi == 1){
      reached_v[h][w] = true;
      if(field[h][w] == '#'){
        return count;
      }
      return var[h][w] = func(h+1, w, count+1, 1);
    }else{
      reached_h[h][w] = true;
      if(field[h][w] == '#'){
        return count;
      }
      return hor[h][w] = func(h, w+1, count+1, 2);
    }
  }
}

Measured memory_bytes: 98976
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
double dp[301][301][301];
ll n;
double f(ll i,ll j,ll k){
 if(dp[i][j][k]!=-1) return dp[i][j][k];
 if(i==n) return dp[i][j][k]=0;
 ll l=n-(i+j+k);
 double ans=0;
 if(i) ans+=i*1.00/n;
 if(j) ans+=(1+f(i+1,j-1,k))*j/n;
 if(k) ans+=(1+f(i,j+1,k-1))*k/n;
 if(l) ans+=(1+f(i,j,k+1))*l/n;
 ans/=(1-i*1.00/n);
 return dp[i][j][k]=ans;
}
int main(){
 cin>>n;
 vector<ll> a(4,0);
 for(ll i=0;i<301;i++) for(ll j=0;j<301;j++) for(ll k=0;k<301;k++) dp[i][j][k]=-1;
 for(ll i=0;i<n;i++){
  ll in;
  cin>>in;
  a[in]++;
 }
 cout.precision(12);
 cout<<f(a[0],a[1],a[2])<<endl;
 return 0;
}

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

using namespace std;

const int maxd = 1002;

bool grid[maxd][maxd]; //true is a dot
int dp[maxd][maxd];
int H, W;

const int mod = 1000000007;

void add(int & a, int b) {
	a = (a+b)%mod;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> H >> W;
	string s;
	for (int i = 0; i < H; i++) {
		cin >> s;
		for (int j = 0; j < W; j++) {
			if (s[j] == '.') grid[i][j] = true;
			else grid[i][j] = false;
		}
	}
	dp[0][0] = 1;
	for (int i = 0; i < H; i++) {
		for  (int j = 0; j < W; j++) {
			if (i) add(dp[i][j], dp[i-1][j]);
			if (j) add(dp[i][j], dp[i][j-1]);

			if (!grid[i][j]) dp[i][j] = 0;
		}
	}

	cout << dp[H-1][W-1] << endl;


}

Measured memory_bytes: 5120
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
using namespace std;

int n, k;

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

    if ((n + 1) / 2 >= k)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
    int x,y;
    for(int i = 1;i <= 3000;i++){
        scanf("%d %d",&x,&y);
        if(x == 0&&y == 0){
            break;
        }
        else if(x <= y){
            printf("%d %d\n",x,y);
        }
        else{
            printf("%d %d\n",y,x);
        }
    }
    return 0;
    
}


Measured memory_bytes: 2740
package main

import (
	"fmt"
)

func main() {

	var N, K int
	fmt.Scan(&N, &K)

	ans := exec(N, K)

	fmt.Println(ans)
}

func exec(N, K int) int {
	if N%K == 0 {
		return 0
	}

	num := N % K
	diff := abs(num - K)

	if num < diff {
		return num
	} else {
		return diff
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	} else {
		return a
	}
}


Measured memory_bytes: 1768
a,b,n = map(int, input().split())
if b > n:
    ans = (a*n-(a%b))/b - a*((n-(n%b))/b)
else:
    x = b - 1
    ans = (a*x-(a%b))/b - a*((x-(x%b))/b)

print(int(ans))

Measured memory_bytes: 9124
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
	int N,max=-1,sum=0,p;

	cin >> N;
	
	for(int i=0;i<N;i++){
		cin >> p;
		sum = sum + p;
		if(p > max) max = p;
	}
	
	sum = sum - (max/2);
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256