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

int main(){
    int a,b,h,m;
    double w1, w2, ans;

    cin >> a >> b >> h >> m;
    w1 = h/12.+m/720.; w2 = m/60.;
    ans = a*a+b*b-2*a*b*cos(2*M_PI*(w1-w2));
    printf("%.12lf\n", sqrt(ans));
}

Measured memory_bytes: 4160
N = int(input())

def rec(p, ptn, ans):
    if len(ptn) > 0 and int(ptn) <= int(N) and '3' in ptn and '5' in ptn and '7' in ptn:
        ans[0] += 1

    if p >= len(str(N)):
        return
    else:
        for n in ('3', '5', '7'):
            ptn += n
            rec(p+1, ptn, ans)
            ptn = ptn[:-1]

ans = [0]
rec(0, "", ans)

print(ans[0])


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

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



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



int main() {
	int n, k;
	cin >> n >> k;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int h;
		cin >> h;
		cnt += (h >= k);

	}

	cout << cnt << endl;
}


Measured memory_bytes: 3596
s = input()
l= len(s)
 
if l== 1:
    print(0)
    exit()
 
even = s[::2]
odd = s[1::2]

odd_zero = odd.count("0")
even_one = even.count("1")
 

odd_one = odd.count("1")
even_zero = even.count("0")
 
print(min(odd_zero + even_one, odd_one + even_zero))

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){
  
  int A,B,C,K,t;
  cin >> A >> B >> C >> K;
  t = 0;
    
  while(B <= A){
    B *= 2;
    t++;
  }
  if(t > K) cout << "No" << endl;
  
  else{
    for(int i = 0; i < K-t; i++){
    
    	C *= 2;
 	}
  	if(C > B) cout << "Yes" << endl;
  	else cout << "No" << endl;
  }
  
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
struct c{
    int x,y;
} z[110];
bool comp(c a,c b){
    return atan2(a.y,a.x)<atan2(b.y,b.x);
}
signed main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>z[i].x>>z[i].y;
    }
    sort(z,z+n,comp);
    double ans=0;
    for(int i=0;i<n;i++){
        int j=i;
        int x=0,y=0;
        do{
            x+=z[j].x;
            y+=z[j].y;
            ans=max(ans,(double)sqrt(x*x+y*y));
            j++;
            j%=n;
        }while(j!=i);
    }
    printf("%.20llf",ans);
    return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    pri(a*b);
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

struct DATA{
  int number;
  int distance;
};

bool Compare(const DATA&, const DATA&);

int main(){
  int i, n, p, d1, d2, d;
  DATA person;
  vector<DATA> data;

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

    for(i=0; i<n; ++i){
      cin >> p >> d1 >> d2;
      d = d1 + d2;
      person.number = p;
      person.distance = d;
      data.push_back(person);
    }

    sort(data.begin(), data.end(), Compare);

    cout << data[0].number << " " << data[0].distance << endl;
    data.clear();
  }

  return 0;
}

bool Compare(const DATA& x, const DATA& y){
  return x.distance > y.distance;
}

Measured memory_bytes: 1116
from itertools import groupby
S=input()
K=int(input())
count=0
group=[len(list(value)) for key,value in groupby(S)]
for value in group:
    count+=value//2
count*=K
if S[0]==S[-1] and group[0]%2!=0 and group[-1]%2!=0:
    if len(S)==group[0]:
        count+=K//2
    else:
        count+=K-1
print(count)

Measured memory_bytes: 9104
from collections import deque

def bfs(a, b):
    global dist
    q = deque()
    q.append([a, b])
    bl, wh = 0, 0
    dist[a][b] = 0
    while q:
        p = q.popleft()
        x, y = p[0], p[1]
        if s[x][y] == "#":
            bl += 1
            for u in v:
                xx, yy = x + u[0], y + u[1]
                if s[xx][yy] == "." and dist[xx][yy] == -1:
                    dist[xx][yy] = dist[x][y] + 1
                    q.append([xx, yy])
        else:
            wh += 1
            for u in v:
                xx, yy = x + u[0], y + u[1]
                if s[xx][yy] == "#" and dist[xx][yy] == -1:
                    dist[xx][yy] = dist[x][y] + 1
                    q.append([xx, yy])
    return bl * wh

h, w = map(int, input().split())
s = [["$"] + list(input()) + ["$"] for _ in range(h)]
t = ["$"] * (w + 2)
s.insert(0, t)
s.append(t)
dist = [[-1] * (w + 2) for _ in range(h + 2)]
v = [[1, 0], [-1, 0], [0, 1], [0, -1]]
ans = 0
for i in range(1, h + 1):
    for j in range(1, w + 1):
        if dist[i][j] == -1:
            ans += bfs(i, j)
print(ans)

Measured memory_bytes: 9996
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k; string S;
    cin >> k >> S;
    rep(i, min(k, (int)S.length())) {
        cout << S[i];
    }
    if(k < S.length()) cout << "...";
    cout << endl;

    return 0;
}


Measured memory_bytes: 3656
import sys
from copy import copy
input = sys.stdin.readline
'''
n, m = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
S = input().strip()
for test in range(int(input())):
'''
inf = 100000000000000000  # 1e17
mod = 998244353

