akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws Exception {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] strArr = br.readLine().split(" ");
        int a = Integer.parseInt(strArr[0]);
        int b = Integer.parseInt(strArr[1]);
        int c = Integer.parseInt(strArr[2]);

        if(b<a){
        	int d=a;
        	a=b;
        	b=d;
        }

        if(c<b){
        	int d=b;
        	b=c;
        	c=d;
        }

        if(b<a){
        	int d=a;
        	a=b;
        	b=d;
        }

        System.out.println(a+" "+ b+" "+ c);
    }
}

Measured memory_bytes: 24216
<?php
ob_start();
echo file_get_contents('php://stdin');
$input = ob_get_contents();
ob_end_clean();
$input = trim($input);
$len = strlen($input);
$t = "";
for($i=0;$i <= $len;$i++) {
    if ( $i+2 > $len -1 ) {
        break;
    }
    $s = abs(((int)$input[$i]*100 + (int)$input[$i+1]*10 + (int)$input[$i+2]) - 753);
    if($t == "" || $s < $t ) {
        $t = $s;
    }
}
echo $t.PHP_EOL;

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

int main()
{
	int A, B;
	cin >> A >> B;
	int res = 0;
	for (int i = A; i <= B; i++) {
		string s = to_string(i);
		auto t = s;
		reverse(t.begin(), t.end());
		res += s == t;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.OptionalInt;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	static PrintWriter out = new PrintWriter(System.out);
	public static void main(String[] args) {
		// 入力
		String n;		// 1≦N<10000
		final int k;	// 1≦K<10
		final int[] d;	// 0≦D1<D2<…<DK≦9  {D1,D2,…,DK}≠{1,2,3,4,5,6,7,8,9}
		try(Scanner scan = new Scanner(System.in)) {
			n = scan.next();
			k = scan.nextInt();
			d = new int[k];
			for (int i = 0; i < k; i++) {
				d[i] = scan.nextInt();
			}
			
		}
		
		// 嫌いでない数字の配列  maxはlike[10 - k -1] minはlike[0]
		final int[] like = IntStream.range(0, 10).filter(i -> !Arrays.stream(d).anyMatch(dd -> dd == i)).toArray();
		
		// 各位の数字の取得
		final int[] value = new int[n.length()];		// 1≦N<10000より4桁
		for (int i = 0; i < value.length; i++) {
			value[i] = Integer.parseInt(n.substring(i, i + 1));
		}
		
		int[] result = new int[n.length() + 1];
		boolean big = false;	//大きいことが確定すればtrue
		
		result[0] = 0;
		for (int j = 0; j < n.length(); j++) {
			final int i = j;

			if (big) {
				result[i + 1] = like[0];
			} else {
				OptionalInt temp = Arrays.stream(like).filter(likevalue -> likevalue >= value[i]).min();
				
				if (temp.isPresent()) {
					result[i + 1] = temp.getAsInt();
					big = value[i] < result[i + 1];
				} else {			// value[i] > likeMax
					moveUp(result, like, i);
					big = true;
				}
			}
						
		}

		
		//数値に戻す
		// 出力
		out.println(Arrays.stream(result).reduce((start, element) -> start * 10 + element).getAsInt());
		out.flush();
	}
	
	/** 繰り上がり */
	static void moveUp(int[] result, int[] like, int i) {
		OptionalInt temp = Arrays.stream(like).filter(likevalue -> likevalue > result[i]).min();
		result[i+1] = like[0];
		if (temp.isPresent()) {
			result[i] = temp.getAsInt();		// i == 0でlike[0]==0 ? like[1] : like[0]になる
		} else {								// よって、ここでは i > 1
			moveUp(result, like, i -1);
		}
	}
	
}


Measured memory_bytes: 16464
#include <bits/stdc++.h>
using namespace std;
const int mxn = 1e5;
int T;
int dp[mxn+5][4];
int a[mxn+5][4];

int fn(int pos, int mask){

    if(pos>T) return 0;
    if(dp[pos][mask]!=-1) return dp[pos][mask];

    int res = 0;
    for(int i=1; i<=3; i++)
        if(mask!=i)
            res = max( fn(pos+1,i), res);

    return dp[pos][mask] = res + a[pos][mask];
}

void solve(){

    cin>>T;
    memset(dp,-1,sizeof(dp));

    for(int i=1; i<=T; i++){
        for(int j=1; j<=3; j++){
            cin>>a[i][j];
        }
    }

    cout<<fn(0,0)<<"\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}




Measured memory_bytes: 8064
#include <bits/stdc++.h>
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  vector<int> a(2);
  rep(i, 2) cin >> a[i];

  sort(a.begin(), a.end());
  if (a[0] == 2) cout << 1 << endl;
  else if (a[1] == 3) cout << 2 << endl;
  else cout << 3 << endl;




  
  return 0;
}

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

happy = n
for i in range(n - 1):
    if s[i] + s[i + 1] == "RL":
        happy -= 2
if s[0] == "L":
    happy -= 1
if s[-1] == "R":
    happy -= 1

answer = happy + 2 * k
print(min(answer, n - 1))


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int INF = 1<<30;
int main(){
  while(true){
    int n;
    cin >> n;
    if(n == 0) return 0;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int ans = INF;
    for(int i = 0; i < n-1; i++){
      ans = min(ans, a[i+1] - a[i]);
    }
    cout << ans << endl;
  }
}



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

using namespace std;

const int N = 100;
int sumCanGet[N];
int vt[N];
int n, m, q;
int a[N], b[N], c[N], d[N];
int ans = 0;

void rec(int pos, int sum) {
    if (pos == n + 1) {
        ans = max(ans, sum);
        return;
    }
    if (sumCanGet[pos] + sum <= ans)
        return;
    int brd = 1; if (pos != 1) brd = vt[pos - 1];
    for (int i = brd; i <= m; i++) {
        vt[pos] = i;
        int nsum = sum;
        for (int j = 0; j < q; j++) {
            if (b[j] == pos) {
                if (vt[b[j]] - vt[a[j]] == c[j])
                    nsum += d[j];
            }
        }
        rec(pos + 1, nsum);
    }
}

void solve() {
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        sumCanGet[b[i]] += d[i];
    }
    for (int i = n; i >= 1; i--) {
        sumCanGet[i] += sumCanGet[i + 1];
    }
    rec(1, 0);
    cout << ans;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string str;
	
	getline(cin, str);
	
	for (string::iterator it = str.begin(); it != str.end(); it++) {
		if (*it == ' ' || *it == '.') continue;
		else *it -= 32;
	}
	
	for (string::iterator it = str.begin(); it != str.end(); it++) {
		cout << *it;
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
int cnt[MAXN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    long long ans = 0;
    for(int g = 1; g <= n; g++) {
        ans += (long long) g * (n - g + 1);
    }
    for(int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        if (u > v) swap(u, v);
        ans -= (long long) u * (n - v + 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

int main(){
    std::string s, t;
    std::cin >> s >> t;

    std::sort(s.begin(), s.end());
    std::sort(t.begin(), t.end());
    std::reverse(t.begin(), t.end());

    if(s < t){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }

    return 0;
}


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

using namespace std;

#define ll long long

main() {
  ll q, h, s, d;
  cin >> q >> h >> s >> d;
  ll n;
  cin >> n;
  s = min(s, min(q * 4, h * 2));
  d = min(d, s * 2);
  ll ans = n / 2 * d;
  n %= 2;
  ans += n * s;
  cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
	int N;
	cin >> N;
	vector<pair<int, int>> A(N);
	rep(i, N) {
		int a; cin >> a;
		A[i] = {a, i+1};
	}

	sort(all(A));
	for(auto& p : A){
		cout << p.second << " ";
	}
	cout << endl;
}


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

int main(){
    string s;

    //入力
    cin >> s;
    size_t ans = std::count(s.begin(), s.end(), 'R');
  if(ans==2 && s[1]=='S'){
      ans = 1;
  }
    cout << ans << endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;
typedef unordered_map<int,int> uoii;
typedef unordered_map<string,int> uosi;

const int MOD = 1e9+7;

const int INF = 1e10;




int32_t main()
{
    
    IOS
    int h,n;
    cin>>h>>n;
    vpii ab(n+1);
    for(int i=1;i<=n;i++){
        cin>>ab[i].fi>>ab[i].se;
    }
    vi dp(h+1,INT_MAX);
    dp[0]=0;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=n;j++){
                dp[i]=min(dp[i],dp[max(i-ab[j].fi,0ll)]+ab[j].se);
        }
    }

    cout<<dp[h];

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	string s;
	cin >> s;
	int f0 = 0, f1 = 0;
	rep(i,s.size()) {
		if ((s[i] - '0') ^ (i & 1))f0++;
		else f1++;
	}
	cout << min(f0, f1) << endl;

}

Measured memory_bytes: 3736
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
    
    string s;
    cin>>s;
    int a=0,b=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0')a++;
        else b++;
    }
    cout<<min(a,b)*2<<endl;
    
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

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

	cout << 800*N-200*(N/15) << endl;
	return 0;
}

Measured memory_bytes: 256
Imports System.Console
Module Module1
    Dim ans As Int64
    Dim max As Int64
    Dim n, k, x, t As Int64
    Sub Main()
        Dim n2 As String
        n2 = ReadLine()
        Dim ncc() As Char = n2.ToCharArray
        Dim nc(ncc.Length - 1) As String
        Dim ni(ncc.Length - 1) As Integer
        Dim wa As Integer
        For i = 0 To nc.Length - 1
            nc(i) = ncc(i)
        Next
        For i = 0 To nc.Length - 1
            ni(i) = nc(i)
            wa += ni(i)
            wa = wa Mod 9
        Next
        If wa = 0 Then
            WriteLine("Yes")
        Else
            WriteLine("No")
        End If
        'WriteLine(ans)
    End Sub
End Module


Measured memory_bytes: 36756
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }


        static void Main(string[] args)
        {
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            var pq = new priority_queue<long>((long r, long l) => (int)(r - l));
            var Ai = Sarray();
            foreach (var v in Ai)
                pq.insert(v);

            for (var i = 0; i < M; ++i)
            {
                var v = pq.extract();
                pq.insert(v / 2);
            }
            long ans = 0;
            while (0 < pq.num)
                ans += pq.extract();
            WriteLine(ans);
        }
        class priority_queue<T>
        {
            Comparison<T> cmp;
            T[] A = new T[2000000];
            public priority_queue(Comparison<T> c)
            {
                cmp = c;
            }
            public int num { get; private set; } = 0;
            public void insert(T v)
            {
                A[num] = v;
                ++num;
                increaseKey(num);
            }
            void increaseKey(int i)
            {
                while (1 < i && 0 < cmp(A[i - 1], A[i / 2 - 1]))
                {
                    var t = A[i - 1];
                    A[i - 1] = A[i / 2 - 1];
                    A[i / 2 - 1] = t;
                    i = i / 2;
                }
            }
            public T extract()
            {
                if (num < 1) return default(T);
                var max = A[0];
                A[0] = A[num - 1];
                --num;
                maxHeapify(1);
                return max;
            }
            void maxHeapify(int i)
            {
                var H = num;
                var l = left(i);
                var r = right(i);
                var largest = 0;
                if (l <= H && 0 < cmp(A[l - 1], A[i - 1]))
                { largest = l; }
                else
                { largest = i; }
                if (r <= H && 0 < cmp(A[r - 1], A[largest - 1]))
                { largest = r; }
                if (largest != i)
                {
                    var t = A[i - 1];
                    A[i - 1] = A[largest - 1];
                    A[largest - 1] = t;
                    maxHeapify(largest);
                }
            }
            int left(int l) => l * 2;
            int right(int r) => r * 2 + 1;
        }

    }
}


