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

class Main{
	public static void main(String args[]){
		Scanner s=new Scanner(System.in);
		while(s.hasNext()){
			String str=s.nextLine();
			String []table=str.split(" ");
			Stack<String> stack=new Stack<String>();
			for(int i=0;i<table.length;i++){
				if(table[i].equals("+")){
					double a=Double.parseDouble(stack.pop());
					double b=Double.parseDouble(stack.pop());
					stack.push(""+(a+b));
				}
				else if(table[i].equals("-")){
					double a=Double.parseDouble(stack.pop());
					double b=Double.parseDouble(stack.pop());
					stack.push(""+(b-a));
				}
				else if(table[i].equals("*")){
					double a=Double.parseDouble(stack.pop());
					double b=Double.parseDouble(stack.pop());
					stack.push(""+(a*b));
				}
				else if(table[i].equals("/")){
					double a=Double.parseDouble(stack.pop());
					double b=Double.parseDouble(stack.pop());
					stack.push(""+(b/a));
				}else{
					stack.push(table[i]);
				}
			}
			System.out.println(stack.pop());
		}
	}
}


Measured memory_bytes: 26292
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_C&lang=jp

"""
import sys
from sys import stdin
input = stdin.readline


def solve(n):
    # ビルをつくる(どの部屋も入居者は0)
    buildings = []
    for _ in range(4):          #  ビルは4棟
        buildings.append([[0]*10 for _ in range(3)]) #  1フロア10部屋で3階建

    # 入居者の増減処理 (ビル番号、フロア番号、部屋番号が0起算になっているので、-1する)
    for _ in range(n):
        b, f, r, v = map(int, input().split())
        buildings[b-1][f-1][r-1] += v

    res = []
    for b in buildings:
        for f in b:
            f_stat = ' '.join(map(str, f))
            res.append(' ' + f_stat)
        res.append('#'*20)
    res = res[:-1]
    print(*res, sep='\n')


def main(args):
    n = int(input())
    solve(n)


if __name__ == '__main__':
    main(sys.argv[1:])



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

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


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

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

    if (a + W < b)
    {
        cout << b - (a + W) << endl;
    }
    else if (b + W < a)
    {
        cout << a - (b + W) << endl;
    }
    else
    {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define LD long double

LL MOD = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int sum_or = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        sum_or = (sum_or ^ a[i]);
    }
    for(int i = 0; i < n; ++i){
        cout << (sum_or ^ a[i]) << " ";
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 3916
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  bool flag = false;
  for(int i = 0; i < 10; i++) {
    for(int j = i; j < 10; j++) {
      if(i * j == n) flag = true;
    }
  }
  YesorNo(flag);
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <algorithm>

using namespace std;

int main(){
  int N;

  scanf("%d", &N);

  bool possible = false;
  for(int i=0; i <= 100; i++){
    int remain = N - i*4;
    if(remain >= 0 && remain % 7 == 0){
      possible = true;
      break;
    }
  }
  
  if(possible){
    printf("Yes\n");
    }else{
    printf("No\n");
  }
  
  
  return 0;
}
  


Measured memory_bytes: 128
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(void){
  string s;cin >> s;
  int ans = 0;
  for(int i = 0;i < 3;i++)ans += s[i] - '0';
  printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;

int main()
{
    int n, m;
    cin >> n >> m;
    priority_queue<int, vector<int>, greater<int>> q;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        q.push(a);
    }
    vector<pair<int, int>> cb(m);
    for (int i = 0; i < m; i++)
    {
        int b, c;
        cin >> b >> c;
        cb[i] = {c, b};
    }
    sort(cb.begin(), cb.end(), greater<>());
    int i = 0;
    int index = 0;
    while (true)
    {
        if (cb[i].fi > q.top() && cb[i].se > 0)
        {
            q.pop();
            q.push(cb[i].fi);
            cb[i].se--;
            index++;
        }
        else if (cb[i].fi > q.top() && cb[i].se == 0)
        {
            i++;
        }
        else
        {
            break;
        }
    }
    ll ans = 0;
    while (!q.empty())
    {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(string, A, B, C);
  if (A.back() == B[0] && B.back() == C[0]) {
    print("YES");
  } else {
    print("NO");
  }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import itertools#これは色々使える組み込み関数みたいなやつ
#import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
from operator import itemgetter
from sys import stdin
#input = sys.stdin.readline#こっちの方が入力が早いが使える時に使っていこう
from math import factorial
N=3
M=3
i=0
j=0
k=0

number_list=list(map(int, input().split(" ")))
N=number_list[0]
M=number_list[1]
#print(N,M)
if N >=2:
    i=factorial(N) / factorial(2) /factorial(N-2)
else:
    i=0

if M>=2:
    j=factorial(M) / factorial(2) /factorial(M-2)
else:
    j=0
print(int(i+j))
#N=int(input())
#A=int(input())
#B=int(input())
#print(N)
"1行1つの整数を入力を取得し、整数と取得する"


#number_list=list(map(int, input().split(" ")))#数字の時
#print(number_list)
"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
#メモ
for i in number_list:#こっちの方がrage使うより早いらしい
    print(number_list[i-1])

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''
#array=[input().split()for i in range(N)]
#print(type(array[0][0]))
#print(array)
"正方行列にstr型の値を入力"
'''

#brray=[list(map(int, input().split(" ")))for i in range(N)]
#print(type(brray[0][0]))
#print(brray)
'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"
#以下に別解を記載
#N, M = [int(i) for i in input().split()]
'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''




#s=input()
#a=[int(i) for i in s]
#print(a[0])
#print([a])
#単数値．桁ごとに分割したい．入力と出力は以下の通り
#イメージとして1桁ごとにリストに値を入れているかんじ

'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()#何個でもいけることが多い
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''


#a= stdin.readline().rstrip()
#print(a.upper())
"aという変数に入っているものを大文字にして出力"




#なんかうまく入力されるけど
#a=[[int(i) for i in 1.strip()]for 1 in sys.stdin]
#a = [[int(c) for c in l.strip()] for l in sys.stdin]]
#print(a)
#複数行の数値を入力して正方行列を作成


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

int main(){
    int N;
    std::cin >> N;
    std::vector< int > A(N);
    for(int i=0; i<N; i++){
        std::cin >> A[i];
    }
    
    std::vector< int > boll(N);
    int N_cnr = N;
    while(N_cnr != 0){
        int N_half = N_cnr / 2;
        for(int i=N_half; i<N_cnr; i++){
            int cnt = A[i];
            int cur = i * 2 + 1;
            while(cur < N){
                cnt += boll[cur];
                cur += i + 1;
            }
            boll[i] = cnt % 2;
        }
        N_cnr /= 2;
    }
    
    std::vector< int > ans;
    int ans_cnt = 0;
    for(int i=0; i<N; i++){
        if(boll[i]){
            ans_cnt++;
            ans.push_back(i + 1);
        }
    }
    std::cout << ans_cnt << std::endl;
    if(ans_cnt){
        for(int i=0; i<ans.size(); i++){
            std::cout << ans[i] << std::endl;
        }
    }
    
    return 0;
}



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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long n, ans=0;
    cin >> n;
    vector<long> a(n);
    for (long i=0; i<n; i++)
        cin >> a[i];
    sort(a.begin(), a.end());
    for (long i=0; i<n; ) {
        long k, tmp = a[i];
        for (k=1; i+k<n; k++)
            if (a[i+k] != tmp)
                break;
        if (k > tmp)
            ans += k-tmp;
        else if (k < tmp)
            ans += k;
        i += k;
    }
    cout << ans << endl;
}

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

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector< int > B(M);
    rep(i, M) cin >> B[i];
    vector< vector< int > > A(N, vector< int >(M));
    rep(i, N) rep(j, M) cin >> A[i][j];

    int ans = 0;
    rep(i, N) {
        int res = C;
        rep(j, M) { res += A[i][j] * B[j]; }
        if (res > 0) {
            ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    s = input()
    t = input()
    cond = t[:-1] == s
    print('Yes' if cond else 'No')


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 9088
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n,q = map(int,input().split())
G = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(lambda x:int(x)-1,input().split())
    G[a].append(b)
    G[b].append(a)

ans = [0 for _ in range(n)]
for i in range(q):
    p,x = map(int,input().split())
    ans[p-1] += x

def dfs(pre,now,point):
    for to in G[now]:
        if to==pre:continue
        ans[to]+=point
        dfs(now,to,ans[to])
dfs(-1,0,ans[0])
print(*ans)

Measured memory_bytes: 230920
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  // Declare values
  int H, W; cin >> H >> W;
  vector<vector<char>> table(H, vector<char>(W));
  // input
  rep(i, H) {
    rep(j, W) {
      cin >> table.at(i).at(j); 
    }
  }
 
  // Checkpoint
  vector<bool> line(H, false);
  vector<bool> quene(W, false);
 
  rep(i, H) {
    rep(j, W) {
      if (table.at(i).at(j) == '#') {
        line.at(i) = true;
        quene.at(j) = true;
      }
    }
  }
 
 
  rep(i, H) {
    if (line.at(i)){
      rep(j, W) {
        if (quene.at(j)) {
          cout << table.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
  
  return 0; 
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define W while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007

int main() {
    FASTIO;
  ll x,y,z;
  cin>>x>>y>>z;
  swap(x,y);
  swap(x,z);
  pr3(x,y,z);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define MAX 1e9+7
#define MIN -MAX
#define i(a) cin>>a
#define in(a,b) cin>>a>>b
#define o(a) cout<<a
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loop1(i,a,b) for(ll i=a;i<=b;i++)
#define v(a) vector<ll>a
#define mp(a,b) make_pair(a,b)
using namespace std;
int main()
{
    ll k,x;
    cin>>k>>x;
    for(ll i=x-k+1;i<x;i++){
        cout<<i<<" ";
    }
    for(ll i=x;i<=k+x-1;i++){
        cout<<i<<" ";
    }
         /*for(ll i=1;i<=n;i++){
        cout<<dp[i]<<" ";
    }*/
    //cout << dp[n] <<"\n";

}


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


class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		long[] a=new long[N];
		long[] b=new long[N];
		for(int i=0; i<N; i++) {
			a[i]=sc.nextLong();
		}
		for(int i=0; i<N; i++) {
			b[i]=sc.nextLong();
		}
		long[] diff=new long[N];
		long sumdiff=0;
		long sup=0;
		long kaz=0;
		for(int i=0; i<N; i++) {
			if(a[i]>=b[i]) {
				sup+=a[i]-b[i];
			}
			else {
				sumdiff+=b[i]-a[i];
				kaz++;
			}
			diff[i]=a[i]-b[i];
		}
		if(sumdiff>sup) {
			pl(-1);
		}
		else if(sumdiff==0) {
			pl(0);
		}
		else {
			Arrays.sort(diff);
			for(int i=N-1; i>=0; i--) {
				sumdiff-=diff[i];
				if(sumdiff<=0) {
					pl(kaz+(N-i));
					System.exit(0);
				}
			}
		}

	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0;i<N;i++) {
        cin >> a[i];
    }
    sort(a.begin(),a.end());

    int ans=0;
    for(int i=0;i<N;i++) {
        if(i%2 == 0) {
            ans += a[i];
        }
        else {
            ans -= a[i];
        }
    }
    cout << abs(ans) << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define    ss   second
#define    ff   first
#define    pb   push_back
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);

 vector<pair<ll, ll>>v(mx+1);
ll t[mx+1] = {};
int N, X[mx], Y[mx], T[mx];

int main() {
    FIO;
    ll n;
    cin >> n;
       for (ll i = 1; i <= n; i++) {
            cin >> T[i] >> X[i] >> Y[i];

    }

    for (ll i = 1; i <= n; i++) {
        int tm = T[i] - T[i - 1];
		int ds = abs(X[i] - X[i - 1]) + abs(Y[i] - Y[i - 1]);
		if (ds > tm || (tm - ds) % 2 == 1) {
			cout << "No" << endl;
			return 0;
		}
    }
cout << "Yes" << endl;
}


Measured memory_bytes: 160424
def main():
    n = int(input())
    A = list(map(int, input().split()))
    s = 0
    for a in A:
        if a % 2 == 0:
            if a % 3 == 0 or a % 5 == 0:
                s += 1
        else:
            s += 1
    if s == n:
        print("APPROVED")
    else:
        print("DENIED")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import scala.io.Source

object Main{
  def main(args: Array[String]){
    val line =
      for{
        in <- Source.stdin.getLines.toList
      } yield in.map(c => c.toLower)

      println(if((line(0) + line(0)).contains(line(1))) "Yes" else "No")
  }
}

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

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

int ans;
int main(){
  int N;cin>>N;
  set<int> s;
  rep(i,N){
    int d;cin>>d;
    s.insert(d);
  }
  cout<<s.size()<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>

using namespace std;

#define LL long long

set<char> vis;

int main() {
	string s;
	cin>>s;
	if(s == "zyxwvutsrqponmlkjihgfedcba") return puts("-1"), 0;
	else if(s.size() > 26) return puts("-1"), 0;
	else if(s.size() < 26) {
		for(int i = 0; i < s.size(); ++i) vis.insert(s[i]);
		char i = 'a';
		for(; i <= 'z'; ++i) if(!vis.count(i)) break;
		cout<<s + i<<endl;
		return 0;
	}else {
		char t; int j;
		for(j = s.size() - 1; j >= 0; --j) {
			vis.clear();
			for(int i = 0; i < j; ++i) vis.insert(s[i]);
			t = s[j] + 1;
			for(; t <= 'z'; ++t) {
				if(!vis.count(t)) goto label;
			}
		}
		label: string ans(s, 0, j);
		ans += t;
		cout<<ans<<endl;
		return 0;
	}
} 

Measured memory_bytes: 256
'''ika tako
高い順に割引券を多く使いたい。1枚使ってもまだ他より高ければ
2枚、3枚、、、と使えばよいが、ある程度使って他の商品が高くなれば、
そちらに使った方がよい。なので、「今の最高額の商品を、
半額で置き換える」ことを  M  回繰り返す。heapqを使うと1回の操作に  
O(logN)  かかるので、全体で  O(MlogN)  となる。
pop()してpush()してもよいが、replace()を使えば2つの操作を1度に行え、
heap構造を保つための比較処理も1回で済むので定数倍高速。
'''
from heapq import heapify, heapreplace
 
n, m = list(map(int, input().split()))
aaa = [-a for a in map(int, input().split())]
#最大値を取り出したいので、-マイナスを付けている
heapify(aaa)#リストをヒープ(二分木)にする
 
for _ in range(m):
    heapreplace(aaa, aaa[0] // 2 + aaa[0] % 2)
    #heappopを行ってからheappushを行う
    
print(-sum(aaa))

Measured memory_bytes: 14180
def main():
    from sys import stdin
    import math
    a,b,h,m = map(int,stdin.readline().rstrip().split())
    h_rad = (h*60+m)/(12*60)*math.pi*2
    m_rad = m/60*math.pi*2

    x = (a*math.cos(h_rad), a*math.sin(h_rad))
    y = (b*math.cos(m_rad), b*math.sin(m_rad))

    dis = ((x[0]-y[0])**2 + (x[1]-y[1])**2)**0.5
    print(dis)

main()

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

using namespace std;

int main() {
  int N;
  int t[16][17];
  int dp[1<<16];
  while(cin >> N && N) {
    for(int i=0;i<N;i++)
      for(int j=0;j<N+1;j++)
	cin>>t[i][j];
    memset(dp, 63, sizeof dp);dp[0]=0;
    for(int S=0;S<(1<<N);S++) {
      for(int i=0;i<N;i++) {
	if(S>>i & 1) continue;
	dp[S+(1<<i)]=min(dp[S+(1<<i)], dp[S]+t[i][0]);
	for(int j=0;j<N;j++) {
	  if(!(S>>j & 1)) continue;
	  dp[S+(1<<i)]=min(dp[S+(1<<i)], dp[S]+t[i][j+1]);
	}
      }
    }
    cout<<dp[(1<<N)-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1424
#include <stdio.h>

#define MAX 100000

void swap(int*,int*);
void Partirion(int,int,int*);

int  main(void){
    int n,i,A[MAX];
    
    scanf("%d",&n);
    for(i = 0 ; i < n ; i++) scanf("%d",&A[i]);
    
    Partirion(0,n-1,A);
}

void swap(int* a,int* b)
{
    int temp = *a;
    *a = *b;
    *b = temp;
}

void Partirion(int l,int r,int* A)
{
    int x = A[r];
    int i = l, j;
    
    for(j = l; j < r; j++)
    {
        if(A[j] <= x) swap(&A[i++],&A[j]);
    }
    swap(&A[i],&A[j]);
    
    for(j = 0;  j <= r; j++)
    {
        if(j != 0) printf(" ");
        if(j == i) printf("[%d]",A[j]);
        else printf("%d",A[j]);
    }
    printf("\n");
} 


Measured memory_bytes: 2188
#include <bits/stdc++.h>
typedef long long int64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	int h, w; cin >> h >> w; std::vector<std::string> s(h);
	for(int i = 0; i < h; i++) cin >> s[i];
	
	std::vector<std::string> a(h, std::string(w, '.')), b(h, std::string(w, '.'));
	for(int i = 0; i < h; i++) a[i][w - 1] = b[i][0] = '#';
	for(int i = 0; i < h; i += 2) {
		for(int j = 1; j < w; j++) a[i][j] = '#';
		if(i + 1 < h) for(int j = 0; j < w - 1; j++) b[i + 1][j] = '#';
	}
	
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if(s[i][j] == '.') continue;
			if(a[i][j] == '.') a[i][j] = '#';
			else b[i][j] = '#';
		}
	}
	
	for(int i = 0; i < h; i++) cout << a[i] << endl; cout << endl;
	for(int i = 0; i < h; i++) cout << b[i] << endl;
	return 0;
}


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

int main(void){
	string str;
	int c=0;
	while(cin>>str){
		bool f=true;
		for(int i=0;i<str.length()/2;i++){
			if(str[i]!=str[str.length()-1-i]){f=false;break;}
		}
		if(f)c++;
	}
	cout<<c<<endl;
	return 0;
}

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

int main() {
  int a;
  cin >> a;
  
  bool ok = false;
  for (int i = 1; i <= 9; ++i) {
    for (int j = 1; j <= 9; ++j) {
      if (i * j == a) {
        ok = true;
      }
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

    int N;
    cin >> N;

    int A[N];

    int max = 0;
    int second_max = 0;
    for (int i=0; i<N; i++) {
        cin >> A[i];
    } 

    for (int i=0; i<N; i++) {
        if (max < A[i]) {
            max = A[i];
        } else if ((second_max < A[i]) & (A[i] <= max)) {
            second_max = A[i];
        }
    }

    for (int i=0; i<N; i++) {
        if (A[i] == max) {
            cout << second_max << "\n";
        } else {
            cout << max << "\n";
        }
    }



    return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n>>m>>s;
      vector<ll> g[ohara];
      queue<ll> que;
      map<ll,ll> a;
      map<ll,ll> b;
      map<ll,ll> out;
      rep(i,m){
        cin>>c>>d;
        c--,d--;
        g[c].push_back(d);
        g[d].push_back(c);
      }
      rep(i,n){
        rep(j,Size(g[i])){
          pos=g[i][j];
          if(s[pos]=='A')a[i]++;
          else b[i]++;
        }
      }
      rep(i,n){
        if(a[i]==0||b[i]==0){
          out[i]=1;
          que.push(i);
        }
      }
      while(!que.empty()){
        ll p=que.front();que.pop();
        rep(i,Size(g[p])){
          pos=g[p][i];
          if(out[pos]==1)continue;
          if(s[p]=='A')a[pos]--;
          else b[pos]--;
          if(a[pos]==0||b[pos]==0){
            que.push(pos);
            out[pos]=1;
          }
        }
      }
      rep(i,n){
        if(out[i]==1)cnt++;
      }
      if(cnt==n)Cout("No");
      else Cout("Yes");

       
return 0;
}


Measured memory_bytes: 64720
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int P = sc.nextInt();
        int Q = sc.nextInt();
        int R = sc.nextInt();
        int ans = Math.min(P + Q, Q + R);
        ans = Math.min(ans, R + P);
        System.out.print(ans);
    }
}

Measured memory_bytes: 23508
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
#include <string.h>

#define X first
#define Y second
#define MP make_pair
#define FOR(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
const int MAX = 101;

template<class T, class U>
void convert(T &t, U &u){
    stringstream ss;
    ss << t;
    ss >> u;
}

int main(){
	int n;
	cin >> n;
	while(n--){
		bool base[4];
		memset(base, false, sizeof(base));
		int out = 0, point = 0;
		while(1){
			bool base_next[4];
			memset(base_next, false, sizeof(base_next));
			string ev;
			cin >> ev;
			if(ev=="HIT"){
				FOR(i, 3){
					if(base[i]){
						base_next[i+1]=true;
						if(i+1==3) point++;
					}
				}
				base_next[0]=true;
			}else if(ev=="OUT"){
				out++;
				if(out==3) break;
				continue;
			}else{
				FOR(i, 3){
					if(base[i]) point++;
				}
				point++;
			}
			FOR(i, 4){
				base[i] = base_next[i];
			}
		}
		cout << point << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, S, A, B;
  cin >> N >> K;
  S = 0;
  A = 0;
  B = 0;
  for(int i = 0;i < N;i++){
    int x;
    cin >> x;
    A = 2 * x;
    B = (x - K) * 2;
    if(B < 0)
      B *= -1;
   if(A > B){
     S += B;
   }
   else{
     S += A;
  }
  }
  cout << S << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX_N = 1e5 + 10;
vector<vector<int>> edge(MAX_N, vector<int>{});
vector<int> visited(MAX_N, 0);
vector<int> path{};

bool dfs(int n){
    visited[n] = 1;
    path.push_back(n);
    for(int i=0; i<(int)edge[n].size(); i++){
        if(visited[edge[n][i]] == 0){
            dfs(edge[n][i]);
            break;
        }
    }
    return true;
}

int main(){
    int n, m; cin >> n >> m;
    int a, b;
    for(int i=0; i<m; i++){
        cin >> a >> b; a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    dfs(0);
    reverse(path.begin(), path.end());
    path.pop_back();
    visited[0] = 0;
    dfs(0);
    cout << (int)path.size() << endl;
    for(auto& v:path){
        cout << v + 1 << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 10104
#include <iostream>
using namespace std;
int findSumOfDigits(int n){
    int sum = 0;
    while (n > 0){
        sum += n%10;
        n /= 10;
    }
    return sum;
}

int main(){ 
    int n;
    cin >> n;
    int sum = findSumOfDigits(n);
    cout << ((n%sum==0)? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
N = int(input())
l = []
for _ in range(N):
  s, t = input().split()
  t = int(t)
  l.append([s, t])
X = input()

ans = 0
found = False
for s in l:
  if found:
    ans += s[1]
    continue
  if s[0] == X:
    found = True
    
print(ans)

Measured memory_bytes: 8848
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int H,W;cin >> H >> W;
    vector<string> s(H);
    rep(i,H)cin >> s[i];

    vector<vector<int>> dp(H,vector<int>(W,1000));
    dp[0][0] = 0;
    if(s[0][0] == '#')dp[0][0] = 1;

    rep(i,H)rep(j,W){
        char c = s[i][j];
        if(c == '#'){

            if(i < H-1)chmin(dp[i+1][j],dp[i][j]);
            if(j < W-1)chmin(dp[i][j+1],dp[i][j]);
        }
        else{
            if(i < H-1 && s[i+1][j] == '#')chmin(dp[i+1][j],dp[i][j]+1);
            else if(i < H-1) chmin(dp[i+1][j],dp[i][j]);

            if(j < W-1 && s[i][j+1] == '#')chmin(dp[i][j+1],dp[i][j]+1);
            else if(j < W-1)chmin(dp[i][j+1],dp[i][j]);
        }
    }

    cout << dp[H-1][W-1] << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
p = list(map(int, input().split()))

# 平均値のlist
m = [(e + 1) / 2 for e in p]

t = sum(m[0:K])
result = t

for i in range(N - K):
    t -= m[i]
    t += m[i + K]
    if t > result:
        result = t
print(result)

Measured memory_bytes: 24804
N, M = list(map(int, input().split())) # 整数
a = []
for i in range(N):
    a.append(list(map(int, input().split())))
    

m_lis= [0 for i in range(M+1)]
for i in range(N):
    for j in range(a[i][0]):
        m_lis[a[i][j+1]]+=1
        
        

count=0
for i in range(M+1):
    if m_lis[i]==N:
        count+=1
        
print(count)

Measured memory_bytes: 3064
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef long int				int32;
typedef unsigned long int		uint32;
typedef long long int			int64;
typedef unsigned long long int  uint64;
typedef pair<int, int>			PII;
typedef vector<int>				VI;
typedef vector<long long>		VLL;
typedef vector<string>			VS;
typedef vector<PII>				VII;
typedef vector<VI>				VVI;

#define MEM(a, b)				memset(a, (b), sizeof(a))
#define calctime				std::cout << setprecision(5) << fixed << "Time to completed program: " << (double)(clock() - start)/(CLOCKS_PER_SEC) << "s.\n";
#define FOR(i, j, k, in)		for (int i = (j); i < (k); i += (in))
#define FORW(i, j, k, in)		for (int i = (j); i <= (k); i += (in))
#define RFOR(i, j, k, in)		for (int i = (j); i >= (k); i -= (in))
#define RFORW(i, j, k, in)		for (int i = (j); i > (k); i -= (in))
#define aint64(cont)			cont.begin(), cont.end()
#define raint64(cont)			cont.end(), cont.begin()
#define sz(cont)				int((cont).size())
#define PB						push_back
#define MP						make_pair
#define EPS						1e-9
#define MOD						1000000007
#define PI						3.1415926535897932384626433832795
#define Ff						first
#define Ss						second
#define FastIO					ios_base::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);
#define fileIO(name)			ifstream iFs(name".inp"); ofstream oFs(name".out");
#define fileio(name)			ifstream cin(name".inp"); ofstream cout(name".out");
#define endl					'\n'

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

int a[105] = {}, v[105] = {};	

int main() {
	FastIO;
#ifndef ONLINE_JUDGE
	fileio("input");		//Remember to change this
#endif

	int64 dp[100006] = {}; FOR(i, 0, 100005, 1) dp[i] = LLONG_MAX;
	int n, w; cin >> n >> w; FOR(i, 0, n, 1) cin >> a[i] >> v[i];
	FORW(i, 0, n, 1) {
		RFOR(j, 100000, 0, 1) {
			if (j == 0) {
				dp[j] = 0;
				continue;
			}
			if (i == 0) {
				dp[j] = w + 1;
				continue;
			}
			if (v[i - 1] <= j) {
				dp[j] = min(a[i - 1] + dp[j - v[i - 1]], dp[j]);
			}
		}
	}

	int64 ans = 0;
	FORW(i, 0, 100000, 1) {
		if (dp[i] <= w && dp[i] > 0) { 
			ans = max(ans, (int64)i); 
		}
	}

	cout << ans << endl;

	//calctime
	return 0;
}

Measured memory_bytes: 4364
#include <bits/stdc++.h>
using namespace std;
int func(int b,char s){
    if(b==1) return s-'0';
    return -(s-'0'); 
}
int main(){
    string S;
    cin>>S;
    for(int i=0;i<(1<<3);i++){
        bitset<3> b(i); //1を+
        if(7-(S[0]-'0')==func(b[2],S[1])+func(b[1],S[2])+func(b[0],S[3])){
            cout<<S[0];
            for(int j=2;j>=0;j--)
                cout<<(b[j]==1?'+':'-')<<S[abs(3-j)];
            cout<<"=7"<<endl;
            break;
        }
    }
}

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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i += 2){
        int coans  = 0;
        for(int j = 1; j <= i; j++){
            if(i % j == 0) coans++;
        }
        if(coans == 8) ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// ConsoleApplication9.cpp : アプリケーションのエントリ ポイントを定義します。
//


#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>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define p(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
//#define int long long


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(ll a, ll n) {//aのn乗を計算します。
	ll x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool arr[100000100];
vector<ll>sosuu;
void Eratosthenes() {
	ll N = 10000010;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (ll i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (ll j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (int ll i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu.pb(i);
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}

ll stoL(string s) {
	ll n = s.length();
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += pow2(10, n - i-1)*(ll)(s[i]-'0');
	}
	return ans;
}
ll T[1010], A[1010];
int main() {
	int N; cin >> N;
	REP(i, N) {
		cin >> T[i] >> A[i];
	}
	ll x = T[0], y = A[0];
	FOR(i, 1, N) {
		ll t = T[i], a = A[i];
		ll k1 = (x + t - 1) / t, k2 = (y + a - 1) / a;
		ll k = max(k1, k2);
		x = t * k; y = a * k;
	}
	cout << x + y << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int i, flag, n, tmp, count = 0;
  int A[100];

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

  flag = 1;
  while(flag) {
    flag = 0;
    for(i=n-1; i>=1; i--) {
      if(A[i] < A[i-1]) {
	tmp = A[i];
	A[i] = A[i-1];
	A[i-1] = tmp;
	flag = 1;
	count++;
      }
    }
  }
  for(i=0 ; ; i++) {
    printf("%d", A[i]);
    if(i == n-1) break;
    printf(" ");
  }
  printf("\n%d\n", count);
  return 0;
}

Measured memory_bytes: 604
import math
import itertools

N=int(input())
X=list()
Y=list()
for i in range(N):
   x,y=map(int,input().split())
   X.append(x)
   Y.append(y)

numbers=[c for c in range(N)]
kyori=0
for i in itertools.permutations(numbers,N):
   for j in range(N-1):
      mae=i[j]
      usiro=i[j+1]
      kyori+=(((X[usiro]-X[mae])**2)+((Y[usiro]-Y[mae])**2))**0.5

N_f=math.factorial(N)
print(kyori/N_f)

Measured memory_bytes: 40684
#include <iostream>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    for(int i=1; i<=9; i++) {
        for(int j=1; j<=9; j++) {
            if(i*j == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define db long double
#define pii pair<ll,ll>
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define vii vector<vi>
#define lb lower_bound
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,b,a) for(int i=(b);i>=(a);--i)
#define rep0(i,a,b) for(int i=(a);i<(b);++i)
#define fore(i,a) for(int i=0;i<a.size();++i)
#define gc() getchar()
#define ls x<<1,l,m
#define rs x<<1|1,m+1,r
inline int rd()
{
	int x=0;char c=gc();while(!isdigit(c))c=gc();
	while(isdigit(c))x=x*10+c-48,c=gc();return x;
}
const int N=200005;
int n,a[N];
struct F
{
	int v0,p1,p2,a;
	inline int calc(int x,int b)
	{
		int t=v0+(a<b-x);
		if(p1<=a)t=min(t,v0-1+(p1>x)+(a-p1<b-x));
		if(p2<=a)t=min(t,v0-2+(p2>x)+(a-p2<b-x));
		return t;
	}
    inline F upd(int b)
    {
    	F t=(F){calc(0,b),b+1,b+1,b};
    	int l=0,r=b,m;
    	while(l<=r)if(calc(m=l+r>>1,b)==t.v0)l=m+1;else t.p1=m,r=m-1;
    	l=t.p1;r=b;
    	while(l<=r)if(calc(m=l+r>>1,b)==t.v0-1)l=m+1;else t.p2=m,r=m-1;
		return t;
	}
};
int main()
{
	n=rd();rep(i,1,n)a[i]=rd();
	F f=(F){0,1,1,0};rep(i,1,n)f=f.upd(a[i]);
	f=f.upd(0);printf("%d\n",f.v0);return 0;
} 

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

int main() {
	int r, c;
	int count;

	cin >> r >> c;
	
	int table[r][c];
	int r_sum = 0, c_sum[c], t_sum = 0;

	for (int i = 0; i < r; i++){
		for (int j = 0; j < c; j++){
			cin >> table[i][j];
		}
	}

	for (int i = 0; i < r; i++){
		for (int j = 0; j < c; j++){
			if (i == 0) c_sum[j] = 0;

			cout << table[i][j] << " ";
			r_sum += table[i][j];
			c_sum[j] += table[i][j];
		}
		cout << r_sum << endl;
		r_sum = 0;
	}

	for (int i = 0; i < c; i++){
		cout << c_sum[i] << " ";
		t_sum += c_sum[i];
	}

	cout << t_sum << endl;

	return 0;
}


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

int main(){
    int n;
    cin>>n;
    
    vector<int> arr(n);
    for(int i = 0; i < n; i++) cin>>arr[i];
    
    int res = 1000000000;
    for(int i = -100 ; i <= 100; i++){
        int temp = 0;
        for(int j = 0; j < arr.size(); j++){
            temp+=(arr[j] - i)*(arr[j] - i);
        }
        res = min(res,temp);
    }
    cout<<res;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

int n, a[3], ans;
map<PP, bool>mp;

int main() {
	cin >> n;
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < 3;j++)cin >> a[j];
		sort(a, a + 3);
		if (mp[PP(a[0], P(a[1], a[2]))])ans++;
		mp[PP(a[0], P(a[1], a[2]))] = true;
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
	unsigned long long n;
	string s;
	cin >> n;
	//Ascii from 97 to 122 (+96)
	while (true)
	{
		if (n % 26 == 0)
		{
			s += 'z';
			n /= 26;
			n--;
		}
		else
		{
			s += (char)((n % 26) + 96);
			n = n / 26;
		}
		if (n == 0) break;
	}
	reverse(s.begin(), s.end());
	cout << s << endl;

	ios::sync_with_stdio(false);
	cin.tie();
	cout.tie();
	return 0;
}

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

int main()
{
    int v, e, start, end;
    cin>>v;
    vector < vector <int> > g(v + 1);
    cin>>e;
    while(e--)
    {
        cin>>start>>end;
        g[start].push_back(end);
    }
    vector <int> indeg(v + 1, 0);
    for(int i = 1; i < v + 1; i++)
    {
        for(int j = 0; j < g[i].size(); j++)
        {
            indeg[g[i][j]] += 1;
        }
    }
    vector <int> sorted;
    vector <bool> vis(v + 1, false);
    priority_queue <pair<int, int>, vector <pair <int, int> >, greater <pair <int, int> > > pq;
    for(int i = 1; i < v + 1; i++)
    {
        pq.push(make_pair(indeg[i], i));
    }
    while(!pq.empty())
    {
        int prev = pq.top().second;
        pq.pop();
        if(indeg[prev] == 0 && !vis[prev])
        {
            vis[prev] = 1;
            sorted.push_back(prev);
        }
        for(int i = 0; i < g[prev].size(); i++)
        {
            if(indeg[g[prev][i]] > 0)
            {
                indeg[g[prev][i]] -= 1;
                pq.push(make_pair(indeg[g[prev][i]], g[prev][i]));
            }
        }
    }
//    for(int i = 0; i < sorted.size(); i++)
//    cout<<sorted[i]<<" ";
    vector <int> dist(v + 1, 0);
    for(int i = 0; i < sorted.size(); i++)
    {
        int pr = sorted[i];
        for(int j = 0; j < g[pr].size(); j++)
        {
            if(dist[g[pr][j]] < dist[pr] + 1)
            {
                dist[g[pr][j]] = dist[pr] + 1;
            }
        }
    }
    int ans = INT_MIN;
    for(int i = 1; i < dist.size(); i++)
    {
        if(ans < dist[i])
        ans = dist[i];
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 7796
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e4+10;
int p[N],lim=10000,p1;
int flag[N];
int q[N],q1;
ll a[505][505];
map<int,int> px,py;
int n;
void prep(int n){
	for (int i=2;i<=n;i++){
		if (!flag[i])p[++p1]=i;
		for (int j=1;j<=p1;j++){
			int x=i*p[j];
			if (x>n)break;
			flag[x]=1;
			if (i%p[j]==0)break;
		}
	}
}
ll gcd(ll a,ll b){
	return b?gcd(b,a%b):a;
}
ll lcm(ll a,ll b){
	if (!a||!b)return a+b;
	return a/gcd(a,b)*b;
}
int main(){
	cin>>n;
	if (n==2){
		cout<<"4 7\n23 10\n";
		return 0;
	}
	prep(lim);
	p1=0;p[0]=1;
	for (int i=0,j=999;i<j;i++,j--)
		q[++q1]=p[i],q[++q1]=p[j];
	p1=0;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			if ((i+j)&1)continue;
			if (!px[i+j])px[i+j]=q[++p1];
//			if (!py[i-j])py[i-j]=q[++p1];
//			a[i][j]=px[i+j]*py[i-j];
		}
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			if ((i+j)&1)continue;
			if (!py[i-j])py[i-j]=q[++p1];
			a[i][j]=px[i+j]*py[i-j];
		}
	}
//	cout<<q[p1]<<endl;
	ll mx=0;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			if ((i+j)&1);else continue;
			a[i][j]=lcm(lcm(a[i-1][j],a[i][j-1]),lcm(a[i+1][j],a[i][j+1]))+1;
			mx=max(mx,a[i][j]);
			if (a[i][j]>1e15){
				cout<<px[i+j-1]<<' '<<px[i+j+1]<<endl;
				cout<<py[i-j-1]<<' '<<py[i-j+1]<<endl;
				cout<<i<<' '<<j<<endl;
			}
		}
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			printf("%lld ",a[i][j]);
		}
		printf("\n");
	}
//	cout<<mx<<endl;
}

Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<int>p(n);
  for(int i=0; i<n; i++)cin >> p[i];
  sort(p.begin(), p.end());
  cout << accumulate(p.begin(), p.begin()+k, 0);
  return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int w[110], v[110];
long dp[110][110000];

int main(){
    int n, W;
    cin >> n >> W;
    for(int i = 01; i <= n; i++) cin >> w[i] >> v[i];
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= 100000; j++){
            dp[i][j] = dp[i-1][j];
            if(j - w[i] >= 0)
            dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + v[i]);
        }
    }
    cout << dp[n][W] << endl;
}

Measured memory_bytes: 87424
#include <algorithm>
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main()
{
  int n; cin >> n;
  
  map<string, int> mp;
  for (int i = 0; i < n; ++i) {
    string s; cin >> s;
    ++mp[s];
  }
  
  int mx = 0;
  for (auto x: mp) mx = max(mx, x.second);
  for (auto x: mp) if (x.second == mx) cout << x.first << endl;
  return 0;
}

Measured memory_bytes: 25216