n, s = map(int, input().split())
a = [0]
a += list(map(int, input().split()))
#  dp = [[0] * (3010)] * (n + 2)  #
dp = [[0]*(3010) for i in range(n+2)]

ans = 0
for i in range(1, 1 + 1):
    dp[i][a[i]] = i
if a[1] == s:
    ans += n
for i in range(2, n + 1):
    if a[i] < s:
        dp[i][a[i]] += i
    dp[i][a[i]] %= mod
    if s > a[i]:
        ans += (n - i + 1) * dp[i - 1][s - a[i]]  # = -> +=
    elif s == a[i]:
        ans += (n - i + 1) * i
    ans %= mod
    for j in range(a[i], s+1):  #
        dp[i][j] += dp[i - 1][j - a[i]]
        dp[i][j] %= mod
    for j in range(0, s+1):
        dp[i][j] += dp[i - 1][j]
        dp[i][j] %= mod
print(ans)


Measured memory_bytes: 113628
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <cmath>
#include <sstream>
#include <algorithm>
#include <set>
#include <deque>
#include <list>
#include <cassert>
#include <iomanip>

using namespace std;

#define in cin
#define out cout
#define ll long long


int main() {

    string str;
    in>>str;

    int n=str.length();
    int cand=0;
    for (;1;cand++) {
        bool ok=1;
        for (char let='a';let<='z';let++) {
            ok=1;
            for (int start=0;start+cand<n;start++) {
                bool found=0;
                for (int span=0;span<=cand;span++) {
                    if (str[start+span]==let) found=1;
                }
                if (not found) ok=0;
            }
            if (ok) break;
        }
        if (ok) break;
    }

    out<<cand<<endl;

    return 0;


}







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

using namespace std;
using ll = long long;
vector<ll> ch[26];

int main () {
	ll n, k;
	cin >> n >> k;
	int ans = 1;
	ll nu = 1;
	for (; nu  * k <= n; nu *= k, ans++);
	cout << ans << "\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] c = sc.next().toCharArray();
        int[] currency = new int[c.length+1];
        int ans = 0;
        int borrow = 0;
        int tmp = 0;
        for(int i=c.length-1;i>=0;i--){
            tmp = c[i]-'0'+borrow;
            if(tmp < 5){
                currency[i+1] = tmp;
                ans+=tmp;
                borrow = 0;
            }else if(tmp == 5){
                if(i>=1 && c[i-1] >='5'){
                    borrow = 1;
                }else{
                    currency[i+1] = tmp;
                    borrow = 0;
                    ans+=tmp;
                }
            }else if(tmp<=9){
                borrow = 1;
            }else if(tmp==10){
                borrow = 1;
            }
        }
        if(borrow==1){
            ans++;
            currency[0] = 1;
        }
        borrow = 0;
        for(int i=c.length-1;i>=0;i--){
            tmp = currency[i+1] - (c[i] - '0') - borrow;
            if(tmp < 0){
                tmp  = tmp + 10;
                borrow = 1;
            }else{
                borrow = 0;
            }
            ans+=tmp;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 41016
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x;cin>>x;
  ll ans=(x/11)*2;
  x%=11;
  if(x==0){}
  else if(x<=6)ans++;
  else ans+=2;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



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

  if( x < 600) {
    cout << 8 << endl;
    return 0;
  }

  if( x < 800) {
    cout << 7 << endl;
    return 0;
  }

  if( x < 1000) {
    cout << 6 << endl;
    return 0;
  }

  if( x < 1200) {
    cout << 5 << endl;
    return 0;
  }
  if( x < 1400) {
    cout << 4 << endl;
    return 0;
  }

  if( x < 1600) {
    cout << 3 << endl;
    return 0;
  }

  if( x < 1800) {
    cout << 2 << endl;
    return 0;
  }

  if( x < 2000) {
    cout << 1 << endl;
    return 0;
  }

  return 0;
}


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

int a,b,x=0;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>a>>b;
	for(int i=1;i<b-a;i++){
		x+=i;
	}
	cout<<x-a;
	return 0;
}

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


int main(){
  
  int ixr, ixw, N, cnt=0;
  string S;
  cin>>N>>S;
  ixw=0; ixr=N-1;
  
  while(true){
    
    while(S[ixw]!='W' && ixw!=N-1) ixw++;
    while(S[ixr]!='R' && ixr!=0) ixr--;
    if(ixr<=ixw) break;
    cnt++;
    ixw++; ixr--;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3720
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int S = scan.nextInt();
		int W = scan.nextInt();

		if (W >= S) {
			System.out.println("unsafe");
		} else {
			System.out.println("safe");
		}
	}
}

Measured memory_bytes: 35588
//
// Created on 2020/01/26.
//

//#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;
using gragh = vector<vector<int>>;

int main() {
    int ans;
    int h;
    int n;
    int sum = 0;
    cin>>h>>n;
    for (int i = 0; i < n; ++i) {
        int temp;
        cin>>temp;
        sum += temp;
    }
    if(sum >= h) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    
}


Measured memory_bytes: 256
N = int(input())
ss = list(input())

