akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#define N 100005
using namespace std;
typedef long long ll;
const ll mod = 1000000007LL;
int n;
int a[N];
ll getres(ll x) {
	ll tot=abs(a[0]-x);
	ll pre=x;
	for (int i = 1; i < n; ++i) {
		int sum=pre+a[i];
		if (i % 2 == 0) {
			if (x > 0 && sum > 0) {
				pre = sum;
				continue;
			} else if (x < 0 && sum < 0) {
				pre = sum;
				continue;
			} else {
				if (x > 0) {
					tot += abs(sum-1);
					pre=1;
				} else {
					tot += abs(sum+1);
					pre=-1;
				}
			}
		} else {
			if (x > 0 && sum < 0) {
				pre=sum;
				continue;
			} else if (x < 0 && sum > 0) {
				pre=sum;
				continue;
			} else {
				if (x > 0) {
					tot += abs(sum+1);
					pre=-1;
				} else {
					tot += abs(sum-1);
					pre=1;
				}
			}
		}
	}
	return tot;
}
int main() {
	cin>>n;
	for (int i = 0; i < n; ++i) {
		cin>>a[i];
	}
	ll res;
	res=getres(1);
	res=min(res,getres(-1));
	if (a[0] != 0) {
		res=min(res,getres(a[0]));
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 640
a, b, n = gets.split.map(&:to_i)

pat = []
pat.push( ((a * n) / b) -  (a * (n / b)) )
if b < n
  pat.push( ((a * b) / b) - a )
end
if b <= n
  pat.push( ((a * (b-1)) / b) )
end
puts pat.max 

Measured memory_bytes: 14236
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    vector<string> field(3);
    string s;
    while (cin >> s, s != "0") {
        field[0] = s;
        cin >> field[1];
        cin >> field[2];

        string res = "NA";
        for (int i = 0; i < 3; i++) {
            if (field[i] == "www") {
                res = "w";
                break;
            } else if (field[i] == "bbb") {
                res = "b";
                break;
            }
        }
    
        for (int i = 0; i < 3; i++) {
            if (field[0][i] == field[1][i] && field[1][i] == field[2][i]) {
                if (field[0][i] == 'w') {
                    res = "w";
                    break;
                } else if (field[0][i] == 'b') {
                    res = "b";
                    break;
                }
            }
        }
    
        if (field[0][0] == field[1][1] && field[1][1] == field[2][2]) {
            if (field[0][0] == 'w') res = "w";
            else if (field[0][0] == 'b') res = "b";
        }
    
        if (field[0][2] == field[1][1] && field[1][1] == field[2][0]) {
            if (field[0][2] == 'w') res = "w";
            else if(field[0][2] == 'b') res = "b";
        }
    
        cout << res << endl;
    }
    return 0;
}

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

int main(void){
	double n;
	stack <double> buf;

	while (true){
		cin>>n;
		if (cin.eof()) break;

		if (n!=0) buf.push(n);
		else{
			cout<<buf.top()<<endl;
			buf.pop();
		}
	}
    return 0;
}

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

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

#define roop(i, n) for(int i = 0;i < n;i++)

int main(void){

    string str;
    cin >> str;

    string tmp = str;
    for(int i = str.length()-1;i >= 0;i--){
        tmp.erase(tmp.size()-1);
        string tmp1, tmp2;
        tmp1 = tmp.substr(0, tmp.size()/2);
        tmp2 = tmp.substr(tmp.size()/2, tmp.size());
        if(tmp1 == tmp2){
            cout << tmp.size() << endl;
            return 0;
        }
        // cout << "str:" << str << endl;
        // cout << "tmp1:" << tmp1 << " tmp2:" << tmp2 << endl;
    }

    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();

        long ans = 1;
        for (int i = 0; i < n; i++) {
            long t = sc.nextLong();
            ans = lcm(ans, t);
        }

        System.out.println(ans);
    }

    static long gcd(long a, long b) {
        long max = Math.max(a, b);
        long min = Math.min(a, b);

        long re = max % min;
        if (re == 0)
            return min;
        return gcd(min, re);
    }

    static long lcm(long a, long b) {
        long g = gcd(a, b);
        return a / g * b;
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void) {
    
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size()-2;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')ans++;
    }
    fin(ans);

}


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

int mod(int m, int n){
	while(m >= n)
		m -= n;
	return m;
}

int main(void){
	int n, k, i, t, loc, stone[10000], count;
	while(1){
		scanf("%d%d%d",&n,&k,&loc);
		if(n == 0 && k == 0 && loc == 0)
			break;
		loc--;
		count = 1;
		memset(stone,0,sizeof(stone));
		stone[loc] = 1;
		while(count < n - 1){
			t = k;
			if(n - count < t)
				t = (t - 1) % (n - count) + 1;
			for(i = 0;i < t;i++){
				loc = mod(loc + 1,n);
				while(stone[loc])
					loc = mod(loc + 1,n);
			}
			stone[loc] = 1;
			count++;
		}
		for(i = 0;i < n;i++){
			if(!stone[i])
				printf("%d\n",i + 1);
		}
	}
	return 0;
}

Measured memory_bytes: 1072
from collections import deque
from heapq import heapify, heappush as hpush, heappop as hpop

def dijkstra(n, E, i0=0):
    h = [[0, i0]]
    D = [-1] * n
    done = [0] * n
    D[i0] = 0
    
    while h:
        d, i = hpop(h)
        done[i] = 1
        for j, w in E[i]:
            nd = d + w
            if D[j] < 0 or D[j] > nd:
                if done[j] == 0:
                    hpush(h, [nd, j])
                    D[j] = nd
    return D






