akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
const ll BetsuMOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int n, k;
	cin >> n >> k;
	n--, k--;
	cout << (n + k - 1) / k << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
mem=[[0] * 10 for _ in range(10)]

for i in range(1, N+1):
    s = str(i)
    mem[int(s[0])][int(s[-1])] += 1 
    
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += mem[i][j] * mem[j][i]
print(ans)

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

using namespace std;

const int INF = 1e9;
const int N = 1e5;
const int MOD = 1e9 + 7;

const double PI = acos(-1);



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    long long a, b, k;
    cin >> a >> b >> k;
    long long x = min(a, k);
    a -= x;
    k -= x;
    b -= min(b, k);
    cout << a << ' ' << b;
}

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

int tbl[5][5] = {
	{1, 1, 1, 1, 0},
	{1, 1, 1, 0, 0},
	{1, 1, 1, 0, 1},
	{0, 0, 1, 1, 0},
	{1, 0, 0, 0, 1},
};

int main(){
	int mod = 1000000;
	int n, m, ans = 0;
	cin >> n >> m;
	if(m == 1){
		ans = 1;
		for(int i = 0; i < n; ++i){
			ans = ans * 2 % mod;
		}
	}
	else{
		int v[5] = {1, 1, 1, 0, 1}, w[5] = {};
		for(int i = 1; i < n; ++i){
			for(int j = 0; j < 5; ++j){
				w[j] = 0;
				for(int k = 0; k < 5; ++k){
					w[j] += tbl[j][k] * v[k];
				}
			}
			for(int j = 0; j < 5; ++j){
				v[j] = w[j] % mod;
			}
		}
		ans = (v[0] + v[1] + v[2] + v[4]) % mod;
	}
	cout << ans << endl;
}

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

int main() {
	int n;
	int a[1000];

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

	double sum = 0;

	for (int i = 0; i < n; i++) {
		sum += (double)1 / a[i];
	}

	cout << fixed << setprecision(7) << (double)1 / sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
  int x, a , b;
  
  scanf("%d%d%d", &x, &a, &b);

  if((b-a) > x){
    printf("dangerous");
  }else if((b-a) > 0){
    printf("safe");
  }else if((b-a) <= 0){
    printf("delicious");
  }

  printf("\n");

}


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

using namespace std;

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

const ll MOD = 1e9 + 7;

ll rep_pow(int n, int p) { // n^p
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        ll t = rep_pow(n, p / 2);
        return t * t % MOD;
    } else {
        return n * rep_pow(n, p - 1) % MOD;
    }
}

ll x (int n, int k) {
    if (k == 0) {
        return 1;
    }
    return n * x(n - 1, k - 1) % MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = rep_pow(2, n) - 1;
    ans -= x(n, a) * rep_pow(x(a, a), MOD - 2) % MOD;
    ans -= x(n, b) * rep_pow(x(b, b), MOD - 2) % MOD;
    while (ans < 0) {
        ans += MOD;
    }
    cout << ans << endl;
   return 0;
}


Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	static int[][] diamond = null;
	static int[][] max = null;
	static int[] tmpMax = null;
	static int height = -1;
	static int width = -1;

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<String> array = new ArrayList<String>();

		try {
			String str = null;
			while ((str = br.readLine()) != null && !str.equals("")) {
				array.add(str);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				br.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		width = array.size() / 2 + 1;
		height = array.size();
		diamond = new int[height][width];

		max = new int[height][width];

		for (int i = 0; i < height; i++) {
			String s = array.get(i);
			String[] data = s.split(",");
			for (int j = 0; j < data.length; j++) {
				diamond[i][j] = Integer.parseInt(data[j]);
			}
		}
		bfs();

		System.out.println(max[height - 1][0]);

	}

	private static void bfs() {
		max[0][0] = diamond[0][0];
		//前半
		for (int i = 1; i < width; i++) {
			for (int j = 0; j <= i; j++) {
				if (j == 0)
					max[i][j] = diamond[i][j] + max[i - 1][j];
				else if (j == i)
					max[i][j] = diamond[i][j] + max[i - 1][j - 1];
				else {
					max[i][j] = diamond[i][j]
							+ Math.max(max[i - 1][j], max[i - 1][j - 1]);
				}
			}
		}
		//後半
		for (int i = width; i < height; i++) {
			for (int j = 0; j <= (height - i - 1); j++) {
				max[i][j] = diamond[i][j]
						+ Math.max(max[i - 1][j], max[i - 1][j + 1]);
			}
		}
	}
}

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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

int main(void) {
    ll h, w;
    cin >> h >> w;

    ll ans = 0;
    if(h==1||w==1) { 
        cout << 1 << endl;
        return 0;
    }

    for(ll i=0;i<w;i++) {
        if(i%2==0) {
            ans += (h+1)/2;
        }
        else ans += h/2;
    }

    cout << ans << endl;
    return 0;
}


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

const int MOD = 1000000007;

//fill an N-dimensional array with val
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){fill((T*)array,(T*)(array+N),val);}

int dp[100005];
int broken[100005];
int main(){
    int n,m;
    cin>>n>>m;
    FILL(broken,0);
    REP(i,m) {
        int a;
        cin>>a;
        broken[a] = 1;
    }

    FILL(dp,0);
    dp[0] = 1;
    dp[1] = ((broken[1]==0)?1:0);

    REP2(i,2,n+1){
        if(broken[i]==1) continue;
        dp[i] = ((dp[i] + dp[i-1])%MOD + dp[i-2])%MOD;
    }

    cout<<dp[n]<<endl;

    return 0;
}

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


