akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    static long MOD = 998244353;
    
    public static void main(String[] args) throws Exception {
        // Your code here! 
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int s = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        // ans: f(L,R)の全パターンの和 (1 <= L <= R <= N)
        // f(L,R): 区間L,R中の部分列であって、和がsになるパターン数
        long ans = 0;
        
        // ans: [x^s] (f1 + f1f2 + f1f2f3 + f2 + f2f3 + f3)
        // -> (F1 = f1, F2 = f1f2 + f2, F3 = f1f2f3 + f2f3 + f3とすると、)
        // -> [x^s] (F1 + F2 + F3)
        // -> (F1 = (F0 + 1)f1, F2 = (F1 + 1)f2, F3 = (F2 + 1)f3とできる)
        // -> F1, F2, ...を都度計算して、その都度ans += [x^s]Fiする
        
        // ex. n = 3, s = 4, array[] = {2, 2, 4}
        // -> f(1,2)に1個、f(1,3)に2個、f(2,3)に1個、f(3,3)に1個 -> ans = 5
        // f1f2f3: 区間L,Rから部分列を全部取って和がいくつになるか考慮したもの
        // -> 部分列の全パターンは2^3 (各要素を選ぶか選ばないか)なので、
        // -> f1f2f3 = (1+x^2)(1+x^2)(1+x^4)
        // -> [x^4] (f1f2f3) = 2 ([2,2], [4])
        
        // dp[i][s]: [x^s] (Fi)
        long[][] dp = new long[n+1][s+1];
        for (int i = 0; i < n; i++) {
            int offset = array[i];
            
            // Fi = ((Fi-1) + 1)fi
            
            // Fi-1fi (選ぶ)
            for (int j = s; j - offset >= 0; j--) {
                dp[i+1][j] += dp[i][j - offset];
                dp[i+1][j] %= MOD;
            }
            // Fi-1fi (選ばない)
            for (int j = 0; j <= s; j++) {
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
            }
            
            // fi (選ぶ,選ばない)
            if (offset <= s) {
                dp[i+1][offset]++;
                dp[i+1][offset] %= MOD;
            }
            dp[i+1][0]++;
            dp[i+1][0] %= MOD;
            
            ans += dp[i+1][s];
            ans %= MOD;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 127708
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N; cin>>N;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  sort(ALL(A));
  vi sum(N);
  sum[0]=A[0];
  rep(i,1,N){
    sum[i]=sum[i-1]+A[i];
  }
  int ans=0;
  rep(i,0,N){
    int K=sum[i];
    int memo=i;
    while(1){
      if(A[N-1]<=K*2){
        ans=N-i;
        goto XYZ;
      }
      int Z=disup(A,K*2);
      if(Z==memo+1)
        break;
      memo=Z-1;
      K=sum[Z-1];
    }
  }
  XYZ:
  cout<<ans<<endl;
  }


Measured memory_bytes: 1792
N,K=map(int,input().split())
A=list(map(int,input().split()))
lk=len(bin(K))-2
C=[0]*lk
for j in range(N):
  a=A[j]
  for i in range(lk):
    if a%2==1:
      C[i]+=1
    a=(a-a%2)//2

X="0b"
for i in reversed(range(lk)):
  if C[i]>=N-C[i]:
    X+="0"
  else:
    X+="1"
    
if int(X,0)<=K:
  X=int(X,0)
  ans=0
  for i in range(N):
    ans+=X^A[i]
  print(ans)
else:
  ans=-1
  for i in range(2,lk+2):
    x=int(bin(K)[:i]+"0"+X[i+1:],0)
    if x<=K:
      a=0
      for i in range(N):
        a+=x^A[i]
      ans=max(ans,a)
  print(ans)


Measured memory_bytes: 68696
s = input().split()
a = int(s[0])
b = int(s[1])
c = int(s[2])

if a == b:
    if a == c:
        print("No")
    else:
        print("Yes")
elif a != b:
    if a == c:
        print("Yes")
    elif b == c:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int n;
cin >>n;
int a[n];
for(int i=0;i<n;i++) cin >>a[i];
sort(a,a+n);
if(a[0]==0&&a[1]==0) {
  cout << 0<<endl;
  return 0;
}
int k=0;
if(a[0]==0) k=1;
  int ans=0;int c=1;
  for(int i=k;i<n-1;i++){
    if(a[i]==a[i+1]){
      c++;
      if(i==n-2){
         if(c!=2) {
           cout << 0<<endl;
           return 0;
         }
      }
    }
    else{
      if(c!=2) {
        cout << 0<<endl;
        return 0;
      }
      c=1;
    }
  }
if(n%2==1){
 if(a[0]!=0){
   cout <<0<<endl;
   return 0;
 }
 long long int ans=1;
 for(int i=0;i<n/2;i++){
   ans*=2;
   ans%=1000000007;
 }
cout <<ans<<endl;
}
else{
  long long int ans=1;
  for(int i=0;i<n/2;i++){
    ans*=2;
    ans%=1000000007;
  }
 cout <<ans<<endl;
}
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <sstream>
#include <math.h>
#include <map>
using namespace std;

int G=0;

long long int gcd(long long int C,long long int D)
{
	int A,B;
	A=max(C,D);
	B=min(C,D);
	if(B==0){return A;}
	A=A%B;
	gcd(A,B);
}

int main()
{
	long long int A,B,C,D,T1,T2,T3,T4,T5,T6,g,L,ANS;
	cin >> A >> B >> C >> D;
	T1=B/C;
	T2=(A-1)/C;
	T3=B/D;
	T4=(A-1)/D;
	ANS=T1+T3-(T2+T4);
	G=gcd(C,D);
	L=(C*D)/G;
	T5=B/L;
	T6=(A-1)/L;
	ANS=ANS-(T5-T6);

	cout << B-A+1-ANS << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;



int main()
{
    int w, h, x, y, r ;
    cin >> w >> h >> x >> y >> r ;
    if(r<=y && y<=h-r && r<=x && x<=w-r){
        cout <<"Yes"<<endl;
    }
    else{
        cout <<"No"<<endl ;
    }

  return 0 ;
}


Measured memory_bytes: 3096
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int N, dp[100000];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> N;

    dp[0] = 0;
    FOR(n, 1, N) {
        dp[n] = dp[n - 1] + 1;

        int c6 = 1;
        while (c6 * 6 <= n) {
            c6 *= 6;
            dp[n] = min(dp[n], dp[n - c6] + 1);
        }

        int c9 = 1;
        while (c9 * 9 <= n) {
            c9 *= 9;
            dp[n] = min(dp[n], dp[n - c9] + 1);
        }
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define BUF 1e5
#define INF 1 << 30
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
constexpr ll mod = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> S >> T;
    map<char, vi> mp;
    for (int i = 0; i < S.size(); i++) {
        mp[S[i]].push_back(i);
    }
    bool flag = 1;
    int index = 0;
    for (int i = 0; i < T.size(); i++) {
        dump(ans);
        vi &x = mp[T[i]];
        if (x.size() == 0) {
            flag = 0;
            break;
        }
        auto itr = lower_bound(all(x), index);
        int tmp = *itr;
        dump(x, tmp, index, itr - x.begin());
        if (itr - x.begin() > x.size() - 1) {
            ans += S.size() - index;
            index = 0;
            int tmp2 = *lower_bound(all(x), index);
            dump(tmp2, ans);
            ans += tmp2 - index + 1;
            index = tmp2 + 1;
            continue;
        }
        ans += tmp - index + 1;
        index = tmp + 1;
        if (index >= S.size()) {
            index = 0;
        }
    }
    if (flag) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
}

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

int main()
{
    ll n;
    char c;
    string ans;
    cin >> n;

    while (n > 0)
    {
        n--;
        c = n % 26 + 97;
        ans += c;
        n /= 26;
        
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

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

int main(){
  ll X,K,D,f,left;
  cin>>X>>K>>D;
  X=abs(X);
  if(K<=X/D){
    cout<<abs(X-K*D)<<endl;
  }
  else{
    f=floor(X/D);
    left=K-f;
    X-=D*f;
    cout<<(left%2==0?X:abs(X-D))<<endl;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(v) std::begin(v), std::end(v)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Jul 26 18:28:31 JST 2020
 **/

signed main() {
    Int Q;
    std::cin >> Q;
    std::set<Int> s;
    REP(q, Q) {
        Int t, x;
        std::cin >> t >> x;
        if (t == 0) {
            s.insert(x);
            std::cout << s.size() << "\n";
        } else if (t == 1) {
            std::cout << s.count(x) << "\n";
        } else if (t == 2) {
            s.erase(x);
        } else {
            Int y;
            std::cin >> y;
            auto it1 = s.lower_bound(x);
            auto it2 = s.upper_bound(y);
            for (auto it = it1; it != it2; it++) {
                std::cout << *it << "\n";
            }
        }
    }
}



Measured memory_bytes: 12412
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s;
    cin >> s;
    cout << s.substr(0,5) << " " << s.substr(6,7) << " " << s.substr(14,5) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >>n;
  vector<double> vec(n);
  vector<double> vec2(n-1);
  for(int i=0;i<n;i++){
    cin >>vec[i];
  }
  sort (vec.begin(),vec.end());
  vec2[0]=(vec[0]+vec[1])/2;
  for(int i=1;i<n-1;i++){
    vec2[i]=(vec2[i-1]+vec[i+1])/2;
             }
    
    cout <<vec2[n-2]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a=0,b=0,c=0;
	int x=0;
	scanf("%d %d %d",&a,&b,&c);
	if(a+b==c|| a+c==b || b+c==a) x=1;
	if(x==1) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<climits>

using namespace std;

int main()
{
    int res=INT_MIN, currentMin=-1, N, data;
    scanf("%d", &N);
    scanf("%d", &data);
    currentMin=data;
    for(int i=1; i<N; i++)
    {
        scanf("%d", &data);
        res=max(data-currentMin, res);
        if(data<currentMin)
            currentMin=data;
    }
    printf("%d\n", res);
    return 0;
}



Measured memory_bytes: 3220
#include <iostream>
#include <stdio.h>
#include <malloc.h>
#define MAXV 500000
using namespace std;

struct Node
{
    int key;
    Node *parent,*right,*left;
};
Node *root = NULL;
void inserts(int key)
{
    Node *z,*y,*x;
    z = (Node*)malloc(sizeof(Node));
    z->key = key;
    z->left = z->parent = z->right = NULL;
    y = NULL;
    x = root;
    while(x!=NULL)
    {
        y = x;
        if(x->key < z->key)
            x = x->right;
        else
            x = x->left;
    }
    z->parent = y;
    if(y==NULL){
        root = z;
    }
    else if(z->key < y->key){
        y->left = z;
    }
    else {
        y->right = z;
    }
}
void preParse(Node *x){
    if(x==NULL){
        return ;
    }
    printf(" %d",x->key);
    preParse(x->left);
    preParse(x->right);
}
void inParse(Node *x){
    if(x==NULL){
        return;
    }
    inParse(x->left);
    printf(" %d",x->key);
    inParse(x->right);
}
void print(){
    inParse(root);
    putchar('\n');
    preParse(root);
    putchar('\n');
}

int main()
{
    int m,key,i;
    char com[7];
    scanf("%d",&m);
    for(i = 0; i < m; i++)
    {
        scanf("%s",&com);
        if(com[0]=='i')
        {
            scanf("%d",&key);
            inserts(key);
        }
        else if(com[0]=='p')
        {
            print();
        }
    }
    return 0;
}



Measured memory_bytes: 26516
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << "-->" << x << endl;
#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        cout << it << " ";        \
    }                             \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
    #define mod 998244353
 
#define fi first
#define se second
string s;
int dp[1000001][2];
int fun(int i,int g){
    if(i<0)
        return g;
        if(dp[i][g]!=-1)
            return dp[i][g];
    int ans = 1e15;
        if(s[i]=='9'){
            if(g==1){
                ans = min(ans, fun(i - 1, 1));
            }
            else{
                ans = min(ans, 1+fun(i - 1, 1));
                ans = min(ans, 9+fun(i - 1, 0));
            }
            return dp[i][g]=ans;
        }
    int val = s[i] - '0' + g;
    //deb(val);
    ans = min(ans, val + fun(i - 1, 0));
    ans = min(ans,10 - val+ fun(i - 1, 1));
    //deb(ans);
    return dp[i][g]=ans;

}
int32_t main() 
{
   
   cin>>s;
   int ans = 0;
   
    int n=s.size();
    memset(dp, -1, sizeof(dp));
    cout << fun(n - 1, 0);
//     int c = 0;
//     vec v(n);
//     vec val(n, 0);
//     foo(i, 1, n)
//     {

//         if (((s[i - 1] - '0') > 5) || ((s[i - 1] == '5') && (val[i - 1] == 1)))
//         {
//             val[i] = 1;
//         }
//    }
//        //deb1a(val);
 
//        for (int i = n - 1; i >= 0; i--)
//        {
//            if (s[i] == '9')
//            {
//                if (c == 0)
//                    ans++;
//                s[i] = '0';
//                c = 1;
//            }
//            else
//            {
 
//                s[i] += c;
 
//                if (s[i] - '0' > 5)
//                {
//                    ans += (10 - (s[i] - '0'));
//                    s[i] = '0';
//                    c = 1;
//                }
//                else if ((s[i] - '0' == 5) && (val[i] == 1))
//                {
//                    ans += (10 - (s[i] - '0'));
//                    s[i] = '0';
//                    c = 1;
//                }
//                else
//                {
//                    c = 0;
//                }
//            }
//    }
//    ans += c;
//    fo(i,n){
//        ans += (s[i] - '0');
//    }
//    cout << ans;
} 

Measured memory_bytes: 63876
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

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

int main() {
    int N, K; cin >> N >> K;
    vector<ll> v(N); for (int i = 0; i < N; ++i) cin >> v[i];

    ll res = 0;

    for (int i = 0; i <= K; ++i) {
        for (int j = 0; i + j <= K; ++j) {
            if (i + j > N) continue;

            vector<ll> h;
            for (int k = 0; k < i; ++k) h.push_back(v[k]);
            for (int k = 0; k < j; ++k) h.push_back(v[N-k-1]);

            sort(h.begin(), h.end());

            int n = i + j;
            for (int k = 0; k < K - n && k < n; ++k) h[k] = max(0LL, h[k]);

            res = max(res, accumulate(h.begin(), h.end(), 0LL));
        }
    }

    cout << res << endl;
}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
#define guard(x) if( not ( x ) ) continue;
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      std::string ss; scan(ss);
      Int res = 0;
      for(char c : ss) if( c == '1' ) res += 1;
      printf("%ld\n", res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ll res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ull gcd(ull x,ull y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<ll,ll> x,pair<ll,ll> y)
{
    return x.first>y.first;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[100005]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<100005;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(100005);i++){
//      if(prime[i]){
//          for(j=i*i;j<100005;j+=i){
//              prime[j]=0;
//          }
//      }
//  }
    
// }
void swap(int &x,int &y){
    int temp=x;
    x=y;
    y=temp;
}

void solve()
{   
    ll a,b,n;
    cin>>a>>b>>n;
    ll x=min(b-1,n);
    cout<<(a*x)/b;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}


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

bool solve() {
    string S;
    cin >> S;
    for ( int i = 0; i < S.size()-1; i++ ) {
        if ( S.substr(i,2) == "AC" ) return true;
    }
    return false;
}

int main() {
    string ans = solve() ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
                                                                                                
  
int main(void){
                                                                                                
   
    long long n, i, j;

    long long b[10000];

    long long k[10000] = {0};

    long long a = 1;
         
   
    scanf("%lld", &n );


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

         b[i] = i;

         for( j = 2 ; j <= n ; j = j + 1 ){

              while( b[i] % j == 0 ){

                     k[j] += 1;

                     b[i] = b[i] / j;

                     }

              }

         }

         


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

         if( k[i] != 0 ){

             a *= k[i] + 1;

             a = a % ( 1000000000 + 7 );                  

             }

         }
 

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


    return 0;
                                                          
}

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

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

  vector<ll> a(n);
  map<ll, ll> cnt;
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  
  ll total = 0;
  for (auto item : cnt) {
    total += item.second * (item.second - 1) / 2;
  }

  for (ll i = 0; i < n; i++) {
    cout << total - cnt[a[i]] * (cnt[a[i]] - 1) / 2 + (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2 << endl;
  }
}


Measured memory_bytes: 11008
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

const double EPS = 1e-9;

struct Node
{
	int city, flag;
	double cost;

	Node( int c, int f, double co ) : city( c ), flag( f ), cost( co )
	{
		return;
	}

	bool operator > ( const Node & a ) const
	{
		return a.cost > cost;
	}
};

double dijkstra( vector< vector< PII > > G, VI tic, int s, int t )
{
	const int n = tic.size();

	vector< vector<double> > dist( G.size(), vector<double>( 1 << n, DBL_MAX ) );
	dist[s][0] = 0;

	vector< vector<bool> > used( G.size(), vector<bool>( 1 << n, false ) );

	while ( true )
	{
		int v = -1, u = -1;

		REP( i, 0, dist.size() )
		{
			REP( j, 0, dist[i].size() )
			{
				if ( !used[i][j] && ( v == -1 || dist[i][j] < dist[v][u] ) )
				{
					v = i;
					u = j;
				}
			}
		}

		if ( v == -1 )
		{
			break;
		}

		used[v][u] = true;

		Node cur( v, u, dist[v][u] );

		EACH( e, G[ cur.city ] )
		{
			REP( i, 0, n )
			{
				if ( cur.flag & ( 1 << i ) )
				{
					continue;
				}

				auto nflag = cur.flag | ( 1 << i );
				
				dist[ e.fst ][ nflag ] = min( dist[ e.fst ][ nflag ], dist[v][u] + (double)e.snd / tic[i] );
			}	
		}
	}

	return *min_element( ALL( dist[t] ) );
}

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

	cout.precision( 6 );
	cout << fixed;

	while ( true )
	{
		int n, m, p, a, b;
		cin >> n >> m >> p >> a >> b;

		if ( !( n | m | p | a | b ) )
		{
			break;
		}

		a--;
		b--;

		VI tic( n );

		EACH( t, tic )
		{
			cin >> t;
		}

		vector< vector< PII > > G( m );

		REP( i, 0, p )
		{
			int x, y, z;
			cin >> x >> y >> z;

			x--;
			y--;

			G[x].PB( MP( y, z ) );
			G[y].PB( MP( x, z ) );
		}

		double res = dijkstra( G, tic, a, b );

		if ( res != DBL_MAX )
		{
			cout << res << endl;
		}
		else
		{
			cout << "Impossible" << endl;
		}
	}

	return 0;
}

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

int main(){
    ll n; cin>>n;
    ll ans=0LL;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            if(i<=n/i-2)ans+=n/i-1;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100000
 
int main(void){
 
  int i,j,n,m,count=0;
  int s[N],t[N];
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
 
  scanf("%d",&m);
 
  for(j=0;j<m;j++){
    scanf("%d",&t[j]);
  }
 
  for(j=0;j<m;j++){
    for(i=0;i<n;i++){
      if(s[i] == t[j]){
    count++;
    break;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 2104
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let n = line.trim().parse::<u32>().ok().unwrap();
    match n % 10 {
        3 => println!("bon"),
        0 | 1 | 6 | 8 => println!("pon"),
        _ => println!("hon"),
    }
}


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

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

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

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

#define PB push_back
#define MP make_pair
#define itr iterator

int v, e;
int cap[100][100];
bool used[100];

int flow(int x, int amt){
	if(x==v-1) return amt;
	used[x]=true;
	REP(i, v){
		if(cap[x][i] && !used[i]){
			int f = flow(i, min(amt, cap[x][i]));
			if(f){
				cap[x][i]-=f;
				cap[i][x]+=f;
				return f;
			}
		}
	}
	return 0;
}

int main(){
	scanf("%d%d", &v, &e);
	REP(i, 100) REP(j, 100) cap[i][j]=0;
	REP(i, e){
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		cap[a][b]=c;
	}
	int ans = 0;
	while(1){
		fill(used, used+100, false);
		int f = flow(0, INT_MAX);
		if(f) ans+=f;
		else break;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 3256
n,m=map(int,input().split())
x=[]
ans=0
for i in range(m):
    l=list(map(int,input().split()))
    x.append(l)
p=list(map(int,input().split()))
for i in range(2**n):
    frag=True
    for j in range(m):
        count=0
        for a in range(1,x[j][0]+1):
            s=x[j][a]
            count+=(i>>(s-1))&1
        if count%2!=p[j]:
            frag=False
    if frag:
        ans+=1
print(ans)

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

int main(){
  ll n, m, v, p;
  cin >> n >> m >> v >> p;
  ll a[n];
  rep(i,n) cin >> a[i];
  sort(a,a+n,greater<ll>());
  ll ans = p;
  ll s = 0;
  for(int i = p; i < n; i++) {
    s += a[i-1];
    if(a[i] + m < a[p-1]) continue;
    int l = v-1-(p+n-i-2);
    if(l <= 0) ans++;
    else {
      if((m+a[i])*(i-p+1) - s >= l*m) ans++;
    } 
  }
  cout << ans << endl;
  return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<int32_t mod>
struct ModInt{
	int32_t a;
	inline int32_t normalize(int64_t x){
		x%=mod;
		if(x<0)x+=mod;
		return x;
	}
	ModInt(const int64_t a=0):a(normalize(a)){}

	ModInt& operator+=(const ModInt &x){
		a+=x.a;
		if(a>=mod)a-=mod;
		return *this;
	}
	ModInt& operator-=(const ModInt &x){
		a-=x.a;
		if(a<0)a+=mod;
		return *this;
	}
	ModInt& operator*=(const ModInt &x){
		a=(int64_t)a*x.a%mod;
		return *this;
	}
	ModInt& operator/=(const ModInt &x){
		*this*=x.inv();
		return *this;
	}

	ModInt operator+(const ModInt x){return ModInt(*this)+=x;}
	ModInt operator-(const ModInt x){return ModInt(*this)-=x;}
	ModInt operator*(const ModInt x){return ModInt(*this)*=x;}
	ModInt operator/(const ModInt x){return ModInt(*this)/=x;}
	bool operator==(const ModInt x){return a==x.a;}
	bool operator!=(const ModInt x){return a!=x.a;}

	ModInt operator-(){return ModInt(0)-ModInt(*this);}
	ModInt pow(int64_t ex)const{
		int64_t x=a;
		int64_t res=1;
		while(ex){
			if(ex&1)res=res*x%mod;
			x=x*x%mod;
			ex>>=1;
		}
		return ModInt(res);
	}
	ModInt inv()const{return pow(mod-2);}
};

template<int32_t mod>
istream& operator>>(istream& in,ModInt<mod>& a){
	return (in>>a.a);
}
template<int32_t mod>
ostream& operator<<(ostream& out,const ModInt<mod>& a){
	return (out<<a.a);
}
using mint=ModInt<1000000007>;

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


	int cur=0;
	mint ans=1;
	for(int i=0;i<2*N;i++){
		int b;
		if(S[i]=='B')b=1;else b=0;

		if((cur+b)%2==0){
			ans*=cur;
			cur--;
		}
		else{
			cur++;
		}
	}

	for(int i=1;i<=N;i++)ans*=i;
	if(cur)cout<<0<<endl;
	else cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
int strL[1000000];
char str[1000000];
int main() {
	string d;
	cin >> d;
	int now=0,nowL=0;
	for(int i=0;i<d.length();i++){
		if(d[i+1]==d[i]){
			now++;
		}
		else{
			strL[nowL]=now+1;
			str[nowL]=d[i];
			now=0;
			nowL++;
		}
	}
	int maxer=0;
	for(int i=1;i<nowL-1;i++){
		if(str[i]=='O' && str[i-1]=='J' && str[i+1] == 'I'){
			if(strL[i]<=strL[i-1] && strL[i]<=strL[i+1])
				maxer=max(maxer,strL[i]);
		}
	}
	cout << maxer << endl;
	return 0;
}

Measured memory_bytes: 6992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
 
 
ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/
int main(){
    double R;
    cin>>R;
    double ans=0;
    ans = R*2*3.141592653589;
    cout<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void mul(ll &x, ll y){
	x *= y;
	x %= mod;
}
 
void add(ll &x, ll y){
	x = x + y + mod;
	x %= mod;
}
ll binpow(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

void solve(){
	int n,k;
	cin>>n>>k;
	int a[n];
	rep(i,n)cin>>a[i];
	ll ans=0;
	sort(a,a+n);
	reverse(a,a+n);
	for(int i=k;i<n;i++)ans+=a[i];
	cout<<ans;
	

}


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

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

int main(){
    char b;
    cin >> b;
    
    if(b == 'A'){
        cout << 'T' << endl;
    }  
    if(b == 'T'){
        cout << 'A' << endl;
    }
    if(b == 'G'){
        cout << 'C' << endl;
    }
    if(b == 'C'){
        cout << 'G' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	string str;
	int pos1=0,pos2,cnt=0;
	cin >> str;
	pos2 = str.length()-1;
	while(pos1 < pos2){
		if(str[pos1] != str[pos2]){
			if(str[pos1] == 'x'){
				cnt++;
				pos1++;
			}else if(str[pos2] == 'x'){
				cnt++;
				pos2--;
			}else{
				break;
			}
		}else{
			pos1++;
			pos2--;
		}
	}
	if(pos1 < pos2)
		cout << "-1" << endl;
	else
		cout << cnt << endl;
}

Measured memory_bytes: 512
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

int d(int i, int j) {
    return abs(i - j);
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> ans(n - 1, 0);
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            int cur = d(i, j);
            cur = min(cur, d(i, x) + d(y, j) + 1);
            cur = min(cur, d(i, y) + d(x, j) + 1);
            ans[cur - 1]++;
//            cout << i << " " << j << " " << cur << "\n";
        }
    }
    for (int i = 0 ;i < n - 1; i++) cout << ans[i] << "\n";
}
/*

*/


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

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        long n = sc.NextLong();
        long m = sc.NextLong();

        Console.WriteLine(n == 1 && m == 1 ? 1 : n == 1 || m == 1 ? n * m - 2 : Math.Max(n - 2, 0) * Math.Max(m - 2, 0));
    }

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

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 11092
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var ab = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            Console.WriteLine(ab[0] % 3 == 0 || ab[1] % 3 == 0 || ab.Sum() % 3 == 0 ? "Possible" : "Impossible");
        }
    }
}

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



int N;


int main(){
	cin >> N;
	vector<int> A(N);
	
	
	
	for ( int i = 0; i < N; i++ )
		cin >> A[i];
	
	deque<int> q; // 全ての色の、現在の最大値
	
	for ( int i = 0; i < N; i++ ){
		if ( q.empty() ){
			q.push_back( A[i] );
		}
		else {
			auto it = lower_bound(q.begin(), q.end(), A[i]);
			if ( it == q.begin() ){
				// このAより小さい色が無い。新しい色を用意する
				q.push_front( A[i] );
			}
			else {
				// 小さい色があるので、それを使う
				*(it-1) = A[i];
			}
		}
	}
	
	cout << q.size() << endl;
	
	
	return 0;
}



Measured memory_bytes: 1024
/* ex4_2 KitamoriFumiya */
#include <stdio.h>
#include <math.h>
#define PI 3.14159265359
 
//  余弦定理で長針と短針の先端の距離を出力する関数
void cosine(double length_hour, double length_minute, double hour, double minute){
	double angle_hour, angle_minute, difference_angle; // angle_hour(長針の角度), angle_minute(短針の角度), difference_angle(長針と短針の角度の差)をdouble型の変数として宣言
	angle_hour = 360 * hour / 12 + 30 * minute / 60; // 長針の角度を計算
	angle_minute = 360 * minute / 60; // 短針の角度を計算
	difference_angle = angle_hour - angle_minute; // 長針と短針の角度の差を計算
	difference_angle = (difference_angle / 180) * PI ; // 角度の差を弧度法で表す
	double distance; // 長針と短針の先端の距離をdouble型の変数として宣言
	distance = length_hour * length_hour + length_minute * length_minute - 2 * length_hour * length_minute * cos(difference_angle); // 距離の2乗を余弦定理で求める
	distance = sqrt(distance); // 距離をルートに入れて戻す
	printf("%.10lf\n", distance); // 距離を少数第10位まで出力する
}
 
int main(){
	double length_hour, length_minute, hour, minute; // length_hour(長針の長さ), length_minute(短針の長さ), hour(時間), minute(分数)をdouble型の変数として宣言
	scanf("%lf %lf %lf %lf", &length_hour, &length_minute, &hour, &minute); // length_hour, length_minute, hour, minuteを入力
	
	cosine(length_hour, length_minute, hour, minute); // 余弦定理で長針と短針の先端の距離を出力する関数を実行
	
	return 0;
}

Measured memory_bytes: 2588
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

int main() {
  int N, M, K, tmp;
  bool flag;
  while (cin >> N, N) {
    vector<vector<int> > vv(N);
    vector<int> leak;
    vector<int> criminal;
    for (int i = 0; i < N; i++) {
      cin >> M;
      for (int j = 0; j < M; j++) {
        cin >> tmp;
        vv[i].pb(tmp-1);
      }
    }
    cin >> K;
    for (int i = 0; i < K; i++) {
      cin >> tmp;
      leak.pb(tmp-1);
    }
    for (int i = 0; i < N; i++) {
      flag = true;
      for (int j = 0; j < K; j++) {
        vector<int>::iterator itr = find(vv[i].begin(), vv[i].end(), leak[j]);
        if (itr == vv[i].end()) {
          flag = false;
          break;
        }
      }
      if (flag) {
        criminal.pb(i+1);
      }
    }
    if (criminal.size() == 1) {
      cout << criminal[0] << el;
    } else {
      cout << "-1" << el;
    }
  }
}

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

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    int a,b;
    bool start=true;
    while(cin>>a>>b&&a){
        if(start){
            start=false;
        }else cout<<endl;
        bool f=true;
        rep(i,a,b+1){
            int n=i;
            if(n%400==0){
                cout<<i<<endl;
                f=false;
            }
            else if(n%100&&n%4==0){
                cout<<i<<endl;
                f=false;
            }
        }
        if(f)cout<<"NA"<<endl;
        
    }

    return 0;
}



Measured memory_bytes: 2964
# AC: 753 msec(Python3)
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.size = [1] * (n+1)
    
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.find(self.par[x])
  
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.size[x] < self.size[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
           
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    
    def get_size(self, x):
        return self.size[self.find(x)]


def main():
    N,M,K,*uv = map(int, read().split())
    ab, cd = uv[:2*M], uv[2*M:]

    uf = UnionFind(N)
    friend = [[] for _ in range(N+1)]
    for a, b in zip(*[iter(ab)]*2):
        uf.unite(a, b)
        friend[a].append(b)
        friend[b].append(a)
    
    ans = [uf.get_size(i) - 1 - len(friend[i]) for i in range(N+1)]

    for c, d in zip(*[iter(cd)]*2):
        if uf.is_same(c, d):
            ans[c] -= 1
            ans[d] -= 1
    
    print(*ans[1:])


if __name__ == "__main__":
    main()


Measured memory_bytes: 46580
#include <stdio.h>
int main(void){
    long long int a,b,x1=0,x2=0,ans=10;
    scanf("%lld%lld",&a,&b);
    for(int i=a;i<=b;i++){
        if(i<0)x1++;
        else if(i==0)ans=0;
        else x2++;
    }
    if(x1%2==0&&ans!=0)ans=1;
    else if(x1%2==1&&ans!=0)ans=-1;
    if(ans==0)printf("Zero\n");
    else if(ans==1)printf("Positive\n");
    else printf("Negative\n");
    return 0;
}


Measured memory_bytes: 128
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define RREP(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define ALL(vector) vector.begin(), vector.end()

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    if (n%1000==0){
        cout<<0<<endl;
        return 0;
    }
    cout<<1000 - (n % 1000)<<endl;
    return 0;
}

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

struct p{
    int x,y;
};

int main()
{
    int n,m,i;
    cin>>n>>m;
    p st[n],cp[m];
    for(i=0;i<n;i++)
    {
        cin>>st[i].x>>st[i].y;
    }
    for(i=0;i<m;i++) cin>>cp[i].x>>cp[i].y;
    for(i=0;i<n;i++)
    {
        int md=900000000,ans,a;
        for(int j=0;j<m;j++)
        {
            a=abs(st[i].x-cp[j].x)+abs(st[i].y-cp[j].y);
            if(a<md){
                ans=j+1;
                md=min(md,a);
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> c(n-1), s(n-1), f(n-1);
    for (int i = 0; i < n - 1; i++) cin >> c[i] >> s[i] >> f[i];

    for (int i = 0; i < n; i++) {
        int tmp = 0;
        for (int j = i; j + 1 < n; j++) {
            tmp = tmp <= s[j] ? s[j] + c[j] : (tmp + f[j] - 1) / f[j] * f[j] + c[j];
        }
        cout << tmp << endl;;
    }
}


Measured memory_bytes: 256
import bisect
n=int(input())
L=list(map(int,input().split()))

L.sort()
ans=0

#a<b<c,a+b>c
for b in range(n):
    for a in range(b):
        ab=L[a]+L[b]
        r=bisect.bisect_left(L,ab)
        l=b+1
        #print("a=" + str(a) + "b=" +str(b))
        ans+=max(0,r-l)

print(ans)

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

int main() {
  int N, M;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }
  cin >> M;
  vector<string> t(M);
  for (int i = 0; i < M; i++) {
    cin >> t[i];
  }

  vector<int> pointList(N);

  for (int i = 0; i < N; i++) {
    int point = 0;
    for (int j = 0; j < N; j++) {
      if (s[i] == s[j]) {
        point += 1;
      }
    }
    for(int k = 0; k < M; k++) {
      if(s[i] == t[k]) {
        point -= 1;
      }
    }
    if (point < 0) {
      point = 0;
    }
    pointList[i] = point;
  }

  sort(pointList.begin(), pointList.end());
  reverse(pointList.begin(), pointList.end());
  cout << pointList[0] << endl;
};


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,k;
int dislike[10];
bool like(int a){
	while(a>0){
		if(dislike[a%10])
			return false;
		a/=10;
	}
	return true;
}
int main(){
	cin>>n>>k;
	for(int i=0;i<k;++i){
		int tmp;
		cin>>tmp;
		dislike[tmp]=1;
	}
	while(!like(n)){
		++n;
	}
	cout<<n<<endl; 
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto SP = new string[2][](N);

	foreach (i; 0..N)
	{
		auto S = RD!string;
		auto P = RD!string;
		SP[i] = [S, P];
	}

	auto index = MAKE_IDX!("a[0] < b[0]")(SP);
	auto ans = new long[](N);
	long[] pool;
	string last;
	long cnt;
	foreach (i; index)
	{
		if (last == SP[i][0])
		{
			pool ~= i;
		}
		else
		{
			long[2][] ps;
			foreach (j; pool)
			{
				ps ~= [j, SP[j][1].to!long];
			}
			auto index2 = MAKE_IDX!("a[1] > b[1]")(ps);
			
			foreach (j; index2)
			{
				auto num = ps[j][0];
				ans[cnt] = num;
				++cnt;
			}
			last = SP[i][0];
			pool.length = 0;
			pool ~= i;
		}
	}
	long[2][] ps;
	foreach (j; pool)
	{
		ps ~= [j, SP[j][1].to!long];
	}
	auto index2 = MAKE_IDX!("a[1] > b[1]")(ps);

	foreach (j; index2)
	{
		auto num = ps[j][0];
		ans[cnt] = num;
		++cnt;
	}
	
	foreach (e; ans)
		writeln(e+1);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256