Measured memory_bytes: 30292
import sys
import math
import itertools
import collections
import numpy as np

rl = sys.stdin.readline

h, w = map(int, rl().split())

li = []
dh = [0, -1]
dw = [-1, 0]
dp = [[0] * w for _ in range(h)]
dp[0][0] = 1
for _ in range(h):
    li.append(rl().rstrip())
for i in range(h):
    for j in range(w):
        if li[i][j] == '#':
            continue
        a = 0
        for k in range(2):
            nh = i + dh[k]
            nw = j + dw[k]
            if nh < 0 or nw < 0:
                continue
            a += dp[nh][nw]
        if dp[i][j] == 0:
            dp[i][j] = a
print((dp[-1][-1]) % (10**9 + 7))


Measured memory_bytes: 166392
#include <iostream>

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;

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

    double kijun = total_vote / ((double)M * 4.0);
     
    double count_ninki;
    for (i = 0; i < N; i++) {
        if (A[i] >= kijun) count_ninki++;
    }

    if (count_ninki >= M) cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<map>
#include<iostream>
#include<algorithm>
using namespace std;

string d;

int main() {
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    cin >> d;
    int size = d.size();
    map<string, int> n;
    n[d] = 1;
    string temp = d;
    reverse(temp.begin(), temp.end());
    n[temp] = 1;
    for (int i = 1; i < size; i++) {
      string s1 = d.substr(0, i), s2 = d.substr(i, size - i);
      string r1 = s1, r2 = s2;
      reverse(r1.begin(), r1.end());
      reverse(r2.begin(), r2.end());
      n[s1 + r2] = 1;
      n[r1 + s2] = 1;
      n[r1 + r2] = 1;
      n[s2 + s1] = 1;
      n[s2 + r1] = 1;
      n[r2 + s1] = 1;
    }
    printf("%d\n", (int)n.size());
  }
}



