akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String S_2 = S + S;
		String S_3 = S + S + S;
		int N = Integer.parseInt(sc.next());
		char first = S.charAt(0);
		char before = first;
		long cnt_1 = 0L;
		for (int i=1;i<S.length();i++) {
			if (S.charAt(i)==before) {
				cnt_1++;
				i++;
			}
			if (i<=S.length()-1) {
				before=S.charAt(i);
			}
		}

		long cnt_2 = 0L;
		int flag=0;
		before = first;
		for (int i=1;i<S_2.length();i++) {
			if (S_2.charAt(i)==before) {
				cnt_2++;
				i++;
			}
			if (i<=S_2.length()-1) {
				before=S_2.charAt(i);
			}
		}

		long cnt_3 = 0L;
		before = first;
		for (int i=1;i<S_3.length();i++) {
			if (S_3.charAt(i)==before) {
				cnt_3++;
				i++;
			}
			if (i<=S_3.length()-1) {
				before=S_3.charAt(i);
			}
		}

		long ans = 0L;
		if (N%2==0) {
			ans = (cnt_3-cnt_1) * (N/2-1) + cnt_2;
		} else {
			ans = (cnt_3-cnt_1) * (N/2) + cnt_1;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

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


int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())
#define rSORT(v) std::sort(v.begin(), v.end(),std::greater<int>())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,W;
    cin >> N >> W;
    vector<vector<ll>> dp(110, vector<ll>(100100, 0));
    vector<ll> w(110), v(110);
    for (int i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }

    for (int i = 0; i < N; ++i) {
        for (int sum_w = 0; sum_w <= W; ++sum_w) {
            if (sum_w - w[i] >= 0) {
                chmax(dp[i + 1][sum_w], dp[i][sum_w - w[i]] + v[i]);
            }

            chmax(dp[i + 1][sum_w], dp[i][sum_w]);
        }
    }

    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 87296
#include<bits/stdc++.h>
#define int long long
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int32_t main()
{
    FastIO;
    int a,p;
    cin>>a>>p;
    cout<<(a*3+p)/2;
    
}

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

