akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	n := sc.NextInt()

	ans := n - 1
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			tmp := n / i
			tmp_ans := (i - 1) + (tmp - 1)
			if tmp_ans < ans {
				ans = tmp_ans
			}
		}
	}
	fmt.Printf("%v\n", ans)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
n=input()
length=len(n)
if length==1:
    print(n)
elif length==2:
    print(9)
elif length==3:
    print(9+int(n)-99)
elif length==4:
    print(9+900)
elif length==5:
    print(9+900+int(n)-9999)
else:
    print(9+900+90000)


Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <ctime>
#include <cstdlib>
#include <cstdio>

using namespace std;

string createStr ( char s, char e, int num, set<string> &S )
{
	string ret;

	do
	{
		ret.clear();
		ret.push_back(s);

		for (int i = 0, ilen = num - 2; i < ilen; ++i)
		{
			ret.push_back('a' + rand() % 26);
		}

		ret.push_back(e);

	} while(S.count(ret));

	return ret;
}

bool check ( string prev, string str, set<string> &S )
{
	if (S.count(str)) return true;
	if (str.size() > 2) return true;
	if (str.size() < 1) return true;
	if (prev[prev.size()-1] != str[0]) return true;
	for (int i = 0, ilen = str.size(); i < ilen; ++i)
	{
		if ('a' > str[i] || str[i] > 'z') return true;
	}
	return false;
}

int main ( void )
{
	set<string> S;
	char s = 'a';
	char e = 'b';
	string player = createStr(s, e, 5, S), computer;

	while (true)
	{
		S.insert(player);
		cout << '?' << player << endl;

		cin >> computer;

		if (check(player, computer, S))
		{
			cout << "!OUT" << endl;
			break;
		}

		S.insert(computer);

		player = createStr(computer[computer.size()-1], e, 5, S);
	}
	return 0;
}

Measured memory_bytes: 1260
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    int v[n];
    for (int i = 0; i <n ; ++i) {
        scanf("%d", &v[i]);
    }
    fflush(0);
    int c[n];
    for (int i = 0; i <n ; ++i) {
        scanf("%d", &c[i]);
    }
    fflush(0);
    int ans= 0;
    for (int i = 0; i <n ; ++i) {
        if(v[i] > c[i]){
            ans += v[i] - c[i];
        }
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxx = 110;
const LL INF = (1LL << 32);

int n,q;
LL d[maxx][maxx];

void floyd() {
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			if (d[i][k] == INF)
				continue;
			for (int j = 0; j < n; j++) {
				if (d[k][j] == INF)
					continue;
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}
int main()
{
	int u, v, c;
	scanf("%d %d", &n, &q);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)
			d[i][j] = i == j ? 0 : INF;
	}

	// ?????\??????
	for (int i = 0; i < q; i++) {
		scanf("%d %d %d", &u, &v, &c);
		d[u][v] = c;
	}

	floyd();
	
	// ?????????????????¨?´????
	bool negative = false;
	for (int i = 0; i < n; i++)
		if (d[i][i] < 0)
			negative = true;

	if (negative)
		printf("NEGATIVE CYCLE\n");
	else {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (d[i][j] == INF)
					printf("INF");
				else
					printf("%d", d[i][j]);
				printf("%c", j == n - 1 ? '\n' : ' ');
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3292
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = myconv(next(),4);
  var a = one[0];
  var b = one[1];
  var c = one[2];
  if(a == b && a != c ||
    a == c && b != c ||
    b == c && a != c){
     myout("Yes");
  }else{
    myout("No");
  }
}

Measured memory_bytes: 22080
N = int(input())
A = [0] + [int(input()) for i in range(N)]

ans = 0
for i in range(1, N+1):
  a = A[i]; pre_a = A[i-1]
  if pre_a == 1 and a >= 1:
    ans += 1
    a -= 1
  ans += a//2
  A[i] = a % 2

print(ans)

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

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	map<char, int> freq;
	for(char x : s){
		freq[x]++;
	}
	int ans = 1;
	for(auto r : freq){
		ans = (1ll * ans * (r.second + 1) ) % 1000000007;
	}
	ans--;
	cout << ans << '\n';
}

Measured memory_bytes: 1020
<?php

fscanf(STDIN, "%s", $b);

switch ($b) {
    case 'A':
        echo 'T';
        break;
    case 'T':
        echo 'A';
        break;
    case 'C':
        echo 'G';
        break;
    case 'G':
        echo 'C';
        break;
}


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

