akhauriyash/Code-Regression huggingface dataset:
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let v : Vec<String> = s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
    if v[0] < v[1] {
        println!("<");
    }
    else if v[0] > v[1] {
        println!(">");
    }
    else {
        println!("=");
    }

}


Measured memory_bytes: 4352
# B - Kleene Inversion
from typing import Optional, Sequence


class BinaryIndexedTree:
    """Binary Indexed Tree (Fenwick Tree)
    Each operation runs in O(logN).

    References:
        http://hos.ac/slides/20140319_bit.pdf
    """

    __slots__ = ["_size", "_tree", "is_zero_origin"]

    def __init__(
        self,
        size: int,
        initial_values: Optional[Sequence[int]] = None,
        is_zero_origin: bool = True,
    ):
        self._size = size
        self._tree = [0] * (size + 1)
        self.is_zero_origin = is_zero_origin
        if initial_values:
            self._build(initial_values)

    def _build(self, initial_values: Sequence[int]):
        for i, a in enumerate(initial_values):
            self.add(i, a)

    def add(self, index: int, value: int) -> None:
        """Add value to tree[index], O(logN)."""
        if self.is_zero_origin:
            index += 1
        while index <= self._size:
            self._tree[index] += value
            index += index & -index

    def sum(self, index: int) -> int:
        """Return the sum of [1, index] in O(logN)."""
        ret = 0
        while index > 0:
            ret += self._tree[index]
            index -= index & -index
        return ret

    def range_sum(self, left: int, right: int) -> int:
        """Return the range sum of [left, right] in O(logN)."""
        if not self.is_zero_origin:
            left -= 1
        return self.sum(right) - self.sum(left)


