akhauriyash/Code-Regression huggingface dataset:
/*
Problem : atcoder 084D
Algorithm : dijkstra
Status :
*/
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

int n,len;
int head[MAXN],dis[MAXN],vis[MAXN];
priority_queue<pii,vector<pii>,greater<pii> > q;

struct Edge{
	int to,next,w;
} e[MAXN * 2];

void add(int u,int v,int w){
	e[++len].to = v;
	e[len].next = head[u];
	e[len].w = w;
	head[u] = len;
}

int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    memset(head,-1,sizeof(head));
	scanf("%d",&n);
	for(int i = 0;i < n;i++){
		add(i,(i + 1) % n,1);
		add(i,i * 10 % n,0);
		dis[i] = INF;
	}
	dis[1] = 1;
	q.push(make_pair(0,1));
	while(!q.empty()){
		int u = q.top().second;
		q.pop();
		if(vis[u])
		    continue;
		vis[u] = true;
		for(int i = head[u];i != -1;i = e[i].next){
			int v = e[i].to;
			if(dis[v] > dis[u] + e[i].w){
				dis[v] = dis[u] + e[i].w;
				q.push(make_pair(dis[v],v));
			}
		}
	}
	printf("%d\n",dis[0]);
	return 0;
}



Measured memory_bytes: 4348
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    while (true) {
        val n = sc.nextInt()
        if (n == 0) break
        var total: Long = 0
        var ans: Long = -100000
        for (i in 1..n) {
            val m = sc.nextLong()
            total = Math.max(total+m, m)
            ans = Math.max(ans, total)
        }
        println(ans)
    }
}


Measured memory_bytes: 34968
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;

int main()
{
    int d;
    scanf("%d",&d);
    if(d==25)printf("Christmas\n");
    if(d==24)printf("Christmas Eve\n");
    if(d==23)printf("Christmas Eve Eve\n");
    if(d==22)printf("Christmas Eve Eve Eve\n");
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	void run() throws IOException {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int W = sc.nextInt();
			int H = sc.nextInt();
			if (W == 0 && H == 0)
				break;
			char[][] map = new char[H][W];
			for (int i = 0; i < H; ++i) {
				map[i] = sc.next().toCharArray();
			}
			int Ax = -1, Ay = -1;
			int Qx = -1, Qy = -1;
			for (int i = 0; i < H; ++i) {
				for (int j = 0; j < W; ++j) {
					if (map[i][j] == 'A') {
						Ay = i;
						Ax = j;
					} else if (map[i][j] == 'Q') {
						Qy = i;
						Qx = j;
					}
				}
			}
			int[][][] memo = new int[H * W][H * W][2];

			for (int q = 0; q < H * W; ++q) {
				if (!valid(q, map, H, W))
					continue;
				for (int a = 0; a < H * W; ++a) {
					if (!valid(a, map, H, W))
						continue;
					for (int t = 0; t < 2; ++t) {
						if (q == a) {
							memo[q][a][t] = -1;// Q?????????
						} else if (t == 0 && map[q / W][q % W] == 'E') {
							memo[q][a][t] = 1;// Q?????????
						}
					}
				}
			}
			int[] d = { 0, W, -W, 1, -1 };

			for (boolean update = true; update;) {
				update = false;
				for (int q = 0; q < H * W; ++q) {
					if (!valid(q, map, H, W))
						continue;
					for (int a = 0; a < H * W; ++a) {
						if (!valid(a, map, H, W))
							continue;
						for (int t = 0; t < 2; ++t) {
							if (memo[q][a][t] != 0) {
								continue;
							}
							int v = (t == 0 ? -999 : 999);
							for (int i = 0; i < 5; ++i) {
								int na = a, nq = q;
								if (t == 0)
									nq += d[i];
								else
									na += d[i];
								if ((t == 1 && !valid(a, d[i], map, H, W)) || (t == 0 && !valid(q, d[i], map, H, W)))
									continue;
								if (t == 0) {
									v = Math.max(v, memo[nq][na][t ^ 1]);
								} else {
									v = Math.min(v, memo[nq][na][t ^ 1]);
								}
							}
							if (v != 0) {
								memo[q][a][t] = v;
								update = true;
							}
						}
					}
				}

			}
			int Q = Qy * W + Qx;
			int A = Ay * W + Ax;
			if (memo[Q][A][0] == 0) {
				System.out.println("Queen can not escape and Army can not catch Queen.");
			} else if (memo[Q][A][0] == -1) {
				System.out.println("Army can catch Queen.");
			} else if (memo[Q][A][0] == 1) {
				System.out.println("Queen can escape.");
			}
		}

	}

	boolean valid(int a, int d, char[][] map, int H, int W) {
		if (!valid(a, map, H, W) || !valid(a + d, map, H, W)) {
			return false;
		}
		int h = a / W;
		int w = a % W;
		int nh = (a + d) / W;
		int nw = (a + d) % W;
		if (Math.abs(nh - h) + Math.abs(nw - w) <= 1) {
			return true;
		} else {
			return false;
		}
	}

	boolean valid(int a, char[][] map, int H, int W) {
		if (a < 0 || a >= H * W)
			return false;
		int h = a / W;
		int w = a % W;
		if (map[h][w] == '#')
			return false;
		return true;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 75776
import qualified Data.Vector.Unboxed as V
main=print.solve=<<readLn
solve n=g 4+g 3*(g 0-1)+g 2*(g 1-1)+(g 1*(g 1-1)`div`2)*(g 0-2)where
  g i=ks V.! i
  ks=V.fromList$map(\i->V.length$V.filter(>=i)vs)([2,4,14,24,74]::[Int])
  vs=V.accum(+)(V.replicate(n+1)0).(`zip`repeat 1)$concatMap(f 2)[2..n]
f k i
  |k*k>i=[i]
  |r==0=k:f k j
  |otherwise=f(k+1)i
  where(j,r)=divMod i k

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

using namespace std;

long long dfs(string str, int cursor) {
	if(cursor == str.size()) {
		long long ret = 0;
		long long tmp = 0;
		for(int i = 0; i < str.size(); i++) {
			if(str[i] == '+') {
				ret += tmp;
				tmp = 0;
			} else {
				tmp *= 10;
				tmp += str[i] - '0';
			}
		}
		ret += tmp;
		return ret;
	}
	
	long long ret1 = dfs(str, cursor + 1);
	str.insert(str.begin() + cursor, '+');
	long long ret2 = dfs(str, cursor + 2);
	return ret1 + ret2;
}

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


	cout << dfs(S, 1) << endl;

	return 0;
}

