akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b; cin >> a >> b;
    int sum = 0;
    if (a > b) {
        sum += a;
        a--;
    } else {
        sum += b;
        b--;
    }
    if (a > b) {
        sum += a;
        a--;
    } else {
        sum += b;
        b--;
    }
    cout << sum << endl;
}


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

int main() {
  long long a,b,c,d;
  cin>>a>>b>>c>>d;
  
  long long ac,ad,bc,bd;
  ac=a*c;
  ad=a*d;
  bc=b*c;
  bd=b*d;
  
  long long ans;
  
  ans=max(ac,max(ad,max(bc,bd)));
  
  cout<<ans<<endl;
}








Measured memory_bytes: 3632
def main():
    """
    2 <= N <= 3 * 10^5
    |S| = N
    Si = {E, W}
    """
    N = int(input())
    S = input()

    f(N, S)


def f(N, S):
    """
    leaderにする人の東西について
    どちらを向いているか分かればよい
    """
    ans = N
    # 自分を含めて、自分より西にいる人が西を向いている人数
    w_cumsum = [0] * N
    w_cumsum[0] = int(S[0] == "W")
    for i in range(1, N):
        w = int(S[i] == "W")
        w_cumsum[i] = w_cumsum[i-1] + w

    # print(w_cumsum)
    for i in range(N):
        # 対象の外向き
        # 対象より(西and西を向いている人数)+(東and東を向いている人数)
        diff = w_cumsum[i] - int(S[i] == "W")
        diff += (N - (i+1)) - (w_cumsum[-1] - w_cumsum[i])
        ans = min(ans, diff)
        #same = N - 1 - diff
        #print(i, diff, same, ans)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15260
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> card(N);
    int i,j;
    for(i=0;i<N;i++){
        cin >> card.at(i);
    }
    for(i=0;i<N;i++){
        for(j=0;j<N-i-1;j++){
            if(card.at(j)<card.at(j+1)){
                int swap = card.at(j);
                card.at(j) = card.at(j+1);
                card.at(j+1) = swap;
            }
        }
    }
    int alice = 0,bob = 0;
    for(i=0;i<N;i=i+2){
        alice += card.at(i);
    }
    for(i=1;i<N;i=i+2){
        bob += card.at(i);
    }
    cout << alice - bob << endl;
    return 0;
}

Measured memory_bytes: 3620
def main():
    N = int(input())
    A = list(map(int, input().split()))
    c = 0
    for a in A:
        if 0 > a:
            c += 1
    ans = 0
    absA = [abs(a) for a in A]
    if c % 2 == 0:
        ans = sum(absA)
    else:
        ans = sum(absA) - 2 * min(absA)
    print(ans)
    

main()


Measured memory_bytes: 14224
package main

import (
	"fmt"
)

func main() {
	count := len(readLine())
	loop(0, count, func(i int) {
		fmt.Print("x")
	})
}

func loop(start, end int, f func(i int)) {
	for i := start; i < end; i++ {
		f(i)
	}
}

func readLine() string {
	var v string
	fmt.Scanln(&v)
	return v
}

Measured memory_bytes: 512
#include<stdio.h>
#include<vector>
#include<algorithm>

#define pb push_back
typedef long long LL;
using namespace std;
vector<int> r[100005];

LL a[100005];
int c[100005],D[100005];

int f(int x)
{
    LL sum=0,t,X0=0,T;
    int k=0,N,i,nx,XX;
    c[x]=1;
    N=r[x].size();
    if(N==1)return 1;
    for(i=0;i<N;i++){
        nx=r[x][i];
        if(c[nx]){
            XX=nx;
            continue;
        }
        if(!f(nx))return 0;
    }
    for(i=0;i<N;i++){
        nx=r[x][i];
        if(nx==XX)continue;
        sum+=a[nx];
        X0=max(X0,a[nx]);
    }
    t=sum-a[x];
    if(t<0)return 0;
    a[x]-=t;
    T=min(sum-X0,sum/2);
    if(t<=T)return 1;
    return 0;
}

int main()
{
    int n,s,e,i;
    scanf("%d", &n);
    for(i=1;i<=n;i++){
        scanf("%lld", &a[i]);
    }
    for(i=1;i<n;i++){
        scanf("%d %d", &s, &e);
        r[s].pb(e);
        r[e].pb(s);
        D[s]++,D[e]++;
    }
    if(n==2){
        if(a[1]==a[2])printf("YES");
        else printf("NO");
        return 0;
    }
    for(i=1;i<=n;i++){
        if(D[i]!=1)break;
    }
    s=i;
    if(f(s)&&!a[s])printf("YES");
    else printf("NO");
    return 0;
}


Measured memory_bytes: 12544
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y) {
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for ( int i = 1; i <= m; i++ ) c[i][0] = 0;
  for ( int j = 1; j <= n; j++ ) c[0][j] = 0;

  for ( int i = 1; i <= m; i++ ) {
    for ( int j = 1; j <= n; j++ ) {
      if( X[i] == Y[j] ) {
	c[i][j] = c[i - 1][j - 1] + 1;
      } else {
	c[i][j] = max(c[i-1][j] , c[i][j-1]);
      }
      maxl = max(maxl, c[i][j]);
    }
  }

  return maxl;
}

int main() {
  string s1,s2;
  int n; cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> s1 >> s2;
    cout << lcs(s1,s2) << endl;
  } 
  return 0;
}

