akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
int t;
ll gcd(ll x,ll y){
    if(x<y)swap(x,y);
    if(x%y==0)return y;
    else return gcd(y,x%y);
}
int main(void){
    cin>>t;
    for(int i=0;i<t;i++){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        if(a<b||b>d){
            cout<<"No\n";
            continue;
        }
        if(b<=c+1){
            cout<<"Yes\n";
            continue;
        }
        a-=c;
        ll e=a%b,f=d-b;
        c=b-c;
        f=f%b;
        if(f==0){
            if(0<e&&e<c)cout<<"No\n";
            else cout<<"Yes\n";
            continue;
        }
        ll p=gcd(b,f);
        if(0<e&&e<c){
            cout<<"No\n";
            continue;
        }
        if(0<p-(b-e)%p&&p-(b-e)%p<c)cout<<"No\n";
        else cout<<"Yes\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
#define pb push_back
#define mp make_pair
#define inf 0x7fffffff
#define inff 100000
#define ff first
#define ss second
#define sz(x) ((int) (x).size())
#define fast cin.sync_with_stdio(0);cin.tie(0)
#define rep(i,N) for(int i = 0;i < N;i++)
#define frep(i,a,b) for(int i = a;i <= b;i++)
#define pii pair<int , int>
#define pll pair<ll , ll>
#define vii vector<int>
#define vpii vector< pii >
#define fill(A,v) memset(A,v,sizeof(A))
#define setbits(x) __builtin_popcountll(x)
#define print(A,j,k) for(int ii=j;ii<k;ii++)cout<<A[ii]<<" ";cout<<"\n"
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
#define SQRT 350
#define CASES int t;cin>>t;while(t--)
#define FILE freopen("inp.txt" , "r" , stdin);
#define ld long double

const int MOD = 1e9 + 7;
const int N = 1e6 + 500;
const int lgN = 20;
const ll INF = 1e16;

ll A[N] , L[N] , R[N];

int main(int argc, char const *argv[])
{
	fast;

	int n;
	cin >> n;

	frep(i , 1 , n)
		cin >> A[i];

	stack<int> S;

	//index of nearest element that is greater
	frep(i , 1 , n) {
		L[i] = 0;
		while (S.size() > 0) {
			int index = S.top();
			if (A[i] <= A[index])
				S.pop();
			else
				break;
		}
		if (S.size() > 0)
			L[i] = S.top();
		S.push(i);
	}

	while (S.empty() == false)
		S.pop();

	for(int i = n;i >= 1;i--) {
		R[i] = n + 1;
		while (S.size() > 0) {
			int index = S.top();
			if (A[i] <= A[index])
				S.pop();
			else
				break;
		}
		if (S.size() > 0)
			R[i] = S.top();
		S.push(i);
	}

	// print (L , 1 , n + 1);
	// print (R , 1 , n + 1);

	ll ans = 0;
	frep(i , 1 , n) {
		ll lo = L[i] + 1;
		ll hi = R[i] - 1;
		ll cnt = (i - lo + 1) * (hi - i + 1);
		ans += cnt * A[i];
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  char S;
  cin >> S;
  cout << (char)(S+1) << endl;
 return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int n, k, x = 1;
	cin >> n >> k;
	for( int i = n; i > 0; i-- ){
		if( x < k ){
			x *= 2;
		}else{
			x += k;
		}
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] input =Console.ReadLine().Split(' ');
      int A=int.Parse(input[0]);
      int B=int.Parse(input[1]);
      int C=int.Parse(input[2]);
      
      if((A==B&&A!=C)||(B==C&&B!=A)||(C==A&&C!=B)){
        Console.WriteLine("Yes");
      }else{
        Console.WriteLine("No");}
    
    }
    
  }

}

Measured memory_bytes: 11092
N=int(input())
a=list(map(int, input().split()))

flag=1
cnt=0
while flag==1:
  for i in range(N):
    if a[i]%2==0:
      a[i]=int(a[i]/2)
    else:
      flag=0
      break
  if flag==1:
    cnt+=1
print(cnt)


Measured memory_bytes: 3064
n, a, b, c, d = list(map(int, input().split()))
s = list(str(input()))

if c < d:
    ans = "Yes"
    for i in range(a,d-1):
        if s[i] == "#" and s[i+1] == "#":
            ans = "No"
        
if c > d:
    ans = "No"
    for i in range(b-2,d-1):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
                ans = "Yes"
    for i in range(a,c-1):
        if s[i] == "#" and s[i+1] == "#":
            ans = "No"

print(ans)

Measured memory_bytes: 4916
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 100005;

int n;
struct point{
	int x,y,t;
}a[N];

int main(){
	n=get();
	fo(i,1,n){
		a[i].t=get();
		a[i].x=get();
		a[i].y=get();
	}
	fo(i,1,n){
		int delt=a[i].t-a[i-1].t,w=abs(a[i].x-a[i-1].x)+abs(a[i].y-a[i-1].y);
		if ((delt&1)!=(w&1)||w>delt)return printf("No\n"),0;
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;

int main() {
  int N;
  cin>>N;
  int ans=0;
  si s;
  bool ok = true;
  rep(i,N) {
    int a; cin>>a;
    if (s.find(a) != s.end()) {
      ok = false;
      break;
    }
    s.insert(a);
  }
  puts(ok?"YES":"NO");
  return 0;
}

Measured memory_bytes: 9600
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;

int main()
{
  long long N, X;
  cin >> N >> X;

  long long width = X, height = N - X;
  long long res = height;
  while (width > 0) {
    long long over_iter = 1;
    if (width < height) over_iter = (height - 1) / width;

    res += width * 2 * over_iter;
    long long iter = (width - 1) / height;
    res += height * iter;

    long long new_width = width % height;
    height = height - new_width * over_iter;
    width = new_width;
  }

  cout << res << endl;
}


Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    string s; cin >> s;
    if(s.size() & 1){
        cout << "No" << '\n';
        return 0;
    }
    for(int i = 0; i < (int)s.size(); i += 2){
        if(s[i] != 'h' || s[i + 1] != 'i'){
            cout << "No" << '\n';
            return 0;
        }
    }
    cout << "Yes" << '\n';
}


Measured memory_bytes: 760
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int p[100000];
int y[100000];
int z[100000];
int ans[100000];
ll b[51][2];

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int  Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}void hSwap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}

