akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
  public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int m;
		
		LinkedList list = new LinkedList();
		
		for(int i = 0; i < n; i++){
			String[] meirei = br.readLine().split(" ");
			
			if(meirei[0].equals("deleteFirst")){
				list.removeFirst();
			}else if(meirei[0].equals("deleteLast")){
				list.removeLast();
			}else if(meirei[0].equals("insert") || meirei[0].equals("delete")){
				m = Integer.parseInt(meirei[1]);
				if(meirei[0].equals("insert")){
					list.insert(m);
				}else{
					list.remove(m);
				}
			}
		}
		System.out.println(list.toString());
	}
}

class Room{
	Room prev; //????????¨?±????????????????
	Room next; //?¬??????¨?±????????????????
	int data; //??¨?±?????????????
	
	public Room(int data){
		this.data = data;
		prev = null;
		next = null;
	}

}

class LinkedList {
	Room head;
	Room leg;
	
	public LinkedList(){
		head = new Room(0);
		head.next = head;
		head.prev = head;
		leg = head;
	}
	
	//??¨?±?x?????´??????data????????\
	void insert(int data){
		Room x = new Room(data);
		x.prev = head;
		x.next = head.next;
		head.next.prev = x;
		head.next = x;
		leg = head.prev;
	}
	
	public void removeFirst(){
		Room x = head.next;
		x.next.prev = x.prev;
		x.prev.next = x.next;
		leg = head.prev;
	}
	
	public void removeLast(){
		leg.next.prev = leg.prev;
		leg.prev.next = leg.next;
		leg = head.prev;
	}
	
	public void remove(int num){
		Room p = head.next;
		while(p != head){
			if(p.data == num){
				p.prev.next = p.next;
				p.next.prev = p.prev;
				break;
			}
			p = p.next;
		}
		leg = head.prev;
	}

	public String toString(){
		StringBuilder st = new StringBuilder();
		for(Room p=head.next; p != head; p = p.next){
			if(p.next != head){
				st.append(p.data + " ");
			}else{
				st.append(p.data);
			}
		}
		return st.toString();
	}
} 

Measured memory_bytes: 189012
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  ll N, K;
  cin >> N >> K;
  vector<P> A(N);
  REP(i, N) cin >> A[i].first >> A[i].second;
  sort(A.begin(), A.end());
  ll i = 0;
  while(0<K){
    K -= A[i].second;
    if (K <= 0) break;
    i++;
  }
  cout << A[i].first << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 998244353 
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        int x,n;
        cin>>x>>n;
        set<int> s;
        for(int i=0;i<n;i++){
            int a;
            cin>>a;
            s.insert(a);
        }
        int ans=-1;
        for(int i=0;i<=n;i++){
            if(s.count(x-i)==0){
                ans=x-i;
                break;
            }
            if(s.count(x+i)==0){
                ans=x+i;
                break;
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(12);
  for(int i=0;i<n;i++)cin >> a[i];
  int c=1,d=1;
  for(int i=0;i<n;i++){
    c*=3;
    if(a[i]%2==0){d*=2;}
    else{d*=1;}
  }
  cout << c-d << endl;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main(){
    gearup;
    string s,t;cin>>s>>t;
    int n = s.size();
    vl a(26,0),b(26,0);
    rep(i,n){
        a[s[i] - 'a']++;
        b[t[i] - 'a']++;
    }
    sort(all(a));
    sort(all(b));
    bool is_res = true;
    rep(i,26){
        if(a[i] != b[i])is_res = false;
    }
    cout << (is_res?"Yes":"No") << endl;
}


Measured memory_bytes: 916
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 100005;

int rnk[N], parent[N], total[N];

int find(int x) {
	if(parent[x] < 0) return x;
	return parent[x] = find(parent[x]);
}

int merge(int x, int y) {
	x = find(x), y = find(y);
	if(x == y)
		return 0;
	if(rnk[y] > rnk[x])
		swap(x,y);
	parent[y] = x;
	rnk[x] = rnk[x]==rnk[y] ? rnk[x]+1 : rnk[x];
	int sv = total[x];
	total[x] += total[y];
	return sv*total[y];
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
    int n,m;
    cin >> n >> m;

    rep(i,N) {
    	parent[i] = -1;
    	total[i] = 1;
    	rnk[i] = 1;
    }

    vector<pii> bridge(m);
    rep(i,m) 
    	cin >> bridge[i].X >> bridge[i].Y;

    reverse(all(bridge));

    // int prev = 0;
    vector<int> store(m);
    rep(i,m) {
    	store[i] = merge(bridge[i].X, bridge[i].Y);
    }

    reverse(all(store));
    cout << store[0] << '\n';
    repA(i,1,m-1) {
    	store[i] += store[i-1]; 
    	cout << store[i] << '\n';
    }
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var NKQ = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var N = NKQ[0];
            var K = NKQ[1];
            var Q = NKQ[2];

            int[] A = new int[N+1];

            for(int i=0; i < Q; i++)
            {
                 var B= int.Parse(Console.ReadLine());
                 A[B]++;
            }

            for(int i = 1; i <= N; i++)
            {
                Console.WriteLine(Q - A[i] < K ? "Yes" : "No");
            }
            

        }


    }
}