Measured memory_bytes: 5128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n;i++)
using namespace std;
int main(){
    int ans = 0;
    rep(i, 3) {
        int a;
        cin >> a;
        ans += a;
    }
    if(ans>=22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)

readIntsLines :: IO [[Int]]
readIntsLines = map (map (fst . fromJust . BC.readInt) . BC.words) . BC.lines <$> BC.getContents

solve :: Int -> Int -> [[Int]] -> (Int, Int)
solve s e [] = (s, e)
solve s e ([l, r]:xs) = solve s' e' xs
  where s' = if s < l then l else s
        e' = if r < e then r else e

main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  lrs <- readIntsLines
  let (l, r) = solve 1 n lrs
  print $ max 0 (r - l + 1)

Measured memory_bytes: 35324
import java.io.*;
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int MOD = (int) 1e9 + 7;
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] arr = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            arr[i] = sc.nextInt();
        }

        int[][] dp = new int[n + 1][k + 1];

        dp[0][0] = 1;

        for (int i = 1; i <= n; i++) {
            int[] prefixSum = new int[k + 1];
            prefixSum[0] = dp[i - 1][0];
            for (int j = 1; j <= k; j++) {
                prefixSum[j] = (prefixSum[j - 1] + dp[i - 1][j]) % MOD;
            }

            for (int j = 0; j <= k; j++) {
                if (j <= arr[i]) {
                    dp[i][j] = prefixSum[j];
                } else {
                    dp[i][j] = (prefixSum[j] - prefixSum[j - arr[i] - 1] + MOD) % MOD;
                }
            }
        }
        // System.out.println(Arrays.deepToString(dp));
        System.out.println(dp[n][k]);
    }
}


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

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set

    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }

    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }

    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }

    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main() {
    int N; cin >> N;
    int Q; cin >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];    
    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}


Measured memory_bytes: 21724
import java.util.Arrays;
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
      float a = sc.nextFloat();
      float b = sc.nextFloat();
      if(a%3==0||b%3==0||(a+b)%3==0){
        System.out.println("Possible");
      }else{
        System.out.println("Impossible");
      }
        
  }
}


Measured memory_bytes: 24148
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
#define rep(i,m) for(int i=0;i<(n);i++)
using namespace std;
const int MAX = 100005;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main(){
  int n; cin >> n;
  int sum = 0;
  int a[n],b[n],c[n];
  rep(i,n){
    cin >> a[i];
    a[i]--;
  }
  rep(i,n){
    cin >> b[i];
    sum += b[i];
  }
  rep(i,n-1){
    cin >> c[i];
  }
  rep(i,n-1){
    if((a[i]+1) == a[i+1]) sum += c[a[i]];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int sum = 0;
		int i;
		int[] a;
		a = new int[n];
		for(i=0;i<n;i++) a[i] = sc.nextInt();

		for(i=1;i<n;i++) {
			if(a[i]==a[i-1]) {
				a[i] = -1;
				sum++;
				i++;
			}
		}
		System.out.println(sum);

	}

}

Measured memory_bytes: 21716
A, B = map(int, input().split())
C = int()
if A > B:
    C = A*2 - 1
    print("{}".format(C))
elif A < B:
    C = B*2 - 1
    print("{}".format(C))
else :
    C = A*2
    print("{}".format(C))

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int N,W,H,x,y,S,T;
  int i,j,max,cnt,ii,jj;
  while(cin>>N,N){
    cin>>W>>H;
    vector< vector<int> > field(W+1,vector<int>(H+1));
    while(N-->0){
      cin>>x>>y;
      field[x][y]=1;
    }
    cin>>S>>T;

    max=0;
    for(i=1;i<=W-S+1;i++){
      for(j=1;j<=H-T+1;j++){
	cnt=0;
	for(ii=0;ii<S;ii++){
	  for(jj=0;jj<T;jj++){
	    if(field[i+ii][j+jj])cnt++;
	  }
	}
	if(max<cnt)max=cnt;
      }
    }
    cout<<max<<endl;
  }
}

Measured memory_bytes: 0
/*input
11 10 9

*/
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define mod 998244353
#define int long long
struct node {
	int a,b,c,d;
	node(int a , int b, int c, int d):a(a),b(b),c(c),d(d) {}
};