T = int(input())
for _ in range(T):
    N, A, B, C, D = map(int, input().split())
    S = set()
    E = []
    Q = deque([N])
    while Q:
        x = deque.popleft(Q)
        if x in S: continue
        S.add(x)
        if x == 0: continue
        if x <= 10:
            nx = 0
            dd = D * x
            deque.append(Q, nx)
            E.append((x, nx, dd))
        if x % 2 == 0:
            nx = x // 2
            dd = min(A, (x - nx) * D)
            deque.append(Q, nx)
            E.append((x, nx, dd))
        elif x > 1:
            nx = x // 2
            dd = min(A + D, (x - nx) * D)
            deque.append(Q, nx)
            E.append((x, nx, dd))
            
            nx = x // 2 + 1
            dd = min(A + D, (x - nx) * D)
            deque.append(Q, nx)
            E.append((x, nx, dd))
            
        if x % 3 == 0:
            nx = x // 3
            dd = min(B, (x - nx) * D)
            deque.append(Q, nx)
            E.append((x, nx, dd))
        elif x % 3 == 1:
            nx = x // 3
            dd = min(B + D, (x - nx) * D)
            deque.append(Q, nx)
            E.append((x, nx, dd))
        else:
            nx = x // 3 + 1
            dd = min(B + D, (x - nx) * D)
            deque.append(Q, nx)
            E.append((x, nx, dd))
            
        if x % 5 == 0:
            nx = x // 5
            dd = min(C, (x - nx) * D)
            deque.append(Q, nx)
            E.append((x, nx, dd))
        elif x % 5 == 1:
            nx = x // 5
            dd = min(C + D, (x - nx) * D)
            deque.append(Q, nx)
            E.append((x, nx, dd))
            
        elif x % 5 == 2:
            nx = x // 5
            dd = min(C + D * 2, (x - nx) * D)
            deque.append(Q, nx)
            E.append((x, nx, dd))
            
        elif x % 5 == 3:
            nx = x // 5 + 1
            dd = min(C + D * 2, (x - nx) * D)
            deque.append(Q, nx)
            E.append((x, nx, dd))
            
        elif x % 5 == 4:
            nx = x // 5 + 1
            dd = min(C + D, (x - nx) * D)
            deque.append(Q, nx)
            E.append((x, nx, dd))
    
    # print("E =", len(E), E)
    A = []
    for a, b, d in E:
        A.append(a)
        A.append(b)
    A = sorted(list(set(A)))
    I = {a: i for i, a in enumerate(A)}
    E = [(I[a], I[b], d) for a, b, d in E]
    NN = len(A)
    # print("E =", len(E), E)
    EE = [[] for _ in range(NN)]
    for a, b, d in E:
        EE[a].append((b, d))
    print(dijkstra(NN, EE, I[N])[0])
    
    # print("-----")

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


vector<int> d;

set<int> px, tx, py, ty;

int main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	string s;
	int x,y;
	cin >> s >> x >> y;
	s += 'T';
	for(int i = 0, r = 0; i < s.size(); ++i) {
		if(s[i] == 'F') ++r;
		else d.push_back(r), r = 0;
	}
	px.insert(d[0]);
	py.insert(0);
	for(int i = 1; i < d.size(); ++i) {
		if(i&1) {
			ty.clear();
			for(int y : py) {
				ty.insert(y-d[i]);
				ty.insert(y+d[i]);
			}
			swap(ty,py);
		} else {
			tx.clear();
			for(int x : px) {
				tx.insert(x-d[i]);
				tx.insert(x+d[i]);
			}
			swap(tx,px);
		}
	}
	if(px.count(x) && py.count(y)) {
		cout << "Yes\n";
	} else cout << "No\n";
}

Measured memory_bytes: 1152
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String input = scanner.nextLine();
        String inputArr[] = input.split(" ");
        
        double a = Double.parseDouble(inputArr[0]);
        double b = Double.parseDouble(inputArr[1]);
        double c = Double.parseDouble(inputArr[2]);
        
        double S = a * b * Math.sin(Math.toRadians(c)) / 2;
        System.out.println(String.format("%.8f", S));
        
        double x =  Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2*a*b*Math.cos(Math.toRadians(c)) );
        double L = a+b+x;     
        System.out.println(String.format("%.8f", L));
        
        double h = 2 * S / a; 
        System.out.println(String.format("%.8f", h));
    }
}


Measured memory_bytes: 26456
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

int main() {
    int w, h, x, y;
    cin >> w >> h >> x >> y;

    printf("%lf %d\n", (double)w * h / 2, (double)w / 2 == x && (double)h / 2 == y);
    return 0;
}



Measured memory_bytes: 256
def main():
  N = int(input())
  A = list(map(int, input().split()))

  if 0 in A:
    print(0)
    return

  r, max = 1, 10 ** 18
  for num in A:
    r *= num
    if r > max:
      print(-1)
      return
  print(r)

main()


Measured memory_bytes: 21772
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
d.sort()
t.sort()
i=0
j=0
while i<m and j<n:
    if t[i]==d[j]:
        i+=1
        j+=1
    elif t[i]<d[j]:
        print("NO")
        exit()
    else:
        j+=1
print("YES")

Measured memory_bytes: 34024
use std::io::{stdin, Read};
use std::str::FromStr;


fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let M: usize = read();
    let Q: usize = read();
    let mut L: Vec<usize> = vec![];
    let mut R: Vec<usize> = vec![];
    let mut p: Vec<usize> = vec![];
    let mut q: Vec<usize> = vec![];
    for _ in 0..M {
        L.push(read::<usize>() - 1);
        R.push(read::<usize>() - 1);
    }
    for _ in 0..Q {
        p.push(read::<usize>() - 1);
        q.push(read::<usize>() - 1);
    }

    let mut train = vec![vec![0; N + 1]; N + 1];
    for i in 0..M {
        train[L[i] + 1][R[i] + 1] += 1;
    }
    let mut cum = vec![vec![0; N + 1]; N + 1];
    for i in 0..N {
        for j in 0..N {
            cum[i + 1][j + 1] = cum[i][j + 1] + cum[i + 1][j] + train[i + 1][j + 1] - cum[i][j];
        }
    }

    for i in 0..Q {
        let ret = cum[q[i] + 1][q[i] + 1] - cum[q[i] + 1][p[i]] - cum[p[i]][q[i] + 1] + cum[p[i]][p[i]];
        println!("{}", ret);
    }
}


Measured memory_bytes: 8772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  ll n,k;cin>>n>>k;
  vector<ll> a(n);
  rep(i,n){
    cin>>a[i];
  }
  sort(all(a));
  ll l=a[0]<0?a[0]*a[n-1]-1:a[0]*a[1]-1;
  ll r=max(a[0]*a[0],a[n-1]*a[n-1])+1;
  while(l+1<r){
    ll x=(l+r)/2;
    ll cnt=0;
    rep(i,n-1){
      ll base=a[i];
      if(base>=0){
        ll mx=n;
        ll mn=i;
        while(mn+1<mx){
          ll md=(mx+mn)/2;
          ll tmp=base*a[md];
          if(tmp<x){
            mn=md;
          }else{
            mx=md;
          }
        }
        cnt+=mx-(i+1);
      }else{
        ll mx=n;
        ll mn=i;
        while(mn+1<mx){
          ll md=(mx+mn)/2;
          ll tmp=base*a[md];
          if(tmp<x){
            mx=md;
          }else{
            mn=md;
          }
        }
        cnt+=(n-1)-mn;
      }
    }
    if(cnt<k){
      l=x;
    }else{
      r=x;
    }
  }
  cout <<l<<endl;
  return 0;
}

Measured memory_bytes: 1792
def main():
    n = int(input())
    C = input()
    w_count = C.count("W")
    if w_count == 0:
        print(0)
        return

    right_ws = C[-w_count:].count("W")
    diff = w_count - right_ws
    print(diff)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 9468
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.IArray           as IA
import qualified Data.Array.IO               as AI
import qualified Data.Array.MArray           as MA
import qualified Data.Array.ST               as STA
import qualified Data.Array.Unboxed          as AU
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import qualified Data.Graph                  as G
import           Data.Int
import qualified Data.IntMap                 as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence               as SQ
import qualified Data.Set                    as S
import           Data.Time
import qualified Data.Tree                   as T
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

class Printable a where
  format :: a -> String

instance Printable Int where
  format = show

instance Printable Integer where
  format = show

instance Printable Double where
  format = show

instance Printable Float where
  format = show

instance Printable Char where
  format = show

instance Printable String where
  format x = x

instance Printable Bool where
  format = show

put :: Printable a => a -> IO ()
put = putStr . format

putLn :: Printable a => a -> IO ()
putLn = putStrLn . format

putList :: Printable a => [a] -> IO ()
putList [a] = put a
putList (a:as) = do
  put a
  putStr " "
  putList as

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

main = do
  [n] <- readInt
  if n == 1
    then put "Hello World"
    else do
      [a] <- readInt
      [b] <- readInt
      put $ a + b


Measured memory_bytes: 380
#include<iostream>
#include <vector>
#include <cstring>
using namespace std;
int dfs(int);
bool visit[100005];
int dp[100005];
vector<int> map1[100005];
int n,m;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i = 0; i < m; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        map1[a].push_back(b);
    }
    //start dfs
    memset(visit,0,sizeof(visit));
    int mx = 0;
    for(int i = 1; i <= n; i++)
    {
        if(visit[i]==false)mx = max(dfs(i),mx);
    }
    printf("%d\n",mx);
}
int dfs(int x)
{
    if(visit[x])return dp[x];
    visit[x] = true;
    for(int i = 0; i < map1[x].size();i++)
    {
        dp[x] = max(dp[x],dfs(map1[x][i])+1);
    }

    return dp[x];
}