using namespace std;

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF 1000000007
#define PI 3.141592653
#define inf 100007
#define P pair<ll,ll>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

bool prime[100001];
int c[inf];
void SieveOfEratosthenes(int n) 
{
    prime[1]=true;
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == false) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = true; 
        } 
    }
}

int main(){
    int q;
    cin>>q;
    SieveOfEratosthenes(100000);
    vi v,ans;
    for (int i = 3; i <= 100000; i+=2)
    {
        if(!prime[i] && !prime[((i+1)/2)]) c[i]++;
    }
    for(int i=3;i<=100000;i++) c[i]+=c[i-1];
    for (int i = 0; i < q; i++){
        int l,r;
        cin>>l>>r;
        ans.pb(c[r]-c[l-1]);
    }
    pan(i,(int)ans.size()) cout<<ans[i]<<endl;
}

Measured memory_bytes: 1656
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(a)-1;i>=n;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define sn st.nd 
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
/****************************/
ll n,m,k;
int a[100010];
string s;
int main()
{
	cin>>n;
	cin>>m;
//	cin>>k;
//	cin>>s;
	ll x;
	x=n*m;
	cout<<x;
	return 0;
}

Measured memory_bytes: 3596
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            a0, l = map(int, raw_input().split())
            if a0 == 0 and l == 0:
                break
            a = [a0]
            flg = False
            for i in range(21):
                x = list(str(a[i] + 10 ** l))[1:]
                x.sort()
                min_num = int(''.join(x))
                x.sort(reverse=True)
                max_num = int(''.join(x))
                n = max_num - min_num
                for j in range(len(a)):
                    if a[j] == n:
                        print str(j) + ' ' + str(a[j]) + ' ' + str(i - j + 1)
                        flg = True
                        break
                if flg:
                    break
                a.append(n)
            
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Measured memory_bytes: 4660
#include <iostream>
#include <math.h>

