akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
const ll  MOD = 1000000007;

ll s(ll a, ll b) {
	if (a < b) swap(a, b);
	return (a + b) * (a - b + 1) / 2 % MOD;
}

int main() {
	ll n, k;
	cin >> n >> k;
	if (k == n + 1) {
		cout << 1;
		return 0;
	}
	ll ans = 0;
	reps(i, k - 1, n + 1) {
		ans += (s(n, n - i) - s(i, 0) + 1) % MOD;
		ans %= MOD;
	}
	if (ans < 0) ans += MOD;
	cout << ans;
	return 0;
}

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

//ライブラリ始まり

//定数

//円周率
const double PI = 3.1415926535897932384;

//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15

//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";

//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//関数

//ctoi
int ctoi(char c){
  if (c == '0') {
    return 0;
  }
  if (c == '1') {
    return 1;
  } 
  if (c == '2') {
    return 2;
  } 
  if (c == '3') {
    return 3;
  }
  if (c == '4') {
    return 4;
  } 
  if (c == '5') {
    return 5;
  } 
  if (c == '6') {
    return 6;
  }
  if (c == '7') {
    return 7;
  } 
  if (c == '8') {
    return 8;
  } 
  if (c == '9') {
    return 9;
  }
  return -1;  
}

//素数判定
bool PN(int x) {
  if (x <= 1) {
    return false;
  }
  if (x == 2) {
    return true;
  }
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

//ライブラリ終わり

int main() {
  int N;
  cin >> N;
  bool ok = false;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    if (A % 2 == 1) {
      ok = true;
    }
  }
  if (ok) {
    cout << "first" << endl;
  }
  else {
    cout << "second" << endl;
  }
}

Measured memory_bytes: 3688
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define SZ(x) (int)(x.size())
#define F0(i,n) for(int i=0;i<n;i++)
#define F1(i,n) for(int i=1;i<=n;i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define P(x) cerr << #x << "=" << x << endl

const int MOD = 998244353;
const double pi = atan(1.0)*4.0;
const double eps = 1e-8;
ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
int bc(int n) { return n ? bc((n-1)&n)+1 : 0; }

int i, j, k, m, n, l, B;
string s;
int a[200001];

int ok() {
    unordered_map<int, int> M;
    set<int> S;
    for (int i = 1; i < n; i++) {
        if (a[i] <= a[i - 1]) {
            if (B == 1) return 0;
            for (int j = a[i] - 1; j >= 0; j--) {
                int current = M[j];
                current++;
                if (current < B) {
                    M[j] = current;
                    S.insert(j);
                    break;
                } else {
                    if (j == 0) return 0;
                    M[j] = 0;
                }
            }
            auto it = S.end();
            while (1) {
                if (it == S.begin()) break;
                it--;
                if (*it >= a[i]) {
                    M[*it] = 0;
                    it = S.erase(it);
                }
                else break;
            }
        }
    }
    return 1;
}



void solve() {
    F0(i, n) scanf("%d", &a[i]);
    //F0(i, n) a[i] = 1LL*rand()*rand()%1000000000+1;
    int P = 1, Q = n;
    while (P < Q) {
        B = (P + Q) / 2;
        //P(B);
        if (ok()) Q = B; else P = B + 1;
    }
    cout << P << endl;
}