Measured memory_bytes: 8192
#include<cstdio>
#include<cstring>
using namespace std;
int flag[100010];
int a[100010];
int main()
{
	int N;
	while(~scanf("%d",&N))
	{
		memset(flag,0,sizeof flag);
		for(int i=1;i<=N;i++)
		{
			scanf("%d",&a[i]);
			flag[a[i]]++;
		}
		int num1=0,num2=0;
		bool sign = false;
			for(int i=1;i<=N;i++)
			{
				if(N%2==0){
				if(flag[a[i]]!=2)
				{
					sign = true;
					break;
				}}
				else 
				{
					if(flag[a[i]]==1&&a[i]==0)
					num1++;
					if(flag[a[i]]==2)
					num2++;
					
				}
			}
			if(N%2==0)
			if(sign)
			{
				printf("0\n");
				continue;
			}
			if(N%2!=0){
			if(num1==1&&num2==N-1);
			else 
			{
				printf("0\n");
				continue;
			}}
		int ans = 1;
		if(N%2==0)
		{
			//long long ans = 1;
			for(int i=1;i<=N/2;i++)
			ans *= 2,ans %= 1000000000+7;
			
		}
		else 
		{
			for(int i=1;i<=(N-1)/2;i++)
			ans *= 2,ans %= 1000000000+7;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int k;
  cin >> k;
  ll ans = 0;
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= k; j++) {
      for (int x = 1; x <= k; x++) {
        ans += __gcd(i, __gcd(j, x));
      }
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3692
program probC
  implicit none
  integer*8,allocatable :: t(:),x(:),y(:)
  integer*8 N,i,del_x,del_y,del_t,del_min

  read(*,*) N
  allocate(t(0:N),x(0:N),y(0:N))
  t=0
  x=0
  y=0
  do i=1,n
     read(*,*) t(i),x(i),y(i)
  end do
  
  do i=1,N
     del_t=t(i)-t(i-1)
     del_x=x(i)-x(i-1)
     del_y=y(i)-y(i-1)
     del_min=del_t-abs(del_x)-abs(del_y)
     select case(del_min)
     case(:(-1))
        write(*,*) 'No'
        stop
     end select
     select case(mod(del_min,2))
     case(1)
        write(*,*) 'No'
        stop
     end select
  end do

  write(*,*) 'Yes'
end program probC


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    int X;
    cin>>N>>X;
    vector<tuple<ll,ll,ll,ll> > vec(0);
    ll nep = 0;
    ll b,l,u;
    rep(i,N){
        cin>>b>>l>>u;
        ll p = u*X - (u-l)*b;
        //auto nov = vec.at(i);
        /*get<0>(nov) = p;
        get<1>(nov) = b;
        get<2>(nov) = l;
        get<3>(nov) = u;*/
        vec.emplace_back(p,b,l,u);
        nep += l*b;
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());

    /*rep(i,N){
        auto v = vec.at(i);
        cout<<get<0>(v)<<' '<<get<1>(v)<<' '<<get<2>(v)<<' '<<get<3>(v)<<endl;
    }*/

    //cout<<nep<<endl;
    ll li,pli;
    rep(i,N){
        if(nep <= get<0>(vec.at(i))) {
            li = i;
            pli = get<0>(vec.at(li));
            break;
        }
        nep -= get<0>(vec.at(i));
    }
    ll res = X;
    ll neppli = nep - pli;
    ll temp;
    rep(i,li){
        auto nv = vec.at(i);
        l = get<2>(nv);
        ll nep2 = neppli + get<0>(nv);
        if(nep2 <= get<1>(nv) * l){
            temp = (nep2 + l - 1) / l;
        }else{
            temp = get<1>(nv) + (nep2 - get<1>(nv) * l + get<3>(nv) - 1)/get<3>(nv);
        }
        res = min(res,temp);
    }
    reps(i,li,N){
        //cout<<'a'<<endl;
        auto nv = vec.at(i);
        l = get<2>(nv);
        if(nep <= get<1>(nv) * l){
            temp = (nep + l - 1) / l;
        }else{
            temp = get<1>(nv) + (nep - get<1>(nv) * l + get<3>(nv) - 1)/get<3>(nv);
        }
        res = min(res,temp);
    }
    ll ans = X * li + res;
    cout<<ans<<endl;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    double d, t, s; cin >> d >> t >> s;
    if(d/s > t) cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second
#define lwb lower_bound
#define upb upper_bound
#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  freopen("in", "r", stdin);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  vector<int> c(n + 1);
  for (int i = 2; i <= n; i++) {
    int t;
    cin >> t;
    c[t]++;
  }
  for (int i = 1; i <= n; i++) {
    cout << c[i] << '\n';
  }
}


Measured memory_bytes: 4768
N, A, B, C = list(map(int, input().split()))
vectors = [int(input()) for i in range(N)]

def recursiv(cur, a, b, c):
    if cur == N:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) - 30
        else:
            return 9999
    r0 = recursiv(cur + 1, a, b, c)
    r1 = recursiv(cur + 1, a + vectors[cur], b, c) + 10
    r2 = recursiv(cur + 1, a, b + vectors[cur], c) + 10
    r3 = recursiv(cur + 1, a, b, c + vectors[cur]) + 10
    return min(r0, r1, r2, r3)

print(recursiv(0,0,0,0))

Measured memory_bytes: 3064
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        int n = scan.nextInt();
        int[] p = new int[n];
        int a = 1;
        for(int i = 0; i < n; i++){
            p[i] = scan.nextInt();
        }
        int min = p[0];
        for(int i = 0; i < n - 1; i++){
            if(p[i + 1] <= min && p[i] > p[i + 1]){
                min = p[i + 1];
                a++;
            }
        }
        System.out.println(a);
    }
}

Measured memory_bytes: 86396
#include<iostream>
#include<fstream>
#include<list>

using namespace std;

