akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  ll n,k,r,s,p;
  cin>>n>>k>>r>>s>>p;
  string t;
  cin>>t;

  vector<string> st(k);
  rep(i,k){
    for(ll j=i;j<n;j+=k){
      st[i] += t[j];
    }
  }
  map<char,ll> score;
  score['r']=p;
  score['s']=r;
  score['p']=s;

  ll ans = 0;
  rep(i,k){
    using pcl = pair<char,ll>;
    vector<pcl> com;
    ll cnt=1;
    ll m = st[i].size();
    for(ll j=1;j<m;++j){
      if(st[i][j-1]!=st[i][j]){
        com.emplace_back(st[i][j-1],cnt);
        cnt=1;
      }else{
        cnt++;
      }
    }
    com.emplace_back(st[i][m-1],cnt);
    for(auto x:com){
      ans += (x.second+1)/2 * score[x.first];
    }
  }
  cout<<(ans)<<endl;

}

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

public class Main {
	static final int mod = (int) 1e9 + 7;
	static final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int[] DX8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, DY8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static final String nextLine = "\n";

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		boolean even = true;
		for(int i=0;i<n;i++) {
			int a = fs.nextInt();
			if(a % 2 != 0) even = false;
		}
		if(even)System.out.println("second");
		else System.out.println("first");
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

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

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

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

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

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

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

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

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

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

Measured memory_bytes: 34768
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+50;
int h[N];
int dp[N];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    memset(dp,127,sizeof(dp));
    dp[0]=0;
    //dp[1]=abs(h[1]-h[0]);
    for(int i=1;i<n;i++){
        for(int j=1;j<=k;j++){
            if(j>i)break;
            dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
        }
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 1024
// 問題の URL を書いておく
// 

#include <algorithm>
#include <bitset>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

int main(int, const char**)
{
    int a, b;
    cin >> a >> b;
    if(b == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    b -= a;
    int ans = 1;
    while(b > 0)
    {
        ans++;
        b -= (a - 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const int MAX=1e5+10;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    ll n,k;
    cin >> n >> k;
    ll ans1=n%k,ans2=k-ans1;
    ll ans=(ans1<ans2)?ans1:ans2;
    cout << ans << endl;
     
    return 0;   
}

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

int main(){
  int N;
  cin >> N;
  long long cnt[5] = {};
  string tag = "MARCH";
  for(int i = 0; i < N; ++i){
    string s;
    cin >> s;
    auto id = tag.find(s[0]);
    if(id == string::npos) continue;
    ++cnt[id];
  }
  long long ans = 0;
  for(int i = 0; i < 5; ++i){
    for(int j = 0; j < i; ++j){
      for(int k = 0; k < j; ++k){
        ans += cnt[i]*cnt[j]*cnt[k];
      }
    }
  }
  cout << ans << endl;
}


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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

ll n, a, x[50] = {}, dp[51][51][2501] = {};

int main() {
  cin >> n >> a;
  for(int i = 0;i < n;i++){
      cin >> x[i];
  }
  dp[0][0][0] = 1;
  for(int i = 0;i < n;i++){
      for(int j = 0;j < n;j++){
          for(int k = 0;k <= 2500;k++){
              dp[i+1][j][k] += dp[i][j][k];
              if(k-x[i] >= 0)dp[i+1][j+1][k] += dp[i][j][k-x[i]];
          }
      }
  }
  ll ans = 0;
  for(int i = 1;i <= n && i*a <= 2500;i++){
      ans += dp[n][i][i*a];
  }
  cout << ans << endl;
}


Measured memory_bytes: 50048
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		int k;
		List<Integer> spot = new ArrayList<>();

		Scanner scanner = new Scanner(System.in);
		
		for (int i = 0; i < 5; i++) {
			spot.add(scanner.nextInt());
		}
		k = scanner.nextInt();
		scanner.close();

		List<Integer> tmpSpot = new ArrayList<>(spot);
		
		for(int i = 0; i < 3; i++) {
			tmpSpot.remove(i);
			for (int l : tmpSpot) {
				if ((l - spot.get(i)) > k) {
					System.out.println(":(");
					return;
				}
			}
		}
		System.out.println("Yay!");
	}
}


Measured memory_bytes: 22100
while True:
    X = input().split()
    
    a = int(X[0])
    op = X[1]
    b = int(X[2])
    
    if op == '?' :
        break
        
    elif op == '+' :
        print("%d" %(a+b))
    elif op == '-' :
        print('%d' %(a-b))
    elif op == '/' :
        print('%d' %(a/b))
    else :
        print('%d' %(a*b))


Measured memory_bytes: 5596
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	cin >> s;
	int sum = 0, diff = 0;
	for (int i = 0;i < 4;++i) {
		if (s[i] == '+') {
			++sum;
		}
		else ++diff;
	}
	cout << sum - diff << endl;
	return 0;
}

Measured memory_bytes: 256
b1=input().split()
N=int(b1[0])
K=int(b1[1])

L=[0 for n in range(N)]
for k in range(K):
  n1=int(input())
  n2=input().split()
  for x in range(n1):
    L[int(n2[x])-1]+=1

A=0
for z in L:
  if z==0:
    A+=1

print(A)

Measured memory_bytes: 9136
#include <stdio.h>
#include <math.h>
int main(void){
	double xa,ya,xb,yb,ra,rb,d;
	int n;
	for(scanf("%d",&n);n--;){
		scanf("%lf%lf%lf%lf%lf%lf",&xa,&ya,&ra,&xb,&yb,&rb);
		d=hypot(xa-xb,ya-yb);
		if(d>ra+rb)puts("0");
		else if(ra>rb){
			if(ra>rb+d)puts("2");
			else puts("1");
		}else{
			if(rb>ra+d)puts("-2");
			else puts("1");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void){
    int n,i,b,f,r,v;
    int floor[4][3][10]={0};
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        floor[b-1][f-1][r-1]+=v;
    }
    for(i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                printf(" %d",floor[i][j][k]);
            }
            printf("\n");
        }
        if(i!=3){
            printf("####################\n");
        }
    }
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

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

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}

