akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int N, K;
  cin >> N >> K;
  if (N % K == 0) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Random;
import java.util.StringTokenizer;

import java.util.Arrays;

public class Main {

	public static class LeftshiftHeap<T extends Comparable<? super T>> {

		private static class Node<T> {
			Node<T> left, right;
			T value; // value に null を入れると死ぬ.
			int s;

			public Node(T value){ this.value = value; this.s = 1; }
			public Node(Node<T> n){
				this.left = n.left; this.right = n.right;
				this.value = n.value; this.s = n.s;
			}

			public String toString(){ // これはデバッグ用なので削ってもいい.
				return "[" + this.left + "] " + this.value + " [ " + this.right + " ]";
			}
		}

		private static <T extends Comparable<? super T>> Node<T> meld(Node<T> a, Node<T> b){
			if(a == null){ return b; }
			if(b == null){ return a; }
			if(a.value.compareTo(b.value) > 0){ return meld(b, a); } // > で Min, < で Max

			a.right = meld(a.right, b);
			if(a.left == null || a.left.s < a.right.s){
				Node<T> tmp = a.left; a.left = a.right; a.right = tmp;
			}
			a.s = (a.right == null ? 0 : a.right.s) + 1; //交換してるから, rightの方が低い
			return a;
		}

		private Node<T> root = null;
		// 基本的な操作
		public void add(T value){ root = meld(root, new Node<T>(value)); }
		public void pop(){ root = meld(root.left, root.right);}
		public void merge(LeftshiftHeap<T> other){ root = meld(this.root, other.root); }
		// ユーティリティ
		public T poll(){ T val = peek(); pop(); return val; }
		public T peek(){ return root.value; }
		public boolean isEmpty(){ return root == null; }
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		LeftshiftHeap<Integer> heap = new LeftshiftHeap<Integer>();

		while(true){
			final String ops = sc.next();
			if("end".equals(ops)){ break; }
			
			if("extract".equals(ops)){
				System.out.println(-(heap.poll()));
			}else{
				heap.add(-sc.nextInt());
			}
		}
	}
		
	public static class Scanner {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() {
			try {
				while (!hasNext()) {tok = new StringTokenizer(br.readLine());}
			} catch(IOException e){ /* ignore */ }
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() {
			getLine(); return tok.nextToken();
		}

		public int nextInt(){
			return Integer.parseInt(next());
		}

		public void close() {
			try{ br.close(); } catch (IOException e){ /*ignore*/ }
		}
	}
}

Measured memory_bytes: 228512
#include<stdio.h>
#include<stdlib.h>
   
#define MIN_VALUE 1
#define MAX_VALUE 300
#define IS_ERR(n) (n < MIN_VALUE || n > MAX_VALUE)
   
typedef struct _Rect {
    int w;
    int h;
    struct _Rect *next;
} Rect;
   
int main(void)
{
   
    int w, h;
    Rect *rect;
    Rect *pre_rect;
    Rect *start_rect;
   
    pre_rect = (Rect *)malloc(sizeof(Rect));
    pre_rect->w = 0;
    pre_rect->h = 0;
    pre_rect->next = NULL;
   
    start_rect = pre_rect;
   
    while(1)
    {
        scanf("%d %d", &h, &w);
 
        if(w == 0 && h == 0) break;
        if(IS_ERR(w) || IS_ERR(h)) return -1;
   
        rect = (Rect *)malloc(sizeof(Rect));
        rect->w = w;
        rect->h = h;
        rect->next = NULL;
   
        pre_rect->next = rect;
        pre_rect = rect;
    }
   
    rect = start_rect->next;
   
    while(1)
    {
        for(int i=0;i<(rect->h);i++)
        {
            for(int j=0;j<(rect->w);j++)
            {
                printf("#");
            }
            printf("\n");
        }
   
        printf("\n");
   
        rect = rect->next;
        if(rect == NULL) break;
    }
   
    return 0;
}


Measured memory_bytes: 1896
from collections import deque

n, m = [int(v) for v in input().split()]
a_s = [int(v) for v in input().split()]
bc_s = [[int(v) for v in input().split()] for i in range(m)]

bc_s_sorted_by_c = deque(sorted(bc_s, key=lambda x:x[1], reverse=True))


#c_count = 0
#use_index = 0
#for i in range(len(bcs_sorted_by_c)):
#  c_count += bcs_sorted_by_c[0]
#  if(c_count >= n):
#    use_index = i
#    break

a_s_sorted = deque(sorted(a_s, reverse=True))


ans = 0
room = n
while True:
  if len(bc_s_sorted_by_c) >= 1 and a_s_sorted[0] < bc_s_sorted_by_c[0][1]:
    bc = bc_s_sorted_by_c.popleft()
    count, value = bc
  else:
    count, value = 1, a_s_sorted.popleft()
    
  if room < count:
    count = room
    
  ans += value * count
  room -= count
  