Measured memory_bytes: 256
a, b, c = [int(i) for i in input().split()]
# a*b*cの直方体を2分割する場合を考えればよい

minDiff = a * b * c
minDiff = min(minDiff, abs(int(a/2)*b*c - (a-int(a/2))*b*c))
minDiff = min(minDiff, abs(int(b/2)*c*a - (b-int(b/2))*c*a))
minDiff = min(minDiff, abs(int(c/2)*a*b - (c-int(c/2))*a*b))
print(minDiff)

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
mod = 92709568269121

N = int(input())

def factrial(N):
    fc = [1, 1] + [None] * N
    inv = [0, 1] + [None] * N
    fcInv = [1, 1] + [None] * N
    for i in range(2, N+1):
        fc[i] = i*fc[i-1]%mod
        inv[i] = mod-(inv[mod%i]*(mod//i))%mod
        fcInv[i] = fcInv[i-1]*inv[i]%mod
    return fc, fcInv
fc, fcInv = factrial(N+1)

def modCom(n, k):
    return 0 if n < k else fc[n] * fcInv[k] * fcInv[n-k] % mod

A = [int(x) for x in input().split()]
C = Counter(A)
X = 0
dic1 = defaultdict(int)
dic2 = defaultdict(int)
for x in C.keys():
    dic1[x] = modCom(C[x], 2)
    dic2[x] = modCom(C[x]-1, 2)
    X = X + dic1[x]
for x in A:
    print(X - dic1[x] + dic2[x])


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

using namespace std;

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if (-a + b <= 0) {
        cout << "delicious" << endl;
    } else if (-a + b <= x) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++)
      a[i] = sc.nextInt();
    sc.close();

    long[][] memo = new long[N][N];
    long ans = fN(memo, a, 0, N - 1);
    System.out.println(ans);
  }

  private static long fN(long[][] memo, int[] a, int l, int r) {
    if (memo[l][r] != 0) return memo[l][r];
    if (l == r) return 0;
    long min = Long.MAX_VALUE;
    long sum = a[r];
    for (int i = l; i < r; i++) {
      min = Long.min(min, fN(memo, a, l, i) + fN(memo, a, i + 1, r));
      sum += a[i];
    }
    memo[l][r] = sum + min;
    return memo[l][r];
  }
}

Measured memory_bytes: 24532
#include <stdio.h>
int main(void)
{
	int a,b,c,d;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b){
		d=c;
	}else if(a==c){
		d=b;
	}else if(b==c){
		d=a;
	}
	printf("%d\n",d);
	return 0;
}

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