int main() {
    //freopen("x.in", "r", stdin);
    while (cin >> n) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 8948
#include <iostream>
using namespace std;
int main(void){
    string s,t;
    cin>>s>>t;
    for(int i=s.size()-t.size();i>=0;i--){
        //cout<<i<<endl;
        bool ok=true;
        for(int j=0;j<t.size();j++){
            //cout<<s[i+j]<<t[j]<<i<<j<<endl;
            if(s[i+j]!='?'&&s[i+j]!=t[j]){
                ok=false;
                break;
            }
        }
            if(ok){
                s.replace(i,t.size(),t);
                for(int k=0;k<s.size();k++){
                    if(s[k]=='?')cout<<'a';
                    else cout<<s[k];
                }
                cout<<endl;
                return 0;
            }
    }
    cout<<"UNRESTORABLE"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
using namespace std;


long long gcd(long long a, long long b) {
    long long _max = a > b ? a : b;
    long long _min = a > b ? b : a;
    if (!(_max%_min)) return _min;
    else return gcd(_min, _max%_min);
}

long long lcm(long long a, long long b) {
    return a/gcd(a,b)*b;
}


void solve(long long A, long long B, long long C, long long D){
    auto CD=lcm(C,D);
    auto nc = (B/C-A/C)+(A%C==0?1:0);
    auto nd = (B/D-A/D)+(A%D==0?1:0);
    auto ncd= (B/CD-A/CD)+(A%CD==0?1:0);
    cout << (B-A+1) - (nc+nd-ncd) << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    solve(A, B, C, D);
    return 0;
}


Measured memory_bytes: 256
#include    <stdio.h>
#include    <stdlib.h>
#include    <string.h>

int main(void)
{
    int a, b, c, k;
    int cnt = 0;

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &k);

    while (0 != a && 0 != k) {
        cnt++;
        k--;
        a--;
    }
    while (0 != k && 0 != b) {
        k--;
        b--;
    }
    while (0 != k && 0 != c) {
        cnt--;
        k--;
        c--;
    }
    printf("%d\n", cnt);

    return 0;
}


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

int n;
void dfs(string s, int mx){
  if(s.size() == n) cout << s << endl;
  else{
    for(int i = 0; i <= mx; i++){
      char c = 'a' + i;
      if(i == mx) dfs(s + c, mx + 1);
      else dfs(s + c, mx);
    }
  }
}
  
int main() {
  cin >> n;
  dfs("", 0);
}

Measured memory_bytes: 1536
N, Q = map(int, input().split())
q = [0] * Q
for i in range(Q):
    q[i] = list(map(int, input().split()))

ans = (N - 2) ** 2

b1 = [0] * (N-2)
b2 = [0] * (N-2)
l = N-2
u = N-2

for i in range(Q):
    x = q[i][1] - 2
    if q[i][0] == 1:
        if x < l:
            ans -= u
            for j in range(x+1, l):
                b2[j] = u
            l = x
        else:
            ans -= b2[x]
        #b1[x] = 0
    else:
        if x < u:
            ans -= l
            for j in range(x+1, u):
                b1[j] = l
            u = x
        else:
            ans -= b1[x]
        #b1[x] = 0

print(ans)

Measured memory_bytes: 101832
#include <bits/stdc++.h>
using namespace std;
#include<map>
#define MEM(var,val) memset(var,(val),sizeof(var))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define nitro   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define F first
#define S second
int  main()
{
    nitro;
    ll a,b,n;
    cin>>a>>b>>n;
    ll x;
    if(b>n)
        x=n;
    else x=b-1;
    cout<<(a*x)/b-a*(x/b);

}


Measured memory_bytes: 3604
import sys
readline = sys.stdin.readline
write = sys.stdout.write

N = int(readline())
*P, = map(float, readline().split())
*Q, = map(float, readline().split())

K = [[None]*(N+1) for i in range(N+1)]
C = [[None]*(N+1) for i in range(N+1)]
S = [0]*(2*N+2)
for i in range(2*N+1):
    S[i+1] = S[i] + (P[i//2] if i % 2 else Q[i//2])

for i in range(N+1):
    C[i][i] = Q[i]
    K[i][i] = i

for l in range(1, N+1):
    for i in range(N+1-l):
        j = i+l
        k0 = K[i][j-1]; k1 = K[i+1][j]
        tmp = 1e30
        k2 = None
        for k in range(k0, min(k1+1, j)):
            v = C[i][k] + C[k+1][j]
            if v < tmp:
                k2 = k
                tmp = v
        K[i][j] = k2
        C[i][j] = tmp + (S[2*j+1] - S[2*i])
write("%.10f\n" % C[0][N])



Measured memory_bytes: 14444
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

struct Edge{
    int to;
    int id;
    Edge(int t, int i):to(t), id(i){}
};
vector<int> ans;
int k = 0;

void dfs(vector<vector<Edge>> &G, int u, int v,int c){
    int k = 1;
    for(int i = 0; i < G[u].size(); i++){
        if(G[u][i].to == v) continue;
        if(k == c) k++;
        ans[G[u][i].id] = k; k++;
        dfs(G, G[u][i].to, u, ans[G[u][i].id]);
    }
    return;
}

int main(){
    int n;
    cin >> n;
    vector<vector<Edge>> G(n);
    ans.resize(n);
    ans.assign(n, 0);
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(Edge(b, i + 1));
        G[b].push_back(Edge(a, i + 1));
    }
    int x;
    rep(i, n){
        if(k < int(G[i].size())){
            k = G[i].size();
            x = i;
        }
    }
    cout << k << endl;
    dfs(G, x, -1, 0);
    for(int i = 1; i  < n ; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mp make_pair
#define F first
#define S second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const unsigned ll l=1000000007;
const int MAX_=2000;
int T;
 
void print(string res, int i)
{
  printf("Case #%d: %s\n",T-i,res.c_str());
  // cout << res;
}
void print(ll res, int i)
{
  printf("Case #%d: %lld\n",T-i,res);
  // cout << res;
}

void solve(int t)
{
  ll a,b;
  cin >> a >> b;
  
  if(a < b)
  {
    for(int i=0; i<b; i++)
    {
      cout << a;
    }
    cout << endl;
  }
  else
  {
    for(int i=0; i<a; i++)
    {
      cout << b;
    }
    cout << endl;
  }
}
 
int main()
{
  IOS
  int t,testCases;
  testCases=1;
  #ifdef DEBUG
    freopen("input.txt","r",stdin);
    cin >> testCases;
    cout << "Running " << testCases << " testcases" << endl;
    freopen("output.txt","w",stdout);
    freopen("error.txt","w",stderr);
  #endif
 
 
  while(testCases--)
  {
    t=1;
    // cin >> t; //comment this in case of singular test case
    T = t;
    while(t--)
    {
      solve(t);
    }
  }
  return 0;
 
}

Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const B& (*func)(A)){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class T,class U>
void msg_with_compare(T A,T B,U A_greater_B,U A_eq_B,U A_less_B){
    if(A==B){cout<<A_eq_B<<"\n";}else if(A>B){cout<<A_greater_B<<"\n";}else{cout<<A_less_B<<"\n";}}
template<class A> bool
none_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]>0){flag=false;}; }return flag;}
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}