Measured memory_bytes: 17756
/*input
7
1 1 1 1 1 1 1
*/

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end(), greater<int>());
    ll ans = 0;
    for (int i = 1; i < N; i++) {
        ans += A[i/2];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const string YES = "Possible";
const string NO = "Impossible";

void solve(long long N, long long L, std::vector<long long> a) {
    int r = -1;
    for(int i = 0; i < N - 1; ++i) {
        if (a[i] + a[i + 1] >= L) {
            r = i;
        }
    }
    if (r < 0) {
        cout << "Impossible" << endl;
        return;
    }
    cout << "Possible" << endl;
    stack<int> S;
    S.push(r);
    for(int i = r - 1; i >= 0; --i) {
        S.push(i);
    }
    for(int i = r + 1; i < N - 1; ++i) {
        S.push(i);
    }
    while(!S.empty()) {
        cout << S.top() + 1 << endl;
        S.pop();
    }
}

signed main(){
	ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    long long L;
    scanf("%lld",&L);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, L, std::move(a));
    return 0;
}

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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (long long)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 500005

int32_t main(){
sp;
int n;
cin>>n;
int a[n+2],b[n+2],c[n+2];
memset(a,0,sizeof a);
memset(b,0,sizeof b);
memset(c,0,sizeof c);
for(int i=1; i<=n; ++i){
    cin>>a[i];
    b[i]=__gcd(a[i],b[i-1]);
}
for(int i=n; i>0; --i)
    c[i]=__gcd(c[i+1],a[i]);
int mx=b[n];
for(int i=1; i<=n; ++i){
    int x1=b[i-1];
    int x2=c[i+1];
    int z=__gcd(x1,x2);
    mx=max(mx,z);
}
cout<<mx;
return 0;}


Measured memory_bytes: 2560
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def make_cumulative(A):
    C = [0] * (len(A) + 1)
    for i, a in enumerate(A):
        i += 1
        C[i] = C[i - 1] + a
    return C


def main():
    N, M = NMI()
    cakes = [[] for _ in range(8)]
    for i in range(N):
        x, y, z = NMI()
        cakes[0].append(sum([x, y, z]))
        cakes[1].append(sum([x, y, -z]))
        cakes[2].append(sum([x, -y, z]))
        cakes[3].append(sum([x, -y, -z]))
        cakes[4].append(sum([-x, y, z]))
        cakes[5].append(sum([-x, y, -z]))
        cakes[6].append(sum([-x, -y, z]))
        cakes[7].append(sum([-x, -y, -z]))
    for i in range(8):
        cakes[i] = sorted(cakes[i], reverse=True)
        cakes[i] = sum(cakes[i][:M])
    print(max(cakes))


if __name__ == "__main__":
    main()