def counter(ss,direction):
    l = []
    cnt = 0
    l.append(cnt)
    for s in ss[:-1]:
        if s == direction:
            cnt += 1
        l.append(cnt)
        
    return l

wtoe_cnt = counter(ss,"W")
etow_cnt = counter(ss[::-1],"E")[::-1]

cnt = 10**9
for wtoe,etow in zip(wtoe_cnt,etow_cnt):
    tmp_cnt = wtoe+etow
    if tmp_cnt < cnt:
        cnt = tmp_cnt
        
print(cnt)

Measured memory_bytes: 110784
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng (chrono::steady_clock::now().time_since_epoch().count() );

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 1e6 + 12; //check the limits, dummy

int main() {

    ios_base::sync_with_stdio (0);
    cin.tie (0);

    ll n;
    cin >> n;
    vector<vpl>in;
    F0R (i, n) {
        ll x;
        cin >> x;
        vpl now (x);
        F0R (j, x) cin >> now[j].fr >> now[j].se;
        in.pb (now);
    }

    ll ans = 0;
    FOR (i, 1, (1LL << n) ) {
        ll can = 0;
        bool check = 1;

        F0R (j, n) {
            if ( (1LL << j) &i) {
                can++;
                FOR (k, 0, sz (in[j]) ) {
                    ll x = in[j][k].fr - 1;
                    ll y = in[j][k].se;
                    ll mask_bit = ( ( (1LL << x ) &i) != 0);
                    if (y != mask_bit) check = 0;
                }
            }
        }

        if (check) ans = max (ans, can);
    }

    cout << ans << '\n';


    return  0;
}


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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
    return 0;
}

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

#define MAXINF 1000000005
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repc(it, x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rrepc(it, x) for(auto it = (x).rbegin(); it != (x).rend(); ++it)
#define all(x) (x).begin(), (x).end()
#define P pair<int, int>

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

Measured memory_bytes: 1536
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, ma, mb = map(int, readline().split())
inf = 40000
dp = [[[inf] * 401 for _ in range(401)] for _ in range(n + 1)]
ans = inf
dp[0][0][0] = 0
for i in range(n):
    a, b, c = map(int, readline().split())
    for j in range(401):
        for k in range(401):
            if dp[i][j][k] != inf:
                dp[i + 1][j + a][k + b] = min(dp[i + 1][j + a][k + b], dp[i][j][k] + c)
                dp[i + 1][j][k] = min(dp[i][j][k], dp[i + 1][j][k])
for i in range(1, 401):
    for j in range(1, 401):
        if i * mb == j * ma:
            if ans > dp[n][i][j]:
                ans = dp[n][i][j]
if ans == inf:
    ans = -1
print(ans)


Measured memory_bytes: 96092
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <list>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <iomanip>
#define INF 1050000000
 
using namespace std;

int par[10001];
int rank_[10001];

void init(int n)
{
	for (int i = 0; i < n; i++) {
		par[i] = i;
		rank_[i] = 0;
	}
}

int find(int x)
{
	if (par[x] == x) 
		return (x);
	else 
		return par[x] = find(par[x]);
}

void unite(int x, int y)
{
	x = find(x);
	y = find(y);
	if (x == y) return;
	if (rank_[x] < rank_[y]) {
		par[x] = y;
	} else {
		par[y] = x;
		if (rank_[x] == rank_[y]) rank_[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}

int main(void)
{
	int n;
	int q;
	int com, x, y;

	cin >> n >> q;

	init(n);
	for (int i = 0; i < q; i++) {
		cin >> com >> x >> y;

		if (com == 0) unite(x, y);
		else {
			if(same(x, y)) cout << "1" << endl;
			else		   cout << "0" << endl;
		}
	}


	return (0);
}

Measured memory_bytes: 1232
#include <iostream>
#include <algorithm>
using namespace std;
int n, a[9], p[9]; char c[9];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 9; j++) cin >> a[j], p[j] = j;
		for (int j = 0; j < 9; j++) cin >> c[j];
		int f = 0;
		do {
			int g = 1;
			for (int j = 0; j < 9; j += 3) {
				if (!(c[p[j]] == c[p[j + 1]] && c[p[j]] == c[p[j + 2]])) { g = 0; break; }
				int b[3] = { a[p[j]], a[p[j + 1]], a[p[j + 2]] };
				sort(b, b + 3);
				if ((b[1] - b[0]) != (b[2] - b[1]) || (b[1] - b[0]) >= 2) { g = 0; break; }
			}
			if (g) { f = 1; break; }
		} while (next_permutation(p, p + 9));
		cout << f << endl;
	}
	return 0;
}

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

int main()
{
  int n,w;
  cin>>n>>w;
  vector<int> weight(n);
  vector<int> value(n);
  
  for(int i=0;i<n;i++)
    cin>>weight[i]>>value[i];
  
  vector<vector<int64_t>> value_sum(n,vector<int64_t>(w+1));
  
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<=w;j++)
    {
      if(i==0)
      {
        if(weight[i]>j)
          value_sum[i][j]=0;
        else
          value_sum[i][j]=value[i];
      }
      else
      {
        if(weight[i]>j)
          value_sum[i][j]=value_sum[i-1][j];
        else
          value_sum[i][j]=max(value_sum[i-1][j],value_sum[i-1][j-weight[i]]+value[i]);
      }
    }
  }
      cout<<value_sum[n-1][w]<<endl;
}
  