	ll ans = 0;
	int r = 0;
	int sum = 0;
	for (int l = 0; l < n; l++) {
		while (r < n && (sum ^ a[r]) == (sum + a[r])) {
			sum += a[r];
			r++;
		}
		ans += r - l;
		if (l == r) {
			r++;
		}
		else {
			sum -= a[l];
		}
	}

	out(ans);

	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  int tmp;
  int a=0, b=0, cnt=0;
  REP(i, n) {
    cin >> tmp;
    if(tmp % 4 == 0) a++;
    if(tmp % 2 == 1) b++;
    cnt++;
  }

  if(a >= b || (b-a == 1 && a+b == cnt)) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>

auto& in = std::cin;
auto& out = std::cout;

int64_t N;
int64_t A[100000];
int64_t B[100000];
int64_t BBB[100010];
int64_t C[100000];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (int32_t i = 0; i < N; i++)
	{
		in >> A[i];
	}std::sort(A, A + N);
	for (int32_t i = 0; i < N; i++)
	{
		in >> B[i];
	}std::sort(B, B + N);
	for (int32_t i = 0; i < N; i++)
	{
		in >> C[i];
	}std::sort(C, C + N);


	for (int32_t i = 0; i < N; i++)
	{
		BBB[i] = C+N-std::upper_bound(C,C+N,B[i]);
	}
	for (int32_t i = 2; i <= N; i++)
	{
		BBB[N-i] += BBB[N-i+1];
	}

	uint64_t res = 0;
	for (int32_t i = 0; i < N; i++)
	{
		auto beet = std::upper_bound(B, B + N, A[i]) - B;
		res += BBB[beet];
	}
	out << res << endl;

	return 0;
}
#endif


Measured memory_bytes: 3456
#include<cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
using namespace std;
typedef long long LL;

int a[105];

