akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<algorithm>

using namespace std;
typedef long long int l;
#define mod 1000000007
#define t1 l t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define vl vector<l>
#define pb push_back
#define ub upper_bound
#define lb lower_bound

int main() {
fast;
string s;
cin>>s;
l c1=0;
for(l i=0;i<s.size();i++)
{
    l c=0;
    if(s[i]=='R'){
for(l j=i;j<s.size();j++)
{if(s[j]=='R')
c++;
else
break;
}}
if(c1<c)
c1=c;
}
cout<<c1<<"\n";

	return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

int main(){
	ll n;
	while(scanf("%lld",&n),n){
		n*=2;
		ll ans=0;
		rep(i,1,n+1)if(i*i<n&&n%i==0&&i%2!=n/i%2)ans++;
		printf("%lld\n",ans-1);
	}
}


Measured memory_bytes: 2104
n = gets.to_i
ss = n.times
  .map { gets.chomp[0] }
  .select { |s| %w(M A R C H).include?(s) }

counts = ss.each_with_object(Hash.new(0)) { |s, h| h[s] += 1 }

ans = counts.keys.combination(3).inject(0) do |r, (a, b, c)|
  r + counts[a] * counts[b] * counts[c]
end

puts ans


Measured memory_bytes: 10876
N,M = map(int, input().split())
a = [int(input()) for _ in range(M)]

step_normal = [True for _ in range(N+1)]

for i in range(M):
    step_normal[a[i]] = False

dp = [0 for _ in range(N+1)]
dp[0] = 1
for i in range(0,N):
    if step_normal[i+1] == True:
        dp[i+1] += dp[i]
    if N >= i+2 and step_normal[i+2] == True:
        dp[i+2] += dp[i]
print(dp[N] % 1000000007)    
        



Measured memory_bytes: 463512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int _;

int main()
{
    fastio();
    ll n,m;
    cin>>n>>m;
    ll s = 0,x;
    for(int i=0;i<m;i++) {cin>>x;s+=x;}
    if(n<s) cout<<-1<<endl;
    else cout<<n-s<<endl;
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}

const string YES = "Yes";
const string NO = "No";
#define judge(f) cout<<((f)?YES:NO)<<"\n";


int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    //solve(A, B, C, D);
    bool f=true;
    for (long long i = 0; i < 110; i++) {
        C-=B;
        if(C<=0){
            f=true;
            break;
        }
        A-=D;
        if(A<=0){
            f=false;
            break;
        }
    }
    judge(f);
    return 0;
}


Measured memory_bytes: 3692
gets
x = gets.split.map(&:to_f)
y = gets.split.map(&:to_f)
puts x.zip(y).inject(0) { |sum, (a,b)| sum += (a - b).abs }
puts Math.sqrt x.zip(y).inject(0) { |sum, (a,b)| sum += (a - b).abs ** 2 }
puts x.zip(y).inject(0) { |sum, (a,b)| sum += (a - b).abs ** 3 } ** (1.0 / 3.0)
a1,b1 = x.zip(y).max_by { |(a,b)| (a - b).abs }
puts (a1-b1).abs

Measured memory_bytes: 6204
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;
vector <pair <long long, int> > edges[2][100000];
long long d[2][100000];
void dijikstra(int S, int N, int ys){
    for(int i = 0; i < N; i++){
      d[ys][i] = LLONG_MAX;
    }
    priority_queue <pair<long long, int> , vector <pair<long long, int> >, greater<pair<long long, int> > > pq;
    d[ys][S] = 0;
    pq.push(make_pair(0, S));
    while(!pq.empty()){
        auto cur = pq.top();
        auto cur_cost = cur.first;
        auto cur_node = cur.second;
        pq.pop();
        if(d[ys][cur_node] < cur_cost){
            continue;
        }
        for(int i = 0; i < edges[ys][cur_node].size(); i++){
            auto next = edges[ys][cur_node][i];
            auto next_node = next.second;
            long long next_d = d[ys][cur_node] + next.first;
            if(d[ys][next_node] > next_d){
                d[ys][next_node] = next_d;
                pq.push(make_pair(next_d, next_node));
            }
        }
    }
}
 long long ans[100000];