ll n,m,a,b;
vector<string> s;
void input(){
    cin>>n>>m;
    s.resize(n);
    rep(i,n){
        cin>>s[i];
    }
}
void src(){
    rep(i,m+2){
        cout<<'#';
    }
        cout<<'\n';
    rep(i,n){
        cout<<'#';
        cout<<s[i];
        cout<<'#'<<"\n";
    }
    rep(i,m+2){
        cout<<'#';
    }
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
long long int arr[3001];
long long int dp[3001][3001];
long long int ans=0;
long long int fun(long long int arr[],int i,int j,int k)
{
	if(i<0||j<0||i>n||j>n||i>j)
	return 0;
	else if(dp[i][j]!=-1)
	return dp[i][j];
	else
	{
		if(k%2==0)
		{
			ans=max(arr[i]+fun(arr,i+1,j,k+1),arr[j]+fun(arr,i,j-1,k+1));
		}
		else
		{
			ans=min(-arr[i]+fun(arr,i+1,j,k+1),-arr[j]+fun(arr,i,j-1,k+1));
		}
	}
	dp[i][j]=ans;
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cin >> n;
	int i,j,k;
	for(i=0;i<n;i++)
	cin >> arr[i];
	memset(dp,-1,sizeof(dp));
	cout << fun(arr,0,n-1,0);
	return 0;
}

Measured memory_bytes: 70912
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;

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

    ll n,m;
    cin>>n>>m;
    vector<ll> adj[n+1];
    ll ar[n+1];
    for(ll i=1;i<=n;++i){cin>>ar[i];}
    for(ll i=0;i<m;++i){
        ll a,b;
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    ll ans=0;
    for(ll v=1;v<=n;++v){
        int f=1;
        for(auto u:adj[v]){
            if(ar[u]>=ar[v]){f=0;}
        }
        ans+=f;
    }
    cout<<ans;

    return (0);
}


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

using namespace std;

typedef long long ll;

const int N = 15;

map <vector <int>, ll> cnt;

int main() {
  int n; cin >> n;
  ll ans = 0;
  for(int i = 0; i < n; i++) {
    string x; cin >> x;
    set <char> s;
    vector <int> cur(27, 0);
    for(auto c : x) {
      cur[c - 'a']++;
      s.insert(c);
    }
    vector <int> dekho;
    for(int i = 0; i < 27; i++) {
      dekho.push_back(cur[i]);
    }
    ans += cnt[dekho];
    cnt[dekho]++;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 26752
s = input()
s_inv = s[::-1]
n = int(len(s))
start = (n-1)/2
fin = (n+2)/2


if s == s_inv:
  s1 = s[:int(start)]
  s1_inv = s1[::-1]
  if s1 == s1_inv:
    s2 = s[int(fin):]
    s2_inv = s2[::-1]
    if s2 == s2_inv:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  print("No")


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

using namespace std;

int main(){
    int64_t a;
    double b;
    int64_t b_int;

    cin >> a >> b;

    b_int = b*100 + 0.1;

    if(a==0||b_int==0){
        cout << 0 << endl;
        return 0;
    }

  	cout << a*b_int/100 << endl;

    return 0;
}

Measured memory_bytes: 3732
from operator import itemgetter
flag1 = 0
n = int(input())
ans_list = []
for i in range(n):
    a = list(map(int, input().split()))
    ans_list.append(a)
ans_list.sort(key=itemgetter(1))
timequeue = 0
for i in range(n):
    timequeue += ans_list[i][0]
    if timequeue > ans_list[i][1]:
        flag1 += 1
        break
if flag1 == 1:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 53720
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <queue>
#include <climits>
#include<cmath>
#include <sstream>
#include <iomanip>

bool sort_pair( std::pair< int64_t, std::string > origin, std::pair< int64_t, std::string > another )
{
    return origin.first < another.first;
}


int main()
{

    int a,c,d;
    
    std::cin>> a;
    double b=0;
    for( int i = 1; i <= a; i++ )
    {
        if( i % 2 == 1 )
        {
            b += 1;
        }
    }

    std::cout<< b / a;
    
}


Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > P;
int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a.at(i);
  sort(a.begin(),a.end());

  int tmp=a.at(0),cnt=1,ans=0;
  for(int i=1;i<n;i++)
  {
    if(a.at(i)==tmp)
    {
      cnt++;
    }
    else
    {
      if(cnt<tmp) ans+=cnt;
      else ans+=(cnt-tmp);

      tmp=a.at(i),cnt=1;
    }

    if(i==(n-1))
    {
      if(cnt<tmp) ans+=cnt;
      else ans+=(cnt-tmp);
    }
  }
  if(n==1)
  {
    if(a.at(0)==1) ans=0;
    else ans=1;
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
main(){
  int n,x,y;
  int i,j;
  cin >> n >> x >> y; 
  int dist[n-1] = {0};
  for(i=1;i<=n;i++)
    for(j=i+1;j<=n;j++)
      ++dist[ min(abs(j-i),abs(x-i)+1+abs(y-j))-1 ];
  for(i=0;i<n-1;i++){
    cout << dist[i] <<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ld  double
#define ll long long 
#define pp push
#define pb push_back
#define pf push_front
#define mp make_pair
#define inf 1e9
#define f first
#define s second
#define pll pair<ll,ll>
#define vll vector<ll>
#define vi vector<int>
#define mod 1000000007
using namespace std; 
const int MAXN = 1e5 + 10;

vector<int> grafo[MAXN];
int dp[MAXN],vis[MAXN],N,M;

int solve(int v){

	if(vis[v]) return dp[v];

	vis[v] = 1;
	int best = 0;

	for(int u : grafo[v]){
		best = max(best, solve(u) + 1 );
	}

	return dp[v] = best;

}

int main(){

	scanf("%d %d",&N,&M);
	for(int i = 1;i<=M;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		grafo[u].push_back(v);
	}

	int best = 0;
	for(int i = 1;i<=N;i++) best = max(best, solve(i) );
	printf("%d\n",best);

	return 0;

}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    int match[22] = {};
    int a;
    ll mod = 1000000007;
    Scd(N);

    Rep(i,N){
        Rep(j,N){
            Scd(a);
            match[i] <<= 1;
            match[i] += a;
        }
    }

    static ll dp[23][1<<21] = {};
    // dp[ni][bi]

    dp[0][0] = 1;

    Rep(ni,N)Rep(bi,1<<N){
        if( !dp[ni][bi] ) continue;
        for (int nni = 1; nni < 1<<N; nni<<=1 ){
            if( nni & bi ) continue;
            if( nni & match[ni] ){
                // printf ("?%d\n", bi);
                dp[ni+1][bi|nni] += dp[ni][bi];
                dp[ni+1][bi|nni] %= mod;
            }
        }
    }

    printf ("%llu\n", dp[N][(1<<N)-1]);
    return 0;
}



Measured memory_bytes: 311552
#include<bits/stdc++.h>
#define ll long long 
const int maxn=1e5+50;
const int maxm=maxn<<1;;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
using namespace std;
ll n,a[100005];
ll id[100005];
ll ent[100005];
map<ll,int> mp;
int main() 
{
    scanf("%lld",&n);
    int f0=0;
    for(int i=1;i<=n;i++)
    {
    	scanf("%lld",&a[i]);
    	if(a[i])
    		f0=1;
    }
    if(!f0)
    {
    	printf("Yes\n");
    	return 0;
    }
    int tot=0;
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)
    {
    	if(i==1)
    	{
    		id[++tot]=a[i];
    		ent[tot]++;
    	}
    	else
    	{
    		if(a[i]!=a[i-1])
    		{
    			id[++tot]=a[i];
    			ent[tot]++;
    		}
    		else
    		{
    			ent[tot]++;
    		}
    	}
    }
    if(tot>3||n%3!=0)
    {
    	printf("No\n");
    	return 0;
    }
    if(tot==3)
    {
    	if((id[1]^id[2]^id[3])==0&&ent[1]==n/3&&ent[2]==n/3&&ent[3]==n/3)
    	{
    		printf("Yes\n");
    		return 0;
    	}
    }
    if(tot==2)
    {
    	if(id[1]==0&&ent[1]==n/3&&ent[2]==n/3*2)
    	{
    		printf("Yes\n");
    		return 0;
    	}
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 2048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    // static int INF = (1 << 30) - 1;
    // static long L_INF = (1L << 62) - 1;
    // static long MOD = (long) 1e9 + 7;

    static class Solver {
        // グラフの隣接行列での表現。 (蟻本参照)
        // 辺があるかの判定: 定数時間
        // メモリ: |V|^2
        //
        // 無向グラフの場合、 g[i][j] == g[j][i] となるように設定する。
        // 有向グラフの場合、 i->jに向かう辺があるなら、g[i][j] == 1 となる。

        int MAX_V = 101;

        int N;
        int[][] G = new int[MAX_V][MAX_V];

        // write your code
        void solve(InputReader in, PrintWriter out) {
            N = in.nextInt();
            for (int i = 0; i < N; i++) {
                int u = in.nextInt() - 1;
                int k = in.nextInt();
                for (int j = 0; j < k; j++) {
                    int vi = in.nextInt() - 1;
                    G[i][vi] = 1;
                }
            }

            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    if (j != 0) {
                        out.print(" ");
                    }
                    out.print(G[i][j]);
                }
                out.println();
            }
        }

        void debug(Object... os) {
            System.err.println(Arrays.deepToString(os));
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}



Measured memory_bytes: 26824
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

void solve()
{
	string S;
	cin >> S;
	bool isUsed[26] = {false};
	for (int i = 0; i < S.length(); ++i)
	{
		isUsed[S[i] - 'a'] = true;
	}
	int minIndex = 0;
	bool isNothing = true;
	for (int i = 0; i < 26; ++i)
	{
		if (!isUsed[i])
		{
			minIndex = i;
			isNothing = false;
			break;
		}
	}
	if (isNothing)
	{
		cout << "None" << endl;
	}
	else
	{
		cout << char('a' + minIndex) << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a,a+n);
    int m=1000000000;
    for(int i=0;i<=n-k;i++) m=min(m,a[i+k-1]-a[i]);
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
 	
  int a,b;
  cin >> a >> b;
  int m = -1111;
  
  m = max(m,a+b);
  m = max(m,a-b);
  m = max(m,a*b);
  
  cout << m << endl;
}
  
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  string s;
  cin >> s;

  int n = s.length();

  int sCount = 0;
  int tCount = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'S') {
      sCount++;
    }
    else {
      if (sCount > 0) sCount--;
      else tCount++;
    }
  }

  int ans = sCount + tCount;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n;
  cin >> n;
  int res = 0;
  
  for(int i = 1; i <= n; i++){
    int cnt = 0;
    if(i%2){
      for (int j = 1; j <= n; j++){
        if(i%j == 0) cnt++;
      }
    }
    
    if(cnt == 8) res++;
  }
  
  cout << res;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 1145141919
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)

using namespace std;

int main(void){
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<char>());
  if(s<t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<cstdio>
using namespace std;
int main()
{
    int key;
    char s[1001];
    priority_queue<int>PQ;
    while(1){
            scanf("%s",s);
        if(s[0]=='i'){
            scanf("%d\n",&key);
            PQ.push(key);
        }else if(s[0]=='e'&&s[1]=='x'){
            printf("%d\n",PQ.top());
            PQ.pop();
        }else{
        break;
        }
    }
    return 0;
}

Measured memory_bytes: 6892
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int a, b, c;
	int k;
	int n;

	scanf("%d%d%d", &a, &b, &c);
	n = 0;
	for (k = a; k <= b; k++) {
		if (c % k == 0) n++;
	}
	printf("%d\n", n);
	return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

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

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    string s;
    cin >> n >> k >> s;
    s[k - 1] = tolower(s[k - 1]);
    cout << s;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		for(int i = S.length() - 1; i > 0; i--) {
			String T = S.substring(0, i);
			if(T.length() % 2 == 0) {
				String former = T.substring(0, T.length() / 2);
				String latter = T.substring(T.length() / 2, T.length());
				if(former.equals(latter)) {
					System.out.println(T.length());
					return;
				}else {
					continue;
				}
			}else {
				continue;
			}
		}
	}

}

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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int r, c, k;
	cin >> r >> c >> k;
	vector<vector<int>> g(r, vector<int>(c));
	for (int i = 0, R, C, v; i < k; i++) {
		cin >> R >> C >> v;
		g[R - 1][C - 1] = v;
	}
	
	vector<vector<vector<long long>>> dp(r, vector<vector<long long>>(c, vector<long long>(4)));
	dp[0][0][1] = g[0][0];
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			if (i != r - 1) {
				for (int k = 0; k < 4; k++) {
					dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
					dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][k] + g[i + 1][j]);
				}
			}
			if (j != c - 1) {
				for (int k = 0; k < 4; k++) {
					dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
					if (k != 3) dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], dp[i][j][k] + g[i][j + 1]);
				}
			}
		}
	}
	long long ans{};
	for (int i = 0; i < 4; i++) ans = max(ans, dp[r - 1][c - 1][i]);
	cout << ans;
}