def main():
    N, K, *A = map(int, open(0).read().split())
    tree = BinaryIndexedTree(2000, is_zero_origin=False)
    x = 0
    for i, a in enumerate(A, 1):  # internal inversion
        tree.add(a, 1)
        x += i - tree.sum(a)
    y = -x
    for i, a in enumerate(A, 1):  # external inversion
        tree.add(a, 1)
        y += i + N - tree.sum(a)
    MOD = 10 ** 9 + 7
    print((x * K + y * K * (K - 1) // 2) % MOD)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10284
#include <stdio.h>

int H, N, D[21111];

int main()
{
	scanf ("%d %d", &H, &N);
	for (int i = 1; i <= H + 10000; i++) D[i] = 1e9;
	while (N--){
		int a, b; scanf ("%d %d", &a, &b);
		for (int i = a; i <= H + 10000; i++) if (D[i] > D[i - a] + b) D[i] = D[i - a] + b;
	}
	int ans = D[H];
	for (int i = H; i <= H + 10000; i++) if (ans > D[i]) ans = D[i];
	printf ("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
import sys
from collections import Counter
import random
import numpy as np
import time

a,b,c,x,y=map(int,input().split())
cost=0
if(a+b>=2*c):
    if(x>y):
        cost+=c*2*y
        x-=y
        y=0
    else:
        cost+=c*2*x
        y-=x
        x=y
        y=0
        a=b
    if(a>=2*c):
        cost+=2*c*x
    else:
        cost+=a*x
else:
    if(x>y):
        cost+=b*y+a*y
        x-=y
        y=0
    else:
        cost+=a*x+b*x
        y-=x
        x=y
        y=0
        a=b
    if(a>=2*c):
        cost+=2*c*x
    else:
        cost+=a*x
print(cost)
        

Measured memory_bytes: 12396
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;


signed main()
{
  int N, K;
  cin >> N >> K;

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    int x; cin >> x;
    ans += min(x, abs(K-x));
  }

  cout << ans*2 << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

int main(void){
  int n,k,i;
  int h[200000];

  cin>>n>>k;
  for(i=0;i<n;i++){
    cin>>h[i];
  }

  sort(h,h+n);

  ll sum=0;
  if(k>=n){
    cout<<0<<endl;
    return 0;
  }

  for(i=0;i<(n-k);i++){
    sum+=h[i];
  }

  cout<<sum<<endl;

  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

vector<string> str;
string conj[15][15];
int n;
bool used[15];
string answer(int x, int p){
    if(p == 0)return str[x];
    int res = (1 << 20);
    string ans;
    for(int i = 0;i < n;i++){
	if(used[i])continue;
	used[i] = true;
	string tmp = answer(i, p - 1);
	used[i] = false;
	if(x != -1)tmp = conj[x][i] + tmp;
	int p = tmp.size();
	if(p > res || p == res && ans < tmp)continue;	  
	res = p;
	ans = tmp;
    }
    return ans;
}

string conjection(string a, string b){
    string t = "";
    for(int i = 0;i < a.size();i++){
	if(i + b.size() <= a.size()){
	    t += a[i];
	    continue;
	}
	bool res = true;
	for(int j = i;j < a.size();j++){
	    if(a[j] != b[j - i]){
		res = false;break;
	    }
	}
	if(res)return t;
	t += a[i];
    }
    return t;
}

bool in(string a, string b){
    if(b.size() > a.size())return false;
    for(int i = 0;i < a.size();i++){
	if(i + b.size() > a.size())return false;
	bool t = true;
	for(int j = i;j < a.size();j++){
	    if(j - i == b.size())break;
	    if(a[j] != b[j - i]){
		t = false;
		break;
	    }
	}
	if(t)return t;
    }
    return false;
}

int main(){
    while(true){
	cin >> n;
	str.clear();
	if(n == 0)return 0;
	for(int i = 0;i < 15;i++)
	    for(int j = 0;j < 15;j++)
		conj[i][j] = "";


	for(int i = 0;i < n;i++){
	    string tmp;
	    cin >> tmp;
	    str.push_back(tmp);
	}
	for(int i = 0;i < n;i++){
	    for(int j = 0;j < n;j++){
		if(i == j)continue;
		if(in(str[i], str[j])){
		    str[j] = str[i];
		}
	    }
	}
	sort(str.begin(), str.end());
	str.erase(unique(str.begin(), str.end()), str.end());
	n = str.size();
	for(int i = 0;i < n;i++){
	    for(int j = 0;j < n;j++){
		if(i == j)continue;
		conj[i][j] = conjection(str[i], str[j]);
	    }
	}
	cout << answer(-1, n) << endl;
    }
    return 0;
}

Measured memory_bytes: 1232
#include <stdio.h>

int n,A[50];
int solve(int i,int m)
{
  if(m==0)return 1;
  if(i>=n)return 0;
  int res=solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}

int main(){
  int q,M,i;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&M);
      if(solve(0,M)) printf("yes\n");
      else printf("no\n");
    }
  return 0;
}
      
  



Measured memory_bytes: 2108
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define int ll
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=410,Mod=1e9+7;
int a[N],b[N],n,sum[N][N],c,dp[N][N];
int val(int i,int Q){
	return (sum[Q][b[i]]-sum[Q][a[i]-1]+Mod)%Mod;
}
int qpow(int a,int b){
	int ret=1;
	while(b){
		if(b&1)ret=1ll*ret*a%Mod;b>>=1;
		a=1ll*a*a%Mod;
	}
	return ret;
}
signed main(){
	n=gi();c=gi();
	for(int i=1;i<=n;i++)a[i]=gi();for(int i=1;i<=n;i++)b[i]=gi();
	for(int i=0;i<=c;i++)
		for(int j=1;j<=400;j++)
			sum[i][j]=(sum[i][j-1]+qpow(j,i))%Mod;
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=c;j++)
			for(int k=0;k<=j;k++)
				dp[i][j]=(dp[i][j]+1ll*dp[i-1][k]*val(i,j-k)%Mod)%Mod;
	printf("%lld\n",dp[n][c]);
	return 0;
}


Measured memory_bytes: 2816
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
	static BufferedReader br;
	public static void main(String[] args){
		try{
		br = new BufferedReader(new InputStreamReader(System.in));
		System.out.println((Integer.parseInt(br.readLine())
				+ Integer.parseInt(br.readLine()))
				* Integer.parseInt(br.readLine()) / 2);
		} catch (Exception e){
			System.err.println("Error : " + e.getMessage());
		}
	}
}


Measured memory_bytes: 7892
#include<stdio.h>

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

Measured memory_bytes: 592
n,k = map(int,input().split())

okashi = [0 for i in range(n)]
for i in range(k):
    d = int(input())
    for j in list(map(int,input().split())):
        okashi[j-1] = 1

cnt = 0
for i in okashi:
    if i == 0:
        cnt += 1

print(cnt)

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

long gcd(long a, long b) {
    if(b == 0) return a;
    return gcd(b,a%b);
}

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

    long tmp = gcd(a,b);
    if(c%tmp==0) {
        printf("YES\n");
    }
    else {
        printf("NO\n");
    }

    return 0;
}


