akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   int n;
   string s, t;
   cin >> n >> s >> t;

   // reverse(all(s));
   rep (i, s.size()) {
      string a = s.substr(i, s.size());
      string b = t.substr(0, a.size());
      if (a == b) {
         cout << s.size() + t.size() - a.size() << endl;
         return 0;
      }
   }

   cout << s.size() + t.size() << endl;

   return 0;
}

Measured memory_bytes: 636
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import deque

    n = int(readline())
    a = [int(readline()) for _ in range(n)]
    a.sort()

    def calc1():
        b = deque(a)

        que = deque()
        que.append(b.popleft())

        while b:
            if len(b) >= 2:
                que.append(b.pop())
                que.appendleft(b.pop())
            elif len(b) == 1:
                if abs(que[0] - b[0]) > abs(que[-1] - b[0]):
                    que.appendleft(b.pop())
                else:
                    que.append(b.pop())
            if len(b) >= 2:
                que.append(b.popleft())
                que.appendleft(b.popleft())
            elif len(b) == 1:
                if abs(que[0] - b[0]) > abs(que[-1] - b[0]):
                    que.appendleft(b.popleft())
                else:
                    que.append(b.popleft())
        score = 0
        prev = que[0]
        for x in que:
            score += abs(x - prev)
            prev = x
        return score

    def calc2():
        b = deque(a)

        que = deque()
        que.append(b.pop())

        while b:
            if len(b) >= 2:
                que.append(b.popleft())
                que.appendleft(b.popleft())
            elif len(b) == 1:
                if abs(que[0] - b[0]) > abs(que[-1] - b[0]):
                    que.appendleft(b.popleft())
                else:
                    que.append(b.popleft())
            if len(b) >= 2:
                que.append(b.pop())
                que.appendleft(b.pop())
            elif len(b) == 1:
                if abs(que[0] - b[0]) > abs(que[-1] - b[0]):
                    que.appendleft(b.pop())
                else:
                    que.append(b.pop())
        score = 0
        prev = que[0]
        for x in que:
            score += abs(x - prev)
            prev = x
        return score

    print(max(calc1(), calc2()))


if __name__ == '__main__':
    main()


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

int k;

inline int Get(LL x)
{
	int res=0;
	while (x) res+=x%10,x/=10;
	return res;
}