Measured memory_bytes: 9716
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <iterator>
#include <utility>
#include <iomanip>
#include <stack>
#include<bitset>
#include <cmath>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > >pq;
vector<ll>adj[1000005];
ll expo(ll b,ll n,ll m)
{
 ll r,p;
	p=1;
	 b=b%m;
	while(n>0)
	{ 
		r=n%2;
		if(r==1)
		   p=((p%m)*(b%m))%m;
		b=((b%m)*(b%m))%m; 
		n=n/2;		
	}
 return (p%m);
}
ll divide1(ll a,ll b,ll m)
	{ ll r,p,n;
			p=a%m;
				n=m-2;
				while(n>0){
						 r=n%2;
						if(r==1)
							p=((p%m)*(b%m))%m;
						b=((b%m)*(b%m))%m; 
						n=n/2;	
					}
	return (p%m); }
bool check(ll x,ll n)
{
	while(n>=x&&n%x==0)
	{
		n/=x;
	}
	return n%x==1;
}

int main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	ll n1;
	 cin>>n1;
	for(ll n=n1;n<=n1;n++)
	{
		ll ans=0;
		for (ll i = 2; i*i <= n; i++)
	{
		if (n%i>0)
		{
			continue;
		}
		ans+=(check(i,n));
		if(i!=n/i){
			ans+=(check(n/i,n));			
		}
	}
	ans+=check(n,n);
	--n;
	for (ll i = 1; i*i <= n; i++)
	{
		if (n%i>0)
		{
			continue;
		}
		if(i>1)
		ans++;
		if(i!=n/i&&n/i>1){
			ans++;			
		}
	}
	++n;
	cout<<ans<<endl;
}
	return 0;
}


Measured memory_bytes: 23680
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(){
    int a,b,c;
    cin >> a ;
    if (a == 1){
        cout << "Hello World" << endl;
    }
    else {
        cin >> b >> c;
        cout << b + c << endl;
}
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h> // only for GCC

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

//repetition
//------------------------------------------
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T>ostream&operator<<(ostream&os, vector<T>const&v){
        iter(it,v) os<<*it<<(it+1==v.end()?"":",");
        return os;
    }
    template<typename T, typename U>ostream&operator<<(ostream&os,const pair<T,U>&p){
        return os << "[" << p.dirst << "," << p.second << "]";
    }
}

//clear memory
// ------------------------------------------
#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
   string s,a,b;
   int ans=0;
   while(cin >> s){
      a=s.substr(0,s.size()/2);
      b=s.substr(s.size()-s.size()/2,s.size());
      reverse(all(b));
      if(a==b) ans++;
   }
   cout << ans << endl;
}

Measured memory_bytes: 1188
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    long a,b;
    cin >> a >> b;

    cout << max({a+b, a-b, a*b}) << endl;

    return 0;
}



Measured memory_bytes: 256
n = int(input())
s = input()
ans = n
lstw = [0]*n
lste = [0]*n
cntw = 0
cnte = 0

for i in range(n):
    lstw[i] = cntw
    if s[i] == "W": cntw += 1
    lste[n-1-i] = cnte
    if s[n-1-i] == "E": cnte += 1

for i in range(n):
    ans = min(lstw[i]+lste[i],ans)

print(ans)


Measured memory_bytes: 17548
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());

        var A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var B = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var C = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        int sum = 0;

        for (var i = 0; i < N; i++)
        {
            var dishNum = A[i];
            sum += B[dishNum - 1];

            if (i == 0) continue;

            if (dishNum == (A[i - 1] + 1))
            {
                sum += C[dishNum - 2];
            }
        }

        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <vector>
#define ll long long
#define fr first
#define sc second
#define ii pair< double , int >

