akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>

const auto MOD = 1000000007;
const int INF = 1e9;
const long long LINF = 1e18;
using namespace std;

int n, m;
string s;

int main() {
	cin >> n >> m;
	if (m <= 0) {
		if (n + m - 1 < 0) {
			cout << ((2 * m + n - 2)*(n - 1)) / 2 << endl;return 0;
		}
		else {
			cout << ((2 * m + n - 1)*(n)) / 2 << endl;return 0;
		}
	}
	else {
		cout << ((2 * m + n - 1)*(n)) / 2 -m << endl;return 0;
	}
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int n; std::cin >> n;
  int t = 0, x = 0, y = 0;
  bool ok = true;
  rep(i, n) {
    int nt, nx, ny; std::cin >> nt >> nx >> ny;
    int dt = nt-t, dx = abs(nx-x), dy = abs(ny-y);
    if (dt < dx+dy) ok = false;
    if (dt > dx+dy && (dt - (dx + dy)) % 2) ok = false;
    t = nt, x = nx, y = ny;
  }
  std::cout << (ok ? "Yes" : "No") << "\n";
}


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>;

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

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

    ll ans = 10e16;
    for (int bit = 0; bit < (1 << (N - 1)); ++bit) {
        if (__builtin_popcount(bit) + 1 < K) continue;

        bool ok = true;
        ll tmp = 0;
        ll lmax = a[0];
        for (int i = 0; i < N - 1; ++i) {
            if (bit & (1 << i)) {
                ll next = max(lmax + 1, a[i + 1]);
                tmp += next - a[i + 1];
                lmax = next;
            } else {
                if (a[i + 1] > lmax) {
                    ok = false;
                    break;
                }
            }
        }
        if (ok) chmin(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3520
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        int S,h,m,s;
        //?¨??????\??????????????????????????§????????????
    	Scanner scanner = new Scanner(System.in);
    	//??\????????????int??????????????????
    	S = scanner.nextInt();
    	//??????????±??????????1??????=60*60?§????S???60*60??§?????£???????????????
    	h = S/(60*60);
    	//????§???????????±???????
    	m = (S-h*60*60)/60;
    	//????§?????§?????±???????
    	s = S-h*60*60-m*60;
        System.out.println(h+":"+m+":"+s);
    }
}

Measured memory_bytes: 26180
#include <bits/stdc++.h>
typedef long long ll;
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++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


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

    int n,m;
    cin >> n >> m;
    vector<vector<int>> d(n,vector<int>(n,-1));
    rep(i,m) {
        int a,b,din,tin;
        cin >> a >> b >> din;
        d[a][b]=din;
    }
    vector<vector<int>> dp((1<<n),vector<int>(n,1e9));
    dp[0][0]=0;
    rep(bit,(1<<n)) {
        rep(i,n) {
            if (bit & (1<<i)) {
                rep(k,n) {
                    if (dp[bit-(1<<i)][k]!=1e9 && i!=k && d[k][i]>=0) {
                        dp[bit][i]=min(dp[bit][i],dp[bit-(1<<i)][k]+d[k][i]);
                    }
                }
            }
        }
    }
    int ans=1e9;
    ans=dp[(1<<n)-1][0];
    if (ans==1e9) ans=-1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6220
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e3+5;

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n, m;
	cin >> n >> m;
	char a[n][m];
	for (int i = 0; i < n ;i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> a[i][j];
		}
	}
	int dp[n][m] = {};
	dp[0][0] = 1;
	for (int i = 0; i < n ;i++)
	{
		for (int j = 0; j < m; j++)
		{
			if (a[i][j] == '#') continue;

			if (i > 0) dp[i][j] += dp[i-1][j];

			if (j > 0) dp[i][j] += dp[i][j-1];

			dp[i][j] %= mod;
		}
	}
	cout << dp[n-1][m-1];
	return 0;
}
	/*

	states : row , col

	base case : dp[0][0] = 1

	transitions : (row-1, col) + (row, col-1)


	. . . #

	. # . .

	. . . .

	 */


