akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define inf (1e9 + 7)
#define mem(a, b) memset(a, b, sizeof(a))
using namespace std;

int n, num[105], num2[205], nn = 0, ji = 0, ou = 0, lk[205], ans = 0;
bool vis[205];
vector<int> eg[205];

bool dfs(int u)
{
    int lim = eg[u].size();
    for(int i = 0;i < lim;i++)
    {
        int v = eg[u][i];
        if(!vis[v])
        {
            vis[v] = 1;
            if(lk[v] == -1||dfs(lk[v]))
            {
                lk[v] = u;
                return true;
            }
        }
    }
    return false;
}

bool jg(int a)
{
    if(a <= 2)
        return false;
    for(int i = 2;i * i <= a;i++)
    {
        if(a % i == 0)
            return false;
    }
    return true;
}

int main()
{
    mem(lk, -1);
    scanf("%d", &n);
    for(int i = 1;i <= n;i++)
        scanf("%d", &num[i]);
    sort(num + 1, num + 1 + n);
    num2[++nn] = num[1];
    for(int i = 2;i <= n;i++)
    {
        if(num[i] - 1 != num[i - 1])
        {
            num2[++nn] = num[i - 1] + 1;
            num2[++nn] = num[i];
        }
    }
    num2[++nn] = num[n] + 1;
    for(int i = 1;i <= nn;i++)
    {
        if(num2[i] % 2 == 0)
        {
            ou++;
            for(int j = i + 1;j <= nn;j++)
            {
                if(jg(num2[j] - num2[i]))
                    eg[j].push_back(i);
            }
        }
        else
        {
            ji++;
            for(int j = i + 1;j <= nn;j++)
            {
                if(jg(num2[j] - num2[i]))
                    eg[i].push_back(j);
            }
        }
    }
    int res = 0;
    for(int i = 1;i <= nn;i++)
    {
        if(num2[i] % 2 == 0)
            continue;
        mem(vis, 0);
        if(dfs(i))
            res++;
    }
    ans += res;
    ji -= res;
    ou -= res;
    ans += ji / 2 * 2;
    ji %= 2;
    ans += ou / 2 * 2;
    ou %= 2;
    if(ji||ou)
        ans += 3;
    printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 256
def resolve():
    N = int(input())
    A = [ int(input()) for _ in range(N)]

    #print(N, A)

    next = 0
    cnt = 0
    for i in range(N):
        next = A[next] - 1
        #print(next)
        cnt += 1
        if next == 1:
            break

    if cnt == N:
        print(-1)
    else:
        print(cnt)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 13044
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
from io import StringIO
import unittest


def resolve():
    n, m = map(int, input().split())

    if n == m:
        print("Yes")
    else:
        print("No")



class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3 3"""
        output = """Yes"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3 2"""
        output = """No"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """1 1"""
        output = """Yes"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 51312
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int MOD = 1e9 + 7;

int add(int a, int b) {
	return (a + b) % MOD;
}

int mul(int a, int b) {
	return (a * b) % MOD;
}

int n;



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

    int N, M;

    cin >> N >> M;

    vector<int> A;
    int acc = 0;

    for(int i=0; i<N; i++){
        int tmp;
        cin >> tmp;
        acc += tmp;
        A.push_back(tmp);
    }

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

    for(int i=0; i<M; i++){
        if(4*M*A[i] < acc){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

}


Measured memory_bytes: 256
digit = 100
def vrand(seed):
    del_down = int(seed * seed / digit)
    up_ = int(del_down / (digit * digit))
    up_ *= (digit * digit)
    return del_down - up_

num = int(input())
sds = []
for i in range(num):
    sd = int(input())
    sds.append(sd)

for i in range(num):
    print("Case "+str(i+1)+":")
    seed = sds[i]
    for j in range(10):
        seed = vrand(seed)
        print(seed)



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

int main()
{
    int L, R, d;
    cin >> L >> R >> d;
    int answer=0;
    for (int i=L; i<=R; i++)
    {
        if (i%d==0) answer++;
    }
    cout << answer<< endl;
}

Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {

	/** ケーキの値段 */
	private static final int CAKE = 4;
	/** ドーナツの値段 */
	private static final int DOUGHNUT = 7;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			for (int i = 0; i <= n / CAKE; i++) {
				if (0 == (n - CAKE * i) % DOUGHNUT) {
					System.out.println("Yes");
					return;
				}
			}
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35452
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin>>n>>m;
  vector<vector<int>> ab_s(n, vector<int>(2));
  vector<vector<int>> cd_s(m, vector<int>(2));
  for(int i=0;i<n;i++){
    cin>>ab_s.at(i).at(0)>>ab_s.at(i).at(1);
  }
  for(int i=0;i<m;i++){
    cin>>cd_s.at(i).at(0)>>cd_s.at(i).at(1);
  }
  for(int i=0;i<n;i++){
    int a=ab_s.at(i).at(0);
    int b=ab_s.at(i).at(1);
    int min_d, min_j;
    for(int j=0;j<m;j++){
      int d=abs(a-cd_s.at(j).at(0))+abs(b-cd_s.at(j).at(1));
      if(j==0||d<min_d){
        min_d=d;
        min_j=j;
      }
    }
    cout<<min_j+1<<endl;
  }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {


    public static void main(String args[]){
        Scanner in=new Scanner(System.in);
        //
        int a[]=new int[3];
        for(int i=0;i<3;i++){
            a[i]=in.nextInt();
        }
        Arrays.sort(a);
        //
        boolean ans= a[1]==a[2]&&a[0]==a[1];
        System.out.println(ans==true?"Yes":"No");
    }

}


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

#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define endl "\n" 
#define all(c) c.begin(),c.end()
#define present(c,element) (c.find(element)!=c.end())
#define cpresent(c,element) (find(c,element)!=c.end())
typedef vector<int> vi;
typedef vector<ll> vll;
ll mod=1e9+7;


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

int test=1;
//cin>>test;
while(test--)
{
	int n;
	cin>>n;
	ll a[n];
	ll p[n];
	map<ll,int> mp;
	for(int i=0;i<n;i++){
		cin>>a[i];
		p[i]=i+a[i];
		ll j=i-a[i];
		auto it=mp.find(j);
		if(it==mp.end())mp[j]=1;
		else mp[j]++;
	}
	ll ans=0;
	for(int i=0;i<n;i++)
	{
		auto it=mp.find(p[i]);
		if(it!=mp.end())ans+=mp[p[i]];
	}
	cout<<ans<<endl;

}
return 0;
}









Measured memory_bytes: 18288
s=input()
for _ in range(int(input())):
    o=input().split()
    a,b=map(int,o[1:3]);b+=1
    c=o[0][2]
    if c=='p':s=s[:a]+o[3]+s[b:]
    elif c=='i':print(s[a:b])
    elif c=='v':s=s[:a]+s[a:b][::-1]+s[b:]


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

import sys

def parse_input(lines_as_string = None):
    
    lines = []
    lines.append(input())

    params = lines[0].split(" ")
    a = params[0]

    return (a)


def solve(s):

    result = "TBD"
    if s <= "2019/04/30":
        result = "Heisei"
    else:
        result = "TBD"

    return result

def main():
    # 出力

    print("%s" % solve(parse_input()))

if __name__ == '__main__':

    main()


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
using ll=long long;
const ll mod=1000000007; 
int main(){

  int N;
  cin>>N;
  ll ans=1;
  for(int i=1;i<=N;i++){
  
    ans*=10;
    ans%=mod;
  }
  ll nine=1;
  ll Not=1;
  for(int i=1;i<=N;i++){
  
    nine*=9;
    Not*=8;
    nine%=mod;
    Not%=mod;
  }
  ll nineans=ans-nine;
  if(nineans<0)nineans+=mod;
  ll one=nine;
  ll oneans=ans-one;
  if(oneans<0)oneans+=mod;
  ll trueans=nineans+oneans-(ans-Not);
  trueans%=mod;
  if(trueans<0)trueans+=mod;
  cout<<trueans;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    char c; cin >> c;
    if(c == 'A') return 'T';
    if(c == 'T') return 'A';
    if(c == 'C') return 'G';
    if(c == 'G') return 'C';
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<char>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#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 FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#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()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

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 int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int X[3],Y[3];
ld r,mxline;

ld line(int i,int j){
    int x=abs(X[i]-X[j]);
    int y=abs(Y[i]-Y[j]);
    return sqrt(1.*x*x+1.*y*y);
}

bool ck(ld x){
    ld l=mxline*(r-x)/r;
    return (x*2<=l);
}

void calc(){
    ld a=line(0,1);
    ld b=line(1,2);
    ld c=line(0,2);
    mxline=max(a,max(b,c));
    ld s=(a+b+c)/2;
    ld S=sqrt(s*(s-a)*(s-b)*(s-c));
    r=S/s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    rep(i,3) cin>>X[i]>>Y[i];
    calc();
    
    ld lb=0, ub=r, mid;
    while(ub-lb>1e-10){
        mid=(ub+lb)/2;
        if(ck(mid)) lb=mid;
        else ub=mid;
    }
    printf("%.12llf\n",mid);
}

Measured memory_bytes: 256
#include<iostream>
#define mod 1000000007
#define DIM 200005
using namespace std;
int n, m, i, k, nr, sol;
char s[DIM];
int d[DIM], sum[DIM];
int main(){
    cin>> n >> m;
    cin>> s + 1;
    k = m;
    for(i = 1; i <= m; i++){
        if(s[i] == s[1]){
            nr++;
        }
        else{
            if(nr == i - 1){
                if(nr % 2 == 1){
                    k = min(k, nr);
                }
                else{
                    k = min(k, nr + 1);
                }
            }
            else{
                if(nr % 2 == 1){
                    k = min(k, nr);
                }
            }
            nr = 0;
        }
    }
    sum[1] = d[1] = 1;
    if(k == m){
        sum[2] = 1;
        for(i = 3; i < n; i++){
            d[i] = sum[i - 2];
            sum[i] = (d[i] + sum[i - 1]) % mod;
        }
        sol = 1;
        for(i = 1; i < n; i++){
            sol = (sol + d[n - i] * 1LL * (i + 1) ) % mod;
        }
        cout<< sol;
        return 0;
    }
    for(i = 3; i < n; i += 2){
        d[i] = sum[i - 2];
        if(i - k - 3 > 0){
            d[i] -= sum[i - k - 3];
            if(d[i] < 0){
                d[i] += mod;
            }
        }
        sum[i] = d[i] + sum[i - 2];
        if(sum[i] >= mod){
            sum[i] -= mod;
        }
    }
    for(i = 1; i < min(n, k + 2); i += 2){
        sol = (sol + d[n - i] * 1LL * (i + 1) ) % mod;
    }
    cout<< sol;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define ll long long
using namespace std;
unordered_map<ll,ll> bok;
ll D,lim;
int p[]={2,3,5};
ll cst[3];
ll G(ll x)
{
	if(!x)return 0;
	if(bok[x])return bok[x];
	ll tmp=x<=lim?D*x:(ll)4e18;
	for(int i=0;i<3;i++){
		ll dv=x/p[i],res=x%p[i];
		tmp=min(tmp,G(dv)+D*res+cst[i]);
		if(res)tmp=min(tmp,G(dv+1)+D*(p[i]-res)+cst[i]);
	}
	return bok[x]=tmp;
}
int main()
{
	int t;
	cin>>t;
	while(t--){
		bok.clear();
		ll n;
		cin>>n>>cst[0]>>cst[1]>>cst[2]>>D;
		bok[1]=D,lim=4e18/D;
		printf("%lld\n",G(n));
	}
}

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

using namespace std;
typedef long long int ll;

int main(){
    ll N, K;
    cin >> N >> K;
    
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        ll t = 0; cin >> t;
        if(t >= K){
            ans++;
        }
    }

    cout << ans << endl;



}

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

int main() {
  int a, b, c; cin >> a >> b >> c;
   
  for (int i = 1; i <= b; i++) {
    if ((a * i) % b == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  
  cout << "NO" << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 100000
#define vmax 10000
#define sentinel 2000000000
#define INF (1<<30)
constexpr long long int inf = 1000000000000;
constexpr long long int rinf = -(INT64_MAX);
static const int NIL=-1;

//cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);

int n;
vector<int> g[MAX];
int color[MAX];

void dfs(int r,int c){
    stack<int> s;
    s.push(r);
    color[r]=c;
    while(!s.empty()){
        int u=s.top();s.pop();
        for(auto v:g[u]){
            if(color[v]==NIL){
                color[v]=c;
                s.push(v);
            }
        }
    }
}

void assigncolor(){
    int id=1;
    rep(i,n) color[i]=NIL;
    rep(i,n){
        if(color[i]==NIL){
            dfs(i,id++);
        }
    }
}

int main() {
    int s,t,m,q;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>s>>t;
        g[s].push_back(t);
        g[t].push_back(s);
    }
    assigncolor();
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>s>>t;
        if(color[s]==color[t]){
            cout<<"yes"<<endl;
        }else{
            cout<<"no"<<endl;
        }
    }
    return 0;
}






Measured memory_bytes: 8996
int main(void){
    int a, b;

    scanf("%d %d", &a, &b);
    if(a < b){
        printf("a < b\n");
    }else{
        if(a > b){
            printf("a > b\n");
        }else{
            printf("a == b\n");
        }
    }
    return 0;
}

Measured memory_bytes: 580
import numpy as np

X,N=list(map(int,input().split()))
Pn=list(map(int,input().split()))


possible=[]

for i in range(min(Pn)-1,max(Pn)+2) if N!=0 else [X]:
    if i not in Pn:
        possible.append(i)

idx = np.abs(np.asarray(possible) - X).argmin()

print(possible[idx])

Measured memory_bytes: 27212
#include<bits/stdc++.h>
using namespace std;
#define INF 9223372036854775805;
long long int dp[500][500];

long long int solve(long long int arr[],int i,int j)
{
	if(dp[i][j]!=-1)
		return dp[i][j];
	if(i==j)
	{
		dp[i][j]=0;
		return dp[i][j];
	}
	long long int mn=INF;
	for(int k=i+1;k<=j;k++)
		mn=min(mn,solve(arr,i,k-1)+solve(arr,k,j));
	dp[i][j]=mn;
	for(int k=i;k<=j;k++)
	 	dp[i][j]+=arr[k];
	return dp[i][j];
}

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    	for(int j=0;j<n;j++)
    		dp[i][j]=-1;
    long long int arr[n];
    for(int i=0;i<n;i++)
    	cin>>arr[i];
    cout<<solve(arr,0,n-1)<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)

//x^y
int64_t power(int64_t x, int64_t y){
  if(y < 0)
    return 0;
  else{
    int64_t n = 1ll;
    for(int64_t i = 0; i < y; i++)
      n *= x;
    return n;
  }
}

int main() {
    int n;
    cin >> n;
    vector<int64_t> t(n);
    rep(i,n) cin >> t[i];
    int64_t ans = 1;
    int64_t l = power(10,18)/2;
    rep(i,n){
        int64_t ti = t[i];
        ans = ans/__gcd(ans,ti)*ti;
        if(ans > l) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>

int t, x;
int main()
{
	std::cin >> t >> x;
	std::cout << std::setprecision(10) << std::fixed << static_cast<double>(t) / static_cast<double>(x) << std::endl;
	return 0;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=(1LL<<60);
const int INF=1<<29;
const int MOD=1e9+7;


int main(){
    int N; cin >> N;
    vi A(N), B(N), C(N);
    for(auto &x : A) cin >> x;
    for(auto &x : B) cin >> x;
    for(auto &x : C) cin >> x;
    sort(all(A));
    sort(all(C));
    ll res=0;
    for(int i=0; i<N; i++){
        ll x, y;
        x=lower_bound(all(A), B[i])-A.begin();
        y=C.end()-upper_bound(all(C), B[i]);
        res+=x*y;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4556
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //

int t[200000] = {};
int main() {
	in(int, N);
	int cnt4 = 0, cnt2 = 0, cnt1 = 0;
	loop(i, N) {
		in(ll, a);
		if (a % 4 == 0)
			++cnt4;
		else if (a % 2 == 0)
			++cnt2;
		else
			++cnt1;
	}
	if (!cnt2)
		--cnt1;
	YesNo(cnt4 >= cnt1);
	return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

//Confusing Login Names
public class Main{

	Set<String>[] s;
	
	class P implements Comparable<P>{
		String s, t;
		public P(String s, String t) {
			this.s = s.compareTo(t)<0?s:t;
			this.t = s.compareTo(t)<0?t:s;
		}
		public int compareTo(P o) {
			return s.equals(o.s)?t.compareTo(o.t):s.compareTo(o.s);
		}
	}
	
	void make(int i, String v){
		int n = v.length();
		StringBuffer f = new StringBuffer(v);
		//delete
		for(int j=0;j<n;j++){
			char ch = f.charAt(j);
			f.deleteCharAt(j);
			s[i].add(f.toString());
			f.insert(j, ch);
		}
		//insert
		for(int j=0;j<=n;j++){
			for(char ch='a';ch<='z';ch++){
				f.insert(j, ch); s[i].add(f.toString()); f.deleteCharAt(j);
			}
		}
		//replace
		for(int j=0;j<n;j++){
			char ch = f.charAt(j);
			for(char c='a';c<='z';c++){
				f.setCharAt(j, c); s[i].add(f.toString());
			}
			f.setCharAt(j, ch);
		}
		//swap
		for(int j=0;j<n-1;j++){
			char a = f.charAt(j), b = f.charAt(j+1);
			f.setCharAt(j, b); f.setCharAt(j+1, a);
			s[i].add(f.toString());
			f.setCharAt(j, a); f.setCharAt(j+1, b);
		}
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			int d = sc.nextInt();
			s = new HashSet[n];
			String[] name = new String[n];
			for(int i=0;i<n;i++){
				name[i] = sc.next();
				s[i] = new HashSet<String>();
				make(i, name[i]);
			}
			PriorityQueue<P> q = new PriorityQueue<P>();
			for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){
				if(d==1){
					if(s[i].contains(name[j]))q.add(new P(name[i], name[j]));
				}
				else{
					if(s[i].contains(name[j]))q.add(new P(name[i], name[j]));
					else{
						for(String v:s[i])if(s[j].contains(v)){
							q.add(new P(name[i], name[j]));
							break;
						}
					}
				}
			}
			int r = q.size();
			while(!q.isEmpty()){
				P p = q.poll(); System.out.println(p.s+","+p.t);
			}
			System.out.println(r);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 33000
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vll = vector<ll>;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);

    const ll MOD = 1e9 + 7;
    int n;
    cin >> n;
    string s;
    cin >> s;
    vll dp(n);
    dp[0] = 1;
    auto sum = [&dp, &MOD] {
        ll res = 0;
        for (ll e : dp) (res += e) %= MOD;
        return res;
    };
    for (int i = 1; i < n; i++) {
        vll new_dp(n);
        ll a = 0, b = sum();
        for (int j = 0; j <= i; j++) {
            if (s[i - 1] == '<') {
                (new_dp[j] += a) %= MOD;
            }
            else {
                (new_dp[j] += b) %= MOD;
            }
            (b += MOD - dp[j]) %= MOD;
            (a += dp[j]) %= MOD;
        }
        swap(dp, new_dp);
        swap(a, b);
    }

    cout << sum() << '\n';
}

Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize -O3
#endif
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ld = double;
using ull = uint64_t;

const int MAXN = 100228;
const ll INF = 6e9 + 20;
const int MOD = 1e9 + 7;

ll a[MAXN];
ll x[MAXN];
ll y[MAXN];

void c(vector<ll>& v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
}

int fn(vector<ll>& v, ll x) {
    return lower_bound(v.begin(), v.end(), x) - v.begin();
}

ll fen[MAXN];
int fs;

void ad(int x, ll y) {
    y %= MOD;
    if (y < 0) {
        y += MOD;
    }

    for (int i = x; i < MAXN; i |= (i + 1)) {
        fen[i] += y;
        fen[i] %= MOD;
    }
}

ll gt(int x) {
    ll ans = 0;
    for (int i = x + 1; --i >= 0; i &= (i + 1)) {
        ans += fen[i];
    }

    return ans % MOD;
}

vector<int> yy[MAXN];

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);
    vector<ll> xs = {INF};
    vector<ll> ys = {INF};

    int n, m;
    cin >> n >> m;

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

    for (int i = 1; i <= m; ++i) {
        cin >> a[i];
    }

    a[0] = -3 * INF;
    a[m + 1] = 3 * INF;

    for (int i = 0; i < n; ++i) {
        int g = lower_bound(a, a + m + 1, x[i]) - a;
        ll cx = x[i] - a[g - 1];
        ll cy = a[g] - x[i];
        x[i] = cx;
        y[i] = cy;

        if (x[i] < INF && y[i] < INF) {
            xs.push_back(x[i]);
            ys.push_back(y[i]);
        }
    }

    c(xs);
    c(ys);

    int yc = ys.size();

    for (int i = 0; i < n; ++i) {
        if (x[i] < INF && y[i] < INF) {
            x[i] = fn(xs, x[i]);
            y[i] = fn(ys, y[i]);
            yy[x[i]].push_back(y[i]);
        }
    }

    ad(0, 1);

    for (int i = xs.size(); i >= 0; --i) {
        sort(yy[i].begin(), yy[i].end());
        int py = -1;
        for (int y: yy[i]) {
            if (y == py) {
                continue;
            }

            py = y;
            int cy = yc - y;
            ll g = gt(cy - 1);
            ad(cy, g);
        }
    }

    cout << gt(yc) << endl;
}

Measured memory_bytes: 9580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())
 
int main() {
  int n, m;
  cin >> n >> m;

  vector<int> a(n);
  int sum=0;
  rep(i, n) {
    cin >> a.at(i);
    sum+=a.at(i);
  }

  int cnt=0;
  rep(i,n){
    int val = a.at(i);
    if(val*4*m>=sum) cnt++;
  }

  if(cnt>=m) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

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

    vector<pair<int, int>> ev(100001, make_pair(0, 0)), od(100001, make_pair(0, 0));
    for (int i = 0; i <= 100000; i++) {
        ev[i].second = i;
        od[i].second = i;
    }

    for (int i = 0; i < n; i++) {
        int v;
        cin >> v;

        if (i % 2 == 0) {
            ev[v].first++;
        } else {
            od[v].first++;
        }
    }

    sort(ev.begin(), ev.end(), greater<pair<int, int>>());
    sort(od.begin(), od.end(), greater<pair<int, int>>());

    if (ev[0].second == od[0].second) {
        cout << min((n / 2 - ev[0].first) + (n / 2 - od[1].first),
                (n / 2 - ev[1].first) + (n / 2 - od[0].first)) << endl;
    } else {
        cout << (n / 2 - ev[0].first) + (n / 2 - od[0].first) << endl;
    }
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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 main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(1){
        c-=b;
        if(c<=0){
            cout << "Yes" << endl;
            break;
        }
        a-=d;
        if(a<=0){
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3636
use std::io::stdin;
use std::vec::Vec;

mod utils {
    use std::io::BufRead;
    use std::str::{self, FromStr};

    pub struct StdinReader<R: BufRead> {
        reader: R,
        buf: Vec<u8>,
    }

    impl<R: BufRead> StdinReader<R> {
        pub fn new(reader: R) -> StdinReader<R> {
            StdinReader {
                reader: reader,
                buf: Vec::new(),
            }
        }

        #[allow(unused)]
        #[inline]
        pub fn reads<T: FromStr>(&mut self) -> T {
            self.read_until(b' ')
        }

        #[allow(unused)]
        #[inline]
        pub fn readl<T: FromStr>(&mut self) -> T {
            self.read_until(b'\n')
        }

        #[allow(unused)]
        #[inline]
        pub fn read_vec<T: FromStr>(&mut self) -> Vec<T> {
            return self.read_until::<String>(b'\n').trim().split_whitespace().map(|c| c.parse().ok().unwrap()).collect();
        }

        #[inline]
        pub fn read_until<T: FromStr>(&mut self, delim: u8) -> T {
            loop {
                self.buf.clear();
                let len = self.reader
                    .read_until(delim, &mut self.buf)
                    .expect("failed reading bytes");
                match len {
                    0 => panic!("early eof"),
                    1 if self.buf[0] == delim => (),
                    _ => {
                        if self.buf[len - 1] == delim {
                            self.buf.truncate(len - 1);
                        }
                        break;
                    }
                }
            }

            let elem = unsafe { str::from_utf8_unchecked(&self.buf) };
            elem.parse().unwrap_or_else(|_| panic!(format!("failed parsing: {}", elem)))
         }
    }
}


fn main(){
    let stdin = stdin();
    let mut r = utils::StdinReader::new(stdin.lock());
    let n:i32 = r.reads();
    let k:usize = r.readl();
    let ps:Vec<f64> = r.read_vec();
    let mut p_max = 0;
    let mut es_p:Vec<f64> = vec![];
    for i in ps {
        es_p.push((1_f64 + i) / 2_f64);
    }
    let mut res = 0_f64;
    let mut e_k = 0_f64;
    for i in 0..(es_p.len() - k + 1) {
        if(i == 0){
            for e in i..(i + k) {
                e_k += es_p[e];
            }
        }else{
            e_k -= es_p[i-1];
            e_k += es_p[i + k - 1];
        }
        if(e_k > res){
            res = e_k;
        }
    }
    println!("{}",res);

}


Measured memory_bytes: 13556
// author: hjy
// Problem:
#include<bits/stdc++.h>
//#pragma GCC optimize(2)
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define rep(i,n) for(register int i=0; i<(int)(n); ++i)
#define per(i,n) for(register int i=(int)(n)-1; i>=0; --i)
#define rep1(i,n) for(register int i=1; i<=(int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<"="<<x<<'\n'

inline int read() {
	int x=0,ng=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') ng=1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return ng?-x:x;
}

const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int seed=20040305;

priority_queue<pii> pq;
int n,k;
vector<int> vec[100100];
int s[100100];
int visit[100100];

int main()
{
	scanf("%d",&n);
	rep(i,n-1)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		vec[a].pb(b);
		vec[b].pb(a);
	}
	scanf("%d",&k);
	rep(i,k)
	{
		int v,p;
		scanf("%d%d",&v,&p);
		s[v]=p;
		pq.push(mp(p,v));
		visit[v]=1;
	}
	while(pq.size())
	{
		int v=pq.top().se;
		int p=pq.top().fi;
		pq.pop();
		rep(i,vec[v].size())
		{
			int u=vec[v][i];
			if(!visit[u])
			{
				s[u]=p-1;
				visit[u]=1;
				pq.push(mp(p-1,u));
			}
		}
	}
	rep(i,n) rep(j,vec[i].size())
	{
		if(abs(s[vec[i][j]]-s[i])!=1)
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	rep1(i,n) printf("%d\n",s[i]);
}


Measured memory_bytes: 8308
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin>>a;
  long long int n[a];
  for(int i=0;i<a;i++){
    cin>>n[i];
  }

  long long int d;
  int m=0;
  for(int i=0;i<a;i++){
    for(int j=0;j<a;j++){
        if(n[i]<n[j]){
            d=n[i];
            n[i]=n[j];
            n[j]=d;
        }
    }
  }
  /**for(int i=0;i<a;i++){
    cout<<n[i]<<endl;
  }**/
  for(int i=0;i<a-1;i++){
    for(int j=i+1;j<a;j++){
        if(n[i]!=n[j]){
        d=n[i]+n[j];
        for(int k=j+1;k<a;k++){
            if(n[k]!=n[i] && n[k]!=n[j])
            {if(d>n[k])
                m++;
            }
        }
        }
    }
  }
  cout<<m;


}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements < num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define int long long int
//Binary_Search->dp->greedy
//auto check = [&](ll x){};
void solve(){
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	for(int i=k;i<=n+1;i++){
		ll val=i*(n+1-i)%mod;
		val=(val+1)%mod;
		ans=(ans+val)%mod;
	}
	cout<<ans<<endl;
	
	
	
}
int main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
return 0;
}    
 

Measured memory_bytes: 3632
#include <stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
    int n, i, j, key, count = 0, temp;
    int A[N];
    scanf("%d", &n);

    for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
    
    for (i = 0; i < n; i++)
    {
        key = i;
        for (j = i + 1; j < n; j++)
        {
            if (A[j] < A[key]) key = j;
        }
        if (key != i)
        {A[i] = A[key] ^ A[i];
        A[key] = A[key] ^ A[i];
        A[i] = A[key] ^ A[i];
        count++;}
    }
    
    trace(A, n);
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 1844
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>

using namespace std;


int N;
int c[100000];

int main() {
	while (cin >> N, N)
	{
		if (N == 0) break;

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

		int ans = 0;
		int ren[100000]; ren[0] = 0;
		int k = 0;
		int last = c[0];
		for (int i = 0; i < N; i++) {
			if (i % 2 == 1) {
				if (last != c[i]) {
					if (c[i] == 0) {
						ans += ren[k];						
					}
					else {
						ans -= ren[k];
					}

					if (k > 0) {
						ren[k - 1] += ren[k];
						k--;
					}					
				}
				ren[k]++;
			}
			else {
				if (last == c[i]) {
					ren[k]++;
				}
				else {
					k++;
					ren[k] = 1;
				}
			}

			if (c[i] == 0) {
				ans++;
			}

			last = c[i];
		}


		cout << ans << endl;
	}

	return 0;
}




Measured memory_bytes: 3464
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int x,y;
int main(){
	cin>>x>>y;
	if(2*x<=y&&y<=4*x&&y%2==0)puts("Yes");
	else puts("No");
    return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>

int main()
{
	int a, b, d, r;
	double f,af,bf;
	
	scanf("%d %d", &a, &b);
	af=a;
	bf=b;
	d = a / b;
	r = a % b;
	f = af / bf;
	
	printf("%d %d %f\n", d, r, f);
	
	return 0;
}


Measured memory_bytes: 2728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int main(){
    int n, t, ans=INF;
    R n >> t;
    rep(i, n){
        int c, x;
        R c >> x;
        if(x <= t)chmin(ans, c);
    }
    if(ans==INF)co("TLE");
    else co(ans);
}

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

int main(){
	int n=0;
	int a=0;
	int b=0;
	int k=0;
	int c[101];
	int i=0;
	int j=0;
	int t=0;
	int w=0;
	int wa=0;
	int s=0;
	
	cin>>n;
	cin>>a;
	cin>>b;
	cin>>k;
	for(i=0;i<101;i++){
		c[i]=0;
	}
	for(i=0;i<n;i++){
		cin>>c[i];
	}
	wa=k;
	t=k/a;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(c[s]<c[j]){
				s=j;
			}
		}
		if(t*b<c[s]){
			wa=wa+c[s];
			w++;
		}else{
			break;
		}
		for(j=s;j<100;j++){
			c[j]=c[j+1];
		}
		t=wa/(a+w*b);
		s=0;
	}
	cout<<t<<endl;
}

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

int main()
{
    int A, B;
    cin >> A >> B;
    int C[100];
    for(int i = 0; i < A; i++) cin >> C[i];
    sort(C, C+A, greater<int>());
    LL sum = 0;
    for(int i = 0; i < B; i++){
        sum += C[i];
    }
    cout << sum << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	bool flg=true;

    int N,A;

    cin>>N;

    for (int i = 0; i < N; i++)
    {
        cin>>A;

        if(A%2==0){
            if(A%3!=0){
                if(A%5!=0){
                    flg=false;
                }
            }
            
        }
    }
    
    if(flg){
        cout<<"APPROVED"<<endl;
    }else{
        cout<<"DENIED"<<endl;
    }

	return 0;
}

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

using namespace std;

#define REP(i,x,y) for (int i=x;i<y;i++)

const int8_t INFC=0x3f;
const int16_t INFS=0x3f3f;
const int32_t INF=0x3f3f3f3f;
const int64_t INFL=0x3f3f3f3f3f3f3f3fLL;
int a[123456];
int main()
{
    ios::sync_with_stdio(0);
    int n;
    int64_t ans=0;
    cin >> n;
    for (int i=0;i<n;i++)
    {
        cin >>a[i];
    }
    ans+=a[0]>>1;
    a[0]&=1;
    for (int i=1;i<n;i++)
    {
        if (a[i-1]&&a[i])
        {
            ans++;
            a[i]--;
        }
        ans+=a[i]>>1;
        a[i]&=1;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i++){
    int k;
    cin >> k;
    if(i % 2 == 0) continue;
    if(k % 2 == 0) continue;
    ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3608
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

// End of template.


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

    int n, m;
    pair<int, int> ab[100100];
    scanf("%d", &n);
    scanf("%d", &m);
    rep(i, m) {
        int a, b;
        a--; b--;
        scanf("%d %d", &a, &b);
        ab[i] = make_pair(a, b);
    }

    sort(begin(ab), begin(ab) + m, [](pii a, pii b) {return a.second < b.second;});

    int prev = -1;
    int ans = 0;
    rep(i, m) {
        if (prev < ab[i].first) {
            prev = ab[i].second - 1;
            ans++;
        }
    }

    cout << ans << '\n';

    return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  int g[101][101],a[101],f[101],n,i,j,k=1,m=0,num,sum=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&g[i][j]);
    }
  }
  
  a[0]=0;
  f[0]=1;
  
  for(i=1;i<n;i++) f[i]=0;
  
  while(1){
    num=2000;
    
    for(i=0;i<k;i++){
      for(j=0;j<n;j++){
	if(g[a[i]][j]<num && g[a[i]][j]!=-1 && f[j]!=1){
	  num=g[a[i]][j];
	  m=j;
	}
      }
    }
    
    if(k!=n){
      a[k]=m;
      f[m]=1;
      sum+=num;
      k++;
    }
    else break;
  }
  printf("%d\n",sum);
  
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <set>
#include <iterator>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;


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

  int N;
  string S;
  cin >> N;
  cin >> S;

  int cur = 0;
  // leader is 0th.
  for(int i=1;i<N;i++){
    if(S.at(i) == 'E') cur++;
  }
  int ans = cur;

  for(int i=1;i<S.size();i++){
    if(S.at(i-1) == 'W') cur++;
    if(S.at(i) == 'E') cur--;
    ans = min(cur, ans);
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 720