using namespace std;
vector < vector < pair < double ,int > > > v;
vector < double > d(1005);
int bfs(int i)
{
    for(int j=0; j<d.size(); j++)
        d[j] = 1e15;
    d[i] = 0;
    priority_queue < ii , vector < ii > , greater < ii >  > q ;
    q.push(ii(0,i));
    while(!q.empty())
    {
        ii R = q.top();
        q.pop();
        double L = R.fr ;
        int u = R.sc;
        if(L > d[u])
            continue;
        for(int j=0; j<v[u].size(); j++)
        {
            ii node = v[u][j];
            if(d[node.sc] > d[u]+node.fr)
            {
                d[node.sc] = d[u]+node.fr;
                q.push(ii (d[node.sc],node.sc));
            }
        }
    }
}
struct point
{
    int x,y;
};
struct circle
{
    point p;
    int r;
} a[1005];

double distanc(circle b,circle c)
{
    double t=hypot(b.p.x-c.p.x,b.p.y-c.p.y);
    if(t>b.r+c.r)
        return t-(b.r+c.r);
    else return 0;
}
int main()
{
    int x1,y1,x2,y2,n;
    v.resize(1005);
    cin>>x1>>y1>>x2>>y2>>n;
    a[0].p.x=x1;
    a[0].p.y=y1;
    a[0].r=0;
    a[n+1].p.x=x2;
    a[n+1].p.y=y2;
    a[n+1].r=0;
    for(int i=1; i<=n; i++)
    {
        int x,y,r;
        cin>>x>>y>>r;
        a[i].p.x=x;
        a[i].p.y=y;
        a[i].r=r;
    }
    for(int i=0; i<=n+1; i++)
        for(int j=i+1; j<=n+1; j++)
        {
            double di=distanc(a[i],a[j]);
            v[i].push_back(ii(di,j));
            v[j].push_back(ii(di,i));
        }
    bfs(0);
    cout<<fixed<<setprecision(10)<<d[n+1];
    return 0;
}


Measured memory_bytes: 22676
#!/usr/local/bin/python3
# coding: utf-8
import numpy as np

kita = input().split(" ")
n = int(kita[0])
d = float(kita[1])
count = 0

for i in range(n):
    kita = input().split(" ")
    com = np.sqrt(int(kita[0]) ** 2 + int(kita[1]) ** 2)
    if com <= d:
        count += 1

print(count)

Measured memory_bytes: 27156
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
a,b,m = readInts()
A = readInts()
B = readInts()
res = min(A) + min(B)
for i in range(m):
    x,y,c = readInts()
    x -=1;y-=1;
    res = min(res,A[x] + B[y] - c)
print(res)


Measured memory_bytes: 20688
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) {
        cin>>a[i];
        a[i]--;
    }
    ll sum=0;
    rep(i,n){
        if(a[a[i]]==i) sum++;
    }
    cout<<sum/2<<endl;
    return 0;
}


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

const int L = 32, N = 1e5 + 10;
int n, x, ans, t, a, cnt[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a;
		cnt[__builtin_ctz(a)]++;
		x ^= a;
	}
	
	bool t = 1;
	for (int i = L - 1; i >= 0; i--){
		if((x >> i) % 2 == t){
			if(cnt[i] == 0)
				return cout << -1, 0;
			t = 1 - t;
			ans++;
		}
	}
	
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    ll res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}

ll f[200001];
 
ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a; 
 while(b > 0)
    {
        if(b%2 == 1)
    {
        x=(x*y);
        if(x>MOD) x%=MOD;
    }
    y = (y*y);
    if(y>MOD) y%=MOD; 
    b /= 2;
    }
 return x;
}
 
/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}
 
ll C(ll n, ll r, ll MOD)
{
 
 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x=nxt();
    int l=400;
    int ans=8;
    while(l+200<=x)
    {
        ans--;
        l+=200;
    }
    cout<<ans<<endl;
    
    
    return 0;   
}


 
 


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define vv vector<lli>
#define vp vector<pair<lli,lli>>
#define vpp vector<pair<lli,pair<lli,lli>>>
#define lims(w) (w).begin(),(w).end()
#define rlims(w) (w).rbegin(),(w).rend()
#define pb push_back
#define mp make_pair
#define f(i,a,b) for(lli i=a;i<b;i++)
#define ff first
#define ss second
#define sz(a) (lli)(a.size())
lli inf = (1e18 + 2);