//v//ector<node>
signed main() {
	int a,b,n;
	cin>>a>>b>>n;
	int trial = b-1; trial = min(trial,n);
	cout<< (a*trial)/b - a*(trial/b)<<endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    ll *arr=new ll[n+1];
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    ll *dp=new ll[n+1];
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(ll i=2;i<n;i++)
    {
        ll option1=abs(arr[i]-arr[i-1])+dp[i-1];
        ll option2=abs(arr[i]-arr[i-2])+dp[i-2];
        dp[i]=min(option1,option2);
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdbool.h>
#define ll long long
ll cnt_2=0,cnt_5=0;
int main(){
  ll n,ans;
  scanf("%lld",&n);
  if(n%2!=0){
    printf("0");
    return 0;
  }
  ll a=n,b=n;
  while(a>0){
    a/=2;
    cnt_2+=a;
  }
  b/=10;
  cnt_5+=b;
  while(b>0){
    b/=5;
    cnt_5+=b;
  }
  ans=cnt_2<cnt_5?cnt_2:cnt_5;
  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ExplodingFreeze
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define f(i,a,b) for(int i=(a);i<(b);i++)
const int MOD=1e9+7;
using pii=std::pair<int,int>;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

using namespace std;

int n,a[300005];
class DXorSum4 {
public:
	void solve(std::istream& in, std::ostream& out) {
		in >> n;
		f(i,0,n)
			in >> a[i];
		int pow2[65]={0},cnt[65]={0};
		pow2[0]=1;
		f(i,1,62)
			pow2[i]=(pow2[i-1]*2)%MOD;
		f(j,0,62)
			if(a[0]&(1ll<<j))
				cnt[j]++;
		int ans=0;
		f(i,1,n)
		{
			f(j,0,62)
			{
				if(a[i]&(1ll<<j))
					ans+=((i-cnt[j])*pow2[j]);
				else
					ans+=(cnt[j]*pow2[j]);
				if(ans>=MOD)
					ans%=MOD;
			}
			f(j,0,62)
				if(a[i]&(1ll<<j))
					cnt[j]++;
		}
		out << ans << "\n";
	}
};


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	DXorSum4 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int linearSearch(int n, int key ,int A[]) {
    int i = 0;
    A[n] = key;
    while (A[i] != key){
        i++;
        if(i==n) return 0;
    }return 1;
    
}
int main(){
    int n,S[10000],q,T[10000];
    cin >>n;
    for(int i=0; i<n; i++){
        scanf("%d", &S[i]);
    }
    cin >>q;
    for(int i=0; i<q; i++){
        scanf("%d", &T[i]);
    }
    int t = 0;
    for(int j = 0; j<q; j++){
        if(linearSearch(n, T[j], S) == 1){
            t++;
        }
    }
    cout <<t <<endl;
}




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

int main(){    
  
  ll N,R,w;
  string c;
  cin >> N >> c;
  R = 0;
  w = 0;
  for(ll i = 0; i < N; i++){
    if(c[i] == 'R') R++;
  }
  for(ll i = 0; i < R; i++){
    if(c[i] == 'W') w++;
  }
  cout << w << endl;
}


Measured memory_bytes: 3684
import fractions
n = int(input())
a = list(map(int, input().split()))

left = []
left.append(a[0])
right = []
right.append(a[n-1])
for i in range(n-2):
	right.append(fractions.gcd(right[i], a[n-2-i]))

for i in range(n):
	if i == 0:
		ma = right[n-2]
	elif i == n-1:
		if ma < left[n-2]:
			ma = left[n-2]
	else:
		gc = fractions.gcd(left[i-1], right[n-2-i])
		if ma < gc:
			ma = gc
		left.append(fractions.gcd(left[i-1], a[i]))

print(ma)

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

int main(){
    string S;
    cin >> S;
    int64_t N;
    N = S.length();
    bool flag = true;
    for ( int64_t i = 0; i < N; ++i){
        if ( S[i] != S[N-i-1] ){
            flag = false;
        }
    }
    for ( int64_t i = 0; i < (N-1)/2; ++i){
        //cout << i << (N-1)/2 - i - 1 << N-1-i << (N+3)/2 + i - 1 ;
        //cout << S[i] << S[(N-1)/2 - i - 1] << S[N-1-i] << S[(N+3)/2 + i - 1] ;
        if ( S[i] != S[(N-1)/2 - i - 1] or S[N-1-i] != S[(N+3)/2 + i-1] ){
            flag = false;
        }
    }
    if ( flag ){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n,k,q = map(int,input().split())
a = [int(input()) for _ in range(q)]
p = [k-q for _ in range(n)]
WIN = []
for i in range(q):
	p[a[i]-1] += 1

for i in range(n):
	if p[i] >0:
		print("Yes")
	else:
		print("No")



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

int n,maxv=-1000000007,num=0;

struct node
{
	int l,r;
}robot[100005];

int cmp(node a,node b)
{
	return a.r<b.r;
}

int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		int x,y;
		cin>>x>>y;
		robot[i].l=x-y;
		robot[i].r=x+y; 
	}
	sort(robot+1,robot+n+1,cmp);
	
	for (int i=1;i<=n;i++)
	{
		if (robot[i].l>=maxv)
		{
			maxv=robot[i].r;
			num++;
		}	
	}
	cout<<num<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner t = new Scanner(System.in);
		String S = t.nextLine();
		int c = 0;
		int v[] = new int[4];
		for(int i = 0; i < 4; i++) {
			v[i] = S.charAt(i);
		}
		
		if(v[0] == v[1]||v[1] == v[2]||v[2] == v[3]) {
			System.out.println("Bad");
		}else {
			System.out.println("Good");
	t.close();
	}
	}

}


Measured memory_bytes: 25172
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

typedef long long ll;
typedef long double ld;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

void solve(){

	ll x,y;
	cin>>x>>y;

	cout<<x+y/2<<endl;

}


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


Measured memory_bytes: 256
use proconio::{input, fastout};
use std::collections::HashSet;
#[fastout]
fn main() {
    input!{
        n:usize,
        m:usize,
        a:[usize;m]
    }
    let mut can = a.into_iter().collect::<HashSet<usize>>();
    let mut dp = vec![0;n+1];dp[0] = 1; if !(can.contains(&1)) {dp[1] = 1;}
    let mod_num = 1_000_000_007;
    for i in 2..=n {
        if !(can.contains(&i)) {
            dp[i] = (dp[i-1] %1_000_000_007+ dp[i-2]%1_000_000_007)%1_000_000_007;
        }    
    }
    println!("{}",dp[n]);
}


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

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

using ll = long long;
using P = pair<int, int>;

const ll INF=1e9;
const ll MOD=1e9+7;

int main(int, char**)
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int t1 = h1 * 60 + m1;
    int t2 = h2 * 60 + m2;
    cout << t2 - t1 - k << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#define nmax_def 220000
#define Cmax_def 2200
#define mod 1000000007
using namespace std;
typedef long long ll;

int main() {
	ll i, j;
	ll N, K, A[nmax_def];
	vector<vector<ll>> sA;
	vector<ll> sAnum;
	vector<ll> Anext;
	cin >> N >> K;
	sA.resize(nmax_def);
	sAnum.resize(nmax_def);
	Anext.resize(N);
	for (i = 0; i < nmax_def; i++)
		sAnum[i] = 0;
	for (i = 0; i < N; i++)
	{
		cin >> A[i];
		sA[A[i]].push_back(i);
		sAnum[A[i]]++;
	}
	for (i = 0; i < nmax_def; i++)
	{
		ll sAnumtmp = sAnum[i];
		//cout << i << " " << sAnumtmp << endl;
		for (j = 0; j < sAnumtmp; j++)
		{
			ll jnext = (j + 1) % sAnumtmp;
			//if (i < 10)
				//cout << sA[i][j] << " " << j << " " << jnext << endl;
			Anext[sA[i][j]] = sA[i][jnext];
		}
	}
	j = 1;
	ll sta_tmp = 0;
	//for (i = 0; i < N; i++)
		//cout << Anext[i] << endl;
	//cout << endl;
	while (1)
	{
		ll sta_tmp_tmp = Anext[sta_tmp];
		if (sta_tmp_tmp <= sta_tmp)
			j++; // loop
		sta_tmp = sta_tmp_tmp + 1;
		//cout << sta_tmp << endl;
		if (sta_tmp == N)
			break;
	}
	//cout << j << endl;
	sta_tmp = 0;
	K %= j;
	j = 1;
	while (1)
	{
		if (j >= K)
			break;
		ll sta_tmp_tmp = Anext[sta_tmp];
		if (sta_tmp_tmp <= sta_tmp)
			j++;
		sta_tmp = sta_tmp_tmp + 1;
	}
	ll slen_tmp = N - sta_tmp;
	ll stmp[nmax_def];
	for (i = 0; i < N - sta_tmp; i++)
		stmp[i] = A[i + sta_tmp];
	bool s_use[nmax_def];
	bool A_in[nmax_def];
	for (i = 0; i < slen_tmp; i++)
	{
		s_use[i] = 1;
	}
	for (i = 0; i < nmax_def; i++)
	{
		A_in[i] = 0;
	}
	for (i = 0; i < slen_tmp; i++)
	{
		ll stmptmp = stmp[i];
		if (A_in[stmptmp] == 0)
		{
			A_in[stmptmp] = 1;
		}
		else
		{
			//cout << i << endl;
			j = i;
			s_use[j] = 0;
			while (1)
			{
				A_in[stmp[j]] = 0;
				if (s_use[j] && stmp[j] == stmptmp)
				{
					s_use[j] = 0;
					break;
				}
				s_use[j] = 0;
				j--;
			}
			A_in[stmptmp] = 0;
		}
	}

	for (i = 0; i < slen_tmp; i++)
	{
		if (s_use[i])
			cout << stmp[i] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 19840
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        long x = scan.nextLong();
        long out = (x / 11) * 2;
        x %= 11;
        if(x > 6) out += 2;
        else if(x > 0) out++;
        System.out.println(out);
    }

    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 35652
#2
import numpy as np
line = np.zeros([5,],dtype=np.int)
for i in range(0,5):
    line[i] = int(input())

line_k = line%10
#print(line_k)

last_one=0
last_one_min=10
for l in range(0,5):
    if (line_k[l]>0):
        if last_one_min>line_k[l]:
            last_one_min=line_k[l]
            last_one=l
#print(last_one)
count = 0
for j in range(0,5):
    if j==last_one:
        count+=line[j]
    else:
        if line_k[j]==0:
            count+=line[j]
        else:
            count+=10*(line[j]//10) + 10
print(count)

Measured memory_bytes: 12428
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K,S=0;cin>>N>>K;vector<int>l(N);
  for(int i=0;i<N;i++)cin>>l.at(i);
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  for(int i=0;i<K;i++)S+=l.at(i);
  cout<<S<<endl;
}

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

const int INF = 1e9;

class min_cost_flow {
	using pii = pair<int, int>;
	struct edge {
		int to, cap, cost, rev;
		edge(int to_, int cap_, int cost_, int rev_)
			: to(to_), cap(cap_), cost(cost_), rev(rev_) {}
	};
	int V;
	vector<vector<edge>> G;
	vector<int> h, dist, prevv, preve;
public:
	min_cost_flow(int _V) : V(_V), G(_V), h(_V), dist(_V), prevv(_V), preve(_V) {}
	void add(int from, int to, int cap, int cost) {
		G[from].push_back(edge(to, cap, cost, G[to].size()));
		G[to].push_back(edge(from, 0, -cost, G[from].size() - 1));
	}
	int calc(int s, int t, int f) {
		int res = 0;
		fill(h.begin(), h.end(), 0);
		while (f > 0) {
			priority_queue<pii, vector<pii>, greater<pii>> que;
			fill(dist.begin(), dist.end(), INF);
			dist[s] = 0;
			que.push(pii(0, s));
			while (!que.empty()) {
				pii p = que.top(); que.pop();
				int v = p.second;
				if (dist[v] < p.first) continue;
				for (size_t i = 0; i < G[v].size(); i++) {
					edge &e = G[v][i];
					if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
						dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
						prevv[e.to] = v;
						preve[e.to] = i;
						que.push(pii(dist[e.to], e.to));
					}
				}
			}
			if (dist[t] == INF) return -1;
			for (int v = 0; v < V; v++)
				h[v] += dist[v];
			int d = f;
			for (int v = t; v != s; v = prevv[v]) {
				d = min(d, G[prevv[v]][preve[v]].cap);
			}
			f -= d;
			res += d * h[t];
			for (int v = t; v != s; v = prevv[v]) {
				edge &e = G[prevv[v]][preve[v]];
				e.cap -= d;
				G[v][e.rev].cap += d;
			}
		}
		return res;
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N;
	while (cin >> N, N) {
		vector<int> x(N), y(N), z(N);
		int sum = 0;
		for (int i = 0; i < N; i++) {
			cin >> x[i] >> y[i] >> z[i];
			vector<int> tp = { x[i], y[i], z[i] };
			sort(tp.begin(), tp.end());
			x[i] = tp[0];
			y[i] = tp[1];
			z[i] = tp[2];
			sum += x[i] * y[i] * z[i];
		}
		min_cost_flow mcf(N * 2 + 2);
		int s = N * 2, t = N * 2 + 1;
		mcf.add(s, t, INF, 0);
		for (int i = 0; i < N; i++) {
			mcf.add(s, i, 1, 0);
		}
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (x[i] < x[j] && y[i] < y[j] && z[i] < z[j]) {
					mcf.add(i, N + j, 1, -x[i] * y[i] * z[i]);
				}
			}
		}
		for (int i = 0; i < N; i++) {
			mcf.add(N + i, t, 1, 0);
		}
		cout << sum + mcf.calc(s, t, INF) << endl;
	}
	return 0;
}



Measured memory_bytes: 3316
import copy
import queue
def bfs(count, x, y, cheese):
    q = queue.Queue()
    q.put((count,x,y))
    tempVisited = copy.deepcopy(visited)
    tempVisited[x][y] = True
    
    while q.qsize()>0:
        tempc,tempx,tempy = q.get()
        if geo[tempx][tempy] == cheese:
            return tempc,tempx,tempy
        for i in range(4):
            neox = tempx+dx[i]
            neoy = tempy+dy[i]
            if canGoTo(neox,neoy, tempVisited):
                #if (tempc+1,neox,neoy) not in q:
                q.put((tempc+1,neox,neoy))
                tempVisited[neox][neoy]=True
    return (-1,-1,-1)

def canGoTo(x,y,tempVisited):
    if 0<=x<H and 0<=y<W:
        return not tempVisited[x][y]
    return False

dx = [0,1,0,-1]
dy = [-1,0,1,0]

data = input().split(' ')
H,W,N = map(int, data)

#maps
geo = [[None for i in range(W)] for j in range(H)]
visited = [[False for i in range(W)] for j in range(H)]

x,y=-1,-1
for i in range(H):
    line = input()
    for j in range(W):
        p = line[j:j+1]
        geo[i][j] = p
        if p == 'X':
            visited[i][j] = True
        elif p == 'S':
            x,y, = i,j
            
count = 0
for n in range(1,N+1):
    count,x,y = bfs(count,x,y,str(n))
print(count)

Measured memory_bytes: 35316
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <cmath>
typedef long long ll;
using namespace std;
#define rep(i,st,ed) for (int i=st;i<=ed;++i)

const int INF=0x3f3f3f3f;
const int N=2000005;

int a[N];

int read() {
    int x=0,v=1; char ch=getchar();
    for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):v,ch=getchar());
    for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
    return x*v;
}