int main(){

	ifstream fin("in.txt");

	typedef list<int>::iterator Iterator;

	list <int> stock;
	list<int> tmp;

	int n = 0, r = 0;
	int p = 0, c = 0;
	
	while (true){

		cin >> n >> r;
		if (n == 0 && r == 0)break;

		//?????????
		stock.clear();
		tmp.clear();
		for (int i = 1; i <= n; i++){
			stock.push_back(n - i + 1);
		}

		for (Iterator it = stock.begin(); it != stock.end();){
		//	cout << *it << " ";
			it++;
		}
		//cout << endl;

		//cout << stock.front() << endl;


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

			cin >> p >> c;


			Iterator front = stock.begin();
			for (int i = 0; i < p - 1; i++){
				front++;
			}

			Iterator back = stock.begin();
			for (int i = 0; i < p + c - 1; i++){
				back++;
			}

			tmp.splice(tmp.begin(), stock, front, back);

			stock.splice(stock.begin(), tmp);

			for (Iterator it = stock.begin(); it != stock.end();){
			//	cout << *it << " ";
				it++;
			}
			//cout << endl;
		}

		cout << *stock.begin() << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
x, a, b = input().split()
x = int(x)
a = int(a)
b = int(b)
 #print("x = ", x)
 #print("a = ", a)
 #print("b = ", b)

if x < a:
    distance_xa = a - x
else:
    distance_xa = x - a
 #print("distance_xa = ", distance_xa)

if x < b:
    distance_xb = b - x
else:
    distance_xb = x - b
 #print("distance_xb = ", distance_xb)

if distance_xa < distance_xb:
    print("A")
else:
    print("B")

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

using namespace std;

const int M = 2e5 + 10, N = 8000 + 10, mod = 1e9 + 7;
int a[M], b[M], fac[N], inv[N];
int ans, n, f[N][N];

int qpow(int a, int x) {
	int ret = 1;
	while(x) {
		if(x & 1) 
			ret = 1ll * ret * a % mod;
		x >>= 1, a = 1ll * a * a % mod;
	}
	return ret;
}

void Init(int maxn) {
	scanf("%d", &n);
	fac[0] = inv[0] = 1;
	for(int i = 1; i <= maxn; ++ i)
		fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[maxn] = qpow(fac[maxn], mod - 2);
	for(int i = maxn; i >= 1; -- i)
		inv[i - 1] = 1ll * inv[i] * i % mod;
}

int C(int n, int m) {
	if(n < m) return 0;
	return 1ll * fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int main() {
	Init(N - 5);
	for(int i = 1; i <= n; ++ i) {
		scanf("%d%d", &a[i], &b[i]);
		++ f[2002 - a[i]][2002 - b[i]];
	}
	for(int i = 1; i <= 4002; ++ i)
		for(int j = 1; j <= 4002; ++ j) 
			(f[i][j] += (f[i - 1][j] + f[i][j - 1]) % mod) %= mod;
	for(int i = 1; i <= n; ++ i)
		(ans += f[a[i] + 2002][b[i] + 2002] - C((a[i] + b[i]) * 2, a[i] * 2)) %= mod;
	cout << 1ll * (mod + 1) / 2 * (ans + mod) % mod << endl;
	return 0;
}


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

typedef long long lld;
const int NN = 1e5 + 5;
lld aa[NN][4];
lld dp[NN][4];
int nn;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
        cin >> nn;
        for (int ii = 1; ii <= nn; ++ii)
            cin >> aa[ii][1] >> aa[ii][2] >> aa[ii][3];
        dp[1][1] = aa[1][1]; dp[1][2] = aa[1][2]; dp[1][3] = aa[1][3];
        for (int ii = 2; ii <= nn; ++ii) {
            dp[ii][1] = max(dp[ii - 1][2], dp[ii - 1][3]) + aa[ii][1];
            dp[ii][2] = max(dp[ii - 1][3], dp[ii - 1][1]) + aa[ii][2];
            dp[ii][3] = max(dp[ii - 1][1], dp[ii - 1][2]) + aa[ii][3];
        }
        cout << max(dp[nn][1], max(dp[nn][2], dp[nn][3]));
    return 0;
}


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

int main(void){

    int X, Y, Z;

    scanf("%d%d%d", &X, &Y, &Z);

    if((X-2*Z) % (Y+Z) < Y){
        printf("%d\n", (X-2*Z) / (Y+Z));
    }else{
        printf("%d\n", (X-2*Z) / (Y+Z) + 1);
    }

    return 0;
}

Measured memory_bytes: 1704
import java.util.*;

public class Main {
	public static void main (String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] arr = sc.next().toCharArray();
		if (n % 2 == 1) {
		    System.out.println("No");
		    return;
		}
		for (int i = 0; i < n / 2; i++) {
		    if (arr[i] != arr[i + n / 2]) {
		        System.out.println("No");
		        return;
		    }
		}
		System.out.println("Yes");
	}
}


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