int main()
{
	lli a,b,c;
	cin>>a>>b>>c;
	lli k;
	cin>>k;
	lli ans = 0;

	while(a >= b)
	{
		b *= 2;
		ans++;
	}

	while(c <= b)
	{
		c *= 2;
		ans++;
	}

	if(ans <= k)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 3632
// Author : MohamedSameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
void fo (){fflush(stdout);}
using namespace std;

int main ()
{
  int n , m ;
  cin >> n >> m ;
  n%=500 ;
  if (n <= m )
  {
    cout <<"Yes\n";
  }else
  cout <<"No\n"; 
  //cerr << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int inf = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int n;
    cin >> n;
    int a[n] = {0}, b[n-1];
    for (int i = 0; i < n - 1; i++)
        cin >> b[i];
    for (int i = 0; i < n - 1; i++) {
        a[i] = b[i];
        a[i+1] = max(a[i+1], b[i]);
        if (b[i] < a[i]) a[i] = b[i];
        if (i != 0 && b[i-1] < a[i]) a[i] = b[i-1];
    }
    int s = 0;
    for (int i = 0; i < n; i++) {
        // cout << a[i] << " ";
        s += a[i];
    }
    cout << s << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    ll k;
    scanf("%lld", &k);

    ll n = min(50LL, k);
    n = n < 2 ? 2 : n;

    ll q = k / n;
    ll r = k % n;

    ll ans[n];
    memset(ans, 0, sizeof(ans));
    for (int i = 0; i < n; i++) {
        ans[i] = q + i;
    }
    reverse(ans, ans + n);

    for (int i = 0; i < r; i++)
        ans[i]++;

    printf("%lld\n", n);
    for (int i = 0; i < n; i++)
        printf("%lld%c", ans[i], i == n - 1 ? '\n' : ' ');

    return 0;
}

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

int N, M, P;
int X[210];

int main() {
  while (cin >> N >> M >> P) {
    if (N == 0) break;
    int sum = 0;
    for (int i = 0; i < N; ++i) cin >> X[i], sum += X[i] * 100;
    cout << (X[M-1] ? sum*(100-P)/100/X[M-1] : 0) << endl;
  }
}


Measured memory_bytes: 1160
from sys import stdin

inf = 10**9 + 1

def solve():
    n = int(stdin.readline())
    R = [int(stdin.readline()) for i in range(n)]
    ans = max_profit(n, R)
    print(ans)

def max_profit(n, R):
    max_dif = -inf
    min_v = R[0]

    for i in range(1, n):
        max_dif = max(max_dif, R[i] - min_v)
        min_v = min(min_v, R[i])

    return max_dif

if __name__ == '__main__':
    solve()

Measured memory_bytes: 15696
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		ACGT acgt = new ACGT(s);
		int ans = acgt.calcACGT();
		System.out.println(ans);
	}
	
}