Measured memory_bytes: 3376
import Control.Applicative

main = do
  ss <- (map stoi . words) <$> getLine
  let [w, h, x, y, r] = ss
  putStrLn (if x + r > w || x - r < 0 || y + r > h || y - r < 0 then "No" else "Yes")

stoi :: String -> Int
stoi str = read str :: Int

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

const int N = 202;

int n, ans, a[N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (int i = 0; i < 2 * n; i++)
		cin >> a[i];
	sort(a, a + 2 * n);
	for (int i = 0; i < 2 * n; i += 2)
		ans += a[i];
	cout << ans;
}


Measured memory_bytes: 256
/////Mu Ha Ha, GiantSlayer is here!!//////
//Be patient, keep working hard and never be satisfied//

#include <iostream>
#include <stdio.h>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <iomanip>
//#include <bits/stdc++.h>
//#define SIZE 30001
#define gcode __gcd
#define bitcoin __builtin_popcount
#define check(n, pos) (n & (1<<pos))
#define set(n, pos) (n | (1<<pos))
using namespace std;

bool sortbysecin(const pair<int,int> &a, const pair<int,int> &b){
	return a.second<b.second;
}
bool sortbyfirstin(const pair<int,int> &a, const pair<int,int> &b){
	return a.first<b.first;
}
bool sortbysecdec(const pair<int,int> &a, const pair<int,int> &b){
	return a.second>b.second;
}
bool sortbyfirstdec(const pair<int,int> &a, const pair<int,int> &b){
	return a.first>b.first;
}


