akhauriyash/Code-Regression huggingface dataset:
N,M=[int(i) for i in input().split(" ")]
stores=[]
for j in range(N):
    A,B=[int(i) for i in input().split(" ")]
    stores.append([A,B])

stores=sorted(stores,key=lambda w:w[0])

money=0

while M>0:
    store=stores.pop(0)
    if store[1]>=M:
        money+=store[0]*M
        M=0
    else:
        money+=store[1]*store[0]
        M-=store[1]
print(money)


Measured memory_bytes: 21988
a= int(input())
lis = list(map(int, input().split()))

ok = 0

for i in range(a):
    if lis[i] % 2 == 0:
        #print(lis[i])
        if lis[i] % 3 != 0 and lis[i] % 5 != 0:
            #print(lis[i])
            ok =1

if ok == 1:
    print("DENIED")
else:
    print("APPROVED")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    map<ll,ll> mp;
    ll tmp=0;
    ll res=0;
    rep(i,n){
        ll a;cin>>a;
        tmp+=a;
        res+=mp[tmp];
        mp[tmp]++;
    }
    res+=mp[0];
    cout<<res<<endl;
}

Measured memory_bytes: 12800
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 4 2019
 * 
 */

#include <bits/stdc++.h>

#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    bint x , y , z ;
    bint K ;

    cin>>x>>y>>z>>K;

    vl a(x);
    iv(a);
    vl b(y);
    iv(b);
    vl c(z);
    iv(c);

    sort(all(a),greater<bint>());
    sort(all(b),greater<bint>());
    sort(all(c),greater<bint>());


    vl ans;

    for(int i=0; i<x; ++i){
        for(int j=0; j<y; ++j){
            for(int k=0; k<z; ++k){
                if((i+1) * (j+1)* (k+1)<=K){
                    ans.pb(a[i]+b[j]+c[k]);
                }else{
                    break;
                }
            }
        }
    }


    sort(all(ans),greater<bint>());

    rep(K){
        cout<<ans[i]<<endl;
    }

    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("din","r",stdin);
    freopen("dout","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(d.begin(), d.end());
    int ans = d[n/2] - d[n/2-1];
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int N=500005;
typedef long long ll;
const ll mod=998244353;

inline void MOD(int &x) {if (x>=mod) x-=mod;}

int power_mod(int a,int b) 
{
	int ans=1;
	while (b) 
	{
		if (b&1) ans=(ll)ans*a%mod;
		a=(ll)a*a%mod;
		b>>=1;
	}
	return ans;
}
int m,n,jc[N*2],ny[N*2];

int C(int n,int m) 
{
	if (n<m) return 0;
	return (ll)jc[n]*ny[m]%mod*ny[n-m]%mod;
}


int main()
{
	scanf("%d%d",&n,&m);
	if (n>m) swap(n,m);
	
	jc[0]=jc[1]=ny[0]=ny[1]=1;
	for (int i=2;i<=n+m;i++) jc[i]=(ll)jc[i-1]*i%mod,ny[i]=(mod-mod/i)*ny[mod%i]%mod;
	for (int i=2;i<=n+m;i++) ny[i]=(ll)ny[i-1]*ny[i]%mod;
	
	
	int ans=0;
	for (int i=1;i<=n;i++) ans=((ll)C(i*2,i)*C(n+m-2*i,n-i)+ans)%mod;
	ans=((ll)ans*power_mod(2*C(n+m,n)%mod,mod-2)+m)%mod;
	printf("%d\n",ans);
	return 0;
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()
S = input()[::-1]

# 地点aから行ける最大位置を返す
def check(a):
    for i in range(min(N, a+M), a, -1):
        if S[i] == '0':
            return i
    return a

i = 0
ans = []
while i < N:
    # 行けるところまで行く
    res = check(i)
    # 1歩も動けなければNG
    if res == i:
        print(-1)
        exit()
    ans.append(res-i)
    i = res
# 逆からやったので、もう1回逆順して出力
print(*ans[::-1])


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  string S;
  cin >> S;

  int min_change = sz(S) / 2;
  int left = sz(S), right = sz(S);

  rep(i, 0, sz(S) - 1) {
    if (S[i] != S[i + 1]) {
      if (i >= min_change) break;
      left = sz(S) - (i + 1);
    }
  }

  reverse(all(S));
  rep(i, 0, sz(S) - 1) {
    if (S[i] != S[i + 1]) {
      if (i >= min_change) break;
      right = sz(S) - (i + 1);
    }
  }

  put(min(left, right));
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

llong N;
vector<string> S;

void solve(int now, int use, string &s) {
  if (now == 0) {
    S.push_back(s);
    return;
  }

  for (int i = 1; i <= use + 1; ++i) {
    s.push_back('a' + i - 1);
    solve(now - 1, max(use, i), s);
    s.pop_back();
  }

  return;
}

int main() {
  cin >> N;
  string s = "";
  solve(N, 0, s);
  sort(ALL(S));
  for (auto &ret: S) {
    cout << ret << endl;
  }

  return 0;
}

Measured memory_bytes: 9588
import std.stdio, std.string, std.array, std.conv, std.algorithm.iteration, std.functional;

long[10^^5+1] AS;

void main()
{
    readln;
    auto as = readln.split.to!(long[]);
    foreach (a; as) ++AS[a];
    
    auto cnt = as.length;
    size_t i = 1, j = 10^^5+1;
    for (; j > i && i < 10^^5+1 && j > 0;) {
        if (AS[i] > 2) {
            AS[i] -= 2;
            cnt -= 2;
        } else if (AS[i] == 2) {
            if (AS[j] < 2) {
                --j;
            } else if (AS[j] > 2) {
                AS[j] -= 2;
                cnt -= 2;
            } else {
                --AS[i];
                --AS[j];
                cnt -= 2;
            }
        } else {
            ++i;
        }
    }
    while (AS[i] > 1) {
        AS[i] -= 2;
        cnt -= 2;
    }
    while (AS[j] > 1) {
        AS[j] -= 2;
        cnt -= 2;
    }
    writeln(cnt);
}

Measured memory_bytes: 5176
(defparameter *prime* (+ 7 (expt 10 9)))

(defun solve (n as)
  (declare (ignore n))
  (let ((ab (apply #'lcm as)))
    (mod (* ab (loop for a in as
                     sum (/ 1 a)))
         *prime*)))

#-swank
(let* ((n (read))
       (as (loop repeat n
                 collect (read))))
  (format t "~A~%" (solve n as)))


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


int main() {
  ll n;
  cin >> n;
  vector<ll> a(1100000);
  rep(i, 3*n) cin >> a[i];
  sort(&a[0], &a[0]+n*3);
  
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a[n + 2*i];
  }
  cout << ans << endl;
}



Measured memory_bytes: 8832
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int ans=0;
	for(int i=0;i<n-1;i++){
		if(a[i+1]>a[i])ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3368
import java.util.Scanner;

public class Main{
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int n=sc.nextInt();
		int m=sc.nextInt();
		int l=sc.nextInt();

		int a[][] = new int[n][m];
		int b[][]= new int[m][l];
		long c[][] =new long[n][l];

		for (int i=0;i<n;++i){
			for (int j=0;j<m;++j){
				a[i][j]=sc.nextInt();
			}
		}

		for (int i=0;i<m;++i){
			for (int j=0;j<l;++j){
				b[i][j]=sc.nextInt();
			}
		}

		for (int i=0;i<n;++i){
			for (int j=0;j<l;++j){
				c[i][j]=0;
				for (int k=0;k<m;++k){
					c[i][j]= c[i][j]+(long)a[i][k]*b[k][j];
				}
				System.out.print(c[i][j]);
				if (j!=l-1) System.out.print(" ");
				else System.out.println();
			}
		}
	}

}


Measured memory_bytes: 55280
s = input().split(" ")
r = int(s[0])
c = int(s[1])
a = [[0 for i in range(c)] for j in range(r+1)]
for i in range(r):
    s = input().split(" ")
    for j in range(c):
        a[i][j] = int(s[j])
for i in range(c):
    sk = 0
    for j in range(r):
        sk += a[j][i]
    a[r][i] = sk
for i in range(r+1):
    sk = 0
    for j in range(c):
        print(a[i][j],end=" ")
        sk += a[i][j]
    print(sk)

Measured memory_bytes: 8352
N,M=map(int,input().split())
klist = []
slist = []
for i in range(M):
  ks = list(map(int,input().split()))
  klist.append(ks[0])
  slist.append(ks[1:])
plist = list(map(int,input().split()))

cnt = 0
for i in range(2**N):  
  sbin = format(i, '0'+str(N)+'b')
  
  ison = True
  for j in range(M):
    cnt_k = 0
    for sk in slist[j]:
      if sbin[sk-1] == "1":
        cnt_k += 1
      
    if cnt_k%2 != plist[j]:
      ison = False
      break
      
  if ison:
    cnt += 1
    
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
long long int __lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
 //__gcd 最大公約数
 //__lcm 最小公倍数
 //double 少数（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
 
int main() {
  int a;
  cin>>a;
  cout<<3*a*a;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,m;
	while(cin>>n>>m){
		int ans=0;
		if(n>=2) ans+=(n*(n-1)/2);
		if(m>=2) ans+=(m*(m-1)/2);
		cout<<ans<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using graph = vector<vector<pair<int, int>>>;

bool dfs(const graph &to, vector<int> &x, vector<bool> &visited, int i) {
  visited.at(i) = true;
  for (auto v : to.at(i)) {
    int next = v.first, d = v.second;
    if (visited.at(next)) {
      if (x.at(next) != x.at(i) + d) return false;
      continue;
    }
    x.at(next) = x.at(i) + d;
    if (!dfs(to, x, visited, next)) return false;
  }
  return true;
}

int main() {
  int n, m;
  cin >> n >> m;
  graph to(n);
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    l--; r--;
    to.at(l).emplace_back(r, d);
    to.at(r).emplace_back(l, -d);
  }
  vector<int> x(n);
  vector<bool> visited(n);
  for (int i = 0; i < n; i++) {
    if (visited.at(i)) continue;
    if (!dfs(to, x, visited, i)) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}


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

void solve(){
    double n,d;
    cin >> n >> d;
    cout << ceil(n/(2*d+1)) << endl;
}

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

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

const int M = 1000005;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<int> cnt(M);
    for (int x : a)
    {
        // 入力に重複がある可能性を考慮
        // aを予めソートすることで計算量減
        if (cnt[x] != 0)
        {
            cnt[x] = 2;
            continue;
        }
        // xの倍数に1を足していく
        for (int i = x; i < M; i += x)
            cnt[i]++;
    }
    int ans = 0;
    for (int x : a)
    {
        if (cnt[x] == 1)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8004
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    double a,b;
    scanf("%lf%lf",&a,&b);
    int ans = int(a)/int(b);
    int ans2 = int(a)%int(b);
    double ans3 = a/b;
    printf("%d\n",ans);
    printf("%d\n",ans2);
    printf("%lf\n",ans3);
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define boost ios::sync_with_stdio(false); cin.tie(0)
#define ll 				long long int
#define ld 				long double
#define mk 				make_pair
#define pb 				push_back
#define f				first
#define s				second
#define fo(i,a,b) 		for(i=a;i<b;i++)
#define foe(i,a,b) 		for(i=a;i<=b;i++)
#define all(x)			x.begin(),x.end()
// #define vi 				vector<int>
#define vl 				vector <long long int>
// #define pii 			pair <int,int>
#define pll 			pair <long long int, long long int>
// #define vpii			vector< pair<int,int> >
#define vpll 			vector < pair <long long int,long long int> >
#define MOD				1000000007
using namespace std;
const int inf = INT_MAX;
const ll inf64 = LLONG_MAX;


int main()
{
	boost;
	ll a;
	ld b;
	cin >> a >> b;
	cout << (ll)((ld)a * b);



	return 0;
}

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

int main() {
	int n;
	cin>>n;
	string a[n];
	
	for(int i=0;i<n;i++){
		string temp;
		cin>>temp;
		
		int c[10];
		for(int k=0;k<10;k++){
			c[k]=(int)temp.at(k);
		}
		
		sort(c,c+10);
		string s="";
		
		for(int k=0;k<10;k++){
			s=s+(char)c[k];
		}
		a[i]=s;
		
	}
	sort(a,a+n);
	
	long sum=0;
	long x=1;
	for(int i=0;i<n-1;i++){
		if(a[i]==a[i+1]){
			x++;
		}
		else{
			sum=sum+(((x-1)*x)/2);
			x=1;
		}
	}
	if(x>1){
		sum=sum+(((x-1)*x)/2);
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 5760
n = int(input())
list_V = list(map(int, input().split()))

list_Vx = []
list_Vy = []

for i, s in enumerate(list_V):
    if i % 2 == 0:
        list_Vx.append(s)
    else:
        list_Vy.append(s)

list_Vx_Count = [0 for _ in range(pow(10, 5))]
list_Vy_Count = [0 for _ in range(pow(10, 5))]

for i in list_Vx:
    list_Vx_Count[i-1] += 1
for i in list_Vy:
    list_Vy_Count[i-1] += 1

ans = n - max(list_Vx_Count) - max(list_Vy_Count)

if list_Vx_Count.count(max(list_Vx_Count)) == 1 and list_Vy_Count.count(max(list_Vy_Count)):
    if list_Vx_Count.index(max(list_Vx_Count)) == list_Vy_Count.index(max(list_Vy_Count)):
        ans = n - max(max(list_Vx_Count)+sorted(list_Vx_Count)[-2], max(list_Vy_Count)+sorted(list_Vy_Count)[-2])

print(ans)

Measured memory_bytes: 14268
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, w;
int dp[2][1 << 16], bc[1 << 16];
string in[130];

int main(){
	cin >> n >> w;
	rep(i, n) cin >> in[i];
	rep(i, 1 << w) bc[i] = __builtin_popcount(i);
	
	memset(dp, -1, sizeof(dp));
	dp[0][0] = 0;
	
	int cur = 0, next = 1;
	rep(i, n) rep(j, w){
		memset(dp[next], -1, sizeof(dp[next]));
		
		rep(bit, 1 << w) if(dp[cur][bit] >= 0){
			int idx = bc[bit & (1 << j) - 1];
			if(idx < in[i].size()){
				int nxt = dp[cur][bit];
				if(j && (bit & 1 << (j - 1)) && in[i][idx - 1] == in[i][idx]) nxt++;
				if(i && (bit & 1 << j) && in[i][idx] == in[i - 1][in[i - 1].size() - bc[bit >> j]]) nxt++;
				dp[next][bit | 1 << j] = max(dp[next][bit | 1 << j], nxt);
			}
			if(idx + w - j > in[i].size()){
				dp[next][bit & ~(1 << j)] = max(dp[next][bit & ~(1 << j)], dp[cur][bit]);
			}
		}
		swap(cur, next);
	}
	cout << 2 * *max_element(dp[cur], dp[cur] + (1 << w)) << endl;
	
	return 0;
}

Measured memory_bytes: 1992
#include<bits/stdc++.h>
using namespace std;
#define ll  long long 
#define mp make_pair
#define pb push_back
#define f first
//#define s second
#define mod 1000000007
const ll N=2e5+5;
unordered_map<ll,vector<ll>> adj;
vector<ll> vis(300005,0);
vector<ll> p(100005,0);
ll c[100005];
ll cnt;
ll n;
void dfs(ll node)
{
  if(vis[node])
    return;
  vis[node]=1;
  cnt++;
  for(auto i:adj[node])
    {
      dfs(i);
    }
}
struct range{
  ll l;
  ll r;
  ll index;
};
bool cmp(range& p1,range& p2)
{
     return p1.l<p2.l;
}


int main()
{
   ll n;
   cin>>n;
   ll cnt=0;
   while(n--)
   {
    ll a,b;
    cin>>a>>b;
      if(cnt==3)
        continue;
    if(a==b)
      cnt++;
    else
      cnt=0;
   }
   if(cnt>2)
    cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 6232
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=105;
int n,x[N],y[N],h[N],cx,cy,ch;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    	scanf("%d%d%d",&x[i],&y[i],&h[i]);
	int fi,fr,state; 
    for(cx=0;cx<=100;cx++)
    {
    	for(cy=0;cy<=100;cy++)
    	{
    		fi=0;fr=0;state=0;
	    	for(int i=1;i<=n;i=i%n+1)
	    	{
	    		if(!fi)
	    		{
		    		if(h[i]>0)
		    		{
		    			fi=1;
		    			fr=i;
		    			ch=h[i]+abs(cx-x[i])+abs(cy-y[i]);
					}
				}
				else if(fi)
				{
					if(h[i]!=max(ch-abs(cx-x[i])-abs(cy-y[i]),0))
					{
						state=1;
						break;
					}
		    		if(i==fr)
		    		{
		    			state=2;
		    			break;
					}
				}
			}
			if(state==1)continue;
			if(state==2)break;
		}
	if(state==2)break;
	}
	printf("%d %d %d\n",cx,cy,ch);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.awt.geom.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			Point2D[] p = new Point2D[n];

			for(int i=0;i<n;i++){
				String[] s = sc.next().split(",");
				p[i] = new Point2D.Double(Double.parseDouble(s[0]), Double.parseDouble(s[1]));
			}

			System.out.println(p.length - convexHull(p).length);
		}
	}

	public static Point2D[] convexHull(Point2D[] ps) {        
		Arrays.sort(ps , new Comparator< Point2D >() {
				public int compare(Point2D o1, Point2D o2) {
					if(o1.getX() < o2.getX()) return -1;
					else if(o1.getX() > o2.getX()) return 1;
					else if(o1.getY() < o2.getY()) return -1;
					else if(o1.getY() > o2.getY()) return 1;
					else return 0;        
				}
			});
		int n = ps.length, k = 0;
		Point2D[] ch = new Point2D[2 * n];

		for (int i = 0; i < n; ch[k++] = ps[i++])
			while (k >= 2
						 && Line2D.relativeCCW(ch[k - 2].getX(), ch[k - 2].getY(),
																	 ch[k - 1].getX(), ch[k - 1].getY(), ps[i].getX(),
																	 ps[i].getY()) <= 0)
				k--;

		for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--])
			while (k >= t
						 && Line2D.relativeCCW(ch[k - 2].getX(), ch[k - 2].getY(),
																	 ch[k - 1].getX(), ch[k - 1].getY(), ps[i].getX(),
																	 ps[i].getY()) <= 0)
				k--;
		return Arrays.copyOf(ch, k - 1);
	}
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

bool is_ok(vector<ll> a, vector<ll> b){
    ll d = 0;
    ll n = ll(a.size());
    REP(i, n){
        d += (a[i] - b[i]) * (a[i] - b[i]);
    }
    ll tmp = sqrt(d);
    if(tmp*tmp == d) return true;
    else return false;
}

int main(){
    ll n, d;
    cin >> n >> d;
    vector<vector<ll>> x(n, vector<ll>(d));
    REP(i, n){
        REP(j, d) cin >> x[i][j];
    }
    ll cnt = 0;
    REP(i, n-1){
        for(ll j = i+1; j < n; j++){
            if(is_ok(x[i], x[j])) cnt++;
        }
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;
	ll ar[n+2],br[n+1];
	for(i=1;i<=n+1;i++){
		cin>>ar[i];
	}
	for(i=1;i<=n;i++){
		cin>>br[i];
	}

	ll ans=0;
	for(i=1;i<=n;i++){
		k=min(ar[i],br[i]);
		ans+=k;
		br[i]-=k;
		if(br[i]>0){
			k=min(ar[i+1],br[i]);
			ans+=k;
			ar[i+1]-=k;
		}
	}
	cout<<ans;
	return 0;
}

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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;


ll sum(ll n) {
  ll m=0;
  FOR(i,0,12){
    m+=n%10;
    n/=10;
  }
  return m;
}


ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}


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


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/


signed main() {
  ll a,b,c;
  	ci(a>>b>>c);
  if((a+b)>=c){
    co("Yes")
  }
  else{
    co("No")
  }
}

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

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

    ll n = S.size();
    n--;
    while(true){
        if(n % 2 == 1){
            n--;
            continue; 
        }
        if(S.substr(0, n/2) == S.substr(n/2, n/2)){
            cout << n << endl;
            break;
        }
        n--;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//solved by *ALIKHAN*
#define ll long long
#define ld long double
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
#define ppb pop_back
#define mp make_pair
#define all(n) n.begin(), n.end()
#define timefaster ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18;

int main(){
	timefaster;
	int n , m;
	cin >> n >> m;
	if(n <= m) {
	 	cout << 1;
	 	return 0;
	}
	else if(n % m == 0) {
	 	cout << n/m;
	 	return 0;
	}
	cout << n/m + 1;
}// Aksay sila

Measured memory_bytes: 256
H, W = map(int, input().split())
s = [input() for _ in range(H)]
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            if i - 1 < 0:
                if j - 1 < 0:
                    if s[i][j + 1] == '#' or s[i + 1][j] == '#':
                        continue
                    else:
                        print('No')
                        exit()
                elif j + 1 >= W:
                    if s[i][j - 1] == '#' or s[i + 1][j] == '#':
                        continue
                    else:
                        print('No')
                        exit()
                else:
                    if s[i][j - 1] == '#' or s[i][j + 1] == '#' or s[i + 1][
                        j] == '#':
                        continue
                    else:
                        print('No')
                        exit()
            elif i + 1 >= H:
                if j - 1 < 0:
                    if s[i][j + 1] == '#' or s[i - 1][j] == '#':
                        continue
                    else:
                        print('No')
                        exit()
                elif j + 1 >= W:
                    if s[i][j - 1] == '#' or s[i - 1][j] == '#':
                        continue
                    else:
                        print('No')
                        exit()
                else:
                    if s[i][j - 1] == '#' or s[i][j + 1] == '#' or s[i - 1][
                        j] == '#':
                        continue
                    else:
                        print('No')
                        exit()
            else:
                if j - 1 < 0:
                    if s[i][j + 1] == '#' or s[i + 1][j] == '#' or s[i - 1][
                        j] == '#':
                        continue
                    else:
                        print('No')
                        exit()
                elif j + 1 >= W:
                    if s[i][j - 1] == '#' or s[i + 1][j] == '#' or s[i - 1][
                        j] == '#':
                        continue
                    else:
                        print('No')
                        exit()
                else:
                    if s[i][j - 1] == '#' or s[i][j + 1] == '#' or s[i + 1][
                        j] == '#' or s[i - 1][j] == '#':
                        continue
                    else:
                        print('No')
                        exit()
print('Yes')


Measured memory_bytes: 3192
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int N;

int main()
{
	in >> N;
	out << "ABC" << N << std::endl;
	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(max(a*c, a*d), max(b*c, b*d)) << "\n";
	
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> h(n+2);
    rep(i, n) cin >> h[i];
    vector<int> dp(n+2);
    rep(i, n) dp[i] = 1e9;
    dp[0] = 0;

    rep(i, n) {
        if (dp[i+1] > dp[i] + abs(h[i] - h[i+1])) dp[i+1] = dp[i] + abs(h[i] - h[i+1]);
        if (dp[i+2] > dp[i] + abs(h[i] - h[i+2])) dp[i+2] = dp[i] + abs(h[i] - h[i+2]);
    }
    
    cout << dp[n-1] << endl;
    
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
	#include <set>
	#define ll long long 
	#include <string>
	#define pb push_back
	#define mp make_pair
	# define pi 3.14159265358979323846
	#define mod 1000000007
    #define rep(i,n) for(i=0;i<n;i++)
    #define rep1(i,n) for(i=1;i<n;i++)
	using namespace std;
	ll int multiply(ll int a,ll int b)
{
	ll int ans=(a%mod*b%mod)%mod;
	return ans;
}
ll int add(ll int a, ll int b)
{
	ll int ans=(a%mod+b%mod)% mod;	
	return ans;
}

	int power(ll int x,  ll int y, ll int p)  
{  
    ll int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
	void fastio()
	{					
		#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	    #endif
	    ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    cout.tie(NULL);

	}
	vector<ll int> adj[100001];
	ll int vis[100001]={0};
	ll int indegree[100001]={0};
	ll int dist[100001]={0};
	void dfs(ll int n)
	{
		vis[n]=1;
		for(auto node: adj[n])
		{
			dist[node]=max(dist[node],dist[n]+1);
			indegree[node]--;
			if (indegree[node]==0)
				dfs(node);
		}
	}
	void solve()
	{
		ll int n,m,i;
		cin>>n>>m;
	while(m--)

	{
		ll int a,b;
		cin>>a>>b;
		adj[a].pb(b);
		indegree[b]++;
	}
	for(i=1;i<=n;i++)
	{
		if (vis[i]==0 && indegree[i]==0)
		{
			dfs(i);
		}
	}
	ll int ans=0;
	for(i=1;i<=n;i++)
	{
		ans=max(ans,dist[i]);

	}
	cout<<ans<<endl;
		
    }
	int main()
	{
		fastio();
		ll int t;
		t=1;
		// cin>>t;
		
		while(t--)
		{
			solve();
		}
			
	}
			

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define read            freopen("in.txt","r",stdin)
#define write           freopen("out.txt","w",stdout)
#define ms(a,x)         memset(a,x,sizeof a)
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd((a),(b))
#define lcm(a,b)        ((a)*(b))/(gcd(a,b))
#define sq(a)           (a)*(a)
#define loop(i,a,b)     for (int i = a; i <= b; i++)
#define rloop(i,a,b)    for (int i = a; i >= b; i--)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)

int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        ll x,k,d;
        cin>>x>>k>>d;
        x=abs(x);
        ll y=x/d;
        if(k>y){
        k=k-y;
        x=x-y*d;
        if(k&1) cout<<abs(x-d);
        else cout<<x;
        }
        else cout<<x-k*d;

    }
    return 0;
}


Measured memory_bytes: 3652
from heapq import heappush, heappop
import math

N,M = [int(i) for i in input().split(' ')]
itemList = [int(i) for i in input().split(' ')]
heap = []

for i in itemList:
    heappush(heap, -i)

for _ in range(M):
    heappush(heap, math.ceil(heappop(heap)/2))
print(-sum(heap))

Measured memory_bytes: 14536
def quiksort(arr,p,r)
    if p < r
        q =partition(arr,p,r)
        quiksort(arr,p,q-1)
        quiksort(arr,q+1,r)
    end
    return arr
end

def merge(arr,left,mid,right)
    n1 = mid-left
    n2 = right-mid
    l = []
    r = []
    i = 0
    while i < n1
         l[i] =arr[left+i]
         i +=1
    end
    i = 0
    while i < n2
        r[i] = arr[mid+i]
        i +=1
    end
    l[n1] = "A",9999999999
    r[n2] = "A",9999999999
    i = 0
    j = 0
    k = left
    while k < right
        if l[i][1] <= r[j][1]
            arr[k] = l[i]
            i +=1
        else
            arr[k] = r[j]
            j +=1
        end
        k +=1
    end
end

def mergesort(arr,left,right)
    #leftは配列の先頭だから常に0。関数の中で関数を呼び出すからひたすら配列の要素が一つだけになるまでマージソートを繰り返す
    #要素の分解が１まできたことを表す。
    if left+1 < right
        mid =(left+right)/2
        #配列の左半分
        mergesort(arr,left,mid)
        #配列の右半分
        mergesort(arr,mid,right)
        merge(arr,left,mid,right)
    end
    return arr
end

def partition(arr,p,r)
    x = arr[r][1]
    i = p-1
    j = p
    while j < r
        if arr[j][1] <= x
            i +=1
            arr[i],arr[j] = arr[j],arr[i]
        end
        j +=1
    end
    arr[i+1],arr[r] =arr[r],arr[i+1]
    return i+1
end

n =gets.to_i
arr=[]
n.times do
    arr << gets.split(" ")
    arr.last[1] = arr.last[1].to_i
end
arr2 = arr.dup

arr  =mergesort(arr,0,n)
arr2 =quiksort(arr2,0,n-1)

if arr == arr2
    puts "Stable"
else
    puts "Not stable"
end

arr2.each do |obj,obj2|
    puts "#{obj} #{obj2}"
end


Measured memory_bytes: 27628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Atcoder
{
    class aaaa
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');

            int A = int.Parse(input[0]); int B = int.Parse(input[1]); int C = int.Parse(input[2]); int D = int.Parse(input[3]); 
        
            int L = A + B; int R = C + D;

            if (L>R){
                Console.WriteLine("Left");
            }else if ( L==R){
                Console.WriteLine("Balanced");
            }else{
                Console.WriteLine("Right");
            }
        }
    }
}

Measured memory_bytes: 13140
/*X に最も近いもの、つまり X との差の絶対値が最小のものを求めてください。そのような整数が複数存在する場合は、そのうち最も小さいものを答えてください*/
#include<stdio.h>
int main(void) {

	int x = 0;
	int N = 0;
	int v[100] = { 0 };
	int ans = 0;
	int i = 0;
	int sa = 0;

	/*xを入力*/
	scanf("%d", &x);
	/*個数を入力*/
	scanf("%d", &N);

	int j = 0;


	for (i = 0; i < N; i++) {
		// printf("[%d]\n", i);
		scanf("%d", &v[i]);
	}



	/*優先順位が高い順に
	  x = 10
	  10, 9, 11, 8, 12, 7, 13, 6, 14, 5を表示。
	  x = 50 を入力すると
	  50, 49, 51, 48, 52, 47, 53, 46, 52, 45 */

	int a = x - 1;
	int b = x + 1;

	// x が配列v に含まれているかチェック
	// 含まれてなければ、x 自身が正答。printf して終了

	int count = 0;

	for (i = 0; i < N; i++) {
		if (v[i] != x) {
			count++;
		}
	}

	if (count == N) {
		printf("%d", x);
		return 0;
	}


	/*整数列にxがあるとき*/

	int count_2 = 0;
	int count_3 = 0;

	while (a >= 0) {
		// a が配列v に含まれているかチェック
		// 含まれてなければ、a が正答。printf して終了

		count_2 = 0;

		for (i = 0; i < N; i++) {
			if (v[i] != a) {
				count_2++;
			}
		}

		if (count_2 == N) {
			printf("%d\n", a);
			return 0;
		}

		a--;

		// b が配列v に含まれているかチェック
		// 含まれてなければ、a が正答。printf して終了

		count_3 = 0;

		for (i = 0; i < N; i++) {
			if (v[i] != b) {
				count_3++;
			}
		}

		if (count_3 == N) {
			printf("%d\n", b);
			return 0;
		}

		b++;
	}

	return 0;
}



Measured memory_bytes: 1732
#include<stdio.h>
int main()
{
	int a,b;
	int d,r;
	double f;
	scanf("%d%d",&a,&b);
	d=a/b;r=a%b;f=(double)a/b;
	printf("%d %d %6f",d,r,f);
	return 0;
}

Measured memory_bytes: 636
#include <stdio.h>
#include<iostream>
#include<string>
#include <string.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <climits>
#include <map>
using namespace std;
int a[100005],b[100005],p[100005],n;
int t[100005];
void add(int x){
    while(x<=n){
        t[x]++;
        x+=x&-x;
    }
}
int query(int x){
    int ans=0;
    while(x){
        ans+=t[x];
        x-=x&-x;
    }
    return ans;
}
int main() {
    int x;
    cin>> x;
    cout<<1-x;
    return 0;
}


Measured memory_bytes: 3500
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>

using namespace std;  //このネームスペースを使う

int main(){
  int a,b;
  cin >> a >> b;

  int max;
  max=a+b;

  if(max < a-b){
  	max = a-b;
  }
  if(max < a*b){
    max = a*b;
  }

  cout << max << endl;
    return 0;
}



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

int main(){
    int64_t N;
    cin >> N;
    int64_t m,M;
    for (int i=1; i<=sqrt(N); i++){
        if (N%i==0){
            m = i;
            M = N/i;
        }
    }
    cout << m+M-2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int n, i, num[2], result[2] = { 0,0 };

    while (scanf("%d", &n)) {
        if (n == 0) break;

        result[0] = 0;
        result[1] = 0;
        for (i = 0; i < n; i++) {
            scanf("%d %d", &num[0], &num[1]);
            if (num[0] > num[1]) result[0] += num[0] + num[1];
            else if (num[0] < num[1]) result[1] += num[0] + num[1];
            else result[0] += num[0], result[1] += num[1];
        }
        printf("%d %d\n", result[0], result[1]);
    }

    return 0;
}

Measured memory_bytes: 2620
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 1e18+10 : 1e9+10;
// int dx[]={0,1,0,-1,1,1,-1,-1};
// int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int dx[]={-1,-1,0,0,1,1};
int dy[]={-1,0,-1,1,0,1};//RDLU
class DIJ{
	public:
	struct edge{
		int to,cost;
	};
	vector<vector<edge> >G;
	int n;
	vi d;//distance
	DIJ(int size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int a,int b,int c){
		edge e={b,c},ee={a,c};
		G[a].pb(e);
		G[b].pb(ee);
	}
	void dij(int s){
		d=vi(n,inf);
		d[s]=0;
		priority_queue<pii>q;
		q.push(pii(0,s));
		while(!q.empty()){
			pii p=q.top();
			q.pop();
			int pos=p.second,cost=-p.first;
			if(cost>d[pos])continue;
			rep(i,G[pos].size()){
				edge e=G[pos][i];
				int to=e.to;
				int nowcost=cost+e.cost;
				if(nowcost<d[to]){
					d[to]=nowcost;
					q.push(pii(-d[to],to));
				}
			}
		}
	}
};
signed main(){
	int n,m,s,t;
	cin>>n>>m>>s>>t;
	s--;t--;
	DIJ dij1(n),dij2(n);
	while(m--){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		a--;b--;
		dij1.add_edge(a,b,c);
		dij2.add_edge(a,b,d);
	}
	dij1.dij(s);
	dij2.dij(t);
	vi d(n);
	rep(i,n)d[i]=dij1.d[i]+dij2.d[i];
	for(int i=n-2;i>=0;i--)
		cmin(d[i],d[i+1]);
	rep(i,n)cout<<1000000000000000ll-d[i]<<endl;
}







Measured memory_bytes: 19012
# -*- coding: utf-8 -*-
import sys
from collections import deque
from collections import defaultdict
 
H,W=map(int, sys.stdin.readline().split())
S=[ sys.stdin.readline().strip() for _ in range(H) ]
 
D=[(1,0),(-1,0),(0,1),(0,-1)]
 
def bfs(start):
    Visit={}
    q=deque()
    q.append(start)
    L=defaultdict(lambda: float("inf")) 
    L[start]=0
 
    while q:
        fro_x,fro_y=q.popleft()
        for dx,dy in D:
            to_x=fro_x+dx
            to_y=fro_y+dy
            alt=L[(fro_x,fro_y)]+1
            if 0<=to_x<H and 0<=to_y<W:
                if S[to_x][to_y]=="." and alt<L[(to_x,to_y)]:
                    L[(to_x,to_y)]=alt
                    q.append((to_x,to_y))
    return max(L.values())
 
ans=0
for h in range(H):
    for w in range(W):
        if S[h][w]==".":
            ans=max(ans,bfs((h,w)))
print ans


Measured memory_bytes: 34152
import functools

import os
import sys

sys.setrecursionlimit(10000)
INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        ret = fn(*args, **kwargs)
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        print(ret)
        return ret

    return wrapper



a, b, c = inl()
print("Yes" if a <= c <= b else "No")


Measured memory_bytes: 3568
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n; cin >> n;
    vvl v(n, vl(3));
    rep(i,n){
        rep(j,3) cin >> v[i][j];
    }
    vvl dp(n, vl(3,0));
    rep(i,3) dp[0][i] = v[0][i];
    for(int i=1; i<n; i++){
        rep(j,3){
            dp[i][j] = max(dp[i-1][(j+1)%3] + v[i][j], dp[i-1][(j+2)%3] + v[i][j]);
        }
    }
    ll M = max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    cout << M << endl;
}

Measured memory_bytes: 11136