int main(){
	int n,sum1 = 0,sum2 = 0;
	cin >> n;
	for(int i = 1;i <= n;i++) cin >> a[i];
	sort(a + 1,a + 1 + n);
	int flag = 1;
	for(int i = n;i >= 1;i--){
		if(flag) sum1 += a[i],flag = 0;
		else sum2 += a[i],flag = 1;
	}
	cout << sum1 - sum2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;

#define LL long long

const int MAXN = 500000 + 5;

int a[MAXN], c[MAXN], last[MAXN], ans[MAXN];
vector<int> qu[MAXN], ind[MAXN];

void add (int N, int x, int v)
{
    for (; x <= N; x += x & -x){
        a[x] += v;
    }
}

int sum (int x)
{
    int ret = 0;
    for (; x > 0; x -= x & -x){
        ret += a[x];
    }

    return ret;
}


int main()
{
    int N, i, j, Q, l, r;
    cin >> N >> Q;
    for (i = 1; i <= N; i ++)
    {
        cin >> c[i];
    }
    for (i = 1; i <= Q; i ++){
        cin >> l >> r;
        qu[r].push_back(l);
        ind[r].push_back(i);
    }
    memset(last, 0, sizeof(last));
    memset(a, 0, sizeof(a));

    for (i = 1; i <= N; i ++)
    {
        if (last[c[i]] > 0)
        {
            add(N, last[c[i]], -1);
        }
        add(N, i, 1);
        last[c[i]] = i;
        for (j = 0; j < qu[i].size(); j ++)
        {
            r = i;
            l = qu[i][j];
            ans[ind[i][j]] = sum(r) - sum(l - 1);
        }
    }
    for (i = 1; i <= Q; i ++)
    {
        cout << ans[i] << endl;
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 53284
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
int64_t pair_counter(int n){
int64_t cnt=0;
  n--;
  for(int i=1;i<=n;i++){
    cnt+=i;}
  return cnt;
}
int main() {

    int64_t N,ans=0;
    cin >> N;
    vector<string> A(N);
  unordered_map <string,int> map;
    for(int i=0; i<N; i++){
      cin>>A[i];
      sort(A[i].begin(),A[i].end());
      if(map.count(A[i]))map[A[i]]++;
      else map[A[i]]=1;
    }
  for(auto i=map.begin(); i!=map.end(); i++){
    ans+=pair_counter(i->second);}
    // vector<vector<int>> A(N,vector<int>(M));
    // for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
    //sort(A.begin(),A.end());
    cout <<ans<< endl;
}


Measured memory_bytes: 17700
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

int GCD(int x, int y) {
	return x ? GCD(y % x, x) : y;
}

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using uint1024_t = mp::uint1024_t;
using namespace std;


int main() {
	int n, X;
	scanf("%d %d", &n, &X);
	int ans;
	bool initialize=true;
	rep(i, n) {
		int x;
		scanf("%d",&x);
		x = abs(x - X);
		if (initialize) {
			ans = x;
			initialize = false;
		}
		ans = GCD(x, ans);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
<?php
// unihernandez22
// https://atcoder.jp/contests/abc075/tasks/abc075_a
// implementation

$a = explode(" ",trim(fgets(STDIN)));
if ($a[0] == $a[1]) {
	echo $a[2];
} else if ($a[0] == $a[2]) {
	echo $a[1];
} else {
	echo $a[0];
}
?>


Measured memory_bytes: 16228
#include<bits/stdc++.h>
//#include"atcoder/all"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
//using namespace atcoder;
typedef long long ll;
int main(){
  cin.tie(nullptr);ios::sync_with_stdio(false);
  int N,Q,i,j,cnt;string s;cin >> N >> s >> Q;
  set<int> al[26];
  for(i=0;i<26;i++) al[i].insert(N);
  for(i=0;i<N;i++) al[s[i]-'a'].insert(i);
  int q,k,l,r;char c;
  for(i=0;i<Q;i++){
    cin >> q;
    if(q == 1){
      cin >> k >> c;k--;
      al[s[k]-'a'].erase(k);
      al[c-'a'].insert(k);
      s[k] = c;
    }
    else{
      cin >> l >> r;l--;r--;
      cnt = 0;
      for(j=0;j<26;j++) cnt += *al[j].lower_bound(l) <= r;
      cout << cnt << "\n"; 
    }
  }
}

Measured memory_bytes: 27164
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
typedef pair<int,int> P;

const int maxn = 309;
const int MOD = 1000000007;
int f[maxn][maxn][maxn];
vector<P> q[maxn];
int n, m, l, r, x, p, ans;

bool check(int r, int R, int G, int B){
	int l, x, cnt;
	for (int i=q[r].size()-1; i>=0; i--){
		l = q[r][i].first; x = q[r][i].second;
		cnt = (l <= R);
		cnt += (l <= G);
		cnt += (l <= B);
		if (cnt != x) return false;
	}
	return true;
}

int main(){
	scanf("%d%d", &n, &m);
	for (int i=1; i<=m; i++){
		scanf("%d%d%d", &l, &r, &x);
		q[r].push_back(make_pair(l, x));
	}
	f[0][0][0] = 1;
	for (int i=0; i<=n; i++)
		for (int j=0; j<=n; j++)
			for (int k=0; k<=n; k++){
				p = max(i, max(j, k));
				if (!check(p, i, j, k)) continue;
				if (p == n) ans = (ans + f[i][j][k]) % MOD;
				f[p+1][j][k] = (f[p+1][j][k] + f[i][j][k]) % MOD;
				f[i][p+1][k] = (f[i][p+1][k] + f[i][j][k]) % MOD;
				f[i][j][p+1] = (f[i][j][p+1] + f[i][j][k]) % MOD;
			}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 114944
#include <iostream>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;

int main(void) {
	int num, i, j;
	ll buf, x = 0, kk = 0, ans = 0;
	string k = "";
	cin >> num >> kk;
	buf = kk;
	while (buf > 0) {
		if (buf & 1)
			k = "1" + k;
		else
			k = "0" + k;
		buf >>= 1;
	}
	vector<ll> d(num);
	vector<int> a(k.size(), 0);
	for (i = 0; i < num; i++) {
		scanf("%lld", &d[i]);
		buf = d[i];
		j = 0;
		while (buf > 0 && j < k.size()) {
			if (buf & 1)
				a[j]++;
			buf >>= 1;
			j++;
		}
	}
	for (i = k.size() - 1; i >= 0; i--) {
		if ((a[i] << 1) < num) {
			if (x + (1ll << i) <= kk)
				x += (1ll << i);
		}
	}
	for (i = 0; i < num; i++)
		ans += (x ^ d[i]);
	cout << ans << "\n";
	return 0;
}

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

int main() {
  double n;
  cin >> n;
  if (n == 1) {
    cout << 1 << endl;
  } else {
    int mid = n / 2 + 0.5;
    double ans = mid / n;
    printf("%.10f\n", ans);
  }
  return 0;
}

Measured memory_bytes: 256
line_num = int(raw_input())
out_all = line_num * 3
out_now = 0
out_inning = 0
score = 0
runner = 0
while out_all > out_now:
	if out_inning > 2:
		print score
		out_inning = 0
		score = 0
		runner = 0
	EVENT = raw_input()
	if EVENT.find("HOMERUN") > -1:
		score += 1 + runner
		runner = 0
	if EVENT.find("HIT") > -1:
		runner += 1
		if runner > 3:
			runner = 3
			score += 1
	if EVENT.find("OUT") > -1:
		out_inning += 1
		out_now += 1
print score

Measured memory_bytes: 4240
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int blood[] = new int [4];
		while(sc.hasNext()){
			String[] str = sc.next().split(",");
			switch (str[1]){
			case "A": blood[0]++; break;
			case "B": blood[1]++; break;
			case "AB": blood[2]++; break;
			case "O": blood[3]++; break;
			}
			
		}
		for (int ans : blood) {
			out.println(ans);
		}
		out.flush();
	}
}

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

int main() {
  ll n,k;
  cin>>n>>k;
  ll ans;
  if(n<k) ans=min(n,abs(n-k));
  else if(n==k) ans=0;
  else ans = min(n%k,abs(n%k-k));

  cout<<ans<<endl;
 
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int taro[100];
  int hana[100];
  int n,m,flag;
  int tarom,hanam,sa;
  int anst,ansh;
  while(1){
    tarom=hanam=0;
    anst=ansh=1000000;
    cin>>n>>m;
    if(n==0&&m==0) return 0;
    for(int i=0;i<n;i++){
      cin >>taro[i];
      tarom+=taro[i];
    }
    for(int i=0;i<m;i++){
      cin >>hana[i];
      hanam+=hana[i];
    }
    sa=hanam-tarom;
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++) 
	if(sa==(hana[j]-taro[i])*2){
	  if((hana[j]+taro[i])<(anst+ansh)){
	    ansh=hana[j];
	    anst=taro[i];
	  }
	}
    if(ansh>10000) cout<<-1<<endl;
    else cout<<anst<<" "<<ansh<<endl; 
  }
}

Measured memory_bytes: 1160
import math

N, M = map(int, input().split())
mod = int(1e9+7)

if N < M:
    N, M = M, N

if N == M:
    ans = (2 * (math.factorial(N)) ** 2) % mod

elif N == M + 1:
    ans = ((math.factorial(M)) ** 2 * N) % mod

else:
    ans = 0

print(ans)

Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x,y,z,k;
  cin >> x >> y >> z >> k;
  vector<ll> A,B,C;
  ll tmp;
  int m = 1000;
  set<tuple <int,int,int> > used;
  REP(i,x){
      cin >> tmp;
      A.push_back(tmp);
  }
  SORT(A);REV(A);
  REP(i,y){
      cin >> tmp;
      B.push_back(tmp);
  }
  SORT(B);REV(B);
  REP(i,z){
      cin >> tmp;
      C.push_back(tmp);
  }
  SORT(C);REV(C);
  //cout << "a" << endl;
  priority_queue<pair<ll, tuple<ll, ll, ll> > > PQ;
  auto t = make_tuple(0,0,0);
  used.insert(t);
  PQ.push(make_pair(A[0]+B[0]+C[0],make_tuple(0,0,0)));


  while(k--){
      auto e = PQ.top();PQ.pop();
      ll e0 = get<0>(e.second);
      ll e1 = get<1>(e.second);
      ll e2 = get<2>(e.second);
      cout << A[e0]+B[e1]+C[e2] << endl;
      t = make_tuple(e0+1,e1,e2);
      if ( e0 < x-1 && used.count(t)!=1){
          PQ.push(make_pair(A[e0+1]+B[e1]+C[e2],t));
          used.insert(t);
      }
      t = make_tuple(e0,e1+1,e2);
      if ( e1 < y-1 && used.count(t)!=1){
          PQ.push(make_pair(A[e0]+B[e1+1]+C[e2],t));
          used.insert(t);
      }
      t = make_tuple(e0,e1,e2+1);
      if ( e2 < z-1 && used.count(t)!=1){
          PQ.push(make_pair(A[e0]+B[e1]+C[e2+1],t));
          used.insert(t);
      }          
      
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007


int main() {
  int D, G;
  cin >> D >> G;
  vi p(D), c(D);
  rep(i, D) cin >> p[i] >> c[i];

  int ans = 10000;

  rep(i, (1 << D)) {
    int point = 0;
    int res = 0;
    int k = -1;
    rep(j, D) {
      if (i & (1 << j)) {
        point += 100 * (j + 1) * p[j] + c[j];
        res += p[j];
      }
      else {
        k = j;
      }
    }
    if (point < G) {
      int y = 100 * (k + 1);
      int x = (G - point + y - 1) / y;
      if (x >= p[k]) continue;
      res += x;
    }
    ans = min(ans, res);
  }
  cout << ans << endl;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pll pair<ll,ll>
#define vll vector<ll,ll>
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define sz(x) (ll)x.size()
#define hell 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>b;i--)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define gcd(a,b) __gcd((a),(b))
#define EPS 1e-12
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define sqrt sqrtl
#define mod 1000000007
#define cbrt cbrtl
using namespace __gnu_pbds;
using namespace std;

int main()
{
  IOS

  ll n;
  cin>>n;
  ll i,ans=0;
  ll a[n+5];
  for(i=1;i<=n;i++)
  	cin>>a[i];
  sort(a+1,a+n+1);
  ll j;
  for(i=1;i<=n;i++)
  	for(j=i+1;j<=n;j++)
  	{
  		ll sum=a[i]+a[j];
  		ll ind=lower_bound(a+1,a+n+1,sum)-a;
  		ind--;
  		ll ind1=upper_bound(a+1,a+n+1,a[j]-a[i])-a;

  		ans+=(ind-ind1+1);
  		if(a[i]>=a[ind1] && a[i]<=a[ind])
  			ans--;
  		if(a[j]>=a[ind1] && a[j]<=a[ind])
  			ans--;
  		//cout<<a[i]<<" "<<a[j]<<" "<<ind<<" "<<ans<<"\n";
  	}
  	cout<<ans/3;
  return 0; 
  		
}

Measured memory_bytes: 256
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

N = None
K = None
A = None

def check(start):
    global N,K,A
    slow = A[start]
    fast = A[A[start]]
    while slow != fast:
        slow = A[slow]
        fast = A[A[fast]]

    slow = start
    while slow != fast:
        slow = A[slow]
        fast = A[fast]

    cycle_start = slow

    cycle_length = 1
    slow = A[slow]
    fast = A[A[fast]]
    while slow != fast:
        slow = A[slow]
        fast = A[A[fast]]
        cycle_length += 1

    return cycle_start, cycle_length

def main():
    global N,K,A
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    A = [""] + A
    start,length = check(1)
    current = 1
    count = 0
    for _ in range(K):
        if current == start:
            break
        current = A[current]
        count += 1
    if current != start:
        return current
    K = (K-count)%length
    for _ in range(K):
        current = A[current] 
    return current

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 34600
s=int(input())
n=len(str(s))
k=int(input())
S=[int(i) for i in str(s)]
dpl=[[0]*(k+1) for i in range(n+1)]
dpj=[[0]*(k+1) for i in range(n+1)]
dpj[0][0]=1
for i in range(n):
    for j in range(k+1):
        dpj[i+1][j]+=dpj[i][j]*(S[i]==0)
        dpl[i+1][j]+=dpl[i][j]+dpj[i][j]*(S[i]>0)
        if j<k:
            dpj[i+1][j+1]+=dpj[i][j]*(S[i]>0)
            dpl[i+1][j+1]+=dpl[i][j]*9+dpj[i][j]*max(0,S[i]-1) 
print(dpl[n][k]+dpj[n][k])

Measured memory_bytes: 3064
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
using namespace std;
const int MAXN = (int) 2e5 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;

int n;
int a[MAXN];

void work(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int cnt=0;
    for(int i=1;i<n;i++){
        int mi=i;
        for(int j=i;j<=n;j++){
            if(a[mi]>a[j]) mi=j;
        }
        if(mi!=i) cnt++;
        swap(a[i],a[mi]);
    }
    for(int i=1;i<n;i++) printf("%d ",a[i]);
    printf("%d\n%d\n",a[n],cnt);
}

int main(){
    work();
    return 0;
}








Measured memory_bytes: 2744
#include <iostream>

using namespace std;

int main() {
  int x, a, b, c;
  cin >> a >> b >> c >> x;
  int matched = 0;

  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++){
	if (500*i + 100*j + 50*k == x) matched += 1;
      }
    }
  }
  printf("%d\n", matched);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int inf=1e9+7;
signed main(){
    int n,m,a[100000];
    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    int lb=0,ub=inf*inf;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        int sum=0;
        for(int i=0;i<n;i++)
            sum+=a+n-lower_bound(a,a+n,mid-a[i]);
        (sum>=m?lb:ub)=mid;
    }
    int sum2=0;
    for(int i=0;i<n;i++)
        sum2+=a+n-lower_bound(a,a+n,lb-a[i]);
    int sum[100001]={};
    for(int i=0;i<n;i++)
        sum[i+1]=sum[i]+a[i];
    int ans=0;
    for(int i=0;i<n;i++)
        ans+=a[i]*(a+n-lower_bound(a,a+n,lb-a[i]))+sum[n]-sum[lower_bound(a,a+n,lb-a[i])-a];
    cout<<ans-(sum2-m)*lb<<endl;
}


Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Comparator;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            final int n = in.nextInt();
            List<Integer> a = new ArrayList<>();
            List<Integer> b = new ArrayList<>();
            List<Integer> c = new ArrayList<>();
            for (int i = 0; i < n; i++) a.add(in.nextInt());
            for (int i = 0; i < n; i++) b.add(in.nextInt());
            for (int i = 0; i < n; i++) c.add(in.nextInt());
            a.sort(Comparator.naturalOrder());
            c.sort(Comparator.reverseOrder());

            long ans = 0;
            for (int x : b) {
                if (a.get(0) >= x || c.get(0) <= x) continue;
                int min = 0;
                int max = n - 1;
                while (true) {
                    int mid = (min + max) / 2;
                    if (mid == min || mid == max) break;
                    if (a.get(mid) < x) min = mid;
                    else max = mid - 1;
                }
                long ba = (a.get(max) < x) ? max : min;
                min = 0;
                max = n - 1;
                while (true) {
                    int mid = (min + max) / 2;
                    if (mid == min || mid == max) break;
                    if (c.get(mid) > x) min = mid;
                    else max = mid - 1;
                }
                long bc = (c.get(max) > x) ? max : min;
                ans += ++ba * ++bc;
            }

            out.println(ans);
        }

    }
}



