akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void mul(ll &x, ll y){
	x *= y;
	x %= mod;
}
 
void add(ll &x, ll y){
	x = x + y + mod;
	x %= mod;
}
ll binpow(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

void solve(){
	int n;
	cin>>n;
	int a[n];
	rep(i,n)cin>>a[i];
	int ans=1e8,id=-1;
	for(int j=1;j<=100;j++){
		int mx=0;
		for(int i=0;i<n;i++){
			mx+=abs(a[i]-j)*abs(a[i]-j);
		}
		if(mx<ans){
			ans=mx;
			id=j;
		}
	}	
	cout<<ans;
	//<<id;


}


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

string change(string s,int n){
	string ret(s);
	rep(i,0,ret.size()){
		if(ret[i]>='a' && ret[i]<='z'){
			if(ret[i]+n>'z') ret[i]+=n-26;
			else ret[i]+=n;
		}
	}
	return ret;
}

int main(){
	string s;
	string str[3]={"this","that","the"};
	string stu[2]={" ","."};
	while(getline(cin,s)){
		bool f=0;
		rep(i,0,26){
			string t;
			t=change(s,i);
			rep(j,0,3){
				rep(k,0,2){
					if(t.find(str[j]+stu[k])!=string::npos){
						o(t); f=1; break;
					}
				}
				if(f) break;
			}if(f) break;
		}
	}
}

Measured memory_bytes: 1184
<?php

$s = trim(fgets(STDIN));
$count = 0;
for($i=0;$i<strlen($s);$i++){
    if(substr_count($s,$s[$i]) <= 1 || substr_count($s,$s[$i]) > 3){
        $count ++;
    }
}
if($count >0){
    echo "No\n";
}else{
    echo "Yes\n";
}



Measured memory_bytes: 4728
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split()))for i in range(n)]
cnt=0
for i in range(n):
    x=0
    for j in range(m):
        x+=a[i][j]*b[j]
    if x+c>0:
        cnt+=1
print(cnt)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();
		int T[] = new int[N];
		for(int i = 0; i < N; i++) {
			T[i] = sc.nextInt();
		}
		
		Arrays.sort(T);
		
		int ans = 0;
		int cnt = 0;
		int time = 0;
		for(int i = 0; i < N; i++) {
			if(cnt == 0) {
				time = T[i];
			}
			cnt++;
			if(cnt >= C || (i < N - 1 && T[i + 1] - time > K)) {
				cnt = 0;
				time = 0;
				ans++;
			}
		}
		if(cnt > 0) {
			ans++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 50408
#include<cstdio>
using namespace std;

typedef double D;

int n,a[110],r;
D b,v,e,f;
D dp[10100][110];
const D EPS = 1e-8;

int main(){
  while(scanf("%d",&n),n){
    a[0] = 0;
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    scanf("%lf%d%lf%lf%lf",&b,&r,&v,&e,&f);

    for(int i=0;i<=a[n];i++)
      for(int j=0;j<=n;j++)dp[i][j] = 1e15;
    dp[0][0] = 0;

    int pos = 1;
    for(int i=0;i<a[n];i++){
      if(i==a[pos]){
	for(int j=0;j<pos;j++){
	  if(dp[i][pos] > dp[i][j] + b + EPS){
	    dp[i][pos] = dp[i][j] + b;
	  }
	}
	pos++;
      }

      for(int j=0;j<=n;j++){
	int x = i-a[j];
	D cost = (x<r)?(1.0/(v-f*(r-x))):(1.0/(v-e*(x-r)));
	if(dp[i+1][j] > dp[i][j] + cost + EPS){
	  dp[i+1][j] = dp[i][j] + cost;
	}
      }
    }
    
    D res = 1e15;
    for(int i=0;i<=n;i++){
      if(res > dp[a[n]][i] + EPS)res = dp[a[n]][i];
    }
    printf("%.10lf\n",res);
  }
}

Measured memory_bytes: 9688
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && a != c) {
        cout << "Yes" << endl;
    }
    else if (b == c && a != b) {
        cout << "Yes" << endl;
    }
    else if (a == c && a != b) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from collections import Counter
    n=int(input())
    A=list(Counter(map(int,input().split())).values())
    A.sort()
    m=len(A)
    S=[0]*(m+1) # cumulative distribution
    for i in range(m): S[i+1]=S[i]+A[i]
    # output
    p=n
    i=m-1
    from bisect import bisect_left
    for k in range(1,n+1):
        while(1):
            # pに対して先にi_pを求めておく
            i=bisect_left(A,p)
            if(S[i]+p*(m-i)>=k*p): break
            p-=1 # pの条件が真になるまで減らし続ける
        print(p)
resolve()

Measured memory_bytes: 120476
using System;
class Program
{

static string[] input = Console.ReadLine().Split(' ');
static int n = int.Parse(input[0]);
static int m = int.Parse(input[1]);
static int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
static int[] parents = new int[n];//親
  