  if room <= 0:
    break
    
print(ans)

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

int main(void){
    int n;
    cin >> n;
    map<string,int> d;
    string s;
    int m=1;
    rep(_,n){
        cin >> s;
        d[s]++;
        m=max(m,d[s]);
    }
    for(auto p:d){
        if(p.sc == m){
            cout << p.fs << endl;
        }
    }
}

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

/* next combination */
int next_combination(int sub)
{
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}

void solve(int bit, vector<ll> a)
{

    return;
}

int main()
{
    int n = 0, k = 0;
    cin >> n >> k;

    vector<ll> a(n, 0);
    rep0(i, n)
    {
        cin >> a[i];
    }

    ll cntmin = LLONG_MAX;
    for (int bit = (1 << k) - 1; bit < (1 << n); ++bit)
    {
        if (__builtin_popcount(bit) < k)
        {
            continue;
        }

        vector<int> s(1, 0);
        for (int i = 0; i < n; i++)
        {
            if (bit & (1 << i))
            {
                s.push_back(i);
            }
        }

        vector<ll> b = a;
        ll cnt = 0, m = LLONG_MIN;
        for (int i = 1; i <= k; i++)
        {
            for (int j = s[i - 1]; j < s[i]; j++)
            {
                m = max(m, b[j]);
            }

            if (a[s[i]] <= m)
            {
                cnt += m + 1 - b[s[i]];
                b[s[i]] = m + 1;
            }
        }

        // for (int i = 1; i <= k; i++)
        // {
        //     cout << a[s[i]] << " ";
        // }
        // cout << ": " << cnt << endl;

        cntmin = min(cnt, cntmin);
    }

    cout << cntmin << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		if(N == M){
			System.out.println("Yes");
		}else{
			System.out.println("No");			
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>

using namespace std;

using ll = long long;
using ui = unsigned int;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807;

//C

//B

//A
int main() {
	ll A;
	scanf("%lld", &A);
	ll B;
	scanf("%lld", &B);

	ll result = 0;

	if (A <= 9 && B <= 9) {
		result = A * B;
	}
	else {
		result = -1;
	}

	printf("%lld\n", result);
}


Measured memory_bytes: 256
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    n = int(readline())
    a = list(map(int, readline().split()))
    a.sort()
    limit = a[-1]
    dp = [0] * (limit + 1)
    for aa in a:
        dp[aa] += 1
        if dp[aa] == 1:
            for i in range(aa * 2, limit + 1, aa):
                dp[i] += 1
    print(sum((1 for aa in a if dp[aa] == 1)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 27772
h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
m+='@'*w,
d=[I:=h*w]*I
a=~w+a*w+b
d[a]=1
q=[a]
for s in q:
 for y,x in(1,0),(-1,0),(0,1),(0,-1):
  for z in range(k):
   i,j=s//w+y*~z,s%w+x*~z;t=i*w+j;p=d[s]+1
   if'.'!=m[i][j]or d[t]<p:break
   if d[t]>p:q+=t,;d[t]=p
print(d[~w+f*w+g]%I-1)

Measured memory_bytes: 66276
#include<stdio.h>
#include<math.h>

# define PI 3.141592653589793

int main(void){
	double x=0,y=0;
	double a,rad=0,deg=0;

	while(1){
		scanf("%lf,%lf",&a,&deg);
		if(a==0 && deg==0)break;
		x+=a*sin(rad);
		y+=a*cos(rad);
		rad+=deg*PI/180;
	}
	printf("%d\n%d\n",(int)x,(int)y);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int N, M, a, b; bool vis[100009]; vector<int> g[100009];
int main() {
	cin >> N >> M;
	for(int i = 0; i < M; i++) {
		cin >> a >> b; a--, b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<int> ret = { 0 };
	int pos = 0; vis[0] = true;
	while(true) {
		bool f = false;
		for(int i : g[pos]) {
			if(!vis[i]) {
				f = true;
				vis[i] = true;
				ret.push_back(i);
				pos = i;
				break;
			}
		}
		if(!f) break;
	}
	reverse(ret.begin(), ret.end());
	pos = 0;
	while(true) {
		bool f = false;
		for(int i : g[pos]) {
			if(!vis[i]) {
				f = true;
				vis[i] = true;
				ret.push_back(i);
				pos = i;
				break;
			}
		}
		if(!f) break;
	}
	cout << ret.size() << endl;
	for(int i : ret) cout << i + 1 << ' ';
	return 0;
}

Measured memory_bytes: 6904
/// 11:57 AM 04/04/20
/// Author: t_bone_289 (An Immature Programmer.... I'm still developing !!)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

template<typename T>
void ContainerError(T &v);

ll powmod(ll base, ll exp, ll MOD);

ll mpow(ll base, ll exp);

ll gcd(ll a, ll b);
ll check(ll n,ll k) {
    while(n%k==0) {
        n=n/k;
    }
    return (n%k==1);
}
ll brute(ll n) {
    ll ans=0;
    for(ll i=2;i<=n;i++) {
        if(check(n,i)) {
            ans++;
        }
    }
    return ans;
}
ll opt(ll n) {
    ll ans = 2;
    for(ll i=2;i*i<=n;i++) {
        if(n%i==0) {
            if(check(n,i) == 1) {
                ans++;
            }
            if(check(n,n/i)==1 && i*i!=n) {
                ans++;
            }
        }
    }
    //cout<<ans<<endl;
    n--;
    for(ll i=2;i*i<=n;i++) {
        if(n%i==0) {
            ans+=2;
            if(i*i==n) {
                ans--;
            }
        }
    }
    return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n;
    cin>>n;
    if(n==2) {
        cout<<1;
        return 0;
    }
    cout<<opt(n);

//    ll ans = 0;
//    for(ll i=1;i*i<=n;i++) {
//        if(n%i==0) {
//            ll v1 = n/i;
//            if(check(n,v1)) {
//                //error(v1);
//                ans++;
//            }
//            ll v2 = i;
//            if(check(n,v2)) {
//                //error(v2);
//                ans++;
//            }
//        }
//    }
//    n--;
//    for(ll i=1;i*i<=n;i++) {
//        if(n%i==0) {
//            ll v1 = n/i;
//            if(check(n,v1)) {
//                //error(v1);
//                ans++;
//            }
//            ll v2 = i;
//            if(check(n,v2)) {
//                //error(v2);
//                ans++;
//            }
//        }
//    }
//    cout<<ans<<endl;
//    cout<<brute(n)<<endl;
    return 0;
}

template<typename T>
void ContainerError(T &v) {
    cout << "{";
    for (auto &x:v) { cout << x << ','; }
    cout << "}" << endl;
    return;
}

ll powmod(ll base, ll exp, ll MOD) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2 == 1) res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return (res % MOD);
}

ll mpow(ll base, ll exp) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2 == 1) res = (res * base);
        base = (base * base);
        exp /= 2;
    }
    return (res);
}

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



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

int main()
{
    int k,x;
    scanf("%d %d",&k,&x);
    for(int i=x-k+1;i<=k+x-1;i++)
    {
        if(i<(k+x-1))
            printf("%d ",i);
        else
            printf("%d\n",i);
    }


    return 0;
}


Measured memory_bytes: 256
N = int(input())
D = list(map(int,input().split(" ")))

ans = D[:]
D.sort()
D_1 = []
D_2 = []

for i in range(N):
	if i % 2 == 0:
		D_1.append(24-D[i])
		D_2.append(D[i])
	else:
		D_2.append(24-D[i])
		D_1.append(D[i])


for i in range(N):
	for j in range(i+1,N):
		df1 = abs(D_1[j] - D_1[i])
		df2 = abs(D_2[j] - D_2[i])
		
		df1 = min([df1,24-df1])
		df2 = min([df2,24-df2])
			
		ans.append(df1)
		ans.append(df2)

print(min(ans))






Measured memory_bytes: 3064
N = gets.to_i
L = gets.split.map(&:to_i)

c = 0

(N - 2).times do |i|
  ((i+1)...(N-1)).each do |j|
    ((j+1)...(N)).each do |k|
      if (L[i]!=L[j])&&(L[i]!=L[k])&&(L[j]!=L[k]) then
        s = [L[i],L[j],L[k]].sort
        b = (s[1] - s[2]).abs
        if b < s[0] && s[0] < s[1] + s[2] then
          c += 1
        end
      end
    end
  end
end

puts c


Measured memory_bytes: 14388
a = int(input())

#リストの定義
l = []

for i in range(100//4+1):
	for j in range(100//7+1):
		l.append(4*i+7*j)

#リスト中の重複を削除
set(l)

#l.sort()
#print(l)

#リストlの中にaがある時
if a in l :
	print('Yes')
else:
	print('No')


Measured memory_bytes: 2940
N = int(input())
A = list(map(int,input().split()))
S = set()
T = set()
def counter(array):
    from collections import Counter
    return Counter(array)
c = counter(A)
for x in A:
    S.add(x)
    T.add(x)
cnt = 0
maxi = max(S)
for x in sorted(S):
    i = 2
    while x * i <= maxi:
        if x * i in T:
            T.remove(x*i)
        i += 1
ans = 0
for x in T:
    if c[x] == 1:
        ans += 1
print(ans)

Measured memory_bytes: 170784
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>

using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

Node * find(Node *u, int k) {
	while(u != NIL && k != u->key) {
		if(k < u->key) u = u->left;
		else u = u->right;
	}
	return u;
}

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key   = k;
	z->left  = NIL;
	z->right = NIL;
	
	while(x != NIL) {
		y = x;
		if(z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if(y == NIL) {
		root = z;
	} else {
		if( z->key < y->key) {
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}
	
int main(void) {
	int n, i, x;
	string com;
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		cin >> com;
		if(com[0] == 'f') {
			scanf("%d",&x);
			Node *t = find(root,x);
			if(t != NIL) printf("yes\n");
			else printf("no\n");
		} else if(com == "insert") {
			scanf("%d",&x);
			insert(x);
		} else if(com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}


Measured memory_bytes: 22068
/*
                                               
 ____                 ______           _____   
|    |            ___|\     \      ___|\    \  
|    |           |    |\     \    |    |\    \ 
|    |           |    |/____/|    |    | |    |
|    |        ___|    \|   | |    |    |/____/|
|    |       |    \    \___|/     |    ||    ||
|    |       |    |\     \        |    ||____|/
|____|  ___  |\ ___\|_____|  ___  |____|       
|    | |   | | |    |     | |   | |    |       
|____| |___|  \|____|_____| |___| |____|       
  \(             \(    )/           \(         
   '              '    '             '      
   				template v.1.4   
                                           
*/
#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define sz(s) (int)s.size()
#define OPTIMIZE ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x) cerr << "#" << x << ": " << x << '\n';
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define FORD(i, a, b) for (int i = b; i >= a; i--)
#define FORL(i, a, b) for (LL i = a; i <= b; i++)
#define FORDL(i, a, b) for (LL i = b; i >= a; i--)

using namespace std;

typedef long long LL;
typedef pair<int,int> ii;
typedef pair<LL,LL> pll;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<ii> vii;
typedef vector<pll> vll;

const LL MODPRIME = 1e9 + 7;
const double EPS  = 1e-12;
const LL MAXL = 4e18;
const LL MINL = -4e18;
const int MAXI = 2e9;
const int MINI = -2e9;

int arr[3][3];
int A[3];

int main(){
	// #ifndef ONLINE_JUDGE
	// 	freopen("in.txt", "r", stdin);
	// #endif
	//OPTIMIZE
	cin >> arr[0][1] >> arr[1][2] >> arr[2][0];
	arr[1][0] = arr[0][1];
	arr[2][1] = arr[1][2];
	arr[0][2] = arr[2][0];
	for (int i = 0; i < 3; i++) A[i] = i;
	int ans = INT_MAX;
	do {
		int tmp = 0;
		tmp += arr[A[0]][A[1]];
		tmp += arr[A[1]][A[2]];
		ans = min(ans, tmp);
	}while (next_permutation(A, A+3));
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int gcd(int a,int b){
    int r;
    if(a<b) swap(a,b);
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int atcoder(){
    //入力
    string a,b;
    cin >> a >> b;
    
    //処理

    //出力
    REP(i,0,b.length()) cout << a[i] << b[i];
    if(a.length()>b.length()) cout << a[a.length()-1];
    return 0;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;
using int32 = __uint32_t;

void solve() {
    string s;
    cin >> s;

    for (int i = 1; i < s.size(); i++) {
        if (s[i] == s[i - 1]) {
            cout << i << " " << i + 1 << endl;
            return;
        }
    }
    for (int i = 2; i < s.size(); i++) {
        if (s[i] == s[i - 2]) {
            cout << i - 1 << " " << i + 1 << endl;
            return;
        }
    }
    cout << "-1 -1" << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

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


Measured memory_bytes: 512
#include <stdio.h>

int
main(int argc, char *argv[])
{
    int a, b, c, d, e, f;

    while (6 == scanf("%d %d %d " "%d %d %d\n", &a, &b, &c, &d, &e, &f)) {
        double det, x, y;

        det = a*e - b*d;
        x = (c*e - b*f) / det;
        y = (-c*d + a*f) / det;
        x = (double)((long)(x * 1000)) / 1000;
        y = (double)((long)(y * 1000)) / 1000;
        printf("%.3f %.3f\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 636
#include "bits/stdc++.h"
#define lint long long

using namespace std;

int main() {
	string s;
	cin >> s;
	
	for (int i = 0; i < s.length() - 1; i++) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
	}
	for (int i = 0; i < s.length() - 2; i++) {
		if (s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
	return 0;
}

Measured memory_bytes: 512
n,b,r=list(map(int,input().split()))

m=n%(b+r)
l=n//(b+r)
x=n-l*(b+r)

if x<b:
    s=m
else:
    s=b

if m==0:
    n_b=l*b
else:
    n_b=l*b+s
print(n_b)

Measured memory_bytes: 3060
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, K) = read!(i32, i32);
    println!("{}", if N >= 2 * K - 1 { "YES" } else { "NO" })
}


Measured memory_bytes: 4352
#include <cstdio>
#define rng(x, y) (0 <= x && x < W && 0 <= y && y < H)
#pragma warning(disable : 4996)
using namespace std;
int H, W, d[105][105][4]; long long L; char c[105][105], w[5] = "NESW";
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
int main() {
	while (scanf("%d%d%lld", &H, &W, &L), L) {
		for (int i = 0; i < H; i++) scanf("%s", c[i]);
		int sx = -1, sy = -1, sd = -1;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				for (int k = 0; k < 4; k++) {
					if (c[i][j] == w[k]) sx = j, sy = i, sd = k;
					d[i][j][k] = -1;
				}
			}
		}
		d[sy][sx][sd] = 0;
		int x = sx, y = sy, r = sd;
		while (true) {
			int tx = x, ty = y, tr = r;
			while (!rng(x + dx[r], y + dy[r]) || c[y + dy[r]][x + dx[r]] == '#') r = (r + 1) % 4;
			x += dx[r], y += dy[r];
			if (d[y][x][r] == -1) d[y][x][r] = d[ty][tx][tr] + 1;
			else {
				int t = d[ty][tx][tr] + 1, sa = t - d[y][x][r];
				if (L >= t) L = t + (L - t) % sa - sa;
				break;
			}
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				for (int k = 0; k < 4; k++) {
					if (d[i][j][k] == L) printf("%d %d %c\n", i + 1, j + 1, w[k]);
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2784
#include <stdio.h>

int main(void)
{
	int s, m, h;
	scanf("%d", &s);
	
	h = s/3600;
	m = (s - h*3600)/60;
	s = s - (h*3600 + m*60);
	
	printf("%d:%d:%d\n", h, m ,s);
	
	return 0;
}



Measured memory_bytes: 2128
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

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

	string s;
	cin >> s;
	int ans = 0;
	int d = 0;
	int a = 0, b = 0;
	for (auto i : s) {
		if (i == 'R') {
			d++;
			d %= 4;
		}
		else {
			d += 3;
			d %= 4;
		}
		if (d == 1 && i == 'R')a = 1;
		if (d == 3 && a)b = 1;
		if (d == 0) {
			if (b&&i=='R')ans++;
			a = b = 0;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3256
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<ll>;

ll MOD = 1000000007;



int main()
{
	int N;
	cin >> N;
	vec A(N), B(N), C(N);

	for (int i = 0; i < N; ++i)cin >> A[i];
	for (int i = 0; i < N; ++i)cin >> B[i];
	for (int i = 0; i < N-1; ++i)cin >> C[i];

	int ans = 0;
	for (int i = 0; i < N; ++i)
	{
		ans += B[A[i]-1];

		if (i != 0 && A[i]==A[i-1]+1)
		{
			ans += C[A[i - 1]-1];
		}
	}

	cout << ans << endl;

	return 0;
}

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

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

  int keta = 1;
  int64_t ma = 26;
  int64_t minus = 0;
  while(ma<n) {
    keta++;
    ma += pow(26,keta);
    minus += pow(26,keta-1);
  }

  n -= minus;
  char ans[keta];
  for(int i=0; i<keta; i++) {
    int64_t div = pow(26, keta-i-1);
    int now = n/div;
    n = n%div;
    // if(i==keta-1) ans[i] = (char)(now+96);
    // else ans[i] = (char)(now+97);
    // if(i==keta-1 && now==0) {
    //   ans[i]='z';
    // }
    if(n==0) {
      ans[i]=(char)(now+96);
      if(now==0) ans[i]='z';
    }
    else {
      ans[i] = (char)(now+97);
    }
    // ans[i] = (char)(now+97);
  }

  for(int i=0; i<keta; i++) cout<<ans[i];

  cout<<endl;

  return 0;
}

Measured memory_bytes: 4032
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/













int K, X;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> K >> X;

	bool isTop = true;
	rep(x, -1e6, 1e6 + 1) if (abs(x - X) < K) {
		if (isTop) printf("%d", x);
		else printf(" %d", x);

		isTop = false;
	}
	printf("\n");
}









Measured memory_bytes: 256
import sys

lines = []
for line in sys.stdin:
    num = line.split(" ")
    a, b, e, c, d, f = int(num[0]), int(num[1]), int(num[2]), int(num[3]), int(num[4]), int(num[5])
    x = (e*d-b*f)/(a*d-b*c)
    y = (a*f-e*c)/(a*d-b*c)
    if x == -0.0:
        x = 0.0
    if y == -0.0:
        y = 0.0
    print("{0:.3f} {1:.3f}".format(x,y))

Measured memory_bytes: 7656
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y) {
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;  // X[0] に空白を挿入
  Y = ' ' + Y;  // Y[0] に空白を挿入
  for ( int i = 0; i <= m; i++ ) c[i][0] = 0;
  for ( int j = 1; j <= n; j++ ) c[0][j] = 0;

  for ( int i = 1; i <= m; i++ )
    for ( int j = 1; j <= n; j++ ) {
      if ( X[i] == Y[j] )
        c[i][j] = c[i - 1][j - 1] + 1;
      else
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      maxl = max(maxl, c[i][j]);
    }

  return maxl;
}

int main() {
  string s1, s2;
  int n; cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
  return 0;
}


Measured memory_bytes: 7032
sd = input()
t = input()

def coincide(s, t):
    res = True
    for i in range(0, len(s)):
        if s[i] != t[i] and s[i] != '?':
            res = False
    return res

ss = []
for i in range(0, len(sd) - len(t) + 1):
    if coincide(sd[i:i+len(t)], t):
        ss.append((sd[0:i]+t+sd[i+len(t):]).replace('?', 'a'))
    else:
        continue

if len(ss) != 0:
    print(sorted(ss)[0])
else:
    print('UNRESTORABLE')

Measured memory_bytes: 3064
#include<stdio.h>
#include<algorithm>
#include<vector>
#define fst first
#define snd second

using namespace std;

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

const int MN = 1e5 + 1;
int A[MN];

int main() {
    int N;
    scanf("%d", &N);
    for(int i = 0; i < N; i++) scanf("%d", &A[i]);
    sort(A, A+N);
    if (N % 3 == 0) {
        puts(
            (A[0] == A[N/3 - 1]) &&
            (A[N/3] == A[2*N/3 - 1]) &&
            (A[2*N/3] == A[N-1]) &&
            ((A[0]^A[N/3]^A[2*N/3]) == 0) ? "Yes" : "No"
        );
    }
    else {
        puts((A[0] == A[N-1]) && (A[0] == 0) ? "Yes" : "No");
    }
    return 0;
}

Measured memory_bytes: 512
# coding: utf-8

def func(lx, rx, ly, ry, e):
    ret = 0
    soto_min = 0xdeadbeef

    for i in range(lx, rx+1):
        for j in range(ly, ry+1):
            if i == lx or i == rx or j == ly or j == ry:
                soto_min = min(soto_min, e[j][i])

    for i in range(lx, rx+1):
        for j in range(ly, ry+1):
            if i == lx or i == rx or j == ly or j == ry:
                continue

            if e[j][i] >= soto_min:
                return 0

            ret += (soto_min - e[j][i])

    return ret


while True:
    d, w = map(int, raw_input().split())

    if d == 0 and w == 0:
        break

    e = [map(int, raw_input().split()) for _ in range(d)]

    ans = 0

    for lx in range(w-2):
        for rx in range(lx+2, w):
            for ly in range(d-2):
                for ry in range(ly+2, d):
                    ans = max(ans, func(lx, rx, ly, ry, e))

    print ans



Measured memory_bytes: 4692
import java.io.*;

public class Main{
    public static void main(String args[]){
        int a, b;
        String line;
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            while((line = reader.readLine()) != null) {
                String number[] = line.split(" ");
                a = Integer.parseInt(number[0]);
                b = Integer.parseInt(number[1]);
                a = a + b;
                line = Integer.toString(a);
                System.out.println(line.length());
            }
        } catch (IOException e){
            System.exit(0);
        }
    }
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    ll n; cin >> n;
    vector<int> a(3);
    vector<string> s(n);
    vector<int> ans;
    REP(i, 3) cin >> a[i];
    REP(i, n) cin >> s[i];

    REP(i, n) {
        int idx, idx2;
        idx = s[i][0] - 'A';
        idx2 = s[i][1] - 'A';

        if(a[idx] == 0 && a[idx2] == 0) {
            cout << "No" << endl;
            return 0;
        } else if(a[idx] >= 1 && a[idx2] == 0) {
            a[idx]--, a[idx2]++;
            ans.push_back(idx2);
        } else if(a[idx] == 0 && a[idx2] >= 1) {
            a[idx2]--, a[idx]++;
            ans.push_back(idx);
        } else {
            if(i == n-1) {
                ans.push_back(idx);
            } else {
                int idx3 = s[i+1][0] - 'A';
                int idx4 = s[i+1][1] - 'A';
                if(idx == idx3 || idx == idx4) {
                    a[idx]++, a[idx2]--;
                    ans.push_back(idx);
                } else {
                    a[idx2]++, a[idx]--;
                    ans.push_back(idx2);
                }
            }
        }
    }

    cout << "Yes" << endl;
    REP(i, n) cout << (char)('A' + ans[i]) << endl;
    cout << endl;

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

  cout << t + s << endl;
  return 0;
}


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

int main(){
    int N, M;
    cin >> N >> M;
    double ans = 0.0;
    int level = 100000;
    for(int i=1;i<=level;i++){
        // cout << ans << endl;
        ans += pow(1-pow(0.5, (double)M), (double)(i-1)) *  (double)((N+18*M)*100*i);
    }
    ans *= pow(0.5, (double)M);
    cout << round(ans) << endl;
    return 0;
}

Measured memory_bytes: 256
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n,x=input2()
L=input_array()

D=0
flag=True
for i in range(1,n+1):
	D+=L[i-1]
	if D>x:
		print(i)
		flag=False
		break
if flag:
	print(n+1)

Measured memory_bytes: 9176
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	string a,b,c;
	cin >> a >> b >>c;
	if (a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) cout << "YES" << endl;
	else cout << "NO" << endl;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

ll dp[105][64];

bool bad3( long a, long b, long c) {
    if(a==0 && b==1 && c==2) {
        return true;
    }
    return false;
}

bool bad4( long a, long b, long c, long d) {
    if( bad3(a,b,c) || bad3(b,c,d) || bad3(b,a,c) || bad3(a,c,d) || bad3(a,b,d) || bad3(b,d,c) || bad3(a,c,b) || bad3(c,b,d)) return true;
    return false;
}

ll calc( long n ) {
    if(n<2) return 0;

    long i, k;
    for(i=0; i<n; i++) {
        for(k=0; k<64; k++) {
            dp[i][k]=0;
        }
    }

    for(k=0; k<64; k++) {
        long tmp=k;
        long a=tmp%4; tmp/=4;
        long b=tmp%4;
        long c=tmp/4;
        if(bad3(a,b,c) || bad3(b,a,c) || bad3(a,c,b)) continue;
        dp[2][k]=1;
    }

    for(i=2; i<n-1; i++) {
        for(k=0; k<64; k++) {
            long tmp=k;
            long a=tmp%4; tmp/=4;
            long b=tmp%4;
            long c=tmp/4;
            if(bad3(a,b,c)) continue;

            long d;
            for(d=0; d<4; d++) {
                if(bad4(a,b,c,d)) {
                    //printf("%ld%ld%ld%ld\n", a,b,c,d);
                    continue;
                }

                long next = b+c*4+d*16;
                dp[i+1][next] = (dp[i+1][next] + dp[i][k])%MOD;
            }
        }
    }

    ll ans = 0;
    for(k=0; k<64; k++) {
        ans = (ans + dp[n-1][k])%MOD;
    }
    return ans;
}

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    ll ans = calc( n );
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int mat[128][128];
int n;

void MCM(int *);
int min(int, int);

int main(){
        int i, j, k;
        int *p;

        scanf("%d", &n);
        p = malloc((n + 1) * sizeof(int));
        for(i = 1 ; i <= n ; i++){
                scanf("%d %d", &j, &k);
                if(i == 1)p[0] = j;
                p[i] = k;
        }

        MCM(p);
        /*
        for(i = 0 ; i <= n ; i++){
                for(j = 0 ; j <= n ; j++)
                        printf("%d ", mat[i][j]);
                printf("\n");
        }
        */
        printf("%d\n", mat[1][n]);
        return 0;
}

void MCM(int *p){
        int l, i, j, k;

        for(l = 2 ; l <= n ; l++){
                for(i = 1 ; i <= n - l + 1 ; i++){
                        j = i + l - 1;
                        mat[i][j] = 1000000;
                        for(k = i ; k <= j ; k++){
                                mat[i][j] = min(mat[i][j], mat[i][k] + mat[k+1][j] + p[i-1]*p[k]*p[j]);
                        }
                }
        }
}

int min(int a, int b){
        if(a > b)return b;
        else return a;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;

signed main(){
	int a, b, c, x, y;
  scanf("%lld%lld%lld%lld%lld", &a, &b, &c, &x, &y);
  int m = a+b, ans = 0, res1 = 0, res2 = 0;
  if(m > 2*c)m = 2*c;
  int mn = min(x, y);
  ans += m*mn;
  y -= mn;x -= mn;
  if(x > 0)res1 += x*a;
  if(y > 0)res1 += y*b;
  res2 = m*max(x, y);
  //printf("%lld\n",);
  printf("%lld\n", ans+min(res1, res2));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

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

  ll ans = 0;
  ans += ((h + 1) / 2) * ((w + 1) / 2);
  ans += (h / 2) * (w / 2);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// In The Name Of God

#include<bits/stdc++.h>

#define ll long long

using namespace std;

const int N = 1e5+22 ;

ll t,r,sum,a[N],n;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	
	for(int i=1;i<=n;i++)
	{
		if(i%2==0)
		{
			if(sum+a[i]>0)
			{
				sum+=a[i];
				continue;
			}
			else
			{
				r+=-(a[i]+sum)+1;
				sum=1;
			}
		}
		else
		{
			if(sum+a[i]<0)
			{
				sum+=a[i];
				continue;
			}
			else
			{
				r+=a[i]+sum+1;
				sum=-1;
			}
		}
	}
	t=r;
	sum=0;
	r=0;
	
	for(int i=1;i<=n;i++)
	{
		if(i&1)
		{
			if(sum+a[i]>0)
			{
				sum+=a[i];
				continue;
			}
			else
			{
				r+=-(a[i]+sum)+1;
				sum=1;
			}
		}
		else
		{
			if(sum+a[i]<0)
			{
				sum+=a[i];
				continue;
			}
			else
			{
				r+=a[i]+sum+1;
				sum=-1;
			}
		}
	}
	
	cout<<min(t,r);
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n;
    cin>>n;
    int a[111111], mx = -INF, mn = INF, mxcnt = 0, mncnt = 0;
    rep(i, n) {
        cin>>a[i];
        chmax(mx, a[i]);
        chmin(mn, a[i]);
    }
    if(mx == mn) {
        if(mx == n - 1 || 2 * mx <= n) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    } else {
       if(mx - mn > 1) {
            cout<<"No"<<endl;
            return 0;
       }
        rep(i, n) {
            if(a[i] == mx) mxcnt++;
            else mncnt++;
        }
        if(mncnt < mx && 2 * (mx - mncnt) <= mxcnt) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


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

int main(){
    int N,K,X,Y;
    cin >> N >> K >> X >> Y;

    int sum;
    if(N>K){
        sum = sum + K*X + (N-K)*Y;
    } else {
        sum = sum + N*X;
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (int i = 0; i < (o);i++)
#define rep_s(i, o) for (int i = 1; i < (o);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

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

    int candies[2][n];
    rep(i, 2) {
        rep(j, n) {
            cin >> candies[i][j];
        }
    }

    int s[n+1][2];
    s[0][0] = candies[0][0]; s[0][1] = 0;
    rep_s(i, n) {
        s[i][0] = s[i-1][0] + candies[0][i]; // right
        s[i][1] = max(s[i-1][1] + candies[1][i-1], s[i-1][0] + candies[1][i-1]);   // down
        // cout << s[i][0] << " " << s[i][1] << endl;
    }
    s[n-1][1] = max(s[n-1][0] + candies[1][n-1], s[n-1][1] + candies[1][n-1]);
    cout << s[n-1][1] << endl;
    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else if ( A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define N (int)1e5
#define f1 first
#define s2 second
#define INF INT_MAX
#define pb push_back
#define ll long long
#define ull unsigned long long;
#define all(a) a.begin(),a.end()
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);

ll dizi[N],dp[N],n,k;

int main(){
	//fri("in.txt");
	//fro("out.txt");
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		dp[i] = INF;
		cin >> dizi[i];
	}
	dp[0] = 0;
	dp[1] = abs(dizi[1] - dizi[0]);
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= k && i - j >= 0; j++){
			dp[i] = min(dp[i] , dp[i-j] + abs(dizi[i] - dizi[i-j]));
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1792
while True:
    m, f, r  = [int(_) for _ in input().split()]
    if m == f == r == -1:
        break

    if m == -1 or f == -1:
        rank = "F"
    elif (m + f) >= 80:
        rank = "A"
    elif 65 <= (m + f) < 80:
        rank = "B"
    elif 50 <= (m + f) < 65:
        rank = "C"
    elif 30 <= (m + f) < 50:
        if r >= 50:
            rank = "C"
        else:
            rank = "D"
    else:
        rank = "F"
    print(rank)


Measured memory_bytes: 5604
fun main(args:Array<String>):Unit {
    var current = readLine()!!.trim().toInt()
    while(true){
        val op = readLine()!!.trim()
        when(op){
            "=" -> {
                println(current)
                return
            }
            else -> {
                val right = readLine()!!.trim().toInt()
                when(op){
                    "+" -> current += right
                    "-" -> current -= right
                    "*" -> current *= right
                    else -> current /= right
                }
            }
        }
    }
}


Measured memory_bytes: 28832
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double PI = 3.14159265358979323846;
typedef long long ll;

int main(void) {
  int n, d[100009];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> d[i];
  sort(d, d + n);
  int ans = d[(n - 1) / 2 + 1] - d[(n - 1) / 2];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {

  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;

  ll a;
  set<ll> st;
  
  for (int i = 0; i < N; i++) {
    cin >> a;
    st.insert(a);
  }

  cout << st.size() << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000

int main(){
	
	string N;
	cin>>N;	
	
	reverse(N.begin(),N.end());
	N+='0';
	
	vector<vector<int>> dp(N.size(),vector<int>(2,Inf));
	
	dp[0][0] = N[0]-'0';
	if(N[0]!='0')dp[0][1] = 10-dp[0][0];
	
	for(int i=0;i<N.size()-1;i++){
		int k = N[i+1]-'0';
		dp[i+1][0] = min(dp[i+1][0],dp[i][0] + k);
		if(k!=0)dp[i+1][1] = min(dp[i+1][1],dp[i][0] + (10-k));
		
		k++;
		if(k==10){
			dp[i+1][1] = min(dp[i+1][1],dp[i][1]);
		}
		else{
			dp[i+1][0] = min(dp[i+1][0],dp[i][1] + k);
			if(k!=0)dp[i+1][1] = min(dp[i+1][1],dp[i][1] + (10-k));
		}
	}
	
	cout<<min(dp.back()[0],dp.back()[1])<<endl;
	
	return 0;
}



Measured memory_bytes: 55940