int main(){
	string a,b;
	cin>>a>>b;
	if(a.length()>b.length()) puts("GREATER");
	else if(a.length()<b.length()) puts("LESS");
	else{
	if(a>b) puts("GREATER");
	else if(a<b) puts("LESS");
	else puts("EQUAL");
}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,n;
    cin>>x>>n;
    vector<bool> vis(101,false);
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        vis[t]=true;
    }
    int aage=x;
    while(aage<101 && vis[aage]){
        aage++;
    }
    int peeche=x-1;
    while(peeche>=0 && vis[peeche]){
        peeche--;
    }
    if((abs(aage-x))<abs(peeche-x)){
        cout<<aage<<endl;
    }
    else if((abs(aage-x))>abs(peeche-x)){
        cout<<peeche<<endl;
    }
    else{
    cout<<min(aage,peeche)<<endl;
    }
}

Measured memory_bytes: 3628
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return 0

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        a = self.parents[x]
        b = self.parents[y]

        self.parents[x] += self.parents[y]
        self.parents[y] = x

        return (a * b)

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M = map(int, input().split())
AB = []
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    AB.append((a, b))
AB = AB[::-1]
uf = UnionFind(N)
ans = []
comb = N * (N - 1) // 2
tmp = comb
for a, b in AB:
    tmp -= uf.union(a, b)
    # print(cnt)
    ans.append(tmp)
# print(ans)
ans = ans[:-1][::-1]
# print(ans)
for x in ans:
    print(x)
print(comb)

Measured memory_bytes: 24528
#include <stdio.h>

int main(void)
{
	int n, a, b;

	scanf("%d%d%d", &n, &a, &b);

	if (n * a > b) {
		printf("%d\n", b);
	}
	else {
		printf("%d\n", n * a);
	}

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#define INF 100000000000
using namespace std;
typedef long long ll;
int n,W;
ll w[100],v[100];
ll dp[101][100001];
int main(){
  cin >> n >> W;
  for(int i=0;i<n;i++) cin >> w[i] >> v[i];
  for(int i=1;i<=100000;i++) dp[0][i]=INF;
  dp[0][0]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<=100000;j++){
      if(j<v[i]) dp[i+1][j]=dp[i][j];
      else dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
    }
  }
  int res=0;
  for(int i=0;i<=100000;i++){
    if(dp[n][i]<=W) res=i;
  }
  cout << res << "\n";

  
  return 0;
}


Measured memory_bytes: 79104
#include <stdio.h>

int main()
{
  char S[100];
  scanf ("%s",S);
  if (S[0] == 'S') puts("Cloudy");
  if (S[0] == 'C') puts("Rainy");
  if (S[0] == 'R') puts("Sunny");
return 0;
}


Measured memory_bytes: 1620
import java.util.Scanner;

/**
 *
 * @author C0117306
 */