Measured memory_bytes: 5120
def ff(n):
    if(n==0): return [0]
    if(n==1): return [1]
    ans=set([1,n])
    i=2
    while(i*i<=n):
        if(n%i==0):
            ans.add(n//i)
            ans.add(i)
        i+=1
    return ans

x=int(input())
fx=ff(abs(x))
A=-1000000
B=-1000000
for f in fx:
    if(A!=-1000000 and B!=1000000): break
    for i in range(-10000,10000):
        b,a=i,i+f
        z=a**5-b**5
        if(z==abs(x)):
            A=a
            B=b
            break
if(x<0): A,B=B,A
print(A,B)

Measured memory_bytes: 67868
#include <bits/stdc++.h>
#define INF 1000000000000001
#define ll long long
using namespace std;

bool comp(pair<ll, ll> a, pair<ll, ll> b)
{
  return a.first > b.first;
}

int main()
{
  ll X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<ll> red(A), green(B), nul(C);
  vector<pair<ll, ll>> all(A + B + C);// tast, color
  ll cnt = 0;
  for (ll i = 0; i < A; ++i)
  {
    ll a;
    cin >> a;
    red.at(i) = a;
    all.at(cnt) = {a, 0};
    cnt += 1;
  }
  for (ll i = 0; i < B; ++i)
  {
    ll a;
    cin >> a;
    green.at(i) = a;
    all.at(cnt) = {a, 1};
    cnt += 1;
  }
  for (ll i = 0; i < C; ++i)
  {
    ll a;
    cin >> a;
    nul.at(i) = a;
    all.at(cnt) = {a, 2};
    cnt += 1;
  }
  // sort(red.begin(), red.end(), greater<ll>());
  // sort(green.begin(), green.end(), greater<ll>());
  // sort(nul.begin(), nul.end(), greater<ll>());
  sort(all.begin(), all.end(), comp);
  // for (ll i = 0; i < A + B + C; ++i)
  // {
  //   cout << all.at(i).first << all.at(i).second << endl;
  // }
  ll ans = 0;
  vector<ll> cnts(3, 0);
  vector<ll> max_cnt = {X, Y};
  ll used = 0;
  for (ll i = 0; i < A + B + C; ++i)
  {
    pair<ll, ll> check = all.at(i);
    if (check.second == 2)
    {
      ans += all.at(i).first;
      used += 1;
      cnts.at(2) += 1;
    }
    else
    {
      if (cnts.at(check.second) < max_cnt.at(check.second))
      {
        ans += all.at(i).first;
        used += 1;
        cnts.at(check.second) += 1;
      }
    }
    if (used == X + Y)
    {
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, M;
  cin >> N >> M;
  vector<long> data(N);
  for(int i = 0; i < N; i++)cin >> data.at(i);
  vector<pair<long, long>> sub(M);
  for(int i = 0; i < M; i++){
    cin >> sub.at(i).second >> sub.at(i).first;
  }
  sort(sub.begin(), sub.end());
  reverse(sub.begin(), sub.end());
  int count = 0, pls = 0;
  while(count < N && pls < M){
    for(int i = 0; i < sub.at(pls).second; i++){
      if(i == 0)count += sub.at(pls).second;
      data.push_back(sub.at(pls).first);
    }
    pls++;
  }
  long ans = 0;
  sort(data.begin(), data.end());
  reverse(data.begin(), data.end());
  for(int i = 0; i < N; i++){
    ans += data.at(i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6256
from sys import stdin
import bisect

def main():
    input = stdin.readline
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = [0] * (n + 1)
    for i in range(n):
        c[i + 1] = c[i] + a[i]
    d = [0] * (m + 1)
    for i in range(m):
        d[i + 1] = d[i] + b[i]
    cnt = 0
    for i in range(n + 1):
        if c[i] > k:
            break
        e = bisect.bisect_right(d, k - c[i])
        if cnt < i + e - 1:
            cnt = i + e - 1
    print(cnt)
main()

Measured memory_bytes: 47596
N,M = map(int,input().split())
H = list(map(int,input().split()))
H.insert(0,0)
AB =  [list(map(int,input().split(" "))) for _ in range(M)]
links = [[] for _ in range(N+1)]

for a,b in AB:
  links[a].append(b)
  links[b].append(a)

res = [True] * (N+1)
res[0] = False

for i in range(1,N+1):
  for j in links[i]:
    if H[i] <= H[j]:
      res[i] = False

ans = res.count(True)
print(ans)


Measured memory_bytes: 41880
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    string s;
    cin >> s;
    smatch mat;
    if (regex_search(s, mat, regex("^A[a-z]+C[a-z]+$"))) {
        cout << "AC\n";
    } else {
        cout << "WA\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

int fac(int x)
{
    ll ans = 1;
    for(int i = 2; i <= x; i++){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

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

    if(abs(n-m) <= 1) cout << (ll)(n%2 == m%2 ? 2 : 1)*fac(n)*fac(m)%mod << endl;
    else cout << 0 << endl;
  
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

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

void solve(int n,char c[])
{
    int cnt[26]={0};
    P a[26];
    REP(i,n){
        cnt[c[i]-'A']++;
        REP(j,26) a[j]=P(cnt[j],j);
        sort(a,a+26);
        reverse(a,a+26);
        if(a[0].first>a[1].first+(n-i-1)){
            cout<<(char)('A'+a[0].second)
                <<" "<<i+1<<endl;
            return;
        }
    }
    cout<<"TIE"<<endl;
}

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

    int n;
    while(cin>>n,n){
        char c[100];
        REP(i,n) cin>>c[i];
        solve(n,c);
    }
}



Measured memory_bytes: 3156
def gcd(a,b):
    while b:a,b=b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)
def main():
    N = int(input())
    T = [int(input())for _ in range(N)]
    tmp = T[0]
    for i in range(1,N):
        tmp = lcm(tmp,T[i])
    print(tmp)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define all(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T>bool chmin(T &a,T b){if(b<a){a=b;return 1;} return 0;}
// run : ctrl + c 

int f(int a,int k,int pre){
    if(a%k==0) return a/k;
    if(a < k) return 0;
    int n = a % k;
    int dif = (a/k) + 1;
    n -= (n/dif)*dif;
    n += a/k*k;
    if(n==pre) n-=dif;
    return f(n,k,a);
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n;
    cin>>n;
    int ans = 0;
    rep(i,n){
        int a,k;
        cin>>a>>k;
        ans ^= f(a,k,-1);
    }
    if(ans) cout << "Takahashi" << endl;
    else cout << "Aoki" << endl;
   
}

Measured memory_bytes: 256
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

vector< pair<string, pair<int, int> > > V;

///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		string s;
		int x;
		cin >> s >> x;
		V.pb(mp(s, mp(-x, i)));
	}
	
	sort(V.begin(), V.end());
	
	for(auto it : V){
		cout << it.second.second << endl;
		
	}
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 256
import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

r, c = map(int, readline().split())
A = []
for _ in range(r):
    x = [int(i) for i in readline().split()]
    x.append(sum(x))
    A.append(x)

B = []
for i in range(c + 1):
    ans = 0
    for j in range(r):
        ans += A[j][i]
    B.append(ans)
A.append(B)

for i in A:
    print(*i)


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

int calc_dist (int x, int y, int x_1, int y_1){
	int dist = abs(x_1 - x) + abs(y_1 - y);
    return dist;
}
 
int main() {
  long int A, B;
  cin >> A >> B;
  int r = 0, tmp_l = 0, tmp_s = 0;
  if(A < B) {
    tmp_l = B;
    tmp_s = A;
  }
  else{
    tmp_l = A;
    tmp_s = B;
  }
  r = tmp_l % tmp_s;
  while(r > 0){
    tmp_l = tmp_s;
    tmp_s = r;
    r = tmp_l % tmp_s;
  }
  //cout << A << ", " << B << ", " << tmp_s << ", " << endl;
  cout << A * B / tmp_s << endl;
  return 0;
}

Measured memory_bytes: 256
N, X = map(int, input().split())
L = list(map(int, input().split()))

max_x = N + 1
start = [0]
for i in range(N):
  s = start[i] + L[i]
  if s <= X:
  	start.append(s)
  else:
    max_x = i+1
    break
print(max_x)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N , K;
  cin >> N;
  cin >> K;
  
  int ans = 1;
  
  for(int i=0; i<N; i++){
	if(ans+K <= ans*2){
      ans = ans+K;  	
	}
	else{
      ans = ans*2;
	}
  }
	cout << ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
char go[5] = "RDLU";

bool cangocw(int y, int x, int dir, vector<string> &s){
    if(dir%2==0){
        return s[2*y +1][x +1-(dir/2)] == '0';
    }else{
        return s[2*y +(1-dir/2)*2][x+1] == '0';
    }
}

int main(){
    vector<string> s(11);
    s[0] = s[10] = "0000000";
    for(int i=1; i<=9; i++){
        cin >> s[i];
        s[i] = "0" + s[i] + "0";
    }
    int dir=0;
    int x=0, y=0;
    string ans = "";
    
    do{
        if(cangocw(y, x, dir, s)){
            dir = (dir+1)%4;
            continue;
        }
        x += dx[dir];
        y += dy[dir];
        ans += go[dir];
        dir = (dir+3)%4;
    }while(!(x==0 && y==0 && dir==0));
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  scanf("%d",&n);
  vector<double>dp(n+1);
  dp[0]=1;
  for(int coins=0 ; coins<n ; coins++){
    double x;
    scanf("%lf",&x);
    for(int i = coins+1 ; i>=0 ; i--){
      dp[i]=(i==0 ? 0 : dp[i-1])*x + dp[i]*(1-x);
    }
    /*for(int i=0;i<=n;i++){
      cout << dp[i] << " ";
    }
    cout << "\n";*/
  }
  double sum = 0;
  for(int i=n;i>=(n+1)/2;i--){
    sum = sum + dp[i];
  }
  printf("%.10lf",sum);
  return 0;
}


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

int main() {
	
	string s;
	cin >> s;
	set<char> a;
	rep(i, s.size()){
		a.insert(s[i]);
	}
	string ans;
	if(a.size() == 26) ans = "None";
	else{
		for(int i = 0; i <= 26; i++){
			if(a.count(i+'a')){
				
			}else{
				ans = i+'a';
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e18;


void pre(){



}

 

void solve(){

    ll n;
    cin >> n;
    map<string , ll> MAP;
    for(ll i=0;i<n;i++){
        string s;
        cin >> s;
        MAP[s]++;
    }

    cout << "AC x " << MAP["AC"] << endl;
    cout << "WA x " << MAP["WA"] << endl;
    cout << "TLE x " << MAP["TLE"] << endl;
    cout << "RE x " << MAP["RE"] << endl;
    
}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

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

int main () {
  int a , b ;
  cin >> a >> b ;
  int board[a+1][b+1] = {};
  for(int i = 0 ; i < a ; i++ ){
    for(int j = 0 ; j < b ; j++ ){
      cin >> board[i][j] ;
      board[i][b] += board[i][j] ;
    }
  }
  for(int i = 0 ; i < a ; i++ ){
    for(int j = 0 ; j < b + 1; j++ ){
      cout << board[i][j] ;
      if( j != b ) cout << " " ;
    }
    cout << endl ;
  }
  for(int i = 0 ; i < b + 1 ; i++ ){
    int pre = 0 ;
    for(int j = 0 ; j < a ; j++ ){
      pre += board[j][i] ;
    }
    cout << pre ;
    if(i!=b) cout << " " ;
  }
  cout << endl ;
}


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

using namespace std;

int main() {
	string s; cin >> s;
	bool flag = true;
	for (int i = 1; i < s.size(); ++i)
		if (s[i - 1] != s[i]) flag = false;
	cout << (flag ? "No" : "Yes") << endl;

	return 0;
}

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

int n;
int a[105];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    bool f=true;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(!((a[i]&1)||a[i]%3==0||a[i]%5==0))f=false;
    }
    cout<<(f?"APPROVED":"DENIED")<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int x,y;
	scanf("%d%d",&x,&y);
	int i=x,j=0,k;
	
	while(1)
	{
		k=((i*2)+(j*4));
		if(k==y)
		{
			printf("Yes\n");
			return 0;
		}
		i--;
		j++;
		k=0;
		if(i<0)
		{
			break;
		}
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
#include <cstdio>
#include <complex>
#include <cstring>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int n;
  int m[31] = {1,1,2};
  loop(i,3,31)
    m[i] = m[i-1] + m[i-2] + m[i-3];
  while(cin>>n,n)
    cout<<m[n]/3650 + 1 <<endl;
}

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

bool chmax(long long &a, long long b){
  if(a < b){
    a = b;
    return true;
  }
  return false;
}


int main() {
  int n;
  cin >> n;
  
  vector<vector<int>> h(1000000, vector<int>(3));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 3; j++){
      cin >> h.at(i).at(j);
    }
  }
  
  vector<vector<long long>> dp(1000000, vector<long long>(3));
  
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 3; k++){
        if(j == k) continue;
        chmax(dp.at(i + 1).at(k), dp.at(i).at(j) + h.at(i).at(k));
      }
    }
  }
  
  long long ans = 0;
  for(int i = 0; i < 3; i++) chmax(ans, dp.at(n).at(i));
  cout << ans << endl;
    
}

Measured memory_bytes: 109568
nn = 2002002
P = 10**9+7
fa = [1]
for i in range(1, nn): fa.append(fa[-1] * i % P)
fainv = [pow(fa[-1], P-2, P)]
for i in range(1, nn)[::-1]: fainv.append(fainv[-1] * i % P)
fainv = fainv[::-1]
f = lambda a, b: fa[a+b+2] * fainv[a+1] * fainv[b+1] % P - 1
r1, c1, r2, c2 = map(int, input().split())
print((f(r2, c2) - f(r2, c1-1) - f(r1-1, c2) + f(r1-1, c1-1)) % P)

Measured memory_bytes: 142720
import java.util.Scanner;
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn = null;
		int[] data = new int[100];
		int index = 0;
		int max = 0;
		int[] check = new int[100];
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			while( stdIn.hasNext() ){
				if( stdIn.hasNextInt() ){
					data[index] = stdIn.nextInt();
					check[data[index]-1]++;
					if( check[data[index]-1] > max ){
						max = check[data[index]-1];
					}
				} else {
					stdIn.next();
				}
				index++;
			}
			
			for(int i = 0; i < 100; i++){
				if( check[i] == max ){
					System.out.println(i+1);
				}
			}
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

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

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if(N % 1000 == 0)
            System.out.println(0);
        else
            System.out.println(1000 - N % 1000);
    }
}


Measured memory_bytes: 35620
h, w, k = map(int, input().split())

area = []
ans = 0
for i in range(h):
    x = list(input())
    area.append(x)

for i in range(2**(h+w)):
    num = format(i, 'b').zfill(h+w)
    cnt = 0
    for j in range(h):
        for l in range(w):
            if num[j] == '1' or num[h+l] == '1':
                continue
            else:
                if area[j][l] == '#':
                    cnt += 1
    if cnt == k:
        ans += 1

print(ans)

Measured memory_bytes: 9032
#define a printf("%d ",i)
i,j,x;main(n){for(scanf("%d",&n);n--;printf("%d\n",j)){scanf("%d%d",&i,&j);if(i<6)for(;i-j;i+=i<j?1:-1)a;if(i>5)for(x=-1;i-j;x=i?x:1)a,i+=i<6?x:i>8?-4:1;}}

Measured memory_bytes: 0
#include<cstdio>
#define mid (id+l[id]>>1)
typedef long long ll;
const int inf=0x3f3f3f3f;
ll dp[1005],n,a[1005],l[1005],r[1005],id,ans[1005],tail;
int main(){
	scanf("%lld",&n);dp[0]=-inf;
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]),dp[i]=a[i];
	for(int i=1;i<=n;i++)
		for(int j=1;j<i;j++)
			if(!((i-j)&1)&&dp[j]+a[i]>dp[i])
				dp[i]=dp[j]+a[i],l[i]=j;
	for(int i=1;i<=n;i++)if(dp[i]>dp[id])id=i;
	printf("%lld\n",dp[id]);
	for(int i=n;i>id;i--)ans[++tail]=i;
	while(l[id]){
		for(int i=mid;i>l[id];i--)ans[++tail]=i;
		id=l[id];
	}
	for(int i=1;i<id;i++)ans[++tail]=1;
	printf("%lld\n",tail);
	for(int i=1;i<=tail;i++)printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#define LL long long
using namespace std;

LL k, n, d=1;

int s(LL x)
{
    int sum=0;
    while(x) sum+=x%10, x/=10;
    return sum;
}

int main()
{
    scanf("%lld", &k);
    for(int i=1; i<=k; i++)
    {
        if((n+d*10)*s(n+d)<(n+d)*s(n+d*10)) d*=10;
        n+=d;
        printf("%lld\n", n);
    }
}

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


int main() {
string s;
cin>>s;
int N=s.size();
int ans=0;
for(int i=0;i<N;i++){
  for(int j=1;j<=N-i;j++){
    string t=s.substr(i,j);
    //cout<<t<<endl;
    bool flg = true;
    for(int k=0;k<t.size();k++){
      if(t[k]=='A'||t[k]=='C'||t[k]=='G'||t[k]=='T') continue;
      else {
        flg=false;
         break;
       }
    }
    if(flg){
      //cout<<t<<endl;
      ans=max(ans,int(t.size()));
      //cout<<t.size()<<endl;
    }
  }
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
' Imports System.Collections.Generic
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Sub Main()
        Dim N As Integer = Console.ReadLine()
        Dim S As String = Console.ReadLine()
        Dim alp As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        Console.WriteLine(Trans(S, alp, alp.Substring(N) + alp.Substring(0, N)))
        Return
    End Sub

    Shared Function Trans(ByRef S As String, ByVal f As String, ByVal t As String) As String
        For i As Integer = 0 To S.Length - 1
            Dim idx = f.indexOf(S(i))
            S = S.Substring(0, i) + t(idx) + S.Substring(i + 1)
        Next
        Trans = S
    End Function
End Class


Measured memory_bytes: 47244
#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cassert>

using namespace std;

#define EPS 1e-10
#define equal(a,b) (fabs(a-b) < EPS)
#define not_equal(a,b) (!equal(a,b))
#define lt(a,b) (a-b < -EPS)
#define PI acos(-1)

struct Point{
  double x,y;

  Point(){}
  Point(double x,double y) : x(x),y(y) {}

  Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
  Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
  Point operator * (const double &k)const{ return Point(x*k,y*k); }
  Point operator / (const double &k)const{ return Point(x/k,y/k); }
  bool operator < (const Point &p)const{ return x != p.x ? x < p.x : y < p.y; }
};

Point operator * (const Point &a,const Point &b){ return Point(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x); }

double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; }
double norm(const Point &p){ return dot(p,p); }
double abs(const Point &p){ return sqrt(norm(p)); }

istream &operator >> (istream &is,Point &p){ 
  return is >> p.x >> p.y;
}

struct Circle{
  Point p;
  double r;
  Circle(){}
  Circle(Point p,double r) : p(p),r(r) {}
};

bool isIntersectCC(const Circle &a,const Circle &b){
  double d = abs(a.p-b.p);
  return (d <= a.r+b.r && d >= abs(a.r-b.r));
}

vector<Point> crosspointCC(const Circle &a,const Circle &b){
  vector<Point> res;
  double d = abs(a.p-b.p);
  if(!isIntersectCC(a,b) || d < EPS){ return res; }
  double rc = (a.r*a.r-b.r*b.r+d*d)/(2.0*d);
  double rs = sqrt(a.r*a.r-rc*rc);
  Point p = (b.p-a.p)/d;
  res.push_back(Point(a.p+p*Point(rc,rs)));
  res.push_back(Point(a.p+p*Point(rc,-rs)));
  return res;
}

int main(){
  Circle c1,c2;
  cin >> c1.p >> c1.r;
  cin >> c2.p >> c2.r;
  vector<Point> res = crosspointCC(c1,c2);
  assert(res.size() > 0);
  sort(res.begin(),res.end());
  for(int i = 0 ; i < (int)res.size() ; i++){
    if(i > 0){ cout << " "; }
    printf("%.10f %.10f",res[i].x,res[i].y);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdio>
using namespace std;

double calc(int r1, int r2) {
    if (r1 < r2) {
        swap(r1, r2);
    }

    return sqrt((r1 + r2) * (r1 + r2) - (r2 - r1) * (r2 - r1));
}

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

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

    double ans = 0.0;
    vector<double> c;
    for (int i = 0; i < N; ++i) {
        double cc = r[i];
        for (unsigned int j = 0; j < c.size(); ++j) {
            double d = calc(r[i], r[j]);
            cc = max(cc, c[j] + d);
        }
        c.push_back(cc);
        ans = max(ans, cc + r[i]);
    }

    printf("%.10f\n", ans);

    return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INFL = 1e18;
const int MN = 5050;
ll dp[MN][MN];
ll dt[MN];
ll ord[MN];
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	ll n,a,b;
	cin >> n >> a >> b;
	for(int i=0;i<n;i++) {
		int t;
		cin >> t;
		t--;
		ord[t] = i+1;
	}
	memset(dp,0,sizeof(dp));
	for(int i=0;i<n;i++) {
		ll ma = INFL;
		for(int j=0;j<=n;j++) {
			if(i > 0) {
				if(j == ord[i-1]) {
					ma = min(ma,dt[i-1]);
				}
				ma = min(ma,dp[i-1][j]);
			} else {
				ma = 0;
			}
			if(j == ord[i]) {
				dt[i] = ma;
			}
			dp[i][j] = ma + (j>=ord[i]?a:b);
		}
	}
	ll res = INFL;
	for(int i=0;i<=n;i++) {
		res = min(res,dp[n-1][i]);
	}
	res = min(res,dt[n-1]);
	cout << res << '\n';
}


Measured memory_bytes: 199680
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

int main()
{

    int N, X;

    std::cin >> N >> X;
    std::vector<int> L;
    std::vector<int> D;
    L.resize(N);
    D.resize(N+1);
    D[0] = 0;

    for(int i=0; i<N; ++i)
        std::cin >> L[i];

    for(int i=1; i<D.size()+1; ++i)
    {
        D[i] = D[i-1] + L[i-1];
        if(D[i]>X)
        {
            std::cout << i << std::endl;
            return 0;
        }
    }

    std::cout << N+1 << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ALL(n) n.begin(),n.end()
const ll MOD=1000000007;
const long double PI=3.14159265358979;

int main() {
  ll a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  ll A=((a-1)/10+(b-1)/10+(c-1)/10+(d-1)/10+(e-1)/10+5)*10;
  ll ans=10;
  if(a%10){
    ans=min(ans,a%10);
  }
  if(b%10){
    ans=min(ans,b%10);
  }
  if(c%10){
    ans=min(ans,c%10);
  }
  if(d%10){
    ans=min(ans,d%10);
  }
  if(e%10){
    ans=min(ans,e%10);
  }
  cout<<A+ans-10;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    cin >> S;
    int count=0;
    for(int i=0; i<S.size(); i++)
    {
        if(S.at(i)=='o')
        {
            count++;
        }
    }
    cout << 700+100*count << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
	int n,m,ans=1;
	cin>>n>>m;
	if(n>1){
		for(int i=1;i<=m/n;i++){
			if(m%i==0&&m/i>=n){
				ans=i;
			}
		}
	}
	else{
		ans=m;
	}
	cout<<ans<<endl;
	return 0;
}

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()
{
    char c;

    cin >> c;

    if ('A' <= c && c <= 'Z')
    {
        cout << "A" << endl;
    }
    else
    {
        cout << "a" << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int X, Y;
	cin >> X >> Y;
	cout << max((4 - X), 0ll) * 100000 + max((4 - Y), 0ll) * 100000 + (X == 1 && Y == 1) * 400000;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

fn main() {
    input! {
    n: usize,
    m: usize,
    mut a:[usize; n],
    mut bc: [(usize, usize); m]
    }
    a.sort();
    bc.sort_by(|x, y| y.1.partial_cmp(&x.1).unwrap());
    let mut s = 0;
    for i in 0..m {
        let (mut b, c) = (bc[i].0, bc[i].1);
        while b > 0 && s < n && a[s] < c {
            a[s] = c;
            b -= 1;
            s += 1;
        }
        if s == n || a[s] >= c {
            break;
        }
    }
    let ans = a.iter().sum::<usize>();
    println!("{}", ans);
}


Measured memory_bytes: 7464
#include <bits/stdc++.h>
using namespace std;
int a[55];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int ans=0;
    for(int i=1;i<n;i++)
        for(int j=i+1;j<=n;j++)
            ans+=a[i]*a[j];
    cout<<ans;
    return 0;
}

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

int main() {
  int K;
  string S;
  cin >> K >> S;
 
  if(S.length()<=K){
    cout << S << endl;
  }

  else{
    cout << S.substr(0,K) << "..."<< endl;
  }
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m;
int l[325],r[325],x[325];
vector<pii> ranges[325];

int dp[325][325][325];

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m)scanf("%d%d%d",l+i,r+i,x+i);
  REP(i,m)ranges[r[i]].push_back(pii(l[i],x[i]));
  dp[0][0][0] = 1;
  int ans = 0;
  REP(r,n+1)REP(b,n+1)REP(g,n+1)if(dp[r][g][b]){
    bool ng = false;
    int p = max({r,g,b});
    int aa = min({r,g,b});
    int cc = p;
    int bb = (r+g+b) -cc-aa;
    bool ok = true;
    for(pii P : ranges[p]){
      int l = P.first;
      int x = P.second;
      if(x==1 && bb>=l){
        ok = false;break;
      }else if(x==2 && (aa>=l || bb<l)){
        ok = false;break;
      }else if(x==3 && aa<l){
        ok = false;break;
      }
    }
    if(!ok){
      dp[r][g][b]=0;
      continue;
    }
    if(p==n){
      (ans += dp[r][g][b]) %= MOD;
      continue;
    }
    // step r
    (dp[p+1][g][b] += dp[r][g][b]) %= MOD;
    (dp[r][p+1][b] += dp[r][g][b]) %= MOD;
    (dp[r][g][p+1] += dp[r][g][b]) %= MOD;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 125056
#include <iostream>
#include <cstdio>
#define N 55
using namespace std;

typedef long long ll;
ll n, p, s, d[N][2];
int main()
{
	ll i, j, t;
	cin >> n >> p;
	d[0][0] = 1;
	for (i = 1; i <= n; i++) {
		scanf("%lld", &t);
		for (j = 0; j < i; j++) {
			d[i][t % 2] += d[j][0];
			d[i][(t + 1) % 2] += d[j][1];
		}
	}
	for (i = 0; i <= n; i++) s += d[i][p];
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a,b,d,f=0;
    scanf("%d %d",&a,&b);
    if(a>=1 && a<=3 && b>=1 && b<=3){
    for(int c=1;c<=3;c++){
        d= a*b*c;
        if(d % 2 != 0){
            f=1;
            break;
        }
    }
    if(f == 0)
        printf("No");
    else
        printf("Yes");
}
}


Measured memory_bytes: 128
package main

import (
    "fmt"
)

func main() {
    var (
        n int
        count int
    )
    fmt.Scan(&n)

    nums := make([]int, n)
    for i := 0; i < n; i++ {
        fmt.Scan(&nums[i])
    } 

    flag := true
    for flag {
        for i := 0; i < n; i++ {
            if nums[i]%2 == 0 {
                nums[i] = nums[i]/2
            } else{
                flag = false
            }
        }
        if flag == true{
            count += 1
        }
    }

    fmt.Println(count)
}


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

using namespace std;

#define io freopen("test.txt", "r", stdin);
#define fast ios_base::sync_with_stdio(0);cin.tie(0);


#define ull unsigned long long int
#define lli long long int
#define li long int
#define ld long double

#define cout(x) cout<<x<<" "
#define coutn(x) cout<<x<<endl
#define newline cout<<endl

#define sz(x) (int)x.size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define ar array

#define pii pair<int,int>
#define pll pair<lli,lli>
#define pps pair<pair<int,int>, string>

const int MOD=1000000007;
const lli INF=1e18;
const int MX=100001;
const int N=1000000;


void solve(){

    lli a,b,c,d;
    cin>>a>>b>>c>>d;

    lli ans=max(a*c,max(a*d, max(b*c, b*d)));
    cout<<ans<<"\n";
}


int main(){
    fast
    // #ifndef godzqa
    //     io
    // #endif

    lli t;
    // cin>>t; 
    t=1;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3664
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-20;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

int main(){
	int a,b,c,d,e;scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	int ret=0;
	if(a<0){
		ret+=c*(-a);
		a=0;
	}
	if(a==0)ret+=d;
	ret+=e*(b-a);
	printf("%d\n",ret);
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll S[100005];
ll U[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    REP(i, N) {
        S[i] = 1;
        U[i] = false;
    }
    U[0] = true;
    REP(i, M) {
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        S[x]--;
        S[y]++;
        if (U[x])
            U[y] = true;
        if (S[x] == 0)
            U[x] = false;
    }

    ll ans = 0;
    REP(i, N) {
        if (U[i])
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
N, K = map(int, input().split())

AB = []
for i in range(N):
    AB.append(tuple(map(int, input().split())))

AB.sort(key=lambda x: (x[0], -x[1]))

idx = 0
rignt = 0
for a, b in AB:
    idx += b
    rignt = a
    if idx >= K:
        break

print(rignt)


Measured memory_bytes: 27780
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n = gi();
    int f = 0;
    while (n) {
        if (n%10 == 7)
            f = 1;
        n/=10;
    }
    printf(f ? "Yes\n": "No\n");

    return 0;
}


Measured memory_bytes: 3852
package main

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

func main() {
	fsc := NewFastScanner()
	N := fsc.NextInt()
	A := []string{}
	for i := 0; i < N; i++ {
		A = append(A, fsc.Next())
	}
	M := fsc.NextInt()
	B := []string{}
	for i := 0; i < M; i++ {
		B = append(B, fsc.Next())
	}

	ans := 0
	for _, blue := range A {
		result := 0
		for _, red := range B {
			if blue == red {
				result--
			}
		}
		for _, v := range A {
			if blue == v {
				result++
			}
		}
		ans = IntMax(ans, result)
	}
	fmt.Println(ans)

}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}

func (s *FastScanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, l;
    cin >> n >>l;
    vector<string>a(n);
    for(int i =0 ; i < n; ++i){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    string ans;
    for(int i =0 ; i < n; ++i){
        ans += a[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	ll n,mx=-1;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)cin>>a[i];
	ll dp[n];
	memset(dp,0,sizeof(dp));
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(ll i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 1792