	static void Main()
	{
    int answer = 0;
    
    for(int i = 1; i < n; i++)
    {
    parents[i] = i;
    }
  
    for(int i = 0; i < m; i++)
    {
      int[] edges = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
      
        if(whatParent(edges[0]-1) != whatParent(edges[1]-1))
          parents[whatParent(edges[0]-1)] = whatParent(edges[1]-1);//親を結合して統一。親が2人できることはない。
      
    }

    for(int i = 0; i < n; i++)
    {
      if(whatParent(nums[i]-1) == whatParent(nums[nums[i]-1]-1)) answer++;
    }

    Console.WriteLine(answer);
    
	}

  static int whatParent(int child)
  {
    if(parents[child] == child) return child;
    else return parents[child] = whatParent(parents[child]);
  }
  
}

Measured memory_bytes: 24544
# B

inputs = input().split(' ')

d = inputs[0:2]
takahashi = {'Name': 'Takahashi', 'Hp': int(d[0]), 'Power': int(d[1])}
d = inputs[2:4]
aoki = {'Name': 'Aoki', 'Hp': int(d[0]), 'Power': int(d[1])}

players = [takahashi, aoki]

def compute(players):
    N =len(players)
    while True:
        for i in range(N):
            players[i-1]['Hp'] -= players[i]['Power']
            if players[i-1]['Hp'] <= 0:
                if players[i]['Name'] == 'Takahashi':
                    print('Yes')
                else:
                    print('No')
                return 

compute(players)

Measured memory_bytes: 9224
<?php
// Here your code !
    $n = fgets(STDIN);
    $prime = array();
    $prime[0] = 2;
    for($i=3;$i<=1000;$i+=2){
        $flag = 1;
        foreach ($prime as $value) {
            if($i % $value == 0){;
                $flag = 0;
            }
        }
        if($flag == 1){
            array_push($prime,$i);
        }
    }
    
    $check = array();
    $temp = 0;
    for($i = 1; $i<=$n; $i++){
        foreach ($prime as $value) {
            $temp = $i;
            while($temp % $value == 0){
                $check[$value]++;
                $temp = $temp / $value;
            }
        }
    }
    
//    var_dump($check);
    
    $answer = 1;
    foreach ($check as $value) {
        $answer = $answer * ($value + 1);
        $answer = $answer % 1000000007;
        if($answer<0){
        $answer += 1000000007;
    }
    }
    
//    while($answer > 1000000007){
//        $answer -= 1000000007;
//    }

    echo $answer;
?>


Measured memory_bytes: 3700
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>

using namespace std;

string s;

int valid(int foot, int a, int b) {
    if (foot) {
        if (a == 1) return 0;
        else if (a == 2) {
            if (b != 1 ) return 0;
            else return 1;
        }
        else {
            if (b == 0) return 0;
            else return 1;
        }
    }
    else {
        if (a == 0) return 0;
        else if (a == 2) {
            if (b != 0) return 0;
            else return 1;
        }
        else {
            if (b == 1) return 0;
            else return 1;
        }
    }
}

int check(int f) {
    vector<int> dp(s.size()+1, 1e9);
    dp[0] = 0;
    
    for (int i = 1; i < s.size(); i++) {
        int now = (s[i-1]-'0') % 3;
        int next = (s[i]-'0') % 3;
        int foot;
        (i%2) == f ? foot = 1 : foot = 0;
        int v = valid(foot,now,next);
        if (v) f = (f+1)%2;
        dp[i] = min(dp[i], dp[i-1] + v);
    }
    return dp[s.size()-1];
}

int main(void){
    while (cin>>s && s[0] != '#') {
        
        int ans = min(check(0), check(1));
        cout << ans << endl;
    }
}

Measured memory_bytes: 3380
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int h,w,k;
vector<vector<char>> c;
vvi v;
queue<pii> q;
queue<int> qw;

void f(){
	while(!q.empty()){
		pii tmp=q.front();
		q.pop();
		
		int y=tmp.first;
		int x=tmp.second;
		int num=v[y][x];
		
		for(int i=x-1;i>=0;--i){
			if(v[y][i]!=-1) break;
			v[y][i]=num;
		}
		for(int i=x+1;i<w;++i){
			if(v[y][i]!=-1) break;
			v[y][i]=num;
		}
	}
}

void g(){
	stack<int> st;
	int hoge=-1;
	while(!qw.empty()){
		int y=qw.front();
		qw.pop();
		if(y==0){
			st.push(y);
			hoge=y;
		}else{
			if(y-1==hoge){
				st.push(y);
				hoge=y;
			}else{
				REP(i,w) v[y][i]=v[y-1][i];
			}
		}
	}
	
	while(!st.empty()){
		int y=st.top();
		st.pop();
		REP(i,w) v[y][i]=v[y+1][i];
	}
}

int main(){
	cin>>h>>w>>k;
	
	c.assign(h,vector<char>(w));
	v.assign(h,vi(w,-1));
	int num=1;
	REP(i,h){
		int cnt=0;
		REP(j,w){
			cin>>c[i][j];
			if(c[i][j]=='#'){
				v[i][j]=num++;
				q.emplace(i,j);
				cnt++;
			}
		}
		if(cnt==0) qw.push(i);
	}
	
	f();
	g();
	
	REP(i,h) line(v[i]);
}


Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