void ShowData(int x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%d  ", x[i]);
	printf("\n");
}
void QSort(int x[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}

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

ll dfs(int n, ll x) {
	if (x < 1) {
		return 0;
	}
	else if (x >= b[n][0]) {
		return b[n][1];
	}
	else {
		ll v = 0;
		v+=dfs(n - 1, x - 1);
		if (x > b[n - 1][0] + 1)v++;
		if (x > b[n - 1][0] + 2) v += dfs(n - 1, x-(b[n - 1][0] + 2));
		return v;
	}
}


int main() {
	int n;
	ll x;
	scanf("%d%lld", &n,&x);
	b[0][0] = 1;
	b[0][1] = 1;
	REPS(i, n) {
		b[i][0] = b[i - 1][0] * 2 + 3;
		b[i][1] = b[i - 1][1] * 2 + 1;
	}
	ll ans=dfs(n,x);
	PRINTL(ans);
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;


signed main() {
    int X;
    cin>>X;
    if(X>=30)out("Yes");
    else out("No");
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define int long long
#define vin vector<int>
#define vcn vector<char>
#define ver pair<int,int>
#define pb push_back
#define ld long double
#define x first
#define y second
#define blush fflush(stdout);fflush(stdin);
#define $(a) (int)a.size()
#define scanf ;
#define printf ;
using namespace std;
void i_love_misaka_mikoto();
int32_t main(){
    #ifdef RNS
        freopen("input.txt","r",stdin);
        #ifndef DBG
            freopen("output.txt","w",stdout);
        #endif
    #else
        ios_base::sync_with_stdio(false);
    #endif
    i_love_misaka_mikoto();
    #ifdef RNS
        cout<<'\n'<<(ld)clock()/CLOCKS_PER_SEC<<'\n';
    #endif
    return 0;
}
int rz[(int)1e6+10];

void i_love_misaka_mikoto(){
    int n, w;
    cin>>n>>w;
    vector<ver> zn(n);
    for(int i=0;i<n;i++){
        cin>>zn[i].x>>zn[i].y;
    }
    for(int i=0;i<n;i++){
        for(int j=1e5+9;j>=0;j--){
            if(rz[j]||j==0){
                rz[j+zn[i].x]=max(rz[j+zn[i].x], rz[j]+zn[i].y);
            }
        }
    }
    int mx=0;
    for(int i=0;i<=w;i++){
        if(rz[mx]<=rz[i])mx=i;
    }
    cout<<rz[mx];
}

Measured memory_bytes: 1792
//AdditionandSubtractionEasy.cpp (A)
#include <iostream>
#include <string>
using namespace std;

int main(){
  long long A,B;
  char op;
  cin >> A >> op >> B;
  if(op == '+') printf("%lld\n",A+B);
  else printf("%lld\n",A-B);
  return 0;
}


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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

map<int, int> mp;
ll res = 0;
string s;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> s;
	mp[0]++;
	reverse(all(s));

	for (int i = 0, b = 1, acu = 0; i < s.size(); i++, (b *= 10) %= 2019) {
		(acu += (s[i] - '0') * b) %= 2019;
		res += mp[acu];
		mp[acu]++;
	}

	cout << res << endl;

	return 0;
}


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

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


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,m;
  cin>>n>>m;
  int a[111111];
  for(int i=0;i<n;i++)cin>>a[i];
  map<int,int> mp;
  a[0]%=m;
  mp[a[0]]++;
  for(int i=1;i<n;i++){
    a[i]+=a[i-1];
    a[i]%=m;
    mp[a[i]]++;
  }
  int sum=0;
  int k=0;
  for(int i=0;i<n;i++){
    sum+=mp[(m+k)%m];
    k=a[i];
    mp[a[i]]--;
  }
  cout<<sum<<endl;
  return 0;
}


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

bool check(int count[], int n)
{
	if (n == 0){
		return (true);
	}
	
	for (int i = 1; i <= 9 - 2; i++){
		if (count[i] > 0 && count[i + 1] > 0 && count[i + 2] > 0){
			count[i]--;
			count[i + 1]--;
			count[i + 2]--;
			if (check(count, n - 3) == true){
				return (true);
			}
			count[i]++;
			count[i + 1]++;
			count[i + 2]++;
		}
	}
	for (int i = 1; i <= 9; i++){
		if (count[i] >= 3){
			count[i] -= 3;
			if (check(count, n - 3) == true){
				return (true);
			}
			count[i] += 3;
		}
	}
	
	return (false);
}

int main(void)
{
	char in[256];
	int count[10];
	
	while (fgets(in, 256, stdin) != NULL){
		
		memset(count, 0, sizeof(count));
		for (int i = 0; i < 13; i++){
			count[in[i] - '0']++;
		}
		int temp[10];
		bool start = true;
		
		memcpy(temp, count, sizeof(count));
		for (int i = 1; i <= 9; i++){
			memcpy(count, temp, sizeof(count));
			if (count[i] < 4){
				count[i]++;
				
				bool flag = false;
				for (int j = 1; j <= 9; j++){
					if (count[j] >= 2){
						count[j] -= 2;
						if (check(count, 12) == true){
							flag = true;
							break;
						}
						count[j] += 2;
					}
				}
				if (flag == true){
					if (start == true){
						start = false;
						printf("%d", i);
					}
					else {
						printf(" %d", i);
					}
				}
				count[i]--;
			}
		}
		if (start == true){
			printf("0");
		}
		puts("");
	}
	
	return (0);
}

Measured memory_bytes: 0
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k = LI()
    if k == 2:
        print((pow(2,n,mod)+1)%mod)
    elif k == 3:
        print((pow(3,n,mod)+3)%mod)
    elif k == 4:
        print((pow(4,n,mod)+pow(2,n,mod)+4)%mod)
    elif k == 5:
        print((pow(5,n,mod)+pow(2,n,mod)+8)%mod)
    else:
        f = [-1]*(k+1)
        p = 2
        while p <= k:
            x = 2*p
            while x <= k:
                f[x] -= f[p]
                x += p
            p += 1
        ans = 0
        p = [1]
        for i in range(1,k+1):
            p.append(pow(k//i,n,mod))
        for i in range(1,k+1):
            res = p[i]
            x = 2*i
            j = 2
            while x <= k:
                res += p[x]*f[j]
                x += i
                j += 1
            ans += i*res
            ans %= mod
        print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;



int main(){
  int N;
  cin >> N;
  string c;
  cin >> c;
  vector<int> red, white;
  REP(i, N){
    if(c[i] == 'R'){
      red.push_back(i);
    }
    else{
      white.push_back(i);
    }
  }
  int w = white.size();
  int cnt = 0;
  REP(i, w){
    if(red.empty()) break;
    if(white[i] > red.back()) break;
    cnt++;
    red.pop_back();
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 4752
#include<iostream>
#include<vector>
#include<numeric>
using namespace std;
int main(){
int M,N,i;
long long int P,X,sum[110],total;
cin>>N;
vector<int> T(N);
for(i=0;i<N;i++){
 cin>>T[i];
 }
total = accumulate(T.begin(),T.end(),0);
cin>>M;
for(i=0;i<M;i++){
cin>>P>>X;
sum[i] = total -T[P-1] + X;
 }
for(i=0;i<M;i++){
cout<<sum[i]<<endl;
}
return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, ans = 0;
ll L[105];


int main(){
  cin >> N;
  for (int i = 0; i < N; i++) cin >> L[i];


  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      if (L[i] == L[j]) continue;
      for (int k = j + 1; k < N; k++){
        if (L[i] == L[k] || L[j] == L[k]) continue;

        ll a[3] = {L[i], L[j], L[k]};
        sort(a, a + 3);
        if (a[2] < a[0] + a[1]) ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n = INT()
    lis = [LIST() for _ in range(n)]
    ans = 0
    #print(*lis)
    for i in range(n):
        for j in range(i, n):
            ans += sqrt((lis[i][0] - lis[j][0]) ** 2 + (lis[i][1] - lis[j][1]) ** 2)
    m = factorial(n)
    ans *= 2 * factorial(n-1)
    #print(ans)
    print(ans/m)

if  __name__=='__main__':
    main()


Measured memory_bytes: 5400
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main(){
  ll n,k;
  cin>>n>>k;
  ll arr[n];
  for(ll i=0;i<n;i++){
    cin>>arr[i];
  }
  sort(arr,arr+n);
  if(k>=n){
    cout<<0<<endl;
  }
  else{
    ll p=n-k;
    ll cnt=0;
    for(ll i=0;i<p;i++){
      cnt+=arr[i];
    }
    cout<<cnt<<endl;
  }
  return 0;
}
    
  
  

Measured memory_bytes: 1792
#
import sys
import math
import numpy as np
import itertools

n = int(input())

a = [int(i) for i in input().split()] 

answer = 0
ren = 0
for i in range(1,n):
    if a[i] == a[i-1]:
        ren += 1
    else:
        if ren > 0:
            answer += (ren+1) // 2
            ren = 0
answer += (ren+1) // 2
print(answer)


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

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

  bool answer = false;
  for (int i = 1;i <= B ; i++){  
   if ((A*i)%B == C) {
     answer = true;
     break;
   }  
  }
   if(answer) cout << "YES" << endl;
   else cout << "NO" << endl;
}

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

int main() {
    int32_t n;
    cin >> n;
    int32_t a[n], b[n];
    
    int64_t answer = 0;

    for (int32_t i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }

    for (int32_t i = n - 1; i >= 0; i--) {
        int32_t m = (answer + a[i]) % b[i];
        if (m > 0) {
            answer += b[i] - m;
        }
    }
    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val c = sc.nextInt()
    val d = Array(c) { Array(c) { sc.nextInt() } }
    val col = Array(n) { Array(n) { sc.nextInt() - 1 } }
    val cost = Array(3) { Array(c) { 0L } }
    for (i in 0 until n) {
        for (j in 0 until n) {
            for (k in 0 until c) {
                cost[(i + j) % 3][k] += d[col[i][j]][k].toLong()
            }
        }
    }
    var min = Long.MAX_VALUE
    for (i in 0 until c) {
        for (j in 0 until c) {
            for (k in 0 until c) {
                if (i == j || j == k || i == k) continue
                min = minOf(min, cost[0][i] + cost[1][j] + cost[2][k])
            }
        }
    }
    println(min)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 57716
data = [int(i) for i in input().split(' ')]
N = data[0]
L = data[1]

s_list = []
for n in range(N):
    s = input()
    s_list.append(s)
    
s_list = sorted(s_list)
ans =''
for s in s_list:
    ans += s

print(ans)

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

#define int long long
#define rep(i,a,b) for(int i = a; i < b; i++)
const int mod = 1e9 + 7;

int S[10000];
int T[10000];
int dp[10000][10000];
bool checked[10000][10000];

int rec(int i, int j) {
    if (checked[i][j]) {
        return dp[i][j];
    }
    checked[i][j] = true;
    int res = 0;
    if (S[i-1] == T[j-1]) {
        res = rec(i,j-1) + rec(i-1,j);
    }
    else {
        res = rec(i,j-1) + rec(i-1,j) - rec(i-1,j-1);
    }
    res = (res + mod) % mod;
    dp[i][j] = res;
    return res;
}

signed main() {
    int N,M;
    cin >> N >> M;
    rep(i,0,N) cin >> S[i];
    rep(j,0,M) cin >> T[j];

    rep(i,0,N+1) {
        rep(j,0,M+1) {
            if (i == 0 || j == 0) {
                dp[i][j] = 1;
                checked[i][j] = true;
            }
            else {
                dp[i][j] = 0;
                checked[i][j] = false;
            }
        }
    }

    int ans = rec(N,M);
    cout << ans << endl;
}

Measured memory_bytes: 177792
while True:
    a, op, b= input().split()
    a = int(a)
    b = int(b)
     
    if op == "?":
        break
    elif op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(a//b)

Measured memory_bytes: 7708
def main():
    li = []
    for i in range(3):
        x,y,z = map(int,input().split())
        li.append(x)
        li.append(y)
        li.append(z)
    n = int(input())
    bingo_li = []
    for i in range(n):
        bingo_li.append(int(input()))
    ans_li = [0,0,0,0,0,0,0,0,0]
    for i in bingo_li:
        for j in range(9):
            if li[j] == i:
                ans_li[j] = 1
    if (ans_li[0] + ans_li[1] + ans_li[2] == 3):
        ans = "Yes"
    elif(ans_li[3] + ans_li[4] + ans_li[5] == 3):
        ans = "Yes"
    elif(ans_li[6] + ans_li[7] + ans_li[8] == 3):
        ans = "Yes"
    elif(ans_li[0] + ans_li[3] + ans_li[6] == 3):
        ans = "Yes"
    elif(ans_li[1] + ans_li[4] + ans_li[7] == 3):
        ans = "Yes"
    elif(ans_li[2] + ans_li[5] + ans_li[8] == 3):
        ans = "Yes"
    elif(ans_li[0] + ans_li[4] + ans_li[8] == 3):
        ans = "Yes"
    elif(ans_li[2] + ans_li[4] + ans_li[6] == 3):
        ans = "Yes"
    else:
        ans = "No"
    print(ans)

if __name__ == '__main__':
  main()

Measured memory_bytes: 3192
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	long long int n;
	cin >> n;
	vector<long long int> s;
	for (int i = 0; i < n; i++) {
		long long int a;
		cin >> a;
		s.push_back(a);
	}
	map<long long int, long long int> mp;
	for (int i = 0; i < n; i++) {
		mp[s[i]]++;
	}
	long long int sum = 0;
	for (auto i = mp.begin(); i != mp.end(); i++) {
		long long int a = i->second;
		sum = sum + a * (a - 1) / 2;
	}
	for (int i = 0; i < n; i++) {
		long long int ans = 0;
		long long int a = mp[s[i]];
		ans = a * (a - 1) / 2 - (a - 1) * (a - 2) / 2;
		cout << sum -ans << endl;
	}

}


Measured memory_bytes: 11120
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
using namespace std;


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


int main(){
  int n;
  cin >> n;
  vector<ll> A(n);
  rep(i, n) cin >> A[i];
  ll r = 0;
  ll s = 0, xs = 0;
  ll ans = 0;

  for(int l = 0; l < n; ++l){
    while(r < n && (s + A[r]) == (xs ^ A[r])){
      s += A[r];
      xs ^= A[r];
      r++;
    }

    ans += r - l;
    s -= A[l];
    xs ^= A[l];

  }

  cout << ans << endl;

}


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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  while(true){
    C -= B;
    if(C <= 0 ) break;
    A -= D;
    if(A <= 0) break;
  }
  if(C <= 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3596
#include <cstdio>
#include <iostream>
#include <utility>
#include <vector>
#include <string>

void bubblesort(std::vector<std::pair<char, int> > &array)
{
    std::pair<char, int> tmp;

    for (int i = 0; i < array.size(); i++) {
        for (int j = array.size() - 1; j > i; j--) {
            if (array[j].second < array[j - 1].second) {
                tmp = array[j];
                array[j] = array[j - 1];
                array[j - 1] = tmp;
            }
        }
    }
}

void selectionsort(std::vector<std::pair<char, int> > &array)
{
    for (int i = 0; i < array.size(); i++) {
        int min_index = i;
        for (int j = i; j < array.size(); j++) {
            if (array[j].second < array[min_index].second)
                min_index = j;
        }

        std::pair<char, int> tmp = array[i];
        array[i] = array[min_index];
        array[min_index] = tmp;
    }
}

bool isstable(std::vector<std::pair<char, int> > &stable, std::vector<std::pair<char, int> > &array)
{
    for (int i = 0; i < array.size(); i++) {
        if (stable[i].first != array[i].first)
            return false;
    }

    return true;
}

int main(int argc, char const *argv[])
{
    int n;
    std::cin >> n;
    // for bubble sort
    std::vector<std::pair<char, int> > vb(n);
    std::string input;

    for (int i = 0; i < n; i++) {
        std::cin >> input;
        vb[i].first = input[0];
        vb[i].second = input[1] - '0';
    }

    // for selection sort
    std::vector<std::pair<char, int> > vs = vb;

    bubblesort(vb);
    for (int i = 0; i < n - 1; i++) {
        std::cout << vb[i].first << vb[i].second << " ";
    }
    std::cout << vb[n - 1].first << vb[n - 1].second << std::endl;
    // bubble sort is known stable
    std::cout << "Stable" << std::endl;

    selectionsort(vs);
    for (int i = 0; i < n - 1; i++) {
        std::cout << vs[i].first << vs[i].second << " ";
    }
    std::cout << vs[n - 1].first << vs[n - 1].second << std::endl;

    // judge stability
    if (isstable(vb, vs))
        std::cout << "Stable" << std::endl;
    else
        std::cout << "Not stable" << std::endl;

    return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(a  > 0 || c > 0){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            break;
        }
        
    }


    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int N;
long long h[100010];

long long dp[100010];

int main(){
  int N; cin >> N;
  rep(i, N) cin >> h[i];

  rep(i, 100010) dp[i] = INF;

  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  REP(i, 2, N){
    chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
    chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
  }

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

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N;
    cin >> N;
    vector<int> prev(200000, -1), dp(N + 1);
    dp[0] = 1;
    for (int i = 0; i < N; ++i) {
        int C;
        cin >> C;
        C--;
        (dp[i + 1] += dp[i]) %= MOD;
        if ((i > 0 && prev[C] == i - 1) || prev[C] == -1) {
            prev[C] = i;
            continue;
        }
        (dp[i + 1] += dp[prev[C] + 1]) %= MOD;
        prev[C] = i;
    }

    cout << dp[N] << endl;
    return 0;
}


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int calc(int n){
    if(n == 1)return 1;
    return 1 + calc(n-1) * 2;
}

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

    double n,k;cin >> n >> k;
    vi a(n);
    rep(i,n)cin >> a[i];
    cout << ceil((n-1)/(k-1)) << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		double a=sc.nextDouble(),b=sc.nextDouble();
		double all =(a+b)/2;
		if(all%1==0)
			System.out.println((int)(all));
		else
			System.out.println((int)(all+1));
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <sstream>

#define repeat(x, y) for(int cnt##x = 0; cnt##x < y; cnt##x++)
using namespace std;

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

    if((N * K) % 2 == 0){
        cout << "Even" << endl;
    }else{
        cout << "Odd" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def solve():
	n=int(input())
	if n%2==0 or n%5==0:
		print(-1)
		return 
	ans=1
	p=7%n
	while(p!=0):
		p=(p*10+7)%n
		ans+=1
	print(ans)
if __name__ == "__main__":
	#code goes below
	# for _ in range(int(input())):
	solve()

Measured memory_bytes: 9172
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

static long gcd(long a, long b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

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;
}

map< long long int, long long int > prime_factor(long long int n) {//素因数分解
    map< long long int, long long int > ret;
    for(long long int i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}



int main() {
    long long int a,b;
    cin >> a >> b;
    if(a*b<=0){
        cout << "Zero" << endl;
    }else{
        long long int s=abs(b-a+1)%2;
        if(s==1&&a<0){
            cout << "Negative" << endl;
        }else if(a==b) {

                cout << "Positive" << endl;


        }else{
                cout << "Positive" << endl;
            }
        }
    }








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

int main() {
    int n,m,lmax,rmin;
    cin>>n>>m;
    vector<int> l(m),r(m);
    rep(i,m) cin>>l[i]>>r[i];
    lmax=l[0];
    rmin=r[0];
    for (int i=1; i<m; i++) {
        lmax=max(lmax,l[i]);
        rmin=min(rmin,r[i]);
    }
    if (lmax>rmin) cout<<0<<endl;
    else cout<<rmin-lmax+1<<endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Linq;
using System.IO;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
#if DEBUG
            ReadLine();
#endif
        }


        void Solve(ConsoleInput cin)
        {
            int[] l = cin.ReadIntArray(3);

            if(l[0]==l[1] && l[1] == l[2])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;

            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }

            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }

            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}

Measured memory_bytes: 11220
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <cmath>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
constexpr ll mod = 1000000007;

int main() {
    int N, W, v[100], w[100], dp[101][11001];
    cin >> N >> W;
    for (int i = 0; i < N; i++) {
        cin >> v[i] >> w[i];
    }
    auto m = [](int &a, int b) { a = max(a, b); };
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W; j++) {
            m(dp[i + 1][j], dp[i][j]);
            m(dp[i + 1][j + w[i]], max(dp[i][j] + v[i], dp[i + 1][j] + v[i]));
        }
    }
    cout << dp[N][W] << endl;
}



Measured memory_bytes: 7396
#include <string>  
#include <string.h>  
#include <iostream>  
#include <vector>  
#include <math.h>  
#include <stdio.h>  
using namespace std;  
const int maxn = 400200;  
int head[maxn],nxt[maxn],to[maxn],w[maxn];  
int flag[maxn];  
int sz;  
int n,m;  
int ans = 1;  
void init()  
{  
    for(int i=1;i<=n;i++) head[i]=-1,flag[i]=0;  
    sz=0;  
   
}  
void add(int u,int v,int ww)  
{  
    nxt[++sz]=head[u];  
    to[sz]=v;  
    w[sz]=ww;  
    head[u]=sz;  
   
}  
int dis[maxn];  
void dfs(int u,int pre)  
{  
    if(!ans) return;  
    for(int i=head[u];~i;i=nxt[i]){  
        int v = to[i];  
        if(v==pre) continue;  
        if(flag[v]){  
            if(dis[v]-dis[u]!=w[i]){  
                ans=0;  
                return;  
            }  
        }else{  
            flag[v]=1;  
            dis[v]=dis[u]+w[i];  
            dfs(v,u);  
        }  
    }  
}  
int main()  
{  
    scanf("%d %d",&n,&m);  
    init();  
    for(int i=1;i<=m;i++){  
        int l,r,d;scanf("%d %d %d",&l,&r,&d);  
        add(l,r,d);  
        add(r,l,-d);  
    }  
    for(int i=1;i<=n;i++){  
        if(flag[i]==0){  
            flag[i]=1;  
            dis[i]=0;  
            dfs(i,-1);  
        }  
    }  
    if(ans){  
        printf("Yes\n");  
    }else  
        printf("No\n");  
   
   
    return 0;  
}  

Measured memory_bytes: 11648
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main() {
  int N; cin >> N;
  vector<long long> L(N);
  for (int i = 0; i < N; i++) cin >> L[i];
  
 sort(L.begin(), L.end());
 
 long long res = 0;
 
  for (int i = 0; i < N; i++) {
   for (int j = i + 1; j < N; j++) {
     int k = lower_bound(L.begin(), L.end(), L[i] + L[j]) - L.begin();
     res += k - (j + 1);
   }
  }
  cout << res << endl;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int d;
int f[501][501];
void solve(int x, int y) {
    int q = x;
    if ( ( x + y) % 2 != 0) x++;
    int a = (x + y) / 2; int b = ( x - y) / 2; int t = d / 2;
    a = a % d; b = ((b % d) + d) % d;
    if ( a < t && b < t) cout << "R";
    else if ( a < t && b >= t) cout << "Y";
    else if ( a >= t && b < t) cout << "G";
    else cout << "B";

}
int main() {
    ios_base::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    cin >> d;
    if ( d % 2 != 0) {
        for ( int i = 1; i <= h; i++) {
            for ( int j = 1; j <= w; j++) {
                if ( ( i + j) % 2 == 0) cout << "R";
                else cout << "Y";
            }
            cout << '\n';
        }
        return 0;
    }
    for (int i = 1; i <= h; i++) {
        for ( int j = 1; j <= w; j++) {
            solve(i, j);
        }
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int64_t> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }

    partial_sum(A.begin(), A.end(), A.begin());

    int64_t ans = numeric_limits<int64_t>::max();
    int64_t P, Q, R, S;
    int low, mid, high;
    for(int r=1; r<N-2; r++) {
        low = 0;
        high = r;
        while(low + 1 < high) {
            mid =(low + high) / 2;
            if(2*A[mid] <= A[r]) {
                low = mid;
            } else {
                high = mid;
            }
        }
        if(max(A[low], A[r] - A[low]) - min(A[low], A[r] - A[low]) < max(A[high], A[r] - A[high]) - min(A[high], A[r] - A[high])) {
            P = A[low];
            Q = A[r] - A[low];
        } else {
            P = A[high];
            Q = A[r] - A[high];
        }

        low = r+1;
        high = N-1;
        while(low + 1 < high) {
            mid =(low + high) / 2;
            if(2*(A[mid] - A[r]) <= A[N-1] - A[r]) {
                low = mid;
            } else {
                high = mid;
            }
        }
        if(max(A[low] - A[r], A[N-1] - A[low]) - min(A[low] - A[r], A[N-1] - A[low]) < max(A[high] - A[r], A[N-1] - A[high]) - min(A[high] - A[r], A[N-1] - A[high])) {
            R = A[low] - A[r];
            S = A[N-1] - A[low];
        } else {
            R = A[high] - A[r];
            S = A[N-1] - A[high];
        }

        ans = min(ans, max({P, Q, R, S}) - min({P, Q, R, S}));
    }

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int A1,A2,A3,B;
  cin >> A1 >> A2 >>A3;
  
  B=A1+A2+A3;
  if(B>=22){
    printf("bust");
  }
  
  else{
    printf("win");
  }
  
}

Measured memory_bytes: 256