akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

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

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

int main()
{
  ll n, m, d;
  cin >> n >> m >> d;

  if(d == 0){
    printf("%.9f\n", (m-1.0)/n);
  }else{
    printf("%.9f\n", 2.0*(m-1.0)*(n-d)/(n*n));
  }


  return 0;
}


Measured memory_bytes: 256
n = int(input())

s = list(input())

res = 0

s_dif_g = [0]*n
s_dif_r = [0]*n
s_dif_b = [0]*n

for i in range(n):
    s_dif_r[i] = s[i::].count('R')
    s_dif_g[i] = s[i::].count('G')
    s_dif_b[i] = s[i::].count('B')

sample = ["R","G","B"]
for i in range(n):
    fst = s[i]
    for j in range(i+1,n-1):
        if(s[j] != fst):
            scd = s[j]
            for x in sample:
                if(x != fst and x != scd):
                    if(x == "R"):
                        res += s_dif_r[j+1]
                    if(x == "G"):
                        res += s_dif_g[j+1]
                    if(x == "B"):
                        res += s_dif_b[j+1]
                    if(2*j-i < n):    
                        if(s[2*j-i] == x):
                            res -= 1
            
            

print(res)
    

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

int main() {
	int N,K;
	cin >> N >> K;
	vector<int64_t>score(N);
	for(int i=0;i<N;i++){
		cin >> score.at(i);
	}
	for(int i=0;i<N-K;i++){
		if(score.at(i)<score.at(i+K)){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int a,b;
	cin >> a >> b;
	int h[1010] = {0,1};
	for(int i = 2; i < 1010; i++) h[i] = h[i-1]+i;
	cout << h[b-a-1] - a << endl;
	return 0;
}

Measured memory_bytes: 256
K, N = map(int, input().split())
A = list(map(int, input().split()))
if N == 2:
    print(min(A[1]-A[0], K-A[1]+A[0]))
else:
    ans = K - A[N-1] + A[0]
    for i in range(N-1):
        ans = max(A[i+1]-A[i], ans)
    print(K - ans)

Measured memory_bytes: 99988
#include <bits/stdc++.h>
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
#define bit(x) (1<<(x))
using namespace std;

int n,m,p;
int a[15][15];

using R=long double;
R dp[1<<14];

int main(void){
	cin >> n >> m >> p;
	rep(i,m){
		int u,v;
		cin >> u >> v;
		a[u-1][v-1]++;
		a[v-1][u-1]++;
	}

	rep(mask,1,1<<n){
		dp[mask]=1.0;		
		if(__builtin_popcount(mask)==1) continue;
		int limit=bit(31-__builtin_clz(mask));
		for(int add=(mask-1)&mask;add>=limit;add=(add-1)&mask){
			int root=add^mask;
			double cur=dp[add];
			rep(i,n)rep(j,n) if(root&bit(i)) if(add&bit(j)) rep(loop,a[i][j]) cur*=1.0*p/100.0; 
			dp[mask]-=cur;	
		}
	}
	cout.precision(20);
	cout << fixed << dp[(1<<n)-1] << endl;
	return 0;
}

Measured memory_bytes: 3528
package main

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

func main() {
	x1 := readi()
	x2 := readi()
	x3 := readi()
	x4 := readi()
	x5 := readi()

	if x1 == 0 {
		fmt.Println(1)
		return
	}
	if x2 == 0 {
		fmt.Println(2)
		return
	}
	if x3 == 0 {
		fmt.Println(3)
		return
	}
	if x4 == 0 {
		fmt.Println(4)
		return
	}
	if x5 == 0 {
		fmt.Println(5)
		return
	}
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

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

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

func isPrime(n int) bool {
	if n == 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

// func searchInts(a []int, k int) int {
// 	return binarySearch(len(a), func(i int) bool {
// 		return a[i] >= k
// 	})
// }

func binarySearch(n int, f func(int) bool) int {
	i, j := 0, n
	for i < j {
		h := int(uint(i+j) >> 1)
		if !f(h) {
			i = h + 1
		} else {
			j = h
		}
	}
	return i
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


Measured memory_bytes: 1756
import java.util.*;

public class Main{

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

        int count0 = 0;
        int count1 = 0;
        for(int i = 0; i < S.length(); i++){
            if(S.charAt(i) == '1')
                count1++;
            if(S.charAt(i) == '0')
                count0++;
        }
        System.out.println(2*Math.min(count1,count0));
    }
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
ll s[N], t[N], res[N];
ll a, b, q, x;
ll l1, r1, l2, r2;
int main() {
    cin >> a >> b >> q;
    for (int i = 0; i < a; ++i) {
        cin >> s[i];
    }
    for (int i = 0; i < b; ++i) {
        cin >> t[i];
    }
    for (int i = 0; i < q; ++i) {
        cin >> x;
        auto it = lower_bound(s, s + a, x);
        if (it != s + a) {
            r1 = *it - x;
        } else {
            r1 = 1e15;
        }
        if (it != s) {
            l1 = x - *(it - 1);
        } else {
            l1 = 1e15;
        }

        it = lower_bound(t, t + b, x);
        if (it != t + b) {
            r2 = *it - x;
        } else {
            r2 = 1e15;
        }
        if (it != t) {
            l2 = x - *(it - 1);
        } else {
            l2 = 1e15;
        }
        // cout << l1 << ' ' << r1 << ' ' << l2 << ' ' << r2 << endl;
        ll ans = min(max(r1, r2), max(l1, l2));
        if (l1 > r2) {
            ans = min(ans, r2 * 2 + l1);
        } else {
            ans = min(ans, l1 * 2 + r2);
        }
        if (r1 > l2) {
            ans = min(ans, l2 * 2 + r1);
        } else {
            ans = min(ans, r1 * 2 + l2);
        }
        res[i] = ans;
    }
    for (int i = 0; i < q; ++i) {
        cout << res[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 5924
#include <iostream>
using namespace std;
int main(void){
    char upper_line[3], lower_line[3];
    cin >> upper_line >> lower_line;
    if( upper_line[0] != lower_line[2] || upper_line[1] != lower_line[1] || upper_line[2] != lower_line[0] ) {
        cout << "NO" << endl;
        return 0;
    }
    
    cout << "YES" << endl;
    return 0;
}


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

int main(){
    string a,b,c;
    cin >>a>>b>>c;
    cout << (a[a.size()-1]==b[0]&&b[b.size()-1]==c[0] ? "YES":"NO") << endl;
}

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

int main() {
  int n,k,cnt_lr=0,cnt_rl=0,ans=0,ch=0;
  string s;
  cin >> n >> k >> s;
  
  for(int i=0;i<n-1;i++){
    if( s.at(i) == s.at(i+1) ) ans++;
    else if(s.at(i) == 'L') cnt_lr++;
    else cnt_rl++;
    //cout << ans << " " << cnt_lr << " " << cnt_rl << endl;
  }
  //cout << ans << " " << cnt_lr << " " << cnt_rl << endl;
  ch = min(k , min(cnt_lr , cnt_rl) );
  ans += ch*2;
  //cout << ans << endl;
  if(ch != k && ans == n-2) ans++;
  
  cout << ans << endl;    
  
}



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

int main(){
    long long N,A,B,C;
    cin >> N;
    vector<char> vec(N);
    vector<string> S(N+1);
    cin >> A >> B >> C;
    for(int i=0;i<N;i++){
        cin >> S[i];
    }
    S[N]=="AA";
    for(long long i=0;i<N;i++){
        if(S[i]=="AB"){
            if(A>B||(A==B&&S[i+1]!="AC")){
                vec[i]='B';
                B++;
                A--;
            }
            else{
                vec[i]='A';
                A++;
                B--;
            }
        }
        else if(S[i]=="AC"){
            if(A>C||(A==C&&S[i+1]!="AB")){
                vec[i]='C';
                C++;
                A--;
            }
            else{
                vec[i]='A';
                A++;
                C--;
            }
        }
        else{
            if(B>C||(B==C&&S[i+1]!="AB")){
                vec[i]='C';
                C++;
                B--;
            }
            else{
                vec[i]='B';
                B++;
                C--;
            }
        }
        if(A<0||B<0||C<0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(long long i=0;i<N;i++){
        cout << vec[i] << endl;
    }
}

Measured memory_bytes: 6436
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using psi=pair<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD ((ll)1e9+7)
void get(){}template<class H,class...T>void get(H&h,T&...t){cin>>h;get(t...);}
template<class T>void geti(T&a){for(auto&_:a)cin>>_;}
template<class T>void getii(T&a){for(auto&_:a)geti(_);}
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}
#define dcl(...) ll __VA_ARGS__;get(__VA_ARGS__)
#define dclt(t,...) t __VA_ARGS__;get(__VA_ARGS__)
template<class F,class S>void add(map<F,S>&mp,F f,S s){if(mp.find(f)==mp.end())mp[f]=F();mp[f]+=s;}
 
int main(){
    int h,v;
    using data=pair<int,int>;
    
    while(cin>>h>>v, h or v){
        int tv[]={-3,-1,1,3};
        int tc[]={v,h,h,v};
        int p10[]={100000000,10000000,1000000,100000,10000,1000,100,10,1};
        array<int,9> a,b;
        geti(a);
        geti(b);
        int sa=0,sb=0;
        for(auto i:a)sa=sa*10+i;
        for(auto i:b)sb=sb*10+i;
    
        unordered_map<int,int> s;

        priority_queue<data> q;
        q.emplace(0,sa);
        
        while(1){
            int cost=q.top().fs;
            int board=q.top().sc;
            q.pop();
            if(board==sb){
                cout<<-cost<<endl;
                break;
            }
            int index=to_string(board).find('0');
            if(index==-1)index=0;
            rep(i,4){
                int fixed=(index+tv[i]+9)%9;
                int next=board;
                int fx=next/p10[fixed]%10;
                next-=p10[fixed]*fx;
                next+=p10[index]*fx;
                if((s.find(next)==s.end() || s[next]<cost-tc[i]) && cost-tc[i]>-3000){
                    q.emplace(cost-tc[i], next);
                    s[next]=cost-tc[i];
                }
            }
        }
    }
}



Measured memory_bytes: 21272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int vis[30];
vector<int> G[30];
bool valid;

void dfs(int now)
{
    if(vis[now]==2)
    {
        valid=false;
        return;
    }
    else if(vis[now]==0)
    {
        vis[now]=2;
        rep(i,G[now].size()) dfs(G[now][i]);

        vis[now]=1;
    }
}

int main()
{
    int n;
    while(cin >>n,n)
    {
        vector<string> s(n);
        rep(i,n) cin >>s[i];

        rep(i,30)
        {
            vis[i]=0;
            G[i].clear();
            valid=true;
        }

        rep(i,n)for(int j=i+1; j<n; ++j)
        {
            int I=s[i].size(), J=s[j].size();
            int S=min(I,J);

            int idx=0;
            while(idx<S)
            {
                if(s[i][idx] != s[j][idx]) break;
                ++idx;
            }

            if(idx<S)
            {
                int from = s[i][idx]-'a', to = s[j][idx]-'a';
                G[from].pb(to);
            }
            else
            {
                if(I>J) valid=false;
            }
        }

        rep(i,30) dfs(i);

        cout << (valid?"yes":"no") << endl;
    }
    return 0;
}

Measured memory_bytes: 8348
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
#define MOD 1000000007
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
ll N;
ll A,B,C,D;
int main(int argc,char const* argv[])
{
  cin >> N >> A >> B >> C >> D;
  for(ll m=0;m<N;m++)
    {
      if(((B-A)>=C*(N-1-m)-D*m) && ((B-A)<=((N-1-m)*D-C*m)))
	{
	  cout << "YES" << endl;
	  return 0;
	}
    }
  cout << "NO" << endl;
  return 0;
}


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

using namespace std;

bool solve(int n, const vector<string>& words)
{
    auto c = words[0].back();

    set<string> S;
    S.insert(words[0]);

    for(int i = 1; i < n; ++i)
    {
        if(S.count(words[i]) or words[i].front() != c)
            return false;
        
        c = words[i].back();
        S.insert(words[i]);
    }

    return true;
}

int main()
{
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<string> words(n);
    
    for(int i = 0; i < n; i++)
        cin >> words[i];

    auto ans = solve(n, words);

    cout << (ans ? "Yes\n" : "No\n");

    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int>sn = { 6,36,216,1296,7776,46656 };
	reverse(sn.begin(), sn.end());
	vector<int>ni = {9,81,729,6561,59049};
	vector<int>dp(n+1,0);
	for (int i = 0; i <= n; i++) {
		ll ans = 0;
		ll x = i;
		for (int j = 0; j < sn.size(); j++) {
			ans += x / sn.at(j);
			x %= sn.at(j);
		}
		ans += x;
		dp.at(i) = ans;
	}
	for (int i = 0; i < ni.size(); i++) {
		int x = ni.at(i);
		for (int j = 0; j <= n; j++) {
			int res = 10000;
			for (int k = 0; k <= j/x; k++) {
				res = min(res, dp.at(j - x * k) + k);
			}
			dp.at(j) = min(dp.at(j), res);
		}
	}
	cout << dp.at(n) << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
const int MOD = 998244353;
// const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	
	int a,b;
	cin >> a >> b;
	double eps = 0.000001;
	rep(i,100000){
		if(int(i*0.08+eps) == a && int(i*0.1+eps) == b){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	


	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://abc158.contest.atcoder.jp/tasks/abc158_c

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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
// template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  ll X;
  cin >> X;

  ll i = 1;
  ll a = 100;
  while (true) {
    a = a + a * 0.01;

    if (X <= a) {
      break;
    }
    i++;
  }

  cout << i << endl;

  return 0;
}


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

long long func(int N, long long X) {
	// レベルNの厚さ:2^(2+N)-3
	// レベルN内のパティ:2^(1+N)-1
	if (N == 0)
		return 1;
	if (X == 1)
		return 0;
	if (1 < X && X < pow(2, 1 + N) - 1)
		return func(N - 1, X - 1);
	if (X == pow(2, 1 + N) - 1)
		return func(N - 1, X - 1) + 1;
	if (X > pow(2, 1 + N) - 1)
		return func(N - 1, X - (pow(2, 1 + N) - 1)) + pow(2, N);
}

int main() {
	int n;
    long long x;
	cin >> n >> x;
	cout << func(n, x) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;
typedef long long ll;

#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 INF 2e9
#define ALL(v) v.begin(), v.end()
#define  DESC std::greater<int>() //sort 3rd arg



int main()
{
	double d, t, s;
	cin >> d >> t >> s;
		
	double time = d / s;

	if (t >= time) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

template <typename Monoid> struct SegmentTree {
    using F = function<Monoid(Monoid, Monoid)>;

  private:
    int n;
    vector<Monoid> node;
    Monoid E;
    F f;

  public:
    SegmentTree(vector<Monoid> &v, Monoid e, const F func) : f(func), E(e) {
        int sz = v.size();
        n = 1;
        while(n < sz) {
            n *= 2;
        }
        node.resize(2 * n - 1, E);
        for(int i = 0; i < sz; i++) {
            node[i + n - 1] = v[i];
        }
        for(int i = n - 2; i >= 0; i--) {
            node[i] = f(node[2 * i + 1], node[2 * i + 2]);
        }
    }

    void update(int i, Monoid val) {
        i += (n - 1);
        node[i] = val;
        while(i > 0) {
            i = (i - 1) / 2;
            node[i] = f(node[2 * i + 1], node[2 * i + 2]);
        }
    }

    Monoid query(int a, int b, int i = 0, int l = 0, int r = -1) {
        if(r < 0) {
            r = n;
        }
        if(r <= a || b <= l) {
            return E;
        }
        if(a <= l && r <= b) {
            return node[i];
        }
        Monoid vl = query(a, b, 2 * i + 1, l, (l + r) / 2);
        Monoid vr = query(a, b, 2 * i + 2, (l + r) / 2, r);
        return f(vl, vr);
    }

    Monoid operator[](const int &i) const { return node[i + n - 1]; }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    SegmentTree<int> segmax(a, -INF, [](int p, int q) { return max(p, q); });
    map<int, int> mp;
    for(int i = 0; i < n - 1; i++) {
        int mx = segmax.query(i + 1, n);
        if(mx > a[i]) {
            mp[mx - a[i]]++;
        }
    }
    auto it = mp.rbegin();
    cout << it->second << endl;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T> void fill_all(T& arr, const T& v) { arr = v; }
template<typename ARR, typename U> void fill_all(ARR& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T>auto&operator<<(ostream&s,const unordered_set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const unordered_map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const int INF = 1LL<<60;
const int MOD = 1e9+7;

signed main()
{
   int N; cin >> N;
   
   vector<pair<int,string>> res(2);
   cout << 0 << endl;
   string s; cin >> s;
   if (s == "Vacant") {
      return 0;
   }
   res[0] = { 0, s }; res[1] = { N, s };

   while (true) {
      int i = (res[0].first + res[1].first) / 2;
      cout << i << endl;
      cin >> s;
      if (s == "Vacant") {
         return 0;
      }

      for (int k = 0; k < 2; ++k) {
         if (((i - res[k].first) % 2 == 0) ^ (s == res[k].second)) {
            res[(k+1)%2].first = i;
            res[(k+1)%2].second = s;
            break;
         }
      }
   }

   return 0;
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
int R;
int main(){
  cin>>R;
  string ans;
  if(R<1200){
    ans="ABC";
  }else if(R<2800){
    ans="ARC";
  }else{
    ans="AGC";
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <ctime>
#include <complex>

#define enp 	printf("**Entry Point**\n")
#define A		first
#define B		second
#define MP		make_pair

using namespace std;

typedef long long ll;

const int INF = 0x6fffffff;
const int MINF = 0x80000000;
const ll mod = 100003;
const int cons = 100001;
const double pi = 3.141592653589793;

char ch[2] = { '.', '#' };
int nxt[4][2];
char s1[400];
char s2[400];

int main()
{
	nxt[0][0] = 0;
	nxt[0][1] = 1;
	nxt[1][0] = 1;
	nxt[1][1] = 0;
	nxt[2][0] = 1;
	nxt[2][1] = 1;
	nxt[3][0] = 0;
	nxt[3][1] = 0;

	int n;
	scanf("%d", &n);

	int front = 200;
	int rear = 200;
	int i1 = 0, i2 = 0;
	bool flag = true;
	int cur = 0;

	while (1)
	{
		if (flag)
		{
			s1[rear] = ch[i1];
			s2[rear++] = ch[i2];
		}
		else
		{
			s1[front - 1] = ch[i1];
			s2[front - 1] = ch[i2];
			front--;
		}

		printf("%s\n%s\n", s1 + front, s2 + front); fflush(stdout);

		string ans;
		cin >> ans;
		if (ans == "end")break;

		if (ans == "F")
		{
			i1 = nxt[cur][0];
			i2 = nxt[cur][1];

			if (flag)
			{
				rear--;
				s1[rear] = 0;
				s2[rear] = 0;
			}
			else
			{
				front++;
			}

			cur++;
			cur %= 4;
			if (cur == 0)
			{
				flag ^= true;
			}
		}
		else
		{
			cur = 0;
			i1 = 0;
			i2 = 0;
		}
	}

	return 0;
}

Measured memory_bytes: 596
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        long[][] a = new long[n][2];
        for (int i = 0; i < n; i++) {
            a[i][0] = scanner.nextInt();
            a[i][1] = scanner.nextInt();
        }
        Arrays.sort(a, Comparator.comparingLong(array -> array[1]));
        long time = 0;
        for (long[] task : a) {
            time += task[0];
            if (time > task[1]) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(const T x,const T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {set_intersection(ALL(a),ALL(b),inserter(c,c.end()));}
template<class T> void getor(const T &a,const T &b,T &c) {set_union(ALL(a),ALL(b),inserter(c,c.end()));}

typedef long long ll;
typedef pair<ll, ll> P;

const int MOD=1e9+7;


int main() {
  // 存在判定一つでもあれあOK
  // 下二桁が1~5で作れればOK
  int X;cin>>X;

  if (X<100) {
    OUT(0);
    return 0;
  }

  int cnt = X/100;
  int rest = X%100;

  // 全部100で帰る
  if (rest==0) {
    OUT(1);
    return 0;
  }
  // 101でかえる
  if (cnt>=rest) {
    OUT(1);
    return 0;
  }

  // 0 < rest < cntの場合、
  // cnt=1 0~5
  // cnt=2 0~10
  // という感じで帰る範囲が広がる
  (rest<=5*cnt) ? OUT(1) : OUT(0);

  return 0;
}

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

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long llint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double pi = 3.14159265358979323846;

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
//

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

  int a[33] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
               1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k - 1] << endl;

  return 0;
}

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

using ll = long long;

int main() {
	ll h, w; cin >> h >> w;

	ll ans = 1e18L;

	for(int _ : {0, 1}) {
		if(h % 3)
			ans = min(ans, w);
		else
			ans = 0;

		for(ll i = 1; i < h; i ++) {
			vector <ll> v = {i * w, (h - i) * (w / 2), (h - i) * (w - w / 2)};
			sort(v.begin(), v.end());
			ans = min(ans, v[2] - v[0]);
		}

		swap(h, w);
	}
	cout << ans << '\n';
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

int main(){
    bool prime[200000];
    int ans[10100] = {0};
    rep(i,105000){
        prime[i] = true;
    }
    prime[0] = false;
    prime[1] = false;
    int j = 1;
    rep(i,200000){
        if(prime[i]){
            ans[j] = ans[j - 1] + i;
            j++;
            for(int k = 2 * i; k < 105000; k+= i){
                prime[k] = false;
            }
        }
    }
    int n;
    while(cin >> n, n){
        cout << ans[n] << endl;
    }
}

Measured memory_bytes: 1312
N, T = map(int, input().split())
min_cost = 9999
for i in range(N):
  c, t = map(int, input().split())
  if t<=T:
    min_cost = min(min_cost, c)
if min_cost == 9999:
  print("TLE")
else:
  print(min_cost)
  

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int x, l, r;
    cin >> x >> l >> r;
    while(l <= r) {
        if(l % x == 0) cout << "OK", exit(0);
        l++;
    }
    cout << "NG";
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using namespace std;

const long long MAX = numeric_limits<long long>::max()/2LL;

void solve(long long N, long long M, long long L, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C, long long Q, std::vector<long long> s, std::vector<long long> t){

  vector<vector<long long>> G(N, vector<long long>(N, MAX));

  for (int i = 0; i < M; ++i) {
    G[A[i]-1][B[i]-1] = C[i];
    G[B[i]-1][A[i]-1] = C[i];
  }

  for (int k = 0; k < N; ++k) {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (G[i][j] <= L) {
        G[i][j] = 1;
      } else {
        G[i][j] = MAX;
      }
    }
  }

  for (int k = 0; k < N; ++k) {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }

  for (int i = 0; i < Q; ++i) {
    if (G[s[i]-1][t[i]-1] >= MAX) {
      std::cout << -1 << std::endl;
    } else {
      std::cout << G[s[i]-1][t[i]-1]-1 << std::endl;
    }
  }
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  long long L;
  scanf("%lld",&L);
  std::vector<long long> A(M);
  std::vector<long long> B(M);
  std::vector<long long> C(M);
  for(int i = 0 ; i < M ; i++){
    scanf("%lld",&A[i]);
    scanf("%lld",&B[i]);
    scanf("%lld",&C[i]);
  }
  long long Q;
  scanf("%lld",&Q);
  std::vector<long long> s(Q);
  std::vector<long long> t(Q);
  for(int i = 0 ; i < Q ; i++){
    scanf("%lld",&s[i]);
    scanf("%lld",&t[i]);
  }
  solve(N, M, L, std::move(A), std::move(B), std::move(C), Q, std::move(s), std::move(t));
  return 0;
}


Measured memory_bytes: 3584
/**
 *    author        : Saurav Paul 
 *    created       : July 12, 2020 9:02 PM
 *    Problem Name  : A - Payment
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc173/tasks/abc173_a
**/

#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    long long x;
    cin >> x;
    x = x%1000;
    cout << (x?1000-x:0) << endl ;

    return 0 ;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for(auto v:(V))cout<<v<<" "<<endl
inline int GCD(int a, int b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;

int main()
{
    vi A(5);
    int K;
    rep(i, 5)
    {
        cin >> A[i];
    }
    cin >> K;
    if (A[4]-A[0] > K)
    {
        cout << ":(" << endl;
    }
    else
    {
        cout << "Yay!" << endl;
    }
    
}

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

using namespace std;
typedef long long ll;
const int modint = 1000000007;

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    int n, k;
    cin >> n >> k;
    ll m = n - k;
    ll temp = m + 1;
    ll temp2 = k - 1;
    COMinit();
    for (int i = 1; i <= k; i++)
    {
        cout << (COM(temp, i) * COM(temp2, i - 1)) % MOD << endl;
    }
    return 0;
}

Measured memory_bytes: 15576
import math
a,b,c = map(float,input().split())
h = math.sin(math.radians(c))
cosA = math.cos(math.radians(c))
S = 0.5*a*b*h
yogen = (a**2 + b**2 - 2*a*b*cosA)**0.5
print(S)
print(a+b+yogen)
print(b*h)


Measured memory_bytes: 5696
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;

int main() {
  int N;
  in(N);
 map<string,int> M;
  rep(i,N){
   string s;
    in(s);
    M[s]++;
  }
  int mx  =-1;
  for(auto i:M) mx = max(mx,i.S);
  for(auto i:M){
   if(i.S == mx) out(i.F); 
  }
}


Measured memory_bytes: 25216
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//<ここに一言>

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
template <typename T>
T gcd(T a,T b){
  if(a%b==0)return b;
  else return gcd(b,a%b);
}
template <typename T>
T lcm(T a,T b){
  return a/gcd(a,b)*b;
}
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
	int n;cin>>n;
	vector<int> A(n);
	vector<int> B(n);
	for(int i = 0; n > i; i++){
		cin>>A[i];
		B[i]=A[i];
	}
	sort(B.begin(),B.end());
	set<int> Z;
	for(int i = 0; n > i; i++){
		if(A[i]!=B[i]){
			Z.insert(i);
		}
	}
	if(!Z.size()){
		cout << 0 << endl;
		return 0;
	}
	int q;cin>>q;
	for(int i = 0; q > i; i++){
		int a,b;cin>>a>>b;
		a--;b--;
		swap(A[a],A[b]);
		if(A[a]==B[a]){
			Z.erase(a);
		}else{
			Z.insert(a);
		}
		if(A[b]==B[b]){
			Z.erase(b);
		}else{
			Z.insert(b);
		}
		if(!Z.size()){
			cout << i+1 << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}



Measured memory_bytes: 19176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007;
#define MOD2 998244353;
#define INF ((1<<30)-1);
#define LINF (1LL<<60);
#define EPS (1e-10);
typedef long long Int;
typedef pair<Int, Int> P;

#define PI 3.141592653589793

int main() {
    double n;
    cin >> n;
    printf("%.10lf\n", 2*n*PI);
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define fi first
#define se second
#define inf (long long)1e18
using namespace std;
typedef pair<long long, long long> p;

struct Unionfind {
  // tree number
  vector<int> par;
  // tree rank
  vector<int> treerank;
  // constructor
  Unionfind(int n = 1) { stree(n + 1); }
  // make and initialization
  void stree(int n = 1) {
    par.resize(n);
    treerank.resize(n);
    for(int i = 0; i < n; ++i) {
      par[i] = i;
      treerank[i] = 0;
    }
  }
  // search root
  int root(int x) {
    if(par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  // is same?
  bool issame(int x, int y) { return root(x) == root(y); }

  // add
  // already added, return 0
  bool uni(int x, int y) {
    x = root(x);
    y = root(y);
    if(x == y) return 0;
    if(treerank[x] < treerank[y])
      par[x] = y;
    else if(treerank[y] < treerank[x])
      par[y] = x;
    else {
      par[y] = x;
      ++treerank[x];
    }
    return 1;
  }
};

long long n;
// x,y, point num
vector<pair<p, int>> v;
// cost, from, to
priority_queue<pair<long long, p>,
               vector<pair<long long, p>>,
               greater<pair<long long, p>>>
    pq;
Unionfind uf;

long long calccost(int x, int y) {
  return min(
      max(v[x].fi.fi - v[y].fi.fi, v[y].fi.fi - v[x].fi.fi),
      max(v[x].fi.se - v[y].fi.se,
          v[y].fi.se - v[x].fi.se));
}

void setedge();
long long solve();

int main() {
  cin >> n;
  uf = Unionfind(n + 1);
  for(int i = 0; i < n; ++i) {
    long long x, y;
    cin >> x >> y;
    v.push_back(make_pair(make_pair(x, y), i));
  }
  setedge();
  cout << solve() << endl;
  return 0;
}

void setedge() {
  sort(v.begin(), v.end());
  for(int i = 1; i < n; ++i) {
    long long now = calccost(i - 1, i);
    pq.push(
        make_pair(now, make_pair(v[i - 1].se, v[i].se)));
  }
  for(int i = 0; i < n; ++i) swap(v[i].fi.fi, v[i].fi.se);
  sort(v.begin(), v.end());
  for(int i = 1; i < n; ++i) {
    long long now = calccost(i - 1, i);
    pq.push(
        make_pair(now, make_pair(v[i - 1].se, v[i].se)));
  }
}

long long solve() {
  long long ans = 0;
  while(pq.size() > 0) {
    pair<long long, p> now = pq.top();
    pq.pop();
    if(!uf.issame(now.se.fi, now.se.se)) {
      ans += now.fi;
      uf.uni(now.se.fi, now.se.se);
    }
  }
  return ans;
}


Measured memory_bytes: 11632
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
 ll ub = 1e12-1, lb = 1e11, mid;

 while (ub-lb > 1) {
   mid = (ub+lb)/2;
   cout << '?' << ' ' << mid << endl;
   char c;
   cin >> c;
   if (c == 'Y') ub = mid;
   else lb = mid;
 }

 bool exeption = true;
 ll digit = 1;
 for (ll l = 1; l <= 1e11; l *= 10) {
   cout << "? " << l << endl;
   char c;
   cin >> c;
   if (c == 'N') {
     exeption = false;
     digit = l / 10;
     break;
   }
 }

 if (exeption) {
   for (ll l = 2; l <= 2*1e11; l *= 10) {
     cout << "? " << l << endl;
     char c;
     cin >> c;
     if (c == 'Y') {
       digit = l / 2;
       break;
     }
   }
 }

 ll ans = ub / (1e11 / digit);   

 cout << "! " << ans << endl;

 return 0;
}


Measured memory_bytes: 596
#include <stdio.h>
int main(){
	int n;
	int re=0;
	scanf("%d",&n);
	if(n%10==2)
	{
		re++;
	}
	
	if((n/10)%10==2)
	{
		re++;
	}
	
	if((n/100)%10==2)
	{
		re++;
	}
	
	if((n/1000)%10==2)
	{
		re++;
	}
	printf("%d",re);
	}

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

int main() {
  string S;
  cin >> S;
  
  if (S == "SUN") cout << 7 << endl;
  else if (S == "MON") cout << 6 << endl;
  else if (S == "TUE") cout << 5 << endl;
  else if (S == "WED") cout << 4 << endl;
  else if (S == "THU") cout << 3 << endl;
  else if (S == "FRI") cout << 2 << endl;
  else cout << 1 << endl;
  
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    string result = "No";
    rep(i, k)
    {

        if (a < b)
        {
            c *= 2;
        }
        else
        {
            b *= 2;
        }

        if (a < b && b < c)
        {
            result = "Yes";
            break;
        }
    }
    cout << result << endl;
}

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

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

    int keta[N];
    for (int i=0; i<N; i++){
        keta[i] = -1;
    }
    for (int i=0; i<M; i++){
        if (keta[N - s[i]] == -1){
            keta[N - s[i]] = c[i];
        } else{
            if (keta[N - s[i]] != c[i]){
                cout << -1 << endl;
                return 0;
            }
        }
    }

    int ans = 0;
    if (N == 1){
        if (keta[0] == -1){
            ans = 0;
        } else{
            ans = keta[0];
        }
    } else if (N == 2){
        if (keta[0] == -1) keta[0] = 0;
        if (keta[1] == -1){
            ans = 10 + keta[0];
        } else{
            ans = 10 * keta[1] + keta[0];
        }
    } else{
        if (keta[0] == -1) keta[0] = 0;
        if (keta[1] == -1) keta[1] = 0;
        if (keta[2] == -1){
            ans = 100 + 10 * keta[1] + keta[0];
        } else{
            ans = 100 * keta[2] + 10 * keta[1] + keta[0];
        }
    }
    if (to_string(ans).length() != N) ans = -1;

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


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

int main(){
  int K,cnt=0;
  cin >> K;
  string S;
  cin >> S;
  if(K >= S.size()) K = S.size();
  else cnt = -1;
  
  for(int i=0;i<K;i++){
    cout << S.at(i);
  }
  if(cnt == -1) cout << "..." << endl;
  else cout << ' ' << endl;  
  
  return 0;
}

Measured memory_bytes: 3628