int main() {
	
	int n;
	cin>>n;
	int arr[n],temp=10001;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	
	int cnt=0;
	for(int i=0;i<n-1;i++)
	{
		if(arr[i]==arr[i+1])
		{
			arr[i+1]=temp;
			cnt++;
			temp++;
		}
		
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input());
A = list(map(int, input().split()));

ans = 0;
min_ = 2 * (10 ** 5);

for i in range(n):
  min_ = min(A[i], min_);
  if min_ == A[i]:
    ans += 1;
  else:
    pass;
print(ans);

Measured memory_bytes: 24744
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

LL node[500002] = {0};
vector<vector<PLL>> link(500002);

void f(LL i, int color, LL w){
    if(node[i]!=-1)return;

    if(w % 2 == 1){
        color = (color + 1)%2;
    }
    node[i] = color;

    EACH(itr, link[i]){
        f(itr->first, color, itr->second);
    }
}


int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n;
    cin>>n;
    REP(i,500002)node[i]=-1;

    REP(i,n-1){
        LL u,v,w;
        cin>>u>>v>>w;
        link[u].PB(MP(v,w));
        link[v].PB(MP(u,w));
    }
    f(1, 0, 0);
    REP(i,n){
        PUTS(node[i+1]);
    }
}

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

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 1e9;
    rep(si, s.size()) {
        if (si + t.size() > s.size()) break;
        int cnt = 0;
        rep(i, t.size()) {
            if (s[si+i] != t[i]) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
k = io.read("*n")

if k % 2 == 0 then
  print(-1)
  return
end

sevens = 7
step = 1

while sevens % k ~= 0 do
  if step > 10 ^ 6 then
    step = -1
    break
  end

  sevens = sevens * 10 + 7
  sevens = sevens % k
  step = step + 1
end

print(step)


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

int main(){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  
  string ans = "", up = "", down = "", left = "", right = "";
  for(int i = 0; i < ty - sy; i++){
    up += 'U';
    down += 'D';
  }
  for(int i = 0; i < tx - sx; i++){
    left += 'L';
    right += 'R';
  }
  
  ans += up + right + down + left + 'L' + 'U' + up + 'R' + right + 'D';
  ans += "RD" + down + left + "LU";
  
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
typedef long long ll;

using namespace std;
struct A
{
    int i;
    int s;
};
A a[100000];
int cmp(A a, A b)
{
    return a.i < b.i;
}
int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i].i >> a[i].s;
    }
    sort(a, a+n, cmp);
    int ans = 0;
    ans += a[n-1].s+a[n-1].i;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

long long int gcd(long long int a, long long int b){
	while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

int main()
{
	long long int a, b, c, d;
	cin >> a >> b >> c;
	cin >> d;

	long long int g = c * d / gcd(c, d);
	long long int countc = 0;
	long long int countd = 0;
	long long int countg = 0;


	if(a%c != 0 && b%c != 0){
		countc = b/c - a/c - 1 + 1;
	}else if(b%c != 0 && a%c == 0){
		countc = b/c - a/c + 1;
	}else if(b%c == 0 && a%c != 0){
		countc = b/c - a/c - 1 + 1;
	}else{
		countc = b/c - a/c + 1;
	}

	if(a%d != 0 && b%d != 0){
		countd = b/d - a/d - 1 + 1;
	}else if(b%d != 0 && a%d == 0){
		countd = b/d - a/d + 1;
	}else if(b%d == 0 && a%d != 0){
		countd = b/d - a/d - 1 + 1;
	}else{
		countd = b/d - a/d + 1;
	}

	if(a%g != 0 && b%g != 0){
		countg = b/g - a/g - 1 + 1;
	}else if(b%g != 0 && a%g == 0){
		countg = b/g - a/g + 1;
	}else if(b%g == 0 && a%g != 0){
		countg = b/g - a/g - 1 + 1;
	}else{
		countg = b/g - a/g + 1;
	}

	cout << (b-a+1) - (countc + countd - countg) << endl;

}



Measured memory_bytes: 256
/*input
1000000
*/
#include <bits/stdc++.h>
#define pii pair<int, int>
#define F first
#define S second
#define int long long
using namespace std;
vector<pii> G[30];
int cnt[100];
main () {
	int l; cin >> l;
// int tt = l;
// 	while(tt) {
// 		cout << tt % 2;
// 		tt /= 2;
// 	}
// 	cout << endl;
	int ss = 0;
	if(l > pow(2, 19)) {
		//cout << "Ue";
		for(int i = 19; i > 0; i --) {
			if(l & (1 << i));
			else {
				ss = i;
				//cout << ss << endl;
				break;
			}
		}
	}
	cnt[19] = 2;
	cnt[20] = 1;
	G[19].push_back({20, 0});
	G[19].push_back({20, 1});
	int m = 2, p = 18, tt = 1;
	for(int i = 4; i <= l; i <<= 1) {
		G[p].push_back({p + 1, 0});
		G[p].push_back({p + 1, i / 2 * tt});
		if(i == (1 << ss)) {
			G[p].push_back({p + 1, i});
			G[p].push_back({p + 1, i + i / 2});
			i <<= 1;
			cnt[p] = i;
			m += 4;
			p --;
			//tt <<= 1;
			//i <<= 1;
		}
		else {
			cnt[p] = i;
			p --;
			m += 2;
		}
	}
	//cout << p << endl;
	if(G[1].empty()) {
		int cur = 0;
		for(int i = p + 1; i <= 20; i ++) {
			if(l & cnt[i]) {
				G[1].push_back({i, cur});
				cur += cnt[i];
				m ++;
			}
		}
		//cout << cur << endl;
	}
	cout << 20 << ' ' << m << endl;
	for(int i = 1; i <= 20; i ++) {
		for(auto it: G[i]) cout << i << ' ' << it.F << ' ' << it.S << endl;
	}
}

Measured memory_bytes: 256
/*
ID: usaco.t3
TASK: test
LANG: C++14
*/

#pragma GCC optimize ("O3")
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define pii pair<intt,intt>
#define vi vector<intt>
#define vii vector<pii>

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define IO ios_base::sync_with_stdio(false);cin.tie();
#define endl '\n'

#define wtfis(x) cerr << "at line " << __LINE__ << ": " << #x << " = " << (x) << endl

const intt max3 = 1003;
const intt max4 = 10004;
const intt maxx = 200005;
const intt max6 = 1000006;
const intt max7 = 10000007;

const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;

const intt INF = 2LL * 1000000000;
const intt INFLL = 9LL * 1000000000 * 1000000000;
/***************/

intt powmod (intt a, intt b, intt mod) {
    intt res = 1;
    a %= mod;
    for (; b; b >>= 1) {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

intt gcd (intt a, intt b) {
    while (b > 0) {
        intt t = a % b;
        a = b, b = t;
    }
    return a;
}

intt lcm (intt a, intt b) {
    return (a / gcd (a, b)) * b;
}

intt is_prime (intt n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (intt i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/**************************/

string s, tmp;

intt check (intt x) {
    s = tmp;
    intt ok = 0;
    for (intt i = 0; i + x - 1 < s.size(); i++) {
        if ((s[i] - 48) ^ ok) {
            ok ^= 1;
        }
        s[i] = '0';
    }
    if (ok == 1) {
        for (intt i = s.size() - x + 1; i < s.size(); i++) {
            s[i] = char (1 - (s[i] - 48) + 48);
        }
    }
    ok = 0;
    for (intt i = s.size() - 1; i - x + 1 >= 0; i--) {
        if ((s[i] - 48) ^ ok) {
            ok ^= 1;
        }
        s[i] = '0';
    }
    if (ok == 1) {
        for (intt i = s.size() - x + 1; i < s.size(); i++) {
            s[i] = char (1 - (s[i] - 48) + 48);
        }
    }
    for (intt i = 0; i < s.size(); i++) {
        if (s[i] == '1') {
            return 0;
        }
    }
    return 1;
}

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    IO;
    string s;
    cin >> s;
    tmp = s;
    intt l = 1, r = s.size(), best;
    while (r - l >= 0) {
        intt mid = (l + r) >> 1;
        if (check (mid) == 1) {
            best = mid;
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }
    cout << best << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int k,n;
double p[N];
double acm[N];
double sm(int p) {
	return (p * (p + 1)) / 2;
}
int main() {
	cin>>n>>k;
	for(int i = 1; i <= n; ++i) cin>>p[i];
	double temp = 0.0f;
	for(int i = 1; i < k; ++i) {
		acm[i] = sm(p[i]) * 1.0f / p[i];
		temp += acm[i];
	}
	double ans = 0;
	for(int i = k; i <= n; ++i) {
		temp -= acm[i - k];
		acm[i] = sm(p[i]) * 1.0f / p[i];
		temp += acm[i];
		ans = max(ans, temp);
	}
	printf("%.15lf\n", ans);
	return 0;
}


Measured memory_bytes: 3328
//In The Name of Allah
#include <bits/stdc++.h>

using namespace std;

const int N = 50 + 10;

int a[N];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, t;
    cin >> n >> t;
    for (int i = 1; i <= n; i ++)
        cin >> a[i];
    int ans = 0;
    for (int i = 0; i <= n; i ++){
        for (int j = n + 1; j > i; j --){
            if (t < i + n + 1 - j)
                continue;
            int res = 0;
            vector < int > vec;
            for (int k = 1; k <= i; k ++)
                vec.push_back(a[k]), res += a[k];
            for (int k = n; k >= j; k --)
                vec.push_back(a[k]), res += a[k];
            sort(vec.begin(), vec.end());
            for (int k = 0; k < min((int)(vec.size()), t - i - n - 1 + j); k ++)
                if (vec[k] < 0)
                    res -= vec[k];
            ans = max(ans, res);
        }
    }
    cout << ans;
    return 0;
}

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

int main() {
	
	string a,b;
	cin>>a>>b;
	a=a+b;
	lint num=0;
	int i;
	int j=a.size()-1;
	for(i=0;i<a.size();i++)
	{
	        int val=a[i]-'0';
	        num=num*10+val;
	        
	}
	if(sqrt(num)==(lint )sqrt(num))
	{
	        cout<<"Yes";
	}
	else
	cout<<"No";
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main()
{
	ll N, M;
	cin >> N >> M;

	ll a, b;
	map<ll, ll> mp;
	for (int i = 0; i < M; i++)
	{
		cin >> a >> b;

		if (a == 1 || b == 1)
		{
			if (a == 1)
			{
				mp[b]++;
			}
			else {
				mp[a]++;
			}
		}
		if (a == N || b == N)
		{
			if (a == N)
			{
				mp[b]++;
			}
			else {
				mp[a]++;
			}
		}
	}
	for (map<ll, ll>::iterator it = mp.begin(); it != mp.end(); it++)
	{
		if (it->second >= 2)
		{
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;

	return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    if ((A * B) % 2 == 0){
        cout << "No" << endl;
    }
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))
h.insert(0,0)
ab=[]
for _ in range(m):
    ab.append(list(map(int,input().split())))
good=[0]+[1]*n
for i in range(m):
    if h[ab[i][0]]==h[ab[i][1]]:
        good[ab[i][0]]=0
        good[ab[i][1]]=0
    elif h[ab[i][0]]<=h[ab[i][1]]:
        good[ab[i][0]]=0
    elif h[ab[i][0]]>=h[ab[i][1]]:
        good[ab[i][1]]=0
print(sum(good))

Measured memory_bytes: 32816
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

ll dp[110][5][2][2];

int main() {
    string s; cin >> s;
    int N = s.size();
    int K; cin >> K;
    
    const int MAX = 4;
    dp[0][0][0][0] = 1;
    for(int i=0; i<N; i++) {
        for(int j=0; j<=MAX; j++) {
            for(int f=0; f<2; f++) {
                for(int l=0; l<2; l++) {
                    // if(dp[i][j][f][l] != 0) fprintf(stderr, "dp[%d][%d][%d][%d] = %lld\n", i, j, f, l, dp[i][j][f][l]);
                    int lim = f ? 9 : s[i] - '0';
                    for(int x=0; x<=lim; x++) {
                        int nj = min(MAX, j + (x != 0));
                        int nf = f || (x < lim);
                        int nl = l || (x != 0);
                        dp[i+1][nj][nf][nl] += dp[i][j][f][l];
                        chmin(dp[i+1][nj][nf][nl], LONGINF);
                    }
                }
            }
        }
    }

    ll ans = dp[N][K][0][1] + dp[N][K][1][1];
    cout << ans << endl;
    return 0;
}


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

#define lol long long

int main() {

	vector<lol> a;
	lol n,input;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> input;
		a.emplace_back(input);
	}

	lol ans = 0;
	for (int i = 0; i < n; i++) {
		ans += a[i] - 1;
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 256
a, b, k = map(int, input().split())
if a != b:
  if k == 0:
    print(a, b, sep='\n')
    exit()
else:
  print(a)
  exit()
for i in range(a, min(b,a+k)):
  print(i)
for j in range(max(i,b-k)+1,b+1):
  print(j)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class AEatingSymbolsEasy {
public:
	void solve(istream& in, ostream& out) {
        string s; in >> s;
        int ans = 0;
        rep(i,4){
            if(s[i] == '+') ans++;
            else ans--;
        }
        out << ans << endl;
	}
};

int main() {
	AEatingSymbolsEasy solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

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

    int64_t dp[61][3] = {0};
    dp[60][0] = 1;

    for(int d=59; d>=0; d--){
        for(int s=0; s<=2; s++){
            for(int k=0; k<=2; k++){
                int s2 = min(2, 2*s + nth_bit(N, d) - k);
                if(s2 >= 0) add(dp[d][s2], dp[d+1][s]);
            }
        }
    }

    int64_t ans = (dp[0][0] + dp[0][1] + dp[0][2]) % MOD;
    cout << ans << endl;
    return 0;
}


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

int main() {
  string s;
  cin>>s;
  bool flag=false;
  for(int i=0;i<s.size();i++){
    if(i%2==0){
      if(s.at(i)!='h'){
        cout<<"No"<<endl;
        return 0;
      }else{
        flag=true;
      }
    }else{
      if(s.at(i)!='i'){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  if(flag==true&&s.size()%2==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){

    unsigned long long a, b, x;
    cin >> a >> b >> x;

    unsigned long long count;
    if(a != 0) count = ((b)/x+1)-((a-1)/x+1);    
    else count = ((b)/x+1);

    cout << count << endl;

    return 0;
}

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

ll solve() {
    ll H, W, K;
    cin >> H >> W >> K;
    vector<string> C(H);
    for ( int h = 0; h < H; h++ ) {
        cin >> C[h];
    }
    ll ans = 0;
    for ( int bh = 0; bh < 1<<H; bh++ ) {
        for ( int bw = 0; bw < 1<<W; bw++ ) {
            ll t = 0;
            for ( int h = 0; h < H; h++ ) {
                for ( int w = 0; w < W; w++ ) {
                    if ( C[h][w] == '#' && (((bh>>h) & 1) == 0) && (((bw>>w) & 1) == 0) ) {
                        t++;
                    }
                }
            }
            if ( t == K ) ans++;
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3592
import itertools

N=int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))
nlis=[i for i in range(1,N+1)]

j=list(itertools.permutations(nlis))
cp=j.index(P)+1
cq=j.index(Q)+1
print(abs(cp-cq))

  

Measured memory_bytes: 8052
import sys
sys.setrecursionlimit(10**7)

def dfs(x):
    seen[x]=1
    for nx in lis[x]:
        if seen[nx]==0:
            psum[nx]=psum[x]+plis[nx]
            dfs(nx)

n,q=map(int,input().split())

lis=[[] for i in range(n)]

for _ in range(n-1):
    ai,bi=map(lambda x:int(x)-1,input().split())
    lis[ai].append(bi)
    lis[bi].append(ai)

plis=[0 for i in range(n)]

for _ in range(q):
    pi,xi=map(int,input().split())
    plis[pi-1]+=xi

seen=[0 for _ in range(n)]
psum=[0 for _ in range(n)]
psum[0]=plis[0]

dfs(0)

print(*psum)

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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;


void solve(){
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif

	string str;
	cin >> str;

	bool flag = false;
	for (char c = 'a'; c <= 'z' && !flag; c++){
		auto prev = str.find(c);
		if (prev == string::npos) continue;
		while (1){
			auto next = str.find(c, prev + 1);
			if (next == string::npos) break;
			else if (next - prev < 3){
				flag = true;
				cout << prev + 1 << " " << next + 1 << endl;
				break;
			}
			prev = next;
		}

	}



	if (!flag) cout << "-1 -1" << endl;
}


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


	solve();
	system("PAUSE");
	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;

  if (S[0] == 'R' && S[0] == S[1] && S[1] == S[2]){
      cout << 3 <<endl;
  }else if (S[0] == S[1] && S[0] == 'R' ){
      cout << 2 <<endl;
  }else if (S[1] == S[2] && S[1] == 'R' ){
      cout << 2 <<endl;
  }else if (S[0] == 'R' || S[1] == 'R' || S[2] == 'R'){
      cout << 1 <<endl;
  }else{
      cout << 0 <<endl;
  }    
}

Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string s;
int w;

string solve() {
    string res = "";
    for (int i = 0; i < (int)s.size(); i+=w) {
        res += s[i];
    }
    return res;
}

void input() {
    cin >> s >> w;
}

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

    input();
    cout << solve() << endl;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n, k;
  while (cin >> n >> k) {
    if (k == 0) {
      cout << n * n << endl;
      continue;
    }
    lli sum = 0;
    for (int b = k; b <= n; ++b) {
      lli x = (n / b) * (b - k);
      lli y = max<lli>(0, (n % b) - k + 1);
      // cout << b << ' ' << make_pair(x, y) << endl;
      sum += x + y;
    }
    cout << sum << endl;
    // break;
  }
  
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1000000000 + 7;
const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

string s;
int cnt[26];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    int n = s.size();
    rep(i, n) {
        cnt[s[i] - 'a']++;
    }
    rep(i, 26) {
        if (cnt[i] == 0) {
            cout << char(i + 'a') << endl;
            exit(0);
        }
    }
    cout << "None" << endl;
}


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

typedef long long int Long;
typedef long double Double;
const int MAXN = 1e5 + 4;


int main() {
	string s;
	cin >> s;
	int cnt = 0;
	for(int i = 0; i < 6; ++i)
		cnt += s[i] - '0';
	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 892
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int a = in.nextInt();
            int b = in.nextInt();
            int n = b - a + 1;
            if (a <= 0 && b >= 0 || a == 0 || b == 0) {
                System.out.println("Zero");
                return;
            }
            if (a > 0) {
                System.out.println("Positive");
                return;
            }
            if (n % 2 == 0) {
                System.out.println("Positive");
                return;
            }
            System.out.println("Negative");
        }
    }

    private static int f(int n) {
        return (int) Math.floor((n * n + 4.0) / 8.0);
    }
}


Measured memory_bytes: 21844
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
from collections import Counter
import bisect
from functools import reduce

def main():
    mod = 10 ** 9 + 7
    N, K = MI()
    A = LI()
    flag = 0
    for a in A:
        if a >= 0:
            flag = 1
            break

    A.sort(key=lambda x: abs(x), reverse=True)

    if K == N:
        ans = 1
        for a in A:
            ans *= a
            ans %= mod
        print(ans % mod)
        exit()
    elif flag == 0 and K % 2 != 0:
        B = A[::-1]
        ans = 1
        for i in range(K):
            ans *= B[i]
            ans %= mod
        ans %= mod
        print(ans)
        exit()
    else:
        ans = 1
        now_p = 0
        now_n = 0
        cnt_n = 0
        for i in range(K):
            a = A[i]
            ans *= a
            ans %= mod
            if a > 0:
                now_p = a
            elif a < 0:
                now_n = a
                cnt_n += 1
            else:
                print(0)
                exit()
        if cnt_n % 2 == 0:
            print(ans)
            exit()
        else:
            next_p = 0
            next_n = 0
            flag_p = 0
            flag_n = 0
            for i in range(K, N):
                a = A[i]
                if a > 0 and flag_p == 0:
                    next_p = a
                    flag_p = 1
                elif a < 0 and flag_n == 0:
                    next_n = a
                    flag_n = 1
                if flag_n == 1 and flag_p == 1:
                    break
                if a == 0:
                    break
        if now_p == 0:
            ans *= (pow(now_n, mod - 2, mod) * next_p) % mod
            ans %= mod
        elif next_p != 0 and next_n != 0:
            if now_p * next_p <= now_n * next_n:
                ans *= (pow(now_p, mod - 2, mod) * next_n) % mod
                ans %= mod
            else:
                ans *= (pow(now_n, mod - 2, mod) * next_p) % mod
                ans %= mod
        elif next_p == 0:
            ans *= (pow(now_p, mod - 2, mod) * next_n) % mod
            ans %= mod
        elif next_n == 0:
            ans *= (pow(now_n, mod - 2, mod) * next_p) % mod
            ans %= mod


        print(ans)

if __name__ == "__main__":
    main()


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

using namespace std;

int main(){
    int n,d,x;
    cin>>n>>d>>x;
    vector<int> hoge(n);
    for(int i=0;i<n;i++) cin>>hoge.at(i);
    int ans=x;
    
    for(int i=1;i<=d;i++){
        for(int j=0;j<n;j++){
            if(i%hoge.at(j)==1) ans++;
            else if(hoge.at(j)==1) ans++;
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define M 10000000

using namespace std;

int Prim(const vector< vector<int> >& data){
  vector<bool> is_reached(data.size(), false);
  vector<int> cost(data.size(), M);
  int i, j, ans;

  i = 0;
  ans = 0;
  cost[i] = 0;

  while(i >= 0){
    ans += cost[i];
    is_reached[i] = true;

    for(j=0; j<data[i].size(); ++j){
      cost[j] = min(cost[j], data[i][j]);
    }
    for(i=-1, j=0; j<is_reached.size(); ++j){
      if(!is_reached[j] && (i < 0 || cost[i] > cost[j])) i = j;
    }
  }
  return ans;
}

int main(){
  int n, m;
  int a, b, c;
  char dm;

  while(1){
    cin >> n;
    if(n == 0) break;
    vector< vector<int> > data(n, vector<int>(n, M));

    cin >> m;
    for(int i=0; i<m; ++i){
      cin >> a >> dm >> b >> dm >> c;
      c = c/100 - 1;
      data[a][b] = c;
      data[b][a] = c;
    }

    cout << Prim(data) << endl;
  }
  return 0;
}

Measured memory_bytes: 1260
n, m = map(int, input().split())
xyz = [ [int(x) for x in input().split()] for _ in range(n) ]

ans = 0

for bit in range(2**3):
    s = []
    is_plus = [1, 1, 1]
    for i in range(3):
        if bit>>i & 1:
            is_plus[i] = -1

    for (x, y, z) in xyz:
        s += [ x * is_plus[0] + y * is_plus[1] + z * is_plus[2] ]

    s.sort(reverse=True)
    ans = max(ans, sum(s[:m]))

print(ans)

Measured memory_bytes: 3292
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <sstream>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	int A,P,max;
	cin >> A >> P;
	max = (A*3+P)/2;
	cout << max << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    string a, b, c;
    cin >> a >> b >> c;
    cout << "A" << b[0] << "C" << endl;
    return 0;
}


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

vector<int> u_f(222222);

void init_unionfind(int N){
	for(int i=0;i<N;i++)u_f[i]=i;
}

int root(int a){
	if(u_f[a]==a)return a;
	else return u_f[a]=root(u_f[a]);
}

void unite(int a,int b){
	a=root(a);
	b=root(b);
	if(a==b)return;
	
	u_f[b]=a;
}

bool query(int a,int b){
	return root(a)==root(b);
}

int main(){
	int N,M;
	cin >> N >> M;
	
	init_unionfind(N+M);
	
	for(int i=0;i<N;i++){
		int K;
		cin >> K;
		for(int j=0;j<K;j++){
			int L;
			cin >> L;
			L--;
			L+=N;
			unite(i,L);
		}
	}
	for(int i=0;i<N;i++){
		if(!query(0,i)){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 2688
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second

using namespace std;

const long long MOD = (long long)1e9 + 7;
int n, k;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	if (k == 1) {
		cout << "YES\n";
	}
	else {
		if ((k - 1) * 2 + 1 <= n) cout << "YES\n";
		else cout << "NO\n";
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define pf printf
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node

using namespace std;
///check n=1;
///check corner case;

int main()
{
    string str;
    ll n,i,j,cc=0;
    cin>>n;
    cin>>str;
    for(i=0;i<str.size();i++){
        if(str[i]+n>90){
           ll x=(int)str[i];
            x=x+n-90;
           str[i]=x+'A'-1;
        }
        else str[i]+=n;
    }
    cout<<str<<endl;
    return 0;
}


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

def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    X, K, D = list(map(int, input().split()))

    return X, K, D


def main(X: int, K: int, D: int) -> None:
    """
    メイン処理.

    Args:\n
        X (int): 座標(-10^{15} <= X <= 10^{15})
        K (int): 移動回数(1 <= K <= 10^{15})
        D (int): 移動距離(1 <= D <= 10^{15})
    """
    X = abs(X)

    # 求解処理
    ans = int()
    straight = min(K, int(abs(X) / D))
    K -= straight
    X -= straight * D

    if K % 2 == 0:
        ans = X
    else:
        ans = D - X

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    X, K, D = get_input()

    # メイン処理
    main(X, K, D)


Measured memory_bytes: 9216
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;

bool is(ll t,ll k,ll n,vector<ll>a,vector<ll>f){
    ll sum= 0;
    for(int i=0;i<n;i++){
        if(a[i]*f[i]>t)
            sum+=a[i]-t/f[i];
    }
        return sum<=k;

}

int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll>a(n);
    vector<ll>f(n);
    for(int i=0;i<n;i++)cin>>a[i];
      for(int i=0;i<n;i++)cin>>f[i];
      //a[i]*f[i] seconds to complete ith food
      //score is max(a[i]*f[i]) f.a. i
      sort(a.begin(),a.end());
      sort(f.begin(),f.end(),greater<ll>());

      ll lo=0;ll hi = 1000000000010;;
      while(lo<hi){
        ll mid = (lo+hi)/2;
        if(is(mid,k,n,a,f))hi=mid;
        else lo = mid+1;
      }
      cout<<lo;
    return 0;
}


Measured memory_bytes: 9596
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n, m = map(int, input().split())
if n <= 1 and m <= 1:
    print(0)
elif n <= 1:
    print(combinations_count(m, 2))
elif m <= 1:
    print(combinations_count(n, 2))
else:
    print(combinations_count(n, 2) + combinations_count(m, 2))

Measured memory_bytes: 38256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)
#define AAA (1000000007)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;



ll gcd(ll a, ll b) {
	if (a < b) {
		ll t = a;
		a = b;
		b = t;
	}
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

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

int main() {
	ll i, j, k;
	ll N, M, K;
	ll ans = 0;

	int a, b;
	cin >> a >> b;
	

	if (a > b) {
		for (i = 0; i < a; i++)cout << b;
	}
	else {
		for (i = 0; i < b; i++)cout << a;
	}
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#include <math.h> 


int main(){
    long double a,b,c;
    cin >> a >> b >> c;
    if((a+b+(2*(sqrtl(a*b))))<c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    

    
}


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

int S[100001];
int N;

bool binary(int q, int left, int right){
    int mid = (left + right)/2;
    if (right - left == 1) return (S[left] == q);
    
    //if (S[mid] == q) return true;
    else if (S[mid] > q) {
        return binary(q, left, mid);
    }else{
        return binary(q, mid, right);
    }
}

int main(){
    int q,Noq;
    cin >> N;
    
    for (int i = 0; i < N; i++) scanf("%d",&S[i]);
    
    cin >> Noq;
    int count = 0;
    
    for (int i = 0; i < Noq; i++) {
        scanf("%d",&q);
        if (binary(q,0,N)) count++;
    }
    
    printf("%d\n",count);
    
    return 0;
}

Measured memory_bytes: 1616
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <unordered_map>
// #include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x)  if(DEBUG_Switch) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
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;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
void pvarr_int(int *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%d%c", arr[i], i == n ? '\n' : ' ');}}
void pvarr_LL(ll *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%lld%c", arr[i], i == n ? '\n' : ' ');}}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
#define DEBUG_Switch 0
int main()
{
#if DEBUG_Switch
    freopen("C:\\code\\input.txt", "r", stdin);
#endif
    //freopen("C:\\code\\output.txt","r",stdin);
    string s, t;
    cin >> s >> t;
    int n = sz(s);
    int ans = 0;
    repd(i, 0, n - 1)
    {
        if (s[i] != t[i])
        {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 3472