Measured memory_bytes: 97972
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
 
ll fastpower (ll b , ll p){
    ll k= p%2 ? b : 1 ;
    return p==0 ? 1 : k*(fastpower(b*b,p/2));
}

//ll p[100005],a[100005],v[100005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=1;i<=n;i++){
		ans+=(i*(n/i)*((n/i)+1))/2;
	}
	cout<<ans;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <set> 
using namespace std;

int main(void){
    // Your code here!　t 
    string S, T;
    cin >> S >> T;
    vector<int> I;
    int j;
    int k =  -1;
    if(int(S.length()) - int(T.length()) >= 0){
        for(int i = 0; i <= int(S.length()) - int(T.length()); i++){
            bool equal = true;
            j = 0;
            while(j < T.size()){
                if(S[i + j] == T[j]){
                    j++;
                } else if(S[i+j] == '?'){
                    j++;
                } else{
                    equal = false;
                    break;
                }
            }
        
            if(equal){
                k = 1;
                I.push_back(i);
            }
        }
    }
    
    set<string> ans;

    if(k == -1){
        cout << "UNRESTORABLE" << endl;
    } else{
        for(int e = 0; e < I.size(); e++){
            string tmp;
            for(int i = 0; i < S.length(); i++){
                if(I[e] <= i && i < I[e] + T.length()){
                    tmp += T[i-I[e]];
                } else if(S[i] == '?'){
                    tmp += "a";
                } else{
                    tmp += S[i];
                }
            }
            ans.insert(tmp);
        }
        
        cout << *ans.begin() << endl;

        
    }
    
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int H, W, N; cin >> H >> W >> N;
    map<pii, int> m;
    int dy[] = {-2, -1, 0};
    int dx[] = {-2, -1, 0};
    REP(i, N)
    {
        int a, b; cin >> a >> b;
        REP(j, 3)
        {
            REP(k, 3)
            {
                int ny = a+dy[j];
                int nx = b+dx[k];
                if(1 <= ny && ny <= H-2 && 1 <= nx && nx <= W-2)
                {
                    pii p(ny, nx);
                    if(m.find(p) == m.end()) m.insert(make_pair(p, 0));
                    m[p]++;
                }
            }
        }
    }
    ll c0 = (W-2) * (H-2);
    c0 -= m.size();
    cout << c0 << endl;
    REP1(i, 9)
    {
        int ans = 0;
        for(auto itr = m.begin(); itr != m.end(); itr++)
        {
            if(itr->second == i) ans++;
        }
        cout << ans << endl;
    }
}
    
