akhauriyash/Code-Regression huggingface dataset:
//
import java.math.*;
import java.util.*;
import java.io.*;
  
public class Main { 
  
    static BufferedReader in;
    static PrintWriter out = new PrintWriter(System.out);
    static String file = "../in";
    static int test = 10; // 0 for local testing, 1 for std input
    static int inf = 1_000_000;

    void swap(int[]ary, int i, int j)
    {
        int t = ary[i];
        ary[i] = ary[j];
        ary[j] = t;
    }
    
    String[] split() throws Exception
    {
        return in.readLine().split(" ");
    }

    int readInt() throws Exception
    {
        return Integer.valueOf(in.readLine());
    }

    int[] toIntArray() throws Exception
    {
        String[] sp = split();
        int n = sp.length;
        int[] ary = new int[n];
        for(int i = 0; i < n; i++) ary[i] = Integer.valueOf(sp[i]);
        return ary;
    }

    String reverse(String str)
    {
        return new StringBuilder(str).reverse().toString();
    }

    public static void main(String[] args) throws Exception
    {
        int _k = Integer.valueOf("1");
        if(test > 0) in = new BufferedReader(new InputStreamReader(System.in));
        else in = new BufferedReader(new FileReader(file));
        if(test < 0) {String[] str = in.readLine().split(" ");}
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
        // System.out.println((-100 + 0) / 2);

        new Main().b();
        out.flush();
    }

    void b() throws Exception
    {
        int[] ary = toIntArray();
        int n = ary[0], a = ary[1], b = ary[2];
        ary = toIntArray();
        long sum = 0;
        for(int i = 1; i < n; i++)
        {
            long costa = (0L + ary[i] - ary[i - 1]) * a,
                costb = 0L + b;
            sum += Math.min(costa, costb);
        }
        
      	out.println(sum);
    }
}


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

using namespace std;

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

  vector<vector<int>> adjacent(n);
  for (int i = 0; i < n; i++) {
    int u, k;
    cin >> u >> k;
    --u;

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

      adjacent[u].push_back(v);
    }
  }

  vector<int> d(n, 0), f(n, 0);
  vector<bool> visited(n, false);
  stack<int> S;

  S.push(0);

  int t = 1;

  d[0] = t;

  while (!S.empty()) {
    ++t;

    int u = S.top();

    if (!visited[u]) {
      visited[u] = true;
    }

    bool done = true;
    for (int i = 0; i < adjacent[u].size(); i++) {
      int v = adjacent[u][i];

      if (!visited[v]) {
        done = false;
        d[v] = t;
        S.push(v);
        break;
      }
    }

    if (done) {
      f[u] = t;
      S.pop();
    }

    // スタックが空になった後、未訪問なノードがあればそれを始点として再度DFSする
    if (S.empty()) {
      for (int i = 0; i < n; i++) {
        if (!visited[i]) {
          ++t;
          S.push(i);
          d[i] = t;
          break;
        }
      }
    }
  }

  for (int i = 0; i < n; i++) {
    cout << i + 1 << " " << d[i] << " " << f[i] << endl;
  }

  return 0;
}

/*
6
1 2 2 3
2 2 3 4
3 1 5
4 1 6
5 1 6
6 0
*/


Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