class ACGT {
	String s;
	public ACGT(String s) {
		this.s = s;
	}
	int calcACGT() {
		int length = 0;
		int longest = 0;
		for (int i = 0; i < s.length(); i++) {
			if (isACGT(s.charAt(i))) {
				length++;
			} else {
				longest = Math.max(length, longest);
				length = 0;
			}
		}
		return Math.max(length, longest);
	}
	boolean isACGT(char c) {
		switch (c) {
		case 'A':
		case 'C':
		case 'G':
		case 'T':
			return true;
		}
		return false;
	}
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main 
{
	public static void main(String[] args)
	{
	Scanner sc = new Scanner(System.in);
	int X = sc.nextInt();
	if (X>=30)
	{
	System.out.println("Yes");
	}
	else
	{
	System.out.print("No");
	}
	}
}


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

int main(){
  string s;cin>>s;
  while(true){
    s = s.substr(0, s.size()-2);
    int l=s.size()/2;
    string a=s.substr(0, l);
    string b=s.substr(l, l);
    if(a==b){cout << 2*l << endl;break;}
  }
}


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

using namespace std;
typedef long long ll;

int main(){
 
ll L,R;
cin>>L>>R;

int ans=2018;

for(ll i=L;i<R;i++){
    for(ll j=i+1;j<=R;j++){
        ans=min(ans,int((i*j)%2019));
        if(ans==0){
        cout<<0;
        return 0;
        }
    }
}

cout<<ans<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n =sc.nextInt();
		int m = sc.nextInt();
		long sum = 0;
		for(int i = 0; i < m; i++) {
			sum += sc.nextLong();
		}
		long ans = n - sum;
		if (ans < 0)
			ans = -1;
		
		out.println(ans);
		
		out.close();
	}

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




Measured memory_bytes: 33488
# -*- coding: utf-8 -*-
# ALDS1_2_C

def BubbleSort(C):
    for i in range(len(C)):
        for j in range(len(C)-1, i, -1):
            if int(C[j][1]) < int(C[j-1][1]):
                C[j], C[j-1] = C[j-1], C[j]
    return C

def SelectionSort(C):
    for i in range(len(C)):
        minj = i
        for j in range(i, len(C)):
            if int(C[j][1]) < int(C[minj][1]):
                minj = j
        C[i], C[minj] = C[minj], C[i]
    return C

N = int(input())
C = input().split()
C1 = C.copy()
C2 = C.copy()

BSC = BubbleSort(C1)
print(" ".join(BSC))
print("Stable")
SSC = SelectionSort(C2)
print(" ".join(SSC))
if BSC == SSC:
    print("Stable")
else:
    print("Not stable")



Measured memory_bytes: 5612
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}
#define int ll
 
int n, m, k;
ll b[N], low[N], upp[N];
pair<ll, int> c[N];
ll f[N];

ll eval (int i, int k) {
	if (k >= b[i]) {
		return k * (ll)upp[i] - (b[i] * (ll)(upp[i] - low[i]));
	}
	return k * (ll)low[i];
}
ll B = 0;

bool check (ll x) {
	int pref = (x/m);
	int left = x%m;
//	cout << B << '\n';
	for (int i = pref + 1; i <= n; ++i) {
//		cout << f[pref] + eval(c[i].second, left) << ' ' << B << ' ' << c[i].second << '\n';
		if (f[pref] + eval(c[i].second, left) >= B)
			return 1;
	}

	++pref;

	for (int i = 1; i < pref; ++i) {
		if(f[pref] + eval(c[i].second, left) - eval(c[i].second, m) >= B)
			return 1;
	}

	return 0;
}

int32_t main () {
	SpeedForce;
	
	cin >> n >> m;
	ll l = -1, r = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> b[i] >> low[i] >> upp[i];
		c[i] = {eval(i, m), i};
		r += b[i];
		B += b[i] * (ll)low[i];
	}
	
	sort(c+1, c+n+1);
	reverse(c+1, c+n+1);
	for (int i = 1; i <= n; ++i) {
	//	cout << c[i].first << ' ' << c[i].second << '\n';
		f[i] = f[i-1] + c[i].first;
	}
	while(r - l > 1) {
		ll md = (l+r)>>1ll;
		if(check(md)) r= md;
		else l = md;
	}
	
	cout << r << '\n';
	

	return Accepted;
}

// B...a

Measured memory_bytes: 13312
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
cnt = 0
i = 1
while True:
    cnt += i
    if cnt >= n:
        break
    i += 1
for j in range(1,i+1):
    if j == cnt-n:
        continue
    print(j)

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

using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector<ll> s1(n + 1), s2(n + 1);
    for(int i = 0; i < n; ++i) {
        s1[i + 1] = s1[i] ^ a[i];
        s2[i + 1] = s2[i] + a[i];
    }

    ll ans = 0;
    for(int i = 0; i < n; ++i) {
        int lb = i, ub = n + 1;
        while(ub - lb > 1) {
            const int mid = (ub + lb) / 2;
            if((s1[mid] ^ s1[i]) == s2[mid] - s2[i]) {
                lb = mid;
            } else {
                ub = mid;
            }
        }

        ans += lb - i;
    }

    cout << ans << endl;
}


Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

#include<vector>
template<typename T>
class UnionFind
{
	public:
	vector<T> parent;
	