int main(int argc, char const *argv[])
{
    int n;
    cin>>n;
    vector<int> card(n);
    for(int i = 0; i < n; i++)cin>>card[i];
    int alice = 0;
    int bob = 0;
    sort(card.begin(), card.end(), greater<int>());
    for(int i = 0; i < n; i++){
//        cout << "card = " << card[i] << endl;
        if(i % 2 == 0){
            alice += card[i];
        }else{
            bob += card[i];
        }
    }
//    cout<<"alice = " << alice << " bob = " << bob << endl;
    int gap = alice - bob;
    cout<<gap<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
  int l,x,i,j,k=0;
  
  scanf("%d",&l);

  for(i=0;i<l;i++)
    {
      scanf("%d",&x);
      
      for(j=2;j<=sqrt(x);j++)
	{
	  if(x%j==0){ k++; break;}
	}
      
    }
  
  printf("%d\n",l-k);

  return 0;
}



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

signed main(void){
    int m,n; cin >> m >> n;
    int m2,n2; cin >> m2 >> n2;
    if(m2==m)cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int[] P = new int[N];
    int count = 0;
    int min = Integer.MAX_VALUE;
    for(int i=0; i<N; i++) {
      P[i] = scan.nextInt();
      if(min > P[i]) {
        count++;
        min = P[i];
      }
    }
    scan.close();

    System.out.println(count);
  }
}

Measured memory_bytes: 64404
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    a = [[int(_) for _ in input().split()] for _ in range(N)]
    MOD = 10**9+7
    
    dp = [[0]*((1<<N)+1) for _ in range(N+1)]
    dp[0][0] = 1

    for i in range(N):
        for s in range(1<<N):
            if dp[i][s] == 0:
                continue
            for j in range(N):
                jb = 1<<j
                if not (s&jb) and a[i][j]:
                    dp[i+1][s|jb] += dp[i][s]
    
    print(dp[-1][(1<<N)-1]%MOD)

if __name__ == "__main__":
    main()


Measured memory_bytes: 422152
k = int(input())

sum = 0

def gcd(x, y): # ユークリッドの互除法
    if y > x:
        y,x = x,y
    while y > 0:
        r = x%y
        x = y
        y = r
    return x

import math

for i in range(1,k+1):
    for m in range(1,k+1):
        sub = gcd(i,m)
        for l in range(1,k+1):
            sum += gcd(sub,l)
print(sum)


Measured memory_bytes: 9060
#include<iostream>
#include<cstdio>
#include<cstring>
#include <fstream>
#include<string>
#include<sstream>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
#include <math.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const int INF = 1000000007;
const double EPS = 1e-10;
const double PI = 3.14159265359;
const int N = 100005;
//cout << fixed << std::setprecision(9)
//--------------------------

int n;
ll a[3003];
ll dp[3003][3003];

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

	for (int i = 0; i < n; i++) {
		dp[i][i] = a[i];
	}

	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			if (i + k >= n) continue;

			if (k == 0) {
				dp[i][i] = a[i];
			}
			else if (k == 1) {
				dp[i][i + 1] = max(a[i], a[i + 1]) - min(a[i], a[i + 1]);
			}
			else {
				// left
				ll l = a[i] + min(dp[i + 2][i + k] - a[i + 1], dp[i + 1][i + k - 1] - a[i + k]);

				// right
				ll r = a[i + k] + min(dp[i + 1][i + k - 1] - a[i], dp[i][i + k - 2] - a[i + k - 1]);

				dp[i][i + k] = max(l, r);
			}
		}
	}

	cout << dp[0][n - 1] << endl;

	return 0;
}

Measured memory_bytes: 70016
import numpy as np
import sys

#inp = list(map(int, input().split())
#inp = list(input())


n = int(input())
count = 0

for i in range(n):
    d = list(map(int, input().split()))
    if d[0] == d[1]:
        count += 1
    else :
        count = 0
    if count == 3:
        print("Yes")
        sys.exit()

print("No")
        