Measured memory_bytes: 128
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

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

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

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

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


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

    N = ii()
    L0, L1 = 2, 1

    for n in range(N):
        L0, L1 = L1, L1 + L0
    print(L0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10040
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

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







Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <set>
using namespace std;

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

    set<char> T;

    for(long long i = 0; i < s.size(); i++) T.insert(s[i]);
    
    if(T.size() == s.size()) printf("yes\n");
    else printf("no\n");

    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
long long f(long long b, long long n) {
    if (n < b) {
        return n;
    }
    return f(b, n/b) + n%b;
}
int main () {
    long long n, s;
    cin >> n >> s;
    long long q = (sqrt(4*n+1)-1)/2;
    for (long long i = 2; i <= n/(q+1); i++) {
        if (f(i, n) == s) {
            cout << i << endl;
            return 0;
        }
    }
    // 2桁
    for (long long i = q; i >= 1; i--) {
        long long l = n/(i+1) + 1;
        long long r = n/i;
        if ((s-i) <= n%l && (s-i) >= n%r && (s-i-n%r) % i == 0) {
            cout << l + (n%l-(s-i))/i << endl;
            return 0;
        }
    }
    // 1桁
    if (n == s) {
        cout << n+1 << endl;
        return 0;
    }
    puts("-1");
}

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

int main(){
	int x,y;
	int temp;

	while(true){
		cin >> x >> y;
		if(x == 0 && y == 0){
			break;
		}
		if(x > y){
			temp = x;
			x = y;
			y = temp;
		}
		cout << x << " " <<  y << endl;
	}
	return 0;
}

Measured memory_bytes: 3088
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""
import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


"""
N, X = map(int, input().split())

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

#Distance Transformation
    for h in range(0,H):
        for w in range(0,W):
            if h == 0 and w == 0:
                pass
            elif h == 0:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h-1][W-w]+1)
            elif w == 0:   
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1)
            else:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1, D[H-h-1][W-w]+1, D[H-h][W-w]+2)
            d_max = max(D[H-h-1][W-w-1], d_max)

"""
N, K = list(map(int, input().split()))
S = input()
S = list(S)

def main():
    k=K-1
    if S[k]=="A":
        S[k] = "a"
    if S[k]=="B":
        S[k] = "b"
    if S[k]=="C":
        S[k] = "c"
    print("".join(S))
                
                
                
    
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 24588
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

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

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);
  
  int n; cin >> n;
  if (n<=999){cout << "ABC" << endl;}
  else {cout << "ABD" << endl;}

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
int head=0;
struct list{
    int plast,pnext;
}L[500000];
void init(int n){
    for(int i=0;i<=n;i++){
        L[i].plast=i-1;
        L[i].pnext=i+1;
    }
    L[n].pnext=-1;
}
void doit(int t){
    L[L[t].plast].pnext=L[t].pnext;
    L[L[t].pnext].plast=L[t].plast;
    L[t].pnext=L[head].pnext;
    L[t].plast=head;
    L[L[head].pnext].plast=t;
    L[head].pnext=t;
}
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    init(n);
    for(int i=0;i<m;i++){
        int t;
        scanf("%d",&t);
        doit(t);
    }
    int t=head;
    while(L[t].pnext!=-1){
        t=L[t].pnext;
        printf("%d\n",t);
    }
    return 0;
}

Measured memory_bytes: 4788
#include<stdio.h>

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

int main(void){
  int n,i,j,ans=0,tmp;
  char s[101];
  
  scanf("%d %s",&n,s);

  for(i=1;i<n;i++){
    int alpha[26] = {};
    for(j=0;j<i;j++) alpha[s[j]-'a']++;
  
    tmp = 0;
    for(j=i;j<n;j++){
      if(alpha[s[j]-'a']>0){
        tmp++;
        alpha[s[j]-'a']=0;
      }
    }
    
    ans = max(ans,tmp);
  }
  
  printf("%d\n",ans);
  
  return 0;
}

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

