akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    char c;
    cin >> c;

    if('a' <= c && c <= 'z') {
        cout << 'a' << endl;
    } else {
        cout << 'A' << endl;
    }

    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
long inf = 1000000007;

int main() {
    int n, m; cin >> n >> m;
    int count = 0;
    if (n >= 2) {
        count += n * (n - 1) / 2;
    }
    if (m >= 2) {
        count += m * (m - 1) / 2;
    }

    cout << count << endl;
}


    


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

int main(){
	int n;
	while(cin >> n){
		int a[1005];
		bool f = true;
		for(int i = 1; i <= n; i++){
			int x;
			cin >> x;
			if(x % 2 == 0){
				if(x % 3 != 0 && x % 5 != 0)
				    f = false;				
			}
		}
		if(f) printf("APPROVED\n");
		else printf("DENIED\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 6700417
#define h2 1777771
using namespace std;
int H[N];

int CtoN(char c){
  if(c == 'A') return 1;
  if(c == 'C') return 2;
  if(c == 'G') return 3;
  return 4;
}

int StoN(char str[]){
  int n = strlen(str);
  int res = 0;
  for(int i=0;i<n;i++)
    res = res*5 + CtoN(str[i]);
  return res;
}



void Insert(char str[],int i){
  int k = StoN(str);
  int hash = k%N;
  while(H[hash] != 0) hash = (hash + k%h2)%N;
  H[hash] = i;
}

char S[1000001][11];
bool Find(char str[]){
  int k = StoN(str);
  int hash = k%N;
  while(H[hash]){
    if(strcmp(str,S[H[hash]]) == 0) return 1;
    hash = (hash+k%h2)%N;
  }
  return 0;
}

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

  for(int i=1;i<=n;i++){
    char q[11]; 
    scanf("%s %s",q,S[i]);
    if(q[0] == 'i') Insert(S[i],i);
    else printf("%s\n",(Find(S[i])? "yes":"no"));
  }
  
  return 0;
}

Measured memory_bytes: 37168
#include <stdio.h>
#define MAX 2000000
 
int size,A[MAX+1];
 
void max(int i)
{
  int l,r,largest,t;
 
  l=2*i;
  r=2*i+1;
  if(l<=size && A[l]>A[i]) largest=l;
  else largest = i;
  if(r<=size&&A[r]>A[largest]) largest = r;
  if(largest != i)
    {
      t=A[i];A[i]=A[largest];A[largest]=t;
      max(largest);
    }
}
 
int extract()
{
  int maxv;
  if(size<1) return 0; 
  maxv=A[1];
  A[1]=A[size--];
  max(1);
  return maxv;
}
 
void increase(int i,int key)
{
  int tmp;
  if(key<A[i]) return;
  A[i]=key;
  while(i>1&&A[i/2]<A[i])
  {
    tmp=A[i];
    A[i]=A[i/2];
    A[i/2]=tmp;
    i=i/2;
  }
}
 
void insert(int key)
{
  size++;
  A[size]=-1000000001;
  increase(size,key);
}
 
int main ()
{
  int key;
  char com[20];
 
  while(1)
  {
    scanf("%s",com);
    if(com[0]=='i')
    {
      scanf("%d",&key);
      insert(key);
    }
    else if (strcmp(com,"extract")==0)
    {
     printf("%d\n",extract());
   }
    else break;
    }
 
  return 0;
}


Measured memory_bytes: 5700
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
    //ios_base::sync_with_stdio(false);
    string tmp[4] = {"AC", "WA", "TLE", "RE"} ;
    ll t;
    cin>>t;
     map<string, ll>mp;
    while(t--)
    {
       string s;
        cin>>s;
        mp[s]++;
    }
    for(int i=  0; i < 4; i ++) cout<<tmp[i]<<" x "<<mp[tmp[i]]<<"\n";
    return 0;
}


Measured memory_bytes: 3628
import scala.io.StdIn.readLine
import scala.collection.mutable.Queue

object Main extends App {
  val l = readLine.split(" ").map(_.toInt)
  val q = new Queue[(String,Int)]
  var total = 0

  for(i<-0 until l(0)) {
    val m = readLine.split(" ")
    q += ((m(0), m(1).toInt))
  }

  while(!q.isEmpty) {
    val (p,t) = q.dequeue
    if(t>l(1)) {
      q += ((p,t-l(1)))
      total += l(1)
    } else {
      println(p + " " + (t+total))
      total += t
    }
  }
}

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

int main(){
	int w;
	while(cin >> w , ~w){
		int ans = 1150;
		ans += max(0,min(10,w-10)*125);
		ans += max(0,min(10,w-20)*140);
		ans += max(0,(w-30)*160);
		cout << 4280-ans << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i] ;
    }
    vector<int> B(N);
    for(int i=0;i<N;i++){
        B[A[i]-1]=i;
    }
    for(int i=0;i<N;i++){
        if(i<N-1){
            cout << B[i]+1 << " ";
        }
        else{
            cout << B[i] + 1 << endl;
        }
    }
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
#include <time.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
const long double PI=3.14159265358979;
const ll MAX=0;

int main() {
  ll D,ans=0;
  cin>>D;
  ll c[26];
  ll s[D][26];
  rep(i,26){
    cin>>c[i];
    //c[i]=0;
  }
  rep(i,D){
    rep(j,26){
      cin>>s[i][j];
      //s[i][j]=1;
    }
  }
  ll t[D];
  rep(i,D){
    t[i]=i%26;
  }
  
  
  ll satis=0;
  rep(i,D){
    ll last[26];
    rep(j,26){
      last[j]=-1;
    }
    satis=0;
    satis+=s[i][t[i]];
    last[t[i]]=i;
    rep(j,26){
      satis-=c[j]*(i-last[j]);
    }
  }
  
  ans=satis;
  while(clock()<1900000){
    ll w=rand()%365,u=rand()%26;
    satis=0;
    ll last[26];
    rep(i,26){
      last[i]=-1;
    }
    ll g=t[w];
    t[w]=u;
    rep(i,D){
      satis+=s[i][t[i]];
      last[t[i]]=i;
      rep(j,26){
        satis-=c[j]*(i-last[j]);
      }
      
    }
    if(ans>satis){
      t[w]=g;
    }
    ans=max(ans,satis);
  }
  rep(i,D){
    cout<<t[i]+1<<endl;
    
  }
  //cout<<ans;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
          using namespace std;
          #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
          #define M_PI 3.14159265358979323846
          #define data data_
          #define ff first
          #define ss second
          int const N = 101;
          int const K = 100009;
          long long const mod = 1e9+7;
          int a[N];
          long long dp[N][K];
          int main()
          {
          // clock_t begin = clock();
          // #ifndef ONLINE_JUDGE
          // freopen("input.txt", "r", stdin);
          // freopen("output.txt", "w", stdout);
          // #endif
          tani_nachi_ke  

          int n,k;
          cin >> n >> k;
          memset(dp, 0 ,sizeof(dp));
          for(int i = 1; i <= n; i++)
               cin >> a[i];
          dp[0][0] = 1;
          long long sum[k+2] = {0};
          for(int l = 0; l <= k; l++)
               sum[l+1] = (sum[l] + dp[0][l])%mod;
          for(int i = 1; i <= n; i++)
          {
               for(int l = 0 ; l <= k; l++)
               {
                    dp[i][l] = (sum[l+1] - sum[max(0,l-a[i])] + mod)%mod;
               }
               for(int l = 0; l <= k; l++)
                    sum[l+1] = (sum[l] + dp[i][l])%mod;
              
          }
          cout << dp[n][k] << endl;




          // #ifndef ONLINE_JUDGE 
          // clock_t end = clock();
          // cout<<endl<<double(end - begin) / CLOCKS_PER_SEC*1000<<" ms";
          // #endif 
          // return 0;
          }

Measured memory_bytes: 80000
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        s: chars,
    }
    if n % 2 != 0 {
        println!("No");
        return;
    }
    let mut ok = true;
    for i in 0..(n / 2) {
        if s[i] != s[n / 2 + i] {
            ok = false;
            break;
        }
    }
    if ok {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define INF 200200200200

vector<double> dijk(int s, int v, vector<vector<pair<double, int> > > adjlist){
    
    priority_queue <pair<double, int> > wait;
    vector<double> result(v, INF);

    //スタート地点を追加
    result[s] = 0.0;
    wait.push(make_pair(0.0, s));

    //ダイクストラ本体
    while(!wait.empty()){    //waitが空になるまで

        int nowpoint = wait.top().second;
        double nowcost = -wait.top().first;
        wait.pop();

        if(result[nowpoint] < nowcost) continue;


        //今いる頂点と隣接しているすべての頂点をなめる
        for(int i = 0; i < adjlist[nowpoint].size(); i++){

            int nextpoint = adjlist[nowpoint][i].second;
            double nextcost = nowcost + adjlist[nowpoint][i].first;
            //現時点より安く到達できそうであれば、結果を更新して優先度付きキューに格納
            if(result[nextpoint] > nextcost){
                result[nextpoint] = nextcost;
                wait.push(make_pair(-nextcost, nextpoint));
            }
        }
    }
    
    return result;         //結果列を返す
}

int main(){

    while(1){
        int n, m, p, a, b; cin >> n >> m >> p >> a >> b;
        a--;
        b--;
        if(!n) break;
        vector<int> t(n);
        for(int i = 0; i < n; i++) cin >> t[i];

        vector<vector<pair<int, int> > > edge(m);
        
        for(int i = 0; i < p; i++){
            
            int aa, bb, cc; cin >> aa >> bb >> cc;
            aa--;
            bb--;
            edge[aa].push_back({cc, bb});
            edge[bb].push_back({cc, aa});            
        }

        vector<vector<int> > Map(m, vector<int> ((1 << n)));

        int cnt = 0;
        for(int i = 0; i < m; i++){
            for(int j = 0; j < (1 << n); j++){
                Map[i][j] = cnt;
                cnt++;
            }
        }

        vector<vector<pair<double, int> > > adjlist(cnt);

        for(int i = 0; i < m; i++){
            for(int bit = 1; bit < (1 << n); bit++){

                int now_node = Map[i][bit];

                for(int j = 0; j < edge[i].size(); j++){
                    
                    for(int k = 0; k < n; k++){

                        //馬車券がなかったらcontinue
                        if(!(bit & (1 << k))) continue;
                        int uma = t[k];
                        int next_bit = bit & (~(1 << k));
                        double cost = (double)edge[i][j].first / uma;
                        int next_node = edge[i][j].second;
                        next_node = Map[next_node][next_bit];

                        adjlist[now_node].push_back({cost, next_node});
                    }

                }
                
            }
        }

        vector<double> result(cnt);
        int S = Map[a][(1 << n) - 1];
        result = dijk(S, cnt, adjlist);

        double ans = INF;
        for(int bit = 0; bit < (1 << n); bit++){
            int G = Map[b][bit];
            ans = min(ans, result[G]);
        }

        if(ans == INF) cout << "Impossible" << endl;
        else printf("%f\n", ans); //<< endl;

        /*for(int i = 0; i < V; i++){
            cout << i << ": " << result[i] << endl;
        }*/

    }

}


Measured memory_bytes: 38912
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const ll mo = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N, M, S, T;
vector<pii> E[100009];
ll D[2][100009], pat[2][100009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N>>M>>S>>T;
    S--; T--;
    rep(i,M){
        int u,v,c; cin>>u>>v>>c;
        u--; v--;
        E[u].push_back({v,c});
        E[v].push_back({u,c});
    }
    
    priority_queue<pair<ll,int>> P;
    pat[0][S]=pat[1][T]=1;
    rep(i,N) D[0][i]=D[1][i]=1LL<<60;
    D[0][S]=D[1][T]=0;
    P.push({0,S});
    P.push({0,T+100000});
    
    while(P.size()){
        int cur=P.top().second%100000;
        int id=P.top().second/100000;
        ll co=-P.top().first;
        P.pop();
        if(D[id][cur]!=co) continue;
        for(auto& e:E[cur]){
            if(co+e.second<D[id][e.first]){
                pat[id][e.first]=0;
                D[id][e.first]=co+e.second;
                P.push({-D[id][e.first],id*100000+e.first});
            }
            if(co+e.second==D[id][e.first]) (pat[id][e.first]+=pat[id][cur])%=mo;
        }
    }
    
    ll tot=pat[0][T]*pat[0][T]%mo;
    rep(i,N) if(D[0][i]+D[1][i]==D[0][T]){
        if(D[0][i]==D[1][i]){
            tot+=mo-pat[0][i]*pat[0][i]%mo*pat[1][i]%mo*pat[1][i]%mo;
        }
        if(D[0][i]<D[1][i]){
            for(auto& e:E[i]) if(D[0][e.first]+D[1][e.first]==D[0][T]&&D[0][e.first]>D[1][e.first]&&D[0][e.first]==D[0][i]+e.second){
                tot+=mo-pat[0][i]*pat[0][i]%mo*pat[1][e.first]%mo*pat[1][e.first]%mo;
            }
        }
        tot%=mo;
    }
    cout1(tot);
}

Measured memory_bytes: 16112
// 選択ソート
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

static const int MAX_N = 36;

// 選択ソートを実施する関数
void selectionSort(vector<string> &A, int n);
// バブルソートを実施する関数
void bubbleSort(vector<string> &A, int n);

void print_method(vector<string> &A, int n);
void check_stable( vector<string> &in, vector<string> &out, int n );

int main(void)
{
    int N;
    vector<string> ary_string_1(MAX_N);

    cin >> N;

    for(int i = 0; i < N; i++)
    {
        cin >> ary_string_1[i];
    }

    // 配列の要素をコピー (コピーコンストラクタ)
    vector<string> ary_string_2(ary_string_1);

    bubbleSort(ary_string_1, N);
    selectionSort(ary_string_2, N);

    return 0;
}

// 選択ソートを実施する関数
void selectionSort(vector<string> &str, int n)
{

	//cout << "選択ソート" << endl;

	// コピーコンストラクタ
	vector<string> base_str(str);

    int count = 0;
    // 最小値の存在する配列の要素No.
    int min_pos;

    for(int i = 0; i < n - 1; i++)
    {
        min_pos = i;

        for(int j = i; j < n; j++)
        {

            if( str[j][1] < str[min_pos][1] )
            {
                // 最小値の存在する位置を保存する
                min_pos = j;
            }
        }

        if( i != min_pos )
        {
            // 最小値を交換する
            swap(str[i], str[min_pos]);

            count++;
        }
    }

    // 結果を表示する
    print_method(str, n);
    check_stable(base_str, str, n);

    return;
}

// バブルソートを実施する関数
void bubbleSort(vector<string> &str, int n)
{
	//cout << "バブルソート" << endl;

	// コピーコンストラクタ
	vector<string> base_str(str);

    int count = 0, j = 0;
    bool flag = true;

    string tmp;

    while( flag )
    {
        flag = false;

        for(int i = n - 1; i > j; i--)
        {

            if( str[i - 1][1] > str[i][1] )
            {
                // 値の入れ替え
                tmp = str[i];
                str[i] = str[i - 1];
                str[i - 1] = tmp;

                flag = true;

                // 交換回数の保存
                count++;
            }
        }

        j++;
    }

    	// 結果を表示する
    print_method(str, n);
    check_stable(base_str, str, n);

    return;
}

// 安定なソートかの判定
void check_stable( vector<string> &in, vector<string> &out, int n )
{
	bool ret = true;

	for(int i = 0; i < n; i++)
    {
        for(int j = i + 1; j < n; j++)
        {
            for(int a = 0; a < n; a++)
            {
                for(int b = a + 1; b < n; b++)
                {
                    if( in[i][1] == in[j][1]
                            && in[i] == out[b] && in[j] == out[a] )
                    {
                        ret = false;
                    }
                }
            }
        }
    }

	if(ret == true)
	{
		cout << "Stable" << endl;
	}
	else
	{
		cout << "Not stable" << endl;
	}
	return;
}

// 結果表示用
void print_method(vector<string> &A, int n)
{

    for(int i = 0; i < n; i++)
    {
       if( i )
       {
           cout << ' ';
       }

       cout << A[i];
    }

    cout << endl;

}



Measured memory_bytes: 3172
#include<stdio.h>
#include<stdlib.h>
#define k 10001
void CountingSort(int *, int *, int);
main(){
  int n, i;
  int *A, *B;
  scanf("%d", &n);
  A = (int *)malloc(sizeof(int)*n);
  if(A == NULL) exit(1);
  B = (int *)malloc(sizeof(int)*n);
  if(B == NULL) exit(2);
  
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
  CountingSort(A, B, n);
  for(i = 0; i < n; i++){
    if(i == 0) printf("%d",  B[i]);
    else       printf(" %d", B[i]);
  }
  printf("\n");
  free(A);
  free(B);
  return 0;
}

void CountingSort(int *A, int *B,int n){
  int i;
  int C[k];
  for(i = 0; i < k; i++){
    C[i] = 0;
  }
  for(i = 0; i < n; i++){
    C[A[i]]++;
  }
  for(i = 1; i < k; i++){
    C[i] = C[i]+C[i-1];
  }
  for(i = n; i >= 1; i--){
    B[ C[A[i-1]]-1 ] = A[i-1];
    C[A[i-1]]--;
  }
}

Measured memory_bytes: 16056
import java.util.*;

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

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

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

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

    /**
     * https://atcoder.jp/contests/abc142/submissions/7746549
     * AとBで共通する素数の約数の個数+1が解
     * @param A
     * @param B
     * @return
     */
    private static int solve(long A, long B) {
        int count = 1;
        List<Pair> primeFactorA = primeFactorize(A);

        for (Pair p : primeFactorA) {
            System.err.println(p.first + " ** " + p.second);
            if (B%p.first == 0) {
                count++;
            }
        }

        return count;
    }

    public static class Pair {
        long first;
        long second;

        public Pair(long a, long b) {
            this.first = a;
            this.second = b;
        }
    }

    private static List<Pair> primeFactorize(Long N) {
        List<Pair> list = new ArrayList();
        

        for (long p=2; p*p <= N; p++) {
            if (N%p != 0) continue;
            int num = 0;
            while (N%p == 0) {
                num++;
                N /= p;
            }

            list.add(new Pair(p, num));
        }
        if (N != 1) {
            list.add(new Pair(N, 1));
        }

        return list;
    }
}

Measured memory_bytes: 23252
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int x1, y1, x2, y2;
  scanf("%d %d %d %d", &x1, &y1, &x2, &y2);

  int dx = x2 - x1;
  int dy = y2 - y1;
  int x3 = x2 - dy;
  int y3 = y2 + dx;
  int x4 = x3 - dx;
  int y4 = y3 - dy;
  printf("%d %d %d %d\n", x3, y3, x4, y4);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  int n;
  cin>>n;
  vp a(n*2);
  rep(i,n*2) {
    int x,y;
    scanf("%d%d",&x,&y);
    a[x] = P(y,i<n);
  }
  set<int> s;
  int ans = 0;
  rep(i,n*2) {
    int x = a[i].fi;
    if (a[i].se) {
      s.insert(x);
    } else {
      auto it = s.lower_bound(x);
      if (it != s.begin()) {
        --it;
        s.erase(it);
        ++ans;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define M                    1000000007
#define pi                   3.14159265358979323846
#define cel(x,a)             (x+a-1)/a
#define ll                   long long
#define pii                  pair<int, int>
#define pll                  pair<ll, ll>
#define vi                   vector<int>
#define vl                   vector<ll>
#define vpi                  vector<pii>
#define vpl                  vector<pll>
#define pb                   push_back
#define lb                   lower_bound
#define ub                   upper_bound
#define ps(x,y)              fixed<<setprecision(y)<<x
#define pf(x,y)              setfill('x')<<setw(y)
#define mp                   make_pair
#define F                    first
#define S                    second
/*.*Ashish_akj*.*/
#define lcm(m,n)             (m/__gcd(m,n))*n
#define all(v)               v.begin(), v.end()
using namespace std;
const int N = 2e6 + 4;
/*
int ncr(int n, int r) 
{ 
    long long p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 

    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            long long m = __gcd(p, k); 
            p /= m; 
            k /= m; 

            n--; 
            r--;
        }
    } 

    else
        p = 1; 
    return p;
} */
/*vector<bool>visited;
 vector<vector<int>>adj;
void dfs(int v)
{visited[v]=true;
for(int i:adj[v])
{if(!visited){dfs(i);}
}}
*/
int main()
{ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;cin>>n;int ans=0;
for(int i=1; i<n; i++)
{
    int p=(n-1)/i;
    ans+=p;
}
cout<<ans;
    return 0;
}




Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <utility>

int main()
{
        int a, b, c;
        std::cin >> a >> b >> c;
        int min = std::min(a, std::min(b, c));
        int max = std::max(a, std::max(b, c));
        std::cout << (max - min) << "\n";
}

Measured memory_bytes: 256
#include<cstdio>
#include<map>

using namespace std;

int n;
int a[200005];
long long ans;
map<int, int> m;

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    m[i - a[i]]++;
  }
  for (int i = 0; i < n; i++) {
    m[i - a[i]]--;
    ans += m[i + a[i]];
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 21168
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}
			int sum = 0;
			for(int i = 0;i < n*(n-1)/2;i++){
				sum += scan.nextInt();
			}
			System.out.println(sum/(n-1));
		}
	}
}

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;