bool check(int l,int r) {
    int mx = 0, mn = INF;
    for (int i = l; i <= r; i++) {
        mx = max(mx, a[i]);
        mn = min(mn, a[i]);
    }
    if (mn < l || mx > r) return true;
    int r1 = 0, r2 = 0;
    for(int i=l;i<=r;i++){
        if(a[i] != i){
            if(a[i]<i){//那么他是从小的换过来的
                if(r1<a[i]) r1=a[i];
                else return true;
            }else{//那么他是从大的换过来的
                if(r2<a[i]) r2=a[i];
                else return true;
            }
        }
    }
    return false;
}

int main(void) {
    int n=read(),x;
    for(int i=1;i<=n;i++) a[i]=read();
    for(int i=1;i<=n;i++){
        if(a[i] != i){
            for(x=i;a[x+1]==x+1&&a[x+2]!=x+2;) x+= 2;
            x=min(x,n);// 得到交换的段，也就是这个是分段的，有些段是跨不过去的
            if(check(i, x)) return puts("No"), 0;
            i=x;
        }
    }
    return puts("Yes"),0;
}


Measured memory_bytes: 1280
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
def dfs(d, a, b, c):
  if d == N:
    res = abs(a - A) + abs(b - B) + abs(c - C) - 30
    return 1e9 if min(a, b, c) == 0 else res
  ret = [0] * 4
  ret[0] = dfs(d + 1, a, b, c)
  ret[1] = dfs(d + 1, a + l[d], b, c) + 10
  ret[2] = dfs(d + 1, a, b + l[d], c) + 10
  ret[3] = dfs(d + 1, a, b, c + l[d]) + 10
  return min(ret)
