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

#define rep_(v, f, l) for (int v = (f); v < (l); ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)

using namespace std;

typedef long long int lint;
typedef pair<double, int> pdi;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int main()
{
    vector<pdi> a, b, c, total;
    rep(i, 24){
        double record;
        int id;
        scanf("%d %lf", &id, &record);
        if (i < 8){
            a.push_back(make_pair(record, id));
        }
        else if (i < 16){
            b.push_back(make_pair(record, id));
        }
        else {
            c.push_back(make_pair(record, id));
        }
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    rep(j, 3){
        rep(i, 2){
            if (j == 0){
                printf("%d %.2f\n", a[i].second, a[i].first);
            }
            if (j == 1){
                printf("%d %.2f\n", b[i].second, b[i].first);
            }
            if (j == 2){
                printf("%d %.2f\n", c[i].second, c[i].first);
            }
        }
    }
    rep(i, 6){
        total.push_back(a[i + 2]);
        total.push_back(b[i + 2]);
        total.push_back(c[i + 2]);
    }
    sort(total.begin(), total.end());
    rep(i, 2){
        printf("%d %.2f\n", total[i].second, total[i].first);
    }

    return (0);
}

Measured memory_bytes: 1240
#include<stdio.h>

int main(){
  int c[3][3];
  for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) scanf("%d", &c[i][j]);
  
  int a[3];
  int b[3];
  
  a[0] = 0;
  for(int j = 0; j < 3; j++) b[j] = c[0][j];
  for(int i = 1; i < 3; i++) a[i] = c[i][0] - b[0];
  
  int result = 1;
  for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) if(a[i] + b[j] != c[i][j]) result = 0;
  
  if(result) puts("Yes");
  else puts("No");
  
  return 0;
}


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

int n, a[100], ta = 0, mu = 0, rin = 0;

