akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;

static class Extensions
{
    public static int ToInt(this string s) => int.Parse(s);
    public static long ToLong(this string s) => long.Parse(s);
    public static char ToChar(this string s) => char.Parse(s);
    public static double ToDouble(this string s) => double.Parse(s);
    public static int[] ToIntArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToInt()).ToArray();
    public static long[] ToLongArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToLong()).ToArray();
    public static double[] ToDoubleArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToDouble()).ToArray();
    public static Queue<T> ToQueue<T>(this IEnumerable<T> seq) => new Queue<T>(seq);
    public static Stack<T> ToStack<T>(this IEnumerable<T> seq) => new Stack<T>(seq);
    public static HashSet<T> ToHashSet<T>(this IEnumerable<T> seq) => new HashSet<T>(seq);
}
static class MyMath
{
    static public long GCD(long a, long b) => (a < b) ? GCD(b, a) : ((b == 0) ? a : GCD(b, a % b));
    static public long LCM(long a, long b) => (a > b) ? (a / GCD(a, b) * b) : (b / GCD(a, b) * a);
    static private readonly long _m = 1000000000 + 7;
    static public long Mod(long val) => (val % _m + _m) % _m;
    static private long extGCD(long a, long b, ref long x, ref long y) => (b == 0) ? (a + (x = 1) * 0 + (y = 0) * 0) : (extGCD(b, a % b, ref y, ref x) + (y -= a / b * x) * 0);
    static public long ModInverse(long a, long dummy1 = 0, long dummy2 = 0) => extGCD(a, _m, ref dummy1, ref dummy2) * 0 + Mod(dummy1);    
}

class Program
{
    static string[] ReadLines(int n) => Enumerable.Range(0, n).Select(s => Console.ReadLine()).ToArray();

    static void Main()
    {
        int N = Console.ReadLine().ToInt();
        long[] array = ReadLines(N).Select(s => s.ToLong()).ToArray();

        //降順
        List<long> xxx = new List<long>();

        foreach (var n in array)
        {
            var x = helper(xxx, n);

            if (x < 0)
            {
                xxx.Add(n);                
            }
            else
            {
                xxx[x] = n;
            }
        }

        Console.WriteLine(xxx.Count);
    }

    static int helper (IList<long> list, long val)
    {
        if (list.Count == 0) return -1;
        
        int left = 0;
        int right = list.Count - 1;
        
        if (list[0] < val) return 0;
        
        if (list[list.Count - 1] >= val) return -1;

        while (right - left > 1)
        {
            int mid = (right - left) / 2 + left; 
            if (list[mid] < val)
            {
                right = mid;
            }
            else
            {
                left = mid;
            }
        }
        
        return right;
    }
    
}

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

int main(){ 
  string a,b; cin>>a>>b;
  int n= a.length();
  for(int k=0;k<n;k++){ 
    int i=0; 
    while((a[i]==b[(k+i)%n])&&(i<n)){ 
      i++;}
    if(i==n){ 
      cout<<"Yes";
      return 0;}
    }
  cout<<"No";
  }

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

#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair

using namespace std;

typedef long long ll;

const ll mod = (ll)1e9 + 7;
const ll N = (ll)1e5 + 7;

ll n;
ll d;
ll a[N],u[N];
ll fac[N];

ll bp (ll b,ll l) {
        ll res = 1;
        while (l) {
                if (l & 1)
                        res = (res * b) % mod;
                b = (b * b) % mod;
                l >>= 1;
        }
        return res;
}
ll cnk (ll nn,ll kk) {
        if (nn < kk)
                return 0;
        return fac[nn] * (bp(fac[kk] * fac[nn - kk] % mod,mod - 2) % mod) % mod;
}
 main () {
        cin >> n;

        fac[0] = 1;

        for (int i = 1; i < N; i ++) {
                fac[i] = (fac[i - 1] * i) % mod;
        }
        for (ll i = 1; i <= n + 1; i ++)
        {
                cin >> a[i];
                if (u[a[i]] > 0) {
                        d = i - u[a[i]];
                }
                u[a[i]] = i;
        }

        for (ll i = 1; i <= n; i ++) {
                cout << (cnk(n + 1,i) - cnk(n - d,i - 1) + mod)  % mod << endl;
        }
        cout << 1 << endl;

}