signed main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 56576
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright © 2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>

using namespace std;

#define ll long long
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define INT_INF 0x7fffffff

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)

#define cio ios::sync_with_stdio(false); // Do not use it with "scanf" and other c input!

#define itn int
#define nit int
#define inr int
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


int main()
{
    ll a,b,n;
    scanf("%lld%lld%lld",&a,&b,&n);
    ll x;
    if (b <= n) x = b - 1;
    else x = n;
    printf("%lld\n",a * x / b - a * (x / b));
    return 0;
}


Measured memory_bytes: 3224
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         UNIQUE(v)                   v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
//int dx[]={0,0,1,-1,1,1,-1,-1};
//int dy[]={1,-1,0,0,1,-1,1,-1};


bool ispal(ll n){
    string s = "",t;
    while(n){
         s += (n%10)+'0';
        n /= 10;
    }
    t = s;
    reverse(all(t));
    return s==t;
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll a,b,cnt=0;
    sfl(a),sfl(b);
    for(ll i=a;i<=b;i++){
        if(ispal(i)) cnt++;
    }
    pfl(cnt);
    return 0;
}

Measured memory_bytes: 3764
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    l = list(map(int, readline().split()))

    ans = 0
    for i in range(n):
        a = l[i]
        for j in range(i + 1, n):
            b = l[j]
            if a == b:
                continue
            for k in range(j + 1, n):
                c = l[k]
                if a == c or b == c:
                    continue
                d = [a, b, c]
                d.sort()
                if d[0] + d[1] > d[2]:
                    ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68064