print(dfs(0, 0, 0, 0))


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

int n,a,b,c;
int arr[10];

int dfs(int idx,int A,int B,int C){
	if(idx==n){
		if(min(A,min(B,C))>0) return abs(a-A)+abs(b-B)+abs(c-C)-30;
		else return (1<<30);
	}
	
	int ret = dfs(idx+1,A+arr[idx],B,C) + 10;
	int ret1 = dfs(idx+1,A,B+arr[idx],C) + 10;
	int ret2 = dfs(idx+1,A,B,C+arr[idx]) + 10;
	int ret3 = dfs(idx+1,A,B,C);
	
	return min(ret,min(ret1,min(ret2,ret3)));
}

int main(){
	scanf("%d%d%d%d",&n,&a,&b,&c);
	for(int i=0;i<n;i++){
		scanf("%d",&arr[i]);
	}
	int ans=dfs(0,0,0,0);
	printf("%d",ans);
}

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

using namespace std;
const int INF = numeric_limits<int>::max() / 2;

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

  int h,w;cin>>h>>w;
  char c[h+1][w+1];
  for(int i=1;i<=h;i++)for(int j=1;j<=w;j++){
      char a;cin>>a;
      c[i][j]=a;
  }
  for(int i=1;i<=2*h;i++){
      for(int j=1;j<=w;j++){
          cout<<c[(i+1)/2][j];
      }
      cout<<endl;
  }
    return 0;
}


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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int H, W, M;
    cin >> H >> W >> M;
    map<int, int> hbomb;
    map<int, int> wbomb;
    vector<pair<int, int>> bombs(M);
    for(int i=0; i<M; i++){
        int h, w;
        cin >> h >> w;
        hbomb[h-1]++;
        wbomb[w-1]++;
        bombs[i] = make_pair(h-1, w-1);
    }
    sort(bombs.begin(), bombs.end());

    vector<int> hmax;
    vector<int> wmax;
    int valmaxh = 0, valmaxw = 0;
    for(int i=0; i<H; i++){
        if(valmaxh < hbomb[i]){
            hmax.resize(1);
            hmax[0] = i;
            valmaxh = hbomb[i];
        }
        else if(valmaxh == hbomb[i]){
            hmax.push_back(i);
        }
    }
    for(int j=0; j<W; j++){
        if(valmaxw < wbomb[j]){
            wmax.resize(1);
            wmax[0] = j;
            valmaxw = wbomb[j];
        }
        else if(valmaxw == wbomb[j]){
            wmax.push_back(j);
        }
    }
    sort(hmax.begin(), hmax.end());
    sort(wmax.begin(), wmax.end());

    int cnt = 0;
    for(int i=0; i<M; i++){
        if(binary_search(hmax.begin(), hmax.end(), bombs[i].first) && binary_search(wmax.begin(), wmax.end(), bombs[i].second)){
            cnt++;
        }
    }
    int cross = 1;
    if(cnt != hmax.size() * wmax.size()){
        cross = 0;
    }
    
    cout << valmaxh + valmaxw - cross << endl;

    return 0;
}