public class Main {
     public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String s = sc.next();
         for (int i = 0; i < s.length(); i++) {
             if (i%2==0) {
                 System.out.print(s.subSequence(i, i+1));
             }
         }
         System.out.println();
    }
}


Measured memory_bytes: 31312
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const int N = 100;
int e[N][N];
int f[N][N];
int dp[N][N][6];/*day,weight,num of x*/

int solve(const int n,int now,const int c,int w,const int wlim,int x,const int xlim){
  if (n == now)return 0;
  int &ret = dp[now][w][x];
  if (ret != -1)return ret;
  ret = solve(n,now+1,c,w,wlim,x,xlim);

  rep(i,c){
    int ne = e[i][now];
    int nf = f[i][now];
    if (e[i][now] == 0)continue;
    if (w + nf <= wlim){
      ret = max(ret,solve(n,now+1,c,w+nf,wlim,x  ,xlim)+ne);
    }
    if (x == xlim)continue;
    REP(j,i+1,c){
      if (e[j][now] == 0)break;
      ne += e[j][now];
      nf += f[j][now];
      if (w + nf > wlim)break;
      ret = max(ret,solve(n,now+1,c,w+nf,wlim,x+1,xlim)+ne);
    }
  }
  return ret;
}


main(){
  int c,d,w,x;
  while(cin>>c>>d>>w>>x && c){
    rep(i,N)rep(j,N)rep(k,6)dp[i][j][k] = -1;
    rep(i,c)rep(j,d)cin>>e[i][j];
    rep(i,c)rep(j,d)cin>>f[i][j];
    cout << solve(d,0,c,0,w,0,x) << endl;
  }
  return false;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
#define PER(i,n) for(int i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int a, b, h;
  cin >> a >> b >> h;
  int ans = (a+b) * h / 2;
  cout << ans << endl;
}

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

using namespace std;

#define PB push_back
#define MP make_pair
#define f first
#define s second
#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define RFOR(i, b, a) for (int i = b-1; i>=a; --i)
#define FILL(a, b) memset(a, b, sizeof a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) ((int)a.size())

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

const int INF = 1000 * 1000 * 1000;
const LL LINF = 1LL * INF*INF;
const int MAX = 1e5;
const double PI = acos(-1.);
const double EPS = 1e-8;

int n;
VI x(100005);

LL res()
{
	int pos = n / 2;
	if (n % 2 == 0)
	{
		pos--;
	}
	multiset<int> s;
	FOR(I, 0, n)
	{
		s.insert(x[I]);
	}
	x[pos] = *s.begin();
	s.erase(s.begin());
	for(int i = 1;i + pos < n;++i)
	{
		if (i % 2)
		{
			x[pos+i] = *(--s.end());
			s.erase((--s.end()));
			if (s.empty())
			{
				break;
			}
			x[pos-i] = *(--s.end());
			s.erase((--s.end()));
		}
		else
		{
			x[pos+i] = *s.begin();
			s.erase(s.begin());
			if (s.empty())
			{
				break;
			}
			x[pos-i] = *s.begin();
			s.erase(s.begin());
		}
	}
	LL ans = 0;
	FOR(i, 1, n)
	{
		ans += abs(x[i] - x[i-1]);
	}
	return ans;
}