Measured memory_bytes: 27144
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
const int mod=1e9+7;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  int n;cin>>n;
  int d,ans;
  cin>>d>>ans;
  d--;
  rep(i,n){
    int a;cin>>a;
    ans+=d/a+1;
    }
  cout<<ans<<endl;
  return 0;
  }

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <time.h>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
#define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int, int> Pii;
const int inf = 0x3f3f3f3f;
const LL INF = (1uLL << 63) - 1;
const LL mod = 1000000007;
const int N = 150 + 5;
const double Pi = acos(-1.0);
const int maxn = 1e6 + 5;
int n;
char s[maxn];
char ans[maxn];
char fan(char a) {
    if(a == 'W')return 'S';
    else return 'W';
}
bool judge(char a, char b) {
    ans[0] = a;
    ans[1] = b;
    for(int i = 1; i < n - 1; i++) {
        if(ans[i] == 'S') {
            if(s[i] == 'o')
                ans[i + 1] = ans[i - 1];
            else ans[i + 1] = fan(ans[i - 1]);
        } else {
            if(s[i] == 'x')
                ans[i + 1] = ans[i - 1];
            else ans[i + 1] = fan(ans[i - 1]);
        }
    }
    for(int i = 0; i < n; i++){
        int l = (i - 1 + n) % n;
        int r = (i + 1) % n;
        if(ans[i] == 'S'){
            if(s[i] == 'o' && ans[l]!=ans[r])return 0;
            if(s[i] == 'x' && ans[l] == ans[r])return 0;
        }
        else {
            if(s[i] == 'x' && ans[l]!=ans[r])return 0;
            if(s[i] == 'o' && ans[l] == ans[r])return 0;
        }
    }
    return 1;
}
int main() {
#ifdef local
    freopen("in", "r", stdin);
    //  freopen("w","w",stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    cin >> s;
    if(judge('S', 'S')) {
        cout << ans << endl;
    } else if(judge('S', 'W')) {
        cout << ans << endl;
    } else if(judge('W', 'W')) {
        cout << ans << endl;
    } else if(judge('W', 'S')) {
        cout << ans << endl;
    } else cout << -1 << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
#define ll long long
using namespace std;
int read()
{
	int k=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) k=k*10+c-'0';return k*f;
}
const int N=1000055;
int n,m,tot,a[N],rt[N],lch[N*30],rch[N*30],sum[N*30];
void add(int &k,int pre,int l,int r,int a,int b)
{
	k=++tot;sum[k]=sum[pre]+b;
	if(l==r) return;
	int mid=l+r>>1;
	if(a<=mid) rch[k]=rch[pre],add(lch[k],lch[pre],l,mid,a,b);
	else lch[k]=lch[pre],add(rch[k],rch[pre],mid+1,r,a,b);
}
int query(int k,int l,int r,int a,int b)
{
	if(!k) return 0;
	if(a<=l&&b>=r) return sum[k];
	int mid=l+r>>1,res=0;
	if(a<=mid) res=query(lch[k],l,mid,a,b);
	if(b>mid) res+=query(rch[k],mid+1,r,a,b);
	return res;
}
map<int,int> mp;
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	for(int i=1;i<=n;i++)
	{
		rt[i]=rt[i-1];
		if(mp[a[i]])
			add(rt[i],rt[i],1,n,mp[a[i]],-1);
		mp[a[i]]=i;
		add(rt[i],rt[i],1,n,mp[a[i]],1);
	}
	for(int i=1;i<=m;i++)
	{
		int l,r;
		l=read();r=read();
		printf("%d\n",query(rt[r],1,n,l,r));
	}
	return 0;
}

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

int main(){

  int N=0;
  
  cin>>N;
  
  int A[N];
  
  rep(i,N){
    cin>>A[i];
    
    if(A[i]%2==0){

      if(A[i]%3==0 || A[i]%5==0)continue;
      else {
        cout<<"DENIED";
        return 0;
      }
    }	
  
  }
 
  cout<<"APPROVED";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    std::ios_base::sync_with_stdio(false);
    //std::cin.tie(nullptr);
    int k,n;
    cin>>k>>n;
    int a[n],t;
    int big=0,ans1=0,ans2=0,dis=0,index=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<n;i++)
    {
        if((a[i]-a[i-1])>dis)
        {
            dis=a[i]-a[i-1];
            index=i;
        }
    }
    ans1=a[n-1]-a[0];
    ans2=(k-a[index])+a[index-1];
    if(ans1<ans2)
        cout<<ans1;
    else
        cout<<ans2;
}


Measured memory_bytes: 1024
// #pragma GCC optimize(2)
// #pragma G++ optimize(2)
// #pragma comment(linker,"/STACK:102400000,102400000")

#include <bits/stdc++.h>
using namespace std;

typedef long long int64;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef float fl;
typedef double dl;
typedef pair<int,int> pii;
#if (WIN32) || (WIN64) || (__WIN32) || (__WIN64) || (_WIN32) || (_WIN64) || (WINDOWS)
#define lld "%I64d"
#define llu "%I64u"
#else
#define lld "%lld"
#define llu "%llu"
#endif
#define uint(n) ((unsigned int)(n))
#define int64(n) ((long long)(n))
#define ull(n) ((unsigned long long)(n))
#define fl(n) ((float)(n))
#define dl(n) ((double)(n))
#define char(n) ((char)(n))
#define Bool(n) ((bool)(n))
#define fixpoint(n) fixed<<setprecision(n)

const int INF=1061109567;
const int NINF=-1044266559;
const int64 LINF=4557430888798830399;
const dl eps=1e-15;
#define MOD (1000000007)
#define PI (3.1415926535897932384626433832795028841971)

#define MP make_pair
#define MT make_tuple
#define All(a) (a).begin(),(a).end()
#define pall(a) (a).rbegin(),(a).rend()
#define Log(x,y) log(x)/log(y)
#define SZ(a) ((int)(a).size())
#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 repd(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define repd1(i,n) for(int i=((int)(n));i>=1;i--)
#define repv(itr,v) for(__typeof((v).begin()) itr=(v).begin();itr!=(v).end();itr++)
#define repV(i,v) for(auto i:v)
#define repE(i,v) for(auto &i:v)
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x) MS(x,0)
#define MINF(x) MS(x,63)
#define MCP(x,y) memcpy(x,y,sizeof(y))
#define UN(v) sort(All(v)),v.erase(unique(All(v)),v.end())
#define filein(x) freopen(x,"r",stdin)
#define fileout(x) freopen(x,"w",stdout)
#define fileio(x)\
	freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout)