Measured memory_bytes: 53752
using System;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            string[] str;
            while (true)
            {
                str = Console.ReadLine().Split(' ');
                int x = int.Parse(str[0]);
                int y = int.Parse(str[1]);
                if (x == 0 && y == 0) { break; }
                for (int i = 1; i <= x; i++)
                {
                    for (int j = 1; j <= y; j++)
                    {
                        if (i == 1 || i == x || j == 1 || j == y)
                        {
                            Console.Write("#");
                        }
                        else
                        {
                            Console.Write(".");
                        }

                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}



Measured memory_bytes: 15880
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
#include<unordered_map>
#include<stack>
#include<vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    int d[110];
    for(int i = 1;i <= N;i++){
        cin >> d[i];
    }
    int ans = 0;
    for(int i = 1;i <= N;i++){
        for(int j = 1;j <= N;j++){
            if(i == j)continue;
            ans += d[i] * d[j];
        }
    }
    
    cout << ans / 2;
}


Measured memory_bytes: 256
k = int(input())
if k == 0:
    print("2\n1 1")
    exit(0)
if k == 1:
    print("2\n2 0")
    exit(0)
n = min(50,k)
a = [i for i in range(n)]
c = k // n

for i in range(n):
    a[i] += c

for i in range(k % n):
    a[i] += n
    for j in range(n):
        if i != j:
            a[j] -= 1
print(n)
for i in a:
    if i in range(10**16 + 1001):
        print(i, end=' ')
    '''else:
        exit(1)'''
print()

Measured memory_bytes: 3064
#include <iostream>
#include <set>

using namespace std;

int main() {
    int N; cin >> N;
    set<int> A;
    int ai;
    for (int i=0; i<N; i++) {
        cin >> ai;
        A.insert(ai);
    }
    
    int c = (int)(A.size());
    if (c % 2 == 0) c -= 1;
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 4864
module mod_selection_sort
  implicit none
  integer, private, parameter :: intkind = 4
contains
  logical function less(a, b) result(res)
    integer(intkind), intent(in) :: a, b
    res = a <= b
  end
  subroutine swap(a, b)
    integer(intkind), intent(inout) :: a, b
    a = xor(a, b)
    b = xor(a, b)
    a = xor(a, b)
  end
  subroutine selection_sort(a)
    integer(intkind), intent(inout) :: a(:)
    integer :: n, i, j, m
    n = size(a)
    do i = 1, n - 1
      m = i
      do j = i + 1, n
        if (.not.less(a(m), a(j))) m = j
      end do
      if (i /= m) call swap(a(i), a(m))
    end do
  end
end module mod_selection_sort
program brave_chain
  use mod_selection_sort
  implicit none
  integer, parameter :: inf = 1e9
  integer :: n, a(6000) = 0, a1, a2, a3, dp(2000, 2000) = -inf, m = 0, b(3) = 0, v, i, j
  integer, dimension(2000) :: dp0 = 0, mv = -inf, mv0 = 0
  read(*,*) n
  read(*,*) a(1:3 * n)
  call update(a(1), a(2), 0)
  do i = 3, 3 * n - 2, 3
    if (a(i) == a(i + 1) .and. a(i) == a(i + 2)) then
      m = m + 1
      cycle
    end if
    call selection_sort(a(i:i + 2))
    if (a(i + 1) == a(i + 2)) call swap(a(i), a(i + 2))
    a1 = a(i)
    a2 = a(i + 1)
    a3 = a(i + 2)
    do j = 1, n
      dp0(j) = dp(min(a1, j), max(a1, j))
    end do
    mv0(1:n) = mv(1:n)
    v = max(0, maxval(mv(1:n)))
    b(1) = dp(a1, a1)
    b(2) = dp(a2, a2)
    b(3) = dp(a3, a3)
    if (a1 == a2) then
      do j = 1, n
        call update(a3, j, dp0(j) + 1)
      end do
    end if
    call update(a2, a3, b(1) + 1)
    call update(a1, a3, b(2) + 1)
    call update(a1, a2, b(3) + 1)
    call update(a2, a3, v)
    call update(a1, a3, v)
    call update(a1, a2, v)
    do j = 1, n
      call update(a1, j, mv0(j))
      call update(a2, j, mv0(j))
      call update(a3, j, mv0(j))
    end do
  end do
  i = a(3 * n)
  write(*,'(i0)') max(dp(i, i) + 1, maxval(mv(1:n))) + m
contains
  subroutine update(a, b, z)
    integer, intent(in) :: a, b, z
    integer :: x, y
    if (a > b) then
      x = b
      y = a
    else
      x = a
      y = b
    end if
    if (dp(x, y) >= z) return
    dp(x, y) = z
    mv(x) = max(mv(x), z)
    mv(y) = max(mv(y), z)
  end
end program brave_chain

Measured memory_bytes: 18656
#include<bits/stdc++.h>
#define inf 2147483647
#define ll long long
using namespace std;
struct node{
    int u,v;
    ll cost;
}edge[500005];
ll dis[10005];
int n,m,s;
void init()
{
    for(int i=0;i<n;i++) dis[i]=(i==s?0:inf);
}
bool Bellman_Ford()
{
    init();
    bool flag=true;
    for(int i=0;i<n;i++)
    {
        flag=true;
        for(int j=0;j<m;j++)
        if(dis[edge[j].v]>dis[edge[j].u]+edge[j].cost&&dis[edge[j].u]!=inf)
        {
            dis[edge[j].v]=dis[edge[j].u]+edge[j].cost;
            flag=false;
        }
        if(flag) return true;
    }
    for(int j=0;j<m;j++)
    if(dis[edge[j].v]>dis[edge[j].u]+edge[j].cost&&dis[edge[j].u]!=inf) return false;
    return true;
}
int main()
{
    cin>>n>>m>>s;
    for(int i=0;i<m;i++) cin>>edge[i].u>>edge[i].v>>edge[i].cost;
    if(Bellman_Ford())
    for(int i=0;i<n;i++)
	if(dis[i]!=inf) cout<<dis[i]<<endl;
	else cout<<"INF"<<endl;
    else cout<<"NEGATIVE CYCLE"<<endl;
    return 0;
}


Measured memory_bytes: 3124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		int move = 0;
		if(a > b) {
			int c = a;
			a = b;
			b = c;
		}
		if(a + w >= b) {
			move = 0;
		} else {
			move = b - (a + w);
		}
		System.out.println(move);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[200010];
    rep(i,0,N) cin >> A[i];
    ll max_val = 0;
    rep(i,0,N){
        max_val = max(max_val, A[i]);
    }
    ll second_val = -1;
    rep(i,0,N){
        if(A[i] != max_val) second_val = max(second_val, A[i]);
    }
    ll cnt = 0;
    rep(i,0,N){
        if(A[i] == max_val) cnt++;
    }
    rep(i,0,N){
        if(A[i] == max_val){
            if(cnt > 1){
                print(max_val);
            }else{
                print(second_val);
            }
        }else{
            print(max_val);
        }
    }


    
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define COUT(x) cout<<x<<"\n"

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = lcm(a, v[i]);} return a;}