int main(void)
{
  char s[100],t[100],tmp;
  if(scanf("%s",s)<0) exit(1);
  if(scanf("%s",t)<0) exit(1);

// fgets(s,100,stdin);
// fgets(t,100,stdin);
  int i,j;
//  printf("%lu",strlen(s));


   for(i=0;i<strlen(s)-1;i++)
  {
    if(strcmp(s,t)==0)
    {
      break;
    }
    else
    {
      tmp=s[0];
      for(j=0;j<strlen(s)-1;j++)
      {
        s[j]=s[j+1];
      }
      s[strlen(s)-1]=tmp;
    }
  }

  if(strcmp(s,t)==0)
  {
    printf("Yes\n");
  }
  else printf("No\n");

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    string s, t;
    cin >> s >> t;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef unsigned long long ull;
    typedef long long ll;
    typedef long double ld;
    #define FOR(type,a,b,c,d) for(type i = a;i b c;i += d)
    #define QUICK ios_base::sync_with_stdio(0);cout << fixed;
    #define MOD 1000000007

    string upper(string);
    string lower(string);
    bool isalup(string);
    bool isalow(string);

    int main(){

        int a;
        cin >> a;
        cout << (a>=30?"Yes":"No");
    

        return 0;
    }









                string upper(string a){
                    for(char& c:a){
                        if(islower(c))
                            c -= 32;
                       }
                    return a;
                }
                    string lower(string a){
                        for(char& c : a){
                            if(isupper(c))
                                c += 32;
                        }
                        return a;
                    }
                    bool isalup(string a){
                        for(char& c: a){
                            if(islower(c))
                                return false;
                        }
                        return true;
                    }
                    bool isalow(string a){
                        for(char& c:a){
                            if(isupper(c))
                                return false;
                        }
                       return true;
                    }


Measured memory_bytes: 3600
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#define INF 2139062143
#define inf -2139062144
#define ll long long
using namespace std;
long long result[110];
long long cal(int k,int n) {
	for(int i=1; i<=n; i++) {
		result[i] = 1;
		for(int j=i-1; j>=1; j--) {
			result[j] = result[j-1]+result[j];
		}
		result[0] = 1;
	}
	return result[k];
}
int main() {
	int n,p,i,mul=0,o=0,temp;
	scanf("%d%d",&n,&p);
	long long ans=0;
	for(i=1; i<=n; i++) {
		scanf("%d",&temp);
		if(temp%2==0)	o++;
		else	mul++;
	}
	if(p==0) {
		long long a=1;
		if(o==0) {
			a=1;
		} else {
			for(i=1; i<=o; i++)
				a*=2;
		}
		long long b=0;
		if(mul==0) {
			b=1;
		} else {
			for(i=0; i<=mul; i=i+2) {
				b+=cal(i,mul);
			}
		}
		ans=a*b;
	} else if(p==1) {
		long long a=1;
		for(i=1; i<=o; i++) {
			a*=2;
		}
		long long b=0;
		if(mul==0) {
			b=0;
		} else {
			for(i=1; i<=mul; i=i+2) {
				b+=cal(i,mul);
			}
		}
		ans=a*b;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
s = gets.to_i
def f(n)
  cnt = 1
  ns =[]
  loop do
    break if ns.include?(n)
    ns.push(n)
    if n.even?
      n = n/2
      cnt += 1
    else
      n = 3*n+1
      cnt += 1
    end
  end
  return cnt
end
puts f(s)


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

int point(int x,int y,int w,int h){
  int s;
  s= y*w+x;
  return s;
}

int point_x(int x,int w){
  int s;
  s=x%w;
  return s;
}

int point_y(int x,int w){
  int s;
  s=x/w;
  return s;
}

int main(){
  int w,h;
  cin>>w>>h;
  while(w!=0){
    int a[21][21]={};
    int sx,sy;
    for(int j=0;j<h;j++){
      for(int i=0;i<w;i++){
	char s;
	cin>>s;
	if(s=='.'){
	  a[i][j]=1;
	}else if(s=='#'){
	  a[i][j]=-1;
	}else{
	  a[i][j]=2;
	  sx=i;
	  sy=j;
	}
      }
    }

    int d[21][21];
    for(int i=0;i<21;i++){
      for(int j=0;j<21;j++){
	d[i][j]=-1;
      }
    }
    queue<int>q;
    d[sx][sy]=0;
    int str;
    str=point(sx,sy,w,h);
    q.push(str);
    while(! q.empty()){
      int cur =q.front();
      q.pop();
      int x,y;
      x=point_x(cur,w);
      y=point_y(cur,w);
      if(x>=1){
	if(a[x-1][y]==1&&d[x-1][y]==-1){
	  d[x-1][y]=0;
	  q.push(point(x-1,y,w,h));
	}
      }
      if(x<=w-2){
	if(a[x+1][y]==1&&d[x+1][y]==-1){
	  d[x+1][y]=0;
	  q.push(point(x+1,y,w,h));
	}
      }
      if(y>=1){
	if(a[x][y-1]==1&&d[x][y-1]==-1){
	  d[x][y-1]=0;
	  q.push(point(x,y-1,w,h));
	}
      }
      if(y<=h-2){
	if(a[x][y+1]==1&&d[x][y+1]==-1){
	  d[x][y+1]=0;
	  q.push(point(x,y+1,w,h));
	}
      }
    }

    int t=0;
    for(int i=0;i<w;i++){
      for(int j=0;j<h;j++){
	if(d[i][j]==0){
	  t+=1;
	}
      }
    }
    cout <<t<< endl;
    cin>>w>>h;
  }
}
    
    

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

public class Main {
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int n = in.readInt();
		int ans = 0;  
	    int lol = 0; 
	    for(int i = 0; lol <= n; i++) {
	    	lol = (int)Math.pow(2, i); 
	    	ans = (int)Math.pow(2, i-1);
	    }
	    System.out.println(ans); 
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 23124
import io.StdIn.{readInt, readLine}
object Main extends App {
  val n = readInt
  val as = readLine.split(" ").map(_.toInt)
  println(solve(as))

  def solve(as: Seq[Int]) = {
    ((for (i <- (as.size - 1) to 0 by -2) yield as(i)) ++
    (for (i <- (as.size - 2) to 0 by -2) yield as(i)).reverse).mkString(" ")
  }
}


Measured memory_bytes: 64424
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
for(var i=0;i<Arr.length;i++){
   var n=(Arr[i]-0)+1;
   var x=1/2*n*(n-1);
   console.log(x+1);
}

Measured memory_bytes: 7904
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getLine >>= print . uncurry min . ( solve ( cycle "01" ) &&& solve ( cycle "10" ) )

solve s t = length $ filter id $ zipWith (/=) s t

Measured memory_bytes: 7164
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int N,M, aa, bb; cin>>N>>M;
    vector<int> a; set<int> b;
    set<int>::iterator ite;
    if(M==1) {
      cout<<"IMPOSSIBLE"<<endl;return 0;
}
    for(int i=0; i<M;i++){
      cin>>aa>>bb;
      if(aa==1) b.insert(bb);
      if(bb==N) a.push_back(aa);
    }
    for(int i=0; i<a.size();i++)    {
      aa = a[i];
          if(b.find(aa) != b.end()){
            cout<<"POSSIBLE"<<endl;
            return 0;
          }
        }

    cout<<"IMPOSSIBLE"<<endl;

    return 0;
}


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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))
#define int long long

signed main(){
    int x, y;
    cin >> x >> y;
    cout << ceiv(x + y, 2) << endl;
}

Measured memory_bytes: 256
s=input()
k=int(input())
uselist=[]
count=0
checker=0
alphabet="abcdefghijklmnopqrstuvwxyz"
while count<=5 and checker<=26:
    for i in alphabet:
        for j in range(len(s)):
            if s[j]==i:
                uselist.append((j,i))
                count+=1
        checker+=1
anslist=[]
for some in uselist:
    count=0
    for j in range(some[0],len(s)):
        anslist.append(s[some[0]:j+1:])
        count+=1
        if count>5:
            break           
anslist=sorted(set(anslist))
print(anslist[k-1])
    

Measured memory_bytes: 5960
#include<stdio.h>

#define TRUE 1
#define FALSE 0
typedef struct {
  int num;
  char attribute;
}CARD;

void bubbleSort(CARD*,int);
void selectionSort(CARD*,int);
void print(CARD*,int);
int judgeStable(CARD*,CARD*,int);


int main(){
  CARD c1[100],c2[100];
  int i,N;
  
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf(" %c%d",&c1[i].attribute,&c1[i].num);
    c2[i] = c1[i];
  }

 

  bubbleSort(c1,N);
  selectionSort(c2,N);
  print(c1,N);
  printf("Stable\n");
  print(c2,N);
  if(judgeStable(c1,c2,N)!=FALSE){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }

  return 0;
}
  