#define filein2(filename,name) ifstream name(filename,ios::in)
#define fileout2(filename,name) ofstream name(filename,ios::out)
#define fileio2(filename,name) fstream name(filename,ios::in|ios::out)
#define sqr(x) ((x)*(x))
#define Pause system("pause")
#define Cls system("cls")
#define fs first
#define sc second
#define SF scanf
#define PF printf

const int maxn=INF;

int64 x,d,k;

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

	x=labs(x);

	int64 num=min(x/d,k);
	x-=num*d;
	k-=num;

	if(k%2==0) cout<<x; else cout<<labs(x-d);

	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    vi man(n+1);
    FOR(i,n-1){
        int a; cin >> a;
        man[a]++;
    }
    F0R(i,1,n) cout << man[i] << endl;
    return 0;
}


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


int main()
{
  int n;
  cin >> n;
  vector<ll> x;
  rep(n){
    ll tmp;
    cin >> tmp;
    x.push_back(tmp);
  }
  sort(x.begin(),x.end());
  ll tmp = 0;
  rep(n-1){
    tmp += x[i];
  }
  if(tmp>x[n-1]){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <vector>
typedef long long ll;
using namespace std;

const int N=105;
bool vis[N][N];

void solve(){
	int n;
	scanf("%d",&n);
	int ans;
	if(n&1){
		for(int i=1;i<=n-1;i++){
			vis[i][n-i]=vis[n-i][i]=1;
		}
		ans=n*(n-1)/2-(n-1)/2;
	}
	else{
		for(int i=1;i<=n;i++) vis[i][n+1-i]=vis[n+1-i][i]=1;
		ans=n*(n-1)/2-n/2;
	}
	printf("%d\n",ans);
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(vis[i][j]) continue;
			printf("%d %d\n",i,j);
		}
	}
}

int main(){

	solve();

    return 0;
}

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

using namespace std;

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

	int B = b * 10;
	
	for (int i = B; i < (B + 9); i++)
	{
		if(floor(i * 0.08) == a) {
			cout << i;
			return 0;
		}
	}
	cout << -1;
	return 0;
}


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

#define ll unsigned long long
#define maxval 100005
#define mod 1000000007



int solve(char **arr , int r, int c) {

	int dp[r][c];
	memset(dp, 0, sizeof(dp));

	for (int i = 0; i < c; ++i) {
		if (arr[0][i] == '#') {
			break;
		}
		dp[0][i] = 1;
	}

	for (int i = 0; i < r; ++i) {
		if (arr[i][0] == '#') {
			break;
		}
		dp[i][0] = 1;
	}

	for (int i = 1; i < r; ++i) {
		for (int j = 1; j < c; ++j) {
			if (arr[i][j] == '#') {
				dp[i][j] = 0;
			} else {
				if (arr[i - 1][j] != '#' && arr[i][j - 1] != '#') {
					dp[i][j] = dp[i - 1][j] % mod + dp[i][j - 1] % mod;
					dp[i][j] = dp[i][j] % mod;
				} else if (arr[i][j - 1] == '#') {
					dp[i][j] = dp[i - 1][j];
				} else if (arr[i - 1][j] == '#') {
					dp[i][j] = dp[i][j - 1];
				} else {
					dp[i][j] = 0;
				}
			}
		}
	}


	return dp[r - 1][c - 1];




}



int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int r, c;
	cin >> r >> c;

	char ** arr = new char* [r];
	for (int i = 0; i < r; ++i) {
		arr[i] = new char [c];
		for (int j = 0; j < c; ++j) {
			cin >> arr[i][j];
		}
	}


	cout << solve(arr, r, c) << endl;



	return 0;
}

Measured memory_bytes: 8464
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int h, w;
    cin >> h >> w;
    vector<vector<bool>> maize(h);
    REP(i,h) {
        string s;
        cin >> s;
        REP(j, s.size()) {
            if(s[j]=='#') {
                maize[i].push_back(false);
            }else{
                maize[i].push_back(true);
            }
        }
    }

    int ans = 0;
    REP(i,h)
    REP(j,w)
    REP(k,h)
    REP(l,w) {
        vector<vector<int>> dist(h);
        REP(nn,h) dist[nn].resize(w,-1);
        queue<P> que;
        bool flag = false;
        int tmpans = -1;
        
        auto push = [&] (int nx, int ny, int nd) {
            if(nx < 0 || ny < 0 || nx >= w || ny >= h) return;
            if(dist[ny][nx] != -1 || !(maize[ny][nx])) return;
            que.push(make_pair(nx,ny));
            dist[ny][nx] = nd;
            if(nx == l && ny == k) {
                flag = true;
                tmpans = nd;
            }
        };

        push(j,i,0);
        while(!que.empty()) {
            P tmp = que.front(); que.pop();
            int newx = tmp.first;
            int newy = tmp.second;
            int tmpd = dist[newy][newx];

            push(newx+1, newy, tmpd+1);
            push(newx-1, newy, tmpd+1);
            push(newx, newy+1, tmpd+1);
            push(newx, newy-1, tmpd+1);
            if(flag) {
                break;
            }
        }
        ans = max(ans,tmpans);
    }
    cout  << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    ll N, M;
    //箱がN個
    //鍵がM個
    // i個目の鍵はai円で販売されており
    // bi種類の箱Ci1 to Cibiをあけることができる
    cin >> N >> M;
    vector<ll> a(M), b(M);
    vector<ll> cases(1 << N, INF);
    cases[0] = 0LL;
    vector<ll> c(M);
    REP(i, M) {
        cin >> a[i] >> b[i];
        ll encode = 0;
        REP(j, b[i]) {
            ll k;
            cin >> k;
            k--;
            encode |= 1LL << k;
        }
        c[i] = encode;
        REP(j, 1 << N) {
            cases[encode | j] = min(cases[encode | j], cases[j] + a[i]);
        }
    }
    ll last = 1 << N;
    last--;
    if(cases[last] != INF) {
        cout << cases[last] << endl;
    } else {
        cout << "-1" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

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

    let indices: Vec<_> = (1..=n)
        .permutations(n)
        .enumerate()
        .filter(|(_, v)| {
            v.iter().zip(p.iter()).all(|(v, p)| v == p)
                || v.iter().zip(q.iter()).all(|(v, q)| v == q)
        })
        .map(|(i, _)| i as isize)
        .collect();
    if indices.len() > 1 {
        println!("{}", (indices[0] - indices[1]).abs());
    } else {
        println!("0");
    }
}


