akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int) n;i++)
#define rep1(i,m,n) for(int i=(int) m;i<(int) n;i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
    if(x>=0) return ;
    else x=-x; return;
}

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 INF = 1LL << 60;

int N;

//DPテーブル
vector<ll> dp(100010);

int main() {
    ll a; double b;
    cin>>a>>b;
    ll ans=b*100+0.5;
    ans*=a;
    cout<<ans/100<<endl;
}

Measured memory_bytes: 3900
#ABC104C - All Green
import math
def dfs(i,s,c,r):
    global ans
    if i == d:
        if s < g:
            use = max(r)
            n = min(pc[use -1][0], math.ceil((g-s)/(use*100)))
            c += n
            s += n*use*100
        if s >= g:
            ans = min(ans,c)
    
    else:
        dfs(i+1, s, c, r)
        dfs(i+1, s+ pc[i][0]*(i+1)*100+pc[i][1],c+pc[i][0],r-{i+1})
        
d,g = list(map(int,input().split()))
pc = [list(map(int,input().split())) for i in range(d)]

ans = float("inf")

dfs(0,0,0,set(range(1,d+1)))
print(ans)

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

int main() {
    int a,b,c;

    cin >> a >> b>> c;

    if ((a==b && a != c)|| (a==c && a != b) || (c==b && a != c)){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    int n,m;
    cin >> n >> m;
    vi a(n);
    vi b(n);
    vi c(m);
    vi d(m);
    vi ans(n,0);
    rep(i,n) cin >> a[i] >> b[i];
    rep(i,m) cin >> c[i] >> d[i];
    rep(i,n){
        int dis=inf;
        rep(j,m){
            int ma=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(ma<dis){
                dis=ma;
                ans[i]=j+1;
            }
        }
    }
    rep(i,n){
        cout << ans[i] <<endl;
    }

    return 0;
}


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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;


int main() {
	int n;
	cin >> n;
	VI  t(n), a(n), v;
	REP(i, n) cin >> t[i];
	REP(i, n)cin >> a[i];
	if (a[0] != t[n-1]) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = 1;
	FOR(i, 1, n - 1) {
		if (t[i - 1] == t[i] && a[i] == a[i + 1]) {
			ans *= min(t[i], a[i]);
			ans %= mod;
		}
		else if (t[i - 1] < t[i] && a[i] > a[i + 1] && t[i] != a[i])ans = 0;
		else if (t[i - 1] == t[i] && a[i] > a[i + 1] && t[i] < a[i])ans = 0;
		else if (t[i - 1] < t[i] && a[i] == a[i + 1] && t[i] > a[i])ans = 0;
	}
	cout << ans << endl;

}

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

typedef long long LL;

LL num_seq[200005];

int main() {
    LL N, count = 0, sum_num = 1, target;
    cin >> N;

    num_seq[0] = 0;
    for (int i = 1; i <= N; i++) {
        cin >> num_seq[i];
        num_seq[i] += num_seq[i - 1];
    }

    sort(num_seq, num_seq + N + 1);

    target = num_seq[0];
    for (int i = 1; i <= N; i++) {
        if (num_seq[i] == target) {
            sum_num++;
        }
        else {
            count += (sum_num * (sum_num - 1)) / 2;
            target = num_seq[i];
            sum_num = 1;
        }
    }
    count += (sum_num * (sum_num - 1)) / 2;

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 1792
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

void main()
{
  foreach (line; stdin.byLine) {
    auto n = line.chomp.to!int % 39;
    if (!n) n = 39;
    writefln("3C%02d", n);
  }
}

Measured memory_bytes: 1188
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        String first = reader.nextLine();
        String second = reader.nextLine();
        System.out.println(first.chars()
                .distinct()
                .mapToLong(a -> first.chars()
                        .filter(el -> el == a)
                        .count())
                .boxed()
                .sorted()
                .collect(Collectors.toList())
                .equals(second.chars()
                        .distinct()
                        .mapToLong(a -> second.chars()
                                .filter(el -> el == a)
                                .count())
                        .boxed()
                        .sorted()
                        .collect(Collectors.toList())) ? "Yes" : "No");
    }
}

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