ll gcd(ll a,ll b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll K; cin >> K;
    ll res = 0;
    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= K; j++) {
            ll gcd_ij = gcd(i,j);
            for (int l = 1; l <= K; l++) {
                res += gcd(gcd_ij,l);
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3616
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
def worstdata():
    a=0
    return a
#solution:
def vacation(N,act):
    lastact =[]
    dp=[0,max(act[0])]*(N+1) #[i]日目のActivity で得られる最大幸福量
    
    return 0

#input


S=input()
window=len(S)-7
k="keyence"
cond=0
for i in range(7):
    c=S[0:i]+S[i+window:]
    #print(c)
    if c==k:
        cond=1
        break
#output
#print(solution(H,N))
print(["NO","YES"][cond])



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

#define all(v) v.begin(), v.end()
#define mp make_pair
#define EPS (int)1e-9
#define PI acos(-1)
#define endl '\n'
#define pb push_back
#define fi first
#define se second

using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int mod = 1000000007;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if(c >= b or a >= d)
	{
		cout << 0 << endl;
		return 0;
	}

	cout << min(b,d)-max(a, c) << endl;
	return 0;	
}

Measured memory_bytes: 256
#import<iostream>
int64_t r,d,i,b,c;main(){std::string s;std::cin>>s;for(;i<s.size();d=b^c?0:d)b=s[i]==66,c=s[i+1]>66,s[i++]<66?d++:r+=b&c?d:0;std::cout<<r;}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,n;
  cin>>k>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=k;;i++){
    int j=i;
    bool f=false;
    while(j!=0){
      int m=j%10;
      for(int l=0;l<n;l++){
        if(a[l]==m){
          f=true;
          break;
        }
      }
      if(f)
        break;
      j/=10;
    }
    if(!f){
      cout<<i;
      return 0;
    }
  }
}

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