Measured memory_bytes: 2192
//In the name of God

#include <bits/stdc++.h>
using namespace std;

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

const int N = 1e5+10 , mod = 1e9+7;

int dp[N][2];
vector <int> g[N];

void dfs(int v , int p){
   int sm[2] = {1 , 1};
   for(int u : g[v])
      if(u != p){
         dfs(u , v);
         sm[0] = 1ll * sm[0] * dp[u][0] % mod;
         sm[1] = 1ll * sm[1] * (dp[u][0] + dp[u][1]) % mod;
      }
   dp[v][0] = sm[1];
   dp[v][1] = sm[0];
}

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   cout << fixed << setprecision(9);
   int n;
   cin >> n;
   for(int i = 0 ; i < n - 1 ; i++){
      int x , y;
      cin >> x >> y;
      x--; y--;
      g[x].push_back(y);
      g[y].push_back(x);
   }
   dfs(0 , 0);
   cout << (dp[0][0] + dp[0][1]) % mod;
   return 0;
}


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

int func(int n, int a) {
    int res = 0;
    while (n > 0) {
        res += n % a;
        n /= a;
    }
    return res;
}

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

    int res = N;
    for (int i = 0; i <= N; i++) {
        int tmp = func(i, 6) + func(N-i, 9);
        res = min(res, tmp);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
S = input()
flg = 0
for i in range(len(S)):
    if (i+1)%2==1:
        if (S[i]=="R") or (S[i]=="U") or (S[i]=="D"):
            flg += 1
    else:
        if (S[i]=="L") or (S[i]=="U") or (S[i]=="D"):
            flg += 1
if flg == len(S):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
import sys

input=sys.stdin.readline
sys.setrecursionlimit(1000000)

N=int(input())
edge={i:[] for i in range(1,N+1)}
for i in range(0,N-1):
    a,b=map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)

K=int(input())
dic={}
for i in range(K):
    v,p=map(int,input().split())
    dic[v]=0
    dic[v]=p

memo={i:[] for i in range(1,N+1)}
flag={i:True for i in range(2,N+1)}
def dfs(num):
    flag[num]=False
    if memo[num]:
        return memo[num]

    if num!=1 and len(edge[num])==1:
        if num in dic.keys():
            memo[num]=[dic[num],dic[num],dic[num]%2]
            return memo[num]
        else:
            memo[num]=[-float("inf"),float("inf"),2]
        return memo[num]

    ansl=-float("inf")
    ansr=float("inf")
    anseo=2
    if num in dic.keys():
        ansl=dic[num]
        ansr=dic[num]
        anseo=dic[num]%2
    for i in edge[num]:
        if flag[i]:
            l,r,eo=dfs(i)
            if eo!=2:
                eo=(eo+1)%2
            if anseo==2:
                ansr=min(ansr,r+1)
                ansl=max(ansl,l-1)
                anseo=eo
                if ansl>ansr:
                    print("No")
                    exit()
            else:
                ansr=min(ansr,r+1)
                ansl=max(ansl,l-1)
                if ansl>ansr or (eo!=2 and eo!=anseo):
                    print("No")
                    exit()

    memo[num]=[ansl,ansr,anseo]
    return memo[num]

l,r,eo=dfs(1)
print("Yes")
ans={i:-float("inf") for i in range(1,N+1)}
flag={i:True for i in range(2,N+1)}
ans[1]=l
flag[1]=False
q=set([(1,ans[1])])
sub=set([])
while q:
    while q:
        node,num=q.pop()
        for i in edge[node]:
            if flag[i]:
                flag[i]=False
                l,r,eo=memo[i]
                if r>=num-1>=l:
                    ans[i]=num-1
                else:
                    ans[i]=num+1
                sub.add((i,ans[i]))

        if not q:
            q=sub
            sub=set([])
            break

for i in range(1,N+1):
    print(ans[i])