int main(void){
  int n;
  int m;
  int s;
  int t;
  cin >> n >> m >> s >> t;
  for(int i = 0; i < m; i++){
    int u;
    int v;
    long long a;
    long long b;
    cin >> u >> v >> a >> b;
    edges[0][u - 1].push_back(make_pair(a, v - 1));
    edges[0][v - 1].push_back(make_pair(a, u - 1));
    edges[1][u - 1].push_back(make_pair(b, v - 1));
    edges[1][v - 1].push_back(make_pair(b, u - 1));
  }

  dijikstra(s - 1, n, 0);
  dijikstra(t - 1, n, 1);
  long long tmp = 0;
  
  for(int i = n - 1; i >= 0; i--){
    tmp = max(tmp, 1000000000000000 - d[0][i] - d[1][i]);
    ans[i] = tmp;
  }
  for(int i = 0; i < n; i++){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 19140
n, d = gets.chomp.split.map(&:to_i)
matrix = []
n.times do
  matrix << gets.chomp.split.map(&:to_i)
end

ret = 0
n.times do |i|
  (i + 1..n - 1).each do |j|
    sum = 0
    d.times do |k|
      sum += (matrix[i][k] - matrix[j][k])**2
    end
    sqrt = Math.sqrt(sum).to_i
    ret += 1 if [(sqrt - 1)**2, sqrt**2, (sqrt + 1)**2].include?(sum)
  end
end

puts ret

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

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

#define rep(i,n) for(i=1;i<=n;i++)
#define Rep(i,n) for(i=0;i<n;i++)
#define For(i,a,b) for(i=a;i<=b;i++)

#define pb(x) push_back(x)
#define sz(x) x.size()

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define eps 1e-11

#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define ss(ch) scanf("%s",ch)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d %d",x,y)
#define piii(x,y,z) printf("%d %d %d",x,y,z)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld %lld",x,y)
#define plll(x,y,z) printf("%lld %lld %lld",x,y,z)
#define ps(ch) printf("%s",ch)
#define Afridi 0
#define NL printf("\n")
#define debug(x) printf("wow  %d !!\n",x)
#define Max 500005
#define INF (LL)1e18
#define mod 1000000007
#define un(x) x.erase( unique( x.begin() , x.end() ) , x.end() )
#define pii pair<int,int>
#define _mp make_pair

#define FI freopen("in.txt","r",stdin)

#define D(x) cout << #x << " = " << (x) << endl
#define DD(x,y) cout << #x << " = " << x << "   " << #y << " = " << y << endl

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;


LL bigmod(LL b,LL p,LL m)
{
    if(p == 0)return 1;
    LL my = bigmod(b,p/2,m);
    my*=my;my%=m;
    if(p & 1)my*=b,my%=m;
    return my;
}
int setb(int n,int pos){return n=n | (1 << pos);}
int resb(int n,int pos){return n=n & ~(1 << pos);}
bool checkb(int n,int pos){return (bool)(n & (1 << pos));}

LL d1[Max],n,N;
char s[Max],str[Max];

void manodd()
{
	LL l=0, r=-1;
	for(LL i=0; i<n; ++i)
	{
		LL k = (i>r ? 1 : min (d1[l+r-i], r-i));
		while (i+k < n && i-k >= 0 && s[i+k] == s[i-k])++k;
		d1[i] = k--;
		if (i+k > r)l=i-k, r=i+k;
	}
}

///(id+1)*2 actual index, (id+1)*2-1 is between (id-1) and id
void make()
{
	LL k = 0;
	s[k++] = '$';
	for(LL i=0;i<n;i++)
	{
		s[k++] = '#';
		s[k++] = str[i];
	}
	s[k++] = '#';
	s[k] = 0;
	n = k;
}

int main()
{
	//FI;
	LL i;
	ss(str);
	n = strlen(str);
	/*N = n;
	make();
	manodd();
	LL ret = 0;
    Rep(i,N)
    {
		LL my = d1[ (i+1) * 2 ];
		my /= 2;
		D(my);
		ret += my;
    }
    rep(i,N-1)
    {
		LL my = d1[ (i+1)*2 -1 ] - 1;
		my /= 2;
		ret += my;
    }
    LL tot = N * (N + 1);
    tot /= 2;
    D(tot);
    tot -= ret;
    pl(tot + 1); NL;*/
    LL cnt[30];
    mem(cnt,0);
    Rep(i,n) cnt[ str[i] - 'a' ]++;
    LL ret = 0;
    Rep(i,26)
    {
		ret += ( cnt[i] * (cnt[i] + 1) ) / 2;
    }
    LL tot = (n * (n + 1)) / 2;
    tot -= ret;
    tot++;
    pl(tot); NL;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,k;
    cin>>n>>k;
    string s[n];
    for(i=0;i<n;i++)
    cin>>s[i];
    sort(s,s+n);
    for(i=0;i<n;i++)
    cout<<s[i];
    cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;
 
typedef pair<string,int> P;
 
int main(){
    int n,t,sh,sm,gh,gm,dt;
    string name;
    vector<P> v;
     
    cin >> n >> t;
    scanf("%d:%d" ,&sh ,&sm);
    cin >> name;
    scanf("%d:%d" ,&gh ,&gm);
    cin >> name;
     
    int tt = gh*60+gm;
    for(int i = 0 ; i < n-1 ; i++){
        scanf("%d:%d" ,&sh ,&sm);
        cin >> name;
        dt = 60*sh+sm - tt;
         
        if(dt >= t){
            v.push_back(P(name,dt));
        }
        scanf("%d:%d" ,&gh ,&gm);
        cin >> name;
        tt = gh*60+gm;
    }
     
    cout << v.size() << endl;
    for(int i = 0 ; i < v.size() ; i++){
        cout << v[i].first << ' ' << v[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 3300
#include <iostream>
using namespace std;
static const int MAX = 200000;

int main() {
    int R[MAX], n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> R[i];
    }

    int maxv = -2000000000;
    int minv = R[0];

    for (int j = 1; j < n; j++) {
        maxv = max(maxv, R[j] - minv);
        minv = min(minv, R[j]);
    }

    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 3876
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define F first
#define S second
#define pb push_back
#define all(c)  c.begin(), c.end()
#define vb vector<bool>
#define vll vector<ll>
#define vi vector<int>
#define vp vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define lb "\n"
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define INF 1000000007
#define MAX LLONG_MAX
#define PI 3.14159265358
ll max(ll x,ll y){if(x>y)return x;else return y;}
ll min(ll x,ll y){if(x>y)return y;else return x;}
ll dp[101][100001],dp2[101][100001];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
      #ifdef LOCAL
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
   ll i,j,k,h,w,p,n;
   cin>>n>>k;
   vll a(n);
   rep(i,0,n)
   cin>>a[i];
   rep(i,0,n+1)
   {
   dp[i][0]=1;
   dp2[i][0]=1;
   }
   rep(i,1,k+1)
   dp2[0][i]=dp2[0][i-1]+dp[0][i];
   rep(i,1,n+1)
   rep(j,1,k+1)
   {
       p=max(0,j-a[i-1]);
       if(p==0)
      dp[i][j]=dp2[i-1][j];
      else
        dp[i][j]=(dp2[i-1][j]-dp2[i-1][p-1]+INF)%(INF);
      dp2[i][j]=(dp2[i][j-1]+dp[i][j])%(INF);
   }
   cout<<dp[n][k];
}


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

using namespace std;

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

    int answer = 0;
    for(int i = 0; i < S.size(); i++)
        answer += (S[i] == '+' ? 1 : -1);

    cout << answer;
    return 0;
}


Measured memory_bytes: 256
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n;
const int MAXN = 202000;
int a[MAXN],sumo[MAXN],sume[MAXN],sumr[MAXN];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> n;
  for(int i=1;i<=n;i++){
    cin >> a[i];
    sume[i] = sume[i-1];
    sumo[i] = sumo[i-1];
    if(i&1){
      sumo[i] += a[i];
    }
    else {
      sume[i] += a[i];
    }
  }

  if(n%2==0){
    int ans = max(sume[n],sumo[n]);
    for(int i=1;i<=n;i++){
      if(i&1){
        int cur = sumo[i]+sume[n]-sume[i+1];
        ans = max(ans,cur);
      }
    }
    cout << ans << endl;
  }
  else {
    int ans = sume[n];
    multiset<int> s;
    s.insert(sume[n]);
    int sum = 0;
    for(int i=n;i>=3;i--){
      if(i&1){
        sum+=a[i];
        int cur = sum + sume[i-2];
        s.insert(cur);
        ans = max(ans, sumo[i-3]+sum);
        sumr[i]=cur;
      }
    }
    ans = max(ans,sumo[n-1]);
    ans = max(ans,sumo[n]-a[1]);
    // cerr << ans << endl;
    for(int i=1;i<n-2;i++){
      if(i%2==0)continue;
      if(i+2<=n){
        // cerr << i << endl;
        s.erase(s.find(sumr[i+2]));
      }
      auto it = s.end();it--;
      ans = max(ans, sumo[i]+(*it)-sume[i+1] );
    }
    cout << ans << endl;
  }


return 0;
}
///....


Measured memory_bytes: 14540
n,m=[int(j) for j in input().split()]
a=[int(j) for j in input().split()]
l=set()

for i in a:
    if i%2==0:
        l.add(i//2)
    else:
        print(0)
        exit()

c=1
l=list(l)
p=l[0]
while True:
    if p%2==0:
        c*=2
        p=p//2
    else:
        break

for i in l:
    if i%c!=0:
        print(0)
        exit()
    if (i//c)%2==0:
        print(0)
        exit()


def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)

#最小公倍数
def lcm(x,y):
    return x*y//gcd(x,y)

p=1
for i in l:
    p=lcm(p,i)


ans=m//p
import math
print(math.ceil(ans/2))







Measured memory_bytes: 14244
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vlll = vector<vll>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
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; }
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
//AtCoder以外ではコメントアウトを忘れずに！
//#include <atcoder/all>
//using namespace atcoder;
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, LIS, digitDP, treeDP, Rerooting//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA, FordFulkerson//
ll i, j, k, l; ll N, M, K, H, W, X, Y, Z, R, Q, T;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vll path; vs S;
//***********//
int main() {
	cin >> N;
	ll count = 0;
	ll ans = 0;
	for (i = 0; i < N; i++) {
		ll a, b;
		cin >> a >> b;
		if (a == b) count++;
		else count = 0;
		if (count >= 3) {
			ans = 1;
		}
	}
	if (ans) cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 3640
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String op = sc.next();
        int b = sc.nextInt();

        if (op.equals("+")){
            System.out.println(a+b);
        }else if(op.equals("-")){
            System.out.println(a-b);
        }
    }
}


Measured memory_bytes: 35712
// https://atcoder.jp/contests/abc085/tasks/abc085_b
// B - Kagami Mochi
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// 標準入力から改行かスペースまで読み取り、数字として返す
int get_num() {
    // 10文字+区切り文字までしか受け付けられない
    char s[11];
    int i, n;
    // scanf()の直後は改行が入力に残っているので、
    // 最初の改行は読み飛ばす
    do {
        s[0] = getchar();
    } while (s[0] == '\0' || s[0] == '\n');
    for (i = 1; i < sizeof(s); i++) {
        s[i] = getchar();
        if (s[i] == ' ' || s[i] == '\n') {
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}

int main(void) {
    int d[100] = {0};
    int input;
    int n;
    int count = 0;
    n = get_num();

    for (int i = 0; i < n; i++) {
        input = get_num();
        if (d[input-1]==0){
            d[input-1] = 1;
            count++;
        }
    }
    
    printf("%d\n", count);
    
    return 0;
}


Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := range as {
		fmt.Scan(&as[i])
	}
	counter := make(map[int]int)
	for _, a := range as {
		counter[a]++
	}
	max := 0
	for k, cnt := range counter {
		if cnt > 1 && k > max {
			max = k
		}
	}
	counter[max] -= 2
	second := 0
	for k, cnt := range counter {
		if cnt > 1 && k > second {
			second = k
		}
	}
	fmt.Println(max * second)
}


Measured memory_bytes: 8704
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoderSolve.Tool;

namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;

        
        
        //static char[] s;
        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            var input = cin.SplitReaderL();
            long Q = input[0];
            long H = input[1];
            long S = input[2];
            long D = input[3];
            long N = int.Parse(Console.ReadLine());

            long Pmin = Min(4 * Q, Min(2 * H, S));
            long ans = 0;

            if (Pmin > (double)D / 2)
            {
                ans += (N / 2) * D;
                ans += (N % 2) * Pmin;
            }
            else
            {
                ans += N * Pmin;
            }

            Console.WriteLine(ans);


            

            //Console.Out.Flush();
        }

        

    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for(var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }

    struct Pair<T> : IComparable<Pair<T>> where T : IComparable<T>
    {
        public T variable;
        public int index;

        public Pair(T val, int i)
        {
            variable = val;
            index = i;
        }

        public int CompareTo(Pair<T> otherPair)
        {
            return variable.CompareTo(otherPair.variable);
        }

        public int CompareIndex(Pair<T> otherPair)
        {
            return index.CompareTo(otherPair.index);
        }
    }



}






Measured memory_bytes: 13268
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>

//#define NDEBUG

#ifdef NDEBUG
#define DEBUG_PRINT(fmt, ...) ((void)0)
#else
#define DEBUG_PRINT(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#endif
#define ASSERT_RANGE(min,x,max) assert(((x)>=(min)) && ((x)<=(max)))


#define N_MIN 1
#define N_MAX 20

int sort_int(int *a, int N) {// {{{
	int i;
	for (i = 0; i < N-1; i++) {
		int j;
		for (j = i + 1; j < N; j++) {
			if (a[i] > a[j]) {
				int tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
	return 0;
}// }}}

int main(int argc, char **argv) {
	int A,B;
	fscanf(stdin,"%d%d",&A,&B);
	ASSERT_RANGE(N_MIN,A,N_MAX);
	ASSERT_RANGE(N_MIN,B,N_MAX);

	if ((A<10)&&(B<10)) {
		fprintf(stdout,"%d\n",A*B);
	} else {
		fprintf(stdout,"-1\n");
	}
	return 0;
}



Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long mLL;

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

    mLL A[N],smaller=0,bigger=0;
    for(int i=0;i<N;i++){
		scanf("%lld",&A[i]);
	}
	sort(A,A+N);
	int K=N/2;
	
	if(N%2)
	{
		for(int i=0;i<K;i++) smaller+=A[i];
		for(int i=K+1;i<N;i++) bigger+=A[i];
		mLL pattern1 = 2*bigger - 2*smaller + A[K-1] - A[K];
		mLL pattern2 = 2*bigger - 2*smaller - A[K+1] + A[K];
		printf("%lld\n", pattern1>pattern2?pattern1:pattern2);
	}
	else
	{
		for(int i=0;i<K;i++) smaller+=A[i];
		for(int i=K;i<N;i++) bigger+=A[i];
		printf("%lld\n",2*bigger-A[K]-2*smaller+A[K-1]);
	}

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define R cin>>
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

int main() {
  int n,m;
  while(cin >> m >> n && n) {
    string s[n];
    rep(i,n) R s[i];
    string d[n][m];
    string ans="";
    rep(i,n)rep(j,m){
      d[i][j]="";
      if(s[i][j]=='0') ans="0";
    }
    rep(sx,n){
      rep(sy,m){
	if(isdigit(s[sx][sy]) && s[sx][sy]!='0' && d[sx][sy]=="") {
	  queue<P> que;
	  que.push(P(sx,sy));
	  d[sx][sy]=s[sx][sy];
	  while(!que.empty()) {
	    P p=que.front();que.pop();
	    int nx=p.F,ny=p.S;
	    if(ans.size()<d[nx][ny].size()) ans=d[nx][ny];
	    else if(ans.size()==d[nx][ny].size()) ans=max(ans,d[nx][ny]);
	    REP(i,1,3) {
	      int x=nx+dx[i],y=ny+dy[i];
	      if(check(n,m,x,y) && isdigit(s[x][y])) {
		if(d[x][y].size()>d[nx][ny].size()+1) continue;
		if(d[x][y].size()==d[nx][ny].size()+1) {
		  if(d[x][y]>=d[nx][ny]+s[x][y]) continue;
		}
		d[x][y]=d[nx][ny]+s[x][y];
		que.push(P(x,y));
	      }
	    }
	  }
	}
      }
    }
    pr(ans);
  }
  return 0;
}


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


int main(){
  int n, m; cin >> n >> m;
  vector<vector<int>> v(m,vector<int>(0));

  for(int i = 0; i < m; i++){
    int a; cin >> a;
    for(int j = 0; j < a; j++){
      int b; cin >> b;
      v[i].push_back(b);
    }
  }

  vector<int> p(m, 0);
  for(int i = 0; i < m; i++){
    cin >> p[i];
  }
  int res;
  bool f;
  int cnt = 0;
  for (int bit = 0; bit < (1<<n); ++bit){
    f = false;
    for(int i = 0; i < m; i++){
      res = 0;
      for(int j = 0; j < v[i].size(); j++){
        if(bit & (1<<v[i][j]-1)){res++;}
      }
      if(res % 2 != p[i]){f = true; break;}
    }
    if(!f){cnt++;}
  }

  cout << cnt << endl;
  

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int n,l[1<<18],r[1<<18];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",l+i,r+i);
	sort(l+1,l+1+n);
	sort(r+1,r+1+n);
	if(n&1)printf("%d\n",r[n+1>>1]-l[n+1>>1]+1);
	else printf("%d\n",r[n/2+1]+r[n/2]-l[n/2]-l[n/2+1]+1);
	return 0;
}

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

int main(){
    int N, W;
    cin >> N >> W;
    int dp[W+1];
    fill_n(dp, W+1, -1);
    dp[0] = 0;
    vector<int> v(N);
    vector<int> w(N);
    for(int i = 0; i < N; i++) cin >> v[i] >> w[i];

    for(int i = 0; i < N; i++){
        for(int j = W; j >= w[i]; j--){
            dp[j] = max(dp[j], dp[j-w[i]]+v[i]);
        }
    }

    cout << *max_element(dp, dp+W+1) << endl;
}


Measured memory_bytes: 3128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
//    return *(int*)a - *(int*)b;
    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

int main()
{
  int a ,b, c, d, e, X, Y;
//  long long  b, c, d, e, X, Y;
  //  double  c;
  long long  A[200003]={};
  long long  B[100003]={};
  int  C[100003][2]={};

  int  flag[103]={};

//  long long  a, b, c, d, X, Y;
  char s[101][101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
//  int flag=0;
//  int tmp=0;
  char tmp[101]={};
//  int min=1000000;
  long long min=100000001;
  int len=0;
  int l=0;
  int r=1000001;
  int cnt=0;
  int num=0;
  int ans=0;
  int max=0;
  int addr=0;
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
//  scanf("%d%d", &a,&c);
//  cnt = strlen(t);
// printf("%d\n",a);
    scanf("%d", &a);
  for(i=0;i<a;i++){
    scanf("%s%d", &s[i],&C[i][0]);
    C[i][1]=i+1;
  }

  
  for(i=1;i<a;i++){
    for(j=1;j<a;j++){
      if(strcmp(s[j-1], s[j])>0){
        strcpy(tmp, s[j-1]);
        strcpy(s[j-1], s[j]);
        strcpy(s[j], tmp);
        num=C[j-1][0];
        C[j-1][0]=C[j][0];
        C[j][0]=num;
        num=C[j-1][1];
        C[j-1][1]=C[j][1];
        C[j][1]=num;
      }
    }
  }
  for(i=1;i<a;i++){
    for(j=1;j<a;j++){
        if(strcmp(s[j-1], s[j])==0){
          if(C[j-1][0]<C[j][0]){


        num=C[j-1][0];
        C[j-1][0]=C[j][0];
        C[j][0]=num;
        num=C[j-1][1];
        C[j-1][1]=C[j][1];
        C[j][1]=num;
        }
      }
    }
  }
  for(i=0;i<a;i++){
//    printf("%s %d %d\n", s[i],C[i][0],C[i][1]);
    printf("%d\n", C[i][1]);
  }
/*  for(i=0;i<addr;i++){
//  scanf("%lld%lld", &B[0][i],&B[1][i]);
//    ans=ans+A[i];
    printf("%lld ", A[i]);
  }
*/
//    printf("%d ", cnt);
   
//  ans=a*3;
//  ans=(ans+b)/2;
//  printf("%d\n", ans);

  
//  printf("%lf\n",ans);
  //  //  if(flag==0)   printf("TLE\n");
//    if(max < cnt - max)  printf("Yes\n");
//    else  printf("No\n");
  
return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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 ll MRINF = 5000000000000000;

int main() {

    ll N; cin >> N;
    ll ans = 0;

    REP1(i, N+1){
        ll syoko = i;
        ll makko = N/i * i;
        ll kousa = i;
        ll kousu = N/i;
        ans += kousu * (syoko+makko) / 2;
    } 
    cout << ans << endl;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

void swap(int *n1, int *n2) {
    int tmp = *n1;
    *n1 = *n2;
    *n2 = tmp;
}

int main(void) {
    int n, m;
    get_int2(&n, &m);
    if(n > m) swap(&n, &m);
    int64_t ans = 0;
    if(n == 1) {
        if(m == 1) {
            ans = 1;
        } else {
            ans = m - 2;
        }
    } else {
        ans = (int64_t)(n-2)*(m-2);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
def diff_number(runrun_num: int, master_num: int = 753) -> int:
    return abs(753 - runrun_num)


def main():
    s = input()
    min_diff = int(s[0:3])
    for i in range(3, len(s) + 1):
        runrun_num = int(s[(i - 3):i])
        
        if diff_number(runrun_num) < diff_number(min_diff):
            min_diff = runrun_num
    print(diff_number(min_diff))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9084
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N;
  int A, B;
  cin >> N >> A >> B;
  auto sum = [](int n){
    string s = std::to_string(n);
    return boost::accumulate(s, 0, [](int r, char c){ return r + (c - '0'); });
  };

  ll res{};
  while (N) {
    auto s = sum(N);
    if (s >= A && s <= B) {
      res += N;
    }
    --N;
  }
  cout << res << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


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

int main(){
    LL N, M;
    cin >> N >> M;
    LL mm = 1;
    for(int i = 0;i < M;i++)    mm *= 2;
    LL ans = (1900*M+100*(N-M))*mm;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    private static final int MAXN = 100001;

    public static void main(String[] args) {
        var scanner = new Scanner(System.in);
        int n, m;
        var h = new int[MAXN];
        var paths = new ArrayList<ArrayList<Integer>>();

        n = scanner.nextInt();
        m = scanner.nextInt();
        for (int i = 0; i < n; ++i) {
            h[i] = scanner.nextInt();
        }
        for (int i = 0; i < n; ++i) {
            paths.add(new ArrayList<>());
        }
        for (int i = 0; i < m; ++i) {
            int a = scanner.nextInt() - 1, b = scanner.nextInt() - 1;
            paths.get(a).add(b);
            paths.get(b).add(a);
        }

        int count = 0;
        for (int i = 0; i < n; ++i) {
            boolean flag = true;
            for (Integer j: paths.get(i)) {
                if (h[j] >= h[i]) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                count++;
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 72208
#include <stdio.h>

int main(void){
int temp,a,b,c;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  temp=a;
  a=b;
  b=temp;
  temp=a;
  a=c;
    c=temp;
  printf("%d %d %d\n", a, b, c);
  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;

bool used[30];
vector<string> vec;
int main(){
  string s;
  int K;
  cin>>s>>K;
  string str=s;
  int n=s.size();
  sort(s.begin(),s.end());


  rep(i,n){
    rep(j,n){
    //  dump(s[i]-'0');
  //  dump(K);
      if(s[i]==str[j] && !used[s[i]-'0']){

        if(K<=n-j){
          string gstr="";
          for(int k=j;k<j+K;k++){
            gstr+=str[k];
          }
          vec.push_back(gstr);
        }else{
          K-=n-j;
          used[s[i]-'0']=true;
        }
      }
    }
    if(vec.size()!=0)break;
  }
  sort(all(vec));
  dump(vec.size());
  cout<<vec[0]<<endl;
  //
  // int temp=30;
  // int memo=-1;
  // //一番接頭辞若い
  // for(int i=0;i<s.size();i++){
  //   int t=s[i]-'a';
  //   if(t<temp){
  //     temp=t;
  //     memo=i;
  //   }
  // }




}


Measured memory_bytes: 512
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}


#pragma endregion


// 060 B - Choose Integers
int main(void) {
	ll a,b,c,i=1,mod,fmod;

	scanf("%lld %lld %lld", &a,&b,&c);
	fmod = a % b;

	while (1) {
		mod = (a * i) % b;
		if (mod == c) {
			printf("YES\n"); break;
		}
		if (mod == fmod && i!=1) {
			printf("NO\n"); break;
		}
		i++;
	}

	return 0;
}






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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> n;
	rep(i, 100000000000){
		if(i * i > n){
			cout << (i-1) * (i-1) << endl;
			break;
		}
	}
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

signed main(){
  int N;
  cin >> N;
  int k;
  bool flag = 1;
  for(k = 1;k*(k-1)<=N*2;k++){
    if(k*(k-1)==N*2){
      flag = 0;
      break;
    }
  }
  if(flag){
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n" << k << endl;
  int ans[k][k-1]={0};
  int n = 0;
  int yay = 1;
  while(n < k-2){
    debug(n);
    debug(yay);
    FOR(i,0,k-1-n)ans[n][n+i]=yay+i;
    FOR(i,0,k-1-n)ans[n+1+i][n]=yay+i;
    n++;
    yay+=k-n;
  }
  ans[k-2][k-2]=N;
  ans[k-1][k-2]=N;
  FOR(i,0,k){
    DEBUG(ans[i]);
  }
  FOR(i,0,k){
    cout << k-1 << ' ';
    FOR(j,0,k-2)cout << ans[i][j] << ' ';
    cout << ans[i][k-2] << endl;
  }
}

Measured memory_bytes: 2176
X,K,D=map(int,input().split())
def solve(X,K,D):
  X=abs(X)
  if X>D:
    a=X//D
    if K>a:
      X=X%D
      K-=a
    else:
      return abs(X-D*K)
  if K%2==0:
    return X
  else:
    return abs(X-D)
print(solve(X,K,D))

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

void solve(long long N){
    if (N % 2) cout << N / 2 + 1 << '\n';
    else cout << N / 2 << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

using namespace std;

int main() {
    vector <int> tab;
    int n ;
    cin >> n;
    int x;
    cin >> x;
    int a;
    for(int i = 1; i <= n; i++){
        cin >> a;
        tab.push_back(a);
    }
    sort(tab.begin(),tab.end());
    int i = 0;
    while(x > 0 && i < n){
        x -= tab[i];
        i++;
    }
    cout << i - (x != 0);
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cstring>
#include <cctype>
#include <inttypes.h>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

const int cap = 1e5 + 1;
int N, x, y;
int64_t M;
vector<int> G[cap]; 
vector<int64_t> pre[cap], suf[cap];
int P[cap];
int64_t cnt[cap], dp[cap];

void prepro(int i) {
    pre[i] = vector<int64_t>(G[i].size() + 1, 1);
    suf[i] = vector<int64_t>(G[i].size() + 1, 1);
    for (int k = 0; k < int(G[i].size()); ++k) {
        int j = G[i][k];
        P[j] = i;
        auto it = find(G[j].begin(), G[j].end(), i);
        G[j].erase(it);
        prepro(j);
        cnt[i] = (cnt[i] * cnt[j]) % M;
        pre[i][k + 1] = (pre[i][k] * cnt[j]) % M;
    }
    for (int k = int(G[i].size()) - 1; k >= 0; --k)
        suf[i][k] = (suf[i][k + 1] * cnt[G[i][k]]) % M;
    ++cnt[i];
}

void calc(int i, int64_t res) {
    dp[i] = ((cnt[i] - 1) * res) % M;
    for (int k = 0; k < int(G[i].size()); ++k) {
        int nxt = (((pre[i][k] * suf[i][k + 1]) % M) * res + 1) % M;
        calc(G[i][k], nxt);
    }
}

int main() {
    scanf("%d %" SCNd64, &N, &M);
    for (int i = 1; i < N; ++i) {
        scanf(" %d %d", &x, &y);
        G[x].push_back(y);
        G[y].push_back(x);
    }
    
    fill(cnt, cnt + N + 1, 1);
    P[1] = 0;
    prepro(1);
    calc(1, 1);

    for (int i = 1; i <= N; ++i)
        printf("%" PRId64 "\n", dp[i]);
}





Measured memory_bytes: 26240
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static readonly int[] d=new int[]{5,4,3,2};
	static int n,m=0,z1=0,z2=0,z3=60;
	static HashSet<int> hs=new HashSet<int>();
	static int[] h2=new int[6],h3=new int[6];
	static void Main(){
		Sc sc=new Sc();
		int l=sc.I;
		n=l;
		int g=60,e=0;
		for(int i = 0;i<d.Length;i++) {Fu(1,i,0,d[i]);}
		Array.Copy(h3,h2,6);
		StringBuilder sb=new StringBuilder();
		int p1=1,w1=1;
		for(int i = 2;i<6;i++){
			while(h3[i]>0){
				h3[i]--;
				for(int j = 0;j<i;j++) {sb.Append(p1+" "+(p1+1)+" "+(j*w1)+"\n");e++;}
				p1++;
				w1*=i;
			}
		}
		g-=z3;
		n-=z1;
		while(n>g){
			Array.Copy(h2,h3,6);
			int q=1,k=0,x=1;
			for(int i=2;i<6;i++){
				while(h3[i]>0&&q*i<=n){
					x++;
					q*=i;
					h3[i]--;
					k=i;
				}
			}
			while(k*q>n){k--;}
			for(int i=1;i<=k;i++){sb.Append(x+" "+p1+" "+(z1+q*(i-1))+"\n");e++;}
			g-=1*k;
			n-=q*k;
			z1+=q*k;
		}
		for(int i=z1;i<l;i++){sb.Append(1+" "+p1+" "+i+"\n");e++;}
		Console.WriteLine("{0} {1}",p1,e);
		Console.Write(sb);
	}
	static void Fu(int q,int a,int p,int hn){
		q*=d[a];
		h2[d[a]]++;
		if(q>n){
			q=q/d[a];
			h2[d[a]]--;
			if(hs.Contains(q)){return;}
			hs.Add(q);
			m++;
			if(z1<q){
				z1=q;z2=p-1;z3=hn-d[a];
				Array.Copy(h2,h3,6);
			}
			return;
		}
		for(int i = a;i<d.Length;i++) {Fu(q,i,p+1,hn+d[i]);}
		h2[d[a]]--;
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

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

class Step{
private:
    int n;
    vector<int> A;
public:
    Step(){
        cin>>n;
        A.resize(n,0);
        for(int i=0; i<n; ++i) cin>>A[i];
    }
    long long solve(){
        int mx = A[0];
        long long ans=0;
        for(int i=1; i<n; ++i){
            ans+=max(0, mx-A[i]);
            mx = max(mx,A[i]);
        }
        return ans;
    }
};

int main(){
    Step problem;
    long long ans = problem.solve();
    cout<<ans<<'\n';
}

Measured memory_bytes: 4048
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   ll d, g, sum_score = 0;
   int ans = INF, sum_qnum = 0, partial_ans = -1;
   cin >> d >> g;
   vector<ll> p(d, 0), c(d, 0);
   for (int i = 0; i < d; i++)
      cin >> p[i] >> c[i];

   for (int i = 0; i < (1 << d); i++)
   {
      sum_score = 0;
      sum_qnum = 0;
      partial_ans = -1;
      for (int j = d - 1; j >= 0; j--)
      {

         if ((i >> j) & 1)
         {
            sum_score += 100 * (j + 1) * p[j] + c[j];
            sum_qnum += p[j];
         }
         else if (partial_ans == -1)
         {
            partial_ans = j;
         }
      }
      if (partial_ans >= 0)
         for (int j = 0; j < p[partial_ans] - 1; j++)
         {
            if (sum_score >= g)
               break;
            sum_score += 100 * (partial_ans + 1);
            sum_qnum++;
         }
      if (sum_score >= g)
         ans = min(ans, sum_qnum);
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256