ll n, k, sum;
vector<ll> list, s;
int main() {
	cin >> n >> k;
	s.resize(n);
	REP(i, n) {
		cin >> s[i];
		sum += s[i];
	}
	for (int i = 1; i <= sqrt(sum); i++){
		if (sum % i == 0) {
			list.push_back(i);
			list.push_back(sum / i);
		}
	}
	sort(ALL(list), greater<ll>());
	REP(j, list.size()) {
		vector<ll> now;
		ll a[510] = {}, b[510] = {};
		REP(i, s.size()) {
			now.push_back(s[i] % list[j]);
		}
		sort(ALL(now));
		REP(i, n) {
			a[i + 1] += a[i] + now[i];
		}
		REPR(i, n - 1) {
			b[i] += b[i + 1] + list[j] - now[i];
		}
		REP(i, n + 1) {
			if (max(a[i], b[i]) <= k) {
				cout << list[j] << endl;
				return 0;
			}
		}
	}
}
	


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

int main() {
	char s[3005],t[3005];
	scanf("%s%s",s,t);
	int m=strlen(s),n=strlen(t);
	int dp[m+1][n+1];
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			if(s[i-1]==t[j-1])dp[i][j]=dp[i-1][j-1]+1;
			else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
		}
	}
	string ans;
	int i=m,j=n;
	while(i>0&&j>0){
		if(s[i-1]==t[j-1]){ans.push_back(s[i-1]);i--; j--;}
		else if(dp[i][j]==dp[i][j-1])j--;
		else i--;
	}
	reverse(ans.begin(),ans.end());
	printf("%s",ans.c_str());
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int k;
    cin >> k;
    int ans = 0;
    
    for(int a = 1; a <= k; a++) {
        for(int b = 1; b <= k; b++) {
            for(int c = 1; c <= k; c++) {
                ans += __gcd(__gcd(a, b), c);
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3652
from collections import deque
S = list(input())
Q = int(input())

day = deque(S)

r = False
for i in range(Q):
    x = input().split()
    
    if x[0] == "1":
        r = not r
        
    else:
        if x[1] == "1":
            if r == False :
                day.appendleft(x[2])
            else:
                day.append(x[2])
        else:
            if r == True :
                day.appendleft(x[2])
            else:
                day.append(x[2])
                
day = list(day)
        
if r:
    print("".join(day[::-1]))
else:
    print("".join(day))

Measured memory_bytes: 10868
#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<ll,ll>;

vector<ll> a;
vector<ll> b;
vector<ll> c;
vector<ll> d;
ll n,m,q;
ll ans=0;
void dfs(vector<ll>A){
  if (A.size()==n+1){
    ll now=0;
    rep(i,q){
      if ((A[a[i]]+c[i])==A[b[i]]){
        now+=d[i];
      }
    }
    ans=max(ans,now);
    return;
  }
  A.push_back(A.back());
  while(A.back()<=m){
    dfs(A);
    A.back()++;
  }
}

int main() {

  cin>>n>>m>>q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);
  rep(i,q){
    ll a1,b1,c1,d1;
    cin>>a[i]>>b[i]>>c[i]>>d[i];
  }
  dfs(vector<ll>(1,1));
  cout<<ans;


}


Measured memory_bytes: 3600
rgbn = list(map(int, input().split()))
R = rgbn[0]
G = rgbn[1]
B = rgbn[2]
N = rgbn[3]
res = 0
r = 0
while R * r <= N:
    b = 0
    while B * b <= N - R * r:
        if (N - R * r -B * b) % G == 0:
            res += 1
        b += 1
    r += 1
print(res)


Measured memory_bytes: 40556
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <deque>
#include <vector>
using namespace std;
#define FO(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
#define ll long long
#define ull unsigned ll
#define db double
#define lb long db
#define pb push_back
#define com complex<db>
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define cle(x) memset(x,0,sizeof(x))
#define DEBUG(x) cout<<#x<<"="<<x<<endl;
#define fo(i,j,k) for(int i=(j),end_i=(k);i<=end_i;i++)
#define fd(i,j,k) for(int i=(j),end_i=(k);i>=end_i;i--)
inline ll read()
{
	ll x=0; char ch=getchar(); bool f=0;
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<3)+(x<<1)+(ch^48);
	return f?-x:x;
}
#define CASET fo(___,1,read())
ll n,a,b;
int main()
{
	n=read(); a=read(); b=read();
	if((b-a)%2==0) printf("%lld",(b-a)/2);
	else printf("%lld",min(a-1,n-b)+(abs(a-b)+1)/2);
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0

for i in range(N):
    left = 0
    right = 0
    for j in range(N):
        if A[i] > A[j]:
            if j < i:
                left += 1
            else:
                right += 1
    
    ans += right * K * (K+1) // 2
    ans += left * K * (K-1) // 2

print(ans % (10**9+7))

Measured memory_bytes: 3188
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 6
double p[2][N];

double calc(double x){
	double y = 0.0;
	//rep(i, N) y += (x*x*p[0][i]*p[0][i]+(1-x)*(1-x)*p[1][i]*p[1][i])/(x*p[0][i]+(1-x)*p[1][i]);
	//rep(i, N) y += (x*x*p[0][i]*p[0][i]+(1-x)*(1-x)*p[1][i]*p[1][i]);
	rep(i, N) y += max(x*p[0][i], (1-x)*p[1][i]);
	return y;
}

int main(){
	rep(j, 2) rep(i, N){ cin>>p[j][i]; p[j][i] /= 100.0; }
	double lb = 0.0, ub = 1.0;
	rep(_, 1000){
		double lb2 = (lb*2+ub)/3, ub2 = (lb+ub*2)/3;
		double a = calc(lb2), b = calc(ub2);
		if(a<b) ub = ub2;
		else lb = lb2;
	}
	cout.precision(20);
	cout<<calc(lb)<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
aa = list(map(int,input().split()))

a = []
for i in range(n):
    a.append(aa[i]-(i+1))
b = list(sorted(a))

ans = 0

for i in range(n//2):
    ans += b[-i-1] - b[i]
print(ans)
    

Measured memory_bytes: 25196
#include <stdio.h>

int main(void){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a+b==15){
    printf("+");
    return 0;
  }
  
  if(a*b==15){
    printf("*");
    return 0;
  }

  printf("x");
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int n;
int r[100], c[100];
int dp[101][101];

int main(void)
{
	int i, j, w, m;
	
	for (i = 0; i < 101; i++){
		for (j = 0; j < 101; j++){
			dp[i][j] = 1 << 28;
		}
	}
	for (i = 0; i < 100; i++){
		dp[i][i + 1] = 0;
	}
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%d %d", &r[i], &c[i]);
	}
	
	for (w = 2; w <= n; w++){
		for (i = 0; i + w <= n; i++){
			for (m = i + 1; m < i + w; m++){
				if (dp[i][i + w] > dp[i][m] + dp[m][i + w] + r[i] * r[m] * c[i + w - 1]){
					dp[i][i + w] = dp[i][m] + dp[m][i + w] + r[i] * r[m] * c[i + w - 1];
				}
			}
		}
	}
	
	printf("%d\n", dp[0][n]);
}

Measured memory_bytes: 1064
N,A,B = map(int, input().split())
tot=0
for i in range(1,N+1):
    i_s = str(i)
    keta_sum = 0
    for j in range(len(i_s)):
        keta_sum+=int(i_s[j])
    if (A<=keta_sum)&(keta_sum<=B):
        tot+=i
print(tot)

Measured memory_bytes: 40176
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <set>

#define DEBUG 0

#define lli long long unsigned int
#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(){

	lli n,k;
	vector<lli> a;
	map<lli,lli> data;
	priority_queue<int, vector<int>, greater<int> > q;
	cin>>n>>k;
	REP(i,n){
		lli tmpA;
		cin>>tmpA;
		data[tmpA]++;
	}

	for(auto itr = data.begin();itr != data.end();itr++){
		q.push((*itr).second);
		if(DEBUG)cout<<"first="<<(*itr).first<<" second="<<(*itr).second<<endl;
	}

	lli ans=0;
	while(q.size() > k){
		ans += q.top();
		q.pop();
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 13944
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():

    return

#B
def B():
    n,m = LI()
    f = [1]*n
    l = [0]*n
    l[0] = 1
    for i in range(m):
        x,y = LI()
        x -= 1
        y -= 1
        if l[x]:
            l[y] = 1
        f[x] -= 1
        f[y] += 1
        if f[x] == 0:
            l[x] = 0
    ans = 0
    for i in range(n):
        if l[i]:
            ans += 1
    print(ans)
    return

#C
def C():
    n,l = LI()
    a = LI()
    for i in range(n-1):
        if a[i]+a[i+1] >= l:
            break
    else:
        print("Impossible")
        return
    ans = list(range(1,i+1))+list(range(i+2,n))[::-1]+[i+1]
    print("Possible")
    for i in ans:
        print(i)
    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 60016
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val nm    = inputs(0).split(" ").map(_.toInt)
  val n     = nm(0)
  val m     = nm(1)
  val lines = inputs.tail

  solve(n, m, lines)

  def solve(n: Int, m: Int, lines: Seq[String]): Unit = {
    var filtered = lines.filter(_.contains('#'))
    val size     = filtered.size
    var v        = scala.collection.mutable.ArrayBuffer.empty[Int]

    (0 until m).foreach { i =>
      if((0 until size).map { j =>
        filtered(j)(i)
      }.contains('#')) {
        v.append(i)
      }
    }

    filtered.foreach { s =>
      s.zipWithIndex.foreach { case (c, i) =>
        if(v.contains(i)) {
          print(c)
        }
      }
      println()
    }
  }
}

Measured memory_bytes: 59452
#include<iostream>
int main(){
  long long int L,R,r,l,min=2019;
  std::cin>>L>>R;
  l=L%2019;
  r=R%2019;
  if(l>=r||R-L>=2019){
      std::cout<<'0'<<std::endl;
      return 0;
  }
  for(int i=l;i<r;i++){
      for(int j=i+1;j<=r;j++){
        if(min>(i*j)%2019) min=(i*j)%2019;
      }
    }
  std::cout<<min<<std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=1000000007;
ll MOD=998244353;
int inf=1000001000;
ll INF=2e18+17;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if (abs(a-b)>abs(a-c)) cout << "B" << endl;
    else cout << "A" << endl;
}

Measured memory_bytes: 256
s = input()
k = int(input())
n = len(s)

substring = []

for i in range(min(n, k)):
    for j in range(n-i+1):
        substring.append(s[j:j+i+1])
        #print(s[j:j+i+1], j, j+i+1)

substring = list(set(substring))
substring.sort()
substring.pop(0)

print(substring[k-1])

Measured memory_bytes: 5068
#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<pair<int, vector<int>>> ks(M, pair<int, vector<int>>());
    for (int i = 0; i < M; i++)
    {
        cin >> ks[i].first;
        for (int j = 0; j < ks[i].first; j++)
        {
            int t;
            cin >> t;
            ks[i].second.push_back(t - 1);
        }
    }
    vector<int> p(M, 0);
    for (int i = 0; i < M; i++)
    {
        cin >> p[i];
    }
    int result = 0;
    for (int i = 0; i < (1 << N); i++)
    {
        vector<int> sw(N + 1, 0);
        for (int j = 0; j <= N; j++)
        {
            if ((i & (1 << j)) != 0)
            {
                sw[j] = 1;
            }
        }
        bool judge = true;
        for (int j = 0; j < M; j++)
        {
            int counter = 0;

            for (int k = 0; k < ks[j].first; k++)
            {
                counter += sw[ks[j].second[k]];
            }
            if ((counter % 2) != p[j])
            {
                judge = false;
                break;
            }
        }
        if (judge)
        {
            result++;
        }
    }
    cout << result;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

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


int main () {
  int n, x, count;
  int i, j, k;

  while (1) {
    cin >> n >> x;
    if (n == 0 && x == 0) break;
    count = 0;
    rep(i,n) {
      REP(j,i+1,n) {
	REP(k,j+1,n) {
	  if (i + j + k + 3 == x) {
	    count++;
	  }
	}
      }
    }
    cout << count << endl;
  }
  return 0;
}

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

int main(){
short n,m;
short *ans;
short tmp = -1;

cin >> n,cin >> m;

ans = new short[n];
for(short i = 0;i < n;i++) ans[i] = 0;

for(short i = 0;i < m;i++){
   cin >> tmp;
   ans[tmp-1]++;
   cin >> tmp;
   ans[tmp-1]++;
}

for(short i = 0;i < n;i++) cout << ans[i]<<"\n"; 

delete[] ans;

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int n;
    int a[1001];
    int ans;

    while(true){
        cin >> n;
        if(n == 0) break;

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

        int min = 1000000;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(i != j){
                    ans = abs(a[i] - a[j]);
                    if(ans < min) min = ans;
                }
            }
        }
        cout << min << endl;
    }
}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long H,W;
    cin >> H >> W;
    std::vector<std::vector<long>> a(H, vector<long>(W, 0));
    std::vector<std::vector<bool>> explore(H, vector<bool>(W, false));
    ll total = 0;
    for(size_t i=0;i<H; i++)
    {
        for(size_t j=0;j<W; j++)
        {
            cin >> a[i][j];
            total += a[i][j];
        }
    }
    //cerr << total << endl;
    ll ans=0;
    vector<long> x, y, x2, y2;
    for(size_t i=0;i<H-1; i++)
    {
        for(size_t j=0;j<W; j++)
        {
            if(a[i][j] % 2 == 1)
            {
                ans++;
                a[i+1][j]++;
                x.push_back(i+1);
                y.push_back(j+1);
                x2.push_back(i+2);
                y2.push_back(j+1);
            }
        }
    }

    for(size_t j=0;j<W-1; j++)
    {
        if(a[H-1][j] % 2 == 1)
        {
            ans++;
            a[H-1][j+1]++;
            x.push_back(H);
            y.push_back(j+1);
            x2.push_back(H);
            y2.push_back(j+2);
        }
    }

    cout << ans << endl;
    for(size_t i=0;i<ans; i++)
    {
        cout << x[i] << " " << y[i] << " " << x2[i] << " " << y2[i] << endl;
    }
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 8148
let n = read_int ()
let rec f n = if n < 10 then false else if n mod 10 = 9 then f (n / 10) else true
let rec g s n b = if n < 10 then s + n + if b then -1 else 0 else g (s + if b then 9 else n mod 10) (n / 10) b
let _ = Printf.printf "%d\n" @@ g 0 n @@ f n

Measured memory_bytes: 384
//A - On the Way
#include <bits/stdc++.h>
using namespace std;
template<size_t SIZE, class T> inline size_t array_size(T (&arr)[SIZE]) {
    return SIZE;
}
int main() {
    int A,B,C;
    cin>>A>>B>>C;
    if (A < C && C < B) {
        cout<<"Yes"<<endl;
    } else if (B < C && C < A) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//UnionFind木のテンプレ.parentには根のindexが入っている.
//根には連結成分のサイズが入っている.nはノード数.
class UnionFind{
public:
	vector<int> parent;
	UnionFind(){}
	UnionFind(int n){
		this->parent = vector<int>(n,-1);
	}
	int root(int x){
		if (this->parent[x] < 0) return x;
		this->parent[x] = root(this->parent[x]);
		return this->parent[x];
	}
	int unite(int x, int y){
		int rx = this->root(x);
		int ry = this->root(y);
		if (rx == ry) return false;
		if (this->parent[rx] > this->parent[ry]) swap(rx, ry);
		this->parent[rx] += this->parent[ry];
		this->parent[ry] = rx;
		return true;
	}
	int same(int x, int y){
		int rx = this->root(x);
		int ry = this->root(y);
		return rx == ry;
	}
	int size(int x){
		return -this->parent[this->root(x)];
	}
};

int main()
{
	vector<int> a(3);
	rep(i, 3) cin >> a[i];
	sort(all(a));
	if(a[0] == 5 && a[1] == 5 && a[2] == 7)
		puts("YES");
	else
		puts("NO");

	return 0;
}

Measured memory_bytes: 3596
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
    public static void sortbyColumn(long arr[][], int col) 
    {Arrays.sort(arr, new Comparator<long[]>() { 
           @Override
           
          public int compare(final long[] entry1, final long[] entry2) { 
            if (entry1[col] > entry2[col]) 
                return 1; 
            else
                return -1;} 
        });
    } 
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		long a[][]=new long[n][2];
		for(int i=0;i<n;i++)
		{long k=s.nextLong();
		 long p=s.nextLong();
		 a[i][0]=k-p;
		 a[i][1]=k+p;}
		 sortbyColumn(a,1);
		 int count=0;
		 long f=a[0][1];
		 count++;
		 for(int i=1;i<n;i++)
		 {if(f<=a[i][0])
		 {count++;f=a[i][1];}}
		 System.out.println(count);}}
		 