Measured memory_bytes: 176484
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ans[15];
int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */  
    ll n,m;
    int k;
    scanf("%lld%lld%d",&n,&m,&k);
    ll total = (n-2)*(m-2);
    int i,j,x,y;
    int x1,x2,y1,y2;
    set< pair<int,int> > ss;
    map< pair< pair<int,int> , pair<int,int> >,int > rect;
    for(i=0;i<k;i++)
        {
        scanf("%d%d",&x,&y);
      //  printf("%d %d is included in\n",x,y);
        ss.insert(make_pair(x,y));
        int mix = max(x-2,1);
        int miy = max(y-2,1);
        for(x1 = mix; x1 <= x; x1++)
            {
            for(y1 = miy; y1<=y; y1++)
                {
                x2 = x1 + 2;
                y2 = y1 + 2;
                if(x2<=n && y2<=m)
                    {
                  //  printf("rectangel %d %d %d %d\n",x1,y1,x2,y2);
                    rect[make_pair(make_pair(x1,y1),make_pair(x2,y2))]++;
                }
            }
        }
    }
    map< pair< pair<int,int> , pair<int,int> >,int >::iterator I;
    ans[0] = total;
    for(I = rect.begin(); I!=rect.end();I++)
        {
       // sum++;
        ans[I->second]++;
        ans[0]--;
    }
    for(i=0;i<10;i++)
        printf("%lld\n",ans[i]);
    return 0;
}


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

int main() {
	vector<bool> sieve(100010, true);
 	for(int i=2; i*i< 100010; i++){
 		if(sieve[i] == true){
 			for(int j=i*i; j<(100010); j+=i){
 				sieve[j] = false;
 			}
 		}
 	}
 	
 	vector<int> sieve2;
 	for(int i=2; i<100010; i++){
 		if(sieve[i]) sieve2.emplace_back(i);
 	}
 	
 	int n;
 	cin >> n; 
 	cout << sieve2[lower_bound(sieve2.begin(), sieve2.end(), n) - sieve2.begin()];
}

Measured memory_bytes: 384
def give_grade(m, f, r):
    if m == -1 or f == -1:
        return "F"
    elif m + f < 30:
        return "F"
    elif m + f < 50:
        return "D" if r < 50 else "C"
    elif m + f < 65:
        return "C"
    elif m + f < 80:
        return "B"
    else:
        return "A"

while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break
    else:
        print(give_grade(m, f, r))

Measured memory_bytes: 7712
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll N;
  cin >> N;
  ll x=26,y=1;
  while(x<N){
    y++;
    x=26*(((ll)pow(26,y)-1)/25);
    if(y==12&&x<N){
      y++;
      break;
    }
  }
  vector<char> A(y);
  ll z=y;
  ll i=0;
  N-=26*(((ll)pow(26,y-1)-1)/25);
  while(y>0){
    if(y!=1){
      A.at(i)=(N-1)/(ll)pow(26,y-1)+'a';
      N=(N-1)%(ll)pow(26,y-1)+1;
      
    }else{
      A.at(i)=N/(ll)pow(26,y-1)+'a'-1;
    }
    y--;
    i++;
  }
  rep(j,z){
    cout << A.at(j);
  }
  cout << endl;
}


Measured memory_bytes: 4036
#[allow(dead_code)]
fn main() {
    let (n, k) = i::u2();
    let a = i::uv(n);
    const M: usize = 1_000_000_007;

    let mut all = vec![0; n];
    let mut after = vec![0; n];
    for i in 0..n {
        for j in 0..n {
            if a[i] > a[j] {
                all[i] += 1;
                if i < j {
                    after[i] += 1;
                }
            }
        }
    }
    let mut ans = 0usize;
    for i in 0..n {
        ans = (ans + after[i] * k + all[i] * (k * (k - 1) / 2 % M)) % M;
    }
    println!("{}", ans);
    //dbg!(all, after);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    int A, B;
    cin >> A >> B;
    if(A + B >= 10){
        cout << "error" << endl;
    }else{
        cout << A + B << endl;
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> V(N);
  for(int i=0;i<N;i++){
    cin >> V.at(i);
  }
  sort(V.begin(),V.end());
  double cost=V.at(0);
  for(int j=1;j<N;j++){
    cost = (cost + V.at(j))*0.5;
  }
  
  cout << setprecision(20) << cost << endl;
}


Measured memory_bytes: 256
import sys
N,M=map(int,sys.stdin.readline().split())
E=N;c=[0]*300000;l=[0]*300000
A=list(map(int,sys.stdin.readline().split()))
def Z(e):
	global E
	p=e-c[e]
	c[e]+=1
	if p>0:
		if not l[p]: E-=1
		l[p]+=1
for e in A:Z(e)
A=[0]+A
for m in range(M):
	x,y=map(int,sys.stdin.readline().split())
	p=A[x]-c[A[x]]+1
	c[A[x]]-=1
	if p>0:
		l[p]-=1
		if not l[p]: E+=1
	A[x]=y
	Z(A[x])
	print(E)

Measured memory_bytes: 56420
import java.util.Scanner;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> l = new ArrayList<>();
        int max = 0;
        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            max = Math.max(max, num);
            l.add(num);
        }

        int sum = 0;
        for (int x : l) {
            sum += x;
        }
        sum -= max;
        if (max < sum) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}


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


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

	long long val[n];
	long long  wt[n];

	for(int i=0;i<n;i++){
		cin>>wt[i]>>val[i];
	}
	// cout<<"--"<<endl;
	long long dp[n+1][w+1] = {0};

	for(int i=0;i<n+1;i++){
		for(int j = 0;j<w+1;j++){
			if(i==0||j==0){
				dp[i][j] = 0;
			}
			else if(wt[i-1] > j){
				dp[i][j] = dp[i-1][j];
			}
			else{
				dp[i][j] = max(val[i-1]+dp[i-1][j-wt[i-1]] , dp[i-1][j]);
			}
		}
	}
	// cout<<"--"<<endl;
	cout<<dp[n][w]<<endl;
}