Measured memory_bytes: 671416
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define ITER( c ) __typeof( c ).begin()
#define REP( i, m, n ) for ( int i = m; i < n; i++ )
#define UREP( i, m, n ) for ( unsigned int i = m; i < n; i++ )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) c.begin(), c.end()
#define PB( n ) push_back( n );
#define MP( a, b ) make_pair( a, b )
#define fst first
#define snd second

int main()
{
	int n;
	cin >> n;
	cin.ignore( 1 );

	REP( i, 0, n )
	{
		string line;
		getline( cin, line );

		while ( true )
		{
			int pos = line.find( "Hoshino", 0 );
			if ( pos == string::npos )
			{
				break;
			}
			else
			{
				line.replace( pos, 7, "Hoshina" );
			}
		}

		cout << line << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1440

struct Info{
	Info(int arg_end_time,int arg_live_value,int arg_record_value){
		end_time = arg_end_time;
		live_value = arg_live_value;
		record_value = arg_record_value;
	}
	int end_time,live_value,record_value;
};

int N;
int dp[NUM][NUM];
vector<Info> G[NUM];

int get_time(char buf[6]){
	int hour = 10*(buf[0]-'0')+buf[1]-'0';
	int minute = 10*(buf[3]-'0')+buf[4]-'0';
	return 60*hour+minute;
}

int recursive(int live_time,int record_time){

	if(dp[live_time][record_time] != -1){
		return dp[live_time][record_time];
	}

	int ret = 0;

	if(live_time < record_time){

		ret = max(ret,recursive(live_time+1,record_time));

		for(int i = 0; i < G[live_time].size(); i++){

			ret = max(ret,recursive(G[live_time][i].end_time,record_time)+G[live_time][i].live_value);
		}

		return dp[live_time][record_time] = ret;

	}else if(live_time > record_time){

		ret = max(ret,recursive(live_time,record_time+1));

		for(int i = 0; i < G[record_time].size(); i++){
			ret = max(ret,recursive(live_time,G[record_time][i].end_time)+G[record_time][i].record_value);
		}
		return dp[live_time][record_time] = ret;

	}else{ //live_time == record_time

		if(live_time == NUM-1){

			return 0;
		}

		ret = max(ret,recursive(live_time+1,record_time+1));

		for(int i = 0; i < G[live_time].size(); i++){
			ret = max(ret,recursive(G[live_time][i].end_time,record_time+1)+G[live_time][i].live_value);
		}

		for(int i = 0; i < G[record_time].size(); i++){
			ret = max(ret,recursive(live_time+1,G[record_time][i].end_time)+G[record_time][i].record_value);
		}

		if(G[live_time].size() > 1){
			for(int i = 0; i < G[live_time].size(); i++){
				for(int k = 0; k < G[live_time].size(); k++){
					if(k == i)continue;

					ret = max(ret,recursive(G[live_time][i].end_time,G[live_time][k].end_time)+
							G[live_time][i].live_value+G[live_time][k].record_value);

				}
			}
		}
		return dp[live_time][record_time] = ret;
	}
}

void func(){

	for(int i = 0; i < NUM; i++){
		G[i].clear();
	}

	int live_value,record_value,start_time,end_time;
	char name[33],start_buf[6],end_buf[6];

	for(int loop = 0; loop < N; loop++){

		scanf("%s %s %s %d %d",name,start_buf,end_buf,&live_value,&record_value);
		start_time = get_time(start_buf);
		end_time = get_time(end_buf);

		G[start_time].push_back(Info(end_time,live_value,record_value));
	}

	for(int i = 0; i < NUM; i++){
		for(int k = 0; k < NUM; k++){
			dp[i][k] = -1;
		}
	}

	printf("%d\n",recursive(0,0));
}

int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}



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

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> c.at(i);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (v.at(i) > c.at(i)) ans += v.at(i) - c.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# なぜかうまくいかない
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_right, bisect_left

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, Q = MAP()
S = [INT() for i in range(A)]
T = [INT() for i in range(B)]
X = [INT() for i in range(Q)]
S.insert(0, -INF)
S.append(INF)
T.insert(0, -INF)
T.append(INF)

for x in X:
    s = bisect(S, x)
    t = bisect(T, x)
    # print(s, t)
    # a = min(x - S[s-1], S[s] - x)
    # b = min(x - T[t-1], T[t] - x)
    res = INF
    for a in [S[s-1], S[s]]:
        for b in [T[t-1], T[t]]:
            res = min(res, min(abs(a - x) + abs(b - a), abs(x - b) + abs(b - a)))
    print(res)    
    



Measured memory_bytes: 19680
import sys
import queue
bbn=1000000007
	
#+++++

		
def main():
	s = input()
	ll=[]
	for c in s:
		if c == 'B':
			if len(ll) != 0:
				ll.pop(-1)
				
		else:
			ll.append(c)
			
	ret=''.join(ll)
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define MAXN 205
#define eps 1e-8
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,a[MAXN],s;
void Solve() {
    read(N);
    s = 0;
    for(int i = 0 ; i < N ; ++i) {read(a[i]);s += a[i];}
    int t = 0;
    for(int i = 1 ; i < N ; ++i) {
	if(abs(a[i] * N - s) < abs(a[t] * N - s)) t = i;
    }
    out(t);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int n; cin >> n;
	int arr[n];
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	int count = 0;
	for(int i = 1; i < n-1; i++)
	{
		int num = arr[i];
		if((arr[i - 1] > num && arr[i + 1] < num)  ||  (arr[i - 1] < num && arr[i + 1] > num))
		{
			count++;
		}
	}
	cout<<count;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

const int MOD = 1e9+7;
const int MAXR = 1010000;

template<ll mod> class modint{
public:
    ll val=0;
    //コンストラクタ
    modint(ll x=0){while(x<0)x+=mod;val=x%mod;}
    //コピーコンストラクタ
    modint(const modint &r){val=r.val;}
    //算術演算子
    modint operator -(){return modint(-val);} //単項
    modint operator +(const modint &r){return modint(*this)+=r;}
    modint operator -(const modint &r){return modint(*this)-=r;}
    modint operator *(const modint &r){return modint(*this)*=r;}
    modint operator /(const modint &r){return modint(*this)/=r;}
    //代入演算子
    modint &operator +=(const modint &r){
        val+=r.val;
        if(val>=mod)val-=mod;
        return *this;
    }
    modint &operator -=(const modint &r){
        if(val<r.val)val+=mod;
        val-=r.val;
        return *this;
    }
    modint &operator *=(const modint &r){
        val=val*r.val%mod;
        return *this;
    }
    modint &operator /=(const modint &r){
        ll a=r.val,b=mod,u=1,v=0;
        while(b){
            ll t=a/b;
            a-=t*b;swap(a,b);
            u-=t*v;swap(u,v);
        }
        val=val*u%mod;
        if(val<0)val+=mod;
        return *this;
    }
    //等価比較演算子
    bool operator ==(const modint& r){return this->val==r.val;}
    bool operator <(const modint& r){return this->val<r.val;}
    bool operator !=(const modint& r){return this->val!=r.val;}
};

using mint = modint<MOD>;

//入出力ストリーム
istream &operator >>(istream &is,mint& x){//xにconst付けない
    ll t;is >> t;
    x=t;
    return (is);
}
ostream &operator <<(ostream &os,const mint& x){
    return os<<x.val;
}

//累乗
mint modpow(const mint &a,ll n){
    if(n==0)return 1;
    mint t=modpow(a,n/2);
    t=t*t;
    if(n&1)t=t*a;
    return t;
}

//二項係数の計算
mint fac[MAXR+1],finv[MAXR+1],inv[MAXR+1];
//テーブルの作成
void COMinit() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    FOR(i,2,MAXR){
        fac[i]=fac[i-1]*mint(i);
        inv[i]=-inv[MOD%i]*mint(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}
//演算部分
mint COM(ll n,ll k){
    if(n<k)return 0;
    if(n<0)return 0;
    if(k==0) return 1;
    return fac[n]*finv[k]*finv[n-k];
}

int main() {
    COMinit();
    int X,Y; cin >> X >> Y;

    int r,u;

    if((2*Y-X)%3!=0 || (2*Y-X)<0){
        cout << 0 << endl;
        return 0;
    }
    if((2*X-Y)%3!=0 || (2*X-Y)<0){
        cout << 0 << endl;
        return 0;
    }
    r = (2*Y-X)/3;
    u = (2*X-Y)/3;
    cout << COM(r+u, r) << endl;

    return 0;
}
//x+2y = X, 2x+y = Yとなるx,y,を求める

Measured memory_bytes: 27316
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){

    int N, T;
    cin >> N >> T;
    map<int, int> mp;

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

    for(auto m: mp){
        if(m.second <= T){
            cout << m.first << endl;
            return 0;
        }
    }
    cout << "TLE" << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
C = []
S = []
F = []
T = [0 for i in range(N)]

for i in range(N - 1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(1, N):
    time = 0
    if i == 1:
        time = S[-i] + C[-i]
    else:
        time = S[-i] + C[-i]
        for j in range(1, i):
            if time < S[-(i - j)]:
                time = S[-(i - j)] + C[-(i - j)]
            else:
                dev = (time - S[-(i - j)]) % F[-(i - j)]
                if dev != 0:
                    time = (time + (F[-(i - j)] - dev) + C[-(i - j)])
                else:
                    time = time + C[-(i - j)]
    T[-(i + 1)] = time

for t in T:
    print(t)


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

int main()
{
  string S, T;
  cin >> S >> T;
  bool can = true;
  map<char, int> smp, tmp; //mapで各アルファベットの出現数を記録

  for (int i = 0; i < S.size(); i++)
  {
    smp[S.at(i)]++;
    tmp[T.at(i)]++;
  }
  vector<int> scnt(26);
  vector<int> tcnt(26);
  int j = 0;
  for (auto itr = smp.begin(); itr != smp.end(); itr++)
  {
    scnt.at(j) = itr->second;
    j++;
  }
  int k = 0;
  for (auto itr = tmp.begin(); itr != tmp.end(); itr++)
  {
    tcnt.at(k) = itr->second;
    k++;
  }
  sort(scnt.begin(), scnt.end());
  sort(tcnt.begin(), tcnt.end());
  for (int l = 0; l < 26; l++)
  {
    if (scnt.at(l) != tcnt.at(l))
    {
      can = false;
      break;
    }
  }
  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 776
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using Graph = std::vector<std::vector<int> >;
const int INF = 1e17;
/* libraries */

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


signed main() {
	int k;
	std::cin >> k;
	int sum = 0;
	for(int a=1;a<=k;a++) 
		for(int b=1;b<=k;b++) 
			for(int c=1;c<=k;c++) {
				sum+=gcd(gcd(a,b),c);
			}
	print(sum);
	return 0;
}


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

void joint(int i,vector<vector<int>> &edge,vector<int> &checked,vector<int> &group){
    checked[i]=true;
    group.push_back(i);
    for(int j=0;j<edge[i].size();j++){
        if(!checked[edge[i][j]]){
            joint(edge[i][j],edge,checked,group);
        }
    }


}

int main(){
    int n,k,l;
    cin>>n>>k>>l;
    vector<int> p(k),q(k),r(l),s(l);
    vector<vector<int>> kedge(n);
    vector<vector<int>> ledge(n);
 
   for(int i=0;i<k;i++) {
        cin>>p[i]>>q[i];
        p[i]--,q[i]--;
        kedge[p[i]].push_back(q[i]);
        kedge[q[i]].push_back(p[i]);
    }
    for(int i=0;i<l;i++) {
        cin>>r[i]>>s[i];
        r[i]--,s[i]--;
        ledge[r[i]].push_back(s[i]);
        ledge[s[i]].push_back(r[i]);
    }
    vector<int> kchecked(n,0);
    vector<vector<int>> kgroup;
    for(int i=0;i<n;i++){
        if(!kchecked[i]){
            vector<int> groupi;
            joint(i,kedge,kchecked,groupi);
            kgroup.push_back(groupi);
        }
    }
    vector<int> lchecked(n,0);
    vector<vector<int>> lgroup;
    for(int i=0;i<n;i++){
        if(!lchecked[i]){
            vector<int> groupi;
            joint(i,ledge,lchecked,groupi);
            lgroup.push_back(groupi);
        }

    }
    vector<int> mapl(n);
    for(int i=0;i<lgroup.size();i++){
        for(int j=0;j<lgroup[i].size();j++){
            mapl[lgroup[i][j]]=i;
        }
    }
    vector<int> mapk(n);
    for(int i=0;i<kgroup.size();i++){
        for(int j=0;j<kgroup[i].size();j++){
            mapk[kgroup[i][j]]=i;
        }
    }
    vector<pair<int,int>> pp(n);
    for(int i=0;i<n;i++) {
        pp[i]=make_pair(mapk[i],mapl[i]);
    }
    vector<pair<int,int>> qq=pp;
    sort(pp.begin(),pp.end());
    for(int i=0;i<n;i++){
        cout<<upper_bound(pp.begin(),pp.end(),qq[i])-lower_bound(pp.begin(),pp.end(),qq[i])<<endl;
    }

    return 0;
}
                     

Measured memory_bytes: 40620
import math

pi = math.pi
a = input()
a = a.split()
A = float(a[0])
B = float(a[1])
H = float(a[2])
M = float(a[3])
Ab = H*5 + 5/60*M
Ar = 2*pi * Ab / 60
Br = 2*pi * M / 60
if Ar > Br:
    Cr = Ar - Br
else:
    Cr = Br - Ar
if Cr > pi:
    Cr = 2*pi - Cr
ans = A**2 + B**2 - 2*A*B*math.cos(Cr)
print(math.sqrt(ans))


Measured memory_bytes: 9392
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

const int N = 111111;
int p[N], q[N];
vector<pair<int, int> > v;
int w, h;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> w >> h;
    rep(i, 1, w) {
        cin >> p[i];
    }
    rep(i, 1, h) {
        cin >> q[i];
    }
    rep(i, 1, w) {
        v.pb({p[i], 0});
    }
    rep(i, 1, h) {
        v.pb({q[i], 1});
    }
    sort(rng(v));
    int r = 0, c = 0, ans = 0;
    rall(pa, v) {
        bool row = pa.se;
        int x = pa.fi;
        if(row) {
            ans += (w - r + 1) * x;
            c++;
        } else {
            ans += (h - c + 1) * x;
            r++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8168
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    K = int(input())

    def dfs(depth, max_depth, num):
        if depth==max_depth:
            lunlun_temp.append(''.join([str(i) for i in num]))
        elif depth==0:
            for i in range(1, 10):
                dfs(depth+1, max_depth, num+[i])
        else:
            for i in range(3):
                if 0<=num[-1]-1+i<=9:
                    dfs(depth+1, max_depth, num+[num[-1]-1+i])

    lunlun = []

    i = 1
    while len(lunlun)<K:
        lunlun_temp = []
        dfs(0, i, [])
        lunlun += lunlun_temp
        i += 1

    print(lunlun[K-1])

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 18496
n = int(input())
a = [int(x) for x in input().split()]

res = 1
increasing = True
decreasing = True

for i in range(n):
    if i > 0:
        if a[i - 1] > a[i]:
            increasing = False
        if a[i - 1] < a[i]:
            decreasing = False
    if not (increasing or decreasing):
        res += 1
        increasing = True
        decreasing = True
print(res)


Measured memory_bytes: 14252
#include <iostream>
using namespace std;
int main(void) {
	int S;
	cin >> S;
	int h, m, s;
	h = (S / 60) / 60;
	m = (S / 60) % 60;
	s = S % 60;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}

Measured memory_bytes: 1164