Measured memory_bytes: 3584
s = input(); 
n = len(s);
ss = "";
sss = "";
ssss = "";

for i in range(1,n+1):
  ss = ss + s[n-i];

mid = int((n+1)/2);

for i in range(mid-1):
  sss = sss + s[mid-2-i]
  
for i in range(mid-1):
  ssss = ssss + s[n - i -1];
  
if ss ==s and sss == s[0:mid-1] and ssss == s[mid:n]:
  print("Yes");
else:
  print("No")

Measured memory_bytes: 3064
A,B,K = [int(i) for i in input().split()]

counter = 1
ans_list = []
for i in range(A,B+1) :
	ans_list.append(i)
	counter += 1
	if (counter > K) :
		break

counter = 1
for i in range(B,A,-1) :
	ans_list.append(i)
	counter += 1
	if (counter > K) :
		break

ans_list = list(set(ans_list))
ans_list.sort()
for i in ans_list :
	print(i)




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

int main() {
    // input
    string sa, sb, sc;
    cin >> sa >> sb >> sc;

    // solve & output
    int a = 0, b = 0, c = 0;
    char turn = 'a';
    while (true) {
        switch (turn) {
        case 'a':
            if (sa.length() == a) {
                cout << "A" << endl;
                return 0;
            }
            turn = sa[a];
            a++;
            break;
        case 'b':
            if (sb.length() == b) {
                cout << "B" << endl;
                return 0;
            }
            turn = sb[b];
            b++;
            break;
        case 'c':
            if (sc.length() == c) {
                cout << "C" << endl;
                return 0;
            }
            turn = sc[c];
            c++;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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_MAX	2,147,483,647 = 2*1.0e9

int main(){
  string S;
  int K;
  cin >> S >> K;

  int cnt1;
  for(int i = 0; i < S.length(); i++){
    if(S[i] != '1'){
      cnt1 = i;
      break;
    }
  }

  char next1 = S[cnt1];

  if(K > cnt1) cout << next1 << endl;
  else cout << 1 << endl;

  return 0;
}


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  string a,b,c;cin>>a>>b>>c;
  cout<<"A"<<b[0]<<"C"<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define int long long
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define pivi pair<int,vector<int>>
#define traverse(container, it)  for(auto it = container.begin(); it != container.end(); it++)
#define all(c) c.begin(), c.end()
#define repeat(n) for(int i=0;i<n;i++)
#define PI 3.1415926535897932384626;

   
signed main(){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	
	int n;
	cin >> n;
	int arr[n];
	map<int,int> mp;
	int count=0;

	for(int i=0;i<n;i++){
		cin >> arr[i];
		mp[arr[i]]++;
	}



	for(int i=0;i<n;i++){
		// cout <<"num = " << arr[i] ;

		for(int j=1;j*j<=arr[i];j++){
			if(arr[i]%j!=0) continue;
			int a = j, b = arr[i]/j;
			// cout << "num=" << arr[i] <<" a=" << a<< " b=" << b << endl;
			if(arr[i]==1){
				if(mp[1]>1) {count++; break;}
			}
			else if(a==1){
				if(a==arr[i]) {
					if(mp[a]>1 || mp[b]>0) {count++; break;} 
				}
				if(b==arr[i]){
					if(mp[b]>1 || mp[a]>0) {count++;  break;}
				}
			}
			else if(mp[a]>0 || mp[b]>0) {count++;  break;}

		}
		// cout << endl;

	}

	cout << n - count << endl;

	return 0;
}



Measured memory_bytes: 33196
//author : Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll long long
#define ln "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }

const ll MOD = 1e9 + 7;
ll n, k;
vector<int> graph[105];

int main()
{
	FASTIO;
	cin >> n >> k;
	ll lim = (n - 1) * (n - 2);
	lim /= 2;
	if (k > lim)
	{
		cout << "-1" << ln;
		return 0;
	}
	ll curr = lim;
	int root = n;
	for (int i = 1; i < n; i++)
		graph[root].emplace_back(i), graph[i].emplace_back(root);

	int a = n - 2, i = 0;
	int diff = 1;
	while (curr != k)
	{
		graph[a].emplace_back(a + diff);
		graph[a + diff].emplace_back(a);
		a--;
		curr--;
		if (!a)
		{
			i++;
			a = n - 2 - i;
			diff++;
		}
	}
	set<pair<int, int>> edges;
	for (int i = 1; i < n + 1; i++)
		for (auto child : graph[i])
			edges.insert({min(i, child), max(i, child)});

	cout << edges.size() << ln;
	for (auto x : edges)
		cout << x.first << " " << x.second << ln;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
bool prime(int n){
	for(int i=2;i<n;i++){
		if(n%i==0)return false;
	}
	return true;
}

int main(){
	int x,xx;
	while(cin>>x){
		xx=x-1;
		while(prime(xx)==false)xx--;
		cout<<xx<<" ";
		xx=x+1;
		while(prime(xx)==false)xx++;
		cout<<xx<<endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;

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

typedef pair<int, int> pii;

int maps[3001][3001]; 
int w, h;

bool check(int x, int y) {
	return x >= 0 && x < w && y >= 0 && y < h;
}

int compress(vector<int> &xa, vector<int> &xb, int maxSize) {
	vector<int> cx;
	REP(i, xa.size()) {
		FOR(j, -1, 2) {
			if (xa[i] + j >= 0 && xa[i] + j < maxSize) cx.push_back(xa[i] + j);
			if (xb[i] + j >= 0 && xb[i] + j < maxSize) cx.push_back(xb[i] + j);
		}
	}
	cx.push_back(0);
	cx.push_back(maxSize - 1);
	
	sort(cx.begin(), cx.end());
	cx.erase(unique(cx.begin(), cx.end()), cx.end());
	
	REP(i, xa.size()) {
		xa[i] = find(cx.begin(), cx.end(), xa[i]) - cx.begin();
		xb[i] = find(cx.begin(), cx.end(), xb[i]) - cx.begin();
	}
	
	return cx.size();
}

int main() {
	while (cin >> w >> h, w || h) {
		int n;
		cin >> n;
		
		vector<int> x1, y1, x2, y2;
		REP(i, n) {
			int a1, b1, a2, b2;
			scanf("%d %d %d %d", &a1, &b1, &a2, &b2);
			x1.push_back(a1);
			y1.push_back(b1);
			x2.push_back(a2);
			y2.push_back(b2);
		}
		w = compress(x1, x2, w);
		h = compress(y1, y2, h);
		fill(maps[0], maps[h], 0);
		
		REP(i, n) {
			maps[y1[i]][x1[i]]++;
			maps[y2[i]][x1[i]]--;
			maps[y1[i]][x2[i]]--;
			maps[y2[i]][x2[i]]++;
		}
		
		REP(i, h) FOR(j, 1, w) maps[i][j] += maps[i][j - 1];
		REP(i, w) FOR(j, 1, h) maps[j][i] += maps[j - 1][i];
		
		REP(i, h) REP(j, w) maps[i][j] = maps[i][j] > 0 ? 1 : 0;
		
		int ans = 0;
		queue<pii> que;
		REP(i, h) REP(j, w) if (maps[i][j] == 0) {
			ans++;
			que.push(pii(j, i));
			while (!que.empty()) {
				pii now = que.front(); que.pop();
				int x = now.first, y = now.second;
				
				if (!check(x, y) || maps[y][x] == 1) continue;
				maps[y][x] = 1;
				
				int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
				REP(k, 4) que.push(pii(x + dx[k], y + dy[k]));
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 19024
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
/*........................................DEFINE FUNCTIONS.........................................*/
int N;
int ans;
/*....................................DEFINE GLOBAL VARIABLES .....................................*/
void func(ll cur, int use) {
	if (cur > N)return;
	if (use == 0b111)ans++;
	func(cur * 10 + 3, use | 0b001);
	func(cur * 10 + 5, use | 0b010);
	func(cur * 10 + 7, use | 0b100);
}
/*.........................................kemkemG0................................................*/
int main() {
	cin >> N;
	func(0, 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    std::cerr.write(names, comma - names) << " = " << arg1;
    ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
int clz(unsigned long long N) { return N ? 64 - __builtin_clzll(N) : -INF;}//may not work for some compiler returns position of msb; 
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fiṇxed;
const ll mod =1000000007;
ll modinv(ll x)
{
    return pow(x,mod-2,mod);
}
ll dp[1001][1001];
int main()
{
        FastIO

        int h,w,i,j;
        cin>>h>>w;
        string s[h];
        for(i=0;i<h;i++)
        cin>>s[i];
        dp[0][0]=1;
        for(i=0;i<h;i++)
        {
            for(j=0;j<w;j++)
            {
                if(i>0 && s[i-1][j]!='#')
                dp[i][j]+=dp[i-1][j];
                if(j>0 && s[i][j-1]!='#')
                dp[i][j]+=dp[i][j-1];
                dp[i][j]%=mod;
            }
        }
        cout<<dp[h-1][w-1];
        return 0;
}

Measured memory_bytes: 12500
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int q;
  cin>>q;char c;int f;
  int rev=0;int z;
  deque<char> ans;
  for(auto x: s)ans.push_back(x);
  while(q--)
  {
    cin>>z;
    if(z==1)
    {
      rev=rev^1;
    }
    else
    {
      	cin>>f>>c;
     	if(f==1)
		{
			if(rev)ans.push_back(c);
			else ans.push_front(c);
		}
		else
		{
			if(rev)ans.push_front(c);
			else ans.push_back(c);
		}
    }
    
  }
  while(!ans.empty())
  {	if(!rev)
    {cout<<ans.front();
    ans.pop_front();}
	else
	{
		cout<<ans.back();
		ans.pop_back();
	}
  }
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int N; cin >> N;

	int befo, aft;
	aft = N % 10;
	N /= 10;
	aft += (N % 10) * 10;
	N /= 10;

	befo = N % 10;
	N /= 10;
	befo += (N % 10) * 10;

	//cout << befo << " " << aft << endl;

	bool befoIsMonth = !(befo == 0 || befo >= 13);
	bool aftIsMonth = !(aft == 0 || aft >= 13);

	if (!befoIsMonth && !aftIsMonth) cout << "NA" << endl;
	else if (!befoIsMonth) cout << "YYMM" << endl;
	else if (!aftIsMonth) cout << "MMYY" << endl;
	else cout << "AMBIGUOUS" << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
using ll = long long;
using namespace std;

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

//sort(a, a + N, greater<int>())   // descend
//sort(a, a+N)                    //  ascend

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll cnt = 0;
	ll pp = GCD(c, d);
	ll ppp = c * d / pp;
	cnt = b / c - (a-1) / c + b / d - (a-1) / d - b / ppp + (a-1)/ppp;

	
	cout << b - a + 1 - cnt;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  ll N; cin >> N;
  ll p = 5;
  if (N%2==0){
    ll ans = 0;
    while (2*p<=N){
      ans += N/2/p;
      p *= 5;
    }
    cout << ans << endl;
  }
  else cout << 0 << endl;


  // cout << fixed << setprecision(10);
  
  return 0;
}


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

int main() {
  int n;cin>>n;
  vector<int>h(n);
  rep(i,n)cin>>h[i];
  int ans=0,cnt=0;
  rep(i,n-1){
    if(h[i]<h[i+1])cnt=0;
    else cnt++;
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3748
import sys
sys.setrecursionlimit(1000000) # 再帰上限を増やす

def main():
    input = sys.stdin.readline  # 文字列に対してinputした場合は、rstripするのを忘れずに！
    ticket = input().rstrip()
    N = 4
    num_list = []
    for num in ticket:
        num_list.append(int(num))

    for bit in range(1 << (N-1)):
        sum_value = num_list[0]
        op_list = [None] * N

        for i in range(N-1):
            if bit & (1 << i):
                # +を入れるパターン
                op_list[i] = "+"
                sum_value += num_list[i+1]
            else:
                # -を入れるパターン
                op_list[i] = "-"
                sum_value -= num_list[i+1]

        if sum_value == 7:
            op_list[3] = "="
            for num, op, in zip(num_list, op_list):
                print(num, op, sep="", end="")
            print(7)
            exit()

if __name__ == '__main__':
    main()

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

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

using namespace std;

int main(){
    int N;
    cin >> N;
    if(N == 1){
        cout << "Hello World" << endl;
        return 0;
    }
    int A, B;
    cin >> A >> B;
    cout << A+B << endl;
    return 0;
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

int mm[30001][10];

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;

    for(int i = 0; i < 10; i++){
        int ip = -1;
        for(int l = 0; l < n; l++){
            if(s[l]-'0' == i){
                ip = l;
                break;
            }
        }
        if(ip == -1) continue;
        for(int j = 0; j < 10; j++){
            int jp = -1;
            for(int l = ip+1; l < n; l++){
                if(s[l]-'0' == j){
                    jp = l;
                    break;
                }
            }
            if(jp == -1) continue;
            for(int k = 0; k < 10; k++){
                int kp = -1;
                for(int l = jp+1; l < n; l++){
                    if(s[l]-'0' == k){
                        ans += 1;
                        break;
                    }
                }
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int h,n;
    cin >> h >> n;

    for(int i = 0; i< n; ++i)
	{
		int x;
		cin >> x;
		h-=x;
		if(h <= 0)
		{
			cout << "Yes";
			return 0;
		}
	}

	cout << "No";
    return 0;
}

Measured memory_bytes: 256
# 最小公倍数
# ユークリッドの互除法
def lcm(a, b): 
    def gcd(a, b):  # a >= b
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    return a * b // gcd(a, b)

N = int(input())
T = [0]*N
for i in range(N):
    T[i] = int(input())

ans = 1
for i in range(N):
    ans = lcm(ans, T[i])
print(ans)


Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<ll> x(n), y(n), h(n);
  for(int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> h[i];
  }
  for(int i = 0; i <= 100; i++) {
    for(int j = 0; j <= 100; j++) {
      int idx = 0;
      while(h[idx] == 0) {
        idx++;
      }
      ll tmpH = abs(i - x[idx]) + abs(j - y[idx]) + h[idx];
      bool ok = true;
      for(int k = 0; k < n; k++) {
        if(h[k] == max(tmpH - abs(i - x[k]) - abs(j - y[k]), (ll)0)) {
          continue;
        } else {
          ok = false;
          break;
        }
      }
      if(ok) {
        cout << i << " " << j << " " << tmpH << '\n';
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  
  int a, b, c;
  a = n % 10;
  b = (n - a) / 10 % 10;
  c = (n - b * 10 - a) / 100;
  
  if(a == 7 || b == 7 || c == 7){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3648
s = input()
count = 0
al = "qwertyuiopasdfghjklzxcvbnm"
al_list = [i for i in al]
al_list.sort()
for i in al_list:
    if i not in s:
        print(i)
        break
    else:
        count += 1
if count == len(al_list):
    print("None")

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

ll N, K;
vector<ll> F, S;

main()
{
    cin >> N >> K;
    vector<pair<ll, ll>> v;
    for (ll i = 0; i < N; i++)
    {
        ll t, d;
        cin >> t >> d;
        v.push_back(make_pair(t, d));
    }
    map<ll, ll> mp;
    sort(v.rbegin(), v.rend());
    for (ll i = 0; i < v.size(); i++)
    {
        pair<ll, ll> p = v[i];
        if (mp[p.first] == 0)
            F.push_back(p.second);
        else
            S.push_back(p.second);
        mp[p.first]++;
    }
    sort(F.rbegin(), F.rend());
    sort(S.rbegin(), S.rend());
    ll sum = 0, ans = 0, L = F.size();
    for (ll i = 0; i < min(K, L); i++)
    {
        sum += F[i];
    }
    if (K > L)
    {
        ll check = 0;
        for (ll i = 0; i < K - L; i++)
        {
            sum += S[i];
            check = i;
        }
        check++;
        ans = sum + L * L;
        for (ll j = L - 1; j > 0 && check < S.size(); j--)
        {
            sum -= F[j];
            sum += S[check];
            check++;
            ans = max(ans, sum + j * j);
        }
        cout << ans << endl;
    }
    else
    {
        ans = sum + K * K;
        for (ll i = 0; i < K - 1 && i < S.size(); i++)
        {
            sum -= F[K - 1 - i];
            sum += S[i];
            ans = max(ans, sum + (K - i - 1) * (K - i - 1));
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 8816
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)
#define clz(n)				__builtin_clzll(n))

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int n;
	cin>>n;
	vi a(n), b(n), c(n);
	for(int i=0;i<n;i++ ) cin>>a[i]>>b[i]>>c[i];
	vii dp(n,vi(3));
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for(int i=0;i<n-1;i++) {
			dp[i+1][0] = a[i+1]+max(dp[i][1],dp[i][2]);
			dp[i+1][1] = b[i+1]+max(dp[i][0],dp[i][2]);
			dp[i+1][2] = c[i+1]+max(dp[i][1],dp[i][0]);
	}
	cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
	return 0;
}





Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define debug(x) cerr << #x " = " << (x) << endl;
#define P(x) cerr << #x << endl;    
#define int long long
typedef pair<int, int> pii;
const int mod = 1000000007;


int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(9);
    
    
    int n;
	cin >> n;
	vector<int> h(n + 10);
	vector<int> dp(n + 10);
	for(int i = 1; i <= n; ++ i)
	{
		cin >> h[i];
	}
	dp[1] = 0;
	dp[2] = abs(h[2] - h[1]);
	for(int i = 3; i <= n; ++ i)
	{
		dp[i] = 1e18;
		for(int j = 1; j <= 2; ++ j)
		{
			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}
	cout << dp[n] << endl;
    
    return 0;
}






Measured memory_bytes: 1792
n=int(input())
alist=[0]*n
for i in range(n):
  a,b=map(int, input().split())
  if a==b:
    if i==0:
      alist[0]=1
    else:
      alist[i]=alist[i-1]+1
if max(alist)>=3:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9168
#include<stdio.h>
int main(){
  int q,a,b,r,n,m,p[10010]={0};
  scanf("%d %d",&n,&m);
  while(m--){
    scanf("%d %d %d",&q,&a,&b);
    for(r=++a;p[r];r=p[r]);
    for(;n=p[a];a=n)p[a]=r;
    for(r=++b;p[r];r=p[r]);
    for(;n=p[b];b=n)p[b]=r;
    if(q)printf("%d\n",a-b?0:1); 
    else if(a-b)p[a]=b;
  }
  return 0;
}
	 

Measured memory_bytes: 648
#include <stdio.h>

int main(void)
{
	int A, B, C, D, P;
	int x;
	int y;
	
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	scanf("%d", &D);
	scanf("%d", &P);
	
	x = P * A;
	
	if (P > C){
		y = B + (P - C) * D;
	}
	else if (P <= C){
		y = B;
	}
	
	if (x < y){
		printf("%d", x);
	}
	else {
		printf("%d", y);
	}
	printf("\n");
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll a,b,c,d;
ll N;

int main(){
    cin >> a >> b >> c >> d;
    cin >> N;

    ll t = min(a*8,min(b*4,min(c*2,d)));

    ll ans = 0;
    ans += N/2*t;
    
    N = N % 2;
    t = min(a*4,min(b*2,c));

    ans += N * t;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define f first
#define s second
#define ld long double
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

vvint g;
vint cost;
vector<bool> seen;
void dfs(int v=0){
    seen[v]=true;
    for(int nv:g[v]){
        if(seen[nv]==true) continue;
        cost[nv]+=cost[v];
        dfs(nv);
    }
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,q; cin >> n >> q;
    g.resize(n);
    seen.resize(n);
    rep(i,n-1){
        int a,b; cin >> a >> b;
        a--; b--;
        g[a].PB(b);
        g[b].PB(a);
    }
    cost.resize(n);
    rep(i,q){
        int node,c;
        cin >> node >> c;
        cost[node-1]+=c;
    }
    dfs();
    rep(i,n) cout<<cost[i]<<' '; cout<<endl;
}

Measured memory_bytes: 24320
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair < llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗を1000000007で割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, b / 2);
	tmp *= tmp;
	tmp %= 1000000007;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= 1000000007;
	}
	return tmp;
}

int main() {
	int n;
	cin >> n;
	cout << n * n * n << endl;
	return 0;
}


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

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

	if(abs(a-b)%2==0)
	{
		cout<<(abs(a-b))/2<<endl;
	}
	else
	{
		long long a1 = min(a-1,b-1);

		long long a2 = max(a-1,b-1);
		long long d1 = a1 + 1 + (a2-a1-1)/2;

		a1 = min(n-a,n-b);
		a2 = max(n-a,n-b);

		long long d2 = a1 + 1 + (a2-a1-1)/2;

		cout<<min(d1,d2)<<endl;
	}

	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

void solve() {
	int n, W; cin >> n >> W;
    vector<int> w(n), v(n);
    rep(i, n) {
        cin >> w[i] >> v[i];
    }
    vector<vector<int>> dp(n + 1, vector<int>(W + 1, 0));
    rep(i, n) {
        for(int j = 0; j <= W; ++j) {
            if(j - w[i] < 0) dp[i + 1][j] = dp[i][j];
            else dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
        }
    }
    cout << dp[n][W] << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n;
    cin>>n;
    vector<LP> rs(n), bs(n);
    cin>>rs>>bs;
    sort(rng(rs));
    sort(rng(bs));

    vector<bool> used(n);
    ll cnt = 0;
    rep(i, n) {
        LP b = bs[i];
        ll bx = b.fi;
        ll by = b.se;

        ll m = -1;
        ll mj = -1;
        rep(j, n) {
            if (used[j]) continue;

            LP r = rs[j];
            ll rx = r.fi;
            ll ry = r.se;

            if (rx > bx) break;
            if (ry > m && ry < by) {
                m = ry;
                mj = j;
            }
        }
        if (mj != -1) {
            used[mj] = true;
            cnt++;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
a, v = list(map(int,input().strip().split()))
b, w = list(map(int,input().strip().split()))
t = int(input())

if w - v >= 0:
  print("NO")
else:
  time = abs(a-b)/(v-w)
  if time <= t:
    print("YES")
  else:
    print("NO")

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

using namespace std;

int main() {
    vector<int> ns = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << ns[k - 1] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  int ans = 0;
  for(int i = 0; i < N; ++i) {
    int a; std::cin >> a;
    if(i%2 == 0 && a%2 == 1) ++ ans;
  }
  fin(ans);
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define Rrep(i,n) for(int i=((int)n-1); i>=0; i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e15
#define MOD 1000000007

typedef vector<int> vint;
typedef long long ll;



int main()
{
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(15);

        int s;
        cin >> s;
        vector <ll> dp(s+1,0);
        dp[0] = 1;

        for(int i = 3 ; i <= s ; i++){
                int j = i-3;
                while(j>=0){dp[i] += dp[j]; j--;}
                dp[i] %= MOD;
        }

        /*rep(i,s){
                cout << dp[i] <<endl;
        }*/

        cout << dp[s] << endl;

        return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep1(i, h) cin >> s[i];
    vector<P> G;
    G.push_back(make_pair(1, 0));
    G.push_back(make_pair(-1, 0));
    G.push_back(make_pair(0, 1));
    G.push_back(make_pair(0, -1));
    ll ans = 0;
    rep1(i, h) rep1(j, w){
        vector<vector<ll> > dist(h, vector<ll>(w, -1));
        queue<P> que;
        if (s[i][j]=='.'){
            dist[i][j] = 0; que.push(make_pair(i, j));
            while (!que.empty()){
                P v = que.front(); que.pop();
                ans = max(ans, dist[v.first][v.second]);
                for (auto nv: G){
                    ll x = v.first+nv.first, y = v.second+nv.second;
                    if (x>=0 && x<h && y>=0 && y<w && s[x][y]=='.' && dist[x][y]==-1){
                        dist[x][y] = dist[v.first][v.second] + 1;
                        que.push(make_pair(x, y));
                    }
                }
            }
        }
    }
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 3580
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

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

        int H = sc.nextInt();
        int W = sc.nextInt();
        char[][] grid = new char[H][W];
        for (int r = 0; r < H; ++r) {
            String line = sc.next();
            for (int c = 0; c < W; ++c) {
                grid[r][c] = line.charAt(c);
            }
        }

        System.out.println(solve(grid));

        sc.close();
    }

    static String solve(char[][] grid) {
        List<Integer> rowIndices = new ArrayList<>();
        List<Integer> colIndices = new ArrayList<>();

        for (int r = 0; r < grid.length; ++r) {
            for (int c = 0; c < grid[0].length; ++c) {
                if (grid[r][c] == '#') {
                    rowIndices.add(r);
                    colIndices.add(c);
                }
            }
        }

        rowIndices = rowIndices.stream().distinct().sorted().collect(Collectors.toList());
        colIndices = colIndices.stream().distinct().sorted().collect(Collectors.toList());

        char[][] result = new char[rowIndices.size()][colIndices.size()];
        for (int r = 0; r < rowIndices.size(); ++r) {
            for (int c = 0; c < colIndices.size(); ++c) {
                result[r][c] = grid[rowIndices.get(r)][colIndices.get(c)];
            }
        }

        return Arrays.stream(result).map(String::new).collect(Collectors.joining("\n"));
    }
}

Measured memory_bytes: 38488
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
#define int long long
#define maxn 200005
using namespace std;

const int INF = 1e9;

struct ZKW {
    vector<pair<int, int>> arr; int n;
    ZKW(int sz) : arr(sz * 2, make_pair(INF, 0)), n(sz) {}
    void upd(int x, pair<int, int> v) {
        for(arr[x += n] = v; x > 1; x >>= 1) {
            arr[x >> 1] = min(arr[x], arr[x ^ 1]);
        }
    }
    pair<int, int> ask(int l, int r) {// [l, r]
        pair<int, int> ret(INF, 0); r++;
        for(l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if(l & 1) ret = min(ret, arr[l++]);
            if(r & 1) ret = min(ret, arr[--r]);
        }
        return ret;
    }
};

ZKW LR(maxn), BT(maxn);
int n, k;

int solve(int l, int r, int b, int t) {
    if(r < l || t < b) return 0;
    //printf("%lld %lld %lld %lld\n", l, r, b, t);
    int ret = 0;
    auto A = b == 2 ? LR.ask(l, r) : make_pair(INF, 0LL);
    auto B = l == 2 ? BT.ask(b, t) : make_pair(INF, 0LL);
    //printf("%lld %lld\n", A.second, B.second);
    if(min(A, B).first == INF) return (r - l + 1) * (t - b + 1);
    if(A < B) { // L, R
        ret += solve(l, A.second - 1, b, t);
        ret += solve(A.second + 1, r, b, t);
    }
    else { // B, T
        ret += solve(l, r, b, B.second - 1);
        ret += solve(l, r, B.second + 1, t);
    }
    return ret;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> k;
    vector<pair<int, int>> v;
    for(int i = 0; i < k; i++) {
        int op, x; cin >> op >> x;
        if(op == 1) LR.upd(x, {i, x});
        else BT.upd(x, {i, x});
    }
    cout << solve(2, n - 1, 2, n - 1) << '\n';
    return 0;
}


Measured memory_bytes: 37328
// 2013/11/10 Tazoe

#include <iostream>
using namespace std;

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

	bool S[100][3];
	for(int i=0; i<N; i++){
		for(int j=0; j<3; j++){
			S[i][j] = true;
		}
	}

	for(int i=0; i<K; i++){
		int A, B;
		cin >> A >> B;

		if(B==1){
			S[A-1][1] = S[A-1][2] = false;
		}
		else if(B==2){
			S[A-1][0] = S[A-1][2] = false;
		}
		else if(B==3){
			S[A-1][0] = S[A-1][1] = false;
		}
	}

	int DP[100][3];
	for(int i=0; i<N; i++){
		for(int j=0; j<3; j++){
			DP[i][j] = 0;
		}
	}

	for(int j=0; j<3; j++){
		if(!S[0][j])
			continue;

		DP[0][j] = 1;
	}

	for(int j=0; j<3; j++){
		if(!S[1][j])
			continue;

		int s = 0;
		for(int k=0; k<3; k++){
			s += DP[0][k];
		}

		DP[1][j] = s;
	}

	for(int i=2; i<N; i++){
		for(int j=0; j<3; j++){
			if(!S[i][j])
				continue;

			int s = 0;
			for(int k=0; k<3; k++){
				s += DP[i-1][k];
			}

			DP[i][j] = s%10000;

			if(S[i-1][j]){
				int t = 0;
				for(int k=0; k<3; k++){
					if(j==k)
						continue;

					t += DP[i-2][k];
				}

				DP[i][j] = (DP[i][j]-(DP[i-1][j]-t+20000)+30000)%10000;
			}
		}
	}
/*
	for(int i=0; i<N; i++){
		for(int j=0; j<3; j++){
			cout << DP[i][j] << ' ';
		}
		cout << endl;
	}
*/

	int s = 0;
	for(int j=0; j<3; j++){
		s += DP[N-1][j];
	}

	cout << s%10000 << endl;

	return 0;
}

Measured memory_bytes: 1160