int main() {
  int h,w;
  cin >> h >> w;
  vector<int>alp(26);
  rep(i,0,h){
    string s;
    cin >> s;
    rep(j,0,w) alp[s[j]-'a']++;
  }
  int ac4 = 1,ac2 = 0,ac1 = 0;
  if(h%2 != 0) ac4 *= h-1;
  else ac4 *= h;
  if(w%2 != 0) ac4 *= w-1;
  else ac4 *= w;
  ac4 /= 4;
  
  if(h%2 == 1) ac2 += w/2;
  if(w%2 == 1) ac2 += h/2;
  
  if(h%2 == 1 && w%2 == 1) ac1 = 1;
  
  int c4 = 0,c2 = 0,c1 = 0;
  rep(i,0,26){
    if(alp[i] >= 4){
      if(c4+alp[i]/4 > ac4){
        alp[i] -= (ac4-c4)*4;
        c4 = ac4;
      }
      else{
        c4 += alp[i]/4;
        alp[i] %= 4;
      }
    }
  }
  rep(i,0,26){
    if(alp[i] >= 2){
      if(c2+alp[i]/2 > ac2){
        alp[i] -= (ac2-c2)*2;
        c2 = ac2;
      }
      else{
        c2 += alp[i]/2;
        alp[i] %= 2;
      }
    }
  }
  rep(i,0,26) c1 += alp[i];
  if(c4 == ac4 &&(c2 == ac2 && c1 == ac1)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3612
K = int(input())
if K % 2 == 0:
    print(-1)
else:
    r = 0
    rem = 7
    while (True):
        r += 1
        rem = rem % K
        if rem == 0:
            break
        if r > K:
            r = -1
            break
        rem = (rem * 10) + 7
    print(r)


Measured memory_bytes: 9168
S=input()
ls=[]
tmp=0
aaa=['A', 'T', 'G', 'C']
for i in range(len(S)):
	if S[i] not in aaa:
		ls.append(tmp)
		tmp=0
		continue
	else:
		tmp+=1
ls.append(tmp)
print(max(ls))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
inline int read(){char c = getchar();int x = 0,s = 1;
while(c < '0' || c > '9') {if(c == '-') s = -1;c = getchar();}
while(c >= '0' && c <= '9') {x = x*10 + c -'0';c = getchar();}
return x*s;}
using namespace std;
#define NewNode (TreeNode *)malloc(sizeof(TreeNode))
#define Mem(a,b) memset(a,b,sizeof(a))
const int N = 1e6 + 5;
const long long INFINF = 0x7f7f7f7f7f7f7f;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-7;
const unsigned long long mod = 998244353;
const double II = acos(-1);
const double PP = (II*1.0)/(180.00);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> piil;
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int n1,m1,n2,m2,k;
    cin >> n1 >> m1 >> n2 >> m2 >> k;
    cout << abs(n2-n1)*60+(m2-m1)-k << endl;
}


Measured memory_bytes: 3640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        int n = 0;
        final int MOD = 1_000_000_007;
        try (Scanner s = new Scanner(System.in)) {
            n = s.nextInt();
        }
        long p = modPow(10, n, MOD) - 2 * modPow(9, n, MOD) + modPow(8, n, MOD);
        p %= MOD;
        System.out.println(p >= 0 ? p : p + MOD);
    }
    
    private static long modPow(int base, int pow, int mod) {
        long a = base;
        long result = 1;
        for (int i = 1; i <= pow; i <<= 1) {
            if ((pow & i) != 0) {
                result = (result * a) % mod;
            }
            a = (a * a) % mod;
        }
        return result;
    }
}


Measured memory_bytes: 35752
#include <stdio.h>

int main(void){
	int i,N;
	int a,b,c;
	int check;

	scanf("%d",&N);

	for(i = 0;i < N;i++){
		scanf("%d %d %d",&a,&b,&c);

		check = 0;

		//三平方の定理
		if(a*a == b*b + c*c)check = 1;
		if(b*b == a*a + c*c)check = 1;
		if(c*c == a*a + b*b)check = 1;

		if(check == 1){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)n; ++i)

ll x[100001];

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	ll an = 0;
	f(i, 1, n + 1){
		scanf("%lld", x + i);
		if (x[i] > 0)an += x[i];
	}
	int i = 0;
	ll h = 0, l = 0, d = -1e18;
	while (i < k){
		++i;
		if (x[i] > 0)h += x[i];
		else l -= x[i];
	}
	d = max(-h, -l);
	while (i < n){
		++i;
		if (x[i] > 0)h += x[i];
		else l -= x[i];
		if (x[i - k] > 0)h -= x[i - k];
		else l += x[i - k];
		d = max(d, max(-h, -l));
	}
	printf("%lld\n", an + d);
}


Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;
const int MOD=1000000007;

int N,M;
int A[100010],B[100010],C[100010];
int Q,K;
int X[100010],Y[100010];
vector<edge> G[100010];
int d[100010];

int d1[100010],d2[100010];