Measured memory_bytes: 79488
use proconio::{fastout, input};
const MOD: usize = 1_000_000_000 + 7;

#[fastout]
fn main() {
    input! {
        n: usize,
    }

    let mut pow10 = vec![1; n + 1];
    for i in 1..=n {
        pow10[i] = pow10[i - 1] * 10 % MOD;
    }

    let mut pow9 = vec![1; n + 1];
    for i in 1..=n {
        pow9[i] = pow9[i - 1] * 9 % MOD;
    }

    let mut pow8 = vec![1; n + 1];
    for i in 1..=n {
        pow8[i] = pow8[i - 1] * 8 % MOD;
    }

    let ans = (pow10[n] + 2 * MOD - 2 * pow9[n] + pow8[n]) % MOD;

    println!("{}", ans);
}


Measured memory_bytes: 25360
import sys
input = sys.stdin.readline

N = int(input())
a = [int(i) for i in input().split()]

from collections import Counter

Count_a = Counter(a)

if len(Count_a) == 1:
    if Count_a[0] == N:
        print("Yes")
    else:
        print("No")

elif len(Count_a) == 2 and N % 3 == 0:
    if Count_a[0] == N // 3:
        print("Yes")
    else:
        print("No")

elif len(Count_a) == 3 and N % 3 == 0:
    three = list(set(a))
    if three[0] ^ three[1] ^ three[2] == 0:
        for i in range(3):
            if Count_a[three[i]] != N // 3:
                print("No")
                exit()
        print("Yes")
    else:
        print("No")

else:
    print("No")

Measured memory_bytes: 14212
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
c.sort()
ct=0
for i in range(n):
  x=bisect.bisect_left(a,b[i])
  y=len(c)-bisect.bisect(c,b[i])
  ct+=x*y
print(ct)

Measured memory_bytes: 23232
def multi_lcm(array: list) -> dict:
    """arrayのLCMを素因数分解の積の形として求める(ABC152-E)
    入出力例: [4, 18, 21] -> {2: 2, 3: 2, 7: 1}
    key, val = 素因数, 素因数の個数
    """
    pf = {}  # pf: prime_factor
    for num in array:
        for k in range(2, int(num**0.5) + 1):
            cnt = 0
            while num % k == 0:
                cnt += 1
                num //= k
            if cnt != 0:
                if k not in pf:
                    pf[k] = cnt
                else:
                    pf[k] = max(cnt, pf[k])
        if num != 1:
            if num not in pf:
                pf[num] = 1
    return pf

  
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9 + 7

factor = multi_lcm(a)
lcm_ = 1
for num in factor:
    cnt = factor[num]
    lcm_ *= pow(num, cnt, MOD)
    lcm_ %= MOD

ans = 0
for num in a:
    ans += lcm_ * pow(num, MOD - 2, MOD)
    ans %= MOD
print(ans)

Measured memory_bytes: 46832
import sys
import heapq
my_input = sys.stdin.readline