void Main()
{
	ll n=0; string s="";
	ll res=0; string sres="Yes";
	cin>>n;
	VPLL ab;
	REP(i, n) {
		ll a,b;
		cin >> a>>b;
		ab.emplace_back(make_pair(b,a));
	}
	SORT(ab);
	ll currt=0;
	REP(i,n){
		currt+=ab[i].second;
		if(currt>ab[i].first){ COUT("No"); return;}
	}
	COUT("Yes");
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 6384
#include <iostream>
#include <string> 
using namespace std;
int main() {
	string a[50], b[50];
	int N, M;
	bool flag = 0;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (a[i][j] == b[0][0])flag = 1;
			if (flag == 1) {
				for (int ii = 0; ii < M; ii++) {
					for (int jj = 0; jj < M; jj++) {
						if (a[i + ii][jj + j] != b[ii][jj]) { flag = 0; break; }

					}
				}
			}
			if (flag == 1)break;
		}
		if (flag == 1)break;
	}

	if (flag == 1)cout << "Yes\n";
	else cout << "No\n";
	return 0;

}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c;
    d = 0;
    for(int i = a;i <= b;i++){
        if(c % i == 0){
            d++;
        }
    }
    cout << d << endl;
return 0;
}


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

int main(){
    long long x;
    cin >> x;
    long long sam=100;
    int ans=0;
    for(int i=1;i<=3760;i++){
        sam += sam/100;
        if(sam>=x){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    ll ANS = 5;
    vector<ll> a;
    ll most = 0;
    ll tmp;
    bool flag = true;
    cin >> tmp;
    a.push_back(tmp);
    rep(i,5)
    {
        cin >> tmp;
        a.push_back(tmp);
        if(tmp>a[0])continue;
        flag = false;
        if(a[0]%tmp == 0 && most < a[0]/tmp) most = a[0]/tmp;
        else if(a[0]%tmp != 0 && most < a[0]/tmp+1) most = a[0]/tmp+1;
    }
    if(flag) cout << ANS << endl;
    else
    {
        most--;
        ANS += most;
        cout << ANS << endl;
    }

}


Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    t = 0
    for i in range(n):
        t += (1 / a[i])
    print(1 / t)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	string a, b, c;
	cin >> a >> b >> c;
	cout << (char)(a[0] - 'a' + 'A');
	cout << (char)(b[0] - 'a' + 'A');
	cout << (char)(c[0] - 'a' + 'A');
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastIO;
    int r;
    cin >> r;
    cout << 3 * r * r;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static char[][] f;
	static char[][] m = new char[2][];

	public static void main(String[] args) {
		int M = sc.nextInt();
		int N = sc.nextInt();
		f = new char[M + 2][N + 2];
		for (int i = 0; i < M; ++i) {
			String row = sc.next();
			for (int j = 0; j < N; ++j) {
				f[i + 1][j + 1] = row.charAt(j);
			}
		}
		m[0] = sc.next().toCharArray();
		m[1] = sc.next().toCharArray();
		int max = 0;
		for (int i = 1; i <= M; ++i) {
			for (int j = 1; j <= N; ++j) {
				char orig = f[i][j];
				int prev = count(i, j);
				int diff = 0;
				for (char c : new char[] { 'J', 'O', 'I' }) {
					f[i][j] = c;
					diff = Math.max(diff, count(i, j) - prev);
				}
				f[i][j] = orig;
				max = Math.max(max, diff);
			}
		}
		int all = 0;
		for (int i = 0; i < M; ++i) {
			for (int j = 0; j < N; ++j) {
				if (isJOI(i, j)) ++all;
			}
		}
		System.out.println(all + max);
	}

	static int count(int r, int c) {
		int ret = 0;
		if (isJOI(r - 1, c - 1)) ++ret;
		if (isJOI(r - 1, c)) ++ret;
		if (isJOI(r, c - 1)) ++ret;
		if (isJOI(r, c)) ++ret;
		return ret;
	}

	static boolean isJOI(int r, int c) {
		return f[r][c] == m[0][0] && f[r][c + 1] == m[0][1] && f[r + 1][c] == m[1][0] && f[r + 1][c + 1] == m[1][1];
	}
}

Measured memory_bytes: 59936
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pc = tuple<int, int, int>;
const ll INF = ll(1e18)+1;

void Main() {
  int n; ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  ll l = -INF, r = INF;
  while(l+1 < r) {
    ll x = (l+r)/2;
    bool ok = [&]{
      ll tot = 0;
      rep(i, n) {
        if (a[i] < 0) {
          int l = -1, r = n;
          while(l+1 < r) {
            int c = (l+r)/2;
            if (a[i]*a[c] < x) r = c; else l = c;
          }
          tot += n - r;
        } else {
          int l = -1, r = n;
          while(l+1 < r) {
            int c = (l+r)/2;
            if (a[i]*a[c] < x) l = c; else r = c;
          }
          tot += r;
        }
        if (a[i]*a[i] < x) tot--;
      }
      tot /= 2;
      return tot < k;
    }();
    if (ok) l = x; else r = x;
  }
  cout << l << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

using namespace std;

long long comb(int n, int k)
{
    long long res = 1;
    for(int i = 1; i <= k; i++){
        res *= (n - i + 1);
        res /= i;
    }
    return res;
}

void Solve(){
    int n;
    cin>>n;
    vector<int> v(n);
    map<int, int> mm;
    for(int i = 0; i < n; i++){
        cin>>v[i];
        ++mm[v[i]];
    }
    long long sum = 0;
    for(auto x: mm){
        if(x.second > 1){
            sum += comb(x.second, 2);
        }
    }
    for(int i = 0; i < n; i++){
        if(mm[v[i]] < 2) cout<<sum<<'\n';
        else{
            long long tmp = comb(mm[v[i]], 2);
            tmp = sum - tmp;
            tmp += comb(mm[v[i]] - 1, 2);
            cout<<tmp<<'\n';
        }
    }
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int q = 1;
    //cin>>q;
    while(q--){
    	Solve();
    }
}

Measured memory_bytes: 8320
import sys
input = sys.stdin.readline
def main():
	N,W = map(int, input().split())
	dp = [0 for _ in range(W+1)]
	for _ in range(N):
		w,v = map(int, input().split())
		for i in range(W,0,-1):
			if i>=w:
				a = dp[i]
				b = dp[i-w]+v
				if a>b:
					dp[i] = a
				else:
					dp[i] = b
		
	print(dp[-1])
 
if __name__ == '__main__':
	main()

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

int a[3];
int MIN=3*10000;

void solve(){
        for(int i=0;i<3;i++){
                for(int j=i+1;j<3;j++){
                        MIN = min(MIN, a[i]+a[j]);
                }
        }
        cout << MIN << endl;
}

int main(){
        for(int c=0;c<3;c++){
                cin >> a[c];
        }

        solve();
        return 0;
}


Measured memory_bytes: 256