void Dijkstra(int s){
	std::priority_queue<P,vector<P>,std::greater<P>> que;
	std::fill(d,d+N,INF);
	d[s]=0;
	que.push(P(0,s));
	while(!que.empty()){
		P p =que.top();que.pop();
		int v=p.second;
		if(d[v]<p.first)continue;
		for(int i=0;i<(signed)G[v].size();i++){
			edge e =G[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}

signed main(){
	cin>>N;
	M=N;
	REP(i,N-1){
		cin>>A[i]>>B[i]>>C[i];
		edge e;
		e.to=B[i]-1,e.cost=C[i];
		G[A[i]-1].push_back(e);
		e.to=A[i]-1;
		G[B[i]-1].push_back(e);
	}
	cin>>Q>>K;
	REP(i,Q){
		cin>>X[i]>>Y[i];
	}
	Dijkstra(K-1);
	DEB(d[0])END
	REP(i,N){
		d1[i]=d[i];
	}
	REP(i,Q){
		cout<<d1[X[i]-1]+d1[Y[i]-1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 15088
#include <stdio.h>

int main(){
  
  int i,j,k,l,t,n,a,b,upmax,downmax;
  int data[100];
  
  scanf("%d",&t);
  for(l=0;l<t;l++){
    upmax=0;
    downmax=0;
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
       scanf("%d",&data[i]);
    }
    for(k=1;k<n;k++){
      
      if(data[k-1]<data[k]){
	a=data[k]-data[k-1];
	if(upmax<a){
	  upmax=a;
	}
      }
    }
    for(j=1;j<n;j++){  

      if(data[j-1]>data[j]){
	b=data[j-1]-data[j];
	if(downmax<b){
	  downmax=b;
	}
      }
    }
    printf("%d %d\n",upmax,downmax);
  }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long n,long long m){
  if(n%m==0){
    return m;
  }
  return gcd(m,n%m);
}
long long lcm(long long a,long long b){
  return (a*b)/gcd(a,b);
}
int main(){
  long long a,b,c,d;
  cin>>a>>b>>c>>d;
  long long x=(b/c)-(a/c);
  long long y=(b/d)-(a/d);
  long long g=lcm(c,d);
  long long z=(b/g)-(a/g);
  if(a%c==0)x=(b/c)-(a/c)+1;
  if(a%d==0)y=(b/d)-(a/d)+1;
  if(a%g==0)z=(b/g)-(a/g)+1;
  cout<<(b-a+1)-(x+y-z)<<endl;
  return 0;
}

Measured memory_bytes: 3624
D = int(input())
s = [input() for i in range(2*D+1)]
for i in range(0,2*D+1):
    s[i] = s[i].split()
    s[i] = [int(p) for p in s[i]]
a = []
b = [0]*len(s[0])
S = 0
m = 0
for i in range (1,D+1):
    for j in range(0,len(s[0])):
        if j == s[D+i][0]-1:
            b[s[D+i][0]-1] = 0
        else:
            b[j] = b[j] + s[0][j]
    S = S + s[i][s[D+i][0]-1] - sum(b)
    a.append(S)
for i in (a):
    print(i)

Measured memory_bytes: 9236
from time import time
start = time()
from random import randrange

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

for i in range(n):
    if A[i] != B[i]:
        continue
    while time() - start < 1.8:
        j = randrange(n)
        if A[i] != B[j] and A[j] != B[i]:
            B[i], B[j] = B[j], B[i]
            break
    else:
        print("No")
        exit(0)

print("Yes")
print(*B)

Measured memory_bytes: 124132
#include <iostream>
#include <cctype>
//#include <string>
//#include <iomanip>

using namespace std;
//#define

int main() {
	char ch;

	while(1){
		cin.get(ch);
		if(ch == '\n') break;

		if(islower(ch)){
			char ans = toupper(ch);
			cout << ans;
		} else if(isupper(ch)){
			char ans = tolower(ch);
			cout << ans;
		} else {
			cout << ch;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1128
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k;
	cin>>n>>k;
	vector<int>A(n), dp(n, INT_MAX);
	for(auto&a:A)cin>>a;
	dp[0]=0;
	for(int i=0; i<n; i++){
		for(int j=1; j<=k; j++)
		if(i+j<n){
			dp[i+j]=min(dp[i+j], dp[i]+abs(A[i]-A[i+j]));
		}
	}
	cout<<dp[n-1]<<"\n";
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#define int long long
#define double long double
using namespace std;
signed main(){
    int n;
    cin>>n;
    vector<int> t(n);
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>t[i]>>a[i];
    }
    
    int t_temp=1;
    int a_temp=1;
    double k;
    for(int i=0;i<n;i++){
        k=max(ceil((double)t_temp/(double)t[i]),ceil((double)a_temp/(double)a[i]));
        t_temp=(int)k*t[i];
        a_temp=(int)k*a[i];
    }
    
    cout<<t_temp+a_temp<<endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <cstdio>
int main(){
	int height, width, n;
	scanf("%d%d%d", &height, &width, &n);
	int col[height*width];
	int k = 0;
	for(int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		for(int j = k; j < k + a; j++){
			col[j] = i;
		}
		k += a;
	}
	int l[width];
	int now = 0;
	for(int i = 0; i < height; i++){
		if(i % 2 == 0){
			for(int j = 0; j < width; j++){
				l[j] = col[now+j];
			}
		}else{
			for(int j = 0; j < width; j++){
				l[width - j - 1] = col[now+j];
			}
		}
		now += width;
		for(int j = 0; j < width; j++){
			printf("%d ", l[j]+1);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))

def selection_sort(A, N):
    count = 0
    for i in range(0, N):
        min_j = i
        for j in range(i, N):
            if A[j] < A[min_j]:
                min_j = j
        if min_j != i:
            count += 1
        A[i], A[min_j] = A[min_j], A[i]
    return A, count

A, count = selection_sort(A, N)
print(' '.join(map(str, A)))
print(count)


Measured memory_bytes: 5600
n = int(input())
xl = [list(map(int,input().split())) for _ in range(n)]
for i in range(n):
    x = xl[i][0]
    l = xl[i][1]
    xl[i][0] = x+l
    xl[i][1] = x-l
#[終点、支店]
xl.sort()
ans = 1
right = xl[0][0]
for i in range(n-1):
    siten = xl[i+1][1]
    shuten = xl[i+1][0]
    if right <= siten:
        ans += 1
        right = shuten

print(ans)

Measured memory_bytes: 63576
import java.io.*
import java.util.*
import kotlin.collections.*


fun solve() {
    val s = kin.str()
    var last = ""
    var ans = 0
    var cur = ""
    for (ch in s) {
        cur += ch
        if (cur != last) {
            last = cur
            cur = ""
            ans++
        }
    }
    kout.println(ans)
}

fun main(args: Array<String>) {
    kout.use { solve() }
}

var kin = InputReader(getInput())
val kout = PrintWriter(System.out)

class InputReader(stream: InputStream) {
    private val reader = BufferedReader(InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer? = null

    fun str(): String {
        while (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun <R> list(n: Int, parse: (String) -> R): MutableList<R> {
        return (1..n).map { parse.invoke(str()) }.toMutableList()
    }

    fun int() = str().toInt()
    fun listInt(n: Int) = list(n) { it.toInt() }
    fun long() = str().toLong()
    fun listLong(n: Int) = list(n) { it.toLong() }
}

fun getInput(): InputStream {
    val inputFile = try {
        System.getProperty("compet.input")
    } catch (ex: Exception) {
        null
    } ?: return System.`in`

    return FileInputStream(InputReader::class.java.classLoader.getResource(inputFile).file)
}



Measured memory_bytes: 41168
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <iostream>
#include <bitset>
#include <stack>
using namespace std;
#define N 200005
int h,w,n,x,y;char s[N],t[N];
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
int trs(char c){if(c=='U')return 2;if(c=='D')return 0;if(c=='L')return 3;return 1;}
bool check(int opt,int x,int y)
{
	int siz=0;
	for(int i=1;i<=n;i++)
	{
		int op=trs(s[i]),tx,ty;
		if(op==opt)tx=x+dx[op],ty=y+dy[op];else tx=x,ty=y;
		if((tx<=0||tx>h)||(ty<=0||ty>w))
		{
			if(siz)siz--;
			else return 0;
		}else x=tx,y=ty;
		if((trs(t[i])^opt)==2)
			if(opt==0)siz=min(siz+1,x-1);
			else if(opt==1)siz=min(siz+1,y-1);
			else if(opt==2)siz=min(siz+1,h-x);
			else siz=min(siz+1,w-y);
	}
	return 1;
}
int main()
{
	scanf("%d%d%d%d%d%s%s",&h,&w,&n,&x,&y,s+1,t+1);
	for(int i=0;i<4;i++)if(!check(i,x,y))return puts("NO"),0;
	puts("YES");
}

Measured memory_bytes: 640
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()
S=input()
if S=="ABC":
    print("ARC")
else:
    print("ABC")


Measured memory_bytes: 72696
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

struct s_t{
  ll a,b;
};
bool asc(s_t left,s_t right) {
  return left.a == right.a ? left.b > right.b : left.a < right.a;
}

int main(){
  ll n;
  cin>>n;
  vector<ll>v(n,0);
  vector<s_t>v2;
  s_t zz;
  for(ll i=0;i<n;i++){
    cin>>v[i];
    zz={v[i],i};
    v2.push_back(zz);
  }
  sort(v2.begin(),v2.end(),asc);
  set<ll>st;
  st.insert(v2[0].b);
  for(ll i=1;i<n;i++){
    auto itr=st.lower_bound(v2[i].b);
    if(itr!=st.begin()){
      itr--;
      st.erase(itr);
    }
    st.insert(v2[i].b);
    // for(auto j=st.begin();j!=st.end();j++){
    //   cout<<*j<<" ";
    // }
    // cout<<endl;
  }
  ll ans=st.size();
  cout<<ans<<endl;
}


Measured memory_bytes: 7912
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

int main()
{
    string s;
    cin >> s;
    if (s[s.size() - 1] == 's')
    {
        cout << s << "es" << endl;
    }
    else
    {
        cout << s << 's' << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define all(v) v.begin(),v.end()
#define vi vector<int> 
#define mod 1000000007
#define inf 1e17
#define fs first
#define ss second

template <typename T> 
void amax(T& x, T y) 
{ 
    if( x < y) x = y;
} 

template <typename T> 
void amin(T& x, T y) 
{ 
    if( x > y) x = y;
} 



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

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int a, b, c;
    int cnt = 1;

    scanf("%d %d", &a, &b);
    c = a - 2;
    if (c > 0) {
        cnt += a - 2;
        if (b >= a) cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 128
h, n = map(int, input().split())

inf = 10**8
dp = [[inf for i in range(h+10001)] for j in range(n+1)]
dp[0][0] = 0
a = []
b = []
for i in range(n):
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)
#dp[i][j]: i番目の魔法まででjダメージ与えるときの最小魔力
for i in range(n):
    for j in range(h+10001):
        if j-a[i] >= 0:
            dp[i+1][j] = min(dp[i+1][j-a[i]] + b[i], dp[i+1][j])
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])

ans = min(dp[n][h:])
print(ans)


Measured memory_bytes: 268552
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())|	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
def inpl(): return list(map(int, input().split()))

#### START
N = int(input())

ans = ""
cnt = 0

while(N!=0):
  if(N%(-2) != 0):
    N-=1
    ans = "1" + ans
  else:
    ans = "0" + ans
  N/=-2

if ans=="":
  ans = "0"
print(ans)

Measured memory_bytes: 3444
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)
from copy import deepcopy
h,w,k=map(int,input().split())
c=[list(input().rstrip()) for _ in range(h)]
ans=0

for H in range(2**h):
    for W in range(2**w):
        b=deepcopy(c)
        nowh=bin(H)[2:].zfill(h)
        noww=bin(W)[2:].zfill(w)
        for hi in range(h):
            if nowh[hi]=="1":
                for i in range(w):b[hi][i]="r"
        for wi in range(w):
            if noww[wi]=="1":
                for i in range(h):b[i][wi]="r"
        cnt=0
        for i in b:
            cnt+=i.count("#")
        if cnt==k:ans+=1
print(ans)

Measured memory_bytes: 9348