class Dice{
public:
	int top,front,r;
	Dice():top(1),front(2),r(3){}
	void north(){
		int a=top;
		top=front;
		front=7-a;
	}
	void east(){
		int a=top;
		top=7-r;
		r=a;
	}
	void west(){
		int a=top;
		top=r;
		r=7-a;
	}
	void south(){
		int a=top;
		top=7-front;
		front=a;
	}
	void right(){
		int a=front;
		front=r;
		r=7-a;
	}
	void left(){
		int a=front;
		front=7-r;
		r=a;
	}
};
int main(){
	int n;
	string op;
	Dice dice;
	while(cin>>n&&n){
		int ans=1;
		dice = Dice();
		while(n--){
			cin>>op;
			if(op=="North")dice.north();
			else if(op=="East")dice.east();
			else if(op=="West")dice.west();
			else if(op=="South")dice.south();
			else if(op=="Right")dice.right();
			else dice.left();
			ans += dice.top;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std ;

#define ll long long

const int N = 2010 ;

int n ;
int cnt ;
int _eve ;
ll nx, ny ;
int bc[N] ;
struct rg{
    int l ;
    int r ;
    int t ;
}base[N] ; //D  R  U  L
int dx[4] = {0, 1, 0, -1} ;
int dy[4] = {-1, 0, 1, 0} ;
char s[4] = {'U', 'L', 'D', 'R'} ;

int main(){
    cin >> n ;
    bc[0] = 1 ;
    for (int i = 1 ; i <= n ; ++ i){
        cin >> base[i].l >> base[i].r ;
        base[i].t = abs(base[i].l + base[i].r) & 1 ;
    }
    for (int i = 2 ; i <= n ; ++ i)
        if (base[i].t != base[1].t) return puts("-1"), 0 ;
    for (int i = 1 ; i <= 30 ; ++ i) bc[++ cnt] = 1 << i ;
    cout << cnt + 1 + (bool)(!(base[1].t & 1)) << '\n' ;
    if (!(base[1].t & 1)) cout << 1 << " " ;
    for (int i = cnt ; ~i ; -- i) printf("%d%c", bc[i], " \n"[!i]) ;
    for (int i = 1 ; i <= n ; ++ i){
        nx = base[i].l ;
        ny = base[i].r ;
        if (!(base[i].t & 1))
            ny -= 1, putchar('U') ;
		//cout << nx << " " << ny << endl ;
		for (int j = cnt ; ~j ; -- j){
            for (int k = 0 ; k < 4 ; ++ k){
                ll kx = nx + (ll)dx[k] * bc[j] ;
                ll ky = ny + (ll)dy[k] * bc[j] ;
                if (abs(kx) + abs(ky) < bc[j]){
                    nx = kx ; ny = ky ;
					//cout << nx << " " << ny << endl ;
                    printf("%c", s[k]) ; break ;
                }
			}
		}
        puts("") ;
    }
    return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
       int H,W,s,d;
   while(1){
   cin>>H>>W;
   s=0;
   d=1;
   if(H == 0&&W == 0)break;
       for(int j = 1;j <= H;j++){
           for(int a = 1;a <= W;a++){
               s=s+1;
           if(s%2 == 1){cout<<"#";}else if(s%2 == 0){cout<<".";}
           }
       cout<<endl;
       if(d%2==1){s=1;}else if(d%2==0){s=0;}
       d=d+1;
       }
   cout<<endl;
   d=1;
   }
}


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

#define for(i, a, b) for(ll (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)

const ll inf = 1e15;
const ll mod = 1e9+7;

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

ll dp[52][2502][52];

int main() {
    ll N, A; cin >> N >> A;
    vector<ll> x(N); rep(i, N) cin >> x[i];
    
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;
    
    rep(i, N) rep(j, A*N) rep(k, N) {
        dp[i+1][j][k] += dp[i][j][k];
        dp[i+1][j + x[i]][k+1] += dp[i][j][k];
    }
    
    ll ans = 0;
    for(j, 1, A*N+1) for(k, 1, N+1) {
        if (!dp[N][j][k]) continue;
        if (j == A * k) ans += dp[N][j][k];
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 53120
#include <stdio.h>

int main()
{
    char S[5];
    
    scanf("%s", S);
    
    if(S[0] == S[1] && S[2] == S[3] && S[0] != S[2]||
        S[0] == S[2] && S[1] == S[3] && S[0] != S[1]||
        S[0] == S[3] && S[1] == S[2] && S[0] != S[1]) {
            printf("Yes");
    } else {
            printf("No");
    }
    
    return 0;
}


Measured memory_bytes: 128
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin >> n >> m;
    int count=0;
    itn sum=0;
    vector<int> a(n);
    for(int i=0;i<n;++i){
        cin >> a.at(i);
        sum+=a.at(i);
    }
    for(int i=0;i<n;++i){
        if(a.at(i)>=(((double)sum)/(4*m)))count++;
    }
    if(count>=m){
        cout << "Yes" ENDL;
    }else cout << "No" ENDL;
    
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
      int a,b,c;
    cin >> a>>b>>c;
    int flag=0;
    if(a>=1 && b>=1 && c>=1)
    {
        if(a<=9 && b<=9 && c<=9)
        {
            if(b==a && b!=c)
            {
                flag=0;
            }
            if(a==c && a!=b)
            {
               flag=0;
            }
            if(c==a && c==b)
            {
                flag=1;
            }
            if(a!=b && b!=c && a!=c)
            {
                flag=1;
            }
            if(flag==0)
            {
                cout << "Yes" << endl;
            }
            if(flag==1)
            {
                cout << "No" << endl; 
            } 
        }
    }
    
   
  
    
     
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    string s; cin >> s;
    bool ans = false;
    if (n % 2 == 0) {
        ans = true;
        REP(i,n/2) {
            if (s[i] != s[i + n/2]) {
                ans = false;
                break;
            }
        }
    }

    ATYN(ans);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long 
#define f(z) for(int i=1;i<=z;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define pb push_back
#define si set<int>
int cl(int n ,int m) { if(n%m)return n/m + 1 ;else return n/m ;}
int pw(int a,int b){int r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
#define mod  1000000007
#define T() int TT; cin>>TT; while(TT--)
#define P pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 1e6 + 5 ;

signed main(){
	int m , dx ,mx; 
	cin >> mx >> dx; 
	int cnt = 0 ; 
	for ( int m = 1 ; m<=mx ; m++){
	for ( int i =1 ; i<=dx ; i++){
		int d = i;
		if( d > 10 ){
			if( d%10 >=2 ){
				int x= d%10 ; 
				d = d/10 ; 
				if(d%10 >=2 && d%10*x == m ) cnt++ ;
			}
		}
	}
}
	cout << cnt ;
}









Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <algorithm>

int main()
{
  std::vector<int> W;
  int N;
  std::cin >> N;
  
  for (int i = 0; i < N; ++i)
  {
    int w;
    std::cin >> w;
    W.push_back(w);
  }
  
  auto S1 = 0;
  auto S2 = std::accumulate(W.begin(), W.end(), 0);
  
  std::vector<int> x;
  for (int i = 0; i < (W.size() - 1); ++i)
  {
    S1 += W[i];
    S2 -= W[i];
    x.push_back(std::abs(S1 - S2));
  }
  std::cout << *std::min_element(x.begin(), x.end()) << std::endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int[][] a;
		int[] b;
		int c;
		int n = 0;
		int m = 0;

		Scanner sc= new Scanner( System.in );
		n = sc.nextInt();
		m = sc.nextInt();

		a = new int[n][m];
		b = new int[m];


		for ( int i = 0 ; i < n ; i++ ) {
			for ( int j = 0 ; j < m ; j++ ) {
				a[i][j] = sc.nextInt();
			}
		}

		for ( int j = 0 ; j < m ; j++ ) {
			b[j] = sc.nextInt();
		}

		for ( int i = 0 ; i < n ; i++ ) {
			c = 0;
			for ( int j = 0 ; j < m ; j++ ) {
				c += a[i][j] * b[j];
			}
			System.out.println( c );
		}
		sc.close();
	}
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int h, w;
char s[305][305];
int d[305][305];
char a[305], b[305];
int x[305][305], y[305][305];

const int INF = 1e9;

int main() {
    scanf("%d%d", &h, &w);
    forn(i, h) {
        scanf("%s", s[i]);
    }
    LL ans = 0;
    forn(z, w - 1) {
        forn(i, h) a[i] = s[i][z];
        forn(i, h) b[i] = s[i][z + 1];
        forn(i, h) {
            x[i][0] = y[i][0] = 0;
            forn(j, h - i) {
                x[i][j + 1] = x[i][j] + (a[j] == b[i + j]);
                y[i][j + 1] = y[i][j] + (a[i + j] == b[j]);

            }
        }
        forn(i, h + 1) forn(j, h + 1) {
            d[i][j] = INF;
        }
        d[0][0] = 0;
        forn(i, h + 1) forn(j, h + 1) {
            int delta;
            if (i < j) {
                delta = y[j - i][h - j];
            } else {
                delta = x[i - j][h - i];
            }
            if (i < h) {
                d[i + 1][j] = min(d[i + 1][j], d[i][j] + delta);
            }
            if (j < h) {
                d[i][j + 1] = min(d[i][j + 1], d[i][j] + delta);
            }
        }
        ans += d[h][h];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

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

void Main() {
  Cin(int, n, k);

  double ans = 0;
  for (int i = 1; i <= n; ++i) {
    double x = 1. / n;
    int now = i;
    while (now < k) {
      now *= 2;
      x /= 2.;
    }
    ans += x;
  }
  cout << ans << endl;
}

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

n = int(input())
a = input()
b = input()
c = input()

d = [{} for i in range(n)]

for i in range(n):
    for s in [a,b,c]:
        if s[i] in d[i]:
            d[i][s[i]] += 1
        else:
            d[i][s[i]] = 1

count = 0
for subd in d:
    if len(d) > 1:
        count += 3 - max(subd.values())

print(count)


Measured memory_bytes: 3064
#include<stdio.h>

#define MAX 100

int main(void){
  
    int N,i,x = 0,max=0;
    char S[MAX];
  
    scanf("%d",&N);
    scanf("%s",S);

    for(i = 0;i < N;i++){
        if(S[i] == 'I'){
            x++;
            if(x > max){
                max = x;
            }
        }else{
            x--;
        }
    }

    printf("%d",max);
    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize "03"
#include <bits/stdc++.h>
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int N = 2505;
const int mod = 1e9 + 7;
const int inf = 1e18 + 9;

vector<int> g[2*N];
int dis[N], pre[N];

signed main() {
	#ifdef LOCAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	IOS;
	int n, m, p;
	cin >> n >> m >> p;
	for(int i = 0; i < m; i++){
		int u, v, w;
		cin >> u >> v >> w;
		g[i].push_back(u);
		g[i].push_back(v);
		g[i].push_back(p-w);
	}
	for(int i = 1; i <= n; i++)
		dis[i] = inf;
	dis[1] = 0;
	for(int i = 1; i <= n; i++){
		int j = 0;
		while(g[j].size() != 0){
			if(dis[g[j][0]] == inf)
			{ j++;	continue;}
			if(dis[g[j][0]] + g[j][2] < dis[g[j][1]])
				dis[g[j][1]] = dis[g[j][0]] + g[j][2];
			j++;
		}
		if(i == n){
			for(int j = 1; j <= n; j++){
				if(pre[j] != dis[j])
					dis[j] = -inf;
			}
		}
		else{
			for(int j = 1; j <= n; j++)
				pre[j] = dis[j];
		}
	}
	for(int i = 1; i <= n-1; i++){
		int j = 0;
		while(g[j].size() != 0){
			if(dis[g[j][0]] == -inf)
				dis[g[j][1]] = -inf;
			else if(dis[g[j][0]] + g[j][2] < dis[g[j][1]] )
				dis[g[j][1]] = dis[g[j][0]] + g[j][2];
			j++;
		}
	}
	if(dis[n] == -inf)
		cout << -1;
	else if(dis[n] > 0)
		cout << 0;
	else
		cout << -1*dis[n];
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

    int ans = 0;
    for(int i = 0; i < N; ++i){
        for(int j = i; j < N; ++j){
            if(i == j) continue;
            ans += Ds[i]*Ds[j];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp.split("").map(&:to_i)
count = 0
10.times do |i1|
  pos1 = s[0..n-1].index(i1)
  next if pos1 == nil || pos1 == n - 1
  10.times do |i2|
    pos2 = s[(pos1+1)..n-1].index(i2)
    next if pos2 == nil || pos2 == n - 1
    pos2 += pos1 + 1
    10.times do |i3|
      count += 1 if s[(pos2+1)..n-1].index(i3) != nil 
    end
  end
end
puts count


Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <climits>
#include <utility>

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define SPACE " "

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 1LL << 25;
double EPS = 1e-9;

// BEGIN //////////////////////////////////////////////////////////////
int main() {
	int ds[101] = {0};
	int n;
	while (scanf("%d", &n) != EOF) {
		ds[n]++;
	}
	int d_max = -1;
	REP(i, 100) {
		d_max = max(d_max, ds[i]);
	}
	REP(i, 100) {
		if (ds[i] == d_max) {
			PRINT(i);
		}
	}
	return 0;
}
// END   //////////////////////////////////////////////////////////////

Measured memory_bytes: 1208
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#define N 1000000
#define STD_BMI 22.000
#define EPS 1.0e-10
using namespace std;
struct Person{
	int id,h,w;
	double BMI;
	bool operator<(const Person &t)const{
		if( fabs(this->BMI-STD_BMI)<fabs(t.BMI-STD_BMI) ){
			return true;
		}else if( fabs( fabs(this->BMI-STD_BMI) - fabs(t.BMI-STD_BMI) ) < EPS ){
			return this->id < t.id;
		}
		return false;
	}
};
istream &operator>>(istream &is, Person &t){
	is>>t.id>>t.h>>t.w;
	t.BMI=t.w/((double)(t.h)*(t.h)/10000.0);
	return is;
}
int main(){
	while(true){
		int n;
		vector<Person> v;
		v.reserve(N);
		cin>>n;
		if(n==0)break;
		for(int i =0; i <n; ++i){
			Person t;
			cin>>t;
			v.push_back(t);
		}
		sort(v.begin(),v.end());
		cout<<v[0].id<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>
 
#define pb(a) push_back(a)
#define mp make_pair
 
int main(){
  
  CIN(n);
  vector<P> a(n);vector<P> b(n);
  REP(i,n){
    CIN(x,y);a[i]=mp(x,i);b[i]=mp(y,i);//10^5
  }
  sort(ALL(a));//5*10^5
  sort(ALL(b));//5*10^5
  int cost=0;
  vector<M> edges(n);

  REP(i,n-1){
    edges[a[i].second][a[i+1].second]=abs(a[i].first-a[i+1].first);
    edges[a[i+1].second][a[i].second]=abs(a[i].first-a[i+1].first);
  }
  REP(i,n-1){
    if( edges[b[i].second].count(b[i+1].second))
      edges[b[i].second][b[i+1].second]=
      min(edges[b[i].second][b[i+1].second],abs(b[i].first-b[i+1].first));
    else 
      edges[b[i].second][b[i+1].second]=
      abs(b[i].first-b[i+1].first);

    if( edges[b[i+1].second].count(b[i].second))
      edges[b[i+1].second][b[i].second]=
      min(edges[b[i+1].second][b[i].second],abs(b[i].first-b[i+1].first));
    else 
      edges[b[i+1].second][b[i].second]=
      abs(b[i].first-b[i+1].first);


  }

  S set_={0};
  S set__;
  REP(i,n)set__.insert(i);
  priority_queue<P,vector<P>,greater<P>> que;
  FOREACH(xx,edges[0])que.push(mp(xx.second,xx.first));
  while(!que.empty()){
    
    int from = que.top().second;
    int cos = que.top().first;
    que.pop();
    if(set_.count(from))continue;
    set_.insert(from);
    cost+=cos;
    if(set_==set__)break;

    FOREACH(xx,edges[from]){
      int to=xx.first;
      int cost_=xx.second;
      que.push(mp(cost_,to));
    }
  }
  COUT(cost);
 
  return 0;
}


Measured memory_bytes: 36208
#include <iostream>
#include <vector>

using namespace std;

int main(void){
    int N;
    cin >> N;
    
    if (N % 2 == 0) {
        cout << 0.5;  
    } else {
        double ans = 0.5 + 0.5 / (double)N; 
        cout << ans;
    }
    
}


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 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

bool solve() {
    int n, m, p;
    cin >> n >> m >> p;
    m--;
    if(n == 0) {
        return 0;
    }
    vector<int> x(n);
    for(int i = 0; i < n; i++) {
        cin >> x[i];
    }
    int sum = accumulate(ALL(x), 0);
    if(x[m] == 0) {
        cout << 0 << endl;
    } else {
        cout << ((100 - p) * sum / x[m]) << endl;
    }
    return 1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1) {
        if(!solve()) {
            break;
        }
    }
}


Measured memory_bytes: 3100
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn  = 1e4+10;
const int INF = 0x3f3f3f3f;
typedef pair<int,int> P;
struct edge{
	int to,dis,cost;
		
};

int d[maxn];
int value[maxn];

int N,M;

int dijkstra(vector<edge>G[])
{

	memset(d,INF,sizeof(d));
	//memset(value,INF,sizeof(value));
	priority_queue<P,vector<P>,greater<P> > que;
		
	d[1] = 0;
	value[1] = 0;
	que.push(P(d[1],1));
	
	int res = 0;
	while(!que.empty())
	{
		P p  = que.top(); que.pop();
		
		int v = p.second;
		if(d[v] < p.first)
			continue;
			
		res += value[v];
		
		for(int i = 0; i < G[v].size(); i++)
		{
			edge e = G[v][i];
			if(d[e.to] == d[v] + e.dis)
				value[e.to] = min(value[e.to],e.cost);
			if(d[e.to] > d[v] + e.dis)
			{
				d[e.to] = d[v] + e.dis;
				que.push(P(d[e.to],e.to));
				
				value[e.to] = e.cost;
			}
		}
	}
	return res;
	
}

int main()
{

	//freopen("c:\\users\\administrator\\desktop\\in.txt","r",stdin);
	while(cin >> N >> M, N||M)
	{
		
		vector<edge> G[maxn];
		for(int i =0; i < M; i++)
		{
			int u,v,d,c;
			edge e;
			cin >> u >> v >> d >> c;
			e.to= v, e.dis= d, e.cost =c;
			G[u].push_back(e);
			e.to= u;
			G[v].push_back(e);	
		}
		
		int res = dijkstra(G);
		cout << res <<endl;
	}		
} 

Measured memory_bytes: 4204
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    vector<int> c(n), d(n);
    for(int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    for(int i = 0; i < n; i++) {
        cin >> c[i];
    }
    vector<int> dist(n, -1);
    dist[0] = 0;
    queue<int> que;
    que.push(0);
    while(que.size()) {
        int v = que.front();
        que.pop();
        if(dist[v] == -1) {
            continue;
        }
        for(auto u : g[v]) {
            if(dist[u] == -1) {
                dist[u] = dist[v] + 1;
                que.push(u);
            }
        }
    }

    sort(RALL(c));
    for(int i = 0; i < n; i++) {
        int mn = *min_element(ALL(dist));
        int id;
        for(id = 0; id < n; id++) {
            if(dist[id] == mn) {
                break;
            }
        }
        d[id] = c[i];
        dist[id] = INF;
    }
    cout << accumulate(ALL(c), -c[0]) << endl;
    for(int i = 0; i < n; i++) {
        cout << d[i] << ' ';
    }
    cout << endl;
}


Measured memory_bytes: 1024
n=int(input())
ls=list(map(int,input().split()))
count_ls=[0]*n
answers=[]
m=0

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.remove(n)
    return divisors

for i in range(n,0,-1):
    plus_flag=False
    idx=i-1
    if count_ls[idx]%2!=ls[idx]:
        plus_flag=True
        m+=1
        answers.append(i)
    if plus_flag:
        divisors=set(make_divisors(i))
        for j in divisors:
            j_idx=j-1
            count_ls[j_idx]+=1

print(m)
if m:
    print(" ".join(list(map(str,answers))))

Measured memory_bytes: 78192
import sys
input = sys.stdin.readline
sys.setrecursionlimit(200000)


def binom_preprocess(n, MOD=998244353):
    f = [0 for i in range(n+1)]  # n!
    invf = [0 for i in range(n+1)]  # (n!)^-1
    f[0] = 1
    f[1] = 1
    invf[0] = 1
    invf[1] = 1
    for i in range(2, n+1):
        f[i] = f[i-1] * i % MOD
        invf[i] = pow(f[i], MOD-2, MOD)
    return f, invf


def binom(n, k, f, invf, MOD=998244353):
    if n < k or n < 0 or k < 0:
        return 0
    else:
        return (f[n] * invf[k] % MOD) * invf[n-k] % MOD


def read():
    N, M, K = map(int, input().strip().split())
    return N, M, K


# 998244353は素数
def solve(N, M, K, MOD=998244353):
    ans = 0
    f, invf = binom_preprocess(N)
    for k in range(K+1):
        ans += binom(N-1, N-k-1, f, invf) * M * pow(M-1, N-k-1, MOD)
        ans %= MOD
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


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

int main() {
    ll a,b,c,ans=0;
    cin>>a>>b>>c;
    if(a==b&&b==c){
        ans=1;
    }
    else if(a!=b&&b!=c&&c!=a){
        ans=3;
    }else ans=2;
    cout<<ans<<endl;
    
    return 0;
    }

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

int main() {
  ll Ans = 0;  // 遊べる日数
  ll N; cin >> N; // 夏休み数
  ll M; cin >> M; // 宿題数
  Ans = N;  // 最大で全日遊ぶ

  int wk_a=0;
  rep(i,M){
    cin >> wk_a;  // 宿題日数
    Ans -= wk_a;
    if ( Ans < 0 ) break;
  }
  if ( Ans < 0 ){ Ans = -1; }
  cout << Ans << endl;
}


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

int main(){
    int N;
    cin >> N;
    int A[N];
    int GCD_F[N-1];
    int GCD_B[N-1];
    int MaxGCD;
    for(int i = 0;i < N;++i){
        int tmp;
        cin >> tmp;
        A[i] = tmp;
    }
    for(int i = 0;i < N-1;++i){
        if(i == 0){
            GCD_F[i] = A[i];
        }else{
            GCD_F[i] = __gcd(GCD_F[i-1], A[i]);
        }
    }
    for(int i = 0;i < N-1;++i){
        if(i == 0){
            GCD_B[N-2-i] = A[N-1-i];
        }else{
            GCD_B[N-2-i] = __gcd(GCD_B[N-2-i+1], A[N-1-i]);
        }
    }
    MaxGCD = max(1, max(GCD_F[N-2], GCD_B[0]));
    for(int i = 0;i < N-2;++i){
        MaxGCD = max(__gcd(GCD_F[i], GCD_B[i+1]), MaxGCD);
    }
    cout << MaxGCD << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  string s,t;
  cin >> s >> t;
  
  string ss=s+s;
  bool exist=0;
    for(int i=0; i<=s.size(); i++){
      bool flg=1;
    	for(int j=0; j<s.size(); j++){
        	if(t[j]!=ss[j+i]){
              flg=0; break;
            }
        }
      if(flg){
        exist=1;
        break;
      }
    }
  
  if(exist) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	if(a - 1 > b) printf("%d\n", a + a - 1);
	else if(b - 1 > a) printf("%d\n", b + b - 1);
	else printf("%d\n", a + b);
	return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first               // For pairs
#define ss second              // For pairs
#define sz(a) int((a).size())  // Function to determine size of any container
#define pb push_back           // Pushback to vector
#define mp make_pair           // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()
#define tr(container, it) for (auto it = container.begin(); it != container.end(); it++)  //traversing macro
#define lp(it1, it2) for (auto i = it1; i < it2; i++)                                     //loop
#define present(c, x) (c.find(x) != c.end())
using namespace std;
using namespace std::chrono;
typedef vector<ll> vi;            // Vector of long long
typedef vector<vi> vvi;           // Vector of vi
typedef vector<pair<ll, ll>> ii;  // Vector of pairs
typedef vector<ii> vii;           // Vector of ii
int main() {
    // auto start = high_resolution_clock: :now();
    ll n;
    cin >> n;
    vi h(n), dp(n);
    lp(0, n) {
        cin >> h[i];
    }
    dp[1] = abs(h[1] - h[0]);
    lp(2, n) {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n - 1] << "\n";
    // auto stop = high_resolution_clock: :now();
    // auto duration = duration_cast<microseconds>(stop - start);
    // cerr << duration.count() / 1000000;
    return 0;
}


Measured memory_bytes: 1792