S = input()
l = len(S)
tmp0 = ''
tmp1 = ''
for i in range(l):
    if i&1:
        tmp0 += '0'
        tmp1 += '1'
    else:
        tmp0 += '1'
        tmp1 += '0'

cnt0 = 0
cnt1 = 0
for i in range(l):
    if S[i]==tmp0[i]:
        cnt0 += 1
    if S[i]==tmp1[i]:
        cnt1 += 1
print(min(cnt0,cnt1))

Measured memory_bytes: 3316
def main():
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())
    k = int(input())

    max_antena = max(a,b,c,d,e)
    min_antena = min(a,b,c,d,e)

    print('Yay!' if max_antena - min_antena <= k else ':(')

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main() {
    string a, b;
    cin >> a >> b;
    int ans = stoi(a+b);
    bool flag = false;
   // cout << ans << endl;
    rep(i, 1000) if(i*i == ans) flag = true;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


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

  ll n,a,b;
  cin>>n>>a>>b;

  a-=b;

  vector<ll> p(n);
  rep(i,n){
    cin>>p[i];
  }

  //————————————————二分探索——————————————————————————

  ll ng = 0;
  ll ok = 1e9;
  while (abs(ok - ng) > 1) {
    ll mid = (ng + ok) / 2;

    ll cnt=0;
    rep(i,n){
      ll x = p[i]-mid*b;
      if(x>0) cnt+=(x+a-1)/a;
    }
    (cnt<=mid? ok : ng) = mid;
  }

  cout << ok << endl;

//——————————————————————————————————————————


}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;
	int x = 0, y = 0;
	REP(i, n) {
		bool f = x + y < a + b && (s[i] == 'a' || (s[i] == 'b' && y < b));
		cout << (f ? "Yes" : "No") << endl;
		if (f && s[i] == 'a') ++x;
		if (f && s[i] == 'b') ++y;
	}
	return 0;
}

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