Measured memory_bytes: 79104
k=int(input())

q=["1","2","3","4","5","6","7","8","9"]
x=9
for i in q:
    if x>100000:
        break
    x+=1
    a=i[-1]
    for j in ([-1,0,1]):
        bb=int(a)+j
        if bb<10 and bb>=0:
            q.append(i+str(bb))


print(q[k-1])

Measured memory_bytes: 29752
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			StringTokenizer tok = new StringTokenizer(br.readLine());
			final int h = Integer.parseInt(tok.nextToken());
			final int w = Integer.parseInt(tok.nextToken());
			final int n = Integer.parseInt(tok.nextToken());
			
			if(h == 0 && w == 0 && n == 0){
				break;
			}
			
			boolean[][] map = new boolean[h][w];
			
			for(int i = 0; i < h; i++){
				StringTokenizer tok2 = new StringTokenizer(br.readLine());
				
				for(int j = 0; j < w; j++){
					map[i][j] = tok2.nextToken().equals("1");
				}
			}
			
			int[][] dp = new int[h][w];
			dp[0][0] = n - 1;
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					if(dp[i][j] % 2 == 0){
						if(i != h-1){
							dp[i+1][j] += dp[i][j] / 2;
						}
						if(j != w-1){
							dp[i][j+1] += dp[i][j] / 2;
						}
					}else{
						if(i != h-1){
							dp[i+1][j] += dp[i][j] / 2 + (map[i][j] ? 0 : 1);
						}
						if(j != w-1){
							dp[i][j+1] += dp[i][j] / 2 + (map[i][j] ? 1 : 0);
						}
					}
				}
			}
			
			/*
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					System.out.print(dp[i][j] + " ");
				}
				System.out.println();
			}
			
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					System.out.print((dp[i][j] % 2 == 0 ? map[i][j] : !map[i][j]) + " ");
				}
				System.out.println();
			}
			*/
						
			int cur_x = 0;
			int cur_y = 0;
			
			while(cur_x != w && cur_y != h){
				if(dp[cur_y][cur_x] % 2 == 0){
					int n_x, n_y;
					n_x = cur_x + (map[cur_y][cur_x] ? 1 : 0);
					n_y = cur_y + (map[cur_y][cur_x] ? 0 : 1);
					cur_x = n_x;
					cur_y = n_y;
				}else{
					int n_x, n_y;
					n_x = cur_x + (map[cur_y][cur_x] ? 0 : 1);
					n_y = cur_y + (map[cur_y][cur_x] ? 1 : 0);
					cur_x = n_x;
					cur_y = n_y;
				}
			}
			
			System.out.println((cur_y + 1) + " " + (cur_x + 1));
		}
		
	}

}

Measured memory_bytes: 16000
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    int n, w[100] = {}, s = 10000;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> w[i];
    }
    for (int k = 0; k < n; k++) {
        int m = 0;
        for (int i = 0; i < n;i++) {
            if (i<=k) m += w[i];
            else m -= w[i];
        }
        if (s > abs(m)) s = abs(m);
    }
    cout << s << endl;
}

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

using namespace std;

int max1(int a , int b)
{
    if(a < b)
        return a;
    return b;    
}

int main()
{
    int N, x;
    vector<int> h;

    cin >> N;
    vector<int> dp(N);

    for(int i =0; i<N;i++)
    {
        cin >>x ;
        h.push_back(x);
    }

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

    for(int i=2; i<N; i++)
        dp[i] = max1( dp[i-1]+abs(h[i]-h[i-1]) , dp[i-2]+abs(h[i]-h[i-2]) );

    cout << dp[N-1] << endl;

}

Measured memory_bytes: 1276
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4") // wonderful

// https://leetcode.com/problems/count-complete-tree-nodes/
#include <bits/stdc++.h>
using namespace std;


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

	int a, b, c;
	cin >> a >> b;
  	c = (a * b);
  	cout << c;
    return 0;
}

Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    D, G = map(int, input().split())
    P, C = [0] * D, [0] * D
    for i in range(D):
        P[i], C[i] = map(int, input().split())
    ans = 10**10

    # 昇順での探索だよ
    for i in range(2 ** D):
        checked = [False]*D
        pnt = 0
        cnt = 0

        for j in range(D):  # このループが一番のポイント
            if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
                pnt += C[j]
                pnt += P[j]*(j+1)*100
                checked[j] = True
                cnt += P[j]
        if pnt < G:
            for k in reversed(range(D)):
                if not checked[k]:
                    prob_cnt = 0
                    br_fl = False

                    while prob_cnt < P[k]-1:
                        pnt += (k+1)*100
                        cnt += 1
                        prob_cnt += 1
                        if pnt >= G:
                            br_fl = True
                            break
                    if br_fl:
                        break
        if pnt >= G:
            ans = min(ans, cnt)

    print(ans)