void bubbleSort(CARD *c,int N){
  int i,j;
  CARD temp;
  for(i=0;i<N;i++){
    for(j=N-1;j>=i+1;j--){
      if(c[j].num < c[j-1].num){
	temp = c[j];
	c[j] = c[j-1];
	c[j-1] = temp;
      }
    }
  }
}

void selectionSort(CARD *c,int N){
  int i,j,min;
  CARD temp;
  for(i = 0;i<N;i++){
    min = i;
    for (j = i;j<N;j++){
      if(c[j].num < c[min].num){
	min = j;
      }
    }
    temp = c[i];
    c[i] = c[min];
    c[min] = temp;
  }
}

void print(CARD *c,int N){
  int i;
  for(i = 0;i<N;i++){
    printf("%c%d",c[i].attribute,c[i].num);
    if(i!=N-1)printf(" ");
  }
  printf("\n");
}

int judgeStable(CARD *c1,CARD *c2,int N){
  int i;
  for(i=0;i<N;i++){
    if(c1[i].attribute != c2[i].attribute)return FALSE;
  }
  return TRUE;
}



Measured memory_bytes: 2108
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): pass
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n, k = LI()
A = LI()
dp = [0] * (k + 2)
dp[1] = 1
for i in range(n):
    dp = list(accumulate(dp))
    ndp = [0] * (k + 2)
    for j in range(k + 1):
        ndp[j + 1] = dp[j + 1] - dp[max(j - A[i], 0)]
        ndp[j + 1] %= mod
    dp = ndp