LL res2()
{
	int pos = n / 2;
	if (n % 2 == 0)
	{
		pos--;
	}
	multiset<int> s;
	FOR(I, 0, n)
	{
		s.insert(x[I]);
	}
	x[pos] = *(--s.end());
	s.erase(--s.end());
	for(int i = 1;i + pos < n;++i)
	{
		if (i % 2 == 0)
		{
			x[pos+i] = *(--s.end());
			s.erase((--s.end()));
			if (s.empty())
			{
				break;
			}
			x[pos-i] = *(--s.end());
			s.erase((--s.end()));
		}
		else
		{
			x[pos+i] = *s.begin();
			s.erase(s.begin());
			if (s.empty())
			{
				break;
			}
			x[pos-i] = *s.begin();
			s.erase(s.begin());
		}
	}
	LL ans = 0;
	FOR(i, 1, n)
	{
		ans += abs(x[i] - x[i-1]);
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin >> n;
	FOR(i, 0, n)
	{
		cin >> x[i];
	}

	LL ans = res();
	cout << max(ans, res2());

	return 0;
}













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

int main()
{
    int a, b, c ,d;
    cin >> a >> b >> c >> d;
    a+=b, c+=d;
    if(a>c)cout << "Left";
    else if(a<c)cout << "Right";
    else cout << "Balanced";
}



Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 301;
    ans = min(ans, abs(a-b)+abs(b-c));
    ans = min(ans, abs(a-c)+abs(c-b));
    ans = min(ans, abs(b-a)+abs(a-c));
    ans = min(ans, abs(b-c)+abs(c-a));
    ans = min(ans, abs(c-a)+abs(a-b));
    ans = min(ans, abs(c-b)+abs(b-a));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

 
int main() {
	int n; cin >> n;
	vector<int> y(n);
	rep(i,0,n) cin >> y.at(i);
	vector<int> u = y;
	sort(u.begin(), u.end());
	reverse(u.begin(), u.end());
	int max_1 = u.at(0);
	int max_2 = u.at(1);
	for (int i : y) {
		if (max_1 == i) cout << max_2 << endl;
		else cout << max_1 << endl;
	}
}

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

using namespace std;

int main() {
  int h,w;
  cin>>h>>w;
  vector<vector<char>> a(h,vector<char>(w));
  rep(i,h)rep(j,w)cin>>a[i][j];
  vector<bool> t(h),y(w);
  rep(i,h){
    rep(j,w){
      if(a[i][j]=='#')t[i]=y[j]=true;
    }
  }
  rep(i,h){
    if(t[i]){
      rep(j,w){
        if(y[j])cout<<a[i][j];
        if(j==w-1)cout<<endl;
      }
    }
  }
}

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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  cin >> N;
  static int a[202020], sum[202020];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    if (i == 0)
      sum[i] = a[i];
    else
      sum[i] = sum[i - 1] + a[i];
  }

  int ans = INF;
  for (int i = 0; i + 1 < N; i++) {
    int tmp = abs(sum[N - 1] - sum[i] - sum[i]);
    chmin(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3328
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;
int main() {
  ll N,M;
  cin >> N >> M;
  cout << min(N % M, abs(N%M-M));
}
  /*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
  //配列の内容表示
dout << "====listの内容====\n";
for (int i = 0; i < N; i++) dout << list[i] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

using namespace std;

typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> PIII;

int main(void) {
    while(true) {
        int x, y, s;
        cin >> x >> y >> s;
        if (x == 0) {
            break;
        }
        int nmax = 0;
        for (int i = 1; i < s; i++) {
            for (int j = i; j < s; j++) {
                int first = i * (100 + x) / 100;
                int second = j * (100 + x) / 100;
                if (first + second == s) {
                    int new_first = i * (100 + y) / 100;
                    int new_second = j * (100 + y) / 100;
                    nmax = max(nmax, new_first + new_second);
                }
            }
        }
        cout << nmax << endl;
    }
    return 0;
}

Measured memory_bytes: 3056
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    h, a = LI()
    print(math.ceil(h/a))
    return


# Solve
if __name__ == "__main__":
    solve()


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

int n, c[500 - 1], s[500 - 1], f[500 - 1];

int main() {
	cin >> n;
	for (int i = 0; i < n-1; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}

	for (int i = 0; i < n - 1; i++) {
		int time = 0;
		for (int j = i; j < n - 1; j++) {
			if (s[j] >= time) {
				time = s[j] + c[j];
			}
			else {
				time = s[j] + (time - s[j]) / f[j] * f[j] + ((time - s[j]) % f[j] == 0 ? 0 : f[j]) + c[j];
			}
			//cout << "time:" << time << endl;
		}
		cout << time << endl;
	}
	cout << 0 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void solve(){
    int A, B, M;
    vector<int> a, b;
    cin >> A >> B >> M;
    int elm1, elm2;
    for(int i=0; i<A; i++){
        cin >> elm1;
        a.push_back(elm1);
    }
    for(int i=0; i<B; i++){
        cin >> elm2;
        b.push_back(elm2);
    }

    int x, y, c, tmpmin=1000000;
    for(int i=0; i<M; i++){
        cin >> x >> y >> c;
        int vsum = a[x-1] + b[y-1] - c;
        tmpmin = min(tmpmin, vsum);
    }
    
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    tmpmin = min(tmpmin, a[0]+b[0]);

    cout << tmpmin << endl;
}

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

Measured memory_bytes: 1400
#include<iostream>
using namespace std;
#define int long long int
int32_t main()
{
	int n,k;
	cin>>n>>k;
	int arr[n+1];
	int j;
	for(j=1;j<=n;j++)
	{
		cin>>arr[j];
	}
	while(k!=0)
	{
		int prefix[n+2]={0};
		for(j=1;j<=n;j++)
		{
			int val1=j-arr[j];
			val1=max(val1,1LL);
			int val2=j+arr[j];
			val2=min(val2,n);
			prefix[val1]++;
			prefix[val2+1]--;
		}
		for(j=1;j<=n;j++)
		{
			prefix[j]+=prefix[j-1];
		}
		for(j=1;j<=n;j++)
		{
			arr[j]=prefix[j];
		}
		k--;
		bool result=true;
		for(j=1;j<=n;j++)
	    {
			if(arr[j]!=n)
			{
				result=false;
				break;
			}
		}
		if(result)
		   break;
	}
	for(j=1;j<=n;j++)
	  cout<<arr[j]<<" ";
	cout<<endl;
}


Measured memory_bytes: 6756
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power(ll a, ll b, ll m)
{
	if (b == 0)
		return(1);
	ll sol = power(a, b / 2, m);
	sol = (sol * sol) % m;
	if (b % 2 == 1)
		sol = (sol * a) % m;
	return(sol);
}
ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	else
	{
		return gcd(b, a % b);
	}
}
void solve()
{
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a * n, b);
}
int main()
{
	int t = 1;
	//cin>>t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int  a,b,c,x,ans,s;
int main()
{
	cin>>a>>b>>c>>x;
	for(long long int i=0;i<=a;i++)
	{
		for(long long int j=0;j<=b;j++)
		{
			for(long long int m=0;m<=c;m++)
			{
				s=m*50+i*500+j*100;
				if(s==x)
				{
					ans++;
				}
				s=0;
			}
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long LL;

#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::string S, T;

int main()
{
	in >> S >> T;
	std::vector<char>cngS(30, '\0'), cngT(30, '\0');
	rep(i, S.length())
	{
		if (cngS[S[i] - 'a'] == '\0') cngS[S[i] - 'a'] = T[i];
		if (cngT[T[i] - 'a'] == '\0') cngT[T[i] - 'a'] = S[i];
		if (cngS[S[i] - 'a'] != T[i])
		{
			out << "No" << std::endl;
			return 0;
		}
		if (cngT[T[i] - 'a'] != S[i])
		{
			out << "No" << std::endl;
			return 0;
		}
	}
	out << "Yes" << std::endl;
	return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long 
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
 
#define y1 what

using namespace std;
 
const int N = (int) 505;
const int M = (int) 2e6 + 10;
const ll big =  (1LL << 51);
const ll LINF = (ll) 1e18;
const int INF = (int) 1e9 + 7;
const double EPS = (double) 1e-6;
const double PI =  3.14159265359;

int n;
int ans[N * N], cnt[N];
pii a[N];

int main() {
    #define fn "balls"
    #ifdef witch
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
//        freopen(fn".in", "r", stdin);
//        freopen(fn".out", "w", stdout);
    #endif
    srand(time(0));
    /*
    n = rand() % 10 + 1;
    vector<int> perm;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            perm.pb(i);
        }
    }
    random_shuffle(perm.begin(), perm.end());
    cout << n << endl;
    for (auto it : perm) {
        cout << it << " ";
    } cout << "\n";
    */
    cin >> n;   
    for (int i = 1; i <= n; i++) {
    /*
        for (int j = 0, cnt = 0; j < perm.size(); j++) {
            if (perm[j] == i) {
                cnt++;
            }
            if (cnt == i) {
                a[i].f = j + 1;
                break;
            }
        }
        cout << a[i].f << "\n";
    */
        cin >> a[i].f;
        a[i].s = i;
    }
    //cout << "-------------\n";
    memset(ans, -1, sizeof(ans));
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++) {
        int cnt = a[i].s;
        if (ans[a[i].f] != -1) {
            cout << "No";
            return 0;
        }
        ans[a[i].f] = a[i].s;
        --cnt;
        for (int j = 1; j < a[i].f && cnt > 0; j++) {
            if (ans[j] == -1) {
                ans[j] = a[i].s;
                --cnt;
            }
        }
        if (cnt > 0) {
            cout << "No";
            return 0;
        }
    }
    /*
    for (int i = 1; i <= n * n; i++) {
        cout << ans[i] << " ";
    }
    cout << "\n";
    */
    for (int i = 1; i <= n * n; i++) {
        if (ans[i] == -1) {
            for (int j = 1; j <= n; j++) {
                if (cnt[j] >= j && cnt[j] < n) {
                    ans[i] = j;
                    break;
                }
            }
            if (ans[i] == -1) {
                cout << "No";
                return 0;
            }
        }
        cnt[ans[i]]++;
    }
    cout << "Yes\n";
    for (int i = 1; i <= n * n; i++) {
        cout << ans[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define forn(i,n) for(int i=0;i<n;i++)
#define free(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%lld", &n)
#define sff(a,b) scanf("%lld %lld", &a, &b)
#define sfff(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define pfn(n) printf("%lld\n", n)
#define pfs(n) printf("%lld ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define f find
#define ub upper_bound
#define lb lower_bound
#define ld long double
#define in insert
#define bs binary_search
#define le length()
const ll max_i=1e16+7;
#define np(s) next_permutation(s.begin(),s.end())
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
//it gives the lexicographically smallest string//


void solve()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  int t=1;
  //cin>>t;
  while(t--){
char a;
cin>>a;
if(a<='Z') cout<<'A';
else cout<<'a';
  }
}

int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input1.txt", "r",stdin);
  freopen("output1.txt","w",stdout);
  #endif
  solve();
  return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>

int position(int ar[], int start, int end)
{
	int pvalue = ar[end], pindex,i,temp;
	for(i=pindex=start ; i<end; i++)
	{
		if(ar[i]< pvalue)
			{
				temp = ar[pindex];
				ar[pindex] = ar[i];
				ar[i] = temp;
				pindex++;
			}
	}
	temp = ar[pindex];
	ar[pindex] = ar[end];
	ar[end] = temp;

	return pindex;
}

void quicksort(int ar[], int start, int end)
{
	if(start>=end) return;

	int index = position(ar, start, end);

	quicksort(ar, start, index-1);
	quicksort(ar, index+1, end);

	return;
}
int main()
{
	int ar[100000], n, i,a,b;
	while(~scanf("%d", &n))
	{
		for(i=0; i<n; i++)
			scanf("%d", ar+i);
		if(n%2)
			printf("0\n");
		else
		{	
			quicksort(ar, 0, n-1);
			a=(n-1)/2;
			b=a+1;
			if(ar[a]==ar[b])			
				printf("0\n");
			else
				printf("%d\n", ar[b]-ar[a]);
		}
		
	}
	return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld,lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer cout<<endl<<"answer : ";
#define maxn 100005
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {messi lld t=1;//cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0;string s;bool flag=false;
        cin>>n; lld a[n]; for(i=0;i<n;i++) cin>>a[i];
        x=a[0];
        vec v;
        for(i=1;i<n;i++)
            x=x^a[i];
        for(i=0;i<n;i++)
            v.pb(x^a[i]);
        for(auto u:v)
            cout<<u<<" ";
        cout<<endl;
    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|

*/


Measured memory_bytes: 6832
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
/*
  Node treeMinimum(Node x){


  }*/

Node treeSearch(Node u, int k){
  if(u ==NIL || k == u->key)return u;
  if(k<u->key)return treeSearch(u->left, k);
  else return treeSearch(u->right, k);
}
/*
  Node treeSuccessor(Node x){


  }

  void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



  }
*/
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y = x;
    if(z->key<x->key)x=x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NIL)root = z;
  else if(z->key<y->key)y->left=z;
  else y->right = z;

}

void inorder(Node u){

  if (u!=NIL){

    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){

  if (u!=NIL){

    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
      if ( com[0] == 'f' ){
	scanf("%d", &x);
	Node t = treeSearch(root, x);
	if ( t != NIL ) printf("yes\n");
	else printf("no\n");
	} else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
	inorder(root);
	printf("\n");
	preorder(root);
	printf("\n");
	} /* else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
      }*/}

return 0;
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;



int main() {
    int n,d; cin >> n >> d;
    n%(d*2+1) == 0 ? cout << n / (d*2+1) : cout << n / (d*2+1) + 1;
    
}


Measured memory_bytes: 3604
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys

input = sys.stdin.readline
n = int(input())
w = []

for i in range(n):
    w.append(str(input()))

for i in range(n):
    if w.count(w[i]) > 1:
        print("No")
        exit(0)

    if i != n - 1:
        if w[i][-2] != w[i + 1][0]:
            print("No")
            exit(0)


print("Yes")


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

public class Main {
    FastScanner in;
    PrintWriter out;

    void solve() {
        int x = in.nextInt();
        for (int y = 1; ; y++) {
            if (y * x % 360 == 0) {
                out.println(y);
                return;
            }
        }
    }

    final int mod = 988244353;

    int mul(int x, int y) {
        return (int) ((x * 1L * y) % mod);
    }

    int add(int x, int y) {
        x += y;
        return x >= mod ? (x - mod) : x;
    }

    void run() {
        try {
            in = new FastScanner(new File("Main.in"));
            out = new PrintWriter(new File("Main.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();
        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}

Measured memory_bytes: 32900