using namespace std;
typedef long long ll;
ll n,m;

int main()
{
    scanf("%d%d",&n,&m); if (n>m) swap(n,m);
    if (n==1){
        if (m==1) cout << 1 << endl;
        if (m==2) cout << 0 << endl;
        if (m>2) cout << m-2 << endl;
    }
    else{
        cout << (n-2)*(m-2) << endl;
    }
    return 0;
}


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

bool is_ACGT(char c){
    if(c=='A'||c=='C'||c=='G'||c=='T'){
        return true;
    }else{
        return false;
    }
}

int main(){
    string S;
    cin >> S;
    int ans = 0;
    for(int i=0;i<S.length();i++){
        int tmp=0;
        for(int j=i;j<S.length();j++){
            if(is_ACGT(S[j])){
                //cout << j << '-' << S[j] << endl;
                tmp++;
            }else{
                i=j;
                break;
            }
        }
        ans = max(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

LL n, m, l, q, INF = 700;

template<typename T> class RPQ : public priority_queue<T, vector<T>, greater<T>> { };
template<typename C> void dijkstra(int s, vector<pair<int, C>> g[], pair<C, C> d[]) {
	typedef pair<C, C> Z;
	RPQ<pair<Z, int>> q;
	d[s] = { 0, 0 };
	q.emplace(d[s], s);
	while(! q.empty()) {
		Z   c = q.top().FI;
		int v = q.top().SE;
		q.pop();
		if(d[v] != c) { continue; }
		for(auto & e : g[v]) {
			int ev = e.FI;
			C   ec = e.SE;
			auto x = d[v];
			
			if(x.SE + ec <  l) { x.SE += ec; }
			ef(x.SE + ec == l) { x.FI++; x.SE = 0; }
			else               { x.FI++; x.SE = ec; }
			
			if(setmin(d[ev], x)) { q.emplace(d[ev], ev); }
		}
	}
}

vector<pair<int, LL>> g[300];
pair<LL, LL> d[300][300];

int main() {
	cin >> n >> m >> l;
	inc(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		if(c <= l) {
			g[a].EB(b, c);
			g[b].EB(a, c);
		}
	}
	
	inc(i, n) {
	inc(j, n) {
		d[i][j] = { INF, INF };
	}
	}
	
	inc(i, n) { dijkstra(i, g, d[i]); }
	
	inc(i, n) {
	inc(j, n) {
		if(d[i][j].FI >= INF) { d[i][j] = { -1, -1 }; }
		if(d[i][j].SE == 0) { d[i][j].FI--; }
	}
	}
	
	cin >> q;
	inc(qq, q) {
		int s, t;
		cin >> s >> t;
		s--; t--;
		
		cout << d[s][t].FI << "\n";
	}
	
	return 0;
}


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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a[300300], dp[20][2][300300];

signed main() {
	cin >> n;
	rep(i,1<<n) cin >> a[i];
	rep(i,n) rep(j,2) rep(k,1<<n) if ((k>>i&1)==j) dp[i][j][k] = a[k];
	rep(i,n) rep(j,2) rep(k,n) rep(l,1<<n)
		if (l>>k&1) chmax(dp[i][j][l], dp[i][j][l^(1<<k)]);
	int res = 0;
	reps(k,1,1<<n) {
		rep(i,n) chmax(res, dp[i][0][k]+dp[i][1][k]);
		cout << res << ln;
	}
}

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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

int n, m;
vi adj[100100];
int memo[100100];
int dp(int u) {
  int &res = memo[u];
  if (res != -1) return res;
  res = 1;
  for (int v : adj[u]) {
    res = max(res, 1 + dp(v));
  }
  return res;
}

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

    cin >> n >> m;
    for (int i = 0; i < m; i++) {
      int u, v; cin >> u >> v;
      u--; v--;
      adj[u].push_back(v);
    }
    memset(memo, -1, sizeof memo);
    int res = 0;
    for (int i = 0; i < n; i++) {
      res = max(res, dp(i)-1);
    }
    cout << res << endl;
}


Measured memory_bytes: 7552
#include <iostream>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  if(n>1 && m>1){
    int a = (n*(n-1))/2;
    int b= (m*(m-1))/2;
    cout << a+b;
  }
  else if (n<2 && m>1){
    int b= (m*(m-1))/2;
    cout << b;
  }
  else if(n>1 && m<2){
     int a = (n*(n-1))/2;
    cout << a;
  }
  else{
    cout << "0";
  }
  return 0;
}
    
    
    

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)