Measured memory_bytes: 91924
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;


int main() {
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;
  
  if(s[k-1]=='A') s[k-1] = 'a';
  if(s[k-1]=='B') s[k-1] = 'b';
  if(s[k-1]=='C') s[k-1] = 'c';
  
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
ans = float("inf")
e = [0]*(n+1)
w = [0]*(n+1)
for i in range(n):
    if s[i] == "E":
        e[i+1] = e[i] + 1
        w[i+1] = w[i]
    else:
        e[i+1] = e[i]
        w[i+1] = w[i] + 1

for i in range(n+1):
    ans = min((e[-1]-e[i])+(w[i-1]), ans)

print(ans)

Measured memory_bytes: 17636
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000

int main(){
    int K;
    cin>>K;
    if(K%2==0){
        cout<<K/2*K/2<<endl;
    }else{
        int p=K/2;
        cout<<p*(p+1)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc151/tasks/abc151_d

from collections import deque

h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]


def bfs(sx, sy):
    count = [[0] * w for i in range(h)]
    check = [[0] * w for i in range(h)]
    check[sx][sy] = 1
    d = deque([[sx, sy]])
    while d:
        x, y = d.popleft()
        for i, j in ([1, 0], [0, 1], [-1, 0], [0, -1]):
            tx, ty = x + i, y + j
            if (
                not (0 <= tx < h)
                or not (0 <= ty < w)
                or maze[tx][ty] == "#"
                or check[tx][ty] == 1
            ):
                continue
            else:
                count[tx][ty] = count[x][y] + 1
                check[tx][ty] = 1
                d.append([tx, ty])

    result = 0
    for k in count:
        for l in k:
            result = max(result, l)
    return result


ans = 0
for i in range(w):
    for j in range(h):
        if maze[j][i] == ".":
            ans = max(ans, bfs(j, i))
print(ans)


Measured memory_bytes: 3316
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math
import collections


fib_list=[1, 1]
for i in range(10**5):
    fib_list.append(fib_list[-1] + fib_list[-2])

# def fib(n):
#     return int((1 / math.sqrt(5)) * (math.pow((1 + math.sqrt(5)) / 2, n) - math.pow((1 - math.sqrt(5)) / 2, n)))

def fib(n):
    return fib_list[n-1]


# for i in range(-10, 10):
#     print(fib(i))

N, M = map(int, sys.stdin.readline().rstrip().split(" "))
As = []
for i in range(M):
    a, = map(int, sys.stdin.readline().rstrip().split(" "))
    As.append(a)
As.append(N+1)
result = 1
current = 0
for a in As:
    diff = a - current - 1
    if diff < 0:
        print(0)
        exit(0)
    # 1: 1
    # 2: 2
    # 3: 3C0 + 2C1 = 3
    # 4: (1,1,1,1) (1,1,2) (1, 2, 1) (2, 1, 1), (2, 2): 4C4 + 3C1 + 2C2 = 1+ 3 + 1 = 5
    # 5: 5C0 + 4C1 + 3C2 = 1 + 4 + 3 = 8
    # 6: 6C0 + 5C1 + 4C2 + 3C3 = 1+5+6+1 = 13
    # 7: 7C0 + 6C1 + 5C2 + 4C3 = 1+6+10+4 = 21
    # print(current, a, fib(diff+1))
    result *= fib(diff+1)
    result %= 1000000007
    # print("res", result)
    current = a + 1
print(result)
exit(0)


Measured memory_bytes: 464496
#include<stdio.h>
#define abs(x) ((x) < 0 ? -(x) : (x))

int main(){
  int n, res;
  double xa, ya, ra, xb, yb, rb;
  scanf("%d", &n);
  while(n--){
    res = 1;
    scanf("%lf%lf%lf%lf%lf%lf", &xa, &ya, &ra, &xb, &yb, &rb);
    double dist = (xa - xb) * (xa - xb) + (ya - yb) * (ya - yb);
    if(dist > (ra + rb) * (ra + rb))res = 0;
    if(dist < (ra - rb) * (ra - rb)){
      if(ra > rb)res = 2;
      else res = -2;
    }
    printf("%d\n", res);  
  }
  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

LLONG times[50][2501];

int main()
{
    int N, M; cin >> N >> M;
    // a1 + ... + aN = M について M は常に GCM(a1, ..., aN) の倍数
    // M の約数 d のうち，M / d が N 以上の d のうち最大のものが答え
    vector<int> divisors;
    for (int d = 1; d * d <= M; ++d)
    {
        if (M % d == 0)
        {
            divisors.push_back(d);
            divisors.push_back(M / d);
        }
    }
    int ans = 0;
    for (const int d : divisors)
    {
        if (M / d >= N)
        {
            ans = max(ans, d);
        }
    }
    cout << ans << endl;
}

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

int main() {
  int N,i=0;
  cin >> N;
  for(; i<N; i++){
    string S;
    cin >> S;
    if(S == "Y"){
      break;
    }
  }
  if(i==N){
    cout << "Three" << endl;
    return 0;
  }
    cout << "Four" << endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string s;
    cin >> s;
    
    int l = s.size(), count = 0;
    
    for(int i=0;i<l;i++){
        if(count == 0 && s[i] == 'C')
            count++;
        if(count == 1 && s[i] == 'F'){
            count++;
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;

}

Measured memory_bytes: 256
from collections import Counter
def comb(x):
    return x*(x-1)//2
n = int(input())
a = list(map(int,input().split()))
c = Counter(a)
b = 0
for i in c.values():
    b+=comb(i)
for k in range(n):
    print(b-c[a[k]]+1)

Measured memory_bytes: 25896
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

const ll MOD = INF + 7;



int main(){
    ll n, k;
    cin >> n >> k;
    VEC(ll, a, n);

    vector<P>cnt(n);
    rep(i, n){
        int fst = 0, snd = 0;
        rep(j, n){
            if(j < i){
                if(a[j] < a[i])fst++;
            }
            else if(j == i)continue;
            else{
                if(a[j] < a[i])snd++;
            }
        }
        cnt[i] = P(fst, snd);
    }

    ll res = 0;
    rep(i, n){
        ll fst = cnt[i].first, snd = cnt[i].second;
        ll hoge = ((k + 1) * k / 2) % MOD * snd % MOD;
        res += hoge;
        hoge = (k * (k - 1) / 2) % MOD * fst % MOD;
        res += hoge;
    }
  res %= MOD;
    cout << res;
}

Measured memory_bytes: 256
/// input macro from https://qiita.com/tanakh/items/1ba42c7ca36cd29d0ac8
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input!(n: u64, x: u64, t: u64);
    println!("{}", (n + x - 1) / x * t);
}


Measured memory_bytes: 2072
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Rishabhdeep Singh
 */

// doot diddly donger cuckerino Hahahahahah
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

// @formatter:off
#define PB              push_back
#define EB              emplace_back
#define F               first
#define S               second
#define all(x)          (x).begin(), (x).end()
#define rall(x)         rbegin(x), rend(x)
#define sz(x)           (long long) (x).size()
#define NL              << '\n'
#define IOS             ios::sync_with_stdio(false);cin.tie(NULL); cout << fixed << setprecision(12);
#define IN_REP          int tt; cin >> tt; while(tt--)
#define sim             template<typename T
#define ris             return *this
#define dor             > debug & operator <<
#define eni(x)          sim > typename enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i)
sim> struct rge { T b, e; };
sim> rge<T> range(T i, T j) { return rge<T>{i, j}; }
sim> auto dud(T *x) -> decltype(cerr << *x, 0);
sim> char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) { cerr << boolalpha << i; ris; }
  eni(==) { ris << range(all(i)); }
  sim, typename U dor(pair<U, T> d) { ris << "(" << d.first << ", " << d.second << ")"; }
  sim dor(rge<T> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
  sim dor(const T&) { ris; }
#endif
};
#define pr(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;

using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = acos(-1);

template<typename T> T gcd(T x, T y) { return (y == 0) ? x : gcd(y, x % y); }
template<typename T> void mini(T& x, T y) { x = min(x, y); }
template<typename T> void maxi(T& x, T y) { x = max(x, y); }
template<typename T, typename U> string to_string(pair<T, U> p) { return to_string(p.F) + " " + to_string(p.S); }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
// @formatter:on


class CSumOfGcdOfTuplesEasy {
 public:

  auto solveOne(istream &cin, ostream &cout) {

  }

  void solve(std::istream& cin, std::ostream& cout) {
	int n;
	cin >> n;
	ll res = 0;
	for(int i = 1; i <= n; ++i){
	  for(int j = 1; j <= n; ++j){
        for (int k = 1; k <= n; ++k) {
          res += gcd(i, gcd(j, k));
        }
	  }
	}
	cout << res << '\n';
  }
};

int main() {
    IOS;
	CSumOfGcdOfTuplesEasy solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

typedef vector<int> veci;
typedef pair<int, int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define INF (1e9 + 7)
#define fi first
#define se second
#define endl '\n'

void solve() {
    int n, t;
    cin >> n >> t;

    int ans = INF;
    int ci, ti;
    for (int i=0; i<n; ++i) {
        cin >> ci >> ti;
        if (ti<=t) {
            ans = min(ans,ci);
        }
    }

    cout << (ans==INF?"TLE":to_string(ans)) << endl;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL_TEST
    (void)argc;
    const string strpath = string(argv[0]) + string("-test.in");
    freopen(strpath.c_str(), "r", stdin);
    int tcs;
    cin >> tcs;
    while (tcs-- > 0)
#endif
    solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lb lower_bound
#define debug(x) cout<<"["<<#x<<": "<<x<<"]"<<endl
#define f(p,n) for(ll i=p;i<n;i++)
ll exp(ll a,ll b,ll m);

int main()
{
 ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 		/*
 	#ifndef ONLINE_JUDGE
        freopen("/home/savish/Desktop/2019/io/input.txt", "r", stdin);
        freopen("/home/savish/Desktop/2019/io/output.txt", "w", stdout);
    #endif
        */
    string s,t;
    cin>>s>>t;

    ll sl = s.length(), st = t.length();

    ll dp[sl+1][st+1];

    f(0,sl+1)
    {
    	for(ll j=0;j<=st;j++)
    	{
    		if(i==0 || j ==0) dp[i][j]=0;
    		else if(s[i-1]==t[j-1]) dp[i][j] = dp[i-1][j-1]+1;
    		else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
    	}
    }
    string ans = "";
    while(st>0 && sl>0)
    {
    	if(t[st-1]==s[sl-1])
    	{
    		ans = t[st-1]+ans;
    		st--;
    		sl--;
    	}
    	else if(dp[sl][st]==dp[sl-1][st]) sl--;
    	else st--;
    }
    cout<<ans<<endl;
return 0;
}

ll exp(ll a,ll b,ll m)
{
	if(b==0)
	{
		return 1;
	}
	ll temp =exp(a,b/2,m);
	temp=(temp*temp)%m;
	if(b&1)
	{
		return (temp*(a%m))%m;
	}
	return temp;
}

Measured memory_bytes: 70656
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctype.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef long long Int;
Int mod = 1e9+7;
Int MOD = 998244353;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    Int n = (Int)s.size();
    for (Int i = 0; i < n - 1; i++) {
        if (s[i] == s[i+1]) {
            cout << i + 1 << " " << i + 2 << '\n';
            return 0;
        }
    }
    for (Int i = 0; i < n - 2; i++) {
        if (s[i] == s[i+2]) {
            cout << i + 1 << " " << i + 3 << '\n';
            return 0;
        }
    }
    cout << -1 << " " << -1 << '\n';
    return 0;  
}

Measured memory_bytes: 512
S = raw_input()
n = 0
wc = 0
s_pos = 0
for i, c in enumerate(S):
    if c == "W":
        n += 1
        wc += i - s_pos
        s_pos = n

n = 0
bc = 0
s_pos = 0
for i, c in enumerate(reversed(S)):
    if c == "B":
        n += 1
        bc += i - s_pos
        s_pos = n

print max(wc, bc)


Measured memory_bytes: 6756
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);

int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}

#pragma endregion



int main(void) {
	int n[4];

	i_cins(3, n);
	if ((n[0] == n[1] && (n[0] == n[2]) && (n[1] == n[2])) ||
		(n[0] != n[1] && (n[0] != n[2]) && (n[1] != n[2])))
	{No_RTN;}
	Yes_RTN;
}


int _swp(int *a, int *b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}



Measured memory_bytes: 128