int main(){
  int n,h,w;
  cin >>n >>h >>w;
  cout << (n-h+1)*(n-w+1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

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

Measured memory_bytes: 3628
n = int(input())
a = list(map(int,input().split()))
mi = 0
for i in range(n):
  if a[i] < 0:
    mi+=1
  a[i]= abs(a[i])
if mi %2 == 1:
  print(sum(a)-2*min(a))
else:
  print(sum(a))

Measured memory_bytes: 14412
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    int k, x;
    cin >> k >> x;
    cout << x - k + 1;
    for (int i = x - k + 2; i <= x + k - 1; ++i) {
        cout << " " << i;
    }
    cout<< endl;

    return 0;
}

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

namespace ALDS1_4_A
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            int[] target = ReadIntAr();
            int m = ReadInt();
            int[] searchKeys = ReadIntAr();

            int cnt = 0;
            for (int i = 0 ; i < searchKeys.Length ; i++)
            {
                if (target.Contains(searchKeys[i])) cnt++;
            }
            Console.WriteLine(cnt.ToString());
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 20272
N,Y = list(map(int,input().split()))
flag_1000,flag_5000,flag_10000,flag = True,True,True,True
ans_10000,ans_5000,ans_1000 = -1,-1,-1

while flag:
    for num_10000 in range(N+1):
        if flag_5000 == False:
            flag = False
            break
        for num_5000 in range((N-num_10000)+1):
            if Y == 10000*num_10000 + 5000*num_5000 + 1000*(N-num_10000-num_5000):
                ans_10000,ans_5000,ans_1000 = num_10000,num_5000,N-num_10000-num_5000
                flag_5000 = False
                break
            if num_10000 == N:
                flag=False
print(ans_10000,ans_5000,ans_1000)

Measured memory_bytes: 3064