print(dp[-1])


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 998244353

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

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

  ll n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));

  ll res=1;
  rep(i,n){
    res*=gcd(i,a[i]);
    res%=mod;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;

/**
 * 不安なら ll を使う.
 * 小数は double を忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 * pair<型, 型> 変数名
 * map<型, 型> 変数名  // 連想配列
 * priority_queue<型> 変数名  // 最大値から出てくるヒープ
 * 比較するときは型まで注意
 * 区間の計算は累積和
*/

/* ===== コーナーケースに気をつけろ ===== */

int main()
{
    string S;
    cin >> S;
    string s1 = "", s2 = "";
    int N = S.length();
    bool flag1 = true, flag2 = true, flag3 = true;

    for (int i = 0; i < (N - 1) / 2; i++)
    {
        s1 += S.at(i);
    }

    for (int i = ((N + 3) / 2) - 1; i < N; i++)
    {
        s2 += S.at(i);
    }

    int a = N;
    for (int i = 0; i < (N / 2) + 1; i++)
    {
        if (S.at(i) != S.at(a - 1))
        {
            flag1 = false;
        }
        a--;
    }

    int b = s1.length();
    for (int i = 0; i < (b / 2) + 1; i++)
    {
        if (s1.at(i) != s1.at(b - 1))
        {
            flag2 = false;
        }
        b--;
    }

    int c = s2.length();
    for (int i = 0; i < (c / 2) + 1; i++)
    {
        if (s2.at(i) != s2.at(c - 1))
        {
            flag3 = false;
        }
        c--;
    }

    // cout << s1 << " " << s2 << " " << S << endl;
    if (flag1 && flag2 && flag3)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    int N, M, A, B, C;
    
    cin >> N >> M;
    
    vector<int> arr;
    vector<pair<int,int>> op;
    for(int i = 0; i < N; i++) {
        cin >> A;
        arr.push_back(A);
    }
    
    for(int i = 0; i < M; i++) {
        cin >> B >> C;
        op.push_back({C,B});
    }
    
    sort(arr.begin(), arr.end());
    sort(op.begin(), op.end());
    
    int remain = N;
    long long ans = 0;
    while(remain-- > 0) {
        if(op.empty() || (arr.size() && arr.back() >= op.back().first)) {
            ans += arr.back();
            arr.pop_back();
        } else {
            ans += op.back().first;
            op.back().second--;
            if(op.back().second == 0) op.pop_back();
        }
    }
    cout << ans;
}

Measured memory_bytes: 1784
#include <cstdio>

int main() {
  int A, B;
  char op;
  scanf("%d %c %d", &A, &op, &B);

  if (op == '+') {
    printf("%d\n", A+B);
  } else if (op == '-') {
    printf("%d\n", A-B);
  }
}

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

n = int(input())
F = [list(map(int, input().split())) for _ in range(n)]
P = [list(map(int, input().split())) for _ in range(n)]
ans = -1e10

for sister in range(1, 1024):
    count = 0
    for i in range(n):
        cost_list = list('{:b}'.format(int(''.join(map(str, F[i])), 2) & sister))
        cost = 0
        for j in range(len(cost_list)):
            cost += int(cost_list[j])
        count += P[i][cost]
    ans = max(ans, count)

print(ans)


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

vector<pint> rle(vint &v)
{
    sort(ALL(v));
    vector<pint> ret;
    ret.reserve(v.size() / 2);
    for (const auto &x : v)
    {
        if (ret.empty() || ret.back().first != x)
            ret.emplace_back(x, 1);
        else
            ++ret.back().second;
    }
    return ret;
}

void Main()
{
    int n = in();
    vint a = in(n);
    auto v = rle(a);
    bool even = false;
    for (const auto &x : v)
    {
        if (x.second % 2 == 0)
            even = !even;
    }
    int ans = v.size() - even;
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

//mod m での a の逆元
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main(){
    int n; cin >> n;
    vector<ll> ar(n);
    rep(i,n) cin >> ar[i];
    auto nar = ar;
    const int mp = 500000;
    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }
    vector<ll> p(mp);
    p[0] = 2;
    repp(i,mp,1) p[i] = i * 2 + 1;
    vector<int> cp(mp,0);
    rep(i,n){
        ll a = pow(ar[i],0.5) / 2;
        rep(j,a+1){
            int c = 0;
            ll np = ar[i] / p[j];
            while (np * p[j] == ar[i]){
                ar[i] /= p[j];
                np = ar[i] / p[j];
                c++;
            }
            cp[j] = max(cp[j], c);
        }
        if (ar[i] != 1) cp[(ar[i]-1)/2] = max(cp[(ar[i]-1)/2],1);
    }
    ll lcm = 1;
    rep(i,mp){
        ll k = pow(p[i],cp[i]);
        lcm *= k % MOD;
        lcm %= MOD;
    }
    ll ans = 0;
    rep(i,n){
        ans += lcm * modinv(nar[i],MOD) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

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

using namespace std;
#define ll long long

const int N=1e6+100;


void solve()
{
    string s;cin>>s;
    int ans=0;
    int len=0;
    for(int i=0;i<s.size();i++) {
        if(s[i]== 'R') len++;
        else  {
            ans=max(ans,len);
            len=0;
        }
    }
    ans=max(ans,len);
    cout<<ans<<endl;
}
int main()
{
    ios::sync_with_stdio(0);
    solve();
    return 0;
}

/*

4 9
2 6
3 3
6 5
5 4

*/


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

int main(void)
{
    string s, t;
    cin >> s;
    cin >> t;
    int a,  b;
    cin >> a >> b;    
    string u;
    cin >> u;
    if(u == s)
        --a;
    else
    {
        --b;
    }
    cout << a << " " << b << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int gcd(int a, int b)
{
    int r;
    while (b != 0){
    	r = a % b;
    	a = b;
    	b = r;
    }
    return a;
}

int main()
{
	int x,y;
	scanf("%d%d",&x,&y);
	printf("%d\n",1+x+y-gcd(x,y));
    return 0;
}

Measured memory_bytes: 1828
#include<stdio.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
int n,m,x,y,xm,ym,xx,yy;
int main(){
	scanf("%d%d%d%d",&n,&m,&x,&y);
	scanf("%d",&xm);
	fo(i,2,n){
		scanf("%d",&xx);
		if (xx>xm) xm=xx;
	}
	scanf("%d",&ym);
	fo(i,2,m){//2..n
		scanf("%d",&yy);
		if (yy<ym) ym=yy;
	}
	xm++;x++;
	if (xm>x) x=xm;
	if (ym<y) y=ym;
	if (x<=y) printf("No War\n");else printf("War\n");
	return 0;
}

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

using namespace std;

typedef long long ll;

ll d[200004];
ll ball[2000004];

void FASTIO() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
}

int main() {
	FASTIO();
	ll n; cin >> n;
	for (int i=1; i<=n; i++) {
		cin >> ball[i];
		d[ball[i]]++;
	}
	ll ans = 0;
	for (int i=1; i<=n; i++) {
		ans += d[i]*(d[i]-1)/2;
	}
	for (int i=1; i<=n; i++) {
		ans -= d[ball[i]]*(d[ball[i]]-1)/2;
		d[ball[i]]--;
		ans += d[ball[i]]*(d[ball[i]]-1)/2;
		cout << ans << "\n";
		ans -= d[ball[i]]*(d[ball[i]]-1)/2;
		d[ball[i]]++;
		ans += d[ball[i]]*(d[ball[i]]-1)/2;
	}
	return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


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

    
    if (k>(n-1)*(n-2)/2) {
        cout << "-1" << endl;
        return 0;
    }
    
    
    int m = n-1 + ((n-1)*(n-2)/2-k);
    cout << m << endl;
    for (int i=2; i<=n; i++) {
        cout << "1 " << i << endl;
        m--;
    }
    if (m==0) return 0;
    for (int i=2; i<=n-1; i++) {
        for (int j=i+1; j<=n; j++) {
            cout << i << " " << j << endl;
            m--;
            if (m==0) return 0;
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void insertion_sort(int* A, int n);
void print_line(int* A, int n);

int main(void){
    int N;
    int A[100];
    int i;
    scanf("%d", &N);

    for(i = 0; i < N; ++i){
        scanf("%d", &A[i]);
    }
    insertion_sort(A, N);
    return 0;
}

void insertion_sort(int* A, int N){
    int i, j;
    int v;
    print_line(A, N);
    for(i = 1; i <= N-1; ++i){
        v = A[i];
        j =i - 1;
        while(j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        print_line(A, N);
    }
}

void print_line(int *A, int N){
    int i;
    for(i = 0; i < N-1; ++i){
        printf("%d ", A[i]);
    }
    printf("%d\n", A[N-1]);
}


Measured memory_bytes: 1968
#include <iostream>
#include "string"
#include <algorithm>
#include <vector>

using namespace std;


int main()
{
	int X,N;
	cin >> N;
	vector<int> d(N);
	for (int i=0; i < N; i++) {
		cin >> d[i];
	}
	sort(d.begin(),d.end());
	d.erase(unique(d.begin(), d.end()),d.end());
	cout << d.size();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
const ll mod=1e9+7;
const int Max=2e5+5;
vector<int>q[100005];
int a[100005];
int main()
{
	int n,m;
	sc(n);sc(m);
	rep(i,1,m){
		int u,v;sc(u);sc(v);
		q[u].push_back(v);q[v].push_back(u);
	}
	queue<int>p;
	p.push(1);a[1]=0;
	while(!p.empty()){
		int u=p.front();p.pop();
		for(int i=0;i<q[u].size();i++){
			int v=q[u][i];
			if(a[v]==0&&v!=1){
				a[v]=u;p.push(v);
				//pf("%d %d\n",a[v],v);
			}
		}
	}int biaoji=0;
	rep(i,2,n)if(a[i]==0)biaoji=1;
	if(biaoji==1)pf("No\n");
	else {
		pf("Yes\n");
		rep(i,2,n)pf("%d\n",a[i]);
	}
}


Measured memory_bytes: 10564
s = list(input())
t = list(input())
ss, tt = len(s), len(t)
flag = 0
for i in range(ss - tt + 1):
    temp = s[i: i + tt + 1]
    ttt = 0
    for k, j in zip(temp, t):
        if k == j:
            ttt += 1
    flag = max(flag, ttt)
print(tt - flag)
    

Measured memory_bytes: 9064
#include <stdio.h>
#include <string.h>
int main(){
	long long num;
	scanf("%lld", &num);
	char name[105] = {0};
	int i = 0;
	num-=1;
	while(num >= 0){
		name[i] = num%26 + 'a';
		num/=26;
		i++;
		num--;
	}
	int len = strlen(name);
	for(int j=len-1;j>=0;j--){
		printf("%c", name[j]);	
	}
	return 0;
} 

Measured memory_bytes: 1644
x = int(input())
lis = []
for i in range(-120, 121):
    lis.append(i**5)
flag = False
for i in range(1, len(lis)):
    for j in range(i):
        if lis[i] - lis[j] == x:
            print("{} {}".format(-120 + i, -120+j))
            flag = True
        if flag:
            break
    if flag:
        break


Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
    int a,b,c,d,e,k;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    cin >> k;
    if(e - a <= k)
    {   
        cout << "Yay!";
    }else
    {
        cout << ":(";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    int n, r;
    while(1) {
        cin >> n >> r;
        if(n == 0 && r == 0) break;
        stack<int> yama;
        for(int i = 1; i <= n; ++i) yama.push(i);
        stack<int> hako;
        stack<int> ue;
        for(int i = 0; i < r; ++i) {
            int p, c; cin >> p >> c;
            for(int j = 0; j < p-1; ++j) {
                hako.push(yama.top());
                yama.pop();
            }
            for(int j = 0; j < c; ++j) {
                ue.push(yama.top());
                yama.pop();
            }
            while(!hako.empty()) {
                yama.push(hako.top());
                hako.pop();
            }
            while(!ue.empty()) {
                yama.push(ue.top());
                ue.pop();
            }
        }
        cout << yama.top() << endl;
    }
}


Measured memory_bytes: 3072
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		long count = 0;
		int prev = sc.nextInt();
		if (prev > x) {
			count += prev - x;
			prev = x;
		}
		for (int i = 1; i < n; i++) {
			int z = sc.nextInt();
			if (prev + z > x) {
				int sa = prev + z - x;
				count += sa;
				z -= sa;
			}
			prev = z;
		}
		System.out.println(count);
	}
}


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

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

  vector<pair<string, int>> p(n) ;

  for (int i = 0 ; i < n ; i++){
    string a;
    int b ;
    cin >> a >> b ;
    p.at(i) = make_pair(a, b) ;
  }

  string name ;
  cin >> name ;

  /*for (int i = 0 ; i  < n ; i++) {
    cout << p.at(i).first << " " << p.at(i).second << endl ;
  }*/

  int time = 0 ;
  int num ;
  for ( num = 0; num < n ; num++) {
    if(p.at(num).first == name){
      break ;
    }
  }

  for (int i = num+1 ; i < n ; i++ ) {
    time += p.at(i).second ;
  }

  cout << time << endl ;

  return 0 ;
}


Measured memory_bytes: 256
//   ┏━━┓┏━━┓┏┓┏┓┏┳━┳┓┏━━┓┏━┳┓┏━━┓     ┏┳┓┏┳┓┏━┳━┓┏━━┓┏━┓
//   ┃┏┓┃┃━━┫┃┗┛┃┃┃┃┃┃┃┏┓┃┃┃┃┃┗┃┃┛     ┃┏┛┃┃┃┃┃┃┃┃┃┏┓┃┃╋┃
//   ┃┣┫┃┣━━┃┃┏┓┃┃┃┃┃┃┃┣┫┃┃┃┃┃┏┃┃┓     ┃┗┓┃┃┃┃┃┃┃┃┃┣┫┃┃┓┫
//   ┗┛┗┛┗━━┛┗┛┗┛┗━┻━┛┗┛┗┛┗┻━┛┗━━┛     ┗┻┛┗━┛┗┻━┻┛┗┛┗┛┗┻┛
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    int count=0;
    cin>>s;
    if(s=="RRR"){
      cout<< 3;
    }
    else if(s=="SRR" || s=="RRS"){
      cout<< 2;
    }
    else if(s=="RSS" || s=="SRS" || s=="SSR" || s=="RSR"){
      cout<< 1;
    }
    else{
      std::cout << 0;
    }
  return 0;
}
// By Ashwani Kumar, Indian Institute Of Technology(IIT), Guwahati.
//   ╔══╗╔══╗╔══╗     ╔══╗╔╦╗╔╦═╦╗╔══╗╔╗╔╗╔══╗╔══╗╔══╗
//   ╚║║╝╚║║╝╚╗╔╝     ║╔═╣║║║║║║║║║╔╗║║╚╝║║╔╗║╚╗╔╝╚║║╝
//   ╔║║╗╔║║╗─║║─     ║╚╗║║║║║║║║║║╠╣║║╔╗║║╠╣║─║║─╔║║╗
//   ╚══╝╚══╝─╚╝─     ╚══╝╚═╝╚═╩═╝╚╝╚╝╚╝╚╝╚╝╚╝─╚╝─╚══╝


Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
const lint MOD = pow(10, 9) + 7;

int main() {
	lint N, K;
	cin >> N >> K;
	vector<lint>H(N);
	rep(i, N) {
		cin >> H[i];
	}
	sort(H);
	reverse(H);
	if (K >= N) {
		cout << 0 << endl;
	}
	else {
		lint ans = 0;
		rep(i, N) {
			ans += H[i];
		}
		rep(i, K) {
			ans -= H[i];
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 1792
# import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

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

def main():
    n = int(input())
    x = list(map(int,ipti().split()))
    x_sorted = sorted(x)

    med_small = x_sorted[n//2 - 1]
    med_big = x_sorted[n//2]

    for i in range(n):
        if x[i] <= med_small:
            print(med_big)
        else:
            print(med_small)

if __name__ == '__main__':
    main()

Measured memory_bytes: 85972
#include <bits/stdc++.h>
using namespace std;
#define N 50
#define INF 99999999
typedef pair<int,int>P;

int main(){
    int n;cin>>n;
    vector <int>a(n);
    vector <int>b(n);
    for(int i=0;i<n;i++){cin>>a[i];}//cout<<a[i];}cout<<endl;
    for(int i=0;i<n;i++){b[i]=a[i];}//dummy
    sort(a.begin(),a.end());
    int mid1=a[n/2-1];
    int mid2=a[n/2];
    for(int i=0;i<n;i++){
        if(b[i]<=mid1)cout<<mid2<<endl;
        else cout<<mid1<<endl;
    }
    

}



Measured memory_bytes: 3712
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
#include <boost/any.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto i:v)output(i);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define sum(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
struct SEG{
    lint n=1;
    vec node,lazy;
    SEG(lint size){
        while(n<size)n<<=1;
        n*=2;
        node.resize(2*n-1,0);
        lazy.resize(2*n-1,0);
    }
    //0-indexed [a,b)
    void add(lint a,lint b,lint x,lint k=0,lint l=0,lint r=-1){
        if(r<0)r=n;
        if(a<=l&&r<=b){
            node[k]+=(r-l)*x;
            if(k<n-1){
                lazy[2*k+1]+=x;
                lazy[2*k+2]+=x;
            }
        }else if(l<b&&a<r){
            node[k]+=(min(b,r)-max(a,l))*x;
            add(a,b,x,2*k+1,l,(l+r)/2);
            add(a,b,x,2*k+2,(l+r)/2,r);
        }
    }
    //0-indexed [a,b)
    lint get(lint a,lint b,lint k=0,lint l=0,lint r=-1){
        if(r<0)r=n;
        if(b<=l||r<=a)return 0;
        if(a<=l&&r<=b)return lazy[k]*(r-l)+node[k];
        if(k<n-1){
            lazy[2*k+1]+=lazy[k];
            lazy[2*k+2]+=lazy[k];
        }
        lazy[k]=0;
        return get(a,b,2*k+1,l,(l+r)/2)+get(a,b,2*k+2,(l+r)/2,r);
    }
};
int main(){
    lint n;
    cin>>n;
    cout<<800*n-(n/15)*200;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i < (n);i++)
using namespace std;
//最大値を求める
int main(){
  int n;
  scanf("%d",&n);
  vector<int> a(n);
  rep(i,n) scanf("%d",&a[i]);
  vector<int> ac = a;
  sort(ac.rbegin(),ac.rend());
  rep(i,n){
    int ans = ac[0];
    if(ac[0] == a[i]) ans = ac[1];
    printf("%d\n",ans);
  }
}



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

int64_t powpow(int64_t y, int64_t x){
  int64_t res=1;
  for (int i=0; i<x; i++){
    res*=y;
  }
  return res;
}

int64_t pow5(int64_t N, int64_t i){
  return N/(powpow(5,i)*2);
}

int main(){
  int64_t N;
  cin >> N;
  if (N%2==1){
    cout << 0 << endl;
    return 0;
  }
  int64_t res = 0;
  for (int i=1; pow(5,i)<=pow(10,18); i++){
    res += pow5(N,i);
  }
  cout << res << endl;
}

Measured memory_bytes: 256
N, X, Y = map(int, input().split())

dist_list =[0] *(N+10)
for i in range(1, N):
    for j in range(i+1, N+1):
        dist = min(abs(j-i), abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X))
        dist_list[dist] += 1
for k in range(1, N):
    print(dist_list[k])

Measured memory_bytes: 47836
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64 + num%26)

N = int(input())
a = num2alpha(N)
print(a.lower())

Measured memory_bytes: 9200
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr ll inf = 1ll<<60;
int main(){
    vector<vector<int>> m(105,vector<int>(105,1<<20));
    int N,M;
    cin>>N>>M;
    for(int i=0;i<N;++i)m[i][i] = 0;
    vector<tuple<int,int,int>> v;
    for(int i=0;i<M;++i){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        m[a][b] = m[b][a] = c;
        v.emplace_back(a,b,c);
    }
    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            for(int k=0;k<N;++k){
                m[j][k] = min(m[j][k],m[j][i] + m[i][k]);
            }
        }
    }
    int ret = 0;
    for(int i=0;i<M;++i){
        bool remove = true;
        int a,b,c;
        tie(a,b,c) = v[i];
        for(int j=0;j<N;++j){
            for(int k=0;k<N;++k){
                if((m[j][k] == m[j][a] + m[b][k] + c) or (m[k][j] == m[k][a] + m[b][j] + c))remove = false;
            }
        }
        if(remove)ret++;
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
int n,l,r;
ll ans=1e16;
ll a[200010],pre[200010];
ll aa,ab,ac,ad;
int main(){
	scanf("%d",&n);
	int i,j;
	pre[0]=0;
	for(i=1;i<=n;++i){scanf("%lld",&a[i]);pre[i]=pre[i-1]+a[i];}
	l=1;r=3;
	for(i=2;i<n-1;++i){
		while(l<i && abs(pre[l]-(pre[i]-pre[l]))>=abs(pre[l+1]-(pre[i]-pre[l+1])))  l++;
		while(r<n && abs(pre[r]-pre[i]-(pre[n]-pre[r]))>=abs(pre[r+1]-pre[i]-(pre[n]-pre[r+1])))  r++;
		aa=pre[l];ab=pre[i]-pre[l];ac=pre[r]-pre[i];ad=pre[n]-pre[r];
		ans=min(ans,max(max(aa,ab),max(ac,ad))-min(min(aa,ab),min(ac,ad)));
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>

int main()
{
    int N;
    scanf("%d", &N);
    int a[N];
    int all = 0;
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &a[i]);
        all ^= a[i];
    }

    for (int i = 0; i < N; i++)
        printf("%d ", a[i] ^ all);
    puts("");
}

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

Measured memory_bytes: 128
using System;

namespace _6_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var num = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var len = num.Length;
            for(var i=len-1;i>=0;i--)
            {
                if (i == len - 1) Console.Write(num[i]);
                else Console.Write(" " + num[i]);
            }
            Console.WriteLine();
        }
    }
}



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

int main() {
    int n;
    cin>>n;
    double t, a;
    scanf("%lf %lf", &t, &a);
    double h[n];
    for(int i=0;i<n;i++) scanf("%lf", &h[i]);
    for(int i=0;i<n;i++) {
        h[i]=a-(t-h[i]*0.006);
        if(h[i]<0) h[i]=0.0-h[i];
        }
    double mini=100000000;
    int index=0;
    for(int i=0;i<n;i++) {
        double tmp=mini;
        mini=min(mini, h[i]);
        if(tmp!=mini) index=i;
    }
    cout<<index+1<<endl;
}

Measured memory_bytes: 256
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/01/20 21:30:49
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  struct Train {
    int c,s,f;
  };
  vector<Train> ts(n-1);
  for (int i = 0; i < n-1; i++) {
    int c,s,f; cin>>c>>s>>f;
    ts[i] = {c,s,f};
  }
  vector<int> ans(n);
  ans[n-1] = 0;
  for (int i = n-2; i >= 0; i--) {
    int t = 0;
    for (int p = i; p < n-1; p++) {
      if (t <= ts[p].s)
        t = ts[p].s;
      else {
        if (t % ts[p].f != 0)
          t += ts[p].f - t % ts[p].f;
      }
      t += ts[p].c;
    }
    ans[i] = t;
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3656
# import sys
# input = sys.stdin.readline

def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

a,v = mp()
b,w = mp()
t = int(input())
dif = abs(a-b)
u = v - w
if dif <= t*u:
    print("YES")
else:
    print("NO")





Measured memory_bytes: 61692
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
/*
77*101

111 = 3*37
1111 = 11*101
11111 = 41*271
111111 = 3*7*11*13*37 //111*1001
1111111 = 239*4649 // 
11111111 = 11*73*101*137//11*1010101
111111111 = 3^2*37*333667//111*1001001
えええ・・・
*/
int main(){
  ll K; cin>>K;
  ll ans = 0;
  ll des=7;
  bool end=false;
  rep(i,1000010){
    ans = i+1;
    if(des%K == 0){
      end=true;
      break;
    }
    des%=K;
    des=des*10+7;
  }
  if(end)
    cout<<ans<<endl;
  else
    cout<<-1<<endl;
}

Measured memory_bytes: 3576