	UnionFind(T n):parent(n)
	{
		for(int i=0;i<n;i++)
			parent[i]=i;
	}
	
	void unite(T a,T b)
	{
		a=root(a);
		b=root(b);
		if(a==b)return;
		if(a>b)swap(a,b);
		parent[b]=a;
		return;
	}
	
	T root(T n)
	{
		if(parent[n]==n)
			return n;
		else
		{
			T ret=root(parent[n]);
			parent[n]=ret;
			return ret;
		}
	}
};

int main()
{
	lint N,M;
	lint A[100010]={};
	lint B[100010]={};
	
	cin >> N >> M;
	for(lint i=M;i>0;i--)
	{
		cin >> A[i] >> B[i];
		A[i]--;
		B[i]--;
	}
	
	UnionFind<lint> uf(N);
	lint ans[100010]={};
	lint rsum[100010]={};
	
	ans[0]=(N*(N-1))/2;
	for(lint i=0;i<N;i++)
		rsum[i]=1;
	for(lint i=1;i<=M;i++)
	{
		ans[i]=ans[i-1];
		if(uf.root(A[i])==uf.root(B[i]))
			continue;
		
		lint x=rsum[uf.root(A[i])]*rsum[uf.root(B[i])];
		lint Minrt=min(uf.root(A[i]),uf.root(B[i]));
		lint Maxrt=max(uf.root(A[i]),uf.root(B[i]));
		
		rsum[Minrt]+=rsum[Maxrt];
		rsum[Maxrt]=0;
		uf.unite(A[i],B[i]);
		ans[i]-=x;
	}
	
	for(int i=M-1;i>=0;i--)
		cout << ans[i] << endl;
	return 0;
}



Measured memory_bytes: 5248
n = int(input())
L = sorted(map(int, input().split()))
S = [0] * n
S[0] = L[0]
cnt = 1
for i in range(n-1):
    S[i+1] = S[i] + L[i+1]
    if L[i+1] <= 2 * S[i]:
        cnt += 1
    else:
        cnt = 1
print(cnt)


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<ll, ll>;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

ll N;
vector<ll> A;
void dfs(ll i) {
  if(i <= N && i != 0) {
    map<ll, ll> m;
    string check = to_string(i);
    REP(i, check.size()) {
      m[check[i]]++;
    }
    if(m.size() == 3) A.push_back(i);
  }
  if(i > N || to_string(i).size() >= 13) return;
  dfs(i * 10 + 3);
  dfs(i * 10 + 5);
  dfs(i * 10 + 7);
}

int main() {
  cin >> N;
  dfs(3); dfs(5); dfs(7);
  cout << A.size() << endl;
}

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

int main(){
  string s , t ; 
  cin >> s >> t ; 
  int a , b ; 
  cin >> a >> b ; 
  string u ; 
  cin >> u ; 
  if ( u == s ) a-- ; 
  else b--; 
  cout << a << ' ' << b << endl;
  
}

Measured memory_bytes: 256
//AOJ0280

#include <iostream>
#include <algorithm>
using namespace std;

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

    if(N==0)
      break;

    int n[10] = {0};
    int m = 0;

    for(int i=0; i<100; i++){
      char c;
      cin >> c;

      n[i%N]++;

      if(c=='S'){
        m += n[i%N];
        n[i%N] = 0;
      }
      else if(c=='L'){
        n[i%N] += m;
        m = 0;
      }
    }

    sort(n, n+N);

    for(int i=0; i<N; i++){
      cout << n[i] << ' ';
    }
    cout << m << endl;
  }

  return 0;
}

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

namespace AtCoder176
{
    class Program
    {
        static void Main(string[] args)
        {
            QA();
        }

        static void QA()
        {
            string line = Console.ReadLine();
            string[] splited = line.Split(' ');
            int N = int.Parse(splited[0]);
            int X = int.Parse(splited[1]);
            int T = int.Parse(splited[2]);

            Console.WriteLine(Math.Ceiling((double)N / X) * T);
        }
    }
}


