akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

void Main() {
	int A, B;
	cin >> A >> B;
	if (A <= 9 && B <= 9) {
		cout << A * B << endl;
	} else {
		cout << -1 << endl;
	}
}

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[2][120];
    int candies[2][120];
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }
    candies[0][0] = a[0][0];
    candies[1][0] = a[0][0] + a[1][0];
    for(int i = 1; i < n; i++){
        candies[0][i] = candies[0][i-1] + a[0][i];
    }
    for(int i = 1; i < n; i++){
        candies[1][i] = max(candies[1][i-1], candies[0][i]) + a[1][i];
    }
    cout << candies[1][n-1] << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int K = sc.nextInt();
            long[] H = new long[N];
            for (int i = 0; i < N; i++) {
                H[i] = sc.nextLong();
            }

            Arrays.sort(H);

            long ans = 0;

            for (int i = 0; i < N - K; i++) {
                ans += H[i];
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 82832
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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; }

int main() {
	int n,k;
	cin >> n >> k;
	int r,s,p;
	cin >> r >> s >> p;
	string t;
	cin >> t;
	vector<char> tt(n);
	rep(i,n) {
		if(t[i] == 'r') tt[i] = 'p';
		if(t[i] == 's') tt[i] = 'r';
		if(t[i] == 'p') tt[i] = 's';
	}
	ll sum = 0;
	rep(i,n) {
		if(i-k>=0) {
			if(tt[i-k] == tt[i]) {
				tt[i] = -1;
				continue;
			}
		}	
		if(tt[i] == 'r') sum += r;
		if(tt[i] == 's') sum += s;
		if(tt[i] == 'p') sum += p;
			
	}
	cout << sum << endl;
}

Measured memory_bytes: 512
import numpy as np
N, M = map(int, input().split())
menu = np.array([])
for i in range(N):
  a = np.array(input().split())
  menu = np.append(menu, a[1:])
menu = np.array(menu).astype(int).ravel()
count = 0
for i in range(1, M+1):
  if np.sum(menu == i) == N:
    count += 1
print(count)

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

using namespace std;

int main()
{
 
    long long int n,d,x,y,dem = 0,m;
    cin >> n >> d;
    while (n--)
    {
        cin >> x>>y;
        if ( sqrt(x*x+y*y) <= d)
            dem++;
    }
    cout << dem;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    int n;
    string s;
    cin >> n >> s;
    map<char,ll> mp;
    for (int i=0;i<n;i++) {
        mp[s[i]]++;
    }

    ll ans = 1;
    for (int i=0;i<26;i++) {
        ans *= (mp['a'+i]+1);
        ans %= mod;
    }
    ans --;
    cout << ans << endl;
}

Measured memory_bytes: 512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        m: usize,
        q: usize,
        v: [chars; n],
        qs: [(usize, usize, usize, usize); q]
    }
    let v: Vec<Vec<usize>> = v.iter().map(|l| l.iter().map(|c| c.to_digit(10).unwrap() as usize).collect()).collect();
    let mut bs = vec![vec![0; m + 1]; n + 1];
    for i in 0..n {
        for j in 0..m {
            bs[i + 1][j + 1] = v[i][j];
        }
    }
    let mut lx = vec![vec![0; m + 1]; n + 1];
    let mut ly = vec![vec![0; m + 1]; n + 1];
    for i in 1..n {
        for j in 0..m {
            lx[i + 1][j + 1] = v[i - 1][j] * v[i][j];
        }
    }
    for i in 0..n {
        for j in 1..m {
            ly[i + 1][j + 1] = v[i][j - 1] * v[i][j];
        }
    }
    for i in 0..n {
        for j in 0..m {
            bs[i + 1][j + 1] += bs[i][j + 1] + bs[i + 1][j] - bs[i][j];
            lx[i + 1][j + 1] += lx[i][j + 1] + lx[i + 1][j] - lx[i][j];
            ly[i + 1][j + 1] += ly[i][j + 1] + ly[i + 1][j] - ly[i][j];
        }
    }
    for &(x1, y1, x2, y2) in &qs {
        let p = bs[x2][y2] + bs[x1 - 1][y1 - 1] - bs[x2][y1 - 1] - bs[x1 - 1][y2];
        let l1 = lx[x2][y2] + lx[x1][y1 - 1] - lx[x2][y1 - 1] - lx[x1][y2];
        let l2 = ly[x2][y2] + ly[x1 - 1][y1] - ly[x2][y1] - ly[x1 - 1][y2];
        println!("{}", p - l1 - l2);
    }
}


Measured memory_bytes: 194300
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    S = input()

    d = {}
    for c in S:
        if c not in d:
            if len(d) >= 2:
                print('No')
                return
            else:
                d[c] = 1
        else:
            if d[c] > 2:
                print('No')
                return
            else:
                d[c] = d[c] + 1
    print('Yes')




# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc132","a",main)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int count;
		while ((count = in.nextInt()) != 0) {
			String maxNum = "";
			int maxD = 0;
			while (count-- > 0) {
				String num = in.next();
				int d = in.nextInt() + in.nextInt();
				if (maxD < d) {
					maxNum = num;
					maxD = d;
				}
			}
			System.out.println(maxNum+" "+maxD);
		}
	}
}

Measured memory_bytes: 104824
#include <stdio.h>
 
int main(){
  int h,w;
 
  while(1){
    scanf("%d %d",&h,&w);
    if(h == 0 && w == 0)
      return 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        putchar('#');
      }
      putchar('\n');
    }
    putchar('\n');
  }
  return 0;
}


Measured memory_bytes: 2592
#include <stdio.h>

void output(int A[], int N) {
	int i;
	
	for (i = 0; i < N; i++) {
		if (i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

void insertionSort(int A[], int N) {
	int i, j;
	int tmp;
	
	for (i = 1; i < N; i++) {
		tmp = A[i];
		j = i - 1;
		
		while (j >= 0 && A[j] >= tmp) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = tmp;
		output(A, N);
	}
}

int main(void) {
	int N;
	int A[100];
	int i;
	
	scanf("%d", &N);
	
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
		
	output(A, N);
	insertionSort(A, N);

	return 0;
}

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

int main()
{
  int n,w,v,sum;

  for(;;){
    cin>>n>>w;
    if(!(n|w)) break;
    int mark=0,sum[100]={0};
    for(int i=0;i<n;i++){
      cin>>v;
      sum[v/w]++;
      if((v/w)>mark) mark=(v/w);
    }
    int max=0;
    double ans=0;
    for(int i=0;i<=mark;i++)
      if(sum[i]>max) max=sum[i];
    for(int i=0;i<n;i++)
      ans+=((double)(mark-i)/mark)*((double)sum[i]/max);
    printf("%.7f\n", ans+0.01);
  }
}


Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  const int N = 100005;



int n,a,b,c;

vector<string> v;
bool ans[N];
void dfs(int idx,int a,int b,int c)
{
  if(a < 0 or b < 0 or c < 0)return;

  if(idx >=n)
  {
    cout << "Yes" << endl;

    for(int i = 0; i < n; i++)
    {
      cout << v[i][ans[i]] << endl;
    }
    exit(0);
    return;
  }

  int a1 = a, b1 = b,c1 = c;

  if(v[idx][0] == 'A')a++;
  if(v[idx][0] == 'B')b++;
  if(v[idx][0] == 'C')c++;
  if(v[idx][1] == 'A')a--;
  if(v[idx][1] == 'B')b--;
  if(v[idx][1] == 'C')c--;

  ans[idx] = 0;
  if(a >=0 and b >=0 and c >=0)dfs(idx+1,a,b,c);


  a = a1;
  b = b1;
  c = c1;

  if(v[idx][0] == 'A')a--;
  if(v[idx][0] == 'B')b--;
  if(v[idx][0] == 'C')c--;
  if(v[idx][1] == 'A')a++;
  if(v[idx][1] == 'B')b++;
  if(v[idx][1] == 'C')c++;

  ans[idx] = 1;
  if(a >=0 and b >=0 and c >=0)dfs(idx+1,a,b,c);

}

int32_t main()
{



    IOS

    cin >> n >> a >> b >> c;




    for(int i = 0; i < n; i++)
      {
        string s;
        cin >> s;

        v.push_back(s);
      }


      dfs(0,a,b,c);

      cout << "No";

    
    return 0;
}



Measured memory_bytes: 14504
N = int(input())
b = list(map(int, input().split()))

# 最後の状態を後ろから見ていく
ans = []
for i in range(N):
    for j in reversed(range(len(b))):
        if b[j] == j+1:
            b.pop(j)
            ans.append(j+1)
            break
ans.reverse()
if len(b) == 0:
    for a in ans:
        print(a)
else:
    print(-1)


Measured memory_bytes: 3064
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0

    for i in range(n):
        tmp = i
        for j in range(i, n):
            if a[j] < a[tmp]:
                tmp = j
        if i != tmp:
            a[i], a[tmp] = a[tmp], a[i]
            ans += 1

    print(*a)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll ans = LINF;
    REP(i,1e5+1){
        ll cost = i*2*C + max(0,X-i)*A + max(0,Y-i)*B;
        chmin(ans, cost);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int arr[200005];
int main()
{
    int n,i,j,a;
    cin>>n;
    for(i=2;i<=n;i++){
        cin>>a;
        arr[a]++;
    }
    for(i=1;i<=n;i++) cout<<arr[i]<<endl;
}



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

using namespace std;

int main() {
    int n,k;
    cin>>n>>k;
    vector<int> v;
    vector<int> dp(k+1);
    for(int i=0; i<n;i++){
        int x;
        cin>>x;
        v.push_back(x);
    }
    for(int i=0; i<=k;i++){
        for(int stone : v){
            if(stone+i<=k){
                if(dp[i]==0) dp[i+stone] = 1;
            }
        }    
        
    }
    cout<<((dp[k])?"First":"Second");
}

Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	string s;
	string end = "zyxwvutsrqponmlkjihgfedcba";

	cin>>s;
	if(s==end){
		cout<<-1<<endl;
		return 0;
	}

	if(s.length()<26){
		int al[26] = {};
		rep(i,s.length())al[s[i]-'a']++;
		rep(i,26)if(al[i]==0){
			s+=('a'+i);
			break;
		}
		cout<<s<<endl;
		return 0;
	}else{
		int pos = -1;
		for (int i = 25; i >= 0; i--){
			if(s[i]>s[i-1]){
				pos = i-1;
				break;
			}
		}
		char ad='z';
		for (int i = pos+1; i < 26; i++){
			if(s[i]>s[pos]){
				ad = min(s[i],ad);
			}
		}
		s = s.substr(0,pos)+ad;
		cout<<s<<endl;
		return 0;
	}

	return 0;
}

Measured memory_bytes: 256
N = int(input())
play_list = []
for i in range(N):
    play_list.append(list(input().split()))

title = input()

s = 0
for i in range(N):
    if play_list[i][0] == title:
        s = i
    else:
        s = s

time = 0
if s+1 == N:
    time = 0
else:
    for i in range(s+1, N):
        time += int(play_list[i][1])

print(time)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, m; cin >> n >> m;
    vector<int> k(m);
    vector<vector<int>> s(m);
	for(int i=0; i<m; ++i){
        cin >> k[i];
        s[i].resize(k[i]);
        for(int j=0; j<k[i]; ++j){
            cin >> s[i][j];
            --s[i][j];
        }
    }
    vector<int> p(m);
    for(int &i : p) cin >> i;

    int cnt=0, sz=(1<<n);
    for(int i=0; i<sz; ++i){
        int flg=1;
        for(int j=0; j<m; ++j){
            int sum=0;
            for(int ii=0; ii<k[j]; ++ii){
                sum += ((i>>(s[j][ii]))&1);
            }
            if(sum%2!=p[j]){
                flg=0;
                break;
            }
        }
        cnt += flg;
    }
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

bool all_same(string& s)
{
    for (auto ch : s)
    {
        if (ch != s[0])
        {
            return false;
        }
    }
    return true;
}

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

    map<int64_t, int64_t> counter;

    if (all_same(s))
    {
        counter[s.size() * k] = 1;
    }
    else
    {

        if (s.back() != s[0])
        {
            int count = 0;
            int prev_char = s[0];
            for (auto ch : s)
            {
                if (ch == prev_char)
                {
                    count++;
                }
                else
                {
                    counter[count] += k;
                    count = 1;
                }
                prev_char = ch;
            }
            counter[count] += k;
        }
        else
        {
            bool first = true;
            int count = 0;
            int prev_char = s[0];
            for (auto ch : s)
            {
                if (ch == prev_char)
                {
                    count++;
                }
                else
                {
                    counter[count] += first ? 1 : k;
                    count = 1;
                    first = false;
                }
                prev_char = ch;
            }
            counter[count] += 1;

            count = 0;
            for (int i = 0; i < s.size(); i++)
            {
                if (s[i] != s[0])
                {
                    count += i;
                    break;
                }
            }
            for (int i = s.size() - 1; i >= 0; i--)
            {
                if (s[i] != s.back())
                {
                    count += s.size() - 1 - i;
                    break;
                }
            }
            counter[count] += k - 1;
        }
    }
    int64_t ans = 0;
    for (auto key_val : counter)
    {
        ans += key_val.second * (key_val.first / 2);
    }
    cout << ans << endl;
}


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

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (N, M) = nextIntList()
    val A = PriorityQueue(nextLongList())
    val array = Array(M) {
        val (B, C) = nextLongList()
        Pair(B, C)
    }.sortedByDescending { it.second }
    loop@ for (p in array) {
        val (b, c) = p
        for (i in 1..b) {
            if (A.peek() >= c) break@loop
            A.poll()
            A.add(c)
        }
    }
    println(A.sum())
}

Measured memory_bytes: 100284
x,n=map(int,input().split())
l=list(map(int,input().split()))
flag=0
i=0
while flag==0:
    if x-i not in l:
        flag=1
        ansa=x-i
    i+=1
flag=0
i=0
while flag==0:
    if x+i not in l:
        flag=1
        ansb=x+i
    i+=1
if abs(ansa-x)<=abs(ansb-x):
    print(ansa)
else:
    print(ansb)

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

int main(void){
    int N,L;
    cin >> N >> L;
    string S[N];
    for(int i = 0 ; i < N ;i++){
        cin >> S[i];
    }
    sort(S,S+N);
    string ans="";
    for(int i = 0 ; i < N ; i++){
        ans += S[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3128
#include<stdio.h>

int main(){
  long n,d[2001],i,j,k,cnt=0;
  scanf("%ld",&n);
  for(i=0;i<n;i++){
  	scanf("%ld",&d[i]);
  }
  
  for(j=0;j<n-1;j++){
      for(k=j+1;k<n;k++){
        if(d[j]>d[k]){
        	long tmp=d[j];
          	d[j]=d[k];
            d[k]=tmp;
        }
      }
  }
  
  for(i=0;i<n-2;i++){
  	for(j=i+1;j<n-1;j++){
      for(k=j+1;k<n;k++){
        //printf("%ld %ld %ld\n",d[i],d[j],d[k]);
        if((d[i]+d[j])>d[k]){
		  cnt++;
        }
        else{
        	break;
        }
      }
    }
  }
  printf("%ld",cnt);
  return 0;
}


Measured memory_bytes: 128
// 2014/05/28 Tazoe

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
	double P[1001][2];

	P[1][0] = 1.0;
	P[1][1] = 0.0;

	for(int i=2; i<=1000; i++){
		double x = -P[i-1][1];
		double y = P[i-1][0];

		double L = sqrt(x*x+y*y);

		P[i][0] = P[i-1][0]+x/L;
		P[i][1] = P[i-1][1]+y/L;
	}

	while(true){
		int n;
		cin >> n;

		if(n==-1)
			break;

		cout << P[n][0] << endl;
		cout << P[n][1] << endl;
	}

	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n;cin >>n;
    vector<ll>p(n);
    vector<ll>q(n);
    for (int i = 0; i < n; ++i) {
        cin >>p[i];
        p[i]--;
    }
    for (int i = 0; i < n; ++i) {
        cin >>q[i];
        q[i]--;
    }
    ll a,b;
    vector<ll>num(n);
    for (int i = 0; i < n; ++i) {
        num[i]=i;
    }
    ll k=0;
    do{
        if(num==p)a=k;
        if(num==q)b=k;
        k++;
    }while(next_permutation(all(num)));
    cout <<abs(a-b)<<endl;
    return 0;
}



Measured memory_bytes: 256
def sieve_eratosthenes(n):
    primes = [0, 1] * (n // 2 + 1)
    if n % 2 == 0:
        primes.pop()
    primes[1] = 0
    primes[2] = 1
    for p in range(3, n + 1, 2):
        if primes[p]:
            for q in range(p * p, n + 1, 2 * p):
                primes[q] = 0
    return primes

Q = int(input())
primes = sieve_eratosthenes(10**5)
C = [0]*(10**5+1)
for x in range(1,10**5+1):
    if primes[x] == 1 and primes[(x+1)//2] == 1:
        C[x] = C[x-1] + 1
    else:
        C[x] = C[x-1]

for _ in range(Q):
    l, r = map(int, input().split())
    print(C[r]-C[l-1])



Measured memory_bytes: 4980
#include<bits/stdc++.h>
using namespace std;
long long pi = 3.14159265358979323846264338327;
int a,b,c,counter=0;
int main() {
	cin >> a >> b;
	vector<int> s(a+1);
	for(int i = 0;i<a;++i){
		cin >> c;
		s[i] = c;
	}
	for(int j = 0;j+b-1<a;++j){
        ++counter;
        if(counter-1 == a-b){
          break;
        }
		if(s.at(j+b) > s.at(j)){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
 	return 0;
}

Measured memory_bytes: 3916
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (D, N) = Slice2<long>();
            var w = (long)Pow(100, D);
            if (N == 100) N = 101;
            WriteLine(w * N);
        }
 
        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 27460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
class MQ {
	private:
	deque<ll> q;
	public:
	void push(ll val) {
		while(!(q.empty()) && q.back() > val) {
			q.pop_back();
		}
		q.push_back(val);
	}
	void pop(ll val) {
		if(!q.empty() && q.front() == val) {
			q.pop_front();
		}
	}
	ll front() {
		return q.front();
	}
};
vl w,dp;
int main() {
	ll n,ti,ed;
	cin >> n >> ed >> ti;
	for(int i=0;i<n;i++) {
		ll t;
		cin >> t;
		w.push_back(t);
	}
	w.push_back(ed);
	dp.assign(w.size(),1e18);

	dp.back() = 0;
	ll rv = 1e18;
	MQ q;
	ll pt = dp.size()-1;
	q.push(0);
	for(int i=n-1;i>=0;i--) {
		while(pt > i && (w[pt-1]-w[i])*2 > ti) {
			q.pop(dp[pt]);
			rv = min(rv,dp[pt]+(w[pt-1]-w[i])*2);
			pt--;
		}
		dp[i] = min(q.front()+ti,rv);
		q.push(dp[i]);
		if(i > 0) {
			rv += 2*(w[i]-w[i-1]);
		}
	}
	//what
	cout << dp[0]+ed << '\n';
}


Measured memory_bytes: 4984
import java.util.*;
public class Main{
  
  public static void main(String[] args)
  {

    Scanner s=new Scanner(System.in);
    int n=s.nextInt();
    int k=s.nextInt();
    int arr[]=new int[n];
    for(int i=0;i<n;i++)
    {
      arr[i]=s.nextInt();
    }
    
    int dp[]=new int[k+1];
    for(int i=0;i<arr[0];i++)
    {
     dp[i]=0; 
    }
    for(int i=arr[0];i<=k;i++)
      dp[i]=-1;
    for(int i=arr[0];i<=k;i++)
    {
      for(int j=0;j<n;j++)
      {
        if(i>=arr[j])
        {
          if(dp[i-arr[j]]==0)
          {
            dp[i]=1;
            break;
          }
        }
      }
      if(dp[i]==-1)
        dp[i]=0;
     
    }
    if(dp[k]==1)
      System.out.println("First");
    else
      System.out.println("Second");
  }
}


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



int main() {
  ll N,K,ans = 1;
  cin >> N >> K;
  rep(i,N)
  {
    ans = min (ans * 2,ans + K);
  } 
  cout << ans << endl;
    
  return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int dp[2][1<<16];

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

  int R, C;
  cin >> R >> C;
  VI len(R);
  VS vs(R);
  REP(i,R){
	cin >> vs[i];
	len[i] = SZ(vs[i]);
  }

  int crt = 0, nxt = 1;
  fill((int*)dp, (int*)dp+2*(1<<16), -1);
  REP(B,1<<C){
	if(__builtin_popcount(B) != len[0]) continue;
	dp[crt][B] = 0;
	for(int x=0,i=0;i+1<len[0];++i){
	  while(x < C && (B>>x&1) == 0) ++x;
	  if((B>>(x+1)&1) && vs[0][i] == vs[0][i+1])
		dp[crt][B]++;
	  ++x;
	}
  }

  FOR(y,1,R){
	REP(x,C){
	  fill(dp[nxt], dp[nxt]+(1<<16), -1);
	  REP(B,1<<C) if(dp[crt][B] >= 0){
		// not place character
		maxi(dp[nxt][B>>1], dp[crt][B]);

		int next_b = (B >> 1) | (1 << (C-1));
		int next = dp[crt][B];
		int lb = B & ((1<<(C-x))-1);
		int lbi = len[y-1] - __builtin_popcount(lb);
		int ub = B >> (C-x);
		int ubi = __builtin_popcount(ub);

		if(ubi >= len[y])
		  continue;
		// up
		if(lbi < len[y-1] && (B&1) && vs[y-1][lbi] == vs[y][ubi])
		  ++next;
		// left
		if(ubi > 0 && (B>>(C-1)&1) && vs[y][ubi-1] == vs[y][ubi])
		  ++next;

		maxi(dp[nxt][next_b], next);
	  }
	  swap(crt, nxt);
	}

	REP(B,1<<C){
	  if(__builtin_popcount(B) != len[y])
		dp[crt][B] = -1;
	}
  }

  int ans = 0;
  REP(B,1<<C)
	maxi(ans, dp[crt][B]);
  cout << ans*2 << endl;

  return 0;
}

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

using namespace std;

using ll = long long;
using Square = array<int, 4>;

map<Square, ll> memo;

const Square indices[] = {{1,0,1,0},{2,1,0,3},{3,2,3,2},{0,3,2,1}};

void normalize(Square& s) {
	set<Square> tmp;
	for (int i = 0; i < 4; i++) {
		tmp.insert(s);
		rotate(s.begin(), s.begin() + 1, s.end());
	}
	s = *tmp.begin();
}

int pattern(Square& s) {
	if (s[0] == s[2] && s[1] == s[3]) {
		if (s[0] == s[1]) return 4;
		else return 2;
	}
	return 1;
}

ll solve(const Square& s1, const Square& s2) {
	ll res = 1;
	int used = -1;
	for (int i = 0; i < 4; i++) {
		Square tmp = {s1[indices[i][0]], s1[indices[i][1]], s2[indices[i][2]], s2[indices[i][3]]};
		normalize(tmp);
		if (memo.find(tmp) == memo.end() || memo[tmp] == 0) {
			res = 0;
			break;
		}
		res *= memo[tmp] * pattern(tmp);
		memo[tmp]--;
		used++;
	}

	for (int i = 0; i <= used; i++) {
		Square tmp = {s1[indices[i][0]], s1[indices[i][1]], s2[indices[i][2]], s2[indices[i][3]]};
		normalize(tmp);
		memo[tmp]++;	
	}
	return res;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<Square> c(n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++) {
			cin >> c[i][j];
		}
		normalize(c[i]);
		memo[c[i]]++;
	}

	ll ans = 0;
	for (int i = 0; i < n; i++) {
		memo[c[i]]--;
		for (int j = 0; j < i; j++) {
			memo[c[j]]--;
			for (int k = 0; k < 4; k++) {
				ans += solve(c[i], c[j]);
				rotate(c[j].begin(), c[j].begin() + 1, c[j].end());
			}
			memo[c[j]]++;
		}
		memo[c[i]]++;	
	}
	cout << ans / 3 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstring>
using namespace std;

void printVector(vector<string> vec)
{
    cout << "size = " << vec.size() << endl;
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << ", ";
    }
    cout << endl << endl;
}

int main(int argc, char const* argv[])
{
    string s;
    int k, n, len;
    vector<string> sVec;
    cin >> s;
    cin >> k;
    len = s.length();
    n = 0;
    for (int i = 1; i <= k; i++) {
        for (int j = 0; j <= len - i; j++) {
            sVec.push_back(s.substr(j, i));
        }
    }
    sort(sVec.begin(), sVec.end());
    sVec.erase(unique(sVec.begin(), sVec.end()), sVec.end());
//    printVector(sVec);
    cout << sVec[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 1660
import random
import time

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum = sum + c[i]*(d-last_d[i])
        
    return int(score - sum)


def main():
    D = int(input())

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

    s = [list(map(int, input().split())) for i in range(D)]

    start = time.time()
    
    last_d = [0 for i in range(26)]
    
    ans = []
    
    score1 = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2 and c[j] != 0:
                idx = j
            
        last_d[idx] = i+1
        score1 += s[i][j]
        score1 = down_score(i+1,c,last_d,score1)
        
        ans.append(idx)

    while time.time() - start < 1.9:
        last_d = [0 for i in range(26)]
        score2 = 0  
        tmp1 = 0
        tmp2 = 1
        tmp3 = 2
        if random.randint(0,1):           
            d1 = random.randint(0,D-21) 
            d2 = random.randint(d1+1,d1+10)
            d3 = random.randint(d2+1,d2+10) 
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            tmp3 = ans[d3]
            if random.randint(0,1):
                ans[d1] = tmp2
                ans[d2] = tmp1
                ans[d3] = tmp3
            else:
                ans[d1] = tmp1
                ans[d2] = tmp3
                ans[d3] = tmp2
                  
        else:
            d1 = random.randint(0,D-15) 
            d2 = random.randint(d1+1,d1+7)
            d3 = random.randint(d2+1,d2+7) 
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            tmp3 = ans[d3]
            if random.randint(0,1):
                ans[d1] = tmp2
                ans[d2] = tmp3
                ans[d3] = tmp1
            else:
                ans[d1] = tmp3
                ans[d2] = tmp1
                ans[d3] = tmp2
            
        for i in range(D):
            score2 += s[i][ans[i]-1]
            last_d[ans[i]-1] = i+1
            score2 = down_score(i+1, c, last_d, score2)
        
        if score1 > score2:
            ans[d1] = tmp1
            ans[d2] = tmp2
            ans[d3] = tmp3
        else:
            score1 = score2
    
    for i in range(D):
        print(ans[i]+1)  

if __name__ == "__main__":
    main()


Measured memory_bytes: 9488
#include<stdio.h>
#include<algorithm>
using namespace std;

int main() {
    int n,tmp;
    int minv=1000001, maxv=-1000001;
    long long int sum = 0;
    
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++) {
        scanf("%d", &tmp);
        sum += tmp;
        minv = min(minv, tmp);
        maxv = max(maxv, tmp);
    }
    
    printf("%d %d %lld\n", minv, maxv, sum);
}


Measured memory_bytes: 2748
#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef complex < double > P;
typedef pair < P, P >      L;
typedef pair < P, P >      Ls;
typedef vector< P >        G;
const double EPS = 1e-10;
const double INF = 1e8;
double cross( P a,  P b){ //OK
  return imag( conj(a) * b);
}
double dot( P a, P b){ //OK
  return real( conj(a) * b);
}
int ccw( P a, P b, P c){  //OK
  b -= a, c -= a;
  if(cross(b,c) > 0)    return +1;  // a → b で 反時計方向におれて c
  if(cross(b,c) < 0)    return -1; // a → b で 時計方向におれて c
  if(dot(b,c) < 0)      return +2;  // c -- a -- b
  if(norm(b) < norm(c)) return -2; // a -- b -- c
                        return 0;  // a -- c -- b
}
P projection( L l, P p) { //OK
  double t = dot( p - l.fr, l.fr - l.sc) / norm( l.fr - l.sc);
  return l.fr + t * ( l.fr - l.sc);
}
bool intersect( L a, P p){ //OK
   return abs( a.fr - p) + abs( a.sc - p) - abs( a.fr - a.sc) < EPS;
}
bool intersect( L a, L b){ //OK
  return ccw( a.fr, a.sc, b.fr) * ccw( a.fr, a.sc, b.sc) <= 0 &&
    ccw( b.fr, b.sc, a.fr) * ccw( b.fr, b.sc, a.sc) <= 0;
}
double distance( L s, P p){ //OK
  P r = projection(s, p);
  if ( intersect( s, r)) return abs( r - p);
  return min( abs( s.fr - p), abs( s.sc - p));
}
double distancion( L a, L b){ //OK
  if(intersect( a, b)) return 0;
  return min( min( distance( a, b.fr), distance( a, b.sc)),
              min( distance( b, a.fr), distance( b, a.sc)));
}
double Degree_to_Radian(double n){
  return n * M_PI / 180.0;
}
double Radian_to_Degree(double n){
  return n * 180.0 / M_PI;
}
/* ここまでテンプレート */
double info[100][100];
int n, m, l;
L stars[100][5];
int table[][5] = {{0,0,1,1,2},{2,3,3,4,4}};
void add( double x, double y, double a, double r, int z){
  G hosi(5);
  for(int i = 0 ; i < 5 ; i++ ){
    double theta = Degree_to_Radian(a + 72 * i);
    double nx = r * sin( theta ), ny = r * cos( theta );
    hosi[i] = P( x - nx, y + ny);
  }
  for(int i = 0 ; i < 5 ; i++ ){
    stars[z][i] = L( hosi[table[0][i]], hosi[table[1][i]]);
  }
}
int main(){ //vectorが重いかも
  while(scanf("%d%d%d", &n, &m, &l), n|m|l){
    m--, l--;
    for(int i = 0 ; i < n ; i++ ){
      double x, y, a, r;
      scanf("%lf%lf%lf%lf", &x, &y, &a, &r);
      add( x, y, a, r, i);
    }
    for(int i = 0 ; i < n ; i++ ){
      for(int j = i + 1 ; j < n ; j++ ){
        double dist = INF;
        for(int a = 0 ; a < 5 ; a++ ){
          for(int b = 0 ; b < 5 ; b++ ){
            dist = min( dist, distancion( stars[i][a], stars[j][b]));
          }
        }
        info[i][j] = info[j][i] = dist;
      }
    }
    for(int k = 0; k < n; k++ ){
      for(int i = 0; i < n; i++ ){
        for(int j = 0; j < n; j++ ){
          info[i][j] = min( info[i][j], info[i][k] + info[k][j]);
        }
      }
    }
    printf("%.10f\n", info[m][l]);
  }
}

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

int main() {
	int n, m;

	cin >> n >> m;
	
	int left = 1, right = n;
	
	for(int i = 0;i < m;i++){
		int l, r;
		cin >> l >> r;
		if(l > left)
			left = l;
		if(r < right)
			right = r;
	}
	int ans = right - left + 1;
	if(ans > 0)
		cout << right - left + 1 << endl;
	else
		cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int k = scan.nextInt();
		int n = scan.nextInt();
		int count = 0;

		ArrayList<Integer> list = new ArrayList<Integer>(n);

		for(int i = 0;i < n;i++) {
			list.add(scan.nextInt());
		}

		for(int i = 1;i <= n;i++) {
			if(i == n) {
				if((k - list.get(n - 1)) + list.get(0) > count) {
					count = (k - list.get(n - 1)) + list.get(0);
				}
			}else {
				if((list.get(i) - list.get(i - 1)) > count) {
					count = list.get(i) - list.get(i - 1);
				}
			}
		}

		System.out.println(k - count);
	}
}


Measured memory_bytes: 88660
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pll pair<ll,ll>
#define vi vector < int >
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define s(x) scanf("%d",&x)
#define sll(x) scanf("%lld",&x)
#define pf(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define flash ios_base::sync_with_stdio(false);cin.tie(0)
#define goog(x) cout << "Case #" << x << ": "
#define MAX5 200005
#define MAX6 2000005
#define MLOG 18
#define limit 1e18
#define mod 1000000007   
void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int power(int x, int y, int p){
    int res = 1;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

void solve(){
    int n;
    cin >> n;
    if(n%2){
        cout << 0 << endl;
    }
    else{
        int x = 0;
        int a = 5;
        n /= 2;
        while(n/a > 0){
            x += n/a;
            a = a*5;
        }
        cout << x << endl;
    }
} 
signed main(){  
//  freopen("ii.txt", "w", stdin);
    flash;
    int t = 1;
    //  cin >> t;  
    for(int tc = 1; tc <= t; tc++){
    //goog(tc);
        solve();
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N,T,i;
  scanf("%d %d",&N,&T);
  int c[N],t[N];

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

  int besti=-1,bestc=1001;
  for(i=0;i<N;i++){
    if(t[i]<=T){
      if(bestc>c[i]) {
        besti = i;
        bestc=c[i];
      }
    }
  }

  if(besti==-1) printf("TLE\n");
  else{
    printf("%d\n",bestc);
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){

    ll n,c,k;
    cin >> n >> c >> k;
    vector <ll> t(n);
    REP(i,n)
    {
        cin >> t[i];
    }
    ll res = 0;

    //方針: 貯めれるだけ貯める
    sort(t.begin(),t.end());

    ll kireLine;
    ll ima;
    ll cap = 0;

    kireLine = t[0] + k;

    REP(i,n)
    {
        ima = t[i];
        if(t[i] > kireLine && cap != 0)
        {
            res += 1;
            cap = 0;
            kireLine = ima + k;
        }
        cap += 1;
        if(cap >= c)
        {
            ++res;
            cap = 0;
            if(i + 1 < n)
            {
                kireLine = t[i+1] + k;
            }
        }
    }
    if(cap != 0)++res;



    cout << res << endl;
    return 0;    
}



Measured memory_bytes: 1024
#include<cstdio>

int n;
int prime[1000000];
int cnt[1000000];
int main(void){
	for(int i=2;i<=500000;i++){
		if(prime[i]==0){
			for(int j=i*2;j<=500000;j+=i)prime[j]=1;
		}
	}
	for(int i=2;i<=500000;i++)cnt[i]=cnt[i-1]+(1-prime[i]);
	prime[1]=1;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		printf("%d\n",cnt[n*2]-cnt[n]);
	}
	return 0;
}

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

#define debug_input freopen("stdin.in", "r", stdin)
#define debug_output freopen("stdout.out", "w", stdout)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORALL(i, n) for(int i = 0; i < n; i++)
#define FORD(i, a, b) for(int i = a; i >= b; i--)
#define SORT(a) sort(a.begin(), a.end())
#define REV(a) reverse(a.begin(), a.end())
#define NP(a) next_permutation(a.begin(), a.end())
#define ALL(a) a.begin, a.end()
#define mp make_pair
#define pb push_back
#define endl "\n"
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int a, b, c;
	cin >> a >> b >> c;
	int s = (a + b + c) / 2;
	cout << (int) sqrt(s * (s - a) * (s - b) * (s - c)) << endl;
	return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long ll;

int main(){
	ll a,b,c,d;
	ll q[4]; 
	cin>>a>>b>>c>>d;
	q[0]=a*c;q[1]=a*d;q[2]=b*c;q[3]=b*d;
	sort(q,q+4);
	cout<<q[3];
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main(){
int H, W, A, B; cin >> H >> W >> A >> B;
string S=string(A,'0')+string(W-A,'1'), T=string(A,'1')+string(W-A,'0');  
for(int i=1; i<=H-B; i++){ cout << S << "\n"; }
for(int i=1; i<=B; i++){ cout << T << "\n"; }  
}

Measured memory_bytes: 1280
X,N=map(int,input().split())
p=list(map(int,input().split()))
upper=float("inf")
lower=float("inf")
a=X
b=X
while True:
    if not a in p:
        upper=a
        break
    a+=1
while True:
    if not b in p:
        lower=b
        break
    b-=1
if abs(upper-X)==abs(lower-X):
    print(lower)
elif abs(upper-X)>abs(lower-X):
    print(lower)
else:
    print(upper)

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

int main()
{
    int n,minp, num;
    cin >> n;
    cin >> minp;
    int maxp = -2000000000; // 用足够小的初始值来初始化
    for (int i = 1; i < n;i++)
    {
        cin >> num;
        maxp = max(maxp, num - minp);
        minp = min(minp, num);
    }

    cout << maxp << endl;

    return 0;
}


Measured memory_bytes: 3100
n = gets.to_i
dp = Array.new(n) { Array.new(3, 0) }

n.times do |i|
  a, b, c = gets.chomp.split.map(&:to_i)
  if i == 0
    dp[0] = [a, b, c]
  else
    dp[i][0] = [dp[i - 1][1], dp[i - 1][2]].max + a
    dp[i][1] = [dp[i - 1][2], dp[i - 1][0]].max + b
    dp[i][2] = [dp[i - 1][0], dp[i - 1][1]].max + c
  end
end

puts dp[-1].max

Measured memory_bytes: 9340
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(ll i = (ll)(n)-1;i >= 0;--i)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
#define int ll
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  cioacc();
  int n;
  cin >> n;
  vl a(n);
  REP(i,n){
    int in;
    cin >> in;
    a.at(i) = in -i-1;
  }
  sort(ALL(a));
  int md = a.at((n-1)/2);
  REP(i,n) a.at(i) -= md;
  cout << accumulate(ALL(a),0LL,[](int left,int right){return left+abs(right);}) << endl;
}

Measured memory_bytes: 1792
S = input()
ans = 'AC'
if S[0] != 'A':
    ans = 'WA'
cnt = 0
for i in range(1,len(S)):
    if S[i].isupper():
        if i == 1 or i == len(S)-1 or S[i] != 'C':
            ans = 'WA'
        cnt+=1

if cnt != 1:
    ans = 'WA'
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int ara[100];
int main()
{
    int i,cnt=0;
    char str[4];
    scanf("%s",str);
    for(i=0;i<4;i++){
        ara[str[i]]++;
    }
    for(i=65;i<=90;i++){
        if(ara[i]==2){
            cnt++;
        }
    }
    if(cnt!=2)printf("No\n");
    else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
using namespace std;

string n;
bool flag=false;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n;
	for(int i=0;i<n.size();i++){
		if(n[i]=='9'){
			flag=true;
			break;
		}
	}

	if(flag)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> D(N);
  for(int i=0;i<N;i++) cin >> D.at(i);
  sort(D.begin(),D.end());
  
  int a=D.at(N/2-1),b=D.at(N/2);
  cout << b-a << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

signed main(){
	int K, A, B;
	cin >> K >> A >> B;
	if (A >= B || B - A < 3 || A >= K + 1) {
		cout << K + 1 << endl;
		return 0;
	}
	K -= A - 1;
	int res = A;
	if(K % 2 == 1) {
		res++;
	}
	cout << res + K / 2 * (B - A) << endl;
	return 0;
}


Measured memory_bytes: 256