int main() {
    int N,A,B;
    cin>>N>>A>>B;
    if (N*A<B) {
        cout<<N*A<<endl;
    } else if (N*A==B) {
        cout<<B<<endl;
    } else {
        cout<<B<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

bool primecheck(int n){
	if(n<2)return false;
	for(int i=2;i*i<=n;i++){
		if(n %i == 0)return false;
	}
	return true;
}
int N;
int cnt =0;
int main(){
	cin >> N;
	for(int i=2;i<=55555; i+=5){
		if(primecheck(i)==true){
			if(i !=2) cout << " ";
			cout << i ;
			cnt ++;

		}
		if(cnt ==N)break;
	}
	cout << endl;
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    string s; cin>>s;
    int n=s.size();
    int k; cin>>k;
    for(int i=0;i<n;i++){
        if(s[i]!='a'&&'{'-s[i]<=k){
            k-=(int)('{'-s[i]);
            s[i]='a';
        }
    }
    k%=26;
    while(k--){
        s[n-1]=(char)(s[n-1]+1);
        if(s[n-1]=='{') s[n-1]='a';
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.*;
 
public class Main {
    private static String solve(int N, int K, int[] a) {
        int result = solve(K, N, a, new int[K+1]);
        return result == +1 ? "First": "Second";
    }
 
    private static int solve(int k, int N, int[] a, int[] memo) {
        if (memo[k] != 0) return memo[k];
 
        int result = -1;
        for (int i = 0; i < N; i++) {
            if (a[i] > k) continue;
 
            int alt = solve(k - a[i], N, a, memo);
            if (alt == -1) {
                result = +1;
                break;
            }
        }
        memo[k] = result;
        return result;
    }
 
    public static String run(Scanner scanner) {
        int N = scanner.nextInt();
        int K = scanner.nextInt();
        int[] a = new int[N];
        for (int i=0; i < N; i++) a[i] = scanner.nextInt();
 
        return solve(N, K, a);
    }
 
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            System.out.println(run(scanner));
        }
        //Tests.run();
    }
}

Measured memory_bytes: 31828
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

dic = {}
check = [0]*100000
for i in A:
    if check[i-1] == 0:
        dic[i] = 1
        check[i-1] = 1
    else:
        dic[i] += 1
ans = 0
for i in dic.keys():
    ans += i*dic[i]

for i in range(Q):
    B, C = map(int, input().split())
    if check[B-1] == 1:
        if check[C-1] == 1:
            ans = ans + dic[B]*(C-B)
            dic[C] += dic[B]
            check[B-1] = 0
            dic[B] = 0
            print(ans)
        else:
            ans += dic[B]*(C-B)
            check[C-1] = 1
            check[B-1] = 0
            dic[C] = dic[B]
            dic[B] = 0
            print(ans)

    else:
        print(ans)

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

typedef long long int ll;
typedef vector<int> vi;            typedef vector<ll> vl;
typedef vector<vi> vvi;         typedef vector<vl> vvl;
typedef pair<int, int>     pii;    typedef pair<ll, ll> pll;
typedef vector<pii> vii;         typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
const ll INFL = 1e18;
const int INFI = 1e9;
#ifdef KARAN
    #include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}
ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
    while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
    int n; cin>>n;
    vl a(n); forn(i, n) cin>>a[i];
    map<ll, ll> cntr;
    forn(i, n)
        cntr[a[i]+i]++;
    ll answer = 0;
    forn(i, n)
        if(cntr.find(i-a[i])!=cntr.end())
            answer += cntr[i-a[i]];
    cout<<answer<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef KARAN
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        freopen("err.txt", "w", stderr);
    #endif
    int t=1;
    // cin>>t;
    while(t--)
        solve();
}

Measured memory_bytes: 17080
#include <cstdio>

int A,B,C,D,E,F;
const int MAX_N = 3001;
int W[MAX_N];
int S[MAX_N];

int min(int x,int y){return x<y?x:y;}

int main(){
	scanf("%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F);
	A*=100;
	B*=100;
	W[0]=1;
	W[A]=1;
	W[B]=1;
	for(int i=B+100;i<=F;i+=100){
		if(W[i-A]||W[i-B])W[i]=1;
	}
	S[0]=1;
	S[C]=1;
	S[D]=1;
	for(int i=D+1;i<=F;i++){
		if(S[i-C]||S[i-D])S[i]=1;
	}

	W[0]=S[0]=0;
	for(int i=1;i<=F;i++){
		if(W[i])W[i]=i;
		else W[i]=W[i-1];
		if(S[i])S[i]=i;
		else S[i]=S[i-1];
	}

	int X=A,Y=0;
	for(int i=1;i<=F;i++){
		if(W[i]){
			int x=W[i], y=S[min(E*(W[i]/100),F-W[i])];
			if(y*(X+Y) > Y*(x+y)){
				X=x,Y=y;
			}
		}
	}

	printf("%d %d\n",X+Y,Y);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define MOD 1000000007
using namespace std;
const long long INF = 3*1e18;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string S;
    cin >> S;
    ll Q;
    cin >> Q;
    deque<char> dq;
    bool rev = false;
    for(char ch : S) dq.push_back(ch);
    for(ll i = 0; i < Q; i++){
        int T;
        cin >> T;
        if(T == 1) rev = !rev;
        else{
            int F; char ch;
            cin >> F >> ch;
            if(F == 1){ //front
                if(rev) dq.push_back(ch);
                else dq.push_front(ch);
            }
            else{ //end
                if(rev) dq.push_front(ch);
                else dq.push_back(ch);
            }
        }
    }
    string ans;
    if(!rev){
        while(!dq.empty()){
            ans += dq.front();
            dq.pop_front();
        }
    } 
    else{
        while(!dq.empty()){
            ans += dq.back();
            dq.pop_back();
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1368
#include <bits/stdc++.h>
#define int long long
typedef long long ll;
using namespace std;

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, M, P, ans=0, tmp=0;
vector<vector<pair<ll,ll>>> G;
vector<ll> to[2505], rto[2505];
bool reachableFrom1[2505], reachableToN[2505], ok[2505];

void dfs(int v) {
    if(reachableFrom1[v]) return;
    reachableFrom1[v] = true;
    for(int u:to[v]) {
        dfs(u);
    }
}

void rdfs(int v) {
    if(reachableToN[v]) return;
    reachableToN[v] = true;
    for(int u:rto[v]) {
        rdfs(u);
    }
}

signed main(){
    cin >> N >> M >> P;
    G.resize(N);
    for(int i=0;i<M;i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        c -= P;
        c = -c;
        G[a].push_back(make_pair(b,c));
        to[a].push_back(b);
        rto[b].push_back(a);
    }
    dfs(0);
    rdfs(N-1);
    for(int i=0;i<N;i++) {
        ok[i] = reachableFrom1[i]&reachableToN[i];
    }
    { // bellman-ford
        vector<ll> d(N,INF);
        d[0] = 0;
        bool upd = true;
        ll step = 0;
        while(upd) {
            upd = false;
            for(int a=0;a<N;a++) {
                if(d[a]==INF) continue;
                for(int j=0;j<G[a].size();j++) {
                    ll b=G[a][j].first;
                    ll c=G[a][j].second;
                    if(!ok[a]) continue;
                    if(!ok[b]) continue;
                    ll newD = d[a]+c;
                    if(newD<d[b]) {
                        upd = true;
                        d[b] = newD;
                    }
                }
            }
            step++;
            if(step>N) {
                cout << -1 << endl;
                return 0;
            }
        }
        ans = max(-d[N-1], 0LL);
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n-1; i >= 0; i--)
#define PRINT(x) cout << x << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll MOD = 1000000007;


int main()
{
    ll N;
    cin >> N;
    string S;
    cin >> S;
    vector<ll> R(N);
    vector<ll> G(N);
    vector<ll> B(N);
    vector<ll> Rr(N);
    vector<ll> Gr(N);
    vector<ll> Br(N);
    REP(i, N)
    {
        if (S[i] == 'R') R[i]++;
        else if (S[i] == 'G') G[i]++;
        else B[i]++;
    }
    REPR(i, N) {
        if (S[i] == 'R') Rr[i]++;
        else if (S[i] == 'G') Gr[i]++;
        else Br[i]++;
    }
    REP(i, N-1) {
        R[i+1] += R[i];
        G[i+1] += G[i];
        B[i+1] += B[i];
        Rr[N-1 - (i+1)] += Rr[N-1 - i];
        Gr[N-1 - (i+1)] += Gr[N-1 - i];
        Br[N-1 - (i+1)] += Br[N-1 - i];

    }


    ll ans = 0;
    for (int i = 1; i < N-1; i++) {
        if (S[i] == 'R') {
            ans += G[i-1] * Br[i+1];
            ans += B[i-1] * Gr[i+1];
        } else if (S[i] == 'G') {
            ans += R[i-1] * Br[i+1];
            ans += B[i-1] * Rr[i+1];
        } else {
            ans += R[i-1] * Gr[i+1];
            ans += G[i-1] * Rr[i+1];
        }
        REP(j, min(i, (int)(N-1 - i))) {
            if (S[i-(j+1)] != S[i] && S[i] != S[i+(j+1)] && S[i-(j+1)] != S[i+(j+1)]) {
                ans--;
            }
        }
    }
    PRINT(ans);
    return 0;
}


Measured memory_bytes: 3716
N=int(input())
A=list(input())

E_l=[0]*N
for n in range(1,N):
    E_l[n]=E_l[n-1]
    if A[n-1] == 'W':
        E_l[n]+=1
    
W_r=[0]*N
for n in range(N-2,-1,-1):
    W_r[n] = W_r[n+1]
    if A[n+1] == 'E':
        W_r[n]+=1

ans=10**20
for n in range(N):
    if ans > E_l[n]+W_r[n]:
        ans=E_l[n]+W_r[n]
print(ans)

Measured memory_bytes: 91116
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define mod 1000000007 //1e9+7
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 1001

void calc(int n){
  int a,b,c,x,y;

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

  int ans = 0;
  
  for(int i=0;i<n;i++){
    scanf("%d",&y);

    if(ans==-1) continue;

    if(y==x && i==0) continue;
    
    while(1){
      x = (a*x + b)%c;
      ans++;

      if(ans>10000){
	ans = -1;
	break;
      }
      
      if(x==y) break;
    }
  }
  
  printf("%d\n",ans);
}

int main(){
  int n;
  
  while(1){
    scanf("%d",&n);
    if(n==0) break;
    calc(n);
  }
  
  return 0;
}

Measured memory_bytes: 3192
#include<stdio.h>
#include<string.h>
main(){
  int i,k,j,n;
  char str[100],tmp;
  scanf("%s",str);
  for(i=strlen(str)-1;i>-2;i--){
    printf("%c",i>-1?str[i]:'\n');
  }
  return 0;
}

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

int main() {
  int N, K, input;
  vector<int> H;
  long total = 0;

  cin >> N >> K;

  if (K > N) {
    cout << 0;
    return 0;
  }
  else {
    while (N--) {
      cin >> input;
      total += input;
      H.push_back(input);
    }

    sort(H.begin(), H.end(), greater<int>());

    for (int i = 0; i < K; i++) {
      total -= H[i];
    }
  }

  cout << total;

  return 0;
}

Measured memory_bytes: 1400
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int K = sc.nextInt();
		PrintWriter out = new PrintWriter(System.out);
		if(N%K == 0)out.println(0);
		else out.println(1);
		out.flush();
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 23380
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
const long long INF = 1e18;

struct Edge {
    int fr, to;
    long long cost;
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<Edge> edge(M);
    for (int i = 0; i < M; i++) {
        int a, b; long long c;
        cin >> a >> b >> c;
        edge[i].fr = a - 1; edge[i].to = b - 1;
        edge[i].cost = -c;
    }

    vector<long long> mc(N);
    mc[0] = 0;
    for (int i = 1; i < N; i++) mc[i] = INF;

    for (int i = 0; i < N - 1; i++) {
        for (int j = 0; j < M; j++) {
            int f = edge[j].fr, t = edge[j].to;
            if (mc[f] + edge[j].cost < mc[t]) {
                mc[t] = mc[f] + edge[j].cost;
            }
        }
    }

    bool flag = false;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            int f = edge[j].fr, t = edge[j].to;
            if (mc[f] + edge[j].cost < mc[t]) {
                mc[t] = mc[f] + edge[j].cost;
                if (t == N - 1) flag = true;
            }
        }
    }


    if (flag) cout << "inf" << endl;
    else cout << -mc[N - 1] << endl;

    return 0;
}

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

using namespace std;
long long a[2001];
int main(){
	long long r,d,x;
	cin>>r>>d>>x;
	a[0]=x;
	for(int i=1;i<=10;i++){
		a[i]=a[i-1]*r-d;
		cout<<a[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
// Medha's code  :


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double dd;
#define fastio ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define INF 0x3f3f3f3f3f
#define MOD 1000000007

int main() {

    fastio;

    ll n;
    dd sum = 0;
    dd product =1;
    vector<dd> prob(3005);
    vector<vector<dd>> probdp(3005 , vector<dd> (3005) );

    cin >> n;

    for( ll i = 1 ; i <= n ; i++)
    {
        cin >> prob[i];
    }

    probdp[1][1]= prob[1];
    for( ll i = 2 ; i <= n ; i++)
    {
        probdp[1][i] = 0 ;
    }

    for( ll i = 1 ; i<=n ; i++)
    {
      product *= (1-prob[i]);

       probdp[i][0] = product;
    }

    for(ll i = 2 ; i <= n ; i++)
    {
        for( ll j = 1 ; j <= n ; j++)
        {
            probdp[i][j] = probdp[i-1][j] * (1-prob[i]) + probdp[i-1][j-1] * prob[i];
        }
    }

    for( ll i = floor(n/2)+1 ; i <= n  ; i++)
    {
         sum += probdp[n][i];
    }

    cout<< fixed<< setprecision(9);
    cout << sum;


    return 0;
}


Measured memory_bytes: 70912
#include<iostream>

using namespace std;

int main(){
    int n,i,k;
    long long all,count = 0;
    cin>>n;
    long long a[n+1],num[n+1] = {0};
    for(i=1;i<=n;i++){
        cin>>a[i];
        num[a[i]]++;
    }
    for(i=1;i<=n;i++){
        if(num[i]>1) count += num[i]*(num[i]-1)/2;
    }
    all = count;
    for(k=1;k<=n;k++){
        count = all;
        count -= num[a[k]] - 1;
        cout<<count<<endl;
    }
}

Measured memory_bytes: 5760
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int a[4][1000];
	int b[4];
	int n;
	int judge;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		judge = 0;
		for (int i = 0; i < n; i++) {
			cin >> a[0][i] >> a[1][i] >> a[2][i] >> a[3][i];
		}
		cin >> b[0] >> b[1] >> b[2] >> b[3];

		for (int i = 0; i < n; i++) {
			if (a[1][i] <= b[0] && a[2][i] <= b[1] && a[3][i] <= b[2] && a[1][i] * 4 + a[2][i] * 9 + a[3][i] * 4 <= b[3]) {
				cout << a[0][i] << endl;
				judge = 1;
			}
		}
		if (judge == 0) {
			cout << "NA" << endl;
		}
	}
	return 0;
}

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


using namespace std;


double solveY(int a,int b,int c,int d,int e,int f){
	double ret;
	ret=(double)(a*f-d*c)/(a*e-b*d);
	return ret;
}

int main(){
	while(1){
		int a,b,c,d,e,f;
		if( !(cin>>a>>b>>c>>d>>e>>f) )break;
		double y=solveY(a,b,c,d,e,f);
		double x=(c-b*y)/a;
		printf("%5.3lf %5.3lf\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int s,d,x;
    cin>>s;
    d=s%100;

    s=s/100;
    s=s%100;
//cout<<d<<" "<<s;
    if((d<=12&&d!=0) && (s<=12 && s!=0))
        cout<<"AMBIGUOUS"<<endl;
    else if((d>12||d==0)&&(s>12 || s==0 ))
        cout<<"NA"<<endl;
    else if((d<=12&&d!=0))
        cout<<"YYMM"<<endl;
    else
         cout<<"MMYY"<<endl;




    }


Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <string>
#define INF -2000000000
using namespace std;
vector <int> s;
int check(int x){
  for(int i=1;i<s.size()-1;i++){
    int ima = s[i],nx = s[i+1],mae = s[i-1];
    if(ima == INF) ima =x;
    if(nx == INF) nx = x;
    if(mae == INF) mae = x;
    if(i%2 == 0 && (ima >= mae || ima>= nx)) {
      if(s[i] == INF)return -1;
      else return 1;
    }
    else if(i%2==1 &&(mae >= ima||nx >= ima)) {
      if(s[i] == INF)  return 1;
      else return -1;
    }
  }

  if(s.size() == 2) {
    int ima = s[0],nx = s[1];
    if(s[0] == INF) ima = x;
    if(s[1] == INF) nx  = x;
    if(ima >= nx) {
      if(s[0] == INF) return -1;
      else return 1;
    }
  }
  
  return 0;
}

int main() {
  while(1){
    int n;
    cin >> n;
    if(n == 0) break;
    string str;
    s.clear();
    for(int i=0;i<n;i++) {
      cin >> str;
      if(str == "x") s.push_back(INF);
      else {
	int sum = 0,k=0,flg = 1;
	if(str[0] == '-') k=1,flg = -1;
	for(int j=k;j<str.size();j++) sum = sum*10 + (str[j]-'0');
	s.push_back(flg*sum);
      }
    }
  
    int R = 1000000010,L=-1000000011,M,ans = INF;
    int cnt = 0;
    while(L < R) {
      cnt ++;
      int t = M;
      M = (L+R)/2;
      if(M == t) L--,R++,M=(L+R)/2;
      if(cnt > 35) break;
      int res = check(M);
      if(res == -1) R = M;
      else if(res == 1) L=M+1;
      else if(res == 0) {
	ans = M;
	break;
      }
   
    }
    if(ans == INF) cout << "none"<<endl;
    else if(check(ans+1) == 0 || check(ans-1) == 0) cout << "ambiguous"<<endl;
    else cout << ans <<endl;
  }
  return 0;

}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int n, k;

#include <boost/numeric/ublas/matrix.hpp>
using boost::numeric::ublas::matrix;
template <typename T>
class CumulativeSum2D {
	public:
		matrix<T> sum;
		CumulativeSum2D (int h, int w) : sum(matrix<T>(h + 1, w + 1)) {}

		void add(int x, int y, int num) {
			x++;
			y++;
			sum(x, y) += num;
		}

		void build() {
			for (int i = 1; i < sum.size1(); i++) {
				for (int j = 1; j < sum.size2(); j++) {
					sum(i, j) += sum(i, j - 1) + sum(i - 1, j) - sum(i - 1, j - 1);
				}
			}
		}

		T query(int sx, int sy, int gx, int gy) {
			return (sum(gx, gy) - sum(sx, gy) - sum(gx, sy) + sum(sx, sy));
		}
};

int main() {
	cin >> n >> k;
	CumulativeSum2D<int> pear(4 * k, 4 * k);
	rep (i, n) {
		int x, y;
		char c;
		cin >> x >> y >> c;
		if (c == 'W') y += k;
		pear.add(x % (2 * k), y % (2 * k), 1);
	}
	range (i, 1, 2 * k + 1) range (j, 1, 2 * k + 1) {
		pear.sum(i, j + 2 * k) = pear.sum(i, j);
		pear.sum(i + 2 * k, j) = pear.sum(i, j);
		pear.sum(i + 2 * k, j + 2 * k) = pear.sum(i, j);
	}
	pear.build();
	int macs = 0;
	rep (i, 2 * k) rep (j, 2 * k) {
		int sum = 0;
		sum += pear.query(i, j, i + k, j + k);
		sum += pear.query(i + k, j + k, i + 2 * k, j + 2 * k);
		macs = max(macs, sum);
	}
	cout << macs << endl;
	return 0;
}

Measured memory_bytes: 62720
#include<stdio.h>

int main(){
  int d, first;
  while(scanf("%d", &d) != EOF){
    first = 1;
    while(d){
      if(!first)putchar(' ');
      first = 0;
      printf("%d", d & -d);
      d -= d & -d;
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 612
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int L;
ll A[200005], dp[200005][5];

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cin >> L;
    for (int i = 1; i <= L; i++) {
        cin >> A[i];
    }

    for (int i = 1; i <= L; i++) {
        ll mn = dp[i-1][0];
        dp[i][0] = mn + A[i];

        mn = min(mn, dp[i-1][1]);
        dp[i][1] = mn + (A[i] == 0 ? 2 : A[i] % 2);

        mn = min(mn, dp[i-1][2]);
        dp[i][2] = mn - (A[i] % 2 - 1);

        mn = min(mn, dp[i-1][3]);
        dp[i][3] = mn + (A[i] == 0 ? 2 : A[i] % 2);

        mn = min(mn, dp[i-1][4]);
        dp[i][4] = mn + A[i];
    }

    ll ret = dp[L][0];
    for (int i = 1; i < 5; i++) {
        ret = min(ret, dp[L][i]);
    }

    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() 
{
	ll n,sum=0;
  cin>>n;
  ll i=1;
  vector<int>v;
  while(i<=n)
  {
    if(i%3==0 && i%5==0)
      v.push_back(0);
    else if(i%3==0 && i%5!=0)
        v.push_back(0);
        else if(i%5==0 && i%3!=0)
            v.push_back(0);
            else
            v.push_back(i);
    i++;
  }
  sum=accumulate(v.begin(),v.end(),sum);
  cout<<sum;
}


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

char str[1000];

int main() {
#ifdef TEST
    freopen("input", "r", stdin);
#endif

    while (scanf("%s", str)) {
        int sum = 0;
        int len = strlen(str);
        if(1 == len && str[0] == '0') break;
        for (int i = 0; i < len; ++i) {
            sum += str[i] - '0';
        }
        printf("%d\n", sum);
        memset(str, 0x0, sizeof(str));
    }

    return 0;
}



Measured memory_bytes: 2032
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
/*
int a[200000];
signed main(){
	int n;scanf("%d",&n);
	rep(i,n)scanf("%d",&a[i]);
	sort(a,a+n);
	int s=1,g=n-1;
	ll ans=0;
	vector<int>v;
	v.push_back(a[0]);
	for(int i=1;i<n;i++){
		int t;
		if(i%2==1)t=g,g--;
		else t=s,s++;
		ans+=abs(a[t]-v.back());
		v.push_back(a[t]);
	}
	ll ans2=0;
	s=0,g=n-2;
	vector<int>v2;
	v2.push_back(a[n-1]);
	for(int i=1;i<n;i++){
		int t;
		if(i%2==0)t=g,g--;
		else t=s,s++;
		ans2+=abs(a[t]-v2.back());
		v2.push_back(a[t]);
	}
	cout<<max(ans,ans2)<<endl;
}
*/
int b[200000];
int cnt[200000];
signed main(){
	int n;cin>>n;
	int a;
	for(a=1;(1+a)*a/2<n;a++);
	if((1+a)*a/2!=n){
		puts("No");return 0;
	}
	puts("Yes");
	cout<<a+1<<endl;
	for(int i=a+1;i>=1;i--){
		cout<<a<<" ";
		set<int>se;
		int cc=0;
		int j=0;
		while(cc<a){
			if(cnt[j]==2){j++;continue;}
			if(b[j]==0){
				cout<<j+1<<" ";
				b[j]=i;cc++;
				cnt[j]++;
			}
			else if(!se.count(b[j])){
				se.insert(b[j]);
				cout<<j+1<<" ";
				cc++;
				cnt[j]++;
			}
			j++;
		}
		cout<<endl;
	}
}

Measured memory_bytes: 2176
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,M,L = inpl()
cost = [[INF]*N for _ in range(N)]
for i in range(N):
    cost[i][i] = 0

for _ in range(M):
    a,b,c = inpl()
    a,b = a-1,b-1
    cost[a][b] = c
    cost[b][a] = c

for k in range(N):
    for i in range(N):
        for j in range(N):
            cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j])

# print(cost)

for i in range(N):
    for j in range(N):
        if cost[i][j] == 0:
            cost[i][j] = 0
        elif cost[i][j] <= L:
            cost[i][j] = 1
        else:
            cost[i][j] = INF

# print(cost)

for k in range(N):
    for i in range(N):
        for j in range(N):
            cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j])


Q = inp()
ans = []
for _ in range(Q):
    s,t = inpl()
    tmp = cost[s-1][t-1]
    if tmp == INF:
        ans.append(-1)
    else:
        ans.append(tmp-1)

print('\n'.join(map(str,ans)))


Measured memory_bytes: 131080
N = int(input())
A = [int(x) for x in input().split(' ')]

left = [0] * N
right = [0] * N

for i, a in enumerate(A):
  if i - a >=0:
    right[i-a] += 1
  if i + a < N:
    left[i + a] += 1
#print(right)
#print(left)
ans = 0
for l, r in zip(left, right):
  ans += l*r
print(ans)
  


Measured memory_bytes: 32328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int n;
    cin >> n;
    
    int tmp = 0;
    int ans = 0;
    rep(i, n){
        int p;
        cin >> p;
        if(p==i+1){
            if(tmp==i-1){
                tmp = 0;
                continue;
            }
            ans++;
            tmp = i;
        }
    }

    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

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

string S,T,U;
ll ANS, SUM, NOW, N, M, A, B, C, D, E, F[1100000];

ll mod(ll n) {
  if (n==1) return 10;
  if (n%2==0) return (mod(n/2)*mod(n/2))%2019;
  return (mod(n-1)*10)%2019;
}

int main() {
	cin >> S;
	N = S.size();
	F[0] = 0;
    T=S.substr(N-1,1);
    F[1]=stoll(T);
	for (ll i = 2; i <= N; i++) {
		U=S.substr(N-i,1);
        F[i]=(F[i-1]+stoll(U)*mod(i-1))%2019;
	}
	sort(F, F + N + 1);
	ANS = 0;
	NOW = F[0];
	SUM = 1;
    for (ll i = 1; i <= N; i++) {
        if (NOW == F[i]) {
            SUM++;
            ANS += (SUM - 1);
        }
        else {
            SUM=1;
            NOW=F[i];
        }
    }
    cout<< ANS << endl;
	return 0;
}

Measured memory_bytes: 5236
#include <bits/stdc++.h>
using namespace std;
#include <math.h> 
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll ch[10][10];
int main() {
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++){
		ll now=i;
		ll r=i%10;
		while(now/10!=0){
			now/=10;
		}
		ch[now][r]++;
	}
	ll ans=0;
	for(ll i=1;i<10;i++){
		for(ll j=1;j<10;j++){
			ans+=ch[i][j]*ch[j][i];
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3636
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int a, b;
    cin >> a >> b;
    cout << max(a+b, max(a-b, a*b)) << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
ls = list(map(int,input().split()))
di = [0]*(n+1)
mod = 10**9+7
ans = 0
for i in range(1,n+1):
    di[i] = di[i-1] + ls[i-1]
for j in range(n-1):
    ans += ls[j]*(di[n]-di[j+1]) % mod
print(ans%mod)

Measured memory_bytes: 105356
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define repf(i, n) for(int i=1; i<(int)(n+1); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

lli gcd(lli a, lli b){
    if(a < b) swap(a, b);
    if(a%b == 0) return b;
    return gcd(a%b, b);
}

lli lcm(lli a, lli b){
    return (a*b)/gcd(a, b);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main()
{
	int n;
	cin >> n;
	ll a[100000];
	ll c1 = 0;
	ll c2 = 0;

	for (int i = 0; i < n; i++) cin >> a[i];

	ll sum = 0;
	int c = 1;

	//odd number are over 0;
	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (sum * c <= 0)
		{
			c1 += abs(sum) + 1;
			sum = c;
		}

		c *= -1;
	}

	//even numbers are over 0
	c = -1;
	sum = 0;
	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (c * sum <= 0)
		{
			c2 += abs(sum) + 1;
			sum = c;
		}
		c *= -1;
	}

	cout << min(c1, c2) << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
    int n,i,j,k,l,count=0;
    while(cin>>n){
    for(i=0;i<10;i++){
        for(j=0;j<10;j++){
            for(k=0;k<10;k++){
                for(l=0;l<10;l++){
                    if(n==i+j+k+l)count++;
                }
            }
        }
    }
    cout<<count<<endl;
        count=0;
    }
    return 0;
}

Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 998244353;
const int N = 100000 + 5;
int a[N];
 
ll mul_pow(ll x,ll y){
	ll ans = 1;
	while(y){
		if(y&1)
			ans = (ans*x) % mod;
		x = (x*x)%mod;
		y>>=1;
	}
	return ans;
}
 
int main()
{
	int n;
	cin >> n;
	int maxn = 0;
	int flag = 0;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		if(i == 0 && x != 0)
			flag = 1;
		a[x]++;
		maxn = max(maxn,x);
	}
	long long sum = 1;
	if(flag || a[0] != 1)
		cout << 0 << endl;
	else{
		for(int i = 2; i <= maxn; i++){
			if(a[i] == 0){
				sum = 0;
				break;
			}
			else{
				for (int j = 0; j < a[i]; j++){
					sum *= a[i-1];
					sum %= mod;
				}
			}
			
		}
		cout << sum << endl;
	}
	return 0;
 } 

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

int main()
{
    int n;
    cin>>n;
    vector<int> d(n);
    for(int i=0; i<n; i++){
        cin>>d[i];
    }
    sort(d.begin(),d.end());
    int count=1;
    for(int i=0;i<n-1; i++){
        if(d[i+1]>d[i]){
            count++;
        }
    }
        
    cout<<count<<endl;
}

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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pil = pair<int, ll>;

int main() {
	int A, B;
	cin >> A >> B;
	int ans = B;

	if (A <= 12) {
		if (A >= 6)
			ans /= 2;
		else
			ans = 0;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long A, V;
    scan(A, V);
    long B, W;
    scan(B, W);
    long T = lread();
    if (V - W <= 0)
    {
        writeln("NO");
        return;
    }
    if (abs(A - B) <= T * (V - W))
    {
        writeln("YES");
        return;
    }
    writeln("NO");
}


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

const int MAX=2000050;
const long long MOD=1000000007;

typedef long long ll;

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

ll mod_pow(ll x, ll n){ //べき乗
    ll ans=1;
    while(n!=0){
        if(n&1) ans=ans*x%MOD;
        x=x*x%MOD;
        n=n>>1;
    }
    return ans;
}

void com_init(){ //初期化
    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;
        finv[i]=finv[i-1]*mod_pow(i,MOD-2)%MOD;//フェルマーの小定理より
    }
}

ll comb(ll n, ll k){ //nCk
    if(n<k) return 0;
    if(n<0||k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
    ll X,Y; cin >> X >> Y;
    if((X+Y)%3!=0){
        cout << 0 << endl;
        return 0;
    }
    ll ans=0;
    com_init();
    int n=(X+Y)/3;
    int m=(2*X-Y)/3;
    if(2*X-Y<0){
        cout << 0 << endl;
        return 0;
    }
    ans=comb(n,m);
    cout << ans%MOD << endl;
}

Measured memory_bytes: 32896
-- ABC 136 C
import Data.Maybe
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU

main :: IO()
main = do
  n <- getInt
  hs <- getIntList
  if solve hs
    then putStrLn "Yes"
    else putStrLn "No"

solve :: [Int] -> Bool
solve (h:hs) = solve' h hs
  where
    solve' n [] = True
    solve' n (m:ms)
      | n <= m = solve' m ms
      | n - m == 1 = solve' n ms
      | otherwise = False


-- ByteStringを用いた入力
readInt = fst . fromJust . BS.readInt

-- 整数を一つ受け取る
getInt = readInt <$> BS.getLine

-- 長さnの整数列を受け取る
getIntVec n = VU.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

-- 空白区切りの整数列をListで受け取る
getIntList = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

Measured memory_bytes: 4092
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}

ll dig(ll n){
    ll d = 0;
    while(n != 0){
        n/=10;
        d++;
    }
    return d;
}

void solve() {
    int n;
    cin >> n;
    vector<pair<int,int>> a;
    for(int i = 0;i < n;i++){
        int p;
        cin >> p;
        a.push_back(make_pair(p,i+1));
    }
    sort(a.begin(),a.end());
    for(int i = 0;i < n;i++) cout << a[i].second << " ";

}


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}



Measured memory_bytes: 1780
## B
N, K = map(int, input().split() )
rt = []
for k in range(K):
    d = int(input())
    a = list(map(int, input().split() ) )
    rt += a
val = 0
for n in range(1, N+1):
    if n not in rt:
        val += 1
print(val)

Measured memory_bytes: 9224
#include <iostream>
#include <algorithm>
using namespace std;
int n, m, a[1000], sum;
int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    sum = (sum + 4 * m - 1) / (4 * m);//向上取整
    sort(a + 1, a + n + 1);
    for (int i = n; i >= 1; i--) {
        if (a[i] >= sum) {
            m--;
        } else {
            break;
        }
    }
    if (m > 0) puts("No");
    else puts("Yes");
    return 0;
}



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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)

int H1,M1,H2,M2,K;

int main(){
	fast;
	
	cin>>H1>>M1>>H2>>M2>>K;
	
	int a = H1 * 60 + M1;
	int b = H2 * 60 + M2;
	
	cout<<max(0,b - a - K);
}



Measured memory_bytes: 3616