Measured memory_bytes: 18620
//xを固定すると、一番おいしい寿司がおいしい種類順に1個ずつ選んだあと貪欲。
//xを1動かしたときの貪欲法の結果を比較すると、multisetで殴れることに気付く。
#include <iostream>
#include <algorithm>
#include <functional>
#include <set>
#define int long long
using namespace std;

int n, k;
int t, d;
int best[100000];
int sd[100000];
multiset<int> greedy;

signed main() {
	int i;
	
	cin >> n >> k;
	for (i = 0; i < n; i++) {
		cin >> t >> d;
		t--;
		best[t] = max(best[t], d);
		sd[i] = d;
	}
	sort(sd, sd + n, greater<int>());
	sort(best, best + n, greater<int>());
	
	int initAns = 0;
	for (i = 0; i < k; i++) {
		initAns += sd[i];
		greedy.insert(sd[i]);
	}
	
	int x = 0;
	int nowAns = initAns;
	int ans = 0;
	for (i = 0; i < n; i++) {
		if (best[i] == 0) continue;
		x++;
		if (x > k) break;
		
		multiset<int>::iterator it = greedy.lower_bound(best[i]);
		nowAns -= (*it);
		greedy.erase(it);
		nowAns += best[i];
		
		//cout << "i = " << i << ", x = " << x << ", nowAns = " << nowAns << endl;
		ans = max(nowAns + x * x, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6272
#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>;
const int MOD=1000000007;

int main() {
  int n, m, l;
  cin >> n >> m >> l;

  cout << (n+m+l>21? "bust" : "win") << endl;
}


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

void fastio() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}

int main(int argc, char const *argv[])
{
	// fastio();
	int n;
	cin >> n;
	vector<int> nums(n);
	for (int i = 0; i < n; ++i)	 {
		cin >> nums[i];
	}
	vector<int> ans(n, INT_MAX);
	ans[0] = 0;
	for (int i = 1; i < n; ++i) {
		if (i - 1 >= 0)
			ans[i] = min(ans[i], ans[i-1]+abs(nums[i]-nums[i-1]));
		if (i - 2 >= 0)
			ans[i] = min(ans[i], ans[i-2]+abs(nums[i]-nums[i-2]));
	}
	cout << ans[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
  int a,b;
  scanf("%d %d", &a, &b);
  if (a < b){
      puts("a < b");
  }
  else if (a > b){
      puts("a > b");
  }
  else{
      puts("a == b");
  }
  return (0);
}

Measured memory_bytes: 580
N = int(input())
a = input()
b = input()
c = input()

ans = 0
for i in range(N):
    d = dict()
    d[a[i]] = d.get(a[i], 0) + 1
    d[b[i]] = d.get(b[i], 0) + 1
    d[c[i]] = d.get(c[i], 0) + 1
    t = max(d[a[i]], d[b[i]], d[c[i]])
    ans += (3 - t)
print(ans)

Measured memory_bytes: 3064
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()
typedef long long ll;
#define rep(i, z, n) for(int i = z; i < n; i++)
//const int INF = 1<<29;
const ll MOD = 1000000007;
#define P pair<int, int>
using namespace std;

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll powmod(ll x, ll n, ll mod){
    //pow(x, n) % mod
    int ret = 1;
    while(n > 0){
        if(n & 1) ret = ret * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return ret;
}

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A.at(i);
    ll sum = 0;
    ll sq = 0;
    rep(i, 0, N){
        sum += A.at(i);
        sum %= MOD;
        
        ll sqi = A.at(i);
        sqi *= A.at(i);
        sqi %= MOD;
        sq += sqi;
        sq %= MOD;
    }
    sum *= sum;
    sum %= MOD;
    sum += MOD;
    sum -= sq;
    sum %= MOD;
    ll syo = powmod(2, 1000000005, 1000000007);
    sum *= syo;
    sum %= MOD;
    
    cout << sum << endl;
    //cout << ll(ll(1000000000) * ll(1000000000) % MOD) << endl;
}

Measured memory_bytes: 4832