int main(){
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ta += a[i];
	}
	mu = ta / n;
	rin = ta - mu * n;
	if (rin * 2 >= n) {
		mu++;
	}
	ta = 0;
	for (int i = 0; i < n; i++) {
		ta += (max(mu, a[i]) - min(mu, a[i]))*(max(mu, a[i]) - min(mu, a[i]));
	}
	cout << ta << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  ll N;
  cin >> N;
  vector<Pl> Tasks(N);
  REP(i, N) cin >> Tasks.at(i).second >> Tasks.at(i).first;
  sort(Tasks.begin(), Tasks.end());
  ll Time = 0;
  for (auto a : Tasks) {
    Time += a.second;
    if (Time > a.first) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3456
#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;
  cin >> n;

  if (n % 2 == 0) {
    ll cnt = 0;
    ll b = 10;
    while (b <= n) {
      cnt += n / b;
      b *= 5;
    }
    cout << cnt << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
//using System.Linq;
//using System.Numerics;

class Program {
    static void Main (string[] args) {
        var input = INP();
        char ch = input[0][0];
        if(Char.IsUpper(ch)) {
            CWL("A");
        } else {
            CWL("a");
        }
    }

    public static List<int> PrimeFactors (int n) {
        var tmpList = new List<int>();
        int i = 2;
        int tmp = n;

        while(i * i <= n) {
            if(tmp % i == 0) {
                tmp /= i;
                tmpList.Add(i);
            } else {
                i++;
            }
        }

        if(tmp != 1) tmpList.Add(tmp);

        return tmpList;
    }

    static string[] INP () {
        return Console.ReadLine().Split(' ');
    }

    static void CWL (string value) {
        Console.WriteLine(value);
    }

    static void CWL (int value) {
        Console.WriteLine(value);
    }

    static void CWL (long value) {
        Console.WriteLine(value);
    }

    static void CWL (float value) {
        Console.WriteLine(value);
    }

    static void CWL (double value) {
        Console.WriteLine(value);
    }

    static int TOI (string str) {
        return int.Parse(str);
    }

    static long TOL (string str) {
        return long.Parse(str);
    }

    static float TOF (string str) {
        return float.Parse(str);
    }

    static double TOD (string str) {
        return double.Parse(str);
    }

    /*static void Main (string[] args) {
        var input = INP();
        var input2 = INP();
        var input3 = INP();

        CWL("dummy");
    }*/
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXV 100000
vector<pll> g[MAXV];
ll d[MAXV];

int main(){
  int v,e,r;cin>>v>>e>>r;
  rep(i, e){
    ll s,t,d;cin>>s>>t>>d;

    g[s].push_back({d, t});
  }

  rep(i, MAXV)d[i]=INF;

  priority_queue< pll, vector<pll>, greater<pll> > q;
  q.push({0, r});
  while(!q.empty()){
    ll dist = q.top().first;
    ll node = q.top().second;
    q.pop();
    if(d[node]<dist)continue;
    d[node]=dist;
    for(auto dist_to: g[node]){
      ll to_dist = d[node]+dist_to.first;
      ll to_node = dist_to.second;
      if(to_dist<d[to_node])q.push({to_dist, to_node});
    }
  }

  rep(i, v){
    if(d[i]==INF)cout<<"INF"<<endl;
    else cout<<d[i]<<endl;
  }

  return 0;
}



Measured memory_bytes: 21616
// #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>	// istringstream
using namespace std;

int solve(int n){
	int count = 0;
	while (n != 1){
		if (n % 2 == 0)
			n /= 2;
		else
			n = n * 3 + 1;
		count++;
	}
	return count;
}

int main(){
	int n;
	while (cin >> n, n){
		cout << solve(n) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import std.stdio,
       std.string,
       std.conv,
       std.algorithm;

void main() {
  int[] buf = readln.chomp.split.to!(int[]);
  int a = buf[0], b = buf[1], x = buf[2];

  if (a == x || a < x && a + b >= x) {
    writeln("YES");
  }
  else {
    writeln("NO");
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double tm = (m / 60) * (2 * PI);
	double th = (h / 12) * (2 * PI) + (2 * PI) / 12 * tm / (2 * PI);
	double xh = a * cos(th), yh = a * sin(th);
	double xm = b * cos(tm), ym = b * sin(tm);
	double dx = xh - xm, dy = yh - ym;
	cout << fixed << setprecision(12) << sqrt(dx * dx + dy * dy) << endl;
}

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

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<int> L;
    vector<int> rui(10003,0); //これ以下の長さ
    rep(i,0,n){
        int tmp;
        cin >> tmp;
        L.push_back(tmp);
        rui[tmp]++;
    }

    L.push_back(0);
    rel(i,1001,1) rui[i] += rui[i+1];
    ll ans = n*(n-1)*(n-2)/(ll)(2*3); //全部正解とする
    sort(all(L));
    rep(i,1,n-1){
        rep(j,i+1,n){
            ans -= rui[L[i]+L[j]];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
import math
def Koch(initialx,endx,initialy,endy,repeat):
    if repeat > num:
        return 0
    else:
        if initialx >= endx:
            onex,secondx = abs(endx-initialx) * 2 / 3 + endx,abs(endx-initialx) / 3 + endx
        else:
            onex,secondx = abs(endx-initialx) / 3 + initialx,abs(endx-initialx) * 2 / 3 + initialx
        if initialy <= endy:
            oney,secondy = abs(endy-initialy) / 3 +initialy,abs(endy-initialy) * 2 / 3 + initialy
        else:
            oney,secondy = initialy - abs(endy-initialy) / 3 ,initialy - abs(endy-initialy) * 2 / 3

        if initialy == endy:
            thirdy = math.sqrt(3) / 2 * (secondx-onex) + oney
            thirdx = (onex + secondx) / 2
        else:
            if initialy > endy:
                if initialx > endx:
                    thirdx = initialx
                    thirdy = secondy
                else:
                    thirdx = endx
                    thirdy = oney
            else:
                if initialx > endx:
                    thirdx = endx
                    thirdy = oney
                else:
                    thirdx = initialx
                    thirdy = secondy
        if [round(initialx,8),round(initialy,8)] not in ans:
            ans.append([round(initialx,8),round(initialy,8)])
        #print(initialx,endx,onex,oney,secondx,secondy,thirdx,thirdy)
        Koch(initialx,onex,initialy,oney,repeat+1)
        Koch(onex,thirdx,oney,thirdy,repeat+1)
        Koch(thirdx,secondx,thirdy,secondy,repeat+1)
        Koch(secondx,endx,secondy,endy,repeat+1)
global num
num = int(input())
ans = []
Koch(0,100,0,0,0)
for n in range(len(ans)):
    print("%.8f %.8f" % (ans[n][0],ans[n][1]))
print("100.00000000 0.00000000")

Measured memory_bytes: 8392
//  Copyright © 2017 Adán López Alatorre. All rights reserved.
//

#include <iostream>
#include <vector>
#include <string.h>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <sstream>
#include <stack>
#include <iomanip>
#include <climits>
#include <cmath>
#define fi first
#define se second
#define th second

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, int> di;
typedef vector<int> vi;
typedef multiset<ll, greater<ll>>::iterator iit;
typedef pair<iit, iit> pvi;

const int maxN = 5e5 + 3, maxV = 1e5 + 5, LIM = 2e4;

int n, res[maxN];
ii arr[maxN];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    
    cin >> n;
    
    for(int i = 0; i < n; i++) cin >> arr[i].fi, arr[i].se = i;
    
    sort(arr, arr + n);
    
    for(int i = 0; i < (n >> 1); i++){
        res[arr[i].se] = arr[n >> 1].fi;
    }
    for(int i = (n >> 1); i < n; i++){
        res[arr[i].se] = arr[(n >> 1) - 1].fi;
    }
    for(int i = 0; i < n; i++) cout << res[i] << '\n';
    
}


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

template <typename S>
struct LazySegmentTree {
    using V = typename S::V;
    using T = typename V::T;
    using O = typename S::O;
    using E = typename O::E;

    LazySegmentTree(int n) : LazySegmentTree(vector<T>(n, V::id)) {}
    LazySegmentTree(const vector<T>& v) {
        size = 1;
        height = 0;
        while (size < v.size()) size <<= 1, height++;
        node.resize(2 * size, V::id);
        lazy.resize(2 * size, O::id);
        copy(v.begin(), v.end(), node.begin() + size);
        for (int i = size - 1; i > 0; i--) node[i] = V::op(node[2 * i], node[2 * i + 1]);
    }

    T operator[](int k) {
        return query(k, k + 1);
    }

    void update(int a, int b, const E& x, int k = 1, int l = 0, int r = -1) {
        if (r == -1) r = size;

        push(k, r - l);
        if (r <= a || b <= l) return;
        if (a <= l && r <= b) {
            lazy[k] = O::op(lazy[k], x);
            push(k, r - l);
            return;
        }
        int m = (l + r) / 2;
        update(a, b, x, 2 * k, l, m);
        update(a, b, x, 2 * k + 1, m, r);
        node[k] = V::op(node[2 * k], node[2 * k + 1]);
    }

    T query(int a, int b, int k = 1, int l = 0, int r = -1) {
        if (r == -1) r = size;

        push(k, r - l);
        if (r <= a || b <= l) return V::id;
        if (a <= l && r <= b) return node[k];
        int m = (l + r) / 2;
        return V::op(query(a, b, 2 * k, l, m),
                     query(a, b, 2 * k + 1, m, r));
    }

private:
    int size, height;
    vector<T> node;
    vector<E> lazy;

    void push(int k, int len) {
        if (lazy[k] == O::id) return;
        if (k < size) {
            lazy[2 * k] = O::op(lazy[2 * k], lazy[k]);
            lazy[2 * k + 1] = O::op(lazy[2 * k + 1], lazy[k]);
        }
        node[k] = S::op(node[k], S::mul(lazy[k], len));
        lazy[k] = O::id;
    }
};

const ll mod = 998244353;

struct S {
    struct V {
        using T = ll;
        inline static const T id = 0;
        static T op(T a, T b) {
            return (a + b) % mod;
        }
    };

    struct O {
        using E = pair<ll, ll>;
        inline static const E id = {1, 0};
        static E op(E a, E b) {
            return {a.first * b.first % mod, (a.second * b.first + b.second) % mod};
        }
    };

    static V::T op(V::T a, O::E b) {
        return (a * b.first + b.second) % mod;
    }

    static O::E mul(O::E a, int b) {
        return {a.first, a.second * b % mod};
    }
};

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

    int N, Q;
    cin >> N >> Q;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    LazySegmentTree<S> st(a);
    for (int i = 0; i < Q; i++) {
        int t, l, r;
        cin >> t >> l >> r;
        if (t == 0) {
            int b, c;
            cin >> b >> c;
            st.update(l, r, {b, c});
        } else {
            cout << st.query(l, r) << "\n";
        }
    }
}

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

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

int main() {

	int n; cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	int ans = 0;
	for (int i = 1; i < n - 1; i++) {
		if (p[i - 1] < p[i] && p[i] < p[i + 1]) ans++;
		if (p[i + 1] < p[i] && p[i] < p[i - 1]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3576
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   : combinatorics NCR
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define rw freopen("graphs_as_a_service.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define rep(i,a) lp(i,0,a-1)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 2e3 + 3, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
int dp[N][N] = { };
inline int solve(int num, int g) {
	if (!g || !num)
		return !(g | num);
	int &ret = dp[num][g];
	if (ret != -1)
		return (ret % mod);
	ret = 0;
	ret += solve(num - 1, g);
	if (ret >= mod)
		ret %= mod;
	ret += solve(num - 1, g - 1);
	if (ret >= mod)
		ret %= mod;
	return ret;
}
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	int n, k;
	cin >> n >> k;
	clr(dp, -1);
	lp(i,1,k)
	{
		int b = solve(k, i);
		int sum = solve(n - k, i);
		sum <<= 1;
		if (sum >= mod)
			sum %= mod;
		sum += solve(n - k, i + 1);
		if (sum >= mod)
			sum %= mod;
		sum += solve(n - k, i - 1);
		if (sum >= mod)
			sum %= mod;
		cout << (sum * 1LL * b) % mod << "\n";
	}
	return 0;
}

Measured memory_bytes: 16000
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 10000;
		for(int i = 1; i < n; i++) {
			int a = i, sumA = 0, b = n - i, sumB = 0;
			while(a > 0) {
				sumA += a % 10;
				a /= 10;
			}
			while(b > 0) {
				sumB += b % 10;
				b /= 10;
			}
			ans = Math.min(ans, sumA + sumB);
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
from math import gcd
n, m, S, T = open(0).read().split()
n, m = int(n), int(m)
l = n*m // gcd(n, m)

d = {}
t = l//n
for i in range(n):
    d[i*t] = S[i]
t = l//m
for i in range(m):
    if i*t not in d or d[i*t] == T[i]:
        d[i*t] = T[i]
    else:
        print(-1)
        break
else:
    print(l)

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

using namespace std;

long long gcd(long long x, long long y){
  if (y==0) {
    return(x);
  }
  long long tmp = x % y;
  return(gcd(y, tmp));
}


int main(){
  long long N, M, L, W, V, n, m;
  string S, T;
  cin >> N >> M;
  cin >> S >> T;
  W = gcd(N, M);
  if (S[0] != T[0]) {
    cout << -1 << endl;
    return(0);
  }
  n = N/W;
  m = M/W;
  V = n * m * W;
  if (W==1) {
    cout << V << endl;
    return(0);
  }

  for (long long p = n;p<N;p+=n) {
    long long q = m * p/n;
    if (S[p] != T[q]) {
      cout << -1 << endl;
      return(0);
    }
  }
  cout << V << endl;
  return(0);
}


Measured memory_bytes: 888
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int[] nums = new int[n];
		long[] prefix = new long[n];
		long[] postfix = new long[n];
		/*
		1  2  3  4  5  6
		1  3  6 10 15 21
		20 18 15 11 6 0

		10 0
		-10*/
		for (int i = 0; i < n; i++) {
			nums[i] = sc.nextInt();
		}
		prefix[0] = nums[0];
		for (int i = 1; i < n; i++) {
			prefix[i] = nums[i] + prefix[i - 1];
		}
		
		for (int i = n - 2; i >=0; i--) {
			postfix[i] = nums[i + 1] + postfix[i + 1];
		}
		long res = Integer.MAX_VALUE;
		for (int i = 0; i < n - 1; i++) {
			res = Math.min(res, Math.abs(prefix[i] - postfix[i]));
		}
		System.out.println(res);
	}
	
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


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

int main(){
  
  char a;
  cin>>a;
  if(a<='z'&&'a'<=a) cout << 'a' << endl;
  else cout << 'A' << endl;
  
  
  
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define SZ(a) (LL)((a).size())
const int INF = 1000 * 1000 * 1000 + 47;
const int mod = 1000 * 1000 * 1000 + 7;

vector<vector<pair<int , int> > > g(1005);
int p[1005];
int n , m;
LL x;
int add(int a , int b)
{
	return a + b >= mod ? a + b - mod : a + b;
}
int sub(int a , int b)
{
	return a - b < 0 ? a - b + mod : a - b;
}
int mult(int a , int b)
{
	return a * (LL)b % mod;
}
int step2(int x)
{
	int ans = 1;
	while(x--)
		ans = add(ans , ans);
	return ans;
}


int find(int u)
{
	return u == p[u] ? u : find(p[u]);
}
bool unite(int u , int v , int w)
{
	u = find(u);
	v = find(v);
	if(u == v)
		return false;
	p[v] = u;
	g[u].PB({v , w});
	g[v].PB({u , w});
	return true;
}
int maxPath(int u , int dest , int p = -1, int cur = 0)
{
	if(u == dest)
		return cur;
	int ans = -INF;
	for(auto v : g[u])
	{
		if(v.X == p)
			continue;
		ans = max(ans , maxPath(v.X , dest , u , max(cur , v.Y)));
	}
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> n >> m >> x;
	for(int i = 0; i < n; i++)
		p[i] = i;
	vector<pair<int , pair<int , int> > > edges , edgesOut;
	for(int i = 0; i < m; i++)
	{
		int u , v , w;
		cin >> u >> v >> w;
		u--;v--;
		edges.PB({w , {u , v}});
	}
	sort(edges.begin() , edges.end());
	LL s = 0;
	for(auto e : edges)
		if(!unite(e.Y.X , e.Y.Y , e.X))
			edgesOut.PB(e);
		else
			s += e.X;
	LL d = x - s;
	int lower = 0 , equal = 0 , upper = 0;
	for(auto e : edgesOut)
	{
		lower += (e.X - maxPath(e.Y.X , e.Y.Y)) < d;
		equal += (e.X - maxPath(e.Y.X , e.Y.Y)) == d;
		upper += (e.X - maxPath(e.Y.X , e.Y.Y)) > d;
	}
	//cout << lower << " " << equal << " " << upper << endl;
	
	if(d < 0)
	{
		cout << 0;
		return 0;
	}
	if(d == 0)
	{
		cout << mult(step2(upper) , sub(step2(n - 1 + equal) , 2));
		return 0;
	}
	
	cout << mult(2 , mult(sub(step2(equal) , 1) , step2(upper)));
		
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

void print(bool ok) {
  if (ok) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  exit(0);
}

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

  string s;
  cin >> s;
  int n = (int) s.size();
  if (n % 2 == 1) {
    print(0);
  }
  for (int i = 0; i < n; i += 2) {
    if (s[i] != 'h') {
      print(0);
    }
  }
  for (int i = 1; i < n; i += 2) {
    if (s[i] != 'i') {
      print(0);
    }
  }
  print(1);

}


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


int main(){
  
  string S;
  cin >> S;
  int c;
  c = 0;
  
  for(int i=0; i < 3; i++){
    if(S.at(i) == 'o'){
      c++;
    }
  }
  
  cout << c*100 + 700 << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> a[1010];

int main(){
    scanf("%d",&n);
    int t = sqrt(2*n+0.5);
    if(t*(t+1)==2*n){
        printf("Yes\n%d\n",t+1);
        int cnt = 1;
        for(int i=1;i<=t;i++){
            for(int j=1;j<=i;j++){
                a[i].push_back(cnt);
                if(j==i)a[t+1].push_back(cnt);
                else
                a[j].push_back(cnt);
                cnt++;
            }
        }
        for(int i=1;i<=t+1;i++){
            printf("%d",t);
            for(int j=0;j<a[i].size();j++){
                printf(" %d",a[i][j]);
            }
            printf("\n");
        }
    }
    else printf("No\n");
}

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

int main() {
  int N;
  cin >> N;
  vector<int>data(N);
  int a=0;
  for(int i=0;i<N;i++){
    char s;
    cin >> s;
    if(s=='W') data.at(i)=0;
    else{
      data.at(i)=1;
      a++;
    }
  }
  int ans=0;
  for(int i=0;i<a;i++){
    if(data.at(i)==0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
vector<vi> res;int n,m,q;
int cnt  =0;

int main(){
    string a,b;
    cin>>a;
    if(a=="ABC"){
    cout<<"ARC"<<endl;}
    else {
        cout<<"ABC"<<endl;
    }
}

Measured memory_bytes: 3572
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int D;
vector<int> c(26);
vector<vector<int>> s;

int scoring(const vector<int>& t) {
    int v = 0;
    vector<int> last(26, -1);
    rep(i, D) {
        v += s[i][t[i]];
        last[t[i]] = i;
        rep(j, 26) {
            v -= c[j] * (i - last[j]);
        }
    }
    return v;
}

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

    auto start = chrono::system_clock::now();
    
    cin >> D;
    rep(i, 26) cin >> c[i];
    s.resize(D, vector<int>(26));
    rep(i, D) rep(j, 26) cin >> s[i][j];

    vector<int> t(D);

    rep(i, D) t[i] = max_element(s[i].begin(), s[i].end()) - s[i].begin();
    
    random_device rnd;
    mt19937 mt(rnd());
    uniform_int_distribution<> rand_d(0, D-1);
    uniform_int_distribution<> rand_t(0, 25);
    
    int v = scoring(t);
    int x = 0;
    while (true) {
        int to_d = rand_d(mt);
        int to_t = rand_t(mt);
        if (t[to_d] == to_t) continue;
        int old = t[to_d];
        t[to_d] = to_t;
        int nv = scoring(t);
        if (nv < v) t[to_d] = old;
        if (x % 1000 == 0) {
            auto end = chrono::system_clock::now();
            auto dur = end - start;
            auto msec = chrono::duration_cast<chrono::milliseconds>(dur).count();
            if (msec >= 1970) break;
        }
        x++;
    }
    rep(i, D) cout << t[i] + 1 << '\n';
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double PI = 3.14159265358979323846;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0; i < (n); ++i)

int main() {
  ll n, a[16] = {0}, x[16][16] = {0}, y[16][16] = {0};
  cin >> n;
  REP(i, n) {
    cin >> a[i];
    REP(j, a[i]) cin >> x[i][j] >> y[i][j];
  }
  ll maxCount = 0;
  for (ll bit = 0; bit < (1 << n); ++bit) {
    ll count = 0;
    bool honest = true;
    REP(i, n) {
      REP(j, a[i]) {
        if (bit & (1 << i)) {
          if (y[i][j] == 1) {
            if (!(bit & (1 << (x[i][j] - 1)))) {
              honest = false;
            }
          } else if (y[i][j] == 0) {
            if (bit & (1 << (x[i][j] - 1))) {
              honest = false;
            }
          }
        }
      }
      if (!honest) break;
    }
    if (honest) {
      REP(i, n) {
        if (bit & (1 << i)) ++count;
      }
    }
    maxCount = max(maxCount, count);
  }
  cout << maxCount << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
# define pll pair<ll,ll>
	
int main()
{
	int h,w,k;
	cin>>h>>w>>k;
	int b[h][w],f[h][w];
	char c;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cin>>c;
			if(c=='.')
			b[i][j]=0;
			else
			b[i][j]=1;
	//		cout<<b[i][j]<<" ";
		}
	//	cout<<"\n";
	}
	int ans=0;
	for(int i=0;i<1<<h;i++)
	{
		for(int j=0;j<1<<w;j++)
		{
		for(int y=0;y<h;y++)
	    {
		for(int x=0;x<w;x++)
		{
			f[y][x]=b[y][x];
		}
	    }
	    for(int x=0;x<h;x++)
	    {
	    	if((1<<x)&i)
	    	{
	    		for(int y=0;y<w;y++)
	    		f[x][y]=0;
			}
		}
	    for(int x=0;x<w;x++)
	    {
	    	if(1<<x&j)
	    	{
	    	for(int y=0;y<h;y++)
	    		f[y][x]=0;
			}
		}
		int cnt=0;
		for(int y=0;y<h;y++)
	    {
		for(int x=0;x<w;x++)
		{
			if(f[y][x]==1)++cnt;
		}
	    }
	     if(cnt==k){++ans;}
	   }	
	}	
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s1,s2,s3,a,b,c;
	cin>>s1>>s2>>s3;
	a=s1[0];
	b=s2[0];
	c=s3[0];
	cout<<a<<b<<c;
	return 0;
}

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

struct Task {
    int time;
    int deadline;
    Task(int t, int d) {
        time = t;
        deadline = d;
    }
};

bool cmp(const Task& a, const Task& b)
{
    if (a.deadline == b.deadline) {
        return a.time < b.time;
    } else {
        return a.deadline < b.deadline;
    }
}
int main()
{
    int N; cin >> N;
    vector<Task> arr;
    for (int i = 0; i < N; i++) {
        int A, B;
        cin >> A >> B;
        Task t(A, B);
        arr.push_back(t);
    }
    std::sort(arr.begin(), arr.end(),cmp);
    int acc_time = 0;
    for (int i = 0; i < N; i++) {
        // cout << arr[i].time << " " <<  arr[i].deadline << endl;
        acc_time += arr[i].time;
        if (acc_time > arr[i].deadline) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;

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

int dig2(int n) {
  int ans = 0;
  while(n > 0) {
    n /= 2;
    ans++;
  }
  return ans;
}


signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int x, y; cin >> x >> y;
  int z = y / x;
  cout << dig2(z) << endl;
}


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

int main( ) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n,i,k,a;
    t = 1;
    while(t--) {
     a = 0;
     cin >> n >> k;
     int arr[n];
     for(i = 0; i <n; i++)
      cin >> arr[i];
     for(i = 0; i <n; i++) {
      if(arr[i] >= k)
       a++;
	 }
	 cout << a;
    }
    return 0;
}



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

using namespace std;
#define int long long
typedef pair<int, int> P;

int extgcd(int a, int b, int& x, int& y) {
  int d = a;
  if (b != 0) {
	d = extgcd(b, a % b, y, x);
	y -= (a / b) * x;
  } else {
	x = 1; y = 0;
  }
  return d;
}

int mod_inverse(int a, int m) {
  int x, y;
  extgcd(a, m, x, y);
  return (m + x % m) % m;
}

bool allminus(vector<int> B) {
  for (int i = 0; i < (int)B.size(); i++) {
	if (B[i] >= 0)
	  return false;
  }
  return true;
}

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

P linear_congruence(const vector<int>& B, const vector<int>& M) {
  int x = 0, m = 1;
  int n = B.size();
  if (allminus(B)) return P(-1, -1);
  for (int i = 0; i < n; i++) {
	if (B[i] < 0) continue;
	int a = m, b = B[i] - x, d = gcd(M[i], a);
	if (b % d != 0) return P(0, -1);
	int t = b / d * mod_inverse(a / d, M[i] / d) % (M[i] / d);
	x = x + m * t;
	m *= M[i] / d;
  }
  return P(x % m , m);
}

signed main() {
  int n, m, d;
  cin >> n >> m >> d;
  vector<int> M(m);
  for (int i = 0; i < m; i++)
	cin >> M[i];

  vector<int> B[d];
  for (int i = 0; i < d; i++) {
	for (int j = 0; j < m; j++) {
	  int r;
	  cin >> r;
	  B[i].push_back(r);
	}
  }

  for (int i = 0; i < d; i++) {
	P p = linear_congruence(B[i], M);
	if (p.first == -1 && p.second == -1) continue;
	if (p.first == 0 && p.second == -1) {
	  cout << -1 << endl;
	  return 0;
	}
	if (n >= p.first) {
	  int t = (n - p.first) / p.second;
	  n = p.first + p.second * t;
	} else {
	  cout << -1 << endl;
	  return 0;
	}
  }
  cout << n << endl;
}

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

#define int long long

using namespace std;

signed main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    int dp[n][3];
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(int i = 1; i < n; i++){
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }
    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
    return 0;
}

Measured memory_bytes: 7952
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    map<int, int> m;
    rep(i, N) {
        int a;
        cin >> a;
        m[a] = (i+1);
    }

    for (auto it: m) {
        cout << it.second << ' ';
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
 
int main(){
   string s;
   cin>>s ;
int k=s.size() ;
   rep(i,k){
     if(i==k-1){
     if(s[i]=='P') cout<<'P'<<endl;
     if(s[i]=='D') cout<<'D' <<endl;
     if(s[i]=='?') cout<<'D' <<endl;
   }
   else{
     if(s[i]=='P') cout<<'P';
     if(s[i]=='D') cout<<'D' ;
     if(s[i]=='?') cout<<'D' ;
   }
   }
    return 0;
  }

Measured memory_bytes: 3760
"世界の天秤"
pattern = ('()', '[]')

while True:
    S = input()
    if S == '.':
        break
    sentence_list = list(S)
    target = ('(', ')', '[', ']')
    for i in range(len(sentence_list)):
        if sentence_list[i] not in target:
            sentence_list[i] = ''

    sentence = ''.join(sentence_list).strip()

    while True:
        sentence_len = len(sentence)
        sentence = sentence.replace('[]', '')
        sentence = sentence.replace('()', '')
        if sentence_len == len(sentence):
            break

    if len(sentence) == 0:
        print('yes')
    else:
        print('no')



Measured memory_bytes: 5584
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin >> s;
  int counter=0;
  if (s[0]=='1') counter++;
  if (s[1]=='1') counter++;
  if (s[2]=='1') counter++;
  cout << counter << endl;
  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

typedef ll ll;
#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    stack<int> S;
    char s[100];
    while (scanf("%s", s) != -1) {
        if (s[0] == '+')
        {
            int a = S.top(); S.pop();
            int b = S.top(); S.pop();
            S.push(a + b);
        }
        else if (s[0] == '-')
        {
            int a = S.top(); S.pop();
            int b = S.top(); S.pop();
            S.push(b - a);
        }
        else if (s[0] == '*')
        {
            int a = S.top(); S.pop();
            int b = S.top(); S.pop();
            S.push(a * b);
        }
        else
        {
            int x = atoi(s);
            S.push(x);
        }
    }

    cout << S.top() << endl;
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++)
    cin >> a.at(i);
  sort(a.begin(), a.end(), greater<ll>());
  
  ll max1=0, max2=0;
  for(int i=0;i<n-1;i++){
    if(a.at(i) == a.at(i+1)){
      if(max1 == 0)
        max1 = a.at(i);
      else if(max2 == 0){
        max2 = a.at(i);
        break;
      }
      i++;
    }
  }
  cout << (ll)max1*max2 << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,P,W,G,Y;
  P=0;
  W=0;
  G=0;
  Y=0;
  string A;

  cin >> N;
 
  for(int i = 0; i < N; i++) {
    cin >> A;
    
    if(A=="P"){
      P++;
    }
    else if (A=="W"){
      W++;
    }
    else if (A=="G"){
      G++;
    }
    else if (A=="Y"){
      Y++;
    }
    
    if(P!=0 && W!=0 && G!=0 && Y!=0){
      cout << "Four" << endl;
      break;
    }
  }
  if(P!=0 && W!=0 && G!=0 && Y==0){
      cout << "Three" << endl;
  }
  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Read();
            var v = ab.Replace(" ", "");
            var n = int.Parse(v);

            for (int i = 1; i <= 316; i++)
            {
                var a = i * i;
                if (a == n)
                {
                    WriteLine("Yes");
                    return;
                }
                if (a > n)
                {
                    WriteLine("No");
                    return;
                }
            }
            WriteLine("No");

        }
        

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (int i = int(x); i < (int)(n); i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9 + 7
using ll = long long;

int main() {
    int a[3][3];
    int ans[3][3];

    rep(i, 3) {
        rep(j, 3) {
            cin >> a[i][j];
            ans[i][j] = false;
        }
    }

    int N;
    cin >> N;
    rep(i, N) {
        int rel;
        cin >> rel;

        rep(j, 3) {
            rep(k, 3) {
                if (a[j][k] == rel) {
                    ans[j][k] = true;
                }
            }
        }
    }

    bool isBingo = false;

    rep(i, 3) {
        if(isBingo == true) break; 

        if(ans[i][0] == true && ans[i][1] == true && ans[i][2] == true){
            isBingo = true;
        }
    }

    rep(i, 3){
        if(isBingo == true) break;

        if(ans[0][i] == true && ans[1][i] == true && ans[2][i] == true){
            isBingo = true;
        }
    }

    if(ans[0][0] == true && ans[1][1] == true && ans[2][2] == true ){
        isBingo = true;
    }

    if(ans[0][2] == true && ans[1][1] == true && ans[2][0] == true ){
        isBingo = true;
    }

    if(isBingo){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3592
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	for (int j = 0; j < 50; j++)
	{
		int n = 0;
		float a = 0,b = 0;
		char v,vv;

		cin >> n >> v >> a >> vv >> b;
		

		if (a / (b * b) >= 25)
		{
			cout << n << endl;
		}
	}

}


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

int main()
{
	int n, m;
	int l[100000], r[100000];
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		cin >> l[i] >> r[i];
	}

	int lmax = *std::max_element(l, l + m);
	int rmin = *std::min_element(r, r + m);
	if (lmax <= rmin) {
		cout << rmin - lmax + 1 << endl;
	}
	else {
		cout << 0 << endl;
	}

}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;
const ll MOD = 1e9 + 7;
bool cmp(pair<int,int> l,pair<int,int> r){
	return l.first < r.first;
}

int main()
{
	int n,m; cin>>n>>m;
	int ans = 1;
	vector<pair<int,int> > v;

	v.resize(m);

	for(int i=0;i<m;i++)
	{
		cin>>v[i].first>>v[i].second;
	}

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

	int a=v[0].first,b=v[0].second;
	for(int i=1;i<m;i++){
		int x = v[i].first , y = v[i].second;

		if(x >= a and y <= b){
			a = x; b = y;
		}
		else if(x < b and y >= b){
			a = x;
		}
		else if(x >= b){
			ans++;
			a = x;
			b = y;
		}
	}

	cout<<ans;
}

Measured memory_bytes: 1024
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

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

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    rep(i,N){
        ll a;
        cin >> a;
        ans += a-1;
    }


    cout << ans << endl;

}


Measured memory_bytes: 3604
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<int,int> P;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int main (){
      int N,C;
      cin>>N>>C;
      int s[N],t[N],c[N];
      int maxt=0;
      rep0(i,N){
            cin>>s[i]>>t[i]>>c[i];
            maxt=max(maxt,t[i]);
            --c[i];
      }
      int huu=((maxt+1))*C;
      int hoge[huu];
      int used[huu];
      int anss[maxt+1];
      fill(hoge,hoge+huu,0);
      fill(used,used+huu,0);
      fill(anss,anss+maxt+1,0);

      rep0(ch,C){
            rep0(i,N){
                  if(c[i]==ch){
                        hoge[ch*(maxt+1)+(s[i]-1)]++;
                        hoge[ch*(maxt+1)+(t[i])]--;
                  }
            }
      }
      rep0(ch,C){
            rep0(t,maxt+1){
                  if(t==0) used[ch*(maxt+1)+t]=hoge[ch*(maxt+1)+t];
                  else used[ch*(maxt+1)+t]=used[ch*(maxt+1)+(t-1)]+hoge[ch*(maxt+1)+t];
            }
      }
      rep0(ch,C)rep0(t,(maxt+1)){
            if(used[ch*(maxt+1)+t]>0) used[ch*(maxt+1)+t]=1;
      }
      rep0(t,(maxt+1))rep0(ch,C){
            anss[t]+=used[ch*(maxt+1)+t];
      }
      int ans=0;
      rep0(t,(maxt+1)){
            ans=max(ans,anss[t]);
      }
      cout<<ans<<endl;

      
      return 0;
}


Measured memory_bytes: 25344
x,n = map(int,input().split())
if n == 0:print(x)
else:
  li = list(map(int,input().split()))

  for i in range(100):
    plus = (x+i)  in li
    minus = (x-i)  in li
  
    if plus == 1 and minus == 1:
      pass  
    elif plus == 1 and minus == 0:
      print(x-i)
      break
    elif plus == 0 and minus == 1:
      print(x+i)
      break
    else:
      print(x-i)
      break
  

Measured memory_bytes: 9224
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int R, M;
vector<int> calc(int a[3][3]) {
  vector<int> res;
  REP(i, 3) {
    int sum = 0;
    REP(j, 3) sum += a[i][j];
    res.push_back(sum%M);
  }
  REP(j, 3) {
    int sum = 0;
    REP(i, 3) sum += a[i][j];
    res.push_back(sum%M);
  }
  REP(k, 2) {
    int sum = 0;
    REP(i, 3) {
      int j;
      if (k) j = 2-i;
      else j = i;
      sum += a[i][j];
    }
    res.push_back(sum%M);
  }
  return res;
}
int a[3][3];
int dfs(int y, int x, int S) {
  if (y == 3) {
    // REP(i, 3) {
    //   REP(j, 3) {
    //     cout << a[i][j] << " ";
    //   }
    //   cout << endl;
    // }
    vector<int> v = calc(a);
    int hoge = v[0];
    for (int i=1; i<v.size(); ++i) {
      if (hoge != v[i]) return 0;
    }
    return 1;
  }
  if (x == 3) return dfs(y+1, 0, S);
  if (a[y][x] != 0) return dfs(y, x+1, S);
  int res = 0;
  for (int i=1; i<=10; ++i) {
    if (S>>i&1) continue;
    a[y][x] = i;
    res += dfs(y, x+1, S|1<<i);
  }
  a[y][x] = 0;
  return res;
}

int main() {
  while(1) {
    int S = 0;
    REP(i, 3) REP(j, 3) {
      cin >> a[i][j];
        S |= 1<<(a[i][j]);
    }
    cin >> M;
    S |= 1<<M;
    if (a[0][0] == -1) break;
    int res = 0;
    if (M == 0) {
      for (int i=1; i<=10; ++i) {
        if (S>>i&1) continue;
        M = i;
        res += dfs(0, 0, S|1<<i);
      }
    } else {
      res = dfs(0,0,S);
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 908
#include<iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
    int n;
    cin >> n;
    int s[102];
    rep(i, n) cin >> s[i];

    bool exist = true;
    rep(i, n){
        if(s[i] % 2 == 1) continue;
        if( !(s[i] % 3 == 0 || s[i] % 5 == 0)) exist = false;
    }

    if(exist) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;

}

Measured memory_bytes: 256