int main ()
{
	scanf("%d",&k);LL cur=1,nxt;LL delta=1;
	while (k--)
	{
		printf("%lld\n",cur);
		nxt=cur+delta;
		while (double(nxt)*1.0/Get(nxt)>delta)
		{
			delta*=10;
			nxt=cur+delta;
		}
		cur=nxt;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <locale>
#include <math.h>

using namespace std;

int main()
{
    int N, M, L, R, Li, Ri;
    cin>>N>>M;
    L=1;
    R=N;
    for(int i=0;i<M;i++)
    {
        cin>>Li>>Ri;
        if(Li > L)
        {
            L=Li;
        }
        if(Ri < R)
        {
            R=Ri;
        }
    }
    if(R < L)
    {
        cout<<0;
    }
    else
    {
        cout<<R-L+1;
    }



    return 0;
}


Measured memory_bytes: 256
// E - This Message Will Self-Destruct in 5s
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	map<long long, long long> x, y;
	for (int i = 1; i <= n; i++) {
		long long t;
		cin >> t;
		x[i + t]++;
		y[t - i]++;
	}
	long long ans = 0;
	for (map<long long, long long>::iterator it = x.begin(); it != x.end(); ++it)
		ans += it->second * y[-it->first];

	cout << ans << endl;

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int>vec(100);
  
  for (int i = 0; i < N; i++)
  {
    int A;
    cin >> A;
    vec.at(A - 1)++;
  }
  
  int ans = 0;
  for (int i = 0; i < 100; i++)
  {
    if (vec.at(i) != 0)
    {
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Maximum Sum
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int a, b, c, k;
  scanf("%d%d%d%d", &a, &b, &c, &k);

  int m = max(max(a, b), c);
  int sum = a + b + c + m * ((1 << k) - 1);
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 256
while True:
    h,w = map(int, input().split())
    if h == 0 and w == 0: 
        break
    for j in range(h):
        for i in range(w):
            if (i + j)%2 == 0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()



Measured memory_bytes: 7004
#include<stdio.h>
int main(void){
    int N;
    long long x = 2;
    long long y = 1;
    long long z;
    scanf("%d",&N);
    if(N==1){
        printf("%d",1);
    }
    else{
    for(int i = 0 ; i < N - 1 ; i++){
    z = y + x;
    x = y;
    y = z;
    }
    printf("%lld",z);
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main() {
    long long int N,K;
    long long int A[100500];
    long long int M[100500];
    long long int m[100500];
    long long int ans = -1;
	cin >> N >> K;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		m[i] = m[i - 1];
		M[i] = M[i - 1];
		if (A[i] > 0)M[i] += A[i];
		else m[i] += A[i];
	}
	for (int i = K; i <= N; i++) {
		ans = max(ans, M[N] + m[i] - m[i - K]);
	}
	for (int i = K; i <= N; i++) {
		ans = max(ans, M[N] - M[i] + M[i - K]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
//標準関数をすべてインクルードする。
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

const int_least64_t INF = 10000000;

int main(){
    //cin coutを高速化
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout.tie(0);

    int n, L;
    cin >> n >> L;
    vector<int> D(n);
    int sum = 0;
    rep(i, n){
        D[i] = L + i + 1 - 1;
        sum += D[i];
    }
    
    int rem =INF;
    int cou = 0;
    rep(i, n){
        if(rem > abs(D[i]))
        {
            rem = abs(D[i]);
            cou = D[i];
        }
    }
    
    cout << sum - cou << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#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()
{
    double n, d;
    cin >> n >> d;
    cout << ceil(n / (2 * d + 1)) << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long int 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;}

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

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

  if (s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
import queue

N = int(input())
q = queue.Queue()
for i in range(1, 10):
    q.put(i)

ans = 0
for i in range(N):
    ans = q.get()
    m = ans % 10
    if ans % 10 != 0:
        q.put(ans * 10 + m - 1)
    q.put(ans * 10 + m)
    if ans % 10 != 9:
        q.put(ans * 10 + m + 1)

print(ans)

Measured memory_bytes: 12476
//---------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                        NEVER  GIVE  UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug cout<<"Hello\n";
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
//------------------------------------------------------------------------------------------------------------------------------
#define mod 1000000007
int main()
{
	
	#ifndef ONLINE_JUDGE
	freopen("C:/Users/DELL/Desktop/input.txt", "r", stdin);
	#endif

	fast;
	ll n,ans = 0;
	cin>>n;
	vector<ll> v(n);
	for(ll i=0;i<n;i++) {
		cin>>v[i];
	}
	vector<ll> prefix(n,0);
	prefix[0] = v[0];
	for(int i=1;i<n;i++) {
		prefix[i] = (prefix[i-1] + v[i]) % mod;
	}
	for(ll i=n-1;i>0;i--) {
		ans = (ans + (v[i] * prefix[i-1]) % mod) % mod;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 6348
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
    long long int n, i, j, min, ans=0;
    scanf("%lld", &n);
    long long int h[n];
    for(i=0; i<n; i++) scanf("%lld", &h[i]);

    h[0]--;
    for(i=1; i<n; i++){
        if(h[i-1]!=h[i]) h[i]--;
        if(h[i-1]>h[i]) ans++;
    }
    if(ans==0) printf("Yes");
    else printf("No");
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
using namespace std;
long long a[1000005];

int main(){
	long long n,k;
	long long i;
	cin>>n>>k;
	for(i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	long long min=a[k-1]-a[0];
	for(i=k-1;i<n;i++){
		if(a[i]-a[i-k+1]<min)
		min=a[i]-a[i-k+1];
	}
	cout<<min<<endl;
	return 0;
} 

Measured memory_bytes: 1024
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=5e5+5;
int a[N],b[N],st[N],col[N],n,t,l,r,mid,ans;
bool ck(){
	fp(i,1,n)b[i]=a[i]>=mid;
	R int top=0;bool fl1=1,fl2=1;
	fp(i,1,n)fl1&=(b[i]==(i&1)),fl2&=(b[i]!=(i&1));
	if(fl1)return true;if(fl2)return false;
	for(R int l=1,r=2;r<=n;l=r++){
		if(b[r]==b[l]){
			while(r+1<=n&&b[r+1]==b[l])++r;
			st[++top]=r,col[top]=b[l];
		}else{
			while(r+1<=n&&((r+1-l)&1)==(b[r+1]^b[l]))++r;
			if((r-l+1)&1)st[++top]=r,col[top]=b[l];
			else st[++top]=(l+r)>>1,col[top]=b[l],st[++top]=r,col[top]=b[r];
		}
	}
	assert(top);
	fp(i,1,top)if(st[i-1]<=t&&st[i]>=t)return col[i];
}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d",&n),t=n,n=(n<<1)-1;
	fp(i,1,n)scanf("%d",&a[i]);
	l=2,r=n-1;
	while(l<=r){
		mid=(l+r)>>1;
		ck()?(ans=mid,l=mid+1):r=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define FAST {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pll pair<ll,ll>
#define LB lower_bound
#define UB upper_bound
#define endl "\n"
using namespace std;



int main()
{
    FAST
    ll n;cin>>n;
    string s;cin>>s;
    ll ans=0;
    ll l=0,r=n-1;
    while(l<r)
    {
        while(l<r && s[l]=='R') l++;
        if(l==r) break;
        while(l<r && s[r]=='W') r--;
        if(l==r) break;
        swap(s[l],s[r]);
        ans++;
        l++;
        r--;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3716
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

 class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        Set<Character> set = new HashSet<>();
        for(char ch: s.toCharArray() ){
            set.add(ch);
        }
        if(set.size()==2){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 23764
from math import ceil

n, a, b = map(int, input().split())
h = [int(input()) for _ in range(n)]


def f(x):
    cnt = 0
    for e in h:
        cnt += max(0, ceil((e - b * x) / (a - b)))

    if cnt > x:
        return False

    return True


l = 0
r = 10 ** 9 + 1
while r - l > 1:
    mid = (l + r) // 2
    if f(mid):
        r = mid
    else:
        l = mid

print(r)


Measured memory_bytes: 7120
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

if A < B*2:
	print(0)
else:
	print(A-2*B)

Measured memory_bytes: 5712
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		final int X = 0;
		final int Y = 1;
		final int SIZE = 2;
		int countAxis = 0;
		int maxThickness = 0;

		// 真っ白(全てが0である)座標を作成
		int[][] axis = new int[10][10];
		for (int countX = 0; countX < 10; countX++) {
			for (int countY = 0; countY < 10; countY++) {
				axis[countX][countY] = 0;
			}
		}
		BufferedReader input = new BufferedReader(new InputStreamReader(
				System.in));
		// 無限ループ
		while (true) {

			String inputData = input.readLine();
			// 入力データがnullもしくは空文字の時、ループを抜ける
			if (inputData == null || inputData.equals("")) {
				break;
			}
			// 入力データをカンマで区切り配列に格納(0→X軸、１→Y軸、２→インクのサイズ)
			String[] data = inputData.split(",");
			// 入力データのインクのサイズに合わせてそれぞれのメソッドを実行
			if (Integer.parseInt(data[SIZE]) == 1) {
				makeSmallArea(axis, Integer.parseInt(data[X]),
						Integer.parseInt(data[Y]));
			}

			if (Integer.parseInt(data[SIZE]) == 2) {
				makeMiddleArea(axis, Integer.parseInt(data[X]),
						Integer.parseInt(data[Y]));

			}

			if (Integer.parseInt(data[SIZE]) == 3) {
				makeBigArea(axis, Integer.parseInt(data[X]),
						Integer.parseInt(data[Y]));

			}

		}
		// 色がついていない部分(値が0である部分)の数をカウントする
		countAxis = 0;
		for (int countX = 0; countX < 10; countX++) {
			for (int countY = 0; countY < 10; countY++) {
				if (axis[countX][countY] == 0) {
					countAxis++;
				}
				// 一番高い濃度を記録する
				if (axis[countX][countY] > maxThickness) {
					maxThickness = axis[countX][countY];
				}

			}
		}
		// 出力
		System.out.println(countAxis);
		System.out.println(maxThickness);
	}

	// インクサイズが小の場合のメソッド、枠からはみ出した部分を無視するif分を記載
	static void makeSmallArea(int[][] axis, int xAxis, int yAxis) {
		if (xAxis >= 1) {
			axis[xAxis - 1][yAxis]++;
		}
		if (xAxis <= 8) {
			axis[xAxis + 1][yAxis]++;
		}
		if (yAxis >= 1) {
			axis[xAxis][yAxis - 1]++;
		}
		if (yAxis <= 8) {
			axis[xAxis][yAxis + 1]++;
		}
		axis[xAxis][yAxis]++;
	}

	// インクサイズが中の場合のメソッド、枠からはみ出した部分を無視するif分を記載
	static void makeMiddleArea(int[][] axis, int xAxis, int yAxis) {
		makeSmallArea(axis, xAxis, yAxis);
		if (xAxis >= 1 && yAxis >= 1) {
			axis[xAxis - 1][yAxis - 1]++;

		}
		if (xAxis >= 1 && yAxis <= 8) {
			axis[xAxis - 1][yAxis + 1]++;

		}
		if (xAxis <= 8 && yAxis >= 1) {
			axis[xAxis + 1][yAxis - 1]++;
		}
		if (xAxis <= 8 && yAxis <= 8) {
			axis[xAxis + 1][yAxis + 1]++;

		}
	}

	// インクサイズが大の場合のメソッド、枠からはみ出した部分を無視するif分を記載
	static void makeBigArea(int[][] axis, int xAxis, int yAxis) {
		makeMiddleArea(axis, xAxis, yAxis);
		if (xAxis >= 2) {
			axis[xAxis - 2][yAxis]++;
		}
		if (xAxis <= 7) {
			axis[xAxis + 2][yAxis]++;
		}
		if (yAxis >= 2) {
			axis[xAxis][yAxis - 2]++;
		}
		if (yAxis <= 7) {
			axis[xAxis][yAxis + 2]++;
		}
	}
}

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

using namespace std;

const int N = 1e5;
const int oo = INT_MAX;

int main()
{
    long long n, cap;
    cin >> n >> cap;
    vector<int> v, w; //values, weights
    v.push_back(0);
    w.push_back(0);
    for (int i = 0; i < n; i++)
    {
        long long wi, vi;
        cin >> wi >> vi;
        w.push_back(wi);
        v.push_back(vi);
    }

    long long dp[n + 2][cap + 2];
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= cap; j++)
        {
            if (i == 0 || j == 0)
            {
                dp[i][j] = 0;
                continue;
            }

            if (j >= w[i])
            {
                dp[i][j] = max(v[i] + dp[i-1][j - w[i]],
                               dp[i - 1][j]);
            }
            else
                dp[i][j] = dp[i - 1][j];
        }
    }

    cout << dp[n][cap];
    return 0;
}

Measured memory_bytes: 79360
import java.util.*;
 
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char[]c = S.toCharArray();
    
    for(int i=0; i<S.length(); i++){
    if(i%2==0){
            System.out.print(c[i]);
    }
    }
}
}

Measured memory_bytes: 47776
def main():
    x, y = map(int, input().split())

    # ans = f(x, y)
    ans = editorial(x, y)
    print(ans)


def editorial(x, y):
    """
    |b12| x  y|
    |---|-----|
    | 00| x  y|
    | 01| x -y|
    | 10|-x  y|
    | 11|-x -y|
    |---|-----|
    """
    xya = [
        (x, y, 0),
        (x, -y, 1),
        (-x, y, 1),
        (-x, -y, 2),
    ]

    answers = []
    for x, y, a in xya:
        ans = float("inf")
        if x <= y:
            ans = y - x + a
        answers.append(ans)

    return min(answers)


if __name__ == '__main__':
    main()


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

int main(){
    int n;
    cin>>n;
    int a=0,b=n;
    while(b!=0){
        a+=b%10;
        b/=10;
    }
    cout<<(n%a==0?"Yes":"No")<<endl;
    return 0;
}

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

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


    if( a[0] == '-' && b[0] == '-' ){
        // {N(b) - N(a)} % 2 == 1  ->  Negative
        if( a[a.length()-1]%2 == b[b.length()-1]%2 )
            cout << "Negative" << endl;
        else // {N(b) - N(a)} % 2 == 0  ->  Positive
            cout << "Positive" << endl;
    } else if( a[0] == '-' && b[0] != '-' ){
        cout << "Zero" << endl;
    } else if( a[0] == '0' ){
        cout << "Zero" << endl;
    } else {
        cout << "Positive" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
typedef struct Edge{
    ll u, v, w;
    Edge(ll a, ll b, ll c)
    {
        u = a;
        v = b;
        w = c;
    }
} edge;
vector< edge > g1;
int main()
{
    she_told_me_dont_worry
    ll n, m , p;
    cin>>n>>m>>p;
    ll i;
    FOR0(i, m)
    {
        int a, b, c;
        cin>>a>>b>>c;
        a--;b--;
        g1.push_back(edge(a, b, c));
    }
    ll dis1[n+5] = {}, dis2[n+5] = {};
    FOR0(i, n)
    {
        dis1[i] = inf;
        dis2[i] = ninf;
    }
    dis1[0] = 0;
    dis2[0] = 0;
    // bellman ford
    ll j;
    ll c1, c2, t1, t2;
    FOR0(j, n-1)
    {
        FOR0(i, m)
        {
            int u = g1[i].u, v = g1[i].v, w = g1[i].w;
            if( (dis2[v] - p*dis1[v]) < (dis2[u]  + w) - p*(dis1[u] + 1))
            {
                dis1[v] = dis1[u] + 1;
                dis2[v] = dis2[u] + w;
            }
        }
    }
    t1 = dis1[n-1];
    c1 = dis2[n-1];
    FOR0(j, n-1)
    FOR0(i, m)
    {
        ll u = g1[i].u, v = g1[i].v, w = g1[i].w;
        if( (dis2[v] - p*dis1[v]) < (dis2[u]  + w) - p*(dis1[u] + 1))
        {
            dis1[v] = dis1[u] + 1;
            dis2[v] = dis2[u] + w;
        }
    }
    t2 = dis1[n-1];
    c2 = dis2[n-1];
    if( c1 - p*t1 < c2 - p*t2 )
    {
        cout<<-1;
    }
    else 
    {
        ll val = MAX2(0, c1 - p*t1);
        cout<<val;
    }
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

// main.cpp

int main() {
  std::int_fast64_t N;
  std::cin >> N;
  std::vector<std::int_fast64_t> X;
  X.reserve(N);
  std::copy_n(std::istream_iterator<std::int_fast64_t>(std::cin), N, std::back_inserter(X));

  std::vector<std::int_fast64_t> Y(X);
  std::sort(Y.begin(), Y.end());

  for (const std::int_fast64_t& X_i : X) {
    std::cout << (X_i <= Y[N / 2 - 1] ? Y[N / 2] : Y[N / 2 - 1]) << std::endl;
  }
  return 0;
}

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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    ll H, W;
    cin >> H >> W;
    if (H == 1 || W == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    cout << ((H * W) + 2 - 1) / 2 << endl;
}


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

using namespace std;

int f(int x,int y,int z){
    return x * x + y * y + z * z + x * y + x * z + y * z;
}

int main() {
    int n;
    cin >> n;
    map<int, int> cnt;

    for (int i = 1; i <= 100;++i) {
        for (int j = 1; j <= 100;++j) {
            for (int k = 1; k <= 100;++k) {
                cnt[f(i, j, k)]++;
            }
        }
    }
    for (int i = 1; i <= n;++i) {
        cout << cnt[i] << '\n';
    }
    return 0;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
int main(){
  int n;
  cin>>n;
  int a[2][n];
  r(i,2)r(j,n)cin>>a[i][j];
  for(int i=1;i>=0;i--){
    for(int j=n-1;j>=0;j--){
      if(j!=n-1&&i==0)a[i][j]=max(a[i][j]+a[i][j+1],a[i+1][j]+a[i][j]);
      else if(j!=n-1)a[i][j]=max(a[i][j]+a[i][j+1],a[i][j]);
      else if(i==0)a[i][j]=max(a[i][j]+a[i+1][j],a[i][j]);
    }
  }

  cout<<a[0][0]<<endl;
}

Measured memory_bytes: 256
# frozen_string_literal: true

n = gets.to_i
s = gets.chomp
h = Hash.new(0)
max = 0

1.upto(n - 1) do |i|
  h.clear
  s[0...i].chars.uniq.each { |c| h[c] += 1 }
  s[i..-1].chars.uniq.each { |c| h[c] += 1 }
  tmp = h.values.count { |e| e == 2 }
  max = tmp if max < tmp
end

puts max

Measured memory_bytes: 1788
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
  int n, m=-1, c=1, f=0;
  scanf("%d",&n);
  while(n!=0){
    if(n%10==m) c++;
    else {c=1; m=n%10;}
    if(c==3) {f=1; break;}
    n/=10;
  }
  if(f==1) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef vector<int>   vi;
typedef vector<long long> vll;
typedef vector<pair<int,int> > vii;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pq priority_queue
#define sf1(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
int inf = (1e9) + 7;
int mod = 998244353;


int main(){
	multiset<int> ms;

	int n;
	int aux;
	sf1(n);
	for (int i = 0; i < n; ++i)
	{
		sf1(aux);
		ms.insert(aux);
	}
	int m;
	sf1(m);
	for (int i = 0; i < m; ++i)
	{
		sf1(aux);
		auto u = ms.find(aux);
		if(ms.count(aux) == 0)
		{
			printf("NO\n");
			return 0;
		}
		ms.erase(u);
	}

	printf("YES\n");

}

Measured memory_bytes: 9600
n = int(input())
if n < 100:
    while int(n/10) != n % 10:
        n = n + 1
    print(n)
else:
    while not (int(n/100)==int((n%100)/10) and int(n/100) == n%10):
        n = n + 1
    print(n)
      
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
 

int main()
{
    int N, M;
    cin >> N >> M;
  	cout << (N * M % 2 ? "Odd" : "Even") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int INF=(int)1e9;
const int MOD=(int)1e9+7;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};

int main(){
  int N,K,x[100005];
  cin>>N>>K;
  for(int t=1;t<=N;t++)cin>>x[t];
  int m=INF;
  for(int t=1;t<=N-K+1;t++){
    int temp=min(abs(x[t+K-1]-x[t])+abs(x[t]),abs(x[t+K-1]-x[t])+abs(x[t+K-1]));
    if(temp<m)m=temp;
  }
  cout<<m<<endl;

  return 0;
}


Measured memory_bytes: 640
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 1e18+10 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
signed main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	sort(all(in));
	int sum=0;
	rep(i,n-1)sum+=(in[i+1]-in[i])*2*min(i+1,n-1-i);
	if(n%2){
		sum-=min(in[n/2]-in[n/2-1],in[n/2+1]-in[n/2]);
	}else sum-=in[n/2]-in[n/2-1];
	cout<<sum<<endl;
}








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

int main(){
  ll N,K,R,S,P;
  string T;
  cin>>N>>K>>R>>S>>P>>T;
  vll data(N);
  ll ans=0;
  rep(i,N){
    if(T.at(i)=='r'){
      data.at(i)=P;
      ans+=P;
    }else if(T.at(i)=='s'){
      data.at(i)=R;
      ans+=R;
    }else{
      data.at(i)=S;
      ans+=S;
    }
  }
  ll i=0;
  while(true){
    if(i+K>N-1) break;
    if(T.at(i)==T.at(i+K)){
      ans-=data.at(i); 
      if(T.at(i)=='r'){
        if(T.size()>(i+K*2)&&T.at(i+K*2)=='s') T.at(i+K)='p';
        else T.at(i+K)='s';
      }
      if(T.at(i)=='p'){
        if(T.size()>(i+K*2)&&T.at(i+K*2)=='r') T.at(i+K)='s';
        else T.at(i+K)='r';
      }
      if(T.at(i)=='s'){
        if(T.size()>(i+K*2)&&T.at(i+K*2)=='p') T.at(i+K)='r';
        else T.at(i+K)='p';
      }
    }
    i++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1280
#include<stdio.h>
int main(){int n,i,j,c=1,a[100010];scanf("%d", &n);for(i=1;i<=n;i++)scanf("%d",&a[i]);for(j=a[1];j!=2;c++){j=a[j];if(c>n){printf("-1");return 0;}}printf("%d",c);return 0;}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<map>
using namespace std;

int main(){

int N,i,m;
std::vector<int> x;
std::vector<int> y;

std::cin >> N;

for(i=0;i<N;i++){
  std::cin >> m;
  x.push_back(m);
  y.push_back(m);
}

sort(x.begin(),x.end());

for(i=0;i<N;i++){

  if(y[i]<=x[N/2-1])std::cout << x[N/2] << '\n';
  else std::cout << x[N/2-1] << '\n';
}



  return 0;

}


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

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007
void printbit(int u){if(u==0)cout<<0;else{int s=0,k=0;for(;0<u;u>>=1,k++)s=(s<<1)|(u&1);for(;0<k--;s>>=1)cout<<(s&1);}}

#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

template<typename T1,typename T2>
ostream& operator <<(ostream &o,const pair<T1,T2> p){o<<"("<<p.first<<":"<<p.second<<")";return o;}

int m,n;

bool field[1010][1010];
int result[200010][2];
int rc=0;

int main(){
    int i,j,k;
    
    cin >> n;
    
    int x,y;
    
    for (x=1;x<n;x+=3){
        for (y=!(x%2);y<n;y+=2){
            result[rc][0]=x;
            result[rc][1]=y;
            field[x][y]=true;
            rc++;
        }
    }
    for (x=0;x<n;x+=3){
        y=!(x%2);
        result[rc][0]=x;
        result[rc][1]=y;
        field[x][y]=true;
        rc++;
    }
    if (n%3==1){
        x=n-1;
        for (y=n%2;y<n;y+=2){
            if (field[x][y])continue;
            result[rc][0]=x;
            result[rc][1]=y;
            field[x][y]=true;
            rc++;
        }
    }
    
    cout << rc << endl;
    for (i=0;i<rc;i++){
        printf("%d %d\n",result[i][0],result[i][1]);
    }

    return 0;
}

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

int main() {
  int N, W;
  cin >> N >> W;
  vector<int> DP(1e5+1, 1e9+1);
  DP.at(0) = 0;
  for (int i = 0, w, v; i < N && cin >> w >> v; i++)
    for (int j = 1e5; j >= v; j--) DP.at(j) = min(DP.at(j), DP.at(j - v) + w);
  for (int i = 1e5; i >= 0; i--) if (DP.at(i) <= W) {
    cout << i << "\n";
    break;
  }
}

Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		long K = GetLong();
		long A = GetLong();
		long B = GetLong();

		if(A >= K)
		{
			Console.WriteLine(1);
			return;
		}

		if(A - B <= 0)
		{
			Console.WriteLine(-1);
			return;
		}
		
		long diff = A - B;
		Console.WriteLine(((K - A + diff - 1) / diff) * 2 + 1);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 11092
n, c = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(c)]
C = [list(map(int, input().split())) for _ in range(n)]

CC = [[0] * c for _ in range(3)]

for h, line in enumerate(C):
  for w, i in enumerate(line):
    CC[(h + w) % 3][i - 1] += 1
    
ans = 10 ** 19
for i in range(c):
  for j in range(c):
    for k in range(c):
      if i != j and j != k and k != i:
        score = 0
        score += sum(D[itr][i] * val for itr, val in enumerate(CC[0]))
        score += sum(D[itr][j] * val for itr, val in enumerate(CC[1]))
        score += sum(D[itr][k] * val for itr, val in enumerate(CC[2]))
        ans = min(ans, score)

print(ans)

Measured memory_bytes: 5620
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;
 
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;
 
 
signed main()
{
    int n, m;
    cin >> n >> m;
    std::vector<int> s(n);
    std::vector<int> t(m);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> t[i];
    }
    int out = 1;
 
    std::vector<int> sumarray(n, 0);
    for (int i = 0; i < m; i++) {
        int temp = 0;
        for (int j = 0; j < n; j++) {
            if (j == 0) {
                temp += sumarray[j];
                if (t[i] == s[j]) {
                    sumarray[j] += 1;
                }
            } else {
                if (t[i] == s[j]) {
                    int prev = temp + sumarray[j];
                    sumarray[j] += (temp + 1) % MOD;
                    temp = prev;
                } else {
                    temp += sumarray[j];
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        out += sumarray[i];
        out %= MOD;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3700
#include <stdio.h>
#include <string.h>
 
int main(){
	
	char a[200000]={0};
    char b[200000]={0};
  	int i;
  	int n = 0;
	if(scanf("%s",a) == -1){
    	return 0;
    }
	if(scanf("%s",b) == -1){
    	return 0;
    }
  	for(i=0;i<200000;i++){
        if(a[i]=='\0'&&b[i]=='\0'){
      break;
    }else if(a[i]=='\0'||b[i]=='\0'){
        return 0;
        }else{
     
        }
      
	if(strncmp(&a[i],&b[i],1)!=0){
      n = n+1;
    }
 
    }
  
	printf("%d\n",n);
	
	return 0;
}

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

#define ll long long
#define pb push_back
#define INF 1e9+7
#define cases int t;cin>>t;while(t--)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define ff first
#define ss second

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	ll n,W;
	cin>>n>>W;
	ll w,v;
	ll dp[W+1];
	memset(dp,0,sizeof(dp));
	rep(i,0,n){
		cin>>w>>v;
		for(ll i=W;i>=w;i--){
			dp[i]=max(dp[i],dp[i-w]+v);
		}
	}
	cout<<dp[W];
	
	
	
	return 0;
}

Measured memory_bytes: 4376
x, y = map(int,input().split())

ans = 0
if x == 1 and y == 1:
    ans += 4
if x == 1:
    ans += 3
if x == 2:
    ans += 2
if x == 3:
    ans += 1
if y == 1:
    ans += 3    
if y == 2:
    ans += 2
if y == 3:
    ans += 1

print(ans * 100000)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n, ma, mi;
    cin>>n;
    long a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    mi=a[0];
    ma=a[1]-a[0];
    for(int i=1;i<n;i++){
        if(mi>a[i])mi=a[i];
        else if(ma<a[i]-mi)ma=a[i]-mi;
    }
    cout<<ma<<endl;
   
}


Measured memory_bytes: 4636
import java.util.Scanner;
import java.util.Vector;

public class Main {
	
	private int n , x, cnt = 0;
	private Vector<char[]> lst = new Vector<>();
	Scanner sc = new Scanner(System.in);
	
	void run() {
		init();
		make();
		count();
		System.out.println(cnt);
	}
	

	
	void print(char[] x) {
		System.out.print(String.valueOf(x));
		System.out.println();
	}
	
	void init() {
		int c = 0 ; x = sc.nextInt();
		int ct = x;
		while(ct > 0) {
			c++ ; ct/=10;
		}
		this.n = c ;
	}
	
	void make() {
		for(int i=3;i<=n;i++) {
			rec(0,i,new char[n]);
		}
	}
	void rec(int i,int n,char[]ch) {
		if(i==n) {
			char[] x = new char[n];
			for(int j=0;j<n;j++)x[j]=ch[j];
			lst.add(x);
			return;
		}
		ch[i]='3';
		rec(i+1,n,ch);
		
		ch[i]='5';
		rec(i+1,n,ch);
		
		ch[i]='7';
		rec(i+1,n,ch);
	}
	
	void count() {
		int j;
		for(char[] x :lst) {
			j = 0;
			for(int i=0;i<x.length;i++) {
				j += Character.getNumericValue(x[i]) * Math.pow(10, x.length-1-i);
			}
			if(j>this.x)return;
			cnt+=judge(x);
		}
	}
	
	int judge(char[] x) {
		int[] a = new int[3];
		for(char c : x) {
			switch(c) {
			case '3':a[0]++;break;
			case '5':a[1]++;break;
			case '7':a[2]++;break;
			}
		}
		for(int i:a) {
			if(i==0)return 0;
		}
		return 1;
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 25596
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[3] = {1,0,-1};
int dy[3] = {1,0,-1};
const int MOD = 1000000007;

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int A,B,C;
  cin >> A >> B >> C;
  if(C % __gcd(A,B) == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


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

LL N;

LL erase_bit(LL n, LL m)
{
	LL upper = (n >> (m + 1)) << m, lower = n % (1LL << m);
	return upper + lower;
}

LL push_bit(LL n, LL m, LL k)
{
	LL upper = (n - n % (1LL << m)) << 1, lower = n % (1LL << m);
	return upper + k * (1LL << m) + lower;
}

std::vector<LL>f(LL a, LL b, LL c)
{
	if (c == 1) return std::vector<LL>{a, b};

	LL diff_bit;
	std::vector<LL>res;
	rep(i, N)
	{
		if (((a ^ b) >> i) & 1)
		{
			diff_bit = i;
			break;
		}
	}
	auto res1 = f(erase_bit(a, diff_bit), erase_bit(a, diff_bit) ^ 1, c - 1), res2 = f(erase_bit(a, diff_bit) ^ 1, erase_bit(b, diff_bit), c - 1);
	for (auto i : res1) res.push_back(push_bit(i, diff_bit, (a >> diff_bit) & 1));
	for (auto i : res2) res.push_back(push_bit(i, diff_bit, (b >> diff_bit) & 1));
	return res;
}

int main()
{
	LL A, B;
	in >> N >> A >> B;

	LL cnt1 = 0, cnt2 = 0;
	rep(i, N)
	{
		if ((A >> i) & 1) ++cnt1;
		if ((B >> i) & 1) ++cnt2;
	}
	if (cnt1 % 2 == cnt2 % 2)
	{
		out << "No" << std::endl;
		return 0;
	}

	out << "Yes" << std::endl;
	auto ans = f(A, B, N);
	rep(i, (1LL << N)) out << ans[i] << (i < (1LL << N) - 1 ? " " : "\n");
}


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

int main(void) {
    int a, b;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b;
    if (a + b >= 10) {
        cout << "error" << "\n";
    } else {
        cout << a + b << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N;
	cin >> N;
	vector<long long>Ball(N), Num(N, 0);
	for (long long i = 0; i < N; i++) {
		cin >> Ball.at(i);
		Num.at(Ball.at(i) - 1)++;
	}
	long long  sum = 0;
	for (long long i = 0; i < N; i++) {
		sum += (Num.at(i) * (Num.at(i) - 1)) / 2;
	}
	for (long long i = 0; i < N; i++) {
		cout << sum - (Num.at(Ball.at(i) - 1) * (Num.at(Ball.at(i) - 1) - 1) / 2) + ((Num.at(Ball.at(i) - 1) - 1) * (Num.at(Ball.at(i) - 1) - 2) / 2) << endl;
	}
}

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

#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

using ll = long long;
using ld = long double;
using pt = complex<ld>;

ld dot(pt a, pt b) {return real(conj(a) * b);}

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

constexpr ll lim = 200;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    vector<pt> in(n);
    for (ll i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        in[i] = {x, y};
    }
    ld res = 0;
    ll a = 0;
    for (ll x = -lim; x <= lim; x++) {
        for (ll y = -lim; y <= lim; y++) {
            if (gcd(x, y) != 1) continue;
            a++;
            pt dir = {x, y};
            vector<pt> dist(2);
            for (pt cur : in) {
                if (dot(dir, cur) >= 0) dist[0] += cur;
                if (dot(dir, cur) <= 0) dist[1] += cur;
            }
            res = max({res, abs(dist[0]), abs(dist[1])});
        }
    }
    cout << fixed << setprecision(10) << res << endl;

}


Measured memory_bytes: 512