using namespace std;

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

	int maxi = max(a,max(b,c));
	int ans = 0;

	if(a == maxi){
		ans += b + c;
		ans += a * pow(2.0,k);
	}else if(b == maxi){
		ans += a + c;
		ans += b * pow(2.0,k);
	}else{
		ans += a + b;
		ans += c * pow(2.0,k);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    int ans=0;
    vc<pi> A[N];
    rep(i,N){
        int a; cin >> a;
        rep(j,a){
            int b,c; cin >> b >> c;
            b--;
            A[i].eb(b,c);
        }
    }
    rep(i,(1<<N)){
        int cnt=0;
        rep(j,N){
            if((i>>j)&1)cnt++;
        }
        bool frag=true;
        rep(j,N){
            if((i>>j)&1){
                rep(k,A[j].size()){
                    if(((i>>A[j][k].fi)&1)^A[j][k].se) frag=false;
                }
            }
        }
        if(frag) ans=max(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
int INF = numeric_limits<int>::max() / 2;
using ll = long long;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    if(n%k == 0) cout << 0;
    else cout << 1;
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    ll A[100100], A_[100100], B[100100], B_[100100];
    rep(i, N + 1) {
        cin >> A[i];
        A_[i] = A[i];
    }
    rep(i, N) {
        cin >> B[i];
        B_[i] = B[i];
    }
    ll cnt1 = 0, cnt2 = 0;
    rep(i, N) {
        if(B[i] <= A[i]) {
            cnt1 += B[i];
            continue;
        } else {
            cnt1 += A[i];
            B[i] -= A[i];
            if(B[i] <= A[i + 1]) {
                cnt1 += B[i];
                A[i + 1] -= B[i];
            } else {
                cnt1 += A[i + 1];
                A[i + 1] = 0;
            }
        }
    }
    per(i, N) {
        if(B_[i] <= A_[i + 1]) {
            cnt2 += B_[i];
            continue;
        } else {
            cnt2 += A_[i + 1];
            B_[i] -= A_[i + 1];
            if(B_[i] <= A_[i]) {
                cnt2 += B_[i];
                A_[i] -= B_[i];
            } else {
                cnt2 += A_[i];
                A_[i] = 0;
            }
        }
    }
    ll ans = max(cnt1, cnt2);
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3456
/* package whatever; // don't place package name! */
 
import java.util.*;
import java.lang.*;
import java.io.*;
 
public class Main
{
	public static void main (String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
		int left = in.nextInt() + in.nextInt();
		int right = in.nextInt() + in.nextInt();

		if(left > right) {
			System.out.println("Left");

		} else if(left < right) {
			System.out.println("Right");
		} else 
		System.out.println("Balanced");
 	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  map<int, int> o;
  for(int i = 0; i < n; i++){
    int x; cin >> x;
    o[x]++;
  }
  int k = 0;
  for(auto it : o) k += it.second - 1;
  cout << n - 2 * ((k + 1) / 2) << endl;
  return 0;
}


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

int main(void){
  vector<int> v;
  int i, tmp;
  cin >> i;
  for (int f=0; f<i; f++) {
    cin >> tmp;
    v.push_back(tmp);
  }
  for (int l=0; l<i; l++) {
    if (l!=0) {
      cout << " ";
    }
    cout << v[-1*l+i-1];
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
vector<ll> num;
int main() {
  ll a,b,k;
  cin>>a>>b>>k;
  map<ll,ll>mp;
  for(int i=0;i<k;i++){
    if(!mp[a+i]&&a+i<=b){
      num.push_back(a+i);
      mp[a+i]++;
    }
    if(!mp[b-i]&&b-i>=a){
      num.push_back(b-i);
      mp[b-i]++;
    }
  }
  sort(num.begin(),num.end());
  for(int i=0;i<num.size();i++)cout<<num[i]<<endl;
  return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True


def main():
    s = S()
    t = S()

    for i in range(len(s)):
        if s[i] != t[i]:
            print('No')
            return

    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 74468
/* ITP1_9_D */
import java.io.*;

class Main
{
  public static void main(String[] args)
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String str = br.readLine();
      int q = Integer.parseInt(br.readLine());

      for(int i = 0; i < q; i++){
        String[] order = br.readLine().split(" ");
        int a = Integer.parseInt(order[1]);
        int b = Integer.parseInt(order[2]);
        StringBuilder sb = new StringBuilder();
        String sub = str.substring(a, b+1);

        switch(order[0]){
          case "print":
            sb.append(str.substring(a,b+1));
            System.out.println(sb);
            break;
          case "reverse":
            sb.append(sub);
            sb.reverse();
            sb.insert(0, str.substring(0, a));
            sb.insert(b+1, str.substring(b+1, str.length()));
            str = sb.toString();
            break;
          case "replace":
            sb.append(str.substring(0, a));
            sb.append(order[3]);
            sb.append(str.substring(b+1, str.length()));
            str = sb.toString();
            break;
          default:
            break;
        }
      }
    }catch(Exception e){
      System.out.println(e);
    }
  }
}

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

using namespace std;

void topologicalordering(map<int,vector<int>> &graph,int *visited,queue<int> &s,int n,int ver){

  visited[ver]=1;

  for(int i=0;i<graph[ver].size();i++){
   
       if(visited[graph[ver][i]]==0)
       topologicalordering(graph,visited,s,n,graph[ver][i]);


  }

  s.push(ver);

}



int longestlengthpath(map<int,vector<int>> &graph,int n){



  queue<int> s;
  int visited[n]={0};


     for(int i=0;i<n;i++){
     	if(visited[i]==0)
   topologicalordering(graph,visited,s,n,i);
}


int DP[n];

int ans=0;
while(s.size()!=0){


 int ver=s.front();
 s.pop();

 DP[ver]=0;


 for(int i=0;i<graph[ver].size();i++){
 	DP[ver]=max(DP[ver],1+DP[graph[ver][i]]);

 	
 }
 	if(DP[ver]>ans)
 		ans=DP[ver];

}
return ans;
}

int main(){



   int n,e;

   cin>>n>>e;

   map<int,vector<int>> graph;

   for(int i=0;i<e;i++){

    int v1,v2;
     cin>>v1>>v2;

     graph[v1-1].push_back(v2-1);


   }


  cout<<longestlengthpath(graph,n)<<endl;


	return 0;
}

Measured memory_bytes: 20436
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


def main():

    ss = list(input())[:-1]

    ss = s(ss)

    n = len(ss)

    x,y = m()

    x += 8000

    y += 8000

    dpx = set([8000])

    dpy = set([8000])

    ro = 0

    for i in range(1,n+1):
        pop = ss[i-1]
        if pop[0] == "T":
            if pop[1] % 2 == 1:
                ro ^= 1
        else:
            if i == 1:
                dpx = set([8000+pop[1]])
            else:
                if ro == 0:
                    ch = set()
                    for num in dpx:
                        if num + pop[1] <= 16000:
                            ch.add(num + pop[1])    
                        if num - pop[1] >= 0:
                            ch.add(num - pop[1])
                        dpx = ch
                else:
                    ch = set()
                    for num in dpy:
                        if num + pop[1] <= 16000:
                            ch.add(num + pop[1])
                        if num - pop[1] >= 0:
                            ch.add(num - pop[1])
                        dpy = ch

    if x in dpx and y in dpy:
        print("Yes")
    else:
        print("No")

            


if __name__ == "__main__":
    main()


Measured memory_bytes: 50780
//  Copyright ? 2019 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 1000005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
typedef long long ll;

const ll MOD = 998244353;
ll T;

const ll LIM = 4e5;
ll fact[LIM + 5];
ll finv[LIM + 5];

ll fastpow( ll b , ll e )
{
    ll ans = 1;
    while( e > 0 )
    {
        if( e & 1 )
            ans = ( ans * b ) % MOD;
        
        b = ( b * b ) % MOD;
        e >>= 1;
    }
    return ans;
}

ll nCk( ll n , ll k )
{
    return ( fact[n] * ( ( finv[k] * finv[n - k] ) % MOD ) ) % MOD;
}

void calcFact() {
    fact[0] = finv[0] = 1;
    for( ll i = 1; i <= LIM; i ++ )
        fact[i] = ( fact[i - 1] * i ) % MOD;
    
    finv[LIM] = fastpow( fact[LIM] , MOD - 2 );
    
    for( ll i = LIM - 1; i >= 1; i -- )
        finv[i] = ( finv[i + 1] * ( i + 1 ) ) % MOD;    
}

ll solve( ll N , ll M , ll K ) {
    if( N == K )
        return 0;
    ll ans = nCk( N , K );
    ans = ( ans * fastpow( M , N - K ) );
    return ans % MOD;
}
int main(){
	optimiza_io
	calcFact();
	ll N,M,K;
	cin>>N>>M>>K;
	ll ans=0;
	while(K>=0){
		ll tmp=nCk(N-1,K);
		tmp=(tmp*M)%MOD;
		tmp=(tmp*fastpow(M-1,N-K-1)); 
		ans=(ans+tmp)%MOD;
		K--;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 9904
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
typedef int64_t i64;

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

int N; cin >> N;
VI p(N); rep(i, 0, N) cin >> p[i];

int cnt = 0;
rep(i, 0, N-1){
    if (p[i] == i + 1) {
        ++cnt;
        swap(p[i], p[i+1]);
    }
}
if (p[N-1] == N) ++cnt;

cout << cnt << endl;

}
// 書いて考える．場合分け
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
const LL M = 1e9+7;
using Memo = pair<LL, LL>;
map<Memo,LL> memo;
LL f(LL S, LL X) {
  Memo m(S, X);
  if(memo.count(m)) return memo[m];
  if(S==0) return 1;
  memo[m] = f(S/2, X/2) + f((S-1)/2, (X^1)/2) % M;
  if(S >= 2) memo[m] += f((S-2)/2, X/2);
  return memo[m] %= M;
}
int main() {
  LL N;
  cin >> N;
  cout << f(N, N) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,t[100010],a,b,c,d,e,f,i;
  while(scanf("%d",&n),n){
    int t[100010]={};
    while(n--){
      scanf("%d:%d:%d %d:%d:%d",&a,&b,&c,&d,&e,&f);
      t[a*3600+b*60+c]++;
      t[d*3600+e*60+f]--;
    }
    for(i=a=b=0;i<100000;i++){
      a+=t[i];
      if(b<a)b=a;
    }
    printf("%d\n",b);
  }
  return 0;
}
  

Measured memory_bytes: 996
#include<bits/stdc++.h>
using namespace std;
int n,m,sav=0,re=1,a,cnt,mmm[1008611];
map<int,int> pro,can;
int main(){
	scanf("%d",&n);
	//map<int,int>::iterator it;
	for(int i=0;i<n;i++){
		scanf("%d",&a);
		//it = can.find(a);
		if(can[a]!=0) can[a]++;
		else can[a]=1;
	}
	scanf("%d",&m);
	for(int i=0;i<m;i++){
		scanf("%d",&a);
		//it = pro.find(a);
		if(pro[a]!=0) pro[a]++;
		else{
	        pro[a]=1;
	        mmm[cnt++]=a;
	    }
	}
	int p;
	for(int i=0;i<cnt;i++){
		p=pro[mmm[i]];//it = can.find(mmm[i]);
	    if(can[mmm[i]]!=0&&p<=can[mmm[i]]){
			sav=1;
		}
		if(sav==0){
			re=0;break;
		}else if(sav==1){
			sav=0;
		}
	}
	if(re==1) printf("YES");
	else printf("NO");
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &i : a) {
    cin >> i;
  }

  int ans = 1e9;

  for (int change = -100; change <= 100; change++) {
    int cost = 0;
    for (auto &i : a) {
      cost += (i - change) * (i - change);
    }
    ans = min(ans, cost);
  }
  cout << ans << "\n";
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int mINF = 1e9;
const int MOD = 1e9+7;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    int n;cin >> n;
    cout << (n-1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll L_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;
// const double PI = M_PI;

const ll MAX = pow(10, 18);
ll N;
vector<ll> A;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  A.resize(N);
  for (int i = 0; i < N; i++) {
    ll tmp;
    cin >> tmp;
    A[i] = tmp;
    if (A[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = 1;
  for (int i = 0; i < N; i++) {
    if (ans > MAX / A[i]) {
      ans = -1;
      break;
    }
    ans *= A[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1000100;


int n,m;
int N;
int b[10010];
int a[110][110];
int main()
{
    scanf("%d%d",&n,&m);
    scanf("%d",&N);
    for(int i=1;i<=N;i++)
       {
             scanf("%d",&b[i]);
       }
       int flag=0;
   int i=1,j=1;


   int len=1;
   int tot=0;
   while(len<=N&&tot<=n*m)
    {
           while(flag==0&&b[len]>0&&j<=m)
           {
                b[len]--;
               a[i][j]=len,tot++;
               if(b[len]==0)len++;
               j++;
               if(j>m)
               {
                   flag=1;
                   i++;
                   j=m;
                   break;
               }

           }
           while(flag==1&&b[len]>0&&j>=1)
           {
               b[len]--;
               a[i][j]=len,tot++;

               if(b[len]==0)len++;
               j--;
               if(j<1)
               {
                   flag=0;i++;j=1;break;
               }
           }
   }

   for(int i=1;i<=n;i++)
   {
       printf("%d",a[i][1]);
       for(int j=2;j<=m;j++)
        printf(" %d",a[i][j]);
     printf("\n");
   }


}


Measured memory_bytes: 384
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, X = il()
    print((B // X) - ((A - 1) // X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9844
n = int(input())
A = list(map(int, input().split()))
r = 1
if n>2:
    d = A[1]-A[0]
    for i in range(2, n):
        if d:
            if (A[i]-A[i-1])*d<0:
                r += 1
                d = 0
        else:
            d = A[i]-A[i-1]
print(r)

Measured memory_bytes: 14224
#include<iostream>
#include<set>
#include<algorithm>
using namespace std;
long N,M,i,l=1,a;
int main(){
  cin>>N>>M;
  set<long>A;
  for(i=0;i<N;i++){
    cin>>a;
    A.insert(a/2);
  }
  for(auto a:A)l=l*a/__gcd(a,l);
  for(auto a:A){
    if(l/a%2)continue;
    cout<<0<<endl;
    return 0;
  }
  cout<<(M/l+1)/2<<endl;
}


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

int main(){
    for (int n; cin >> n, n;) {
        vector<string> s(n);
        rep(i, n) {
            cin >> s[i];
            auto pos = s[i].find_last_of('.');
            if (pos == string::npos) continue;
            fill_n(s[i].begin(), pos, ' ');
            s[i][pos] = '+';
            for (int j = i - 1; j >= 0 && s[j][pos] == ' '; --j) s[j][pos] = '|';
        }
        for (auto& e : s) cout << e << endl;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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; }

using ll = long long;
using namespace std;

// 遅延評価セグメント木 lazyRmaxQ
struct lazyRmaxQ{
    ll n;
    vector<ll> node, lazy;

    // 初期化
    lazyRmaxQ(int n_){
        int x = 1;
        while ( x < n_ ) x *= 2;
        n = x;
        node.resize(n*2-1,0);
        lazy.resize(n*2-1,0);
        }
    // 遅延評価
    void eval(int k, int l, int r){
        if(lazy[k] != 0){
            node[k] += lazy[k];
            if(r-l > 1){
                lazy[2*k+1] += lazy[k];
                lazy[2*k+2] += lazy[k];
            }
            lazy[k] = 0;
        }
    }
    // 値の加算（変更）
    void update(int a, int b, ll x, int k = 0, int l = 0, int r = -1){
        if(r == -1) r = n;
        eval(k,l,r);
        if (r <= a || b <= l) return;
        else if (a <= l && r <= b){
            lazy[k] = x;
            eval(k,l,r);
        }
        else {
            update(a, b, x, k * 2 + 1, l, (l + r) / 2);
            update(a, b, x, k * 2 + 2, (l + r) / 2, r);
            node[k] = max(node[2*k+1], node[2*k+2]);
        }
    }
    // 区間maxを取得する
    ll query(int a, int b, int k = 0, int l = 0, int r = -1){
        if(r == -1) r = n;
        if (r <= a || b <= l) return 0;
        eval(k, l, r);
        if (a <= l && r <= b) return node[k];
        else {
            ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return max(vl, vr);
        }
    }
};

int main(){
    int n, m; cin >> n >> m;
    vector<vector<pair<ll,ll>>> data(n);
    rep(i,m){
        ll l, r, a; cin >> l >> r >> a; l--; r--; // 区間[l,r]にaを加算 0-indexed
        data[r].pb(make_pair(l,a));
    }

    lazyRmaxQ ans(n);

    rep(i,n){
        ans.update(i, i+1, ans.query(0,i+1));
        for(auto p : data[i]) ans.update(p.first, i+1, p.second);
    }
    cout << max(0ll, ans.query(0,n)) << endl;
    return 0;
}

Measured memory_bytes: 22468
#include<cstdio>
using namespace std;
int main(void){
    // printf("%ld\n",2147483648L % 1000000007L );
    // return 0;
    int N;
    scanf("%d",&N);
    int A[N];
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
    }

    long ans=1;
    int C[N];
    for(int i=0;i<N;i++){
        C[i]=0;
    }
    // for(int i=0;i<N/2;i++){
    //     ans*=2L;
    // }
    for(int i=0;i<N;i++){
        C[A[i]]++;
    }
    
    for(int i=1;i<N;i++){
            if(C[i]==2){
                ans*=2l;
                ans%=1000000007L;
            }else if(C[i]==1||C[i]>2){
                ans=0;
                break;
            }
    }

    int f= N%2 ;
    for(int i=N-2;i>=1;i-=2){
        if(C[i]!=0){
            ans=0;
            break;
        }
    }
    for(int i=N-1;i>=1;i-=2){
        if(C[i]!=2){
            ans=0;
            break;
        }
    }

    if(f==0&&C[0]!=0){ans=0;}
    if(f==1&&C[0]!=1){ans=0;}

    printf("%ld\n",ans);
    // printf("0");
    return 0;
}

Measured memory_bytes: 896
#include <iostream>

using namespace std;

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  for (int i = 0; i < k && i + a <= b; i++) {
    cout << a + i << endl;
  }
  int j = b - k + 1;
  if (b - k < a + k) {
    j = a + k;
  }
  for (; j <= b; j++) {
    cout << j << endl;
  }
  return 0;
}


Measured memory_bytes: 3132
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N, M, X, Y; cin >> N >> M >> X >> Y;
  int x[N]; rep(i,N) cin >> x[i];
  int y[M]; rep(i,M) cin >> y[i];

  sort(x, x+N); sort(y, y+M);
  string result = (x[N-1]<y[0] && ( (x[N-1]>X&&x[N-1]<Y) || (y[0]>X&&y[0]<Y) ) ) ? "No War" : "War";
  cout << result << endl;
  return 0;
}

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

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

const ll INF = 1LL << 60;

int main() {
    string S; cin >> S;
    int N = S.length();
    
    int sum = 0;
    int r = 0;
    int b = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == '0') {
            if (b > 0) {
                b--;
                sum += 2;
            } else {
                r++;
            }
        } else {
            if (r > 0) {
                r--;
                sum += 2;
            } else {
                b++;
            }
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

struct test{
    signed short mid;
    signed short fin;
    signed short re;
    unsigned char eval;
};char evaluate(int mid, int fin, int re);
int main(){
    struct test test[50];
    int i;
    int count = 0;
    for(i = 0;i < 50;i++){
        scanf("%d %d %d", &test[i].mid, &test[i].fin, &test[i].re);
        if(test[i].mid == -1 && test[i].fin == -1 && test[i].re == -1){
            break;
        }
        test[i].eval = evaluate(test[i].mid, test[i].fin, test[i].re);
        count++;
    }
    for(i = 0;i < count;i++){
        printf("%c\n", test[i].eval);
    }
    return 0;
}

char evaluate(int mid, int fin, int re){
    if(mid == -1 || fin == -1){
        return 'F';
    }
    if(mid + fin >= 80){
        return 'A';
    }
    else if(mid + fin >= 65){
        return 'B';
    }
    else if(mid + fin >= 50){
        return 'C';
    }
    else if(mid + fin >= 30){
        if(re >= 50){
            return 'C';
        }
        else{
            return 'D';
        }
    }
    else{
        return 'F';
    }
}


Measured memory_bytes: 2040
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws Exception {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//		
//		String input = br.readLine();
//		int count = 0;
//		for(int i=0; i<input.length(); i++) {
//			if(input.charAt(i) == '1') count++;
//		}
//		System.out.println(count);
//		br.close();
		
		
		int num = Integer.parseInt(br.readLine());
		StringTokenizer valuesToks = new StringTokenizer(br.readLine(), " ");
		
		int[] values = new int[num];
		for(int i=0; i<num; i++) {
			values[i] = Integer.parseInt(valuesToks.nextToken());
		}
		
		int count = 0;
		while(true) {
			for(int i=0; i<values.length; i++) {
				if((values[i] % 2) == 0) {
					values[i] /= 2;
				} else {
					System.out.println(count);
					System.exit(0);
				}
			}
			count ++;
		}
		
		
		
	}

}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<ll> A_org(N);
    for (int i = 0; i < N; i++) {
        cin >> A_org[i];
    }

    vector<ll> A = A_org;
    SORT(A);
    vector<pll> p;
    Rep(i, 1, N-1){
        if(A.front() <= 0 && 0 <= A.back()){
            if(A[i] < 0){
                p.emplace_back(A.back(), A[i]);
                A.back() -= A[i]; 
            }else{
                p.emplace_back(A.front(), A[i]);
                A.front() -= A[i];
            }
        }else if(A.front() >= 0){
            p.emplace_back(A.front(), A[i]);
            A.front() = -abs(A.front() - A[i]);
        }else{
            p.emplace_back(A.back(), A[N-2]);
            A.back() = A.back() - A[N-2];
            for(int j = N-2; j > i; j--) A[j] = A[j-1]; 
        }
    }

    ll ans = abs(A.back() - A.front());
    p.emplace_back(A.back(), A.front());

    pr(ans);
    for(auto&& pi : p) pr(pi.fi, pi.se);

    // A = A_org;
    // for(auto&& ai : A) ai = -ai;
    // SORT(A);
    // vector<pll> q;
    // Rep(i, 1, N-1){
    //     if(A.front() < 0 && 0 < A.back()){
    //         if(A[i] < 0){
    //             q.emplace_back(A.back(), A[i]);
    //             A.back() -= A[i]; 
    //         }else{
    //             q.emplace_back(A.front(), A[i]);
    //             A.front() -= A[i];
    //         }
    //     }else{
    //         q.emplace_back(A.front(), A[i]);
    //         A.front() = -abs(A.front() - A[i]);
    //     }
    // }

    // // ll ans_b = abs(A.back() - A.front());
    // ll ans_b = -INF;
    // q.emplace_back(A.back(), A.front());

    // pr(ans_a>=ans_b?ans_a:ans_b);
    // if(ans_a >= ans_b) for(auto&& pi : p) pr(pi.fi, pi.se);
    // else for(auto&& qi : q) pr(-qi.fi, -qi.se);
}

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

using namespace std;

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

	int a, b, h, m;

	cin >> a >> b >> h >> m;


	double rm = (double) 1 / 60;
	double rh = (double) 1 / 12 / 60;

	double pm = m * rm;
	double ph = ((60*h) + m) * rh;

	double dm = 2 * M_PI * pm;
	double dh = 2 * M_PI * ph;

	double x1 = a * cos(dh);
	double y1 = a * sin(dh);

	double x2 = b * cos(dm);
	double y2 = b * sin(dm);

	cout << setprecision(12) << sqrt(pow((x1 - x2), 2) + pow((y1 - y2), 2)) << "\n";



	return 0;
}

Measured memory_bytes: 4184
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}
ll fact(ll n)
{
    ll i,cnt=0,temp,ans=1;;
    while(n%2==0)
    {
        n/=2;cnt++;
    }temp=n;ans*=cnt+1;
    for(i=3;i*i<=temp;i+=2)
    {
        cnt=0;
        while(n%i==0)
        {
            n/=i;cnt++;
        }
        ans*=cnt+1;
    }
    if(n>2)ans*=2;
    return ans;
}
int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll t,n,i,j,k,c,f,ans=0;
	cin>>n;vc num(n+1);
	for(i=1;i<n;i++)
	{
	    for(j=i;j<n;j+=i)num[j]++;
	}
	for(i=1;i<n;i++)
	{
	    ans+=num[n-i];
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 11076
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

int V; //頂点数
string name[SIZE];
map<string,int> MAP;

struct Edge{
	Edge(int arg_to,int arg_capacity,int arg_rev_index){
		to = arg_to;
		capacity = arg_capacity;
		rev_index = arg_rev_index;
	}
	int to,capacity,rev_index;
};

vector<Edge> G[SIZE]; //グラフの隣接リスト表現
int dist[SIZE]; //sourceからの距離
int cheked_index[SIZE]; //どこまで調べ終わったか

//fromからtoへ向かう容量capacityの辺をグラフに追加する
void add_edge(int from,int to,int capacity){
	G[from].push_back(Edge(to,capacity,G[to].size()));
	G[to].push_back(Edge(from,0,G[from].size()-1)); //逆辺の、初期容量は0
}

//sourceからの最短距離をBFSで計算する
void bfs(int source){
	for(int i = 0; i < V; i++)dist[i] = -1;
	queue<int> Q;
	dist[source] = 0;
	Q.push(source);

	while(!Q.empty()){
		int node_id = Q.front();
		Q.pop();
		for(int i = 0; i < G[node_id].size(); i++){
			Edge &e = G[node_id][i];
			if(e.capacity > 0 && dist[e.to] < 0){ //辺の容量が正で、かつエッジの行先に未訪問の場合
				dist[e.to] = dist[node_id]+1;
				Q.push(e.to);
			}
		}
	}
}

//増加パスをDFSで探す
int dfs(int node_id,int sink,int flow){
	if(node_id == sink)return flow; //終点についたらflowをreturn

	for(int &i = cheked_index[node_id]; i < G[node_id].size(); i++){ //node_idから出ているエッジを調査
		Edge &e = G[node_id][i];
		if(e.capacity > 0 && dist[node_id] < dist[e.to]){ //流せる余裕があり、かつsourceからの距離が増加する方法である場合
			int tmp_flow = dfs(e.to,sink,min(flow,e.capacity)); //流せるだけ流す
			if(tmp_flow > 0){ //流せた場合
				e.capacity -= tmp_flow; //流した分、エッジの容量を削減する
				G[e.to][e.rev_index].capacity += tmp_flow; //逆辺の容量を、流した分だけ増加させる
				return tmp_flow;
			}
		}
	}
	return 0;
}


//sourceからsinkへの最大流を求める
int max_flow(int source,int sink){ //source:始点 sink:終点
	int flow = 0,add;
	while(true){ //増加パスが存在する限り、流量を追加し続ける
		bfs(source);
		if(dist[sink] < 0)break; //sourceからsinkへと辿り着く残余グラフがない、つまり増加パスが無くなった場合、break
		for(int i = 0; i < V; i++)cheked_index[i] = 0;
		while((add = dfs(source,sink,BIG_NUM)) > 0){ //増加パスが見つかる間、加算
			flow += add;
		}
	}
	return flow;
}




int main(){

	scanf("%d",&V);

	int source = V,sink = V+1;

	for(int i = 0; i < V; i++){

		cin >> name[i];
		if(name[i].length()%2 == 0){

			add_edge(source,i,1);

		}else{

			add_edge(i,sink,1);
		}

		MAP[name[i]] = i;
	}

	for(int i = 0; i < V; i++){
		for(int loc = 0; loc < name[i].length(); loc++){

			string tmp = name[i];
			tmp.erase(tmp.begin()+loc);

			auto at = MAP.find(tmp);
			if(at != MAP.end()){

				if(name[i].length()%2 == 0){

					add_edge(i,MAP[tmp],1);
				}else{

					add_edge(MAP[tmp],i,1);
				}
			}
		}
	}

	V += 2;

	printf("%d\n",max_flow(source,sink));

	return 0;
}



Measured memory_bytes: 59324
#include<bits/stdc++.h>
using namespace std;
#define ifor(i,n) for(i=0;i<n;i++)
#define ll long long
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     ll int i,n,t,p=INT_MAX,j=0,x,a=0,b,l=0,r=0;
     string s,m;
     cin>>n;
     if(n%2==0){
        cout<<n/2<<endl;
     }
     else{
        cout<<n/2 +1<<endl;
     }

     return EXIT_SUCCESS;
}




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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

  int n;
  cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++)
    if((to_string(i).size())&1) ans++;
  cout<<ans<<endl;
  return 0;

    return 0;
}


Measured memory_bytes: 256