inline bool update(int &a, int v) {
    if(a < v) return false;
    a = v;
    return true;
}
// dp[ptr][which][need]
int dp[2][2][5001];
const int INF = 10000*10000;

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

    int N;
    cin >> N;
    vector<int> cost(N-1);
    for(int i = 0; i < N-1; ++i) {
        cin >> cost[i];
    }
    int ans = INF;
    int ptr = 0;
    fill_n(dp[ptr][0], N/2+1, INF);
    fill_n(dp[ptr][1], N/2+1, INF);
    dp[ptr][0][N/2-1] = 0;
    dp[ptr][1][N/2] = 0;
    ptr ^= 1;
    for(int i = 1; i < N; ++i) {
        int prev = ptr ^ 1;
        fill_n(dp[ptr][0], N/2+1, INF);
        fill_n(dp[ptr][1], N/2+1, INF);
        for(int j = 0; j <= N/2; ++j) {
            // 直前がAのとき
            if(j+1 <= N/2) update(dp[ptr][0][j], dp[prev][0][j+1]);
            update(dp[ptr][1][j], dp[prev][0][j] + cost[i-1]);
            
            // 直前がBのとき
            if(j+1 <= N/2) update(dp[ptr][0][j], dp[prev][1][j+1] + cost[i-1]);
            update(dp[ptr][1][j], dp[prev][1][j]);

            // ここで残りが0になるなら，直後で切らないといけない
            if(j == 0) {
                if(i < N-1) dp[ptr][0][j] += cost[i];
            }
            //cout << j << ": " << dp[ptr][0][j] << ' ' << dp[ptr][1][j] << endl;
        }
        update(ans, min(dp[ptr][0][0], dp[ptr][1][0]));
        ptr ^= 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 988
import           Control.Exception (assert)
import           Data.List         (permutations, sort)

main :: IO ()
main = do
  n <- readLn
  p <- map read . words <$> getLine
  q <- map read . words <$> getLine
  assert (length p == n && length q == n) $
    print $ solve n p q

solve :: Int -> [Int] -> [Int] -> Int
solve n p q
  | p < q     = solve' n p q
  | otherwise = solve' n q p

solve' :: Int -> [Int] -> [Int] -> Int
solve' n p q = length $ takeWhile (q /=) $ dropWhile (p /=) $ allPermutation n

allPermutation :: Int -> [[Int]]
allPermutation n = sort $ permutations [1..n]


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, t; cin>>n>>t;
    vi a(n), b(n);
    rep(i, n) cin>>a[i]>>b[i];

    vector<vll> dp(n+1, vll(t, 0));
    for(int i=0; i<n; i++){
        for(int j=0; j<=t-1; j++){
            if (j>=a[i]){
                dp[i+1][j] = max(dp[i][j], dp[i][j-a[i]]+b[i]);
            }else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    vector<vll> dp2(n+1, vll(t, 0));
    for(int i=n-1; i>=0; i--){
        for(int j=0; j<=t-1; j++){
            if (j>=a[i]){
                dp2[i][j] = max(dp2[i+1][j], dp2[i+1][j-a[i]]+b[i]);
            }else{
                dp2[i][j] = dp2[i+1][j];
            }
        }
    }

    ll ans=0;
    rep(i, n){
        for(int j=0; j<=t-1; j++){
            ans = max(ans, dp[i][j]+dp2[i+1][t-1-j]+b[i]);
        }
    }
    cout << ans << "\n";

	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// DON'T USE THESE MACROS DURING ICPC PRACTICE
#define For(i,n) for (int i=0; i<n; i++)
#define FOR(i,a,b) for (int i=a; i<=b; i++)
#define Down(i,n) for (int i=n-1; i>=0; i--)
#define DOWN(i,a,b) for (int i=b; i>=a; i--)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<int> vi;

const char nl = '\n';
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1e-10;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

struct Edge {
	int a,b,c;
};

const int N = 2500+1;
const int M = 5e3+1;
int dist[N], rev[N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(10);

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

	vector<Edge> edges;
	For(i,m) {
		int a,b,c;
		cin>>a>>b>>c;
		edges.push_back({a,b,p-c});
	}

	memset(dist,INF,sizeof dist);
	memset(rev,INF,sizeof rev);
	dist[1] = 0;
	rev[n] = 0;
	For(i,n-1) {
		for (const Edge& e : edges) {
			dist[e.b] = min(dist[e.b], dist[e.a]+e.c);
			rev[e.a] = min(rev[e.a], rev[e.b]);
		}
	}
	for (const Edge& e : edges) {
		if (dist[e.a]<INF/2 && rev[e.b]<INF/2) {
			if (dist[e.a]+e.c < dist[e.b]) {
				cout << -1 << nl;
				return 0;
			}
		}
	}
	cout << max(0, -dist[n]) << nl;

	return 0;
}


Measured memory_bytes: 480
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
  // cin.tie(0); ios::sync_with_stdio(false);
  int t; cin >> t;
  for (int ti = 0; ti < t; ti++) {
    lint a, b, c, d; cin >> a >> b >> c >> d;
    if (a < b or d < b) {
      cout << "No" << '\n';
      continue;
    }
    if (c >= b - 1) {
      cout << "Yes" << '\n';
      continue;
    }
    lint g = __gcd(b, d);
    lint x = a - (a - c - 1) / g * g;
    cout << (x < b ? "No" : "Yes") << '\n';
  }
  return 0;
}

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

int eucl(int a, int b){
    if(a == 0){
        return b;
    }
    else
    {
        // cout << b << " "<< b%a << endl;
        return eucl(b % a, a);
    }
}




int main_1(){
    int N;
    cin >> N;
    std::vector<int> value(N);
    std::vector<int> gcd_r(N);
    std::vector<int> gcd_l(N);
    for(int i=0; i < N; i++){
        cin >> value.at(i);
    }

    gcd_l.at(0) = value.at(0);
    gcd_r.at(N-1) = value.at(N - 1);
    for(int i=1; i < N; i++){
        gcd_l.at(i) = eucl(value.at(i), gcd_l.at(i - 1));
    }
    for(int i=1; i < N; i++){
        gcd_r.at(N - i - 1) = eucl(value.at(N - i -1), gcd_r.at(N-i));
    }
    int max_gcd = gcd_r.at(1);
    int gcd_tmp;
    // for(int i=0; i < N; i++){
    //     cout << gcd_l.at(i) << " ";
    // }
    // cout << endl;
    // for(int i=0; i < N; i++){
    //     cout << gcd_r.at(i) << " ";
    // }
    // cout << endl;

    for(int i = 1; i <  N- 1; i++){
        gcd_tmp = eucl(gcd_l.at(i - 1), gcd_r.at(i + 1));
        max_gcd = max(max_gcd, gcd_tmp);
    }
    gcd_tmp = gcd_l.at(N - 2);
    max_gcd = max(max_gcd, gcd_tmp);

    cout << max_gcd << endl;
    return 0;
}

int main(){
    int N;
    cin >> N;
    std::vector<int> value(N);
    for(int i=0; i < N; i++){
        cin >> value.at(i);
    }
/*
number       12    8    16    15
acc_gcd  0   12    4    4     1
gcd_set  {}  0   12,8 4,(4,4) 4,1


*/
    std::vector<int> acc_gcd(N + 1);
    std::vector<set<int> > gcd_set(N + 1);
    acc_gcd.at(0) = 0;

    for(int i=1; i < N + 1; i++){
        acc_gcd.at(i) = eucl(acc_gcd.at(i-1), value.at(i - 1)); //i番めまでのgcd
        gcd_set.at(i).insert(acc_gcd.at(i-1)); //i番めをremoveした時の, i番めまでのgcd(=i-1番めまでのgcd)
        for(const int &gcd_tmp : gcd_set.at(i - 1)){
            gcd_set.at(i).insert(eucl(gcd_tmp, value.at(i - 1))); //i-1番め以前のどれか(一つ一つがgcd_tmpに対応)をremoveした時の,i番めまでのgcd
        }
    }
    // for(int i=1; i < N + 1; i++){
    //     cout << value.at(i-1) << " " << acc_gcd.at(i) << " ";
    //     for(const int &g : gcd_set.at(i)){
    //         cout << g << ",";
    //     }
    //     cout <<endl;
    // 
    // }
    set<int>::iterator itr = gcd_set.at(N).end();
    itr --;
    cout << *itr << endl;
    return 0;
}


Measured memory_bytes: 14208
use itertools::Itertools;
fn main() {
    proconio::input! {
        n: usize,
        a: [i64; n-1],
    }
    let mut v = vec![0; n];
    for a in a {
        v[(a - 1) as usize] += 1;
    }
    let ans = v.iter().join("\n");
    println!("{}", ans);
}


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

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

    int min = A[0];
    int max = A[0];
    for (int i = 0; i < N; i++) {
      if (A[i] < min) {
        min = A[i];
      }
      if (max < A[i]) {
        max = A[i];
      }
    }
    int ret = max - min;

    cout << ret << endl;
}


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

using namespace std;

int main() {
    int n, k;
    string s;
    cin >> n >> s >> k;
    char c = s[k-1];

    for (int i = 0; i < n; i++) {
        if (s[i] != c) {
            s[i] = '*';
        }
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }

long long n;

int main() {
    cin >> n;
    vector<long long> a(n, 0);
    vector<long long> b(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> a.at(i);
    }
    for(int i = 0; i < n; ++i) {
        cin >> b.at(i);
    }

    long long sum = 0;
    for(int i = 0; i < n; ++i) {
        if(a.at(i) > b.at(i)) {
            sum += 2*(a.at(i)-b.at(i));
            b.at(i) = a.at(i);
        }
    }

    for(int i = 0; i < n; ++i) {
        if(a.at(i) < b.at(i)) {
            long long ccc = (b.at(i)-a.at(i))/2;
            sum -= ccc*2;
        }
    }

    if(sum <= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
long move(int cur,vector<set<int> >hen,vector<bool>went,int n,int m){
  int chk = 1;
  int i;
  went[cur]=true;
  for(i=1;i<=n;i++){
    if(!went[i])chk = 0;
  }
  long ans = 0;
  if(chk==1)return 1;
  else{
    for(auto i : hen[cur]){
      if(!went[i])ans+=move(i,hen,went,n,m);
    }
    return ans;
  }
}


int main(){
  int n,m;
  cin >> n >> m;
  int i;
  int a,b;
  vector<set<int> >hen(n+1);
  for(i=0;i<m;i++){
    cin >> a >> b;
    hen[a].insert(b);
    hen[b].insert(a);
  }
  vector<bool>went(n+1);
  cout << move(1,hen,went,n,m);

}


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

xy = [[-1 for i in range(n)] for j in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        x -= 1
        xy[i][x] = y

bit = '0' + str(n) + 'b'

cnt = 0
for i in range(2 ** n):
    people = [int(peo) for peo in list(format(i, bit))]
    flg = False
    
    for j in range(n):
        if people[j] == 0:
            continue
        for k in range(n):
            if xy[j][k] == -1:
                continue
            if xy[j][k] != people[k]:
                flg = True
                break
        
        if flg:
            break
        
    if flg:
        continue
    else:
        cnt = max(cnt, sum(people))
    
print(cnt)

Measured memory_bytes: 3064
N = int(input())
t = 0
a = 0

for _ in range(N):
  rt,ra = map(int,input().split())
  c = max((t-1)//rt+1,(a-1)//ra+1)
  t = rt*c
  a = ra*c
  if a+t == 0:
    t += rt
    a += ra

print(a+t)

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

#define debug(x) cerr << #x << ": " << x << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (int& p : a)
    cin >>  p;
  int s = accumulate(a.begin(), a.end(), 0);
  if (n - s >= 0)
    cout << n - s << '\n';
  else 
    cout << "-1\n";
  return 0;
}

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

ll N, AX[105], AY[105], BX[105], BY[105];
ll p[205];
bitset<205> t;
vector<ll> G[205];

bool aug(ll v) {
	if (t[v]) return false;
	t[v] = true;
	for (ll i = 0; i < G[v].size(); i++) {
		ll nv = G[v][i];
		if (p[nv] != -1) continue;
		p[nv] = v;
		return true;
	}
	for (ll i = 0; i < G[v].size(); i++) {
		ll nv = G[v][i];
		if (!aug(p[nv])) continue;
		p[nv] = v;
		return true;
	}
	return false;
}



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

	cin >> N;
	for (ll i = 0; i < N; i++) {
		cin >> AX[i] >> AY[i];
	}
	for (ll i = 0; i < N; i++) {
		cin >> BX[i] >> BY[i];
	}

	for (ll i = 0; i < N; i++) {
		for (ll j = 0; j < N; j++) {
			if (AX[i] < BX[j] && AY[i] < BY[j]) {
				G[i].push_back(N+j);
			}
		}
	}

	ll cnt = 0;
	memset(p, -1, sizeof(p));
	for (ll i = 0; i < N; i++) {
		t.reset();
		if (aug(i)) cnt++;
	}

	cout << cnt << "\n";
	
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int ans = 0;
    for (int i = A; i <= B; i++) {
      if (isPalindromic(i)) {
        ans++;
      }
    }
    System.out.println(ans);
  }
  private static boolean isPalindromic(int n) {
    String s = String.valueOf(n);
    for (int i = 0; i < s.length()/2; i++) {
      if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
        return false;
      }
    }
    return true;
  }
}

Measured memory_bytes: 28500
#include <stdio.h>
int main (void)
{
int a,b,i,j;
while(1)
{
scanf("%d %d",&i,&j);
	if(i == 0 && j == 0){
	break;
	}
for ( a = 1; a <= i; a++ ){
    for ( b = 1; b <= j; b++ ){
        if(b == 1 || b == j || a == 1 || a == i){
            printf("#");
        } 
        else {
            printf(".");
        }
    }
    printf("\n");
}
printf("\n");
}
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll a, b; cin >> a >> b;
  ll ans[13] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  if(ans[a] == ans[b]) fin("Yes")
  else fin("No")
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


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


using namespace std;
typedef struct 
{
    int finish;
    int must;
}work;
work A[300000];
bool paixu(const work& a, const work& b)
{
        return a.must < b.must;
};
int main()
{
    int n;
    cin>>n;

    for(int i=0;i<n;i++)
    {
        cin>>A[i].finish>>A[i].must;
    }
    sort(A,A+n,paixu);
    int last;
    last = A[n-1].must - A[n-1].finish;
    for(int i=n-2;i>=0;i--)
    {
        if(last < A[i].must)
            A[i].must = last;
        else
            last = A[i].must;
        last = last - A[i].finish;
    }
    if(last >= 0)
        cout<<"Yes";
    else
    {
            cout<<"No";
    }
    
    return 0;
}

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

long long int MOD = static_cast<long long int>(1e9) + 7;

bool A[1001];
int n;
vector<int> prime_array;

void MakePrimeArray(){

    A[0] = A[1] = false;
    for(int i=2;i<1001;i++){
        A[i] = true;
    }

    for(int i=2;i<1001;i++){
        if(A[i]){
            prime_array.push_back(i);
            for(int j=i*i;j<1001;j+=i){
                A[j] = false;
            }
        }
    }

}

inline long long int Counting(int x,int divide){

    if(x%divide != 0 || x==0){
        return 0;
    }

    return Counting(x/divide,divide) + 1LL;

}

int main(){


    cin >> n;

    MakePrimeArray();


    long long int ans = 1;


    for(int i=0; i<prime_array.size(); i++){
        long long int e = 0;
        for(int j=1; j<=n; j++){
            e += Counting(j,prime_array[i]);
        }
        ans *= (e+1);
        ans %= MOD;
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1e18+10
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
int32_t main() {
	string a;
	cin>>a;
	int n=a.size(),i=0;
	int ans=0;
	while(i<n)
	{
		int c=0;
		while(i<n && (a[i]=='A' ||a[i]=='G' ||a[i]=='C' ||a[i]=='T'))
			i++,c++;
		i++;
		ans=max(ans,c);
	}	
	
	cout<<ans;
	
}


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

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

typedef long long ll;

const int INF=1e9+7;
int G[9][9];
int tmp[8];
int main(){
	int n,m;
	cin>>n>>m;
	rep(i,m){
		int a,b;
		cin>>a>>b;
		G[a][b]=G[b][a]=1;
	}
	rep(i,8)tmp[i]=i+1;
	int ans=0;
	do{
		bool f=true;
		rep(i,n-1)f&=G[tmp[i]][tmp[i+1]];
		if(f)ans++;
	}while(next_permutation(tmp+1,tmp+n));
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
int Candies(vector< int > &candy,int n,int k)
{
    vector< vector< int > > DP(n+1,vector< int > (k+1,0));
    DP[0][0] = 1;
    for(int i=1;i<=n;i++){
        ll sum =0;
        for(int j=0;j<=k;j++){
            sum +=DP[i-1][j];
            //sum %= MOD;
            if(j>candy[i]){
                sum -= DP[i-1][j-candy[i]-1];
                //sum %= MOD;
            }
            DP[i][j] = sum%MOD;
        }
    }
    return DP[n][k];
}
int main()
{
    //freopen("in.txt","r",stdin);
    int n,k;
    cin >> n >> k;

    vector< int > candy(n+1);
    for(int i=1;i<=n;i++){
        cin >> candy[i];
    }
    int ans = Candies(candy,n,k);
    cout << ans << endl;
}


Measured memory_bytes: 40192
#include<iostream>
using namespace std;
int main(){
  
  int b,r,g,c,s,t,lose,coin;
  
  while(1){
    
    cin >>b>>r>>g>>c>>s>>t;
    
    if( b==0 && r==0 && g==0 && c==0 && s==0 && t==0 )break;
    
    lose=t-(s+c+g+4*r+6*b);
    
    coin=100+(77*b+51*r+4*g)-c-(3*lose);
    
    cout <<coin<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
mod utils {
    use std::error::Error;
    use std::io::stdin;
    use std::str::FromStr;

    #[allow(dead_code)]
    pub fn read_line<T>() -> Result<Vec<T>, Box<Error>>
    where
        T: FromStr,
        T::Err: 'static + Error,
    {
        let mut line = String::new();
        let _ = stdin().read_line(&mut line)?;
        let parsed_line = line.split_whitespace()
            .map(|x| x.parse::<T>())
            .collect::<Result<Vec<T>, T::Err>>()?;

        Ok(parsed_line)
    }

    #[allow(dead_code)]
    pub fn read_lines<T>(n: usize) -> Result<Vec<Vec<T>>, Box<Error>>
    where
        T: FromStr,
        T::Err: 'static + Error,
    {
        (0..n).map(|_| read_line()).collect()
    }
}

fn power_modulo(m: u64, n: u64, c: u64) -> u64 {
    if n == 0 {
        return 1;
    }

    power_modulo((m * m) % c, n / 2, c) % c * if n % 2 == 1 { m % c } else { 1 } % c
}

fn solve() -> Result<(), Box<std::error::Error>> {
    let header = utils::read_line::<u64>()?;
    let m = header[0];
    let n = header[1];

    println!("{}", power_modulo(m, n, 1_000_000_007));

    Ok(())
}

fn main() {
    match solve() {
        Err(err) => panic!("{}", err),
        _ => (),
    };
}



Measured memory_bytes: 5036
#include<bits/stdc++.h>
using namespace std;
#define int long long
int ans=0;
char inc(char c){
  if(c=='Z'){
    ans++;
    return 'A';
  }
  return ++c;
}
signed main(){
  char c='A';
  string s;
  cin>>s;
  for(int i=0;i<(int)s.size();i++){
    c=inc(c);
    while(c!=s[i]) c=inc(c);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

ll n, k;
ll a[200005];

ll f(ll p)
{
    ll re = 0;
    for(ll i = 0; i < n; i++)
    {
        ll lt = i + 1, rt = n - 1, mid, ans;
        if(a[i] == 0)
        {
            if(p >= 0) re += n - i - 1;
        }
        else if(a[i] > 0)
        {
            ans = i;
            while(lt <= rt)
            {
                mid = (lt + rt) / 2;
                if(a[i] * a[mid] <= p) ans = mid, lt = mid + 1;
                else rt = mid - 1;
            }
            re += ans - i;
        }
        else
        {
            ans = n;
            while(lt <= rt)
            {
                mid = (lt + rt) / 2;
                if(a[i] * a[mid] <= p) ans = mid, rt = mid - 1;
                else lt = mid + 1;
            }
            re += n - ans;
        }
    }
    return re;
}

int main()
{
    scanf("%lld%lld", &n, &k);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
    }
    sort(a, a + n);
    ll lt = -1e18, rt = 1e18, mid, ans = 1e18;
    f(6);
    while(lt <= rt)
    {
        mid = (lt + rt) / 2;
        if(f(mid) >= k) ans = mid, rt = mid - 1;
        else lt = mid + 1;
    }
    printf("%lld\n", ans);
    return 0;
}


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

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

using namespace std;

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

	int w=0,e=0;
	rep(i,n) if(s[i]=='E') e++;

	int ans=n;
	rep(i,n){
		if(s[i]=='E') e--;
		ans=min(ans,w+e);
		if(s[i]=='W') w++;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
int n,maxn,minn;
int a[200000+5];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i] );
    maxn=-0x3f3f3f3f;
    minn=a[1];
    for(int i=2;i<=n;i++)
    {
        if(a[i]-minn>maxn)
            maxn=a[i]-minn;
        if(a[i]<minn)
            minn=a[i];
    }
    printf("%d\n",maxn);
    return 0;
}



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

int main(){
    string s;
    cin >> s;
    int price = 700;
    if(s[0] == 'o')price += 100;
    if(s[1] == 'o')price += 100;
    if(s[2] == 'o')price += 100;
    cout << price << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];

  int64_t sum_A = 0, sum_B = 0;
  rep(i, N) sum_A += A[i];
  rep(i, N) sum_B += B[i];

  if(sum_A < sum_B){
    cout << -1 << endl;
    return 0;
  }

  vector<int> C;
  int64_t low = 0;
  int ans = 0;
  rep(i, N){
    if(A[i] < B[i]){
      low += B[i] - A[i];
      ans++;
    }
    else if(B[i] < A[i]){
      C.push_back(A[i] - B[i]);
    }
  }

  sort(C.begin(), C.end(), greater<int>());

  int i = 0;
  while(0 < low){
    low -= C[i++];
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = (a), i##ed = (b); i <= i##ed; i++)
#define per(i, a, b) for(int i = (a), i##ed = (b); i >= i##ed; i--)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int n, k, len[2010], Now = 0;
char s[2010][10010], ans[10010];
bitset<10010> is[2010];
pii vis[2][10010]; int cnt = 0;

template<typename T> void gi(T &x) {
	x = 0; register char c = getchar(), pre = 0;
	for(; c < '0' || c > '9'; pre = c, c = getchar());
	for(; c >= '0' && c <= '9'; c = getchar()) x = x * 10ll + (c ^ 48);
	if(pre == '-') x = -x;
}
int main() {
	gi(n), gi(k);
	rep(i, 1, n) scanf("%s", s[i] + 1), len[i] = strlen(s[i] + 1);
	is[n + 1][0] = 1;
	per(i, n, 1) is[i] = is[i + 1] | (is[i + 1] << len[i]);
	rep(i, 1, n) if(is[i + 1][k - len[i]]) vis[0][++cnt] = mp(i, 1);
	rep(i, 0, k - 1) {
		char c = 'z';
		rep(j, 1, cnt) c = min(c, s[vis[Now][j].fst][vis[Now][j].snd]);
		ans[i] = c; int tmp = 0, id = n + 1;
		rep(j, 1, cnt) {
			int u = vis[Now][j].fst, pos = vis[Now][j].snd;
			if(s[u][pos] != c) continue;
			if(len[u] == pos) id = min(id, u);
			else vis[Now ^ 1][++tmp] = mp(u, pos + 1);
		}
		rep(j, id + 1, n)
			if(k - len[j] - i - 1 >= 0 && is[j + 1][k - len[j] - i - 1])
				vis[Now ^ 1][++tmp] = mp(j, 1);
		Now ^= 1, cnt = tmp;
	}
	rep(i, 0, k - 1) printf("%c", ans[i]);
	return 0;
}

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

import io
import sys
import math

def solve(n, p_lst):
    # implement process
    xmin = p_lst[0]
    cnt = 0
    for x in p_lst:
        if x <= xmin:
            cnt+=1
            xmin = x
    return cnt

def main():
    # input
    n = int(input())
    p_lst = list(map(int, input().split()))
    
    # process
    ans = str( solve(n, p_lst ) )
    
    # output
    print(ans)
    return ans
        
### DEBUG I/O ###
_DEB = 0   # 1:ON / 0:OFF

_INPUT = """\
1
1
"""
_EXPECTED = """\
3
"""

def logd(str):
    """usage:
    if _DEB: logd(f"{str}")
    """
    if _DEB: print(f"[deb] {str}")

### MAIN ###
if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

Measured memory_bytes: 32852
x = gets.to_i

def check_prime(num)
  case num
  when 1 then
    false
  when 2 then
    true
  else
    (2..(num-1)).each do |index|
      if num % index == 0
        return false
      end
    end
    return true
  end
end

loop do
  if check_prime(x)
    puts x
    exit
  else
    x += 1
  end
end



Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;

int main(){
    ll a, b, c, ans = -1;
    cin >> a >> b >> c;
    if(a*b*c % 2 == 0)ans = 0;
    else ans = min(a*b, min(b*c, c*a));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	n, m, x, y := Bi(os.Stdin)
	Bo(os.Stdout, Bx(n, m, x, y))
}

// Bi は入力を変換する奴
func Bi(stdin io.Reader) (int, int, []int, []int) {
	sc := bufio.NewScanner(stdin)

	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}

	sc.Scan()
	m, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}

	x := make([]int, m)
	y := make([]int, m)

	for i := 0; i < m; i++ {
		sc.Scan()
		x[i], e = strconv.Atoi(sc.Text())
		if e != nil {
			panic(e)
		}

		sc.Scan()
		y[i], e = strconv.Atoi(sc.Text())
		if e != nil {
			panic(e)
		}
	}

	return n, m, x, y

}

// Bx は実行する奴
func Bx(n, m int, x, y []int) int {
	redable := map[int]bool{1: true}
	num := map[int]int{1: 1}

	for i := 0; i < m; i++ {
		if v, ok := redable[x[i]]; ok && v {
			// キーに存在して
			// かつ赤いボールが入っている可能性があるとき

			// 元の箱にボールが1個しかなければ
			// 取り出すと0個になるので
			// 赤の可能性は0に変わる
			if num[x[i]] == 1 {
				redable[x[i]] = false
			}

			// 元の箱のボールの数は減る
			num[x[i]]--

			// 入れる先は赤が入っている可能性が生じ
			redable[y[i]] = true

			// ボールの数は増える
			// numに存在しなければ初期値を設定
			if _, ok := num[y[i]]; !ok {
				num[y[i]] = 1
			}
			num[y[i]]++
		} else {
			// 赤の可能性がないとき
			// （キーが存在しなければ赤の可能性はない）

			// とりあえずキーを存在させる(冗長の可能性がある）
			redable[x[i]] = false

			// 取り出す
			if _, ok := num[x[i]]; !ok {
				num[x[i]] = 1
			}
			num[x[i]]--

			// 入れる
			if _, ok := num[y[i]]; !ok {
				num[y[i]] = 1
			}
			num[y[i]]++
		}

	}

	sum := 0
	for _, v := range redable {
		if v {
			sum++
		}
	}

	return sum
}

// Bo は出力するやつ
func Bo(stdout io.Writer, x int) {
	fmt.Fprintf(stdout, "%d\n", x)
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int m = 1000010;
    V<int> a(m);
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        a[t]++;
    }
    int res = 0;
    for (int i = 1; i < m; i++) {
        if (a[i] == 1) res++;
        if (a[i] == 0) continue;
        for (int j = i; j < m; j += i) {
            a[j] = 0;
        }
    }
    cout << res << newl;
}

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

int main(){
  int H, W;
  cin >> H >> W;
  vector<int> dirx = {0, 1, 0, -1};
  vector<int> diry = {1, 0, -1, 0};
  vector<vector<char>> map(H, vector<char>(W));
  for (int i=0; i<H; i++)
    for (int j=0; j<W; j++)
      cin >> map[i][j];

  int routeNum = 0;
  for (int i=0; i<H; i++)
    for (int j=0; j<W; j++)
      if (map[i][j] == '.')
        routeNum++;



  queue<pair<int, int>> q; 
  pair<int, int> point;
  q.push(make_pair(0, 0));
  map[0][0] = 0;

  int x, y;

  while(!q.empty()){
    point = q.front(); q.pop();
    for (int i = 0; i<4; i++) {
      x = point.first + dirx[i];
      y = point.second + diry[i];
      if (point.first + dirx[i] < 0 || point.first + dirx[i] >= H) continue;
      if (point.second + diry[i] < 0 || point.second + diry[i] >= W) continue;
      if (map[x][y] == '.') {
        q.push(make_pair(x, y));
        map[x][y] = map[point.first][point.second] + 1;
      }
    }
  }
  if (map[H-1][W-1] == '.') cout << -1 << endl;
  else cout << routeNum - map[H-1][W-1] - 1 << endl;
}


Measured memory_bytes: 888
#include <stdio.h>

int main(void) {

	int N, M;
	scanf("%d%d", &N, &M);
	int K[30];
	int A[30][30];
	int count[31] = { 0 };
	int a = 0;
	int b = 0;
	int count2 = 0;
	for (int i = 0;i < N;i++) {
		scanf("%d", &K[i]);

		for (int j = 0;j < K[i];j++) {
			scanf("%d", &A[i][j]);
			a = A[i][j];
			count[a] += a;
		}
	}

	for (int i = 1;i <= 30;i++) {
		
		b = count[i] / i;
		if (b == N) {
			count2 += 1;
		}
		

	}
	printf("%d", count2);
	
	return 0;
}

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

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

int main(){
    string a, b, c;

    cin >> a;
    cin >> b;
    cin >> c;



    cout << a[0] << b[1] << c[2]<< endl;

}

Measured memory_bytes: 256
cnt = {1: 0, 2: 0, 3: 0, 4: 0}
for _ in range(3):
    a, b = map(int, input().split())
    cnt[a] += 1
    cnt[b] += 1

ans = 'YES'
for k, v in cnt.items():
    if v > 2:
        ans = 'NO'
        break

print(ans)


Measured memory_bytes: 9172
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    string s;cin>>s;
    ll x,y;cin>>x>>y;
    ll n=SIZE(s);
    vector<vector<bool>> dp_x(8000, vector<bool> (16010, false)), dp_y(8000, vector<bool> (16010, false));
    vector<ll> v_x,v_y;
    ll d=0, cnt=0;
    REP(i,n){
        if(s[i]=='F'){
            cnt++;
            if(i==n-1){
                if(d%2==0){
                    v_x.push_back(cnt);
                }else{
                    v_y.push_back(cnt);
                }
            }
        }else if(d%2==0){
            v_x.push_back(cnt);
            d++;
            cnt=0;
        }else{
            v_y.push_back(cnt);
            d++;
            cnt=0;
        }
    }
    REP(i,SIZE(v_x)){
        ll move_x=v_x[i];
        if(i==0){
            dp_x[0][move_x+8000]=true;
        }else{
            REP(j,16010){
                if(dp_x[i-1][j]==true){
                    dp_x[i][j+move_x]=true;
                    dp_x[i][j-move_x]=true;
                }
            }
        }
    }
    REP(i,SIZE(v_y)){
        ll move_y=v_y[i];
        if(i==0){
            dp_y[0][move_y+8000]=true;
            dp_y[0][-move_y+8000]=true;
        }else{
            REP(j,16010){
                if(dp_y[i-1][j]==true){
                    dp_y[i][j+move_y]=true;
                    dp_y[i][j-move_y]=true;
                }
            }
        }
    }
    bool is=false;
    if(SIZE(v_x)!=0 && SIZE(v_y)==0){
        if(dp_x[SIZE(v_x)-1][x+8000]==true){
            is=true;
        }
    }else if(SIZE(v_x)==0 && SIZE(v_y)!=0){
        if(dp_y[SIZE(v_y)-1][y+8000]==true){
            is=true;
        }
    }else{
        if(dp_x[SIZE(v_x)-1][x+8000]==true && dp_y[SIZE(v_y)-1][y+8000]==true){
            is=true;
        }
    }
    
    if(is){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 35564
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

int main() {
	ll N; cin >> N;
	vector<ll> A(N), B(N); rep(i, N)cin >> A[i] >> B[i];

	vector<pair<ll, ll>> ba(N); 
	rep(i, N) {
		ba[i].first = B[i];
		ba[i].second = A[i];
	}

	sort(ALL(ba));

	ll sum = 0;
	rep(i, N) {
		sum += ba[i].second;
		if (sum > ba[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define FINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) ((a) <= (i) && (i) <= (b))
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a < b) { a = b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(begin(a), end(a)); }
template <typename T> inline void REV(T& a) { reverse(begin(a), end(a)); }
template <typename T> inline void UNI(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <typename S, typename T> inline T LB(S& v, T a) { return *lower_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int LBP(S& v, T a) { return lower_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> inline T UB(S& v, T a) { return *upper_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int UBP(S& v, T a) { return upper_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> ostream& operator << (ostream& os, const pair<S, T>& p) { os << p.first << " " << p.second; return os; }
template <typename S, typename T> istream& operator >> (istream& is, pair<S, T>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator >> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> 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, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;



void _main() {
    int A, B;
    cin >> A >> B;
    int wa[3] = {};
    wa[A - 1] = wa[B - 1] = 1;
    REP (i, 3) if (wa[i] == 0) {
        cout << i + 1 << endl;
    }
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
def cin
  gets.split.map(&:to_i)
end

N, M = cin

ac = pena = 0
misses = Array.new(N + 1, 0)

M.times do
  p, s = gets.split
  p = p.to_i

  next if misses[p] == -1

  if s == 'WA'
    misses[p] += 1
  elsif s == 'AC'
    ac += 1
    pena += misses[p]
    misses[p] = -1
  end
end

puts "#{ac} #{pena}"


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

using namespace std;

typedef long long int ll;

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

  int n;
  cin >> n;
  vector < pair < int, int > > p, q;
  for(int i = 0; i < n; i++){
    int a, b;
    cin >> a >> b;
    p.push_back({a, b});
    q.push_back({b, a});
  }

  sort(p.begin(), p.end());
  sort(q.begin(), q.end());

  if(n % 2 != 0){
    cout << q[(n - 1) / 2].first - p[(n - 1) / 2].first + 1 << '\n';
  }else{
    int a = p[(n - 1) / 2].first + p[(n + 1) / 2].first;
    int b = q[(n - 1) / 2].first + q[(n + 1) / 2].first;
    cout << b - a + 1 << '\n';
  }
}


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

int a[25];

bool second_smallest(int a,int b,int c) {
  int d[3]={a,b,c};
  sort(d,d+3);
  return b==d[1];
}

int main() {
  int n; cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int ans = 0;
  for (int i = 2; i < n; i++) {
    if (second_smallest(a[i-1],a[i],a[i+1])) {
      // cout << ans << endl;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
using namespace std;
int main(){
  int a,b,t;
  cin >> a >> b >> t;
  cout << t / a * b << '\n';
  return 0;
}

Measured memory_bytes: 256
import math
A,B,H,M = map(float,input().split())


hrad = H*2*math.pi/12 + M/60*2*math.pi/12
mrad = M*2*math.pi/60

kakudo = min(2*math.pi - abs(hrad-mrad),abs(hrad - mrad))
#kakudo = abs(hrad - mrad)

res = A**2 + B**2 - (2*A*B*math.cos(kakudo))


print(math.sqrt(res))


Measured memory_bytes: 9400
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

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

N = INT()

print("ABC"+str(N))


Measured memory_bytes: 5272
#include<iostream>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int d=a-b;
	if(d>=c){
		cout<<"0";
	}
	else{
		cout<<c-d<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
string a;
long long s, c[30];
int main() {
	int i;
	cin>>a;
	for(i=0; a[i]; i++) c[a[i]-97]++;
	s = a.size();
	s = s * (s-1) / 2;
	for(i=0; i<26; i++) s -= c[i] * (c[i]-1) / 2;
	cout<<s+1;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define N 40010
#define int long long
#define INF 0x3f3f3f3f
#define mod 1000000007
#define rep(i, l, r) for(register int i = l; i <= r; ++ i)
using namespace std;
inline int read()
{
	register char cc = getchar();register int cn(0), flus(1);
	while(cc > '9' || cc < '0') {if(cc == '-') flus = -flus; cc = getchar();}
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - '0'; cc = getchar();}
	return cn * flus; 
}
//int a[N];
signed main()
{
	int n = read(), ans(0);
	int tmp;
	int min = 1e9;
	rep(i, 1, n)
	{
		tmp = read();
		if(tmp <= min)
		{
			ans ++;
			min = tmp;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#define rg register
#define ll long long

using namespace std;
ll n,p,k,ans=1LL;
int cnt;

inline ll quick_pow(ll a,ll b)
{
	ll sum=1LL;
	while(b)
	{
		if(b&1) sum*=a;
		a*=a;
		b>>=1;
	}
	return sum;
}
int main()
{
	scanf("%lld%lld",&n,&p);
	if(n==1LL || p==1LL)
	{
		cout<<p<<endl;
		return 0;
	}
	k=(ll)(sqrt(p));
	for(ll i=2;i<=k;i++)
	{
		if(p%i==0LL)
		{
			cnt=1;
			p/=i;
			while(p%i==0LL)
			{
				p/=i;
				cnt++;
			}
//			cout<<cnt<<endl;
			if((ll)cnt>=n) ans*=quick_pow(i,(ll)cnt/n);
		}
	}
	cout<<ans<<endl;
	
	return 0;
}


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

using namespace std;
int main(){
    string a,b,c;
    int ca=0,cb=0,cc=0,flag=0,ans=0;
    cin>>a>>b>>c;

    for(int i=0;i<a.size()+b.size()+c.size();i++){
        if(flag==0){
             if(ca==a.size()){
                ans=1;
                break;
            }

            if(a[ca]=='a')flag=0;
            if(a[ca]=='b')flag=1;
            if(a[ca]=='c')flag=2;

            ca++;
        }

        else if(flag==1){
             if(cb==b.size()){
                ans=2;
                break;
            }
            
            if(b[cb]=='a')flag=0;
            if(b[cb]=='b')flag=1;
            if(b[cb]=='c')flag=2;

            cb++;
        }

        else if(flag==2){
            if(cc==c.size()){
                ans=3;
                break;
            }    

            if(c[cc]=='a')flag=0;
            if(c[cc]=='b')flag=1;
            if(c[cc]=='c')flag=2;
        
            cc++;
        }
    }

    if(ans==1)cout<<"A"<<endl;
    if(ans==2)cout<<"B"<<endl;
    if(ans==3)cout<<"C"<<endl;

    return 0;
}

Measured memory_bytes: 3644