const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool check_prime(int n)
{
    if(n<2)
        return false;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            return false;
    }
    return true;
}

int setbits(int n)
{
    int count=0;
    while(n)
    {
        if(n%2==1)
            count++;
        n>>=1;
    }
    return count;
}

int lcm(int a,int b)
{
    return (a*b)/__gcd(a,b);
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int x,y;
    cin>>x>>y;
    int a=(4LL*x)-y;
    int b=(y-(2LL*x));

    if(a>=0 and b>=0 and a%2==0 and b%2==0)
    {
        cout<< "Yes";
    }
    else
        cout<< "No";

    return 0;
}


Measured memory_bytes: 3696
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	const mod = int(1e9 + 7)
	n := readI()
	sum := make([]int, n+1)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		tmp := readI()
		sum[i+1] = sum[i] + tmp
		a[i] = tmp
	}

	ans := 0
	for i := 0; i < n; i++ {
		ans += a[i] * ((sum[n] - sum[i+1]) % mod)
		ans %= mod
	}
	fmt.Println(ans)
}

/*-----------Utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}


Measured memory_bytes: 7936
x = list(input())
i = 0
edetector = True
odetector = True
while i < len(x):
    if  i % 2 == 0:
        if not x[i] in ["R", "U", "D"]:
            edetector = False
    else:
        if not x[i] in ["L", "U", "D"]:
            odetector = False
    i += 1

if edetector and odetector:
    print("Yes")
else:
    print("No")


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

int main()
{
  int n, m;
  cin >> n;
  vector<int> s(n), l(n), p(n);
  for (int i = 0; i < n; i++)
  {
    cin >> s[i] >> l[i] >> p[i];
  }
  vector<vector<int>> dp(n + 1, vector<int>(394, 0));
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < 394; j++)
    {
      dp[i + 1][j] = dp[i][j];
      for (int k = j - l[i]; k <= j - s[i]; k++)
      {
        if (k < 0)
        {
          continue;
        }
        dp[i + 1][j] = max(dp[i + 1][j], dp[i + 1][k] + p[i]);
      }
    }
  }
  cin >> m;
  vector<int> ans(m);
  for (int i = 0; i < m; i++)
  {
    int w;
    cin >> w;
    ans[i] = dp[n][w];
    if (!ans[i])
    {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 0; i < m; i++)
  {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 3324
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int a;
    cin >> a;
    cout << a/3;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

int main(){
	ll N, K;
	cin >> N >> K;
	cout << N - K + 1 << endl;
	return 0;


}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
	int a, b[100], i, c, count = 0, j;
	while(scanf("%d", &a) != 0){
		if(a == 0) break;
		for(i = 0; i < a; i++) scanf("%d", &b[i]);
		for(j = a - 1; j >= 1; j--){
			for(i = 0; i < j; i++){
				if(b[i + 1] < b[i]){
						c = b[i];
						b[i] = b[i + 1];
						b[i + 1] = c;
						count++;
				}
			}
		}
		printf("%d\n", count);
		count = 0;
	}
	return 0;
}

Measured memory_bytes: 600
#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 get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int n, m;
auto d = make_vec<int>(20, 20);
auto memo = make_vec<int>(1 << 16, 20);
int dp(int bit, int now) {
    if (memo[bit][now] != -1) return memo[bit][now];
    if (bit == 1 && now == 0) return memo[bit][now] = 0;
    int ret = INF;
    int pbit = bit & ~(1 << now);
    rep(pre, n) {
        if (!(pbit & (1 << pre))) continue;
        chmin(ret, dp(pbit, pre) + d[pre][now]);
    }
    return memo[bit][now] = ret;
}
int main() {
    cin >> n >> m;
    rep(i, n) rep(j, n) d[i][j] = INF;
    rep(i, m) {
        int s, t, x;
        cin >> s >> t >> x;
        d[s][t] = x;
    }
    rep(i, 1 << 16) rep(j, 20) memo[i][j] = -1;
    int ans = INF;
    rep(i, n) chmin(ans, dp((1 << n) - 1, i) + d[i][0]);
    cout << (ans == INF ? -1 : ans) << endl;
}


Measured memory_bytes: 10388
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############

def Base_10_to_n(X, n):
  if (int(X/n)):
    return Base_10_to_n(int(X/n), n)+str(X%n)
  return str(X%n)

N = inputI()

dic = [[3,5,7]]


for _ in range(8):
  temp = []
  for v in dic[-1]:
    temp.append(v*10+3)
    temp.append(v*10+5) 
    temp.append(v*10+7)
  dic.append(temp)

x = []
for item in dic:
  x += item
nx = []
for i in x:
  if len(set(list(str(i)))) == 3:
    nx.append(i)

print(bisect.bisect(nx,N))

Measured memory_bytes: 69224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    int a[m], b[m];
    set<int> st;
    rep(i, m) {
        cin >> a[i] >> b[i];
        if (a[i] == 1) st.insert(b[i]);
    }
    rep(i, m) {
        if (b[i] == n) {
            if (st.count(a[i])) {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }

    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 6528
#include<iostream>
using namespace std;
int main(){
	int K, S;
	cin>>K>>S;
	int count = 0;
	for(int X = 0; X <= K; X++){
		for(int Y = 0; Y <= K; Y++){
			if(S - X - Y <= K && S - X - Y >= 0){
				count++;
				
			}
		}
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256