resolve()

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<double,double> P;
typedef pair<P,ll> PP;

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

const int MAX=(1LL<<31)-1;

struct SegmentTree {
	int m;
	vector<int> node;

	SegmentTree(int sz) {
		m=1;while(m<sz) m*=2;
		node.resize(m*2-1,MAX);
	}

	void update(int x,int y) {
		x+=m-1;
		node[x]=y;
		while(x>0) {
			x=(x-1)/2;
			node[x]=min(node[x*2+1],node[x*2+2]);
		}
	}

	int find(int a,int b,int k,int l,int r=-1) {
		if(r==-1) r=m;
		if(b<=l||r<=a) return MAX;
		if(a<=l&&r<=b) return node[k];
		return min(find(a,b,k*2+1,l,(l+r)/2),find(a,b,k*2+2,(l+r)/2,r));
	}
};

int n,q;

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

	cin>>n>>q;
	SegmentTree seg(n);
	REP(i,q) {
		int type,x,y;cin>>type>>x>>y;
		if(type==0) {
			seg.update(x,y);
		}
		else {
			cout<<seg.find(x,y+1,0,0)<<endl;
		}
		//REP(i,2*n-1) cout<<seg.node[i]<<' ';
		//cout<<endl;
	}

	return 0;
}



Measured memory_bytes: 3820
n = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))

ans = 0
v = 10000000
for i in range(n):
    if v>=abs(A - (T-0.006*H[i])):
        ans = i + 1
        v = abs(A - (T-0.006*H[i]))
print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int X, Y;
    cin >> X >> Y;

    for (int i = 0; i <= X; i++)
    {
        if (X + Y == 5 * i + 3 * (X - i))
        {
            cout << "Yes" << endl;
            return 0;
        }

    }
    
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main(void)
{	
	int score,sum = 0;
	while (cin >> score)
	{
		if (score < 40)
		{
			sum += 40;
		}
		else
		{
			sum += score;
		}
	}
	cout << sum / 5 << endl;

}

Measured memory_bytes: 1160
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

vector<int> dy(4), dx(4);
vector<vector<bool> > check(4, vector<bool>(4, false));

int solve(int y0, int x0){
    if(y0 == 4)
        return 1;
    if(x0 == 4)
        return solve(y0+1, 0);
    if(check[y0][x0])
        return solve(y0, x0+1);

    check[y0][x0] = true;

    int ret = 0;
    for(int i=0; i<4; ++i){
        int y1 = y0 + dy[i];
        int x1 = x0 + dx[i];
        if(y1 >= 4 || x1 < 0 || x1 >= 4 || check[y1][x1])
            continue;
        check[y1][x1] = true;
        ret += solve(y0, x0+1);
        check[y1][x1] = false;
    }

    check[y0][x0] = false;
    return ret;
}

int main()
{
    for(;;){
        for(int i=0; i<4; ++i)
            cin >> dx[i] >> dy[i];
        if(dx[0] > 4)
            return 0;

        cout << solve(0, 0) << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    vector<int64_t> lucas = {2, 1};
    int64_t count = 1;


    for (int i = 0; i < 86; i++) {
        if(n == 1) {
            cout << count;
            break;
        }
        
        lucas.push_back(lucas[i + 1] + lucas[i]);
        count++;

        if(count == n) {
            cout << lucas[i + 2];
            break;
        }
    }
}

Measured memory_bytes: 256
N = int(input())
ps = [tuple(map(int,input().split() + [i//N])) for i in range(2*N)]
ans = 0
unused_red_y = []
for x,y,c in sorted(ps):
    if c == 0:
        unused_red_y.append(y)
    else:
        found_i = found_ry = -1
        for i,ry in enumerate(unused_red_y):
            if ry > y: continue
            if found_ry < ry:
                found_ry = ry
                found_i = i
        if found_i >= 0:
            unused_red_y.pop(found_i)
            ans += 1
print(ans)        


Measured memory_bytes: 3064
import math

DELTA = 1e-10

def readnums():
    return raw_input().split()

def cross(v1,v2):
    return v1[0]*v2[1]-v1[1]*v2[0]

[n] = readnums()
for i in range(0,int(n)):
    [xa,ya,xb,yb,xc,yc,xd,yd] = map(float,readnums())
    vab = (xb-xa,yb-ya)
    vcd = (xd-xc,yd-yc)
    prod = cross(vab,vcd)
    if math.fabs(prod) < DELTA:
        print "YES"
    else:
        print "NO"

Measured memory_bytes: 4392
#include <iostream>
#include <cmath>
using namespace std;
 
int main(void) {
  long X;
  long deposit = 100;
  long duration = 0;
  long gain;
  
  cin >> X;
  
  while (deposit < X) {
    duration = duration + 1;
    gain = floor(deposit * 0.01);
    deposit = deposit + gain;
  }
  
  cout << duration << endl;
}

Measured memory_bytes: 3744
import java.util.Scanner;

public class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        System.out.println((sc.nextInt() * 100 + sc.nextInt() * 10 + sc.nextInt()) % 4 == 0 ? "YES" : "NO");
    }
}

Measured memory_bytes: 21204
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

S = input()
bs = -1
for s in S:
    if s == bs:
        print('Bad')
        break
    bs = s
else:
    print('Good')


Measured memory_bytes: 4336