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

int main(){
  int N;
  cin >>N;
  int ans=0;
  vector<int> a(N);
  for(int i=0;i<N;i++) cin >> a.at(i);
  sort(a.begin(),a.end());
  int count = 1;
  for(int i=1;i<N;i++){
    if(a.at(i-1) != a.at(i)){
      if(count > a.at(i-1)) ans = ans-a.at(i-1)+count;
      else if(count < a.at(i-1)) ans += count;
      count = 1;
      continue;
    }
    if(a.at(i-1) == a.at(i)) count++;
  }
  if(count > a.at(N-1)) ans = ans-a.at(N-1)+count;
  else if(count < a.at(N-1)) ans += count;
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a>b){
		printf("a > b\n");
	}
	else if(a<b){
		printf("a < b\n");
	}
	else{
		printf("a == b\n");
	}
	
	return 0;
}



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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;



int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n;
    cin >> n;

    vector<int> a(n);
    int cnt = 0, zeros = 0, m = INF;
    ll ans = 0;
    rep(i, n) {
        cin >> a[i];

        if(a[i] > 0){
            ans += a[i];
            m = min(m, a[i]);
        }else{
            ans += -a[i];
            m = min(m, -a[i]);
        }
        if(a[i] < 0) cnt++;
        if(a[i] == 0) zeros++;

    }

    if(cnt % 2 == 1 && zeros == 0){
        ans -= 2 * m;
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

void solve()
{
	string number;
	cin >> number;

	int n = len(number);
	int answ = 0;

	for(auto& ch: number)
		answ += ch - '0';

	answ = max(answ, 9 * (n - 1));

	int pref = 0;

	for(int i = 0; i < n; ++i)
	{
		if(number[i] > '0')
		{
			int local = pref + number[i] - '1' + 9 * (n - i - 1);
			answ = max(answ, local);
		}

		pref += number[i] - '0';
	}

	cout << answ << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pl;


int main()
{
	int n;
	while (cin >> n, n) {
		vector<pl> A(n);

		for (int i = 0; i < n; i++) {
			ll d1, d2;
			cin >> A[i].second >> d1 >> d2;
			A[i].first = d1 + d2;
		}
		sort(A.begin(),A.end(), greater<pl>());
		printf("%lld %lld\n", A[0].second, A[0].first);

	}
	return 0;
}

Measured memory_bytes: 3272
#include <bits/stdc++.h>
#define X first
#define Y second
#define mp make_pair
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;

const int N = 100010;
int a[N],n;
int main(){
	scanf("%d",&n);
	int cnt = 0;
	for(int i = 0;i<n;i++){
		int x;
		scanf("%d",&x);
		if(x&1) cnt++;
	}
	if(cnt&1) puts("NO"); else puts("YES");
	return 0;
}

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

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int N; cin>>N;
  vector<int> o(N), ans, n;
  REP(i,N) {
    cin>>o[i];
  }

  while(! o.empty()) {
    //    cout << o.size() << endl;                                                      
    n.clear();
    bool ok = false;
    for(int i = o.size() -1; i >= 0; i--) {
      if(o[i] == i+1 && !ok) {
	ans.push_back(o[i]);
	ok = true;
      } else {
	n.push_back(o[i]);
      } 
    }
    if(!ok) {
      cout << -1 << endl;
      return 0;
    }
    reverse(n.begin(), n.end());
    o = n;
  }
  reverse(ans.begin(), ans.end());
  //  cout << "Answer=" <<endl;                                                          
  REP(i,ans.size()) {
    cout << ans[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 256
M,K=map(int,input().split())
if M==0:
    if K==0:
        print(0,0)
    else:
        print(-1)
elif M==1:
    if K==0:
        print(0,0,1,1)
    else:
        print(-1)
else:
    if K>=2**M:
        print(-1)
    else:
        ans=[]
        for i in range(0,2**M):
            if i!=K:
                ans.append(i)
        ans.append(K)
        for i in range(2**M-1,-1,-1):
            if i!=K:
                ans.append(i)
        ans.append(K)
        print(*ans)

Measured memory_bytes: 59396
#include<stdio.h>
int main()
{
    int N,R;
    int Inner;
    scanf("%d", &N);
    scanf("%d", &R);
    if(N<10)
    {
        Inner = R + (100*(10-N));
        printf("%d\n", Inner);
    }
    else
    {
        Inner = R;
        printf("%d\n", Inner);
    }

    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
int main()
{
	ll a,b,c,k,a1,b1,c1,cnt=0;
    cin>>a>>b>>c>>k;
    if(k%2==0)
        cout<<a-b;
    else
        cout<<b-a;
}

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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const long long LINF = 1000000000000000018ll;
const int INF = 1000000009;
const int mod = 1000000007;
const int mod2 = 998244353;

int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};

int main() {
  std::cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::setprecision(20) << std::fixed;

  int n;
  cin >> n;

  ll sum = 0;
  for (ll i = 0; i <= n; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      sum += i;
      // cout << i << endl;
    }
  }
  cout << sum << endl;

  return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int xl = (int)(n / 1.08);
	if ((int)(xl * 1.08) == n) {
		cout << xl;
	}
	else if ((int)((xl + 1) * 1.08) == n) {
		cout << xl + 1;
	}
	else {
		cout << ":(";
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int a, b;
    cin >> a >> b;

    if (a < b) {
        for (int i = 0; i < b; i++) {
            cout << a;
        }
    } else {
        for (int i = 0; i < a; i++) {
            cout << b;
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

template <class T>
map<T, T> prime_factorize(T n) {
    map<T, T> res;
    for (T i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1)
        res[n] = 1;
    return res;
}

namespace my {
void merge(std::map<int, int> &a, std::map<int, int> b) {
    for (auto i = b.begin(); i != b.end(); i++) {
        if (a[i->first] > 0)
            a[i->first] += i->second;
        else
            a[i->first] = i->second;
    }
}
} // namespace my

signed main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    rep(i, ty - sy) cout << 'U';
    rep(i, tx - sx) cout << 'R';
    rep(i, ty - sy) cout << 'D';
    rep(i, tx - sx) cout << 'L';
    cout << 'L';
    rep(i, ty - sy + 1) cout << 'U';
    rep(i, tx - sx + 1) cout << 'R';
    cout << 'D';
    cout << 'R';
    rep(i, ty - sy + 1) cout << 'D';
    rep(i, tx - sx + 1) cout << 'L';
    cout << 'U' << endl;
}

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

struct node {int parent, left, right;};
const int MAX = 25, NIL = -1;
node T[MAX];
int n;

void preorder(int i){
    if(i == NIL) return;
    cout << " " << i;
    preorder(T[i].left);
    preorder(T[i].right);
}

void Inorder(int i){
    if(i == NIL) return;
    Inorder(T[i].left);
    cout << " " << i;
    Inorder(T[i].right);
}

void Postorder(int i){
    if(i == NIL) return;
    Postorder(T[i].left);
    Postorder(T[i].right);
    cout << " " << i;
}

int main(){
    int v, l, r, root = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
        T[i].parent = NIL;
    for (int i = 0; i < n; i++)
    {
        cin >> v >> l >> r;
        T[v].left = l;
        T[v].right = r;
        if (l != NIL)
            T[l].parent = v;
        if (r != NIL)
            T[r].parent = v;
        
    }
    for (int i = 0; i < n; i++)
    {
        if (T[i].parent == NIL)
            root = i;
    }
    cout << "Preorder" << endl;
    preorder(root);
    cout << "\nInorder" << endl;
    Inorder(root);
    cout << "\nPostorder" << endl;
    Postorder(root);
    cout << endl;
}


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

using namespace std;

#define int long long
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint int t;cin>>t;while(t--)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
const int N=1e5+5;

int mod=1e9+7;
int cache[N];
int a[N];
int n,k;

int dp(int idx){
//    if(idx<0) return 1e10;
    if(idx==1) return 0;

    int &ans=cache[idx];
    if(ans!=-1) return ans;

    ans=1e10;

    for(int i=idx-1;i>=0&&i>=idx-k;i--){
        ans=min(ans,dp(i)+abs(a[idx]-a[i]));
    }

    return ans;
}

int32_t main() {
    faster;

//    int n,k;
    cin>>n>>k;
    memset(cache, -1, sizeof(cache));
//    int h[n];
    for(int i=1;i<=n;i++) cin>>a[i];



    cout<<dp(n)<<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
int main() {	//N個の整数から連続するK個を選ぶ
  int R, G, B, N, count = 0;
  
  cin >> R >> G >> B >> N;

  for (int i=0; i<N+1; i++){
    
    if (i*R > N)
      break;
    
    for (int j=0; j<N+1; j++){
            
      if (i*R + j*G > N)
        break;
      
      if ( (N-i*R-j*G) % B == 0)
        count++;

    }
    
  }
  
  cout << count << endl;
  
}

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

int main() {
  int S, s1, s2, s3;
  cin >> S;
  s1 = S / 100;
  s2 = (S - s1 * 100) / 10;
  s3 = (S - s1 * 100 - s2 * 10);
  cout << s1 + s2 + s3 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int KYR = 1, JNY, OOTJNY = 10;
  long double MRS = 1;
  int PKRN = -1;
  int OOT, TIERU;
  cin >> OOT;
  
  for(int YUNI = 0; YUNI < OOT; YUNI++){
    cin >> JNY;
    if(KYR < 1000000000000000000){
      KYR *= JNY;
      MRS *= JNY;
    }
    else if(JNY == 0){
      KYR *= JNY;
      MRS *= JNY;
      break;
    }
  }
  
  if(MRS > 1000000000000000000){
    cout << -1 << endl;
  }
  
  else{
  cout << KYR << endl;;
  }
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[]args){
		//????????£?????????????????????
		Scanner sc = new Scanner (System.in);
		//???????????? ??????r
		double r = sc.nextDouble();

		//???????°???
		double PI = 3.14;

		//??¢???????±??????? ?????? ?? ?????? ?? 3.14
		double Area = (r * r) * Math.PI;
		//?????¨????????? ?????? * 2 ??3.14
		double Circle = ( r * 2 ) * Math.PI;

		//??¨???
		System.out.printf("%.6f %.6f", Area,Circle);
	}
}

Measured memory_bytes: 28204
#一週間　何日後は何曜日

S=input()
print()

if S=="SUN":
    print(7)
if S=="MON":
    print(6)
if S=="TUE":
    print(5)
if S=="WED":
    print(4)
if S=="THU":
    print(3)
if S=="FRI":
    print(2)
if S=="SAT":
    print(1)

Measured memory_bytes: 9100
object Main {

//  def main(args: Array[String]): Unit = {
//    val sc = new java.util.Scanner(System.in)
//
//    val N = sc.nextInt()
//    val A = Array.fill(N)(BigInt(sc.nextLong()))
//
//    def gcd(a: BigInt, b: BigInt): BigInt =
//      if (a % b == 0L) b
//      else gcd(b, a % b)
//
//    def lcm(a: BigInt, b: BigInt): BigInt =
//      a * (b / gcd(a, b))
//
//    val LCM = A.reduce((a, b) => lcm(a, b)) - 1
//    val r = A.foldLeft(BigInt(0))((b, n) => b + LCM % n)
//    println(r)
//  }

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val A = Array.fill(N)(sc.nextInt())

    // 実際にLCMを計算する必要はなく, 全ての a_i について,
    // n * a_i - 1 であるような m を設定できるので
    // それぞれ a_i - 1 を加算していけば良い

    val r = A.foldLeft(0L)((b, a) => b + a - 1)
    println(r)
  }

}


Measured memory_bytes: 29764
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int r = sc.nextInt();

        if (n < 10) {
            System.out.println(100 * (10 - n) + r);
        } else {
            System.out.println(r);
        }

    }
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;
typedef long long ll;


int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    ll r = (c-a-b) * (c-a-b);
    ll l = 4 * a * b;
    if(c-a-b < 0){
        cout << "No" << endl;
        return 0;
    }
    if(l < r){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_B
#include <iostream>
#include <string>
using namespace std;

int main(){
  int n, buf_n;
  cin >> n;
  string S = "S", H = "H", C = "C", D = "D";
  string buf_s;

  int cards[4][13];
  for(int i=0; i<4; i++){
    for(int j=0; j<13; j++){
      cards[i][j] = 0; //????????\??£???????????¶???????????¨???
    }
  }

  for(int i = 0; i<n; i++){
    cin >> buf_s >> buf_n;
    if(buf_s == S){
        cards[0][buf_n-1] = 1;
      }
    if(buf_s == H){
        cards[1][buf_n-1] = 1;
      }
    if(buf_s == C){
        cards[2][buf_n-1] = 1;
      }
    if(buf_s == D){
        cards[3][buf_n-1] = 1;
      }
  }


  for(int j=0; j<13; j++){
    if(cards[0][j] == 0){
      cout << S << " " << j+1 << endl;
    }
  }
  for(int j=0; j<13; j++){
    if(cards[1][j] == 0){
      cout << H << " " << j+1 << endl;
    }
  }
  for(int j=0; j<13; j++){
    if(cards[2][j] == 0){
        cout << C << " " << j+1 << endl;
    }
  }
  for(int j=0; j<13; j++){
    if(cards[3][j] == 0){
        cout << D << " " << j+1 << endl;
    }
  }
}

Measured memory_bytes: 1212
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	ll n,a,b,ans=0;
	cin>>n>>a>>b;
	for(ll i=1;i<=n;i++){
		string str=to_string(i);
		ll cnt=0;
		for(char j:str)	cnt+=j-'0';
		if(a<=cnt&&cnt<=b)	ans+=i;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
const int N = 2e5 + 10;
ll m, n;

ll sum[N];
ll a[N];
ll k;

map<ll, ll> ma;
// (sum[r] - sum[l -1]) % k == r - l + 1;

int main()
{
	scanf("%lld%lld", &n, &k);
	for (int i = 1; i <= n; i ++)
	{
		scanf("%lld", &a[i]);
		sum[i] = (sum[i - 1] + a[i]);
	}
	for (int i = 1; i <= n; i ++)
	{
		sum[i] = ((sum[i] - i) % k + k) % k;
	}
	ll ans = 0;
	ma[sum[0]] ++;
	for (int i = 1; i <= n; i ++)
	{
		if(i >= k) ma[sum[i - k]]--;
		ans += ma[sum[i]];
		ma[sum[i]] ++;
	}
	cout <<ans << endl;
}


Measured memory_bytes: 15872
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var abcd = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = abcd[0];
            var b = abcd[1];
            var c = abcd[2];
            var d = abcd[3];

            var x = Math.Max(a, c);
            var y = Math.Min(b, d);

            if(x > y)
            {
                Console.WriteLine(0);
                return;
            }

            Console.WriteLine(y - x);
            
        }
    }
}


Measured memory_bytes: 28256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a, b, c;
int main()
{
	cin >> a >> b >> c;
	if (c - a - b <= 0)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << ((4 * a * b < (c - a - b) * (c - a - b)) ? "Yes" : "No") << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
a,b,c=map(int,input().split())
if a==b and b!=c:
  print("Yes")
  sys.exit()
elif c==b and b!=a:
  print("Yes")
  sys.exit()
elif a==c and b!=c:
  print("Yes")
  sys.exit()
else:
  print("No")
  sys.exit()

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

int main(){
    long long a,b,x;
    cin >> a >> b >> x;
    long long c,d;
    if(a == 0){
        c = 0;
    }else{
        c = (a-1)/x+1;
    }
    d = b/x+1;

    cout << d - c << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <unordered_map>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <deque>

using namespace std;

typedef long long ll;

int main(void)
{
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	vector<int> delta(n);
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	for (size_t i = 0; i < n-1; i++)
	{
		delta[i] = a[i + 1] - a[i];
	}
	delta[n - 1] = k - a[n - 1] + a[0];

	sort(delta.begin(), delta.end(), std::greater<int>());

	cout << k - delta[0] << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll=int64_t;
int main(){
  vector<string> b(3);
  vector<int> l(3),p(3);
  char z;
  int j,y=0;
  for(j=0;j<3;j++){
    cin>>b[j];
    l[j]=b[j].length();
  }
  while(p[y]<l[y]){
    z=b[y][p[y]];
    p[y]++;
    y=z-'a';
  }
  cout<<(char)('A'+y)<<endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define PI 3.1415926535897932
#define MOD 1000000007;
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
long long LCM(long long A,long long B){
  long long g=GCD(A,B);
  return A/g*B;
}
long long num_order(long long X){
  long long ans=0;
  while(true){
    if(X==0){
      break;
    }
    else{
      X/=10;
      ans++;
    }
  }
  return ans;
}
int main() {
  
  long long N,M;
  cin>>N>>M;
  
  
  if(abs(N-M)>1){
    cout<<0<<endl;
  }
  else{
    long long ans=1;
    
    if(N==M){
      ans*=2;
      while(N!=0){
        ans*=(N*N);
        ans%=MOD;
        N--;
      }
    }
    else{
      while(N!=0){
        ans*=N;
        ans%=MOD;
        N--;
      }
      while(M!=0){
        ans*=M;
        ans%=MOD;
        M--;
      }
    }
    
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3624
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

c = [lint() for _ in range(3)]
judge(
    c[0][0]-c[0][1]==c[1][0]-c[1][1]==c[2][0]-c[2][1] and
    c[0][0]-c[0][2]==c[1][0]-c[1][2]==c[2][0]-c[2][2] and
    c[0][1]-c[0][2]==c[1][1]-c[1][2]==c[2][1]-c[2][2] and
    c[0][0]-c[1][0]==c[0][1]-c[1][1]==c[0][2]-c[1][2] and
    c[0][0]-c[2][0]==c[0][1]-c[2][1]==c[0][2]-c[2][2] and
    c[2][0]-c[1][0]==c[2][1]-c[1][1]==c[2][2]-c[1][2]
)

Measured memory_bytes: 67556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin>>n;
    map<string,ll> m;
    rep(i,n){
        string s;
        cin>>s;
        sort(all(s));
        m[s]++;
    } 

    ll ans=0;
    for(auto e : m){
        ll x=e.second;
        //cout<<e.first<<" "<<x<<endl;
        ans+=x*(x-1)/2;
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 11408
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];
    vector<ll> sum(N + 1);
    sum[0] = 0;
    rep(i, 0, N) sum[i + 1] = sum[i] + A[i];
    map<ll, ll> m;
    rep(i, 0, N + 1)
    {
        ++m[sum[i]];
    }

    ll ans = 0;
    for (const auto p : m)
    {
        ans += p.second * (p.second - 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	// your code goes here
	string s;
	cin>>s;
	ll a[4];
	for(ll i=0;i<4;i++)
	{
		a[i]=s[i]-'0';
	}
	ll x=a[0]*10+a[1];
	ll y=a[2]*10+a[3];
	if(x==0 && y>12)
	{
		cout<<"NA";
		exit(0);
	}
	if(y==0 && x>12)
	{
		cout<<"NA";
		exit(0);
	}
	if(x==0 && y==0)
	{
		cout<<"NA";
		exit(0);
	}
	if(x>12 && y>12)
	{
		cout<<"NA";
		exit(0);
	}
	if(x==0 && y<13)
	{
		cout<<"YYMM";
		exit(0);
	}
	if(x<13 && y==0)
	{
		cout<<"MMYY";
		exit(0);
	}
	if(x<13 && y<13)
	{
		cout<<"AMBIGUOUS";
		exit(0);
	}
	if(x<13 && y>12)
	{
		cout<<"MMYY";
		exit(0);
	}
	if(x>12 && y<13)
	{
		cout<<"YYMM";
		exit(0);
	}
	
}

Measured memory_bytes: 384
n=int(input())
h=list(map(int,input().split()))
c=0
a=0
for i in range(102):
  if a==1:
    c+=1
    a=0
  if max(h)==0:
    break
  for j in range(n):
    if h[j]>0:
      h[j]-=1
      a=1
    elif a==1:
      c+=1
      a=0
print(c)
    

Measured memory_bytes: 9128
#include <bits/stdc++.h>
//#include <eigen3/Eigen/Dense>
using namespace std;
//using namespace Eigen;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v) cout << i << ' ' << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vin2(v, w) for (ll i = 0; i < v.size(); ++i) cin >> v[i] >> w[i];
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(18);
	int D, T, S;
	cin >> D >> T >> S;
	if(D <= T * S){
		Yes;
	}else{
		No;
	}
}

Measured memory_bytes: 3644
import com.sun.org.apache.bcel.internal.generic.BIPUSH;

import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static final void NO() { out.println("NO"); }
    public static final void YES() { out.println("YES"); }

    public static final void main(String[] args) {
        new Main().solve();
        out.flush();
    }

    // ========================================================================= //

    public void solve() {
        char[][] C = new char[2][];
        C[0] = sc.next().toCharArray();
        C[1] = sc.next().toCharArray();
        if (C[0][0] != C[1][2] || C[0][1] != C[1][1] || C[0][2] != C[1][0]) {
            NO();
        }
        else {
            YES();
        }
    }

}



Measured memory_bytes: 21844
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

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

	for(int x=0;x<=N;x++){
		for(int y=0;(x+y)<=N;y++){
			if(x*10000+y*5000+(N-x-y)*1000==Y){
				printf("%d %d %d\n",x, y, N-x-y);
				return 0;
			}
		}
	}
	printf("-1 -1 -1\n");
	return 0;
}


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

int main(){
  string s, t;
  cin >> s >> t;

//  t.erase(t.begin()+t.size());
t.pop_back();

  if(t==s){
    cout << "Yes" << endl;
  }else{
    cout << "No"<< endl;
  }


  return 0;
}


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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,m;

int A[maxn],has[maxn],cnt;

void Work(){
	if(cnt>2)return void(puts("Impossible"));
	if(m==1){
		if(n>1)printf("%d\n2\n%d %d\n",n,1,n-1);
		else printf("%d\n1\n%d\n",n,n);
		return;
	}
	if(cnt)swap(A[1],A[has[1]]);if(cnt>1)swap(A[m],A[has[2]]);
	REP(i,1,m)printf("%d ",A[i]);puts("");
	if(A[m]>1)printf("%d\n",m);else printf("%d\n",m-1);
	printf("%d ",A[1]+1);
	REP(i,2,m-1)printf("%d ",A[i]);
	if(A[m]>1)printf("%d ",A[m]-1);
}

void Init(){
	read(n,m);
	REP(i,1,m)read(A[i]);
	REP(i,1,m)if(A[i]&1)has[++cnt]=i;
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    if(n == 1){
        cout << "Yes" << endl;
        return 0;
    }
    for(int i=0;i<n;i++)cin >> a[i];
    for(int i=0;i<n-1;i++){
        if(a[i]-a[i+1]<1)continue;
        else if(a[i]-a[i+1]==1){
            a[i+1]=a[i];
        }
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	#endif
	int a,b;
	char c;
	cin>>a>>c>>b;
	if(c == '-')b=-b;
	cout << a + b << '\n';
}


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

int main() {
	int N;
	cin >> N;
	double sum=0.0;
	for(int i=0; i<N; ++i){
	    double a;
	    cin >> a;
	    sum += 1.0/a;
	}
	cout << setprecision(10) << 1.0/sum << 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 SZ(s) ((int)(s.size()))
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair<int,int> PI;


bool vis[1<<12][1000];
vector<PI> G[1000];
int si[1000];
int ti[1000];

int main(int argc, char *argv[])
{
  int n, m, k, p;
  cin >> n >> m >> k >> p;
  --p;
  rep(i, m){
    int x, y, c;
    cin >> x >> y >> c;
    --x, --y;
    G[x].pb(mp(y,c));
    G[y].pb(mp(x,c));
  }
  int go = 0;
  rep(i, k){
    int s, t;
    cin >> s >> t;
    --s, --t;
    si[s] = i + 1;
    ti[t] = i + 1;
    go = go * 4 + 2;
  }

  priority_queue<pair<int,PI> > q;
  q.push(mp(0,mp(p,0)));

  while(!q.empty()){
    int cc = -q.top().F;
    int cv = q.top().S.F;
    int st = q.top().S.S;
    q.pop();
    if(si[cv] && ((~st >> (si[cv] - 1)*2) & 2)){
      st |= 1 << (si[cv] - 1) * 2;
    }
    if(ti[cv] && ((st >> (ti[cv] - 1)*2) & 1)){
      st ^= 3 << (ti[cv]-1) * 2;
    }      
    if(vis[st][cv]) continue;
    vis[st][cv] = 1;
    if(st == go){
      cout << cc << endl;
      return 0;
    }
    
    for(auto e : G[cv]){
      int nst = st;
      q.push(mp(-cc-e.S,mp(e.F,nst)));
    }
  }

  cout << "Cannot deliver" << endl;
}

Measured memory_bytes: 9384
n = int(input())
a = list(map(int, input().split()))

c_4 = 0
c_2 = 0
odd = 0
for i in range(n):
    if a[i]%4==0:
        c_4+=1
    elif a[i]%2==1:
        odd += 1
    else:
        c_2 += 1
if c_2==0:
    if odd <= c_4+1:
        print("Yes")
    else:
        print("No")
else:
    if odd <= c_4:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 14252
#include <stdio.h>
#include <math.h>

int main() {

	int i, j, n, x, count;
	double m;

	count = 0;

	scanf("%d", &n);

	for (i = 1; i <= n; i++)
	{
		scanf("%d", &x);
		m = sqrt(x);
		if (x == 2 || x == 3)
			count++;
		for (j = 2; j <= m + 1; j++)
		{
			if (x % j == 0 || x % 2 == 0 || x % 5 == 0)
			{
				break;
			}
			else if (j >= m)
			{
				count++;
				break;
			}
		}
	}

	printf("%d\n", count);

	return 0;

}


Measured memory_bytes: 2064
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

bool has(vector<string> &v, string s)
{

    return find(ALL(v), s) != v.end();
}

void show(vector<string> &v)
{
    rep(i, v.size())
    {
        cerr << v[i] << " ";
    }
    cerr << endl;
}

bool isprime(ll n)
{
    if (n == 2)
        return true;
    if (n == 1)
        return false;
    ll m = 1;
    while (m * m < n)
    {
        m++;
    }
    rep(i, 2, m + 1)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}

void init(vector<int> &v)
{
    v[0] = 2;
    int n = 3;
    int i = 1;
    while (i <= 100010)
    {
        cerr << i << endl;
        bool f = true;
        rep(j, i)
        {
            if (n % v[j] == 0)
            {
                f = false;
                break;
            }
        }
        if (f)
        {
            v[i] = n;
            i++;
        }
        n++;
    }
}

int main()
{
    vector<int> v(100010, 0);
    while (true)
    {
        int n;
        cin >> n;
        if (n == 0)
        {
            break;
        }
        ll low = n, up = n;

        while (!isprime(low))
            low--;
        while (!isprime(up))
            up++;
        cout << up - low << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include <iostream> 
#include <sstream> 
#include <iomanip> 
#include <algorithm> 
#include <cmath> 
#include <string> 
#include <vector> 
#include <list> 
#include <queue> 
#include <stack> 
#include <set> 
#include <map> 
#include <bitset> 
#include <numeric> 
#include <climits> 
#include <cfloat> 
using namespace std; 

int main()
{
    int n;
    cin >> n;
    cin.ignore();

    while(--n >= 0){
        string s;
        getline(cin, s);
        int m;
        cin >> m;
        cin.ignore();

        list<char> text(s.begin(), s.end());
        list<char>::iterator it = text.begin();

        while(--m >= 0){
            string ope;
            getline(cin, ope);

            if(ope == "forward char"){
                if(it != text.end())
                    ++ it;
            }else if(ope == "backward char"){
                if(it != text.begin())
                    -- it;
            }else if(ope == "delete char"){
                if(it != text.end())
                    it = text.erase(it);
            }else if(ope == "forward word"){
                while(it != text.end() && (*it) == ' ')
                    ++ it;
                while(it != text.end() && (*it) != ' ')
                    ++ it;
            }else if(ope == "backward word"){
                if(text.size() > 0 && it != text.begin()){
                    -- it;
                    while(it != text.begin() && (*it) == ' ')
                        -- it;
                    while(it != text.begin() && (*it) != ' ')
                        -- it;
                    if((*it) == ' ')
                        ++ it;
                }
            }else if(ope == "delete word"){
                list<char>::iterator it2 = it;
                while(it2 != text.end() && (*it2) == ' ')
                    ++ it2;
                if(it2 != text.end()){
                    it = text.erase(it, it2);
                    while(it != text.end() && (*it) != ' ')
                        it = text.erase(it);
                }
            }else{
                for(unsigned i=8; i<ope.size()-1; ++i){
                    it = text.insert(it, ope[i]);
                    ++ it;
                }
            }
        }

        cout << string(text.begin(), it) << '^' << string(it, text.end()) << endl;
    }
    
    return 0;
}

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

int main() {
  int N,A,B,t,tt,An=-1,Bn;
  cin >>N>>A;
    while(t==0){
    t=A%2;
  A=A/2;
    An++;
  }
  for(int i=0;i<N-1;i++){
    cin >> B;
    Bn=-1;
      tt=0;
    while(tt==0){
    tt=B%2;
  B=B/2;
    Bn++;
  }
    if (An>Bn)
      An=Bn; 
}
  cout<< An<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 10000005
#define ll long long
using namespace std;
inline ll read(){
	ll x=0,c;while(!isdigit(c=getchar()));
	while(x=x*10+c-'0',isdigit(c=getchar()));
	return x;
}
int main(){
	int n=read(),a=read(),b=read();
	printf("%d %d\n",min(a,b),max(a+b-n,0));
	return 0;
}

Measured memory_bytes: 256
li = [int(input()) for _ in range(5)]
def fun(a):
    if a % 10 == 0:
        return a
    else:
        return a + 10 - a % 10
su = sum(list(map(fun, li)))
last = li[0]
for l in li:
    if l % 10 != 0 and last % 10 > l % 10:
        last = l
print(su - fun(last) + last)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,T;
int a[MAXN];
set<int> S;
void Solve() {
    read(N);read(T);
    for(int i = 1 ; i <= N ; ++i) read(a[i]);
    int D = 0;
    for(int i = N ; i >= 1 ; --i) {
	if(S.size()) {
	    auto t = *(--S.end());
	    D = max(t - a[i],D);
	}
	S.insert(a[i]);
    }
    S.clear();
    int ans = 0;
    for(int i = N ; i >= 1 ; --i) {
	if(S.size()) {
	    if(S.find(a[i] + D) != S.end()) ++ans;
	}
	S.insert(a[i]);
    }
    out(ans);enter;
}

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {
    
    int N;
    cin >> N;
    
    vector<int> a(N);
    REP(i, N) cin >> a[i];
    
    sort(ALL(a));

    cout << a[N-1] - a[0] << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int l,r;cin>>l>>r;

  if((int)l/2019 != (int)r/2019){
    cout<<0<<endl;
    return 0;
  }
  if(l%2019==0||r%2019==0){
    cout<<0<<endl;
    return 0;
  }

  l %=2019;
  r %= 2019;
  int ans = 2018;

  for(int i=l;i<r;i++){
    for(int j=i+1;j<=r;j++){
      ans = min(ans,i*j%2019);
    }
  }

  cout<<ans<<endl;

 

  return 0;
}

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

using namespace std;

using ll = long long;
using p  = pair<ll, ll>;

constexpr ll MAX_N = 100;
ll cost[MAX_N][MAX_N];
ll edge[MAX_N][MAX_N];
ll N, M;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N >> M;

    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < N; j++) {
            if (i == j) {
                cost[i][j] = 0;
            } else {
                cost[i][j] = cost[j][i] = 1e18;
            }
        }
    }
    
    vector<ll> A, B, C;
    for (ll i = 0; i < M; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        
        A.push_back(a);
        B.push_back(b);
        C.push_back(c);
        cost[a][b] = cost[b][a] = c;
    }
    
    for (ll k = 0; k < N; k++) {
        for (ll i = 0; i < N; i++) {
            for (ll j = 0; j < N; j++) {
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }
    
    ll ans = M;
    for (ll i = 0; i < M; i++) {
        bool shortest = false;
        for (ll j = 0; j < N; j++) {
            if (cost[j][A[i]] + C[i] == cost[j][B[i]]) {
                shortest = true;
            }
        }
        if (shortest) {
            ans--;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 384
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";
    private static final double eps = 0.0001;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long A = sc.nextLong();
        double B = sc.nextDouble();

        System.out.println(solve2(A, B));
    }

    private static String solve(long A, double B) {
        BigDecimal b = BigDecimal.valueOf(A);
        b = b.multiply(BigDecimal.valueOf(B));


        return b.setScale(0, RoundingMode.DOWN).toString();
    }

    private static long solve2(long A, double B) {
        int b100 = (int)(B*100 + eps);

        return A*b100/100;
    }
}

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


/*//______OPTIMISATION______//
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/

//________________MACROS_______________//
#define   fast 	 		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define   int   		long long int
#define   pb  			push_back
#define   f     		first
#define   s     		second
#define   deb(x) 		cerr << #x << " " << x << endl;
#define   debb(x, y) 		cerr << #x << " = " << x << "," << #y << " = " << y << endl <<endl;
#define   in            	insert
#define   lb            	lower_bound
#define   ub            	upper_bound
#define   all(x)        	x.begin(), x.end()
#define   endl              '\n'
bool isPrime(int n)
{
	for(int i = 2; i * i <= n; i++)
	{
		if(n % i == 0)
		{
			return false;
		}
	}
	return true;
}

bool isPowerOfTwo (int x)
{
    return (x && (!(x&(x-1))));
}

int countDigit(int num)
{
	return (floor(log10(num)) + 1);
}

int rightMostFirstSetBit (int n)
{
    return log2(n & -n)+1;
}

int noOfBitInBinaryRepresntation(int n)
{
    return log2(n)+1;
}
signed main()
{
    fast ;

    int test_case;
    cin >> test_case;

    int ac = 0 , re = 0 , tle = 0 , wa = 0 ;
    while (test_case--)
    {
        string str ;
        cin >> str ;

        if (str == "AC")
        {
            ac++;
        }
        else if (str == "WA")
        {
            wa ++;
        }
        else if (str == "TLE")
        {
            tle ++;
        }
        else
        {
            re++;
        }
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle <<endl;
    cout << "RE x " << re << endl;
    return 0;
}



Measured memory_bytes: 3712
N=int(input())
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)
if N%digitSum(N)==0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9100
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cassert>
#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define FILLA(a, x) memset((a), (x), sizeof (a))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
#define COPYA(a, b) memcpy((b), (a), sizeof (a))
using namespace std;

typedef pair<int, int> pii;
typedef long long li;
typedef unsigned long long lu;
const int inf = ~0U >> 2;
const li infl = ~0LLU >> 2;

template <class T> inline void Min(T &x, T y) { if (y < x) x = y; }
template <class T> inline void Max(T &x, T y) { if (y > x) x = y; }

// ----------------------------------------

const int maxn = 1e5;

int n;

struct Perm {
  int p[maxn];

  int & operator [] (int i) {
    return p[i];
  }

  int operator [] (int i) const {
    return p[i];
  }

  Perm operator * (const Perm &q) const {
    static Perm z;
    for (int i = 0; i < n; ++i) {
      z[i] = p[q[i]];
    }
    return z;
  }

  Perm Inv(void) const {
    static Perm z;
    for (int i = 0; i < n; ++i) {
      z[p[i]] = i;
    }
    return z;
  }

  void Read(void) {
    for (int i = 0; i < n; ++i) {
      scanf("%d", p + i);
      --p[i];
    }
  }

  void Print(void) {
    for (int i = 0; i < n; ++i) {
      printf("%d%c", p[i] + 1, " \n"[i == n - 1]);
    }
  }
} p, q, inv_p, inv_q, A, inv_A;

Perm Iden(void) {
  static Perm p;
  for (int i = 0; i < n; ++i) {
    p[i] = i;
  }
  return p;
}

Perm Pow(const Perm &p0, int x) {
  static Perm p;
  static Perm q;
  p = p0;
  q = Iden();
  for (; x; x >>= 1) {
    if (x & 1) q = q * p;
    p = p * p;
  }
  return q;
}

int main(void) {
  int k;
  scanf("%d%d", &n, &k);
  p.Read();
  q.Read();
  inv_p = p.Inv();
  inv_q = q.Inv();
  A = q * inv_p * inv_q * p;
  int rep = (k - 1) / 6;
  int now = 1;

  A = Pow(A, rep);
  inv_A = A.Inv();
  p = A * p * inv_A;
  q = A * q * inv_A;
  now += rep * 6;

  while (now < k) {
    A = q * p.Inv();
    p = q;
    q = A;
    ++now;
  }
  p.Print();
  return 0;
}


Measured memory_bytes: 9728