def main():
    xs, ys, xt, yt = map(int, my_input().split())
    N = int(my_input())
    C = [(xs, ys, 0), (xt, yt, 0)]
    C += [tuple(map(int, my_input().split())) for i in range(N)]

    G = [[] for i in range(N+2)]
    for i in range(N + 2):
        for j in range(i + 1, N + 2):
            cost = max(0, ((C[i][0] - C[j][0]) ** 2 + (C[i][1] - C[j][1]) ** 2) ** 0.5 - (C[i][2] + C[j][2]))
            G[i].append((j, cost))
            G[j].append((i, cost))


    def dijkstra(graph, start, inf=float('inf')):
        import heapq
        n = len(graph)
        distances = [inf] * n
        distances[start] = 0
        visited = [False] * n

        # 距離・頂点
        hq = [(0, start)]
        while hq:
            dist, fr = heapq.heappop(hq)
            if distances[fr] < dist:
                continue
            if fr == 1:
                return distances
            visited[fr] = True

            for to, cost in graph[fr]:
                new_dist = distances[fr] + cost
                if (visited[to]) or (distances[to] <= new_dist):
                    continue

                distances[to] = new_dist
                heapq.heappush(hq, (new_dist, to))

        return distances


    dist = dijkstra(G, 0)
    print(dist[1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 167080
#include <bits/stdc++.h>
#include <string>
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 ll long long

int main() {
	string s;
	ll k;
	int ans;

	cin >> s >> k;

	int x = s.size();
	int n = 0;
	rep(i, s.size()) {
		if (s[i] > '1') {
			x = i;
			n = s[i] - '0';
			break;
		}
	}
	if (k <= (ll)x )
		ans = 1;
	else
		ans = n;

	cout << ans << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
  ll i,j;
  ll n;
  cin>>n;
  ll m=1e11;
  ll ng=0;
  ll x;
  ll ans=0;
  for(i=0;i<n;i++){
    cin>>x;
    m=min(m,abs(x));
    if(x<0) ng=1-ng;
    ans+=abs(x);
  }
  if(ng==1) ans-=m*2;
  cout<<ans<<endl;
  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pi 3.141592653589793
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define vfind(a, e) find(a.begin(), a.end(), e)
#define forr(i, n) for (ll i = 0; i < n; i++)
#define rfor(i, n) for (ll i = n - 1; i >= 0; i--)
#define fors(i, b, e, steps) for(ll i = b; i < e; i += steps)
#define rfors(i, e, b, steps) for(ll i = e; i > b; i -= steps)
#define mp make_pair
using namespace std;


bool isVowel(char c){
    return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}

bool isLower(char c){
    return 97 <= c && c <= 122;
}

bool prime[1001];
void sieve() {
    fill(prime, prime + 1000, 1);
    prime[0] = prime[1] = 0;

    fors(i, 2, 1000, 1) {
        if (prime[i]) {
            fors(j, i * 2, 1000, i) prime[j] = 0;
        }
    }
}

bool f(int a, int b) {
    return a <= b;
}



int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    unordered_map<char, char> d;
    d['A'] = 'T';
    d['T'] = 'A';
    d['C'] = 'G';
    d['G'] = 'C';

    string s;
    cin >> s;
    int t = 0, ans = 0;
    for (char c : s) {
        if (d.find(c) != d.end()) {
            t++;
        }
        else {
            ans = max(t, ans);
            t = 0;
        }
    }
    
    cout << max(t, ans);


}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int Maxn=3010;
string S,T;
int Dp[Maxn][Maxn];
void Print(int N,int M)
{
	if(!N||!M)
		return;
	if(S[N-1]==T[M-1])
	{
		Print(N-1,M-1);
		cout<<S[N-1];
	}
	else if(Dp[N-1][M]>Dp[N][M-1]) 
		Print(N-1,M);
	else                           
		Print(N,M-1);
}
int main()
{
	cin>>S>>T;
	int N=S.length(),M=T.length();
	for(int i=0;i<=N;i++)
		Dp[i][0]=0;
	for(int i=0;i<=M;i++)
		Dp[0][i]=0;
	for(int i=1;i<=N;i++)
	{
		for(int j=1;j<=M;j++)
			if(S[i-1]!=T[j-1])
			{
				if(Dp[i-1][j]>Dp[i][j-1])
					Dp[i][j]=Dp[i-1][j];
				else
					Dp[i][j]=Dp[i][j-1];
			}
			else
			{
				if(Dp[i-1][j]>Dp[i][j-1]) 
					Dp[i][j]=Dp[i-1][j-1]+1;
				else
					Dp[i][j]=Dp[i-1][j-1]+1;
			}
	}
//	cout<<N<<" "<<M<<endl;
//	for(int i=1;i<=N;i++)
//	{
//		for(int j=1;j<=M;j++) cout<<Dp[i][j]<<" ";
//		puts("");
//	}
	Print(N,M);
	return 0;
}

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

int main()
{
	int n,y,m,d;
	int y3,yd,m2,md,dd,y2;

	cin >> n;

	for(int i=0;i<n;i++){
		cin >> y >> m >> d;

		if(y%3!=0)	y2=y+(3-y%3);
		else y2=y;
		y3 = 334-y2/3;
		yd = y3*200 + (1000-y-y3)*195;

		m2 = m/2;
		if(y%3!=0){
			md = yd-39*m2;
			if(m%2==1){
				dd = md-d+1;
			}else{
				dd = md + (19-d+1);
			}
		}else{
			md = yd-20*m;
			dd = md+20-d+1;
		}
		cout << dd << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
using namespace std;

int main(){
  string s;
  cin >> s;
  rep(i, 0, s.length()){
    if(s[i] == '1') s[i] = '9';
    else if(s[i] == '9') s[i] = '1';
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
/*
	*#*#*#* Author GaryMr *#*#*#*
########################################################################
	是否可以简化问题：
	抓住数据范围哪里小
	dfs or bfs
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	树的直径:随便找一点再走到它最远的点A，再从A最远的点走到最远B的点。AB就是树的直径
	匹配括号 左减右>=0
	字符串赋值字符加单引号
	double> printf("%lf")输出小数点6位，%.16lf输出后十六位
	多组数据清空？
	dp优化用g？
	线段树：大小为n的8倍
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
	1<<int(ceil(log2(double(n))))
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define IM int main()
using namespace std;
const int MAX=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n;
int C=1e5+10;
int line_R[200030],line_L[200030];
IM{
	scanf("%d",&n);
	line_R[C]=1;
	line_L[C]=1;
	rb(i,1,n){
		int li,ri;
		scanf("%d %d",&li,&ri);
		li+=C;
		ri+=C; 
		line_R[ri]++;
		line_L[li]++;
	}
	rl(i,2*C-2,1){
		line_L[i]+=line_L[i+1];
	}
	rb(i,1,2*C-1){
		line_R[i]+=line_R[i-1];
	}
	LL res=0;
	rb(i,1,2*C-1){
		res+=min(line_R[i],line_L[i+1]);
	}
	printf("%lld\n",res*2);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>

using namespace std;

int main() {
    string input;
    cin >> input;

    string year = input.substr(0, 4);
    string month = input.substr(5, 2);
    string day = input.substr(8, 2);


    int year_int = stoi(year);
    int month_int = stoi(month);
    int day_int = stoi(day);

    if (year_int <= 2018) {
        cout << "Heisei";
        return 0;
    }

    if (year_int >= 2020) {
        cout << "TBD";
        return 0;
    }

    if (month_int <= 4) {
        cout << "Heisei";
        return 0;
    }
    cout << "TBD";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstring> 
using namespace std;
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define int long long int
#define mpp make_pair
#define F first
#define mem(a,b) memset(a,b,sizeof(a))
#define F first
#define S second
#define MOD 100000007
#define in_range(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)
const int MAXN = 3e5+5;
#define MAXI 2e18+3
#define all(v) v.begin(), v.end()
#define endl "\n"
# define PI 3.14159265358979323846

int mn[1000005];
int tot[1000005];
bool comp1(int x,int y)
{
  return mn[x]>mn[y];
}

bool comp2(int x,int y)
{
  return tot[x]-mn[x]>tot[y]-mn[y];
}

std::vector<int> x, y;

signed main(){
 
    fast;
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    int n, i;
  	cin>>n;
  	string a[n+1];
  	for(i=1;i<=n;i++){
  		cin>>a[i];
  		int l = a[i].length();
  		int c=0, mini=MAXI;
  		for(int j=0;j<l;j++){
  			if(a[i][j]=='(')
  				c++;
  			else
  				c--;
  			mini = min(mini, c);
  		}
  		mn[i]=mini;
  		tot[i]=c;
  		if(c>=0)
  			x.pb(i);
  		else
  			y.pb(i);
  	} 
 	sort(all(x), comp1);
 	sort(all(y), comp2);
  	int ans=0;
  	for(auto i:x){
  		if(ans+mn[i]<0){
  			cout<<"No"<<endl;
  			return 0;
  		}
  		ans+=tot[i];
  	}
  	for(auto i:y){
  		if(ans+mn[i]<0){
  			cout<<"No"<<endl;
  			return 0;
  		}
  		ans+=tot[i];
  	}
  	if(ans!=0){
  		cout<<"No"<<endl;
  	}
  	else{
  		cout<<"Yes"<<endl;
  	}
}

Measured memory_bytes: 58052
#113 B
N =int(input())
T,A= map(int,input().split())
H =[int(j) for j in input().split()]
ans = 10**9
for i,j in enumerate(H):
    if ans >= abs(A-(T- 0.006 *j)):
        ans =abs(A-(T- 0.006 *j))
        ans2=i+1
print(ans2)

Measured memory_bytes: 3060
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <queue>
#include <typeinfo>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int h,w;
    int sx,sy;
    int gx,gy;
    array<string, 50> ma;
    cin >> h >> w;
    //cin >> sy >> sx;
    //cin >> gy >> gx;
    sx = 0; sy = 0; gx = w-1;gy = h-1;

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


    queue<int> que_x;
    queue<int> que_y;
    que_x.push(sx);
    que_y.push(sy);
    array<array<int, 50> , 50> memo;
    for (int i = 0; i < h; i++){
        for (int k = 0; k < w; k++){
            memo[i][k] = -1;
        }
    }
    memo[sy][sx] = 0;

    array<int, 4> dx = {1,-1,0,0};
    array<int, 4> dy = {0,0,1,-1};

    while(que_x.size() != 0 && que_y.size() != 0){
        int x = que_x.front();
        int y = que_y.front();
        que_x.pop();
        que_y.pop();

        for (int i = 0; i < 4; i++){
            int nextX = x + dx[i];
            int nextY = y + dy[i];

            if (0 <= nextX && 0 <= nextY && nextX < w && nextY < h && ma[nextY][nextX] == '.'){

                int passed = memo[nextY][nextX];
                if(passed == -1){
                    memo[nextY][nextX] = memo[y][x] + 1;
                    que_x.push(nextX);
                    que_y.push(nextY);
                }
            }
        }
    }

    vector<int> a;
    for (int i = 0; i < h; i++){
        for (int k = 0; k < w; k++){
            if (memo[i][k] != -1){
                a.push_back(memo[i][k]);
            }
        }
    }
    sort(all(a));

    /*
    int cnt = 0;
    for(int i = 0; i < a.size(); i++){
        for(int k = i+1; k < a.size(); k++){
            cout << "i = " << i << " k = " << k << endl;
            if (a[i] == a[k]){
                cnt++;
            } else {
                i = k-1;
                break;
            }
        }
    }
    */
    int cnt = 0;
    for (int i = 0; i < h; i++){
        for (int k = 0; k < w; k++){
            if (ma[i][k] == '.')cnt++;
        }
    }


    if (memo[gy][gx] == -1){
        cout << -1 << endl;
    } else {
        cout << cnt - memo[gy][gx] -1 << endl;
    }


    //que.push(make_pair(1,2));
    //cout << que.front().first << endl;
    return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, x, t;
    cin >> n >> x >> t;
    int sum = 0;
    while (n >  0) {
        n -= x;
        sum += t;
    }
    cout << sum;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
using Graph = vector<vector<int>>;


int main() {
  ll n, m; cin >> n >> m;
  vector<pair<ll, ll>> py(m), vp(m);
  rep(i, 0, m) cin >> py[i].first >> py[i].second;
  vp = py;
  sort(ALL(vp));
  map<pair<ll, ll>, ll> ma;
  ll cnt = 1;
  rep(i, 0, m){
    if(i){
      if(vp[i].first != vp[i-1].first) cnt = 1;
    }
    ma[vp[i]] = cnt;
    cnt++;
  }
  rep(i, 0, m){
    int a, b;
    a = (int)py[i].first, b = (int)ma[py[i]];
    printf("%06d", a);
    printf("%06d\n", b);
  }

  return 0;
}


Measured memory_bytes: 10880
#include<stdio.h>
int main()
{
  int x,y;
  while(1){
    scanf("%d%d",&x,&y);
    if(x==0&&y==0)break;
    else  if(x>=y){printf("%d %d\n",y,x);
    }else{printf("%d %d\n",x,y);
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T> T count_bit(T p){
  if(typeid(p)==typeid(int))return __builtin_popcount(p);
  else if(typeid(p)==typeid(long))return __builtin_popcountl(p);
  else return __builtin_popcountll(p);
}
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  long N;
  in(N);
  vector<long>A(N);
  ins(A);
  vector<long>B;
  B=A;
  sort(all(B));
  rep(i,N){
    dw(j,N-1,0){
      if(B[j]!=A[i]||B[j]==B[j-1]){
        out(B[j]);
        break;
      }
    }
  }
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 4736
N = int(input())
S = input()

max_num = S[1:].count('W')
pre_num = max_num

for i in range(1, N):
    num = pre_num
    if S[i-1] == 'E':
        num += 1
    if S[i] == "W":
        num -= 1

    if num > max_num:
        max_num = num
    pre_num = num

print(N - max_num - 1)


Measured memory_bytes: 3672
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
using namespace std;
int a[200005] = { 0 };
int main() {
	int k, n, i, t = 0;
	cin >> k >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int ans = 0, max = -1;
	for (i = 1; i < n; i++) {
		t = a[i] - a[i - 1];
		ans += t;
		if (t > max)max = t;
	}
	if (n > 1) {
		t = k - a[n - 1] + a[0];
	}
	ans += t;
	if (t > max)max = t;
	cout << ans - max << endl;
	return 0;
}

Measured memory_bytes: 1024
while True:
    m, f, r = input().split()
    if m == f == r == "-1":
        break
    m = int(m)
    f = int(f)
    r = int(r)
    x = m + f
    if m == -1 or f == -1:
        print("F")
    elif x >= 80:
        print("A")
    elif x >= 65:
        print("B")
    elif x >= 50:
        print("C")
    elif x >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


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

#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<"\n";
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define debug2(a,b) cout<<a<<" "<<b<<"\n";
#define debug4(a,b,c,d) cout<<a<<" "<< b <<" "<<c<<" "<<d<<"\n";

ll mod = 1000000007;

using namespace std;

int main()
{
	
	 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	 int n,h,w;
	 cin>>n>>h>>w;
	 int diff = n-h+1;
	 int diff2 = n-w+1;
	 cout<<diff2*diff<<"\n";
	return 0;
}

Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,w,z;
    char ca,cb,cc;
    cin>>a>>b;
    sum=a-1;
    if(b>=a) sum++;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


void err() {
	puts("NO");
	exit(0);
}

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


	int R, C, N;
	cin >> R >> C >> N;
	set<int>ng;
	vector<vector<int>>tp1, tp2, tp3, tp4;
	for (int i = 0; i < N; i++) {
		vector<int>c(2);
		for (int j = 0; j < 2; j++) {
			int y, x;
			cin >> y >> x;
			if (x == 0 && 0 <= y && y < R)tp1.pb({y,x,i});
			else if (y == R && 0 <= x && x < C)tp2.pb({x,y,i});
			else if (x == C && 0 < y && y <= R)tp3.pb({y,x,i});
			else if (y == 0 && 0 < x && x <= C)tp4.pb({x,y,i});
			else c[j] = 1;
		}
		if (c[0] || c[1])ng.insert(i);
	}


	vector<int>fl(N);

	stack<int>st;
	sort(all(tp1));
	sort(all(tp2));
	sort(all(tp3));
	reverse(all(tp3));
	sort(all(tp4));
	reverse(all(tp4));

	


	for (int i = 0; i < tp1.size(); i++) {
		int idx = tp1[i][2];
		if (ng.count(idx))continue;
		if (fl[idx] == 0) {
			fl[idx] = 1;
			st.push(idx);
		}
		else {
			if (st.top() != idx)err();
			else st.pop();
		}
	}
	for (int i = 0; i < tp2.size(); i++) {
		int idx = tp2[i][2];
		if (ng.count(idx))continue;
		if (fl[idx] == 0) {
			fl[idx] = 1;
			st.push(idx);
		}
		else {
			if (st.top() != idx)err();
			else st.pop();
		}
	}
	for (int i = 0; i < tp3.size(); i++) {
		int idx = tp3[i][2];
		if (ng.count(idx))continue;
		if (fl[idx] == 0) {
			fl[idx] = 1;
			st.push(idx);
		}
		else {
			if (st.top() != idx)err();
			else st.pop();
		}
	}
	for (int i = 0; i < tp4.size(); i++) {
		int idx = tp4[i][2];
		if (ng.count(idx))continue;
		if (fl[idx] == 0) {
			fl[idx] = 1;
			st.push(idx);
		}
		else {
			if (st.top() != idx)err();
			else st.pop();
		}
	}
	


	puts("YES");
	return 0;
}


Measured memory_bytes: 13668
using System;
using System.Linq;
using static System.Math;
using System.Collections.Generic;
using Li = System.Collections.Generic.List<int>;
using Ll = System.Collections.Generic.List<long>;

namespace AtCoder0705
{
	class Program
	{
		static void Main(string[] args)
		{
			B();
		}

		private static void A()
		{
			var n = int.Parse(Console.ReadLine());
			Console.WriteLine((1000 - n % 1000) % 1000);
		}

		private static void B()
		{
			var n = int.Parse(Console.ReadLine());
			var strs = Enumerable.Range(0, n).Select(x => Console.ReadLine()).ToArray().GroupBy(x => x).Select(g => Tuple.Create(g.Key, g.Count())).ToArray();
			var ac = strs.Where(x => x.Item1 == "AC").Select(x => x.Item2).FirstOrDefault();
			var wa = strs.Where(x => x.Item1 == "WA").Select(x => x.Item2).FirstOrDefault();
			var tle = strs.Where(x => x.Item1 == "TLE").Select(x => x.Item2).FirstOrDefault();
			var re = strs.Where(x => x.Item1 == "RE").Select(x => x.Item2).FirstOrDefault();

			Console.WriteLine($"AC x {ac}");
			Console.WriteLine($"WA x {wa}");
			Console.WriteLine($"TLE x {tle}");
			Console.WriteLine($"RE x {re}");
		}

		private static long[] ReadInts() => Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
	}
}


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

int main() {
    ll n,a,b,c,d,e;
    cin>>n>>a>>b>>c>>d>>e;
    ll s = min({a,b,c,d,e});
    
    
    cout << (n+s-1)/s + 4 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;
typedef long long LL;

const int N = 1e8;

int main()
{
	int a , b , c , ta , tb , tc;
	scanf("%d %d %d",&a , &b , &c);
	LL flag = 0 , i;
	if(a == b && b == c && a % 2 == 0) {printf("-1\n");return 0;}
	if(a % 2 || b % 2 || c % 2){printf("0\n");return 0;}
	for(i = 0 ; i <= N ; i++){
		int sum = 0;
		if(a % 4 == 0) sum++;
		if(b % 4 == 0) sum++;
		if(c % 4 == 0) sum++;
		if(sum == 0) {flag = 2; break;}
		else if(sum == 1 || sum == 2){flag = 1;break;}
		ta = (b + c)/2;
		tb = (a + c)/2;
		tc = a + b + c - ta - tb;
		a = ta , b = tb , c = tc;
	}
	if(flag == 0) {printf("-1\n");return 0;} 
	else 
		printf("%d\n",i + flag);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
  int i,f=0;
  char s[6];
  scanf("%s",s);
  for(i=0;i<5;i++){
    if(s[i]=='A'&&s[i+1]=='C')f=1;
  }
  puts(f?"Yes":"No");
  return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n=scanner.nextInt();
        Deque<Integer> result=new LinkedList<>();
        for(int i=0;i<n;i++){
            if(i%2==0){
                result.offerLast(scanner.nextInt());
            }else{
                result.offerFirst(scanner.nextInt());
            }
        }
        Iterator<Integer> itr=(n%2==0)?result.iterator():result.descendingIterator();
        System.out.print(itr.next());
        while(itr.hasNext()){
            System.out.print(format(" %d",itr.next()));
        }
        put("");


    }

    public static void put(Object object) {
        System.out.println(object);
    }
    public static String format(String string, Object... args) {
        return String.format(string, args);
    }
}

Measured memory_bytes: 168224
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
*/public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
static class TaskC   {
public void solve(int testNumber, Scanner in, PrintWriter out) {
        String S = in.next();
        long K = in.nextLong();
        int idx1 = 0;
        while (idx1 < S.length()) {
            if(S.charAt(idx1)-'0' != 1) break;
            idx1++;
        }
        if(K <= idx1) out.println(1);
        else{
            char ans = S.charAt(idx1);
            out.println(ans);
        }
    }

}
}



Measured memory_bytes: 21972
import scala.io.StdIn.readLine

object Main {

  def play(sb:StringBuilder):Unit = {
    val r = readLine.split(" ")
    if(r(0).toInt==0 && r(1).toInt==0) print(sb.result)
    else {
      var hit = 0
      var blow = 0
      for(i<-0 until r(0).length) {
        if(r(0)(i) == r(1)(i)) hit += 1
        else {
          for(j<-0 until r(1).length) {
            if(r(0)(i) == r(1)(j)) blow += 1
          }
        }
      }
      sb.append(hit + " " + blow + "\n")
      play(sb)
    }
  }

  def main(args:Array[String]) = play(new StringBuilder)
}

Measured memory_bytes: 56144